Hi there, I wonder how threejs raycast is returning the face intersect on raycast intersect objects. However, when diving into the git repo, I came up with the surprise that the code source for that method is not posted in github:
Is there anywhere I can see the original source code. By the way, I’m working on a code to get faces from a mesh.
Yup. It does look weird But I think its just a hack.
The bufferGeometry type has accessors for values out of them…
but it doesn’t have an accessor for getting just a single value out…
And an index buffer is just an array of 3 indices per triangle…
with a stride of 1 i guess…
so using .getX like that is equivalent to saying
a=index.array[j]
b=index.array[j+1]
c=index.array[j+2]
It’s ugly but I guess it works… and if that accessor is in the hot code path, it saves a few bytes of js code and might be faster than spelling out the logic… i dunno.
i.e. so as to your question… it’s not using vertices. it’s grabbing vertex indices from the index buffer.
Hi @manthrax
sorry to bother you again
Do you mind taking a look a this other post. It’s related to this issue and it has info about what I was trying to achieve. Unfortunately, I’m blocked.