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