import { BufferGeometry, Geometry, Matrix4, Mesh, Vector2, Vector3 } from '../../refs.node'; /** * Holds a binary space partition tree representing a 3D solid. Two solids can * be combined using the `union()`, `subtract()`, and `intersect()` methods. * * Copyright (c) 2011 Evan Wallace (http://madebyevan.com/), under the MIT license. * THREE.js rework by thrax * Typescript port by freezy * * @see https://github.com/manthrax/THREE-CSGMesh */ export default class ThreeCsg { private polygons; private static _tmpm3; clone(): ThreeCsg; /** * Return a new CSG solid representing space in either this solid or in the * solid `csg`. Neither this solid nor the solid `csg` are modified. * * ``` * A.union(B) * * +-------+ +-------+ * | | | | * | A | | | * | +--+----+ = | +----+ * +----+--+ | +----+ | * | B | | | * | | | | * +-------+ +-------+ * ``` * @param csg */ union(csg: ThreeCsg): ThreeCsg; /** * Return a new CSG solid representing space in this solid but not in the * solid `csg`. Neither this solid nor the solid `csg` are modified. * * ``` * A.subtract(B) * * +-------+ +-------+ * | | | | * | A | | | * | +--+----+ = | +--+ * +----+--+ | +----+ * | B | * | | * +-------+ * ``` * @param csg */ subtract(csg: ThreeCsg): ThreeCsg; /** * Return a new CSG solid representing space both this solid and in the * solid `csg`. Neither this solid nor the solid `csg` are modified. * * ``` * A.intersect(B) * * +-------+ * | | * | A | * | +--+----+ = +--+ * +----+--+ | +--+ * | B | * | | * +-------+ * ``` * @param csg */ intersect(csg: ThreeCsg): ThreeCsg; /** * Return a new CSG solid with solid and empty space switched. This solid is * not modified. */ inverse(): ThreeCsg; toPolygons(): Polygon[]; /** * Construct a CSG solid from a list of `Polygon` instances. * @param polygons */ static fromPolygons(polygons: Polygon[]): ThreeCsg; static fromGeometry(geom: Geometry | BufferGeometry): ThreeCsg; static fromMesh(mesh: Mesh): ThreeCsg; static toMesh(csg: ThreeCsg, toMatrix: Matrix4): Mesh; } /** * Represents a 3D vector. * * Example usage: * * ```ts * new CSG.Vector(1, 2, 3); * new CSG.Vector([1, 2, 3]); * new CSG.Vector({ x: 1, y: 2, z: 3 }); * ``` */ declare class Vector extends Vector3 { static fromVector(v: Vector): Vector; static fromArray(v: number[]): Vector; constructor(x: number, y: number, z: number); negated(): this; plus(a: Vector): this; minus(a: Vector): this; times(a: number): this; dividedBy(a: number): this; lerp(a: Vector, t: number): this; unit(): Vector; crossProduct(a: Vector): Vector; } /** * Represents a vertex of a polygon. Use your own vertex class instead of this * one to provide additional features like texture coordinates and vertex * colors. Custom vertex classes need to provide a `pos` property and `clone()`, * `flip()`, and `interpolate()` methods that behave analogous to the ones * defined by `CSG.Vertex`. This class provides `normal` so convenience * functions like `CSG.sphere()` can return a smooth vertex normal, but `normal` * is not used anywhere else. */ declare class Vertex { pos: Vector; normal: Vector; uv: Vector2; constructor(pos: Vector, normal: Vector, uv: Vector2); clone(): Vertex; flip(): void; interpolate(other: Vertex, t: number): Vertex; } /** * Represents a plane in 3D space. */ declare class Plane { normal: Vector; private w; static EPSILON: number; constructor(normal: Vector, w: number); clone(): Plane; flip(): void; /** * Split `polygon` by this plane if needed, then put the polygon or polygon * fragments in the appropriate lists. Coplanar polygons go into either * `coplanarFront` or `coplanarBack` depending on their orientation with * respect to this plane. Polygons in front or in back of this plane go into * either `front` or `back`. * * @param polygon * @param coplanarFront * @param coplanarBack * @param front * @param back */ splitPolygon(polygon: Polygon, coplanarFront: Polygon[], coplanarBack: Polygon[], front: Polygon[], back: Polygon[]): void; static fromPoints: (a: Vector, b: Vector, c: Vector) => Plane; } /** * Represents a convex polygon. The vertices used to initialize a polygon must * be coplanar and form a convex loop. They do not have to be `Vertex` * instances but they must behave similarly (duck typing can be used for * customization). * * Each convex polygon has a `shared` property, which is shared between all * polygons that are clones of each other or were split from the same polygon. * This can be used to define per-polygon properties (such as surface color). */ declare class Polygon { vertices: Vertex[]; shared: any; plane: Plane; constructor(vertices: Vertex[], shared?: any); clone(): Polygon; flip(): void; } export {};