ReadonlyboundingSquared radius of a sphere around the node's local origin that encloses the volume
A ray that misses this sphere skips raycast. It's read on every
pick, so it can change with the shape. Infinity suits an unbounded shape, at the cost of a
raycast call on every pick.
OptionalcontainsWhether a point in the node's local space is inside the volume
Only needed for the volume to clip the node's descendants, as every hitVolume you set does.
Without it, the volume still picks but never clips.
The point to test, in the node's local space.
Whether the point lies inside the volume.
Finds where localRay first hits the volume
localRay.direction is unit length, so t is the distance to the hit in the node's local
units. Hits on nodes of different scale still compare correctly: the picker measures world
distance from out.point.
On a hit, fill out as the engine shapes do: out.point with localRay.at(t, out.point),
out.distance with t, and, unless the volume has triangles, out.normal and out.uv with
zeros and out.triangleIndex with -1. On a miss, return -1; the picker ignores out.
The pick ray in the node's local space, unit-length direction.
Scratch buffer to fill on a hit.
The parametric t of the closest hit (>= 0), or -1 for a miss.
A hit shape of your own for Container3D#hitVolume, like
IHitAreain 2DAny object with these members works, with no base class: an adapter around a physics collider, an analytic capsule, a signed distance field.
Box,SphereandGeometry3Dwork as they are, with faster built-in tests, so don't wrap them.Everything is in the node's local space, so the volume never deals with transforms.
Example
See