Recalculate position of point after transform (without using bake)

Hello all,

I’m having an issue calculating the angle between two lines after I reposition a point.

Initially, this works fine, I have 4 points in total (represented by spheres), 2 points to make each line and then I calculate the angle between them.

If I move one of the points, the position property of the sphere doesnt change unless I “bake” the transformations in.

However, I don’t want to bake the transformation because this is causing some undesired side-effects with the rest of my scene.

I’m relatively new to BabylonJS, so I’m hoping there is some functionality to tell me what the position is after I translate or rotate the mesh without doing the bake.

Thanks in advance for any help,
Jeff

Welcome aboard!

A repro in the Playground (https://playground.babylonjs.com/) would help people helping you.

If I understand what you need, you will be able to get the world coordinate of a point (sphere) by using the world matrix transformation of this sphere and getting the translation part of it:

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

Sorry for the delay, I finally had a chance to create a playground for my issue here:
https://playground.babylonjs.com/#LUS3WR#1

If you run the playground and click on the sphere, it will add a new (smaller) sphere as a child of that sphere and translate the parent sphere up 2.

When I print the position of the sphere, post-translate, the position has changed, however the position of the child has not changed.

I need to get the position of the child that i added to the parent in “world space” I think.

Here is the console output of the playground:
sphere position before move e {_isDirty: false, _x: 0, _y: 1, _z: 0}
point position before move e {_isDirty: true, _x: 0.9752039909362793, _y: 0.053142547607421875, _z: -0.2060617208480835}
sphere position after move e {_isDirty: true, _x: 0, _y: 3, _z: 0}
point position after move e {_isDirty: true, _x: 0.9752039909362793, _y: 0.053142547607421875, _z: -0.2060617208480835}

Thanks in advance,
Jeff

I may have figured out the answer.

If I take the point and run
point.computeWorldMatrix(true)

and then call
point.getAbsolutePosition()

I believe I get the position that I am looking for. Does that sound right?

It does!

Great! Thanks for the confirmation.