Get the position of child mesh after load

I’m trying to recreate this adding video texture in a gltf model that I have.

I want to put the position of the plane and the video texture on the position of a child mesh (example a door of a house). But when I check for the position of the mesh I wanted to replace, its returning vector (0,0,0). I want to know if there is a w
ay to get the vector of the child mesh in respect of the scene and not what is loaded to.

If this isn’t possible, is there a way to create a mesh with the same position of the child mesh on load? (I tried creating a mesh but since the vector is still (0,0,0) its not on the child mesh’s position)

every mesh has a position in local coordinates and globalPosition which is in world space coordinate (and many times they are the same).

try mesh.getAbsolutePosition()

I tried to use that
mesh.getAbsolutePosition()
it didnt returned 0 and I used it. however it didn’t properly aligned. Would you know any other way to get it?

I also seen an approach where you can put the child mesh as a parent to hopefully put the plane on the mesh but it didn’t work as well.

Would be great to see an example or a playground that doesn’t work so we can understand what the problem is. the absolute position must be the right position of the mesh position (as defined by the model you are loading).

https://playground.babylonjs.com/#CHQ4T#120

might be the wrong thread?

Let me see if I can replicate in a simple model. Just to update as well I tried mesh.getBoundingInfo().boundingBox.centerWorld; and this worked for me though I need to get the local rotation next. Do you know where might I get that?.

this is the center of your model’s bounding box. if that makes sense to your model, that’s great that you found it :slight_smile:
There is no way to find the internal rotation of your model, unless it is defined in one of the parts of the model itself. If it is, try finding this specific node of your model and read its transformation

For the benefit of others, I just spent 2 hours banging against position being (0,0,0)… it turned out the the high fideliety collision detector I’m using calls bakeCurrentTransformIntoVertices();

doh. The boundingBox.centerWorld is working nicely, and I’m just going to track rotations as I implement them

2 Likes