-
-
Notifications
You must be signed in to change notification settings - Fork 36.1k
Closed
Description
Description
The intersectsSphere(sphere) of Ray is not correct for empty Spheres:
intersectsSphere( sphere ) {
return this.distanceSqToPoint( sphere.center ) <= ( sphere.radius * sphere.radius );
}Spheres use radius=-1 to indicate "empty", which is not correctly considered when squaring it here.
This breaks raycasting when testing objects with empty geometries (in some conditions, like when the ray passes close to the origin/Sphere's center)
Reproduction steps
- Raycast an empty object (with uninitialized
BufferGeometry), for exampleLine
Code
scene = new THREE.Scene();
scene.add(new THREE.Line()) // Empty geometry in Line
const raycaster = new THREE.Raycaster() // Default ray traverses the origin -> distance to empty Sphere-center will be 0 < (-1*-1)
raycaster.intersectObject(scene) // Throws an error (intersectsSphere() doesn't exclude properly)Live example
Screenshots
No response
Version
r176
Device
No response
Browser
No response
OS
No response