React Three Map - v1.0.9
    Preparing search index...
    • Tests whether a 3D point is inside a closed polyhedron using ray casting.

      This implements the ray casting algorithm: cast a ray from the point in an arbitrary direction and count how many times it intersects the surface. If the count is odd, the point is inside; if even, it's outside.

      Parameters

      • point: Vector3Tuple

        The 3D point to test as a Vector3Tuple [x, y, z]

      • geometry: BufferGeometry

        The BufferGeometry representing the closed polyhedron

      Returns PointInPolyhedronResult

      A PointInPolyhedronResult with the test result

      The geometry must represent a closed (watertight) surface for accurate results. Open surfaces or surfaces with holes may produce incorrect results.

      Error if BufferGeometry has no position attribute

      import { isPointInPolyhedron } from '@wendylabsinc/react-three-map/maplibre';
      import { BoxGeometry } from 'three';

      const box = new BoxGeometry(100, 100, 100);
      const pointInside: Vector3Tuple = [10, 10, 10];
      const pointOutside: Vector3Tuple = [200, 200, 200];

      isPointInPolyhedron(pointInside, box).inside; // true
      isPointInPolyhedron(pointOutside, box).inside; // false