I have a flat surface which I have exploded and tessellated into triangles. I want to get the position of every single face to apply an animation, but apparently I am not able to do that.
if (intersects.length > 0) {
// if the closest object intersected is not the currently stored intersection object
if (intersects[0].object != INTERSECTED) {
if (INTERSECTED) {
INTERSECTED.face.color.setHex(INTERSECTED.currentHex);
}
INTERSECTED = intersects[0];
INTERSECTED.currentHex = INTERSECTED.face.color.getHex();
INTERSECTED.face.color.setHex(0xc0392b);
INTERSECTED.object.geometry.colorsNeedUpdate = true;
var position = new THREE.Vector3();
position.setFromMatrixPosition( INTERSECTED.matrixWorld );
alert(position.x + ',' + position.y + ',' + position.z);
}
}
I tried to use INTERSECTED.face.matrixWorld.getPosition()
, as specified in this example, but it's throwing an error. Here you can find a JSFiddle with the full code. Do you know what's the issue with my code?
Thank in advance for your replies!