raycast method
Get intersections between a casted ray and this mesh. Raycaster.intersectObject will call this method, but the results are not ordered.
Implementation
@override
void raycast(Raycaster raycaster, List<Intersection> intersects) {
final matrixWorld = this.matrixWorld;
final raycastTimes = count;
_mesh.geometry = geometry;
_mesh.material = material;
if (_mesh.material == null) return;
for (int instanceId = 0; instanceId < raycastTimes!; instanceId++) {
// calculate the world matrix for each instance
getMatrixAt(instanceId, _instanceLocalMatrix);
_instanceWorldMatrix.multiply2(matrixWorld, _instanceLocalMatrix);
// the mesh represents this single instance
_mesh.matrixWorld = _instanceWorldMatrix;
_mesh.raycast(raycaster, _instanceIntersects);
// process the result of raycast
for (int i = 0, l = _instanceIntersects.length; i < l; i++) {
final intersect = _instanceIntersects[i];
intersect.instanceId = instanceId;
intersect.object = this;
intersects.add(intersect);
}
_instanceIntersects.length = 0;
}
}