Thin instances rotation doesn't seem to use the pivot point?

Side note: No tag for thin instances?

Switching from instances to thin instances, and the rotation seems to be from a corner of the mesh, not from the pivot point. When creating normal instances, the rotation seems to work just fine.

How do I set the pivot point when trying to rotate thin instances?

Maybe I’m doing something wrong?

const position = new BABYLON.Vector3(center.y, 0, center.x);
const rotation = this.GetRandomYRotation(); // Vector3 in radians

const rotateQuaternion = BABYLON.Quaternion.FromEulerVector(rotation);
const matrix = BABYLON.Matrix.Compose(BABYLON.Vector3.One(), rotateQuaternion, position);

const thinInstance = prefab.thinInstanceAdd(matrix);
1 Like

Not sure thin instances are relying on Pivot. Adding @Evgeni_Popov to confirm.

No, thin instances are really basic (for performance sake), so a thin instance is really simply a matrix. You can update this matrix, and it’s basically the only thing you can do with a thin instance.

You should compute your matrix taking into account the pivot point and pass this matrix as the thin instance matrix.

Maybe the code used in TransformNode to compute the local matrix when a pivot is in effect can help you:


Gotcha, I have some significant reading to do before hand as I have limited to no knowledge of how a matrix works for transform/rotate…etc

Thank you for the guidance!

1 Like

Actually looks like I can solve this by setting a centered origin in blender first. Centering it on the X & Z axis lets me rotate the thin instances on the Y axis without issue.

Can this origin be modified after import into babylon?

1 Like

You can bake it in like this on lines 260-261 :beers: