declarations
Version:
[](https://www.npmjs.com/package/declarations)
1,479 lines (1,225 loc) • 219 kB
TypeScript
// Type definitions for three.js r80
// Project: http://mrdoob.github.com/three.js/
// Definitions by: Kon <http://phyzkit.net/>, Satoru Kimura <https://github.com/gyohk>, Florent Poujol <https://github.com/florentpoujol>, SereznoKot <https://github.com/SereznoKot>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare namespace THREE {
export const REVISION: string;
// https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent.button
export enum MOUSE { LEFT, MIDDLE, RIGHT }
// GL STATE CONSTANTS
export enum CullFace { }
export const CullFaceNone: CullFace;
export const CullFaceBack: CullFace;
export const CullFaceFront: CullFace;
export const CullFaceFrontBack: CullFace;
export enum FrontFaceDirection { }
export const FrontFaceDirectionCW: FrontFaceDirection;
export const FrontFaceDirectionCCW: FrontFaceDirection;
// Shadowing Type
export enum ShadowMapType { }
export const BasicShadowMap: ShadowMapType;
export const PCFShadowMap: ShadowMapType;
export const PCFSoftShadowMap: ShadowMapType;
// MATERIAL CONSTANTS
// side
export enum Side { }
export const FrontSide: Side;
export const BackSide: Side;
export const DoubleSide: Side;
// shading
export enum Shading { }
export const FlatShading: Shading;
export const SmoothShading: Shading;
// colors
export enum Colors { }
export const NoColors: Colors;
export const FaceColors: Colors;
export const VertexColors: Colors;
// blending modes
export enum Blending { }
export const NoBlending: Blending;
export const NormalBlending: Blending;
export const AdditiveBlending: Blending;
export const SubtractiveBlending: Blending;
export const MultiplyBlending: Blending;
export const CustomBlending: Blending;
// custom blending equations
// (numbers start from 100 not to clash with other
// mappings to OpenGL constants defined in Texture.js)
export enum BlendingEquation { }
export const AddEquation: BlendingEquation;
export const SubtractEquation: BlendingEquation;
export const ReverseSubtractEquation: BlendingEquation;
export const MinEquation: BlendingEquation;
export const MaxEquation: BlendingEquation;
// custom blending destination factors
export enum BlendingDstFactor { }
export const ZeroFactor: BlendingDstFactor;
export const OneFactor: BlendingDstFactor;
export const SrcColorFactor: BlendingDstFactor;
export const OneMinusSrcColorFactor: BlendingDstFactor;
export const SrcAlphaFactor: BlendingDstFactor;
export const OneMinusSrcAlphaFactor: BlendingDstFactor;
export const DstAlphaFactor: BlendingDstFactor;
export const OneMinusDstAlphaFactor: BlendingDstFactor;
// custom blending src factors
export enum BlendingSrcFactor { }
export const DstColorFactor: BlendingSrcFactor;
export const OneMinusDstColorFactor: BlendingSrcFactor;
export const SrcAlphaSaturateFactor: BlendingSrcFactor;
// depth modes
export enum DepthModes { }
export const NeverDepth: DepthModes;
export const AlwaysDepth: DepthModes;
export const LessDepth: DepthModes;
export const LessEqualDepth: DepthModes;
export const EqualDepth: DepthModes;
export const GreaterEqualDepth: DepthModes;
export const GreaterDepth: DepthModes;
export const NotEqualDepth: DepthModes;
// TEXTURE CONSTANTS
// Operations
export enum Combine { }
export const MultiplyOperation: Combine;
export const MixOperation: Combine;
export const AddOperation: Combine;
// Tone Mapping modes
export enum ToneMapping { }
export const NoToneMapping: ToneMapping;
export const LinearToneMapping: ToneMapping;
export const ReinhardToneMapping: ToneMapping;
export const Uncharted2ToneMapping: ToneMapping;
export const CineonToneMapping: ToneMapping;
// Mapping modes
export enum Mapping { }
export const UVMapping: Mapping;
export const CubeReflectionMapping: Mapping;
export const CubeRefractionMapping: Mapping;
export const EquirectangularReflectionMapping: Mapping;
export const EquirectangularRefractionMapping: Mapping;
export const SphericalReflectionMapping: Mapping;
export const CubeUVReflectionMapping: Mapping;
export const CubeUVRefractionMapping: Mapping;
// Wrapping modes
export enum Wrapping { }
export const RepeatWrapping: Wrapping;
export const ClampToEdgeWrapping: Wrapping;
export const MirroredRepeatWrapping: Wrapping;
// Filters
export enum TextureFilter { }
export const NearestFilter: TextureFilter;
export const NearestMipMapNearestFilter: TextureFilter;
export const NearestMipMapLinearFilter: TextureFilter;
export const LinearFilter: TextureFilter;
export const LinearMipMapNearestFilter: TextureFilter;
export const LinearMipMapLinearFilter: TextureFilter;
// Data types
export enum TextureDataType { }
export const UnsignedByteType: TextureDataType;
export const ByteType: TextureDataType;
export const ShortType: TextureDataType;
export const UnsignedShortType: TextureDataType;
export const IntType: TextureDataType;
export const UnsignedIntType: TextureDataType;
export const FloatType: TextureDataType;
export const HalfFloatType: TextureDataType;
// Pixel types
export enum PixelType { }
export const UnsignedShort4444Type: PixelType;
export const UnsignedShort5551Type: PixelType;
export const UnsignedShort565Type: PixelType;
export const UnsignedInt248Type: PixelType;
// Pixel formats
export enum PixelFormat { }
export const AlphaFormat: PixelFormat;
export const RGBFormat: PixelFormat;
export const RGBAFormat: PixelFormat;
export const LuminanceFormat: PixelFormat;
export const LuminanceAlphaFormat: PixelFormat;
export const RGBEFormat: PixelFormat;
export const DepthFormat: PixelFormat;
export const DepthStencilFormat: PixelFormat;
// Compressed texture formats
// DDS / ST3C Compressed texture formats
export enum CompressedPixelFormat { }
export const RGB_S3TC_DXT1_Format: CompressedPixelFormat;
export const RGBA_S3TC_DXT1_Format: CompressedPixelFormat;
export const RGBA_S3TC_DXT3_Format: CompressedPixelFormat;
export const RGBA_S3TC_DXT5_Format: CompressedPixelFormat;
// PVRTC compressed texture formats
export const RGB_PVRTC_4BPPV1_Format: CompressedPixelFormat;
export const RGB_PVRTC_2BPPV1_Format: CompressedPixelFormat;
export const RGBA_PVRTC_4BPPV1_Format: CompressedPixelFormat;
export const RGBA_PVRTC_2BPPV1_Format: CompressedPixelFormat;
// ETC compressed texture formats
export const RGB_ETC1_Format: CompressedPixelFormat;
// Loop styles for AnimationAction
export enum AnimationActionLoopStyles { }
export const LoopOnce: AnimationActionLoopStyles;
export const LoopRepeat: AnimationActionLoopStyles;
export const LoopPingPong: AnimationActionLoopStyles;
// Interpolation
export enum InterpolationModes { }
export const InterpolateDiscrete: InterpolationModes;
export const InterpolateLinear: InterpolationModes;
export const InterpolateSmooth: InterpolationModes;
// Interpolant ending modes
export enum InterpolationEndingModes { }
export const ZeroCurvatureEnding: InterpolationEndingModes;
export const ZeroSlopeEnding: InterpolationEndingModes;
export const WrapAroundEnding: InterpolationEndingModes;
// Triangle Draw modes
export enum TrianglesDrawModes { }
export const TrianglesDrawModesMode: TrianglesDrawModes;
export const TriangleStripDrawMode: TrianglesDrawModes;
export const TriangleFanDrawMode: TrianglesDrawModes;
// Texture Encodings
export enum TextureEncoding { }
export const LinearEncoding: TextureEncoding;
export const sRGBEncoding: TextureEncoding;
export const GammaEncoding: TextureEncoding;
export const RGBEEncoding: TextureEncoding;
export const LogLuvEncoding: TextureEncoding;
export const RGBM7Encoding: TextureEncoding;
export const RGBM16Encoding: TextureEncoding;
export const RGBDEncoding: TextureEncoding;
// Depth packing strategies
export enum DepthPackingStrategies { }
export const BasicDepthPacking: DepthPackingStrategies;
export const RGBADepthPacking: DepthPackingStrategies;
// log handlers
export function warn(message?: any, ...optionalParams: any[]): void;
export function error(message?: any, ...optionalParams: any[]): void;
export function log(message?: any, ...optionalParams: any[]): void;
// Animation ////////////////////////////////////////////////////////////////////////////////////////
export class AnimationAction {
loop: boolean;
time: number;
timeScale: number;
weight: number;
repetitions: number;
paused: boolean;
enabled: boolean;
clampWhenFinished: boolean;
zeroSlopeAtStart: boolean;
zeroSlopeAtEnd: boolean;
play(): AnimationAction;
stop(): AnimationAction;
reset(): AnimationAction;
isRunning(): boolean;
startAt(time: number): AnimationAction;
setLoop(mode: boolean, repetitions: number): AnimationAction;
setEffectiveWeight(weight: number): AnimationAction;
getEffectiveWeight(): number;
fadeIn(duration: number): AnimationAction;
fadeOut(duration: number): AnimationAction;
crossFadeFrom(fadeOutAction: AnimationAction, duration: number, warp: boolean): AnimationAction;
crossFadeTo(fadeInAction: AnimationAction, duration: number, warp: boolean): AnimationAction;
stopFading(): AnimationAction;
setEffectiveTimeScale(timeScale: number): AnimationAction;
getEffectiveTimeScale(): number;
setDuration(duration: number): AnimationAction;
syncWith(action: AnimationAction): AnimationAction;
halt(duration: number): AnimationAction;
warp(statTimeScale: number, endTimeScale: number, duration: number): AnimationAction;
stopWarping(): AnimationAction;
getMixer(): AnimationMixer;
getClip(): AnimationClip;
getRoot(): any;
}
export class AnimationClip {
constructor( name?: string, duration?: number, tracks?: KeyframeTrack[] );
name: string;
tracks: KeyframeTrack[];
duration: number;
uuid: string;
results: any[];
resetDuration(): void;
trim(): AnimationClip;
optimize(): AnimationClip;
static CreateFromMorphTargetSequence( name: string, morphTargetSequence: MorphTarget[], fps: number, noLoop: boolean ): AnimationClip;
static findByName( clipArray: AnimationClip, name: string ): AnimationClip;
static CreateClipsFromMorphTargetSequences( morphTargets: MorphTarget[], fps: number, noLoop: boolean ): AnimationClip[];
static parse( json: any ): AnimationClip;
static parseAnimation( animation: any, bones: Bone[], nodeName: string ): AnimationClip;
static toJSON(): any;
}
export class AnimationMixer extends EventDispatcher {
constructor(root: any);
time: number;
timeScale: number;
clipAction(clip: AnimationClip, root?: any): AnimationAction;
existingAction(clip: AnimationClip, root?: any): AnimationAction;
stopAllAction(clip: AnimationClip, root?: any): AnimationMixer;
update(deltaTime: number): AnimationMixer;
getRoot(): any;
uncacheClip(clip: AnimationClip): void;
uncacheRoot(root: any): void;
uncacheAction(clip: AnimationClip, root?: any): void;
}
export class AnimationObjectGroup {
constructor(...args: any[]);
uuid: string;
stats: {
bindingsPerObject: number;
objects: {
total: number;
inUse: number;
}
};
add(...args: any[]): void;
remove(...args: any[]): void;
uncache(...args: any[]): void;
}
export namespace AnimationUtils {
export function arraySlice(array: any, from: number, to: number): any;
export function convertArray(array: any, type: any, forceClone: boolean): any;
export function isTypedArray(object: any): boolean;
export function getKeyFrameOrder(times: number): number[];
export function sortedArray(values: any[], stride: number, order: number[]): any[];
export function flattenJSON(jsonKeys: string[], times: any[], values: any[], valuePropertyName: string): void;
}
export class KeyframeTrack {
constructor(name: string, times: any[], values: any[], interpolation: InterpolationModes);
name: string;
times: any[];
values: any[];
ValueTypeName: string;
TimeBufferType: Float32Array;
ValueBufferType: Float32Array;
DefaultInterpolation: InterpolationModes;
InterpolantFactoryMethodDiscrete(result: any): DiscreteInterpolant;
InterpolantFactoryMethodLinear(result: any): LinearInterpolant;
InterpolantFactoryMethodSmooth(result: any): CubicInterpolant;
setInterpolation(interpolation: InterpolationModes): void;
getInterpolation(): InterpolationModes;
getValuesize(): number;
shift( timeOffset: number ): KeyframeTrack;
scale( timeScale: number ): KeyframeTrack;
trim( startTime: number, endTime: number ): KeyframeTrack;
validate(): boolean;
optimize(): KeyframeTrack;
static parse(json: any): KeyframeTrack;
static toJSON(track: KeyframeTrack): any;
}
export class PropertyBinding {
constructor(rootNode: any, path: string, parsedPath?: any);
path: string;
parsedPath: any;
node: any;
rootNode: any;
getValue(targetArray: any, offset: number): any;
setValue(sourceArray: any, offset: number): void;
bind(): void;
unbind(): void;
BindingType: { [bindingType: string]: number };
Versioning: { [versioning: string]: number };
GetterByBindingType: Function[];
SetterByBindingTypeAndVersioning: Array<Function[]>;
static create(root: any, path: any, parsedPath?: any): PropertyBinding|PropertyBinding.Composite;
static parseTrackName(trackName: string): any;
static findNode(root: any, nodeName: string): any;
}
export namespace PropertyBinding {
export class Composite {
constructor(targetGroup: any, path: any, parsedPath?: any);
getValue(array: any, offset: number): any;
setValue(array: any, offset: number): void;
bind(): void;
unbind(): void;
}
}
export class PropertyMixer {
constructor(binding: any, typeName: string, valueSize: number);
binding: any;
valueSize: number;
buffer: any;
cumulativeWeight: number;
useCount: number;
referenceCount: number;
accumulate(accuIndex: number, weight: number): void;
apply(accuIndex: number): void;
saveOriginalState(): void;
restoreOriginalState(): void;
}
export class BooleanKeyframeTrack extends KeyframeTrack {
constructor(name: string, times: any[], values: any[]);
}
export class ColorKeyframeTrack extends KeyframeTrack {
constructor(name: string, times: any[], values: any[], interpolation: InterpolationModes);
}
export class NumberKeyframeTrack extends KeyframeTrack {
constructor(name: string, times: any[], values: any[], interpolation: InterpolationModes);
}
export class QuaternionKeyframeTrack extends KeyframeTrack {
constructor(name: string, times: any[], values: any[], interpolation: InterpolationModes);
}
export class StringKeyframeTrack extends KeyframeTrack {
constructor(name: string, times: any[], values: any[], interpolation: InterpolationModes);
}
export class VectorKeyframeTrack extends KeyframeTrack {
constructor(name: string, times: any[], values: any[], interpolation: InterpolationModes);
}
// Cameras ////////////////////////////////////////////////////////////////////////////////////////
/**
* Abstract base class for cameras. This class should always be inherited when you build a new camera.
*/
export class Camera extends Object3D {
/**
* This constructor sets following properties to the correct type: matrixWorldInverse, projectionMatrix and projectionMatrixInverse.
*/
constructor();
/**
* This is the inverse of matrixWorld. MatrixWorld contains the Matrix which has the world transform of the Camera.
*/
matrixWorldInverse: Matrix4;
/**
* This is the matrix which contains the projection.
*/
projectionMatrix: Matrix4;
getWorldDirection(optionalTarget?: Vector3): Vector3;
/**
* This make the camera look at the vector position in local space.
* @param vector point to look at
*/
lookAt(vector: Vector3): void;
clone(): Camera;
copy(camera?: Camera): Camera;
}
export class CubeCamera extends Object3D {
constructor(near?: number, far?: number, cubeResolution?: number);
renderTarget: WebGLRenderTargetCube;
updateCubeMap(renderer: Renderer, scene: Scene): void;
}
/**
* Camera with orthographic projection
*
* @example
* var camera = new THREE.OrthographicCamera( width / - 2, width / 2, height / 2, height / - 2, 1, 1000 );
* scene.add( camera );
*
* @see <a href="https://github.com/mrdoob/three.js/blob/master/src/cameras/OrthographicCamera.js">src/cameras/OrthographicCamera.js</a>
*/
export class OrthographicCamera extends Camera {
/**
* @param left Camera frustum left plane.
* @param right Camera frustum right plane.
* @param top Camera frustum top plane.
* @param bottom Camera frustum bottom plane.
* @param near Camera frustum near plane.
* @param far Camera frustum far plane.
*/
constructor(left: number, right: number, top: number, bottom: number, near?: number, far?: number);
zoom: number;
view: {
fullWidth: number,
fullHeight: number,
offsetX: number,
offsetY: number,
width: number,
height: number
};
/**
* Camera frustum left plane.
*/
left: number;
/**
* Camera frustum right plane.
*/
right: number;
/**
* Camera frustum top plane.
*/
top: number;
/**
* Camera frustum bottom plane.
*/
bottom: number;
/**
* Camera frustum near plane.
*/
near: number;
/**
* Camera frustum far plane.
*/
far: number;
/**
* Updates the camera projection matrix. Must be called after change of parameters.
*/
updateProjectionMatrix(): void;
setViewOffset(fullWidth: number, fullHeight: number, offsetX: number, offsetY: number, width: number, height: number): void;
clearViewOffset(): void;
clone(): OrthographicCamera;
copy(source: OrthographicCamera): OrthographicCamera;
toJSON(meta?: any): any;
}
/**
* Camera with perspective projection.
*
* # example
* var camera = new THREE.PerspectiveCamera( 45, width / height, 1, 1000 );
* scene.add( camera );
*
* @source https://github.com/mrdoob/three.js/blob/master/src/cameras/PerspectiveCamera.js
*/
export class PerspectiveCamera extends Camera {
/**
* @param fov Camera frustum vertical field of view. Default value is 50.
* @param aspect Camera frustum aspect ratio. Default value is 1.
* @param near Camera frustum near plane. Default value is 0.1.
* @param far Camera frustum far plane. Default value is 2000.
*/
constructor(fov?: number, aspect?: number, near?: number, far?: number);
zoom: number;
/**
* Camera frustum vertical field of view, from bottom to top of view, in degrees.
*/
fov: number;
/**
* Camera frustum aspect ratio, window width divided by window height.
*/
aspect: number;
/**
* Camera frustum near plane.
*/
near: number;
/**
* Camera frustum far plane.
*/
far: number;
focus: number;
view: {
fullWidth: number,
fullHeight: number,
offsetX: number,
offsetY: number,
width: number,
height: number
};
filmGauge: number;
filmOffset: number;
setFocalLength(focalLength: number): void;
getFocalLength(): number;
getEffectiveFOV(): number;
getFilmWidth(): number;
getFilmHeight(): number;
/**
* Sets an offset in a larger frustum. This is useful for multi-window or multi-monitor/multi-machine setups.
* For example, if you have 3x2 monitors and each monitor is 1920x1080 and the monitors are in grid like this:
*
* +---+---+---+
* | A | B | C |
* +---+---+---+
* | D | E | F |
* +---+---+---+
*
* then for each monitor you would call it like this:
*
* var w = 1920;
* var h = 1080;
* var fullWidth = w * 3;
* var fullHeight = h * 2;
*
* // A
* camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 0, w, h );
* // B
* camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 0, w, h );
* // C
* camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 0, w, h );
* // D
* camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 1, w, h );
* // E
* camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 1, w, h );
* // F
* camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 1, w, h ); Note there is no reason monitors have to be the same size or in a grid.
*
* @param fullWidth full width of multiview setup
* @param fullHeight full height of multiview setup
* @param x horizontal offset of subcamera
* @param y vertical offset of subcamera
* @param width width of subcamera
* @param height height of subcamera
*/
setViewOffset(fullWidth: number, fullHeight: number, x: number, y: number, width: number, height: number): void;
clearViewOffset(): void;
/**
* Updates the camera projection matrix. Must be called after change of parameters.
*/
updateProjectionMatrix(): void;
clone(): PerspectiveCamera;
toJSON(meta?: any): any;
// deprecated
setLens(focalLength: number, frameHeight?: number): void;
}
export class StereoCamera extends Camera {
constructor();
aspect: number;
cameraL: PerspectiveCamera;
cameraR: PerspectiveCamera;
update(camera: PerspectiveCamera): void;
}
// Core ///////////////////////////////////////////////////////////////////////////////////////////////
/**
* @see <a href="https://github.com/mrdoob/three.js/blob/master/src/core/BufferAttribute.js">src/core/BufferAttribute.js</a>
*/
export class BufferAttribute {
constructor(array: ArrayLike<number>, itemSize: number, normalized?: boolean); // array parameter should be TypedArray.
uuid: string;
array: ArrayLike<number>;
itemSize: number;
dynamic: boolean;
updateRange: {offset: number, count: number};
version: number;
normalized: boolean;
needsUpdate: boolean;
count: number;
setDynamic(dynamic: boolean): BufferAttribute;
clone(): BufferAttribute;
copy(source: BufferAttribute): BufferAttribute;
copyAt(index1: number, attribute: BufferAttribute, index2: number): BufferAttribute;
copyArray(array: ArrayLike<number>): BufferAttribute;
copyColorsArray(colors: {r: number, g: number, b: number}[]): BufferAttribute;
copyIndicesArray(indices: {a: number, b: number, c: number}[]): BufferAttribute;
copyVector2sArray(vectors: {x: number, y: number}[]): BufferAttribute;
copyVector3sArray(vectors: {x: number, y: number, z: number}[]): BufferAttribute;
copyVector4sArray(vectors: {x: number, y: number, z: number, w: number}[]): BufferAttribute;
set(value: ArrayLike<number>, offset?: number): BufferAttribute;
getX(index: number): number;
setX(index: number, x: number): BufferAttribute;
getY(index: number): number;
setY(index: number, y: number): BufferAttribute;
getZ(index: number): number;
setZ(index: number, z: number): BufferAttribute;
getW(index: number): number;
setW(index: number, z: number): BufferAttribute;
setXY(index: number, x: number, y: number): BufferAttribute;
setXYZ(index: number, x: number, y: number, z: number): BufferAttribute;
setXYZW(index: number, x: number, y: number, z: number, w: number): BufferAttribute;
clone(): BufferAttribute;
length: number; // deprecated, use count
}
export class Int8Attribute extends BufferAttribute {
constructor(array: any, itemSize: number);
}
export class Uint8Attribute extends BufferAttribute {
constructor(array: any, itemSize: number);
}
export class Uint8ClampedAttribute extends BufferAttribute {
constructor(array: any, itemSize: number);
}
export class Int16Attribute extends BufferAttribute {
constructor(array: any, itemSize: number);
}
export class Uint16Attribute extends BufferAttribute {
constructor(array: any, itemSize: number);
}
export class Int32Attribute extends BufferAttribute {
constructor(array: any, itemSize: number);
}
export class Uint32Attribute extends BufferAttribute {
constructor(array: any, itemSize: number);
}
export class Float32Attribute extends BufferAttribute {
constructor(array: any, itemSize: number);
}
export class Float64Attribute extends BufferAttribute {
constructor(array: any, itemSize: number);
}
// deprecated, use new THREE.BufferAttribute().setDynamic( true )
export class DynamicBufferAttribute extends BufferAttribute {}
/**
* This is a superefficent class for geometries because it saves all data in buffers.
* It reduces memory costs and cpu cycles. But it is not as easy to work with because of all the nessecary buffer calculations.
* It is mainly interesting when working with static objects.
*
* @see <a href="https://github.com/mrdoob/three.js/blob/master/src/core/BufferGeometry.js">src/core/BufferGeometry.js</a>
*/
export class BufferGeometry extends EventDispatcher {
/**
* This creates a new BufferGeometry. It also sets several properties to an default value.
*/
constructor();
static MaxIndex: number;
/**
* Unique number of this buffergeometry instance
*/
id: number;
uuid: string;
name: string;
type: string;
index: BufferAttribute;
attributes: BufferAttribute|InterleavedBufferAttribute[];
morphAttributes: any;
groups: {start: number, count: number, materialIndex?: number}[];
boundingBox: Box3;
boundingSphere: Sphere;
drawRange: { start: number, count: number };
getIndex(): BufferAttribute;
setIndex( index: BufferAttribute ): void;
addAttribute(name: string, attribute: BufferAttribute|InterleavedBufferAttribute): BufferGeometry;
getAttribute(name: string): BufferAttribute|InterleavedBufferAttribute;
removeAttribute(name: string): BufferGeometry;
addGroup(start: number, count: number, materialIndex?: number): void;
clearGroups(): void;
setDrawRange(start: number, count: number): void;
/**
* Bakes matrix transform directly into vertex coordinates.
*/
applyMatrix(matrix: Matrix4): BufferGeometry;
rotateX(angle: number): BufferGeometry;
rotateY(angle: number): BufferGeometry;
rotateZ(angle: number): BufferGeometry;
translate(x: number, y: number, z: number): BufferGeometry;
scale(x: number, y: number, z: number): BufferGeometry;
lookAt(v: Vector3): void;
center(): Vector3;
setFromObject(object: Object3D): void;
updateFromObject(object: Object3D): void;
fromGeometry(geometry: Geometry, settings?: any): BufferGeometry;
fromDirectGeometry(geometry: DirectGeometry): BufferGeometry;
/**
* Computes bounding box of the geometry, updating Geometry.boundingBox attribute.
* Bounding boxes aren't computed by default. They need to be explicitly computed, otherwise they are null.
*/
computeBoundingBox(): void;
/**
* Computes bounding sphere of the geometry, updating Geometry.boundingSphere attribute.
* Bounding spheres aren't' computed by default. They need to be explicitly computed, otherwise they are null.
*/
computeBoundingSphere(): void;
/**
* Computes vertex normals by averaging face normals.
*/
computeVertexNormals(): void;
merge(geometry: BufferGeometry, offset: number): BufferGeometry;
normalizeNormals(): void;
toNonIndexed(): BufferGeometry;
toJSON(): any;
clone(): BufferGeometry;
copy(source: BufferGeometry): BufferGeometry;
/**
* Disposes the object from memory.
* You need to call this when you want the bufferGeometry removed while the application is running.
*/
dispose(): void;
// deprecated
drawcalls: any;
offsets: any;
addIndex(index: any): void;
addDrawCall(start: any, count: any, indexOffset?: any): void;
clearDrawCalls(): void;
addAttribute(name: any, array: any, itemSize: any): any;
}
/**
* Object for keeping track of time.
*
* @see <a href="https://github.com/mrdoob/three.js/blob/master/src/core/Clock.js">src/core/Clock.js</a>
*/
export class Clock {
/**
* @param autoStart Automatically start the clock.
*/
constructor(autoStart?: boolean);
/**
* If set, starts the clock automatically when the first update is called.
*/
autoStart: boolean;
/**
* When the clock is running, It holds the starttime of the clock.
* This counted from the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC.
*/
startTime: number;
/**
* When the clock is running, It holds the previous time from a update.
* This counted from the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC.
*/
oldTime: number;
/**
* When the clock is running, It holds the time elapsed between the start of the clock to the previous update.
* This parameter is in seconds of three decimal places.
*/
elapsedTime: number;
/**
* This property keeps track whether the clock is running or not.
*/
running: boolean;
/**
* Starts clock.
*/
start(): void;
/**
* Stops clock.
*/
stop(): void;
/**
* Get the seconds passed since the clock started.
*/
getElapsedTime(): number;
/**
* Get the seconds passed since the last call to this method.
*/
getDelta(): number;
}
/**
* @see <a href="https://github.com/mrdoob/three.js/blob/master/src/core/DirectGeometry.js">src/core/DirectGeometry.js</a>
*/
export class DirectGeometry extends EventDispatcher {
constructor();
id: number;
uuid: string;
name: string;
type: string;
indices: number[];
vertices: Vector3[];
normals: Vector3[];
colors: Color[];
uvs: Vector2[];
uvs2: Vector2[];
groups: {start: number, materialIndex: number}[];
morphTargets: MorphTarget[];
skinWeights: number[];
skinIndices: number[];
boundingBox: Box3;
boundingSphere: Sphere;
verticesNeedUpdate: boolean;
normalsNeedUpdate: boolean;
colorsNeedUpdate: boolean;
uvsNeedUpdate: boolean;
groupsNeedUpdate: boolean;
computeBoundingBox(): void;
computeBoundingSphere(): void;
computeGroups(geometry: Geometry): void;
fromGeometry(geometry: Geometry): DirectGeometry;
dispose(): void;
// EventDispatcher mixins
addEventListener(type: string, listener: (event: Event) => void ): void;
hasEventListener(type: string, listener: (event: Event) => void): void;
removeEventListener(type: string, listener: (event: Event) => void): void;
dispatchEvent(event: { type: string; [attachment: string]: any; }): void;
}
/**
* JavaScript events for custom objects
*
* # Example
* var Car = function () {
*
* EventDispatcher.call( this );
* this.start = function () {
*
* this.dispatchEvent( { type: 'start', message: 'vroom vroom!' } );
*
* };
*
* };
*
* var car = new Car();
* car.addEventListener( 'start', function ( event ) {
*
* alert( event.message );
*
* } );
* car.start();
*
* @source src/core/EventDispatcher.js
*/
export class EventDispatcher {
/**
* Creates eventDispatcher object. It needs to be call with '.call' to add the functionality to an object.
*/
constructor();
/**
* Adds a listener to an event type.
* @param type The type of the listener that gets removed.
* @param listener The listener function that gets removed.
*/
addEventListener(type: string, listener: (event: Event) => void ): void;
/**
* Adds a listener to an event type.
* @param type The type of the listener that gets removed.
* @param listener The listener function that gets removed.
*/
hasEventListener(type: string, listener: (event: Event) => void): void;
/**
* Removes a listener from an event type.
* @param type The type of the listener that gets removed.
* @param listener The listener function that gets removed.
*/
removeEventListener(type: string, listener: (event: Event) => void): void;
/**
* Fire an event type.
* @param type The type of event that gets fired.
*/
dispatchEvent(event: { type: string; [attachment: string]: any; }): void;
// deprecated
apply(target: any): void;
}
export interface Event {
type: string;
target: any;
}
/**
* Triangle face.
*
* # Example
* var normal = new THREE.Vector3( 0, 1, 0 );
* var color = new THREE.Color( 0xffaa00 );
* var face = new THREE.Face3( 0, 1, 2, normal, color, 0 );
*
* @source https://github.com/mrdoob/three.js/blob/master/src/core/Face3.js
*/
export class Face3 {
/**
* @param a Vertex A index.
* @param b Vertex B index.
* @param c Vertex C index.
* @param normal Face normal or array of vertex normals.
* @param color Face color or array of vertex colors.
* @param materialIndex Material index.
*/
constructor(a: number, b: number, c: number, normal?: Vector3, color?: Color, materialIndex?: number);
constructor(a: number, b: number, c: number, normal?: Vector3, vertexColors?: Color[], materialIndex?: number);
constructor(a: number, b: number, c: number, vertexNormals?: Vector3[], color?: Color, materialIndex?: number);
constructor(a: number, b: number, c: number, vertexNormals?: Vector3[], vertexColors?: Color[], materialIndex?: number);
/**
* Vertex A index.
*/
a: number;
/**
* Vertex B index.
*/
b: number;
/**
* Vertex C index.
*/
c: number;
/**
* Face normal.
*/
normal: Vector3;
/**
* Array of 4 vertex normals.
*/
vertexNormals: Vector3[];
/**
* Face color.
*/
color: Color;
/**
* Array of 4 vertex normals.
*/
vertexColors: Color[];
/**
* Material index (points to {@link Geometry.materials}).
*/
materialIndex: number;
clone(): Face3;
copy(source: Face3): Face3;
}
export class Face4 extends Face3 {} // deprecated, use Face3
export interface MorphTarget {
name: string;
vertices: Vector3[];
}
export interface MorphColor {
name: string;
colors: Color[];
}
export interface MorphNormals {
name: string;
normals: Vector3[];
}
export let GeometryIdCount: number;
/**
* Base class for geometries
*
* # Example
* var geometry = new THREE.Geometry();
* geometry.vertices.push( new THREE.Vector3( -10, 10, 0 ) );
* geometry.vertices.push( new THREE.Vector3( -10, -10, 0 ) );
* geometry.vertices.push( new THREE.Vector3( 10, -10, 0 ) );
* geometry.faces.push( new THREE.Face3( 0, 1, 2 ) );
* geometry.computeBoundingSphere();
*
* @see https://github.com/mrdoob/three.js/blob/master/src/core/Geometry.js
*/
export class Geometry extends EventDispatcher {
constructor();
/**
* Unique number of this geometry instance
*/
id: number;
uuid: string;
/**
* Name for this geometry. Default is an empty string.
*/
name: string;
type: string;
/**
* The array of vertices hold every position of points of the model.
* To signal an update in this array, Geometry.verticesNeedUpdate needs to be set to true.
*/
vertices: Vector3[];
/**
* Array of vertex colors, matching number and order of vertices.
* Used in ParticleSystem, Line and Ribbon.
* Meshes use per-face-use-of-vertex colors embedded directly in faces.
* To signal an update in this array, Geometry.colorsNeedUpdate needs to be set to true.
*/
colors: Color[];
/**
* Array of triangles or/and quads.
* The array of faces describe how each vertex in the model is connected with each other.
* To signal an update in this array, Geometry.elementsNeedUpdate needs to be set to true.
*/
faces: Face3[];
/**
* Array of face UV layers.
* Each UV layer is an array of UV matching order and number of vertices in faces.
* To signal an update in this array, Geometry.uvsNeedUpdate needs to be set to true.
*/
faceVertexUvs: Vector2[][][];
/**
* Array of morph targets. Each morph target is a Javascript object:
*
* { name: "targetName", vertices: [ new THREE.Vector3(), ... ] }
*
* Morph vertices match number and order of primary vertices.
*/
morphTargets: MorphTarget[];
/**
* Array of morph normals. Morph normals have similar structure as morph targets, each normal set is a Javascript object:
*
* morphNormal = { name: "NormalName", normals: [ new THREE.Vector3(), ... ] }
*/
morphNormals: MorphNormals[];
/**
* Array of skinning weights, matching number and order of vertices.
*/
skinWeights: number[];
/**
* Array of skinning indices, matching number and order of vertices.
*/
skinIndices: number[];
/**
*
*/
lineDistances: number[];
/**
* Bounding box.
*/
boundingBox: Box3;
/**
* Bounding sphere.
*/
boundingSphere: Sphere;
/**
* Set to true if the vertices array has been updated.
*/
verticesNeedUpdate: boolean;
/**
* Set to true if the faces array has been updated.
*/
elementsNeedUpdate: boolean;
/**
* Set to true if the uvs array has been updated.
*/
uvsNeedUpdate: boolean;
/**
* Set to true if the normals array has been updated.
*/
normalsNeedUpdate: boolean;
/**
* Set to true if the colors array has been updated.
*/
colorsNeedUpdate: boolean;
/**
* Set to true if the linedistances array has been updated.
*/
lineDistancesNeedUpdate: boolean;
/**
*
*/
groupsNeedUpdate: boolean;
/**
* Bakes matrix transform directly into vertex coordinates.
*/
applyMatrix(matrix: Matrix4): Geometry;
rotateX(angle: number): Geometry;
rotateY(angle: number): Geometry;
rotateZ(angle: number): Geometry;
translate(x: number, y: number, z: number): Geometry;
scale(x: number, y: number, z: number): Geometry;
lookAt( vector: Vector3 ): void;
fromBufferGeometry(geometry: BufferGeometry): Geometry;
center(): Vector3;
normalize(): Geometry;
/**
* Computes face normals.
*/
computeFaceNormals(): void;
/**
* Computes vertex normals by averaging face normals.
* Face normals must be existing / computed beforehand.
*/
computeVertexNormals(areaWeighted?: boolean): void;
/**
* Computes morph normals.
*/
computeMorphNormals(): void;
computeLineDistances(): void;
/**
* Computes bounding box of the geometry, updating {@link Geometry.boundingBox} attribute.
*/
computeBoundingBox(): void;
/**
* Computes bounding sphere of the geometry, updating Geometry.boundingSphere attribute.
* Neither bounding boxes or bounding spheres are computed by default. They need to be explicitly computed, otherwise they are null.
*/
computeBoundingSphere(): void;
merge(geometry: Geometry, matrix: Matrix, materialIndexOffset?: number): void;
mergeMesh(mesh: Mesh): void;
/**
* Checks for duplicate vertices using hashmap.
* Duplicated vertices are removed and faces' vertices are updated.
*/
mergeVertices(): number;
sortFacesByMaterialIndex(): void;
toJSON(): any;
/**
* Creates a new clone of the Geometry.
*/
clone(): Geometry;
copy(source: Geometry): Geometry;
/**
* Removes The object from memory.
* Don't forget to call this method when you remove an geometry because it can cuase meomory leaks.
*/
dispose(): void;
// These properties do not exist in a normal Geometry class, but if you use the instance that was passed by JSONLoader, it will be added.
bones: Bone[];
animation: AnimationClip;
animations: AnimationClip[];
// EventDispatcher mixins
addEventListener(type: string, listener: (event: Event) => void ): void;
hasEventListener(type: string, listener: (event: Event) => void): void;
removeEventListener(type: string, listener: (event: Event) => void): void;
dispatchEvent(event: { type: string; [attachment: string]: any; }): void;
}
export namespace GeometryUtils { // deprecated
export function merge(geometry1: any, geometry2: any, materialIndexOffset?: any): any; // deprecated, use geometry.merge( geometry2, matrix, materialIndexOffset )
export function center(geometry: any): any; // deprecated, use geometry.center()
}
/**
* @see <a href="https://github.com/mrdoob/three.js/blob/master/src/core/InstancedBufferAttribute.js">src/core/InstancedBufferAttribute.js</a>
*/
export class InstancedBufferAttribute extends BufferAttribute {
constructor(data: ArrayLike<number>, itemSize: number, meshPerAttribute?: number);
meshPerAttribute: number;
clone(): InstancedBufferAttribute;
copy(source: InstancedBufferAttribute): InstancedBufferAttribute;
}
/**
* @see <a href="https://github.com/mrdoob/three.js/blob/master/src/core/InstancedBufferGeometry.js">src/core/InstancedBufferGeometry.js</a>
*/
export class InstancedBufferGeometry extends BufferGeometry {
constructor();
groups: {start: number, count: number, instances: number}[];
maxInstancedCount: number;
addGroup(start: number, count: number, instances: number): void;
clone(): InstancedBufferGeometry;
copy(source: InstancedBufferGeometry): InstancedBufferGeometry;
}
/**
* @see <a href="https://github.com/mrdoob/three.js/blob/master/src/core/InterleavedBuffer.js">src/core/InterleavedBuffer.js</a>
*/
export class InterleavedBuffer {
constructor(array: ArrayLike<number>, stride: number);
array: ArrayLike<number>;
stride: number;
dynamic: boolean;
updateRange: { offset: number; count: number };
version: number;
length: number;
count: number;
needsUpdate: boolean;
setDynamic(dynamic: boolean): InterleavedBuffer;
clone(): InterleavedBuffer;
copy(source: InterleavedBuffer): InterleavedBuffer;
copyAt(index1: number, attribute: InterleavedBufferAttribute, index2: number): InterleavedBuffer;
set(value: ArrayLike<number>, index: number): InterleavedBuffer;
clone(): InterleavedBuffer;
}
/**
* @see <a href="https://github.com/mrdoob/three.js/blob/master/src/core/InstancedInterleavedBuffer.js">src/core/InstancedInterleavedBuffer.js</a>
*/
export class InstancedInterleavedBuffer extends InterleavedBuffer {
constructor(array: ArrayLike<number>, stride: number, meshPerAttribute?: number);
meshPerAttribute: number;
clone(): InstancedInterleavedBuffer;
copy(source: InstancedInterleavedBuffer): InstancedInterleavedBuffer;
}
/**
* @see <a href="https://github.com/mrdoob/three.js/blob/master/src/core/InterleavedBufferAttribute.js">src/core/InterleavedBufferAttribute.js</a>
*/
export class InterleavedBufferAttribute {
constructor(interleavedBuffer: InterleavedBuffer, itemSize: number, offset: number, normalized: boolean);
uuid: string;
data: InterleavedBuffer;
itemSize: number;
offset: number;
count: number;
normalized: boolean;
array: any[];
getX(index: number): number;
setX(index: number, x: number): InterleavedBufferAttribute;
getY(index: number): number;
setY(index: number, y: number): InterleavedBufferAttribute;
getZ(index: number): number;
setZ(index: number, z: number): InterleavedBufferAttribute;
getW(index: number): number;
setW(index: number, z: number): InterleavedBufferAttribute;
setXY(index: number, x: number, y: number): InterleavedBufferAttribute;
setXYZ(index: number, x: number, y: number, z: number): InterleavedBufferAttribute;
setXYZW(index: number, x: number, y: number, z: number, w: number): InterleavedBufferAttribute;
length: number; // deprecated, use count instead
}
export let Object3DIdCount: number;
/**
* Base class for scene graph objects
*/
export class Object3D extends EventDispatcher {
constructor();
/**
* Unique number of this object instance.
*/
id: number;
/**
*
*/
uuid: string;
/**
* Optional name of the object (doesn't need to be unique).
*/
name: string;
type: string;
/**
* Object's parent in the scene graph.
*/
parent: Object3D;
/**
* Array with object's children.
*/
children: Object3D[];
/**
* Up direction.
*/
up: Vector3;
/**
* Object's local position.
*/
position: Vector3;
/**
* Object's local rotation (Euler angles), in radians.
*/
rotation: Euler;
/**