raycast method

SceneRaycastHit? raycast(
  1. Ray ray, {
  2. double maxDistance = double.infinity,
  3. int layerMask = 0xFFFFFFFF,
  4. bool where(
    1. Node node
    )?,
  5. bool includeInvisible = false,
})

Casts ray through the scene's render geometry and returns the nearest hit, or null.

Tests the meshes as rendered (no colliders or physics setup), with the hit's texture coordinate interpolated from the vertex data. Invisible subtrees are skipped unless includeInvisible is set; nodes must intersect layerMask (against Node.layers), have Node.raycastable set, and pass where when provided. Distinct from the physics queries (PhysicsWorld.raycast), which test collision shapes.

Implementation

SceneRaycastHit? raycast(
  Ray ray, {
  double maxDistance = double.infinity,
  int layerMask = 0xFFFFFFFF,
  bool Function(Node node)? where,
  bool includeInvisible = false,
}) => raycastNode(
  root,
  ray,
  maxDistance: maxDistance,
  layerMask: layerMask,
  where: where,
  includeInvisible: includeInvisible,
);