UNPKG

typescript-closure-tools

Version:

Command-line tools to convert closure-style JSDoc annotations to typescript, and to convert typescript sources to closure externs files

1,624 lines (1,354 loc) 175 kB
// Type definitions for three.js -- r67 // Project: http://mrdoob.github.com/three.js/ // Definitions by: Kon <http://phyzkit.net/>, Satoru Kimura <https://github.com/gyohk> // Definitions: https://github.com/borisyankov/DefinitelyTyped interface WebGLRenderingContext {} declare module THREE { export var REVISION: string; // custom blending equations // (numbers start from 100 not to clash with other // mappings to OpenGL constants defined in Texture.js) export enum BlendingEquation { } export var AddEquation: BlendingEquation; export var SubtractEquation: BlendingEquation; export var ReverseSubtractEquation: BlendingEquation; // custom blending destination factors export enum BlendingDstFactor { } export var ZeroFactor: BlendingDstFactor; export var OneFactor: BlendingDstFactor; export var SrcColorFactor: BlendingDstFactor; export var OneMinusSrcColorFactor: BlendingDstFactor; export var SrcAlphaFactor: BlendingDstFactor; export var OneMinusSrcAlphaFactor: BlendingDstFactor; export var DstAlphaFactor: BlendingDstFactor; export var OneMinusDstAlphaFactor: BlendingDstFactor; // custom blending source factors export enum BlendingSrcFactor { } export var DstColorFactor: BlendingSrcFactor; export var OneMinusDstColorFactor: BlendingSrcFactor; export var SrcAlphaSaturateFactor: BlendingSrcFactor; // GL STATE CONSTANTS export enum CullFace { } export var CullFaceNone: CullFace; export var CullFaceBack: CullFace; export var CullFaceFront: CullFace; export var CullFaceFrontBack: CullFace; export enum FrontFaceDirection { } export var FrontFaceDirectionCW: FrontFaceDirection; export var FrontFaceDirectionCCW: FrontFaceDirection; // MATERIAL CONSTANTS // side export enum Side { } export var FrontSide: Side; export var BackSide: Side; export var DoubleSide: Side; // shading export enum Shading { } export var NoShading: Shading; export var FlatShading: Shading; export var SmoothShading: Shading; // colors export enum Colors { } export var NoColors: Colors; export var FaceColors: Colors; export var VertexColors: Colors; // blending modes export enum Blending { } export var NoBlending: Blending; export var NormalBlending: Blending; export var AdditiveBlending: Blending; export var SubtractiveBlending: Blending; export var MultiplyBlending: Blending; export var CustomBlending: Blending; // Shadowing Type export enum ShadowMapType { } export var BasicShadowMap: ShadowMapType; export var PCFShadowMap: ShadowMapType; export var PCFSoftShadowMap: ShadowMapType; // TEXTURE CONSTANTS // Operations export enum Combine { } export var MultiplyOperation: Combine; export var MixOperation: Combine; export var AddOperation: Combine; // Mapping modes export enum Mapping { } export interface MappingConstructor { new (): Mapping; } export var UVMapping: MappingConstructor; export var CubeReflectionMapping: MappingConstructor; export var CubeRefractionMapping: MappingConstructor; export var SphericalReflectionMapping: MappingConstructor; export var SphericalRefractionMapping: MappingConstructor; // Wrapping modes export enum Wrapping { } export var RepeatWrapping: Wrapping; export var ClampToEdgeWrapping: Wrapping; export var MirroredRepeatWrapping: Wrapping; // Filters export enum TextureFilter { } export var NearestFilter: TextureFilter; export var NearestMipMapNearestFilter: TextureFilter; export var NearestMipMapLinearFilter: TextureFilter; export var LinearFilter: TextureFilter; export var LinearMipMapNearestFilter: TextureFilter; export var LinearMipMapLinearFilter: TextureFilter; // Data types export enum TextureDataType { } export var UnsignedByteType: TextureDataType; export var ByteType: TextureDataType; export var ShortType: TextureDataType; export var UnsignedShortType: TextureDataType; export var IntType: TextureDataType; export var UnsignedIntType: TextureDataType; export var FloatType: TextureDataType; // Pixel types export enum PixelType { } export var UnsignedShort4444Type: PixelType; export var UnsignedShort5551Type: PixelType; export var UnsignedShort565Type: PixelType; // Pixel formats export enum PixelFormat { } export var AlphaFormat: PixelFormat; export var RGBFormat: PixelFormat; export var RGBAFormat: PixelFormat; export var LuminanceFormat: PixelFormat; export var LuminanceAlphaFormat: PixelFormat; // Compressed texture formats export enum CompressedPixelFormat { } export var RGB_S3TC_DXT1_Format: CompressedPixelFormat; export var RGBA_S3TC_DXT1_Format: CompressedPixelFormat; export var RGBA_S3TC_DXT3_Format: CompressedPixelFormat; export var RGBA_S3TC_DXT5_Format: CompressedPixelFormat; // 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; /** * This make the camera look at the vector position in local space. * @param vector point to look at */ lookAt(vector: Vector3): void; clone(camera?: Camera): Camera; } /** * 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); /** * 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; clone(): OrthographicCamera; } /** * 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); /** * 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; /** * Uses focal length (in mm) to estimate and set FOV 35mm (fullframe) camera is used if frame size is not specified. * Formula based on http://www.bobatkins.com/photography/technical/field_of_view.html * @param focalLength focal length * @param frameHeight frame size. Default value is 24. */ setLens(focalLength: number, frameHeight?: number): void; /** * 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; /** * Updates the camera projection matrix. Must be called after change of parameters. */ updateProjectionMatrix(): void; clone(): PerspectiveCamera; } // Core /////////////////////////////////////////////////////////////////////////////////////////////// interface BufferGeometryAttributeArray extends ArrayBufferView{ length: number; } interface BufferGeometryAttribute{ itemSize: number; array: BufferGeometryAttributeArray; numItems: number; } interface BufferGeometryAttributes{ [name: string]: BufferGeometryAttribute; index?: BufferGeometryAttribute; position?: BufferGeometryAttribute; normal?: BufferGeometryAttribute; color?: BufferGeometryAttribute; } /** * 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 { /** * This creates a new BufferGeometry. It also sets several properties to an default value. */ constructor(); /** * Unique number of this buffergeometry instance */ id: number; /** * This hashmap has as id the name of the attribute to be set and as value the buffer to set it to. */ attributes: BufferGeometryAttributes; /** * When set, it holds certain buffers in memory to have faster updates for this object. When unset, it deletes those buffers and saves memory. */ dynamic: boolean; offsets: { start: number; count: number; index: number; }[]; /** * Bounding box. */ boundingBox: BoundingBox3D; /** * Bounding sphere. */ boundingSphere: BoundingSphere; morphTargets: any[]; hasTangents: boolean; addAttribute(name: string, type: Function, numItems: number, itemSize: number): any; /** * Bakes matrix transform directly into vertex coordinates. */ applyMatrix(matrix: Matrix4): void; /** * Computes vertex normals by averaging face normals. */ computeVertexNormals(): void; /** * Computes vertex tangents. * Based on http://www.terathon.com/code/tangent.html * Geometry must have vertex UVs (layer 0 will be used). */ computeTangents(): void; /** * 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; /** * Disposes the object from memory. * You need to call this when you want the bufferGeometry removed while the application is running. */ dispose(): void; normalizeNormals(): void; clone(): BufferGeometry; } /** * 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; } /** * 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: any) => 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: any) => 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: any) => void): void; /** * Fire an event type. * @param type The type of event that gets fired. */ dispatchEvent(event: { type: string; target: any; }): void; } /** * 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; // properties inherits from Face /////////////////////////////////// /** * Face normal. */ normal: Vector3; /** * Face color. */ color: Color; /** * Array of 4 vertex normals. */ vertexNormals: Vector3[]; /** * Array of 4 vertex normals. */ vertexColors: Color[]; /** * Array of 4 vertex tangets. */ vertexTangents: number[]; /** * Material index (points to {@link Geometry.materials}). */ materialIndex: number; clone(): Face3; } export interface MorphTarget { name: string; vertices: Vector3[]; } export interface MorphColor { name: string; color: Color[]; } export interface MorphNormals { name: string; normals: Vector3[]; } export interface BoundingBox3D { min: Vector3; max: Vector3; } export interface BoundingSphere { radius: 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 { constructor(); /** * Unique number of this geometry instance */ id: number; /** * Name for this geometry. Default is an empty string. */ name: 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 vertex normals, matching number and order of vertices. * Normal vectors are nessecary for lighting * To signal an update in this array, Geometry.normalsNeedUpdate needs to be set to true. */ // normals: Vector3[]; /** * 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 faces. * To signal an update in this array, Geometry.uvsNeedUpdate needs to be set to true. */ // faceUvs: Vector2[][]; /** * 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 colors. Morph colors have similar structure as morph targets, each color set is a Javascript object: * * morphColor = { name: "colorName", colors: [ new THREE.Color(), ... ] } */ morphColors: MorphColor[]; /** * 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[]; /** * Bounding box. */ boundingBox: BoundingBox3D; /** * Bounding sphere. */ boundingSphere: BoundingSphere; /** * True if geometry has tangents. Set in Geometry.computeTangents. */ hasTangents: boolean; /** * Set to true if attribute buffers will need to change in runtime (using "dirty" flags). * Unless set to true internal typed arrays corresponding to buffers will be deleted once sent to GPU. * Defaults to true. */ dynamic: boolean; /** * 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 tangents in the faces has been updated. */ tangentsNeedUpdate: 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; /** * Set to true if an array has changed in length. */ buffersNeedUpdate: boolean; /** * */ lineDistances: number[]; /** * Bakes matrix transform directly into vertex coordinates. */ applyMatrix(matrix: Matrix4): void; /** * 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; /** * Computes vertex tangents. * Based on <a href="http://www.terathon.com/code/tangent.html">http://www.terathon.com/code/tangent.html</a> * Geometry must have vertex UVs (layer 0 will be used). */ computeTangents(): 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; /** * Checks for duplicate vertices using hashmap. * Duplicated vertices are removed and faces' vertices are updated. */ mergeVertices(): number; /** * Creates a new clone of the Geometry. */ clone(): 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; computeLineDistances(): void; makeGroups(usesFaceMaterial: boolean, maxVerticesInGroup: number): void; } /** * Base class for scene graph objects */ export class Object3D { constructor(); /** * Unique number of this object instance. */ id: number; /** * Optional name of the object (doesn't need to be unique). */ name: string; /** * Object's parent in the scene graph. */ parent: Object3D; /** * Array with object's children. */ children: Object3D[]; /** * Object's local position. */ position: Vector3; /** * Object's local rotation (Euler angles), in radians. */ rotation: Euler; /** * Order of axis for Euler angles. */ eulerOrder: string; // eulerOrder:EulerOrder; /** * Object's local scale. */ scale: Vector3; /** * Up direction. */ up: Vector3; /** * Local transform. */ matrix: Matrix4; /** * Global rotation. */ quaternion: Quaternion; /** * Use quaternion instead of Euler angles for specifying local rotation. */ useQuaternion: boolean; /** * Override depth-sorting order if non null. */ renderDepth: number; /** * Object gets rendered if true. */ visible: boolean; /** * Gets rendered into shadow map. */ castShadow: boolean; /** * Material gets baked in shadow receiving. */ receiveShadow: boolean; /** * When this is set, it checks every frame if the object is in the frustum of the camera. Otherwise the object gets drawn every frame even if it isn't visible. */ frustumCulled: boolean; /** * When this is set, it calculates the matrix of position, (rotation or quaternion) and scale every frame and also recalculates the matrixWorld property. */ matrixAutoUpdate: boolean; /** * When this is set, it calculates the matrixWorld in that frame and resets this property to false. */ matrixWorldNeedsUpdate: boolean; /** * When this is set, then the rotationMatrix gets calculated every frame. */ rotationAutoUpdate: boolean; /** * An object that can be used to store custom data about the Object3d. It should not hold references to functions as these will not be cloned. */ userData: any; /** * The global transform of the object. If the Object3d has no parent, then it's identical to the local transform. */ matrixWorld: Matrix4; /** * This updates the position, rotation and scale with the matrix. */ applyMatrix(matrix: Matrix4): void; /** * Translates object along x axis by distance. * @param distance Distance. */ translateX(distance: number): void; /** * Translates object along y axis by distance. * @param distance Distance. */ translateY(distance: number): void; /** * Translates object along z axis by distance. * @param distance Distance. */ translateZ(distance: number): void; /** * Updates the vector from local space to world space. * @param vector A local vector. */ localToWorld(vector: Vector3): Vector3; /** * Updates the vector from world space to local space. * @param vector A world vector. */ worldToLocal(vector: Vector3): Vector3; /** * Rotates object to face point in space. * @param vector A world vector to look at. */ lookAt(vector: Vector3): void; /** * Adds object as child of this object. */ add(object: Object3D): void; /** * Removes object as child of this object. */ remove(object: Object3D): void; /** * Translates object along arbitrary axis by distance. * @param distance Distance. * @param axis Translation direction. */ traverse(callback: (object: Object3D) => any): void; /** * Searches whole subgraph recursively to add all objects in the array. * @param array optional argument that returns the the array with descendants. */ getDescendants(array?: Object3D[]): Object3D[]; /** * Updates local transform. */ updateMatrix(): void; /** * Updates global transform of the object and its children. */ updateMatrixWorld(force: boolean): void; clone(object?: Object3D, recursive?: boolean): Object3D; /** * Searches through the object's children and returns the first with a matching name, optionally recursive. * @param name String to match to the children's Object3d.name property. * @param recursive Boolean whether to search through the children's children. Default is false. */ getObjectByName(name: string, recursive: boolean): Object3D; /** * Searches through the object's children and returns the first with a matching id, optionally recursive. * @param id Unique number of the object instance * @param recursive Boolean whether to search through the children's children. Default is false. */ getObjectById(id: string, recursive: boolean): Object3D; /** * @param axis A normalized vector in object space. * @param distance The distance to translate. */ translateOnAxis(axis: Vector3, distance: number): Object3D; /** * Rotate an object along an axis in object space. The axis is assumed to be normalized. * @param axis A normalized vector in object space. * @param angle The angle in radians. */ rotateOnAxis(axis: Vector3, angle: number): Object3D; } /** * Projects points between spaces. */ export class Projector { constructor(); projectVector(vector: Vector3, camera: Camera): Vector3; unprojectVector(vector: Vector3, camera: Camera): Vector3; /** * Translates a 2D point from NDC (Normalized Device Coordinates) to a Raycaster that can be used for picking. NDC range from [-1..1] in x (left to right) and [1.0 .. -1.0] in y (top to bottom). */ pickingRay(vector: Vector3, camera: Camera): Raycaster; /** * Transforms a 3D scene object into 2D render data that can be rendered in a screen with your renderer of choice, projecting and clipping things out according to the used camera. * If the scene were a real scene, this method would be the equivalent of taking a picture with the camera (and developing the film would be the next step, using a Renderer). * * @param scene scene to project. * @param camera camera to use in the projection. * @param sort select whether to sort elements using the Painter's algorithm. */ projectScene(scene: Scene, camera: Camera, sortObjects: boolean, sortElements?: boolean): { objects: Object3D[]; // Mesh, Line or other object sprites: Object3D[]; // Sprite or Particle lights: Light[]; elements: Face3[]; // Line, Particle, Face3 or Face4 }; } export interface Intersection { distance: number; point: Vector3; face: Face3; object: Object3D; } export class Raycaster { constructor(origin?: Vector3, direction?: Vector3, near?: number, far?: number); ray: Ray; near: number; far: number; precision: number; set(origin: Vector3, direction: Vector3): void; intersectObject(object: Object3D, recursive?: boolean): Intersection[]; intersectObjects(objects: Object3D[], recursive?: boolean): Intersection[]; } // Lights ////////////////////////////////////////////////////////////////////////////////// /** * Abstract base class for lights. */ export class Light extends Object3D { constructor(hex?: number); color: Color; clone(light?: Light): Light; } /** * This light's color gets applied to all the objects in the scene globally. * * # example * var light = new THREE.AmbientLight( 0x404040 ); // soft white light * scene.add( light ); * * @source https://github.com/mrdoob/three.js/blob/master/src/lights/AmbientLight.js */ export class AmbientLight extends Light { /** * This creates a Ambientlight with a color. * @param hex Numeric value of the RGB component of the color. */ constructor(hex?: number); clone(): AmbientLight; } export class AreaLight extends Light{ constructor(hex: number, intensity?: number); position: Vector3; right: Vector3; normal: Vector3; quadraticAttenuation: number; height: number; linearAttenuation: number; width: number; intensity: number; constantAttenuation: number; } /** * Affects objects using MeshLambertMaterial or MeshPhongMaterial. * * @example * // White directional light at half intensity shining from the top. * var directionalLight = new THREE.DirectionalLight( 0xffffff, 0.5 ); * directionalLight.position.set( 0, 1, 0 ); * scene.add( directionalLight ); * * @see <a href="https://github.com/mrdoob/three.js/blob/master/src/lights/DirectionalLight.js">src/lights/DirectionalLight.js</a> */ export class DirectionalLight extends Light { constructor(hex?: number, intensity?: number); /** * Direction of the light is normalized vector from position to (0,0,0). * Default — new THREE.Vector3(). */ position: Vector3; /** * Target used for shadow camera orientation. */ target: Object3D; /** * Light's intensity. * Default — 1.0. */ intensity: number; /** * If set to true light will cast dynamic shadows. Warning: This is expensive and requires tweaking to get shadows looking right. * Default — false. */ castShadow: boolean; /** * If set to true light will only cast shadow but not contribute any lighting (as if intensity was 0 but cheaper to compute). * Default — false. */ onlyShadow: boolean; /** * Orthographic shadow camera frustum parameter. * Default — 50. */ shadowCameraNear: number; /** * Orthographic shadow camera frustum parameter. * Default — 5000. */ shadowCameraFar: number; /** * Orthographic shadow camera frustum parameter. * Default — -500. */ shadowCameraLeft: number; /** * Orthographic shadow camera frustum parameter. * Default — 500. */ shadowCameraRight: number; /** * Orthographic shadow camera frustum parameter. * Default — 500. */ shadowCameraTop: number; /** * Orthographic shadow camera frustum parameter. * Default — -500. */ shadowCameraBottom: number; /** * Show debug shadow camera frustum. * Default — false. */ shadowCameraVisible: boolean; /** * Shadow map bias. * Default — 0. */ shadowBias: number; /** * Darkness of shadow casted by this light (from 0 to 1). * Default — 0.5. */ shadowDarkness: number; /** * Shadow map texture width in pixels. * Default — 512. */ shadowMapWidth: number; /** * Shadow map texture height in pixels. * Default — 512. */ shadowMapHeight: number; /** * Default — false. */ shadowCascade: boolean; /** * Three.Vector3( 0, 0, -1000 ). */ shadowCascadeOffset: Vector3; /** * Default — 2. */ shadowCascadeCount: number; /** * Default — [ 0, 0, 0 ]. */ shadowCascadeBias: number[]; /** * Default — [ 512, 512, 512 ]. */ shadowCascadeWidth: number[]; /** * Default — [ 512, 512, 512 ]. */ shadowCascadeHeight: number[]; /** * Default — [ -1.000, 0.990, 0.998 ]. */ shadowCascadeNearZ: number[]; /** * Default — [ 0.990, 0.998, 1.000 ]. */ shadowCascadeFarZ: number[]; /** * Default — [ ]. */ shadowCascadeArray: DirectionalLight[]; /** * Default — null. */ shadowMap: RenderTarget; /** * Default — null. */ shadowMapSize: number; /** * Default — null. */ shadowCamera: Camera; /** * Default — null. */ shadowMatrix: Matrix4; clone(): DirectionalLight; } export class HemisphereLight extends Light { constructor(skyColorHex?: number, groundColorHex?: number, intensity?: number); position: Vector3; groundColor: Color; intensity: number; clone(): HemisphereLight; } /** * Affects objects using {@link MeshLambertMaterial} or {@link MeshPhongMaterial}. * * @example * var light = new THREE.PointLight( 0xff0000, 1, 100 ); * light.position.set( 50, 50, 50 ); * scene.add( light ); */ export class PointLight extends Light { constructor(hex?: number, intensity?: number, distance?: number); /** * Light's position. * Default — new THREE.Vector3(). */ position: Vector3; /* * Light's intensity. * Default - 1.0. */ intensity: number; /** * If non-zero, light will attenuate linearly from maximum intensity at light position down to zero at distance. * Default — 0.0. */ distance: number; clone(): PointLight; } /** * A point light that can cast shadow in one direction. * * @example * // white spotlight shining from the side, casting shadow * var spotLight = new THREE.SpotLight( 0xffffff ); * spotLight.position.set( 100, 1000, 100 ); * spotLight.castShadow = true; * spotLight.shadowMapWidth = 1024; * spotLight.shadowMapHeight = 1024; * spotLight.shadowCameraNear = 500; * spotLight.shadowCameraFar = 4000; * spotLight.shadowCameraFov = 30; * scene.add( spotLight ); */ export class SpotLight extends Light { constructor(hex?: number, intensity?: number, distance?: number, angle?: number, exponent?: number); /** * Light's position. * Default — new THREE.Vector3(). */ position: Vector3; /** * Spotlight focus points at target.position. * Default position — (0,0,0). */ target: Object3D; /** * Light's intensity. * Default — 1.0. */ intensity: number; /** * If non-zero, light will attenuate linearly from maximum intensity at light position down to zero at distance. * Default — 0.0. */ distance: number; /* * Maximum extent of the spotlight, in radians, from its direction. * Default — Math.PI/2. */ angle: number; /** * Rapidity of the falloff of light from its target direction. * Default — 10.0. */ exponent: number; /** * If set to true light will cast dynamic shadows. Warning: This is expensive and requires tweaking to get shadows looking right. * Default — false. */ castShadow: boolean; /** * If set to true light will only cast shadow but not contribute any lighting (as if intensity was 0 but cheaper to compute). * Default — false. */ onlyShadow: boolean; /** * Perspective shadow camera frustum near parameter. * Default — 50. */ shadowCameraNear: number; /** * Perspective shadow camera frustum far parameter. * Default — 5000. */ shadowCameraFar: number; /** * Perspective shadow camera frustum field of view parameter. * Default — 50. */ shadowCameraFov: number; /** * Show debug shadow camera frustum. * Default — false. */ shadowCameraVisible: boolean; /** * Shadow map bias. * Default — 0. */ shadowBias: number; /** * Darkness of shadow casted by this light (from 0 to 1). * Default — 0.5. */ shadowDarkness: number; /** * Shadow map texture width in pixels. * Default — 512. */ shadowMapWidth: number; /** * Shadow map texture height in pixels. * Default — 512. */ shadowMapHeight: number; shadowMatrix: Matrix4; shadowMapSize: Vector2; shadowCamera: Camera; shadowMap: RenderTarget; clone(): SpotLight; } // Loaders ////////////////////////////////////////////////////////////////////////////////// export interface Progress { total: number; loaded: number; } /** * Base class for implementing loaders. * * Events: * load * Dispatched when the image has completed loading * content — loaded image * * error * * Dispatched when the image can't be loaded * message — error message */ export class Loader { constructor(showStatus?: boolean); /** * If true, show loading status in the statusDomElement. */ showStatus: boolean; /** * This is the recipient of status messages. */ statusDomElement: HTMLElement; /** * Will be called when load starts. * The default is a function with empty body. */ onLoadStart: () => void; /** * Will be called while load progresses. * The default is a function with empty body. */ onLoadProgress: () => void; /** * Will be called when load completes. * The default is a function with empty body. */ onLoadComplete: () => void; /** * default — null. * If set, assigns the crossOrigin attribute of the image to the value of crossOrigin, prior to starting the load. */ crossOrigin: string; needsTangents(materials: Material[]): boolean; updateProgress(progress: Progress): void; createMaterial(m: Material, texturePath: string): boolean; initMaterials(materials: Material[], texturePath: string): Material[]; extractUrlBase(url: string): string; addStatusElement(): HTMLElement; } export class BufferGeometryLoader { constructor(manager?: LoadingManager); load(url: string, onLoad: (bufferGeometry: BufferGeometry) => void): void; setCrossOrigin(crossOrigin: string): void; parse(json: any): BufferGeometry; } export class Cache{ constructor(); files: any[]; add(key: string, file: any): void; get(key: string): any; remove(key: string): void; clear(): void; } /** * A loa