jakke-graphics-ts
    Preparing search index...

    Class BVHTriangle

    Index

    Constructors

    • Creates a new BVHTriangle instance from three vertices.

      Each vertex is wrapped in a BVHVertex. The constructor checks for duplicate vertices by comparing their hashes. If all three vertices are identical, an error is thrown.

      Parameters

      • v1: Vertex3d

        The first vertex of the triangle.

      • v2: Vertex3d

        The second vertex of the triangle.

      • v3: Vertex3d

        The third vertex of the triangle.

      Returns BVHTriangle

      If all three vertices are identical.

    Properties

    v1: BVHVertex

    The first vertex of the bounding volume hierarchy (BVH) node. This vertex is used to define the geometry or bounds associated with the node.

    v2: BVHVertex

    The second vertex associated with this BVH node. Used to define the geometry or bounds within the BVH structure.

    v3: BVHVertex

    The third vertex of the BVH structure.

    Methods

    • Calculates and returns the centroid of the triangle defined by vertices v1, v2, and v3.

      The centroid is computed as the average of the x, y, and z coordinates of the three vertices.

      Returns Vertex3d

      The centroid of the triangle as a Vertex3d object.

    • Generates a unique hash string for the current object by concatenating the hash values of its three vertices (v1, v2, and v3).

      Returns string

      A string representing the combined hash of the three vertices.

    • Calculates the intersection point of a line segment (defined by pt1 and pt2) with the plane of the triangle defined by the instance vertices (v1, v2, v3). Returns the intersection point as a BVHVertex if it lies within the triangle, otherwise returns undefined.

      Parameters

      • pt1: Vertex3d

        The starting vertex of the line segment.

      • pt2: Vertex3d

        The ending vertex of the line segment.

      Returns undefined | BVHVertex

      The intersection point as a BVHVertex if it is inside the triangle, or undefined otherwise.