Get Updated Object Position

Hi,

I need to get the updated object position, currently I am loading an object in a loop and it gets loaded in a L shape structure (increment in x/y axis with each loading), I want to place another object on top of the loaded object, but the other object gets loaded in a straight line rather than being in L shape, is there any function/method I can use to bind them together.

Thanks in advance.

Each object has its own Cartesian space. If you want a child object to be positioned according to a parent object, just add it to the parent object instead of adding it to the scene.

const parentObject = new Object3D();

parentObject.position.set( 0, 1, 0 );

scene.add( parentObject );

const childObject = new Object3D();

parentObject.add( childObject );

// childObject will be positioned at [ 0, 1, 0 ] in scene space ( aka world space )
1 Like

This seems to be not working in my case, getting this error frequently and positioning is not getting applied same as Parent object, by chance any other example/solution to this problem would be greatful.

three.js:5506 THREE.Object3D.add: object not an instance of THREE.Object3D. undefined

This error means that you are passing something wrong to Object3D.add.

It’s not possible to help you without more information, please demonstrate your issue with a fiddle. Here is a template fiddle to help you : https://jsfiddle.net/u9273yqz/