Options
All
  • Public
  • Public/Protected
  • All
Menu

Class BVHTree

BVH树

Hierarchy

  • BVHTree

Index

Constructors

constructor

  • new BVHTree(triangles: Vector3[][], maxTrianglesPerNode: number): BVHTree
  • 创建BVH树对象

    Parameters

    • triangles: Vector3[][]

      三角形数组,BVH树基于此构建

    • maxTrianglesPerNode: number

      每个树结点包含的最多三角形数量

    Returns BVHTree

Methods

intersectRay

  • intersectRay(rayOrigin: Vector3, rayDirection: Vector3, backfaceCulling?: undefined | false | true): IntersectResult[]
  • Returns a list of all the triangles in the BVH which interected a specific node. We use the BVH node structure to first cull out nodes which do not intereset the ray. For rays that did intersect, we test intersection of the ray with each triangle

    Parameters

    • rayOrigin: Vector3

      the origin position of the ray.

    • rayDirection: Vector3

      the direction vector of the ray.

    • Optional backfaceCulling: undefined | false | true

      if 'true', only intersections with front-faces of the mesh will be performed.

    Returns IntersectResult[]

    []} IntersectionResult an array of intersection result, one for each triangle which intersected the BVH, each item in the form of: { triangle: Vector3[]; triangleIndex: number; intersectionPoint: Vector3; }

nearestIntersection

  • nearestIntersection(rayOrigin: Vector3, rayDirection: Vector3, backfaceCulling?: undefined | false | true): IntersectResult | null
  • 获得与指定射线方向相交的最接近射线起点的相交结果

    Parameters

    • rayOrigin: Vector3

      射线起点

    • rayDirection: Vector3

      射线方向

    • Optional backfaceCulling: undefined | false | true

      可选,是否忽略背面

    Returns IntersectResult | null