declare module 'babylonjs' { export = BABYLON; } declare module BABYLON { /** * Defines how the parser contract is defined. * These parsers are used to parse a list of specific assets (like particle systems, etc..) */ type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void; /** * Defines how the individual parser contract is defined. * These parser can parse an individual asset */ type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any; /** * Base class of the scene acting as a container for the different elements composing a scene. * This class is dynamically extended by the different components of the scene increasing * flexibility and reducing coupling */ abstract class AbstractScene { /** * Stores the list of available parsers in the application. */ private static _BabylonFileParsers; /** * Stores the list of available individual parsers in the application. */ private static _IndividualBabylonFileParsers; /** * Adds a parser in the list of available ones * @param name Defines the name of the parser * @param parser Defines the parser to add */ static AddParser(name: string, parser: BabylonFileParser): void; /** * Gets a general parser from the list of avaialble ones * @param name Defines the name of the parser * @returns the requested parser or null */ static GetParser(name: string): Nullable; /** * Adds n individual parser in the list of available ones * @param name Defines the name of the parser * @param parser Defines the parser to add */ static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void; /** * Gets an individual parser from the list of avaialble ones * @param name Defines the name of the parser * @returns the requested parser or null */ static GetIndividualParser(name: string): Nullable; /** * Parser json data and populate both a scene and its associated container object * @param jsonData Defines the data to parse * @param scene Defines the scene to parse the data for * @param container Defines the container attached to the parsing sequence * @param rootUrl Defines the root url of the data */ static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void; /** * Gets the list of root nodes (ie. nodes with no parent) */ rootNodes: Node[]; /** All of the cameras added to this scene * @see http://doc.babylonjs.com/babylon101/cameras */ cameras: Camera[]; /** * All of the lights added to this scene * @see http://doc.babylonjs.com/babylon101/lights */ lights: Light[]; /** * All of the (abstract) meshes added to this scene */ meshes: AbstractMesh[]; /** * The list of skeletons added to the scene * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons */ skeletons: Skeleton[]; /** * All of the particle systems added to this scene * @see http://doc.babylonjs.com/babylon101/particles */ particleSystems: IParticleSystem[]; /** * Gets a list of Animations associated with the scene */ animations: Animation[]; /** * All of the animation groups added to this scene * @see http://doc.babylonjs.com/how_to/group */ animationGroups: AnimationGroup[]; /** * All of the multi-materials added to this scene * @see http://doc.babylonjs.com/how_to/multi_materials */ multiMaterials: MultiMaterial[]; /** * All of the materials added to this scene * @see http://doc.babylonjs.com/babylon101/materials */ materials: Material[]; /** * The list of morph target managers added to the scene * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh */ morphTargetManagers: MorphTargetManager[]; /** * The list of geometries used in the scene. */ geometries: Geometry[]; /** * All of the tranform nodes added to this scene * @see http://doc.babylonjs.com/how_to/transformnode */ transformNodes: TransformNode[]; /** * ActionManagers available on the scene. */ actionManagers: ActionManager[]; /** * Textures to keep. */ textures: BaseTexture[]; } } declare module BABYLON { /** * Set of assets to keep when moving a scene into an asset container. */ class KeepAssets extends AbstractScene { } /** * Container with a set of assets that can be added or removed from a scene. */ class AssetContainer extends AbstractScene { /** * The scene the AssetContainer belongs to. */ scene: Scene; /** * Instantiates an AssetContainer. * @param scene The scene the AssetContainer belongs to. */ constructor(scene: Scene); /** * Adds all the assets from the container to the scene. */ addAllToScene(): void; /** * Removes all the assets in the container from the scene */ removeAllFromScene(): void; private _moveAssets; /** * Removes all the assets contained in the scene and adds them to the container. * @param keepAssets Set of assets to keep in the scene. (default: empty) */ moveAllFromScene(keepAssets?: KeepAssets): void; /** * Adds all meshes in the asset container to a root mesh that can be used to position all the contained meshes. The root mesh is then added to the front of the meshes in the assetContainer. * @returns the root mesh */ createRootMesh(): Mesh; } } interface Window { mozIndexedDB: IDBFactory; webkitIndexedDB: IDBFactory; msIndexedDB: IDBFactory; webkitURL: typeof URL; mozRequestAnimationFrame(callback: FrameRequestCallback): number; oRequestAnimationFrame(callback: FrameRequestCallback): number; WebGLRenderingContext: WebGLRenderingContext; MSGesture: MSGesture; CANNON: any; AudioContext: AudioContext; webkitAudioContext: AudioContext; PointerEvent: any; Math: Math; Uint8Array: Uint8ArrayConstructor; Float32Array: Float32ArrayConstructor; mozURL: typeof URL; msURL: typeof URL; VRFrameData: any; DracoDecoderModule: any; setImmediate(handler: (...args: any[]) => void): number; } interface WebGLRenderingContext { drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void; drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void; vertexAttribDivisor(index: number, divisor: number): void; createVertexArray(): any; bindVertexArray(vao?: WebGLVertexArrayObject | null): void; deleteVertexArray(vao: WebGLVertexArrayObject): void; blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void; renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void; bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void; getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number; uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void; createQuery(): WebGLQuery; deleteQuery(query: WebGLQuery): void; beginQuery(target: number, query: WebGLQuery): void; endQuery(target: number): void; getQueryParameter(query: WebGLQuery, pname: number): any; getQuery(target: number, pname: number): any; MAX_SAMPLES: number; RGBA8: number; READ_FRAMEBUFFER: number; DRAW_FRAMEBUFFER: number; UNIFORM_BUFFER: number; HALF_FLOAT_OES: number; RGBA16F: number; RGBA32F: number; R32F: number; RG32F: number; RGB32F: number; R16F: number; RG16F: number; RGB16F: number; RED: number; RG: number; R8: number; RG8: number; UNSIGNED_INT_24_8: number; DEPTH24_STENCIL8: number; drawBuffers(buffers: number[]): void; readBuffer(src: number): void; readonly COLOR_ATTACHMENT0: number; readonly COLOR_ATTACHMENT1: number; readonly COLOR_ATTACHMENT2: number; readonly COLOR_ATTACHMENT3: number; ANY_SAMPLES_PASSED_CONSERVATIVE: number; ANY_SAMPLES_PASSED: number; QUERY_RESULT_AVAILABLE: number; QUERY_RESULT: number; } interface Document { mozCancelFullScreen(): void; msCancelFullScreen(): void; webkitCancelFullScreen(): void; requestPointerLock(): void; exitPointerLock(): void; fullscreen: boolean; mozFullScreen: boolean; msIsFullScreen: boolean; readonly webkitIsFullScreen: boolean; readonly pointerLockElement: Element; mozPointerLockElement: HTMLElement; msPointerLockElement: HTMLElement; webkitPointerLockElement: HTMLElement; } interface HTMLCanvasElement { requestPointerLock(): void; msRequestPointerLock?(): void; mozRequestPointerLock?(): void; webkitRequestPointerLock?(): void; } interface CanvasRenderingContext2D { msImageSmoothingEnabled: boolean; } interface WebGLBuffer { references: number; capacity: number; is32Bits: boolean; } interface WebGLProgram { transformFeedback?: WebGLTransformFeedback | null; __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null; } interface MouseEvent { mozMovementX: number; mozMovementY: number; webkitMovementX: number; webkitMovementY: number; msMovementX: number; msMovementY: number; } interface Navigator { mozGetVRDevices: (any: any) => any; webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void; mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void; msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void; webkitGetGamepads(): Gamepad[]; msGetGamepads(): Gamepad[]; webkitGamepads(): Gamepad[]; } interface HTMLVideoElement { mozSrcObject: any; } interface Element { webkitRequestFullScreen: () => void; } interface Screen { readonly orientation: string; readonly mozOrientation: string; } interface Math { fround(x: number): number; imul(a: number, b: number): number; } interface EXT_disjoint_timer_query { QUERY_COUNTER_BITS_EXT: number; TIME_ELAPSED_EXT: number; TIMESTAMP_EXT: number; GPU_DISJOINT_EXT: number; QUERY_RESULT_EXT: number; QUERY_RESULT_AVAILABLE_EXT: number; queryCounterEXT(query: WebGLQuery, target: number): void; createQueryEXT(): WebGLQuery; beginQueryEXT(target: number, query: WebGLQuery): void; endQueryEXT(target: number): void; getQueryObjectEXT(query: WebGLQuery, target: number): any; deleteQueryEXT(query: WebGLQuery): void; } interface WebGLUniformLocation { _currentState: any; } declare module BABYLON { /** * Defines how a node can be built from a string name. */ type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node; /** * Node is the basic class for all scene objects (Mesh, Light, Camera.) */ class Node implements IBehaviorAware { private static _NodeConstructors; /** * Add a new node constructor * @param type defines the type name of the node to construct * @param constructorFunc defines the constructor function */ static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void; /** * Returns a node constructor based on type name * @param type defines the type name * @param name defines the new node name * @param scene defines the hosting scene * @param options defines optional options to transmit to constructors * @returns the new constructor or null */ static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>; /** * Gets or sets the name of the node */ name: string; /** * Gets or sets the id of the node */ id: string; /** * Gets or sets the unique id of the node */ uniqueId: number; /** * Gets or sets a string used to store user defined state for the node */ state: string; /** * Gets or sets an object used to store user defined information for the node */ metadata: any; /** * Gets or sets a boolean used to define if the node must be serialized */ doNotSerialize: boolean; /** @hidden */ _isDisposed: boolean; /** * Gets a list of Animations associated with the node */ animations: Animation[]; protected _ranges: { [name: string]: Nullable; }; /** * Callback raised when the node is ready to be used */ onReady: (node: Node) => void; private _isEnabled; private _isParentEnabled; private _isReady; /** @hidden */ _currentRenderId: number; private _parentRenderId; protected _childRenderId: number; /** @hidden */ _waitingParentId: Nullable; /** @hidden */ _scene: Scene; /** @hidden */ _cache: any; private _parentNode; private _children; /** @hidden */ _worldMatrix: Matrix; /** @hidden */ _worldMatrixDeterminant: number; /** @hidden */ private _sceneRootNodesIndex; /** * Gets a boolean indicating if the node has been disposed * @returns true if the node was disposed */ isDisposed(): boolean; /** * Gets or sets the parent of the node */ parent: Nullable; private addToSceneRootNodes; private removeFromSceneRootNodes; private _animationPropertiesOverride; /** * Gets or sets the animation properties override */ animationPropertiesOverride: Nullable; /** * Gets a string idenfifying the name of the class * @returns "Node" string */ getClassName(): string; /** * An event triggered when the mesh is disposed */ onDisposeObservable: Observable; private _onDisposeObserver; /** * Sets a callback that will be raised when the node will be disposed */ onDispose: () => void; /** * Creates a new Node * @param name the name and id to be given to this node * @param scene the scene this node will be added to */ constructor(name: string, scene?: Nullable); /** * Gets the scene of the node * @returns a scene */ getScene(): Scene; /** * Gets the engine of the node * @returns a Engine */ getEngine(): Engine; private _behaviors; /** * Attach a behavior to the node * @see http://doc.babylonjs.com/features/behaviour * @param behavior defines the behavior to attach * @param attachImmediately defines that the behavior must be attached even if the scene is still loading * @returns the current Node */ addBehavior(behavior: Behavior, attachImmediately?: boolean): Node; /** * Remove an attached behavior * @see http://doc.babylonjs.com/features/behaviour * @param behavior defines the behavior to attach * @returns the current Node */ removeBehavior(behavior: Behavior): Node; /** * Gets the list of attached behaviors * @see http://doc.babylonjs.com/features/behaviour */ readonly behaviors: Behavior[]; /** * Gets an attached behavior by name * @param name defines the name of the behavior to look for * @see http://doc.babylonjs.com/features/behaviour * @returns null if behavior was not found else the requested behavior */ getBehaviorByName(name: string): Nullable>; /** * Returns the latest update of the World matrix * @returns a Matrix */ getWorldMatrix(): Matrix; /** @hidden */ _getWorldMatrixDeterminant(): number; /** * Returns directly the latest state of the mesh World matrix. * A Matrix is returned. */ readonly worldMatrixFromCache: Matrix; /** @hidden */ _initCache(): void; /** @hidden */ updateCache(force?: boolean): void; /** @hidden */ _updateCache(ignoreParentClass?: boolean): void; /** @hidden */ _isSynchronized(): boolean; /** @hidden */ _markSyncedWithParent(): void; /** @hidden */ isSynchronizedWithParent(): boolean; /** @hidden */ isSynchronized(): boolean; /** * Is this node ready to be used/rendered * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default) * @return true if the node is ready */ isReady(completeCheck?: boolean): boolean; /** * Is this node enabled? * If the node has a parent, all ancestors will be checked and false will be returned if any are false (not enabled), otherwise will return true * @param checkAncestors indicates if this method should check the ancestors. The default is to check the ancestors. If set to false, the method will return the value of this node without checking ancestors * @return whether this node (and its parent) is enabled */ isEnabled(checkAncestors?: boolean): boolean; /** @hidden */ protected _syncParentEnabledState(): void; /** * Set the enabled state of this node * @param value defines the new enabled state */ setEnabled(value: boolean): void; /** * Is this node a descendant of the given node? * The function will iterate up the hierarchy until the ancestor was found or no more parents defined * @param ancestor defines the parent node to inspect * @returns a boolean indicating if this node is a descendant of the given node */ isDescendantOf(ancestor: Node): boolean; /** @hidden */ _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void; /** * Will return all nodes that have this node as ascendant * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored * @return all children nodes of all types */ getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[]; /** * Get all child-meshes of this node * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored * @returns an array of AbstractMesh */ getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[]; /** * Get all child-transformNodes of this node * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored * @returns an array of TransformNode */ getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[]; /** * Get all direct children of this node * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored * @returns an array of Node */ getChildren(predicate?: (node: Node) => boolean): Node[]; /** @hidden */ _setReady(state: boolean): void; /** * Get an animation by name * @param name defines the name of the animation to look for * @returns null if not found else the requested animation */ getAnimationByName(name: string): Nullable; /** * Creates an animation range for this node * @param name defines the name of the range * @param from defines the starting key * @param to defines the end key */ createAnimationRange(name: string, from: number, to: number): void; /** * Delete a specific animation range * @param name defines the name of the range to delete * @param deleteFrames defines if animation frames from the range must be deleted as well */ deleteAnimationRange(name: string, deleteFrames?: boolean): void; /** * Get an animation range by name * @param name defines the name of the animation range to look for * @returns null if not found else the requested animation range */ getAnimationRange(name: string): Nullable; /** * Will start the animation sequence * @param name defines the range frames for animation sequence * @param loop defines if the animation should loop (false by default) * @param speedRatio defines the speed factor in which to run the animation (1 by default) * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default) * @returns the object created for this animation. If range does not exist, it will return null */ beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable; /** * Serialize animation ranges into a JSON compatible object * @returns serialization object */ serializeAnimationRanges(): any; /** * Computes the world matrix of the node * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch * @returns the world matrix */ computeWorldMatrix(force?: boolean): Matrix; /** * Releases resources associated with this node. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default) * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default) */ dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void; /** * Parse animation range data from a serialization object and store them into a given node * @param node defines where to store the animation ranges * @param parsedNode defines the serialization object to read data from * @param scene defines the hosting scene */ static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void; } } declare module BABYLON { /** * Define an interface for all classes that will hold resources */ interface IDisposable { /** * Releases all held resources */ dispose(): void; } /** * This class is used by the onRenderingGroupObservable */ class RenderingGroupInfo { /** * The Scene that being rendered */ scene: Scene; /** * The camera currently used for the rendering pass */ camera: Nullable; /** * The ID of the renderingGroup being processed */ renderingGroupId: number; } /** * Represents a scene to be rendered by the engine. * @see http://doc.babylonjs.com/features/scene */ class Scene extends AbstractScene implements IAnimatable { private static _uniqueIdCounter; /** The fog is deactivated */ static readonly FOGMODE_NONE: number; /** The fog density is following an exponential function */ static readonly FOGMODE_EXP: number; /** The fog density is following an exponential function faster than FOGMODE_EXP */ static readonly FOGMODE_EXP2: number; /** The fog density is following a linear function. */ static readonly FOGMODE_LINEAR: number; /** * Gets or sets the minimum deltatime when deterministic lock step is enabled * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */ static MinDeltaTime: number; /** * Gets or sets the maximum deltatime when deterministic lock step is enabled * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */ static MaxDeltaTime: number; /** * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame */ autoClear: boolean; /** * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame */ autoClearDepthAndStencil: boolean; /** * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0)) */ clearColor: Color4; /** * Defines the color used to simulate the ambient color (Default is (0, 0, 0)) */ ambientColor: Color3; /** @hidden */ _environmentBRDFTexture: BaseTexture; /** @hidden */ protected _environmentTexture: BaseTexture; /** * Texture used in all pbr material as the reflection texture. * As in the majority of the scene they are the same (exception for multi room and so on), * this is easier to reference from here than from all the materials. */ /** * Texture used in all pbr material as the reflection texture. * As in the majority of the scene they are the same (exception for multi room and so on), * this is easier to set here than in all the materials. */ environmentTexture: BaseTexture; /** @hidden */ protected _imageProcessingConfiguration: ImageProcessingConfiguration; /** * Default image processing configuration used either in the rendering * Forward main pass or through the imageProcessingPostProcess if present. * As in the majority of the scene they are the same (exception for multi camera), * this is easier to reference from here than from all the materials and post process. * * No setter as we it is a shared configuration, you can set the values instead. */ readonly imageProcessingConfiguration: ImageProcessingConfiguration; private _forceWireframe; /** * Gets or sets a boolean indicating if all rendering must be done in wireframe */ forceWireframe: boolean; private _forcePointsCloud; /** * Gets or sets a boolean indicating if all rendering must be done in point cloud */ forcePointsCloud: boolean; /** * Gets or sets the active clipplane 1 */ clipPlane: Nullable; /** * Gets or sets the active clipplane 2 */ clipPlane2: Nullable; /** * Gets or sets the active clipplane 3 */ clipPlane3: Nullable; /** * Gets or sets the active clipplane 4 */ clipPlane4: Nullable; /** * Gets or sets a boolean indicating if animations are enabled */ animationsEnabled: boolean; private _animationPropertiesOverride; /** * Gets or sets the animation properties override */ animationPropertiesOverride: Nullable; /** * Gets or sets a boolean indicating if a constant deltatime has to be used * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate */ useConstantAnimationDeltaTime: boolean; /** * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated * Please note that it requires to run a ray cast through the scene on every frame */ constantlyUpdateMeshUnderPointer: boolean; /** * Defines the HTML cursor to use when hovering over interactive elements */ hoverCursor: string; /** * Defines the HTML default cursor to use (empty by default) */ defaultCursor: string; /** * This is used to call preventDefault() on pointer down * in order to block unwanted artifacts like system double clicks */ preventDefaultOnPointerDown: boolean; /** * Gets or sets user defined metadata */ metadata: any; /** * Gets the name of the plugin used to load this scene (null by default) */ loadingPluginName: string; /** * Use this array to add regular expressions used to disable offline support for specific urls */ disableOfflineSupportExceptionRules: RegExp[]; /** * An event triggered when the scene is disposed. */ onDisposeObservable: Observable; private _onDisposeObserver; /** Sets a function to be executed when this scene is disposed. */ onDispose: () => void; /** * An event triggered before rendering the scene (right after animations and physics) */ onBeforeRenderObservable: Observable; private _onBeforeRenderObserver; /** Sets a function to be executed before rendering this scene */ beforeRender: Nullable<() => void>; /** * An event triggered after rendering the scene */ onAfterRenderObservable: Observable; private _onAfterRenderObserver; /** Sets a function to be executed after rendering this scene */ afterRender: Nullable<() => void>; /** * An event triggered before animating the scene */ onBeforeAnimationsObservable: Observable; /** * An event triggered after animations processing */ onAfterAnimationsObservable: Observable; /** * An event triggered before draw calls are ready to be sent */ onBeforeDrawPhaseObservable: Observable; /** * An event triggered after draw calls have been sent */ onAfterDrawPhaseObservable: Observable; /** * An event triggered when the scene is ready */ onReadyObservable: Observable; /** * An event triggered before rendering a camera */ onBeforeCameraRenderObservable: Observable; private _onBeforeCameraRenderObserver; /** Sets a function to be executed before rendering a camera*/ beforeCameraRender: () => void; /** * An event triggered after rendering a camera */ onAfterCameraRenderObservable: Observable; private _onAfterCameraRenderObserver; /** Sets a function to be executed after rendering a camera*/ afterCameraRender: () => void; /** * An event triggered when active meshes evaluation is about to start */ onBeforeActiveMeshesEvaluationObservable: Observable; /** * An event triggered when active meshes evaluation is done */ onAfterActiveMeshesEvaluationObservable: Observable; /** * An event triggered when particles rendering is about to start * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well) */ onBeforeParticlesRenderingObservable: Observable; /** * An event triggered when particles rendering is done * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well) */ onAfterParticlesRenderingObservable: Observable; /** * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed */ onDataLoadedObservable: Observable; /** * An event triggered when a camera is created */ onNewCameraAddedObservable: Observable; /** * An event triggered when a camera is removed */ onCameraRemovedObservable: Observable; /** * An event triggered when a light is created */ onNewLightAddedObservable: Observable; /** * An event triggered when a light is removed */ onLightRemovedObservable: Observable; /** * An event triggered when a geometry is created */ onNewGeometryAddedObservable: Observable; /** * An event triggered when a geometry is removed */ onGeometryRemovedObservable: Observable; /** * An event triggered when a transform node is created */ onNewTransformNodeAddedObservable: Observable; /** * An event triggered when a transform node is removed */ onTransformNodeRemovedObservable: Observable; /** * An event triggered when a mesh is created */ onNewMeshAddedObservable: Observable; /** * An event triggered when a mesh is removed */ onMeshRemovedObservable: Observable; /** * An event triggered when a material is created */ onNewMaterialAddedObservable: Observable; /** * An event triggered when a material is removed */ onMaterialRemovedObservable: Observable; /** * An event triggered when a texture is created */ onNewTextureAddedObservable: Observable; /** * An event triggered when a texture is removed */ onTextureRemovedObservable: Observable; /** * An event triggered when render targets are about to be rendered * Can happen multiple times per frame. */ onBeforeRenderTargetsRenderObservable: Observable; /** * An event triggered when render targets were rendered. * Can happen multiple times per frame. */ onAfterRenderTargetsRenderObservable: Observable; /** * An event triggered before calculating deterministic simulation step */ onBeforeStepObservable: Observable; /** * An event triggered after calculating deterministic simulation step */ onAfterStepObservable: Observable; /** * This Observable will be triggered before rendering each renderingGroup of each rendered camera. * The RenderinGroupInfo class contains all the information about the context in which the observable is called * If you wish to register an Observer only for a given set of renderingGroup, use the mask with a combination of the renderingGroup index elevated to the power of two (1 for renderingGroup 0, 2 for renderingrOup1, 4 for 2 and 8 for 3) */ onBeforeRenderingGroupObservable: Observable; /** * This Observable will be triggered after rendering each renderingGroup of each rendered camera. * The RenderinGroupInfo class contains all the information about the context in which the observable is called * If you wish to register an Observer only for a given set of renderingGroup, use the mask with a combination of the renderingGroup index elevated to the power of two (1 for renderingGroup 0, 2 for renderingrOup1, 4 for 2 and 8 for 3) */ onAfterRenderingGroupObservable: Observable; /** * This Observable will when a mesh has been imported into the scene. */ onMeshImportedObservable: Observable; private _registeredForLateAnimationBindings; /** * Gets or sets a predicate used to select candidate meshes for a pointer down event */ pointerDownPredicate: (Mesh: AbstractMesh) => boolean; /** * Gets or sets a predicate used to select candidate meshes for a pointer up event */ pointerUpPredicate: (Mesh: AbstractMesh) => boolean; /** * Gets or sets a predicate used to select candidate meshes for a pointer move event */ pointerMovePredicate: (Mesh: AbstractMesh) => boolean; private _onPointerMove; private _onPointerDown; private _onPointerUp; /** Deprecated. Use onPointerObservable instead */ onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void; /** Deprecated. Use onPointerObservable instead */ onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void; /** Deprecated. Use onPointerObservable instead */ onPointerUp: (evt: PointerEvent, pickInfo: Nullable, type: PointerEventTypes) => void; /** Deprecated. Use onPointerObservable instead */ onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void; /** * This observable event is triggered when any ponter event is triggered. It is registered during Scene.attachControl() and it is called BEFORE the 3D engine process anything (mesh/sprite picking for instance). * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true */ onPrePointerObservable: Observable; /** * Observable event triggered each time an input event is received from the rendering canvas */ onPointerObservable: Observable; /** * Gets the pointer coordinates without any translation (ie. straight out of the pointer event) */ readonly unTranslatedPointer: Vector2; /** The distance in pixel that you have to move to prevent some events */ static DragMovementThreshold: number; /** Time in milliseconds to wait to raise long press events if button is still pressed */ static LongPressDelay: number; /** Time in milliseconds with two consecutive clicks will be considered as a double click */ static DoubleClickDelay: number; /** If you need to check double click without raising a single click at first click, enable this flag */ static ExclusiveDoubleClickMode: boolean; private _initClickEvent; private _initActionManager; private _delayedSimpleClick; private _delayedSimpleClickTimeout; private _previousDelayedSimpleClickTimeout; private _meshPickProceed; private _previousButtonPressed; private _currentPickResult; private _previousPickResult; private _totalPointersPressed; private _doubleClickOccured; /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */ cameraToUseForPointers: Nullable; private _pointerX; private _pointerY; private _unTranslatedPointerX; private _unTranslatedPointerY; private _startingPointerPosition; private _previousStartingPointerPosition; private _startingPointerTime; private _previousStartingPointerTime; private _pointerCaptures; private _timeAccumulator; private _currentStepId; private _currentInternalStep; /** @hidden */ _mirroredCameraPosition: Nullable; /** * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl() * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true */ onPreKeyboardObservable: Observable; /** * Observable event triggered each time an keyboard event is received from the hosting window */ onKeyboardObservable: Observable; private _onKeyDown; private _onKeyUp; private _onCanvasFocusObserver; private _onCanvasBlurObserver; private _useRightHandedSystem; /** * Gets or sets a boolean indicating if the scene must use right-handed coordinates system */ useRightHandedSystem: boolean; /** * Sets the step Id used by deterministic lock step * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep * @param newStepId defines the step Id */ setStepId(newStepId: number): void; /** * Gets the step Id used by deterministic lock step * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep * @returns the step Id */ getStepId(): number; /** * Gets the internal step used by deterministic lock step * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep * @returns the internal step */ getInternalStep(): number; private _fogEnabled; /** * Gets or sets a boolean indicating if fog is enabled on this scene * @see http://doc.babylonjs.com/babylon101/environment#fog * (Default is true) */ fogEnabled: boolean; private _fogMode; /** * Gets or sets the fog mode to use * @see http://doc.babylonjs.com/babylon101/environment#fog * | mode | value | * | --- | --- | * | FOGMODE_NONE | 0 | * | FOGMODE_EXP | 1 | * | FOGMODE_EXP2 | 2 | * | FOGMODE_LINEAR | 3 | */ fogMode: number; /** * Gets or sets the fog color to use * @see http://doc.babylonjs.com/babylon101/environment#fog * (Default is Color3(0.2, 0.2, 0.3)) */ fogColor: Color3; /** * Gets or sets the fog density to use * @see http://doc.babylonjs.com/babylon101/environment#fog * (Default is 0.1) */ fogDensity: number; /** * Gets or sets the fog start distance to use * @see http://doc.babylonjs.com/babylon101/environment#fog * (Default is 0) */ fogStart: number; /** * Gets or sets the fog end distance to use * @see http://doc.babylonjs.com/babylon101/environment#fog * (Default is 1000) */ fogEnd: number; private _shadowsEnabled; /** * Gets or sets a boolean indicating if shadows are enabled on this scene */ shadowsEnabled: boolean; private _lightsEnabled; /** * Gets or sets a boolean indicating if lights are enabled on this scene */ lightsEnabled: boolean; /** All of the active cameras added to this scene. */ activeCameras: Camera[]; /** The current active camera */ activeCamera: Nullable; private _defaultMaterial; /** The default material used on meshes when no material is affected */ /** The default material used on meshes when no material is affected */ defaultMaterial: Material; private _texturesEnabled; /** * Gets or sets a boolean indicating if textures are enabled on this scene */ texturesEnabled: boolean; /** * Gets or sets a boolean indicating if particles are enabled on this scene */ particlesEnabled: boolean; /** * Gets or sets a boolean indicating if sprites are enabled on this scene */ spritesEnabled: boolean; private _skeletonsEnabled; /** * Gets or sets a boolean indicating if skeletons are enabled on this scene */ skeletonsEnabled: boolean; /** * Gets or sets a boolean indicating if lens flares are enabled on this scene */ lensFlaresEnabled: boolean; /** * Gets or sets a boolean indicating if collisions are enabled on this scene * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity */ collisionsEnabled: boolean; private _workerCollisions; /** @hidden */ collisionCoordinator: ICollisionCoordinator; /** * Defines the gravity applied to this scene (used only for collisions) * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity */ gravity: Vector3; /** * Gets or sets a boolean indicating if postprocesses are enabled on this scene */ postProcessesEnabled: boolean; /** * The list of postprocesses added to the scene */ postProcesses: PostProcess[]; /** * Gets the current postprocess manager */ postProcessManager: PostProcessManager; /** * Gets or sets a boolean indicating if render targets are enabled on this scene */ renderTargetsEnabled: boolean; /** * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com */ dumpNextRenderTargets: boolean; /** * The list of user defined render targets added to the scene */ customRenderTargets: RenderTargetTexture[]; /** * Defines if texture loading must be delayed * If true, textures will only be loaded when they need to be rendered */ useDelayedTextureLoading: boolean; /** * Gets the list of meshes imported to the scene through SceneLoader */ importedMeshesFiles: String[]; /** * Gets or sets a boolean indicating if probes are enabled on this scene */ probesEnabled: boolean; /** * @hidden */ database: Database; /** * Gets or sets the action manager associated with the scene * @see http://doc.babylonjs.com/how_to/how_to_use_actions */ actionManager: ActionManager; private _meshesForIntersections; /** * Gets or sets a boolean indicating if procedural textures are enabled on this scene */ proceduralTexturesEnabled: boolean; private _engine; private _totalVertices; /** @hidden */ _activeIndices: PerfCounter; /** @hidden */ _activeParticles: PerfCounter; /** @hidden */ _activeBones: PerfCounter; private _animationRatio; private _animationTimeLast; private _animationTime; /** * Gets or sets a general scale for animation speed * @see https://www.babylonjs-playground.com/#IBU2W7#3 */ animationTimeScale: number; /** @hidden */ _cachedMaterial: Nullable; /** @hidden */ _cachedEffect: Nullable; /** @hidden */ _cachedVisibility: Nullable; private _renderId; private _frameId; private _executeWhenReadyTimeoutId; private _intermediateRendering; private _viewUpdateFlag; private _projectionUpdateFlag; private _alternateViewUpdateFlag; private _alternateProjectionUpdateFlag; /** @hidden */ _toBeDisposed: Nullable[]; private _activeRequests; private _pendingData; private _isDisposed; /** * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound) */ dispatchAllSubMeshesOfActiveMeshes: boolean; private _activeMeshes; private _processedMaterials; private _renderTargets; /** @hidden */ _activeParticleSystems: SmartArray; private _activeSkeletons; private _softwareSkinnedMeshes; private _renderingManager; /** @hidden */ _activeAnimatables: Animatable[]; private _transformMatrix; private _sceneUbo; private _alternateSceneUbo; private _pickWithRayInverseMatrix; private _viewMatrix; private _projectionMatrix; private _alternateViewMatrix; private _alternateProjectionMatrix; private _alternateTransformMatrix; private _useAlternateCameraConfiguration; private _alternateRendering; /** @hidden */ _forcedViewPosition: Nullable; /** @hidden */ readonly _isAlternateRenderingEnabled: boolean; private _frustumPlanes; /** * Gets the list of frustum planes (built from the active camera) */ readonly frustumPlanes: Plane[]; /** * Gets or sets a boolean indicating if lights must be sorted by priority (off by default) * This is useful if there are more lights that the maximum simulteanous authorized */ requireLightSorting: boolean; private _pointerOverMesh; private _pickedDownMesh; private _pickedUpMesh; private _externalData; private _uid; /** * @hidden * Backing store of defined scene components. */ _components: ISceneComponent[]; /** * @hidden * Backing store of defined scene components. */ _serializableComponents: ISceneSerializableComponent[]; /** * List of components to register on the next registration step. */ private _transientComponents; /** * Registers the transient components if needed. */ private _registerTransientComponents; /** * @hidden * Add a component to the scene. * Note that the ccomponent could be registered on th next frame if this is called after * the register component stage. * @param component Defines the component to add to the scene */ _addComponent(component: ISceneComponent): void; /** * @hidden * Gets a component from the scene. * @param name defines the name of the component to retrieve * @returns the component or null if not present */ _getComponent(name: string): Nullable; /** * @hidden * Defines the actions happening before camera updates. */ _beforeCameraUpdateStage: Stage; /** * @hidden * Defines the actions happening before clear the canvas. */ _beforeClearStage: Stage; /** * @hidden * Defines the actions when collecting render targets for the frame. */ _gatherRenderTargetsStage: Stage; /** * @hidden * Defines the actions happening for one camera in the frame. */ _gatherActiveCameraRenderTargetsStage: Stage; /** * @hidden * Defines the actions happening during the per mesh ready checks. */ _isReadyForMeshStage: Stage; /** * @hidden * Defines the actions happening before evaluate active mesh checks. */ _beforeEvaluateActiveMeshStage: Stage; /** * @hidden * Defines the actions happening during the evaluate sub mesh checks. */ _evaluateSubMeshStage: Stage; /** * @hidden * Defines the actions happening during the active mesh stage. */ _activeMeshStage: Stage; /** * @hidden * Defines the actions happening during the per camera render target step. */ _cameraDrawRenderTargetStage: Stage; /** * @hidden * Defines the actions happening just before the active camera is drawing. */ _beforeCameraDrawStage: Stage; /** * @hidden * Defines the actions happening just before a rendering group is drawing. */ _beforeRenderingGroupDrawStage: Stage; /** * @hidden * Defines the actions happening just before a mesh is drawing. */ _beforeRenderingMeshStage: Stage; /** * @hidden * Defines the actions happening just after a mesh has been drawn. */ _afterRenderingMeshStage: Stage; /** * @hidden * Defines the actions happening just after a rendering group has been drawn. */ _afterRenderingGroupDrawStage: Stage; /** * @hidden * Defines the actions happening just after the active camera has been drawn. */ _afterCameraDrawStage: Stage; /** * @hidden * Defines the actions happening just after rendering all cameras and computing intersections. */ _afterRenderStage: Stage; /** * @hidden * Defines the actions happening when a pointer move event happens. */ _pointerMoveStage: Stage; /** * @hidden * Defines the actions happening when a pointer down event happens. */ _pointerDownStage: Stage; /** * @hidden * Defines the actions happening when a pointer up event happens. */ _pointerUpStage: Stage; /** * Creates a new Scene * @param engine defines the engine to use to render this scene */ constructor(engine: Engine); private _defaultMeshCandidates; /** * @hidden */ _getDefaultMeshCandidates(): ISmartArrayLike; private _defaultSubMeshCandidates; /** * @hidden */ _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike; /** * Sets the default candidate providers for the scene. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates * and getCollidingSubMeshCandidates to their default function */ setDefaultCandidateProviders(): void; /** * Gets a boolean indicating if collisions are processed on a web worker * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21 */ workerCollisions: boolean; /** * Gets the mesh that is currently under the pointer */ readonly meshUnderPointer: Nullable; /** * Gets the current on-screen X position of the pointer */ readonly pointerX: number; /** * Gets the current on-screen Y position of the pointer */ readonly pointerY: number; /** * Gets the cached material (ie. the latest rendered one) * @returns the cached material */ getCachedMaterial(): Nullable; /** * Gets the cached effect (ie. the latest rendered one) * @returns the cached effect */ getCachedEffect(): Nullable; /** * Gets the cached visibility state (ie. the latest rendered one) * @returns the cached visibility state */ getCachedVisibility(): Nullable; /** * Gets a boolean indicating if the current material / effect / visibility must be bind again * @param material defines the current material * @param effect defines the current effect * @param visibility defines the current visibility state * @returns true if one parameter is not cached */ isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean; /** * Gets the engine associated with the scene * @returns an Engine */ getEngine(): Engine; /** * Gets the total number of vertices rendered per frame * @returns the total number of vertices rendered per frame */ getTotalVertices(): number; /** * Gets the performance counter for total vertices * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation */ readonly totalVerticesPerfCounter: PerfCounter; /** * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3) * @returns the total number of active indices rendered per frame */ getActiveIndices(): number; /** * Gets the performance counter for active indices * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation */ readonly totalActiveIndicesPerfCounter: PerfCounter; /** * Gets the total number of active particles rendered per frame * @returns the total number of active particles rendered per frame */ getActiveParticles(): number; /** * Gets the performance counter for active particles * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation */ readonly activeParticlesPerfCounter: PerfCounter; /** * Gets the total number of active bones rendered per frame * @returns the total number of active bones rendered per frame */ getActiveBones(): number; /** * Gets the performance counter for active bones * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation */ readonly activeBonesPerfCounter: PerfCounter; /** @hidden */ getInterFramePerfCounter(): number; /** @hidden */ readonly interFramePerfCounter: Nullable; /** @hidden */ getLastFrameDuration(): number; /** @hidden */ readonly lastFramePerfCounter: Nullable; /** @hidden */ getEvaluateActiveMeshesDuration(): number; /** @hidden */ readonly evaluateActiveMeshesDurationPerfCounter: Nullable; /** * Gets the array of active meshes * @returns an array of AbstractMesh */ getActiveMeshes(): SmartArray; /** @hidden */ getRenderTargetsDuration(): number; /** @hidden */ getRenderDuration(): number; /** @hidden */ readonly renderDurationPerfCounter: Nullable; /** @hidden */ getParticlesDuration(): number; /** @hidden */ readonly particlesDurationPerfCounter: Nullable; /** @hidden */ getSpritesDuration(): number; /** @hidden */ readonly spriteDuractionPerfCounter: Nullable; /** * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.) * @returns a number */ getAnimationRatio(): number; /** * Gets an unique Id for the current render phase * @returns a number */ getRenderId(): number; /** * Gets an unique Id for the current frame * @returns a number */ getFrameId(): number; /** Call this function if you want to manually increment the render Id*/ incrementRenderId(): void; private _updatePointerPosition; private _createUbo; private _createAlternateUbo; private _setRayOnPointerInfo; /** * Use this method to simulate a pointer move on a mesh * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay * @param pickResult pickingInfo of the object wished to simulate pointer event on * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch) * @returns the current scene */ simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene; private _processPointerMove; private _checkPrePointerObservable; /** * Use this method to simulate a pointer down on a mesh * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay * @param pickResult pickingInfo of the object wished to simulate pointer event on * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch) * @returns the current scene */ simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene; private _processPointerDown; /** * Use this method to simulate a pointer up on a mesh * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay * @param pickResult pickingInfo of the object wished to simulate pointer event on * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch) * @returns the current scene */ simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene; private _processPointerUp; /** * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down) * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default) * @returns true if the pointer was captured */ isPointerCaptured(pointerId?: number): boolean; /** @hidden */ _isPointerSwiping(): boolean; /** * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp * @param attachUp defines if you want to attach events to pointerup * @param attachDown defines if you want to attach events to pointerdown * @param attachMove defines if you want to attach events to pointermove */ attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void; /** Detaches all event handlers*/ detachControl(): void; /** * This function will check if the scene can be rendered (textures are loaded, shaders are compiled) * Delay loaded resources are not taking in account * @return true if all required resources are ready */ isReady(): boolean; /** Resets all cached information relative to material (including effect and visibility) */ resetCachedMaterial(): void; /** * Registers a function to be called before every frame render * @param func defines the function to register */ registerBeforeRender(func: () => void): void; /** * Unregisters a function called before every frame render * @param func defines the function to unregister */ unregisterBeforeRender(func: () => void): void; /** * Registers a function to be called after every frame render * @param func defines the function to register */ registerAfterRender(func: () => void): void; /** * Unregisters a function called after every frame render * @param func defines the function to unregister */ unregisterAfterRender(func: () => void): void; private _executeOnceBeforeRender; /** * The provided function will run before render once and will be disposed afterwards. * A timeout delay can be provided so that the function will be executed in N ms. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed. * @param func The function to be executed. * @param timeout optional delay in ms */ executeOnceBeforeRender(func: () => void, timeout?: number): void; /** @hidden */ _addPendingData(data: any): void; /** @hidden */ _removePendingData(data: any): void; /** * Returns the number of items waiting to be loaded * @returns the number of items waiting to be loaded */ getWaitingItemsCount(): number; /** * Returns a boolean indicating if the scene is still loading data */ readonly isLoading: boolean; /** * Registers a function to be executed when the scene is ready * @param {Function} func - the function to be executed */ executeWhenReady(func: () => void): void; /** * Returns a promise that resolves when the scene is ready * @returns A promise that resolves when the scene is ready */ whenReadyAsync(): Promise; /** @hidden */ _checkIsReady(): void; /** * Will start the animation sequence of a given target * @param target defines the target * @param from defines from which frame should animation start * @param to defines until which frame should animation run. * @param weight defines the weight to apply to the animation (1.0 by default) * @param loop defines if the animation loops * @param speedRatio defines the speed in which to run the animation (1.0 by default) * @param onAnimationEnd defines the function to be executed when the animation ends * @param animatable defines an animatable object. If not provided a new one will be created from the given params * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value) * @returns the animatable object created for this animation */ beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean): Animatable; /** * Will start the animation sequence of a given target * @param target defines the target * @param from defines from which frame should animation start * @param to defines until which frame should animation run. * @param loop defines if the animation loops * @param speedRatio defines the speed in which to run the animation (1.0 by default) * @param onAnimationEnd defines the function to be executed when the animation ends * @param animatable defines an animatable object. If not provided a new one will be created from the given params * @param stopCurrent defines if the current animations must be stopped first (true by default) * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value) * @returns the animatable object created for this animation */ beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean): Animatable; /** * Begin a new animation on a given node * @param target defines the target where the animation will take place * @param animations defines the list of animations to start * @param from defines the initial value * @param to defines the final value * @param loop defines if you want animation to loop (off by default) * @param speedRatio defines the speed ratio to apply to all animations * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node) * @returns the list of created animatables */ beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable; /** * Begin a new animation on a given node and its hierarchy * @param target defines the root node where the animation will take place * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used. * @param animations defines the list of animations to start * @param from defines the initial value * @param to defines the final value * @param loop defines if you want animation to loop (off by default) * @param speedRatio defines the speed ratio to apply to all animations * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node) * @returns the list of animatables created for all nodes */ beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable[]; /** * Gets the animatable associated with a specific target * @param target defines the target of the animatable * @returns the required animatable if found */ getAnimatableByTarget(target: any): Nullable; /** * Gets all animatables associated with a given target * @param target defines the target to look animatables for * @returns an array of Animatables */ getAllAnimatablesByTarget(target: any): Array; /** * Gets all animatable attached to the scene */ readonly animatables: Animatable[]; /** * Will stop the animation of the given target * @param target - the target * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty) * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty) */ stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void; /** * Stops and removes all animations that have been applied to the scene */ stopAllAnimations(): void; private _animate; /** @hidden */ _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void; private _processLateAnimationBindingsForMatrices; private _processLateAnimationBindingsForQuaternions; private _processLateAnimationBindings; /** @hidden */ _switchToAlternateCameraConfiguration(active: boolean): void; /** * Gets the current view matrix * @returns a Matrix */ getViewMatrix(): Matrix; /** * Gets the current projection matrix * @returns a Matrix */ getProjectionMatrix(): Matrix; /** * Gets the current transform matrix * @returns a Matrix made of View * Projection */ getTransformMatrix(): Matrix; /** * Sets the current transform matrix * @param view defines the View matrix to use * @param projection defines the Projection matrix to use */ setTransformMatrix(view: Matrix, projection: Matrix): void; /** @hidden */ _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void; /** * Gets the uniform buffer used to store scene data * @returns a UniformBuffer */ getSceneUniformBuffer(): UniformBuffer; /** * Gets an unique (relatively to the current scene) Id * @returns an unique number for the scene */ getUniqueId(): number; /** * Add a mesh to the list of scene's meshes * @param newMesh defines the mesh to add * @param recursive if all child meshes should also be added to the scene */ addMesh(newMesh: AbstractMesh, recursive?: boolean): void; /** * Remove a mesh for the list of scene's meshes * @param toRemove defines the mesh to remove * @param recursive if all child meshes should also be removed from the scene * @returns the index where the mesh was in the mesh list */ removeMesh(toRemove: AbstractMesh, recursive?: boolean): number; /** * Add a transform node to the list of scene's transform nodes * @param newTransformNode defines the transform node to add */ addTransformNode(newTransformNode: TransformNode): void; /** * Remove a transform node for the list of scene's transform nodes * @param toRemove defines the transform node to remove * @returns the index where the transform node was in the transform node list */ removeTransformNode(toRemove: TransformNode): number; /** * Remove a skeleton for the list of scene's skeletons * @param toRemove defines the skeleton to remove * @returns the index where the skeleton was in the skeleton list */ removeSkeleton(toRemove: Skeleton): number; /** * Remove a morph target for the list of scene's morph targets * @param toRemove defines the morph target to remove * @returns the index where the morph target was in the morph target list */ removeMorphTargetManager(toRemove: MorphTargetManager): number; /** * Remove a light for the list of scene's lights * @param toRemove defines the light to remove * @returns the index where the light was in the light list */ removeLight(toRemove: Light): number; /** * Remove a camera for the list of scene's cameras * @param toRemove defines the camera to remove * @returns the index where the camera was in the camera list */ removeCamera(toRemove: Camera): number; /** * Remove a particle system for the list of scene's particle systems * @param toRemove defines the particle system to remove * @returns the index where the particle system was in the particle system list */ removeParticleSystem(toRemove: IParticleSystem): number; /** * Remove a animation for the list of scene's animations * @param toRemove defines the animation to remove * @returns the index where the animation was in the animation list */ removeAnimation(toRemove: Animation): number; /** * Removes the given animation group from this scene. * @param toRemove The animation group to remove * @returns The index of the removed animation group */ removeAnimationGroup(toRemove: AnimationGroup): number; /** * Removes the given multi-material from this scene. * @param toRemove The multi-material to remove * @returns The index of the removed multi-material */ removeMultiMaterial(toRemove: MultiMaterial): number; /** * Removes the given material from this scene. * @param toRemove The material to remove * @returns The index of the removed material */ removeMaterial(toRemove: Material): number; /** * Removes the given action manager from this scene. * @param toRemove The action manager to remove * @returns The index of the removed action manager */ removeActionManager(toRemove: ActionManager): number; /** * Removes the given texture from this scene. * @param toRemove The texture to remove * @returns The index of the removed texture */ removeTexture(toRemove: BaseTexture): number; /** * Adds the given light to this scene * @param newLight The light to add */ addLight(newLight: Light): void; /** * Sorts the list list based on light priorities */ sortLightsByPriority(): void; /** * Adds the given camera to this scene * @param newCamera The camera to add */ addCamera(newCamera: Camera): void; /** * Adds the given skeleton to this scene * @param newSkeleton The skeleton to add */ addSkeleton(newSkeleton: Skeleton): void; /** * Adds the given particle system to this scene * @param newParticleSystem The particle system to add */ addParticleSystem(newParticleSystem: IParticleSystem): void; /** * Adds the given animation to this scene * @param newAnimation The animation to add */ addAnimation(newAnimation: Animation): void; /** * Adds the given animation group to this scene. * @param newAnimationGroup The animation group to add */ addAnimationGroup(newAnimationGroup: AnimationGroup): void; /** * Adds the given multi-material to this scene * @param newMultiMaterial The multi-material to add */ addMultiMaterial(newMultiMaterial: MultiMaterial): void; /** * Adds the given material to this scene * @param newMaterial The material to add */ addMaterial(newMaterial: Material): void; /** * Adds the given morph target to this scene * @param newMorphTargetManager The morph target to add */ addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void; /** * Adds the given geometry to this scene * @param newGeometry The geometry to add */ addGeometry(newGeometry: Geometry): void; /** * Adds the given action manager to this scene * @param newActionManager The action manager to add */ addActionManager(newActionManager: ActionManager): void; /** * Adds the given texture to this scene. * @param newTexture The texture to add */ addTexture(newTexture: BaseTexture): void; /** * Switch active camera * @param newCamera defines the new active camera * @param attachControl defines if attachControl must be called for the new active camera (default: true) */ switchActiveCamera(newCamera: Camera, attachControl?: boolean): void; /** * sets the active camera of the scene using its ID * @param id defines the camera's ID * @return the new active camera or null if none found. */ setActiveCameraByID(id: string): Nullable; /** * sets the active camera of the scene using its name * @param name defines the camera's name * @returns the new active camera or null if none found. */ setActiveCameraByName(name: string): Nullable; /** * get an animation group using its name * @param name defines the material's name * @return the animation group or null if none found. */ getAnimationGroupByName(name: string): Nullable; /** * get a material using its id * @param id defines the material's ID * @return the material or null if none found. */ getMaterialByID(id: string): Nullable; /** * Gets a material using its name * @param name defines the material's name * @return the material or null if none found. */ getMaterialByName(name: string): Nullable; /** * Gets a camera using its id * @param id defines the id to look for * @returns the camera or null if not found */ getCameraByID(id: string): Nullable; /** * Gets a camera using its unique id * @param uniqueId defines the unique id to look for * @returns the camera or null if not found */ getCameraByUniqueID(uniqueId: number): Nullable; /** * Gets a camera using its name * @param name defines the camera's name * @return the camera or null if none found. */ getCameraByName(name: string): Nullable; /** * Gets a bone using its id * @param id defines the bone's id * @return the bone or null if not found */ getBoneByID(id: string): Nullable; /** * Gets a bone using its id * @param name defines the bone's name * @return the bone or null if not found */ getBoneByName(name: string): Nullable; /** * Gets a light node using its name * @param name defines the the light's name * @return the light or null if none found. */ getLightByName(name: string): Nullable; /** * Gets a light node using its id * @param id defines the light's id * @return the light or null if none found. */ getLightByID(id: string): Nullable; /** * Gets a light node using its scene-generated unique ID * @param uniqueId defines the light's unique id * @return the light or null if none found. */ getLightByUniqueID(uniqueId: number): Nullable; /** * Gets a particle system by id * @param id defines the particle system id * @return the corresponding system or null if none found */ getParticleSystemByID(id: string): Nullable; /** * Gets a geometry using its ID * @param id defines the geometry's id * @return the geometry or null if none found. */ getGeometryByID(id: string): Nullable; /** * Add a new geometry to this scene * @param geometry defines the geometry to be added to the scene. * @param force defines if the geometry must be pushed even if a geometry with this id already exists * @return a boolean defining if the geometry was added or not */ pushGeometry(geometry: Geometry, force?: boolean): boolean; /** * Removes an existing geometry * @param geometry defines the geometry to be removed from the scene * @return a boolean defining if the geometry was removed or not */ removeGeometry(geometry: Geometry): boolean; /** * Gets the list of geometries attached to the scene * @returns an array of Geometry */ getGeometries(): Geometry[]; /** * Gets the first added mesh found of a given ID * @param id defines the id to search for * @return the mesh found or null if not found at all */ getMeshByID(id: string): Nullable; /** * Gets a list of meshes using their id * @param id defines the id to search for * @returns a list of meshes */ getMeshesByID(id: string): Array; /** * Gets the first added transform node found of a given ID * @param id defines the id to search for * @return the found transform node or null if not found at all. */ getTransformNodeByID(id: string): Nullable; /** * Gets a list of transform nodes using their id * @param id defines the id to search for * @returns a list of transform nodes */ getTransformNodesByID(id: string): Array; /** * Gets a mesh with its auto-generated unique id * @param uniqueId defines the unique id to search for * @return the found mesh or null if not found at all. */ getMeshByUniqueID(uniqueId: number): Nullable; /** * Gets a the last added mesh using a given id * @param id defines the id to search for * @return the found mesh or null if not found at all. */ getLastMeshByID(id: string): Nullable; /** * Gets a the last added node (Mesh, Camera, Light) using a given id * @param id defines the id to search for * @return the found node or null if not found at all */ getLastEntryByID(id: string): Nullable; /** * Gets a node (Mesh, Camera, Light) using a given id * @param id defines the id to search for * @return the found node or null if not found at all */ getNodeByID(id: string): Nullable; /** * Gets a node (Mesh, Camera, Light) using a given name * @param name defines the name to search for * @return the found node or null if not found at all. */ getNodeByName(name: string): Nullable; /** * Gets a mesh using a given name * @param name defines the name to search for * @return the found mesh or null if not found at all. */ getMeshByName(name: string): Nullable; /** * Gets a transform node using a given name * @param name defines the name to search for * @return the found transform node or null if not found at all. */ getTransformNodeByName(name: string): Nullable; /** * Gets a skeleton using a given id (if many are found, this function will pick the last one) * @param id defines the id to search for * @return the found skeleton or null if not found at all. */ getLastSkeletonByID(id: string): Nullable; /** * Gets a skeleton using a given id (if many are found, this function will pick the first one) * @param id defines the id to search for * @return the found skeleton or null if not found at all. */ getSkeletonById(id: string): Nullable; /** * Gets a skeleton using a given name * @param name defines the name to search for * @return the found skeleton or null if not found at all. */ getSkeletonByName(name: string): Nullable; /** * Gets a morph target manager using a given id (if many are found, this function will pick the last one) * @param id defines the id to search for * @return the found morph target manager or null if not found at all. */ getMorphTargetManagerById(id: number): Nullable; /** * Gets a boolean indicating if the given mesh is active * @param mesh defines the mesh to look for * @returns true if the mesh is in the active list */ isActiveMesh(mesh: AbstractMesh): boolean; /** * Return a unique id as a string which can serve as an identifier for the scene */ readonly uid: string; /** * Add an externaly attached data from its key. * This method call will fail and return false, if such key already exists. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method. * @param key the unique key that identifies the data * @param data the data object to associate to the key for this Engine instance * @return true if no such key were already present and the data was added successfully, false otherwise */ addExternalData(key: string, data: T): boolean; /** * Get an externaly attached data from its key * @param key the unique key that identifies the data * @return the associated data, if present (can be null), or undefined if not present */ getExternalData(key: string): Nullable; /** * Get an externaly attached data from its key, create it using a factory if it's not already present * @param key the unique key that identifies the data * @param factory the factory that will be called to create the instance if and only if it doesn't exists * @return the associated data, can be null if the factory returned null. */ getOrAddExternalDataWithFactory(key: string, factory: (k: string) => T): T; /** * Remove an externaly attached data from the Engine instance * @param key the unique key that identifies the data * @return true if the data was successfully removed, false if it doesn't exist */ removeExternalData(key: string): boolean; private _evaluateSubMesh; /** * Clear the processed materials smart array preventing retention point in material dispose. */ freeProcessedMaterials(): void; /** * Clear the active meshes smart array preventing retention point in mesh dispose. */ freeActiveMeshes(): void; /** * Clear the info related to rendering groups preventing retention points during dispose. */ freeRenderingGroups(): void; /** @hidden */ _isInIntermediateRendering(): boolean; /** * Lambda returning the list of potentially active meshes. */ getActiveMeshCandidates: () => ISmartArrayLike; /** * Lambda returning the list of potentially active sub meshes. */ getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike; /** * Lambda returning the list of potentially intersecting sub meshes. */ getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike; /** * Lambda returning the list of potentially colliding sub meshes. */ getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike; private _activeMeshesFrozen; /** * Use this function to stop evaluating active meshes. The current list will be keep alive between frames * @returns the current scene */ freezeActiveMeshes(): Scene; /** * Use this function to restart evaluating active meshes on every frame * @returns the current scene */ unfreezeActiveMeshes(): Scene; private _evaluateActiveMeshes; private _activeMesh; /** * Update the transform matrix to update from the current active camera * @param force defines a boolean used to force the update even if cache is up to date */ updateTransformMatrix(force?: boolean): void; /** * Defines an alternate camera (used mostly in VR-like scenario where two cameras can render the same scene from a slightly different point of view) * @param alternateCamera defines the camera to use */ updateAlternateTransformMatrix(alternateCamera: Camera): void; /** @hidden */ _allowPostProcessClearColor: boolean; private _renderForCamera; private _processSubCameras; private _checkIntersections; /** @hidden */ _advancePhysicsEngineStep(step: number): void; /** * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode */ getDeterministicFrameTime: () => number; /** * Render the scene * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default) */ render(updateCameras?: boolean): void; /** * Freeze all materials * A frozen material will not be updatable but should be faster to render */ freezeMaterials(): void; /** * Unfreeze all materials * A frozen material will not be updatable but should be faster to render */ unfreezeMaterials(): void; /** * Releases all held ressources */ dispose(): void; /** * Gets if the scene is already disposed */ readonly isDisposed: boolean; /** * Call this function to reduce memory footprint of the scene. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly) */ clearCachedVertexData(): void; /** * This function will remove the local cached buffer data from texture. * It will save memory but will prevent the texture from being rebuilt */ cleanCachedTextureBuffer(): void; /** * Get the world extend vectors with an optional filter * * @param filterPredicate the predicate - which meshes should be included when calculating the world size * @returns {{ min: Vector3; max: Vector3 }} min and max vectors */ getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): { min: Vector3; max: Vector3; }; /** * Creates a ray that can be used to pick in the scene * @param x defines the x coordinate of the origin (on-screen) * @param y defines the y coordinate of the origin (on-screen) * @param world defines the world matrix to use if you want to pick in object space (instead of world space) * @param camera defines the camera to use for the picking * @param cameraViewSpace defines if picking will be done in view space (false by default) * @returns a Ray */ createPickingRay(x: number, y: number, world: Matrix, camera: Nullable, cameraViewSpace?: boolean): Ray; /** * Creates a ray that can be used to pick in the scene * @param x defines the x coordinate of the origin (on-screen) * @param y defines the y coordinate of the origin (on-screen) * @param world defines the world matrix to use if you want to pick in object space (instead of world space) * @param result defines the ray where to store the picking ray * @param camera defines the camera to use for the picking * @param cameraViewSpace defines if picking will be done in view space (false by default) * @returns the current scene */ createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable, cameraViewSpace?: boolean): Scene; /** * Creates a ray that can be used to pick in the scene * @param x defines the x coordinate of the origin (on-screen) * @param y defines the y coordinate of the origin (on-screen) * @param camera defines the camera to use for the picking * @returns a Ray */ createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray; /** * Creates a ray that can be used to pick in the scene * @param x defines the x coordinate of the origin (on-screen) * @param y defines the y coordinate of the origin (on-screen) * @param result defines the ray where to store the picking ray * @param camera defines the camera to use for the picking * @returns the current scene */ createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene; private _internalPick; private _internalMultiPick; private _tempPickingRay; /** Launch a ray to try to pick a mesh in the scene * @param x position on screen * @param y position on screen * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used * @returns a PickingInfo */ pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable): Nullable; private _cachedRayForTransform; /** Use the given ray to pick a mesh in the scene * @param ray The ray to use to pick meshes * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must have isPickable set to true * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null * @returns a PickingInfo */ pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable; /** * Launch a ray to try to pick a mesh in the scene * @param x X position on screen * @param y Y position on screen * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used * @returns an array of PickingInfo */ multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable; /** * Launch a ray to try to pick a mesh in the scene * @param ray Ray to use * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true * @returns an array of PickingInfo */ multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable; /** * Force the value of meshUnderPointer * @param mesh defines the mesh to use */ setPointerOverMesh(mesh: Nullable): void; /** * Gets the mesh under the pointer * @returns a Mesh or null if no mesh is under the pointer */ getPointerOverMesh(): Nullable; /** @hidden */ _rebuildGeometries(): void; /** @hidden */ _rebuildTextures(): void; private _getByTags; /** * Get a list of meshes by tags * @param tagsQuery defines the tags query to use * @param forEach defines a predicate used to filter results * @returns an array of Mesh */ getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[]; /** * Get a list of cameras by tags * @param tagsQuery defines the tags query to use * @param forEach defines a predicate used to filter results * @returns an array of Camera */ getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[]; /** * Get a list of lights by tags * @param tagsQuery defines the tags query to use * @param forEach defines a predicate used to filter results * @returns an array of Light */ getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[]; /** * Get a list of materials by tags * @param tagsQuery defines the tags query to use * @param forEach defines a predicate used to filter results * @returns an array of Material */ getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[]; /** * Overrides the default sort function applied in the renderging group to prepare the meshes. * This allowed control for front to back rendering or reversly depending of the special needs. * * @param renderingGroupId The rendering group id corresponding to its index * @param opaqueSortCompareFn The opaque queue comparison function use to sort. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort. * @param transparentSortCompareFn The transparent queue comparison function use to sort. */ setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void; /** * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups. * * @param renderingGroupId The rendering group id corresponding to its index * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true. * @param depth Automatically clears depth between groups if true and autoClear is true. * @param stencil Automatically clears stencil between groups if true and autoClear is true. */ setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void; /** * Gets the current auto clear configuration for one rendering group of the rendering * manager. * @param index the rendering group index to get the information for * @returns The auto clear setup for the requested rendering group */ getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup; private _blockMaterialDirtyMechanism; /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */ blockMaterialDirtyMechanism: boolean; /** * Will flag all materials as dirty to trigger new shader compilation * @param flag defines the flag used to specify which material part must be marked as dirty * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty */ markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void; /** @hidden */ _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useDatabase?: boolean, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest; /** @hidden */ _loadFileAsync(url: string, useDatabase?: boolean, useArrayBuffer?: boolean): Promise; } } declare module BABYLON { /** * Groups all the scene component constants in one place to ease maintenance. * @hidden */ class SceneComponentConstants { static readonly NAME_EFFECTLAYER: string; static readonly NAME_LAYER: string; static readonly NAME_LENSFLARESYSTEM: string; static readonly NAME_BOUNDINGBOXRENDERER: string; static readonly NAME_PARTICLESYSTEM: string; static readonly NAME_GAMEPAD: string; static readonly NAME_SIMPLIFICATIONQUEUE: string; static readonly NAME_GEOMETRYBUFFERRENDERER: string; static readonly NAME_DEPTHRENDERER: string; static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string; static readonly NAME_SPRITE: string; static readonly NAME_OUTLINERENDERER: string; static readonly NAME_PROCEDURALTEXTURE: string; static readonly NAME_SHADOWGENERATOR: string; static readonly NAME_OCTREE: string; static readonly NAME_PHYSICSENGINE: string; static readonly NAME_AUDIO: string; static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number; static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number; static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number; static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number; static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number; static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number; static readonly STEP_BEFORECAMERADRAW_LAYER: number; static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number; static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number; static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number; static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number; static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number; static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number; static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number; static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number; static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number; static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number; static readonly STEP_AFTERCAMERADRAW_LAYER: number; static readonly STEP_AFTERRENDER_AUDIO: number; static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number; static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number; static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number; static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number; static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number; static readonly STEP_POINTERMOVE_SPRITE: number; static readonly STEP_POINTERDOWN_SPRITE: number; static readonly STEP_POINTERUP_SPRITE: number; } /** * This represents a scene component. * * This is used to decouple the dependency the scene is having on the different workloads like * layers, post processes... */ interface ISceneComponent { /** * The name of the component. Each component must have a unique name. */ name: string; /** * The scene the component belongs to. */ scene: Scene; /** * Register the component to one instance of a scene. */ register(): void; /** * Rebuilds the elements related to this component in case of * context lost for instance. */ rebuild(): void; /** * Disposes the component and the associated ressources. */ dispose(): void; } /** * This represents a SERIALIZABLE scene component. * * This extends Scene Component to add Serialization methods on top. */ interface ISceneSerializableComponent extends ISceneComponent { /** * Adds all the element from the container to the scene * @param container the container holding the elements */ addFromContainer(container: AbstractScene): void; /** * Removes all the elements in the container from the scene * @param container contains the elements to remove */ removeFromContainer(container: AbstractScene): void; /** * Serializes the component data to the specified json object * @param serializationObject The object to serialize to */ serialize(serializationObject: any): void; } /** * Strong typing of a Mesh related stage step action */ type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean; /** * Strong typing of a Evaluate Sub Mesh related stage step action */ type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void; /** * Strong typing of a Active Mesh related stage step action */ type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void; /** * Strong typing of a Camera related stage step action */ type CameraStageAction = (camera: Camera) => void; /** * Strong typing of a RenderingGroup related stage step action */ type RenderingGroupStageAction = (renderingGroupId: number) => void; /** * Strong typing of a Mesh Render related stage step action */ type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void; /** * Strong typing of a simple stage step action */ type SimpleStageAction = () => void; /** * Strong typing of a render target action. */ type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate) => void; /** * Strong typing of a pointer move action. */ type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable; /** * Strong typing of a pointer up/down action. */ type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable, evt: PointerEvent) => Nullable; /** * Repressentation of a stage in the scene (Basically a list of ordered steps) * @hidden */ class Stage extends Array<{ index: number; component: ISceneComponent; action: T; }> { /** * Hide ctor from the rest of the world. * @param items The items to add. */ private constructor(); /** * Creates a new Stage. * @returns A new instance of a Stage */ static Create(): Stage; /** * Registers a step in an ordered way in the targeted stage. * @param index Defines the position to register the step in * @param component Defines the component attached to the step * @param action Defines the action to launch during the step */ registerStep(index: number, component: ISceneComponent, action: T): void; /** * Clears all the steps from the stage. */ clear(): void; } } declare module BABYLON { /** Alias type for value that can be null */ type Nullable = T | null; /** * Alias type for number that are floats * @ignorenaming */ type float = number; /** * Alias type for number that are doubles. * @ignorenaming */ type double = number; /** * Alias type for number that are integer * @ignorenaming */ type int = number; /** Alias type for number array or Float32Array */ type FloatArray = number[] | Float32Array; /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */ type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array; /** * Alias for types that can be used by a Buffer or VertexBuffer. */ type DataArray = number[] | ArrayBuffer | ArrayBufferView; } declare module BABYLON { /** * The action to be carried out following a trigger * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions */ class Action { /** the trigger, with or without parameters, for the action */ triggerOptions: any; /** * Trigger for the action */ trigger: number; /** * Internal only - manager for action * @hidden */ _actionManager: ActionManager; private _nextActiveAction; private _child; private _condition?; private _triggerParameter; /** * An event triggered prior to action being executed. */ onBeforeExecuteObservable: Observable; /** * Creates a new Action * @param triggerOptions the trigger, with or without parameters, for the action * @param condition an optional determinant of action */ constructor( /** the trigger, with or without parameters, for the action */ triggerOptions: any, condition?: Condition); /** * Internal only * @hidden */ _prepare(): void; /** * Gets the trigger parameters * @returns the trigger parameters */ getTriggerParameter(): any; /** * Internal only - executes current action event * @hidden */ _executeCurrent(evt?: ActionEvent): void; /** * Execute placeholder for child classes * @param evt optional action event */ execute(evt?: ActionEvent): void; /** * Skips to next active action */ skipToNextActiveAction(): void; /** * Adds action to chain of actions, may be a DoNothingAction * @param action defines the next action to execute * @returns The action passed in * @see https://www.babylonjs-playground.com/#1T30HR#0 */ then(action: Action): Action; /** * Internal only * @hidden */ _getProperty(propertyPath: string): string; /** * Internal only * @hidden */ _getEffectiveTarget(target: any, propertyPath: string): any; /** * Serialize placeholder for child classes * @param parent of child * @returns the serialized object */ serialize(parent: any): any; /** * Internal only called by serialize * @hidden */ protected _serialize(serializedAction: any, parent?: any): any; /** * Internal only * @hidden */ static _SerializeValueAsString: (value: any) => string; /** * Internal only * @hidden */ static _GetTargetProperty: (target: Scene | Node) => { name: string; targetType: string; value: string; }; } } declare module BABYLON { /** * ActionEvent is the event being sent when an action is triggered. */ class ActionEvent { /** The mesh or sprite that triggered the action */ source: any; /** The X mouse cursor position at the time of the event */ pointerX: number; /** The Y mouse cursor position at the time of the event */ pointerY: number; /** The mesh that is currently pointed at (can be null) */ meshUnderPointer: Nullable; /** the original (browser) event that triggered the ActionEvent */ sourceEvent?: any; /** additional data for the event */ additionalData?: any; /** * Creates a new ActionEvent * @param source The mesh or sprite that triggered the action * @param pointerX The X mouse cursor position at the time of the event * @param pointerY The Y mouse cursor position at the time of the event * @param meshUnderPointer The mesh that is currently pointed at (can be null) * @param sourceEvent the original (browser) event that triggered the ActionEvent * @param additionalData additional data for the event */ constructor( /** The mesh or sprite that triggered the action */ source: any, /** The X mouse cursor position at the time of the event */ pointerX: number, /** The Y mouse cursor position at the time of the event */ pointerY: number, /** The mesh that is currently pointed at (can be null) */ meshUnderPointer: Nullable, /** the original (browser) event that triggered the ActionEvent */ sourceEvent?: any, /** additional data for the event */ additionalData?: any); /** * Helper function to auto-create an ActionEvent from a source mesh. * @param source The source mesh that triggered the event * @param evt The original (browser) event * @param additionalData additional data for the event * @returns the new ActionEvent */ static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent; /** * Helper function to auto-create an ActionEvent from a source sprite * @param source The source sprite that triggered the event * @param scene Scene associated with the sprite * @param evt The original (browser) event * @param additionalData additional data for the event * @returns the new ActionEvent */ static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent; /** * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew * @param scene the scene where the event occurred * @param evt The original (browser) event * @returns the new ActionEvent */ static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent; /** * Helper function to auto-create an ActionEvent from a primitive * @param prim defines the target primitive * @param pointerPos defines the pointer position * @param evt The original (browser) event * @param additionalData additional data for the event * @returns the new ActionEvent */ static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent; } /** * Action Manager manages all events to be triggered on a given mesh or the global scene. * A single scene can have many Action Managers to handle predefined actions on specific meshes. * @see http://doc.babylonjs.com/how_to/how_to_use_actions */ class ActionManager { /** * Nothing * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers */ static readonly NothingTrigger: number; /** * On pick * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers */ static readonly OnPickTrigger: number; /** * On left pick * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers */ static readonly OnLeftPickTrigger: number; /** * On right pick * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers */ static readonly OnRightPickTrigger: number; /** * On center pick * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers */ static readonly OnCenterPickTrigger: number; /** * On pick down * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers */ static readonly OnPickDownTrigger: number; /** * On double pick * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers */ static readonly OnDoublePickTrigger: number; /** * On pick up * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers */ static readonly OnPickUpTrigger: number; /** * On pick out. * This trigger will only be raised if you also declared a OnPickDown * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers */ static readonly OnPickOutTrigger: number; /** * On long press * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers */ static readonly OnLongPressTrigger: number; /** * On pointer over * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers */ static readonly OnPointerOverTrigger: number; /** * On pointer out * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers */ static readonly OnPointerOutTrigger: number; /** * On every frame * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers */ static readonly OnEveryFrameTrigger: number; /** * On intersection enter * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers */ static readonly OnIntersectionEnterTrigger: number; /** * On intersection exit * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers */ static readonly OnIntersectionExitTrigger: number; /** * On key down * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers */ static readonly OnKeyDownTrigger: number; /** * On key up * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers */ static readonly OnKeyUpTrigger: number; /** Gets the list of active triggers */ static Triggers: { [key: string]: number; }; /** Gets the list of actions */ actions: Action[]; /** Gets the cursor to use when hovering items */ hoverCursor: string; private _scene; /** * Creates a new action manager * @param scene defines the hosting scene */ constructor(scene: Scene); /** * Releases all associated resources */ dispose(): void; /** * Gets hosting scene * @returns the hosting scene */ getScene(): Scene; /** * Does this action manager handles actions of any of the given triggers * @param triggers defines the triggers to be tested * @return a boolean indicating whether one (or more) of the triggers is handled */ hasSpecificTriggers(triggers: number[]): boolean; /** * Does this action manager handles actions of any of the given triggers. This function takes two arguments for * speed. * @param triggerA defines the trigger to be tested * @param triggerB defines the trigger to be tested * @return a boolean indicating whether one (or more) of the triggers is handled */ hasSpecificTriggers2(triggerA: number, triggerB: number): boolean; /** * Does this action manager handles actions of a given trigger * @param trigger defines the trigger to be tested * @param parameterPredicate defines an optional predicate to filter triggers by parameter * @return whether the trigger is handled */ hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean; /** * Does this action manager has pointer triggers */ readonly hasPointerTriggers: boolean; /** * Does this action manager has pick triggers */ readonly hasPickTriggers: boolean; /** * Does exist one action manager with at least one trigger **/ static readonly HasTriggers: boolean; /** * Does exist one action manager with at least one pick trigger **/ static readonly HasPickTriggers: boolean; /** * Does exist one action manager that handles actions of a given trigger * @param trigger defines the trigger to be tested * @return a boolean indicating whether the trigger is handeled by at least one action manager **/ static HasSpecificTrigger(trigger: number): boolean; /** * Registers an action to this action manager * @param action defines the action to be registered * @return the action amended (prepared) after registration */ registerAction(action: Action): Nullable; /** * Unregisters an action to this action manager * @param action defines the action to be unregistered * @return a boolean indicating whether the action has been unregistered */ unregisterAction(action: Action): Boolean; /** * Process a specific trigger * @param trigger defines the trigger to process * @param evt defines the event details to be processed */ processTrigger(trigger: number, evt?: ActionEvent): void; /** @hidden */ _getEffectiveTarget(target: any, propertyPath: string): any; /** @hidden */ _getProperty(propertyPath: string): string; /** * Serialize this manager to a JSON object * @param name defines the property name to store this manager * @returns a JSON representation of this manager */ serialize(name: string): any; /** * Creates a new ActionManager from a JSON data * @param parsedActions defines the JSON data to read from * @param object defines the hosting mesh * @param scene defines the hosting scene */ static Parse(parsedActions: any, object: Nullable, scene: Scene): void; /** * Get a trigger name by index * @param trigger defines the trigger index * @returns a trigger name */ static GetTriggerName(trigger: number): string; } } declare module BABYLON { /** * A Condition applied to an Action */ class Condition { /** * Internal only - manager for action * @hidden */ _actionManager: ActionManager; /** * Internal only * @hidden */ _evaluationId: number; /** * Internal only * @hidden */ _currentResult: boolean; /** * Creates a new Condition * @param actionManager the manager of the action the condition is applied to */ constructor(actionManager: ActionManager); /** * Check if the current condition is valid * @returns a boolean */ isValid(): boolean; /** * Internal only * @hidden */ _getProperty(propertyPath: string): string; /** * Internal only * @hidden */ _getEffectiveTarget(target: any, propertyPath: string): any; /** * Serialize placeholder for child classes * @returns the serialized object */ serialize(): any; /** * Internal only * @hidden */ protected _serialize(serializedCondition: any): any; } /** * Defines specific conditional operators as extensions of Condition */ class ValueCondition extends Condition { /** path to specify the property of the target the conditional operator uses */ propertyPath: string; /** the value compared by the conditional operator against the current value of the property */ value: any; /** the conditional operator, default ValueCondition.IsEqual */ operator: number; /** * Internal only * @hidden */ private static _IsEqual; /** * Internal only * @hidden */ private static _IsDifferent; /** * Internal only * @hidden */ private static _IsGreater; /** * Internal only * @hidden */ private static _IsLesser; /** * returns the number for IsEqual */ static readonly IsEqual: number; /** * Returns the number for IsDifferent */ static readonly IsDifferent: number; /** * Returns the number for IsGreater */ static readonly IsGreater: number; /** * Returns the number for IsLesser */ static readonly IsLesser: number; /** * Internal only The action manager for the condition * @hidden */ _actionManager: ActionManager; /** * Internal only * @hidden */ private _target; /** * Internal only * @hidden */ private _effectiveTarget; /** * Internal only * @hidden */ private _property; /** * Creates a new ValueCondition * @param actionManager manager for the action the condition applies to * @param target for the action * @param propertyPath path to specify the property of the target the conditional operator uses * @param value the value compared by the conditional operator against the current value of the property * @param operator the conditional operator, default ValueCondition.IsEqual */ constructor(actionManager: ActionManager, target: any, /** path to specify the property of the target the conditional operator uses */ propertyPath: string, /** the value compared by the conditional operator against the current value of the property */ value: any, /** the conditional operator, default ValueCondition.IsEqual */ operator?: number); /** * Compares the given value with the property value for the specified conditional operator * @returns the result of the comparison */ isValid(): boolean; /** * Serialize the ValueCondition into a JSON compatible object * @returns serialization object */ serialize(): any; /** * Gets the name of the conditional operator for the ValueCondition * @param operator the conditional operator * @returns the name */ static GetOperatorName(operator: number): string; } /** * Defines a predicate condition as an extension of Condition */ class PredicateCondition extends Condition { /** defines the predicate function used to validate the condition */ predicate: () => boolean; /** * Internal only - manager for action * @hidden */ _actionManager: ActionManager; /** * Creates a new PredicateCondition * @param actionManager manager for the action the condition applies to * @param predicate defines the predicate function used to validate the condition */ constructor(actionManager: ActionManager, /** defines the predicate function used to validate the condition */ predicate: () => boolean); /** * @returns the validity of the predicate condition */ isValid(): boolean; } /** * Defines a state condition as an extension of Condition */ class StateCondition extends Condition { /** Value to compare with target state */ value: string; /** * Internal only - manager for action * @hidden */ _actionManager: ActionManager; /** * Internal only * @hidden */ private _target; /** * Creates a new StateCondition * @param actionManager manager for the action the condition applies to * @param target of the condition * @param value to compare with target state */ constructor(actionManager: ActionManager, target: any, /** Value to compare with target state */ value: string); /** * Gets a boolean indicating if the current condition is met * @returns the validity of the state */ isValid(): boolean; /** * Serialize the StateCondition into a JSON compatible object * @returns serialization object */ serialize(): any; } } declare module BABYLON { /** * This defines an action responsible to toggle a boolean once triggered. * @see http://doc.babylonjs.com/how_to/how_to_use_actions */ class SwitchBooleanAction extends Action { /** * The path to the boolean property in the target object */ propertyPath: string; private _target; private _effectiveTarget; private _property; /** * Instantiate the action * @param triggerOptions defines the trigger options * @param target defines the object containing the boolean * @param propertyPath defines the path to the boolean property in the target object * @param condition defines the trigger related conditions */ constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition); /** @hidden */ _prepare(): void; /** * Execute the action toggle the boolean value. */ execute(): void; /** * Serializes the actions and its related information. * @param parent defines the object to serialize in * @returns the serialized object */ serialize(parent: any): any; } /** * This defines an action responsible to set a the state field of the target * to a desired value once triggered. * @see http://doc.babylonjs.com/how_to/how_to_use_actions */ class SetStateAction extends Action { /** * The value to store in the state field. */ value: string; private _target; /** * Instantiate the action * @param triggerOptions defines the trigger options * @param target defines the object containing the state property * @param value defines the value to store in the state field * @param condition defines the trigger related conditions */ constructor(triggerOptions: any, target: any, value: string, condition?: Condition); /** * Execute the action and store the value on the target state property. */ execute(): void; /** * Serializes the actions and its related information. * @param parent defines the object to serialize in * @returns the serialized object */ serialize(parent: any): any; } /** * This defines an action responsible to set a property of the target * to a desired value once triggered. * @see http://doc.babylonjs.com/how_to/how_to_use_actions */ class SetValueAction extends Action { /** * The path of the property to set in the target. */ propertyPath: string; /** * The value to set in the property */ value: any; private _target; private _effectiveTarget; private _property; /** * Instantiate the action * @param triggerOptions defines the trigger options * @param target defines the object containing the property * @param propertyPath defines the path of the property to set in the target * @param value defines the value to set in the property * @param condition defines the trigger related conditions */ constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition); /** @hidden */ _prepare(): void; /** * Execute the action and set the targetted property to the desired value. */ execute(): void; /** * Serializes the actions and its related information. * @param parent defines the object to serialize in * @returns the serialized object */ serialize(parent: any): any; } /** * This defines an action responsible to increment the target value * to a desired value once triggered. * @see http://doc.babylonjs.com/how_to/how_to_use_actions */ class IncrementValueAction extends Action { /** * The path of the property to increment in the target. */ propertyPath: string; /** * The value we should increment the property by. */ value: any; private _target; private _effectiveTarget; private _property; /** * Instantiate the action * @param triggerOptions defines the trigger options * @param target defines the object containing the property * @param propertyPath defines the path of the property to increment in the target * @param value defines the value value we should increment the property by * @param condition defines the trigger related conditions */ constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition); /** @hidden */ _prepare(): void; /** * Execute the action and increment the target of the value amount. */ execute(): void; /** * Serializes the actions and its related information. * @param parent defines the object to serialize in * @returns the serialized object */ serialize(parent: any): any; } /** * This defines an action responsible to start an animation once triggered. * @see http://doc.babylonjs.com/how_to/how_to_use_actions */ class PlayAnimationAction extends Action { /** * Where the animation should start (animation frame) */ from: number; /** * Where the animation should stop (animation frame) */ to: number; /** * Define if the animation should loop or stop after the first play. */ loop?: boolean; private _target; /** * Instantiate the action * @param triggerOptions defines the trigger options * @param target defines the target animation or animation name * @param from defines from where the animation should start (animation frame) * @param end defines where the animation should stop (animation frame) * @param loop defines if the animation should loop or stop after the first play * @param condition defines the trigger related conditions */ constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition); /** @hidden */ _prepare(): void; /** * Execute the action and play the animation. */ execute(): void; /** * Serializes the actions and its related information. * @param parent defines the object to serialize in * @returns the serialized object */ serialize(parent: any): any; } /** * This defines an action responsible to stop an animation once triggered. * @see http://doc.babylonjs.com/how_to/how_to_use_actions */ class StopAnimationAction extends Action { private _target; /** * Instantiate the action * @param triggerOptions defines the trigger options * @param target defines the target animation or animation name * @param condition defines the trigger related conditions */ constructor(triggerOptions: any, target: any, condition?: Condition); /** @hidden */ _prepare(): void; /** * Execute the action and stop the animation. */ execute(): void; /** * Serializes the actions and its related information. * @param parent defines the object to serialize in * @returns the serialized object */ serialize(parent: any): any; } /** * This defines an action responsible that does nothing once triggered. * @see http://doc.babylonjs.com/how_to/how_to_use_actions */ class DoNothingAction extends Action { /** * Instantiate the action * @param triggerOptions defines the trigger options * @param condition defines the trigger related conditions */ constructor(triggerOptions?: any, condition?: Condition); /** * Execute the action and do nothing. */ execute(): void; /** * Serializes the actions and its related information. * @param parent defines the object to serialize in * @returns the serialized object */ serialize(parent: any): any; } /** * This defines an action responsible to trigger several actions once triggered. * @see http://doc.babylonjs.com/how_to/how_to_use_actions */ class CombineAction extends Action { /** * The list of aggregated animations to run. */ children: Action[]; /** * Instantiate the action * @param triggerOptions defines the trigger options * @param children defines the list of aggregated animations to run * @param condition defines the trigger related conditions */ constructor(triggerOptions: any, children: Action[], condition?: Condition); /** @hidden */ _prepare(): void; /** * Execute the action and executes all the aggregated actions. */ execute(evt: ActionEvent): void; /** * Serializes the actions and its related information. * @param parent defines the object to serialize in * @returns the serialized object */ serialize(parent: any): any; } /** * This defines an action responsible to run code (external event) once triggered. * @see http://doc.babylonjs.com/how_to/how_to_use_actions */ class ExecuteCodeAction extends Action { /** * The callback function to run. */ func: (evt: ActionEvent) => void; /** * Instantiate the action * @param triggerOptions defines the trigger options * @param func defines the callback function to run * @param condition defines the trigger related conditions */ constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition); /** * Execute the action and run the attached code. */ execute(evt: ActionEvent): void; } /** * This defines an action responsible to set the parent property of the target once triggered. * @see http://doc.babylonjs.com/how_to/how_to_use_actions */ class SetParentAction extends Action { private _parent; private _target; /** * Instantiate the action * @param triggerOptions defines the trigger options * @param target defines the target containing the parent property * @param parent defines from where the animation should start (animation frame) * @param condition defines the trigger related conditions */ constructor(triggerOptions: any, target: any, parent: any, condition?: Condition); /** @hidden */ _prepare(): void; /** * Execute the action and set the parent property. */ execute(): void; /** * Serializes the actions and its related information. * @param parent defines the object to serialize in * @returns the serialized object */ serialize(parent: any): any; } } declare module BABYLON { /** * This defines an action helpful to play a defined sound on a triggered action. */ class PlaySoundAction extends Action { private _sound; /** * Instantiate the action * @param triggerOptions defines the trigger options * @param sound defines the sound to play * @param condition defines the trigger related conditions */ constructor(triggerOptions: any, sound: Sound, condition?: Condition); /** @hidden */ _prepare(): void; /** * Execute the action and play the sound. */ execute(): void; /** * Serializes the actions and its related information. * @param parent defines the object to serialize in * @returns the serialized object */ serialize(parent: any): any; } /** * This defines an action helpful to stop a defined sound on a triggered action. */ class StopSoundAction extends Action { private _sound; /** * Instantiate the action * @param triggerOptions defines the trigger options * @param sound defines the sound to stop * @param condition defines the trigger related conditions */ constructor(triggerOptions: any, sound: Sound, condition?: Condition); /** @hidden */ _prepare(): void; /** * Execute the action and stop the sound. */ execute(): void; /** * Serializes the actions and its related information. * @param parent defines the object to serialize in * @returns the serialized object */ serialize(parent: any): any; } } declare module BABYLON { /** * This defines an action responsible to change the value of a property * by interpolating between its current value and the newly set one once triggered. * @see http://doc.babylonjs.com/how_to/how_to_use_actions */ class InterpolateValueAction extends Action { /** * Defines the path of the property where the value should be interpolated */ propertyPath: string; /** * Defines the target value at the end of the interpolation. */ value: any; /** * Defines the time it will take for the property to interpolate to the value. */ duration: number; /** * Defines if the other scene animations should be stopped when the action has been triggered */ stopOtherAnimations?: boolean; /** * Defines a callback raised once the interpolation animation has been done. */ onInterpolationDone?: () => void; /** * Observable triggered once the interpolation animation has been done. */ onInterpolationDoneObservable: Observable; private _target; private _effectiveTarget; private _property; /** * Instantiate the action * @param triggerOptions defines the trigger options * @param target defines the object containing the value to interpolate * @param propertyPath defines the path to the property in the target object * @param value defines the target value at the end of the interpolation * @param duration deines the time it will take for the property to interpolate to the value. * @param condition defines the trigger related conditions * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered * @param onInterpolationDone defines a callback raised once the interpolation animation has been done */ constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void); /** @hidden */ _prepare(): void; /** * Execute the action starts the value interpolation. */ execute(): void; /** * Serializes the actions and its related information. * @param parent defines the object to serialize in * @returns the serialized object */ serialize(parent: any): any; } } declare module BABYLON { /** * Class used to work with sound analyzer using fast fourier transform (FFT) * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music */ class Analyser { /** * Gets or sets the smoothing * @ignorenaming */ SMOOTHING: number; /** * Gets or sets the FFT table size * @ignorenaming */ FFT_SIZE: number; /** * Gets or sets the bar graph amplitude * @ignorenaming */ BARGRAPHAMPLITUDE: number; /** * Gets or sets the position of the debug canvas * @ignorenaming */ DEBUGCANVASPOS: { x: number; y: number; }; /** * Gets or sets the debug canvas size * @ignorenaming */ DEBUGCANVASSIZE: { width: number; height: number; }; private _byteFreqs; private _byteTime; private _floatFreqs; private _webAudioAnalyser; private _debugCanvas; private _debugCanvasContext; private _scene; private _registerFunc; private _audioEngine; /** * Creates a new analyser * @param scene defines hosting scene */ constructor(scene: Scene); /** * Get the number of data values you will have to play with for the visualization * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount * @returns a number */ getFrequencyBinCount(): number; /** * Gets the current frequency data as a byte array * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData * @returns a Uint8Array */ getByteFrequencyData(): Uint8Array; /** * Gets the current waveform as a byte array * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData * @returns a Uint8Array */ getByteTimeDomainData(): Uint8Array; /** * Gets the current frequency data as a float array * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData * @returns a Float32Array */ getFloatFrequencyData(): Float32Array; /** * Renders the debug canvas */ drawDebugCanvas(): void; /** * Stops rendering the debug canvas and removes it */ stopDebugCanvas(): void; /** * Connects two audio nodes * @param inputAudioNode defines first node to connect * @param outputAudioNode defines second node to connect */ connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void; /** * Releases all associated resources */ dispose(): void; } } declare module BABYLON { /** * This represents an audio engine and it is responsible * to play, synchronize and analyse sounds throughout the application. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music */ interface IAudioEngine extends IDisposable { /** * Gets whether the current host supports Web Audio and thus could create AudioContexts. */ readonly canUseWebAudio: boolean; /** * Gets the current AudioContext if available. */ readonly audioContext: Nullable; /** * The master gain node defines the global audio volume of your audio engine. */ readonly masterGain: GainNode; /** * Gets whether or not mp3 are supported by your browser. */ readonly isMP3supported: boolean; /** * Gets whether or not ogg are supported by your browser. */ readonly isOGGsupported: boolean; /** * Defines if Babylon should emit a warning if WebAudio is not supported. * @ignoreNaming */ WarnedWebAudioUnsupported: boolean; /** * Defines if the audio engine relies on a custom unlocked button. * In this case, the embedded button will not be displayed. */ useCustomUnlockedButton: boolean; /** * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser). */ readonly unlocked: boolean; /** * Event raised when audio has been unlocked on the browser. */ onAudioUnlockedObservable: Observable; /** * Event raised when audio has been locked on the browser. */ onAudioLockedObservable: Observable; /** * Flags the audio engine in Locked state. * This happens due to new browser policies preventing audio to autoplay. */ lock(): void; /** * Unlocks the audio engine once a user action has been done on the dom. * This is helpful to resume play once browser policies have been satisfied. */ unlock(): void; } /** * This represents the default audio engine used in babylon. * It is responsible to play, synchronize and analyse sounds throughout the application. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music */ class AudioEngine implements IAudioEngine { private _audioContext; private _audioContextInitialized; private _muteButton; private _hostElement; /** * Gets whether the current host supports Web Audio and thus could create AudioContexts. */ canUseWebAudio: boolean; /** * The master gain node defines the global audio volume of your audio engine. */ masterGain: GainNode; /** * Defines if Babylon should emit a warning if WebAudio is not supported. * @ignoreNaming */ WarnedWebAudioUnsupported: boolean; /** * Gets whether or not mp3 are supported by your browser. */ isMP3supported: boolean; /** * Gets whether or not ogg are supported by your browser. */ isOGGsupported: boolean; /** * Gets whether audio has been unlocked on the device. * Some Browsers have strong restrictions about Audio and won t autoplay unless * a user interaction has happened. */ unlocked: boolean; /** * Defines if the audio engine relies on a custom unlocked button. * In this case, the embedded button will not be displayed. */ useCustomUnlockedButton: boolean; /** * Event raised when audio has been unlocked on the browser. */ onAudioUnlockedObservable: Observable; /** * Event raised when audio has been locked on the browser. */ onAudioLockedObservable: Observable; /** * Gets the current AudioContext if available. */ readonly audioContext: Nullable; private _connectedAnalyser; /** * Instantiates a new audio engine. * * There should be only one per page as some browsers restrict the number * of audio contexts you can create. * @param hostElement defines the host element where to display the mute icon if necessary */ constructor(hostElement?: Nullable); /** * Flags the audio engine in Locked state. * This happens due to new browser policies preventing audio to autoplay. */ lock(): void; /** * Unlocks the audio engine once a user action has been done on the dom. * This is helpful to resume play once browser policies have been satisfied. */ unlock(): void; private _resumeAudioContext; private _initializeAudioContext; private _tryToRun; private _triggerRunningState; private _triggerSuspendedState; private _displayMuteButton; private _moveButtonToTopLeft; private _onResize; private _hideMuteButton; /** * Destroy and release the resources associated with the audio ccontext. */ dispose(): void; /** * Gets the global volume sets on the master gain. * @returns the global volume if set or -1 otherwise */ getGlobalVolume(): number; /** * Sets the global volume of your experience (sets on the master gain). * @param newVolume Defines the new global volume of the application */ setGlobalVolume(newVolume: number): void; /** * Connect the audio engine to an audio analyser allowing some amazing * synchornization between the sounds/music and your visualization (VuMeter for instance). * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser * @param analyser The analyser to connect to the engine */ connectToAnalyser(analyser: Analyser): void; } } declare module BABYLON { interface AbstractScene { /** * The list of sounds used in the scene. */ sounds: Nullable>; } interface Scene { /** * @hidden * Backing field */ _mainSoundTrack: SoundTrack; /** * The main sound track played by the scene. * It cotains your primary collection of sounds. */ mainSoundTrack: SoundTrack; /** * The list of sound tracks added to the scene * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music */ soundTracks: Nullable>; /** * Gets a sound using a given name * @param name defines the name to search for * @return the found sound or null if not found at all. */ getSoundByName(name: string): Nullable; /** * Gets or sets if audio support is enabled * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music */ audioEnabled: boolean; /** * Gets or sets if audio will be output to headphones * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music */ headphone: boolean; } /** * Defines the sound scene component responsible to manage any sounds * in a given scene. */ class AudioSceneComponent implements ISceneSerializableComponent { /** * The component name helpfull to identify the component in the list of scene components. */ readonly name: string; /** * The scene the component belongs to. */ scene: Scene; private _audioEnabled; /** * Gets whether audio is enabled or not. * Please use related enable/disable method to switch state. */ readonly audioEnabled: boolean; private _headphone; /** * Gets whether audio is outputing to headphone or not. * Please use the according Switch methods to change output. */ readonly headphone: boolean; /** * Creates a new instance of the component for the given scene * @param scene Defines the scene to register the component in */ constructor(scene: Scene); /** * Registers the component in a given scene */ register(): void; /** * Rebuilds the elements related to this component in case of * context lost for instance. */ rebuild(): void; /** * Serializes the component data to the specified json object * @param serializationObject The object to serialize to */ serialize(serializationObject: any): void; /** * Adds all the element from the container to the scene * @param container the container holding the elements */ addFromContainer(container: AbstractScene): void; /** * Removes all the elements in the container from the scene * @param container contains the elements to remove */ removeFromContainer(container: AbstractScene): void; /** * Disposes the component and the associated ressources. */ dispose(): void; /** * Disables audio in the associated scene. */ disableAudio(): void; /** * Enables audio in the associated scene. */ enableAudio(): void; /** * Switch audio to headphone output. */ switchAudioModeForHeadphones(): void; /** * Switch audio to normal speakers. */ switchAudioModeForNormalSpeakers(): void; private _afterRender; } } declare module BABYLON { /** * Defines a sound that can be played in the application. * The sound can either be an ambient track or a simple sound played in reaction to a user action. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music */ class Sound { /** * The name of the sound in the scene. */ name: string; /** * Does the sound autoplay once loaded. */ autoplay: boolean; /** * Does the sound loop after it finishes playing once. */ loop: boolean; /** * Does the sound use a custom attenuation curve to simulate the falloff * happening when the source gets further away from the camera. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function */ useCustomAttenuation: boolean; /** * The sound track id this sound belongs to. */ soundTrackId: number; /** * Is this sound currently played. */ isPlaying: boolean; /** * Is this sound currently paused. */ isPaused: boolean; /** * Does this sound enables spatial sound. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound */ spatialSound: boolean; /** * Define the reference distance the sound should be heard perfectly. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound */ refDistance: number; /** * Define the roll off factor of spatial sounds. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound */ rolloffFactor: number; /** * Define the max distance the sound should be heard (intensity just became 0 at this point). * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound */ maxDistance: number; /** * Define the distance attenuation model the sound will follow. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound */ distanceModel: string; /** * @hidden * Back Compat **/ onended: () => any; /** * Observable event when the current playing sound finishes. */ onEndedObservable: Observable; private _panningModel; private _playbackRate; private _streaming; private _startTime; private _startOffset; private _position; /** @hidden */ _positionInEmitterSpace: boolean; private _localDirection; private _volume; private _isReadyToPlay; private _isDirectional; private _readyToPlayCallback; private _audioBuffer; private _soundSource; private _streamingSource; private _soundPanner; private _soundGain; private _inputAudioNode; private _outputAudioNode; private _coneInnerAngle; private _coneOuterAngle; private _coneOuterGain; private _scene; private _connectedMesh; private _customAttenuationFunction; private _registerFunc; private _isOutputConnected; private _htmlAudioElement; private _urlType; /** * Create a sound and attach it to a scene * @param name Name of your sound * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming */ constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any); /** * Release the sound and its associated resources */ dispose(): void; /** * Gets if the sounds is ready to be played or not. * @returns true if ready, otherwise false */ isReady(): boolean; private _soundLoaded; /** * Sets the data of the sound from an audiobuffer * @param audioBuffer The audioBuffer containing the data */ setAudioBuffer(audioBuffer: AudioBuffer): void; /** * Updates the current sounds options such as maxdistance, loop... * @param options A JSON object containing values named as the object properties */ updateOptions(options: any): void; private _createSpatialParameters; private _updateSpatialParameters; /** * Switch the panning model to HRTF: * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound */ switchPanningModelToHRTF(): void; /** * Switch the panning model to Equal Power: * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound */ switchPanningModelToEqualPower(): void; private _switchPanningModel; /** * Connect this sound to a sound track audio node like gain... * @param soundTrackAudioNode the sound track audio node to connect to */ connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void; /** * Transform this sound into a directional source * @param coneInnerAngle Size of the inner cone in degree * @param coneOuterAngle Size of the outer cone in degree * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0) */ setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void; /** * Gets or sets the inner angle for the directional cone. */ /** * Gets or sets the inner angle for the directional cone. */ directionalConeInnerAngle: number; /** * Gets or sets the outer angle for the directional cone. */ /** * Gets or sets the outer angle for the directional cone. */ directionalConeOuterAngle: number; /** * Sets the position of the emitter if spatial sound is enabled * @param newPosition Defines the new posisiton */ setPosition(newPosition: Vector3): void; /** * Sets the local direction of the emitter if spatial sound is enabled * @param newLocalDirection Defines the new local direction */ setLocalDirectionToMesh(newLocalDirection: Vector3): void; private _updateDirection; /** @hidden */ updateDistanceFromListener(): void; /** * Sets a new custom attenuation function for the sound. * @param callback Defines the function used for the attenuation * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function */ setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void; /** * Play the sound * @param time (optional) Start the sound after X seconds. Start immediately (0) by default. * @param offset (optional) Start the sound setting it at a specific time */ play(time?: number, offset?: number): void; private _onended; /** * Stop the sound * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default. */ stop(time?: number): void; /** * Put the sound in pause */ pause(): void; /** * Sets a dedicated volume for this sounds * @param newVolume Define the new volume of the sound * @param time Define in how long the sound should be at this value */ setVolume(newVolume: number, time?: number): void; /** * Set the sound play back rate * @param newPlaybackRate Define the playback rate the sound should be played at */ setPlaybackRate(newPlaybackRate: number): void; /** * Gets the volume of the sound. * @returns the volume of the sound */ getVolume(): number; /** * Attach the sound to a dedicated mesh * @param meshToConnectTo The mesh to connect the sound with * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh */ attachToMesh(meshToConnectTo: AbstractMesh): void; /** * Detach the sound from the previously attached mesh * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh */ detachFromMesh(): void; private _onRegisterAfterWorldMatrixUpdate; /** * Clone the current sound in the scene. * @returns the new sound clone */ clone(): Nullable; /** * Gets the current underlying audio buffer containing the data * @returns the audio buffer */ getAudioBuffer(): Nullable; /** * Serializes the Sound in a JSON representation * @returns the JSON representation of the sound */ serialize(): any; /** * Parse a JSON representation of a sound to innstantiate in a given scene * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method) * @param scene Define the scene the new parsed sound should be created in * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies * @param sourceSound Define a cound place holder if do not need to instantiate a new one * @returns the newly parsed sound */ static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound; } } declare module BABYLON { /** * Options allowed during the creation of a sound track. */ interface ISoundTrackOptions { /** * The volume the sound track should take during creation */ volume?: number; /** * Define if the sound track is the main sound track of the scene */ mainTrack?: boolean; } /** * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds. * It will be also used in a future release to apply effects on a specific track. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks */ class SoundTrack { /** * The unique identifier of the sound track in the scene. */ id: number; /** * The list of sounds included in the sound track. */ soundCollection: Array; private _outputAudioNode; private _scene; private _isMainTrack; private _connectedAnalyser; private _options; private _isInitialized; /** * Creates a new sound track. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks * @param scene Define the scene the sound track belongs to * @param options */ constructor(scene: Scene, options?: ISoundTrackOptions); private _initializeSoundTrackAudioGraph; /** * Release the sound track and its associated resources */ dispose(): void; /** * Adds a sound to this sound track * @param sound define the cound to add * @ignoreNaming */ AddSound(sound: Sound): void; /** * Removes a sound to this sound track * @param sound define the cound to remove * @ignoreNaming */ RemoveSound(sound: Sound): void; /** * Set a global volume for the full sound track. * @param newVolume Define the new volume of the sound track */ setVolume(newVolume: number): void; /** * Switch the panning model to HRTF: * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound */ switchPanningModelToHRTF(): void; /** * Switch the panning model to Equal Power: * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound */ switchPanningModelToEqualPower(): void; /** * Connect the sound track to an audio analyser allowing some amazing * synchornization between the sounds/music and your visualization (VuMeter for instance). * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser * @param analyser The analyser to connect to the engine */ connectToAnalyser(analyser: Analyser): void; } } declare module BABYLON { /** * Wraps one or more Sound objects and selects one with random weight for playback. */ class WeightedSound { /** When true a Sound will be selected and played when the current playing Sound completes. */ loop: boolean; private _coneInnerAngle; private _coneOuterAngle; private _volume; /** A Sound is currently playing. */ isPlaying: boolean; /** A Sound is currently paused. */ isPaused: boolean; private _sounds; private _weights; private _currentIndex?; /** * Creates a new WeightedSound from the list of sounds given. * @param loop When true a Sound will be selected and played when the current playing Sound completes. * @param sounds Array of Sounds that will be selected from. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1 */ constructor(loop: boolean, sounds: Sound[], weights: number[]); /** * The size of cone in degrees for a directional sound in which there will be no attenuation. */ /** * The size of cone in degress for a directional sound in which there will be no attenuation. */ directionalConeInnerAngle: number; /** * Size of cone in degrees for a directional sound outside of which there will be no sound. * Listener angles between innerAngle and outerAngle will falloff linearly. */ /** * Size of cone in degrees for a directional sound outside of which there will be no sound. * Listener angles between innerAngle and outerAngle will falloff linearly. */ directionalConeOuterAngle: number; /** * Playback volume. */ /** * Playback volume. */ volume: number; private _onended; /** * Suspend playback */ pause(): void; /** * Stop playback */ stop(): void; /** * Start playback. * @param startOffset Position the clip head at a specific time in seconds. */ play(startOffset?: number): void; } } declare module BABYLON { /** * Class used to store an actual running animation */ class Animatable { /** defines the target object */ target: any; /** defines the starting frame number (default is 0) */ fromFrame: number; /** defines the ending frame number (default is 100) */ toFrame: number; /** defines if the animation must loop (default is false) */ loopAnimation: boolean; /** defines a callback to call when animation ends if it is not looping */ onAnimationEnd?: (() => void) | null | undefined; private _localDelayOffset; private _pausedDelay; private _runtimeAnimations; private _paused; private _scene; private _speedRatio; private _weight; private _syncRoot; /** * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation. * This will only apply for non looping animation (default is true) */ disposeOnEnd: boolean; /** * Gets a boolean indicating if the animation has started */ animationStarted: boolean; /** * Observer raised when the animation ends */ onAnimationEndObservable: Observable; /** * Gets the root Animatable used to synchronize and normalize animations */ readonly syncRoot: Animatable; /** * Gets the current frame of the first RuntimeAnimation * Used to synchronize Animatables */ readonly masterFrame: number; /** * Gets or sets the animatable weight (-1.0 by default meaning not weighted) */ weight: number; /** * Gets or sets the speed ratio to apply to the animatable (1.0 by default) */ speedRatio: number; /** * Creates a new Animatable * @param scene defines the hosting scene * @param target defines the target object * @param fromFrame defines the starting frame number (default is 0) * @param toFrame defines the ending frame number (default is 100) * @param loopAnimation defines if the animation must loop (default is false) * @param speedRatio defines the factor to apply to animation speed (default is 1) * @param onAnimationEnd defines a callback to call when animation ends if it is not looping * @param animations defines a group of animation to add to the new Animatable */ constructor(scene: Scene, /** defines the target object */ target: any, /** defines the starting frame number (default is 0) */ fromFrame?: number, /** defines the ending frame number (default is 100) */ toFrame?: number, /** defines if the animation must loop (default is false) */ loopAnimation?: boolean, speedRatio?: number, /** defines a callback to call when animation ends if it is not looping */ onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[]); /** * Synchronize and normalize current Animatable with a source Animatable * This is useful when using animation weights and when animations are not of the same length * @param root defines the root Animatable to synchronize with * @returns the current Animatable */ syncWith(root: Animatable): Animatable; /** * Gets the list of runtime animations * @returns an array of RuntimeAnimation */ getAnimations(): RuntimeAnimation[]; /** * Adds more animations to the current animatable * @param target defines the target of the animations * @param animations defines the new animations to add */ appendAnimations(target: any, animations: Animation[]): void; /** * Gets the source animation for a specific property * @param property defines the propertyu to look for * @returns null or the source animation for the given property */ getAnimationByTargetProperty(property: string): Nullable; /** * Gets the runtime animation for a specific property * @param property defines the propertyu to look for * @returns null or the runtime animation for the given property */ getRuntimeAnimationByTargetProperty(property: string): Nullable; /** * Resets the animatable to its original state */ reset(): void; /** * Allows the animatable to blend with current running animations * @see http://doc.babylonjs.com/babylon101/animations#animation-blending * @param blendingSpeed defines the blending speed to use */ enableBlending(blendingSpeed: number): void; /** * Disable animation blending * @see http://doc.babylonjs.com/babylon101/animations#animation-blending */ disableBlending(): void; /** * Jump directly to a given frame * @param frame defines the frame to jump to */ goToFrame(frame: number): void; /** * Pause the animation */ pause(): void; /** * Restart the animation */ restart(): void; private _raiseOnAnimationEnd; /** * Stop and delete the current animation * @param animationName defines a string used to only stop some of the runtime animations instead of all * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty) */ stop(animationName?: string, targetMask?: (target: any) => boolean): void; /** * Wait asynchronously for the animation to end * @returns a promise which will be fullfilled when the animation ends */ waitAsync(): Promise; /** @hidden */ _animate(delay: number): boolean; } } declare module BABYLON { /** * Represents the range of an animation */ class AnimationRange { /**The name of the animation range**/ name: string; /**The starting frame of the animation */ from: number; /**The ending frame of the animation*/ to: number; /** * Initializes the range of an animation * @param name The name of the animation range * @param from The starting frame of the animation * @param to The ending frame of the animation */ constructor( /**The name of the animation range**/ name: string, /**The starting frame of the animation */ from: number, /**The ending frame of the animation*/ to: number); /** * Makes a copy of the animation range * @returns A copy of the animation range */ clone(): AnimationRange; } /** * Composed of a frame, and an action function */ class AnimationEvent { /** The frame for which the event is triggered **/ frame: number; /** The event to perform when triggered **/ action: (currentFrame: number) => void; /** Specifies if the event should be triggered only once**/ onlyOnce?: boolean | undefined; /** * Specifies if the animation event is done */ isDone: boolean; /** * Initializes the animation event * @param frame The frame for which the event is triggered * @param action The event to perform when triggered * @param onlyOnce Specifies if the event should be triggered only once */ constructor( /** The frame for which the event is triggered **/ frame: number, /** The event to perform when triggered **/ action: (currentFrame: number) => void, /** Specifies if the event should be triggered only once**/ onlyOnce?: boolean | undefined); /** @hidden */ _clone(): AnimationEvent; } /** * A cursor which tracks a point on a path */ class PathCursor { private path; /** * Stores path cursor callbacks for when an onchange event is triggered */ private _onchange; /** * The value of the path cursor */ value: number; /** * The animation array of the path cursor */ animations: Animation[]; /** * Initializes the path cursor * @param path The path to track */ constructor(path: Path2); /** * Gets the cursor point on the path * @returns A point on the path cursor at the cursor location */ getPoint(): Vector3; /** * Moves the cursor ahead by the step amount * @param step The amount to move the cursor forward * @returns This path cursor */ moveAhead(step?: number): PathCursor; /** * Moves the cursor behind by the step amount * @param step The amount to move the cursor back * @returns This path cursor */ moveBack(step?: number): PathCursor; /** * Moves the cursor by the step amount * If the step amount is greater than one, an exception is thrown * @param step The amount to move the cursor * @returns This path cursor */ move(step: number): PathCursor; /** * Ensures that the value is limited between zero and one * @returns This path cursor */ private ensureLimits; /** * Runs onchange callbacks on change (used by the animation engine) * @returns This path cursor */ private raiseOnChange; /** * Executes a function on change * @param f A path cursor onchange callback * @returns This path cursor */ onchange(f: (cursor: PathCursor) => void): PathCursor; } /** * Defines an interface which represents an animation key frame */ interface IAnimationKey { /** * Frame of the key frame */ frame: number; /** * Value at the specifies key frame */ value: any; /** * The input tangent for the cubic hermite spline */ inTangent?: any; /** * The output tangent for the cubic hermite spline */ outTangent?: any; /** * The animation interpolation type */ interpolation?: AnimationKeyInterpolation; } /** * Enum for the animation key frame interpolation type */ enum AnimationKeyInterpolation { /** * Do not interpolate between keys and use the start key value only. Tangents are ignored */ STEP = 1 } /** * Class used to store any kind of animation */ class Animation { /**Name of the animation */ name: string; /**Property to animate */ targetProperty: string; /**The frames per second of the animation */ framePerSecond: number; /**The data type of the animation */ dataType: number; /**The loop mode of the animation */ loopMode?: number | undefined; /**Specifies if blending should be enabled */ enableBlending?: boolean | undefined; /** * Use matrix interpolation instead of using direct key value when animating matrices */ static AllowMatricesInterpolation: boolean; /** * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower */ static AllowMatrixDecomposeForInterpolation: boolean; /** * Stores the key frames of the animation */ private _keys; /** * Stores the easing function of the animation */ private _easingFunction; /** * @hidden Internal use only */ _runtimeAnimations: RuntimeAnimation[]; /** * The set of event that will be linked to this animation */ private _events; /** * Stores an array of target property paths */ targetPropertyPath: string[]; /** * Stores the blending speed of the animation */ blendingSpeed: number; /** * Stores the animation ranges for the animation */ private _ranges; /** * @hidden Internal use */ static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable; /** * Sets up an animation * @param property The property to animate * @param animationType The animation type to apply * @param framePerSecond The frames per second of the animation * @param easingFunction The easing function used in the animation * @returns The created animation */ static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation; /** * Create and start an animation on a node * @param name defines the name of the global animation that will be run on all nodes * @param node defines the root node where the animation will take place * @param targetProperty defines property to animate * @param framePerSecond defines the number of frame per second yo use * @param totalFrame defines the number of frames in total * @param from defines the initial value * @param to defines the final value * @param loopMode defines which loop mode you want to use (off by default) * @param easingFunction defines the easing function to use (linear by default) * @param onAnimationEnd defines the callback to call when animation end * @returns the animatable created for this animation */ static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable; /** * Create and start an animation on a node and its descendants * @param name defines the name of the global animation that will be run on all nodes * @param node defines the root node where the animation will take place * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used * @param targetProperty defines property to animate * @param framePerSecond defines the number of frame per second to use * @param totalFrame defines the number of frames in total * @param from defines the initial value * @param to defines the final value * @param loopMode defines which loop mode you want to use (off by default) * @param easingFunction defines the easing function to use (linear by default) * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node) * @returns the list of animatables created for all nodes * @example https://www.babylonjs-playground.com/#MH0VLI */ static CreateAndStartHierarchyAnimation(name: string, node: Node, directDescendantsOnly: boolean, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable; /** * Creates a new animation, merges it with the existing animations and starts it * @param name Name of the animation * @param node Node which contains the scene that begins the animations * @param targetProperty Specifies which property to animate * @param framePerSecond The frames per second of the animation * @param totalFrame The total number of frames * @param from The frame at the beginning of the animation * @param to The frame at the end of the animation * @param loopMode Specifies the loop mode of the animation * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations * @param onAnimationEnd Callback to run once the animation is complete * @returns Nullable animation */ static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable; /** * Transition property of an host to the target Value * @param property The property to transition * @param targetValue The target Value of the property * @param host The object where the property to animate belongs * @param scene Scene used to run the animation * @param frameRate Framerate (in frame/s) to use * @param transition The transition type we want to use * @param duration The duration of the animation, in milliseconds * @param onAnimationEnd Callback trigger at the end of the animation * @returns Nullable animation */ static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable; /** * Return the array of runtime animations currently using this animation */ readonly runtimeAnimations: RuntimeAnimation[]; /** * Specifies if any of the runtime animations are currently running */ readonly hasRunningRuntimeAnimations: boolean; /** * Initializes the animation * @param name Name of the animation * @param targetProperty Property to animate * @param framePerSecond The frames per second of the animation * @param dataType The data type of the animation * @param loopMode The loop mode of the animation * @param enableBlendings Specifies if blending should be enabled */ constructor( /**Name of the animation */ name: string, /**Property to animate */ targetProperty: string, /**The frames per second of the animation */ framePerSecond: number, /**The data type of the animation */ dataType: number, /**The loop mode of the animation */ loopMode?: number | undefined, /**Specifies if blending should be enabled */ enableBlending?: boolean | undefined); /** * Converts the animation to a string * @param fullDetails support for multiple levels of logging within scene loading * @returns String form of the animation */ toString(fullDetails?: boolean): string; /** * Add an event to this animation * @param event Event to add */ addEvent(event: AnimationEvent): void; /** * Remove all events found at the given frame * @param frame The frame to remove events from */ removeEvents(frame: number): void; /** * Retrieves all the events from the animation * @returns Events from the animation */ getEvents(): AnimationEvent[]; /** * Creates an animation range * @param name Name of the animation range * @param from Starting frame of the animation range * @param to Ending frame of the animation */ createRange(name: string, from: number, to: number): void; /** * Deletes an animation range by name * @param name Name of the animation range to delete * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false) */ deleteRange(name: string, deleteFrames?: boolean): void; /** * Gets the animation range by name, or null if not defined * @param name Name of the animation range * @returns Nullable animation range */ getRange(name: string): Nullable; /** * Gets the key frames from the animation * @returns The key frames of the animation */ getKeys(): Array; /** * Gets the highest frame rate of the animation * @returns Highest frame rate of the animation */ getHighestFrame(): number; /** * Gets the easing function of the animation * @returns Easing function of the animation */ getEasingFunction(): IEasingFunction; /** * Sets the easing function of the animation * @param easingFunction A custom mathematical formula for animation */ setEasingFunction(easingFunction: EasingFunction): void; /** * Interpolates a scalar linearly * @param startValue Start value of the animation curve * @param endValue End value of the animation curve * @param gradient Scalar amount to interpolate * @returns Interpolated scalar value */ floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number; /** * Interpolates a scalar cubically * @param startValue Start value of the animation curve * @param outTangent End tangent of the animation * @param endValue End value of the animation curve * @param inTangent Start tangent of the animation curve * @param gradient Scalar amount to interpolate * @returns Interpolated scalar value */ floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number; /** * Interpolates a quaternion using a spherical linear interpolation * @param startValue Start value of the animation curve * @param endValue End value of the animation curve * @param gradient Scalar amount to interpolate * @returns Interpolated quaternion value */ quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion; /** * Interpolates a quaternion cubically * @param startValue Start value of the animation curve * @param outTangent End tangent of the animation curve * @param endValue End value of the animation curve * @param inTangent Start tangent of the animation curve * @param gradient Scalar amount to interpolate * @returns Interpolated quaternion value */ quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion; /** * Interpolates a Vector3 linearl * @param startValue Start value of the animation curve * @param endValue End value of the animation curve * @param gradient Scalar amount to interpolate * @returns Interpolated scalar value */ vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3; /** * Interpolates a Vector3 cubically * @param startValue Start value of the animation curve * @param outTangent End tangent of the animation * @param endValue End value of the animation curve * @param inTangent Start tangent of the animation curve * @param gradient Scalar amount to interpolate * @returns InterpolatedVector3 value */ vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3; /** * Interpolates a Vector2 linearly * @param startValue Start value of the animation curve * @param endValue End value of the animation curve * @param gradient Scalar amount to interpolate * @returns Interpolated Vector2 value */ vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2; /** * Interpolates a Vector2 cubically * @param startValue Start value of the animation curve * @param outTangent End tangent of the animation * @param endValue End value of the animation curve * @param inTangent Start tangent of the animation curve * @param gradient Scalar amount to interpolate * @returns Interpolated Vector2 value */ vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2; /** * Interpolates a size linearly * @param startValue Start value of the animation curve * @param endValue End value of the animation curve * @param gradient Scalar amount to interpolate * @returns Interpolated Size value */ sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size; /** * Interpolates a Color3 linearly * @param startValue Start value of the animation curve * @param endValue End value of the animation curve * @param gradient Scalar amount to interpolate * @returns Interpolated Color3 value */ color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3; /** * @hidden Internal use only */ _getKeyValue(value: any): any; /** * @hidden Internal use only */ _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any; /** * Defines the function to use to interpolate matrices * @param startValue defines the start matrix * @param endValue defines the end matrix * @param gradient defines the gradient between both matrices * @param result defines an optional target matrix where to store the interpolation * @returns the interpolated matrix */ matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix; /** * Makes a copy of the animation * @returns Cloned animation */ clone(): Animation; /** * Sets the key frames of the animation * @param values The animation key frames to set */ setKeys(values: Array): void; /** * Serializes the animation to an object * @returns Serialized object */ serialize(): any; /** * Float animation type */ private static _ANIMATIONTYPE_FLOAT; /** * Vector3 animation type */ private static _ANIMATIONTYPE_VECTOR3; /** * Quaternion animation type */ private static _ANIMATIONTYPE_QUATERNION; /** * Matrix animation type */ private static _ANIMATIONTYPE_MATRIX; /** * Color3 animation type */ private static _ANIMATIONTYPE_COLOR3; /** * Vector2 animation type */ private static _ANIMATIONTYPE_VECTOR2; /** * Size animation type */ private static _ANIMATIONTYPE_SIZE; /** * Relative Loop Mode */ private static _ANIMATIONLOOPMODE_RELATIVE; /** * Cycle Loop Mode */ private static _ANIMATIONLOOPMODE_CYCLE; /** * Constant Loop Mode */ private static _ANIMATIONLOOPMODE_CONSTANT; /** * Get the float animation type */ static readonly ANIMATIONTYPE_FLOAT: number; /** * Get the Vector3 animation type */ static readonly ANIMATIONTYPE_VECTOR3: number; /** * Get the Vector2 animation type */ static readonly ANIMATIONTYPE_VECTOR2: number; /** * Get the Size animation type */ static readonly ANIMATIONTYPE_SIZE: number; /** * Get the Quaternion animation type */ static readonly ANIMATIONTYPE_QUATERNION: number; /** * Get the Matrix animation type */ static readonly ANIMATIONTYPE_MATRIX: number; /** * Get the Color3 animation type */ static readonly ANIMATIONTYPE_COLOR3: number; /** * Get the Relative Loop Mode */ static readonly ANIMATIONLOOPMODE_RELATIVE: number; /** * Get the Cycle Loop Mode */ static readonly ANIMATIONLOOPMODE_CYCLE: number; /** * Get the Constant Loop Mode */ static readonly ANIMATIONLOOPMODE_CONSTANT: number; /** @hidden */ static _UniversalLerp(left: any, right: any, amount: number): any; /** * Parses an animation object and creates an animation * @param parsedAnimation Parsed animation object * @returns Animation object */ static Parse(parsedAnimation: any): Animation; /** * Appends the serialized animations from the source animations * @param source Source containing the animations * @param destination Target to store the animations */ static AppendSerializedAnimations(source: IAnimatable, destination: any): void; } } declare module BABYLON { /** * This class defines the direct association between an animation and a target */ class TargetedAnimation { /** * Animation to perform */ animation: Animation; /** * Target to animate */ target: any; } /** * Use this class to create coordinated animations on multiple targets */ class AnimationGroup implements IDisposable { /** The name of the animation group */ name: string; private _scene; private _targetedAnimations; private _animatables; private _from; private _to; private _isStarted; private _speedRatio; /** * This observable will notify when one animation have ended. */ onAnimationEndObservable: Observable; /** * This observable will notify when all animations have ended. */ onAnimationGroupEndObservable: Observable; /** * This observable will notify when all animations have paused. */ onAnimationGroupPauseObservable: Observable; /** * Gets the first frame */ readonly from: number; /** * Gets the last frame */ readonly to: number; /** * Define if the animations are started */ readonly isStarted: boolean; /** * Gets or sets the speed ratio to use for all animations */ /** * Gets or sets the speed ratio to use for all animations */ speedRatio: number; /** * Gets the targeted animations for this animation group */ readonly targetedAnimations: Array; /** * returning the list of animatables controlled by this animation group. */ readonly animatables: Array; /** * Instantiates a new Animation Group. * This helps managing several animations at once. * @see http://doc.babylonjs.com/how_to/group * @param name Defines the name of the group * @param scene Defines the scene the group belongs to */ constructor( /** The name of the animation group */ name: string, scene?: Nullable); /** * Add an animation (with its target) in the group * @param animation defines the animation we want to add * @param target defines the target of the animation * @returns the TargetedAnimation object */ addTargetedAnimation(animation: Animation, target: any): TargetedAnimation; /** * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame * It can add constant keys at begin or end * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null) * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null) * @returns the animation group */ normalize(beginFrame?: Nullable, endFrame?: Nullable): AnimationGroup; /** * Start all animations on given targets * @param loop defines if animations must loop * @param speedRatio defines the ratio to apply to animation speed (1 by default) * @param from defines the from key (optional) * @param to defines the to key (optional) * @returns the current animation group */ start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup; /** * Pause all animations * @returns the animation group */ pause(): AnimationGroup; /** * Play all animations to initial state * This function will start() the animations if they were not started or will restart() them if they were paused * @param loop defines if animations must loop * @returns the animation group */ play(loop?: boolean): AnimationGroup; /** * Reset all animations to initial state * @returns the animation group */ reset(): AnimationGroup; /** * Restart animations from key 0 * @returns the animation group */ restart(): AnimationGroup; /** * Stop all animations * @returns the animation group */ stop(): AnimationGroup; /** * Set animation weight for all animatables * @param weight defines the weight to use * @return the animationGroup * @see http://doc.babylonjs.com/babylon101/animations#animation-weights */ setWeightForAllAnimatables(weight: number): AnimationGroup; /** * Synchronize and normalize all animatables with a source animatable * @param root defines the root animatable to synchronize with * @return the animationGroup * @see http://doc.babylonjs.com/babylon101/animations#animation-weights */ syncAllAnimationsWith(root: Animatable): AnimationGroup; /** * Goes to a specific frame in this animation group * @param frame the frame number to go to * @return the animationGroup */ goToFrame(frame: number): AnimationGroup; /** * Dispose all associated resources */ dispose(): void; private _checkAnimationGroupEnded; /** * Returns a new AnimationGroup object parsed from the source provided. * @param parsedAnimationGroup defines the source * @param scene defines the scene that will receive the animationGroup * @returns a new AnimationGroup */ static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup; /** * Returns the string "AnimationGroup" * @returns "AnimationGroup" */ getClassName(): string; /** * Creates a detailled string about the object * @param fullDetails defines if the output string will support multiple levels of logging within scene loading * @returns a string representing the object */ toString(fullDetails?: boolean): string; } } declare module BABYLON { /** * Class used to override all child animations of a given target */ class AnimationPropertiesOverride { /** * Gets or sets a value indicating if animation blending must be used */ enableBlending: boolean; /** * Gets or sets the blending speed to use when enableBlending is true */ blendingSpeed: number; /** * Gets or sets the default loop mode to use */ loopMode: number; } } declare module BABYLON { /** * This represents the main contract an easing function should follow. * Easing functions are used throughout the animation system. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions */ interface IEasingFunction { /** * Given an input gradient between 0 and 1, this returns the corrseponding value * of the easing function. * The link below provides some of the most common examples of easing functions. * @see https://easings.net/ * @param gradient Defines the value between 0 and 1 we want the easing value for * @returns the corresponding value on the curve defined by the easing function */ ease(gradient: number): number; } /** * Base class used for every default easing function. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions */ class EasingFunction implements IEasingFunction { /** * Interpolation follows the mathematical formula associated with the easing function. */ static readonly EASINGMODE_EASEIN: number; /** * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function. */ static readonly EASINGMODE_EASEOUT: number; /** * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half. */ static readonly EASINGMODE_EASEINOUT: number; private _easingMode; /** * Sets the easing mode of the current function. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT) */ setEasingMode(easingMode: number): void; /** * Gets the current easing mode. * @returns the easing mode */ getEasingMode(): number; /** * @hidden */ easeInCore(gradient: number): number; /** * Given an input gradient between 0 and 1, this returns the corrseponding value * of the easing function. * @param gradient Defines the value between 0 and 1 we want the easing value for * @returns the corresponding value on the curve defined by the easing function */ ease(gradient: number): number; } /** * Easing function with a circle shape (see link below). * @see https://easings.net/#easeInCirc * @see http://doc.babylonjs.com/babylon101/animations#easing-functions */ class CircleEase extends EasingFunction implements IEasingFunction { /** @hidden */ easeInCore(gradient: number): number; } /** * Easing function with a ease back shape (see link below). * @see https://easings.net/#easeInBack * @see http://doc.babylonjs.com/babylon101/animations#easing-functions */ class BackEase extends EasingFunction implements IEasingFunction { /** Defines the amplitude of the function */ amplitude: number; /** * Instantiates a back ease easing * @see https://easings.net/#easeInBack * @param amplitude Defines the amplitude of the function */ constructor( /** Defines the amplitude of the function */ amplitude?: number); /** @hidden */ easeInCore(gradient: number): number; } /** * Easing function with a bouncing shape (see link below). * @see https://easings.net/#easeInBounce * @see http://doc.babylonjs.com/babylon101/animations#easing-functions */ class BounceEase extends EasingFunction implements IEasingFunction { /** Defines the number of bounces */ bounces: number; /** Defines the amplitude of the bounce */ bounciness: number; /** * Instantiates a bounce easing * @see https://easings.net/#easeInBounce * @param bounces Defines the number of bounces * @param bounciness Defines the amplitude of the bounce */ constructor( /** Defines the number of bounces */ bounces?: number, /** Defines the amplitude of the bounce */ bounciness?: number); /** @hidden */ easeInCore(gradient: number): number; } /** * Easing function with a power of 3 shape (see link below). * @see https://easings.net/#easeInCubic * @see http://doc.babylonjs.com/babylon101/animations#easing-functions */ class CubicEase extends EasingFunction implements IEasingFunction { /** @hidden */ easeInCore(gradient: number): number; } /** * Easing function with an elastic shape (see link below). * @see https://easings.net/#easeInElastic * @see http://doc.babylonjs.com/babylon101/animations#easing-functions */ class ElasticEase extends EasingFunction implements IEasingFunction { /** Defines the number of oscillations*/ oscillations: number; /** Defines the amplitude of the oscillations*/ springiness: number; /** * Instantiates an elastic easing function * @see https://easings.net/#easeInElastic * @param oscillations Defines the number of oscillations * @param springiness Defines the amplitude of the oscillations */ constructor( /** Defines the number of oscillations*/ oscillations?: number, /** Defines the amplitude of the oscillations*/ springiness?: number); /** @hidden */ easeInCore(gradient: number): number; } /** * Easing function with an exponential shape (see link below). * @see https://easings.net/#easeInExpo * @see http://doc.babylonjs.com/babylon101/animations#easing-functions */ class ExponentialEase extends EasingFunction implements IEasingFunction { /** Defines the exponent of the function */ exponent: number; /** * Instantiates an exponential easing function * @see https://easings.net/#easeInExpo * @param exponent Defines the exponent of the function */ constructor( /** Defines the exponent of the function */ exponent?: number); /** @hidden */ easeInCore(gradient: number): number; } /** * Easing function with a power shape (see link below). * @see https://easings.net/#easeInQuad * @see http://doc.babylonjs.com/babylon101/animations#easing-functions */ class PowerEase extends EasingFunction implements IEasingFunction { /** Defines the power of the function */ power: number; /** * Instantiates an power base easing function * @see https://easings.net/#easeInQuad * @param power Defines the power of the function */ constructor( /** Defines the power of the function */ power?: number); /** @hidden */ easeInCore(gradient: number): number; } /** * Easing function with a power of 2 shape (see link below). * @see https://easings.net/#easeInQuad * @see http://doc.babylonjs.com/babylon101/animations#easing-functions */ class QuadraticEase extends EasingFunction implements IEasingFunction { /** @hidden */ easeInCore(gradient: number): number; } /** * Easing function with a power of 4 shape (see link below). * @see https://easings.net/#easeInQuart * @see http://doc.babylonjs.com/babylon101/animations#easing-functions */ class QuarticEase extends EasingFunction implements IEasingFunction { /** @hidden */ easeInCore(gradient: number): number; } /** * Easing function with a power of 5 shape (see link below). * @see https://easings.net/#easeInQuint * @see http://doc.babylonjs.com/babylon101/animations#easing-functions */ class QuinticEase extends EasingFunction implements IEasingFunction { /** @hidden */ easeInCore(gradient: number): number; } /** * Easing function with a sin shape (see link below). * @see https://easings.net/#easeInSine * @see http://doc.babylonjs.com/babylon101/animations#easing-functions */ class SineEase extends EasingFunction implements IEasingFunction { /** @hidden */ easeInCore(gradient: number): number; } /** * Easing function with a bezier shape (see link below). * @see http://cubic-bezier.com/#.17,.67,.83,.67 * @see http://doc.babylonjs.com/babylon101/animations#easing-functions */ class BezierCurveEase extends EasingFunction implements IEasingFunction { /** Defines the x component of the start tangent in the bezier curve */ x1: number; /** Defines the y component of the start tangent in the bezier curve */ y1: number; /** Defines the x component of the end tangent in the bezier curve */ x2: number; /** Defines the y component of the end tangent in the bezier curve */ y2: number; /** * Instantiates a bezier function * @see http://cubic-bezier.com/#.17,.67,.83,.67 * @param x1 Defines the x component of the start tangent in the bezier curve * @param y1 Defines the y component of the start tangent in the bezier curve * @param x2 Defines the x component of the end tangent in the bezier curve * @param y2 Defines the y component of the end tangent in the bezier curve */ constructor( /** Defines the x component of the start tangent in the bezier curve */ x1?: number, /** Defines the y component of the start tangent in the bezier curve */ y1?: number, /** Defines the x component of the end tangent in the bezier curve */ x2?: number, /** Defines the y component of the end tangent in the bezier curve */ y2?: number); /** @hidden */ easeInCore(gradient: number): number; } } declare module BABYLON { /** * Defines a runtime animation */ class RuntimeAnimation { private _events; /** * The current frame of the runtime animation */ private _currentFrame; /** * The animation used by the runtime animation */ private _animation; /** * The target of the runtime animation */ private _target; /** * The initiating animatable */ private _host; /** * The original value of the runtime animation */ private _originalValue; /** * The original blend value of the runtime animation */ private _originalBlendValue; /** * The offsets cache of the runtime animation */ private _offsetsCache; /** * The high limits cache of the runtime animation */ private _highLimitsCache; /** * Specifies if the runtime animation has been stopped */ private _stopped; /** * The blending factor of the runtime animation */ private _blendingFactor; /** * The BabylonJS scene */ private _scene; /** * The current value of the runtime animation */ private _currentValue; /** @hidden */ _workValue: any; /** * The active target of the runtime animation */ private _activeTarget; /** * The target path of the runtime animation */ private _targetPath; /** * The weight of the runtime animation */ private _weight; /** * The ratio offset of the runtime animation */ private _ratioOffset; /** * The previous delay of the runtime animation */ private _previousDelay; /** * The previous ratio of the runtime animation */ private _previousRatio; /** * Gets the current frame of the runtime animation */ readonly currentFrame: number; /** * Gets the weight of the runtime animation */ readonly weight: number; /** * Gets the current value of the runtime animation */ readonly currentValue: any; /** * Gets the target path of the runtime animation */ readonly targetPath: string; /** * Gets the actual target of the runtime animation */ readonly target: any; /** * Create a new RuntimeAnimation object * @param target defines the target of the animation * @param animation defines the source animation object * @param scene defines the hosting scene * @param host defines the initiating Animatable */ constructor(target: any, animation: Animation, scene: Scene, host: Animatable); /** * Gets the animation from the runtime animation */ readonly animation: Animation; /** * Resets the runtime animation to the beginning * @param restoreOriginal defines whether to restore the target property to the original value */ reset(restoreOriginal?: boolean): void; /** * Specifies if the runtime animation is stopped * @returns Boolean specifying if the runtime animation is stopped */ isStopped(): boolean; /** * Disposes of the runtime animation */ dispose(): void; /** * Interpolates the animation from the current frame * @param currentFrame The frame to interpolate the animation to * @param repeatCount The number of times that the animation should loop * @param loopMode The type of looping mode to use * @param offsetValue Animation offset value * @param highLimitValue The high limit value * @returns The interpolated value */ private _interpolate; /** * Apply the interpolated value to the target * @param currentValue defines the value computed by the animation * @param weight defines the weight to apply to this value (Defaults to 1.0) */ setValue(currentValue: any, weight?: number): void; private _setValue; /** * Gets the loop pmode of the runtime animation * @returns Loop Mode */ private _getCorrectLoopMode; /** * Move the current animation to a given frame * @param frame defines the frame to move to */ goToFrame(frame: number): void; /** * @hidden Internal use only */ _prepareForSpeedRatioChange(newSpeedRatio: number): void; /** * Execute the current animation * @param delay defines the delay to add to the current frame * @param from defines the lower bound of the animation range * @param to defines the upper bound of the animation range * @param loop defines if the current animation must loop * @param speedRatio defines the current speed ratio * @param weight defines the weight of the animation (default is -1 so no weight) * @returns a boolean indicating if the animation is running */ animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean; } } declare module BABYLON { /** * Interface used to define a behavior */ interface Behavior { /** gets or sets behavior's name */ name: string; /** * Function called when the behavior needs to be initialized (after attaching it to a target) */ init(): void; /** * Called when the behavior is attached to a target * @param target defines the target where the behavior is attached to */ attach(target: T): void; /** * Called when the behavior is detached from its target */ detach(): void; } /** * Interface implemented by classes supporting behaviors */ interface IBehaviorAware { /** * Attach a behavior * @param behavior defines the behavior to attach * @returns the current host */ addBehavior(behavior: Behavior): T; /** * Remove a behavior from the current object * @param behavior defines the behavior to detach * @returns the current host */ removeBehavior(behavior: Behavior): T; /** * Gets a behavior using its name to search * @param name defines the name to search * @returns the behavior or null if not found */ getBehaviorByName(name: string): Nullable>; } } declare module BABYLON { /** * Class used to store bone information * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons */ class Bone extends Node { /** * defines the bone name */ name: string; private static _tmpVecs; private static _tmpQuat; private static _tmpMats; /** * Gets the list of child bones */ children: Bone[]; /** Gets the animations associated with this bone */ animations: Animation[]; /** * Gets or sets bone length */ length: number; /** * @hidden Internal only * Set this value to map this bone to a different index in the transform matrices * Set this value to -1 to exclude the bone from the transform matrices */ _index: Nullable; private _skeleton; private _localMatrix; private _restPose; private _baseMatrix; private _absoluteTransform; private _invertedAbsoluteTransform; private _parent; private _scalingDeterminant; private _worldTransform; private _localScaling; private _localRotation; private _localPosition; private _needToDecompose; private _needToCompose; /** @hidden */ /** @hidden */ _matrix: Matrix; /** * Create a new bone * @param name defines the bone name * @param skeleton defines the parent skeleton * @param parentBone defines the parent (can be null if the bone is the root) * @param localMatrix defines the local matrix * @param restPose defines the rest pose matrix * @param baseMatrix defines the base matrix * @param index defines index of the bone in the hiearchy */ constructor( /** * defines the bone name */ name: string, skeleton: Skeleton, parentBone?: Nullable, localMatrix?: Nullable, restPose?: Nullable, baseMatrix?: Nullable, index?: Nullable); /** * Gets the parent skeleton * @returns a skeleton */ getSkeleton(): Skeleton; /** * Gets parent bone * @returns a bone or null if the bone is the root of the bone hierarchy */ getParent(): Nullable; /** * Sets the parent bone * @param parent defines the parent (can be null if the bone is the root) * @param updateDifferenceMatrix defines if the difference matrix must be updated */ setParent(parent: Nullable, updateDifferenceMatrix?: boolean): void; /** * Gets the local matrix * @returns a matrix */ getLocalMatrix(): Matrix; /** * Gets the base matrix (initial matrix which remains unchanged) * @returns a matrix */ getBaseMatrix(): Matrix; /** * Gets the rest pose matrix * @returns a matrix */ getRestPose(): Matrix; /** * Gets a matrix used to store world matrix (ie. the matrix sent to shaders) */ getWorldMatrix(): Matrix; /** * Sets the local matrix to rest pose matrix */ returnToRest(): void; /** * Gets the inverse of the absolute transform matrix. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state) * @returns a matrix */ getInvertedAbsoluteTransform(): Matrix; /** * Gets the absolute transform matrix (ie base matrix * parent world matrix) * @returns a matrix */ getAbsoluteTransform(): Matrix; /** Gets or sets current position (in local space) */ position: Vector3; /** Gets or sets current rotation (in local space) */ rotation: Vector3; /** Gets or sets current rotation quaternion (in local space) */ rotationQuaternion: Quaternion; /** Gets or sets current scaling (in local space) */ scaling: Vector3; /** * Gets the animation properties override */ readonly animationPropertiesOverride: Nullable; private _decompose; private _compose; /** * Update the base and local matrices * @param matrix defines the new base or local matrix * @param updateDifferenceMatrix defines if the difference matrix must be updated * @param updateLocalMatrix defines if the local matrix should be updated */ updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void; /** @hidden */ _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void; /** * Flag the bone as dirty (Forcing it to update everything) */ markAsDirty(): void; private _markAsDirtyAndCompose; private _markAsDirtyAndDecompose; /** * Copy an animation range from another bone * @param source defines the source bone * @param rangeName defines the range name to copy * @param frameOffset defines the frame offset * @param rescaleAsRequired defines if rescaling must be applied if required * @param skelDimensionsRatio defines the scaling ratio * @returns true if operation was successful */ copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable): boolean; /** * Translate the bone in local or world space * @param vec The amount to translate the bone * @param space The space that the translation is in * @param mesh The mesh that this bone is attached to. This is only used in world space */ translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void; /** * Set the postion of the bone in local or world space * @param position The position to set the bone * @param space The space that the position is in * @param mesh The mesh that this bone is attached to. This is only used in world space */ setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void; /** * Set the absolute position of the bone (world space) * @param position The position to set the bone * @param mesh The mesh that this bone is attached to */ setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void; /** * Scale the bone on the x, y and z axes (in local space) * @param x The amount to scale the bone on the x axis * @param y The amount to scale the bone on the y axis * @param z The amount to scale the bone on the z axis * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default) */ scale(x: number, y: number, z: number, scaleChildren?: boolean): void; /** * Set the bone scaling in local space * @param scale defines the scaling vector */ setScale(scale: Vector3): void; /** * Gets the current scaling in local space * @returns the current scaling vector */ getScale(): Vector3; /** * Gets the current scaling in local space and stores it in a target vector * @param result defines the target vector */ getScaleToRef(result: Vector3): void; /** * Set the yaw, pitch, and roll of the bone in local or world space * @param yaw The rotation of the bone on the y axis * @param pitch The rotation of the bone on the x axis * @param roll The rotation of the bone on the z axis * @param space The space that the axes of rotation are in * @param mesh The mesh that this bone is attached to. This is only used in world space */ setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void; /** * Add a rotation to the bone on an axis in local or world space * @param axis The axis to rotate the bone on * @param amount The amount to rotate the bone * @param space The space that the axis is in * @param mesh The mesh that this bone is attached to. This is only used in world space */ rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void; /** * Set the rotation of the bone to a particular axis angle in local or world space * @param axis The axis to rotate the bone on * @param angle The angle that the bone should be rotated to * @param space The space that the axis is in * @param mesh The mesh that this bone is attached to. This is only used in world space */ setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void; /** * Set the euler rotation of the bone in local of world space * @param rotation The euler rotation that the bone should be set to * @param space The space that the rotation is in * @param mesh The mesh that this bone is attached to. This is only used in world space */ setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void; /** * Set the quaternion rotation of the bone in local of world space * @param quat The quaternion rotation that the bone should be set to * @param space The space that the rotation is in * @param mesh The mesh that this bone is attached to. This is only used in world space */ setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void; /** * Set the rotation matrix of the bone in local of world space * @param rotMat The rotation matrix that the bone should be set to * @param space The space that the rotation is in * @param mesh The mesh that this bone is attached to. This is only used in world space */ setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void; private _rotateWithMatrix; private _getNegativeRotationToRef; /** * Get the position of the bone in local or world space * @param space The space that the returned position is in * @param mesh The mesh that this bone is attached to. This is only used in world space * @returns The position of the bone */ getPosition(space?: Space, mesh?: Nullable): Vector3; /** * Copy the position of the bone to a vector3 in local or world space * @param space The space that the returned position is in * @param mesh The mesh that this bone is attached to. This is only used in world space * @param result The vector3 to copy the position to */ getPositionToRef(space: Space | undefined, mesh: Nullable, result: Vector3): void; /** * Get the absolute position of the bone (world space) * @param mesh The mesh that this bone is attached to * @returns The absolute position of the bone */ getAbsolutePosition(mesh?: Nullable): Vector3; /** * Copy the absolute position of the bone (world space) to the result param * @param mesh The mesh that this bone is attached to * @param result The vector3 to copy the absolute position to */ getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void; /** * Compute the absolute transforms of this bone and its children */ computeAbsoluteTransforms(): void; /** * Get the world direction from an axis that is in the local space of the bone * @param localAxis The local direction that is used to compute the world direction * @param mesh The mesh that this bone is attached to * @returns The world direction */ getDirection(localAxis: Vector3, mesh?: Nullable): Vector3; /** * Copy the world direction to a vector3 from an axis that is in the local space of the bone * @param localAxis The local direction that is used to compute the world direction * @param mesh The mesh that this bone is attached to * @param result The vector3 that the world direction will be copied to */ getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void; /** * Get the euler rotation of the bone in local or world space * @param space The space that the rotation should be in * @param mesh The mesh that this bone is attached to. This is only used in world space * @returns The euler rotation */ getRotation(space?: Space, mesh?: Nullable): Vector3; /** * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space * @param space The space that the rotation should be in * @param mesh The mesh that this bone is attached to. This is only used in world space * @param result The vector3 that the rotation should be copied to */ getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void; /** * Get the quaternion rotation of the bone in either local or world space * @param space The space that the rotation should be in * @param mesh The mesh that this bone is attached to. This is only used in world space * @returns The quaternion rotation */ getRotationQuaternion(space?: Space, mesh?: Nullable): Quaternion; /** * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space * @param space The space that the rotation should be in * @param mesh The mesh that this bone is attached to. This is only used in world space * @param result The quaternion that the rotation should be copied to */ getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void; /** * Get the rotation matrix of the bone in local or world space * @param space The space that the rotation should be in * @param mesh The mesh that this bone is attached to. This is only used in world space * @returns The rotation matrix */ getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix; /** * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space * @param space The space that the rotation should be in * @param mesh The mesh that this bone is attached to. This is only used in world space * @param result The quaternion that the rotation should be copied to */ getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void; /** * Get the world position of a point that is in the local space of the bone * @param position The local position * @param mesh The mesh that this bone is attached to * @returns The world position */ getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable): Vector3; /** * Get the world position of a point that is in the local space of the bone and copy it to the result param * @param position The local position * @param mesh The mesh that this bone is attached to * @param result The vector3 that the world position should be copied to */ getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void; /** * Get the local position of a point that is in world space * @param position The world position * @param mesh The mesh that this bone is attached to * @returns The local position */ getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable): Vector3; /** * Get the local position of a point that is in world space and copy it to the result param * @param position The world position * @param mesh The mesh that this bone is attached to * @param result The vector3 that the local position should be copied to */ getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void; } } declare module BABYLON { /** * Class used to apply inverse kinematics to bones * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller */ class BoneIKController { private static _tmpVecs; private static _tmpQuat; private static _tmpMats; /** * Gets or sets the target mesh */ targetMesh: AbstractMesh; /** Gets or sets the mesh used as pole */ poleTargetMesh: AbstractMesh; /** * Gets or sets the bone used as pole */ poleTargetBone: Nullable; /** * Gets or sets the target position */ targetPosition: Vector3; /** * Gets or sets the pole target position */ poleTargetPosition: Vector3; /** * Gets or sets the pole target local offset */ poleTargetLocalOffset: Vector3; /** * Gets or sets the pole angle */ poleAngle: number; /** * Gets or sets the mesh associated with the controller */ mesh: AbstractMesh; /** * The amount to slerp (spherical linear interpolation) to the target. Set this to a value between 0 and 1 (a value of 1 disables slerp) */ slerpAmount: number; private _bone1Quat; private _bone1Mat; private _bone2Ang; private _bone1; private _bone2; private _bone1Length; private _bone2Length; private _maxAngle; private _maxReach; private _rightHandedSystem; private _bendAxis; private _slerping; private _adjustRoll; /** * Gets or sets maximum allowed angle */ maxAngle: number; /** * Creates a new BoneIKController * @param mesh defines the mesh to control * @param bone defines the bone to control * @param options defines options to set up the controller */ constructor(mesh: AbstractMesh, bone: Bone, options?: { targetMesh?: AbstractMesh; poleTargetMesh?: AbstractMesh; poleTargetBone?: Bone; poleTargetLocalOffset?: Vector3; poleAngle?: number; bendAxis?: Vector3; maxAngle?: number; slerpAmount?: number; }); private _setMaxAngle; /** * Force the controller to update the bones */ update(): void; } } declare module BABYLON { /** * Class used to make a bone look toward a point in space * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller */ class BoneLookController { private static _tmpVecs; private static _tmpQuat; private static _tmpMats; /** * The target Vector3 that the bone will look at */ target: Vector3; /** * The mesh that the bone is attached to */ mesh: AbstractMesh; /** * The bone that will be looking to the target */ bone: Bone; /** * The up axis of the coordinate system that is used when the bone is rotated */ upAxis: Vector3; /** * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD */ upAxisSpace: Space; /** * Used to make an adjustment to the yaw of the bone */ adjustYaw: number; /** * Used to make an adjustment to the pitch of the bone */ adjustPitch: number; /** * Used to make an adjustment to the roll of the bone */ adjustRoll: number; /** * The amount to slerp (spherical linear interpolation) to the target. Set this to a value between 0 and 1 (a value of 1 disables slerp) */ slerpAmount: number; private _minYaw; private _maxYaw; private _minPitch; private _maxPitch; private _minYawSin; private _minYawCos; private _maxYawSin; private _maxYawCos; private _midYawConstraint; private _minPitchTan; private _maxPitchTan; private _boneQuat; private _slerping; private _transformYawPitch; private _transformYawPitchInv; private _firstFrameSkipped; private _yawRange; private _fowardAxis; /** * Gets or sets the minimum yaw angle that the bone can look to */ minYaw: number; /** * Gets or sets the maximum yaw angle that the bone can look to */ maxYaw: number; /** * Gets or sets the minimum pitch angle that the bone can look to */ minPitch: number; /** * Gets or sets the maximum pitch angle that the bone can look to */ maxPitch: number; /** * Create a BoneLookController * @param mesh the mesh that the bone belongs to * @param bone the bone that will be looking to the target * @param target the target Vector3 to look at * @param settings optional settings: * * maxYaw: the maximum angle the bone will yaw to * * minYaw: the minimum angle the bone will yaw to * * maxPitch: the maximum angle the bone will pitch to * * minPitch: the minimum angle the bone will yaw to * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target. * * upAxis: the up axis of the coordinate system * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD. * * yawAxis: set yawAxis if the bone does not yaw on the y axis * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis * * adjustYaw: used to make an adjustment to the yaw of the bone * * adjustPitch: used to make an adjustment to the pitch of the bone * * adjustRoll: used to make an adjustment to the roll of the bone **/ constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: { maxYaw?: number; minYaw?: number; maxPitch?: number; minPitch?: number; slerpAmount?: number; upAxis?: Vector3; upAxisSpace?: Space; yawAxis?: Vector3; pitchAxis?: Vector3; adjustYaw?: number; adjustPitch?: number; adjustRoll?: number; }); /** * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender()) */ update(): void; private _getAngleDiff; private _getAngleBetween; private _isAngleBetween; } } declare module BABYLON { /** * Class used to handle skinning animations * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons */ class Skeleton implements IAnimatable { /** defines the skeleton name */ name: string; /** defines the skeleton Id */ id: string; /** * Gets the list of child bones */ bones: Bone[]; /** * Gets an estimate of the dimension of the skeleton at rest */ dimensionsAtRest: Vector3; /** * Gets a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value) */ needInitialSkinMatrix: boolean; /** * Gets the list of animations attached to this skeleton */ animations: Array; private _scene; private _isDirty; private _transformMatrices; private _meshesWithPoseMatrix; private _animatables; private _identity; private _synchronizedWithMesh; private _ranges; private _lastAbsoluteTransformsUpdateId; /** * Specifies if the skeleton should be serialized */ doNotSerialize: boolean; private _animationPropertiesOverride; /** * Gets or sets the animation properties override */ animationPropertiesOverride: Nullable; /** * An observable triggered before computing the skeleton's matrices */ onBeforeComputeObservable: Observable; /** * Creates a new skeleton * @param name defines the skeleton name * @param id defines the skeleton Id * @param scene defines the hosting scene */ constructor( /** defines the skeleton name */ name: string, /** defines the skeleton Id */ id: string, scene: Scene); /** * Gets the list of transform matrices to send to shaders (one matrix per bone) * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true) * @returns a Float32Array containing matrices data */ getTransformMatrices(mesh: AbstractMesh): Float32Array; /** * Gets the current hosting scene * @returns a scene object */ getScene(): Scene; /** * Gets a string representing the current skeleton data * @param fullDetails defines a boolean indicating if we want a verbose version * @returns a string representing the current skeleton data */ toString(fullDetails?: boolean): string; /** * Get bone's index searching by name * @param name defines bone's name to search for * @return the indice of the bone. Returns -1 if not found */ getBoneIndexByName(name: string): number; /** * Creater a new animation range * @param name defines the name of the range * @param from defines the start key * @param to defines the end key */ createAnimationRange(name: string, from: number, to: number): void; /** * Delete a specific animation range * @param name defines the name of the range * @param deleteFrames defines if frames must be removed as well */ deleteAnimationRange(name: string, deleteFrames?: boolean): void; /** * Gets a specific animation range * @param name defines the name of the range to look for * @returns the requested animation range or null if not found */ getAnimationRange(name: string): Nullable; /** * Gets the list of all animation ranges defined on this skeleton * @returns an array */ getAnimationRanges(): Nullable[]; /** * Copy animation range from a source skeleton. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences * @param source defines the source skeleton * @param name defines the name of the range to copy * @param rescaleAsRequired defines if rescaling must be applied if required * @returns true if operation was successful */ copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean; /** * Forces the skeleton to go to rest pose */ returnToRest(): void; private _getHighestAnimationFrame; /** * Begin a specific animation range * @param name defines the name of the range to start * @param loop defines if looping must be turned on (false by default) * @param speedRatio defines the speed ratio to apply (1 by default) * @param onAnimationEnd defines a callback which will be called when animation will end * @returns a new animatable */ beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable; /** @hidden */ _markAsDirty(): void; /** @hidden */ _registerMeshWithPoseMatrix(mesh: AbstractMesh): void; /** @hidden */ _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void; /** @hidden */ _computeTransformMatrices(targetMatrix: Float32Array, initialSkinMatrix: Nullable): void; /** * Build all resources required to render a skeleton */ prepare(): void; /** * Gets the list of animatables currently running for this skeleton * @returns an array of animatables */ getAnimatables(): IAnimatable[]; /** * Clone the current skeleton * @param name defines the name of the new skeleton * @param id defines the id of the enw skeleton * @returns the new skeleton */ clone(name: string, id: string): Skeleton; /** * Enable animation blending for this skeleton * @param blendingSpeed defines the blending speed to apply * @see http://doc.babylonjs.com/babylon101/animations#animation-blending */ enableBlending(blendingSpeed?: number): void; /** * Releases all resources associated with the current skeleton */ dispose(): void; /** * Serialize the skeleton in a JSON object * @returns a JSON object */ serialize(): any; /** * Creates a new skeleton from serialized data * @param parsedSkeleton defines the serialized data * @param scene defines the hosting scene * @returns a new skeleton */ static Parse(parsedSkeleton: any, scene: Scene): Skeleton; /** * Compute all node absolute transforms * @param forceUpdate defines if computation must be done even if cache is up to date */ computeAbsoluteTransforms(forceUpdate?: boolean): void; /** * Gets the root pose matrix * @returns a matrix */ getPoseMatrix(): Nullable; /** * Sorts bones per internal index */ sortBones(): void; private _sortBones; } } declare module BABYLON { /** @hidden */ class Collider { /** Define if a collision was found */ collisionFound: boolean; /** * Define last intersection point in local space */ intersectionPoint: Vector3; /** * Define last collided mesh */ collidedMesh: Nullable; private _collisionPoint; private _planeIntersectionPoint; private _tempVector; private _tempVector2; private _tempVector3; private _tempVector4; private _edge; private _baseToVertex; private _destinationPoint; private _slidePlaneNormal; private _displacementVector; /** @hidden */ _radius: Vector3; /** @hidden */ _retry: number; private _velocity; private _basePoint; private _epsilon; /** @hidden */ _velocityWorldLength: number; /** @hidden */ _basePointWorld: Vector3; private _velocityWorld; private _normalizedVelocity; /** @hidden */ _initialVelocity: Vector3; /** @hidden */ _initialPosition: Vector3; private _nearestDistance; private _collisionMask; collisionMask: number; /** * Gets the plane normal used to compute the sliding response (in local space) */ readonly slidePlaneNormal: Vector3; /** @hidden */ _initialize(source: Vector3, dir: Vector3, e: number): void; /** @hidden */ _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean; /** @hidden */ _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean; /** @hidden */ _testTriangle(faceIndex: number, trianglePlaneArray: Array, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void; /** @hidden */ _collide(trianglePlaneArray: Array, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void; /** @hidden */ _getResponse(pos: Vector3, vel: Vector3): void; } } declare module BABYLON { /** @hidden */ var CollisionWorker: string; /** @hidden */ interface ICollisionCoordinator { getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable) => void, collisionIndex: number): void; init(scene: Scene): void; destroy(): void; onMeshAdded(mesh: AbstractMesh): void; onMeshUpdated(mesh: AbstractMesh): void; onMeshRemoved(mesh: AbstractMesh): void; onGeometryAdded(geometry: Geometry): void; onGeometryUpdated(geometry: Geometry): void; onGeometryDeleted(geometry: Geometry): void; } /** @hidden */ interface SerializedMesh { id: string; name: string; uniqueId: number; geometryId: Nullable; sphereCenter: Array; sphereRadius: number; boxMinimum: Array; boxMaximum: Array; worldMatrixFromCache: any; subMeshes: Array; checkCollisions: boolean; } /** @hidden */ interface SerializedSubMesh { position: number; verticesStart: number; verticesCount: number; indexStart: number; indexCount: number; hasMaterial: boolean; sphereCenter: Array; sphereRadius: number; boxMinimum: Array; boxMaximum: Array; } /** * Interface describing the value associated with a geometry. * @hidden */ interface SerializedGeometry { /** * Defines the unique ID of the geometry */ id: string; /** * Defines the array containing the positions */ positions: Float32Array; /** * Defines the array containing the indices */ indices: Uint32Array; /** * Defines the array containing the normals */ normals: Float32Array; } /** @hidden */ interface BabylonMessage { taskType: WorkerTaskType; payload: InitPayload | CollidePayload | UpdatePayload; } /** @hidden */ interface SerializedColliderToWorker { position: Array; velocity: Array; radius: Array; } /** Defines supported task for worker process */ enum WorkerTaskType { /** Initialization */ INIT = 0, /** Update of geometry */ UPDATE = 1, /** Evaluate collision */ COLLIDE = 2 } /** @hidden */ interface WorkerReply { error: WorkerReplyType; taskType: WorkerTaskType; payload?: any; } /** @hidden */ interface CollisionReplyPayload { newPosition: Array; collisionId: number; collidedMeshUniqueId: number; } /** @hidden */ interface InitPayload { } /** @hidden */ interface CollidePayload { collisionId: number; collider: SerializedColliderToWorker; maximumRetry: number; excludedMeshUniqueId: Nullable; } /** @hidden */ interface UpdatePayload { updatedMeshes: { [n: number]: SerializedMesh; }; updatedGeometries: { [s: string]: SerializedGeometry; }; removedMeshes: Array; removedGeometries: Array; } /** Defines kind of replies returned by worker */ enum WorkerReplyType { /** Success */ SUCCESS = 0, /** Unkown error */ UNKNOWN_ERROR = 1 } /** @hidden */ class CollisionCoordinatorWorker implements ICollisionCoordinator { private _scene; private _scaledPosition; private _scaledVelocity; private _collisionsCallbackArray; private _init; private _runningUpdated; private _worker; private _addUpdateMeshesList; private _addUpdateGeometriesList; private _toRemoveMeshesArray; private _toRemoveGeometryArray; constructor(); static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh; static SerializeGeometry: (geometry: Geometry) => SerializedGeometry; getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable) => void, collisionIndex: number): void; init(scene: Scene): void; destroy(): void; onMeshAdded(mesh: AbstractMesh): void; onMeshUpdated: (transformNode: TransformNode) => void; onMeshRemoved(mesh: AbstractMesh): void; onGeometryAdded(geometry: Geometry): void; onGeometryUpdated: (geometry: Geometry) => void; onGeometryDeleted(geometry: Geometry): void; private _afterRender; private _onMessageFromWorker; } /** @hidden */ class CollisionCoordinatorLegacy implements ICollisionCoordinator { private _scene; private _scaledPosition; private _scaledVelocity; private _finalPosition; getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable) => void, collisionIndex: number): void; init(scene: Scene): void; destroy(): void; onMeshAdded(mesh: AbstractMesh): void; onMeshUpdated(mesh: AbstractMesh): void; onMeshRemoved(mesh: AbstractMesh): void; onGeometryAdded(geometry: Geometry): void; onGeometryUpdated(geometry: Geometry): void; onGeometryDeleted(geometry: Geometry): void; private _collideWithWorld; } } declare function importScripts(...urls: string[]): void; declare const safePostMessage: any; declare module BABYLON { /** @hidden */ var WorkerIncluded: boolean; /** @hidden */ class CollisionCache { private _meshes; private _geometries; getMeshes(): { [n: number]: SerializedMesh; }; getGeometries(): { [s: number]: SerializedGeometry; }; getMesh(id: any): SerializedMesh; addMesh(mesh: SerializedMesh): void; removeMesh(uniqueId: number): void; getGeometry(id: string): SerializedGeometry; addGeometry(geometry: SerializedGeometry): void; removeGeometry(id: string): void; } /** @hidden */ class CollideWorker { collider: Collider; private _collisionCache; private finalPosition; private collisionsScalingMatrix; private collisionTranformationMatrix; constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3); collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable): void; private checkCollision; private processCollisionsForSubMeshes; private collideForSubMesh; private checkSubmeshCollision; } /** @hidden */ interface ICollisionDetector { onInit(payload: InitPayload): void; onUpdate(payload: UpdatePayload): void; onCollision(payload: CollidePayload): void; } /** @hidden */ class CollisionDetectorTransferable implements ICollisionDetector { private _collisionCache; onInit(payload: InitPayload): void; onUpdate(payload: UpdatePayload): void; onCollision(payload: CollidePayload): void; } } declare module BABYLON { /** * @hidden */ class IntersectionInfo { bu: Nullable; bv: Nullable; distance: number; faceId: number; subMeshId: number; constructor(bu: Nullable, bv: Nullable, distance: number); } /** * Information about the result of picking within a scene * @see https://doc.babylonjs.com/babylon101/picking_collisions */ class PickingInfo { /** * If the pick collided with an object */ hit: boolean; /** * Distance away where the pick collided */ distance: number; /** * The location of pick collision */ pickedPoint: Nullable; /** * The mesh corresponding the the pick collision */ pickedMesh: Nullable; /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/ bu: number; /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/ bv: number; /** The id of the face on the mesh that was picked */ faceId: number; /** Id of the the submesh that was picked */ subMeshId: number; /** If a sprite was picked, this will be the sprite the pick collided with */ pickedSprite: Nullable; /** * If a mesh was used to do the picking (eg. 6dof controller) this will be populated. */ originMesh: Nullable; /** * The ray that was used to perform the picking. */ ray: Nullable; /** * Gets the normal correspodning to the face the pick collided with * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false) * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map * @returns The normal correspodning to the face the pick collided with */ getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable; /** * Gets the texture coordinates of where the pick occured * @returns the vector containing the coordnates of the texture */ getTextureCoordinates(): Nullable; } } declare module BABYLON { /** * This represents an orbital type of camera. * * This camera always points towards a given target position and can be rotated around that target with the target as the centre of rotation. It can be controlled with cursors and mouse, or with touch events. * Think of this camera as one orbiting its target position, or more imaginatively as a spy satellite orbiting the earth. Its position relative to the target (earth) can be set by three parameters, alpha (radians) the longitudinal rotation, beta (radians) the latitudinal rotation and radius the distance from the target position. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera */ class ArcRotateCamera extends TargetCamera { /** * Defines the rotation angle of the camera along the longitudinal axis. */ alpha: number; /** * Defines the rotation angle of the camera along the latitudinal axis. */ beta: number; /** * Defines the radius of the camera from it s target point. */ radius: number; protected _target: Vector3; protected _targetHost: Nullable; /** * Defines the target point of the camera. * The camera looks towards it form the radius distance. */ target: Vector3; /** * Current inertia value on the longitudinal axis. * The bigger this number the longer it will take for the camera to stop. */ inertialAlphaOffset: number; /** * Current inertia value on the latitudinal axis. * The bigger this number the longer it will take for the camera to stop. */ inertialBetaOffset: number; /** * Current inertia value on the radius axis. * The bigger this number the longer it will take for the camera to stop. */ inertialRadiusOffset: number; /** * Minimum allowed angle on the longitudinal axis. * This can help limiting how the Camera is able to move in the scene. */ lowerAlphaLimit: Nullable; /** * Maximum allowed angle on the longitudinal axis. * This can help limiting how the Camera is able to move in the scene. */ upperAlphaLimit: Nullable; /** * Minimum allowed angle on the latitudinal axis. * This can help limiting how the Camera is able to move in the scene. */ lowerBetaLimit: number; /** * Maximum allowed angle on the latitudinal axis. * This can help limiting how the Camera is able to move in the scene. */ upperBetaLimit: number; /** * Minimum allowed distance of the camera to the target (The camera can not get closer). * This can help limiting how the Camera is able to move in the scene. */ lowerRadiusLimit: Nullable; /** * Maximum allowed distance of the camera to the target (The camera can not get further). * This can help limiting how the Camera is able to move in the scene. */ upperRadiusLimit: Nullable; /** * Defines the current inertia value used during panning of the camera along the X axis. */ inertialPanningX: number; /** * Defines the current inertia value used during panning of the camera along the Y axis. */ inertialPanningY: number; /** * Defines the distance used to consider the camera in pan mode vs pinch/zoom. * Basically if your fingers moves away from more than this distance you will be considered * in pinch mode. */ pinchToPanMaxDistance: number; /** * Defines the maximum distance the camera can pan. * This could help keeping the cammera always in your scene. */ panningDistanceLimit: Nullable; /** * Defines the target of the camera before paning. */ panningOriginTarget: Vector3; /** * Defines the value of the inertia used during panning. * 0 would mean stop inertia and one would mean no decelleration at all. */ panningInertia: number; /** * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating. */ angularSensibilityX: number; /** * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating. */ angularSensibilityY: number; /** * Gets or Set the pointer pinch precision or how fast is the camera zooming. */ pinchPrecision: number; /** * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming. * It will be used instead of pinchDeltaPrecision if different from 0. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used. */ pinchDeltaPercentage: number; /** * Gets or Set the pointer panning sensibility or how fast is the camera moving. */ panningSensibility: number; /** * Gets or Set the list of keyboard keys used to control beta angle in a positive direction. */ keysUp: number[]; /** * Gets or Set the list of keyboard keys used to control beta angle in a negative direction. */ keysDown: number[]; /** * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction. */ keysLeft: number[]; /** * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction. */ keysRight: number[]; /** * Gets or Set the mouse wheel precision or how fast is the camera zooming. */ wheelPrecision: number; /** * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming. * It will be used instead of pinchDeltaPrecision if different from 0. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used. */ wheelDeltaPercentage: number; /** * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function) */ zoomOnFactor: number; /** * Defines a screen offset for the camera position. */ targetScreenOffset: Vector2; /** * Allows the camera to be completely reversed. * If false the camera can not arrive upside down. */ allowUpsideDown: boolean; /** * Define if double tap/click is used to restore the previously saved state of the camera. */ useInputToRestoreState: boolean; /** @hidden */ _viewMatrix: Matrix; /** @hidden */ _useCtrlForPanning: boolean; /** @hidden */ _panningMouseButton: number; /** * Defines the inpute associated to the camera. */ inputs: ArcRotateCameraInputsManager; /** @hidden */ _reset: () => void; /** * Defines the allowed panning axis. */ panningAxis: Vector3; protected _localDirection: Vector3; protected _transformedDirection: Vector3; private _bouncingBehavior; /** * Gets the bouncing behavior of the camera if it has been enabled. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior */ readonly bouncingBehavior: Nullable; /** * Defines if the bouncing behavior of the camera is enabled on the camera. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior */ useBouncingBehavior: boolean; private _framingBehavior; /** * Gets the framing behavior of the camera if it has been enabled. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior */ readonly framingBehavior: Nullable; /** * Defines if the framing behavior of the camera is enabled on the camera. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior */ useFramingBehavior: boolean; private _autoRotationBehavior; /** * Gets the auto rotation behavior of the camera if it has been enabled. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior */ readonly autoRotationBehavior: Nullable; /** * Defines if the auto rotation behavior of the camera is enabled on the camera. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior */ useAutoRotationBehavior: boolean; /** * Observable triggered when the mesh target has been changed on the camera. */ onMeshTargetChangedObservable: Observable>; /** * Event raised when the camera is colliding with a mesh. */ onCollide: (collidedMesh: AbstractMesh) => void; /** * Defines whether the camera should check collision with the objects oh the scene. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this */ checkCollisions: boolean; /** * Defines the collision radius of the camera. * This simulates a sphere around the camera. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera */ collisionRadius: Vector3; protected _collider: Collider; protected _previousPosition: Vector3; protected _collisionVelocity: Vector3; protected _newPosition: Vector3; protected _previousAlpha: number; protected _previousBeta: number; protected _previousRadius: number; protected _collisionTriggered: boolean; protected _targetBoundingCenter: Nullable; private _computationVector; /** * Instantiates a new ArcRotateCamera in a given scene * @param name Defines the name of the camera * @param alpha Defines the camera rotation along the logitudinal axis * @param beta Defines the camera rotation along the latitudinal axis * @param radius Defines the camera distance from its target * @param target Defines the camera target * @param scene Defines the scene the camera belongs to * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined */ constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean); /** @hidden */ _initCache(): void; /** @hidden */ _updateCache(ignoreParentClass?: boolean): void; protected _getTargetPosition(): Vector3; private _storedAlpha; private _storedBeta; private _storedRadius; private _storedTarget; /** * Stores the current state of the camera (alpha, beta, radius and target) * @returns the camera itself */ storeState(): Camera; /** * @hidden * Restored camera state. You must call storeState() first */ _restoreStateValues(): boolean; /** @hidden */ _isSynchronizedViewMatrix(): boolean; /** * Attached controls to the current camera. * @param element Defines the element the controls should be listened from * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault) * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls * @param panningMouseButton Defines whether panning is allowed through mouse click button */ attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void; /** * Detach the current controls from the camera. * The camera will stop reacting to inputs. * @param element Defines the element to stop listening the inputs from */ detachControl(element: HTMLElement): void; /** @hidden */ _checkInputs(): void; protected _checkLimits(): void; /** * Rebuilds angles (alpha, beta) and radius from the give position and target. */ rebuildAnglesAndRadius(): void; /** * Use a position to define the current camera related information like aplha, beta and radius * @param position Defines the position to set the camera at */ setPosition(position: Vector3): void; /** * Defines the target the camera should look at. * This will automatically adapt alpha beta and radius to fit within the new target. * @param target Defines the new target as a Vector or a mesh * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim) */ setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void; /** @hidden */ _getViewMatrix(): Matrix; protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable) => void; /** * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport. * @param meshes Defines the mesh to zoom on * @param doNotUpdateMaxZ Defines whether or not maxZ should be updated whilst zooming on the mesh (this can happen if the mesh is big and the maxradius pretty small for instance) */ zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void; /** * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius. * The target will be changed but the radius * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on * @param doNotUpdateMaxZ Defines whether or not maxZ should be updated whilst zooming on the mesh (this can happen if the mesh is big and the maxradius pretty small for instance) */ focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | { min: Vector3; max: Vector3; distance: number; }, doNotUpdateMaxZ?: boolean): void; /** * @override * Override Camera.createRigCamera */ createRigCamera(name: string, cameraIndex: number): Camera; /** * @hidden * @override * Override Camera._updateRigCameras */ _updateRigCameras(): void; /** * Destroy the camera and release the current resources hold by it. */ dispose(): void; /** * Gets the current object class name. * @return the class name */ getClassName(): string; } } declare module BABYLON { /** * Default Inputs manager for the ArcRotateCamera. * It groups all the default supported inputs for ease of use. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs */ class ArcRotateCameraInputsManager extends CameraInputsManager { /** * Instantiates a new ArcRotateCameraInputsManager. * @param camera Defines the camera the inputs belong to */ constructor(camera: ArcRotateCamera); /** * Add mouse wheel input support to the input manager. * @returns the current input manager */ addMouseWheel(): ArcRotateCameraInputsManager; /** * Add pointers input support to the input manager. * @returns the current input manager */ addPointers(): ArcRotateCameraInputsManager; /** * Add keyboard input support to the input manager. * @returns the current input manager */ addKeyboard(): ArcRotateCameraInputsManager; /** * Add orientation input support to the input manager. * @returns the current input manager */ addVRDeviceOrientation(): ArcRotateCameraInputsManager; } } declare module BABYLON { /** * This is the base class of all the camera used in the application. * @see http://doc.babylonjs.com/features/cameras */ class Camera extends Node { /** * This is the default projection mode used by the cameras. * It helps recreating a feeling of perspective and better appreciate depth. * This is the best way to simulate real life cameras. */ static readonly PERSPECTIVE_CAMERA: number; /** * This helps creating camera with an orthographic mode. * Orthographic is commonly used in engineering as a means to produce object specifications that communicate dimensions unambiguously, each line of 1 unit length (cm, meter..whatever) will appear to have the same length everywhere on the drawing. This allows the drafter to dimension only a subset of lines and let the reader know that other lines of that length on the drawing are also that length in reality. Every parallel line in the drawing is also parallel in the object. */ static readonly ORTHOGRAPHIC_CAMERA: number; /** * This is the default FOV mode for perspective cameras. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum. */ static readonly FOVMODE_VERTICAL_FIXED: number; /** * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum. */ static readonly FOVMODE_HORIZONTAL_FIXED: number; /** * This specifies ther is no need for a camera rig. * Basically only one eye is rendered corresponding to the camera. */ static readonly RIG_MODE_NONE: number; /** * Simulates a camera Rig with one blue eye and one red eye. * This can be use with 3d blue and red glasses. */ static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number; /** * Defines that both eyes of the camera will be rendered side by side with a parallel target. */ static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number; /** * Defines that both eyes of the camera will be rendered side by side with a none parallel target. */ static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number; /** * Defines that both eyes of the camera will be rendered over under each other. */ static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number; /** * Defines that both eyes of the camera should be renderered in a VR mode (carbox). */ static readonly RIG_MODE_VR: number; /** * Defines that both eyes of the camera should be renderered in a VR mode (webVR). */ static readonly RIG_MODE_WEBVR: number; /** * Defines if by default attaching controls should prevent the default javascript event to continue. */ static ForceAttachControlToAlwaysPreventDefault: boolean; /** * @hidden * Might be removed once multiview will be a thing */ static UseAlternateWebVRRendering: boolean; /** * Define the input manager associated with the camera. */ inputs: CameraInputsManager; /** * Define the current local position of the camera in the scene */ position: Vector3; /** * The vector the camera should consider as up. * (default is Vector3(0, 1, 0) aka Vector3.Up()) */ upVector: Vector3; /** * Define the current limit on the left side for an orthographic camera * In scene unit */ orthoLeft: Nullable; /** * Define the current limit on the right side for an orthographic camera * In scene unit */ orthoRight: Nullable; /** * Define the current limit on the bottom side for an orthographic camera * In scene unit */ orthoBottom: Nullable; /** * Define the current limit on the top side for an orthographic camera * In scene unit */ orthoTop: Nullable; /** * Field Of View is set in Radians. (default is 0.8) */ fov: number; /** * Define the minimum distance the camera can see from. * This is important to note that the depth buffer are not infinite and the closer it starts * the more your scene might encounter depth fighting issue. */ minZ: number; /** * Define the maximum distance the camera can see to. * This is important to note that the depth buffer are not infinite and the further it end * the more your scene might encounter depth fighting issue. */ maxZ: number; /** * Define the default inertia of the camera. * This helps giving a smooth feeling to the camera movement. */ inertia: number; /** * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC) */ mode: number; /** * Define wether the camera is intermediate. * This is usefull to not present the output directly to the screen in case of rig without post process for instance */ isIntermediate: boolean; /** * Define the viewport of the camera. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit. */ viewport: Viewport; /** * Restricts the camera to viewing objects with the same layerMask. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0 */ layerMask: number; /** * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED) */ fovMode: number; /** * Rig mode of the camera. * This is usefull to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes. * This is normally controlled byt the camera themselves as internal use. */ cameraRigMode: number; /** * Defines the distance between both "eyes" in case of a RIG */ interaxialDistance: number; /** * Defines if stereoscopic rendering is done side by side or over under. */ isStereoscopicSideBySide: boolean; /** * Defines the list of custom render target the camera should render to. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere * else in the scene. */ customRenderTargets: RenderTargetTexture[]; /** * Observable triggered when the camera view matrix has changed. */ onViewMatrixChangedObservable: Observable; /** * Observable triggered when the camera Projection matrix has changed. */ onProjectionMatrixChangedObservable: Observable; /** * Observable triggered when the inputs have been processed. */ onAfterCheckInputsObservable: Observable; /** * Observable triggered when reset has been called and applied to the camera. */ onRestoreStateObservable: Observable; /** @hidden */ _cameraRigParams: any; /** @hidden */ _rigCameras: Camera[]; /** @hidden */ _rigPostProcess: Nullable; protected _webvrViewMatrix: Matrix; /** @hidden */ _skipRendering: boolean; /** @hidden */ _alternateCamera: Camera; /** @hidden */ _projectionMatrix: Matrix; /** @hidden */ _postProcesses: Nullable[]; /** @hidden */ _activeMeshes: SmartArray; protected _globalPosition: Vector3; private _computedViewMatrix; private _doNotComputeProjectionMatrix; private _transformMatrix; private _frustumPlanes; private _refreshFrustumPlanes; private _storedFov; private _stateStored; /** * Instantiates a new camera object. * This should not be used directly but through the inherited cameras: ArcRotate, Free... * @see http://doc.babylonjs.com/features/cameras * @param name Defines the name of the camera in the scene * @param position Defines the position of the camera * @param scene Defines the scene the camera belongs too * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene */ constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean); /** * Store current camera state (fov, position, etc..) * @returns the camera */ storeState(): Camera; /** * Restores the camera state values if it has been stored. You must call storeState() first */ protected _restoreStateValues(): boolean; /** * Restored camera state. You must call storeState() first. * @returns true if restored and false otherwise */ restoreState(): boolean; /** * Gets the class name of the camera. * @returns the class name */ getClassName(): string; /** * Gets a string representation of the camera usefull for debug purpose. * @param fullDetails Defines that a more verboe level of logging is required * @returns the string representation */ toString(fullDetails?: boolean): string; /** * Gets the current world space position of the camera. */ readonly globalPosition: Vector3; /** * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame) * @returns the active meshe list */ getActiveMeshes(): SmartArray; /** * Check wether a mesh is part of the current active mesh list of the camera * @param mesh Defines the mesh to check * @returns true if active, false otherwise */ isActiveMesh(mesh: Mesh): boolean; /** * Is this camera ready to be used/rendered * @param completeCheck defines if a complete check (including post processes) has to be done (false by default) * @return true if the camera is ready */ isReady(completeCheck?: boolean): boolean; /** @hidden */ _initCache(): void; /** @hidden */ _updateCache(ignoreParentClass?: boolean): void; /** @hidden */ _isSynchronized(): boolean; /** @hidden */ _isSynchronizedViewMatrix(): boolean; /** @hidden */ _isSynchronizedProjectionMatrix(): boolean; /** * Attach the input controls to a specific dom element to get the input from. * @param element Defines the element the controls should be listened from * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault) */ attachControl(element: HTMLElement, noPreventDefault?: boolean): void; /** * Detach the current controls from the specified dom element. * @param element Defines the element to stop listening the inputs from */ detachControl(element: HTMLElement): void; /** * Update the camera state according to the different inputs gathered during the frame. */ update(): void; /** @hidden */ _checkInputs(): void; /** @hidden */ readonly rigCameras: Camera[]; /** * Gets the post process used by the rig cameras */ readonly rigPostProcess: Nullable; /** * Internal, gets the first post proces. * @returns the first post process to be run on this camera. */ _getFirstPostProcess(): Nullable; private _cascadePostProcessesToRigCams; /** * Attach a post process to the camera. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess * @param postProcess The post process to attach to the camera * @param insertAt The position of the post process in case several of them are in use in the scene * @returns the position the post process has been inserted at */ attachPostProcess(postProcess: PostProcess, insertAt?: Nullable): number; /** * Detach a post process to the camera. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess * @param postProcess The post process to detach from the camera */ detachPostProcess(postProcess: PostProcess): void; /** * Gets the current world matrix of the camera */ getWorldMatrix(): Matrix; /** @hidden */ protected _getViewMatrix(): Matrix; /** * Gets the current view matrix of the camera. * @param force forces the camera to recompute the matrix without looking at the cached state * @returns the view matrix */ getViewMatrix(force?: boolean): Matrix; /** * Freeze the projection matrix. * It will prevent the cache check of the camera projection compute and can speed up perf * if no parameter of the camera are meant to change * @param projection Defines manually a projection if necessary */ freezeProjectionMatrix(projection?: Matrix): void; /** * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix. */ unfreezeProjectionMatrix(): void; /** * Gets the current projection matrix of the camera. * @param force forces the camera to recompute the matrix without looking at the cached state * @returns the projection matrix */ getProjectionMatrix(force?: boolean): Matrix; /** * Gets the transformation matrix (ie. the multiplication of view by projection matrices) * @returns a Matrix */ getTransformationMatrix(): Matrix; private _updateFrustumPlanes; /** * Checks if a cullable object (mesh...) is in the camera frustum * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check * @param target The object to check * @returns true if the object is in frustum otherwise false */ isInFrustum(target: ICullable): boolean; /** * Checks if a cullable object (mesh...) is in the camera frustum * Unlike isInFrustum this cheks the full bounding box * @param target The object to check * @returns true if the object is in frustum otherwise false */ isCompletelyInFrustum(target: ICullable): boolean; /** * Gets a ray in the forward direction from the camera. * @param length Defines the length of the ray to create * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray * @param origin Defines the start point of the ray which defaults to the camera position * @returns the forward ray */ getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray; /** * Releases resources associated with this node. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default) * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default) */ dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void; /** * Gets the left camera of a rig setup in case of Rigged Camera */ readonly leftCamera: Nullable; /** * Gets the right camera of a rig setup in case of Rigged Camera */ readonly rightCamera: Nullable; /** * Gets the left camera target of a rig setup in case of Rigged Camera * @returns the target position */ getLeftTarget(): Nullable; /** * Gets the right camera target of a rig setup in case of Rigged Camera * @returns the target position */ getRightTarget(): Nullable; /** * @hidden */ setCameraRigMode(mode: number, rigParams: any): void; private _getVRProjectionMatrix; protected _updateCameraRotationMatrix(): void; protected _updateWebVRCameraRotationMatrix(): void; /** * This function MUST be overwritten by the different WebVR cameras available. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right. */ protected _getWebVRProjectionMatrix(): Matrix; /** * This function MUST be overwritten by the different WebVR cameras available. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right. */ protected _getWebVRViewMatrix(): Matrix; /** @hidden */ setCameraRigParameter(name: string, value: any): void; /** * needs to be overridden by children so sub has required properties to be copied * @hidden */ createRigCamera(name: string, cameraIndex: number): Nullable; /** * May need to be overridden by children * @hidden */ _updateRigCameras(): void; /** @hidden */ _setupInputs(): void; /** * Serialiaze the camera setup to a json represention * @returns the JSON representation */ serialize(): any; /** * Clones the current camera. * @param name The cloned camera name * @returns the cloned camera */ clone(name: string): Camera; /** * Gets the direction of the camera relative to a given local axis. * @param localAxis Defines the reference axis to provide a relative direction. * @return the direction */ getDirection(localAxis: Vector3): Vector3; /** * Gets the direction of the camera relative to a given local axis into a passed vector. * @param localAxis Defines the reference axis to provide a relative direction. * @param result Defines the vector to store the result in */ getDirectionToRef(localAxis: Vector3, result: Vector3): void; /** * Gets a camera constructor for a given camera type * @param type The type of the camera to construct (should be equal to one of the camera class name) * @param name The name of the camera the result will be able to instantiate * @param scene The scene the result will construct the camera in * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side * @returns a factory method to construc the camera */ static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera; /** * Compute the world matrix of the camera. * @returns the camera workd matrix */ computeWorldMatrix(): Matrix; /** * Parse a JSON and creates the camera from the parsed information * @param parsedCamera The JSON to parse * @param scene The scene to instantiate the camera in * @returns the newly constructed camera */ static Parse(parsedCamera: any, scene: Scene): Camera; } } declare module BABYLON { /** * @ignore * This is a list of all the different input types that are available in the application. * Fo instance: ArcRotateCameraGamepadInput... */ var CameraInputTypes: {}; /** * This is the contract to implement in order to create a new input class. * Inputs are dealing with listening to user actions and moving the camera accordingly. */ interface ICameraInput { /** * Defines the camera the input is attached to. */ camera: Nullable; /** * Gets the class name of the current intput. * @returns the class name */ getClassName(): string; /** * Get the friendly name associated with the input class. * @returns the input friendly name */ getSimpleName(): string; /** * Attach the input controls to a specific dom element to get the input from. * @param element Defines the element the controls should be listened from * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault) */ attachControl(element: HTMLElement, noPreventDefault?: boolean): void; /** * Detach the current controls from the specified dom element. * @param element Defines the element to stop listening the inputs from */ detachControl(element: Nullable): void; /** * Update the current camera state depending on the inputs that have been used this frame. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop. */ checkInputs?: () => void; } /** * Represents a map of input types to input instance or input index to input instance. */ interface CameraInputsMap { /** * Accessor to the input by input type. */ [name: string]: ICameraInput; /** * Accessor to the input by input index. */ [idx: number]: ICameraInput; } /** * This represents the input manager used within a camera. * It helps dealing with all the different kind of input attached to a camera. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs */ class CameraInputsManager { /** * Defines the list of inputs attahed to the camera. */ attached: CameraInputsMap; /** * Defines the dom element the camera is collecting inputs from. * This is null if the controls have not been attached. */ attachedElement: Nullable; /** * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault) */ noPreventDefault: boolean; /** * Defined the camera the input manager belongs to. */ camera: TCamera; /** * Update the current camera state depending on the inputs that have been used this frame. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop. */ checkInputs: () => void; /** * Instantiate a new Camera Input Manager. * @param camera Defines the camera the input manager blongs to */ constructor(camera: TCamera); /** * Add an input method to a camera * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs * @param input camera input method */ add(input: ICameraInput): void; /** * Remove a specific input method from a camera * example: camera.inputs.remove(camera.inputs.attached.mouse); * @param inputToRemove camera input method */ remove(inputToRemove: ICameraInput): void; /** * Remove a specific input type from a camera * example: camera.inputs.remove("ArcRotateCameraGamepadInput"); * @param inputType the type of the input to remove */ removeByType(inputType: string): void; private _addCheckInputs; /** * Attach the input controls to the currently attached dom element to listen the events from. * @param input Defines the input to attach */ attachInput(input: ICameraInput): void; /** * Attach the current manager inputs controls to a specific dom element to listen the events from. * @param element Defines the dom element to collect the events from * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault) */ attachElement(element: HTMLElement, noPreventDefault?: boolean): void; /** * Detach the current manager inputs controls from a specific dom element. * @param element Defines the dom element to collect the events from * @param disconnect Defines whether the input should be removed from the current list of attached inputs */ detachElement(element: HTMLElement, disconnect?: boolean): void; /** * Rebuild the dynamic inputCheck function from the current list of * defined inputs in the manager. */ rebuildInputCheck(): void; /** * Remove all attached input methods from a camera */ clear(): void; /** * Serialize the current input manager attached to a camera. * This ensures than once parsed, * the input associated to the camera will be identical to the current ones * @param serializedCamera Defines the camera serialization JSON the input serialization should write to */ serialize(serializedCamera: any): void; /** * Parses an input manager serialized JSON to restore the previous list of inputs * and states associated to a camera. * @param parsedCamera Defines the JSON to parse */ parse(parsedCamera: any): void; } } declare module BABYLON { /** * This is a camera specifically designed to react to device orientation events such as a modern mobile device * being tilted forward or back and left or right. */ class DeviceOrientationCamera extends FreeCamera { private _initialQuaternion; private _quaternionCache; /** * Creates a new device orientation camera * @param name The name of the camera * @param position The start position camera * @param scene The scene the camera belongs to */ constructor(name: string, position: Vector3, scene: Scene); /** * Gets the current instance class name ("DeviceOrientationCamera"). * This helps avoiding instanceof at run time. * @returns the class name */ getClassName(): string; /** * @hidden * Checks and applies the current values of the inputs to the camera. (Internal use only) */ _checkInputs(): void; /** * Reset the camera to its default orientation on the specified axis only. * @param axis The axis to reset */ resetToCurrentRotation(axis?: Axis): void; } } declare module BABYLON { /** * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and * an arc rotate version arcFollowCamera are available. * @see http://doc.babylonjs.com/features/cameras#follow-camera */ class FollowCamera extends TargetCamera { /** * Distance the follow camera should follow an object at */ radius: number; /** * Define a rotation offset between the camera and the object it follows */ rotationOffset: number; /** * Define a height offset between the camera and the object it follows. * It can help following an object from the top (like a car chaing a plane) */ heightOffset: number; /** * Define how fast the camera can accelerate to follow it s target. */ cameraAcceleration: number; /** * Define the speed limit of the camera following an object. */ maxCameraSpeed: number; /** * Define the target of the camera. */ lockedTarget: Nullable; /** * Instantiates the follow camera. * @see http://doc.babylonjs.com/features/cameras#follow-camera * @param name Define the name of the camera in the scene * @param position Define the position of the camera * @param scene Define the scene the camera belong to * @param lockedTarget Define the target of the camera */ constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable); private _follow; /** @hidden */ _checkInputs(): void; /** * Gets the camera class name. * @returns the class name */ getClassName(): string; } /** * Arc Rotate version of the follow camera. * It still follows a Defined mesh but in an Arc Rotate Camera fashion. * @see http://doc.babylonjs.com/features/cameras#follow-camera */ class ArcFollowCamera extends TargetCamera { /** The longitudinal angle of the camera */ alpha: number; /** The latitudinal angle of the camera */ beta: number; /** The radius of the camera from its target */ radius: number; /** Define the camera target (the messh it should follow) */ target: Nullable; private _cartesianCoordinates; /** * Instantiates a new ArcFollowCamera * @see http://doc.babylonjs.com/features/cameras#follow-camera * @param name Define the name of the camera * @param alpha Define the rotation angle of the camera around the logitudinal axis * @param beta Define the rotation angle of the camera around the elevation axis * @param radius Define the radius of the camera from its target point * @param target Define the target of the camera * @param scene Define the scene the camera belongs to */ constructor(name: string, /** The longitudinal angle of the camera */ alpha: number, /** The latitudinal angle of the camera */ beta: number, /** The radius of the camera from its target */ radius: number, /** Define the camera target (the messh it should follow) */ target: Nullable, scene: Scene); private _follow; /** @hidden */ _checkInputs(): void; /** * Returns the class name of the object. * It is mostly used internally for serialization purposes. */ getClassName(): string; } } declare module BABYLON { /** * This represents a free type of camera. It can be usefull in First Person Shooter game for instance. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad. * @see http://doc.babylonjs.com/features/cameras#universal-camera */ class FreeCamera extends TargetCamera { /** * Define the collision ellipsoid of the camera. * This is helpful to simulate a camera body like the player body around the camera * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera */ ellipsoid: Vector3; /** * Define an offset for the position of the ellipsoid around the camera. * This can be helpful to determine the center of the body near the gravity center of the body * instead of its head. */ ellipsoidOffset: Vector3; /** * Enable or disable collisions of the camera with the rest of the scene objects. */ checkCollisions: boolean; /** * Enable or disable gravity on the camera. */ applyGravity: boolean; /** * Define the input manager associated to the camera. */ inputs: FreeCameraInputsManager; /** * Gets the input sensibility for a mouse input. (default is 2000.0) * Higher values reduce sensitivity. */ /** * Sets the input sensibility for a mouse input. (default is 2000.0) * Higher values reduce sensitivity. */ angularSensibility: number; /** * Gets or Set the list of keyboard keys used to control the forward move of the camera. */ keysUp: number[]; /** * Gets or Set the list of keyboard keys used to control the backward move of the camera. */ keysDown: number[]; /** * Gets or Set the list of keyboard keys used to control the left strafe move of the camera. */ keysLeft: number[]; /** * Gets or Set the list of keyboard keys used to control the right strafe move of the camera. */ keysRight: number[]; /** * Event raised when the camera collide with a mesh in the scene. */ onCollide: (collidedMesh: AbstractMesh) => void; private _collider; private _needMoveForGravity; private _oldPosition; private _diffPosition; private _newPosition; /** @hidden */ _localDirection: Vector3; /** @hidden */ _transformedDirection: Vector3; /** * Instantiates a Free Camera. * This represents a free type of camera. It can be usefull in First Person Shooter game for instance. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera. * @see http://doc.babylonjs.com/features/cameras#universal-camera * @param name Define the name of the camera in the scene * @param position Define the start position of the camera in the scene * @param scene Define the scene the camera belongs to * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined */ constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean); /** * Attached controls to the current camera. * @param element Defines the element the controls should be listened from * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault) */ attachControl(element: HTMLElement, noPreventDefault?: boolean): void; /** * Detach the current controls from the camera. * The camera will stop reacting to inputs. * @param element Defines the element to stop listening the inputs from */ detachControl(element: HTMLElement): void; private _collisionMask; /** * Define a collision mask to limit the list of object the camera can collide with */ collisionMask: number; /** @hidden */ _collideWithWorld(displacement: Vector3): void; private _onCollisionPositionChange; /** @hidden */ _checkInputs(): void; /** @hidden */ _decideIfNeedsToMove(): boolean; /** @hidden */ _updatePosition(): void; /** * Destroy the camera and release the current resources hold by it. */ dispose(): void; /** * Gets the current object class name. * @return the class name */ getClassName(): string; } } declare module BABYLON { /** * Default Inputs manager for the FreeCamera. * It groups all the default supported inputs for ease of use. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs */ class FreeCameraInputsManager extends CameraInputsManager { /** * Instantiates a new FreeCameraInputsManager. * @param camera Defines the camera the inputs belong to */ constructor(camera: FreeCamera); /** * Add keyboard input support to the input manager. * @returns the current input manager */ addKeyboard(): FreeCameraInputsManager; /** * Add mouse input support to the input manager. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true) * @returns the current input manager */ addMouse(touchEnabled?: boolean): FreeCameraInputsManager; /** * Add orientation input support to the input manager. * @returns the current input manager */ addDeviceOrientation(): FreeCameraInputsManager; /** * Add touch input support to the input manager. * @returns the current input manager */ addTouch(): FreeCameraInputsManager; /** * Add virtual joystick input support to the input manager. * @returns the current input manager */ addVirtualJoystick(): FreeCameraInputsManager; } } declare module BABYLON { /** * This represents a FPS type of camera. This is only here for back compat purpose. * Please use the UniversalCamera instead as both are identical. * @see http://doc.babylonjs.com/features/cameras#universal-camera */ class GamepadCamera extends UniversalCamera { /** * Instantiates a new Gamepad Camera * This represents a FPS type of camera. This is only here for back compat purpose. * Please use the UniversalCamera instead as both are identical. * @see http://doc.babylonjs.com/features/cameras#universal-camera * @param name Define the name of the camera in the scene * @param position Define the start position of the camera in the scene * @param scene Define the scene the camera belongs to */ constructor(name: string, position: Vector3, scene: Scene); /** * Gets the current object class name. * @return the class name */ getClassName(): string; } } declare module BABYLON { /** * A target camera takes a mesh or position as a target and continues to look at it while it moves. * This is the base of the follow, arc rotate cameras and Free camera * @see http://doc.babylonjs.com/features/cameras */ class TargetCamera extends Camera { /** * Define the current direction the camera is moving to */ cameraDirection: Vector3; /** * Define the current rotation the camera is rotating to */ cameraRotation: Vector2; /** * Define the current rotation of the camera */ rotation: Vector3; /** * Define the current rotation of the camera as a quaternion to prevent Gimbal lock */ rotationQuaternion: Quaternion; /** * Define the current speed of the camera */ speed: number; /** * Add cconstraint to the camera to prevent it to move freely in all directions and * around all axis. */ noRotationConstraint: boolean; /** * Define the current target of the camera as an object or a position. */ lockedTarget: any; /** @hidden */ _currentTarget: Vector3; /** @hidden */ _viewMatrix: Matrix; /** @hidden */ _camMatrix: Matrix; /** @hidden */ _cameraTransformMatrix: Matrix; /** @hidden */ _cameraRotationMatrix: Matrix; private _rigCamTransformMatrix; /** @hidden */ _referencePoint: Vector3; /** @hidden */ _transformedReferencePoint: Vector3; protected _globalCurrentTarget: Vector3; protected _globalCurrentUpVector: Vector3; /** @hidden */ _reset: () => void; private _defaultUp; /** * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves. * This is the base of the follow, arc rotate cameras and Free camera * @see http://doc.babylonjs.com/features/cameras * @param name Defines the name of the camera in the scene * @param position Defines the start position of the camera in the scene * @param scene Defines the scene the camera belongs to * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined */ constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean); /** * Gets the position in front of the camera at a given distance. * @param distance The distance from the camera we want the position to be * @returns the position */ getFrontPosition(distance: number): Vector3; /** @hidden */ _getLockedTargetPosition(): Nullable; private _storedPosition; private _storedRotation; private _storedRotationQuaternion; /** * Store current camera state of the camera (fov, position, rotation, etc..) * @returns the camera */ storeState(): Camera; /** * Restored camera state. You must call storeState() first * @returns whether it was successful or not * @hidden */ _restoreStateValues(): boolean; /** @hidden */ _initCache(): void; /** @hidden */ _updateCache(ignoreParentClass?: boolean): void; /** @hidden */ _isSynchronizedViewMatrix(): boolean; /** @hidden */ _computeLocalCameraSpeed(): number; /** @hidden */ setTarget(target: Vector3): void; /** * Return the current target position of the camera. This value is expressed in local space. * @returns the target position */ getTarget(): Vector3; /** @hidden */ _decideIfNeedsToMove(): boolean; /** @hidden */ _updatePosition(): void; /** @hidden */ _checkInputs(): void; protected _updateCameraRotationMatrix(): void; /** * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well) * @returns the current camera */ private _rotateUpVectorWithCameraRotationMatrix; private _cachedRotationZ; private _cachedQuaternionRotationZ; /** @hidden */ _getViewMatrix(): Matrix; protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void; /** * @hidden */ createRigCamera(name: string, cameraIndex: number): Nullable; /** * @hidden */ _updateRigCameras(): void; private _getRigCamPosition; /** * Gets the current object class name. * @return the class name */ getClassName(): string; } } declare module BABYLON { /** * This represents a FPS type of camera controlled by touch. * This is like a universal camera minus the Gamepad controls. * @see http://doc.babylonjs.com/features/cameras#universal-camera */ class TouchCamera extends FreeCamera { /** * Defines the touch sensibility for rotation. * The higher the faster. */ touchAngularSensibility: number; /** * Defines the touch sensibility for move. * The higher the faster. */ touchMoveSensibility: number; /** * Instantiates a new touch camera. * This represents a FPS type of camera controlled by touch. * This is like a universal camera minus the Gamepad controls. * @see http://doc.babylonjs.com/features/cameras#universal-camera * @param name Define the name of the camera in the scene * @param position Define the start position of the camera in the scene * @param scene Define the scene the camera belongs to */ constructor(name: string, position: Vector3, scene: Scene); /** * Gets the current object class name. * @return the class name */ getClassName(): string; /** @hidden */ _setupInputs(): void; } } declare module BABYLON { /** * The Universal Camera is the one to choose for first person shooter type games, and works with all the keyboard, mouse, touch and gamepads. This replaces the earlier Free Camera, * which still works and will still be found in many Playgrounds. * @see http://doc.babylonjs.com/features/cameras#universal-camera */ class UniversalCamera extends TouchCamera { /** * Defines the gamepad rotation sensiblity. * This is the threshold from when rotation starts to be accounted for to prevent jittering. */ gamepadAngularSensibility: number; /** * Defines the gamepad move sensiblity. * This is the threshold from when moving starts to be accounted for for to prevent jittering. */ gamepadMoveSensibility: number; /** * The Universal Camera is the one to choose for first person shooter type games, and works with all the keyboard, mouse, touch and gamepads. This replaces the earlier Free Camera, * which still works and will still be found in many Playgrounds. * @see http://doc.babylonjs.com/features/cameras#universal-camera * @param name Define the name of the camera in the scene * @param position Define the start position of the camera in the scene * @param scene Define the scene the camera belongs to */ constructor(name: string, position: Vector3, scene: Scene); /** * Gets the current object class name. * @return the class name */ getClassName(): string; } } declare module BABYLON { /** * This represents a free type of camera. It can be usefull in First Person Shooter game for instance. * It is identical to the Free Camera and simply adds by default a virtual joystick. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera */ class VirtualJoysticksCamera extends FreeCamera { /** * Intantiates a VirtualJoysticksCamera. It can be usefull in First Person Shooter game for instance. * It is identical to the Free Camera and simply adds by default a virtual joystick. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera * @param name Define the name of the camera in the scene * @param position Define the start position of the camera in the scene * @param scene Define the scene the camera belongs to */ constructor(name: string, position: Vector3, scene: Scene); /** * Gets the current object class name. * @return the class name */ getClassName(): string; } } interface VRDisplay extends EventTarget { /** * Dictionary of capabilities describing the VRDisplay. */ readonly capabilities: VRDisplayCapabilities; /** * z-depth defining the far plane of the eye view frustum * enables mapping of values in the render target depth * attachment to scene coordinates. Initially set to 10000.0. */ depthFar: number; /** * z-depth defining the near plane of the eye view frustum * enables mapping of values in the render target depth * attachment to scene coordinates. Initially set to 0.01. */ depthNear: number; /** * An identifier for this distinct VRDisplay. Used as an * association point in the Gamepad API. */ readonly displayId: number; /** * A display name, a user-readable name identifying it. */ readonly displayName: string; readonly isConnected: boolean; readonly isPresenting: boolean; /** * If this VRDisplay supports room-scale experiences, the optional * stage attribute contains details on the room-scale parameters. */ readonly stageParameters: VRStageParameters | null; /** * Passing the value returned by `requestAnimationFrame` to * `cancelAnimationFrame` will unregister the callback. * @param handle Define the hanle of the request to cancel */ cancelAnimationFrame(handle: number): void; /** * Stops presenting to the VRDisplay. * @returns a promise to know when it stopped */ exitPresent(): Promise; /** * Return the current VREyeParameters for the given eye. * @param whichEye Define the eye we want the parameter for * @returns the eye parameters */ getEyeParameters(whichEye: string): VREyeParameters; /** * Populates the passed VRFrameData with the information required to render * the current frame. * @param frameData Define the data structure to populate * @returns true if ok otherwise false */ getFrameData(frameData: VRFrameData): boolean; /** * Get the layers currently being presented. * @returns the list of VR layers */ getLayers(): VRLayer[]; /** * Return a VRPose containing the future predicted pose of the VRDisplay * when the current frame will be presented. The value returned will not * change until JavaScript has returned control to the browser. * * The VRPose will contain the position, orientation, velocity, * and acceleration of each of these properties. * @returns the pose object */ getPose(): VRPose; /** * Return the current instantaneous pose of the VRDisplay, with no * prediction applied. * @returns the current instantaneous pose */ getImmediatePose(): VRPose; /** * The callback passed to `requestAnimationFrame` will be called * any time a new frame should be rendered. When the VRDisplay is * presenting the callback will be called at the native refresh * rate of the HMD. When not presenting this function acts * identically to how window.requestAnimationFrame acts. Content should * make no assumptions of frame rate or vsync behavior as the HMD runs * asynchronously from other displays and at differing refresh rates. * @param callback Define the eaction to run next frame * @returns the request handle it */ requestAnimationFrame(callback: FrameRequestCallback): number; /** * Begin presenting to the VRDisplay. Must be called in response to a user gesture. * Repeat calls while already presenting will update the VRLayers being displayed. * @param layers Define the list of layer to present * @returns a promise to know when the request has been fulfilled */ requestPresent(layers: VRLayer[]): Promise; /** * Reset the pose for this display, treating its current position and * orientation as the "origin/zero" values. VRPose.position, * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be * updated when calling resetPose(). This should be called in only * sitting-space experiences. */ resetPose(): void; /** * The VRLayer provided to the VRDisplay will be captured and presented * in the HMD. Calling this function has the same effect on the source * canvas as any other operation that uses its source image, and canvases * created without preserveDrawingBuffer set to true will be cleared. * @param pose Define the pose to submit */ submitFrame(pose?: VRPose): void; } declare var VRDisplay: { prototype: VRDisplay; new (): VRDisplay; }; interface VRLayer { leftBounds?: number[] | Float32Array | null; rightBounds?: number[] | Float32Array | null; source?: HTMLCanvasElement | null; } interface VRDisplayCapabilities { readonly canPresent: boolean; readonly hasExternalDisplay: boolean; readonly hasOrientation: boolean; readonly hasPosition: boolean; readonly maxLayers: number; } interface VREyeParameters { /** @deprecated */ readonly fieldOfView: VRFieldOfView; readonly offset: Float32Array; readonly renderHeight: number; readonly renderWidth: number; } interface VRFieldOfView { readonly downDegrees: number; readonly leftDegrees: number; readonly rightDegrees: number; readonly upDegrees: number; } interface VRFrameData { readonly leftProjectionMatrix: Float32Array; readonly leftViewMatrix: Float32Array; readonly pose: VRPose; readonly rightProjectionMatrix: Float32Array; readonly rightViewMatrix: Float32Array; readonly timestamp: number; } interface VRPose { readonly angularAcceleration: Float32Array | null; readonly angularVelocity: Float32Array | null; readonly linearAcceleration: Float32Array | null; readonly linearVelocity: Float32Array | null; readonly orientation: Float32Array | null; readonly position: Float32Array | null; readonly timestamp: number; } interface VRStageParameters { sittingToStandingTransform?: Float32Array; sizeX?: number; sizeY?: number; } interface Navigator { getVRDisplays(): Promise; readonly activeVRDisplays: ReadonlyArray; } interface Window { onvrdisplayconnected: ((this: Window, ev: Event) => any) | null; onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null; onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null; addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void; } interface Gamepad { readonly displayId: number; } /** * Module Debug contains the (visual) components to debug a scene correctly */ declare module BABYLON.Debug { /** * The Axes viewer will show 3 axes in a specific point in space */ class AxesViewer { private _xline; private _yline; private _zline; private _xmesh; private _ymesh; private _zmesh; /** * Gets the hosting scene */ scene: Nullable; /** * Gets or sets a number used to scale line length */ scaleLines: number; /** * Creates a new AxesViewer * @param scene defines the hosting scene * @param scaleLines defines a number used to scale line length (1 by default) */ constructor(scene: Scene, scaleLines?: number); /** * Force the viewer to update * @param position defines the position of the viewer * @param xaxis defines the x axis of the viewer * @param yaxis defines the y axis of the viewer * @param zaxis defines the z axis of the viewer */ update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void; /** Releases resources */ dispose(): void; } } declare module BABYLON.Debug { /** * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8 */ class BoneAxesViewer extends AxesViewer { /** * Gets or sets the target mesh where to display the axes viewer */ mesh: Nullable; /** * Gets or sets the target bone where to display the axes viewer */ bone: Nullable; /** Gets current position */ pos: Vector3; /** Gets direction of X axis */ xaxis: Vector3; /** Gets direction of Y axis */ yaxis: Vector3; /** Gets direction of Z axis */ zaxis: Vector3; /** * Creates a new BoneAxesViewer * @param scene defines the hosting scene * @param bone defines the target bone * @param mesh defines the target mesh * @param scaleLines defines a scaling factor for line length (1 by default) */ constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number); /** * Force the viewer to update */ update(): void; /** Releases resources */ dispose(): void; } } declare module BABYLON { interface Scene { /** * @hidden * Backing field */ _debugLayer: DebugLayer; /** * Gets the debug layer (aka Inspector) associated with the scene * @see http://doc.babylonjs.com/features/playground_debuglayer */ debugLayer: DebugLayer; } /** * The debug layer (aka Inspector) is the go to tool in order to better understand * what is happening in your scene * @see http://doc.babylonjs.com/features/playground_debuglayer */ class DebugLayer { /** * Define the url to get the inspector script from. * By default it uses the babylonjs CDN. * @ignoreNaming */ static InspectorURL: string; private _scene; private _inspector; private BJSINSPECTOR; /** * Observable triggered when a property is changed through the inspector. */ onPropertyChangedObservable: Observable<{ object: any; property: string; value: any; initialValue: any; }>; /** * Instantiates a new debug layer. * The debug layer (aka Inspector) is the go to tool in order to better understand * what is happening in your scene * @see http://doc.babylonjs.com/features/playground_debuglayer * @param scene Defines the scene to inspect */ constructor(scene: Scene); /** Creates the inspector window. */ private _createInspector; /** * Get if the inspector is visible or not. * @returns true if visible otherwise, false */ isVisible(): boolean; /** * Hide the inspector and close its window. */ hide(): void; /** * * Launch the debugLayer. * * initialTab: * | Value | Tab Name | * | --- | --- | * | 0 | Scene | * | 1 | Console | * | 2 | Stats | * | 3 | Textures | * | 4 | Mesh | * | 5 | Light | * | 6 | Material | * | 7 | GLTF | * | 8 | GUI | * | 9 | Physics | * | 10 | Camera | * | 11 | Audio | * * @param config Define the configuration of the inspector */ show(config?: { popup?: boolean; initialTab?: number | string; parentElement?: HTMLElement; newColors?: { backgroundColor?: string; backgroundColorLighter?: string; backgroundColorLighter2?: string; backgroundColorLighter3?: string; color?: string; colorTop?: string; colorBot?: string; }; }): void; /** * Gets the active tab * @return the index of the active tab or -1 if the inspector is hidden */ getActiveTab(): number; } } declare module BABYLON.Debug { /** * Used to show the physics impostor around the specific mesh */ class PhysicsViewer { /** @hidden */ protected _impostors: Array>; /** @hidden */ protected _meshes: Array>; /** @hidden */ protected _scene: Nullable; /** @hidden */ protected _numMeshes: number; /** @hidden */ protected _physicsEnginePlugin: Nullable; private _renderFunction; private _debugBoxMesh; private _debugSphereMesh; private _debugMaterial; /** * Creates a new PhysicsViewer * @param scene defines the hosting scene */ constructor(scene: Scene); /** @hidden */ protected _updateDebugMeshes(): void; /** * Renders a specified physic impostor * @param impostor defines the impostor to render */ showImpostor(impostor: PhysicsImpostor): void; /** * Hides a specified physic impostor * @param impostor defines the impostor to hide */ hideImpostor(impostor: Nullable): void; private _getDebugMaterial; private _getDebugBoxMesh; private _getDebugSphereMesh; private _getDebugMesh; /** Releases all resources */ dispose(): void; } } declare module BABYLON { /** * As raycast might be hard to debug, the RayHelper can help rendering the different rays * in order to better appreciate the issue one might have. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging */ class RayHelper { /** * Defines the ray we are currently tryin to visualize. */ ray: Nullable; private _renderPoints; private _renderLine; private _renderFunction; private _scene; private _updateToMeshFunction; private _attachedToMesh; private _meshSpaceDirection; private _meshSpaceOrigin; /** * Helper function to create a colored helper in a scene in one line. * @param ray Defines the ray we are currently tryin to visualize * @param scene Defines the scene the ray is used in * @param color Defines the color we want to see the ray in * @returns The newly created ray helper. */ static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper; /** * Instantiate a new ray helper. * As raycast might be hard to debug, the RayHelper can help rendering the different rays * in order to better appreciate the issue one might have. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging * @param ray Defines the ray we are currently tryin to visualize */ constructor(ray: Ray); /** * Shows the ray we are willing to debug. * @param scene Defines the scene the ray needs to be rendered in * @param color Defines the color the ray needs to be rendered in */ show(scene: Scene, color?: Color3): void; /** * Hides the ray we are debugging. */ hide(): void; private _render; /** * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals. * @param mesh Defines the mesh we want the helper attached to * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node) * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node) * @param length Defines the length of the ray */ attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void; /** * Detach the ray helper from the mesh it has previously been attached to. */ detachFromMesh(): void; private _updateToMesh; /** * Dispose the helper and release its associated resources. */ dispose(): void; } } declare module BABYLON.Debug { /** * Class used to render a debug view of a given skeleton * @see http://www.babylonjs-playground.com/#1BZJVJ#8 */ class SkeletonViewer { /** defines the skeleton to render */ skeleton: Skeleton; /** defines the mesh attached to the skeleton */ mesh: AbstractMesh; /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */ autoUpdateBonesMatrices: boolean; /** defines the rendering group id to use with the viewer */ renderingGroupId: number; /** Gets or sets the color used to render the skeleton */ color: Color3; private _scene; private _debugLines; private _debugMesh; private _isEnabled; private _renderFunction; /** * Creates a new SkeletonViewer * @param skeleton defines the skeleton to render * @param mesh defines the mesh attached to the skeleton * @param scene defines the hosting scene * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) * @param renderingGroupId defines the rendering group id to use with the viewer */ constructor( /** defines the skeleton to render */ skeleton: Skeleton, /** defines the mesh attached to the skeleton */ mesh: AbstractMesh, scene: Scene, /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */ autoUpdateBonesMatrices?: boolean, /** defines the rendering group id to use with the viewer */ renderingGroupId?: number); /** Gets or sets a boolean indicating if the viewer is enabled */ isEnabled: boolean; private _getBonePosition; private _getLinesForBonesWithLength; private _getLinesForBonesNoLength; /** Update the viewer to sync with current skeleton state */ update(): void; /** Release associated resources */ dispose(): void; } } declare module BABYLON { /** * Interface for attribute information associated with buffer instanciation */ class InstancingAttributeInfo { /** * Index/offset of the attribute in the vertex shader */ index: number; /** * size of the attribute, 1, 2, 3 or 4 */ attributeSize: number; /** * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT. * default is FLOAT */ attribyteType: number; /** * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE */ normalized: boolean; /** * Offset of the data in the Vertex Buffer acting as the instancing buffer */ offset: number; /** * Name of the GLSL attribute, for debugging purpose only */ attributeName: string; } /** * Define options used to create a render target texture */ class RenderTargetCreationOptions { /** * Specifies is mipmaps must be generated */ generateMipMaps?: boolean; /** Specifies whether or not a depth should be allocated in the texture (true by default) */ generateDepthBuffer?: boolean; /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/ generateStencilBuffer?: boolean; /** Defines texture type (int by default) */ type?: number; /** Defines sampling mode (trilinear by default) */ samplingMode?: number; /** Defines format (RGBA by default) */ format?: number; } /** * Define options used to create a depth texture */ class DepthTextureCreationOptions { /** Specifies whether or not a stencil should be allocated in the texture */ generateStencil?: boolean; /** Specifies whether or not bilinear filtering is enable on the texture */ bilinearFiltering?: boolean; /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */ comparisonFunction?: number; /** Specifies if the created texture is a cube texture */ isCube?: boolean; } /** * Class used to describe the capabilities of the engine relatively to the current browser */ class EngineCapabilities { /** Maximum textures units per fragment shader */ maxTexturesImageUnits: number; /** Maximum texture units per vertex shader */ maxVertexTextureImageUnits: number; /** Maximum textures units in the entire pipeline */ maxCombinedTexturesImageUnits: number; /** Maximum texture size */ maxTextureSize: number; /** Maximum cube texture size */ maxCubemapTextureSize: number; /** Maximum render texture size */ maxRenderTextureSize: number; /** Maximum number of vertex attributes */ maxVertexAttribs: number; /** Maximum number of varyings */ maxVaryingVectors: number; /** Maximum number of uniforms per vertex shader */ maxVertexUniformVectors: number; /** Maximum number of uniforms per fragment shader */ maxFragmentUniformVectors: number; /** Defines if standard derivates (dx/dy) are supported */ standardDerivatives: boolean; /** Defines if s3tc texture compression is supported */ s3tc: Nullable; /** Defines if pvrtc texture compression is supported */ pvrtc: any; /** Defines if etc1 texture compression is supported */ etc1: any; /** Defines if etc2 texture compression is supported */ etc2: any; /** Defines if astc texture compression is supported */ astc: any; /** Defines if float textures are supported */ textureFloat: boolean; /** Defines if vertex array objects are supported */ vertexArrayObject: boolean; /** Gets the webgl extension for anisotropic filtering (null if not supported) */ textureAnisotropicFilterExtension: Nullable; /** Gets the maximum level of anisotropy supported */ maxAnisotropy: number; /** Defines if instancing is supported */ instancedArrays: boolean; /** Defines if 32 bits indices are supported */ uintIndices: boolean; /** Defines if high precision shaders are supported */ highPrecisionShaderSupported: boolean; /** Defines if depth reading in the fragment shader is supported */ fragmentDepthSupported: boolean; /** Defines if float texture linear filtering is supported*/ textureFloatLinearFiltering: boolean; /** Defines if rendering to float textures is supported */ textureFloatRender: boolean; /** Defines if half float textures are supported*/ textureHalfFloat: boolean; /** Defines if half float texture linear filtering is supported*/ textureHalfFloatLinearFiltering: boolean; /** Defines if rendering to half float textures is supported */ textureHalfFloatRender: boolean; /** Defines if textureLOD shader command is supported */ textureLOD: boolean; /** Defines if draw buffers extension is supported */ drawBuffersExtension: boolean; /** Defines if depth textures are supported */ depthTextureExtension: boolean; /** Defines if float color buffer are supported */ colorBufferFloat: boolean; /** Gets disjoint timer query extension (null if not supported) */ timerQuery: EXT_disjoint_timer_query; /** Defines if timestamp can be used with timer query */ canUseTimestampForTimerQuery: boolean; } /** Interface defining initialization parameters for Engine class */ interface EngineOptions extends WebGLContextAttributes { /** * Defines if the engine should no exceed a specified device ratio * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio */ limitDeviceRatio?: number; /** * Defines if webvr should be enabled automatically * @see http://doc.babylonjs.com/how_to/webvr_camera */ autoEnableWebVR?: boolean; /** * Defines if webgl2 should be turned off even if supported * @see http://doc.babylonjs.com/features/webgl2 */ disableWebGL2Support?: boolean; /** * Defines if webaudio should be initialized as well * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music */ audioEngine?: boolean; /** * Defines if animations should run using a deterministic lock step * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */ deterministicLockstep?: boolean; /** Defines the maximum steps to use with deterministic lock step mode */ lockstepMaxSteps?: number; /** * Defines that engine should ignore context lost events * If this event happens when this parameter is true, you will have to reload the page to restore rendering */ doNotHandleContextLost?: boolean; } /** * Defines the interface used by display changed events */ interface IDisplayChangedEventArgs { /** Gets the vrDisplay object (if any) */ vrDisplay: Nullable; /** Gets a boolean indicating if webVR is supported */ vrSupported: boolean; } /** * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio */ class Engine { /** Use this array to turn off some WebGL2 features on known buggy browsers version */ static ExceptionList: ({ key: string; capture: string; captureConstraint: number; targets: string[]; } | { key: string; capture: null; captureConstraint: null; targets: string[]; })[]; /** Gets the list of created engines */ static Instances: Engine[]; /** * Gets the latest created engine */ static readonly LastCreatedEngine: Nullable; /** * Gets the latest created scene */ static readonly LastCreatedScene: Nullable; /** * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation * @param flag defines which part of the materials must be marked as dirty * @param predicate defines a predicate used to filter which materials should be affected */ static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void; /** * Hidden */ static _TextureLoaders: IInternalTextureLoader[]; /** Defines that alpha blending is disabled */ static readonly ALPHA_DISABLE: number; /** Defines that alpha blending to SRC ALPHA * SRC + DEST */ static readonly ALPHA_ADD: number; /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */ static readonly ALPHA_COMBINE: number; /** Defines that alpha blending to DEST - SRC * DEST */ static readonly ALPHA_SUBTRACT: number; /** Defines that alpha blending to SRC * DEST */ static readonly ALPHA_MULTIPLY: number; /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */ static readonly ALPHA_MAXIMIZED: number; /** Defines that alpha blending to SRC + DEST */ static readonly ALPHA_ONEONE: number; /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */ static readonly ALPHA_PREMULTIPLIED: number; /** * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA */ static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number; /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */ static readonly ALPHA_INTERPOLATE: number; /** * Defines that alpha blending to SRC + (1 - SRC) * DEST * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA */ static readonly ALPHA_SCREENMODE: number; /** Defines that the ressource is not delayed*/ static readonly DELAYLOADSTATE_NONE: number; /** Defines that the ressource was successfully delay loaded */ static readonly DELAYLOADSTATE_LOADED: number; /** Defines that the ressource is currently delay loading */ static readonly DELAYLOADSTATE_LOADING: number; /** Defines that the ressource is delayed and has not started loading */ static readonly DELAYLOADSTATE_NOTLOADED: number; /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */ static readonly NEVER: number; /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */ static readonly ALWAYS: number; /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */ static readonly LESS: number; /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */ static readonly EQUAL: number; /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */ static readonly LEQUAL: number; /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */ static readonly GREATER: number; /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */ static readonly GEQUAL: number; /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */ static readonly NOTEQUAL: number; /** Passed to stencilOperation to specify that stencil value must be kept */ static readonly KEEP: number; /** Passed to stencilOperation to specify that stencil value must be replaced */ static readonly REPLACE: number; /** Passed to stencilOperation to specify that stencil value must be incremented */ static readonly INCR: number; /** Passed to stencilOperation to specify that stencil value must be decremented */ static readonly DECR: number; /** Passed to stencilOperation to specify that stencil value must be inverted */ static readonly INVERT: number; /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */ static readonly INCR_WRAP: number; /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */ static readonly DECR_WRAP: number; /** Texture is not repeating outside of 0..1 UVs */ static readonly TEXTURE_CLAMP_ADDRESSMODE: number; /** Texture is repeating outside of 0..1 UVs */ static readonly TEXTURE_WRAP_ADDRESSMODE: number; /** Texture is repeating and mirrored */ static readonly TEXTURE_MIRROR_ADDRESSMODE: number; /** ALPHA */ static readonly TEXTUREFORMAT_ALPHA: number; /** LUMINANCE */ static readonly TEXTUREFORMAT_LUMINANCE: number; /** LUMINANCE_ALPHA */ static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number; /** RGB */ static readonly TEXTUREFORMAT_RGB: number; /** RGBA */ static readonly TEXTUREFORMAT_RGBA: number; /** RED */ static readonly TEXTUREFORMAT_RED: number; /** RED (2nd reference) */ static readonly TEXTUREFORMAT_R: number; /** RG */ static readonly TEXTUREFORMAT_RG: number; /** RED_INTEGER */ static readonly TEXTUREFORMAT_RED_INTEGER: number; /** RED_INTEGER (2nd reference) */ static readonly TEXTUREFORMAT_R_INTEGER: number; /** RG_INTEGER */ static readonly TEXTUREFORMAT_RG_INTEGER: number; /** RGB_INTEGER */ static readonly TEXTUREFORMAT_RGB_INTEGER: number; /** RGBA_INTEGER */ static readonly TEXTUREFORMAT_RGBA_INTEGER: number; /** UNSIGNED_BYTE */ static readonly TEXTURETYPE_UNSIGNED_BYTE: number; /** UNSIGNED_BYTE (2nd reference) */ static readonly TEXTURETYPE_UNSIGNED_INT: number; /** FLOAT */ static readonly TEXTURETYPE_FLOAT: number; /** HALF_FLOAT */ static readonly TEXTURETYPE_HALF_FLOAT: number; /** BYTE */ static readonly TEXTURETYPE_BYTE: number; /** SHORT */ static readonly TEXTURETYPE_SHORT: number; /** UNSIGNED_SHORT */ static readonly TEXTURETYPE_UNSIGNED_SHORT: number; /** INT */ static readonly TEXTURETYPE_INT: number; /** UNSIGNED_INT */ static readonly TEXTURETYPE_UNSIGNED_INTEGER: number; /** UNSIGNED_SHORT_4_4_4_4 */ static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number; /** UNSIGNED_SHORT_5_5_5_1 */ static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number; /** UNSIGNED_SHORT_5_6_5 */ static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number; /** UNSIGNED_INT_2_10_10_10_REV */ static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number; /** UNSIGNED_INT_24_8 */ static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number; /** UNSIGNED_INT_10F_11F_11F_REV */ static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number; /** UNSIGNED_INT_5_9_9_9_REV */ static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number; /** FLOAT_32_UNSIGNED_INT_24_8_REV */ static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number; /** nearest is mag = nearest and min = nearest and mip = linear */ static readonly TEXTURE_NEAREST_SAMPLINGMODE: number; /** Bilinear is mag = linear and min = linear and mip = nearest */ static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number; /** Trilinear is mag = linear and min = linear and mip = linear */ static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number; /** nearest is mag = nearest and min = nearest and mip = linear */ static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number; /** Bilinear is mag = linear and min = linear and mip = nearest */ static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number; /** Trilinear is mag = linear and min = linear and mip = linear */ static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number; /** mag = nearest and min = nearest and mip = nearest */ static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number; /** mag = nearest and min = linear and mip = nearest */ static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number; /** mag = nearest and min = linear and mip = linear */ static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number; /** mag = nearest and min = linear and mip = none */ static readonly TEXTURE_NEAREST_LINEAR: number; /** mag = nearest and min = nearest and mip = none */ static readonly TEXTURE_NEAREST_NEAREST: number; /** mag = linear and min = nearest and mip = nearest */ static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number; /** mag = linear and min = nearest and mip = linear */ static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number; /** mag = linear and min = linear and mip = none */ static readonly TEXTURE_LINEAR_LINEAR: number; /** mag = linear and min = nearest and mip = none */ static readonly TEXTURE_LINEAR_NEAREST: number; /** Explicit coordinates mode */ static readonly TEXTURE_EXPLICIT_MODE: number; /** Spherical coordinates mode */ static readonly TEXTURE_SPHERICAL_MODE: number; /** Planar coordinates mode */ static readonly TEXTURE_PLANAR_MODE: number; /** Cubic coordinates mode */ static readonly TEXTURE_CUBIC_MODE: number; /** Projection coordinates mode */ static readonly TEXTURE_PROJECTION_MODE: number; /** Skybox coordinates mode */ static readonly TEXTURE_SKYBOX_MODE: number; /** Inverse Cubic coordinates mode */ static readonly TEXTURE_INVCUBIC_MODE: number; /** Equirectangular coordinates mode */ static readonly TEXTURE_EQUIRECTANGULAR_MODE: number; /** Equirectangular Fixed coordinates mode */ static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number; /** Equirectangular Fixed Mirrored coordinates mode */ static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number; /** Defines that texture rescaling will use a floor to find the closer power of 2 size */ static readonly SCALEMODE_FLOOR: number; /** Defines that texture rescaling will look for the nearest power of 2 size */ static readonly SCALEMODE_NEAREST: number; /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */ static readonly SCALEMODE_CEILING: number; /** * Returns the current version of the framework */ static readonly Version: string; /** * Gets or sets the epsilon value used by collision engine */ static CollisionsEpsilon: number; /** * Gets or sets the relative url used to load code if using the engine in non-minified mode */ static CodeRepository: string; /** * Gets or sets the relative url used to load shaders if using the engine in non-minified mode */ static ShadersRepository: string; /** * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required */ forcePOTTextures: boolean; /** * Gets a boolean indicating if the engine is currently rendering in fullscreen mode */ isFullscreen: boolean; /** * Gets a boolean indicating if the pointer is currently locked */ isPointerLock: boolean; /** * Gets or sets a boolean indicating if back faces must be culled (true by default) */ cullBackFaces: boolean; /** * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun */ renderEvenInBackground: boolean; /** * Gets or sets a boolean indicating that cache can be kept between frames */ preventCacheWipeBetweenFrames: boolean; /** * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest **/ enableOfflineSupport: boolean; /** * Gets or sets a boolean to enable/disable checking manifest if IndexedDB support is enabled (Babylon.js will always consider the database is up to date) **/ disableManifestCheck: boolean; /** * Gets the list of created scenes */ scenes: Scene[]; /** * Gets the list of created postprocesses */ postProcesses: PostProcess[]; /** Gets or sets a boolean indicating if the engine should validate programs after compilation */ validateShaderPrograms: boolean; /** * Observable event triggered each time the rendering canvas is resized */ onResizeObservable: Observable; /** * Observable event triggered each time the canvas loses focus */ onCanvasBlurObservable: Observable; /** * Observable event triggered each time the canvas gains focus */ onCanvasFocusObservable: Observable; /** * Observable event triggered each time the canvas receives pointerout event */ onCanvasPointerOutObservable: Observable; /** * Observable event triggered before each texture is initialized */ onBeforeTextureInitObservable: Observable; private _vrDisplay; private _vrSupported; private _oldSize; private _oldHardwareScaleFactor; private _vrExclusivePointerMode; private _webVRInitPromise; /** * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input */ readonly isInVRExclusivePointerMode: boolean; /** * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported */ disableUniformBuffers: boolean; /** @hidden */ _uniformBuffers: UniformBuffer[]; /** * Gets a boolean indicating that the engine supports uniform buffers * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets */ readonly supportsUniformBuffers: boolean; /** * Observable raised when the engine begins a new frame */ onBeginFrameObservable: Observable; /** * Observable raised when the engine ends the current frame */ onEndFrameObservable: Observable; /** * Observable raised when the engine is about to compile a shader */ onBeforeShaderCompilationObservable: Observable; /** * Observable raised when the engine has jsut compiled a shader */ onAfterShaderCompilationObservable: Observable; /** @hidden */ _gl: WebGLRenderingContext; private _renderingCanvas; private _windowIsBackground; private _webGLVersion; /** * Gets a boolean indicating that only power of 2 textures are supported * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them */ readonly needPOTTextures: boolean; /** @hidden */ _badOS: boolean; /** @hidden */ _badDesktopOS: boolean; /** * Gets or sets a value indicating if we want to disable texture binding optmization. * This could be required on some buggy drivers which wants to have textures bound in a progressive order. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is */ disableTextureBindingOptimization: boolean; /** * Gets the audio engine * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music * @ignorenaming */ static audioEngine: IAudioEngine; /** * Default AudioEngine Factory responsible of creating the Audio Engine. * By default, this will create a BabylonJS Audio Engine if the workload * has been embedded. */ static AudioEngineFactory: (hostElement: Nullable) => IAudioEngine; private _onFocus; private _onBlur; private _onCanvasPointerOut; private _onCanvasBlur; private _onCanvasFocus; private _onFullscreenChange; private _onPointerLockChange; private _onVRDisplayPointerRestricted; private _onVRDisplayPointerUnrestricted; private _onVrDisplayConnect; private _onVrDisplayDisconnect; private _onVrDisplayPresentChange; /** * Observable signaled when VR display mode changes */ onVRDisplayChangedObservable: Observable; /** * Observable signaled when VR request present is complete */ onVRRequestPresentComplete: Observable; /** * Observable signaled when VR request present starts */ onVRRequestPresentStart: Observable; private _hardwareScalingLevel; /** @hidden */ protected _caps: EngineCapabilities; private _pointerLockRequested; private _isStencilEnable; private _colorWrite; private _loadingScreen; /** @hidden */ _drawCalls: PerfCounter; /** @hidden */ _textureCollisions: PerfCounter; private _glVersion; private _glRenderer; private _glVendor; private _videoTextureSupported; private _renderingQueueLaunched; private _activeRenderLoops; private _deterministicLockstep; private _lockstepMaxSteps; /** * Observable signaled when a context lost event is raised */ onContextLostObservable: Observable; /** * Observable signaled when a context restored event is raised */ onContextRestoredObservable: Observable; private _onContextLost; private _onContextRestored; private _contextWasLost; private _doNotHandleContextLost; /** * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost */ doNotHandleContextLost: boolean; private _performanceMonitor; private _fps; private _deltaTime; /** * Turn this value on if you want to pause FPS computation when in background */ disablePerformanceMonitorInBackground: boolean; /** * Gets the performance monitor attached to this engine * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation */ readonly performanceMonitor: PerformanceMonitor; /** @hidden */ protected _depthCullingState: _DepthCullingState; /** @hidden */ protected _stencilState: _StencilState; /** @hidden */ protected _alphaState: _AlphaState; /** @hidden */ protected _alphaMode: number; protected _internalTexturesCache: InternalTexture[]; /** @hidden */ protected _activeChannel: number; private _currentTextureChannel; /** @hidden */ protected _boundTexturesCache: { [key: string]: Nullable; }; /** @hidden */ protected _currentEffect: Nullable; /** @hidden */ protected _currentProgram: Nullable; private _compiledEffects; private _vertexAttribArraysEnabled; /** @hidden */ protected _cachedViewport: Nullable; private _cachedVertexArrayObject; /** @hidden */ protected _cachedVertexBuffers: any; /** @hidden */ protected _cachedIndexBuffer: Nullable; /** @hidden */ protected _cachedEffectForVertexBuffers: Nullable; /** @hidden */ protected _currentRenderTarget: Nullable; private _uintIndicesCurrentlySet; private _currentBoundBuffer; /** @hidden */ protected _currentFramebuffer: Nullable; private _currentBufferPointers; private _currentInstanceLocations; private _currentInstanceBuffers; private _textureUnits; private _firstBoundInternalTextureTracker; private _lastBoundInternalTextureTracker; private _workingCanvas; private _workingContext; private _rescalePostProcess; private _dummyFramebuffer; private _externalData; private _bindedRenderFunction; private _vaoRecordInProgress; private _mustWipeVertexAttributes; private _emptyTexture; private _emptyCubeTexture; private _emptyTexture3D; private _frameHandler; private _nextFreeTextureSlots; private _maxSimultaneousTextures; private _activeRequests; private _texturesSupported; private _textureFormatInUse; /** * Gets the list of texture formats supported */ readonly texturesSupported: Array; /** * Gets the list of texture formats in use */ readonly textureFormatInUse: Nullable; /** * Gets the current viewport */ readonly currentViewport: Nullable; /** * Gets the default empty texture */ readonly emptyTexture: InternalTexture; /** * Gets the default empty 3D texture */ readonly emptyTexture3D: InternalTexture; /** * Gets the default empty cube texture */ readonly emptyCubeTexture: InternalTexture; /** * Defines whether the engine has been created with the premultipliedAlpha option on or not. */ readonly premultipliedAlpha: boolean; /** * Creates a new engine * @param canvasOrContext defines the canvas or WebGL context to use for rendering. If you provide a WebGL context, Babylon.js will not hook events on the canvas (like pointers, keyboards, etc...) so no event observables will be available. This is mostly used when Babylon.js is used as a plugin on a system which alreay used the WebGL context * @param antialias defines enable antialiasing (default: false) * @param options defines further options to be sent to the getContext() function * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false) */ constructor(canvasOrContext: Nullable, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean); private _rebuildInternalTextures; private _rebuildEffects; private _rebuildBuffers; private _initGLContext; /** * Gets version of the current webGL context */ readonly webGLVersion: number; /** * Returns true if the stencil buffer has been enabled through the creation option of the context. */ readonly isStencilEnable: boolean; private _prepareWorkingCanvas; /** * Reset the texture cache to empty state */ resetTextureCache(): void; /** * Gets a boolean indicating that the engine is running in deterministic lock step mode * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep * @returns true if engine is in deterministic lock step mode */ isDeterministicLockStep(): boolean; /** * Gets the max steps when engine is running in deterministic lock step * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep * @returns the max steps */ getLockstepMaxSteps(): number; /** * Gets an object containing information about the current webGL context * @returns an object containing the vender, the renderer and the version of the current webGL context */ getGlInfo(): { vendor: string; renderer: string; version: string; }; /** * Gets current aspect ratio * @param camera defines the camera to use to get the aspect ratio * @param useScreen defines if screen size must be used (or the current render target if any) * @returns a number defining the aspect ratio */ getAspectRatio(camera: Camera, useScreen?: boolean): number; /** * Gets current screen aspect ratio * @returns a number defining the aspect ratio */ getScreenAspectRatio(): number; /** * Gets the current render width * @param useScreen defines if screen size must be used (or the current render target if any) * @returns a number defining the current render width */ getRenderWidth(useScreen?: boolean): number; /** * Gets the current render height * @param useScreen defines if screen size must be used (or the current render target if any) * @returns a number defining the current render height */ getRenderHeight(useScreen?: boolean): number; /** * Gets the HTML canvas attached with the current webGL context * @returns a HTML canvas */ getRenderingCanvas(): Nullable; /** * Gets the client rect of the HTML canvas attached with the current webGL context * @returns a client rectanglee */ getRenderingCanvasClientRect(): Nullable; /** * Defines the hardware scaling level. * By default the hardware scaling level is computed from the window device ratio. * if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas. * @param level defines the level to use */ setHardwareScalingLevel(level: number): void; /** * Gets the current hardware scaling level. * By default the hardware scaling level is computed from the window device ratio. * if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas. * @returns a number indicating the current hardware scaling level */ getHardwareScalingLevel(): number; /** * Gets the list of loaded textures * @returns an array containing all loaded textures */ getLoadedTexturesCache(): InternalTexture[]; /** * Gets the object containing all engine capabilities * @returns the EngineCapabilities object */ getCaps(): EngineCapabilities; /** @hidden */ readonly drawCalls: number; /** @hidden */ readonly drawCallsPerfCounter: Nullable; /** * Gets the current depth function * @returns a number defining the depth function */ getDepthFunction(): Nullable; /** * Sets the current depth function * @param depthFunc defines the function to use */ setDepthFunction(depthFunc: number): void; /** * Sets the current depth function to GREATER */ setDepthFunctionToGreater(): void; /** * Sets the current depth function to GEQUAL */ setDepthFunctionToGreaterOrEqual(): void; /** * Sets the current depth function to LESS */ setDepthFunctionToLess(): void; /** * Sets the current depth function to LEQUAL */ setDepthFunctionToLessOrEqual(): void; /** * Gets a boolean indicating if stencil buffer is enabled * @returns the current stencil buffer state */ getStencilBuffer(): boolean; /** * Enable or disable the stencil buffer * @param enable defines if the stencil buffer must be enabled or disabled */ setStencilBuffer(enable: boolean): void; /** * Gets the current stencil mask * @returns a number defining the new stencil mask to use */ getStencilMask(): number; /** * Sets the current stencil mask * @param mask defines the new stencil mask to use */ setStencilMask(mask: number): void; /** * Gets the current stencil function * @returns a number defining the stencil function to use */ getStencilFunction(): number; /** * Gets the current stencil reference value * @returns a number defining the stencil reference value to use */ getStencilFunctionReference(): number; /** * Gets the current stencil mask * @returns a number defining the stencil mask to use */ getStencilFunctionMask(): number; /** * Sets the current stencil function * @param stencilFunc defines the new stencil function to use */ setStencilFunction(stencilFunc: number): void; /** * Sets the current stencil reference * @param reference defines the new stencil reference to use */ setStencilFunctionReference(reference: number): void; /** * Sets the current stencil mask * @param mask defines the new stencil mask to use */ setStencilFunctionMask(mask: number): void; /** * Gets the current stencil operation when stencil fails * @returns a number defining stencil operation to use when stencil fails */ getStencilOperationFail(): number; /** * Gets the current stencil operation when depth fails * @returns a number defining stencil operation to use when depth fails */ getStencilOperationDepthFail(): number; /** * Gets the current stencil operation when stencil passes * @returns a number defining stencil operation to use when stencil passes */ getStencilOperationPass(): number; /** * Sets the stencil operation to use when stencil fails * @param operation defines the stencil operation to use when stencil fails */ setStencilOperationFail(operation: number): void; /** * Sets the stencil operation to use when depth fails * @param operation defines the stencil operation to use when depth fails */ setStencilOperationDepthFail(operation: number): void; /** * Sets the stencil operation to use when stencil passes * @param operation defines the stencil operation to use when stencil passes */ setStencilOperationPass(operation: number): void; /** * Sets a boolean indicating if the dithering state is enabled or disabled * @param value defines the dithering state */ setDitheringState(value: boolean): void; /** * Sets a boolean indicating if the rasterizer state is enabled or disabled * @param value defines the rasterizer state */ setRasterizerState(value: boolean): void; /** * stop executing a render loop function and remove it from the execution array * @param renderFunction defines the function to be removed. If not provided all functions will be removed. */ stopRenderLoop(renderFunction?: () => void): void; /** @hidden */ _renderLoop(): void; /** * Register and execute a render loop. The engine can have more than one render function * @param renderFunction defines the function to continuously execute */ runRenderLoop(renderFunction: () => void): void; /** * Toggle full screen mode * @param requestPointerLock defines if a pointer lock should be requested from the user */ switchFullscreen(requestPointerLock: boolean): void; /** * Clear the current render buffer or the current render target (if any is set up) * @param color defines the color to use * @param backBuffer defines if the back buffer must be cleared * @param depth defines if the depth buffer must be cleared * @param stencil defines if the stencil buffer must be cleared */ clear(color: Nullable, backBuffer: boolean, depth: boolean, stencil?: boolean): void; /** * Executes a scissor clear (ie. a clear on a specific portion of the screen) * @param x defines the x-coordinate of the top left corner of the clear rectangle * @param y defines the y-coordinate of the corner of the clear rectangle * @param width defines the width of the clear rectangle * @param height defines the height of the clear rectangle * @param clearColor defines the clear color */ scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void; private _viewportCached; /** @hidden */ _viewport(x: number, y: number, width: number, height: number): void; /** * Set the WebGL's viewport * @param viewport defines the viewport element to be used * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used */ setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void; /** * Directly set the WebGL Viewport * @param x defines the x coordinate of the viewport (in screen space) * @param y defines the y coordinate of the viewport (in screen space) * @param width defines the width of the viewport (in screen space) * @param height defines the height of the viewport (in screen space) * @return the current viewport Object (if any) that is being replaced by this call. You can restore this viewport later on to go back to the original state */ setDirectViewport(x: number, y: number, width: number, height: number): Nullable; /** * Begin a new frame */ beginFrame(): void; /** * Enf the current frame */ endFrame(): void; /** * Resize the view according to the canvas' size */ resize(): void; /** * Force a specific size of the canvas * @param width defines the new canvas' width * @param height defines the new canvas' height */ setSize(width: number, height: number): void; /** * Gets a boolean indicating if a webVR device was detected * @returns true if a webVR device was detected */ isVRDevicePresent(): boolean; /** * Gets the current webVR device * @returns the current webVR device (or null) */ getVRDevice(): any; /** * Initializes a webVR display and starts listening to display change events * The onVRDisplayChangedObservable will be notified upon these changes * @returns The onVRDisplayChangedObservable */ initWebVR(): Observable; /** * Initializes a webVR display and starts listening to display change events * The onVRDisplayChangedObservable will be notified upon these changes * @returns A promise containing a VRDisplay and if vr is supported */ initWebVRAsync(): Promise; /** * Call this function to switch to webVR mode * Will do nothing if webVR is not supported or if there is no webVR device * @see http://doc.babylonjs.com/how_to/webvr_camera */ enableVR(): void; /** * Call this function to leave webVR mode * Will do nothing if webVR is not supported or if there is no webVR device * @see http://doc.babylonjs.com/how_to/webvr_camera */ disableVR(): void; private _onVRFullScreenTriggered; private _getVRDisplaysAsync; /** * Binds the frame buffer to the specified texture. * @param texture The texture to render to or null for the default canvas * @param faceIndex The face of the texture to render to in case of cube texture * @param requiredWidth The width of the target to render to * @param requiredHeight The height of the target to render to * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true * @param depthStencilTexture The depth stencil texture to use to render * @param lodLevel defines le lod level to bind to the frame buffer */ bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void; private bindUnboundFramebuffer; /** * Unbind the current render target texture from the webGL context * @param texture defines the render target texture to unbind * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated * @param onBeforeUnbind defines a function which will be called before the effective unbind */ unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void; /** * Unbind a list of render target textures from the webGL context * This is used only when drawBuffer extension or webGL2 are active * @param textures defines the render target textures to unbind * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated * @param onBeforeUnbind defines a function which will be called before the effective unbind */ unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void; /** * Force the mipmap generation for the given render target texture * @param texture defines the render target texture to use */ generateMipMapsForCubemap(texture: InternalTexture): void; /** * Force a webGL flush (ie. a flush of all waiting webGL commands) */ flushFramebuffer(): void; /** * Unbind the current render target and bind the default framebuffer */ restoreDefaultFramebuffer(): void; /** * Create an uniform buffer * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets * @param elements defines the content of the uniform buffer * @returns the webGL uniform buffer */ createUniformBuffer(elements: FloatArray): WebGLBuffer; /** * Create a dynamic uniform buffer * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets * @param elements defines the content of the uniform buffer * @returns the webGL uniform buffer */ createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer; /** * Update an existing uniform buffer * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets * @param uniformBuffer defines the target uniform buffer * @param elements defines the content to update * @param offset defines the offset in the uniform buffer where update should start * @param count defines the size of the data to update */ updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void; private _resetVertexBufferBinding; /** * Creates a vertex buffer * @param data the data for the vertex buffer * @returns the new WebGL static buffer */ createVertexBuffer(data: DataArray): WebGLBuffer; /** * Creates a dynamic vertex buffer * @param data the data for the dynamic vertex buffer * @returns the new WebGL dynamic buffer */ createDynamicVertexBuffer(data: DataArray): WebGLBuffer; /** * Update a dynamic index buffer * @param indexBuffer defines the target index buffer * @param indices defines the data to update * @param offset defines the offset in the target index buffer where update should start */ updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void; /** * Updates a dynamic vertex buffer. * @param vertexBuffer the vertex buffer to update * @param data the data used to update the vertex buffer * @param byteOffset the byte offset of the data * @param byteLength the byte length of the data */ updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void; private _resetIndexBufferBinding; /** * Creates a new index buffer * @param indices defines the content of the index buffer * @param updatable defines if the index buffer must be updatable * @returns a new webGL buffer */ createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer; /** * Bind a webGL buffer to the webGL context * @param buffer defines the buffer to bind */ bindArrayBuffer(buffer: Nullable): void; /** * Bind an uniform buffer to the current webGL context * @param buffer defines the buffer to bind */ bindUniformBuffer(buffer: Nullable): void; /** * Bind a buffer to the current webGL context at a given location * @param buffer defines the buffer to bind * @param location defines the index where to bind the buffer */ bindUniformBufferBase(buffer: WebGLBuffer, location: number): void; /** * Bind a specific block at a given index in a specific shader program * @param shaderProgram defines the shader program * @param blockName defines the block name * @param index defines the index where to bind the block */ bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void; private bindIndexBuffer; private bindBuffer; /** * update the bound buffer with the given data * @param data defines the data to update */ updateArrayBuffer(data: Float32Array): void; private _vertexAttribPointer; private _bindIndexBufferWithCache; private _bindVertexBuffersAttributes; /** * Records a vertex array object * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects * @param vertexBuffers defines the list of vertex buffers to store * @param indexBuffer defines the index buffer to store * @param effect defines the effect to store * @returns the new vertex array object */ recordVertexArrayObject(vertexBuffers: { [key: string]: VertexBuffer; }, indexBuffer: Nullable, effect: Effect): WebGLVertexArrayObject; /** * Bind a specific vertex array object * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects * @param vertexArrayObject defines the vertex array object to bind * @param indexBuffer defines the index buffer to bind */ bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable): void; /** * Bind webGl buffers directly to the webGL context * @param vertexBuffer defines the vertex buffer to bind * @param indexBuffer defines the index buffer to bind * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer * @param vertexStrideSize defines the vertex stride of the vertex buffer * @param effect defines the effect associated with the vertex buffer */ bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void; private _unbindVertexArrayObject; /** * Bind a list of vertex buffers to the webGL context * @param vertexBuffers defines the list of vertex buffers to bind * @param indexBuffer defines the index buffer to bind * @param effect defines the effect associated with the vertex buffers */ bindBuffers(vertexBuffers: { [key: string]: Nullable; }, indexBuffer: Nullable, effect: Effect): void; /** * Unbind all instance attributes */ unbindInstanceAttributes(): void; /** * Release and free the memory of a vertex array object * @param vao defines the vertex array object to delete */ releaseVertexArrayObject(vao: WebGLVertexArrayObject): void; /** @hidden */ _releaseBuffer(buffer: WebGLBuffer): boolean; /** * Creates a webGL buffer to use with instanciation * @param capacity defines the size of the buffer * @returns the webGL buffer */ createInstancesBuffer(capacity: number): WebGLBuffer; /** * Delete a webGL buffer used with instanciation * @param buffer defines the webGL buffer to delete */ deleteInstancesBuffer(buffer: WebGLBuffer): void; /** * Update the content of a webGL buffer used with instanciation and bind it to the webGL context * @param instancesBuffer defines the webGL buffer to update and bind * @param data defines the data to store in the buffer * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer */ updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void; /** * Apply all cached states (depth, culling, stencil and alpha) */ applyStates(): void; /** * Send a draw order * @param useTriangles defines if triangles must be used to draw (else wireframe will be used) * @param indexStart defines the starting index * @param indexCount defines the number of index to draw * @param instancesCount defines the number of instances to draw (if instanciation is enabled) */ draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void; /** * Draw a list of points * @param verticesStart defines the index of first vertex to draw * @param verticesCount defines the count of vertices to draw * @param instancesCount defines the number of instances to draw (if instanciation is enabled) */ drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void; /** * Draw a list of unindexed primitives * @param useTriangles defines if triangles must be used to draw (else wireframe will be used) * @param verticesStart defines the index of first vertex to draw * @param verticesCount defines the count of vertices to draw * @param instancesCount defines the number of instances to draw (if instanciation is enabled) */ drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void; /** * Draw a list of indexed primitives * @param fillMode defines the primitive to use * @param indexStart defines the starting index * @param indexCount defines the number of index to draw * @param instancesCount defines the number of instances to draw (if instanciation is enabled) */ drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void; /** * Draw a list of unindexed primitives * @param fillMode defines the primitive to use * @param verticesStart defines the index of first vertex to draw * @param verticesCount defines the count of vertices to draw * @param instancesCount defines the number of instances to draw (if instanciation is enabled) */ drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void; private _drawMode; /** @hidden */ _releaseEffect(effect: Effect): void; /** @hidden */ _deleteProgram(program: WebGLProgram): void; /** * Create a new effect (used to store vertex/fragment shaders) * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx) * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use * @param samplers defines an array of string used to represent textures * @param defines defines the string containing the defines to use to compile the shaders * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails * @param onCompiled defines a function to call when the effect creation is successful * @param onError defines a function to call when the effect creation has failed * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights) * @returns the new Effect */ createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, indexParameters?: any): Effect; private _compileShader; private _compileRawShader; /** * Directly creates a webGL program * @param vertexCode defines the vertex shader code to use * @param fragmentCode defines the fragment shader code to use * @param context defines the webGL context to use (if not set, the current one will be used) * @param transformFeedbackVaryings defines the list of transform feedback varyings to use * @returns the new webGL program */ createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable): WebGLProgram; /** * Creates a webGL program * @param vertexCode defines the vertex shader code to use * @param fragmentCode defines the fragment shader code to use * @param defines defines the string containing the defines to use to compile the shaders * @param context defines the webGL context to use (if not set, the current one will be used) * @param transformFeedbackVaryings defines the list of transform feedback varyings to use * @returns the new webGL program */ createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable): WebGLProgram; private _createShaderProgram; /** * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names * @param shaderProgram defines the webGL program to use * @param uniformsNames defines the list of uniform names * @returns an array of webGL uniform locations */ getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable[]; /** * Gets the lsit of active attributes for a given webGL program * @param shaderProgram defines the webGL program to use * @param attributesNames defines the list of attribute names to get * @returns an array of indices indicating the offset of each attribute */ getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[]; /** * Activates an effect, mkaing it the current one (ie. the one used for rendering) * @param effect defines the effect to activate */ enableEffect(effect: Nullable): void; /** * Set the value of an uniform to an array of int32 * @param uniform defines the webGL uniform location where to store the value * @param array defines the array of int32 to store */ setIntArray(uniform: Nullable, array: Int32Array): void; /** * Set the value of an uniform to an array of int32 (stored as vec2) * @param uniform defines the webGL uniform location where to store the value * @param array defines the array of int32 to store */ setIntArray2(uniform: Nullable, array: Int32Array): void; /** * Set the value of an uniform to an array of int32 (stored as vec3) * @param uniform defines the webGL uniform location where to store the value * @param array defines the array of int32 to store */ setIntArray3(uniform: Nullable, array: Int32Array): void; /** * Set the value of an uniform to an array of int32 (stored as vec4) * @param uniform defines the webGL uniform location where to store the value * @param array defines the array of int32 to store */ setIntArray4(uniform: Nullable, array: Int32Array): void; /** * Set the value of an uniform to an array of float32 * @param uniform defines the webGL uniform location where to store the value * @param array defines the array of float32 to store */ setFloatArray(uniform: Nullable, array: Float32Array): void; /** * Set the value of an uniform to an array of float32 (stored as vec2) * @param uniform defines the webGL uniform location where to store the value * @param array defines the array of float32 to store */ setFloatArray2(uniform: Nullable, array: Float32Array): void; /** * Set the value of an uniform to an array of float32 (stored as vec3) * @param uniform defines the webGL uniform location where to store the value * @param array defines the array of float32 to store */ setFloatArray3(uniform: Nullable, array: Float32Array): void; /** * Set the value of an uniform to an array of float32 (stored as vec4) * @param uniform defines the webGL uniform location where to store the value * @param array defines the array of float32 to store */ setFloatArray4(uniform: Nullable, array: Float32Array): void; /** * Set the value of an uniform to an array of number * @param uniform defines the webGL uniform location where to store the value * @param array defines the array of number to store */ setArray(uniform: Nullable, array: number[]): void; /** * Set the value of an uniform to an array of number (stored as vec2) * @param uniform defines the webGL uniform location where to store the value * @param array defines the array of number to store */ setArray2(uniform: Nullable, array: number[]): void; /** * Set the value of an uniform to an array of number (stored as vec3) * @param uniform defines the webGL uniform location where to store the value * @param array defines the array of number to store */ setArray3(uniform: Nullable, array: number[]): void; /** * Set the value of an uniform to an array of number (stored as vec4) * @param uniform defines the webGL uniform location where to store the value * @param array defines the array of number to store */ setArray4(uniform: Nullable, array: number[]): void; /** * Set the value of an uniform to an array of float32 (stored as matrices) * @param uniform defines the webGL uniform location where to store the value * @param matrices defines the array of float32 to store */ setMatrices(uniform: Nullable, matrices: Float32Array): void; /** * Set the value of an uniform to a matrix * @param uniform defines the webGL uniform location where to store the value * @param matrix defines the matrix to store */ setMatrix(uniform: Nullable, matrix: Matrix): void; /** * Set the value of an uniform to a matrix (3x3) * @param uniform defines the webGL uniform location where to store the value * @param matrix defines the Float32Array representing the 3x3 matrix to store */ setMatrix3x3(uniform: Nullable, matrix: Float32Array): void; /** * Set the value of an uniform to a matrix (2x2) * @param uniform defines the webGL uniform location where to store the value * @param matrix defines the Float32Array representing the 2x2 matrix to store */ setMatrix2x2(uniform: Nullable, matrix: Float32Array): void; /** * Set the value of an uniform to a number (int) * @param uniform defines the webGL uniform location where to store the value * @param value defines the int number to store */ setInt(uniform: Nullable, value: number): void; /** * Set the value of an uniform to a number (float) * @param uniform defines the webGL uniform location where to store the value * @param value defines the float number to store */ setFloat(uniform: Nullable, value: number): void; /** * Set the value of an uniform to a vec2 * @param uniform defines the webGL uniform location where to store the value * @param x defines the 1st component of the value * @param y defines the 2nd component of the value */ setFloat2(uniform: Nullable, x: number, y: number): void; /** * Set the value of an uniform to a vec3 * @param uniform defines the webGL uniform location where to store the value * @param x defines the 1st component of the value * @param y defines the 2nd component of the value * @param z defines the 3rd component of the value */ setFloat3(uniform: Nullable, x: number, y: number, z: number): void; /** * Set the value of an uniform to a boolean * @param uniform defines the webGL uniform location where to store the value * @param bool defines the boolean to store */ setBool(uniform: Nullable, bool: number): void; /** * Set the value of an uniform to a vec4 * @param uniform defines the webGL uniform location where to store the value * @param x defines the 1st component of the value * @param y defines the 2nd component of the value * @param z defines the 3rd component of the value * @param w defines the 4th component of the value */ setFloat4(uniform: Nullable, x: number, y: number, z: number, w: number): void; /** * Set the value of an uniform to a Color3 * @param uniform defines the webGL uniform location where to store the value * @param color3 defines the color to store */ setColor3(uniform: Nullable, color3: Color3): void; /** * Set the value of an uniform to a Color3 and an alpha value * @param uniform defines the webGL uniform location where to store the value * @param color3 defines the color to store * @param alpha defines the alpha component to store */ setColor4(uniform: Nullable, color3: Color3, alpha: number): void; /** * Sets a Color4 on a uniform variable * @param uniform defines the uniform location * @param color4 defines the value to be set */ setDirectColor4(uniform: Nullable, color4: Color4): void; /** * Set various states to the webGL context * @param culling defines backface culling state * @param zOffset defines the value to apply to zOffset (0 by default) * @param force defines if states must be applied even if cache is up to date * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW) */ setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void; /** * Set the z offset to apply to current rendering * @param value defines the offset to apply */ setZOffset(value: number): void; /** * Gets the current value of the zOffset * @returns the current zOffset state */ getZOffset(): number; /** * Enable or disable depth buffering * @param enable defines the state to set */ setDepthBuffer(enable: boolean): void; /** * Gets a boolean indicating if depth writing is enabled * @returns the current depth writing state */ getDepthWrite(): boolean; /** * Enable or disable depth writing * @param enable defines the state to set */ setDepthWrite(enable: boolean): void; /** * Enable or disable color writing * @param enable defines the state to set */ setColorWrite(enable: boolean): void; /** * Gets a boolean indicating if color writing is enabled * @returns the current color writing state */ getColorWrite(): boolean; /** * Sets alpha constants used by some alpha blending modes * @param r defines the red component * @param g defines the green component * @param b defines the blue component * @param a defines the alpha component */ setAlphaConstants(r: number, g: number, b: number, a: number): void; /** * Sets the current alpha mode * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX) * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default) * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered */ setAlphaMode(mode: number, noDepthWriteChange?: boolean): void; /** * Gets the current alpha mode * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered * @returns the current alpha mode */ getAlphaMode(): number; /** * Clears the list of texture accessible through engine. * This can help preventing texture load conflict due to name collision. */ clearInternalTexturesCache(): void; /** * Force the entire cache to be cleared * You should not have to use this function unless your engine needs to share the webGL context with another engine * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states) */ wipeCaches(bruteForce?: boolean): void; /** * Set the compressed texture format to use, based on the formats you have, and the formats * supported by the hardware / browser. * * Khronos Texture Container (.ktx) files are used to support this. This format has the * advantage of being specifically designed for OpenGL. Header elements directly correspond * to API arguments needed to compressed textures. This puts the burden on the container * generator to house the arcane code for determining these for current & future formats. * * for description see https://www.khronos.org/opengles/sdk/tools/KTX/ * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/ * * Note: The result of this call is not taken into account when a texture is base64. * * @param formatsAvailable defines the list of those format families you have created * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.) * * Current families are astc, dxt, pvrtc, etc2, & etc1. * @returns The extension selected. */ setTextureFormatToUse(formatsAvailable: Array): Nullable; private _getSamplingParameters; private _partialLoadImg; private _cascadeLoadImgs; /** @hidden */ _createTexture(): WebGLTexture; /** * Usually called from BABYLON.Texture.ts. * Passed information to create a WebGLTexture * @param urlArg defines a value which contains one of the following: * * A conventional http URL, e.g. 'http://...' or 'file://...' * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...' * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg' * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file * @param scene needed for loading to the correct scene * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE) * @param onLoad optional callback to be called upon successful completion * @param onError optional callback to be called upon failure * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), HTMLImageElement (image format), or a Blob * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures * @param forcedExtension defines the extension to use to pick the right loader * @returns a InternalTexture for assignment back into BABYLON.Texture */ createTexture(urlArg: Nullable, noMipmap: boolean, invertY: boolean, scene: Nullable, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable, fallback?: Nullable, format?: Nullable, forcedExtension?: Nullable): InternalTexture; private _rescaleTexture; /** * Update a raw texture * @param texture defines the texture to update * @param data defines the data to store in the texture * @param format defines the format of the data * @param invertY defines if data must be stored with Y axis inverted * @param compression defines the compression used (null by default) * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default) */ updateRawTexture(texture: Nullable, data: Nullable, format: number, invertY: boolean, compression?: Nullable, type?: number): void; /** * Creates a raw texture * @param data defines the data to store in the texture * @param width defines the width of the texture * @param height defines the height of the texture * @param format defines the format of the data * @param generateMipMaps defines if the engine should generate the mip levels * @param invertY defines if data must be stored with Y axis inverted * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default) * @param compression defines the compression used (null by default) * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default) * @returns the raw texture inside an InternalTexture */ createRawTexture(data: Nullable, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable, type?: number): InternalTexture; private _unpackFlipYCached; /** * In case you are sharing the context with other applications, it might * be interested to not cache the unpack flip y state to ensure a consistent * value would be set. */ enableUnpackFlipYCached: boolean; /** @hidden */ _unpackFlipY(value: boolean): void; /** @hidden */ _getUnpackAlignement(): number; /** * Creates a dynamic texture * @param width defines the width of the texture * @param height defines the height of the texture * @param generateMipMaps defines if the engine should generate the mip levels * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default) * @returns the dynamic texture inside an InternalTexture */ createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture; /** * Update the sampling mode of a given texture * @param samplingMode defines the required sampling mode * @param texture defines the texture to update */ updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void; /** * Update the content of a dynamic texture * @param texture defines the texture to update * @param canvas defines the canvas containing the source * @param invertY defines if data must be stored with Y axis inverted * @param premulAlpha defines if alpha is stored as premultiplied * @param format defines the format of the data */ updateDynamicTexture(texture: Nullable, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void; /** * Update a video texture * @param texture defines the texture to update * @param video defines the video element to use * @param invertY defines if data must be stored with Y axis inverted */ updateVideoTexture(texture: Nullable, video: HTMLVideoElement, invertY: boolean): void; /** * Updates a depth texture Comparison Mode and Function. * If the comparison Function is equal to 0, the mode will be set to none. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader. * @param texture The texture to set the comparison function for * @param comparisonFunction The comparison function to set, 0 if no comparison required */ updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void; private _setupDepthStencilTexture; /** * Creates a depth stencil texture. * This is only available in WebGL 2 or with the depth texture extension available. * @param size The size of face edge in the texture. * @param options The options defining the texture. * @returns The texture */ createDepthStencilTexture(size: number | { width: number; height: number; }, options: DepthTextureCreationOptions): InternalTexture; /** * Creates a depth stencil texture. * This is only available in WebGL 2 or with the depth texture extension available. * @param size The size of face edge in the texture. * @param options The options defining the texture. * @returns The texture */ private _createDepthStencilTexture; /** * Creates a depth stencil cube texture. * This is only available in WebGL 2. * @param size The size of face edge in the cube texture. * @param options The options defining the cube texture. * @returns The cube texture */ private _createDepthStencilCubeTexture; /** * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture. * @param renderTarget The render target to set the frame buffer for */ setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void; /** * Creates a new render target texture * @param size defines the size of the texture * @param options defines the options used to create the texture * @returns a new render target texture stored in an InternalTexture */ createRenderTargetTexture(size: number | { width: number; height: number; }, options: boolean | RenderTargetCreationOptions): InternalTexture; /** * Create a multi render target texture * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target * @param size defines the size of the texture * @param options defines the creation options * @returns the cube texture as an InternalTexture */ createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[]; private _setupFramebufferDepthAttachments; /** * Updates the sample count of a render target texture * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets * @param texture defines the texture to update * @param samples defines the sample count to set * @returns the effective sample count (could be 0 if multisample render targets are not supported) */ updateRenderTargetTextureSampleCount(texture: Nullable, samples: number): number; /** * Update the sample count for a given multiple render target texture * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets * @param textures defines the textures to update * @param samples defines the sample count to set * @returns the effective sample count (could be 0 if multisample render targets are not supported) */ updateMultipleRenderTargetTextureSampleCount(textures: Nullable, samples: number): number; /** @hidden */ _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void; /** @hidden */ _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void; /** @hidden */ _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void; /** @hidden */ _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void; /** * Creates a new render target cube texture * @param size defines the size of the texture * @param options defines the options used to create the texture * @returns a new render target cube texture stored in an InternalTexture */ createRenderTargetCubeTexture(size: number, options?: Partial): InternalTexture; /** * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection) * @param rootUrl defines the url where the file to load is located * @param scene defines the current scene * @param lodScale defines scale to apply to the mip map selection * @param lodOffset defines offset to apply to the mip map selection * @param onLoad defines an optional callback raised when the texture is loaded * @param onError defines an optional callback raised if there is an issue to load the texture * @param format defines the format of the data * @param forcedExtension defines the extension to use to pick the right loader * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture * @returns the cube texture as an InternalTexture */ createPrefilteredCubeTexture(rootUrl: string, scene: Nullable, lodScale: number, lodOffset: number, onLoad?: Nullable<(internalTexture: Nullable) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean): InternalTexture; /** * Creates a cube texture * @param rootUrl defines the url where the files to load is located * @param scene defines the current scene * @param files defines the list of files to load (1 per face) * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default) * @param onLoad defines an optional callback raised when the texture is loaded * @param onError defines an optional callback raised if there is an issue to load the texture * @param format defines the format of the data * @param forcedExtension defines the extension to use to pick the right loader * @param createPolynomials if a polynomial sphere should be created for the cube texture * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness * @param fallback defines texture to use while falling back when (compressed) texture file not found. * @returns the cube texture as an InternalTexture */ createCubeTexture(rootUrl: string, scene: Nullable, files: Nullable, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable): InternalTexture; /** * @hidden */ _setCubeMapTextureParams(loadMipmap: boolean): void; /** * Update a raw cube texture * @param texture defines the texture to udpdate * @param data defines the data to store * @param format defines the data format * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default) * @param invertY defines if data must be stored with Y axis inverted * @param compression defines the compression used (null by default) * @param level defines which level of the texture to update */ updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable, level?: number): void; /** * Creates a new raw cube texture * @param data defines the array of data to use to create each face * @param size defines the size of the textures * @param format defines the format of the data * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT) * @param generateMipMaps defines if the engine should generate the mip levels * @param invertY defines if data must be stored with Y axis inverted * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE) * @param compression defines the compression used (null by default) * @returns the cube texture as an InternalTexture */ createRawCubeTexture(data: Nullable, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable): InternalTexture; /** * Creates a new raw cube texture from a specified url * @param url defines the url where the data is located * @param scene defines the current scene * @param size defines the size of the textures * @param format defines the format of the data * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT) * @param noMipmap defines if the engine should avoid generating the mip levels * @param callback defines a callback used to extract texture data from loaded data * @param mipmapGenerator defines to provide an optional tool to generate mip levels * @param onLoad defines a callback called when texture is loaded * @param onError defines a callback called if there is an error * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE) * @param invertY defines if data must be stored with Y axis inverted * @returns the cube texture as an InternalTexture */ createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, samplingMode?: number, invertY?: boolean): InternalTexture; /** * Update a raw 3D texture * @param texture defines the texture to update * @param data defines the data to store * @param format defines the data format * @param invertY defines if data must be stored with Y axis inverted * @param compression defines the used compression (can be null) * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...) */ updateRawTexture3D(texture: InternalTexture, data: Nullable, format: number, invertY: boolean, compression?: Nullable, textureType?: number): void; /** * Creates a new raw 3D texture * @param data defines the data used to create the texture * @param width defines the width of the texture * @param height defines the height of the texture * @param depth defines the depth of the texture * @param format defines the format of the texture * @param generateMipMaps defines if the engine must generate mip levels * @param invertY defines if data must be stored with Y axis inverted * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE) * @param compression defines the compressed used (can be null) * @param textureType defines the compressed used (can be null) * @returns a new raw 3D texture (stored in an InternalTexture) */ createRawTexture3D(data: Nullable, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable, textureType?: number): InternalTexture; private _prepareWebGLTextureContinuation; private _prepareWebGLTexture; private _convertRGBtoRGBATextureData; /** @hidden */ _releaseFramebufferObjects(texture: InternalTexture): void; /** @hidden */ _releaseTexture(texture: InternalTexture): void; private setProgram; private _boundUniforms; /** * Binds an effect to the webGL context * @param effect defines the effect to bind */ bindSamplers(effect: Effect): void; private _moveBoundTextureOnTop; private _getCorrectTextureChannel; private _linkTrackers; private _removeDesignatedSlot; private _activateCurrentTexture; /** @hidden */ protected _bindTextureDirectly(target: number, texture: Nullable, forTextureDataUpdate?: boolean, force?: boolean): boolean; /** @hidden */ _bindTexture(channel: number, texture: Nullable): void; /** * Sets a texture to the webGL context from a postprocess * @param channel defines the channel to use * @param postProcess defines the source postprocess */ setTextureFromPostProcess(channel: number, postProcess: Nullable): void; /** * Binds the output of the passed in post process to the texture channel specified * @param channel The channel the texture should be bound to * @param postProcess The post process which's output should be bound */ setTextureFromPostProcessOutput(channel: number, postProcess: Nullable): void; /** * Unbind all textures from the webGL context */ unbindAllTextures(): void; /** * Sets a texture to the according uniform. * @param channel The texture channel * @param uniform The uniform to set * @param texture The texture to apply */ setTexture(channel: number, uniform: Nullable, texture: Nullable): void; /** * Sets a depth stencil texture from a render target to the according uniform. * @param channel The texture channel * @param uniform The uniform to set * @param texture The render target texture containing the depth stencil texture to apply */ setDepthStencilTexture(channel: number, uniform: Nullable, texture: Nullable): void; private _bindSamplerUniformToChannel; private _getTextureWrapMode; private _setTexture; /** * Sets an array of texture to the webGL context * @param channel defines the channel where the texture array must be set * @param uniform defines the associated uniform location * @param textures defines the array of textures to bind */ setTextureArray(channel: number, uniform: Nullable, textures: BaseTexture[]): void; /** @hidden */ _setAnisotropicLevel(target: number, texture: BaseTexture): void; private _setTextureParameterFloat; private _setTextureParameterInteger; /** * Reads pixels from the current frame buffer. Please note that this function can be slow * @param x defines the x coordinate of the rectangle where pixels must be read * @param y defines the y coordinate of the rectangle where pixels must be read * @param width defines the width of the rectangle where pixels must be read * @param height defines the height of the rectangle where pixels must be read * @returns a Uint8Array containing RGBA colors */ readPixels(x: number, y: number, width: number, height: number): Uint8Array; /** * Add an externaly attached data from its key. * This method call will fail and return false, if such key already exists. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method. * @param key the unique key that identifies the data * @param data the data object to associate to the key for this Engine instance * @return true if no such key were already present and the data was added successfully, false otherwise */ addExternalData(key: string, data: T): boolean; /** * Get an externaly attached data from its key * @param key the unique key that identifies the data * @return the associated data, if present (can be null), or undefined if not present */ getExternalData(key: string): T; /** * Get an externaly attached data from its key, create it using a factory if it's not already present * @param key the unique key that identifies the data * @param factory the factory that will be called to create the instance if and only if it doesn't exists * @return the associated data, can be null if the factory returned null. */ getOrAddExternalDataWithFactory(key: string, factory: (k: string) => T): T; /** * Remove an externaly attached data from the Engine instance * @param key the unique key that identifies the data * @return true if the data was successfully removed, false if it doesn't exist */ removeExternalData(key: string): boolean; /** * Unbind all vertex attributes from the webGL context */ unbindAllAttributes(): void; /** * Force the engine to release all cached effects. This means that next effect compilation will have to be done completely even if a similar effect was already compiled */ releaseEffects(): void; /** * Dispose and release all associated resources */ dispose(): void; /** * Display the loading screen * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen */ displayLoadingUI(): void; /** * Hide the loading screen * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen */ hideLoadingUI(): void; /** * Gets the current loading screen object * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen */ /** * Sets the current loading screen object * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen */ loadingScreen: ILoadingScreen; /** * Sets the current loading screen text * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen */ loadingUIText: string; /** * Sets the current loading screen background color * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen */ loadingUIBackgroundColor: string; /** * Attach a new callback raised when context lost event is fired * @param callback defines the callback to call */ attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void; /** * Attach a new callback raised when context restored event is fired * @param callback defines the callback to call */ attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void; /** * Gets the source code of the vertex shader associated with a specific webGL program * @param program defines the program to use * @returns a string containing the source code of the vertex shader associated with the program */ getVertexShaderSource(program: WebGLProgram): Nullable; /** * Gets the source code of the fragment shader associated with a specific webGL program * @param program defines the program to use * @returns a string containing the source code of the fragment shader associated with the program */ getFragmentShaderSource(program: WebGLProgram): Nullable; /** * Get the current error code of the webGL context * @returns the error code * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError */ getError(): number; /** * Gets the current framerate * @returns a number representing the framerate */ getFps(): number; /** * Gets the time spent between current and previous frame * @returns a number representing the delta time in ms */ getDeltaTime(): number; private _measureFps; /** @hidden */ _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable): ArrayBufferView; private _canRenderToFloatFramebuffer; private _canRenderToHalfFloatFramebuffer; private _canRenderToFramebuffer; /** @hidden */ _getWebGLTextureType(type: number): number; private _getInternalFormat; /** @hidden */ _getRGBABufferInternalSizedFormat(type: number, format?: number): number; /** @hidden */ _getRGBAMultiSampleBufferFormat(type: number): number; /** @hidden */ _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, database?: Database, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest; /** @hidden */ _loadFileAsync(url: string, database?: Database, useArrayBuffer?: boolean): Promise; private _partialLoadFile; private _cascadeLoadFiles; /** * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found) * @returns true if the engine can be created * @ignorenaming */ static isSupported(): boolean; } } declare module BABYLON { /** * Options to create the null engine */ class NullEngineOptions { /** * Render width (Default: 512) */ renderWidth: number; /** * Render height (Default: 256) */ renderHeight: number; /** * Texture size (Default: 512) */ textureSize: number; /** * If delta time between frames should be constant * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */ deterministicLockstep: boolean; /** * Maximum about of steps between frames (Default: 4) * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */ lockstepMaxSteps: number; } /** * The null engine class provides support for headless version of babylon.js. * This can be used in server side scenario or for testing purposes */ class NullEngine extends Engine { private _options; /** * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */ isDeterministicLockStep(): boolean; /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */ getLockstepMaxSteps(): number; /** * Sets hardware scaling, used to save performance if needed * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer */ getHardwareScalingLevel(): number; constructor(options?: NullEngineOptions); createVertexBuffer(vertices: FloatArray): WebGLBuffer; createIndexBuffer(indices: IndicesArray): WebGLBuffer; clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void; getRenderWidth(useScreen?: boolean): number; getRenderHeight(useScreen?: boolean): number; setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void; createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram; getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[]; getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[]; bindSamplers(effect: Effect): void; enableEffect(effect: Effect): void; setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void; setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void; setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void; setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void; setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void; setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void; setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void; setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void; setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void; setArray(uniform: WebGLUniformLocation, array: number[]): void; setArray2(uniform: WebGLUniformLocation, array: number[]): void; setArray3(uniform: WebGLUniformLocation, array: number[]): void; setArray4(uniform: WebGLUniformLocation, array: number[]): void; setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void; setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void; setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void; setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void; setFloat(uniform: WebGLUniformLocation, value: number): void; setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void; setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void; setBool(uniform: WebGLUniformLocation, bool: number): void; setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void; setColor3(uniform: WebGLUniformLocation, color3: Color3): void; setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void; setAlphaMode(mode: number, noDepthWriteChange?: boolean): void; bindBuffers(vertexBuffers: { [key: string]: VertexBuffer; }, indexBuffer: WebGLBuffer, effect: Effect): void; wipeCaches(bruteForce?: boolean): void; draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void; drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void; drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void; /** @hidden */ _createTexture(): WebGLTexture; /** @hidden */ _releaseTexture(texture: InternalTexture): void; createTexture(urlArg: string, noMipmap: boolean, invertY: boolean, scene: Scene, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable, fallBack?: InternalTexture, format?: number): InternalTexture; createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture; updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void; bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void; unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void; createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer; updateDynamicTexture(texture: Nullable, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void; /** * @hidden * Get the current error code of the webGL context * @returns the error code * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError */ getError(): number; /** @hidden */ _getUnpackAlignement(): number; /** @hidden */ _unpackFlipY(value: boolean): void; updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void; /** * Updates a dynamic vertex buffer. * @param vertexBuffer the vertex buffer to update * @param data the data used to update the vertex buffer * @param byteOffset the byte offset of the data (optional) * @param byteLength the byte length of the data (optional) */ updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void; protected _bindTextureDirectly(target: number, texture: InternalTexture): boolean; /** @hidden */ _bindTexture(channel: number, texture: InternalTexture): void; /** @hidden */ _releaseBuffer(buffer: WebGLBuffer): boolean; releaseEffects(): void; displayLoadingUI(): void; hideLoadingUI(): void; /** @hidden */ _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void; /** @hidden */ _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void; /** @hidden */ _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void; /** @hidden */ _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void; } } interface WebGLRenderingContext { readonly RASTERIZER_DISCARD: number; readonly DEPTH_COMPONENT24: number; readonly TEXTURE_3D: number; readonly TEXTURE_2D_ARRAY: number; readonly TEXTURE_COMPARE_FUNC: number; readonly TEXTURE_COMPARE_MODE: number; readonly COMPARE_REF_TO_TEXTURE: number; readonly TEXTURE_WRAP_R: number; readonly HALF_FLOAT: number; readonly RGB8: number; readonly RED_INTEGER: number; readonly RG_INTEGER: number; readonly RGB_INTEGER: number; readonly RGBA_INTEGER: number; readonly R8_SNORM: number; readonly RG8_SNORM: number; readonly RGB8_SNORM: number; readonly RGBA8_SNORM: number; readonly R8I: number; readonly RG8I: number; readonly RGB8I: number; readonly RGBA8I: number; readonly R8UI: number; readonly RG8UI: number; readonly RGB8UI: number; readonly RGBA8UI: number; readonly R16I: number; readonly RG16I: number; readonly RGB16I: number; readonly RGBA16I: number; readonly R16UI: number; readonly RG16UI: number; readonly RGB16UI: number; readonly RGBA16UI: number; readonly R32I: number; readonly RG32I: number; readonly RGB32I: number; readonly RGBA32I: number; readonly R32UI: number; readonly RG32UI: number; readonly RGB32UI: number; readonly RGBA32UI: number; readonly RGB10_A2UI: number; readonly R11F_G11F_B10F: number; readonly RGB9_E5: number; readonly RGB10_A2: number; readonly UNSIGNED_INT_2_10_10_10_REV: number; readonly UNSIGNED_INT_10F_11F_11F_REV: number; readonly UNSIGNED_INT_5_9_9_9_REV: number; readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number; texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void; texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void; texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ImageBitmap | ImageData | HTMLVideoElement | HTMLImageElement | HTMLCanvasElement): void; compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void; readonly TRANSFORM_FEEDBACK: number; readonly INTERLEAVED_ATTRIBS: number; readonly TRANSFORM_FEEDBACK_BUFFER: number; createTransformFeedback(): WebGLTransformFeedback; deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void; bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void; beginTransformFeedback(primitiveMode: number): void; endTransformFeedback(): void; transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void; clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void; clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void; clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void; clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void; } interface ImageBitmap { readonly width: number; readonly height: number; close(): void; } interface WebGLQuery extends WebGLObject { } declare var WebGLQuery: { prototype: WebGLQuery; new (): WebGLQuery; }; interface WebGLSampler extends WebGLObject { } declare var WebGLSampler: { prototype: WebGLSampler; new (): WebGLSampler; }; interface WebGLSync extends WebGLObject { } declare var WebGLSync: { prototype: WebGLSync; new (): WebGLSync; }; interface WebGLTransformFeedback extends WebGLObject { } declare var WebGLTransformFeedback: { prototype: WebGLTransformFeedback; new (): WebGLTransformFeedback; }; interface WebGLVertexArrayObject extends WebGLObject { } declare var WebGLVertexArrayObject: { prototype: WebGLVertexArrayObject; new (): WebGLVertexArrayObject; }; declare module BABYLON { /** * Class used to store bounding box information */ class BoundingBox implements ICullable { /** * Gets the 8 vectors representing the bounding box in local space */ vectors: Vector3[]; /** * Gets the center of the bounding box in local space */ center: Vector3; /** * Gets the center of the bounding box in world space */ centerWorld: Vector3; /** * Gets the extend size in local space */ extendSize: Vector3; /** * Gets the extend size in world space */ extendSizeWorld: Vector3; /** * Gets the OBB (object bounding box) directions */ directions: Vector3[]; /** * Gets the 8 vectors representing the bounding box in world space */ vectorsWorld: Vector3[]; /** * Gets the minimum vector in world space */ minimumWorld: Vector3; /** * Gets the maximum vector in world space */ maximumWorld: Vector3; /** * Gets the minimum vector in local space */ minimum: Vector3; /** * Gets the maximum vector in local space */ maximum: Vector3; private _worldMatrix; /** * @hidden */ _tag: number; /** * Creates a new bounding box * @param min defines the minimum vector (in local space) * @param max defines the maximum vector (in local space) */ constructor(min: Vector3, max: Vector3); /** * Recreates the entire bounding box from scratch * @param min defines the new minimum vector (in local space) * @param max defines the new maximum vector (in local space) */ reConstruct(min: Vector3, max: Vector3): void; /** * Scale the current bounding box by applying a scale factor * @param factor defines the scale factor to apply * @returns the current bounding box */ scale(factor: number): BoundingBox; /** * Gets the world matrix of the bounding box * @returns a matrix */ getWorldMatrix(): Matrix; /** * Sets the world matrix stored in the bounding box * @param matrix defines the matrix to store * @returns current bounding box */ setWorldMatrix(matrix: Matrix): BoundingBox; /** @hidden */ _update(world: Matrix): void; /** * Tests if the bounding box is intersecting the frustum planes * @param frustumPlanes defines the frustum planes to test * @returns true if there is an intersection */ isInFrustum(frustumPlanes: Plane[]): boolean; /** * Tests if the bounding box is entirely inside the frustum planes * @param frustumPlanes defines the frustum planes to test * @returns true if there is an inclusion */ isCompletelyInFrustum(frustumPlanes: Plane[]): boolean; /** * Tests if a point is inside the bounding box * @param point defines the point to test * @returns true if the point is inside the bounding box */ intersectsPoint(point: Vector3): boolean; /** * Tests if the bounding box intersects with a bounding sphere * @param sphere defines the sphere to test * @returns true if there is an intersection */ intersectsSphere(sphere: BoundingSphere): boolean; /** * Tests if the bounding box intersects with a box defined by a min and max vectors * @param min defines the min vector to use * @param max defines the max vector to use * @returns true if there is an intersection */ intersectsMinMax(min: Vector3, max: Vector3): boolean; /** * Tests if two bounding boxes are intersections * @param box0 defines the first box to test * @param box1 defines the second box to test * @returns true if there is an intersection */ static Intersects(box0: BoundingBox, box1: BoundingBox): boolean; /** * Tests if a bounding box defines by a min/max vectors intersects a sphere * @param minPoint defines the minimum vector of the bounding box * @param maxPoint defines the maximum vector of the bounding box * @param sphereCenter defines the sphere center * @param sphereRadius defines the sphere radius * @returns true if there is an intersection */ static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean; /** * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes * @param boundingVectors defines an array of 8 vectors representing a bounding box * @param frustumPlanes defines the frustum planes to test * @return true if there is an inclusion */ static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean; /** * Tests if a bounding box defined with 8 vectors intersects frustum planes * @param boundingVectors defines an array of 8 vectors representing a bounding box * @param frustumPlanes defines the frustum planes to test * @return true if there is an intersection */ static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean; } } declare module BABYLON { /** * Interface for cullable objects * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling */ interface ICullable { /** * Checks if the object or part of the object is in the frustum * @param frustumPlanes Camera near/planes * @returns true if the object is in frustum otherwise false */ isInFrustum(frustumPlanes: Plane[]): boolean; /** * Checks if a cullable object (mesh...) is in the camera frustum * Unlike isInFrustum this cheks the full bounding box * @param frustumPlanes Camera near/planes * @returns true if the object is in frustum otherwise false */ isCompletelyInFrustum(frustumPlanes: Plane[]): boolean; } /** * Info for a bounding data of a mesh */ class BoundingInfo implements ICullable { /** * Bounding box for the mesh */ boundingBox: BoundingBox; /** * Bounding sphere for the mesh */ boundingSphere: BoundingSphere; private _isLocked; /** * Constructs bounding info * @param minimum min vector of the bounding box/sphere * @param maximum max vector of the bounding box/sphere */ constructor(minimum: Vector3, maximum: Vector3); /** * min vector of the bounding box/sphere */ readonly minimum: Vector3; /** * max vector of the bounding box/sphere */ readonly maximum: Vector3; /** * If the info is locked and won't be updated to avoid perf overhead */ isLocked: boolean; /** * Updates the boudning sphere and box * @param world world matrix to be used to update */ update(world: Matrix): void; /** * Recreate the bounding info to be centered around a specific point given a specific extend. * @param center New center of the bounding info * @param extend New extend of the bounding info * @returns the current bounding info */ centerOn(center: Vector3, extend: Vector3): BoundingInfo; /** * Scale the current bounding info by applying a scale factor * @param factor defines the scale factor to apply * @returns the current bounding info */ scale(factor: number): BoundingInfo; /** * Returns `true` if the bounding info is within the frustum defined by the passed array of planes. * @param frustumPlanes defines the frustum to test * @param strategy defines the strategy to use for the culling (default is BABYLON.Scene.CULLINGSTRATEGY_STANDARD) * @returns true if the bounding info is in the frustum planes */ isInFrustum(frustumPlanes: Plane[], strategy?: number): boolean; /** * Gets the world distance between the min and max points of the bounding box */ readonly diagonalLength: number; /** * Checks if a cullable object (mesh...) is in the camera frustum * Unlike isInFrustum this cheks the full bounding box * @param frustumPlanes Camera near/planes * @returns true if the object is in frustum otherwise false */ isCompletelyInFrustum(frustumPlanes: Plane[]): boolean; /** @hidden */ _checkCollision(collider: Collider): boolean; /** * Checks if a point is inside the bounding box and bounding sphere or the mesh * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh * @param point the point to check intersection with * @returns if the point intersects */ intersectsPoint(point: Vector3): boolean; /** * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh * @param boundingInfo the bounding info to check intersection with * @param precise if the intersection should be done using OBB * @returns if the bounding info intersects */ intersects(boundingInfo: BoundingInfo, precise: boolean): boolean; } } declare module BABYLON { /** * Class used to store bounding sphere information */ class BoundingSphere { /** * Gets the center of the bounding sphere in local space */ center: Vector3; /** * Radius of the bounding sphere in local space */ radius: number; /** * Gets the center of the bounding sphere in world space */ centerWorld: Vector3; /** * Radius of the bounding sphere in world space */ radiusWorld: number; /** * Gets the minimum vector in local space */ minimum: Vector3; /** * Gets the maximum vector in local space */ maximum: Vector3; /** * Creates a new bounding sphere * @param min defines the minimum vector (in local space) * @param max defines the maximum vector (in local space) */ constructor(min: Vector3, max: Vector3); /** * Recreates the entire bounding sphere from scratch * @param min defines the new minimum vector (in local space) * @param max defines the new maximum vector (in local space) */ reConstruct(min: Vector3, max: Vector3): void; /** * Scale the current bounding sphere by applying a scale factor * @param factor defines the scale factor to apply * @returns the current bounding box */ scale(factor: number): BoundingSphere; /** @hidden */ _update(world: Matrix): void; /** * Tests if the bounding sphere is intersecting the frustum planes * @param frustumPlanes defines the frustum planes to test * @returns true if there is an intersection */ isInFrustum(frustumPlanes: Plane[]): boolean; /** * Tests if a point is inside the bounding sphere * @param point defines the point to test * @returns true if the point is inside the bounding sphere */ intersectsPoint(point: Vector3): boolean; /** * Checks if two sphere intersct * @param sphere0 sphere 0 * @param sphere1 sphere 1 * @returns true if the speres intersect */ static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean; } } declare module BABYLON { /** * Class representing a ray with position and direction */ class Ray { /** origin point */ origin: Vector3; /** direction */ direction: Vector3; /** length of the ray */ length: number; private _edge1; private _edge2; private _pvec; private _tvec; private _qvec; private _tmpRay; /** * Creates a new ray * @param origin origin point * @param direction direction * @param length length of the ray */ constructor( /** origin point */ origin: Vector3, /** direction */ direction: Vector3, /** length of the ray */ length?: number); /** * Checks if the ray intersects a box * @param minimum bound of the box * @param maximum bound of the box * @returns if the box was hit */ intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean; /** * Checks if the ray intersects a box * @param box the bounding box to check * @returns if the box was hit */ intersectsBox(box: BoundingBox): boolean; /** * If the ray hits a sphere * @param sphere the bounding sphere to check * @returns true if it hits the sphere */ intersectsSphere(sphere: BoundingSphere): boolean; /** * If the ray hits a triange * @param vertex0 triangle vertex * @param vertex1 triangle vertex * @param vertex2 triangle vertex * @returns intersection information if hit */ intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): Nullable; /** * Checks if ray intersects a plane * @param plane the plane to check * @returns the distance away it was hit */ intersectsPlane(plane: Plane): Nullable; /** * Checks if ray intersects a mesh * @param mesh the mesh to check * @param fastCheck if only the bounding box should checked * @returns picking info of the intersecton */ intersectsMesh(mesh: AbstractMesh, fastCheck?: boolean): PickingInfo; /** * Checks if ray intersects a mesh * @param meshes the meshes to check * @param fastCheck if only the bounding box should checked * @param results array to store result in * @returns Array of picking infos */ intersectsMeshes(meshes: Array, fastCheck?: boolean, results?: Array): Array; private _comparePickingInfo; private static smallnum; private static rayl; /** * Intersection test between the ray and a given segment whithin a given tolerance (threshold) * @param sega the first point of the segment to test the intersection against * @param segb the second point of the segment to test the intersection against * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection */ intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number; /** * Update the ray from viewport position * @param x position * @param y y position * @param viewportWidth viewport width * @param viewportHeight viewport height * @param world world matrix * @param view view matrix * @param projection projection matrix * @returns this ray updated */ update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray; /** * Creates a ray with origin and direction of 0,0,0 * @returns the new ray */ static Zero(): Ray; /** * Creates a new ray from screen space and viewport * @param x position * @param y y position * @param viewportWidth viewport width * @param viewportHeight viewport height * @param world world matrix * @param view view matrix * @param projection projection matrix * @returns new ray */ static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray; /** * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be * transformed to the given world matrix. * @param origin The origin point * @param end The end point * @param world a matrix to transform the ray to. Default is the identity matrix. * @returns the new ray */ static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray; /** * Transforms a ray by a matrix * @param ray ray to transform * @param matrix matrix to apply * @returns the resulting new ray */ static Transform(ray: Ray, matrix: Matrix): Ray; /** * Transforms a ray by a matrix * @param ray ray to transform * @param matrix matrix to apply * @param result ray to store result in */ static TransformToRef(ray: Ray, matrix: Matrix, result: Ray): void; } } declare module BABYLON { /** * Gather the list of keyboard event types as constants. */ class KeyboardEventTypes { /** * The keydown event is fired when a key becomes active (pressed). */ static readonly KEYDOWN: number; /** * The keyup event is fired when a key has been released. */ static readonly KEYUP: number; } /** * This class is used to store keyboard related info for the onKeyboardObservable event. */ class KeyboardInfo { /** * Defines the type of event (BABYLON.KeyboardEventTypes) */ type: number; /** * Defines the related dom event */ event: KeyboardEvent; /** * Instantiates a new keyboard info. * This class is used to store keyboard related info for the onKeyboardObservable event. * @param type Defines the type of event (BABYLON.KeyboardEventTypes) * @param event Defines the related dom event */ constructor( /** * Defines the type of event (BABYLON.KeyboardEventTypes) */ type: number, /** * Defines the related dom event */ event: KeyboardEvent); } /** * This class is used to store keyboard related info for the onPreKeyboardObservable event. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable */ class KeyboardInfoPre extends KeyboardInfo { /** * Defines the type of event (BABYLON.KeyboardEventTypes) */ type: number; /** * Defines the related dom event */ event: KeyboardEvent; /** * Defines whether the engine should skip the next onKeyboardObservable associated to this pre. */ skipOnPointerObservable: boolean; /** * Instantiates a new keyboard pre info. * This class is used to store keyboard related info for the onPreKeyboardObservable event. * @param type Defines the type of event (BABYLON.KeyboardEventTypes) * @param event Defines the related dom event */ constructor( /** * Defines the type of event (BABYLON.KeyboardEventTypes) */ type: number, /** * Defines the related dom event */ event: KeyboardEvent); } } declare module BABYLON { /** * Gather the list of pointer event types as constants. */ class PointerEventTypes { /** * The pointerdown event is fired when a pointer becomes active. For mouse, it is fired when the device transitions from no buttons depressed to at least one button depressed. For touch, it is fired when physical contact is made with the digitizer. For pen, it is fired when the stylus makes physical contact with the digitizer. */ static readonly POINTERDOWN: number; /** * The pointerup event is fired when a pointer is no longer active. */ static readonly POINTERUP: number; /** * The pointermove event is fired when a pointer changes coordinates. */ static readonly POINTERMOVE: number; /** * The pointerwheel event is fired when a mouse wheel has been rotated. */ static readonly POINTERWHEEL: number; /** * The pointerpick event is fired when a mesh or sprite has been picked by the pointer. */ static readonly POINTERPICK: number; /** * The pointertap event is fired when a the object has been touched and released without drag. */ static readonly POINTERTAP: number; /** * The pointerdoubletap event is fired when a the object has been touched and released twice without drag. */ static readonly POINTERDOUBLETAP: number; } /** * Base class of pointer info types. */ class PointerInfoBase { /** * Defines the type of event (BABYLON.PointerEventTypes) */ type: number; /** * Defines the related dom event */ event: PointerEvent | MouseWheelEvent; /** * Instantiates the base class of pointers info. * @param type Defines the type of event (BABYLON.PointerEventTypes) * @param event Defines the related dom event */ constructor( /** * Defines the type of event (BABYLON.PointerEventTypes) */ type: number, /** * Defines the related dom event */ event: PointerEvent | MouseWheelEvent); } /** * This class is used to store pointer related info for the onPrePointerObservable event. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable */ class PointerInfoPre extends PointerInfoBase { /** * Ray from a pointer if availible (eg. 6dof controller) */ ray: Nullable; /** * Defines the local position of the pointer on the canvas. */ localPosition: Vector2; /** * Defines whether the engine should skip the next OnPointerObservable associated to this pre. */ skipOnPointerObservable: boolean; /** * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event. * @param type Defines the type of event (BABYLON.PointerEventTypes) * @param event Defines the related dom event * @param localX Defines the local x coordinates of the pointer when the event occured * @param localY Defines the local y coordinates of the pointer when the event occured */ constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number); } /** * This type contains all the data related to a pointer event in Babylon.js. * The event member is an instance of PointerEvent for all types except PointerWheel and is of type MouseWheelEvent when type equals PointerWheel. The different event types can be found in the PointerEventTypes class. */ class PointerInfo extends PointerInfoBase { /** * Defines the picking info associated to the info (if any)\ */ pickInfo: Nullable; /** * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event. * @param type Defines the type of event (BABYLON.PointerEventTypes) * @param event Defines the related dom event * @param pickInfo Defines the picking info associated to the info (if any)\ */ constructor(type: number, event: PointerEvent | MouseWheelEvent, /** * Defines the picking info associated to the info (if any)\ */ pickInfo: Nullable); } } declare module BABYLON { /** * Represents a gamepad control stick position */ class StickValues { /** * The x component of the control stick */ x: number; /** * The y component of the control stick */ y: number; /** * Initializes the gamepad x and y control stick values * @param x The x component of the gamepad control stick value * @param y The y component of the gamepad control stick value */ constructor( /** * The x component of the control stick */ x: number, /** * The y component of the control stick */ y: number); } /** * An interface which manages callbacks for gamepad button changes */ interface GamepadButtonChanges { /** * Called when a gamepad has been changed */ changed: boolean; /** * Called when a gamepad press event has been triggered */ pressChanged: boolean; /** * Called when a touch event has been triggered */ touchChanged: boolean; /** * Called when a value has changed */ valueChanged: boolean; } /** * Represents a gamepad */ class Gamepad { /** * The id of the gamepad */ id: string; /** * The index of the gamepad */ index: number; /** * The browser gamepad */ browserGamepad: any; /** * Specifies what type of gamepad this represents */ type: number; private _leftStick; private _rightStick; /** @hidden */ _isConnected: boolean; private _leftStickAxisX; private _leftStickAxisY; private _rightStickAxisX; private _rightStickAxisY; /** * Triggered when the left control stick has been changed */ private _onleftstickchanged; /** * Triggered when the right control stick has been changed */ private _onrightstickchanged; /** * Represents a gamepad controller */ static GAMEPAD: number; /** * Represents a generic controller */ static GENERIC: number; /** * Represents an XBox controller */ static XBOX: number; /** * Represents a pose-enabled controller */ static POSE_ENABLED: number; /** * Specifies whether the left control stick should be Y-inverted */ protected _invertLeftStickY: boolean; /** * Specifies if the gamepad has been connected */ readonly isConnected: boolean; /** * Initializes the gamepad * @param id The id of the gamepad * @param index The index of the gamepad * @param browserGamepad The browser gamepad * @param leftStickX The x component of the left joystick * @param leftStickY The y component of the left joystick * @param rightStickX The x component of the right joystick * @param rightStickY The y component of the right joystick */ constructor( /** * The id of the gamepad */ id: string, /** * The index of the gamepad */ index: number, /** * The browser gamepad */ browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number); /** * Callback triggered when the left joystick has changed * @param callback */ onleftstickchanged(callback: (values: StickValues) => void): void; /** * Callback triggered when the right joystick has changed * @param callback */ onrightstickchanged(callback: (values: StickValues) => void): void; /** * Gets the left joystick */ /** * Sets the left joystick values */ leftStick: StickValues; /** * Gets the right joystick */ /** * Sets the right joystick value */ rightStick: StickValues; /** * Updates the gamepad joystick positions */ update(): void; /** * Disposes the gamepad */ dispose(): void; } /** * Represents a generic gamepad */ class GenericPad extends Gamepad { private _buttons; private _onbuttondown; private _onbuttonup; /** * Observable triggered when a button has been pressed */ onButtonDownObservable: Observable; /** * Observable triggered when a button has been released */ onButtonUpObservable: Observable; /** * Callback triggered when a button has been pressed * @param callback Called when a button has been pressed */ onbuttondown(callback: (buttonPressed: number) => void): void; /** * Callback triggered when a button has been released * @param callback Called when a button has been released */ onbuttonup(callback: (buttonReleased: number) => void): void; /** * Initializes the generic gamepad * @param id The id of the generic gamepad * @param index The index of the generic gamepad * @param browserGamepad The browser gamepad */ constructor(id: string, index: number, browserGamepad: any); private _setButtonValue; /** * Updates the generic gamepad */ update(): void; /** * Disposes the generic gamepad */ dispose(): void; } } declare module BABYLON { /** * Manager for handling gamepads */ class GamepadManager { private _scene?; private _babylonGamepads; private _oneGamepadConnected; /** @hidden */ _isMonitoring: boolean; private _gamepadEventSupported; private _gamepadSupport; /** * observable to be triggered when the gamepad controller has been connected */ onGamepadConnectedObservable: Observable; /** * observable to be triggered when the gamepad controller has been disconnected */ onGamepadDisconnectedObservable: Observable; private _onGamepadConnectedEvent; private _onGamepadDisconnectedEvent; /** * Initializes the gamepad manager * @param _scene BabylonJS scene */ constructor(_scene?: Scene | undefined); /** * The gamepads in the game pad manager */ readonly gamepads: Gamepad[]; /** * Get the gamepad controllers based on type * @param type The type of gamepad controller * @returns Nullable gamepad */ getGamepadByType(type?: number): Nullable; /** * Disposes the gamepad manager */ dispose(): void; private _addNewGamepad; private _startMonitoringGamepads; private _stopMonitoringGamepads; /** @hidden */ _checkGamepadsStatus(): void; private _updateGamepadObjects; } } declare module BABYLON { interface Scene { /** @hidden */ _gamepadManager: Nullable; /** * Gets the gamepad manager associated with the scene * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads */ gamepadManager: GamepadManager; } /** * Interface representing a free camera inputs manager */ interface FreeCameraInputsManager { /** * Adds gamepad input support to the FreeCameraInputsManager. * @returns the FreeCameraInputsManager */ addGamepad(): FreeCameraInputsManager; } /** * Interface representing an arc rotate camera inputs manager */ interface ArcRotateCameraInputsManager { /** * Adds gamepad input support to the ArcRotateCamera InputManager. * @returns the camera inputs manager */ addGamepad(): ArcRotateCameraInputsManager; } /** * Defines the gamepad scene component responsible to manage gamepads in a given scene */ class GamepadSystemSceneComponent implements ISceneComponent { /** * The component name helpfull to identify the component in the list of scene components. */ readonly name: string; /** * The scene the component belongs to. */ scene: Scene; /** * Creates a new instance of the component for the given scene * @param scene Defines the scene to register the component in */ constructor(scene: Scene); /** * Registers the component in a given scene */ register(): void; /** * Rebuilds the elements related to this component in case of * context lost for instance. */ rebuild(): void; /** * Disposes the component and the associated ressources */ dispose(): void; private _beforeCameraUpdate; } } declare module BABYLON { /** * Defines supported buttons for XBox360 compatible gamepads */ enum Xbox360Button { /** A */ A = 0, /** B */ B = 1, /** X */ X = 2, /** Y */ Y = 3, /** Start */ Start = 4, /** Back */ Back = 5, /** Left button */ LB = 6, /** Right button */ RB = 7, /** Left stick */ LeftStick = 8, /** Right stick */ RightStick = 9 } /** Defines values for XBox360 DPad */ enum Xbox360Dpad { /** Up */ Up = 0, /** Down */ Down = 1, /** Left */ Left = 2, /** Right */ Right = 3 } /** * Defines a XBox360 gamepad */ class Xbox360Pad extends Gamepad { private _leftTrigger; private _rightTrigger; private _onlefttriggerchanged; private _onrighttriggerchanged; private _onbuttondown; private _onbuttonup; private _ondpaddown; private _ondpadup; /** Observable raised when a button is pressed */ onButtonDownObservable: Observable; /** Observable raised when a button is released */ onButtonUpObservable: Observable; /** Observable raised when a pad is pressed */ onPadDownObservable: Observable; /** Observable raised when a pad is released */ onPadUpObservable: Observable; private _buttonA; private _buttonB; private _buttonX; private _buttonY; private _buttonBack; private _buttonStart; private _buttonLB; private _buttonRB; private _buttonLeftStick; private _buttonRightStick; private _dPadUp; private _dPadDown; private _dPadLeft; private _dPadRight; private _isXboxOnePad; /** * Creates a new XBox360 gamepad object * @param id defines the id of this gamepad * @param index defines its index * @param gamepad defines the internal HTML gamepad object * @param xboxOne defines if it is a XBox One gamepad */ constructor(id: string, index: number, gamepad: any, xboxOne?: boolean); /** * Defines the callback to call when left trigger is pressed * @param callback defines the callback to use */ onlefttriggerchanged(callback: (value: number) => void): void; /** * Defines the callback to call when right trigger is pressed * @param callback defines the callback to use */ onrighttriggerchanged(callback: (value: number) => void): void; /** * Gets the left trigger value */ /** * Sets the left trigger value */ leftTrigger: number; /** * Gets the right trigger value */ /** * Sets the right trigger value */ rightTrigger: number; /** * Defines the callback to call when a button is pressed * @param callback defines the callback to use */ onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void; /** * Defines the callback to call when a button is released * @param callback defines the callback to use */ onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void; /** * Defines the callback to call when a pad is pressed * @param callback defines the callback to use */ ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void; /** * Defines the callback to call when a pad is released * @param callback defines the callback to use */ ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void; private _setButtonValue; private _setDPadValue; /** * Gets the value of the `A` button */ /** * Sets the value of the `A` button */ buttonA: number; /** * Gets the value of the `B` button */ /** * Sets the value of the `B` button */ buttonB: number; /** * Gets the value of the `X` button */ /** * Sets the value of the `X` button */ buttonX: number; /** * Gets the value of the `Y` button */ /** * Sets the value of the `Y` button */ buttonY: number; /** * Gets the value of the `Start` button */ /** * Sets the value of the `Start` button */ buttonStart: number; /** * Gets the value of the `Back` button */ /** * Sets the value of the `Back` button */ buttonBack: number; /** * Gets the value of the `Left` button */ /** * Sets the value of the `Left` button */ buttonLB: number; /** * Gets the value of the `Right` button */ /** * Sets the value of the `Right` button */ buttonRB: number; /** * Gets the value of the Left joystick */ /** * Sets the value of the Left joystick */ buttonLeftStick: number; /** * Gets the value of the Right joystick */ /** * Sets the value of the Right joystick */ buttonRightStick: number; /** * Gets the value of D-pad up */ /** * Sets the value of D-pad up */ dPadUp: number; /** * Gets the value of D-pad down */ /** * Sets the value of D-pad down */ dPadDown: number; /** * Gets the value of D-pad left */ /** * Sets the value of D-pad left */ dPadLeft: number; /** * Gets the value of D-pad right */ /** * Sets the value of D-pad right */ dPadRight: number; /** * Force the gamepad to synchronize with device values */ update(): void; /** * Disposes the gamepad */ dispose(): void; } } declare module BABYLON { /** * Single axis drag gizmo */ class AxisDragGizmo extends Gizmo { /** * Drag behavior responsible for the gizmos dragging interactions */ dragBehavior: PointerDragBehavior; private _pointerObserver; /** * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0) */ snapDistance: number; /** * Event that fires each time the gizmo snaps to a new location. * * snapDistance is the the change in distance */ onSnapObservable: Observable<{ snapDistance: number; }>; /** * Creates an AxisDragGizmo * @param gizmoLayer The utility layer the gizmo will be added to * @param dragAxis The axis which the gizmo will be able to drag on * @param color The color of the gizmo */ constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer); protected _attachedMeshChanged(value: Nullable): void; /** * Disposes of the gizmo */ dispose(): void; } } declare module BABYLON { /** * Single axis scale gizmo */ class AxisScaleGizmo extends Gizmo { private _coloredMaterial; /** * Drag behavior responsible for the gizmos dragging interactions */ dragBehavior: PointerDragBehavior; private _pointerObserver; /** * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0) */ snapDistance: number; /** * Event that fires each time the gizmo snaps to a new location. * * snapDistance is the the change in distance */ onSnapObservable: Observable<{ snapDistance: number; }>; /** * If the scaling operation should be done on all axis (default: false) */ uniformScaling: boolean; /** * Creates an AxisScaleGizmo * @param gizmoLayer The utility layer the gizmo will be added to * @param dragAxis The axis which the gizmo will be able to scale on * @param color The color of the gizmo */ constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer); protected _attachedMeshChanged(value: Nullable): void; /** * Disposes of the gizmo */ dispose(): void; /** * Disposes and replaces the current meshes in the gizmo with the specified mesh * @param mesh The mesh to replace the default mesh of the gizmo * @param useGizmoMaterial If the gizmo's default material should be used (default: false) */ setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void; } } declare module BABYLON { /** * Bounding box gizmo */ class BoundingBoxGizmo extends Gizmo { private _lineBoundingBox; private _rotateSpheresParent; private _scaleBoxesParent; private _boundingDimensions; private _renderObserver; private _pointerObserver; private _scaleDragSpeed; private _tmpQuaternion; private _tmpVector; private _tmpRotationMatrix; /** * If child meshes should be ignored when calculating the boudning box. This should be set to true to avoid perf hits with heavily nested meshes (Default: false) */ ignoreChildren: boolean; /** * Returns true if a descendant should be included when computing the bounding box. When null, all descendants are included. If ignoreChildren is set this will be ignored. (Default: null) */ includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>; /** * The size of the rotation spheres attached to the bounding box (Default: 0.1) */ rotationSphereSize: number; /** * The size of the scale boxes attached to the bounding box (Default: 0.1) */ scaleBoxSize: number; /** * If set, the rotation spheres and scale boxes will increase in size based on the distance away from the camera to have a consistent screen size (Default: false) */ fixedDragMeshScreenSize: boolean; /** * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10) */ fixedDragMeshScreenSizeDistanceFactor: number; /** * Fired when a rotation sphere or scale box is dragged */ onDragStartObservable: Observable<{}>; /** * Fired when a scale box is dragged */ onScaleBoxDragObservable: Observable<{}>; /** * Fired when a scale box drag is ended */ onScaleBoxDragEndObservable: Observable<{}>; /** * Fired when a rotation sphere is dragged */ onRotationSphereDragObservable: Observable<{}>; /** * Fired when a rotation sphere drag is ended */ onRotationSphereDragEndObservable: Observable<{}>; /** * Relative bounding box pivot used when scaling the attached mesh. When null object with scale from the opposite corner. 0.5,0.5,0.5 for center and 0.5,0,0.5 for bottom (Default: null) */ scalePivot: Nullable; private _anchorMesh; private _existingMeshScale; private static _PivotCached; private static _OldPivotPoint; private static _PivotTranslation; private static _PivotTmpVector; /** @hidden */ static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void; /** @hidden */ static _RestorePivotPoint(mesh: AbstractMesh): void; /** * Creates an BoundingBoxGizmo * @param gizmoLayer The utility layer the gizmo will be added to * @param color The color of the gizmo */ constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer); protected _attachedMeshChanged(value: Nullable): void; private _selectNode; /** * Updates the bounding box information for the Gizmo */ updateBoundingBox(): void; /** * Enables rotation on the specified axis and disables rotation on the others * @param axis The list of axis that should be enabled (eg. "xy" or "xyz") */ setEnabledRotationAxis(axis: string): void; /** * Disposes of the gizmo */ dispose(): void; /** * Makes a mesh not pickable and wraps the mesh inside of a bounding box mesh that is pickable. (This is useful to avoid picking within complex geometry) * @param mesh the mesh to wrap in the bounding box mesh and make not pickable * @returns the bounding box mesh with the passed in mesh as a child */ static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh; /** * CustomMeshes are not supported by this gizmo * @param mesh The mesh to replace the default mesh of the gizmo */ setCustomMesh(mesh: Mesh): void; } } declare module BABYLON { /** * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc. */ class Gizmo implements IDisposable { /** The utility layer the gizmo will be added to */ gizmoLayer: UtilityLayerRenderer; /** * The root mesh of the gizmo */ protected _rootMesh: Mesh; private _attachedMesh; /** * Ratio for the scale of the gizmo (Default: 1) */ scaleRatio: number; private _tmpMatrix; /** * If a custom mesh has been set (Default: false) */ protected _customMeshSet: boolean; /** * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged) * * When set, interactions will be enabled */ attachedMesh: Nullable; /** * Disposes and replaces the current meshes in the gizmo with the specified mesh * @param mesh The mesh to replace the default mesh of the gizmo */ setCustomMesh(mesh: Mesh): void; /** * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true) */ updateGizmoRotationToMatchAttachedMesh: boolean; /** * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true) */ updateGizmoPositionToMatchAttachedMesh: boolean; /** * When set, the gizmo will always appear the same size no matter where the camera is (default: false) */ protected _updateScale: boolean; protected _interactionsEnabled: boolean; protected _attachedMeshChanged(value: Nullable): void; private _beforeRenderObserver; /** * Creates a gizmo * @param gizmoLayer The utility layer the gizmo will be added to */ constructor( /** The utility layer the gizmo will be added to */ gizmoLayer?: UtilityLayerRenderer); private _tempVector; /** * @hidden * Updates the gizmo to match the attached mesh's position/rotation */ protected _update(): void; /** * Disposes of the gizmo */ dispose(): void; } } declare module BABYLON { /** * Helps setup gizmo's in the scene to rotate/scale/position meshes */ class GizmoManager implements IDisposable { private scene; /** * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time */ gizmos: { positionGizmo: Nullable; rotationGizmo: Nullable; scaleGizmo: Nullable; boundingBoxGizmo: Nullable; }; private _gizmosEnabled; private _pointerObserver; private _attachedMesh; private _boundingBoxColor; private _defaultUtilityLayer; private _defaultKeepDepthUtilityLayer; /** * When bounding box gizmo is enabled, this can be used to track drag/end events */ boundingBoxDragBehavior: SixDofDragBehavior; /** * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null) */ attachableMeshes: Nullable>; /** * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true) */ usePointerToAttachGizmos: boolean; /** * Instatiates a gizmo manager * @param scene the scene to overlay the gizmos on top of */ constructor(scene: Scene); /** * Attaches a set of gizmos to the specified mesh * @param mesh The mesh the gizmo's should be attached to */ attachToMesh(mesh: Nullable): void; /** * If the position gizmo is enabled */ positionGizmoEnabled: boolean; /** * If the rotation gizmo is enabled */ rotationGizmoEnabled: boolean; /** * If the scale gizmo is enabled */ scaleGizmoEnabled: boolean; /** * If the boundingBox gizmo is enabled */ boundingBoxGizmoEnabled: boolean; /** * Disposes of the gizmo manager */ dispose(): void; } } declare module BABYLON { /** * Single plane rotation gizmo */ class PlaneRotationGizmo extends Gizmo { /** * Drag behavior responsible for the gizmos dragging interactions */ dragBehavior: PointerDragBehavior; private _pointerObserver; /** * Rotation distance in radians that the gizmo will snap to (Default: 0) */ snapDistance: number; /** * Event that fires each time the gizmo snaps to a new location. * * snapDistance is the the change in distance */ onSnapObservable: Observable<{ snapDistance: number; }>; /** * Creates a PlaneRotationGizmo * @param gizmoLayer The utility layer the gizmo will be added to * @param planeNormal The normal of the plane which the gizmo will be able to rotate on * @param color The color of the gizmo * @param tessellation Amount of tessellation to be used when creating rotation circles */ constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number); protected _attachedMeshChanged(value: Nullable): void; /** * Disposes of the gizmo */ dispose(): void; } } declare module BABYLON { /** * Gizmo that enables dragging a mesh along 3 axis */ class PositionGizmo extends Gizmo { /** * Internal gizmo used for interactions on the x axis */ xGizmo: AxisDragGizmo; /** * Internal gizmo used for interactions on the y axis */ yGizmo: AxisDragGizmo; /** * Internal gizmo used for interactions on the z axis */ zGizmo: AxisDragGizmo; /** Fires an event when any of it's sub gizmos are dragged */ onDragStartObservable: Observable<{}>; /** Fires an event when any of it's sub gizmos are released from dragging */ onDragEndObservable: Observable<{}>; attachedMesh: Nullable; /** * Creates a PositionGizmo * @param gizmoLayer The utility layer the gizmo will be added to */ constructor(gizmoLayer?: UtilityLayerRenderer); updateGizmoRotationToMatchAttachedMesh: boolean; /** * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0) */ snapDistance: number; /** * Ratio for the scale of the gizmo (Default: 1) */ scaleRatio: number; /** * Disposes of the gizmo */ dispose(): void; /** * CustomMeshes are not supported by this gizmo * @param mesh The mesh to replace the default mesh of the gizmo */ setCustomMesh(mesh: Mesh): void; } } declare module BABYLON { /** * Gizmo that enables rotating a mesh along 3 axis */ class RotationGizmo extends Gizmo { /** * Internal gizmo used for interactions on the x axis */ xGizmo: PlaneRotationGizmo; /** * Internal gizmo used for interactions on the y axis */ yGizmo: PlaneRotationGizmo; /** * Internal gizmo used for interactions on the z axis */ zGizmo: PlaneRotationGizmo; /** Fires an event when any of it's sub gizmos are dragged */ onDragStartObservable: Observable<{}>; /** Fires an event when any of it's sub gizmos are released from dragging */ onDragEndObservable: Observable<{}>; attachedMesh: Nullable; /** * Creates a RotationGizmo * @param gizmoLayer The utility layer the gizmo will be added to * @param tessellation Amount of tessellation to be used when creating rotation circles */ constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number); updateGizmoRotationToMatchAttachedMesh: boolean; /** * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0) */ snapDistance: number; /** * Ratio for the scale of the gizmo (Default: 1) */ scaleRatio: number; /** * Disposes of the gizmo */ dispose(): void; /** * CustomMeshes are not supported by this gizmo * @param mesh The mesh to replace the default mesh of the gizmo */ setCustomMesh(mesh: Mesh): void; } } declare module BABYLON { /** * Gizmo that enables scaling a mesh along 3 axis */ class ScaleGizmo extends Gizmo { /** * Internal gizmo used for interactions on the x axis */ xGizmo: AxisScaleGizmo; /** * Internal gizmo used for interactions on the y axis */ yGizmo: AxisScaleGizmo; /** * Internal gizmo used for interactions on the z axis */ zGizmo: AxisScaleGizmo; /** * Internal gizmo used to scale all axis equally */ uniformScaleGizmo: AxisScaleGizmo; /** Fires an event when any of it's sub gizmos are dragged */ onDragStartObservable: Observable<{}>; /** Fires an event when any of it's sub gizmos are released from dragging */ onDragEndObservable: Observable<{}>; attachedMesh: Nullable; /** * Creates a ScaleGizmo * @param gizmoLayer The utility layer the gizmo will be added to */ constructor(gizmoLayer?: UtilityLayerRenderer); updateGizmoRotationToMatchAttachedMesh: boolean; /** * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0) */ snapDistance: number; /** * Ratio for the scale of the gizmo (Default: 1) */ scaleRatio: number; /** * Disposes of the gizmo */ dispose(): void; } } declare module BABYLON { /** * This class can be used to get instrumentation data from a Babylon engine * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation */ class EngineInstrumentation implements IDisposable { /** * Define the instrumented engine. */ engine: Engine; private _captureGPUFrameTime; private _gpuFrameTimeToken; private _gpuFrameTime; private _captureShaderCompilationTime; private _shaderCompilationTime; private _onBeginFrameObserver; private _onEndFrameObserver; private _onBeforeShaderCompilationObserver; private _onAfterShaderCompilationObserver; /** * Gets the perf counter used for GPU frame time */ readonly gpuFrameTimeCounter: PerfCounter; /** * Gets the GPU frame time capture status */ /** * Enable or disable the GPU frame time capture */ captureGPUFrameTime: boolean; /** * Gets the perf counter used for shader compilation time */ readonly shaderCompilationTimeCounter: PerfCounter; /** * Gets the shader compilation time capture status */ /** * Enable or disable the shader compilation time capture */ captureShaderCompilationTime: boolean; /** * Instantiates a new engine instrumentation. * This class can be used to get instrumentation data from a Babylon engine * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation * @param engine Defines the engine to instrument */ constructor( /** * Define the instrumented engine. */ engine: Engine); /** * Dispose and release associated resources. */ dispose(): void; } } declare module BABYLON { /** * This class can be used to get instrumentation data from a Babylon engine * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation */ class SceneInstrumentation implements IDisposable { /** * Defines the scene to instrument */ scene: Scene; private _captureActiveMeshesEvaluationTime; private _activeMeshesEvaluationTime; private _captureRenderTargetsRenderTime; private _renderTargetsRenderTime; private _captureFrameTime; private _frameTime; private _captureRenderTime; private _renderTime; private _captureInterFrameTime; private _interFrameTime; private _captureParticlesRenderTime; private _particlesRenderTime; private _captureSpritesRenderTime; private _spritesRenderTime; private _capturePhysicsTime; private _physicsTime; private _captureAnimationsTime; private _animationsTime; private _captureCameraRenderTime; private _cameraRenderTime; private _onBeforeActiveMeshesEvaluationObserver; private _onAfterActiveMeshesEvaluationObserver; private _onBeforeRenderTargetsRenderObserver; private _onAfterRenderTargetsRenderObserver; private _onAfterRenderObserver; private _onBeforeDrawPhaseObserver; private _onAfterDrawPhaseObserver; private _onBeforeAnimationsObserver; private _onBeforeParticlesRenderingObserver; private _onAfterParticlesRenderingObserver; private _onBeforeSpritesRenderingObserver; private _onAfterSpritesRenderingObserver; private _onBeforePhysicsObserver; private _onAfterPhysicsObserver; private _onAfterAnimationsObserver; private _onBeforeCameraRenderObserver; private _onAfterCameraRenderObserver; /** * Gets the perf counter used for active meshes evaluation time */ readonly activeMeshesEvaluationTimeCounter: PerfCounter; /** * Gets the active meshes evaluation time capture status */ /** * Enable or disable the active meshes evaluation time capture */ captureActiveMeshesEvaluationTime: boolean; /** * Gets the perf counter used for render targets render time */ readonly renderTargetsRenderTimeCounter: PerfCounter; /** * Gets the render targets render time capture status */ /** * Enable or disable the render targets render time capture */ captureRenderTargetsRenderTime: boolean; /** * Gets the perf counter used for particles render time */ readonly particlesRenderTimeCounter: PerfCounter; /** * Gets the particles render time capture status */ /** * Enable or disable the particles render time capture */ captureParticlesRenderTime: boolean; /** * Gets the perf counter used for sprites render time */ readonly spritesRenderTimeCounter: PerfCounter; /** * Gets the sprites render time capture status */ /** * Enable or disable the sprites render time capture */ captureSpritesRenderTime: boolean; /** * Gets the perf counter used for physics time */ readonly physicsTimeCounter: PerfCounter; /** * Gets the physics time capture status */ /** * Enable or disable the physics time capture */ capturePhysicsTime: boolean; /** * Gets the perf counter used for animations time */ readonly animationsTimeCounter: PerfCounter; /** * Gets the animations time capture status */ /** * Enable or disable the animations time capture */ captureAnimationsTime: boolean; /** * Gets the perf counter used for frame time capture */ readonly frameTimeCounter: PerfCounter; /** * Gets the frame time capture status */ /** * Enable or disable the frame time capture */ captureFrameTime: boolean; /** * Gets the perf counter used for inter-frames time capture */ readonly interFrameTimeCounter: PerfCounter; /** * Gets the inter-frames time capture status */ /** * Enable or disable the inter-frames time capture */ captureInterFrameTime: boolean; /** * Gets the perf counter used for render time capture */ readonly renderTimeCounter: PerfCounter; /** * Gets the render time capture status */ /** * Enable or disable the render time capture */ captureRenderTime: boolean; /** * Gets the perf counter used for camera render time capture */ readonly cameraRenderTimeCounter: PerfCounter; /** * Gets the camera render time capture status */ /** * Enable or disable the camera render time capture */ captureCameraRenderTime: boolean; /** * Gets the perf counter used for draw calls */ readonly drawCallsCounter: PerfCounter; /** * Gets the perf counter used for texture collisions */ readonly textureCollisionsCounter: PerfCounter; /** * Instantiates a new scene instrumentation. * This class can be used to get instrumentation data from a Babylon engine * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation * @param scene Defines the scene to instrument */ constructor( /** * Defines the scene to instrument */ scene: Scene); /** * Dispose and release associated resources. */ dispose(): void; } } declare module BABYLON { /** * @hidden **/ class _TimeToken { _startTimeQuery: Nullable; _endTimeQuery: Nullable; _timeElapsedQuery: Nullable; _timeElapsedQueryEnded: boolean; } } declare module BABYLON { /** * Represents the different options available during the creation of * a Environment helper. * * This can control the default ground, skybox and image processing setup of your scene. */ interface IEnvironmentHelperOptions { /** * Specifies wether or not to create a ground. * True by default. */ createGround: boolean; /** * Specifies the ground size. * 15 by default. */ groundSize: number; /** * The texture used on the ground for the main color. * Comes from the BabylonJS CDN by default. * * Remarks: Can be either a texture or a url. */ groundTexture: string | BaseTexture; /** * The color mixed in the ground texture by default. * BabylonJS clearColor by default. */ groundColor: Color3; /** * Specifies the ground opacity. * 1 by default. */ groundOpacity: number; /** * Enables the ground to receive shadows. * True by default. */ enableGroundShadow: boolean; /** * Helps preventing the shadow to be fully black on the ground. * 0.5 by default. */ groundShadowLevel: number; /** * Creates a mirror texture attach to the ground. * false by default. */ enableGroundMirror: boolean; /** * Specifies the ground mirror size ratio. * 0.3 by default as the default kernel is 64. */ groundMirrorSizeRatio: number; /** * Specifies the ground mirror blur kernel size. * 64 by default. */ groundMirrorBlurKernel: number; /** * Specifies the ground mirror visibility amount. * 1 by default */ groundMirrorAmount: number; /** * Specifies the ground mirror reflectance weight. * This uses the standard weight of the background material to setup the fresnel effect * of the mirror. * 1 by default. */ groundMirrorFresnelWeight: number; /** * Specifies the ground mirror Falloff distance. * This can helps reducing the size of the reflection. * 0 by Default. */ groundMirrorFallOffDistance: number; /** * Specifies the ground mirror texture type. * Unsigned Int by Default. */ groundMirrorTextureType: number; /** * Specifies a bias applied to the ground vertical position to prevent z-fighting with * the shown objects. */ groundYBias: number; /** * Specifies wether or not to create a skybox. * True by default. */ createSkybox: boolean; /** * Specifies the skybox size. * 20 by default. */ skyboxSize: number; /** * The texture used on the skybox for the main color. * Comes from the BabylonJS CDN by default. * * Remarks: Can be either a texture or a url. */ skyboxTexture: string | BaseTexture; /** * The color mixed in the skybox texture by default. * BabylonJS clearColor by default. */ skyboxColor: Color3; /** * The background rotation around the Y axis of the scene. * This helps aligning the key lights of your scene with the background. * 0 by default. */ backgroundYRotation: number; /** * Compute automatically the size of the elements to best fit with the scene. */ sizeAuto: boolean; /** * Default position of the rootMesh if autoSize is not true. */ rootPosition: Vector3; /** * Sets up the image processing in the scene. * true by default. */ setupImageProcessing: boolean; /** * The texture used as your environment texture in the scene. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true. * * Remarks: Can be either a texture or a url. */ environmentTexture: string | BaseTexture; /** * The value of the exposure to apply to the scene. * 0.6 by default if setupImageProcessing is true. */ cameraExposure: number; /** * The value of the contrast to apply to the scene. * 1.6 by default if setupImageProcessing is true. */ cameraContrast: number; /** * Specifies wether or not tonemapping should be enabled in the scene. * true by default if setupImageProcessing is true. */ toneMappingEnabled: boolean; } /** * The Environment helper class can be used to add a fully featuread none expensive background to your scene. * It includes by default a skybox and a ground relying on the BackgroundMaterial. * It also helps with the default setup of your imageProcessing configuration. */ class EnvironmentHelper { /** * Default ground texture URL. */ private static _groundTextureCDNUrl; /** * Default skybox texture URL. */ private static _skyboxTextureCDNUrl; /** * Default environment texture URL. */ private static _environmentTextureCDNUrl; /** * Creates the default options for the helper. */ private static _getDefaultOptions; private _rootMesh; /** * Gets the root mesh created by the helper. */ readonly rootMesh: Mesh; private _skybox; /** * Gets the skybox created by the helper. */ readonly skybox: Nullable; private _skyboxTexture; /** * Gets the skybox texture created by the helper. */ readonly skyboxTexture: Nullable; private _skyboxMaterial; /** * Gets the skybox material created by the helper. */ readonly skyboxMaterial: Nullable; private _ground; /** * Gets the ground mesh created by the helper. */ readonly ground: Nullable; private _groundTexture; /** * Gets the ground texture created by the helper. */ readonly groundTexture: Nullable; private _groundMirror; /** * Gets the ground mirror created by the helper. */ readonly groundMirror: Nullable; /** * Gets the ground mirror render list to helps pushing the meshes * you wish in the ground reflection. */ readonly groundMirrorRenderList: Nullable; private _groundMaterial; /** * Gets the ground material created by the helper. */ readonly groundMaterial: Nullable; /** * Stores the creation options. */ private readonly _scene; private _options; /** * This observable will be notified with any error during the creation of the environment, * mainly texture creation errors. */ onErrorObservable: Observable<{ message?: string; exception?: any; }>; /** * constructor * @param options * @param scene The scene to add the material to */ constructor(options: Partial, scene: Scene); /** * Updates the background according to the new options * @param options */ updateOptions(options: Partial): void; /** * Sets the primary color of all the available elements. * @param color the main color to affect to the ground and the background */ setMainColor(color: Color3): void; /** * Setup the image processing according to the specified options. */ private _setupImageProcessing; /** * Setup the environment texture according to the specified options. */ private _setupEnvironmentTexture; /** * Setup the background according to the specified options. */ private _setupBackground; /** * Get the scene sizes according to the setup. */ private _getSceneSize; /** * Setup the ground according to the specified options. */ private _setupGround; /** * Setup the ground material according to the specified options. */ private _setupGroundMaterial; /** * Setup the ground diffuse texture according to the specified options. */ private _setupGroundDiffuseTexture; /** * Setup the ground mirror texture according to the specified options. */ private _setupGroundMirrorTexture; /** * Setup the ground to receive the mirror texture. */ private _setupMirrorInGroundMaterial; /** * Setup the skybox according to the specified options. */ private _setupSkybox; /** * Setup the skybox material according to the specified options. */ private _setupSkyboxMaterial; /** * Setup the skybox reflection texture according to the specified options. */ private _setupSkyboxReflectionTexture; private _errorHandler; /** * Dispose all the elements created by the Helper. */ dispose(): void; } } declare module BABYLON { /** * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere. * Potential additions to this helper include zoom and and non-infinite distance rendering effects. */ class PhotoDome extends TransformNode { private _useDirectMapping; /** * The texture being displayed on the sphere */ protected _photoTexture: Texture; /** * Gets or sets the texture being displayed on the sphere */ photoTexture: Texture; /** * Observable raised when an error occured while loading the 360 image */ onLoadErrorObservable: Observable; /** * The skybox material */ protected _material: BackgroundMaterial; /** * The surface used for the skybox */ protected _mesh: Mesh; /** * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out". * Also see the options.resolution property. */ fovMultiplier: number; /** * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh. * @param name Element's name, child elements will append suffixes for their own names. * @param urlsOfPhoto defines the url of the photo to display * @param options defines an object containing optional or exposed sub element properties * @param onError defines a callback called when an error occured while loading the texture */ constructor(name: string, urlOfPhoto: string, options: { resolution?: number; size?: number; useDirectMapping?: boolean; }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>); /** * Releases resources associated with this node. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default) * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default) */ dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void; } } declare module BABYLON { interface Scene { /** * Creates a default light for the scene. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light */ createDefaultLight(replace?: boolean): void; /** * Creates a default camera for the scene. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera * @param replace has default false, when true replaces the active camera in the scene * @param attachCameraControls has default false, when true attaches camera controls to the canvas. */ createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void; /** * Creates a default camera and a default light. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera * @param replace has the default false, when true replaces the active camera/light in the scene * @param attachCameraControls has the default false, when true attaches camera controls to the canvas. */ createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void; /** * Creates a new sky box * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox * @param environmentTexture defines the texture to use as environment texture * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used * @param scale defines the overall scale of the skybox * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1 * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture * @returns a new mesh holding the sky box */ createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable; /** * Creates a new environment * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment * @param options defines the options you can use to configure the environment * @returns the new EnvironmentHelper */ createDefaultEnvironment(options?: Partial): Nullable; /** * Creates a new VREXperienceHelper * @see http://doc.babylonjs.com/how_to/webvr_helper * @param webVROptions defines the options used to create the new VREXperienceHelper * @returns a new VREXperienceHelper */ createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper; } } declare module BABYLON { /** * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere. * Potential additions to this helper include zoom and and non-infinite distance rendering effects. */ class VideoDome extends TransformNode { private _useDirectMapping; /** * The video texture being displayed on the sphere */ protected _videoTexture: VideoTexture; /** * Gets the video texture being displayed on the sphere */ readonly videoTexture: VideoTexture; /** * The skybox material */ protected _material: BackgroundMaterial; /** * The surface used for the skybox */ protected _mesh: Mesh; /** * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out". * Also see the options.resolution property. */ fovMultiplier: number; /** * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh. * @param name Element's name, child elements will append suffixes for their own names. * @param urlsOrVideo defines the url(s) or the video element to use * @param options An object containing optional or exposed sub element properties */ constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: { resolution?: number; clickToPlay?: boolean; autoPlay?: boolean; loop?: boolean; size?: number; poster?: string; useDirectMapping?: boolean; }, scene: Scene); /** * Releases resources associated with this node. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default) * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default) */ dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void; } } declare module BABYLON { /** * Effect layer options. This helps customizing the behaviour * of the effect layer. */ interface IEffectLayerOptions { /** * Multiplication factor apply to the canvas size to compute the render target size * used to generated the objects (the smaller the faster). */ mainTextureRatio: number; /** * Enforces a fixed size texture to ensure effect stability across devices. */ mainTextureFixedSize?: number; /** * Alpha blending mode used to apply the blur. Default depends of the implementation. */ alphaBlendingMode: number; /** * The camera attached to the layer. */ camera: Nullable; /** * The rendering group to draw the layer in. */ renderingGroupId: number; } /** * The effect layer Helps adding post process effect blended with the main pass. * * This can be for instance use to generate glow or higlight effects on the scene. * * The effect layer class can not be used directly and is intented to inherited from to be * customized per effects. */ abstract class EffectLayer { private _vertexBuffers; private _indexBuffer; private _cachedDefines; private _effectLayerMapGenerationEffect; private _effectLayerOptions; private _mergeEffect; protected _scene: Scene; protected _engine: Engine; protected _maxSize: number; protected _mainTextureDesiredSize: ISize; protected _mainTexture: RenderTargetTexture; protected _shouldRender: boolean; protected _postProcesses: PostProcess[]; protected _textures: BaseTexture[]; protected _emissiveTextureAndColor: { texture: Nullable; color: Color4; }; /** * The name of the layer */ name: string; /** * The clear color of the texture used to generate the glow map. */ neutralColor: Color4; /** * Specifies wether the highlight layer is enabled or not. */ isEnabled: boolean; /** * Gets the camera attached to the layer. */ readonly camera: Nullable; /** * Gets the rendering group id the layer should render in. */ readonly renderingGroupId: number; /** * An event triggered when the effect layer has been disposed. */ onDisposeObservable: Observable; /** * An event triggered when the effect layer is about rendering the main texture with the glowy parts. */ onBeforeRenderMainTextureObservable: Observable; /** * An event triggered when the generated texture is being merged in the scene. */ onBeforeComposeObservable: Observable; /** * An event triggered when the generated texture has been merged in the scene. */ onAfterComposeObservable: Observable; /** * An event triggered when the efffect layer changes its size. */ onSizeChangedObservable: Observable; /** * Instantiates a new effect Layer and references it in the scene. * @param name The name of the layer * @param scene The scene to use the layer in */ constructor( /** The Friendly of the effect in the scene */ name: string, scene: Scene); /** * Get the effect name of the layer. * @return The effect name */ abstract getEffectName(): string; /** * Checks for the readiness of the element composing the layer. * @param subMesh the mesh to check for * @param useInstances specify wether or not to use instances to render the mesh * @return true if ready otherwise, false */ abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean; /** * Returns wether or nood the layer needs stencil enabled during the mesh rendering. * @returns true if the effect requires stencil during the main canvas render pass. */ abstract needStencil(): boolean; /** * Create the merge effect. This is the shader use to blit the information back * to the main canvas at the end of the scene rendering. * @returns The effect containing the shader used to merge the effect on the main canvas */ protected abstract _createMergeEffect(): Effect; /** * Creates the render target textures and post processes used in the effect layer. */ protected abstract _createTextureAndPostProcesses(): void; /** * Implementation specific of rendering the generating effect on the main canvas. * @param effect The effect used to render through */ protected abstract _internalRender(effect: Effect): void; /** * Sets the required values for both the emissive texture and and the main color. */ protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void; /** * Free any resources and references associated to a mesh. * Internal use * @param mesh The mesh to free. */ abstract _disposeMesh(mesh: Mesh): void; /** * Serializes this layer (Glow or Highlight for example) * @returns a serialized layer object */ abstract serialize?(): any; /** * Initializes the effect layer with the required options. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information) */ protected _init(options: Partial): void; /** * Generates the index buffer of the full screen quad blending to the main canvas. */ private _generateIndexBuffer; /** * Generates the vertex buffer of the full screen quad blending to the main canvas. */ private _genrateVertexBuffer; /** * Sets the main texture desired size which is the closest power of two * of the engine canvas size. */ private _setMainTextureSize; /** * Creates the main texture for the effect layer. */ protected _createMainTexture(): void; /** * Checks for the readiness of the element composing the layer. * @param subMesh the mesh to check for * @param useInstances specify wether or not to use instances to render the mesh * @param emissiveTexture the associated emissive texture used to generate the glow * @return true if ready otherwise, false */ protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable): boolean; /** * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene. */ render(): void; /** * Determine if a given mesh will be used in the current effect. * @param mesh mesh to test * @returns true if the mesh will be used */ hasMesh(mesh: AbstractMesh): boolean; /** * Returns true if the layer contains information to display, otherwise false. * @returns true if the glow layer should be rendered */ shouldRender(): boolean; /** * Returns true if the mesh should render, otherwise false. * @param mesh The mesh to render * @returns true if it should render otherwise false */ protected _shouldRenderMesh(mesh: Mesh): boolean; /** * Returns true if the mesh should render, otherwise false. * @param mesh The mesh to render * @returns true if it should render otherwise false */ protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean; /** * Renders the submesh passed in parameter to the generation map. */ protected _renderSubMesh(subMesh: SubMesh): void; /** * Rebuild the required buffers. * @hidden Internal use only. */ _rebuild(): void; /** * Dispose only the render target textures and post process. */ private _disposeTextureAndPostProcesses; /** * Dispose the highlight layer and free resources. */ dispose(): void; /** * Gets the class name of the effect layer * @returns the string with the class name of the effect layer */ getClassName(): string; /** * Creates an effect layer from parsed effect layer data * @param parsedEffectLayer defines effect layer data * @param scene defines the current scene * @param rootUrl defines the root URL containing the effect layer information * @returns a parsed effect Layer */ static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer; } } declare module BABYLON { interface AbstractScene { /** * The list of effect layers (highlights/glow) added to the scene * @see http://doc.babylonjs.com/how_to/highlight_layer * @see http://doc.babylonjs.com/how_to/glow_layer */ effectLayers: Array; /** * Removes the given effect layer from this scene. * @param toRemove defines the effect layer to remove * @returns the index of the removed effect layer */ removeEffectLayer(toRemove: EffectLayer): number; /** * Adds the given effect layer to this scene * @param newEffectLayer defines the effect layer to add */ addEffectLayer(newEffectLayer: EffectLayer): void; } /** * Defines the layer scene component responsible to manage any effect layers * in a given scene. */ class EffectLayerSceneComponent implements ISceneSerializableComponent { /** * The component name helpfull to identify the component in the list of scene components. */ readonly name: string; /** * The scene the component belongs to. */ scene: Scene; private _engine; private _renderEffects; private _needStencil; private _previousStencilState; /** * Creates a new instance of the component for the given scene * @param scene Defines the scene to register the component in */ constructor(scene: Scene); /** * Registers the component in a given scene */ register(): void; /** * Rebuilds the elements related to this component in case of * context lost for instance. */ rebuild(): void; /** * Serializes the component data to the specified json object * @param serializationObject The object to serialize to */ serialize(serializationObject: any): void; /** * Adds all the element from the container to the scene * @param container the container holding the elements */ addFromContainer(container: AbstractScene): void; /** * Removes all the elements in the container from the scene * @param container contains the elements to remove */ removeFromContainer(container: AbstractScene): void; /** * Disposes the component and the associated ressources. */ dispose(): void; private _isReadyForMesh; private _renderMainTexture; private _setStencil; private _setStencilBack; private _draw; private _drawCamera; private _drawRenderingGroup; } } declare module BABYLON { interface AbstractScene { /** * Return a the first highlight layer of the scene with a given name. * @param name The name of the highlight layer to look for. * @return The highlight layer if found otherwise null. */ getGlowLayerByName(name: string): Nullable; } /** * Glow layer options. This helps customizing the behaviour * of the glow layer. */ interface IGlowLayerOptions { /** * Multiplication factor apply to the canvas size to compute the render target size * used to generated the glowing objects (the smaller the faster). */ mainTextureRatio: number; /** * Enforces a fixed size texture to ensure resize independant blur. */ mainTextureFixedSize?: number; /** * How big is the kernel of the blur texture. */ blurKernelSize: number; /** * The camera attached to the layer. */ camera: Nullable; /** * Enable MSAA by chosing the number of samples. */ mainTextureSamples?: number; /** * The rendering group to draw the layer in. */ renderingGroupId: number; } /** * The glow layer Helps adding a glow effect around the emissive parts of a mesh. * * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove * glowy meshes to your scene. * * Documentation: https://doc.babylonjs.com/how_to/glow_layer */ class GlowLayer extends EffectLayer { /** * Effect Name of the layer. */ static readonly EffectName: string; /** * The default blur kernel size used for the glow. */ static DefaultBlurKernelSize: number; /** * The default texture size ratio used for the glow. */ static DefaultTextureRatio: number; /** * Sets the kernel size of the blur. */ /** * Gets the kernel size of the blur. */ blurKernelSize: number; /** * Sets the glow intensity. */ /** * Gets the glow intensity. */ intensity: number; private _options; private _intensity; private _horizontalBlurPostprocess1; private _verticalBlurPostprocess1; private _horizontalBlurPostprocess2; private _verticalBlurPostprocess2; private _blurTexture1; private _blurTexture2; private _postProcesses1; private _postProcesses2; private _includedOnlyMeshes; private _excludedMeshes; /** * Callback used to let the user override the color selection on a per mesh basis */ customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void; /** * Callback used to let the user override the texture selection on a per mesh basis */ customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture; /** * Instantiates a new glow Layer and references it to the scene. * @param name The name of the layer * @param scene The scene to use the layer in * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information) */ constructor(name: string, scene: Scene, options?: Partial); /** * Get the effect name of the layer. * @return The effect name */ getEffectName(): string; /** * Create the merge effect. This is the shader use to blit the information back * to the main canvas at the end of the scene rendering. */ protected _createMergeEffect(): Effect; /** * Creates the render target textures and post processes used in the glow layer. */ protected _createTextureAndPostProcesses(): void; /** * Checks for the readiness of the element composing the layer. * @param subMesh the mesh to check for * @param useInstances specify wether or not to use instances to render the mesh * @param emissiveTexture the associated emissive texture used to generate the glow * @return true if ready otherwise, false */ isReady(subMesh: SubMesh, useInstances: boolean): boolean; /** * Returns wether or nood the layer needs stencil enabled during the mesh rendering. */ needStencil(): boolean; /** * Implementation specific of rendering the generating effect on the main canvas. * @param effect The effect used to render through */ protected _internalRender(effect: Effect): void; /** * Sets the required values for both the emissive texture and and the main color. */ protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void; /** * Returns true if the mesh should render, otherwise false. * @param mesh The mesh to render * @returns true if it should render otherwise false */ protected _shouldRenderMesh(mesh: Mesh): boolean; /** * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer. * @param mesh The mesh to exclude from the glow layer */ addExcludedMesh(mesh: Mesh): void; /** * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer. * @param mesh The mesh to remove */ removeExcludedMesh(mesh: Mesh): void; /** * Add a mesh in the inclusion list to impact or being impacted by the glow layer. * @param mesh The mesh to include in the glow layer */ addIncludedOnlyMesh(mesh: Mesh): void; /** * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer. * @param mesh The mesh to remove */ removeIncludedOnlyMesh(mesh: Mesh): void; /** * Determine if a given mesh will be used in the glow layer * @param mesh The mesh to test * @returns true if the mesh will be highlighted by the current glow layer */ hasMesh(mesh: AbstractMesh): boolean; /** * Free any resources and references associated to a mesh. * Internal use * @param mesh The mesh to free. * @hidden */ _disposeMesh(mesh: Mesh): void; /** * Gets the class name of the effect layer * @returns the string with the class name of the effect layer */ getClassName(): string; /** * Serializes this glow layer * @returns a serialized glow layer object */ serialize(): any; /** * Creates a Glow Layer from parsed glow layer data * @param parsedGlowLayer defines glow layer data * @param scene defines the current scene * @param rootUrl defines the root URL containing the glow layer information * @returns a parsed Glow Layer */ static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer; } } declare module BABYLON { interface AbstractScene { /** * Return a the first highlight layer of the scene with a given name. * @param name The name of the highlight layer to look for. * @return The highlight layer if found otherwise null. */ getHighlightLayerByName(name: string): Nullable; } /** * Highlight layer options. This helps customizing the behaviour * of the highlight layer. */ interface IHighlightLayerOptions { /** * Multiplication factor apply to the canvas size to compute the render target size * used to generated the glowing objects (the smaller the faster). */ mainTextureRatio: number; /** * Enforces a fixed size texture to ensure resize independant blur. */ mainTextureFixedSize?: number; /** * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size * of the picture to blur (the smaller the faster). */ blurTextureSizeRatio: number; /** * How big in texel of the blur texture is the vertical blur. */ blurVerticalSize: number; /** * How big in texel of the blur texture is the horizontal blur. */ blurHorizontalSize: number; /** * Alpha blending mode used to apply the blur. Default is combine. */ alphaBlendingMode: number; /** * The camera attached to the layer. */ camera: Nullable; /** * Should we display highlight as a solid stroke? */ isStroke?: boolean; /** * The rendering group to draw the layer in. */ renderingGroupId: number; } /** * The highlight layer Helps adding a glow effect around a mesh. * * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove * glowy meshes to your scene. * * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!! */ class HighlightLayer extends EffectLayer { name: string; /** * Effect Name of the highlight layer. */ static readonly EffectName: string; /** * The neutral color used during the preparation of the glow effect. * This is black by default as the blend operation is a blend operation. */ static NeutralColor: Color4; /** * Stencil value used for glowing meshes. */ static GlowingMeshStencilReference: number; /** * Stencil value used for the other meshes in the scene. */ static NormalMeshStencilReference: number; /** * Specifies whether or not the inner glow is ACTIVE in the layer. */ innerGlow: boolean; /** * Specifies whether or not the outer glow is ACTIVE in the layer. */ outerGlow: boolean; /** * Specifies the horizontal size of the blur. */ /** * Gets the horizontal size of the blur. */ blurHorizontalSize: number; /** * Specifies the vertical size of the blur. */ /** * Gets the vertical size of the blur. */ blurVerticalSize: number; /** * An event triggered when the highlight layer is being blurred. */ onBeforeBlurObservable: Observable; /** * An event triggered when the highlight layer has been blurred. */ onAfterBlurObservable: Observable; private _instanceGlowingMeshStencilReference; private _options; private _downSamplePostprocess; private _horizontalBlurPostprocess; private _verticalBlurPostprocess; private _blurTexture; private _meshes; private _excludedMeshes; /** * Instantiates a new highlight Layer and references it to the scene.. * @param name The name of the layer * @param scene The scene to use the layer in * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information) */ constructor(name: string, scene: Scene, options?: Partial); /** * Get the effect name of the layer. * @return The effect name */ getEffectName(): string; /** * Create the merge effect. This is the shader use to blit the information back * to the main canvas at the end of the scene rendering. */ protected _createMergeEffect(): Effect; /** * Creates the render target textures and post processes used in the highlight layer. */ protected _createTextureAndPostProcesses(): void; /** * Returns wether or nood the layer needs stencil enabled during the mesh rendering. */ needStencil(): boolean; /** * Checks for the readiness of the element composing the layer. * @param subMesh the mesh to check for * @param useInstances specify wether or not to use instances to render the mesh * @param emissiveTexture the associated emissive texture used to generate the glow * @return true if ready otherwise, false */ isReady(subMesh: SubMesh, useInstances: boolean): boolean; /** * Implementation specific of rendering the generating effect on the main canvas. * @param effect The effect used to render through */ protected _internalRender(effect: Effect): void; /** * Returns true if the layer contains information to display, otherwise false. */ shouldRender(): boolean; /** * Returns true if the mesh should render, otherwise false. * @param mesh The mesh to render * @returns true if it should render otherwise false */ protected _shouldRenderMesh(mesh: Mesh): boolean; /** * Sets the required values for both the emissive texture and and the main color. */ protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void; /** * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer. * @param mesh The mesh to exclude from the highlight layer */ addExcludedMesh(mesh: Mesh): void; /** * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer. * @param mesh The mesh to highlight */ removeExcludedMesh(mesh: Mesh): void; /** * Determine if a given mesh will be highlighted by the current HighlightLayer * @param mesh mesh to test * @returns true if the mesh will be highlighted by the current HighlightLayer */ hasMesh(mesh: AbstractMesh): boolean; /** * Add a mesh in the highlight layer in order to make it glow with the chosen color. * @param mesh The mesh to highlight * @param color The color of the highlight * @param glowEmissiveOnly Extract the glow from the emissive texture */ addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void; /** * Remove a mesh from the highlight layer in order to make it stop glowing. * @param mesh The mesh to highlight */ removeMesh(mesh: Mesh): void; /** * Force the stencil to the normal expected value for none glowing parts */ private _defaultStencilReference; /** * Free any resources and references associated to a mesh. * Internal use * @param mesh The mesh to free. * @hidden */ _disposeMesh(mesh: Mesh): void; /** * Dispose the highlight layer and free resources. */ dispose(): void; /** * Gets the class name of the effect layer * @returns the string with the class name of the effect layer */ getClassName(): string; /** * Serializes this Highlight layer * @returns a serialized Highlight layer object */ serialize(): any; /** * Creates a Highlight layer from parsed Highlight layer data * @param parsedHightlightLayer defines the Highlight layer data * @param scene defines the current scene * @param rootUrl defines the root URL containing the Highlight layer information * @returns a parsed Highlight layer */ static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer; } } declare module BABYLON { /** * This represents a full screen 2d layer. * This can be usefull to display a picture in the background of your scene for instance. * @see https://www.babylonjs-playground.com/#08A2BS#1 */ class Layer { /** * Define the name of the layer. */ name: string; /** * Define the texture the layer should display. */ texture: Nullable; /** * Is the layer in background or foreground. */ isBackground: boolean; /** * Define the color of the layer (instead of texture). */ color: Color4; /** * Define the scale of the layer in order to zoom in out of the texture. */ scale: Vector2; /** * Define an offset for the layer in order to shift the texture. */ offset: Vector2; /** * Define the alpha blending mode used in the layer in case the texture or color has an alpha. */ alphaBlendingMode: number; /** * Define if the layer should alpha test or alpha blend with the rest of the scene. * Alpha test will not mix with the background color in case of transparency. * It will either use the texture color or the background depending on the alpha value of the current pixel. */ alphaTest: boolean; /** * Define a mask to restrict the layer to only some of the scene cameras. */ layerMask: number; private _scene; private _vertexBuffers; private _indexBuffer; private _effect; private _alphaTestEffect; /** * An event triggered when the layer is disposed. */ onDisposeObservable: Observable; private _onDisposeObserver; /** * Back compatibility with callback before the onDisposeObservable existed. * The set callback will be triggered when the layer has been disposed. */ onDispose: () => void; /** * An event triggered before rendering the scene */ onBeforeRenderObservable: Observable; private _onBeforeRenderObserver; /** * Back compatibility with callback before the onBeforeRenderObservable existed. * The set callback will be triggered just before rendering the layer. */ onBeforeRender: () => void; /** * An event triggered after rendering the scene */ onAfterRenderObservable: Observable; private _onAfterRenderObserver; /** * Back compatibility with callback before the onAfterRenderObservable existed. * The set callback will be triggered just after rendering the layer. */ onAfterRender: () => void; /** * Instantiates a new layer. * This represents a full screen 2d layer. * This can be usefull to display a picture in the background of your scene for instance. * @see https://www.babylonjs-playground.com/#08A2BS#1 * @param name Define the name of the layer in the scene * @param imgUrl Define the url of the texture to display in the layer * @param scene Define the scene the layer belongs to * @param isBackground Defines whether the layer is displayed in front or behind the scene * @param color Defines a color for the layer */ constructor( /** * Define the name of the layer. */ name: string, imgUrl: Nullable, scene: Nullable, isBackground?: boolean, color?: Color4); private _createIndexBuffer; /** @hidden */ _rebuild(): void; /** * Renders the layer in the scene. */ render(): void; /** * Disposes and releases the associated ressources. */ dispose(): void; } } declare module BABYLON { interface AbstractScene { /** * The list of layers (background and foreground) of the scene */ layers: Array; } /** * Defines the layer scene component responsible to manage any layers * in a given scene. */ class LayerSceneComponent implements ISceneComponent { /** * The component name helpfull to identify the component in the list of scene components. */ readonly name: string; /** * The scene the component belongs to. */ scene: Scene; private _engine; /** * Creates a new instance of the component for the given scene * @param scene Defines the scene to register the component in */ constructor(scene: Scene); /** * Registers the component in a given scene */ register(): void; /** * Rebuilds the elements related to this component in case of * context lost for instance. */ rebuild(): void; /** * Disposes the component and the associated ressources. */ dispose(): void; private _draw; private _drawBackground; private _drawForeground; } } declare module BABYLON { /** * This represents one of the lens effect in a `BABYLON.lensFlareSystem`. * It controls one of the indiviual texture used in the effect. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares */ class LensFlare { /** * Define the size of the lens flare in the system (a floating value between 0 and 1) */ size: number; /** * Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind. */ position: number; /** * Define the lens color. */ color: Color3; /** * Define the lens texture. */ texture: Nullable; /** * Define the alpha mode to render this particular lens. */ alphaMode: number; private _system; /** * Creates a new Lens Flare. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`. * It controls one of the indiviual texture used in the effect. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares * @param size Define the size of the lens flare (a floating value between 0 and 1) * @param position Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind. * @param color Define the lens color * @param imgUrl Define the lens texture url * @param system Define the `lensFlareSystem` this flare is part of * @returns The newly created Lens Flare */ static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare; /** * Instantiates a new Lens Flare. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`. * It controls one of the indiviual texture used in the effect. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares * @param size Define the size of the lens flare in the system (a floating value between 0 and 1) * @param position Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind. * @param color Define the lens color * @param imgUrl Define the lens texture url * @param system Define the `lensFlareSystem` this flare is part of */ constructor( /** * Define the size of the lens flare in the system (a floating value between 0 and 1) */ size: number, /** * Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind. */ position: number, color: Color3, imgUrl: string, system: LensFlareSystem); /** * Dispose and release the lens flare with its associated resources. */ dispose(): void; } } declare module BABYLON { /** * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses. * It is usually composed of several `BABYLON.lensFlare`. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares */ class LensFlareSystem { /** * Define the name of the lens flare system */ name: string; /** * List of lens flares used in this system. */ lensFlares: LensFlare[]; /** * Define a limit from the border the lens flare can be visible. */ borderLimit: number; /** * Define a viewport border we do not want to see the lens flare in. */ viewportBorder: number; /** * Define a predicate which could limit the list of meshes able to occlude the effect. */ meshesSelectionPredicate: (mesh: AbstractMesh) => boolean; /** * Restricts the rendering of the effect to only the camera rendering this layer mask. */ layerMask: number; /** * Define the id of the lens flare system in the scene. * (equal to name by default) */ id: string; private _scene; private _emitter; private _vertexBuffers; private _indexBuffer; private _effect; private _positionX; private _positionY; private _isEnabled; /** * Instantiates a lens flare system. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses. * It is usually composed of several `BABYLON.lensFlare`. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares * @param name Define the name of the lens flare system in the scene * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh). * @param scene Define the scene the lens flare system belongs to */ constructor( /** * Define the name of the lens flare system */ name: string, emitter: any, scene: Scene); /** * Define if the lens flare system is enabled. */ isEnabled: boolean; /** * Get the scene the effects belongs to. * @returns the scene holding the lens flare system */ getScene(): Scene; /** * Get the emitter of the lens flare system. * It defines the source of the lens flares (it can be a camera, a light or a mesh). * @returns the emitter of the lens flare system */ getEmitter(): any; /** * Set the emitter of the lens flare system. * It defines the source of the lens flares (it can be a camera, a light or a mesh). * @param newEmitter Define the new emitter of the system */ setEmitter(newEmitter: any): void; /** * Get the lens flare system emitter position. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh). * @returns the position */ getEmitterPosition(): Vector3; /** * @hidden */ computeEffectivePosition(globalViewport: Viewport): boolean; /** @hidden */ _isVisible(): boolean; /** * @hidden */ render(): boolean; /** * Dispose and release the lens flare with its associated resources. */ dispose(): void; /** * Parse a lens flare system from a JSON repressentation * @param parsedLensFlareSystem Define the JSON to parse * @param scene Define the scene the parsed system should be instantiated in * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures * @returns the parsed system */ static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem; /** * Serialize the current Lens Flare System into a JSON representation. * @returns the serialized JSON */ serialize(): any; } } declare module BABYLON { interface AbstractScene { /** * The list of lens flare system added to the scene * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares */ lensFlareSystems: Array; /** * Removes the given lens flare system from this scene. * @param toRemove The lens flare system to remove * @returns The index of the removed lens flare system */ removeLensFlareSystem(toRemove: LensFlareSystem): number; /** * Adds the given lens flare system to this scene * @param newLensFlareSystem The lens flare system to add */ addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void; /** * Gets a lens flare system using its name * @param name defines the name to look for * @returns the lens flare system or null if not found */ getLensFlareSystemByName(name: string): Nullable; /** * Gets a lens flare system using its id * @param id defines the id to look for * @returns the lens flare system or null if not found */ getLensFlareSystemByID(id: string): Nullable; } /** * Defines the lens flare scene component responsible to manage any lens flares * in a given scene. */ class LensFlareSystemSceneComponent implements ISceneSerializableComponent { /** * The component name helpfull to identify the component in the list of scene components. */ readonly name: string; /** * The scene the component belongs to. */ scene: Scene; /** * Creates a new instance of the component for the given scene * @param scene Defines the scene to register the component in */ constructor(scene: Scene); /** * Registers the component in a given scene */ register(): void; /** * Rebuilds the elements related to this component in case of * context lost for instance. */ rebuild(): void; /** * Adds all the element from the container to the scene * @param container the container holding the elements */ addFromContainer(container: AbstractScene): void; /** * Removes all the elements in the container from the scene * @param container contains the elements to remove */ removeFromContainer(container: AbstractScene): void; /** * Serializes the component data to the specified json object * @param serializationObject The object to serialize to */ serialize(serializationObject: any): void; /** * Disposes the component and the associated ressources. */ dispose(): void; private _draw; } } declare module BABYLON { /** * A directional light is defined by a direction (what a surprise!). * The light is emitted from everywhere in the specified direction, and has an infinite range. * An example of a directional light is when a distance planet is lit by the apparently parallel lines of light from its sun. Light in a downward direction will light the top of an object. * Documentation: https://doc.babylonjs.com/babylon101/lights */ class DirectionalLight extends ShadowLight { private _shadowFrustumSize; /** * Fix frustum size for the shadow generation. This is disabled if the value is 0. */ /** * Specifies a fix frustum size for the shadow generation. */ shadowFrustumSize: number; private _shadowOrthoScale; /** * Gets the shadow projection scale against the optimal computed one. * 0.1 by default which means that the projection window is increase by 10% from the optimal size. * This does not impact in fixed frustum size (shadowFrustumSize being set) */ /** * Sets the shadow projection scale against the optimal computed one. * 0.1 by default which means that the projection window is increase by 10% from the optimal size. * This does not impact in fixed frustum size (shadowFrustumSize being set) */ shadowOrthoScale: number; /** * Automatically compute the projection matrix to best fit (including all the casters) * on each frame. */ autoUpdateExtends: boolean; private _orthoLeft; private _orthoRight; private _orthoTop; private _orthoBottom; /** * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3). * The directional light is emitted from everywhere in the given direction. * It can cast shadows. * Documentation : http://doc.babylonjs.com/tutorials/lights * @param name The friendly name of the light * @param direction The direction of the light * @param scene The scene the light belongs to */ constructor(name: string, direction: Vector3, scene: Scene); /** * Returns the string "DirectionalLight". * @return The class name */ getClassName(): string; /** * Returns the integer 1. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x */ getTypeID(): number; /** * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix. * Returns the DirectionalLight Shadow projection matrix. */ protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array): void; /** * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix. * Returns the DirectionalLight Shadow projection matrix. */ protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void; /** * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix. * Returns the DirectionalLight Shadow projection matrix. */ protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array): void; protected _buildUniformLayout(): void; /** * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name. * @param effect The effect to update * @param lightIndex The index of the light in the effect to update * @returns The directional light */ transferToEffect(effect: Effect, lightIndex: string): DirectionalLight; /** * Gets the minZ used for shadow according to both the scene and the light. * * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5. * @param activeCamera The camera we are returning the min for * @returns the depth min z */ getDepthMinZ(activeCamera: Camera): number; /** * Gets the maxZ used for shadow according to both the scene and the light. * * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5. * @param activeCamera The camera we are returning the max for * @returns the depth max z */ getDepthMaxZ(activeCamera: Camera): number; /** * Prepares the list of defines specific to the light type. * @param defines the list of defines * @param lightIndex defines the index of the light for the effect */ prepareLightSpecificDefines(defines: any, lightIndex: number): void; } } declare module BABYLON { /** * The HemisphericLight simulates the ambient environment light, * so the passed direction is the light reflection direction, not the incoming direction. */ class HemisphericLight extends Light { /** * The groundColor is the light in the opposite direction to the one specified during creation. * You can think of the diffuse and specular light as coming from the centre of the object in the given direction and the groundColor light in the opposite direction. */ groundColor: Color3; /** * The light reflection direction, not the incoming direction. */ direction: Vector3; /** * Creates a HemisphericLight object in the scene according to the passed direction (Vector3). * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction. * The HemisphericLight can't cast shadows. * Documentation : http://doc.babylonjs.com/tutorials/lights * @param name The friendly name of the light * @param direction The direction of the light reflection * @param scene The scene the light belongs to */ constructor(name: string, direction: Vector3, scene: Scene); protected _buildUniformLayout(): void; /** * Returns the string "HemisphericLight". * @return The class name */ getClassName(): string; /** * Sets the HemisphericLight direction towards the passed target (Vector3). * Returns the updated direction. * @param target The target the direction should point to * @return The computed direction */ setDirectionToTarget(target: Vector3): Vector3; /** * Returns the shadow generator associated to the light. * @returns Always null for hemispheric lights because it does not support shadows. */ getShadowGenerator(): Nullable; /** * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string). * @param effect The effect to update * @param lightIndex The index of the light in the effect to update * @returns The hemispheric light */ transferToEffect(effect: Effect, lightIndex: string): HemisphericLight; /** * Computes the world matrix of the node * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch * @param useWasUpdatedFlag defines a reserved property * @returns the world matrix */ computeWorldMatrix(force?: boolean, useWasUpdatedFlag?: boolean): Matrix; /** * Returns the integer 3. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x */ getTypeID(): number; /** * Prepares the list of defines specific to the light type. * @param defines the list of defines * @param lightIndex defines the index of the light for the effect */ prepareLightSpecificDefines(defines: any, lightIndex: number): void; } } declare module BABYLON { /** * Base class of all the lights in Babylon. It groups all the generic information about lights. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased. */ abstract class Light extends Node { /** * Falloff Default: light is falling off following the material specification: * standard material is using standard falloff whereas pbr material can request special falloff per materials. */ static readonly FALLOFF_DEFAULT: number; /** * Falloff Physical: light is falling off following the inverse squared distance law. */ static readonly FALLOFF_PHYSICAL: number; /** * Falloff gltf: light is falling off as described in the gltf moving to PBR document * to enhance interoperability with other engines. */ static readonly FALLOFF_GLTF: number; /** * Falloff Standard: light is falling off like in the standard material * to enhance interoperability with other materials. */ static readonly FALLOFF_STANDARD: number; /** * If every light affecting the material is in this lightmapMode, * material.lightmapTexture adds or multiplies * (depends on material.useLightmapAsShadowmap) * after every other light calculations. */ static readonly LIGHTMAP_DEFAULT: number; /** * material.lightmapTexture as only diffuse lighting from this light * adds only specular lighting from this light * adds dynamic shadows */ static readonly LIGHTMAP_SPECULAR: number; /** * material.lightmapTexture as only lighting * no light calculation from this light * only adds dynamic shadows from this light */ static readonly LIGHTMAP_SHADOWSONLY: number; /** * Each light type uses the default quantity according to its type: * point/spot lights use luminous intensity * directional lights use illuminance */ static readonly INTENSITYMODE_AUTOMATIC: number; /** * lumen (lm) */ static readonly INTENSITYMODE_LUMINOUSPOWER: number; /** * candela (lm/sr) */ static readonly INTENSITYMODE_LUMINOUSINTENSITY: number; /** * lux (lm/m^2) */ static readonly INTENSITYMODE_ILLUMINANCE: number; /** * nit (cd/m^2) */ static readonly INTENSITYMODE_LUMINANCE: number; /** * Light type const id of the point light. */ static readonly LIGHTTYPEID_POINTLIGHT: number; /** * Light type const id of the directional light. */ static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number; /** * Light type const id of the spot light. */ static readonly LIGHTTYPEID_SPOTLIGHT: number; /** * Light type const id of the hemispheric light. */ static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number; /** * Diffuse gives the basic color to an object. */ diffuse: Color3; /** * Specular produces a highlight color on an object. * Note: This is note affecting PBR materials. */ specular: Color3; /** * Defines the falloff type for this light. This lets overrriding how punctual light are * falling off base on range or angle. * This can be set to any values in Light.FALLOFF_x. * * Note: This is only usefull for PBR Materials at the moment. This could be extended if required to * other types of materials. */ falloffType: number; /** * Strength of the light. * Note: By default it is define in the framework own unit. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in. */ intensity: number; private _range; protected _inverseSquaredRange: number; /** * Defines how far from the source the light is impacting in scene units. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff. */ /** * Defines how far from the source the light is impacting in scene units. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff. */ range: number; /** * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type * of light. */ private _photometricScale; private _intensityMode; /** * Gets the photometric scale used to interpret the intensity. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way. */ /** * Sets the photometric scale used to interpret the intensity. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way. */ intensityMode: number; private _radius; /** * Gets the light radius used by PBR Materials to simulate soft area lights. */ /** * sets the light radius used by PBR Materials to simulate soft area lights. */ radius: number; private _renderPriority; /** * Defines the rendering priority of the lights. It can help in case of fallback or number of lights * exceeding the number allowed of the materials. */ renderPriority: number; private _shadowEnabled; /** * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching * the current shadow generator. */ /** * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching * the current shadow generator. */ shadowEnabled: boolean; private _includedOnlyMeshes; /** * Gets the only meshes impacted by this light. */ /** * Sets the only meshes impacted by this light. */ includedOnlyMeshes: AbstractMesh[]; private _excludedMeshes; /** * Gets the meshes not impacted by this light. */ /** * Sets the meshes not impacted by this light. */ excludedMeshes: AbstractMesh[]; private _excludeWithLayerMask; /** * Gets the layer id use to find what meshes are not impacted by the light. * Inactive if 0 */ /** * Sets the layer id use to find what meshes are not impacted by the light. * Inactive if 0 */ excludeWithLayerMask: number; private _includeOnlyWithLayerMask; /** * Gets the layer id use to find what meshes are impacted by the light. * Inactive if 0 */ /** * Sets the layer id use to find what meshes are impacted by the light. * Inactive if 0 */ includeOnlyWithLayerMask: number; private _lightmapMode; /** * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x) */ /** * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x) */ lightmapMode: number; /** * Shadow generator associted to the light. * @hidden Internal use only. */ _shadowGenerator: Nullable; /** * @hidden Internal use only. */ _excludedMeshesIds: string[]; /** * @hidden Internal use only. */ _includedOnlyMeshesIds: string[]; /** * The current light unifom buffer. * @hidden Internal use only. */ _uniformBuffer: UniformBuffer; /** * Creates a Light object in the scene. * Documentation : http://doc.babylonjs.com/tutorials/lights * @param name The firendly name of the light * @param scene The scene the light belongs too */ constructor(name: string, scene: Scene); protected abstract _buildUniformLayout(): void; /** * Sets the passed Effect "effect" with the Light information. * @param effect The effect to update * @param lightIndex The index of the light in the effect to update * @returns The light */ abstract transferToEffect(effect: Effect, lightIndex: string): Light; /** * Returns the string "Light". * @returns the class name */ getClassName(): string; /** * Converts the light information to a readable string for debug purpose. * @param fullDetails Supports for multiple levels of logging within scene loading * @returns the human readable light info */ toString(fullDetails?: boolean): string; /** @hidden */ protected _syncParentEnabledState(): void; /** * Set the enabled state of this node. * @param value - the new enabled state */ setEnabled(value: boolean): void; /** * Returns the Light associated shadow generator if any. * @return the associated shadow generator. */ getShadowGenerator(): Nullable; /** * Returns a Vector3, the absolute light position in the World. * @returns the world space position of the light */ getAbsolutePosition(): Vector3; /** * Specifies if the light will affect the passed mesh. * @param mesh The mesh to test against the light * @return true the mesh is affected otherwise, false. */ canAffectMesh(mesh: AbstractMesh): boolean; /** * Sort function to order lights for rendering. * @param a First Light object to compare to second. * @param b Second Light object to compare first. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b. */ static CompareLightsPriority(a: Light, b: Light): number; /** * Releases resources associated with this node. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default) * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default) */ dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void; /** * Returns the light type ID (integer). * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x */ getTypeID(): number; /** * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode. * @returns the scaled intensity in intensity mode unit */ getScaledIntensity(): number; /** * Returns a new Light object, named "name", from the current one. * @param name The name of the cloned light * @returns the new created light */ clone(name: string): Nullable; /** * Serializes the current light into a Serialization object. * @returns the serialized object. */ serialize(): any; /** * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3. * This new light is named "name" and added to the passed scene. * @param type Type according to the types available in Light.LIGHTTYPEID_x * @param name The friendly name of the light * @param scene The scene the new light will belong to * @returns the constructor function */ static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>; /** * Parses the passed "parsedLight" and returns a new instanced Light from this parsing. * @param parsedLight The JSON representation of the light * @param scene The scene to create the parsed light in * @returns the created light after parsing */ static Parse(parsedLight: any, scene: Scene): Nullable; private _hookArrayForExcluded; private _hookArrayForIncludedOnly; private _resyncMeshes; /** * Forces the meshes to update their light related information in their rendering used effects * @hidden Internal Use Only */ _markMeshesAsLightDirty(): void; /** * Recomputes the cached photometric scale if needed. */ private _computePhotometricScale; /** * Returns the Photometric Scale according to the light type and intensity mode. */ private _getPhotometricScale; /** * Reorder the light in the scene according to their defined priority. * @hidden Internal Use Only */ _reorderLightsInScene(): void; /** * Prepares the list of defines specific to the light type. * @param defines the list of defines * @param lightIndex defines the index of the light for the effect */ abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void; } } declare module BABYLON { /** * A point light is a light defined by an unique point in world space. * The light is emitted in every direction from this point. * A good example of a point light is a standard light bulb. * Documentation: https://doc.babylonjs.com/babylon101/lights */ class PointLight extends ShadowLight { private _shadowAngle; /** * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback * This specifies what angle the shadow will use to be created. * * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps. */ /** * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback * This specifies what angle the shadow will use to be created. * * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps. */ shadowAngle: number; /** * Gets the direction if it has been set. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback */ /** * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback */ direction: Vector3; /** * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene. * A PointLight emits the light in every direction. * It can cast shadows. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it : * ```javascript * var pointLight = new BABYLON.PointLight("pl", camera.position, scene); * ``` * Documentation : http://doc.babylonjs.com/tutorials/lights * @param name The light friendly name * @param position The position of the point light in the scene * @param scene The scene the lights belongs to */ constructor(name: string, position: Vector3, scene: Scene); /** * Returns the string "PointLight" * @returns the class name */ getClassName(): string; /** * Returns the integer 0. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x */ getTypeID(): number; /** * Specifies wether or not the shadowmap should be a cube texture. * @returns true if the shadowmap needs to be a cube texture. */ needCube(): boolean; /** * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer). * @param faceIndex The index of the face we are computed the direction to generate shadow * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true */ getShadowDirection(faceIndex?: number): Vector3; /** * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings : * - fov = PI / 2 * - aspect ratio : 1.0 * - z-near and far equal to the active camera minZ and maxZ. * Returns the PointLight. */ protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array): void; protected _buildUniformLayout(): void; /** * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string). * @param effect The effect to update * @param lightIndex The index of the light in the effect to update * @returns The point light */ transferToEffect(effect: Effect, lightIndex: string): PointLight; /** * Prepares the list of defines specific to the light type. * @param defines the list of defines * @param lightIndex defines the index of the light for the effect */ prepareLightSpecificDefines(defines: any, lightIndex: number): void; } } declare module BABYLON { /** * Interface describing all the common properties and methods a shadow light needs to implement. * This helps both the shadow generator and materials to genrate the corresponding shadow maps * as well as binding the different shadow properties to the effects. */ interface IShadowLight extends Light { /** * The light id in the scene (used in scene.findLighById for instance) */ id: string; /** * The position the shdow will be casted from. */ position: Vector3; /** * In 2d mode (needCube being false), the direction used to cast the shadow. */ direction: Vector3; /** * The transformed position. Position of the light in world space taking parenting in account. */ transformedPosition: Vector3; /** * The transformed direction. Direction of the light in world space taking parenting in account. */ transformedDirection: Vector3; /** * The friendly name of the light in the scene. */ name: string; /** * Defines the shadow projection clipping minimum z value. */ shadowMinZ: number; /** * Defines the shadow projection clipping maximum z value. */ shadowMaxZ: number; /** * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light * @returns true if the information has been computed, false if it does not need to (no parenting) */ computeTransformedInformation(): boolean; /** * Gets the scene the light belongs to. * @returns The scene */ getScene(): Scene; /** * Callback defining a custom Projection Matrix Builder. * This can be used to override the default projection matrix computation. */ customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array, result: Matrix) => void; /** * Sets the shadow projection matrix in parameter to the generated projection matrix. * @param matrix The materix to updated with the projection information * @param viewMatrix The transform matrix of the light * @param renderList The list of mesh to render in the map * @returns The current light */ setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array): IShadowLight; /** * Gets the current depth scale used in ESM. * @returns The scale */ getDepthScale(): number; /** * Returns whether or not the shadow generation require a cube texture or a 2d texture. * @returns true if a cube texture needs to be use */ needCube(): boolean; /** * Detects if the projection matrix requires to be recomputed this frame. * @returns true if it requires to be recomputed otherwise, false. */ needProjectionMatrixCompute(): boolean; /** * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed. */ forceProjectionMatrixCompute(): void; /** * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed. * @param faceIndex The index of the face we are computed the direction to generate shadow * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true */ getShadowDirection(faceIndex?: number): Vector3; /** * Gets the minZ used for shadow according to both the scene and the light. * @param activeCamera The camera we are returning the min for * @returns the depth min z */ getDepthMinZ(activeCamera: Camera): number; /** * Gets the maxZ used for shadow according to both the scene and the light. * @param activeCamera The camera we are returning the max for * @returns the depth max z */ getDepthMaxZ(activeCamera: Camera): number; } /** * Base implementation IShadowLight * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern. */ abstract class ShadowLight extends Light implements IShadowLight { protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array): void; protected _position: Vector3; protected _setPosition(value: Vector3): void; /** * Sets the position the shadow will be casted from. Also use as the light position for both * point and spot lights. */ /** * Sets the position the shadow will be casted from. Also use as the light position for both * point and spot lights. */ position: Vector3; protected _direction: Vector3; protected _setDirection(value: Vector3): void; /** * In 2d mode (needCube being false), gets the direction used to cast the shadow. * Also use as the light direction on spot and directional lights. */ /** * In 2d mode (needCube being false), sets the direction used to cast the shadow. * Also use as the light direction on spot and directional lights. */ direction: Vector3; private _shadowMinZ; /** * Gets the shadow projection clipping minimum z value. */ /** * Sets the shadow projection clipping minimum z value. */ shadowMinZ: number; private _shadowMaxZ; /** * Sets the shadow projection clipping maximum z value. */ /** * Gets the shadow projection clipping maximum z value. */ shadowMaxZ: number; /** * Callback defining a custom Projection Matrix Builder. * This can be used to override the default projection matrix computation. */ customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array, result: Matrix) => void; /** * The transformed position. Position of the light in world space taking parenting in account. */ transformedPosition: Vector3; /** * The transformed direction. Direction of the light in world space taking parenting in account. */ transformedDirection: Vector3; private _needProjectionMatrixCompute; /** * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light * @returns true if the information has been computed, false if it does not need to (no parenting) */ computeTransformedInformation(): boolean; /** * Return the depth scale used for the shadow map. * @returns the depth scale. */ getDepthScale(): number; /** * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed. * @param faceIndex The index of the face we are computed the direction to generate shadow * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true */ getShadowDirection(faceIndex?: number): Vector3; /** * Returns the ShadowLight absolute position in the World. * @returns the position vector in world space */ getAbsolutePosition(): Vector3; /** * Sets the ShadowLight direction toward the passed target. * @param target The point tot target in local space * @returns the updated ShadowLight direction */ setDirectionToTarget(target: Vector3): Vector3; /** * Returns the light rotation in euler definition. * @returns the x y z rotation in local space. */ getRotation(): Vector3; /** * Returns whether or not the shadow generation require a cube texture or a 2d texture. * @returns true if a cube texture needs to be use */ needCube(): boolean; /** * Detects if the projection matrix requires to be recomputed this frame. * @returns true if it requires to be recomputed otherwise, false. */ needProjectionMatrixCompute(): boolean; /** * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed. */ forceProjectionMatrixCompute(): void; /** @hidden */ _initCache(): void; /** @hidden */ _isSynchronized(): boolean; /** * Computes the world matrix of the node * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch * @returns the world matrix */ computeWorldMatrix(force?: boolean): Matrix; /** * Gets the minZ used for shadow according to both the scene and the light. * @param activeCamera The camera we are returning the min for * @returns the depth min z */ getDepthMinZ(activeCamera: Camera): number; /** * Gets the maxZ used for shadow according to both the scene and the light. * @param activeCamera The camera we are returning the max for * @returns the depth max z */ getDepthMaxZ(activeCamera: Camera): number; /** * Sets the shadow projection matrix in parameter to the generated projection matrix. * @param matrix The materix to updated with the projection information * @param viewMatrix The transform matrix of the light * @param renderList The list of mesh to render in the map * @returns The current light */ setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array): IShadowLight; } } declare module BABYLON { /** * A spot light is defined by a position, a direction, an angle, and an exponent. * These values define a cone of light starting from the position, emitting toward the direction. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam, * and the exponent defines the speed of the decay of the light with distance (reach). * Documentation: https://doc.babylonjs.com/babylon101/lights */ class SpotLight extends ShadowLight { private _angle; private _innerAngle; private _cosHalfAngle; private _lightAngleScale; private _lightAngleOffset; /** * Gets the cone angle of the spot light in Radians. */ /** * Sets the cone angle of the spot light in Radians. */ angle: number; /** * Only used in gltf falloff mode, this defines the angle where * the directional falloff will start before cutting at angle which could be seen * as outer angle. */ /** * Only used in gltf falloff mode, this defines the angle where * the directional falloff will start before cutting at angle which could be seen * as outer angle. */ innerAngle: number; private _shadowAngleScale; /** * Allows scaling the angle of the light for shadow generation only. */ /** * Allows scaling the angle of the light for shadow generation only. */ shadowAngleScale: number; /** * The light decay speed with the distance from the emission spot. */ exponent: number; private _projectionTextureMatrix; /** * Allows reading the projecton texture */ readonly projectionTextureMatrix: Matrix; protected _projectionTextureLightNear: number; /** * Gets the near clip of the Spotlight for texture projection. */ /** * Sets the near clip of the Spotlight for texture projection. */ projectionTextureLightNear: number; protected _projectionTextureLightFar: number; /** * Gets the far clip of the Spotlight for texture projection. */ /** * Sets the far clip of the Spotlight for texture projection. */ projectionTextureLightFar: number; protected _projectionTextureUpDirection: Vector3; /** * Gets the Up vector of the Spotlight for texture projection. */ /** * Sets the Up vector of the Spotlight for texture projection. */ projectionTextureUpDirection: Vector3; private _projectionTexture; /** * Gets the projection texture of the light. */ /** * Sets the projection texture of the light. */ projectionTexture: Nullable; private _projectionTextureViewLightDirty; private _projectionTextureProjectionLightDirty; private _projectionTextureDirty; private _projectionTextureViewTargetVector; private _projectionTextureViewLightMatrix; private _projectionTextureProjectionLightMatrix; private _projectionTextureScalingMatrix; /** * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone. * It can cast shadows. * Documentation : http://doc.babylonjs.com/tutorials/lights * @param name The light friendly name * @param position The position of the spot light in the scene * @param direction The direction of the light in the scene * @param angle The cone angle of the light in Radians * @param exponent The light decay speed with the distance from the emission spot * @param scene The scene the lights belongs to */ constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene); /** * Returns the string "SpotLight". * @returns the class name */ getClassName(): string; /** * Returns the integer 2. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x */ getTypeID(): number; /** * Overrides the direction setter to recompute the projection texture view light Matrix. */ protected _setDirection(value: Vector3): void; /** * Overrides the position setter to recompute the projection texture view light Matrix. */ protected _setPosition(value: Vector3): void; /** * Sets the passed matrix "matrix" as perspective projection matrix for the shadows and the passed view matrix with the fov equal to the SpotLight angle and and aspect ratio of 1.0. * Returns the SpotLight. */ protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array): void; protected _computeProjectionTextureViewLightMatrix(): void; protected _computeProjectionTextureProjectionLightMatrix(): void; /** * Main function for light texture projection matrix computing. */ protected _computeProjectionTextureMatrix(): void; protected _buildUniformLayout(): void; private _computeAngleValues; /** * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction. * @param effect The effect to update * @param lightIndex The index of the light in the effect to update * @returns The spot light */ transferToEffect(effect: Effect, lightIndex: string): SpotLight; /** * Disposes the light and the associated resources. */ dispose(): void; /** * Prepares the list of defines specific to the light type. * @param defines the list of defines * @param lightIndex defines the index of the light for the effect */ prepareLightSpecificDefines(defines: any, lightIndex: number): void; } } declare module BABYLON { /** * Interface used to present a loading screen while loading a scene * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen */ interface ILoadingScreen { /** * Function called to display the loading screen */ displayLoadingUI: () => void; /** * Function called to hide the loading screen */ hideLoadingUI: () => void; /** * Gets or sets the color to use for the background */ loadingUIBackgroundColor: string; /** * Gets or sets the text to display while loading */ loadingUIText: string; } /** * Class used for the default loading screen * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen */ class DefaultLoadingScreen implements ILoadingScreen { private _renderingCanvas; private _loadingText; private _loadingDivBackgroundColor; private _loadingDiv; private _loadingTextDiv; /** * Creates a new default loading screen * @param _renderingCanvas defines the canvas used to render the scene * @param _loadingText defines the default text to display * @param _loadingDivBackgroundColor defines the default background color */ constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string); /** * Function called to display the loading screen */ displayLoadingUI(): void; /** * Function called to hide the loading screen */ hideLoadingUI(): void; /** * Gets or sets the text to display while loading */ loadingUIText: string; /** * Gets or sets the color to use for the background */ loadingUIBackgroundColor: string; private _resizeLoadingUI; } } declare module BABYLON { /** * Class used to represent data loading progression */ class SceneLoaderProgressEvent { /** defines if data length to load can be evaluated */ readonly lengthComputable: boolean; /** defines the loaded data length */ readonly loaded: number; /** defines the data length to load */ readonly total: number; /** * Create a new progress event * @param lengthComputable defines if data length to load can be evaluated * @param loaded defines the loaded data length * @param total defines the data length to load */ constructor( /** defines if data length to load can be evaluated */ lengthComputable: boolean, /** defines the loaded data length */ loaded: number, /** defines the data length to load */ total: number); /** * Creates a new SceneLoaderProgressEvent from a ProgressEvent * @param event defines the source event * @returns a new SceneLoaderProgressEvent */ static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent; } /** * Interface used by SceneLoader plugins to define supported file extensions */ interface ISceneLoaderPluginExtensions { /** * Defines the list of supported extensions */ [extension: string]: { isBinary: boolean; }; } /** * Interface used by SceneLoader plugin factory */ interface ISceneLoaderPluginFactory { /** * Defines the name of the factory */ name: string; /** * Function called to create a new plugin * @return the new plugin */ createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync; /** * Boolean indicating if the plugin can direct load specific data */ canDirectLoad?: (data: string) => boolean; } /** * Interface used to define a SceneLoader plugin */ interface ISceneLoaderPlugin { /** * The friendly name of this plugin. */ name: string; /** * The file extensions supported by this plugin. */ extensions: string | ISceneLoaderPluginExtensions; /** * Import meshes into a scene. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported * @param scene The scene to import into * @param data The data to import * @param rootUrl The root url for scene and resources * @param meshes The meshes array to import into * @param particleSystems The particle systems array to import into * @param skeletons The skeletons array to import into * @param onError The callback when import fails * @returns True if successful or false otherwise */ importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean; /** * Load into a scene. * @param scene The scene to load into * @param data The data to import * @param rootUrl The root url for scene and resources * @param onError The callback when import fails * @returns true if successful or false otherwise */ load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean; /** * The callback that returns true if the data can be directly loaded. */ canDirectLoad?: (data: string) => boolean; /** * The callback that allows custom handling of the root url based on the response url. */ rewriteRootURL?: (rootUrl: string, responseURL?: string) => string; /** * Load into an asset container. * @param scene The scene to load into * @param data The data to import * @param rootUrl The root url for scene and resources * @param onError The callback when import fails * @returns The loaded asset container */ loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer; } /** * Interface used to define an async SceneLoader plugin */ interface ISceneLoaderPluginAsync { /** * The friendly name of this plugin. */ name: string; /** * The file extensions supported by this plugin. */ extensions: string | ISceneLoaderPluginExtensions; /** * Import meshes into a scene. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported * @param scene The scene to import into * @param data The data to import * @param rootUrl The root url for scene and resources * @param onProgress The callback when the load progresses * @param fileName Defines the name of the file to load * @returns The loaded meshes, particle systems, skeletons, and animation groups */ importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{ meshes: AbstractMesh[]; particleSystems: IParticleSystem[]; skeletons: Skeleton[]; animationGroups: AnimationGroup[]; }>; /** * Load into a scene. * @param scene The scene to load into * @param data The data to import * @param rootUrl The root url for scene and resources * @param onProgress The callback when the load progresses * @param fileName Defines the name of the file to load * @returns Nothing */ loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise; /** * The callback that returns true if the data can be directly loaded. */ canDirectLoad?: (data: string) => boolean; /** * The callback that allows custom handling of the root url based on the response url. */ rewriteRootURL?: (rootUrl: string, responseURL?: string) => string; /** * Load into an asset container. * @param scene The scene to load into * @param data The data to import * @param rootUrl The root url for scene and resources * @param onProgress The callback when the load progresses * @param fileName Defines the name of the file to load * @returns The loaded asset container */ loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise; } /** * Class used to load scene from various file formats using registered plugins * @see http://doc.babylonjs.com/how_to/load_from_any_file_type */ class SceneLoader { private static _ForceFullSceneLoadingForIncremental; private static _ShowLoadingScreen; private static _CleanBoneMatrixWeights; /** * No logging while loading */ static readonly NO_LOGGING: number; /** * Minimal logging while loading */ static readonly MINIMAL_LOGGING: number; /** * Summary logging while loading */ static readonly SUMMARY_LOGGING: number; /** * Detailled logging while loading */ static readonly DETAILED_LOGGING: number; private static _loggingLevel; /** * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data */ static ForceFullSceneLoadingForIncremental: boolean; /** * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene */ static ShowLoadingScreen: boolean; /** * Defines the current logging level (while loading the scene) * @ignorenaming */ static loggingLevel: number; /** * Gets or set a boolean indicating if matrix weights must be cleaned upon loading */ static CleanBoneMatrixWeights: boolean; /** * Event raised when a plugin is used to load a scene */ static OnPluginActivatedObservable: Observable; private static _registeredPlugins; private static _getDefaultPlugin; private static _getPluginForExtension; private static _getPluginForDirectLoad; private static _getPluginForFilename; private static _getDirectLoad; private static _loadData; private static _getFileInfo; /** * Gets a plugin that can load the given extension * @param extension defines the extension to load * @returns a plugin or null if none works */ static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory; /** * Gets a boolean indicating that the given extension can be loaded * @param extension defines the extension to load * @returns true if the extension is supported */ static IsPluginForExtensionAvailable(extension: string): boolean; /** * Adds a new plugin to the list of registered plugins * @param plugin defines the plugin to add */ static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void; /** * Import meshes into a scene * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb) * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string) * @param scene the instance of BABYLON.Scene to append to * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds * @param onProgress a callback with a progress event for each file being loaded * @param onError a callback with the scene, a message, and possibly an exception when import fails * @param pluginExtension the extension used to determine the plugin * @returns The loaded plugin */ static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string, scene?: Nullable, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[]) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable): Nullable; /** * Import meshes into a scene * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb) * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string) * @param scene the instance of BABYLON.Scene to append to * @param onProgress a callback with a progress event for each file being loaded * @param pluginExtension the extension used to determine the plugin * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups */ static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string, scene?: Nullable, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable): Promise<{ meshes: AbstractMesh[]; particleSystems: IParticleSystem[]; skeletons: Skeleton[]; animationGroups: AnimationGroup[]; }>; /** * Load a scene * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb) * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string) * @param engine is the instance of BABYLON.Engine to use to create the scene * @param onSuccess a callback with the scene when import succeeds * @param onProgress a callback with a progress event for each file being loaded * @param onError a callback with the scene, a message, and possibly an exception when import fails * @param pluginExtension the extension used to determine the plugin * @returns The loaded plugin */ static Load(rootUrl: string, sceneFilename: string, engine: Engine, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable): Nullable; /** * Load a scene * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb) * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string) * @param engine is the instance of BABYLON.Engine to use to create the scene * @param onProgress a callback with a progress event for each file being loaded * @param pluginExtension the extension used to determine the plugin * @returns The loaded scene */ static LoadAsync(rootUrl: string, sceneFilename: string, engine: Engine, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable): Promise; /** * Append a scene * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb) * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string) * @param scene is the instance of BABYLON.Scene to append to * @param onSuccess a callback with the scene when import succeeds * @param onProgress a callback with a progress event for each file being loaded * @param onError a callback with the scene, a message, and possibly an exception when import fails * @param pluginExtension the extension used to determine the plugin * @returns The loaded plugin */ static Append(rootUrl: string, sceneFilename?: string, scene?: Nullable, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable): Nullable; /** * Append a scene * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb) * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string) * @param scene is the instance of BABYLON.Scene to append to * @param onProgress a callback with a progress event for each file being loaded * @param pluginExtension the extension used to determine the plugin * @returns The given scene */ static AppendAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable): Promise; /** * Load a scene into an asset container * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb) * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string) * @param scene is the instance of BABYLON.Scene to append to (default: last created scene) * @param onSuccess a callback with the scene when import succeeds * @param onProgress a callback with a progress event for each file being loaded * @param onError a callback with the scene, a message, and possibly an exception when import fails * @param pluginExtension the extension used to determine the plugin * @returns The loaded plugin */ static LoadAssetContainer(rootUrl: string, sceneFilename?: string, scene?: Nullable, onSuccess?: Nullable<(assets: AssetContainer) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable): Nullable; /** * Load a scene into an asset container * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb) * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string) * @param scene is the instance of BABYLON.Scene to append to * @param onProgress a callback with a progress event for each file being loaded * @param pluginExtension the extension used to determine the plugin * @returns The loaded asset container */ static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable): Promise; } } declare module BABYLON { /** * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT). * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image; * corresponding to low luminance, medium luminance, and high luminance areas respectively. */ class ColorCurves { private _dirty; private _tempColor; private _globalCurve; private _highlightsCurve; private _midtonesCurve; private _shadowsCurve; private _positiveCurve; private _negativeCurve; private _globalHue; private _globalDensity; private _globalSaturation; private _globalExposure; /** * Gets the global Hue value. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange). */ /** * Sets the global Hue value. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange). */ globalHue: number; /** * Gets the global Density value. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect. * Values less than zero provide a filter of opposite hue. */ /** * Sets the global Density value. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect. * Values less than zero provide a filter of opposite hue. */ globalDensity: number; /** * Gets the global Saturation value. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation. */ /** * Sets the global Saturation value. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation. */ globalSaturation: number; /** * Gets the global Exposure value. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure. */ /** * Sets the global Exposure value. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure. */ globalExposure: number; private _highlightsHue; private _highlightsDensity; private _highlightsSaturation; private _highlightsExposure; /** * Gets the highlights Hue value. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange). */ /** * Sets the highlights Hue value. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange). */ highlightsHue: number; /** * Gets the highlights Density value. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect. * Values less than zero provide a filter of opposite hue. */ /** * Sets the highlights Density value. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect. * Values less than zero provide a filter of opposite hue. */ highlightsDensity: number; /** * Gets the highlights Saturation value. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation. */ /** * Sets the highlights Saturation value. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation. */ highlightsSaturation: number; /** * Gets the highlights Exposure value. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure. */ /** * Sets the highlights Exposure value. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure. */ highlightsExposure: number; private _midtonesHue; private _midtonesDensity; private _midtonesSaturation; private _midtonesExposure; /** * Gets the midtones Hue value. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange). */ /** * Sets the midtones Hue value. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange). */ midtonesHue: number; /** * Gets the midtones Density value. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect. * Values less than zero provide a filter of opposite hue. */ /** * Sets the midtones Density value. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect. * Values less than zero provide a filter of opposite hue. */ midtonesDensity: number; /** * Gets the midtones Saturation value. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation. */ /** * Sets the midtones Saturation value. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation. */ midtonesSaturation: number; /** * Gets the midtones Exposure value. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure. */ /** * Sets the midtones Exposure value. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure. */ midtonesExposure: number; private _shadowsHue; private _shadowsDensity; private _shadowsSaturation; private _shadowsExposure; /** * Gets the shadows Hue value. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange). */ /** * Sets the shadows Hue value. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange). */ shadowsHue: number; /** * Gets the shadows Density value. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect. * Values less than zero provide a filter of opposite hue. */ /** * Sets the shadows Density value. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect. * Values less than zero provide a filter of opposite hue. */ shadowsDensity: number; /** * Gets the shadows Saturation value. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation. */ /** * Sets the shadows Saturation value. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation. */ shadowsSaturation: number; /** * Gets the shadows Exposure value. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure. */ /** * Sets the shadows Exposure value. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure. */ shadowsExposure: number; /** * Returns the class name * @returns The class name */ getClassName(): string; /** * Binds the color curves to the shader. * @param colorCurves The color curve to bind * @param effect The effect to bind to * @param positiveUniform The positive uniform shader parameter * @param neutralUniform The neutral uniform shader parameter * @param negativeUniform The negative uniform shader parameter */ static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void; /** * Prepare the list of uniforms associated with the ColorCurves effects. * @param uniformsList The list of uniforms used in the effect */ static PrepareUniforms(uniformsList: string[]): void; /** * Returns color grading data based on a hue, density, saturation and exposure value. * @param filterHue The hue of the color filter. * @param filterDensity The density of the color filter. * @param saturation The saturation. * @param exposure The exposure. * @param result The result data container. */ private getColorGradingDataToRef; /** * Takes an input slider value and returns an adjusted value that provides extra control near the centre. * @param value The input slider value in range [-100,100]. * @returns Adjusted value. */ private static applyColorGradingSliderNonlinear; /** * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV). * @param hue The hue (H) input. * @param saturation The saturation (S) input. * @param brightness The brightness (B) input. * @result An RGBA color represented as Vector4. */ private static fromHSBToRef; /** * Returns a value clamped between min and max * @param value The value to clamp * @param min The minimum of value * @param max The maximum of value * @returns The clamped value. */ private static clamp; /** * Clones the current color curve instance. * @return The cloned curves */ clone(): ColorCurves; /** * Serializes the current color curve instance to a json representation. * @return a JSON representation */ serialize(): any; /** * Parses the color curve from a json representation. * @param source the JSON source to parse * @return The parsed curves */ static Parse(source: any): ColorCurves; } } declare module BABYLON { /** * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog) */ class EffectFallbacks { private _defines; private _currentRank; private _maxRank; private _mesh; /** * Removes the fallback from the bound mesh. */ unBindMesh(): void; /** * Adds a fallback on the specified property. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first) * @param define The name of the define in the shader */ addFallback(rank: number, define: string): void; /** * Sets the mesh to use CPU skinning when needing to fallback. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first) * @param mesh The mesh to use the fallbacks. */ addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void; /** * Checks to see if more fallbacks are still availible. */ readonly isMoreFallbacks: boolean; /** * Removes the defines that shoould be removed when falling back. * @param currentDefines defines the current define statements for the shader. * @param effect defines the current effect we try to compile * @returns The resulting defines with defines of the current rank removed. */ reduce(currentDefines: string, effect: Effect): string; } /** * Options to be used when creating an effect. */ class EffectCreationOptions { /** * Atrributes that will be used in the shader. */ attributes: string[]; /** * Uniform varible names that will be set in the shader. */ uniformsNames: string[]; /** * Uniform buffer varible names that will be set in the shader. */ uniformBuffersNames: string[]; /** * Sampler texture variable names that will be set in the shader. */ samplers: string[]; /** * Define statements that will be set in the shader. */ defines: any; /** * Possible fallbacks for this effect to improve performance when needed. */ fallbacks: Nullable; /** * Callback that will be called when the shader is compiled. */ onCompiled: Nullable<(effect: Effect) => void>; /** * Callback that will be called if an error occurs during shader compilation. */ onError: Nullable<(effect: Effect, errors: string) => void>; /** * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10}) */ indexParameters: any; /** * Max number of lights that can be used in the shader. */ maxSimultaneousLights: number; /** * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings */ transformFeedbackVaryings: Nullable; } /** * Effect containing vertex and fragment shader that can be executed on an object. */ class Effect { /** * Name of the effect. */ name: any; /** * String container all the define statements that should be set on the shader. */ defines: string; /** * Callback that will be called when the shader is compiled. */ onCompiled: Nullable<(effect: Effect) => void>; /** * Callback that will be called if an error occurs during shader compilation. */ onError: Nullable<(effect: Effect, errors: string) => void>; /** * Callback that will be called when effect is bound. */ onBind: Nullable<(effect: Effect) => void>; /** * Unique ID of the effect. */ uniqueId: number; /** * Observable that will be called when the shader is compiled. */ onCompileObservable: Observable; /** * Observable that will be called if an error occurs during shader compilation. */ onErrorObservable: Observable; /** @hidden */ _onBindObservable: Nullable>; /** * Observable that will be called when effect is bound. */ readonly onBindObservable: Observable; /** @hidden */ _bonesComputationForcedToCPU: boolean; private static _uniqueIdSeed; private _engine; private _uniformBuffersNames; private _uniformsNames; private _samplers; private _isReady; private _compilationError; private _attributesNames; private _attributes; private _uniforms; /** * Key for the effect. * @hidden */ _key: string; private _indexParameters; private _fallbacks; private _vertexSourceCode; private _fragmentSourceCode; private _vertexSourceCodeOverride; private _fragmentSourceCodeOverride; private _transformFeedbackVaryings; /** * Compiled shader to webGL program. * @hidden */ _program: WebGLProgram; private _valueCache; private static _baseCache; /** * Instantiates an effect. * An effect can be used to create/manage/execute vertex and fragment shaders. * @param baseName Name of the effect. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect. * @param samplers List of sampler variables that will be passed to the shader. * @param engine Engine to be used to render the effect * @param defines Define statements to be added to the shader. * @param fallbacks Possible fallbacks for this effect to improve performance when needed. * @param onCompiled Callback that will be called when the shader is compiled. * @param onError Callback that will be called if an error occurs during shader compilation. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10}) */ constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable, engine?: Engine, defines?: Nullable, fallbacks?: Nullable, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any); /** * Unique key for this effect */ readonly key: string; /** * If the effect has been compiled and prepared. * @returns if the effect is compiled and prepared. */ isReady(): boolean; /** * The engine the effect was initialized with. * @returns the engine. */ getEngine(): Engine; /** * The compiled webGL program for the effect * @returns the webGL program. */ getProgram(): WebGLProgram; /** * The set of names of attribute variables for the shader. * @returns An array of attribute names. */ getAttributesNames(): string[]; /** * Returns the attribute at the given index. * @param index The index of the attribute. * @returns The location of the attribute. */ getAttributeLocation(index: number): number; /** * Returns the attribute based on the name of the variable. * @param name of the attribute to look up. * @returns the attribute location. */ getAttributeLocationByName(name: string): number; /** * The number of attributes. * @returns the numnber of attributes. */ getAttributesCount(): number; /** * Gets the index of a uniform variable. * @param uniformName of the uniform to look up. * @returns the index. */ getUniformIndex(uniformName: string): number; /** * Returns the attribute based on the name of the variable. * @param uniformName of the uniform to look up. * @returns the location of the uniform. */ getUniform(uniformName: string): Nullable; /** * Returns an array of sampler variable names * @returns The array of sampler variable neames. */ getSamplers(): string[]; /** * The error from the last compilation. * @returns the error string. */ getCompilationError(): string; /** * Adds a callback to the onCompiled observable and call the callback imediatly if already ready. * @param func The callback to be used. */ executeWhenCompiled(func: (effect: Effect) => void): void; /** @hidden */ _loadVertexShader(vertex: any, callback: (data: any) => void): void; /** @hidden */ _loadFragmentShader(fragment: any, callback: (data: any) => void): void; /** @hidden */ _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void; private _processShaderConversion; private _processIncludes; private _processPrecision; /** * Recompiles the webGL program * @param vertexSourceCode The source code for the vertex shader. * @param fragmentSourceCode The source code for the fragment shader. * @param onCompiled Callback called when completed. * @param onError Callback called on error. * @hidden */ _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void; /** * Gets the uniform locations of the the specified variable names * @param names THe names of the variables to lookup. * @returns Array of locations in the same order as variable names. */ getSpecificUniformLocations(names: string[]): Nullable[]; /** * Prepares the effect * @hidden */ _prepareEffect(): void; /** * Checks if the effect is supported. (Must be called after compilation) */ readonly isSupported: boolean; /** * Binds a texture to the engine to be used as output of the shader. * @param channel Name of the output variable. * @param texture Texture to bind. * @hidden */ _bindTexture(channel: string, texture: InternalTexture): void; /** * Sets a texture on the engine to be used in the shader. * @param channel Name of the sampler variable. * @param texture Texture to set. */ setTexture(channel: string, texture: Nullable): void; /** * Sets a depth stencil texture from a render target on the engine to be used in the shader. * @param channel Name of the sampler variable. * @param texture Texture to set. */ setDepthStencilTexture(channel: string, texture: Nullable): void; /** * Sets an array of textures on the engine to be used in the shader. * @param channel Name of the variable. * @param textures Textures to set. */ setTextureArray(channel: string, textures: BaseTexture[]): void; /** * Sets a texture to be the input of the specified post process. (To use the output, pass in the next post process in the pipeline) * @param channel Name of the sampler variable. * @param postProcess Post process to get the input texture from. */ setTextureFromPostProcess(channel: string, postProcess: Nullable): void; /** * (Warning! setTextureFromPostProcessOutput may be desired instead) * Sets the input texture of the passed in post process to be input of this effect. (To use the output of the passed in post process use setTextureFromPostProcessOutput) * @param channel Name of the sampler variable. * @param postProcess Post process to get the output texture from. */ setTextureFromPostProcessOutput(channel: string, postProcess: Nullable): void; /** @hidden */ _cacheMatrix(uniformName: string, matrix: Matrix): boolean; /** @hidden */ _cacheFloat2(uniformName: string, x: number, y: number): boolean; /** @hidden */ _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean; /** @hidden */ _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean; /** * Binds a buffer to a uniform. * @param buffer Buffer to bind. * @param name Name of the uniform variable to bind to. */ bindUniformBuffer(buffer: WebGLBuffer, name: string): void; /** * Binds block to a uniform. * @param blockName Name of the block to bind. * @param index Index to bind. */ bindUniformBlock(blockName: string, index: number): void; /** * Sets an interger value on a uniform variable. * @param uniformName Name of the variable. * @param value Value to be set. * @returns this effect. */ setInt(uniformName: string, value: number): Effect; /** * Sets an int array on a uniform variable. * @param uniformName Name of the variable. * @param array array to be set. * @returns this effect. */ setIntArray(uniformName: string, array: Int32Array): Effect; /** * Sets an int array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader) * @param uniformName Name of the variable. * @param array array to be set. * @returns this effect. */ setIntArray2(uniformName: string, array: Int32Array): Effect; /** * Sets an int array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader) * @param uniformName Name of the variable. * @param array array to be set. * @returns this effect. */ setIntArray3(uniformName: string, array: Int32Array): Effect; /** * Sets an int array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader) * @param uniformName Name of the variable. * @param array array to be set. * @returns this effect. */ setIntArray4(uniformName: string, array: Int32Array): Effect; /** * Sets an float array on a uniform variable. * @param uniformName Name of the variable. * @param array array to be set. * @returns this effect. */ setFloatArray(uniformName: string, array: Float32Array): Effect; /** * Sets an float array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader) * @param uniformName Name of the variable. * @param array array to be set. * @returns this effect. */ setFloatArray2(uniformName: string, array: Float32Array): Effect; /** * Sets an float array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader) * @param uniformName Name of the variable. * @param array array to be set. * @returns this effect. */ setFloatArray3(uniformName: string, array: Float32Array): Effect; /** * Sets an float array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader) * @param uniformName Name of the variable. * @param array array to be set. * @returns this effect. */ setFloatArray4(uniformName: string, array: Float32Array): Effect; /** * Sets an array on a uniform variable. * @param uniformName Name of the variable. * @param array array to be set. * @returns this effect. */ setArray(uniformName: string, array: number[]): Effect; /** * Sets an array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader) * @param uniformName Name of the variable. * @param array array to be set. * @returns this effect. */ setArray2(uniformName: string, array: number[]): Effect; /** * Sets an array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader) * @param uniformName Name of the variable. * @param array array to be set. * @returns this effect. */ setArray3(uniformName: string, array: number[]): Effect; /** * Sets an array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader) * @param uniformName Name of the variable. * @param array array to be set. * @returns this effect. */ setArray4(uniformName: string, array: number[]): Effect; /** * Sets matrices on a uniform variable. * @param uniformName Name of the variable. * @param matrices matrices to be set. * @returns this effect. */ setMatrices(uniformName: string, matrices: Float32Array): Effect; /** * Sets matrix on a uniform variable. * @param uniformName Name of the variable. * @param matrix matrix to be set. * @returns this effect. */ setMatrix(uniformName: string, matrix: Matrix): Effect; /** * Sets a 3x3 matrix on a uniform variable. (Speicified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix) * @param uniformName Name of the variable. * @param matrix matrix to be set. * @returns this effect. */ setMatrix3x3(uniformName: string, matrix: Float32Array): Effect; /** * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix) * @param uniformName Name of the variable. * @param matrix matrix to be set. * @returns this effect. */ setMatrix2x2(uniformName: string, matrix: Float32Array): Effect; /** * Sets a float on a uniform variable. * @param uniformName Name of the variable. * @param value value to be set. * @returns this effect. */ setFloat(uniformName: string, value: number): Effect; /** * Sets a boolean on a uniform variable. * @param uniformName Name of the variable. * @param bool value to be set. * @returns this effect. */ setBool(uniformName: string, bool: boolean): Effect; /** * Sets a Vector2 on a uniform variable. * @param uniformName Name of the variable. * @param vector2 vector2 to be set. * @returns this effect. */ setVector2(uniformName: string, vector2: Vector2): Effect; /** * Sets a float2 on a uniform variable. * @param uniformName Name of the variable. * @param x First float in float2. * @param y Second float in float2. * @returns this effect. */ setFloat2(uniformName: string, x: number, y: number): Effect; /** * Sets a Vector3 on a uniform variable. * @param uniformName Name of the variable. * @param vector3 Value to be set. * @returns this effect. */ setVector3(uniformName: string, vector3: Vector3): Effect; /** * Sets a float3 on a uniform variable. * @param uniformName Name of the variable. * @param x First float in float3. * @param y Second float in float3. * @param z Third float in float3. * @returns this effect. */ setFloat3(uniformName: string, x: number, y: number, z: number): Effect; /** * Sets a Vector4 on a uniform variable. * @param uniformName Name of the variable. * @param vector4 Value to be set. * @returns this effect. */ setVector4(uniformName: string, vector4: Vector4): Effect; /** * Sets a float4 on a uniform variable. * @param uniformName Name of the variable. * @param x First float in float4. * @param y Second float in float4. * @param z Third float in float4. * @param w Fourth float in float4. * @returns this effect. */ setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect; /** * Sets a Color3 on a uniform variable. * @param uniformName Name of the variable. * @param color3 Value to be set. * @returns this effect. */ setColor3(uniformName: string, color3: Color3): Effect; /** * Sets a Color4 on a uniform variable. * @param uniformName Name of the variable. * @param color3 Value to be set. * @param alpha Alpha value to be set. * @returns this effect. */ setColor4(uniformName: string, color3: Color3, alpha: number): Effect; /** * Sets a Color4 on a uniform variable * @param uniformName defines the name of the variable * @param color4 defines the value to be set * @returns this effect. */ setDirectColor4(uniformName: string, color4: Color4): Effect; /** * This function will add a new shader to the shader store * @param name the name of the shader * @param pixelShader optional pixel shader content * @param vertexShader optional vertex shader content */ static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void; /** * Store of each shader (The can be looked up using effect.key) */ static ShadersStore: { [key: string]: string; }; /** * Store of each included file for a shader (The can be looked up using effect.key) */ static IncludesShadersStore: { [key: string]: string; }; /** * Resets the cache of effects. */ static ResetCache(): void; } } declare module BABYLON { /** * This represents all the required information to add a fresnel effect on a material: * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters */ class FresnelParameters { private _isEnabled; /** * Define if the fresnel effect is enable or not. */ isEnabled: boolean; /** * Define the color used on edges (grazing angle) */ leftColor: Color3; /** * Define the color used on center */ rightColor: Color3; /** * Define bias applied to computed fresnel term */ bias: number; /** * Defined the power exponent applied to fresnel term */ power: number; /** * Clones the current fresnel and its valuues * @returns a clone fresnel configuration */ clone(): FresnelParameters; /** * Serializes the current fresnel parameters to a JSON representation. * @return the JSON serialization */ serialize(): any; /** * Parse a JSON object and deserialize it to a new Fresnel parameter object. * @param parsedFresnelParameters Define the JSON representation * @returns the parsed parameters */ static Parse(parsedFresnelParameters: any): FresnelParameters; } } declare module BABYLON { /** * Interface to follow in your material defines to integrate easily the * Image proccessing functions. * @hidden */ interface IImageProcessingConfigurationDefines { IMAGEPROCESSING: boolean; VIGNETTE: boolean; VIGNETTEBLENDMODEMULTIPLY: boolean; VIGNETTEBLENDMODEOPAQUE: boolean; TONEMAPPING: boolean; TONEMAPPING_ACES: boolean; CONTRAST: boolean; EXPOSURE: boolean; COLORCURVES: boolean; COLORGRADING: boolean; COLORGRADING3D: boolean; SAMPLER3DGREENDEPTH: boolean; SAMPLER3DBGRMAP: boolean; IMAGEPROCESSINGPOSTPROCESS: boolean; } /** * @hidden */ class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines { IMAGEPROCESSING: boolean; VIGNETTE: boolean; VIGNETTEBLENDMODEMULTIPLY: boolean; VIGNETTEBLENDMODEOPAQUE: boolean; TONEMAPPING: boolean; TONEMAPPING_ACES: boolean; CONTRAST: boolean; COLORCURVES: boolean; COLORGRADING: boolean; COLORGRADING3D: boolean; SAMPLER3DGREENDEPTH: boolean; SAMPLER3DBGRMAP: boolean; IMAGEPROCESSINGPOSTPROCESS: boolean; EXPOSURE: boolean; constructor(); } /** * This groups together the common properties used for image processing either in direct forward pass * or through post processing effect depending on the use of the image processing pipeline in your scene * or not. */ class ImageProcessingConfiguration { /** * Default tone mapping applied in BabylonJS. */ static readonly TONEMAPPING_STANDARD: number; /** * ACES Tone mapping (used by default in unreal and unity). This can help getting closer * to other engines rendering to increase portability. */ static readonly TONEMAPPING_ACES: number; /** * Color curves setup used in the effect if colorCurvesEnabled is set to true */ colorCurves: Nullable; private _colorCurvesEnabled; /** * Gets wether the color curves effect is enabled. */ /** * Sets wether the color curves effect is enabled. */ colorCurvesEnabled: boolean; private _colorGradingTexture; /** * Color grading LUT texture used in the effect if colorGradingEnabled is set to true */ /** * Color grading LUT texture used in the effect if colorGradingEnabled is set to true */ colorGradingTexture: Nullable; private _colorGradingEnabled; /** * Gets wether the color grading effect is enabled. */ /** * Sets wether the color grading effect is enabled. */ colorGradingEnabled: boolean; private _colorGradingWithGreenDepth; /** * Gets wether the color grading effect is using a green depth for the 3d Texture. */ /** * Sets wether the color grading effect is using a green depth for the 3d Texture. */ colorGradingWithGreenDepth: boolean; private _colorGradingBGR; /** * Gets wether the color grading texture contains BGR values. */ /** * Sets wether the color grading texture contains BGR values. */ colorGradingBGR: boolean; /** @hidden */ _exposure: number; /** * Gets the Exposure used in the effect. */ /** * Sets the Exposure used in the effect. */ exposure: number; private _toneMappingEnabled; /** * Gets wether the tone mapping effect is enabled. */ /** * Sets wether the tone mapping effect is enabled. */ toneMappingEnabled: boolean; private _toneMappingType; /** * Gets the type of tone mapping effect. */ /** * Sets the type of tone mapping effect used in BabylonJS. */ toneMappingType: number; protected _contrast: number; /** * Gets the contrast used in the effect. */ /** * Sets the contrast used in the effect. */ contrast: number; /** * Vignette stretch size. */ vignetteStretch: number; /** * Vignette centre X Offset. */ vignetteCentreX: number; /** * Vignette centre Y Offset. */ vignetteCentreY: number; /** * Vignette weight or intensity of the vignette effect. */ vignetteWeight: number; /** * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode) * if vignetteEnabled is set to true. */ vignetteColor: Color4; /** * Camera field of view used by the Vignette effect. */ vignetteCameraFov: number; private _vignetteBlendMode; /** * Gets the vignette blend mode allowing different kind of effect. */ /** * Sets the vignette blend mode allowing different kind of effect. */ vignetteBlendMode: number; private _vignetteEnabled; /** * Gets wether the vignette effect is enabled. */ /** * Sets wether the vignette effect is enabled. */ vignetteEnabled: boolean; private _applyByPostProcess; /** * Gets wether the image processing is applied through a post process or not. */ /** * Sets wether the image processing is applied through a post process or not. */ applyByPostProcess: boolean; private _isEnabled; /** * Gets wether the image processing is enabled or not. */ /** * Sets wether the image processing is enabled or not. */ isEnabled: boolean; /** * An event triggered when the configuration changes and requires Shader to Update some parameters. */ onUpdateParameters: Observable; /** * Method called each time the image processing information changes requires to recompile the effect. */ protected _updateParameters(): void; /** * Gets the current class name. * @return "ImageProcessingConfiguration" */ getClassName(): string; /** * Prepare the list of uniforms associated with the Image Processing effects. * @param uniforms The list of uniforms used in the effect * @param defines the list of defines currently in use */ static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void; /** * Prepare the list of samplers associated with the Image Processing effects. * @param samplersList The list of uniforms used in the effect * @param defines the list of defines currently in use */ static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void; /** * Prepare the list of defines associated to the shader. * @param defines the list of defines to complete * @param forPostProcess Define if we are currently in post process mode or not */ prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void; /** * Returns true if all the image processing information are ready. * @returns True if ready, otherwise, false */ isReady(): boolean; /** * Binds the image processing to the shader. * @param effect The effect to bind to * @param aspectRatio Define the current aspect ratio of the effect */ bind(effect: Effect, aspectRatio?: number): void; /** * Clones the current image processing instance. * @return The cloned image processing */ clone(): ImageProcessingConfiguration; /** * Serializes the current image processing instance to a json representation. * @return a JSON representation */ serialize(): any; /** * Parses the image processing from a json representation. * @param source the JSON source to parse * @return The parsed image processing */ static Parse(source: any): ImageProcessingConfiguration; private static _VIGNETTEMODE_MULTIPLY; private static _VIGNETTEMODE_OPAQUE; /** * Used to apply the vignette as a mix with the pixel color. */ static readonly VIGNETTEMODE_MULTIPLY: number; /** * Used to apply the vignette as a replacement of the pixel color. */ static readonly VIGNETTEMODE_OPAQUE: number; } } declare module BABYLON { /** * Manages the defines for the Material */ class MaterialDefines { private _keys; private _isDirty; /** @hidden */ _renderId: number; /** @hidden */ _areLightsDirty: boolean; /** @hidden */ _areAttributesDirty: boolean; /** @hidden */ _areTexturesDirty: boolean; /** @hidden */ _areFresnelDirty: boolean; /** @hidden */ _areMiscDirty: boolean; /** @hidden */ _areImageProcessingDirty: boolean; /** @hidden */ _normals: boolean; /** @hidden */ _uvs: boolean; /** @hidden */ _needNormals: boolean; /** @hidden */ _needUVs: boolean; /** * Specifies if the material needs to be re-calculated */ readonly isDirty: boolean; /** * Marks the material to indicate that it has been re-calculated */ markAsProcessed(): void; /** * Marks the material to indicate that it needs to be re-calculated */ markAsUnprocessed(): void; /** * Marks the material to indicate all of its defines need to be re-calculated */ markAllAsDirty(): void; /** * Marks the material to indicate that image processing needs to be re-calculated */ markAsImageProcessingDirty(): void; /** * Marks the material to indicate the lights need to be re-calculated */ markAsLightDirty(): void; /** * Marks the attribute state as changed */ markAsAttributesDirty(): void; /** * Marks the texture state as changed */ markAsTexturesDirty(): void; /** * Marks the fresnel state as changed */ markAsFresnelDirty(): void; /** * Marks the misc state as changed */ markAsMiscDirty(): void; /** * Rebuilds the material defines */ rebuild(): void; /** * Specifies if two material defines are equal * @param other - A material define instance to compare to * @returns - Boolean indicating if the material defines are equal (true) or not (false) */ isEqual(other: MaterialDefines): boolean; /** * Clones this instance's defines to another instance * @param other - material defines to clone values to */ cloneTo(other: MaterialDefines): void; /** * Resets the material define values */ reset(): void; /** * Converts the material define values to a string * @returns - String of material define information */ toString(): string; } /** * Base class for the main features of a material in Babylon.js */ class Material implements IAnimatable { private static _TriangleFillMode; private static _WireFrameFillMode; private static _PointFillMode; private static _PointListDrawMode; private static _LineListDrawMode; private static _LineLoopDrawMode; private static _LineStripDrawMode; private static _TriangleStripDrawMode; private static _TriangleFanDrawMode; /** * Returns the triangle fill mode */ static readonly TriangleFillMode: number; /** * Returns the wireframe mode */ static readonly WireFrameFillMode: number; /** * Returns the point fill mode */ static readonly PointFillMode: number; /** * Returns the point list draw mode */ static readonly PointListDrawMode: number; /** * Returns the line list draw mode */ static readonly LineListDrawMode: number; /** * Returns the line loop draw mode */ static readonly LineLoopDrawMode: number; /** * Returns the line strip draw mode */ static readonly LineStripDrawMode: number; /** * Returns the triangle strip draw mode */ static readonly TriangleStripDrawMode: number; /** * Returns the triangle fan draw mode */ static readonly TriangleFanDrawMode: number; /** * Stores the clock-wise side orientation */ private static _ClockWiseSideOrientation; /** * Stores the counter clock-wise side orientation */ private static _CounterClockWiseSideOrientation; /** * Returns the clock-wise side orientation */ static readonly ClockWiseSideOrientation: number; /** * Returns the counter clock-wise side orientation */ static readonly CounterClockWiseSideOrientation: number; /** * The dirty texture flag value */ static readonly TextureDirtyFlag: number; /** * The dirty light flag value */ static readonly LightDirtyFlag: number; /** * The dirty fresnel flag value */ static readonly FresnelDirtyFlag: number; /** * The dirty attribute flag value */ static readonly AttributesDirtyFlag: number; /** * The dirty misc flag value */ static readonly MiscDirtyFlag: number; /** * The all dirty flag value */ static readonly AllDirtyFlag: number; /** * The ID of the material */ id: string; /** * Gets or sets the unique id of the material */ uniqueId: number; /** * The name of the material */ name: string; /** * Specifies if the ready state should be checked on each call */ checkReadyOnEveryCall: boolean; /** * Specifies if the ready state should be checked once */ checkReadyOnlyOnce: boolean; /** * The state of the material */ state: string; /** * The alpha value of the material */ protected _alpha: number; /** * Sets the alpha value of the material */ /** * Gets the alpha value of the material */ alpha: number; /** * Specifies if back face culling is enabled */ protected _backFaceCulling: boolean; /** * Sets the back-face culling state */ /** * Gets the back-face culling state */ backFaceCulling: boolean; /** * Stores the value for side orientation */ sideOrientation: number; /** * Callback triggered when the material is compiled */ onCompiled: (effect: Effect) => void; /** * Callback triggered when an error occurs */ onError: (effect: Effect, errors: string) => void; /** * Callback triggered to get the render target textures */ getRenderTargetTextures: () => SmartArray; /** * Gets a boolean indicating that current material needs to register RTT */ readonly hasRenderTargetTextures: boolean; /** * Specifies if the material should be serialized */ doNotSerialize: boolean; /** * Specifies if the effect should be stored on sub meshes */ storeEffectOnSubMeshes: boolean; /** * Stores the animations for the material */ animations: Array; /** * An event triggered when the material is disposed */ onDisposeObservable: Observable; /** * An observer which watches for dispose events */ private _onDisposeObserver; private _onUnBindObservable; /** * Called during a dispose event */ onDispose: () => void; private _onBindObservable; /** * An event triggered when the material is bound */ readonly onBindObservable: Observable; /** * An observer which watches for bind events */ private _onBindObserver; /** * Called during a bind event */ onBind: (Mesh: AbstractMesh) => void; /** * An event triggered when the material is unbound */ readonly onUnBindObservable: Observable; /** * Stores the value of the alpha mode */ private _alphaMode; /** * Sets the value of the alpha mode. * * | Value | Type | Description | * | --- | --- | --- | * | 0 | ALPHA_DISABLE | | * | 1 | ALPHA_ADD | | * | 2 | ALPHA_COMBINE | | * | 3 | ALPHA_SUBTRACT | | * | 4 | ALPHA_MULTIPLY | | * | 5 | ALPHA_MAXIMIZED | | * | 6 | ALPHA_ONEONE | | * | 7 | ALPHA_PREMULTIPLIED | | * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | | * | 9 | ALPHA_INTERPOLATE | | * | 10 | ALPHA_SCREENMODE | | * */ /** * Gets the value of the alpha mode */ alphaMode: number; /** * Stores the state of the need depth pre-pass value */ private _needDepthPrePass; /** * Sets the need depth pre-pass value */ /** * Gets the depth pre-pass value */ needDepthPrePass: boolean; /** * Specifies if depth writing should be disabled */ disableDepthWrite: boolean; /** * Specifies if depth writing should be forced */ forceDepthWrite: boolean; /** * Specifies if there should be a separate pass for culling */ separateCullingPass: boolean; /** * Stores the state specifing if fog should be enabled */ private _fogEnabled; /** * Sets the state for enabling fog */ /** * Gets the value of the fog enabled state */ fogEnabled: boolean; /** * Stores the size of points */ pointSize: number; /** * Stores the z offset value */ zOffset: number; /** * Gets a value specifying if wireframe mode is enabled */ /** * Sets the state of wireframe mode */ wireframe: boolean; /** * Gets the value specifying if point clouds are enabled */ /** * Sets the state of point cloud mode */ pointsCloud: boolean; /** * Gets the material fill mode */ /** * Sets the material fill mode */ fillMode: number; /** * @hidden * Stores the effects for the material */ _effect: Nullable; /** * @hidden * Specifies if the material was previously ready */ _wasPreviouslyReady: boolean; /** * Specifies if uniform buffers should be used */ private _useUBO; /** * Stores a reference to the scene */ private _scene; /** * Stores the fill mode state */ private _fillMode; /** * Specifies if the depth write state should be cached */ private _cachedDepthWriteState; /** * Stores the uniform buffer */ protected _uniformBuffer: UniformBuffer; /** * Creates a material instance * @param name defines the name of the material * @param scene defines the scene to reference * @param doNotAdd specifies if the material should be added to the scene */ constructor(name: string, scene: Scene, doNotAdd?: boolean); /** * Returns a string representation of the current material * @param fullDetails defines a boolean indicating which levels of logging is desired * @returns a string with material information */ toString(fullDetails?: boolean): string; /** * Gets the class name of the material * @returns a string with the class name of the material */ getClassName(): string; /** * Specifies if updates for the material been locked */ readonly isFrozen: boolean; /** * Locks updates for the material */ freeze(): void; /** * Unlocks updates for the material */ unfreeze(): void; /** * Specifies if the material is ready to be used * @param mesh defines the mesh to check * @param useInstances specifies if instances should be used * @returns a boolean indicating if the material is ready to be used */ isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean; /** * Specifies that the submesh is ready to be used * @param mesh defines the mesh to check * @param subMesh defines which submesh to check * @param useInstances specifies that instances should be used * @returns a boolean indicating that the submesh is ready or not */ isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean; /** * Returns the material effect * @returns the effect associated with the material */ getEffect(): Nullable; /** * Returns the current scene * @returns a Scene */ getScene(): Scene; /** * Specifies if the material will require alpha blending * @returns a boolean specifying if alpha blending is needed */ needAlphaBlending(): boolean; /** * Specifies if the mesh will require alpha blending * @param mesh defines the mesh to check * @returns a boolean specifying if alpha blending is needed for the mesh */ needAlphaBlendingForMesh(mesh: AbstractMesh): boolean; /** * Specifies if this material should be rendered in alpha test mode * @returns a boolean specifying if an alpha test is needed. */ needAlphaTesting(): boolean; /** * Gets the texture used for the alpha test * @returns the texture to use for alpha testing */ getAlphaTestTexture(): Nullable; /** * Marks the material to indicate that it needs to be re-calculated */ markDirty(): void; /** @hidden */ _preBind(effect?: Effect, overrideOrientation?: Nullable): boolean; /** * Binds the material to the mesh * @param world defines the world transformation matrix * @param mesh defines the mesh to bind the material to */ bind(world: Matrix, mesh?: Mesh): void; /** * Binds the submesh to the material * @param world defines the world transformation matrix * @param mesh defines the mesh containing the submesh * @param subMesh defines the submesh to bind the material to */ bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void; /** * Binds the world matrix to the material * @param world defines the world transformation matrix */ bindOnlyWorldMatrix(world: Matrix): void; /** * Binds the scene's uniform buffer to the effect. * @param effect defines the effect to bind to the scene uniform buffer * @param sceneUbo defines the uniform buffer storing scene data */ bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void; /** * Binds the view matrix to the effect * @param effect defines the effect to bind the view matrix to */ bindView(effect: Effect): void; /** * Binds the view projection matrix to the effect * @param effect defines the effect to bind the view projection matrix to */ bindViewProjection(effect: Effect): void; /** * Specifies if material alpha testing should be turned on for the mesh * @param mesh defines the mesh to check */ protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean; /** * Processes to execute after binding the material to a mesh * @param mesh defines the rendered mesh */ protected _afterBind(mesh?: Mesh): void; /** * Unbinds the material from the mesh */ unbind(): void; /** * Gets the active textures from the material * @returns an array of textures */ getActiveTextures(): BaseTexture[]; /** * Specifies if the material uses a texture * @param texture defines the texture to check against the material * @returns a boolean specifying if the material uses the texture */ hasTexture(texture: BaseTexture): boolean; /** * Makes a duplicate of the material, and gives it a new name * @param name defines the new name for the duplicated material * @returns the cloned material */ clone(name: string): Nullable; /** * Gets the meshes bound to the material * @returns an array of meshes bound to the material */ getBindedMeshes(): AbstractMesh[]; /** * Force shader compilation * @param mesh defines the mesh associated with this material * @param onCompiled defines a function to execute once the material is compiled * @param options defines the options to configure the compilation */ forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{ clipPlane: boolean; }>): void; /** * Force shader compilation * @param mesh defines the mesh that will use this material * @param options defines additional options for compiling the shaders * @returns a promise that resolves when the compilation completes */ forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{ clipPlane: boolean; }>): Promise; /** * Marks a define in the material to indicate that it needs to be re-computed * @param flag defines a flag used to determine which parts of the material have to be marked as dirty */ markAsDirty(flag: number): void; /** * Marks all submeshes of a material to indicate that their material defines need to be re-calculated * @param func defines a function which checks material defines against the submeshes */ protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void; /** * Indicates that image processing needs to be re-calculated for all submeshes */ protected _markAllSubMeshesAsImageProcessingDirty(): void; /** * Indicates that textures need to be re-calculated for all submeshes */ protected _markAllSubMeshesAsTexturesDirty(): void; /** * Indicates that fresnel needs to be re-calculated for all submeshes */ protected _markAllSubMeshesAsFresnelDirty(): void; /** * Indicates that fresnel and misc need to be re-calculated for all submeshes */ protected _markAllSubMeshesAsFresnelAndMiscDirty(): void; /** * Indicates that lights need to be re-calculated for all submeshes */ protected _markAllSubMeshesAsLightsDirty(): void; /** * Indicates that attributes need to be re-calculated for all submeshes */ protected _markAllSubMeshesAsAttributesDirty(): void; /** * Indicates that misc needs to be re-calculated for all submeshes */ protected _markAllSubMeshesAsMiscDirty(): void; /** * Indicates that textures and misc need to be re-calculated for all submeshes */ protected _markAllSubMeshesAsTexturesAndMiscDirty(): void; /** * Disposes the material * @param forceDisposeEffect specifies if effects should be forcefully disposed * @param forceDisposeTextures specifies if textures should be forcefully disposed */ dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void; /** * Serializes this material * @returns the serialized material object */ serialize(): any; /** * Creates a MultiMaterial from parsed MultiMaterial data. * @param parsedMultiMaterial defines parsed MultiMaterial data. * @param scene defines the hosting scene * @returns a new MultiMaterial */ static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial; /** * Creates a material from parsed material data * @param parsedMaterial defines parsed material data * @param scene defines the hosting scene * @param rootUrl defines the root URL to use to load textures * @returns a new material */ static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any; } } declare module BABYLON { /** * "Static Class" containing the most commonly used helper while dealing with material for * rendering purpose. * * It contains the basic tools to help defining defines, binding uniform for the common part of the materials. * * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions. */ class MaterialHelper { /** * Bind the current view position to an effect. * @param effect The effect to be bound * @param scene The scene the eyes position is used from */ static BindEyePosition(effect: Effect, scene: Scene): void; /** * Helps preparing the defines values about the UVs in used in the effect. * UVs are shared as much as we can accross channels in the shaders. * @param texture The texture we are preparing the UVs for * @param defines The defines to update * @param key The channel key "diffuse", "specular"... used in the shader */ static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void; /** * Binds a texture matrix value to its corrsponding uniform * @param texture The texture to bind the matrix for * @param uniformBuffer The uniform buffer receivin the data * @param key The channel key "diffuse", "specular"... used in the shader */ static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void; /** * Helper used to prepare the list of defines associated with misc. values for shader compilation * @param mesh defines the current mesh * @param scene defines the current scene * @param useLogarithmicDepth defines if logarithmic depth has to be turned on * @param pointsCloud defines if point cloud rendering has to be turned on * @param fogEnabled defines if fog has to be turned on * @param alphaTest defines if alpha testing has to be turned on * @param defines defines the current list of defines */ static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void; /** * Helper used to prepare the list of defines associated with frame values for shader compilation * @param scene defines the current scene * @param engine defines the current engine * @param defines specifies the list of active defines * @param useInstances defines if instances have to be turned on * @param useClipPlane defines if clip plane have to be turned on */ static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable): void; /** * Prepares the defines used in the shader depending on the attributes data available in the mesh * @param mesh The mesh containing the geometry data we will draw * @param defines The defines to update * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info) * @param useBones Precise whether bones should be used or not (override mesh info) * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info) * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info) * @returns false if defines are considered not dirty and have not been checked */ static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean; /** * Prepares the defines related to the light information passed in parameter * @param scene The scene we are intending to draw * @param mesh The mesh the effect is compiling for * @param defines The defines to update * @param specularSupported Specifies whether specular is supported or not (override lights data) * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max * @param disableLighting Specifies whether the lighting is disabled (override scene and light) * @returns true if normals will be required for the rest of the effect */ static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean; /** * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms * that won t be acctive due to defines being turned off. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information * @param samplersList The samplers list * @param defines The defines helping in the list generation * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect */ static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void; /** * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality) * @param defines The defines to update while falling back * @param fallbacks The authorized effect fallbacks * @param maxSimultaneousLights The maximum number of lights allowed * @param rank the current rank of the Effect * @returns The newly affected rank */ static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number; /** * Prepares the list of attributes required for morph targets according to the effect defines. * @param attribs The current list of supported attribs * @param mesh The mesh to prepare the morph targets attributes for * @param defines The current Defines of the effect */ static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void; /** * Prepares the list of attributes required for bones according to the effect defines. * @param attribs The current list of supported attribs * @param mesh The mesh to prepare the bones attributes for * @param defines The current Defines of the effect * @param fallbacks The current efffect fallback strategy */ static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void; /** * Prepares the list of attributes required for instances according to the effect defines. * @param attribs The current list of supported attribs * @param defines The current Defines of the effect */ static PrepareAttributesForInstances(attribs: string[], defines: any): void; /** * Binds the light shadow information to the effect for the given mesh. * @param light The light containing the generator * @param scene The scene the lights belongs to * @param mesh The mesh we are binding the information to render * @param lightIndex The light index in the effect used to render the mesh * @param effect The effect we are binding the data to */ static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void; /** * Binds the light information to the effect. * @param light The light containing the generator * @param effect The effect we are binding the data to * @param lightIndex The light index in the effect used to render */ static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void; /** * Binds the lights information from the scene to the effect for the given mesh. * @param scene The scene the lights belongs to * @param mesh The mesh we are binding the information to render * @param effect The effect we are binding the data to * @param defines The generated defines for the effect * @param maxSimultaneousLights The maximum number of light that can be bound to the effect * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not */ static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void; private static _tempFogColor; /** * Binds the fog information from the scene to the effect for the given mesh. * @param scene The scene the lights belongs to * @param mesh The mesh we are binding the information to render * @param effect The effect we are binding the data to * @param linearSpace Defines if the fog effect is applied in linear space */ static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void; /** * Binds the bones information from the mesh to the effect. * @param mesh The mesh we are binding the information to render * @param effect The effect we are binding the data to */ static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void; /** * Binds the morph targets information from the mesh to the effect. * @param abstractMesh The mesh we are binding the information to render * @param effect The effect we are binding the data to */ static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void; /** * Binds the logarithmic depth information from the scene to the effect for the given defines. * @param defines The generated defines used in the effect * @param effect The effect we are binding the data to * @param scene The scene we are willing to render with logarithmic scale for */ static BindLogDepth(defines: any, effect: Effect, scene: Scene): void; /** * Binds the clip plane information from the scene to the effect. * @param scene The scene the clip plane information are extracted from * @param effect The effect we are binding the data to */ static BindClipPlane(effect: Effect, scene: Scene): void; } } declare module BABYLON { /** * A multi-material is used to apply different materials to different parts of the same object without the need of * separate meshes. This can be use to improve performances. * @see http://doc.babylonjs.com/how_to/multi_materials */ class MultiMaterial extends Material { private _subMaterials; /** * Gets or Sets the list of Materials used within the multi material. * They need to be ordered according to the submeshes order in the associated mesh */ subMaterials: Nullable[]; /** * Instantiates a new Multi Material * A multi-material is used to apply different materials to different parts of the same object without the need of * separate meshes. This can be use to improve performances. * @see http://doc.babylonjs.com/how_to/multi_materials * @param name Define the name in the scene * @param scene Define the scene the material belongs to */ constructor(name: string, scene: Scene); private _hookArray; /** * Get one of the submaterial by its index in the submaterials array * @param index The index to look the sub material at * @returns The Material if the index has been defined */ getSubMaterial(index: number): Nullable; /** * Get the list of active textures for the whole sub materials list. * @returns All the textures that will be used during the rendering */ getActiveTextures(): BaseTexture[]; /** * Gets the current class name of the material e.g. "MultiMaterial" * Mainly use in serialization. * @returns the class name */ getClassName(): string; /** * Checks if the material is ready to render the requested sub mesh * @param mesh Define the mesh the submesh belongs to * @param subMesh Define the sub mesh to look readyness for * @param useInstances Define whether or not the material is used with instances * @returns true if ready, otherwise false */ isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean; /** * Clones the current material and its related sub materials * @param name Define the name of the newly cloned material * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance * @returns the cloned material */ clone(name: string, cloneChildren?: boolean): MultiMaterial; /** * Serializes the materials into a JSON representation. * @returns the JSON representation */ serialize(): any; /** * Dispose the material and release its associated resources * @param forceDisposeEffect Define if we want to force disposing the associated effect (if false the shader is not released and could be reuse later on) * @param forceDisposeTextures Define if we want to force disposing the associated textures (if false, they will not be disposed and can still be use elsewhere in the app) */ dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void; } } declare module BABYLON { /** * Base class of materials working in push mode in babylon JS * @hidden */ class PushMaterial extends Material { protected _activeEffect: Effect; protected _normalMatrix: Matrix; constructor(name: string, scene: Scene); getEffect(): Effect; isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean; /** * Binds the given world matrix to the active effect * * @param world the matrix to bind */ bindOnlyWorldMatrix(world: Matrix): void; /** * Binds the given normal matrix to the active effect * * @param normalMatrix the matrix to bind */ bindOnlyNormalMatrix(normalMatrix: Matrix): void; bind(world: Matrix, mesh?: Mesh): void; protected _afterBind(mesh: Mesh, effect?: Nullable): void; protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean; } } declare module BABYLON { /** * Defines the options associated with the creation of a shader material. */ interface IShaderMaterialOptions { /** * Does the material work in alpha blend mode */ needAlphaBlending: boolean; /** * Does the material work in alpha test mode */ needAlphaTesting: boolean; /** * The list of attribute names used in the shader */ attributes: string[]; /** * The list of unifrom names used in the shader */ uniforms: string[]; /** * The list of UBO names used in the shader */ uniformBuffers: string[]; /** * The list of sampler names used in the shader */ samplers: string[]; /** * The list of defines used in the shader */ defines: string[]; } /** * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh. * * This returned material effects how the mesh will look based on the code in the shaders. * * @see http://doc.babylonjs.com/how_to/shader_material */ class ShaderMaterial extends Material { private _shaderPath; private _options; private _textures; private _textureArrays; private _floats; private _ints; private _floatsArrays; private _colors3; private _colors3Arrays; private _colors4; private _vectors2; private _vectors3; private _vectors4; private _matrices; private _matrices3x3; private _matrices2x2; private _vectors2Arrays; private _vectors3Arrays; private _cachedWorldViewMatrix; private _renderId; /** * Instantiate a new shader material. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh. * This returned material effects how the mesh will look based on the code in the shaders. * @see http://doc.babylonjs.com/how_to/shader_material * @param name Define the name of the material in the scene * @param scene Define the scene the material belongs to * @param shaderPath Defines the route to the shader code in one of three ways: * - object - { vertex: "custom", fragment: "custom" }, used with BABYLON.Effect.ShadersStore["customVertexShader"] and BABYLON.Effect.ShadersStore["customFragmentShader"] * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in