Setting two objects to same X,Y,Z location, but they're in different places

Anyone know the answer to this conundrum?
https://www.babylonjs-playground.com/#1JLGFP#119

I set one object to the X,Y,Z of the other, but it gets drawn in a different location. Could it have to do with one being a line and one being a mesh?


My guess is that one of the objects is telling you it’s relative position.
Try object.getAbsolutePosition();

1 Like

That’s not it unfortunately:
https://www.babylonjs-playground.com/#1JLGFP#120

.

Oh! I know! The models have different root locations!

Take this example:
https://playground.babylonjs.com/#UY7PQD

One cube is a 1x1x1 made with Babylon.js, while the other is imported and was made with sketchup. They are the same size, and same location, but one looks off. That one was made with sketchup. This is because models made with sketchup have a corner be the origin. This is how the cube looks when making it:


Notice how the origin is one of it’s corners? Thats the corner that is at the center of the other cube.

So the one object that is higher than the other has an origin that isn’t centered on it.

2 Likes

That’s a great theory. Playing with it now… Thx.

1 Like

No problem! :slight_smile:

I think that was it.
It’s fixed here:
https://www.babylonjs-playground.com/#1JLGFP#127

I think what was happening was that the axisLine was being created using mesh.add, which changed the origin point - by a factor of whatever the origin point was set to. So, setting the origin point to 0,0 resolved the issue.

1 Like

Nice! :+1: