I've spent quite a bit of time trying to figure out this issue. It seems that the
raycaster.intersectObject( pointCloud );
method does not intersect my 'pointCloud' Object when it only has one vertex in its position array attribute with three elements. Strangely, it works fine when the object has two or more vertices.
The geometry I'm working with is a THREE.BufferGeometry()
, and I am using a custom ShaderMaterial
. The object itself is a THREE.Points
.
this.pointCloud = new THREE.Points( geometry, material0 );
Any ideas on how to resolve this?
↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ Updated version of my question ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
It appears that the issue lies in the calculation of the boundingBox's min
and max
values when dealing with a THREE.Point
that has a Buffer Geometry with just one vertex. In this specific scenario, the boundingBox calculations yield the same values for both min
and max
, resulting in no intersection detection. Even with multiple vertices aligned in a straight line, the boundingBox draws a line rather than a box, leading to the same problem.
Further details:
In the case of raycast intersection failures:
//in my file.js
intersections = raycaster.intersectObject( pc.pointCloud , true);
//line 7734 three.js
intersectObject( object, this, intersects, recursive );
//line 7678 three.js
object.raycast( raycaster, intersects );
//line 16542 three.js
if ( ray.isIntersectionBox( geometry.boundingBox ) === false ) {...
//line 6152 three.js
intersectBox: function ( box, optionalTarget ) {...
Within the intersectBox function:
//line 6188 three.js
if ( ( tmin > tymax ) || ( tymin > tmax ) ) return null;
The evaluation returns null due to the similarities between the x and y positions in the boundedBox, causing ( tmin > tymax)
or (tymin > tmax)
to be true. Changing particle positions to have different coordinates still results in no intersection.
If anyone can suggest a solution based on this information, whether by editing the three.js function or modifying the geometry for a valid boundingBox, it would be greatly appreciated!
Thank you!
Three.js 72