const meshPoints = mesh.geometry.attributes.position.array;
const meshNormals = mesh.geometry.attributes.normal.array;
const scale = 0.2;
for(let i =0;i<meshPoints.length/3; i++){
const dx = light.position.x - meshPoints[i*3];
const dy = light.position.y - meshPoints[i*3+1];
const dz = light.position.z - meshPoints[i*3+2];
const dist = dx*dx + dy*dy + dz*dz;
meshPoints[i*3] += meshNormals[i*3] * scale/dist;
meshPoints[i*3+1] += meshNormals[i*3+1] * scale/dist;
meshPoints[i*3+2] += meshNormals[i*3+2] * scale/dist;
// console.log(meshPoints[i*3]);
}
mesh.geometry.attributes.position.needsUpdate = true;
})```
#Trying to modify a geometry by changing its vertices position
4 messages · Page 1 of 1 (latest)
mesh is the geometry I'm trying to modify here; and light is the point of intersection between the geometry and the ray
Because you can't have multiple normals for one vertex, BoxGeometry has a separate 'instance' of each vertex for each face it belongs to; so for instance, there are three distinct vertices (0, 0, 0), one for each of the faces that meet there.
thank you for the reply, see so probably i have to use something like a sphere or icosahedron