Matrix creation question

Hi

I need to move all my elements in the scene according to a matrix.

I get this transform matrix from the plane that I position and move and then when it’s ok I call:

plane.getWorldMatrix();

I would like to create that matrix without the need of creating a plane cause it’s actually not working always.

But the problem starts that I use “setPivotPoint”:

plane.position.x = -100;
plane.position.z = 100;
plane.setPivotPoint(new Vector3(50, 0, -50));
plane.rotation.y = -Math.PI;

var matrix = plane.getWorldMatrix();

I cant create a matrix that will produce movement of the pivot point.

I got the rotation but in different locations of the pivot point and it’s not the same.

How can I create that matrix knowing all values that I need to move the plane? But with a Matrix code?

I prepared PG:

https://playground.babylonjs.com/#WYT262

And I want to make the console log from line 38 to be the same as from line 33 but with the code only.

Regards
Peter

See https://playground.babylonjs.com/#WYT262#1

I have implemented the same local matrix computation than the one we can find in TransformNode.computeWorldMatrix when a pivot is set.

Hi

That’s great. But how to do it without the plane entirely.

I do not want to have the plane completely. I do not need it and setTimeout is needed to have it properly. That’s why I would like to create it by code.

I would like to have something like;

var matrix = new Matrix();

[...] // here all the code to have the good matrix. NO PLANE AT ALL.

Regards
Peter

Well, just replace in the formula plane.scaling.x, plane.scaling.y, plane.scaling.z, plane.position.x, plane.position.y, plane.position.z by the values you want:

https://playground.babylonjs.com/#WYT262#2

Can you use Matrix | Babylon.js Documentation ?