Was looking for quite a while for the right way to apply scaling to a geometry. On the stackoverflow was written, that instead of changing geometry of the mesh directly, it’s better to apply a matrix. What I’m doing (as i understood it correctly), i should translate Mesh to the origin first, scale in a certain amount, then move her back. I’ve take next approach
let transform_m = new Matrix4(this.mesh.matrixWorld);
let height = this.mesh.geometry.parameters.height;
//SCALES IN -y direction
transform_m.makeTranslation(0, -height / 2, 0);
this.mesh.applyMatrix4(transform_m);
transform_m.makeScale(1, 4, 1);
this.mesh.applyMatrix4(transform_m);
transform_m.makeTranslation(0, height / 2, 0);
this.mesh.applyMatrix4(transform_m);
I don’t know whether it’s efficient to apply matrix on every call. Also i don’t understand, why i can’t
chain calls one after another, and applyMatrix at the end once :
transform_m.makeTranslation(0, -height / 2, 0);
transform_m.makeScale(1, 4, 1);
transform_m.makeTranslation(0, height / 2, 0);
this.mesh.applyMatrix4(transform_m);
My knowledge is chunked, but isn’t it correct, that if I’m having a vector, i can apply one matrix after another to it, and get the same result, as if I’ve composed matrices, and then multiplied the vector by the resulting matrix?