/**
* The attribute size type corresponds to float, vec2, vec3, or vec4.
*/
type AttributeSizeType = 1 | 2 | 3 | 4;
/**
* An array of attribute values associated with meta data describing how to interpret the values.
*/
interface Attribute {
/**
* The values of the attribute.
*/
values: number[];
/**
* The number of values that are associated with a given vertex.
*/
size: AttributeSizeType;
}
/**
* DataType with values from WebGLRenderingContextBase.
*
* https://www.khronos.org/registry/webgl/specs/1.0/
*/
declare enum DataType {
BYTE = 5120,
UNSIGNED_BYTE = 5121,
SHORT = 5122,
UNSIGNED_SHORT = 5123,
INT = 5124,
UNSIGNED_INT = 5125,
FLOAT = 5126
}
/**
* A convenience class for implementing the Attribute interface.
* @hidden
*/
declare class DrawAttribute implements Attribute {
readonly values: number[];
readonly size: AttributeSizeType;
readonly type: DataType;
constructor(values: number[], size: AttributeSizeType, type: DataType);
}
/**
* The enumerated modes of drawing WebGL primitives.
* (POINTS, LINES, LINE_LOOP, LINE_STRIP, TRIANGLES, TRIANGLE_STRIP,TRIANGLE_FAN)
*
* https://www.khronos.org/registry/webgl/specs/1.0/
*/
declare enum BeginMode {
POINTS = 0,
LINES = 1,
LINE_LOOP = 2,
LINE_STRIP = 3,
TRIANGLES = 4,
TRIANGLE_STRIP = 5,
TRIANGLE_FAN = 6
}
/**
* The data corresponding to a drawArrays or drawElements call to the WebGL API.
* This data is not interleaved.
*/
interface Primitive {
/**
* The mode used to draw the attribute data.
*/
mode: BeginMode;
/**
* Optional indices for the attribute data.
*/
indices?: number[];
/**
* A mapping from attribute name to attribute data.
*/
attributes: {
[name: string]: Attribute;
};
}
/**
* A convenience class for implementing the Primitive interface.
* @hidden
*/
declare class DrawPrimitive implements Primitive {
mode: BeginMode;
indices: number[];
attributes: {
[name: string]: Attribute;
};
constructor(mode: BeginMode, indices: number[], attributes: {
[name: string]: Attribute;
});
}
/**
* reduces multiple TRIANGLE_STRIP Primitives to a single TRAINGLE_STRIP Primitive.
* @hidden
*/
declare function reduce(primitives: Primitive[]): Primitive;
/**
*
*/
interface Lockable {
/**
* Determines whether this `Lockable` is locked.
* If the `Lockable` is in the unlocked state then it is mutable.
* If the `Lockable` is in the locked state then it is immutable.
*/
isLocked(): boolean;
/**
* Locks this `Lockable` (preventing any further mutation),
* and returns a token that may be used to unlock it.
*/
lock(): number;
/**
* Unlocks this `Lockable` (allowing mutation),
* using a token that was obtained from a preceding lock method call.
*/
unlock(token: number): void;
}
/**
* @hidden
*/
declare class VectorN$1
* Convenient base class for derived classes implementing
* Outputs a warning to the console that this method should be implemented by the derived class.
*
* This method should be implemented by derived classes.
*
* Not implementing this method in a derived class risks leaking resources allocated by the derived class.
*
* Notifies this instance that something is referencing it.
*
* Notifies this instance that something is dereferencing it.
*
* Collection class for maintaining an array of types derived from Shareable.
*
* Provides a safer way to maintain reference counts than a native array.
*
*
* A 3x3 (square) matrix of
* An adapter over a
* The 9 elements are stored in column-major order (the order expected by WebGL):
* Shareable.
* element onto the tail of the list and increments the element reference count.
*/
push(element: T): number;
/**
* Pushes element onto the tail of the list without incrementing the element reference count.
*/
pushWeakRef(element: T): number;
/**
*
*/
pop(): T;
/**
*
*/
unshift(element: T): number;
/**
* unshift without incrementing the element reference count.
* Float32Array.
*/
declare class AbstractMatrixn.
*
* this ⟼ reflection(n)
*
* @param n
*/
reflection(n: VectorE3): this;
/**
* this ⟼ rotation(spinor) * this
*
* @param spinor
*/
rotate(spinor: SpinorE3): this;
/**
* Sets this matrix to be equivalent to the spinor.
*
* this ⟼ rotation(spinor)
*
* @param spinor The spinor from which the rotation will be computed.
*/
rotation(spinor: SpinorE3): this;
/**
* @param i the zero-based index of the row.
*/
row(i: number): Arraynumbers.
* Float32Array, enabling it to be used directly with WebGL.
*
*
*
* 0 3 6
* 1 4 7
* 2 5 8
* Sets this matrix to the inverse of the upper-left 3x3 portion of a 4x4 matrix. *
* * @param matrix * @param throwOnSingular */ private invertUpperLeft; /** * */ inv(): this; /** * */ isOne(): boolean; /** * */ isZero(): boolean; /** * @param rhs */ mul(rhs: Matrix3): this; /** * @param lhs */ rmul(lhs: Matrix3): this; /** * @param a * @param b */ mul2(a: Matrix3, b: Matrix3): this; /** * */ neg(): this; /** ** Sets this 3x3 matrix to the matrix required to properly transform normal vectors * (pseudo or axial vectors) based upon the 4x4 matrix used to transform polar vectors. *
* * @param m */ normalFromMatrix4(m: Matrix4): this; /** * */ one(): this; /** *
* Sets this matrix to the transformation for a
* reflection in the plane normal to the unit vector n.
*
* this ⟼ reflection(n)
*
* Sets all elements of this matrix to the supplied values (provided in row-major order). *
** An advantage of this method is that the function call resembles the matrix written out. *
** The parameters are named according to the 1-based row and column. *
* * @param n11 * @param n12 * @param n13 * @param n21 * @param n22 * @param n23 * @param n31 * @param n32 * @param n33 */ set(n11: number, n12: number, n13: number, n21: number, n22: number, n23: number, n31: number, n32: number, n33: number): this; /** * @param rhs */ sub(rhs: Matrix3): this; /** * @param fractionDigits */ toExponential(fractionDigits?: number): string; /** * @param fractionDigits */ toFixed(fractionDigits?: number): string; /** * @param precision */ toPrecision(precision?: number): string; /** * @param radix */ toString(radix?: number): string; /** ** Computes the homogeneous translation matrix for a 2D translation. *
* * @param d */ translation(d: VectorE2): this; /** * */ transpose(): this; /** * Sets this matrix to the identity element for addition, 0. */ zero(): this; __add__(rhs: any): Matrix3; __radd__(lhs: any): Matrix3; __mul__(rhs: any): Matrix3; __rmul__(lhs: any): Matrix3; __pos__(): Matrix3; __neg__(): Matrix3; __sub__(rhs: any): Matrix3; __rsub__(lhs: any): Matrix3; /** * The identity matrix for multiplication. * The matrix is locked (immutable), but may be cloned. */ static readonly one: Matrix3; /** * @param n */ static reflection(n: VectorE2): Matrix3; /** * @param spinor */ static rotation(spinor: SpinorE2): Matrix3; /** * @param d */ static translation(d: VectorE2): Matrix3; /** * The identity matrix for addition. * The matrix is locked (immutable), but may be cloned. */ static readonly zero: Matrix3; } /** * */ declare class Vector3 { isLocked(): boolean; lock(): number; unlock(token: number): void; /** * */ private coords_; /** * */ private modified_; /** * @param a * @param b */ static dot(a: VectorE3, b: VectorE3): number; /** * Initializes the vector to the specified coordinates and modification state. * The returned vector is not locked. * @param coords Three numbers corresponding to the x, y, and z coordinates. Default is [0, 0, 0]. * @param modified The modification state. Default is false. */ constructor(coords?: [number, number, number], modified?: boolean); get length(): number; get modified(): boolean; set modified(modified: boolean); getComponent(i: number): number; /** * The coordinate corresponding to the e1 basis vector. */ get x(): number; set x(value: number); /** * The coordinate corresponding to the e2 basis vector. */ get y(): number; set y(value: number); /** * The coordinate corresponding to the e3 basis vector. */ get z(): number; set z(value: number); /** * */ get maskG3(): number; set maskG3(unused: number); /** *
* this ⟼ this + vector * α
*
this
*/
add(vector: VectorE3, α?: number): this;
/**
*
* this ⟼ σ * thisT
*
this
*/
applyMatrix4(σ: Matrix4): Vector3;
/**
*
*/
approx(n: number): Vector3;
/**
*
* this ⟼ - n * this * n
*
copy(this)
*/
clone(): Vector3;
/**
* this ⟼ copy(source)
*
* @returns copy(this)
*/
copy(source: VectorE3): this;
/**
* Copies the coordinate values into this Vector3.
*
* @param coordinates
* @returns
*/
copyCoordinates(coordinates: number[]): this;
/**
*
* this ⟼ this ✕ v
*
this ⟼ a ✕ b
*
* @param a
* @param b
* @returns a x b
*/
cross2(a: VectorE3, b: VectorE3): Vector3;
/**
* @param point
*/
distanceTo(point: VectorE3): number;
/**
* @param point
*/
quadranceTo(point: VectorE3): number;
/**
*
* this ⟼ this / α
*
* this ⟼ I * B
*
true, the direction of the resulting vector is reversed.
*
* @param B
* @param changeSign
*/
dual(B: SpinorE3, changeSign: boolean): Vector3;
/**
* @param other
*/
equals(other: any): boolean;
/**
*
*/
isZero(): boolean;
/**
* Computes the square root of the squared norm.
*/
magnitude(): number;
/**
* @return {Vector3} this
*/
neg(): this;
/**
*
* this ⟼ this + α * (target - this)
*
this
*/
lerp(target: VectorE3, α: number): this;
/**
*
* this ⟼ a + α * (b - a)
*
* this ⟼ this / norm(this)
*
this
*/
normalize(): Vector3;
/**
*
* this ⟼ this * α
*
* this ⟼ this, with components modified.
*
this ⋅ this or norm(this) * norm(this)
*/
squaredNorm(): number;
/**
*
* this ⟼ this - v
*
this
*/
sub(v: VectorE3, α?: number): Vector3;
sub2(a: VectorE3, b: VectorE3): Vector3;
/**
*
*/
toArray(): number[];
/**
* @param fractionDigits
* @returns
*/
toExponential(fractionDigits?: number): string;
/**
* @param fractionDigits
* @returns
*/
toFixed(fractionDigits?: number): string;
/**
* @param precision
* @returns
*/
toPrecision(precision?: number): string;
/**
* @param radix
* @returns
*/
toString(radix?: number): string;
/**
* Sets this vector to the identity element for addition, 0.
*/
zero(): Vector3;
__add__(rhs: Vector3): Vector3;
__radd__(lhs: Vector3): Vector3;
__sub__(rhs: Vector3): Vector3;
__rsub__(lhs: Vector3): Vector3;
__mul__(rhs: number): Vector3;
__rmul__(lhs: number | Matrix3): Vector3;
__div__(rhs: number): Vector3;
__rdiv__(lhs: any): Vector3;
__pos__(): Vector3;
__neg__(): Vector3;
/**
* @param vector
*/
static copy(vector: VectorE3): Vector3;
/**
* Constructs a vector which is the dual of the supplied bivector, B.
* dual(B) = B << inv(I)
*/
static dual(B: BivectorE3): Vector3;
static e1(): Vector3;
static e2(): Vector3;
static e3(): Vector3;
/**
*
*/
static isInstance(x: any): x is Vector3;
/**
* @param a
* @param b
* @param α
* @return {Vector3} a + α * (b - a)
*/
static lerp(a: VectorE3, b: VectorE3, α: number): Vector3;
/**
* * Computes a unit vector with a random direction. *
* * @return {Vector3} */ static random(): Vector3; /** * Creates a vector with the specified cartesian coordinates. * The returned vector is not locked. * The returned vector is not modified. * @param x The x-coordinate. * @param y The y-coordinate. * @param z The z-coordinate. */ static vector(x: number, y: number, z: number): Vector3; /** * Creates a vector with all cartesian coordinates set to zero. * The returned vector is not locked. * The returned vector is not modified. */ static zero(): Vector3; } /** * */ interface VectorE1 { /** * The Cartesian x-coordinate. */ readonly x: number; } /** * */ declare class Matrix2 extends AbstractMatrixn.
*
* this ⟼ reflection(n) = I - 2 * nT * n
*
*/
reflection(n: VectorE1): Matrix2;
/**
* Returns the row for the specified index.
* @param i the zero-based index of the row.
*/
row(i: number): Array
* this ⟼ σ * thisT
*
this
*/
neg(): this;
dot(v: VectorE2): number;
/**
* Computes the square root of the squared norm.
*/
magnitude(): number;
normalize(): Vector2;
squaredNorm(): number;
quadranceTo(position: VectorE2): number;
/**
* @param t
* @param controlPoint
* @param endPoint
*/
quadraticBezier(t: number, controlPoint: VectorE2, endPoint: VectorE2): Vector2;
reflect(n: VectorE2): Vector2;
/**
* @param spinor
*/
rotate(spinor: SpinorE2): this;
/**
* this ⟼ this + (v - this) * α
*
* @param v
* @param α
*/
lerp(v: VectorE2, α: number): this;
/**
*
* this ⟼ a + α * (b - a)
*
this
*/
lerp2(a: VectorE2, b: VectorE2, α: number): Vector2;
equals(v: VectorE2): boolean;
/**
* @param σ
*/
stress(σ: VectorE2): this;
/**
*
*/
toArray(): number[];
/**
* @param fractionDigits
*/
toExponential(fractionDigits?: number): string;
/**
* @param fractionDigits
*/
toFixed(fractionDigits?: number): string;
/**
* @param precision
*/
toPrecision(precision?: number): string;
/**
* @param radix
*/
toString(radix?: number): string;
fromArray(array: number[], offset?: number): this;
fromAttribute(attribute: {
itemSize: number;
array: number[];
}, index: number, offset?: number): this;
/**
* Sets this vector to the identity element for addition, 0.
*/
zero(): Vector2;
__neg__(): Vector2;
/**
* @param vector
*/
static copy(vector: VectorE2): Vector2;
/**
* @param a
* @param b
* @return a + α * (b - a)
*/
static lerp(a: VectorE2, b: VectorE2, α: number): Vector2;
/**
* * Computes a unit vector with a random direction. *
*/ static random(): Vector2; static vector(x: number, y: number): Vector2; static readonly zero: Vector2; } /** * @hidden */ declare class MouseControls extends ShareableBase { /** * * @default true */ enabled: boolean; /** * * @default false */ noRotate: boolean; /** * * @default false */ noZoom: boolean; /** * * @default false */ noPan: boolean; /** * * @default 0 */ minDistance: number; /** * * @default Infinity */ maxDistance: number; /** * */ private domElement; /** * The mouse controls operate modally. You can only do one thing (rotate, zoom, or pan) at a time. */ private mode; /** * Using the keyboard allows us to change modes, so we keep this so that we can revert. */ private prevMode; /** * */ protected moveCurr: Vector2; /** * */ protected movePrev: Vector2; /** * */ protected zoomStart: Vector2; /** * */ protected zoomEnd: Vector2; /** * */ protected panStart: Vector2; /** * */ protected panEnd: Vector2; /** * Initialized by calling handleResize */ private screenLoc; /** * Think of this vector as running from the top left corner of the screen. */ private circleExt; /** * Think of this vector as running from the bottom left corner of the screen. */ private screenExt; private mouseOnCircle; private mouseOnScreen; private mousedown; private mousemove; private mouseup; private mousewheel; private keydown; private keyup; private contextmenu; private wnd; /** * * @param wnd */ constructor(wnd?: BrowserWindow); protected destructor(levelUp: number): void; /** * Simulates a movement of the mouse in coordinates -1 to +1 in both directions. * * @param x * @param y */ move(x: number, y: number): void; /** * @param domElement */ subscribe(domElement: HTMLElement): void; /** * */ unsubscribe(): void; disableContextMenu(): void; enableContextMenu(): void; /** * */ reset(): void; /** * Computes coordinates in the range [-1,+1] in both e1 and e2 directions. * e1 goes to the RIGHT * e2 goes UP * Updates the mouseOnCircle property. * * @param mouse */ private updateMouseOnCircle; /** * Computes coordinates in the range [0,1] in both e1 and e2 directions. * e1 goes to the RIGHT * e2 goes DOWN * Updates the mouseOnScreen property. * * @param mouse */ private updateMouseOnScreen; /** * This should be called whenever the window is resized. */ handleResize(): void; } /** * */ interface ViewController { /** ** Called during the animation loop to update the target based upon mouse events. *
*/ update(): void; /** ** Called at any time to reset the target to the last synchonization point. *
*/ reset(): void; /** ** Called at any time to set a view for this controller. *
* This method also synchronizes the controller with the view. * * @param view */ setView(view: { eye: VectorE3; look: VectorE3; up: VectorE3; }): void; /** ** Called at any time to synchronize the controller with the view state. *
*/ synchronize(): void; } /** * @hidden */ declare class ViewControls extends MouseControls implements ViewController { /** * * @default 1 */ rotateSpeed: number; /** * * @default 1 */ zoomSpeed: number; /** * * @default 1 */ panSpeed: number; /** * The view.eye value when the view was acquired by this view controller. */ private eye0; /** * The view.look value when the view was acquired by this view controller. */ private look0; /** * The view.up value when the view was acquired by this view controller. */ private up0; /** * The view that is being controlled. * We work only with coordinates to minimize requirements for interoperability. */ private view; /** * */ protected eyeMinusLook: Vector3; /** * */ protected look: Vector3; /** * */ protected up: Vector3; /** * @param view * @param wnd */ constructor(view: { eye: VectorE3; look: VectorE3; up: VectorE3; }, wnd?: BrowserWindow); /** * @hidden */ protected destructor(levelUp: number): void; /** * @returns */ protected hasView(): boolean; /** * This should be called inside the animation frame to update the camera location. * Notice that the movement of the mouse controls is decoupled from the effect. * We also want to avoid temporary object creation in this and called methods by recycling variables. */ update(): void; /** * */ protected rotateCamera(): void; /** * */ protected zoomCamera(): void; /** * */ protected panCamera(): void; /** * */ reset(): void; /** * @param view */ setView(view: { eye: VectorE3; look: VectorE3; up: VectorE3; }): void; /** * */ synchronize(): void; } /** *
* OrbitControls move a camera over a sphere such that the camera up vector
* remains aligned with the local north vector.
*
* For rotations, the final camera position dictates a new camera local reference frame. * A rotor may be calculated that rotates the camera from its old reference frame to the * new reference frame. This rotor may also be interpolated for animations. *
* @hidden */ declare class OrbitControls extends ViewControls { /** * @param view * @param wnd */ constructor(view: { eye: VectorE3; look: VectorE3; up: VectorE3; }, wnd?: BrowserWindow); /** * @param levelUp */ protected destructor(levelUp: number): void; /** * */ protected rotateCamera(): void; } /** ** Allows a camera to be manipulated using mouse controls. *
* * // The trackball controls a view implementation such as a camera. * const camera = new EIGHT.PerspectiveCamera() * * // Create TrackballControls anytime. * const controls = new EIGHT.TrackballControls(camera) * * // Subscribe to mouse events, usually in the window.onload function. * controls.subscribe(canvas) * * // Update the camera position, usually in the animate function. * controls.update() * * // Stop listening to mouse events. * controls.unsubscribe() * * // Inform the controls they are no longer needed, usually in the window.onunload function. * controls.release() * * You may decide to update directional lighting to synchronize with the camera. */ declare class TrackballControls extends ViewControls { private moveDirection; private eyeMinusLookDirection; private objectUpDirection; private objectSidewaysDirection; /** * The bivector for a rotation. */ private B; private rotor; private mouseChange; private pan; private objectUp; /** * * @param view eye, look, and up vectors. The coordinates will be manipulated by this object. * @param wnd The browser window. Used to add listeners for mouse and keyboard events. */ constructor(view: { eye: VectorE3; look: VectorE3; up: VectorE3; }, wnd?: Window); /** * @hidden */ protected destructor(levelUp: number): void; /** * @hidden */ protected rotateCamera(): void; /** * @hidden */ protected panCamera(): void; } /** * */ declare enum TextureUnit { TEXTURE0 = 33984, TEXTURE1 = 33985, TEXTURE2 = 33986, TEXTURE3 = 33987, TEXTURE4 = 33988, TEXTURE5 = 33989, TEXTURE6 = 33990, TEXTURE7 = 33991, TEXTURE8 = 33992, TEXTURE9 = 33993, TEXTURE10 = 33994, TEXTURE11 = 33995, TEXTURE12 = 33996, TEXTURE13 = 33997, TEXTURE14 = 33998, TEXTURE15 = 33999, TEXTURE16 = 34000, TEXTURE17 = 34001, TEXTURE18 = 34002, TEXTURE19 = 34003, TEXTURE20 = 34004, TEXTURE21 = 34005, TEXTURE22 = 34006, TEXTURE23 = 34007, TEXTURE24 = 34008, TEXTURE25 = 34009, TEXTURE26 = 34010, TEXTURE27 = 34011, TEXTURE28 = 34012, TEXTURE29 = 34013, TEXTURE30 = 34014, TEXTURE31 = 34015, ACTIVE_TEXTURE = 34016 } /** * A facet visitor implementation is able to accept a value to be assigned to a WebGL uniform in a WebGL program. * This interface is normally only implemented by a Material. */ interface FacetVisitor { /** * Informs the facet visitor of which texture unit is to be used. * @param unit The texture unit to be used. */ activeTexture(unit: TextureUnit): void; matrix2fv(name: string, mat2: Float32Array, transpose: boolean): void; matrix3fv(name: string, mat3: Float32Array, transpose: boolean): void; matrix4fv(name: string, mat4: Float32Array, transpose: boolean): void; uniform1f(name: string, x: number): void; uniform1fv(name: string, data: Float32Array, srcOffset: number, srcLength: number): void; uniform1i(name: string, x: number): void; uniform1iv(name: string, data: Int32Array, srcOffset?: number, srcLength?: number): void; uniform2f(name: string, x: number, y: number): void; uniform2fv(name: string, data: Float32Array, srcOffset?: number, srcLength?: number): void; uniform2i(name: string, x: number, y: number): void; uniform2iv(name: string, data: Int32Array, srcOffset?: number, srcLength?: number): void; uniform3f(name: string, x: number, y: number, z: number): void; uniform3fv(name: string, data: Float32Array, srcOffset?: number, srcLength?: number): void; uniform3i(name: string, x: number, y: number, z: number): void; uniform3iv(name: string, data: Int32Array, srcOffset?: number, srcLength?: number): void; uniform4f(name: string, x: number, y: number, z: number, w: number): void; uniform4fv(name: string, data: Float32Array, srcOffset?: number, srcLength?: number): void; uniform4i(name: string, x: number, y: number, z: number, w: number): void; uniform4iv(name: string, data: Int32Array, srcOffset?: number, srcLength?: number): void; } /** * A `facet` is an adapter between a domain concept and a `uniform` value parameter in a WebGL shader program. * An object implementing the `Facet` interface is capable of setting uniform values on a `FacetVisitor` (which is * usually implemented by a `Material`). */ interface Facet extends Shareable { /** * Sets one of more uniform values on the `FacetVisitor`. * @param visitor A visitor to the `Facet`, usually a `Material` implementation. */ setUniforms(visitor: FacetVisitor): void; } /** * */ interface ContextProgramConsumer { contextFree(): void; contextGain(gl: WebGL2RenderingContext | WebGLRenderingContext, program: WebGLProgram): void; contextLost(): void; } /** * An object-oriented representation of anattribute in a GLSL shader program.
*/
declare class Attrib implements ContextProgramConsumer {
/**
* The name of the attribute in the GLSL program.
*/
private _name;
/**
* The index of the attribute in the GLSL program.
* This is obtained by calling the getAttribLocation method on
* the WebGLRenderingContext when it becomes available through
* a contextGain notification.
*/
private _index;
/**
* The cached WebGLRenderingContext obtained through
* a contextGain notification.
*/
private _gl;
/**
*
*/
private suppressWarnings;
/**
*
*/
constructor(contextManager: ContextManager, info: WebGLActiveInfo);
/**
* Returns the cached index obtained by calling getAttribLocation on the
* WebGLRenderingContext.
*/
get index(): number;
set index(unused: number);
/**
* Notifies this Attrib of a browser free WebGL context event.
* This Attrib responds by setting its cached index and context to undefined.
*/
contextFree(): void;
/**
* Notifies this Attrib of a browser gain WebGL context event.
* This Attrib responds by obtaining and caching attribute index.
*
* @param context
* @param program
*/
contextGain(context: WebGL2RenderingContext | WebGLRenderingContext, program: WebGLProgram): void;
/**
* Notifies this Attrib of a browser lost WebGL context event.
* This Attrib responds by setting its cached index and context to undefined.
*/
contextLost(): void;
/**
* Specifies the data formats and locations of vertex attributes in a vertex attributes array.
* Calls the vertexAttribPointer method
* on the underlying WebGLRenderingContext
* using the cached attribute index and the supplied parameters.
* Note that the type parameter is hard-code to FLOAT.
*
* @param size The number of components per attribute. Must be 1, 2, 3, or 4.
* @param type The data type of each component in the array.
* @param normalized Specifies whether fixed-point data values should be normalized (true), or are converted to fixed point vales (false) when accessed.
* @param stride The distance in bytes between the beginning of consecutive vertex attributes.
* @param offset The offset in bytes of the first component in the vertex attribute array. Must be a multiple of type.
*/
config(size: number, type: DataType, normalized?: boolean, stride?: number, offset?: number): void;
/**
* Calls the enableVertexAttribArray method
* on the underlying WebGLRenderingContext
* using the cached attribute index.
*/
enable(): void;
/**
* Calls the disableVertexAttribArray method
* on the underlying WebGLRenderingContext
* using the cached attribute index.
*/
disable(): void;
/**
* Returns the address of the specified vertex attribute.
* Experimental.
*/
getOffset(): number;
/**
* Returns a non-normative string representation of the GLSL attribute.
*/
toString(): string;
}
/**
* A wrapper around a WebGLUniformLocation.
*/
declare class Uniform implements ContextProgramConsumer {
private gl;
private location;
private name;
constructor(info: WebGLActiveInfo);
contextFree(): void;
contextGain(gl: WebGL2RenderingContext | WebGLRenderingContext, program: WebGLProgram): void;
contextLost(): void;
uniform1f(x: number): void;
uniform1fv(data: Float32Array, srcOffset?: number, srcLength?: number): void;
uniform1i(x: number): void;
uniform1iv(data: Int32Array, srcOffset?: number, srcLength?: number): void;
uniform2f(x: number, y: number): void;
uniform2fv(data: Float32Array, srcOffset?: number, srcLength?: number): void;
uniform2i(x: number, y: number): void;
uniform2iv(data: Int32Array, srcOffset?: number, srcLength?: number): void;
uniform3f(x: number, y: number, z: number): void;
uniform3fv(data: Float32Array, srcOffset?: number, srcLength?: number): void;
uniform3i(x: number, y: number, z: number): void;
uniform3iv(data: Int32Array, srcOffset?: number, srcLength?: number): void;
uniform4f(x: number, y: number, z: number, w: number): void;
uniform4fv(data: Float32Array, srcOffset?: number, srcLength?: number): void;
uniform4i(x: number, y: number, z: number, w: number): void;
uniform4iv(data: Int32Array, srcOffset?: number, srcLength?: number): void;
/**
* Sets a uniform location of type mat2 in the WebGLProgram.
*/
matrix2fv(transpose: boolean, value: Float32Array): void;
/**
* Sets a uniform location of type mat3 in a WebGLProgram.
*/
matrix3fv(transpose: boolean, value: Float32Array): void;
/**
* Sets a uniform location of type mat4 in a WebGLProgram.
*/
matrix4fv(transpose: boolean, value: Float32Array): void;
toString(): string;
}
/**
* @hidden
*/
declare class ShareableContextConsumer extends ShareableBase implements ContextConsumer {
protected contextManager: ContextManager;
/**
* Keep track of subscription state
*/
private isSubscribed;
/**
* Creates a subscription to WebGL rendering context events from the contextManager but
* defers synchronization (because this is a base class).
* The contextManager must be defined.
* @param contextManager The ContextManager that will be subscribed to for WebGL rendering context events.
*/
constructor(contextManager: ContextManager);
/**
*
*/
protected resurrector(levelUp: number): void;
/**
*
*/
protected destructor(levelUp: number): void;
/**
* Instructs the consumer to subscribe to context events.
*
* This method is idempotent; calling it more than once with the same ContextManager does not change the state.
*/
private subscribe;
/**
* Instructs the consumer to unsubscribe from context events.
*
* This method is idempotent; calling it more than once does not change the state.
*/
private unsubscribe;
/**
*
*/
synchUp(): void;
/**
*
*/
cleanUp(): void;
contextFree(): void;
contextGain(): void;
contextLost(): void;
/**
* Provides access to the underlying WebGL context.
*/
get gl(): WebGLRenderingContext;
}
/**
* WebGLBuffer usage.
*/
declare enum Usage {
/**
* Contents of the buffer are likely to not be used often.
* Contents are written to the buffer, but not read.
*/
STREAM_DRAW = 35040,
/**
* Contents of the buffer are likely to be used often and not change often.
* Contents are written to the buffer, but not read.
*/
STATIC_DRAW = 35044,
/**
* Contents of the buffer are likely to be used often and change often.
* Contents are written to the buffer, but not read.
*/
DYNAMIC_DRAW = 35048
}
/**
* A wrapper around a WebGLBuffer with binding to ARRAY_BUFFER.
*/
declare class VertexBuffer extends ShareableContextConsumer {
private data;
private usage;
/**
* The underlying WebGL buffer resource.
*/
private webGLBuffer;
/**
*
*/
constructor(contextManager: ContextManager, data: Float32Array, usage: Usage, levelUp?: number);
/**
*
*/
protected resurrector(levelUp: number): void;
/**
*
*/
protected destructor(levelUp: number): void;
upload(): void;
contextFree(): void;
contextGain(): void;
contextLost(): void;
/**
* Binds this buffer to the ARRAY_BUFFER target.
*/
bind(): void;
/**
* Unbinds this buffer from the ARRAY_BUFFER target.
*/
unbind(): void;
}
/**
* Material is an object-oriented wrapper around a WebGLProgram.
*/
interface Material extends FacetVisitor, ContextConsumer {
/**
*
*/
attrib(name: string, value: VertexBuffer, size: number, normalized?: boolean, stride?: number, offset?: number): Material;
/**
*
*/
getAttrib(indexOrName: number | string): Attrib;
/**
* @param name The name of the attribute.
* @returns The index of the attribute.
*/
getAttribLocation(name: string): number;
/**
* @param indexOrName The index or name of the attribute.
*/
enableAttrib(indexOrName: number | string): void;
/**
* @param indexOrName The index or name of the attribute.
*/
disableAttrib(indexOrName: number | string): void;
/**
*
*/
drawArrays(mode: BeginMode, first: number, count: number): Material;
/**
*
*/
drawElements(mode: BeginMode, count: number, type: DataType, offset: number): Material;
getUniform(name: string): Uniform;
hasUniform(name: string): boolean;
matrix2fv(name: string, elements: Float32Array, transpose?: boolean): Material;
matrix3fv(name: string, elements: Float32Array, transpose?: boolean): Material;
matrix4fv(name: string, elements: Float32Array, transpose?: boolean): Material;
/**
*
*/
uniform(name: string, value: number | number[]): Material;
use(): Material;
}
/**
* Encapsulates one or more buffers and a call to drawArrays or drawElements.
*/
interface Geometry extends ContextConsumer {
/**
* Binds the attributes of the material to the buffers in this Geometry.
*/
bind(material: Material): void;
/**
* Unbinds the attributes of the material from the buffers in this Geometry.
*/
unbind(material: Material): void;
/**
* A call to drawArrays or drawElements.
*/
draw(): void;
}
/**
* The interface contract for an object that may exist in a Scene.
* This interface is designed to place very few demands on the implementation.
*/
interface Renderable extends ContextConsumer {
/**
* An optional name allowing the object to be found by name.
*/
name?: string;
/**
* Determines when this object will be renderered relative to other objects.
* Transparent objects are rendered after non-transparent objects.
*/
transparent?: boolean;
/**
* Renders this object to the WebGL pipeline.
*/
render(ambients: Facet[]): void;
}
/**
*
*/
interface AbstractDrawable
* The Geometry that provides the buffered vertex attributes for this AbstractDrawable.
*
* Geometry is a shareable WebGL resource and so is reference counted.
* Consequently, accessing the geometry property increments the Geometry instance reference count.
* Be sure to call release() on shareable WebGL resources in order to prevent memory leaks.
*
* The Material that provides the WebGLProgram for this AbstractDrawable.
*
* Material is a shareable WebGL resource and so is reference counted.
* Consequently, accessing the material property increments the Material instance reference count.
* Be sure to call release() on shareable WebGL resources in order to prevent memory leaks.
*
Geometric3.
* The multivector is initialized to zero.
* coords [a, x, y, z, xy, yz, zx, b]
*/
constructor(coords?: [number, number, number, number, number, number, number, number]);
get length(): number;
get modified(): boolean;
set modified(modified: boolean);
getComponent(i: number): number;
/**
* Consistently set a coordinate value in the most optimized way,
* by checking for a change from the old value to the new value.
* The modified flag is only set to true if the value has changed.
* Throws an exception if this multivector is locked.
*/
private setCoordinate;
/**
* The scalar part of this multivector.
*/
get a(): number;
set a(a: number);
/**
* The coordinate corresponding to the e1 standard basis vector.
*/
get x(): number;
set x(x: number);
/**
* The coordinate corresponding to the e2 standard basis vector.
*/
get y(): number;
set y(y: number);
/**
* The coordinate corresponding to the e3 standard basis vector.
*/
get z(): number;
set z(z: number);
/**
* The coordinate corresponding to the e2e3 standard basis bivector.
*/
get yz(): number;
set yz(yz: number);
/**
* The coordinate corresponding to the e3e1 standard basis bivector.
*/
get zx(): number;
set zx(zx: number);
/**
* The coordinate corresponding to the e1e2 standard basis bivector.
*/
get xy(): number;
set xy(xy: number);
/**
* The pseudoscalar part of this multivector.
*/
get b(): number;
set b(b: number);
/**
* A bitmask describing the grades.
*
* 0x0 = zero
* 0x1 = scalar
* 0x2 = vector
* 0x4 = bivector
* 0x8 = pseudoscalar
*/
get maskG3(): number;
/**
* Adds a multivector value to this multivector with optional scaling.
*
* this ⟼ this + M * alpha
*
* @param M The multivector to be added to this multivector.
* @param alpha An optional scale factor that multiplies the multivector argument.
*
* @returns this + M * alpha
*/
add(M: GeometricE3, alpha?: number): Geometric3;
/**
* Adds a bivector value to this multivector.
*
* this ⟼ this + B
*
* @returns this + B
*/
addBivector(B: BivectorE3): Geometric3;
/**
* Adds a pseudoscalar value to this multivector.
*
* this ⟼ this + I * β
*
* @param β The pseudoscalar value to be added to this multivector.
* @returns this + I * β
*/
addPseudo(β: number): Geometric3;
/**
* Adds a scalar value to this multivector.
*
* @param alpha The scalar value to be added to this multivector.
* @return this + alpha
*/
addScalar(alpha: number): Geometric3;
/**
* Adds a vector value to this multivector.
*
* @param v The vector to be added.
* @param alpha The scaling factor for the vector.
* @returns this + v * alpha
*/
addVector(v: VectorE3, alpha?: number): Geometric3;
/**
*
* this ⟼ a + b
*
this multivector.
*/
arg(): Geometric3;
/**
* Sets any coordinate whose absolute value is less than pow(10, -n) times the absolute value of the largest coordinate.
*/
approx(n: number): Geometric3;
/**
* @returns copy(this)
*/
clone(): Geometric3;
/**
* The Clifford conjugate.
* The multiplier for the grade x is (-1) raised to the power x * (x + 1) / 2
* The pattern of grades is +--++--+
*
* @returns conj(this)
*/
conj(): Geometric3;
/**
* Copies the coordinate values into this Geometric3.
*
* @param coordinates The coordinates in order a, x, y, z, yz, zx, xy, b.
*/
copyCoordinates(coordinates: number[]): this;
/**
* @param point
*/
distanceTo(point: VectorE3): number;
/**
* Computes the quadrance from this position (vector) to the specified point.
*/
quadranceTo(point: VectorE3): number;
/**
* Left contraction of this multivector with another multivector.
* @param m
* @returns this << m
*/
lco(m: GeometricE3): Geometric3;
/**
* Sets this multivector to a << b
*
* @param a
* @param b
* @returns a << b
*/
lco2(a: GeometricE3, b: GeometricE3): this;
/**
* Right contraction.
*
* A >> B = grade(A * B, a - b) = A.rco(B)
*
* @returns this >> rhs
*/
rco(m: GeometricE3): this;
/**
*
* this ⟼ a >> b
*
* this ⟼ this / m
*
* this ⟼ this - v * α
*
* this ⟼ a - b
*
* Sets the graphics buffers to values preselected by clearColor, clearDepth or clearStencil. *
*/ clear(mask?: number): this; /** * Specifies color values to use by theclear method to clear the color buffer.
*/
clearColor(red: number, green: number, blue: number, alpha: number): this;
/**
* Specifies the clear value for the depth buffer.
* This specifies what depth value to use when calling the clear() method.
* The value is clamped between 0 and 1.
*
* @param depth Specifies the depth value used when the depth buffer is cleared.
* The default value is 1.
*/
clearDepth(depth: number): this;
/**
* @param s Specifies the index used when the stencil buffer is cleared.
* The default value is 0.
*/
clearStencil(s: number): this;
depthFunc(func: DepthFunction): this;
depthMask(flag: boolean): this;
/**
* Disables the specified WebGL capability.
*/
disable(capability: Capability): this;
/**
* Enables the specified WebGL capability.
*/
enable(capability: Capability): this;
finish(): this;
/**
* The underlying WebGL rendering context.
*/
get gl(): WebGL2RenderingContext | WebGLRenderingContext;
get contextId(): "webgl2" | "webgl";
/**
*
*/
readPixels(x: number, y: number, width: number, height: number, format: PixelFormat, type: PixelType, pixels: ArrayBufferView): void;
/**
* @param consumer
*/
removeContextListener(consumer: ContextConsumer): void;
/**
* A convenience method for setting the width and height properties of the
* underlying canvas and for setting the viewport to the drawing buffer height and width.
*/
size(width: number, height: number): this;
/**
* The viewport width and height are clamped to a range that is
* implementation dependent.
*
* @returns e.g. Int32Array[16384, 16384]
*/
getMaxViewportDims(): Int32Array;
/**
* Returns the current viewport settings.
*
* @returns e.g. Int32Array[x, y, width, height]
*/
getViewport(): Int32Array;
/**
* Defines what part of the canvas will be used in rendering the drawing buffer.
*
* @param x
* @param y
* @param width
* @param height
*/
viewport(x: number, y: number, width: number, height: number): this;
/**
* Initializes the WebGLRenderingContext for the specified HTMLCanvasElement.
*
* @param canvas The HTML canvas element or canvas element identifier.
* @param dom The document object model that contains the canvas identifier.
*/
start(canvas: string | HTMLCanvasElement | WebGL2RenderingContext | WebGLRenderingContext, dom?: Document): this;
/**
*
*/
stop(): this;
private emitStartEvent;
private emitContextGain;
private emitStopEvent;
private emitContextFree;
/**
* @param consumer
*/
synchronize(consumer: ContextConsumer): this;
/**
* Computes the coordinates of a point in the image cube corresponding to device coordinates.
* @param deviceX The x-coordinate of the device event.
* @param deviceY The y-coordinate of the device event.
* @param imageZ The optional value to use as the resulting depth coordinate.
*/
deviceToImageCoords(deviceX: number, deviceY: number, imageZ?: number): Readonlyfirst parameter in the drawArrays call.
* This is currently hard-code to zero because this class only supportes buffering one primitive.
*/
private first;
/**
* The count parameter in the drawArrays call.
* This is currently maintained at this level because this class only supportes buffering one primitive.
*/
private count;
/**
* The number of bytes for each element.
*
* This is used in the vertexAttribPointer method.
* Normally, we will use gl.FLOAT for each number which takes 4 bytes.
*/
private stride;
/**
*
*/
private pointers;
/**
*
*/
private vbo;
/**
*
*/
constructor(contextManager: ContextManager, primitive: Primitive, options?: {
order?: string[];
tilt?: SpinorE3;
}, levelUp?: number);
/**
*
*/
protected resurrector(levelUp: number): void;
/**
*
*/
protected destructor(levelUp: number): void;
bind(material: Material): this;
draw(): this;
unbind(material: Material): this;
}
/**
* A Geometry that supports interleaved vertex buffers.
*/
declare class GeometryElements extends GeometryBase {
/**
*
*/
private mode;
/**
*
*/
private count;
/**
* Hard-coded to zero right now.
* This suggests that the index buffer could be used for several gl.drawElements(...)
*/
private offset;
/**
* The number of bytes for each element.
*
* This is used in the vertexAttribPointer method.
* Normally, we will use gl.FLOAT for each number which takes 4 bytes.
*/
private stride;
/**
*
*/
private pointers;
/**
*
*/
private ibo;
/**
*
*/
private vbo;
/**
*
*/
constructor(contextManager: ContextManager, primitive: Primitive, options?: {
axis?: VectorE3;
meridian?: VectorE3;
order?: string[];
tilt?: SpinorE3;
}, levelUp?: number);
/**
* @hidden
*/
protected resurrector(levelUp: number): void;
/**
* @hidden
*/
protected destructor(levelUp: number): void;
contextFree(): void;
contextGain(): void;
contextLost(): void;
bind(material: Material): this;
unbind(material: Material): this;
draw(): GeometryElements;
}
/**
* Canonical variable names, which also act as semantic identifiers for name overrides.
* These names must be stable to avoid breaking custom vertex and fragment shaders.
* @hidden
*/
declare class GraphicsProgramSymbols {
/**
* 'aColor'
*/
static ATTRIBUTE_COLOR: string;
/**
* 'aGeometryIndex'
*/
static ATTRIBUTE_GEOMETRY_INDEX: string;
/**
* 'aNormal'
*/
static ATTRIBUTE_NORMAL: string;
/**
* 'aOpacity'
*/
static ATTRIBUTE_OPACITY: string;
/**
* 'aPosition'
*/
static ATTRIBUTE_POSITION: string;
/**
* 'aTangent'
*/
static ATTRIBUTE_TANGENT: string;
/**
* 'aCoords'
*/
static ATTRIBUTE_COORDS: string;
/**
* 'uAlpha'
*/
static UNIFORM_ALPHA: string;
/**
* 'uAmbientLight'
*/
static UNIFORM_AMBIENT_LIGHT: string;
/**
* 'uColor'
*/
static UNIFORM_COLOR: string;
/**
* 'uDirectionalLightColor'
*/
static UNIFORM_DIRECTIONAL_LIGHT_COLOR: string;
/**
* 'uDirectionalLightDirection'
*/
static UNIFORM_DIRECTIONAL_LIGHT_DIRECTION: string;
/**
* 'uImage'
*/
static UNIFORM_IMAGE: string;
/**
* 'uOpacity'
*/
static UNIFORM_OPACITY: string;
/**
* 'uPointLightColor'
*/
static UNIFORM_POINT_LIGHT_COLOR: string;
/**
* 'uPointLightPosition'
*/
static UNIFORM_POINT_LIGHT_POSITION: string;
/**
* 'uPointSize'
*/
static UNIFORM_POINT_SIZE: string;
/**
* 'uProjection'
*/
static UNIFORM_PROJECTION_MATRIX: string;
/**
* 'uReflectionOne'
*/
static UNIFORM_REFLECTION_ONE_MATRIX: string;
/**
* 'uReflectionTwo'
*/
static UNIFORM_REFLECTION_TWO_MATRIX: string;
/**
* 'uModel'
*/
static UNIFORM_MODEL_MATRIX: string;
/**
* 'uNormal'
*/
static UNIFORM_NORMAL_MATRIX: string;
/**
* 'uView'
*/
static UNIFORM_VIEW_MATRIX: string;
/**
* 'vColor'
*/
static VARYING_COLOR: string;
/**
* 'vCoords'
*/
static VARYING_COORDS: string;
/**
* 'vLight'
*/
static VARYING_LIGHT: string;
}
/**
*
*/
declare enum TextureMagFilter {
NEAREST = 9728,
LINEAR = 9729
}
/**
*
*/
declare enum TextureMinFilter {
NEAREST = 9728,
LINEAR = 9729,
NEAREST_MIPMAP_NEAREST = 9984,
LINEAR_MIPMAP_NEAREST = 9985,
NEAREST_MIPMAP_LINEAR = 9986,
LINEAR_MIPMAP_LINEAR = 9987
}
/**
*
*/
declare enum TextureTarget {
TEXTURE_2D = 3553,
TEXTURE = 5890
}
/**
*
*/
declare enum TextureWrapMode {
REPEAT = 10497,
CLAMP_TO_EDGE = 33071,
MIRRORED_REPEAT = 33648
}
declare class Texture extends ShareableContextConsumer {
private _texture;
protected _target: TextureTarget;
/**
*
* @param target
* @param contextManager
* @param levelUp
*/
constructor(target: TextureTarget, contextManager: ContextManager, levelUp?: number);
protected destructor(levelUp: number): void;
contextFree(): void;
contextGain(): void;
contextLost(): void;
/**
*
*/
bind(): void;
/**
*
*/
unbind(): void;
get minFilter(): TextureMinFilter;
set minFilter(filter: TextureMinFilter);
get magFilter(): TextureMagFilter;
set magFilter(filter: TextureMagFilter);
get wrapS(): TextureWrapMode;
set wrapS(mode: TextureWrapMode);
get wrapT(): TextureWrapMode;
set wrapT(mode: TextureWrapMode);
/**
*
*/
upload(): void;
}
declare class ImageTexture extends Texture {
private image;
/**
* @param image
* @param target
* @param contextManager
* @param levelUp
*/
constructor(image: HTMLImageElement, target: TextureTarget, contextManager: ContextManager, levelUp?: number);
/**
* @hidden
*/
protected destructor(levelUp: number): void;
get naturalHeight(): number;
get naturalWidth(): number;
upload(): void;
}
/**
* A wrapper around a WebGLBuffer with binding to ELEMENT_ARRAY_BUFFER.
* @hidden
*/
declare class IndexBuffer extends ShareableContextConsumer {
private data;
private usage;
private webGLBuffer;
/**
*
*/
constructor(contextManager: ContextManager, data: Uint16Array, usage: Usage, levelUp?: number);
/**
* @hidden
*/
protected resurrector(levelUp: number): void;
/**
* @hidden
*/
protected destructor(levelUp: number): void;
upload(): void;
contextFree(): void;
contextGain(): void;
contextLost(): void;
/**
* Binds the underlying WebGLBuffer to the ELEMENT_ARRAY_BUFFER target.
*/
bind(): void;
unbind(): void;
}
/**
*
*/
interface MeshOptions {
/**
* The reference axis.
*/
axis?: VectorE3;
/**
* The reference meridian.
*/
meridian?: VectorE3;
}
/**
* The standard pairing of a Geometry and a Material.
*/
declare class Meshthis multivector.
*/
arg(): Geometric2;
/**
*
*/
approx(n: number): this;
/**
* copy(this)
*/
clone(): Geometric2;
/**
* The Clifford conjugate.
* The multiplier for the grade x is (-1) raised to the power x * (x + 1) / 2
* The pattern of grades is +--++--+
*
* @returns conj(this)
*/
conj(): this;
/**
*
*/
cos(): this;
/**
*
*/
cosh(): this;
/**
*
*/
distanceTo(M: GeometricE2): number;
/**
* this ⟼ copy(M)
*/
copy(M: GeometricE2): this;
/**
* Sets this multivector to the value of the scalar, α.
*/
copyScalar(α: number): this;
/**
* this ⟼ copy(spinor)
*/
copySpinor(spinor: SpinorE2): this;
/**
* this ⟼ copyVector(vector)
*/
copyVector(vector: VectorE2): this;
/**
*
*/
cubicBezier(t: number, controlBegin: GeometricE2, controlEnd: GeometricE2, endPoint: GeometricE2): this;
/**
* this ⟼ this / magnitude(this)
*/
normalize(): this;
/**
* this ⟼ this / m
*/
div(m: GeometricE2): this;
/**
* this ⟼ a / b
*/
div2(a: GeometricE2, b: GeometricE2): this;
/**
* this ⟼ this / α
*/
divByScalar(α: number): this;
/**
*
*/
dual(): Geometric2;
/**
*
*/
equals(other: any): boolean;
/**
* this ⟼ exp(this)
*/
exp(): this;
/**
* this ⟼ this ^ m
*/
ext(m: GeometricE2): this;
/**
* this ⟼ a ^ b
*/
ext2(a: GeometricE2, b: GeometricE2): this;
/**
* Sets this multivector to its inverse, if it exists.
*/
inv(): Geometric2;
/**
*
*/
isOne(): boolean;
/**
*
*/
isZero(): boolean;
/**
* this ⟼ this << m
*/
lco(m: GeometricE2): Geometric2;
/**
* this ⟼ a << b
*/
lco2(a: GeometricE2, b: GeometricE2): this;
/**
* this ⟼ this + α * (target - this)
*/
lerp(target: GeometricE2, α: number): this;
/**
* this ⟼ a + α * (b - a)
*/
lerp2(a: GeometricE2, b: GeometricE2, α: number): this;
/**
* this ⟼ log(sqrt(α * α + β * β)) + e1e2 * atan2(β, α),
* where α is the scalar part of `this`,
* and β is the pseudoscalar part of `this`.
*/
log(): this;
/**
* Computes the square root of the squared norm.
*
* This method does not change this multivector.
*/
magnitude(): number;
/**
* this ⟼ this * m
*/
mul(m: GeometricE2): Geometric2;
/**
* this ⟼ a * b
*/
mul2(a: GeometricE2, b: GeometricE2): this;
/**
* this ⟼ -1 * this
*/
neg(): Geometric2;
/**
* this ⟼ sqrt(this * conj(this))
*/
norm(): this;
/**
* Sets this multivector to the identity element for multiplication, 1.
*/
one(): this;
/**
*
*/
pow(M: GeometricE2): this;
/**
* Updates this target to be the quad or squared norm of the target.
*
* this ⟼ scp(this, rev(this)) = this | ~this
*/
quad(): this;
/**
*
*/
quadraticBezier(t: number, controlPoint: GeometricE2, endPoint: GeometricE2): this;
/**
* this ⟼ this >> m
*/
rco(m: GeometricE2): this;
/**
* this ⟼ a >> b
*/
rco2(a: GeometricE2, b: GeometricE2): this;
/**
* this ⟼ - n * this * n
*/
reflect(n: VectorE2): this;
/**
* this ⟼ rev(this)
*/
rev(): Geometric2;
/**
*
*/
sin(): this;
/**
*
*/
sinh(): this;
/**
* this ⟼ R * this * rev(R)
*/
rotate(R: SpinorE2): this;
/**
* Sets this multivector to a rotation from vector a to vector b.
*/
rotorFromDirections(a: VectorE2, b: VectorE2): this;
rotorFromVectorToVector(a: VectorE2, b: VectorE2): this;
/**
* this ⟼ exp(- B * θ / 2)
*/
rotorFromGeneratorAngle(B: SpinorE2, θ: number): this;
/**
* this ⟼ scp(this, m)
*/
scp(m: GeometricE2): this;
/**
* this ⟼ scp(a, b)
*/
scp2(a: GeometricE2, b: GeometricE2): this;
/**
* this ⟼ this * α
*/
scale(α: number): this;
/**
*
*/
stress(σ: VectorE2): this;
/**
* this ⟼ a * b = a · b + a ^ b
*
* Sets this Geometric2 to the geometric product, a * b, of the vector arguments.
*/
versor(a: VectorE2, b: VectorE2): this;
/**
* this ⟼ this * ~this
*/
squaredNorm(): this;
/**
* @returns the square of the magnitude of this.
*/
quaditude(): number;
/**
* this ⟼ this - M * α
*/
sub(M: GeometricE2, α?: number): this;
/**
* this ⟼ a - b
*/
sub2(a: GeometricE2, b: GeometricE2): this;
/**
*
*/
toArray(): number[];
/**
* Returns a representation of this multivector in exponential notation.
*/
toExponential(fractionDigits?: number): string;
/**
* Returns a representation of this multivector in fixed-point notation.
*/
toFixed(fractionDigits?: number): string;
/**
* Returns a representation of this multivector in exponential or fixed-point notation.
*/
toPrecision(precision?: number): string;
/**
* Returns a representation of this multivector.
*/
toString(radix?: number): string;
/**
* Extraction of grade i.
*
* If this multivector is mutable (unlocked) then it is set to the result.
*
* @param i The index of the grade to be extracted.
*/
grade(i: number): Geometric2;
/**
* Sets this multivector to the identity element for addition, 0.
*
* this ⟼ 0
*/
zero(): this;
/**
* Implements this + rhs as addition.
* The returned value is locked.
*/
__add__(rhs: any): Geometric2;
/**
*
*/
__div__(rhs: any): Geometric2;
/**
*
*/
__rdiv__(lhs: any): Geometric2;
/**
*
*/
__mul__(rhs: any): Geometric2;
/**
*
*/
__rmul__(lhs: any): Geometric2;
/**
*
*/
__radd__(lhs: any): Geometric2;
/**
*
*/
__sub__(rhs: any): Geometric2;
/**
*
*/
__rsub__(lhs: any): Geometric2;
/**
*
*/
__wedge__(rhs: any): Geometric2;
/**
*
*/
__rwedge__(lhs: any): Geometric2;
/**
*
*/
__lshift__(rhs: any): Geometric2;
/**
*
*/
__rlshift__(lhs: any): Geometric2;
/**
*
*/
__rshift__(rhs: any): Geometric2;
/**
*
*/
__rrshift__(lhs: any): Geometric2;
/**
*
*/
__vbar__(rhs: any): Geometric2;
/**
*
*/
__rvbar__(lhs: any): Geometric2;
/**
*
*/
__bang__(): Geometric2;
/**
*
*/
__tilde__(): Geometric2;
/**
*
*/
__pos__(): Geometric2;
/**
*
*/
__neg__(): Geometric2;
/**
*
*/
static copy(M: GeometricE2): Geometric2;
/**
* The basis element corresponding to the vector `x` coordinate.
* The multivector is locked (immutable), but may be cloned.
*/
static readonly E1: Geometric2;
/**
* Constructs the basis vector e1.
* Locking the vector prevents mutation.
*/
static e1(lock?: boolean): Geometric2;
/**
* The basis element corresponding to the vector `y` coordinate.
* The multivector is locked (immutable), but may be cloned.
*/
static readonly E2: Geometric2;
/**
* Constructs the basis vector e2.
* Locking the vector prevents mutation.
*/
static e2(lock?: boolean): Geometric2;
/**
*
*/
static fromCartesian(a: number, x: number, y: number, b: number): Geometric2;
static fromBivector(B: Pseudo): Geometric2;
/**
*
*/
static fromSpinor(spinor: SpinorE2): Geometric2;
/**
*
*/
static fromVector(v: VectorE2): Geometric2;
/**
* The identity element for addition, `0`.
* The multivector is locked.
*/
static readonly PSEUDO: Geometric2;
/**
*
*/
static I(lock?: boolean): Geometric2;
/**
* A + α * (B - A)
*/
static lerp(A: GeometricE2, B: GeometricE2, α: number): Geometric2;
/**
* The identity element for multiplication, `1`.
* The multivector is locked (immutable), but may be cloned.
*/
static readonly ONE: Geometric2;
/**
*
*/
static one(lock?: boolean): Geometric2;
/**
* Computes the rotor that rotates vector a to vector b.
*/
static rotorFromDirections(a: VectorE2, b: VectorE2): Geometric2;
/**
*
*/
static pseudo(β: number): Geometric2;
/**
*
*/
static scalar(α: number): Geometric2;
/**
*
*/
static vector(x: number, y: number): Geometric2;
/**
* The identity element for addition, `0`.
* The multivector is locked.
*/
static readonly ZERO: Geometric2;
/**
*
*/
static zero(lock?: boolean): Geometric2;
}
/**
* @hidden
*/
declare class ModelE2 {
/**
* The name of the property that designates the attitude.
*/
static PROP_ATTITUDE: string;
/**
* The name of the property that designates the position.
*/
static PROP_POSITION: string;
private _position;
private _attitude;
/**
* * A collection of properties for Rigid Body Modeling. *
** ModelE2 implements Facet required for manipulating a composite object. *
** Constructs a ModelE2 at the origin and with unity attitude. *
*/ constructor(); /** ** The attitude, a unitary spinor. *
*/ get R(): Geometric2; set R(attitude: Geometric2); /** ** The position, a vector. * The vector X designates the center of mass of the body (Physics). * The vector X designates the displacement from the local origin (Computer Graphics). *
*/ get X(): Geometric2; set X(position: Geometric2); } /** * @hidden */ declare class ModelE3 { /** * The name of the property that designates the attitude. */ static readonly PROP_ATTITUDE = "R"; /** * The name of the property that designates the position. */ static readonly PROP_POSITION = "X"; private readonly _position; private readonly _attitude; /** ** A collection of properties for Rigid Body Modeling. *
** ModelE3 implements Facet required for manipulating a composite object. *
** Constructs a ModelE3 at the origin and with unity attitude. *
*/ constructor(); /** ** The attitude, a rotor. *
*/ get R(): Geometric3; set R(attitude: Geometric3); /** ** The position, a vector. *
*/ get X(): Geometric3; set X(position: Geometric3); } /** * @hidden */ declare class ModelFacet extends ModelE3 implements Facet { /** * @default diag(1, 1, 1, 1) */ private matS; private _matM; private _matN; private matR; private matT; /** * The name used for the model matrix in the vertex shader. */ private nameM; /** * The name used for the normal matrix in the vertex shader. */ private nameN; /** ** A collection of properties governing GLSL uniforms for Rigid Body Modeling. *
** In Physics, the composite object may represent a rigid body. * In Computer Graphics, the composite object is a collection of drawing primitives. *
** ModelFacet implements Facet required for manipulating a composite object. *
** Constructs a ModelFacet at the origin and with unity attitude. *
*/ constructor(); /** * Stress (tensor) */ get stress(): Matrix4; set stress(stress: Matrix4); /** * */ get matrix(): Matrix4; set matrix(unused: Matrix4); /** * The name of the uniform variable in the vertex shader that receives the model matrix value. */ get modelMatrixUniformName(): string; set modelMatrixUniformName(name: string); /** * The name of the uniform variable in the vertex shader that receives the normal matrix value. */ get normalMatrixUniformName(): string; set normalMatrixUniformName(name: string); /** * */ setUniforms(visitor: FacetVisitor): void; private updateMatrices; } /** *
* The PerspectiveCamera provides projection matrix and view matrix uniforms to the
* current Material.
*
* The PerspectiveCamera plays the role of a host in the Visitor pattern.
* The FacetVistor will normally be a Material implementation. The accepting
* method is called setUniforms.
*
* * const ambients: Facet[] = [] * * const camera = new EIGHT.PerspectiveCamera() * camera.aspect = canvas.clientWidth / canvas.clientHeight * camera.eye = Geometric3.copyVector(R3.e3) * ambients.push(camera) * * scene.draw(ambients) * *
The camera is initially positioned at e3.
*/ declare class PerspectiveCamera implements Facet, Camera, Prism { /** * */ private P; /** * */ private V; /** * * @param fov The field of view. * @param aspect The aspect is the ratio width / height. * @param near The distance of the near plane from the camera. * @param far The distance of the far plane from the camera. */ constructor(fov?: number, aspect?: number, near?: number, far?: number); /** * Converts from image cube coordinates to world coordinates. * @param imageX The x-coordinate in the image cube. -1 <= x <= +1. * @param imageY The y-coordinate in the image cube. -1 <= y <= +1. * @param imageZ The z-coordinate in the image cube. -1 <= z <= +1. */ imageToWorldCoords(imageX: number, imageY: number, imageZ: number): Geometric3; /** * */ setUniforms(visitor: FacetVisitor): void; /** * The aspect ratio (width / height) of the camera viewport. */ get aspect(): number; set aspect(aspect: number); /** * The position of the camera, a vector. */ get eye(): Geometric3; set eye(eye: Geometric3); /** * The field of view is the (planar) angle (magnitude) in the camera horizontal plane that encloses object that can be seen. * Measured in radians. */ get fov(): number; set fov(value: number); /** * The point that is being looked at. */ get look(): Geometric3; set look(look: Geometric3); /** * The distance to the near plane. */ get near(): number; set near(near: number); /** * The distance to the far plane. */ get far(): number; set far(far: number); /** * The approximate up direction. */ get up(): Geometric3; set up(up: Geometric3); /** * The name of the uniform mat4 variable in the vertex shader that receives the projection matrix value. * The default name is `uProjection`. */ get projectionMatrixUniformName(): string; set projectionMatrixUniformName(name: string); get projectionMatrix(): Matrix4; /** * The name of the uniform mat4 variable in the vertex shader that receives the view matrix value. * The default name is `uView`. */ get viewMatrixUniformName(): string; set viewMatrixUniformName(name: string); get viewMatrix(): Matrix4; } /** * @hidden */ declare function perspectiveMatrix(fov: number, aspect: number, near: number, far: number, matrix?: Matrix4): Matrix4; /** * @hidden */ declare class PerspectiveTransform implements Facet { /** * */ private _aspect; /** * */ private _fov; /** * */ private _near; /** * */ private _far; /** * */ matrix: Matrix4; /** * */ private matrixName; /** * */ constructor(fov?: number, aspect?: number, near?: number, far?: number); /** * The aspect ratio (width / height) of the camera viewport. */ get aspect(): number; set aspect(aspect: number); /** * The field of view is the (planar) angle (magnitude) in the camera horizontal plane that encloses object that can be seen. * Measured in radians. */ get fov(): number; set fov(fov: number); /** * The distance to the near plane. */ get near(): number; set near(near: number); /** * The distance to the far plane. */ get far(): number; set far(far: number); /** * */ setUniforms(visitor: FacetVisitor): void; /** * The name of the uniform mat4 variable in the vertex shader that receives the projection matrix value. * The default name is `uProjection`. */ get projectionMatrixUniformName(): string; set projectionMatrixUniformName(name: string); /** * Converts from image cube coordinates to camera coordinates. * This method performs the inverse of the perspective transformation. */ imageToCameraCoords(x: number, y: number, z: number): number[]; /** * */ private refreshMatrix; } /** * @hidden */ declare class PointSizeFacet implements Facet { /** * */ pointSize: number; /** * */ constructor(pointSize?: number); /** * */ setUniforms(visitor: FacetVisitor): void; } /** * @hidden */ declare class ReflectionFacetE2 implements Facet { /** * The vector perpendicular to the (hyper-)plane of reflection. */ _normal: Vector2; /** * */ private matrix; private name; /** * @param name The name of the uniform variable. */ constructor(name: string); /** * */ get normal(): Vector2; set normal(unused: Vector2); /** * */ setUniforms(visitor: FacetVisitor): void; } /** * @hidden */ declare class ReflectionFacetE3 implements Facet { /** * The vector perpendicular to the (hyper-)plane of reflection. */ _normal: Geometric3; private matrix; private name; /** * @param name The name of the uniform variable. */ constructor(name: string); get normal(): Geometric3; set normal(unused: Geometric3); setUniforms(visitor: FacetVisitor): void; } /** * Updates a uniform vec3 shader parameter from a VectorE3. * Using a VectorE3 makes assignment easier, which is the dominant use case. * @hidden */ declare class Vector3Facet implements Facet { /** * Hide the name to provide some degree of safety. */ private _name; /** * Intentionally provide access to the mutable property. * The value property provides interoperability with other types. */ vector: Vector3; constructor(name: string); get name(): string; set name(value: string); get value(): VectorE3; set value(value: VectorE3); /** * */ setUniforms(visitor: FacetVisitor): void; } /** * @hidden */ declare function viewMatrixFromEyeLookUp(eye: VectorE3, look: VectorE3, up: VectorE3, matrix?: Matrix4): Matrix4; /** * @hidden */ declare class ViewTransform implements Facet { /** * */ private _eye; /** * */ private _look; /** * */ private _up; /** * */ private _matrix; /** * */ private matrixName; /** * */ constructor(); /** * */ cameraToWorldCoords(cameraCoords: number[]): Geometric3; /** * */ setUniforms(visitor: FacetVisitor): void; /** * The name of the uniform mat4 variable in the vertex shader that receives the view matrix value. * The default name is `uView`. */ get viewMatrixUniformName(): string; set viewMatrixUniformName(name: string); /** * The position of the camera, a vector. */ get eye(): Geometric3; set eye(eye: Geometric3); /** * The point that is being looked at. */ get look(): Geometric3; set look(look: Geometric3); /** * The approximate up direction. */ get up(): Geometric3; set up(up: Geometric3); get matrix(): Matrix4; private refreshMatrix; } /** * @hidden */ interface GeometryKey { kind?: "ArrowGeometry" | "BoxGeometry" | "CurveGeometry" | "CylinderGeometry" | "GridGeometry" | "HollowCylinderGeometry" | "SphereGeometry" | "TetrahedronGeometry" | "TurtleGeometry"; } /** * @hidden */ interface GeometryOptions { /** * */ axis?: VectorE3; /** * */ meridian?: VectorE3; /** * A translation from the canonical position. * This is the third and last operation applied to canonical vertex data. */ offset?: VectorE3; /** * A scaling along the standard basis directions from the canonical unit scaling. * This is the first operation applied to canonical vertex data. */ stress?: VectorE3; /** * */ tilt?: SpinorE3; } /** * @hidden */ interface ArrowGeometryOptions extends GeometryOptions, GeometryKey { /** * Defaults to 0.08. */ radiusCone?: number; /** * Defaults to 16. * Minimum is 3. */ thetaSegments?: number; } /** ** A convenience class for creating an arrow. *
** The initial axis unit vector defaults to e2 *
** The cutLine unit vector defaults to e3 *
* @hidden */ declare class ArrowGeometry extends GeometryElements { /** * */ constructor(contextManager: ContextManager, options?: ArrowGeometryOptions, levelUp?: number); /** * */ protected resurrector(levelUp: number): void; /** * */ protected destructor(levelUp: number): void; } /** * Determines how a Geometry will be rendered. */ declare enum GeometryMode { /** * */ POINT = 0, /** * */ WIRE = 1, /** * */ MESH = 2 } /** * The options when creating a BoxGeometry. * @hidden */ interface BoxGeometryOptions extends GeometryOptions, GeometryKey { /** * */ depth?: number; /** * */ height?: number; /** * */ mode?: GeometryMode; /** * */ openBack?: boolean; /** * */ openBase?: boolean; /** * */ openFront?: boolean; /** * */ openLeft?: boolean; /** * */ openRight?: boolean; /** * */ openCap?: boolean; /** * */ width?: number; } /** * A convenience class for creating a BoxGeometry. * @hidden */ declare class BoxGeometry extends GeometryElements { /** * */ constructor(contextManager: ContextManager, options?: BoxGeometryOptions, levelUp?: number); /** * */ protected resurrector(levelUp: number): void; /** * */ protected destructor(levelUp: number): void; } /** * Determines how a Curve will be rendered. */ declare enum CurveMode { /** * */ POINTS = 0, /** * */ LINES = 1 } /** * */ interface CurveGeometryOptions extends GeometryOptions, GeometryKey { /** * A parametric function determining the positions of points on the curve. * * @default () => (u, 0) */ aPosition?: (u: number) => VectorE3; /** * */ aColor?: (u: number) => { r: number; g: number; b: number; }; /** * @default LINES */ mode?: CurveMode; /** * @default 0 */ uMin?: number; /** * @default 1 */ uMax?: number; /** * @default 1 */ uSegments?: number; } /** * A Geometry for representing functions of one scalar parameter. */ declare class CurveGeometry extends GeometryElements { constructor(contextManager: ContextManager, options?: CurveGeometryOptions, levelUp?: number); /** * */ protected resurrector(levelUp: number): void; /** * */ protected destructor(levelUp: number): void; } /** * @hidden */ interface CylinderGeometryOptions extends GeometryOptions, GeometryKey { /** * */ heightSegments?: number; /** * */ length?: number; /** * */ mode?: GeometryMode; /** * */ openBase?: boolean; /** * */ openCap?: boolean; /** * */ openWall?: boolean; /** * */ radius?: number; /** * */ thetaSegments?: number; } /** * A geometry for a Cylinder. * @hidden */ declare class CylinderGeometry extends GeometryElements { /** * */ constructor(contextManager: ContextManager, options?: CylinderGeometryOptions, levelUp?: number); /** * */ protected resurrector(levelUp: number): void; /** * */ protected destructor(levelUp: number): void; } /** * @hidden */ interface GridGeometryOptions extends GeometryOptions, GeometryKey { /** * A parametric function determining the vertex positions. */ aPosition?: (u: number, v: number) => VectorE3; /** * A parametric function determining the vertex normals. */ aNormal?: (u: number, v: number) => VectorE3; /** * A parametric function determining the vertex colors. */ aColor?: (u: number, v: number) => { r: number; g: number; b: number; }; /** * A parametric function determining the vertex colors. */ aCoords?: (u: number, v: number) => { u: number; v: number; }; /** * @default WIRE */ mode?: GeometryMode; /** * @default 0 */ uMin?: number; /** * @default 1 */ uMax?: number; /** * @default 1 */ uSegments?: number; /** * */ uClosed?: boolean; /** * @default 0 */ vMin?: number; /** * @default 1 */ vMax?: number; /** * @default 1 */ vSegments?: number; /** * */ vClosed?: boolean; } /** * A Geometry for representing functions of two scalar parameters. * @hidden */ declare class GridGeometry extends GeometryElements { /** * */ constructor(contextManager: ContextManager, options?: GridGeometryOptions, levelUp?: number); /** * */ protected resurrector(levelUp: number): void; /** * */ protected destructor(levelUp: number): void; } /** * The common low values for a Simplex. * @hidden */ declare enum SimplexMode { EMPTY = -1, POINT = 0, LINE = 1, TRIANGLE = 2, TETRAHEDRON = 3, FIVE_CELL = 4 } /** * @hidden */ declare class Simplex { vertices: Vertex[]; constructor(k: SimplexMode); get k(): SimplexMode; static indices(simplex: Simplex): number[]; private static boundaryMap; private static subdivideMap; static boundary(simplices: Simplex[], count?: number): Simplex[]; static subdivide(simplices: Simplex[], count?: number): Simplex[]; /** * Copies the attributes onto all vertices of the simplex. */ static setAttributeValues(attributes: { [name: string]: VectorN
* this ⟼ this + α * spinor
*
* this ⟼ a + b
*
* this ⟼ copy(source)
*
α.
*
* @param α The scalar to be copied.
*/
copyScalar(α: number): Spinor3;
/**
* Intentionally undocumented.
*/
copySpinor(s: SpinorE3): Spinor3;
/**
* Intentionally undocumented.
*/
copyVector(vector: VectorE3): Spinor3;
/**
*
* this ⟼ this / s
*
* this ⟼ a / b
*
* this ⟼ this / α
*
this ⟼ ethis
*
* @returns exp(this)
*/
exp(): this;
getComponent(index: number): number;
/**
*
* this ⟼ conj(this) / quad(this)
*
* this ⟼ this + α * (target - this)
*
* this ⟼ a + α * (b - a)
*
* @param a * @param b * @param α */ lerp2(a: SpinorE3, b: SpinorE3, α: number): this; /** * this ⟼ log(this) */ log(): this; /** *
* Computes the square root of the squared norm. *
** This method does not change this multivector. *
*/ magnitude(): number; /** * Intentionally undocumented. */ magnitudeSansUnits(): number; /** *
* this ⟼ this * rhs
*
* this ⟼ a * b
*
* this ⟼ sqrt(this * conj(this))
*
* this ⟼ this / magnitude(this)
*
* this ⟼ this * conj(this)
*
* This method does not change this multivector. *
*/ squaredNorm(): number; /** * Intentionally undocumented. */ squaredNormSansUnits(): number; /** * @param σ */ stress(σ: VectorE3): this; rco(rhs: SpinorE3): this; rco2(a: SpinorE3, b: SpinorE3): this; /** *
* this = (w, B) ⟼ (w, -B)
*
* this = ⟼ R * this * rev(R)
*
* Computes a rotor, R, from two vectors, where * R = (abs(b) * abs(a) + b * a) / sqrt(2 * (quad(b) * quad(a) + abs(b) * abs(a) * b << a)) *
* * @param a The from vector. * @param b The to vector. * @return The rotor representing a rotation from a to b. */ rotorFromDirections(a: VectorE3, b: VectorE3): this; /** *
* this = ⟼ exp(- B * θ / 2)
*
* this ⟼ this * α
*
* this ⟼ this - s * α
*
* this ⟼ a - b
*
* this ⟼ a * b
*
* this ⟼ a ^ b
*
* Computes a unit spinor with a random direction. *
*/ static random(): Spinor3; /** * Computes the rotor that rotates vectora to vector b.
*
* @param a The from vector.
* @param b The to vector.
*/
static rotorFromDirections(a: VectorE3, b: VectorE3): Spinor3;
/**
* Constructs a new Spinor3 from coordinates.
* The returned spinor is not locked.
* The returned spinor is not modified.
* @param yz The coordinate corresponding to the e2e3 basis bivector.
* @param zx The coordinate corresponding to the e3e1 basis bivector.
* @param xy The coordinate corresponding to the e1e2 basis bivector.
* @param a The coordinate corresponding to the 1 basis scalar.
*/
static spinor(yz: number, zx: number, xy: number, a: number): Spinor3;
/**
* A spinor with the value of 1.
* The spinor is not modified (initially).
* The spinor is not locked (initially).
* @deprecated This value may become locked in future. User Spinor3.spinor(0, 0, 0, 1) instead.
*/
static readonly one: Spinor3;
/**
* @param a
* @param b
*/
static wedge(a: VectorE3, b: VectorE3): Spinor3;
/**
* A spinor with the value of 0.
* The spinor is not modified (initially).
* The spinor is not locked (initially).
* @deprecated This value may become locked in future. User Spinor3.spinor(0, 0, 0, 0) instead.
*/
static readonly zero: Spinor3;
}
/**
* @hidden
*/
interface SphereGeometryOptions extends GeometryOptions, GeometryKey {
azimuthSegments?: number;
azimuthStart?: number;
azimuthLength?: number;
elevationSegments?: number;
elevationStart?: number;
elevationLength?: number;
mode?: GeometryMode;
radius?: number;
}
/**
* A convenience class for creating sphere geometry elements.
* @hidden
*/
declare class SphereGeometry extends GeometryElements {
/**
*
*/
constructor(contextManager: ContextManager, options?: SphereGeometryOptions, levelUp?: number);
/**
*
*/
protected resurrector(levelUp: number): void;
/**
*
*/
protected destructor(levelUp: number): void;
}
/**
* @hidden
*/
interface TetrahedronGeometryOptions extends GeometryOptions, GeometryKey {
radius?: number;
}
/**
* A convenience class for creating a tetrahedron geometry.
* @hidden
*/
declare class TetrahedronGeometry extends GeometryElements {
/**
*
*/
constructor(contextManager: ContextManager, options?: TetrahedronGeometryOptions, levelUp?: number);
/**
*
*/
protected resurrector(levelUp: number): void;
/**
*
*/
protected destructor(levelUp: number): void;
}
/**
*
*/
interface TextureLoaderOptions {
crossOrigin?: string;
}
/**
* A utility for loading Texture resources from a URL.
*/
declare class TextureLoader {
private contextManager;
/**
* @param contextManager
*/
constructor(contextManager: ContextManager);
/**
*
* @param url The Uniform Resource Locator of the image.
* @param options
*/
imageTexture(url: string, options?: TextureLoaderOptions): PromiseContextManager to subscribe to for WebGL rendering context events.
* @param levelUp The level of this class in the implementation inheritance hierarchy.
*/
constructor(vertexShaderSrc: string, fragmentShaderSrc: string, attribs: string[], contextManager: ContextManager, levelUp?: number);
/**
*
*/
protected resurrector(levelUp: number): void;
/**
*
*/
protected destructor(levelUp: number): void;
/**
*
*/
contextGain(): void;
/**
*
*/
contextLost(): void;
/**
*
*/
contextFree(): void;
/**
*
*/
get vertexShaderSrc(): string;
/**
*
*/
get fragmentShaderSrc(): string;
/**
*
*/
get attributeNames(): string[];
set attributeNames(unused: string[]);
/**
* Convenience method for dereferencing the name to an attribute location, followed by enabling the attribute.
*/
enableAttrib(indexOrName: number | string): void;
/**
*
*/
enableAttribs(): void;
/**
*
*/
disableAttrib(indexOrName: number | string): void;
/**
*
*/
disableAttribs(): void;
attrib(name: string, value: VertexBuffer, size: number, normalized?: boolean, stride?: number, offset?: number): Material;
getAttrib(indexOrName: number | string): Attrib;
/**
* Returns the location (index) of the attribute with the specified name.
* Returns -1 if the name does not correspond to an attribute.
*/
getAttribLocation(name: string): number;
/**
* Returns a Uniform object corresponding to the uniform
* parameter of the same name in the shader code. If a uniform parameter of the specified name
* does not exist, this method returns undefined (void 0).
*/
getUniform(name: string): Uniform;
/**
*
* Determines whether a uniform with the specified name exists in the WebGLProgram.
*
this ⟼ this + α * spinor
*
* @param spinor
* @param α
* @return this
*/
add(spinor: SpinorE2, α?: number): Spinor2;
/**
*
* this ⟼ a + b
*
* @param a
* @param b
* @return this
*/
add2(a: SpinorE2, b: SpinorE2): Spinor2;
/**
* Intentionally undocumented.
*/
addPseudo(β: number): Spinor2;
/**
* this ⟼ this + α
*
* @param α
* @return this
*/
addScalar(α: number): this;
/**
* arg(A) = grade(log(A), 2)
*/
arg(): Spinor2;
/**
*
*/
approx(n: number): this;
/**
* @return A copy of this
*/
clone(): Spinor2;
/**
* The Clifford conjugate.
* The multiplier for the grade x is (-1) raised to the power x * (x + 1) / 2
* The pattern of grades is +--++--+
*
* @returns conj(this)
*/
conj(): this;
/**
*
* this ⟼ copy(spinor)
*
α.
*
* @param α The scalar to be copied.
* @return
*/
copyScalar(α: number): this;
/**
* Intentionally undocumented.
*/
copySpinor(spinor: SpinorE2): this;
/**
* Intentionally undocumented.
*/
copyVector(vector: VectorE2): Spinor2;
cos(): Spinor2;
cosh(): Spinor2;
/**
*
* this ⟼ this / s
*
* this ⟼ a / b
*
* this ⟼ this / α
*
* this ⟼ ethis
*
this
*/
exp(): this;
/**
*
* this ⟼ conj(this) / quad(this)
*
this
*/
inv(): this;
/**
*
*/
isOne(): boolean;
/**
*
*/
isZero(): boolean;
lco(rhs: SpinorE2): this;
lco2(a: SpinorE2, b: SpinorE2): this;
/**
*
* this ⟼ this + α * (target - this)
*
* this ⟼ a + α * (b - a)
*
* * @param a * @param b * @param α */ lerp2(a: SpinorE2, b: SpinorE2, α: number): this; /** * this ⟼ log(this) * * @returns log(this) */ log(): Spinor2; /** *
* Computes the square root of the squared norm. *
** This method does not change this spinor. *
*/ magnitude(): number; /** *
* this ⟼ this * s
*
* this ⟼ a * b
*
this
*/
neg(): this;
/**
*
* this ⟼ sqrt(this * conj(this))
*
this
*/
norm(): this;
/**
*
* this ⟼ this / magnitude(this)
*
this
*/
normalize(): this;
/**
* Sets this spinor to the identity element for multiplication, 1.
* @return {Spinor2} this
*/
one(): this;
pow(): Spinor2;
/**
* @returns The square of the magnitude.
*/
quaditude(): number;
sin(): Spinor2;
sinh(): Spinor2;
/**
*
* this ⟼ this * conj(this)
*
this
*/
squaredNorm(): this;
rco(rhs: SpinorE2): Spinor2;
rco2(a: SpinorE2, b: SpinorE2): Spinor2;
/**
*
* this = (w, B) ⟼ (w, -B)
*
this
*/
rev(): this;
/**
* Sets this Spinor to the value of its reflection in the plane orthogonal to n.
* The geometric formula for bivector reflection is B' = n * B * n.
*/
reflect(n: VectorE2): this;
/**
*
* this = ⟼ rotor * this * rev(rotor)
*
this
*/
rotate(rotor: SpinorE2): this;
/**
*
* Sets this multivector to a rotation from vector a to vector b.
*
this = ⟼ exp(- B * θ / 2)
*
* @param B
* @param θ
* @returns this
*/
rotorFromGeneratorAngle(B: SpinorE2, θ: number): this;
rotorFromVectorToVector(a: VectorE2, b: VectorE2): Spinor2;
scp(rhs: SpinorE2): Spinor2;
scp2(a: SpinorE2, b: SpinorE2): Spinor2;
/**
*
* this ⟼ this * α
*
* this ⟼ this - s * α
*
* this ⟼ a - b
*
* this ⟼ a * b
*
* this ⟼ σ * thisT
*
this
*/
neg(): this;
/**
* @param position
*/
distanceTo(position: VectorE1): number;
dot(v: VectorE1): number;
/**
* Computes the square root of the squared norm.
*/
magnitude(): number;
normalize(): Vector1;
mul2(a: VectorE1, b: VectorE1): this;
quad(): this;
squaredNorm(): number;
quadranceTo(position: VectorE1): number;
reflect(n: VectorE1): Vector1;
reflection(n: VectorE0): Vector1;
rotate(rotor: SpinorE1): Vector1;
/**
* this ⟼ this + α * (v - this)
* @param v
* @param α
*/
lerp(v: VectorE1, α: number): this;
/**
*
* this ⟼ a + α * (b - a)
*
this
*/
applyMatrix(σ: Matrix4): Vector4;
/**
* @param n
*/
approx(n: number): Vector4;
clone(): Vector4;
copy(v: VectorE4): this;
divByScalar(α: number): this;
lerp(target: VectorE4, α: number): this;
lerp2(a: VectorE4, b: VectorE4, α: number): Vector4;
neg(): this;
scale(α: number): this;
reflect(n: VectorE4): this;
rotate(rotor: SpinorE4): this;
stress(σ: VectorE4): this;
sub(v: VectorE4, α: number): this;
sub2(a: VectorE4, b: VectorE4): this;
magnitude(): number;
squaredNorm(): number;
toExponential(fractionDigits?: number): string;
toFixed(fractionDigits?: number): string;
toPrecision(precision?: number): string;
toString(radix?: number): string;
zero(): Vector4;
}
/**
* @hidden
*/
interface WindowAnimationRunner {
/**
* @method start
* @return {void}
*/
start(): void;
/**
* @method stop
* @return {void}
*/
stop(): void;
/**
* @method reset
* @return {void}
*/
reset(): void;
/**
* @method lap
* @return {void}
*/
lap(): void;
/**
* @property time
* @type number
* @readOnly
*/
time: number;
/**
* @property isRunning
* @type boolean
* @readOnly
*/
isRunning: boolean;
/**
* @property isPaused
* @type boolean
* @readOnly
*/
isPaused: boolean;
}
/**
* @hidden
*/
interface WindowAnimationOptions {
setUp?: () => void;
tearDown?: (animateException: any) => void;
terminate?: (time: number) => boolean;
window?: BrowserWindow;
}
/**
* @hidden
*/
declare function animation(animate: (time: number) => void, options?: WindowAnimationOptions): WindowAnimationRunner;
/**
* @hidden
*/
declare function getCanvasElementById(elementId: string, dom?: Document): HTMLCanvasElement;
/**
*
*/
interface ArrowOptions {
/**
*
*/
axis?: VectorE3;
/**
*
*/
color?: {
r: number;
g: number;
b: number;
};
/**
* The height of the cone that constitutes the arrow head.
* Default is 0.20
*/
heightCone?: number;
/**
* The height of the cylinder that constitutes the arrow tail.
* Default is 0.80
*/
heightShaft?: number;
/**
* length = heightCone + heightShaft
*/
length?: number;
/**
*
*/
meridian?: VectorE3;
/**
*
*/
mode?: "mesh" | "wire" | "point";
/**
*
*/
offset?: VectorE3;
/**
* The radius of the cone that constitutes the arrow head.
* Default is 0.08
*/
radiusCone?: number;
/**
* The radius of the cylinder that constitutes the arrow tail.
* Default is 0.01
*/
radiusShaft?: number;
/**
* The number of segments, in the azimuth plane, used to construct the arrow.
* Default is 16.
* Minimum is 3.
*/
thetaSegments?: number;
/**
*
*/
tilt?: SpinorE3;
textured?: boolean;
transparent?: boolean;
emissive?: boolean;
colored?: boolean;
reflective?: boolean;
}
/**
* A Mesh in the form of an arrow that may be used to represent a vector quantity.
*/
declare class Arrow extends Mesh* A parametric function determining the positions of points on the curve. *
** umin <= u <= umax *
* * @default (u: number) => u * e1 + v * e2 */ aPosition?: (u: number) => VectorE3; /** * */ aColor?: (u: number) => { r: number; g: number; b: number; }; /** * */ aOpacity?: (u: number) => number; /** * */ color?: { r: number; g: number; b: number; }; /** * Specifies the required Geometric Primitive Type. * Implementations may choose the nearest type. * * @default LINES */ mode?: CurveMode; /** * * @default -0.5 */ uMin?: number; /** * * @default +0.5 */ uMax?: number; /** * The number of segments for the u coordinate. * * @default 1 */ uSegments?: number; } /** * A 3D visual representation of a discrete parameterized line. */ declare class Curve extends Mesh* A parametric function determining the positions of points in the grid. *
** umin <= u <= umax *
** vmin <= v <= vmax *
* * @default (u: number, v: number) => u * e1 + v * e2 */ aPosition?: (u: number, v: number) => VectorE3; /** * * @default (u: number, v: number) => e3 */ aNormal?: (u: number, v: number) => VectorE3; /** * */ axis?: VectorE3; /** * */ aColor?: (u: number, v: number) => { r: number; g: number; b: number; }; /** * */ color?: { r: number; g: number; b: number; }; /** * */ mode?: GeometryMode; /** * The minimum value of the u coordinate. */ uMin?: number; /** * The maximum value of the u coordinate. */ uMax?: number; /** * The number of segments for the u coordinate. */ uSegments?: number; /** * The minimum value of the v coordinate. */ vMin?: number; /** * The maximum value of the v coordinate. */ vMax?: number; /** * The number of segments for the v coordinate. */ vSegments?: number; } /** * A 3D visual representation of a a discrete parameterized surface. */ declare class Grid extends Mesh
* Records the position and attitude history of a Mesh allowing the
* Mesh to be drawn in multiple historical configurations.
*
*
* This class is refererce counted because it maintains a reference to a Mesh.
* You should call the release method when the trail is no longer required.
*