I have transformed a flat surface into triangles and now I am trying to retrieve the position of each face for animation purposes. However, I seem to be facing some challenges in achieving this.
if (intersects.length > 0) {
// Check if the closest intersected object is not the same as the previously selected one
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 attempted to use
INTERSECTED.face.matrixWorld.getPosition()
, following guidance from this example, but encountered an error. You can find the complete code in this JSFiddle. Any insights on what might be causing the issue?
Thank you in advance for your assistance!