raycast method
Get intersections between a casted ray and this Points. Raycaster.intersectObject will call this method.
Implementation
@override
void raycast(Raycaster raycaster, List<Intersection> intersects) {
final geometry = this.geometry!;
final matrixWorld = this.matrixWorld;
final threshold = raycaster.params["Points"]['threshold'];
final drawRange = geometry.drawRange;
// Checking boundingSphere distance to ray
if (geometry.boundingSphere == null) geometry.computeBoundingSphere();
_pointssphere.setFrom(geometry.boundingSphere!);
_pointssphere.applyMatrix4(matrixWorld);
_pointssphere.radius += threshold;
if (raycaster.ray.intersectsSphere(_pointssphere) == false) return;
//
_pointsinverseMatrix..setFrom(matrixWorld)..invert();
_pointsray..copyFrom(raycaster.ray)..applyMatrix4(_pointsinverseMatrix);
final localThreshold = threshold / ((scale.x + scale.y + scale.z) / 3);
final localThresholdSq = localThreshold * localThreshold;
final index = geometry.index;
final attributes = geometry.attributes;
final positionAttribute = attributes["position"];
if (index != null) {
final start = math.max(0, drawRange["start"]!);
final end =
math.min(index.count, (drawRange["start"]! + drawRange["count"]!));
for (int i = start, il = end; i < il; i++) {
final a = index.getX(i)!.toInt();
_position.fromBuffer(positionAttribute, a.toInt());
testPoint(_position, a, localThresholdSq, matrixWorld, raycaster,
intersects, this);
}
} else {
final start = math.max(0, drawRange["start"]!);
final end = math.min<int>(
positionAttribute.count, (drawRange["start"]! + drawRange["count"]!));
for (int i = start, l = end; i < l; i++) {
_position.fromBuffer(positionAttribute, i);
testPoint(_position, i, localThresholdSq, matrixWorld, raycaster,
intersects, this);
}
}
}