Scale objects along an axis

I want to scale the object using the axis I created. What should I do?
The following is what I did.But there was no result

var axis = new THREE.Vector3(1, 2, 1);
var scalar = 2;
var matrix = new THREE.Matrix4().makeScale(axis.x * scalar, axis.y * scalar, axis.z * scalar).makeRotationFromQuaternion(cube.quaternion);

One way to do it, is to rotate the mesh geometry first, so that your custom axis matches one of the world axes, then you can scale the mesh along that matched world axis.

This is a permanent change if the cube’s shape, in the example below I chose Z-axis:

const custom_axis = new THREE.Vector3(1, 2, 1).normalize();
// rotate to match the world's Z-axis
const quat = new THREE.Quaternion()
.setFromUnitVectors(custom_axis, new THREE.Vector3(0, 0, 1));

cube.scale.set(1, 1, 2); // scale on the world Z-axis

renderer.render(scene, camera);

Essentially, in cases like yours, you need to have two coordinate systems (CS), rotated relative to each other, one being a local CS and the other - the World CS.

Okay, got it. Thank you very much :slight_smile: