@awayjs/graphics
Version:
AwayJS graphics classes
67 lines • 2.52 kB
TypeScript
import { Rectangle, Vector3D } from '@awayjs/core';
import { AttributesView } from '@awayjs/stage';
type TGenCallback = (source: PolygonView<any>, result: PolygonView, back: boolean) => void;
export declare class Vertice3DView {
private _data;
get length(): number;
toVec(vect?: Vector3D, index?: number): Vector3D;
fromVec(vect: Vector3D, index?: number): this;
setData(data: Float32Array, index: number, clone?: boolean): this;
getData(index: number): Float32Array;
lerpTo(target: Vertice3DView, alpha: number): this;
add(source: Vertice3DView, scale?: number): this;
scale(s: number): this;
copyFrom(from: Vertice3DView): this;
clone(): Vertice3DView;
}
export declare class PolygonView<T extends {
clone?(): T;
} = any> {
vertices: Array<Vertice3DView>;
userData: T;
private _middle;
get middle(): Vertice3DView;
constructor(points?: Vertice3DView[], userData?: T);
clone(): PolygonView<T>;
add(view: Vertice3DView, clone?: boolean): this;
get length(): number;
}
export declare class MeshView<T extends {} = never> {
poly: PolygonView<T>[];
rect: Rectangle;
polySize: number;
hasNGones: boolean;
push(p: PolygonView<T>): this;
/**
* Unroll all n-gone convex polys to 3-gone polygons
*/
normalise(): this;
/**
* Construct buffer from poly data
* @param index Index of vertices attribute 0 - pos, 1 - uv etc
*/
toFloatArray(index?: number): Float32Array;
static fromAttributes<T>(attrs: AttributesView[], length: number, polySize?: number, userDataCtor?: {
new (): T;
}): MeshView<T>;
}
export declare class GeneratorUtils {
private static EPS;
private static InFront;
private static Behind;
private static OnPlane;
private static Intersect;
private static SliceNaive;
static SliceAllNaive<T>(mesh: MeshView<T>, n: Vector3D, d: number): MeshView<T>;
/**
* It gen corrupted results, need improve, eXponenta
*
* Splits a polygon in half along a splitting plane using a clipping algorithm
* call Sutherland-Hodgman clipping
* Resource: Page 367 of Ericson (Real-Time Collision Detection)
*/
static SutherlandHodgman<T>(poly: PolygonView<T>, normal: Vector3D, d: number, out: MeshView<T>, callback?: TGenCallback): MeshView<T>;
static SliceHodgman<T>(mesh: MeshView<T>, n: Vector3D, d: number, callback?: TGenCallback): MeshView<T>;
}
export {};
//# sourceMappingURL=GeneratorUtils.d.ts.map