with createInstance
I was able to successfully rotate instance like:
var railingRight = _addInstance(railing, 'railingRight' + i, -80, 0, 20);
railingRight.rotate(BABYLON.Axis.Y, 1.57, BABYLON.Space.WORLD);
var _addInstance = function (m, n, x, y, z) {
var i = m.createInstance(n);
i.position.x = x || 0;
i.position.y = y || 0;
i.position.z = z || 0;
return i;
}
how to rotate single box when using thinInstanceSetBuffer
https://www.babylonjs-playground.com/#2SHIQQ#1
You have to create a new (or update an existing) matrix and update the buffer:
https://www.babylonjs-playground.com/#2SHIQQ#2
2 Likes
Thank @Evgeni_Popov , so if I understood correctly
BABYLON.Matrix.Compose(scale, rot, trans).copyToArray(bufferMatrices, 0);
that copyToArray
is updating an existing array indexes and also creating, so for example in this snippet https://www.babylonjs-playground.com/#2SHIQQ#4
I removed matrix1 and just used Matrix.Compose
to create buffer, this way I am not calling multiple times,
or this way too:
https://www.babylonjs-playground.com/#2SHIQQ#5
is that correct?
Yes it is.
A thin instance is simply a matrix that let you position your instance wherever you want.
1 Like
Thank you for confirmation, such a wonderful community , happy to be here.