
Hello everyone, I am developing a project in Three.jswhere the user can hovertessellate the face, and each set should be dropped whenever it crosses the invisible sphere, and return to its original position when its outer is from its area. I use this and this example as a reference, but I am stuck since I don’t know how to make it work in Three.js.
In my code I can make hoverevery facet of the grid red and restore the original color after the mouse disappeared. But I can not do something like this with this position. This is the part of the code where I think the problem is:
if (intersects.length > 0) {
if (intersects[0].object != INTERSECTED) {
if (INTERSECTED) {
INTERSECTED.face.color.setHex(INTERSECTED.currentHex);
}
INTERSECTED = intersects[0];
var intGeometry = INTERSECTED.object.geometry;
var intFace = INTERSECTED.face;
INTERSECTED.currentHex = intFace.color.getHex();
intFace.color.setHex(0xc0392b);
intGeometry.colorsNeedUpdate = true;
var intVertices = intGeometry.vertices;
var v1 = intVertices[intFace.a],
v2 = intVertices[intFace.a],
v3 = intVertices[intFace.a];
var intPosition = new THREE.Vector3();
intPosition.x = (v1.x + v2.x + v3.x) / 3;
intPosition.y = (v1.y + v2.y + v3.y) / 3;
intPosition.z = (v1.z + v2.z + v3.z) / 3;
console.log(intPosition);
}
}
console.log() , , , . JSFiddle .