0
votes

Made a buffered plane, set its vertices with:

var vertices = tg.attributes.position.array;
geometry.addAttribute('position', new THREE.BufferAttribute(vertices, 3));

Now i want to raycast to a face to get it's Z value:

var z = intersects[i].object.geometry.vertices[intersects[i].face.a].z;

This worked on a standard geometry as it had faces and lot of other things i'm trying to save from memory.

My question comes from the index: intersects[i].face.a. What do i have to add? There seem not to be a method to add "faces" to the buffered geometry. Right now there is just one face for the whole geometry at:

object.face.(a,b,c)

Perhaps there is another way of clicking on a face and getting it's vertex value when using buffered geoms.

Tips? Thanks!

1

1 Answers

1
votes

Buffer geometries contain attributes of positions in an array.

If you want to obtain information about z-value of a specific vertex from a buffer geometry's vertices then you can do it like this:

intersects[i].object.geometry.attributes.position.array[intersects[i].face.a * 3 + 2]

also you can use the z-coordinate of the point of intersection (which is in world's coordinates):

intersects[i].point.z;

jsfiddle example (see function showDetails(intersect), the green plane is THREE.PlaneGeometry, the blue plane is THREE.PlaneBufferGeometry)