@wendraw/three-bvh-csg
Version:
A fast, flexible, dynamic CSG implementation on top of three-mesh-bvh
166 lines (149 loc) • 6.07 kB
TypeScript
import * as three from 'three';
import { Mesh } from 'three/src/objects/Mesh.js';
import { Matrix4 } from 'three/src/math/Matrix4.js';
import { Vector3 } from 'three/src/math/Vector3.js';
import { BufferGeometry } from 'three/src/core/BufferGeometry.js';
import { Group } from 'three/src/objects/Group';
import { Matrix4 as Matrix4$1 } from 'three/src/math/Matrix4';
import { MeshPhongMaterial } from 'three/src/materials/MeshPhongMaterial.js';
import { BufferGeometry as BufferGeometry$1 } from 'three/src/core/BufferGeometry';
import { MeshPhongMaterial as MeshPhongMaterial$1 } from 'three/src/materials/MeshPhongMaterial';
import { Mesh as Mesh$1 } from 'three/src/objects/Mesh';
import { LineBasicMaterial } from 'three/src/materials/LineBasicMaterial';
import { LineSegments } from 'three/src/objects/LineSegments';
import { InstancedMesh } from 'three/src/objects/InstancedMesh';
declare class Brush extends Mesh<three.BufferGeometry<three.NormalBufferAttributes>, three.Material | three.Material[]> {
constructor(...args: any[]);
isBrush: boolean;
_previousMatrix: Matrix4;
markUpdated(): void;
isDirty(): boolean;
prepareGeometry(): void;
disposeCacheData(): void;
}
declare class TriangleSplitter {
trianglePool: TrianglePool;
triangles: any[];
normal: Vector3;
coplanarTriangleUsed: boolean;
initialize(tri: any): void;
splitByTriangle(triangle: any): void;
splitByPlane(plane: any, clippingTriangle: any): void;
reset(): void;
}
declare class TrianglePool {
_pool: any[];
_index: number;
getTriangle(): any;
clear(): void;
reset(): void;
}
declare class OperationDebugData {
enabled: boolean;
triangleIntersectsA: TriangleIntersectionSets;
triangleIntersectsB: TriangleIntersectionSets;
intersectionEdges: any[];
addIntersectingTriangles(ia: any, triA: any, ib: any, triB: any): void;
addEdge(edge: any): void;
reset(): void;
init(): void;
complete(): void;
}
declare class TriangleIntersectionSets {
data: {};
addTriangleIntersection(ia: any, triA: any, ib: any, triB: any): void;
getTrianglesAsArray(id?: null): any[];
getTriangleIndices(): number[];
getIntersectionIndices(id: any): number[];
getIntersectionsAsArray(id?: null, id2?: null): any[];
reset(): void;
}
declare class Evaluator {
triangleSplitter: TriangleSplitter;
attributeData: any[];
attributes: string[];
useGroups: boolean;
consolidateGroups: boolean;
debug: OperationDebugData;
getGroupRanges(geometry: any): any;
evaluate(a: any, b: any, operations: any, targetBrushes?: Brush): any;
evaluateHierarchy(root: any, target?: Brush): Brush;
reset(): void;
}
declare class Operation extends Brush {
isOperation: boolean;
operation: number;
_cachedGeometry: BufferGeometry<three.NormalBufferAttributes>;
_cachedMaterials: any;
_previousOperation: number | null;
insertBefore(brush: any): void;
insertAfter(brush: any): void;
}
declare class OperationGroup extends Group {
isOperationGroup: boolean;
_previousMatrix: Matrix4$1;
markUpdated(): void;
isDirty(): boolean;
}
declare class HalfEdgeMap {
constructor(geometry?: null);
data: any;
disjointConnections: Map<any, any> | null;
unmatchedDisjointEdges: Map<any, any> | null;
unmatchedEdges: number;
matchedEdges: number;
useDrawRange: boolean;
useAllAttributes: boolean;
matchDisjointEdges: boolean;
degenerateEpsilon: number;
getSiblingTriangleIndex(triIndex: any, edgeIndex: any): number;
getSiblingEdgeIndex(triIndex: any, edgeIndex: any): number;
getDisjointSiblingTriangleIndices(triIndex: any, edgeIndex: any): any;
getDisjointSiblingEdgeIndices(triIndex: any, edgeIndex: any): any;
isFullyConnected(): boolean;
updateFrom(geometry: any): void;
}
declare class GridMaterial extends MeshPhongMaterial {
constructor(...args: any[]);
set enableGrid(arg: boolean);
get enableGrid(): boolean;
_enableGrid: any;
onBeforeCompile(shader: any): void;
}
declare const ADDITION: 0;
declare const SUBTRACTION: 1;
declare const REVERSE_SUBTRACTION: 2;
declare const INTERSECTION: 3;
declare const DIFFERENCE: 4;
declare const HOLLOW_SUBTRACTION: 5;
declare const HOLLOW_INTERSECTION: 6;
declare function getTriangleDefinitions(...triangles: any[]): string[];
declare function logTriangleDefinitions(...triangles: any[]): void;
declare function generateRandomTriangleColors(geometry: any): void;
declare class TriangleSetHelper extends Group {
constructor(triangles?: any[]);
get color(): three.Color;
set side(arg: three.Side);
get side(): three.Side;
_mesh: Mesh$1<BufferGeometry$1<three.NormalBufferAttributes>, MeshPhongMaterial$1>;
_lines: LineSegments<BufferGeometry$1<three.NormalBufferAttributes>, LineBasicMaterial>;
setTriangles(triangles: any): void;
}
declare class EdgesHelper extends LineSegments<three.BufferGeometry<three.NormalBufferAttributes>, three.Material | three.Material[]> {
constructor(edges?: any[]);
get color(): any;
setEdges(edges: any): void;
}
declare class PointsHelper extends InstancedMesh<three.BufferGeometry<three.NormalBufferAttributes>, three.Material | three.Material[]> {
constructor(count?: number, points?: any[]);
get color(): any;
setPoints(points: any): void;
}
declare class HalfEdgeHelper extends EdgesHelper {
constructor(geometry?: null, halfEdges?: null);
straightEdges: boolean;
displayDisconnectedEdges: boolean;
setHalfEdges(geometry: any, halfEdges: any): void;
}
declare function computeMeshVolume(mesh: any): number;
export { ADDITION, Brush, DIFFERENCE, EdgesHelper, Evaluator, GridMaterial, HOLLOW_INTERSECTION, HOLLOW_SUBTRACTION, HalfEdgeHelper, HalfEdgeMap, INTERSECTION, Operation, OperationGroup, PointsHelper, REVERSE_SUBTRACTION, SUBTRACTION, TriangleSetHelper, TriangleSplitter, computeMeshVolume, generateRandomTriangleColors, getTriangleDefinitions, logTriangleDefinitions };