Change parent position based on child object's geometry

Hello,

I have a 3D object and a cube mesh, added mesh as a child to 3D object. Now I want to change position of 3D object inside mesh so that I can control pivot points of the cube mesh. Here is the codepen https://codepen.io/abnormalcoder/pen/bGGzWVW

Thanks in advance.

any help from anywhere?

Sorry, but I’m afraid your question is unclear. Changing the pivot point in three.js is already explained here:

Thanks for the reply. I’m using the second option provided in your link, took a 3D object and added cube mesh to it. And I want to move 3D object position inside cube mesh. Whenever I update3D object position it gets updated in scene along with cube mesh. I want cube mesh to stay stable while I change 3D object position inside cube mesh. I hope this is clear now.

Thanks again.

Okay, instead of adding the mesh to the instance of 3DObject, try it with Object3D.attach(). In your particular case:

mesh.attach(mesh1);

Sorry, I can’t fork your codepen since an account is required (which is actually stupid).

BTW: You really should not name a variable mesh if it’s not of type Mesh.

1 Like