UNPKG

jakke-graphics-ts

Version:

My common graphics utils for building my aec apps.

147 lines 4.22 kB
import { Vertex3d } from "./types/basicGeometries"; import { ActionResult } from "./types/errorMessages"; /** * BVHTree for fast traverse of triangles. */ export declare class BVHTree { /** * Triangles included. */ readonly triangles: BVHTriangle[]; /** * Triangle hashes included in BVHTree. */ readonly triangleHashes: Set<string>; private leftChild?; private rightChild?; private parent?; private _boundingBox; /** * Get bounding box of this BVHTree. */ get boundingBox(): BVHBoundingBox; /** * Add triangle at this three. * @param triangle * @returns Result of adding triangle action. */ addTriangle(triangle: BVHTriangle): ActionResult; /** * Build BVHTree's structure. * @returns */ calculateTree(): BVHTree; /** * Internal method for calculating the tree structure. * @param triangles * @returns */ private buildBVHTree; /** * Internal method for sorting triangles. * @returns */ private getSortedTriangles; /** * Get all nodes included in this tree. * @returns */ getAllNodes(): BVHTree[]; /** * Get all node's bounding box. * @returns */ getAllBoundingBoxes(): BVHBoundingBox[]; /** * Internal method for traverse tree for collecting all nodes. * @param nodes */ private traverseTree; /** * Get root node of this tree. * @returns */ getRoot(): BVHTree; /** * Get the intersection point between the given line and tree. * This uses Möller Trumbore's soluion for determine the collision. * Currently, it returns only the first collision point. * @param p1 The start point of line. * @param p2 The end point of line. * @param onlyOnLine Parameter for testing the getting collision point. * When this set true, it returns the collision point including outbound of the line. * @returns Intersection point when only the intersection exists. */ getRayCollision(p1: Vertex3d, p2: Vertex3d, onlyOnLine: boolean): Vertex3d | undefined; /** * Internal method for determine the collision between line and bounding box. * @param p1 The start point of line. * @param p2 The end point of line. * @returns */ private isRayCollideAABB; /** * Internal method of testing the collision between line and AABB. * @param p1 The start point of line. * @param p2 The end point of line. * @param axis x, y, z can be set. * @param value * @param ptMin The minimum point of bounding box. * @param ptMax The maximum point of bounding box. * @returns */ private raycastOnPlane; /** * * @param pt * @param min * @param max * @returns */ private isPointInside; } export declare class BVHTriangle { readonly v1: BVHVertex; readonly v2: BVHVertex; readonly v3: BVHVertex; constructor(v1: Vertex3d, v2: Vertex3d, v3: Vertex3d); getCentroid(): Vertex3d; getHash(): string; clone(): BVHTriangle; private isDetZero; getPointOnTrianglePlane(pt1: Vertex3d, pt2: Vertex3d): BVHVertex | undefined; } export declare class BVHBoundingBox { private _min; private _max; private vertexHashes; private _initialized; private constructor(); static create(): BVHBoundingBox; get min(): BVHVertex; get max(): BVHVertex; get isEmpty(): boolean; addVertex(v: BVHVertex): ActionResult; getCentroid(): BVHVertex | undefined; getDiagonal(): BVHVertex | undefined; } declare class BVHVertex { readonly x: number; readonly y: number; readonly z: number; private static readonly PRECISION; constructor(v: Vertex3d); getHash(): string; add(v: BVHVertex): BVHVertex; subtract(v: BVHVertex): BVHVertex; dot(v: BVHVertex): number; cross(v: BVHVertex): BVHVertex; normalized(): BVHVertex; getLength(): number; multiply(t: number): BVHVertex; toObject(): Vertex3d; equals(v: BVHVertex): boolean; clone(): BVHVertex; } export {}; //# sourceMappingURL=bvhTree.d.ts.map