Hi all!
HeEeEEeEeeeEelp!!!
I’ve been struggling to move each of my instanced in my instancedMesh in different positions,
as the docs claims I can do?
(Use InstancedMesh if you have to render a large number of objects with the same geometry and material but with different world transformations.)
How the hell do I read and write those world transformations?
(and I do no mean InstancedBufferGeometry, but instancedMesh)
All I was able to do is rotate all of them at one to match a lookat, on creation, all instances in the instancedMesh move to the same position, and it does the same when I try to animate them…
I’m trying to avoid using
excerpts from my code follow.
//create instances group
instancedStars = new THREE.InstancedMesh( starRefGeo,starRefMat, 100, true);
for ( var i ; i < 100 ; i ++ ) {
x = Math.floor(Math.random()*10+1);
y = Math.floor(Math.random()*10+1);
z = Math.floor(Math.random()*10+1);
instancedStars.setPositionAt(i , position3vector.set(x ,y, z));
}
scene.add( instancedStars );
// where they ALLmove to the same randomized position (see at the bottom)????
function animateThings() {
instanceLookAt.lookAt(camera.position);
// rotate all instancedStars as lookAt
var rotationAsQuaternion = new THREE.Vector4();
var x = instanceLookAt.quaternion.x;
var y = instanceLookAt.quaternion.y;
var z = instanceLookAt.quaternion.z;
var w = instanceLookAt.quaternion.w;
rotationAsQuaternion.set( x, y, z, w ).normalize();
instancedStars.quaternion.copy( rotationAsQuaternion );
for ( var i = 0; i < instancedStars.count; i++ ) {
x = Math.floor(Math.random()*10+1);
y = Math.floor(Math.random()*10+1);
z = Math.floor(Math.random()*10+1);
_position.set( x, y, z );
instancedStars.position.copy( _position );
}
}
I just spent a whole night retrying TONS of examples - this is driving me crazy!!!
oh, and I’m using R113
Thanks for any help you can offer!