diff --git a/dist/preview release/babylon.d.ts b/dist/preview release/babylon.d.ts index 094695f54df..10de979cfeb 100644 --- a/dist/preview release/babylon.d.ts +++ b/dist/preview release/babylon.d.ts @@ -3863,249 +3863,6 @@ declare module BABYLON { } } -declare module BABYLON { - class Collider { - radius: Vector3; - retry: number; - velocity: Vector3; - basePoint: Vector3; - epsilon: number; - collisionFound: boolean; - velocityWorldLength: number; - basePointWorld: Vector3; - velocityWorld: Vector3; - normalizedVelocity: Vector3; - initialVelocity: Vector3; - initialPosition: Vector3; - nearestDistance: number; - intersectionPoint: Vector3; - collidedMesh: AbstractMesh; - private _collisionPoint; - private _planeIntersectionPoint; - private _tempVector; - private _tempVector2; - private _tempVector3; - private _tempVector4; - private _edge; - private _baseToVertex; - private _destinationPoint; - private _slidePlaneNormal; - private _displacementVector; - private _collisionMask; - collisionMask: number; - _initialize(source: Vector3, dir: Vector3, e: number): void; - _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean; - _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean; - _testTriangle(faceIndex: number, trianglePlaneArray: Array, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void; - _collide(trianglePlaneArray: Array, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void; - _getResponse(pos: Vector3, vel: Vector3): void; - } -} - -declare module BABYLON { - var CollisionWorker: string; - interface ICollisionCoordinator { - getNewPosition(position: Vector3, velocity: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh?: AbstractMesh) => void, collisionIndex: number): void; - init(scene: Scene): void; - destroy(): void; - onMeshAdded(mesh: AbstractMesh): any; - onMeshUpdated(mesh: AbstractMesh): any; - onMeshRemoved(mesh: AbstractMesh): any; - onGeometryAdded(geometry: Geometry): any; - onGeometryUpdated(geometry: Geometry): any; - onGeometryDeleted(geometry: Geometry): any; - } - interface SerializedMesh { - id: string; - name: string; - uniqueId: number; - geometryId: string; - sphereCenter: Array; - sphereRadius: number; - boxMinimum: Array; - boxMaximum: Array; - worldMatrixFromCache: any; - subMeshes: Array; - checkCollisions: boolean; - } - interface SerializedSubMesh { - position: number; - verticesStart: number; - verticesCount: number; - indexStart: number; - indexCount: number; - hasMaterial: boolean; - sphereCenter: Array; - sphereRadius: number; - boxMinimum: Array; - boxMaximum: Array; - } - interface SerializedGeometry { - id: string; - positions: Float32Array; - indices: Uint32Array; - normals: Float32Array; - } - interface BabylonMessage { - taskType: WorkerTaskType; - payload: InitPayload | CollidePayload | UpdatePayload; - } - interface SerializedColliderToWorker { - position: Array; - velocity: Array; - radius: Array; - } - enum WorkerTaskType { - INIT = 0, - UPDATE = 1, - COLLIDE = 2, - } - interface WorkerReply { - error: WorkerReplyType; - taskType: WorkerTaskType; - payload?: any; - } - interface CollisionReplyPayload { - newPosition: Array; - collisionId: number; - collidedMeshUniqueId: number; - } - interface InitPayload { - } - interface CollidePayload { - collisionId: number; - collider: SerializedColliderToWorker; - maximumRetry: number; - excludedMeshUniqueId?: number; - } - interface UpdatePayload { - updatedMeshes: { - [n: number]: SerializedMesh; - }; - updatedGeometries: { - [s: string]: SerializedGeometry; - }; - removedMeshes: Array; - removedGeometries: Array; - } - enum WorkerReplyType { - SUCCESS = 0, - UNKNOWN_ERROR = 1, - } - class CollisionCoordinatorWorker implements ICollisionCoordinator { - private _scene; - private _scaledPosition; - private _scaledVelocity; - private _collisionsCallbackArray; - private _init; - private _runningUpdated; - private _runningCollisionTask; - private _worker; - private _addUpdateMeshesList; - private _addUpdateGeometriesList; - private _toRemoveMeshesArray; - private _toRemoveGeometryArray; - constructor(); - static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh; - static SerializeGeometry: (geometry: Geometry) => SerializedGeometry; - getNewPosition(position: Vector3, velocity: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh?: AbstractMesh) => 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 _afterRender; - private _onMessageFromWorker; - } - class CollisionCoordinatorLegacy implements ICollisionCoordinator { - private _scene; - private _scaledPosition; - private _scaledVelocity; - private _finalPosition; - getNewPosition(position: Vector3, velocity: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh?: AbstractMesh) => 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(position, velocity, collider, maximumRetry, finalPosition, excludedMesh?); - } -} - -declare module BABYLON { - var WorkerIncluded: boolean; - 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; - } - 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?: number): void; - private checkCollision(mesh); - private processCollisionsForSubMeshes(transformMatrix, mesh); - private collideForSubMesh(subMesh, transformMatrix, meshGeometry); - private checkSubmeshCollision(subMesh); - } - interface ICollisionDetector { - onInit(payload: InitPayload): void; - onUpdate(payload: UpdatePayload): void; - onCollision(payload: CollidePayload): void; - } - class CollisionDetectorTransferable implements ICollisionDetector { - private _collisionCache; - onInit(payload: InitPayload): void; - onUpdate(payload: UpdatePayload): void; - onCollision(payload: CollidePayload): void; - } -} - -declare module BABYLON { - class IntersectionInfo { - bu: number; - bv: number; - distance: number; - faceId: number; - subMeshId: number; - constructor(bu: number, bv: number, distance: number); - } - class PickingInfo { - hit: boolean; - distance: number; - pickedPoint: Vector3; - pickedMesh: AbstractMesh; - bu: number; - bv: number; - faceId: number; - subMeshId: number; - pickedSprite: Sprite; - getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Vector3; - getTextureCoordinates(): Vector2; - } -} - declare module BABYLON { class BoundingBox implements ICullable { minimum: Vector3; @@ -4477,19 +4234,262 @@ declare module BABYLON { } declare module BABYLON { - class LensFlare { - size: number; - position: number; - color: Color3; - texture: Texture; - alphaMode: number; - private _system; - constructor(size: number, position: number, color: any, imgUrl: string, system: LensFlareSystem); - dispose: () => void; - } -} - -declare module BABYLON { + class Collider { + radius: Vector3; + retry: number; + velocity: Vector3; + basePoint: Vector3; + epsilon: number; + collisionFound: boolean; + velocityWorldLength: number; + basePointWorld: Vector3; + velocityWorld: Vector3; + normalizedVelocity: Vector3; + initialVelocity: Vector3; + initialPosition: Vector3; + nearestDistance: number; + intersectionPoint: Vector3; + collidedMesh: AbstractMesh; + private _collisionPoint; + private _planeIntersectionPoint; + private _tempVector; + private _tempVector2; + private _tempVector3; + private _tempVector4; + private _edge; + private _baseToVertex; + private _destinationPoint; + private _slidePlaneNormal; + private _displacementVector; + private _collisionMask; + collisionMask: number; + _initialize(source: Vector3, dir: Vector3, e: number): void; + _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean; + _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean; + _testTriangle(faceIndex: number, trianglePlaneArray: Array, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void; + _collide(trianglePlaneArray: Array, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void; + _getResponse(pos: Vector3, vel: Vector3): void; + } +} + +declare module BABYLON { + var CollisionWorker: string; + interface ICollisionCoordinator { + getNewPosition(position: Vector3, velocity: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh?: AbstractMesh) => void, collisionIndex: number): void; + init(scene: Scene): void; + destroy(): void; + onMeshAdded(mesh: AbstractMesh): any; + onMeshUpdated(mesh: AbstractMesh): any; + onMeshRemoved(mesh: AbstractMesh): any; + onGeometryAdded(geometry: Geometry): any; + onGeometryUpdated(geometry: Geometry): any; + onGeometryDeleted(geometry: Geometry): any; + } + interface SerializedMesh { + id: string; + name: string; + uniqueId: number; + geometryId: string; + sphereCenter: Array; + sphereRadius: number; + boxMinimum: Array; + boxMaximum: Array; + worldMatrixFromCache: any; + subMeshes: Array; + checkCollisions: boolean; + } + interface SerializedSubMesh { + position: number; + verticesStart: number; + verticesCount: number; + indexStart: number; + indexCount: number; + hasMaterial: boolean; + sphereCenter: Array; + sphereRadius: number; + boxMinimum: Array; + boxMaximum: Array; + } + interface SerializedGeometry { + id: string; + positions: Float32Array; + indices: Uint32Array; + normals: Float32Array; + } + interface BabylonMessage { + taskType: WorkerTaskType; + payload: InitPayload | CollidePayload | UpdatePayload; + } + interface SerializedColliderToWorker { + position: Array; + velocity: Array; + radius: Array; + } + enum WorkerTaskType { + INIT = 0, + UPDATE = 1, + COLLIDE = 2, + } + interface WorkerReply { + error: WorkerReplyType; + taskType: WorkerTaskType; + payload?: any; + } + interface CollisionReplyPayload { + newPosition: Array; + collisionId: number; + collidedMeshUniqueId: number; + } + interface InitPayload { + } + interface CollidePayload { + collisionId: number; + collider: SerializedColliderToWorker; + maximumRetry: number; + excludedMeshUniqueId?: number; + } + interface UpdatePayload { + updatedMeshes: { + [n: number]: SerializedMesh; + }; + updatedGeometries: { + [s: string]: SerializedGeometry; + }; + removedMeshes: Array; + removedGeometries: Array; + } + enum WorkerReplyType { + SUCCESS = 0, + UNKNOWN_ERROR = 1, + } + class CollisionCoordinatorWorker implements ICollisionCoordinator { + private _scene; + private _scaledPosition; + private _scaledVelocity; + private _collisionsCallbackArray; + private _init; + private _runningUpdated; + private _runningCollisionTask; + private _worker; + private _addUpdateMeshesList; + private _addUpdateGeometriesList; + private _toRemoveMeshesArray; + private _toRemoveGeometryArray; + constructor(); + static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh; + static SerializeGeometry: (geometry: Geometry) => SerializedGeometry; + getNewPosition(position: Vector3, velocity: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh?: AbstractMesh) => 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 _afterRender; + private _onMessageFromWorker; + } + class CollisionCoordinatorLegacy implements ICollisionCoordinator { + private _scene; + private _scaledPosition; + private _scaledVelocity; + private _finalPosition; + getNewPosition(position: Vector3, velocity: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh?: AbstractMesh) => 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(position, velocity, collider, maximumRetry, finalPosition, excludedMesh?); + } +} + +declare module BABYLON { + var WorkerIncluded: boolean; + 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; + } + 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?: number): void; + private checkCollision(mesh); + private processCollisionsForSubMeshes(transformMatrix, mesh); + private collideForSubMesh(subMesh, transformMatrix, meshGeometry); + private checkSubmeshCollision(subMesh); + } + interface ICollisionDetector { + onInit(payload: InitPayload): void; + onUpdate(payload: UpdatePayload): void; + onCollision(payload: CollidePayload): void; + } + class CollisionDetectorTransferable implements ICollisionDetector { + private _collisionCache; + onInit(payload: InitPayload): void; + onUpdate(payload: UpdatePayload): void; + onCollision(payload: CollidePayload): void; + } +} + +declare module BABYLON { + class IntersectionInfo { + bu: number; + bv: number; + distance: number; + faceId: number; + subMeshId: number; + constructor(bu: number, bv: number, distance: number); + } + class PickingInfo { + hit: boolean; + distance: number; + pickedPoint: Vector3; + pickedMesh: AbstractMesh; + bu: number; + bv: number; + faceId: number; + subMeshId: number; + pickedSprite: Sprite; + getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Vector3; + getTextureCoordinates(): Vector2; + } +} + +declare module BABYLON { + class LensFlare { + size: number; + position: number; + color: Color3; + texture: Texture; + alphaMode: number; + private _system; + constructor(size: number, position: number, color: any, imgUrl: string, system: LensFlareSystem); + dispose: () => void; + } +} + +declare module BABYLON { class LensFlareSystem { name: string; lensFlares: LensFlare[]; @@ -4649,105 +4649,6 @@ declare module BABYLON.Debug { } } -declare module BABYLON { - interface ILoadingScreen { - displayLoadingUI: () => void; - hideLoadingUI: () => void; - loadingUIBackgroundColor: string; - loadingUIText: string; - } - class DefaultLoadingScreen implements ILoadingScreen { - private _renderingCanvas; - private _loadingText; - private _loadingDivBackgroundColor; - private _loadingDiv; - private _loadingTextDiv; - constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string); - displayLoadingUI(): void; - hideLoadingUI(): void; - loadingUIText: string; - loadingUIBackgroundColor: string; - private _resizeLoadingUI; - } -} - -declare module BABYLON { - interface ISceneLoaderPluginExtensions { - [extension: string]: { - isBinary: boolean; - }; - } - interface ISceneLoaderPlugin { - name: string; - extensions: string | ISceneLoaderPluginExtensions; - importMesh: (meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[], onError: (message: string) => void) => boolean; - load: (scene: Scene, data: string, rootUrl: string, onError: (message: string) => void) => boolean; - canDirectLoad?: (data: string) => boolean; - } - interface ISceneLoaderPluginAsync { - name: string; - extensions: string | ISceneLoaderPluginExtensions; - importMeshAsync: (meshesNames: any, scene: Scene, data: any, rootUrl: string, onSuccess: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, onProgress: (event: ProgressEvent) => void, onError: (message: string) => void) => void; - loadAsync: (scene: Scene, data: string, rootUrl: string, onSuccess: () => void, onProgress: (event: ProgressEvent) => void, onError: (message: string) => void) => void; - canDirectLoad?: (data: string) => boolean; - } - class SceneLoader { - private static _ForceFullSceneLoadingForIncremental; - private static _ShowLoadingScreen; - private static _CleanBoneMatrixWeights; - static readonly NO_LOGGING: number; - static readonly MINIMAL_LOGGING: number; - static readonly SUMMARY_LOGGING: number; - static readonly DETAILED_LOGGING: number; - private static _loggingLevel; - static ForceFullSceneLoadingForIncremental: boolean; - static ShowLoadingScreen: boolean; - static loggingLevel: number; - static CleanBoneMatrixWeights: boolean; - static OnPluginActivatedObservable: Observable; - private static _registeredPlugins; - private static _getDefaultPlugin(); - private static _getPluginForExtension(extension); - private static _getPluginForDirectLoad(data); - private static _getPluginForFilename(sceneFilename); - private static _getDirectLoad(sceneFilename); - private static _loadData(rootUrl, sceneFilename, scene, onSuccess, onProgress, onError); - static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync; - 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 scene and resources - * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene - * @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 - */ - static ImportMesh(meshNames: any, rootUrl: string, sceneFilename: string, scene: Scene, onSuccess?: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, onProgress?: (event: ProgressEvent) => void, onError?: (scene: Scene, message: string, exception?: any) => void): void; - /** - * Load a scene - * @param rootUrl a string that defines the root url for scene and resources - * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene - * @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 - */ - static Load(rootUrl: string, sceneFilename: any, engine: Engine, onSuccess?: (scene: Scene) => void, onProgress?: (event: ProgressEvent) => void, onError?: (scene: Scene, message: string, exception?: any) => void): void; - /** - * Append a scene - * @param rootUrl a string that defines the root url for scene and resources - * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene - * @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 - */ - static Append(rootUrl: string, sceneFilename: any, scene: Scene, onSuccess?: (scene: Scene) => void, onProgress?: (event: ProgressEvent) => void, onError?: (scene: Scene, message: string, exception?: any) => void): void; - } -} - declare module BABYLON { class DirectionalLight extends ShadowLight { private _shadowFrustumSize; @@ -5282,3528 +5183,3627 @@ declare module BABYLON { } declare module BABYLON { - class Scalar { + /** + * 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; /** - * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45) + * 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). */ - static WithinEpsilon(a: number, b: number, epsilon?: number): boolean; /** - * Returns a string : the upper case translation of the number i to hexadecimal. + * 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). */ - static ToHex(i: number): string; + globalHue: number; /** - * Returns -1 if value is negative and +1 is value is positive. - * Returns the value itself if it's equal to zero. + * 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. */ - static Sign(value: number): number; /** - * Returns the value itself if it's between min and max. - * Returns min if the value is lower than min. - * Returns max if the value is greater than max. + * 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. */ - static Clamp(value: number, min?: number, max?: number): number; + globalDensity: number; /** - * Returns the log2 of value. + * 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. */ - static Log2(value: number): number; - /** - * Loops the value, so that it is never larger than length and never smaller than 0. - * - * This is similar to the modulo operator but it works with floating point numbers. - * For example, using 3.0 for t and 2.5 for length, the result would be 0.5. - * With t = 5 and length = 2.5, the result would be 0.0. - * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator - */ - static Repeat(value: number, length: number): number; /** - * Normalize the value between 0.0 and 1.0 using min and max values - */ - static Normalize(value: number, min: number, max: number): number; + * 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; + private _highlightsHue; + private _highlightsDensity; + private _highlightsSaturation; + private _highlightsExposure; /** - * Denormalize the value from 0.0 and 1.0 using min and max values - */ - static Denormalize(normalized: number, min: number, max: number): number; + * 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). + */ /** - * Calculates the shortest difference between two given angles given in degrees. - */ - static DeltaAngle(current: number, target: number): number; + * 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; /** - * PingPongs the value t, so that it is never larger than length and never smaller than 0. - * - * The returned value will move back and forth between 0 and length - */ - static PingPong(tx: number, length: number): 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. + */ /** - * Interpolates between min and max with smoothing at the limits. - * - * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up - * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions. - */ - static SmoothStep(from: number, to: number, tx: number): number; + * 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; /** - * Moves a value current towards target. - * - * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta. - * Negative values of maxDelta pushes the value away from target. - */ - static MoveTowards(current: number, target: number, maxDelta: number): 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. + */ /** - * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees. - * - * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta - * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead. - */ - static MoveTowardsAngle(current: number, target: number, maxDelta: number): number; + * 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; /** - * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar. - */ - static Lerp(start: number, end: number, amount: number): 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. + */ /** - * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees. - * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees. - */ - static LerpAngle(start: number, end: number, amount: number): number; + * 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; /** - * Calculates the linear parameter t that produces the interpolant value within the range [a, b]. - */ - static InverseLerp(a: number, b: number, value: number): number; + * 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). + */ /** - * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2". + * 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). */ - static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number; + midtonesHue: number; /** - * Returns a random float number between and min and max values - */ - static RandomRange(min: number, max: number): 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. + */ /** - * This function returns percentage of a number in a given range. - * - * RangeToPercent(40,20,60) will return 0.5 (50%) - * RangeToPercent(34,0,100) will return 0.34 (34%) - */ - static RangeToPercent(number: number, min: number, max: number): number; - /** - * This function returns number that corresponds to the percentage in a given range. - * - * PercentToRange(0.34,0,100) will return 34. - */ - static PercentToRange(percent: number, min: number, max: number): number; - } -} - -declare module BABYLON { - class SIMDHelper { - private static _isEnabled; - static readonly IsEnabled: boolean; - static DisableSIMD(): void; - static EnableSIMD(): void; - } -} - -declare module BABYLON { - const ToGammaSpace: number; - const ToLinearSpace = 2.2; - const Epsilon = 0.001; - class Color3 { - r: number; - g: number; - b: number; - /** - * Creates a new Color3 object from red, green, blue values, all between 0 and 1. - */ - constructor(r?: number, g?: number, b?: number); - /** - * Returns a string with the Color3 current values. - */ - toString(): string; - /** - * Returns the string "Color3". - */ - getClassName(): string; - /** - * Returns the Color3 hash code. - */ - getHashCode(): number; - /** - * Stores in the passed array from the passed starting index the red, green, blue values as successive elements. - * Returns the Color3. - */ - toArray(array: number[] | Float32Array, index?: number): Color3; - /** - * Returns a new Color4 object from the current Color3 and the passed alpha. - */ - toColor4(alpha?: number): Color4; - /** - * Returns a new array populated with 3 numeric elements : red, green and blue values. - */ - asArray(): number[]; - /** - * Returns the luminance value (float). - */ - toLuminance(): number; - /** - * Multiply each Color3 rgb values by the passed Color3 rgb values in a new Color3 object. - * Returns this new object. - */ - multiply(otherColor: Color3): Color3; - /** - * Multiply the rgb values of the Color3 and the passed Color3 and stores the result in the object "result". - * Returns the current Color3. + * 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. */ - multiplyToRef(otherColor: Color3, result: Color3): Color3; + midtonesDensity: number; /** - * Boolean : True if the rgb values are equal to the passed ones. + * 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. */ - equals(otherColor: Color3): boolean; /** - * Boolean : True if the rgb values are equal to the passed ones. + * 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. */ - equalsFloats(r: number, g: number, b: number): boolean; + midtonesSaturation: number; /** - * Multiplies in place each rgb value by scale. - * Returns the updated Color3. + * 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. */ - scale(scale: number): Color3; /** - * Multiplies the rgb values by scale and stores the result into "result". - * Returns the unmodified current Color3. + * 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. */ - scaleToRef(scale: number, result: Color3): Color3; + midtonesExposure: number; + private _shadowsHue; + private _shadowsDensity; + private _shadowsSaturation; + private _shadowsExposure; /** - * Returns a new Color3 set with the added values of the current Color3 and of the passed one. + * 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). */ - add(otherColor: Color3): Color3; /** - * Stores the result of the addition of the current Color3 and passed one rgb values into "result". - * Returns the unmodified current Color3. + * 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). */ - addToRef(otherColor: Color3, result: Color3): Color3; + shadowsHue: number; /** - * Returns a new Color3 set with the subtracted values of the passed one from the current Color3 . + * 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. */ - subtract(otherColor: Color3): Color3; /** - * Stores the result of the subtraction of passed one from the current Color3 rgb values into "result". - * Returns the unmodified current Color3. + * 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. */ - subtractToRef(otherColor: Color3, result: Color3): Color3; + shadowsDensity: number; /** - * Returns a new Color3 copied the current one. + * 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. */ - clone(): Color3; /** - * Copies the rgb values from the source in the current Color3. - * Returns the updated Color3. + * 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. */ - copyFrom(source: Color3): Color3; + shadowsSaturation: number; /** - * Updates the Color3 rgb values from the passed floats. - * Returns the Color3. + * 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. */ - copyFromFloats(r: number, g: number, b: number): Color3; /** - * Updates the Color3 rgb values from the passed floats. - * Returns the Color3. + * 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. */ - set(r: number, g: number, b: number): Color3; + shadowsExposure: number; + getClassName(): string; /** - * Returns the Color3 hexadecimal code as a string. + * Binds the color curves to the shader. + * @param colorCurves The color curve to bind + * @param effect The effect to bind to */ - toHexString(): string; + static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void; /** - * Returns a new Color3 converted to linear space. + * Prepare the list of uniforms associated with the ColorCurves effects. + * @param uniformsList The list of uniforms used in the effect */ - toLinearSpace(): Color3; + static PrepareUniforms(uniformsList: string[]): void; /** - * Converts the Color3 values to linear space and stores the result in "convertedColor". - * Returns the unmodified Color3. + * 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. */ - toLinearSpaceToRef(convertedColor: Color3): Color3; + private getColorGradingDataToRef(hue, density, saturation, exposure, result); /** - * Returns a new Color3 converted to gamma space. + * 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. */ - toGammaSpace(): Color3; + private static applyColorGradingSliderNonlinear(value); /** - * Converts the Color3 values to gamma space and stores the result in "convertedColor". - * Returns the unmodified Color3. + * 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. */ - toGammaSpaceToRef(convertedColor: Color3): Color3; + private static fromHSBToRef(hue, saturation, brightness, result); /** - * Creates a new Color3 from the string containing valid hexadecimal values. + * 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. */ - static FromHexString(hex: string): Color3; + private static clamp(value, min, max); /** - * Creates a new Vector3 from the startind index of the passed array. + * Clones the current color curve instance. + * @return The cloned curves */ - static FromArray(array: ArrayLike, offset?: number): Color3; + clone(): ColorCurves; /** - * Creates a new Color3 from integer values ( < 256). + * Serializes the current color curve instance to a json representation. + * @return a JSON representation */ - static FromInts(r: number, g: number, b: number): Color3; + serialize(): any; /** - * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3. + * Parses the color curve from a json representation. + * @param source the JSON source to parse + * @return The parsed curves */ - static Lerp(start: Color3, end: Color3, amount: number): Color3; - static Red(): Color3; - static Green(): Color3; - static Blue(): Color3; - static Black(): Color3; - static White(): Color3; - static Purple(): Color3; - static Magenta(): Color3; - static Yellow(): Color3; - static Gray(): Color3; - static Teal(): Color3; - static Random(): Color3; + static Parse(source: any): ColorCurves; } - class Color4 { - r: number; - g: number; - b: number; - a: number; - /** - * Creates a new Color4 object from the passed float values ( < 1) : red, green, blue, alpha. - */ - constructor(r?: number, g?: number, b?: number, a?: number); - /** - * Adds in place the passed Color4 values to the current Color4. - * Returns the updated Color4. - */ - addInPlace(right: any): Color4; - /** - * Returns a new array populated with 4 numeric elements : red, green, blue, alpha values. - */ - asArray(): number[]; - /** - * Stores from the starting index in the passed array the Color4 successive values. - * Returns the Color4. - */ - toArray(array: number[], index?: number): Color4; - /** - * Returns a new Color4 set with the added values of the current Color4 and of the passed one. - */ - add(right: Color4): Color4; - /** - * Returns a new Color4 set with the subtracted values of the passed one from the current Color4. - */ - subtract(right: Color4): Color4; - /** - * Subtracts the passed ones from the current Color4 values and stores the results in "result". - * Returns the Color4. - */ - subtractToRef(right: Color4, result: Color4): Color4; - /** - * Creates a new Color4 with the current Color4 values multiplied by scale. - */ - scale(scale: number): Color4; - /** - * Multiplies the current Color4 values by scale and stores the result in "result". - * Returns the Color4. - */ - scaleToRef(scale: number, result: Color4): Color4; - /** - * Multipy an RGBA Color4 value by another and return a new Color4 object - * @param color The Color4 (RGBA) value to multiply by - * @returns A new Color4. - */ - multiply(color: Color4): Color4; +} + +declare module BABYLON { + class EffectFallbacks { + private _defines; + private _currentRank; + private _maxRank; + private _mesh; + private _meshRank; + addFallback(rank: number, define: string): void; + addCPUSkinningFallback(rank: number, mesh: BABYLON.AbstractMesh): void; + readonly isMoreFallbacks: boolean; + reduce(currentDefines: string): string; + } + class EffectCreationOptions { + attributes: string[]; + uniformsNames: string[]; + uniformBuffersNames: string[]; + samplers: string[]; + defines: any; + fallbacks: EffectFallbacks; + onCompiled: (effect: Effect) => void; + onError: (effect: Effect, errors: string) => void; + indexParameters: any; + maxSimultaneousLights: number; + } + class Effect { + name: any; + defines: string; + onCompiled: (effect: Effect) => void; + onError: (effect: Effect, errors: string) => void; + onBind: (effect: Effect) => void; + uniqueId: number; + onCompileObservable: Observable; + onErrorObservable: Observable; + onBindObservable: Observable; + private static _uniqueIdSeed; + private _engine; + private _uniformBuffersNames; + private _uniformsNames; + private _samplers; + private _isReady; + private _compilationError; + private _attributesNames; + private _attributes; + private _uniforms; + _key: string; + private _indexParameters; + private _fallbacks; + private _program; + private _valueCache; + private static _baseCache; + constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], engine?: Engine, defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, indexParameters?: any); + readonly key: string; + isReady(): boolean; + getEngine(): Engine; + getProgram(): WebGLProgram; + getAttributesNames(): string[]; + getAttributeLocation(index: number): number; + getAttributeLocationByName(name: string): number; + getAttributesCount(): number; + getUniformIndex(uniformName: string): number; + getUniform(uniformName: string): WebGLUniformLocation; + getSamplers(): string[]; + getCompilationError(): string; + getVertexShaderSource(): string; + getFragmentShaderSource(): string; + executeWhenCompiled(func: (effect: Effect) => void): void; + _loadVertexShader(vertex: any, callback: (data: any) => void): void; + _loadFragmentShader(fragment: any, callback: (data: any) => void): void; + private _dumpShadersSource(vertexCode, fragmentCode, defines); + private _processShaderConversion(sourceCode, isFragment, callback); + private _processIncludes(sourceCode, callback); + private _processPrecision(source); + private _prepareEffect(vertexSourceCode, fragmentSourceCode, attributesNames, defines, fallbacks?); + readonly isSupported: boolean; + _bindTexture(channel: string, texture: WebGLTexture): void; + setTexture(channel: string, texture: BaseTexture): void; + setTextureArray(channel: string, textures: BaseTexture[]): void; + setTextureFromPostProcess(channel: string, postProcess: PostProcess): void; + _cacheMatrix(uniformName: string, matrix: Matrix): boolean; + _cacheFloat2(uniformName: string, x: number, y: number): boolean; + _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean; + _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean; + bindUniformBuffer(buffer: WebGLBuffer, name: string): void; + bindUniformBlock(blockName: string, index: number): void; + setIntArray(uniformName: string, array: Int32Array): Effect; + setIntArray2(uniformName: string, array: Int32Array): Effect; + setIntArray3(uniformName: string, array: Int32Array): Effect; + setIntArray4(uniformName: string, array: Int32Array): Effect; + setFloatArray(uniformName: string, array: Float32Array): Effect; + setFloatArray2(uniformName: string, array: Float32Array): Effect; + setFloatArray3(uniformName: string, array: Float32Array): Effect; + setFloatArray4(uniformName: string, array: Float32Array): Effect; + setArray(uniformName: string, array: number[]): Effect; + setArray2(uniformName: string, array: number[]): Effect; + setArray3(uniformName: string, array: number[]): Effect; + setArray4(uniformName: string, array: number[]): Effect; + setMatrices(uniformName: string, matrices: Float32Array): Effect; + setMatrix(uniformName: string, matrix: Matrix): Effect; + setMatrix3x3(uniformName: string, matrix: Float32Array): Effect; + setMatrix2x2(uniformName: string, matrix: Float32Array): Effect; + setFloat(uniformName: string, value: number): Effect; + setBool(uniformName: string, bool: boolean): Effect; + setVector2(uniformName: string, vector2: Vector2): Effect; + setFloat2(uniformName: string, x: number, y: number): Effect; + setVector3(uniformName: string, vector3: Vector3): Effect; + setFloat3(uniformName: string, x: number, y: number, z: number): Effect; + setVector4(uniformName: string, vector4: Vector4): Effect; + setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect; + setColor3(uniformName: string, color3: Color3): Effect; + setColor4(uniformName: string, color3: Color3, alpha: number): Effect; + private _recombineShader(node); + private _evaluateDefinesOnString(shaderString); + static ShadersStore: {}; + static IncludesShadersStore: {}; + static ResetCache(): void; + } +} + +declare module BABYLON { + class FresnelParameters { + private _isEnabled; + isEnabled: boolean; + leftColor: Color3; + rightColor: Color3; + bias: number; + power: number; + clone(): FresnelParameters; + serialize(): any; + static Parse(parsedFresnelParameters: any): FresnelParameters; + } +} + +declare module BABYLON { + /** + * Interface to follow in your material defines to integrate easily the + * Image proccessing functions. + */ + interface IImageProcessingConfigurationDefines { + IMAGEPROCESSING: boolean; + VIGNETTE: boolean; + VIGNETTEBLENDMODEMULTIPLY: boolean; + VIGNETTEBLENDMODEOPAQUE: boolean; + TONEMAPPING: boolean; + CONTRAST: boolean; + EXPOSURE: boolean; + COLORCURVES: boolean; + COLORGRADING: boolean; + SAMPLER3DGREENDEPTH: boolean; + SAMPLER3DBGRMAP: boolean; + IMAGEPROCESSINGPOSTPROCESS: boolean; + } + /** + * 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 { /** - * Multipy an RGBA Color4 value by another and push the result in a reference value - * @param color The Color4 (RGBA) value to multiply by - * @param result The Color4 (RGBA) to fill the result in - * @returns the result Color4. + * Color curves setup used in the effect if colorCurvesEnabled is set to true */ - multiplyToRef(color: Color4, result: Color4): Color4; + colorCurves: ColorCurves; + private _colorCurvesEnabled; /** - * Returns a string with the Color4 values. + * Gets wether the color curves effect is enabled. */ - toString(): string; /** - * Returns the string "Color4" + * Sets wether the color curves effect is enabled. */ - getClassName(): string; + colorCurvesEnabled: boolean; /** - * Return the Color4 hash code as a number. + * Color grading LUT texture used in the effect if colorGradingEnabled is set to true */ - getHashCode(): number; + colorGradingTexture: BaseTexture; + private _colorGradingEnabled; /** - * Creates a new Color4 copied from the current one. + * Gets wether the color grading effect is enabled. */ - clone(): Color4; /** - * Copies the passed Color4 values into the current one. - * Returns the updated Color4. + * Sets wether the color grading effect is enabled. */ - copyFrom(source: Color4): Color4; + colorGradingEnabled: boolean; + private _colorGradingWithGreenDepth; /** - * Copies the passed float values into the current one. - * Returns the updated Color4. + * Gets wether the color grading effect is using a green depth for the 3d Texture. */ - copyFromFloats(r: number, g: number, b: number, a: number): Color4; /** - * Copies the passed float values into the current one. - * Returns the updated Color4. + * Sets wether the color grading effect is using a green depth for the 3d Texture. */ - set(r: number, g: number, b: number, a: number): Color4; + colorGradingWithGreenDepth: boolean; + private _colorGradingBGR; /** - * Returns a string containing the hexadecimal Color4 code. + * Gets wether the color grading texture contains BGR values. */ - toHexString(): string; /** - * Returns a new Color4 converted to linear space. + * Sets wether the color grading texture contains BGR values. */ - toLinearSpace(): Color4; + colorGradingBGR: boolean; + _exposure: number; /** - * Converts the Color4 values to linear space and stores the result in "convertedColor". - * Returns the unmodified Color4. + * Gets the Exposure used in the effect. */ - toLinearSpaceToRef(convertedColor: Color4): Color4; /** - * Returns a new Color4 converted to gamma space. + * Sets the Exposure used in the effect. */ - toGammaSpace(): Color4; + exposure: number; + private _toneMappingEnabled; /** - * Converts the Color4 values to gamma space and stores the result in "convertedColor". - * Returns the unmodified Color4. + * Gets wether the tone mapping effect is enabled. */ - toGammaSpaceToRef(convertedColor: Color4): Color4; /** - * Creates a new Color4 from the valid hexadecimal value contained in the passed string. + * Sets wether the tone mapping effect is enabled. */ - static FromHexString(hex: string): Color4; + toneMappingEnabled: boolean; + protected _contrast: number; /** - * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 and the right Color4. + * Gets the contrast used in the effect. */ - static Lerp(left: Color4, right: Color4, amount: number): Color4; /** - * Set the passed "result" with the linearly interpolated values of "amount" between the left Color4 and the right Color4. + * Sets the contrast used in the effect. */ - static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void; + contrast: number; /** - * Creates a new Color4 from the starting index element of the passed array. + * Vignette stretch size. */ - static FromArray(array: ArrayLike, offset?: number): Color4; + vignetteStretch: number; /** - * Creates a new Color4 from the passed integers ( < 256 ). + * Vignette centre X Offset. */ - static FromInts(r: number, g: number, b: number, a: number): Color4; - static CheckColors4(colors: number[], count: number): number[]; - } - class Vector2 { - x: number; - y: number; + vignetteCentreX: number; /** - * Creates a new Vector2 from the passed x and y coordinates. + * Vignette centre Y Offset. */ - constructor(x: number, y: number); - /** - * Returns a string with the Vector2 coordinates. - */ - toString(): string; - /** - * Returns the string "Vector2" - */ - getClassName(): string; - /** - * Returns the Vector2 hash code as a number. - */ - getHashCode(): number; - /** - * Sets the Vector2 coordinates in the passed array or Float32Array from the passed index. - * Returns the Vector2. - */ - toArray(array: number[] | Float32Array, index?: number): Vector2; - /** - * Returns a new array with 2 elements : the Vector2 coordinates. - */ - asArray(): number[]; + vignetteCentreY: number; /** - * Sets the Vector2 coordinates with the passed Vector2 coordinates. - * Returns the updated Vector2. + * Vignette weight or intensity of the vignette effect. */ - copyFrom(source: Vector2): Vector2; + vignetteWeight: number; /** - * Sets the Vector2 coordinates with the passed floats. - * Returns the updated Vector2. + * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode) + * if vignetteEnabled is set to true. */ - copyFromFloats(x: number, y: number): Vector2; + vignetteColor: BABYLON.Color4; /** - * Sets the Vector2 coordinates with the passed floats. - * Returns the updated Vector2. + * Camera field of view used by the Vignette effect. */ - set(x: number, y: number): Vector2; + vignetteCameraFov: number; + private _vignetteBlendMode; /** - * Returns a new Vector2 set with the addition of the current Vector2 and the passed one coordinates. + * Gets the vignette blend mode allowing different kind of effect. */ - add(otherVector: Vector2): Vector2; /** - * Sets the "result" coordinates with the addition of the current Vector2 and the passed one coordinates. - * Returns the Vector2. + * Sets the vignette blend mode allowing different kind of effect. */ - addToRef(otherVector: Vector2, result: Vector2): Vector2; + vignetteBlendMode: number; + private _vignetteEnabled; /** - * Set the Vector2 coordinates by adding the passed Vector2 coordinates. - * Returns the updated Vector2. + * Gets wether the vignette effect is enabled. */ - addInPlace(otherVector: Vector2): Vector2; /** - * Returns a new Vector2 by adding the current Vector2 coordinates to the passed Vector3 x, y coordinates. + * Sets wether the vignette effect is enabled. */ - addVector3(otherVector: Vector3): Vector2; + vignetteEnabled: boolean; + private _applyByPostProcess; /** - * Returns a new Vector2 set with the subtracted coordinates of the passed one from the current Vector2. + * Gets wether the image processing is applied through a post process or not. */ - subtract(otherVector: Vector2): Vector2; /** - * Sets the "result" coordinates with the subtraction of the passed one from the current Vector2 coordinates. - * Returns the Vector2. + * Sets wether the image processing is applied through a post process or not. */ - subtractToRef(otherVector: Vector2, result: Vector2): Vector2; + applyByPostProcess: boolean; /** - * Sets the current Vector2 coordinates by subtracting from it the passed one coordinates. - * Returns the updated Vector2. - */ - subtractInPlace(otherVector: Vector2): Vector2; + * An event triggered when the configuration changes and requires Shader to Update some parameters. + * @type {BABYLON.Observable} + */ + onUpdateParameters: Observable; /** - * Multiplies in place the current Vector2 coordinates by the passed ones. - * Returns the updated Vector2. + * Method called each time the image processing information changes requires to recompile the effect. */ - multiplyInPlace(otherVector: Vector2): Vector2; + protected _updateParameters(): void; + getClassName(): string; /** - * Returns a new Vector2 set with the multiplication of the current Vector2 and the passed one coordinates. + * Prepare the list of uniforms associated with the Image Processing effects. + * @param uniformsList The list of uniforms used in the effect + * @param defines the list of defines currently in use */ - multiply(otherVector: Vector2): Vector2; + static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void; /** - * Sets "result" coordinates with the multiplication of the current Vector2 and the passed one coordinates. - * Returns the Vector2. + * Prepare the list of samplers associated with the Image Processing effects. + * @param uniformsList The list of uniforms used in the effect + * @param defines the list of defines currently in use */ - multiplyToRef(otherVector: Vector2, result: Vector2): Vector2; + static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void; /** - * Returns a new Vector2 set with the Vector2 coordinates multiplied by the passed floats. + * Prepare the list of defines associated to the shader. + * @param defines the list of defines to complete */ - multiplyByFloats(x: number, y: number): Vector2; + prepareDefines(defines: IImageProcessingConfigurationDefines): void; /** - * Returns a new Vector2 set with the Vector2 coordinates divided by the passed one coordinates. + * Returns true if all the image processing information are ready. */ - divide(otherVector: Vector2): Vector2; + isReady(): boolean; /** - * Sets the "result" coordinates with the Vector2 divided by the passed one coordinates. - * Returns the Vector2. + * Binds the image processing to the shader. + * @param effect The effect to bind to */ - divideToRef(otherVector: Vector2, result: Vector2): Vector2; + bind(effect: Effect, aspectRatio?: number): void; /** - * Returns a new Vector2 with current Vector2 negated coordinates. + * Clones the current image processing instance. + * @return The cloned image processing */ - negate(): Vector2; + clone(): ImageProcessingConfiguration; /** - * Multiply the Vector2 coordinates by scale. - * Returns the updated Vector2. + * Serializes the current image processing instance to a json representation. + * @return a JSON representation */ - scaleInPlace(scale: number): Vector2; + serialize(): any; /** - * Returns a new Vector2 scaled by "scale" from the current Vector2. + * Parses the image processing from a json representation. + * @param source the JSON source to parse + * @return The parsed image processing */ - scale(scale: number): Vector2; + static Parse(source: any): ImageProcessingConfiguration; + private static _VIGNETTEMODE_MULTIPLY; + private static _VIGNETTEMODE_OPAQUE; /** - * Boolean : True if the passed vector coordinates strictly equal the current Vector2 ones. + * Used to apply the vignette as a mix with the pixel color. */ - equals(otherVector: Vector2): boolean; + static readonly VIGNETTEMODE_MULTIPLY: number; /** - * Boolean : True if the passed vector coordinates are close to the current ones by a distance of epsilon. + * Used to apply the vignette as a replacement of the pixel color. */ - equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean; + static readonly VIGNETTEMODE_OPAQUE: number; + } +} + +declare module BABYLON { + class MaterialDefines { + private _keys; + private _isDirty; + _renderId: number; + _areLightsDirty: boolean; + _areAttributesDirty: boolean; + _areTexturesDirty: boolean; + _areFresnelDirty: boolean; + _areMiscDirty: boolean; + _areImageProcessingDirty: boolean; + _normals: boolean; + _uvs: boolean; + _needNormals: boolean; + _needUVs: boolean; + readonly isDirty: boolean; + markAsProcessed(): void; + markAsUnprocessed(): void; + markAllAsDirty(): void; + markAsImageProcessingDirty(): void; + markAsLightDirty(): void; + markAsAttributesDirty(): void; + markAsTexturesDirty(): void; + markAsFresnelDirty(): void; + markAsMiscDirty(): void; + rebuild(): void; + isEqual(other: MaterialDefines): boolean; + cloneTo(other: MaterialDefines): void; + reset(): void; + toString(): string; + } + class Material { + private static _TriangleFillMode; + private static _WireFrameFillMode; + private static _PointFillMode; + static readonly TriangleFillMode: number; + static readonly WireFrameFillMode: number; + static readonly PointFillMode: number; + private static _ClockWiseSideOrientation; + private static _CounterClockWiseSideOrientation; + static readonly ClockWiseSideOrientation: number; + static readonly CounterClockWiseSideOrientation: number; + private static _TextureDirtyFlag; + private static _LightDirtyFlag; + private static _FresnelDirtyFlag; + private static _AttributesDirtyFlag; + private static _MiscDirtyFlag; + static readonly TextureDirtyFlag: number; + static readonly LightDirtyFlag: number; + static readonly FresnelDirtyFlag: number; + static readonly AttributesDirtyFlag: number; + static readonly MiscDirtyFlag: number; + id: string; + name: string; + checkReadyOnEveryCall: boolean; + checkReadyOnlyOnce: boolean; + state: string; + alpha: number; + protected _backFaceCulling: boolean; + backFaceCulling: boolean; + sideOrientation: number; + onCompiled: (effect: Effect) => void; + onError: (effect: Effect, errors: string) => void; + getRenderTargetTextures: () => SmartArray; + doNotSerialize: boolean; + storeEffectOnSubMeshes: boolean; /** - * Returns the vector length (float). - */ - length(): number; + * An event triggered when the material is disposed. + * @type {BABYLON.Observable} + */ + onDisposeObservable: Observable; + private _onDisposeObserver; + onDispose: () => void; /** - * Returns the vector squared length (float); - */ - lengthSquared(): number; + * An event triggered when the material is bound. + * @type {BABYLON.Observable} + */ + onBindObservable: Observable; + private _onBindObserver; + onBind: (Mesh: AbstractMesh) => void; /** - * Normalize the vector. - * Returns the updated Vector2. - */ - normalize(): Vector2; + * An event triggered when the material is unbound. + * @type {BABYLON.Observable} + */ + onUnBindObservable: Observable; + alphaMode: number; + disableDepthWrite: boolean; + private _fogEnabled; + fogEnabled: boolean; + pointSize: number; + zOffset: number; + wireframe: boolean; + pointsCloud: boolean; + fillMode: number; + _effect: Effect; + _wasPreviouslyReady: boolean; + private _useUBO; + private _scene; + private _fillMode; + private _cachedDepthWriteState; + protected _uniformBuffer: UniformBuffer; + constructor(name: string, scene: Scene, doNotAdd?: boolean); /** - * Returns a new Vector2 copied from the Vector2. + * @param {boolean} fullDetails - support for multiple levels of logging within scene loading + * subclasses should override adding information pertainent to themselves */ - clone(): Vector2; + toString(fullDetails?: boolean): string; /** - * Returns a new Vector2(0, 0) + * Child classes can use it to update shaders */ - static Zero(): Vector2; - /** - * Returns a new Vector2(1, 1) - */ - static One(): Vector2; - /** - * Returns a new Vector2 set from the passed index element of the passed array. - */ - static FromArray(array: ArrayLike, offset?: number): Vector2; - /** - * Sets "result" from the passed index element of the passed array. - */ - static FromArrayToRef(array: ArrayLike, offset: number, result: Vector2): void; - /** - * Retuns a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the passed four Vector2. - */ - static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2; - /** - * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max". - * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate. - * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate. - */ - static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2; - /** - * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2". - */ - static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2; - /** - * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end". - */ - static Lerp(start: Vector2, end: Vector2, amount: number): Vector2; - /** - * Returns the dot product (float) of the vector "left" and the vector "right". - */ - static Dot(left: Vector2, right: Vector2): number; - /** - * Returns a new Vector2 equal to the normalized passed vector. - */ - static Normalize(vector: Vector2): Vector2; - /** - * Returns a new Vecto2 set with the minimal coordinate values from the "left" and "right" vectors. - */ - static Minimize(left: Vector2, right: Vector2): Vector2; - /** - * Returns a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors. - */ - static Maximize(left: Vector2, right: Vector2): Vector2; - /** - * Returns a new Vecto2 set with the transformed coordinates of the passed vector by the passed transformation matrix. - */ - static Transform(vector: Vector2, transformation: Matrix): Vector2; - /** - * Transforms the passed vector coordinates by the passed transformation matrix and stores the result in the vector "result" coordinates. - */ - static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void; - /** - * Boolean : True if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2" - */ - static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean; - /** - * Returns the distance (float) between the vectors "value1" and "value2". - */ - static Distance(value1: Vector2, value2: Vector2): number; - /** - * Returns the squared distance (float) between the vectors "value1" and "value2". - */ - static DistanceSquared(value1: Vector2, value2: Vector2): number; - /** - * Returns a new Vecto2 located at the center of the vectors "value1" and "value2". - */ - static Center(value1: Vector2, value2: Vector2): Vector2; + getClassName(): string; + readonly isFrozen: boolean; + freeze(): void; + unfreeze(): void; + isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean; + isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean; + getEffect(): Effect; + getScene(): Scene; + needAlphaBlending(): boolean; + needAlphaTesting(): boolean; + getAlphaTestTexture(): BaseTexture; + markDirty(): void; + _preBind(effect?: Effect): void; + bind(world: Matrix, mesh?: Mesh): void; + bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void; + bindOnlyWorldMatrix(world: Matrix): void; + bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void; + bindView(effect: Effect): void; + bindViewProjection(effect: Effect): void; + protected _afterBind(mesh: Mesh): void; + unbind(): void; + getActiveTextures(): BaseTexture[]; + hasTexture(texture: BaseTexture): boolean; + clone(name: string): Material; + getBindedMeshes(): AbstractMesh[]; /** - * Returns the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB". + * Force shader compilation including textures ready check */ - static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number; + forceCompilation(mesh: AbstractMesh, onCompiled: (material: Material) => void, options?: { + alphaTest: boolean; + clipPlane: boolean; + }): void; + markAsDirty(flag: number): void; + protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void; + protected _markAllSubMeshesAsImageProcessingDirty(): void; + protected _markAllSubMeshesAsTexturesDirty(): void; + protected _markAllSubMeshesAsFresnelDirty(): void; + protected _markAllSubMeshesAsLightsDirty(): void; + protected _markAllSubMeshesAsAttributesDirty(): void; + protected _markAllSubMeshesAsMiscDirty(): void; + dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void; + serialize(): any; + static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial; + static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any; } - class Vector3 { - x: number; - y: number; - z: number; - /** - * Creates a new Vector3 object from the passed x, y, z (floats) coordinates. - * A Vector3 is the main object used in 3D geometry. - * It can represent etiher the coordinates of a point the space, either a direction. - */ - constructor(x: number, y: number, z: number); - /** - * Returns a string with the Vector3 coordinates. - */ - toString(): string; - /** - * Returns the string "Vector3" - */ +} + +declare module BABYLON { + class MaterialHelper { + static PrepareDefinesForMergedUV(texture: BaseTexture, defines: MaterialDefines, key: string): void; + static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void; + static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: any, fogEnabled: boolean, defines: MaterialDefines): void; + static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: MaterialDefines, useInstances: boolean, forceAlphaTest?: boolean): void; + static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: MaterialDefines, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean): boolean; + static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: MaterialDefines, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean; + static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: MaterialDefines, maxSimultaneousLights?: number): void; + static HandleFallbacksForShadows(defines: MaterialDefines, fallbacks: EffectFallbacks, maxSimultaneousLights?: number): void; + static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: MaterialDefines): void; + static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: MaterialDefines, fallbacks: EffectFallbacks): void; + static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void; + static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void; + static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void; + static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: MaterialDefines, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void; + static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect): void; + static BindBonesParameters(mesh: AbstractMesh, effect: Effect): void; + static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void; + static BindLogDepth(defines: MaterialDefines, effect: Effect, scene: Scene): void; + static BindClipPlane(effect: Effect, scene: Scene): void; + } +} + +declare module BABYLON { + class MultiMaterial extends Material { + private _subMaterials; + subMaterials: Material[]; + constructor(name: string, scene: Scene); + private _hookArray(array); + getSubMaterial(index: any): Material; + getActiveTextures(): BaseTexture[]; getClassName(): string; + isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean; + clone(name: string, cloneChildren?: boolean): MultiMaterial; + serialize(): any; + dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void; + } +} + +declare module BABYLON { + class PushMaterial extends Material { + protected _activeEffect: Effect; + constructor(name: string, scene: Scene); + getEffect(): Effect; + isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean; + bindOnlyWorldMatrix(world: Matrix): void; + bind(world: Matrix, mesh?: Mesh): void; + protected _afterBind(mesh: Mesh, effect?: Effect): void; + protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean; + } +} + +declare module BABYLON { + class ShaderMaterial extends Material { + private _shaderPath; + private _options; + private _textures; + private _textureArrays; + private _floats; + private _floatsArrays; + private _colors3; + private _colors3Arrays; + private _colors4; + private _vectors2; + private _vectors3; + private _vectors4; + private _matrices; + private _matrices3x3; + private _matrices2x2; + private _vectors3Arrays; + private _cachedWorldViewMatrix; + private _renderId; + constructor(name: string, scene: Scene, shaderPath: any, options: any); + getClassName(): string; + needAlphaBlending(): boolean; + needAlphaTesting(): boolean; + private _checkUniform(uniformName); + setTexture(name: string, texture: Texture): ShaderMaterial; + setTextureArray(name: string, textures: Texture[]): ShaderMaterial; + setFloat(name: string, value: number): ShaderMaterial; + setFloats(name: string, value: number[]): ShaderMaterial; + setColor3(name: string, value: Color3): ShaderMaterial; + setColor3Array(name: string, value: Color3[]): ShaderMaterial; + setColor4(name: string, value: Color4): ShaderMaterial; + setVector2(name: string, value: Vector2): ShaderMaterial; + setVector3(name: string, value: Vector3): ShaderMaterial; + setVector4(name: string, value: Vector4): ShaderMaterial; + setMatrix(name: string, value: Matrix): ShaderMaterial; + setMatrix3x3(name: string, value: Float32Array): ShaderMaterial; + setMatrix2x2(name: string, value: Float32Array): ShaderMaterial; + setArray3(name: string, value: number[]): ShaderMaterial; + private _checkCache(scene, mesh?, useInstances?); + isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean; + bindOnlyWorldMatrix(world: Matrix): void; + bind(world: Matrix, mesh?: Mesh): void; + getActiveTextures(): BaseTexture[]; + hasTexture(texture: BaseTexture): boolean; + clone(name: string): ShaderMaterial; + dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void; + serialize(): any; + static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial; + } +} + +declare module BABYLON { + class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines { + MAINUV1: boolean; + MAINUV2: boolean; + DIFFUSE: boolean; + DIFFUSEDIRECTUV: number; + AMBIENT: boolean; + AMBIENTDIRECTUV: number; + OPACITY: boolean; + OPACITYDIRECTUV: number; + OPACITYRGB: boolean; + REFLECTION: boolean; + EMISSIVE: boolean; + EMISSIVEDIRECTUV: number; + SPECULAR: boolean; + SPECULARDIRECTUV: number; + BUMP: boolean; + BUMPDIRECTUV: number; + PARALLAX: boolean; + PARALLAXOCCLUSION: boolean; + SPECULAROVERALPHA: boolean; + CLIPPLANE: boolean; + ALPHATEST: boolean; + ALPHAFROMDIFFUSE: boolean; + POINTSIZE: boolean; + FOG: boolean; + SPECULARTERM: boolean; + DIFFUSEFRESNEL: boolean; + OPACITYFRESNEL: boolean; + REFLECTIONFRESNEL: boolean; + REFRACTIONFRESNEL: boolean; + EMISSIVEFRESNEL: boolean; + FRESNEL: boolean; + NORMAL: boolean; + UV1: boolean; + UV2: boolean; + VERTEXCOLOR: boolean; + VERTEXALPHA: boolean; + NUM_BONE_INFLUENCERS: number; + BonesPerMesh: number; + INSTANCES: boolean; + GLOSSINESS: boolean; + ROUGHNESS: boolean; + EMISSIVEASILLUMINATION: boolean; + LINKEMISSIVEWITHDIFFUSE: boolean; + REFLECTIONFRESNELFROMSPECULAR: boolean; + LIGHTMAP: boolean; + LIGHTMAPDIRECTUV: number; + USELIGHTMAPASSHADOWMAP: boolean; + REFLECTIONMAP_3D: boolean; + REFLECTIONMAP_SPHERICAL: boolean; + REFLECTIONMAP_PLANAR: boolean; + REFLECTIONMAP_CUBIC: boolean; + REFLECTIONMAP_PROJECTION: boolean; + REFLECTIONMAP_SKYBOX: boolean; + REFLECTIONMAP_EXPLICIT: boolean; + REFLECTIONMAP_EQUIRECTANGULAR: boolean; + REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean; + REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean; + INVERTCUBICMAP: boolean; + LOGARITHMICDEPTH: boolean; + REFRACTION: boolean; + REFRACTIONMAP_3D: boolean; + REFLECTIONOVERALPHA: boolean; + TWOSIDEDLIGHTING: boolean; + SHADOWFLOAT: boolean; + MORPHTARGETS: boolean; + MORPHTARGETS_NORMAL: boolean; + MORPHTARGETS_TANGENT: boolean; + NUM_MORPH_INFLUENCERS: number; + USERIGHTHANDEDSYSTEM: boolean; + IMAGEPROCESSING: boolean; + VIGNETTE: boolean; + VIGNETTEBLENDMODEMULTIPLY: boolean; + VIGNETTEBLENDMODEOPAQUE: boolean; + TONEMAPPING: boolean; + CONTRAST: boolean; + COLORCURVES: boolean; + COLORGRADING: boolean; + SAMPLER3DGREENDEPTH: boolean; + SAMPLER3DBGRMAP: boolean; + IMAGEPROCESSINGPOSTPROCESS: boolean; + EXPOSURE: boolean; + constructor(); + setReflectionMode(modeToEnable: string): void; + } + class StandardMaterial extends PushMaterial { + private _diffuseTexture; + diffuseTexture: BaseTexture; + private _ambientTexture; + ambientTexture: BaseTexture; + private _opacityTexture; + opacityTexture: BaseTexture; + private _reflectionTexture; + reflectionTexture: BaseTexture; + private _emissiveTexture; + emissiveTexture: BaseTexture; + private _specularTexture; + specularTexture: BaseTexture; + private _bumpTexture; + bumpTexture: BaseTexture; + private _lightmapTexture; + lightmapTexture: BaseTexture; + private _refractionTexture; + refractionTexture: BaseTexture; + ambientColor: Color3; + diffuseColor: Color3; + specularColor: Color3; + emissiveColor: Color3; + specularPower: number; + private _useAlphaFromDiffuseTexture; + useAlphaFromDiffuseTexture: boolean; + private _useEmissiveAsIllumination; + useEmissiveAsIllumination: boolean; + private _linkEmissiveWithDiffuse; + linkEmissiveWithDiffuse: boolean; + private _useSpecularOverAlpha; + useSpecularOverAlpha: boolean; + private _useReflectionOverAlpha; + useReflectionOverAlpha: boolean; + private _disableLighting; + disableLighting: boolean; + private _useParallax; + useParallax: boolean; + private _useParallaxOcclusion; + useParallaxOcclusion: boolean; + parallaxScaleBias: number; + private _roughness; + roughness: number; + indexOfRefraction: number; + invertRefractionY: boolean; + private _useLightmapAsShadowmap; + useLightmapAsShadowmap: boolean; + private _diffuseFresnelParameters; + diffuseFresnelParameters: FresnelParameters; + private _opacityFresnelParameters; + opacityFresnelParameters: FresnelParameters; + private _reflectionFresnelParameters; + reflectionFresnelParameters: FresnelParameters; + private _refractionFresnelParameters; + refractionFresnelParameters: FresnelParameters; + private _emissiveFresnelParameters; + emissiveFresnelParameters: FresnelParameters; + private _useReflectionFresnelFromSpecular; + useReflectionFresnelFromSpecular: boolean; + private _useGlossinessFromSpecularMapAlpha; + useGlossinessFromSpecularMapAlpha: boolean; + private _maxSimultaneousLights; + maxSimultaneousLights: number; /** - * Returns the Vector hash code. - */ - getHashCode(): number; - /** - * Returns a new array with three elements : the coordinates the Vector3. - */ - asArray(): number[]; - /** - * Populates the passed array or Float32Array from the passed index with the successive coordinates of the Vector3. - * Returns the Vector3. - */ - toArray(array: number[] | Float32Array, index?: number): Vector3; - /** - * Returns a new Quaternion object, computed from the Vector3 coordinates. - */ - toQuaternion(): Quaternion; - /** - * Adds the passed vector to the current Vector3. - * Returns the updated Vector3. - */ - addInPlace(otherVector: Vector3): Vector3; - /** - * Returns a new Vector3, result of the addition the current Vector3 and the passed vector. - */ - add(otherVector: Vector3): Vector3; - /** - * Adds the current Vector3 to the passed one and stores the result in the vector "result". - * Returns the current Vector3. - */ - addToRef(otherVector: Vector3, result: Vector3): Vector3; - /** - * Subtract the passed vector from the current Vector3. - * Returns the updated Vector3. - */ - subtractInPlace(otherVector: Vector3): Vector3; - /** - * Returns a new Vector3, result of the subtraction of the passed vector from the current Vector3. - */ - subtract(otherVector: Vector3): Vector3; - /** - * Subtracts the passed vector from the current Vector3 and stores the result in the vector "result". - * Returns the current Vector3. - */ - subtractToRef(otherVector: Vector3, result: Vector3): Vector3; - /** - * Returns a new Vector3 set with the subtraction of the passed floats from the current Vector3 coordinates. - */ - subtractFromFloats(x: number, y: number, z: number): Vector3; - /** - * Subtracts the passed floats from the current Vector3 coordinates and set the passed vector "result" with this result. - * Returns the current Vector3. - */ - subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3; - /** - * Returns a new Vector3 set with the current Vector3 negated coordinates. - */ - negate(): Vector3; - /** - * Multiplies the Vector3 coordinates by the float "scale". - * Returns the updated Vector3. - */ - scaleInPlace(scale: number): Vector3; - /** - * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale". - */ - scale(scale: number): Vector3; - /** - * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the passed vector "result" coordinates. - * Returns the current Vector3. - */ - scaleToRef(scale: number, result: Vector3): Vector3; - /** - * Boolean : True if the current Vector3 and the passed vector coordinates are strictly equal. - */ - equals(otherVector: Vector3): boolean; - /** - * Boolean : True if the current Vector3 and the passed vector coordinates are distant less than epsilon. - */ - equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean; - /** - * Boolean : True if the current Vector3 coordinate equal the passed floats. - */ - equalsToFloats(x: number, y: number, z: number): boolean; - /** - * Muliplies the current Vector3 coordinates by the passed ones. - * Returns the updated Vector3. - */ - multiplyInPlace(otherVector: Vector3): Vector3; - /** - * Returns a new Vector3, result of the multiplication of the current Vector3 by the passed vector. - */ - multiply(otherVector: Vector3): Vector3; - /** - * Multiplies the current Vector3 by the passed one and stores the result in the passed vector "result". - * Returns the current Vector3. + * If sets to true, x component of normal map value will invert (x = 1.0 - x). */ - multiplyToRef(otherVector: Vector3, result: Vector3): Vector3; + private _invertNormalMapX; + invertNormalMapX: boolean; /** - * Returns a new Vector3 set witth the result of the mulliplication of the current Vector3 coordinates by the passed floats. + * If sets to true, y component of normal map value will invert (y = 1.0 - y). */ - multiplyByFloats(x: number, y: number, z: number): Vector3; + private _invertNormalMapY; + invertNormalMapY: boolean; /** - * Returns a new Vector3 set witth the result of the division of the current Vector3 coordinates by the passed ones. + * If sets to true and backfaceCulling is false, normals will be flipped on the backside. */ - divide(otherVector: Vector3): Vector3; + private _twoSidedLighting; + twoSidedLighting: boolean; /** - * Divides the current Vector3 coordinates by the passed ones and stores the result in the passed vector "result". - * Returns the current Vector3. + * Default configuration related to image processing available in the standard Material. */ - divideToRef(otherVector: Vector3, result: Vector3): Vector3; + protected _imageProcessingConfiguration: ImageProcessingConfiguration; /** - * Updates the current Vector3 with the minimal coordinate values between its and the passed vector ones. - * Returns the updated Vector3. + * Gets the image processing configuration used either in this material. */ - MinimizeInPlace(other: Vector3): Vector3; /** - * Updates the current Vector3 with the maximal coordinate values between its and the passed vector ones. - * Returns the updated Vector3. + * Sets the Default image processing configuration used either in the this material. + * + * If sets to null, the scene one is in use. */ - MaximizeInPlace(other: Vector3): Vector3; + imageProcessingConfiguration: ImageProcessingConfiguration; /** - * Returns the length of the Vector3 (float). + * Keep track of the image processing observer to allow dispose and replace. */ - length(): number; + private _imageProcessingObserver; /** - * Returns the squared length of the Vector3 (float). + * Attaches a new image processing configuration to the Standard Material. + * @param configuration */ - lengthSquared(): number; + protected _attachImageProcessingConfiguration(configuration: ImageProcessingConfiguration): void; /** - * Normalize the current Vector3. - * Returns the updated Vector3. + * Gets wether the color curves effect is enabled. */ - normalize(): Vector3; /** - * Returns a new Vector3 copied from the current Vector3. + * Sets wether the color curves effect is enabled. */ - clone(): Vector3; + cameraColorCurvesEnabled: boolean; /** - * Copies the passed vector coordinates to the current Vector3 ones. - * Returns the updated Vector3. + * Gets wether the color grading effect is enabled. */ - copyFrom(source: Vector3): Vector3; /** - * Copies the passed floats to the current Vector3 coordinates. - * Returns the updated Vector3. + * Gets wether the color grading effect is enabled. */ - copyFromFloats(x: number, y: number, z: number): Vector3; + cameraColorGradingEnabled: boolean; /** - * Copies the passed floats to the current Vector3 coordinates. - * Returns the updated Vector3. + * Gets wether tonemapping is enabled or not. */ - set(x: number, y: number, z: number): Vector3; /** - * + * Sets wether tonemapping is enabled or not */ - static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: any): number; + cameraToneMappingEnabled: boolean; /** - * Returns a new Vector3 set from the index "offset" of the passed array. + * The camera exposure used on this material. + * This property is here and not in the camera to allow controlling exposure without full screen post process. + * This corresponds to a photographic exposure. */ - static FromArray(array: ArrayLike, offset?: number): Vector3; /** - * Returns a new Vector3 set from the index "offset" of the passed Float32Array. - * This function is deprecated. Use FromArray instead. + * The camera exposure used on this material. + * This property is here and not in the camera to allow controlling exposure without full screen post process. + * This corresponds to a photographic exposure. */ - static FromFloatArray(array: Float32Array, offset?: number): Vector3; + cameraExposure: number; /** - * Sets the passed vector "result" with the element values from the index "offset" of the passed array. + * Gets The camera contrast used on this material. */ - static FromArrayToRef(array: ArrayLike, offset: number, result: Vector3): void; /** - * Sets the passed vector "result" with the element values from the index "offset" of the passed Float32Array. - * This function is deprecated. Use FromArrayToRef instead. + * Sets The camera contrast used on this material. */ - static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void; + cameraContrast: number; /** - * Sets the passed vector "result" with the passed floats. + * Gets the Color Grading 2D Lookup Texture. */ - static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void; /** - * Returns a new Vector3 set to (0.0, 0.0, 0.0). + * Sets the Color Grading 2D Lookup Texture. */ - static Zero(): Vector3; + cameraColorGradingTexture: BaseTexture; + customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string; + protected _renderTargets: SmartArray; + protected _worldViewProjectionMatrix: Matrix; + protected _globalAmbientColor: Color3; + protected _useLogarithmicDepth: boolean; + constructor(name: string, scene: Scene); + getClassName(): string; + useLogarithmicDepth: boolean; + needAlphaBlending(): boolean; + needAlphaTesting(): boolean; + protected _shouldUseAlphaFromDiffuseTexture(): boolean; + getAlphaTestTexture(): BaseTexture; /** - * Returns a new Vector3 set to (1.0, 1.0, 1.0). + * Child classes can use it to update shaders */ - static One(): Vector3; + isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean; + buildUniformLayout(): void; + unbind(): void; + bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void; + getAnimatables(): IAnimatable[]; + getActiveTextures(): BaseTexture[]; + hasTexture(texture: BaseTexture): boolean; + dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void; + clone(name: string): StandardMaterial; + serialize(): any; + static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial; + static _DiffuseTextureEnabled: boolean; + static DiffuseTextureEnabled: boolean; + static _AmbientTextureEnabled: boolean; + static AmbientTextureEnabled: boolean; + static _OpacityTextureEnabled: boolean; + static OpacityTextureEnabled: boolean; + static _ReflectionTextureEnabled: boolean; + static ReflectionTextureEnabled: boolean; + static _EmissiveTextureEnabled: boolean; + static EmissiveTextureEnabled: boolean; + static _SpecularTextureEnabled: boolean; + static SpecularTextureEnabled: boolean; + static _BumpTextureEnabled: boolean; + static BumpTextureEnabled: boolean; + static _LightmapTextureEnabled: boolean; + static LightmapTextureEnabled: boolean; + static _RefractionTextureEnabled: boolean; + static RefractionTextureEnabled: boolean; + static _ColorGradingTextureEnabled: boolean; + static ColorGradingTextureEnabled: boolean; + static _FresnelEnabled: boolean; + static FresnelEnabled: boolean; + } +} + +declare module BABYLON { + class UniformBuffer { + private _engine; + private _buffer; + private _data; + private _bufferData; + private _dynamic; + private _uniformName; + private _uniformLocations; + private _uniformSizes; + private _uniformLocationPointer; + private _needSync; + private _cache; + private _noUBO; + private _currentEffect; + private static _MAX_UNIFORM_SIZE; + private static _tempBuffer; /** - * Returns a new Vector3 set to (0.0, 1.0, 0.0) + * Wrapper for updateUniform. + * @method updateMatrix3x3 + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {Float32Array} matrix */ - static Up(): Vector3; + updateMatrix3x3: (name: string, matrix: Float32Array) => void; /** - * Returns a new Vector3 set to (0.0, 0.0, 1.0) + * Wrapper for updateUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {Float32Array} matrix */ - static Forward(): Vector3; + updateMatrix2x2: (name: string, matrix: Float32Array) => void; /** - * Returns a new Vector3 set to (1.0, 0.0, 0.0) + * Wrapper for updateUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {number} x */ - static Right(): Vector3; + updateFloat: (name: string, x: number) => void; /** - * Returns a new Vector3 set to (-1.0, 0.0, 0.0) + * Wrapper for updateUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {number} x + * @param {number} y + * @param {string} [suffix] Suffix to add to the uniform name. */ - static Left(): Vector3; + updateFloat2: (name: string, x: number, y: number, suffix?: string) => void; /** - * Returns a new Vector3 set with the result of the transformation by the passed matrix of the passed vector. - * This method computes tranformed coordinates only, not transformed direction vectors. + * Wrapper for updateUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {number} x + * @param {number} y + * @param {number} z + * @param {string} [suffix] Suffix to add to the uniform name. */ - static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3; + updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void; /** - * Sets the passed vector "result" coordinates with the result of the transformation by the passed matrix of the passed vector. - * This method computes tranformed coordinates only, not transformed direction vectors. + * Wrapper for updateUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {number} x + * @param {number} y + * @param {number} z + * @param {number} w + * @param {string} [suffix] Suffix to add to the uniform name. */ - static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void; + updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void; /** - * Sets the passed vector "result" coordinates with the result of the transformation by the passed matrix of the passed floats (x, y, z). - * This method computes tranformed coordinates only, not transformed direction vectors. + * Wrapper for updateUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {Matrix} A 4x4 matrix. */ - static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void; + updateMatrix: (name: string, mat: Matrix) => void; /** - * Returns a new Vector3 set with the result of the normal transformation by the passed matrix of the passed vector. - * This methods computes transformed normalized direction vectors only. + * Wrapper for updateUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {Vector3} vector */ - static TransformNormal(vector: Vector3, transformation: Matrix): Vector3; + updateVector3: (name: string, vector: Vector3) => void; /** - * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed vector. - * This methods computes transformed normalized direction vectors only. + * Wrapper for updateUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {Vector4} vector */ - static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void; + updateVector4: (name: string, vector: Vector4) => void; /** - * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed floats (x, y, z). - * This methods computes transformed normalized direction vectors only. + * Wrapper for updateUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {Color3} color + * @param {string} [suffix] Suffix to add to the uniform name. */ - static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void; + updateColor3: (name: string, color: Color3, suffix?: string) => void; /** - * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4". + * Wrapper for updateUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {Color3} color + * @param {number} alpha + * @param {string} [suffix] Suffix to add to the uniform name. */ - static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3; + updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void; /** - * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max". - * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one. - * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one. + * Uniform buffer objects. + * + * Handles blocks of uniform on the GPU. + * + * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls. + * + * For more information, please refer to : + * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object */ - static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3; + constructor(engine: Engine, data?: number[], dynamic?: boolean); /** - * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2". + * Indicates if the buffer is using the WebGL2 UBO implementation, + * or just falling back on setUniformXXX calls. */ - static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3; + readonly useUbo: boolean; /** - * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end". + * Indicates if the WebGL underlying uniform buffer is in sync + * with the javascript cache data. */ - static Lerp(start: Vector3, end: Vector3, amount: number): Vector3; + readonly isSync: boolean; /** - * Sets the passed vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end". + * Indicates if the WebGL underlying uniform buffer is dynamic. + * Also, a dynamic UniformBuffer will disable cache verification and always + * update the underlying WebGL uniform buffer to the GPU. */ - static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void; + isDynamic(): boolean; /** - * Returns the dot product (float) between the vectors "left" and "right". + * The data cache on JS side. */ - static Dot(left: Vector3, right: Vector3): number; + getData(): Float32Array; /** - * Returns a new Vector3 as the cross product of the vectors "left" and "right". - * The cross product is then orthogonal to both "left" and "right". + * The underlying WebGL Uniform buffer. */ - static Cross(left: Vector3, right: Vector3): Vector3; + getBuffer(): WebGLBuffer; /** - * Sets the passed vector "result" with the cross product of "left" and "right". - * The cross product is then orthogonal to both "left" and "right". + * std140 layout specifies how to align data within an UBO structure. + * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159 + * for specs. */ - static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void; + private _fillAlignment(size); /** - * Returns a new Vector3 as the normalization of the passed vector. + * Adds an uniform in the buffer. + * Warning : the subsequents calls of this function must be in the same order as declared in the shader + * for the layout to be correct ! + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {number|number[]} size Data size, or data directly. */ - static Normalize(vector: Vector3): Vector3; + addUniform(name: string, size: number | number[]): void; /** - * Sets the passed vector "result" with the normalization of the passed first vector. + * Wrapper for addUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {Matrix} mat A 4x4 matrix. */ - static NormalizeToRef(vector: Vector3, result: Vector3): void; - private static _viewportMatrixCache; - static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3; - static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3; - static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3; - static Minimize(left: Vector3, right: Vector3): Vector3; - static Maximize(left: Vector3, right: Vector3): Vector3; + addMatrix(name: string, mat: Matrix): void; /** - * Returns the distance (float) between the vectors "value1" and "value2". + * Wrapper for addUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {number} x + * @param {number} y */ - static Distance(value1: Vector3, value2: Vector3): number; + addFloat2(name: string, x: number, y: number): void; /** - * Returns the squared distance (float) between the vectors "value1" and "value2". + * Wrapper for addUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {number} x + * @param {number} y + * @param {number} z */ - static DistanceSquared(value1: Vector3, value2: Vector3): number; + addFloat3(name: string, x: number, y: number, z: number): void; /** - * Returns a new Vector3 located at the center between "value1" and "value2". + * Wrapper for addUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {Color3} color */ - static Center(value1: Vector3, value2: Vector3): Vector3; + addColor3(name: string, color: Color3): void; /** - * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system), - * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply - * to something in order to rotate it from its local system to the given target system. - * Note : axis1, axis2 and axis3 are normalized during this operation. - * Returns a new Vector3. + * Wrapper for addUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {Color3} color + * @param {number} alpha */ - static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3; + addColor4(name: string, color: Color3, alpha: number): void; /** - * The same than RotationFromAxis but updates the passed ref Vector3 parameter instead of returning a new Vector3. + * Wrapper for addUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {Vector3} vector */ - static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void; - } - class Vector4 { - x: number; - y: number; - z: number; - w: number; + addVector3(name: string, vector: Vector3): void; /** - * Creates a Vector4 object from the passed floats. + * Wrapper for addUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. */ - constructor(x: number, y: number, z: number, w: number); + addMatrix3x3(name: string): void; /** - * Returns the string with the Vector4 coordinates. + * Wrapper for addUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. */ - toString(): string; + addMatrix2x2(name: string): void; /** - * Returns the string "Vector4". + * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`. */ - getClassName(): string; + create(): void; /** - * Returns the Vector4 hash code. + * Updates the WebGL Uniform Buffer on the GPU. + * If the `dynamic` flag is set to true, no cache comparison is done. + * Otherwise, the buffer will be updated only if the cache differs. */ - getHashCode(): number; + update(): void; /** - * Returns a new array populated with 4 elements : the Vector4 coordinates. + * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU. + * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader. + * @param {number[]|Float32Array} data Flattened data + * @param {number} size Size of the data. */ - asArray(): number[]; + updateUniform(uniformName: string, data: number[] | Float32Array, size: number): void; + private _updateMatrix3x3ForUniform(name, matrix); + private _updateMatrix3x3ForEffect(name, matrix); + private _updateMatrix2x2ForEffect(name, matrix); + private _updateMatrix2x2ForUniform(name, matrix); + private _updateFloatForEffect(name, x); + private _updateFloatForUniform(name, x); + private _updateFloat2ForEffect(name, x, y, suffix?); + private _updateFloat2ForUniform(name, x, y, suffix?); + private _updateFloat3ForEffect(name, x, y, z, suffix?); + private _updateFloat3ForUniform(name, x, y, z, suffix?); + private _updateFloat4ForEffect(name, x, y, z, w, suffix?); + private _updateFloat4ForUniform(name, x, y, z, w, suffix?); + private _updateMatrixForEffect(name, mat); + private _updateMatrixForUniform(name, mat); + private _updateVector3ForEffect(name, vector); + private _updateVector3ForUniform(name, vector); + private _updateVector4ForEffect(name, vector); + private _updateVector4ForUniform(name, vector); + private _updateColor3ForEffect(name, color, suffix?); + private _updateColor3ForUniform(name, color, suffix?); + private _updateColor4ForEffect(name, color, alpha, suffix?); + private _updateColor4ForUniform(name, color, alpha, suffix?); /** - * Populates the passed array from the passed index with the Vector4 coordinates. - * Returns the Vector4. + * Sets a sampler uniform on the effect. + * @param {string} name Name of the sampler. + * @param {Texture} texture */ - toArray(array: number[] | Float32Array, index?: number): Vector4; + setTexture(name: string, texture: BaseTexture): void; /** - * Adds the passed vector to the current Vector4. - * Returns the updated Vector4. + * Directly updates the value of the uniform in the cache AND on the GPU. + * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader. + * @param {number[]|Float32Array} data Flattened data */ - addInPlace(otherVector: Vector4): Vector4; + updateUniformDirectly(uniformName: string, data: number[] | Float32Array): void; /** - * Returns a new Vector4 as the result of the addition of the current Vector4 and the passed one. + * Binds this uniform buffer to an effect. + * @param {Effect} effect + * @param {string} name Name of the uniform block in the shader. */ - add(otherVector: Vector4): Vector4; + bindToEffect(effect: Effect, name: string): void; /** - * Updates the passed vector "result" with the result of the addition of the current Vector4 and the passed one. - * Returns the current Vector4. + * Disposes the uniform buffer. */ - addToRef(otherVector: Vector4, result: Vector4): Vector4; + dispose(): void; + } +} + +declare module BABYLON { + interface ILoadingScreen { + displayLoadingUI: () => void; + hideLoadingUI: () => void; + loadingUIBackgroundColor: string; + loadingUIText: string; + } + class DefaultLoadingScreen implements ILoadingScreen { + private _renderingCanvas; + private _loadingText; + private _loadingDivBackgroundColor; + private _loadingDiv; + private _loadingTextDiv; + constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string); + displayLoadingUI(): void; + hideLoadingUI(): void; + loadingUIText: string; + loadingUIBackgroundColor: string; + private _resizeLoadingUI; + } +} + +declare module BABYLON { + interface ISceneLoaderPluginExtensions { + [extension: string]: { + isBinary: boolean; + }; + } + interface ISceneLoaderPlugin { + name: string; + extensions: string | ISceneLoaderPluginExtensions; + importMesh: (meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[], onError: (message: string) => void) => boolean; + load: (scene: Scene, data: string, rootUrl: string, onError: (message: string) => void) => boolean; + canDirectLoad?: (data: string) => boolean; + } + interface ISceneLoaderPluginAsync { + name: string; + extensions: string | ISceneLoaderPluginExtensions; + importMeshAsync: (meshesNames: any, scene: Scene, data: any, rootUrl: string, onSuccess: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, onProgress: (event: ProgressEvent) => void, onError: (message: string) => void) => void; + loadAsync: (scene: Scene, data: string, rootUrl: string, onSuccess: () => void, onProgress: (event: ProgressEvent) => void, onError: (message: string) => void) => void; + canDirectLoad?: (data: string) => boolean; + } + class SceneLoader { + private static _ForceFullSceneLoadingForIncremental; + private static _ShowLoadingScreen; + private static _CleanBoneMatrixWeights; + static readonly NO_LOGGING: number; + static readonly MINIMAL_LOGGING: number; + static readonly SUMMARY_LOGGING: number; + static readonly DETAILED_LOGGING: number; + private static _loggingLevel; + static ForceFullSceneLoadingForIncremental: boolean; + static ShowLoadingScreen: boolean; + static loggingLevel: number; + static CleanBoneMatrixWeights: boolean; + static OnPluginActivatedObservable: Observable; + private static _registeredPlugins; + private static _getDefaultPlugin(); + private static _getPluginForExtension(extension); + private static _getPluginForDirectLoad(data); + private static _getPluginForFilename(sceneFilename); + private static _getDirectLoad(sceneFilename); + private static _loadData(rootUrl, sceneFilename, scene, onSuccess, onProgress, onError); + static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync; + static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void; /** - * Subtract in place the passed vector from the current Vector4. - * Returns the updated Vector4. - */ - subtractInPlace(otherVector: Vector4): Vector4; + * 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 scene and resources + * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene + * @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 + */ + static ImportMesh(meshNames: any, rootUrl: string, sceneFilename: string, scene: Scene, onSuccess?: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, onProgress?: (event: ProgressEvent) => void, onError?: (scene: Scene, message: string, exception?: any) => void): void; /** - * Returns a new Vector4 with the result of the subtraction of the passed vector from the current Vector4. - */ - subtract(otherVector: Vector4): Vector4; + * Load a scene + * @param rootUrl a string that defines the root url for scene and resources + * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene + * @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 + */ + static Load(rootUrl: string, sceneFilename: any, engine: Engine, onSuccess?: (scene: Scene) => void, onProgress?: (event: ProgressEvent) => void, onError?: (scene: Scene, message: string, exception?: any) => void): void; /** - * Sets the passed vector "result" with the result of the subtraction of the passed vector from the current Vector4. - * Returns the current Vector4. - */ - subtractToRef(otherVector: Vector4, result: Vector4): Vector4; + * Append a scene + * @param rootUrl a string that defines the root url for scene and resources + * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene + * @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 + */ + static Append(rootUrl: string, sceneFilename: any, scene: Scene, onSuccess?: (scene: Scene) => void, onProgress?: (event: ProgressEvent) => void, onError?: (scene: Scene, message: string, exception?: any) => void): void; + } +} + +declare module BABYLON { + class Scalar { /** - * Returns a new Vector4 set with the result of the subtraction of the passed floats from the current Vector4 coordinates. + * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45) */ - subtractFromFloats(x: number, y: number, z: number, w: number): Vector4; + static WithinEpsilon(a: number, b: number, epsilon?: number): boolean; /** - * Sets the passed vector "result" set with the result of the subtraction of the passed floats from the current Vector4 coordinates. - * Returns the current Vector4. + * Returns a string : the upper case translation of the number i to hexadecimal. */ - subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4; + static ToHex(i: number): string; /** - * Returns a new Vector4 set with the current Vector4 negated coordinates. + * Returns -1 if value is negative and +1 is value is positive. + * Returns the value itself if it's equal to zero. */ - negate(): Vector4; + static Sign(value: number): number; /** - * Multiplies the current Vector4 coordinates by scale (float). - * Returns the updated Vector4. + * Returns the value itself if it's between min and max. + * Returns min if the value is lower than min. + * Returns max if the value is greater than max. */ - scaleInPlace(scale: number): Vector4; + static Clamp(value: number, min?: number, max?: number): number; /** - * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float). + * Returns the log2 of value. */ - scale(scale: number): Vector4; + static Log2(value: number): number; /** - * Sets the passed vector "result" with the current Vector4 coordinates multiplied by scale (float). - * Returns the current Vector4. - */ - scaleToRef(scale: number, result: Vector4): Vector4; + * Loops the value, so that it is never larger than length and never smaller than 0. + * + * This is similar to the modulo operator but it works with floating point numbers. + * For example, using 3.0 for t and 2.5 for length, the result would be 0.5. + * With t = 5 and length = 2.5, the result would be 0.0. + * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator + */ + static Repeat(value: number, length: number): number; /** - * Boolean : True if the current Vector4 coordinates are stricly equal to the passed ones. - */ - equals(otherVector: Vector4): boolean; + * Normalize the value between 0.0 and 1.0 using min and max values + */ + static Normalize(value: number, min: number, max: number): number; /** - * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the passed vector ones. - */ - equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean; + * Denormalize the value from 0.0 and 1.0 using min and max values + */ + static Denormalize(normalized: number, min: number, max: number): number; /** - * Boolean : True if the passed floats are strictly equal to the current Vector4 coordinates. - */ - equalsToFloats(x: number, y: number, z: number, w: number): boolean; + * Calculates the shortest difference between two given angles given in degrees. + */ + static DeltaAngle(current: number, target: number): number; /** - * Multiplies in place the current Vector4 by the passed one. - * Returns the updated Vector4. - */ - multiplyInPlace(otherVector: Vector4): Vector4; + * PingPongs the value t, so that it is never larger than length and never smaller than 0. + * + * The returned value will move back and forth between 0 and length + */ + static PingPong(tx: number, length: number): number; /** - * Returns a new Vector4 set with the multiplication result of the current Vector4 and the passed one. - */ - multiply(otherVector: Vector4): Vector4; + * Interpolates between min and max with smoothing at the limits. + * + * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up + * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions. + */ + static SmoothStep(from: number, to: number, tx: number): number; /** - * Updates the passed vector "result" with the multiplication result of the current Vector4 and the passed one. - * Returns the current Vector4. - */ - multiplyToRef(otherVector: Vector4, result: Vector4): Vector4; + * Moves a value current towards target. + * + * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta. + * Negative values of maxDelta pushes the value away from target. + */ + static MoveTowards(current: number, target: number, maxDelta: number): number; /** - * Returns a new Vector4 set with the multiplication result of the passed floats and the current Vector4 coordinates. - */ - multiplyByFloats(x: number, y: number, z: number, w: number): Vector4; + * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees. + * + * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta + * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead. + */ + static MoveTowardsAngle(current: number, target: number, maxDelta: number): number; /** - * Returns a new Vector4 set with the division result of the current Vector4 by the passed one. + * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar. + */ + static Lerp(start: number, end: number, amount: number): number; + /** + * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees. + * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees. + */ + static LerpAngle(start: number, end: number, amount: number): number; + /** + * Calculates the linear parameter t that produces the interpolant value within the range [a, b]. + */ + static InverseLerp(a: number, b: number, value: number): number; + /** + * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2". */ - divide(otherVector: Vector4): Vector4; + static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number; /** - * Updates the passed vector "result" with the division result of the current Vector4 by the passed one. - * Returns the current Vector4. + * Returns a random float number between and min and max values + */ + static RandomRange(min: number, max: number): number; + /** + * This function returns percentage of a number in a given range. + * + * RangeToPercent(40,20,60) will return 0.5 (50%) + * RangeToPercent(34,0,100) will return 0.34 (34%) + */ + static RangeToPercent(number: number, min: number, max: number): number; + /** + * This function returns number that corresponds to the percentage in a given range. + * + * PercentToRange(0.34,0,100) will return 34. + */ + static PercentToRange(percent: number, min: number, max: number): number; + } +} + +declare module BABYLON { + class SIMDHelper { + private static _isEnabled; + static readonly IsEnabled: boolean; + static DisableSIMD(): void; + static EnableSIMD(): void; + } +} + +declare module BABYLON { + const ToGammaSpace: number; + const ToLinearSpace = 2.2; + const Epsilon = 0.001; + class Color3 { + r: number; + g: number; + b: number; + /** + * Creates a new Color3 object from red, green, blue values, all between 0 and 1. */ - divideToRef(otherVector: Vector4, result: Vector4): Vector4; + constructor(r?: number, g?: number, b?: number); /** - * Updates the Vector4 coordinates with the minimum values between its own and the passed vector ones. + * Returns a string with the Color3 current values. */ - MinimizeInPlace(other: Vector4): Vector4; + toString(): string; /** - * Updates the Vector4 coordinates with the maximum values between its own and the passed vector ones. + * Returns the string "Color3". */ - MaximizeInPlace(other: Vector4): Vector4; + getClassName(): string; /** - * Returns the Vector4 length (float). + * Returns the Color3 hash code. */ - length(): number; + getHashCode(): number; /** - * Returns the Vector4 squared length (float). + * Stores in the passed array from the passed starting index the red, green, blue values as successive elements. + * Returns the Color3. */ - lengthSquared(): number; + toArray(array: number[] | Float32Array, index?: number): Color3; /** - * Normalizes in place the Vector4. - * Returns the updated Vector4. + * Returns a new Color4 object from the current Color3 and the passed alpha. */ - normalize(): Vector4; + toColor4(alpha?: number): Color4; /** - * Returns a new Vector3 from the Vector4 (x, y, z) coordinates. + * Returns a new array populated with 3 numeric elements : red, green and blue values. */ - toVector3(): Vector3; + asArray(): number[]; /** - * Returns a new Vector4 copied from the current one. + * Returns the luminance value (float). */ - clone(): Vector4; + toLuminance(): number; /** - * Updates the current Vector4 with the passed one coordinates. - * Returns the updated Vector4. + * Multiply each Color3 rgb values by the passed Color3 rgb values in a new Color3 object. + * Returns this new object. */ - copyFrom(source: Vector4): Vector4; + multiply(otherColor: Color3): Color3; /** - * Updates the current Vector4 coordinates with the passed floats. - * Returns the updated Vector4. + * Multiply the rgb values of the Color3 and the passed Color3 and stores the result in the object "result". + * Returns the current Color3. */ - copyFromFloats(x: number, y: number, z: number, w: number): Vector4; + multiplyToRef(otherColor: Color3, result: Color3): Color3; /** - * Updates the current Vector4 coordinates with the passed floats. - * Returns the updated Vector4. + * Boolean : True if the rgb values are equal to the passed ones. */ - set(x: number, y: number, z: number, w: number): Vector4; + equals(otherColor: Color3): boolean; /** - * Returns a new Vector4 set from the starting index of the passed array. + * Boolean : True if the rgb values are equal to the passed ones. */ - static FromArray(array: ArrayLike, offset?: number): Vector4; + equalsFloats(r: number, g: number, b: number): boolean; /** - * Updates the passed vector "result" from the starting index of the passed array. + * Multiplies in place each rgb value by scale. + * Returns the updated Color3. */ - static FromArrayToRef(array: ArrayLike, offset: number, result: Vector4): void; + scale(scale: number): Color3; /** - * Updates the passed vector "result" from the starting index of the passed Float32Array. + * Multiplies the rgb values by scale and stores the result into "result". + * Returns the unmodified current Color3. */ - static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void; + scaleToRef(scale: number, result: Color3): Color3; /** - * Updates the passed vector "result" coordinates from the passed floats. + * Returns a new Color3 set with the added values of the current Color3 and of the passed one. */ - static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void; + add(otherColor: Color3): Color3; /** - * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0) + * Stores the result of the addition of the current Color3 and passed one rgb values into "result". + * Returns the unmodified current Color3. */ - static Zero(): Vector4; + addToRef(otherColor: Color3, result: Color3): Color3; /** - * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0) + * Returns a new Color3 set with the subtracted values of the passed one from the current Color3 . */ - static One(): Vector4; + subtract(otherColor: Color3): Color3; /** - * Returns a new normalized Vector4 from the passed one. + * Stores the result of the subtraction of passed one from the current Color3 rgb values into "result". + * Returns the unmodified current Color3. */ - static Normalize(vector: Vector4): Vector4; + subtractToRef(otherColor: Color3, result: Color3): Color3; /** - * Updates the passed vector "result" from the normalization of the passed one. + * Returns a new Color3 copied the current one. */ - static NormalizeToRef(vector: Vector4, result: Vector4): void; - static Minimize(left: Vector4, right: Vector4): Vector4; - static Maximize(left: Vector4, right: Vector4): Vector4; + clone(): Color3; /** - * Returns the distance (float) between the vectors "value1" and "value2". + * Copies the rgb values from the source in the current Color3. + * Returns the updated Color3. */ - static Distance(value1: Vector4, value2: Vector4): number; + copyFrom(source: Color3): Color3; /** - * Returns the squared distance (float) between the vectors "value1" and "value2". + * Updates the Color3 rgb values from the passed floats. + * Returns the Color3. */ - static DistanceSquared(value1: Vector4, value2: Vector4): number; + copyFromFloats(r: number, g: number, b: number): Color3; /** - * Returns a new Vector4 located at the center between the vectors "value1" and "value2". + * Updates the Color3 rgb values from the passed floats. + * Returns the Color3. */ - static Center(value1: Vector4, value2: Vector4): Vector4; + set(r: number, g: number, b: number): Color3; /** - * Returns a new Vector4 set with the result of the normal transformation by the passed matrix of the passed vector. - * This methods computes transformed normalized direction vectors only. + * Returns the Color3 hexadecimal code as a string. */ - static TransformNormal(vector: Vector4, transformation: Matrix): Vector4; + toHexString(): string; /** - * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed vector. - * This methods computes transformed normalized direction vectors only. + * Returns a new Color3 converted to linear space. */ - static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void; + toLinearSpace(): Color3; /** - * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed floats (x, y, z, w). - * This methods computes transformed normalized direction vectors only. + * Converts the Color3 values to linear space and stores the result in "convertedColor". + * Returns the unmodified Color3. */ - static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void; - } - interface ISize { - width: number; - height: number; - } - class Size implements ISize { - width: number; - height: number; + toLinearSpaceToRef(convertedColor: Color3): Color3; /** - * Creates a Size object from the passed width and height (floats). + * Returns a new Color3 converted to gamma space. */ - constructor(width: number, height: number); - toString(): string; + toGammaSpace(): Color3; /** - * Returns the string "Size" + * Converts the Color3 values to gamma space and stores the result in "convertedColor". + * Returns the unmodified Color3. */ - getClassName(): string; + toGammaSpaceToRef(convertedColor: Color3): Color3; /** - * Returns the Size hash code. + * Creates a new Color3 from the string containing valid hexadecimal values. */ - getHashCode(): number; + static FromHexString(hex: string): Color3; /** - * Updates the current size from the passed one. - * Returns the updated Size. + * Creates a new Vector3 from the startind index of the passed array. */ - copyFrom(src: Size): void; + static FromArray(array: ArrayLike, offset?: number): Color3; /** - * Updates in place the current Size from the passed floats. - * Returns the updated Size. + * Creates a new Color3 from integer values ( < 256). */ - copyFromFloats(width: number, height: number): Size; + static FromInts(r: number, g: number, b: number): Color3; /** - * Updates in place the current Size from the passed floats. - * Returns the updated Size. + * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3. */ - set(width: number, height: number): Size; + static Lerp(start: Color3, end: Color3, amount: number): Color3; + static Red(): Color3; + static Green(): Color3; + static Blue(): Color3; + static Black(): Color3; + static White(): Color3; + static Purple(): Color3; + static Magenta(): Color3; + static Yellow(): Color3; + static Gray(): Color3; + static Teal(): Color3; + static Random(): Color3; + } + class Color4 { + r: number; + g: number; + b: number; + a: number; /** - * Returns a new Size set with the multiplication result of the current Size and the passed floats. + * Creates a new Color4 object from the passed float values ( < 1) : red, green, blue, alpha. */ - multiplyByFloats(w: number, h: number): Size; + constructor(r?: number, g?: number, b?: number, a?: number); /** - * Returns a new Size copied from the passed one. + * Adds in place the passed Color4 values to the current Color4. + * Returns the updated Color4. */ - clone(): Size; + addInPlace(right: any): Color4; /** - * Boolean : True if the current Size and the passed one width and height are strictly equal. + * Returns a new array populated with 4 numeric elements : red, green, blue, alpha values. */ - equals(other: Size): boolean; + asArray(): number[]; /** - * Returns the surface of the Size : width * height (float). + * Stores from the starting index in the passed array the Color4 successive values. + * Returns the Color4. */ - readonly surface: number; + toArray(array: number[], index?: number): Color4; /** - * Returns a new Size set to (0.0, 0.0) + * Returns a new Color4 set with the added values of the current Color4 and of the passed one. */ - static Zero(): Size; + add(right: Color4): Color4; /** - * Returns a new Size set as the addition result of the current Size and the passed one. + * Returns a new Color4 set with the subtracted values of the passed one from the current Color4. */ - add(otherSize: Size): Size; + subtract(right: Color4): Color4; /** - * Returns a new Size set as the subtraction result of the passed one from the current Size. + * Subtracts the passed ones from the current Color4 values and stores the results in "result". + * Returns the Color4. */ - subtract(otherSize: Size): Size; + subtractToRef(right: Color4, result: Color4): Color4; /** - * Returns a new Size set at the linear interpolation "amount" between "start" and "end". + * Creates a new Color4 with the current Color4 values multiplied by scale. */ - static Lerp(start: Size, end: Size, amount: number): Size; - } - class Quaternion { - x: number; - y: number; - z: number; - w: number; + scale(scale: number): Color4; /** - * Creates a new Quaternion from the passed floats. + * Multiplies the current Color4 values by scale and stores the result in "result". + * Returns the Color4. */ - constructor(x?: number, y?: number, z?: number, w?: number); + scaleToRef(scale: number, result: Color4): Color4; /** - * Returns a string with the Quaternion coordinates. + * Multipy an RGBA Color4 value by another and return a new Color4 object + * @param color The Color4 (RGBA) value to multiply by + * @returns A new Color4. + */ + multiply(color: Color4): Color4; + /** + * Multipy an RGBA Color4 value by another and push the result in a reference value + * @param color The Color4 (RGBA) value to multiply by + * @param result The Color4 (RGBA) to fill the result in + * @returns the result Color4. + */ + multiplyToRef(color: Color4, result: Color4): Color4; + /** + * Returns a string with the Color4 values. */ toString(): string; /** - * Returns the string "Quaternion". + * Returns the string "Color4" */ getClassName(): string; /** - * Returns the Quaternion hash code. + * Return the Color4 hash code as a number. */ getHashCode(): number; /** - * Returns a new array populated with 4 elements : the Quaternion coordinates. + * Creates a new Color4 copied from the current one. */ - asArray(): number[]; + clone(): Color4; /** - * Boolean : True if the current Quaterion and the passed one coordinates are strictly equal. + * Copies the passed Color4 values into the current one. + * Returns the updated Color4. */ - equals(otherQuaternion: Quaternion): boolean; + copyFrom(source: Color4): Color4; /** - * Returns a new Quaternion copied from the current one. + * Copies the passed float values into the current one. + * Returns the updated Color4. */ - clone(): Quaternion; + copyFromFloats(r: number, g: number, b: number, a: number): Color4; /** - * Updates the current Quaternion from the passed one coordinates. - * Returns the updated Quaterion. + * Copies the passed float values into the current one. + * Returns the updated Color4. */ - copyFrom(other: Quaternion): Quaternion; + set(r: number, g: number, b: number, a: number): Color4; /** - * Updates the current Quaternion from the passed float coordinates. - * Returns the updated Quaterion. + * Returns a string containing the hexadecimal Color4 code. */ - copyFromFloats(x: number, y: number, z: number, w: number): Quaternion; + toHexString(): string; /** - * Updates the current Quaternion from the passed float coordinates. - * Returns the updated Quaterion. + * Returns a new Color4 converted to linear space. */ - set(x: number, y: number, z: number, w: number): Quaternion; + toLinearSpace(): Color4; /** - * Returns a new Quaternion as the addition result of the passed one and the current Quaternion. + * Converts the Color4 values to linear space and stores the result in "convertedColor". + * Returns the unmodified Color4. */ - add(other: Quaternion): Quaternion; + toLinearSpaceToRef(convertedColor: Color4): Color4; /** - * Returns a new Quaternion as the subtraction result of the passed one from the current Quaternion. + * Returns a new Color4 converted to gamma space. */ - subtract(other: Quaternion): Quaternion; + toGammaSpace(): Color4; /** - * Returns a new Quaternion set by multiplying the current Quaterion coordinates by the float "scale". + * Converts the Color4 values to gamma space and stores the result in "convertedColor". + * Returns the unmodified Color4. */ - scale(value: number): Quaternion; + toGammaSpaceToRef(convertedColor: Color4): Color4; /** - * Returns a new Quaternion set as the quaternion mulplication result of the current one with the passed one "q1". + * Creates a new Color4 from the valid hexadecimal value contained in the passed string. */ - multiply(q1: Quaternion): Quaternion; + static FromHexString(hex: string): Color4; /** - * Sets the passed "result" as the quaternion mulplication result of the current one with the passed one "q1". - * Returns the current Quaternion. + * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 and the right Color4. */ - multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion; + static Lerp(left: Color4, right: Color4, amount: number): Color4; /** - * Updates the current Quaternion with the quaternion mulplication result of itself with the passed one "q1". - * Returns the updated Quaternion. + * Set the passed "result" with the linearly interpolated values of "amount" between the left Color4 and the right Color4. */ - multiplyInPlace(q1: Quaternion): Quaternion; + static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void; /** - * Sets the passed "ref" with the conjugation of the current Quaternion. - * Returns the current Quaternion. + * Creates a new Color4 from the starting index element of the passed array. */ - conjugateToRef(ref: Quaternion): Quaternion; + static FromArray(array: ArrayLike, offset?: number): Color4; /** - * Conjugates in place the current Quaternion. - * Returns the updated Quaternion. + * Creates a new Color4 from the passed integers ( < 256 ). */ - conjugateInPlace(): Quaternion; + static FromInts(r: number, g: number, b: number, a: number): Color4; + static CheckColors4(colors: number[], count: number): number[]; + } + class Vector2 { + x: number; + y: number; /** - * Returns a new Quaternion as the conjugate of the current Quaternion. + * Creates a new Vector2 from the passed x and y coordinates. */ - conjugate(): Quaternion; + constructor(x: number, y: number); /** - * Returns the Quaternion length (float). + * Returns a string with the Vector2 coordinates. */ - length(): number; + toString(): string; /** - * Normalize in place the current Quaternion. - * Returns the updated Quaternion. + * Returns the string "Vector2" */ - normalize(): Quaternion; + getClassName(): string; /** - * Returns a new Vector3 set with the Euler angles translated from the current Quaternion. + * Returns the Vector2 hash code as a number. */ - toEulerAngles(order?: string): Vector3; + getHashCode(): number; /** - * Sets the passed vector3 "result" with the Euler angles translated from the current Quaternion. - * Returns the current Quaternion. + * Sets the Vector2 coordinates in the passed array or Float32Array from the passed index. + * Returns the Vector2. */ - toEulerAnglesToRef(result: Vector3, order?: string): Quaternion; + toArray(array: number[] | Float32Array, index?: number): Vector2; /** - * Updates the passed rotation matrix with the current Quaternion values. - * Returns the current Quaternion. + * Returns a new array with 2 elements : the Vector2 coordinates. */ - toRotationMatrix(result: Matrix): Quaternion; + asArray(): number[]; /** - * Updates the current Quaternion from the passed rotation matrix values. - * Returns the updated Quaternion. + * Sets the Vector2 coordinates with the passed Vector2 coordinates. + * Returns the updated Vector2. */ - fromRotationMatrix(matrix: Matrix): Quaternion; + copyFrom(source: Vector2): Vector2; /** - * Returns a new Quaternion set from the passed rotation matrix values. + * Sets the Vector2 coordinates with the passed floats. + * Returns the updated Vector2. */ - static FromRotationMatrix(matrix: Matrix): Quaternion; + copyFromFloats(x: number, y: number): Vector2; /** - * Updates the passed quaternion "result" with the passed rotation matrix values. + * Sets the Vector2 coordinates with the passed floats. + * Returns the updated Vector2. */ - static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void; + set(x: number, y: number): Vector2; /** - * Returns a new Quaternion set to (0.0, 0.0, 0.0). + * Returns a new Vector2 set with the addition of the current Vector2 and the passed one coordinates. */ - static Zero(): Quaternion; + add(otherVector: Vector2): Vector2; /** - * Returns a new Quaternion as the inverted current Quaternion. + * Sets the "result" coordinates with the addition of the current Vector2 and the passed one coordinates. + * Returns the Vector2. */ - static Inverse(q: Quaternion): Quaternion; + addToRef(otherVector: Vector2, result: Vector2): Vector2; /** - * Returns the identity Quaternion. + * Set the Vector2 coordinates by adding the passed Vector2 coordinates. + * Returns the updated Vector2. */ - static Identity(): Quaternion; - static IsIdentity(quaternion: Quaternion): boolean; + addInPlace(otherVector: Vector2): Vector2; /** - * Returns a new Quaternion set from the passed axis (Vector3) and angle in radians (float). + * Returns a new Vector2 by adding the current Vector2 coordinates to the passed Vector3 x, y coordinates. */ - static RotationAxis(axis: Vector3, angle: number): Quaternion; + addVector3(otherVector: Vector3): Vector2; /** - * Sets the passed quaternion "result" from the passed axis (Vector3) and angle in radians (float). + * Returns a new Vector2 set with the subtracted coordinates of the passed one from the current Vector2. */ - static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion; + subtract(otherVector: Vector2): Vector2; /** - * Retuns a new Quaternion set from the starting index of the passed array. + * Sets the "result" coordinates with the subtraction of the passed one from the current Vector2 coordinates. + * Returns the Vector2. */ - static FromArray(array: ArrayLike, offset?: number): Quaternion; + subtractToRef(otherVector: Vector2, result: Vector2): Vector2; /** - * Returns a new Quaternion set from the passed Euler float angles (y, x, z). + * Sets the current Vector2 coordinates by subtracting from it the passed one coordinates. + * Returns the updated Vector2. */ - static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion; + subtractInPlace(otherVector: Vector2): Vector2; /** - * Sets the passed quaternion "result" from the passed float Euler angles (y, x, z). + * Multiplies in place the current Vector2 coordinates by the passed ones. + * Returns the updated Vector2. */ - static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void; + multiplyInPlace(otherVector: Vector2): Vector2; /** - * Returns a new Quaternion from the passed float Euler angles expressed in z-x-z orientation + * Returns a new Vector2 set with the multiplication of the current Vector2 and the passed one coordinates. */ - static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion; + multiply(otherVector: Vector2): Vector2; /** - * Sets the passed quaternion "result" from the passed float Euler angles expressed in z-x-z orientation + * Sets "result" coordinates with the multiplication of the current Vector2 and the passed one coordinates. + * Returns the Vector2. */ - static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void; + multiplyToRef(otherVector: Vector2, result: Vector2): Vector2; /** - * Returns a new Quaternion as the quaternion rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system. - * cf to Vector3.RotationFromAxis() documentation. - * Note : axis1, axis2 and axis3 are normalized during this operation. + * Returns a new Vector2 set with the Vector2 coordinates multiplied by the passed floats. */ - static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): Quaternion; + multiplyByFloats(x: number, y: number): Vector2; /** - * Sets the passed quaternion "ref" with the quaternion rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system. - * cf to Vector3.RotationFromAxis() documentation. - * Note : axis1, axis2 and axis3 are normalized during this operation. + * Returns a new Vector2 set with the Vector2 coordinates divided by the passed one coordinates. */ - static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void; - static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion; - static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void; + divide(otherVector: Vector2): Vector2; /** - * Returns a new Quaternion located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2". + * Sets the "result" coordinates with the Vector2 divided by the passed one coordinates. + * Returns the Vector2. */ - static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion; - } - class Matrix { - private static _tempQuaternion; - private static _xAxis; - private static _yAxis; - private static _zAxis; - private static _updateFlagSeed; - private _isIdentity; - private _isIdentityDirty; - updateFlag: number; - m: Float32Array; - _markAsUpdated(): void; - constructor(); + divideToRef(otherVector: Vector2, result: Vector2): Vector2; /** - * Boolean : True is the matrix is the identity matrix + * Returns a new Vector2 with current Vector2 negated coordinates. */ - isIdentity(considerAsTextureMatrix?: boolean): boolean; + negate(): Vector2; /** - * Returns the matrix determinant (float). + * Multiply the Vector2 coordinates by scale. + * Returns the updated Vector2. */ - determinant(): number; + scaleInPlace(scale: number): Vector2; /** - * Returns the matrix underlying array. + * Returns a new Vector2 scaled by "scale" from the current Vector2. */ - toArray(): Float32Array; - /** - * Returns the matrix underlying array. - */ - asArray(): Float32Array; + scale(scale: number): Vector2; /** - * Inverts in place the Matrix. - * Returns the Matrix inverted. + * Boolean : True if the passed vector coordinates strictly equal the current Vector2 ones. */ - invert(): Matrix; + equals(otherVector: Vector2): boolean; /** - * Sets all the matrix elements to zero. - * Returns the Matrix. + * Boolean : True if the passed vector coordinates are close to the current ones by a distance of epsilon. */ - reset(): Matrix; + equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean; /** - * Returns a new Matrix as the addition result of the current Matrix and the passed one. + * Returns the vector length (float). */ - add(other: Matrix): Matrix; + length(): number; /** - * Sets the passed matrix "result" with the ddition result of the current Matrix and the passed one. - * Returns the Matrix. + * Returns the vector squared length (float); */ - addToRef(other: Matrix, result: Matrix): Matrix; + lengthSquared(): number; /** - * Adds in place the passed matrix to the current Matrix. - * Returns the updated Matrix. + * Normalize the vector. + * Returns the updated Vector2. */ - addToSelf(other: Matrix): Matrix; + normalize(): Vector2; /** - * Sets the passed matrix with the current inverted Matrix. - * Returns the unmodified current Matrix. + * Returns a new Vector2 copied from the Vector2. */ - invertToRef(other: Matrix): Matrix; + clone(): Vector2; /** - * Inserts the translation vector (using 3 x floats) in the current Matrix. - * Returns the updated Matrix. + * Returns a new Vector2(0, 0) */ - setTranslationFromFloats(x: number, y: number, z: number): Matrix; - /** - * Inserts the translation vector in the current Matrix. - * Returns the updated Matrix. - */ - setTranslation(vector3: Vector3): Matrix; + static Zero(): Vector2; /** - * Returns a new Vector3 as the extracted translation from the Matrix. + * Returns a new Vector2(1, 1) */ - getTranslation(): Vector3; + static One(): Vector2; /** - * Fill a Vector3 with the extracted translation from the Matrix. + * Returns a new Vector2 set from the passed index element of the passed array. */ - getTranslationToRef(result: Vector3): Matrix; + static FromArray(array: ArrayLike, offset?: number): Vector2; /** - * Remove rotation and scaling part from the Matrix. - * Returns the updated Matrix. + * Sets "result" from the passed index element of the passed array. */ - removeRotationAndScaling(): Matrix; + static FromArrayToRef(array: ArrayLike, offset: number, result: Vector2): void; /** - * Returns a new Matrix set with the multiplication result of the current Matrix and the passed one. + * Retuns a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the passed four Vector2. */ - multiply(other: Matrix): Matrix; + static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2; /** - * Updates the current Matrix from the passed one values. - * Returns the updated Matrix. + * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max". + * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate. + * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate. */ - copyFrom(other: Matrix): Matrix; + static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2; /** - * Populates the passed array from the starting index with the Matrix values. - * Returns the Matrix. + * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2". */ - copyToArray(array: Float32Array, offset?: number): Matrix; + static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2; /** - * Sets the passed matrix "result" with the multiplication result of the current Matrix and the passed one. + * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end". */ - multiplyToRef(other: Matrix, result: Matrix): Matrix; + static Lerp(start: Vector2, end: Vector2, amount: number): Vector2; /** - * Sets the Float32Array "result" from the passed index "offset" with the multiplication result of the current Matrix and the passed one. + * Returns the dot product (float) of the vector "left" and the vector "right". */ - multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix; + static Dot(left: Vector2, right: Vector2): number; /** - * Boolean : True is the current Matrix and the passed one values are strictly equal. + * Returns a new Vector2 equal to the normalized passed vector. */ - equals(value: Matrix): boolean; + static Normalize(vector: Vector2): Vector2; /** - * Returns a new Matrix from the current Matrix. + * Returns a new Vecto2 set with the minimal coordinate values from the "left" and "right" vectors. */ - clone(): Matrix; + static Minimize(left: Vector2, right: Vector2): Vector2; /** - * Returns the string "Matrix" + * Returns a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors. */ - getClassName(): string; + static Maximize(left: Vector2, right: Vector2): Vector2; /** - * Returns the Matrix hash code. + * Returns a new Vecto2 set with the transformed coordinates of the passed vector by the passed transformation matrix. */ - getHashCode(): number; + static Transform(vector: Vector2, transformation: Matrix): Vector2; /** - * Decomposes the current Matrix into : - * - a scale vector3 passed as a reference to update, - * - a rotation quaternion passed as a reference to update, - * - a translation vector3 passed as a reference to update. - * Returns the boolean `true`. + * Transforms the passed vector coordinates by the passed transformation matrix and stores the result in the vector "result" coordinates. */ - decompose(scale: Vector3, rotation: Quaternion, translation: Vector3): boolean; + static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void; /** - * Returns a new Matrix as the extracted rotation matrix from the current one. + * Boolean : True if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2" */ - getRotationMatrix(): Matrix; + static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean; /** - * Extracts the rotation matrix from the current one and sets it as the passed "result". - * Returns the current Matrix. + * Returns the distance (float) between the vectors "value1" and "value2". */ - getRotationMatrixToRef(result: Matrix): Matrix; + static Distance(value1: Vector2, value2: Vector2): number; /** - * Returns a new Matrix set from the starting index of the passed array. + * Returns the squared distance (float) between the vectors "value1" and "value2". */ - static FromArray(array: ArrayLike, offset?: number): Matrix; + static DistanceSquared(value1: Vector2, value2: Vector2): number; /** - * Sets the passed "result" matrix from the starting index of the passed array. + * Returns a new Vecto2 located at the center of the vectors "value1" and "value2". */ - static FromArrayToRef(array: ArrayLike, offset: number, result: Matrix): void; + static Center(value1: Vector2, value2: Vector2): Vector2; /** - * Sets the passed "result" matrix from the starting index of the passed Float32Array by multiplying each element by the float "scale". + * Returns the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB". */ - static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void; + static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number; + } + class Vector3 { + x: number; + y: number; + z: number; /** - * Sets the passed matrix "result" with the 16 passed floats. + * Creates a new Vector3 object from the passed x, y, z (floats) coordinates. + * A Vector3 is the main object used in 3D geometry. + * It can represent etiher the coordinates of a point the space, either a direction. */ - static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void; + constructor(x: number, y: number, z: number); /** - * Returns the index-th row of the current matrix as a new Vector4. + * Returns a string with the Vector3 coordinates. */ - getRow(index: number): Vector4; + toString(): string; /** - * Sets the index-th row of the current matrix with the passed Vector4 values. - * Returns the updated Matrix. + * Returns the string "Vector3" */ - setRow(index: number, row: Vector4): Matrix; + getClassName(): string; /** - * Sets the index-th row of the current matrix with the passed 4 x float values. - * Returns the updated Matrix. + * Returns the Vector hash code. */ - setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix; + getHashCode(): number; /** - * Returns a new Matrix set from the 16 passed floats. + * Returns a new array with three elements : the coordinates the Vector3. */ - static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix; + asArray(): number[]; /** - * Returns a new Matrix composed by the passed scale (vector3), rotation (quaternion) and translation (vector3). + * Populates the passed array or Float32Array from the passed index with the successive coordinates of the Vector3. + * Returns the Vector3. */ - static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix; - /** - * Update a Matrix with values composed by the passed scale (vector3), rotation (quaternion) and translation (vector3). - */ - static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void; + toArray(array: number[] | Float32Array, index?: number): Vector3; /** - * Returns a new indentity Matrix. + * Returns a new Quaternion object, computed from the Vector3 coordinates. */ - static Identity(): Matrix; + toQuaternion(): Quaternion; /** - * Sets the passed "result" as an identity matrix. + * Adds the passed vector to the current Vector3. + * Returns the updated Vector3. */ - static IdentityToRef(result: Matrix): void; + addInPlace(otherVector: Vector3): Vector3; /** - * Returns a new zero Matrix. + * Returns a new Vector3, result of the addition the current Vector3 and the passed vector. */ - static Zero(): Matrix; + add(otherVector: Vector3): Vector3; /** - * Returns a new rotation matrix for "angle" radians around the X axis. + * Adds the current Vector3 to the passed one and stores the result in the vector "result". + * Returns the current Vector3. */ - static RotationX(angle: number): Matrix; + addToRef(otherVector: Vector3, result: Vector3): Vector3; /** - * Returns a new Matrix as the passed inverted one. + * Subtract the passed vector from the current Vector3. + * Returns the updated Vector3. */ - static Invert(source: Matrix): Matrix; + subtractInPlace(otherVector: Vector3): Vector3; /** - * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the X axis. + * Returns a new Vector3, result of the subtraction of the passed vector from the current Vector3. */ - static RotationXToRef(angle: number, result: Matrix): void; + subtract(otherVector: Vector3): Vector3; /** - * Returns a new rotation matrix for "angle" radians around the Y axis. + * Subtracts the passed vector from the current Vector3 and stores the result in the vector "result". + * Returns the current Vector3. */ - static RotationY(angle: number): Matrix; + subtractToRef(otherVector: Vector3, result: Vector3): Vector3; /** - * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the Y axis. + * Returns a new Vector3 set with the subtraction of the passed floats from the current Vector3 coordinates. */ - static RotationYToRef(angle: number, result: Matrix): void; + subtractFromFloats(x: number, y: number, z: number): Vector3; /** - * Returns a new rotation matrix for "angle" radians around the Z axis. + * Subtracts the passed floats from the current Vector3 coordinates and set the passed vector "result" with this result. + * Returns the current Vector3. */ - static RotationZ(angle: number): Matrix; + subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3; /** - * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the Z axis. + * Returns a new Vector3 set with the current Vector3 negated coordinates. */ - static RotationZToRef(angle: number, result: Matrix): void; + negate(): Vector3; /** - * Returns a new rotation matrix for "angle" radians around the passed axis. + * Multiplies the Vector3 coordinates by the float "scale". + * Returns the updated Vector3. */ - static RotationAxis(axis: Vector3, angle: number): Matrix; + scaleInPlace(scale: number): Vector3; /** - * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the passed axis. + * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale". */ - static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void; + scale(scale: number): Vector3; /** - * Returns a new Matrix as a rotation matrix from the Euler angles (y, x, z). + * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the passed vector "result" coordinates. + * Returns the current Vector3. */ - static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix; + scaleToRef(scale: number, result: Vector3): Vector3; /** - * Sets the passed matrix "result" as a rotation matrix from the Euler angles (y, x, z). + * Boolean : True if the current Vector3 and the passed vector coordinates are strictly equal. */ - static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void; + equals(otherVector: Vector3): boolean; /** - * Returns a new Matrix as a scaling matrix from the passed floats (x, y, z). + * Boolean : True if the current Vector3 and the passed vector coordinates are distant less than epsilon. */ - static Scaling(x: number, y: number, z: number): Matrix; + equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean; /** - * Sets the passed matrix "result" as a scaling matrix from the passed floats (x, y, z). + * Boolean : True if the current Vector3 coordinate equal the passed floats. */ - static ScalingToRef(x: number, y: number, z: number, result: Matrix): void; + equalsToFloats(x: number, y: number, z: number): boolean; /** - * Returns a new Matrix as a translation matrix from the passed floats (x, y, z). + * Muliplies the current Vector3 coordinates by the passed ones. + * Returns the updated Vector3. */ - static Translation(x: number, y: number, z: number): Matrix; + multiplyInPlace(otherVector: Vector3): Vector3; /** - * Sets the passed matrix "result" as a translation matrix from the passed floats (x, y, z). + * Returns a new Vector3, result of the multiplication of the current Vector3 by the passed vector. */ - static TranslationToRef(x: number, y: number, z: number, result: Matrix): void; + multiply(otherVector: Vector3): Vector3; /** - * Returns a new Matrix whose values are the interpolated values for "gradien" (float) between the ones of the matrices "startValue" and "endValue". + * Multiplies the current Vector3 by the passed one and stores the result in the passed vector "result". + * Returns the current Vector3. */ - static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix; + multiplyToRef(otherVector: Vector3, result: Vector3): Vector3; /** - * Returns a new Matrix whose values are computed by : - * - decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices, - * - interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end, - * - recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices. + * Returns a new Vector3 set witth the result of the mulliplication of the current Vector3 coordinates by the passed floats. */ - static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix; + multiplyByFloats(x: number, y: number, z: number): Vector3; /** - * Returns a new rotation Matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up". - * This methods works for a Left-Handed system. + * Returns a new Vector3 set witth the result of the division of the current Vector3 coordinates by the passed ones. */ - static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix; + divide(otherVector: Vector3): Vector3; /** - * Sets the passed "result" Matrix as a rotation matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up". - * This methods works for a Left-Handed system. + * Divides the current Vector3 coordinates by the passed ones and stores the result in the passed vector "result". + * Returns the current Vector3. */ - static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void; + divideToRef(otherVector: Vector3, result: Vector3): Vector3; /** - * Returns a new rotation Matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up". - * This methods works for a Right-Handed system. + * Updates the current Vector3 with the minimal coordinate values between its and the passed vector ones. + * Returns the updated Vector3. */ - static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix; + MinimizeInPlace(other: Vector3): Vector3; /** - * Sets the passed "result" Matrix as a rotation matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up". - * This methods works for a Left-Handed system. + * Updates the current Vector3 with the maximal coordinate values between its and the passed vector ones. + * Returns the updated Vector3. */ - static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void; + MaximizeInPlace(other: Vector3): Vector3; /** - * Returns a new Matrix as a left-handed orthographic projection matrix computed from the passed floats : width and height of the projection plane, z near and far limits. + * Returns the length of the Vector3 (float). */ - static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix; + length(): number; /** - * Sets the passed matrix "result" as a left-handed orthographic projection matrix computed from the passed floats : width and height of the projection plane, z near and far limits. + * Returns the squared length of the Vector3 (float). */ - static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void; + lengthSquared(): number; /** - * Returns a new Matrix as a left-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits. + * Normalize the current Vector3. + * Returns the updated Vector3. */ - static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix; + normalize(): Vector3; /** - * Sets the passed matrix "result" as a left-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits. + * Returns a new Vector3 copied from the current Vector3. */ - static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void; + clone(): Vector3; /** - * Returns a new Matrix as a right-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits. + * Copies the passed vector coordinates to the current Vector3 ones. + * Returns the updated Vector3. */ - static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix; + copyFrom(source: Vector3): Vector3; /** - * Sets the passed matrix "result" as a right-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits. + * Copies the passed floats to the current Vector3 coordinates. + * Returns the updated Vector3. */ - static OrthoOffCenterRHToRef(left: number, right: any, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void; + copyFromFloats(x: number, y: number, z: number): Vector3; /** - * Returns a new Matrix as a left-handed perspective projection matrix computed from the passed floats : width and height of the projection plane, z near and far limits. + * Copies the passed floats to the current Vector3 coordinates. + * Returns the updated Vector3. */ - static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix; + set(x: number, y: number, z: number): Vector3; /** - * Returns a new Matrix as a left-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits. + * */ - static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix; + static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: any): number; /** - * Sets the passed matrix "result" as a left-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits. + * Returns a new Vector3 set from the index "offset" of the passed array. */ - static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void; + static FromArray(array: ArrayLike, offset?: number): Vector3; /** - * Returns a new Matrix as a right-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits. + * Returns a new Vector3 set from the index "offset" of the passed Float32Array. + * This function is deprecated. Use FromArray instead. */ - static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix; + static FromFloatArray(array: Float32Array, offset?: number): Vector3; /** - * Sets the passed matrix "result" as a right-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits. + * Sets the passed vector "result" with the element values from the index "offset" of the passed array. */ - static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void; + static FromArrayToRef(array: ArrayLike, offset: number, result: Vector3): void; /** - * Sets the passed matrix "result" as a left-handed perspective projection matrix for WebVR computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits. + * Sets the passed vector "result" with the element values from the index "offset" of the passed Float32Array. + * This function is deprecated. Use FromArrayToRef instead. */ - static PerspectiveFovWebVRToRef(fov: any, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void; + static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void; /** - * Returns the final transformation matrix : world * view * projection * viewport + * Sets the passed vector "result" with the passed floats. */ - static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix; + static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void; /** - * Returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the passed Matrix. + * Returns a new Vector3 set to (0.0, 0.0, 0.0). */ - static GetAsMatrix2x2(matrix: Matrix): Float32Array; + static Zero(): Vector3; /** - * Returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the passed Matrix. + * Returns a new Vector3 set to (1.0, 1.0, 1.0). */ - static GetAsMatrix3x3(matrix: Matrix): Float32Array; + static One(): Vector3; /** - * Compute the transpose of the passed Matrix. - * Returns a new Matrix. + * Returns a new Vector3 set to (0.0, 1.0, 0.0) */ - static Transpose(matrix: Matrix): Matrix; + static Up(): Vector3; /** - * Returns a new Matrix as the reflection matrix across the passed plane. + * Returns a new Vector3 set to (0.0, 0.0, 1.0) */ - static Reflection(plane: Plane): Matrix; + static Forward(): Vector3; /** - * Sets the passed matrix "result" as the reflection matrix across the passed plane. + * Returns a new Vector3 set to (1.0, 0.0, 0.0) */ - static ReflectionToRef(plane: Plane, result: Matrix): void; + static Right(): Vector3; /** - * Sets the passed matrix "mat" as a rotation matrix composed from the 3 passed left handed axis. + * Returns a new Vector3 set to (-1.0, 0.0, 0.0) */ - static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void; + static Left(): Vector3; /** - * Sets the passed matrix "result" as a rotation matrix according to the passed quaternion. + * Returns a new Vector3 set with the result of the transformation by the passed matrix of the passed vector. + * This method computes tranformed coordinates only, not transformed direction vectors. */ - static FromQuaternionToRef(quat: Quaternion, result: Matrix): void; - } - class Plane { - normal: Vector3; - d: number; + static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3; /** - * Creates a Plane object according to the passed floats a, b, c, d and the plane equation : ax + by + cz + d = 0 + * Sets the passed vector "result" coordinates with the result of the transformation by the passed matrix of the passed vector. + * This method computes tranformed coordinates only, not transformed direction vectors. */ - constructor(a: number, b: number, c: number, d: number); + static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void; /** - * Returns the plane coordinates as a new array of 4 elements [a, b, c, d]. + * Sets the passed vector "result" coordinates with the result of the transformation by the passed matrix of the passed floats (x, y, z). + * This method computes tranformed coordinates only, not transformed direction vectors. */ - asArray(): number[]; + static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void; /** - * Returns a new plane copied from the current Plane. + * Returns a new Vector3 set with the result of the normal transformation by the passed matrix of the passed vector. + * This methods computes transformed normalized direction vectors only. */ - clone(): Plane; + static TransformNormal(vector: Vector3, transformation: Matrix): Vector3; /** - * Returns the string "Plane". + * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed vector. + * This methods computes transformed normalized direction vectors only. */ - getClassName(): string; + static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void; /** - * Returns the Plane hash code. + * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed floats (x, y, z). + * This methods computes transformed normalized direction vectors only. */ - getHashCode(): number; + static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void; /** - * Normalize the current Plane in place. - * Returns the updated Plane. + * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4". */ - normalize(): Plane; + static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3; /** - * Returns a new Plane as the result of the transformation of the current Plane by the passed matrix. + * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max". + * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one. + * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one. */ - transform(transformation: Matrix): Plane; + static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3; /** - * Returns the dot product (float) of the point coordinates and the plane normal. + * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2". */ - dotCoordinate(point: any): number; + static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3; /** - * Updates the current Plane from the plane defined by the three passed points. - * Returns the updated Plane. + * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end". */ - copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane; + static Lerp(start: Vector3, end: Vector3, amount: number): Vector3; /** - * Boolean : True is the vector "direction" is the same side than the plane normal. + * Sets the passed vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end". */ - isFrontFacingTo(direction: Vector3, epsilon: number): boolean; + static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void; /** - * Returns the signed distance (float) from the passed point to the Plane. + * Returns the dot product (float) between the vectors "left" and "right". */ - signedDistanceTo(point: Vector3): number; + static Dot(left: Vector3, right: Vector3): number; /** - * Returns a new Plane from the passed array. + * Returns a new Vector3 as the cross product of the vectors "left" and "right". + * The cross product is then orthogonal to both "left" and "right". */ - static FromArray(array: ArrayLike): Plane; + static Cross(left: Vector3, right: Vector3): Vector3; /** - * Returns a new Plane defined by the three passed points. + * Sets the passed vector "result" with the cross product of "left" and "right". + * The cross product is then orthogonal to both "left" and "right". */ - static FromPoints(point1: any, point2: any, point3: any): Plane; + static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void; /** - * Returns a new Plane the normal vector to this plane at the passed origin point. - * Note : the vector "normal" is updated because normalized. + * Returns a new Vector3 as the normalization of the passed vector. */ - static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane; + static Normalize(vector: Vector3): Vector3; /** - * Returns the signed distance between the plane defined by the normal vector at the "origin"" point and the passed other point. + * Sets the passed vector "result" with the normalization of the passed first vector. */ - static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number; - } - class Viewport { - x: number; - y: number; - width: number; - height: number; + static NormalizeToRef(vector: Vector3, result: Vector3): void; + private static _viewportMatrixCache; + static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3; + static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3; + static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3; + static Minimize(left: Vector3, right: Vector3): Vector3; + static Maximize(left: Vector3, right: Vector3): Vector3; /** - * Creates a Viewport object located at (x, y) and sized (width, height). + * Returns the distance (float) between the vectors "value1" and "value2". */ - constructor(x: number, y: number, width: number, height: number); - toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport; + static Distance(value1: Vector3, value2: Vector3): number; /** - * Returns a new Viewport copied from the current one. + * Returns the squared distance (float) between the vectors "value1" and "value2". */ - clone(): Viewport; - } - class Frustum { + static DistanceSquared(value1: Vector3, value2: Vector3): number; /** - * Returns a new array of 6 Frustum planes computed by the passed transformation matrix. + * Returns a new Vector3 located at the center between "value1" and "value2". */ - static GetPlanes(transform: Matrix): Plane[]; + static Center(value1: Vector3, value2: Vector3): Vector3; /** - * Sets the passed array "frustumPlanes" with the 6 Frustum planes computed by the passed transformation matrix. + * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system), + * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply + * to something in order to rotate it from its local system to the given target system. + * Note : axis1, axis2 and axis3 are normalized during this operation. + * Returns a new Vector3. */ - static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void; - } - enum Space { - LOCAL = 0, - WORLD = 1, - BONE = 2, - } - class Axis { - static X: Vector3; - static Y: Vector3; - static Z: Vector3; - } - class BezierCurve { + static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3; /** - * Returns the cubic Bezier interpolated value (float) at "t" (float) from the passed x1, y1, x2, y2 floats. + * The same than RotationFromAxis but updates the passed ref Vector3 parameter instead of returning a new Vector3. */ - static interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number; - } - enum Orientation { - CW = 0, - CCW = 1, + static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void; } - class Angle { - private _radians; + class Vector4 { + x: number; + y: number; + z: number; + w: number; /** - * Creates an Angle object of "radians" radians (float). + * Creates a Vector4 object from the passed floats. */ - constructor(radians: number); + constructor(x: number, y: number, z: number, w: number); /** - * Returns the Angle value in degrees (float). + * Returns the string with the Vector4 coordinates. */ - degrees: () => number; + toString(): string; /** - * Returns the Angle value in radians (float). + * Returns the string "Vector4". */ - radians: () => number; + getClassName(): string; /** - * Returns a new Angle object valued with the angle value in radians between the two passed vectors. + * Returns the Vector4 hash code. */ - static BetweenTwoPoints(a: Vector2, b: Vector2): Angle; + getHashCode(): number; /** - * Returns a new Angle object from the passed float in radians. + * Returns a new array populated with 4 elements : the Vector4 coordinates. */ - static FromRadians(radians: number): Angle; + asArray(): number[]; /** - * Returns a new Angle object from the passed float in degrees. + * Populates the passed array from the passed index with the Vector4 coordinates. + * Returns the Vector4. */ - static FromDegrees(degrees: number): Angle; - } - class Arc2 { - startPoint: Vector2; - midPoint: Vector2; - endPoint: Vector2; - centerPoint: Vector2; - radius: number; - angle: Angle; - startAngle: Angle; - orientation: Orientation; + toArray(array: number[] | Float32Array, index?: number): Vector4; /** - * Creates an Arc object from the three passed points : start, middle and end. + * Adds the passed vector to the current Vector4. + * Returns the updated Vector4. */ - constructor(startPoint: Vector2, midPoint: Vector2, endPoint: Vector2); - } - class Path2 { - private _points; - private _length; - closed: boolean; + addInPlace(otherVector: Vector4): Vector4; /** - * Creates a Path2 object from the starting 2D coordinates x and y. + * Returns a new Vector4 as the result of the addition of the current Vector4 and the passed one. */ - constructor(x: number, y: number); + add(otherVector: Vector4): Vector4; /** - * Adds a new segment until the passed coordinates (x, y) to the current Path2. - * Returns the updated Path2. + * Updates the passed vector "result" with the result of the addition of the current Vector4 and the passed one. + * Returns the current Vector4. */ - addLineTo(x: number, y: number): Path2; + addToRef(otherVector: Vector4, result: Vector4): Vector4; /** - * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2. - * Returns the updated Path2. + * Subtract in place the passed vector from the current Vector4. + * Returns the updated Vector4. */ - addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2; + subtractInPlace(otherVector: Vector4): Vector4; /** - * Closes the Path2. - * Returns the Path2. + * Returns a new Vector4 with the result of the subtraction of the passed vector from the current Vector4. */ - close(): Path2; + subtract(otherVector: Vector4): Vector4; /** - * Returns the Path2 total length (float). + * Sets the passed vector "result" with the result of the subtraction of the passed vector from the current Vector4. + * Returns the current Vector4. */ - length(): number; + subtractToRef(otherVector: Vector4, result: Vector4): Vector4; /** - * Returns the Path2 internal array of points. + * Returns a new Vector4 set with the result of the subtraction of the passed floats from the current Vector4 coordinates. */ - getPoints(): Vector2[]; + subtractFromFloats(x: number, y: number, z: number, w: number): Vector4; /** - * Returns a new Vector2 located at a percentage of the Path2 total length on this path. + * Sets the passed vector "result" set with the result of the subtraction of the passed floats from the current Vector4 coordinates. + * Returns the current Vector4. */ - getPointAtLengthPosition(normalizedLengthPosition: number): Vector2; + subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4; /** - * Returns a new Path2 starting at the coordinates (x, y). + * Returns a new Vector4 set with the current Vector4 negated coordinates. */ - static StartingAt(x: number, y: number): Path2; - } - class Path3D { - path: Vector3[]; - private _curve; - private _distances; - private _tangents; - private _normals; - private _binormals; - private _raw; - /** - * new Path3D(path, normal, raw) - * Creates a Path3D. A Path3D is a logical math object, so not a mesh. - * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D - * path : an array of Vector3, the curve axis of the Path3D - * normal (optional) : Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal. - * raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed. - */ - constructor(path: Vector3[], firstNormal?: Vector3, raw?: boolean); + negate(): Vector4; /** - * Returns the Path3D array of successive Vector3 designing its curve. + * Multiplies the current Vector4 coordinates by scale (float). + * Returns the updated Vector4. */ - getCurve(): Vector3[]; + scaleInPlace(scale: number): Vector4; /** - * Returns an array populated with tangent vectors on each Path3D curve point. + * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float). */ - getTangents(): Vector3[]; + scale(scale: number): Vector4; /** - * Returns an array populated with normal vectors on each Path3D curve point. + * Sets the passed vector "result" with the current Vector4 coordinates multiplied by scale (float). + * Returns the current Vector4. */ - getNormals(): Vector3[]; + scaleToRef(scale: number, result: Vector4): Vector4; /** - * Returns an array populated with binormal vectors on each Path3D curve point. + * Boolean : True if the current Vector4 coordinates are stricly equal to the passed ones. */ - getBinormals(): Vector3[]; + equals(otherVector: Vector4): boolean; /** - * Returns an array populated with distances (float) of the i-th point from the first curve point. + * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the passed vector ones. */ - getDistances(): number[]; + equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean; /** - * Forces the Path3D tangent, normal, binormal and distance recomputation. - * Returns the same object updated. + * Boolean : True if the passed floats are strictly equal to the current Vector4 coordinates. */ - update(path: Vector3[], firstNormal?: Vector3): Path3D; - private _compute(firstNormal); - private _getFirstNonNullVector(index); - private _getLastNonNullVector(index); - private _normalVector(v0, vt, va); - } - class Curve3 { - private _points; - private _length; + equalsToFloats(x: number, y: number, z: number, w: number): boolean; /** - * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve - * @param v0 (Vector3) the origin point of the Quadratic Bezier - * @param v1 (Vector3) the control point - * @param v2 (Vector3) the end point of the Quadratic Bezier - * @param nbPoints (integer) the wanted number of points in the curve + * Multiplies in place the current Vector4 by the passed one. + * Returns the updated Vector4. */ - static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3; + multiplyInPlace(otherVector: Vector4): Vector4; /** - * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve - * @param v0 (Vector3) the origin point of the Cubic Bezier - * @param v1 (Vector3) the first control point - * @param v2 (Vector3) the second control point - * @param v3 (Vector3) the end point of the Cubic Bezier - * @param nbPoints (integer) the wanted number of points in the curve + * Returns a new Vector4 set with the multiplication result of the current Vector4 and the passed one. */ - static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3; + multiply(otherVector: Vector4): Vector4; /** - * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline - * @param p1 (Vector3) the origin point of the Hermite Spline - * @param t1 (Vector3) the tangent vector at the origin point - * @param p2 (Vector3) the end point of the Hermite Spline - * @param t2 (Vector3) the tangent vector at the end point - * @param nbPoints (integer) the wanted number of points in the curve + * Updates the passed vector "result" with the multiplication result of the current Vector4 and the passed one. + * Returns the current Vector4. */ - static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3; + multiplyToRef(otherVector: Vector4, result: Vector4): Vector4; /** - * Returns a Curve3 object along a CatmullRom Spline curve : - * @param points (array of Vector3) the points the spline must pass through. At least, four points required. - * @param nbPoints (integer) the wanted number of points between each curve control points. + * Returns a new Vector4 set with the multiplication result of the passed floats and the current Vector4 coordinates. */ - static CreateCatmullRomSpline(points: Vector3[], nbPoints: number): Curve3; + multiplyByFloats(x: number, y: number, z: number, w: number): Vector4; /** - * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space. - * A Curve3 is designed from a series of successive Vector3. - * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object + * Returns a new Vector4 set with the division result of the current Vector4 by the passed one. */ - constructor(points: Vector3[]); + divide(otherVector: Vector4): Vector4; /** - * Returns the Curve3 stored array of successive Vector3 + * Updates the passed vector "result" with the division result of the current Vector4 by the passed one. + * Returns the current Vector4. */ - getPoints(): Vector3[]; + divideToRef(otherVector: Vector4, result: Vector4): Vector4; /** - * Returns the computed length (float) of the curve. + * Updates the Vector4 coordinates with the minimum values between its own and the passed vector ones. */ - length(): number; + MinimizeInPlace(other: Vector4): Vector4; /** - * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB); - * This new Curve3 is built by translating and sticking the curveB at the end of the curveA. - * curveA and curveB keep unchanged. + * Updates the Vector4 coordinates with the maximum values between its own and the passed vector ones. */ - continue(curve: Curve3): Curve3; - private _computeLength(path); - } - class PositionNormalVertex { - position: Vector3; - normal: Vector3; - constructor(position?: Vector3, normal?: Vector3); - clone(): PositionNormalVertex; - } - class PositionNormalTextureVertex { - position: Vector3; - normal: Vector3; - uv: Vector2; - constructor(position?: Vector3, normal?: Vector3, uv?: Vector2); - clone(): PositionNormalTextureVertex; - } - class Tmp { - static Color3: Color3[]; - static Vector2: Vector2[]; - static Vector3: Vector3[]; - static Vector4: Vector4[]; - static Quaternion: Quaternion[]; - static Matrix: Matrix[]; - } -} - -declare module BABYLON { - class SphericalPolynomial { - x: Vector3; - y: Vector3; - z: Vector3; - xx: Vector3; - yy: Vector3; - zz: Vector3; - xy: Vector3; - yz: Vector3; - zx: Vector3; - addAmbient(color: Color3): void; - static getSphericalPolynomialFromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial; - scale(scale: number): void; - } - class SphericalHarmonics { - L00: Vector3; - L1_1: Vector3; - L10: Vector3; - L11: Vector3; - L2_2: Vector3; - L2_1: Vector3; - L20: Vector3; - L21: Vector3; - L22: Vector3; - addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void; - scale(scale: number): void; - convertIncidentRadianceToIrradiance(): void; - convertIrradianceToLambertianRadiance(): void; - static getsphericalHarmonicsFromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics; - } -} - -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; + MaximizeInPlace(other: Vector4): Vector4; /** - * 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). + * Returns the Vector4 length (float). */ + length(): number; /** - * 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). + * Returns the Vector4 squared length (float). */ - globalHue: number; + lengthSquared(): 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. + * Normalizes in place the Vector4. + * Returns the updated Vector4. */ + normalize(): Vector4; /** - * 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. + * Returns a new Vector3 from the Vector4 (x, y, z) coordinates. */ - globalDensity: number; + toVector3(): Vector3; /** - * 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. + * Returns a new Vector4 copied from the current one. */ + clone(): Vector4; /** - * 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. + * Updates the current Vector4 with the passed one coordinates. + * Returns the updated Vector4. */ - globalSaturation: number; - private _highlightsHue; - private _highlightsDensity; - private _highlightsSaturation; - private _highlightsExposure; + copyFrom(source: Vector4): Vector4; /** - * 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). + * Updates the current Vector4 coordinates with the passed floats. + * Returns the updated Vector4. */ + copyFromFloats(x: number, y: number, z: number, w: number): Vector4; /** - * 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). + * Updates the current Vector4 coordinates with the passed floats. + * Returns the updated Vector4. */ - highlightsHue: number; + set(x: number, y: number, z: number, w: number): Vector4; /** - * 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. + * Returns a new Vector4 set from the starting index of the passed array. */ + static FromArray(array: ArrayLike, offset?: number): Vector4; /** - * 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. + * Updates the passed vector "result" from the starting index of the passed array. */ - highlightsDensity: number; + static FromArrayToRef(array: ArrayLike, offset: number, result: Vector4): void; /** - * 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. + * Updates the passed vector "result" from the starting index of the passed Float32Array. */ + static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void; /** - * 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. + * Updates the passed vector "result" coordinates from the passed floats. */ - highlightsSaturation: number; + static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void; /** - * 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. + * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0) */ + static Zero(): Vector4; /** - * 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. + * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0) */ - highlightsExposure: number; - private _midtonesHue; - private _midtonesDensity; - private _midtonesSaturation; - private _midtonesExposure; + static One(): Vector4; /** - * 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). + * Returns a new normalized Vector4 from the passed one. */ + static Normalize(vector: Vector4): Vector4; /** - * 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). + * Updates the passed vector "result" from the normalization of the passed one. */ - midtonesHue: number; + static NormalizeToRef(vector: Vector4, result: Vector4): void; + static Minimize(left: Vector4, right: Vector4): Vector4; + static Maximize(left: Vector4, right: Vector4): Vector4; /** - * 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. + * Returns the distance (float) between the vectors "value1" and "value2". */ + static Distance(value1: Vector4, value2: Vector4): number; /** - * 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. + * Returns the squared distance (float) between the vectors "value1" and "value2". */ - midtonesDensity: number; + static DistanceSquared(value1: Vector4, value2: Vector4): 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. + * Returns a new Vector4 located at the center between the vectors "value1" and "value2". */ + static Center(value1: Vector4, value2: Vector4): Vector4; /** - * 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. + * Returns a new Vector4 set with the result of the normal transformation by the passed matrix of the passed vector. + * This methods computes transformed normalized direction vectors only. */ - midtonesSaturation: number; + static TransformNormal(vector: Vector4, transformation: Matrix): Vector4; /** - * 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 passed vector "result" with the result of the normal transformation by the passed matrix of the passed vector. + * This methods computes transformed normalized direction vectors only. */ + static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void; /** - * 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. + * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed floats (x, y, z, w). + * This methods computes transformed normalized direction vectors only. */ - midtonesExposure: number; - private _shadowsHue; - private _shadowsDensity; - private _shadowsSaturation; - private _shadowsExposure; + static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void; + } + interface ISize { + width: number; + height: number; + } + class Size implements ISize { + width: number; + height: number; /** - * 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). + * Creates a Size object from the passed width and height (floats). */ + constructor(width: number, height: number); + toString(): string; /** - * 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). + * Returns the string "Size" */ - shadowsHue: number; + getClassName(): string; /** - * 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. + * Returns the Size hash code. */ + getHashCode(): number; /** - * 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. + * Updates the current size from the passed one. + * Returns the updated Size. */ - shadowsDensity: number; + copyFrom(src: Size): void; /** - * 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. + * Updates in place the current Size from the passed floats. + * Returns the updated Size. */ + copyFromFloats(width: number, height: number): Size; /** - * 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. + * Updates in place the current Size from the passed floats. + * Returns the updated Size. */ - shadowsSaturation: number; + set(width: number, height: number): Size; /** - * 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. + * Returns a new Size set with the multiplication result of the current Size and the passed floats. */ + multiplyByFloats(w: number, h: number): Size; /** - * 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. + * Returns a new Size copied from the passed one. */ - shadowsExposure: number; - getClassName(): string; + clone(): Size; /** - * Binds the color curves to the shader. - * @param colorCurves The color curve to bind - * @param effect The effect to bind to + * Boolean : True if the current Size and the passed one width and height are strictly equal. */ - static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void; + equals(other: Size): boolean; /** - * Prepare the list of uniforms associated with the ColorCurves effects. - * @param uniformsList The list of uniforms used in the effect + * Returns the surface of the Size : width * height (float). */ - static PrepareUniforms(uniformsList: string[]): void; + readonly surface: number; /** - * 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. + * Returns a new Size set to (0.0, 0.0) */ - private getColorGradingDataToRef(hue, density, saturation, exposure, result); + static Zero(): Size; /** - * 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. + * Returns a new Size set as the addition result of the current Size and the passed one. */ - private static applyColorGradingSliderNonlinear(value); + add(otherSize: Size): Size; /** - * 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. + * Returns a new Size set as the subtraction result of the passed one from the current Size. */ - private static fromHSBToRef(hue, saturation, brightness, result); + subtract(otherSize: Size): Size; /** - * 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. + * Returns a new Size set at the linear interpolation "amount" between "start" and "end". */ - private static clamp(value, min, max); + static Lerp(start: Size, end: Size, amount: number): Size; + } + class Quaternion { + x: number; + y: number; + z: number; + w: number; /** - * Clones the current color curve instance. - * @return The cloned curves + * Creates a new Quaternion from the passed floats. */ - clone(): ColorCurves; + constructor(x?: number, y?: number, z?: number, w?: number); /** - * Serializes the current color curve instance to a json representation. - * @return a JSON representation + * Returns a string with the Quaternion coordinates. */ - serialize(): any; + toString(): string; /** - * Parses the color curve from a json representation. - * @param source the JSON source to parse - * @return The parsed curves + * Returns the string "Quaternion". */ - static Parse(source: any): ColorCurves; - } -} - -declare module BABYLON { - class EffectFallbacks { - private _defines; - private _currentRank; - private _maxRank; - private _mesh; - private _meshRank; - addFallback(rank: number, define: string): void; - addCPUSkinningFallback(rank: number, mesh: BABYLON.AbstractMesh): void; - readonly isMoreFallbacks: boolean; - reduce(currentDefines: string): string; - } - class EffectCreationOptions { - attributes: string[]; - uniformsNames: string[]; - uniformBuffersNames: string[]; - samplers: string[]; - defines: any; - fallbacks: EffectFallbacks; - onCompiled: (effect: Effect) => void; - onError: (effect: Effect, errors: string) => void; - indexParameters: any; - maxSimultaneousLights: number; - } - class Effect { - name: any; - defines: string; - onCompiled: (effect: Effect) => void; - onError: (effect: Effect, errors: string) => void; - onBind: (effect: Effect) => void; - uniqueId: number; - onCompileObservable: Observable; - onErrorObservable: Observable; - onBindObservable: Observable; - private static _uniqueIdSeed; - private _engine; - private _uniformBuffersNames; - private _uniformsNames; - private _samplers; - private _isReady; - private _compilationError; - private _attributesNames; - private _attributes; - private _uniforms; - _key: string; - private _indexParameters; - private _fallbacks; - private _program; - private _valueCache; - private static _baseCache; - constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], engine?: Engine, defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, indexParameters?: any); - readonly key: string; - isReady(): boolean; - getEngine(): Engine; - getProgram(): WebGLProgram; - getAttributesNames(): string[]; - getAttributeLocation(index: number): number; - getAttributeLocationByName(name: string): number; - getAttributesCount(): number; - getUniformIndex(uniformName: string): number; - getUniform(uniformName: string): WebGLUniformLocation; - getSamplers(): string[]; - getCompilationError(): string; - getVertexShaderSource(): string; - getFragmentShaderSource(): string; - executeWhenCompiled(func: (effect: Effect) => void): void; - _loadVertexShader(vertex: any, callback: (data: any) => void): void; - _loadFragmentShader(fragment: any, callback: (data: any) => void): void; - private _dumpShadersSource(vertexCode, fragmentCode, defines); - private _processShaderConversion(sourceCode, isFragment, callback); - private _processIncludes(sourceCode, callback); - private _processPrecision(source); - private _prepareEffect(vertexSourceCode, fragmentSourceCode, attributesNames, defines, fallbacks?); - readonly isSupported: boolean; - _bindTexture(channel: string, texture: WebGLTexture): void; - setTexture(channel: string, texture: BaseTexture): void; - setTextureArray(channel: string, textures: BaseTexture[]): void; - setTextureFromPostProcess(channel: string, postProcess: PostProcess): void; - _cacheMatrix(uniformName: string, matrix: Matrix): boolean; - _cacheFloat2(uniformName: string, x: number, y: number): boolean; - _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean; - _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean; - bindUniformBuffer(buffer: WebGLBuffer, name: string): void; - bindUniformBlock(blockName: string, index: number): void; - setIntArray(uniformName: string, array: Int32Array): Effect; - setIntArray2(uniformName: string, array: Int32Array): Effect; - setIntArray3(uniformName: string, array: Int32Array): Effect; - setIntArray4(uniformName: string, array: Int32Array): Effect; - setFloatArray(uniformName: string, array: Float32Array): Effect; - setFloatArray2(uniformName: string, array: Float32Array): Effect; - setFloatArray3(uniformName: string, array: Float32Array): Effect; - setFloatArray4(uniformName: string, array: Float32Array): Effect; - setArray(uniformName: string, array: number[]): Effect; - setArray2(uniformName: string, array: number[]): Effect; - setArray3(uniformName: string, array: number[]): Effect; - setArray4(uniformName: string, array: number[]): Effect; - setMatrices(uniformName: string, matrices: Float32Array): Effect; - setMatrix(uniformName: string, matrix: Matrix): Effect; - setMatrix3x3(uniformName: string, matrix: Float32Array): Effect; - setMatrix2x2(uniformName: string, matrix: Float32Array): Effect; - setFloat(uniformName: string, value: number): Effect; - setBool(uniformName: string, bool: boolean): Effect; - setVector2(uniformName: string, vector2: Vector2): Effect; - setFloat2(uniformName: string, x: number, y: number): Effect; - setVector3(uniformName: string, vector3: Vector3): Effect; - setFloat3(uniformName: string, x: number, y: number, z: number): Effect; - setVector4(uniformName: string, vector4: Vector4): Effect; - setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect; - setColor3(uniformName: string, color3: Color3): Effect; - setColor4(uniformName: string, color3: Color3, alpha: number): Effect; - private _recombineShader(node); - private _evaluateDefinesOnString(shaderString); - static ShadersStore: {}; - static IncludesShadersStore: {}; - static ResetCache(): void; - } -} - -declare module BABYLON { - class FresnelParameters { - private _isEnabled; - isEnabled: boolean; - leftColor: Color3; - rightColor: Color3; - bias: number; - power: number; - clone(): FresnelParameters; - serialize(): any; - static Parse(parsedFresnelParameters: any): FresnelParameters; - } -} - -declare module BABYLON { - /** - * Interface to follow in your material defines to integrate easily the - * Image proccessing functions. - */ - interface IImageProcessingConfigurationDefines { - IMAGEPROCESSING: boolean; - VIGNETTE: boolean; - VIGNETTEBLENDMODEMULTIPLY: boolean; - VIGNETTEBLENDMODEOPAQUE: boolean; - TONEMAPPING: boolean; - CONTRAST: boolean; - EXPOSURE: boolean; - COLORCURVES: boolean; - COLORGRADING: boolean; - SAMPLER3DGREENDEPTH: boolean; - SAMPLER3DBGRMAP: boolean; - IMAGEPROCESSINGPOSTPROCESS: boolean; - } - /** - * 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 { + getClassName(): string; /** - * Color curves setup used in the effect if colorCurvesEnabled is set to true + * Returns the Quaternion hash code. */ - colorCurves: ColorCurves; - private _colorCurvesEnabled; + getHashCode(): number; /** - * Gets wether the color curves effect is enabled. + * Returns a new array populated with 4 elements : the Quaternion coordinates. */ + asArray(): number[]; /** - * Sets wether the color curves effect is enabled. + * Boolean : True if the current Quaterion and the passed one coordinates are strictly equal. */ - colorCurvesEnabled: boolean; + equals(otherQuaternion: Quaternion): boolean; /** - * Color grading LUT texture used in the effect if colorGradingEnabled is set to true + * Returns a new Quaternion copied from the current one. */ - colorGradingTexture: BaseTexture; - private _colorGradingEnabled; + clone(): Quaternion; /** - * Gets wether the color grading effect is enabled. + * Updates the current Quaternion from the passed one coordinates. + * Returns the updated Quaterion. */ + copyFrom(other: Quaternion): Quaternion; /** - * Sets wether the color grading effect is enabled. + * Updates the current Quaternion from the passed float coordinates. + * Returns the updated Quaterion. */ - colorGradingEnabled: boolean; - private _colorGradingWithGreenDepth; + copyFromFloats(x: number, y: number, z: number, w: number): Quaternion; /** - * Gets wether the color grading effect is using a green depth for the 3d Texture. + * Updates the current Quaternion from the passed float coordinates. + * Returns the updated Quaterion. */ + set(x: number, y: number, z: number, w: number): Quaternion; /** - * Sets wether the color grading effect is using a green depth for the 3d Texture. + * Returns a new Quaternion as the addition result of the passed one and the current Quaternion. */ - colorGradingWithGreenDepth: boolean; - private _colorGradingBGR; + add(other: Quaternion): Quaternion; /** - * Gets wether the color grading texture contains BGR values. + * Returns a new Quaternion as the subtraction result of the passed one from the current Quaternion. */ + subtract(other: Quaternion): Quaternion; /** - * Sets wether the color grading texture contains BGR values. + * Returns a new Quaternion set by multiplying the current Quaterion coordinates by the float "scale". */ - colorGradingBGR: boolean; - _exposure: number; + scale(value: number): Quaternion; /** - * Gets the Exposure used in the effect. + * Returns a new Quaternion set as the quaternion mulplication result of the current one with the passed one "q1". */ + multiply(q1: Quaternion): Quaternion; /** - * Sets the Exposure used in the effect. + * Sets the passed "result" as the quaternion mulplication result of the current one with the passed one "q1". + * Returns the current Quaternion. */ - exposure: number; - private _toneMappingEnabled; + multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion; /** - * Gets wether the tone mapping effect is enabled. + * Updates the current Quaternion with the quaternion mulplication result of itself with the passed one "q1". + * Returns the updated Quaternion. */ + multiplyInPlace(q1: Quaternion): Quaternion; /** - * Sets wether the tone mapping effect is enabled. + * Sets the passed "ref" with the conjugation of the current Quaternion. + * Returns the current Quaternion. */ - toneMappingEnabled: boolean; - protected _contrast: number; + conjugateToRef(ref: Quaternion): Quaternion; /** - * Gets the contrast used in the effect. + * Conjugates in place the current Quaternion. + * Returns the updated Quaternion. */ + conjugateInPlace(): Quaternion; /** - * Sets the contrast used in the effect. + * Returns a new Quaternion as the conjugate of the current Quaternion. */ - contrast: number; + conjugate(): Quaternion; /** - * Vignette stretch size. + * Returns the Quaternion length (float). */ - vignetteStretch: number; + length(): number; /** - * Vignette centre X Offset. + * Normalize in place the current Quaternion. + * Returns the updated Quaternion. */ - vignetteCentreX: number; + normalize(): Quaternion; /** - * Vignette centre Y Offset. + * Returns a new Vector3 set with the Euler angles translated from the current Quaternion. */ - vignetteCentreY: number; + toEulerAngles(order?: string): Vector3; /** - * Vignette weight or intensity of the vignette effect. + * Sets the passed vector3 "result" with the Euler angles translated from the current Quaternion. + * Returns the current Quaternion. */ - vignetteWeight: number; + toEulerAnglesToRef(result: Vector3, order?: string): Quaternion; /** - * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode) - * if vignetteEnabled is set to true. + * Updates the passed rotation matrix with the current Quaternion values. + * Returns the current Quaternion. */ - vignetteColor: BABYLON.Color4; + toRotationMatrix(result: Matrix): Quaternion; /** - * Camera field of view used by the Vignette effect. + * Updates the current Quaternion from the passed rotation matrix values. + * Returns the updated Quaternion. */ - vignetteCameraFov: number; - private _vignetteBlendMode; + fromRotationMatrix(matrix: Matrix): Quaternion; /** - * Gets the vignette blend mode allowing different kind of effect. + * Returns a new Quaternion set from the passed rotation matrix values. */ + static FromRotationMatrix(matrix: Matrix): Quaternion; /** - * Sets the vignette blend mode allowing different kind of effect. + * Updates the passed quaternion "result" with the passed rotation matrix values. */ - vignetteBlendMode: number; - private _vignetteEnabled; + static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void; /** - * Gets wether the vignette effect is enabled. + * Returns a new Quaternion set to (0.0, 0.0, 0.0). */ + static Zero(): Quaternion; /** - * Sets wether the vignette effect is enabled. + * Returns a new Quaternion as the inverted current Quaternion. */ - vignetteEnabled: boolean; - private _applyByPostProcess; + static Inverse(q: Quaternion): Quaternion; /** - * Gets wether the image processing is applied through a post process or not. + * Returns the identity Quaternion. */ + static Identity(): Quaternion; + static IsIdentity(quaternion: Quaternion): boolean; /** - * Sets wether the image processing is applied through a post process or not. + * Returns a new Quaternion set from the passed axis (Vector3) and angle in radians (float). */ - applyByPostProcess: boolean; + static RotationAxis(axis: Vector3, angle: number): Quaternion; /** - * An event triggered when the configuration changes and requires Shader to Update some parameters. - * @type {BABYLON.Observable} - */ - onUpdateParameters: Observable; + * Sets the passed quaternion "result" from the passed axis (Vector3) and angle in radians (float). + */ + static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion; /** - * Method called each time the image processing information changes requires to recompile the effect. + * Retuns a new Quaternion set from the starting index of the passed array. */ - protected _updateParameters(): void; - getClassName(): string; + static FromArray(array: ArrayLike, offset?: number): Quaternion; /** - * Prepare the list of uniforms associated with the Image Processing effects. - * @param uniformsList The list of uniforms used in the effect - * @param defines the list of defines currently in use + * Returns a new Quaternion set from the passed Euler float angles (y, x, z). */ - static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void; + static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion; /** - * Prepare the list of samplers associated with the Image Processing effects. - * @param uniformsList The list of uniforms used in the effect - * @param defines the list of defines currently in use + * Sets the passed quaternion "result" from the passed float Euler angles (y, x, z). */ - static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void; + static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void; /** - * Prepare the list of defines associated to the shader. - * @param defines the list of defines to complete + * Returns a new Quaternion from the passed float Euler angles expressed in z-x-z orientation */ - prepareDefines(defines: IImageProcessingConfigurationDefines): void; + static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion; /** - * Returns true if all the image processing information are ready. + * Sets the passed quaternion "result" from the passed float Euler angles expressed in z-x-z orientation */ - isReady(): boolean; + static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void; /** - * Binds the image processing to the shader. - * @param effect The effect to bind to + * Returns a new Quaternion as the quaternion rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system. + * cf to Vector3.RotationFromAxis() documentation. + * Note : axis1, axis2 and axis3 are normalized during this operation. */ - bind(effect: Effect, aspectRatio?: number): void; + static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): Quaternion; /** - * Clones the current image processing instance. - * @return The cloned image processing + * Sets the passed quaternion "ref" with the quaternion rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system. + * cf to Vector3.RotationFromAxis() documentation. + * Note : axis1, axis2 and axis3 are normalized during this operation. */ - clone(): ImageProcessingConfiguration; + static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void; + static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion; + static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void; /** - * Serializes the current image processing instance to a json representation. - * @return a JSON representation + * Returns a new Quaternion located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2". */ - serialize(): any; + static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion; + } + class Matrix { + private static _tempQuaternion; + private static _xAxis; + private static _yAxis; + private static _zAxis; + private static _updateFlagSeed; + private _isIdentity; + private _isIdentityDirty; + updateFlag: number; + m: Float32Array; + _markAsUpdated(): void; + constructor(); /** - * Parses the image processing from a json representation. - * @param source the JSON source to parse - * @return The parsed image processing + * Boolean : True is the matrix is the identity matrix */ - static Parse(source: any): ImageProcessingConfiguration; - private static _VIGNETTEMODE_MULTIPLY; - private static _VIGNETTEMODE_OPAQUE; + isIdentity(considerAsTextureMatrix?: boolean): boolean; /** - * Used to apply the vignette as a mix with the pixel color. + * Returns the matrix determinant (float). */ - static readonly VIGNETTEMODE_MULTIPLY: number; + determinant(): number; /** - * Used to apply the vignette as a replacement of the pixel color. + * Returns the matrix underlying array. */ - static readonly VIGNETTEMODE_OPAQUE: number; - } -} - -declare module BABYLON { - class MaterialDefines { - private _keys; - private _isDirty; - _renderId: number; - _areLightsDirty: boolean; - _areAttributesDirty: boolean; - _areTexturesDirty: boolean; - _areFresnelDirty: boolean; - _areMiscDirty: boolean; - _areImageProcessingDirty: boolean; - _normals: boolean; - _uvs: boolean; - _needNormals: boolean; - _needUVs: boolean; - readonly isDirty: boolean; - markAsProcessed(): void; - markAsUnprocessed(): void; - markAllAsDirty(): void; - markAsImageProcessingDirty(): void; - markAsLightDirty(): void; - markAsAttributesDirty(): void; - markAsTexturesDirty(): void; - markAsFresnelDirty(): void; - markAsMiscDirty(): void; - rebuild(): void; - isEqual(other: MaterialDefines): boolean; - cloneTo(other: MaterialDefines): void; - reset(): void; - toString(): string; - } - class Material { - private static _TriangleFillMode; - private static _WireFrameFillMode; - private static _PointFillMode; - static readonly TriangleFillMode: number; - static readonly WireFrameFillMode: number; - static readonly PointFillMode: number; - private static _ClockWiseSideOrientation; - private static _CounterClockWiseSideOrientation; - static readonly ClockWiseSideOrientation: number; - static readonly CounterClockWiseSideOrientation: number; - private static _TextureDirtyFlag; - private static _LightDirtyFlag; - private static _FresnelDirtyFlag; - private static _AttributesDirtyFlag; - private static _MiscDirtyFlag; - static readonly TextureDirtyFlag: number; - static readonly LightDirtyFlag: number; - static readonly FresnelDirtyFlag: number; - static readonly AttributesDirtyFlag: number; - static readonly MiscDirtyFlag: number; - id: string; - name: string; - checkReadyOnEveryCall: boolean; - checkReadyOnlyOnce: boolean; - state: string; - alpha: number; - protected _backFaceCulling: boolean; - backFaceCulling: boolean; - sideOrientation: number; - onCompiled: (effect: Effect) => void; - onError: (effect: Effect, errors: string) => void; - getRenderTargetTextures: () => SmartArray; - doNotSerialize: boolean; - storeEffectOnSubMeshes: boolean; + toArray(): Float32Array; /** - * An event triggered when the material is disposed. - * @type {BABYLON.Observable} + * Returns the matrix underlying array. */ - onDisposeObservable: Observable; - private _onDisposeObserver; - onDispose: () => void; + asArray(): Float32Array; /** - * An event triggered when the material is bound. - * @type {BABYLON.Observable} - */ - onBindObservable: Observable; - private _onBindObserver; - onBind: (Mesh: AbstractMesh) => void; + * Inverts in place the Matrix. + * Returns the Matrix inverted. + */ + invert(): Matrix; /** - * An event triggered when the material is unbound. - * @type {BABYLON.Observable} - */ - onUnBindObservable: Observable; - alphaMode: number; - disableDepthWrite: boolean; - private _fogEnabled; - fogEnabled: boolean; - pointSize: number; - zOffset: number; - wireframe: boolean; - pointsCloud: boolean; - fillMode: number; - _effect: Effect; - _wasPreviouslyReady: boolean; - private _useUBO; - private _scene; - private _fillMode; - private _cachedDepthWriteState; - protected _uniformBuffer: UniformBuffer; - constructor(name: string, scene: Scene, doNotAdd?: boolean); + * Sets all the matrix elements to zero. + * Returns the Matrix. + */ + reset(): Matrix; /** - * @param {boolean} fullDetails - support for multiple levels of logging within scene loading - * subclasses should override adding information pertainent to themselves + * Returns a new Matrix as the addition result of the current Matrix and the passed one. */ - toString(fullDetails?: boolean): string; + add(other: Matrix): Matrix; /** - * Child classes can use it to update shaders + * Sets the passed matrix "result" with the ddition result of the current Matrix and the passed one. + * Returns the Matrix. */ - getClassName(): string; - readonly isFrozen: boolean; - freeze(): void; - unfreeze(): void; - isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean; - isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean; - getEffect(): Effect; - getScene(): Scene; - needAlphaBlending(): boolean; - needAlphaTesting(): boolean; - getAlphaTestTexture(): BaseTexture; - markDirty(): void; - _preBind(effect?: Effect): void; - bind(world: Matrix, mesh?: Mesh): void; - bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void; - bindOnlyWorldMatrix(world: Matrix): void; - bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void; - bindView(effect: Effect): void; - bindViewProjection(effect: Effect): void; - protected _afterBind(mesh: Mesh): void; - unbind(): void; - getActiveTextures(): BaseTexture[]; - hasTexture(texture: BaseTexture): boolean; - clone(name: string): Material; - getBindedMeshes(): AbstractMesh[]; + addToRef(other: Matrix, result: Matrix): Matrix; /** - * Force shader compilation including textures ready check + * Adds in place the passed matrix to the current Matrix. + * Returns the updated Matrix. + */ + addToSelf(other: Matrix): Matrix; + /** + * Sets the passed matrix with the current inverted Matrix. + * Returns the unmodified current Matrix. + */ + invertToRef(other: Matrix): Matrix; + /** + * Inserts the translation vector (using 3 x floats) in the current Matrix. + * Returns the updated Matrix. + */ + setTranslationFromFloats(x: number, y: number, z: number): Matrix; + /** + * Inserts the translation vector in the current Matrix. + * Returns the updated Matrix. + */ + setTranslation(vector3: Vector3): Matrix; + /** + * Returns a new Vector3 as the extracted translation from the Matrix. + */ + getTranslation(): Vector3; + /** + * Fill a Vector3 with the extracted translation from the Matrix. + */ + getTranslationToRef(result: Vector3): Matrix; + /** + * Remove rotation and scaling part from the Matrix. + * Returns the updated Matrix. + */ + removeRotationAndScaling(): Matrix; + /** + * Returns a new Matrix set with the multiplication result of the current Matrix and the passed one. + */ + multiply(other: Matrix): Matrix; + /** + * Updates the current Matrix from the passed one values. + * Returns the updated Matrix. + */ + copyFrom(other: Matrix): Matrix; + /** + * Populates the passed array from the starting index with the Matrix values. + * Returns the Matrix. + */ + copyToArray(array: Float32Array, offset?: number): Matrix; + /** + * Sets the passed matrix "result" with the multiplication result of the current Matrix and the passed one. + */ + multiplyToRef(other: Matrix, result: Matrix): Matrix; + /** + * Sets the Float32Array "result" from the passed index "offset" with the multiplication result of the current Matrix and the passed one. + */ + multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix; + /** + * Boolean : True is the current Matrix and the passed one values are strictly equal. + */ + equals(value: Matrix): boolean; + /** + * Returns a new Matrix from the current Matrix. + */ + clone(): Matrix; + /** + * Returns the string "Matrix" */ - forceCompilation(mesh: AbstractMesh, onCompiled: (material: Material) => void, options?: { - alphaTest: boolean; - clipPlane: boolean; - }): void; - markAsDirty(flag: number): void; - protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void; - protected _markAllSubMeshesAsImageProcessingDirty(): void; - protected _markAllSubMeshesAsTexturesDirty(): void; - protected _markAllSubMeshesAsFresnelDirty(): void; - protected _markAllSubMeshesAsLightsDirty(): void; - protected _markAllSubMeshesAsAttributesDirty(): void; - protected _markAllSubMeshesAsMiscDirty(): void; - dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void; - serialize(): any; - static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial; - static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any; - } -} - -declare module BABYLON { - class MaterialHelper { - static PrepareDefinesForMergedUV(texture: BaseTexture, defines: MaterialDefines, key: string): void; - static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void; - static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: any, fogEnabled: boolean, defines: MaterialDefines): void; - static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: MaterialDefines, useInstances: boolean, forceAlphaTest?: boolean): void; - static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: MaterialDefines, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean): boolean; - static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: MaterialDefines, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean; - static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: MaterialDefines, maxSimultaneousLights?: number): void; - static HandleFallbacksForShadows(defines: MaterialDefines, fallbacks: EffectFallbacks, maxSimultaneousLights?: number): void; - static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: MaterialDefines): void; - static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: MaterialDefines, fallbacks: EffectFallbacks): void; - static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void; - static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void; - static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void; - static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: MaterialDefines, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void; - static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect): void; - static BindBonesParameters(mesh: AbstractMesh, effect: Effect): void; - static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void; - static BindLogDepth(defines: MaterialDefines, effect: Effect, scene: Scene): void; - static BindClipPlane(effect: Effect, scene: Scene): void; - } -} - -declare module BABYLON { - class MultiMaterial extends Material { - private _subMaterials; - subMaterials: Material[]; - constructor(name: string, scene: Scene); - private _hookArray(array); - getSubMaterial(index: any): Material; - getActiveTextures(): BaseTexture[]; - getClassName(): string; - isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean; - clone(name: string, cloneChildren?: boolean): MultiMaterial; - serialize(): any; - dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void; - } -} - -declare module BABYLON { - class PushMaterial extends Material { - protected _activeEffect: Effect; - constructor(name: string, scene: Scene); - getEffect(): Effect; - isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean; - bindOnlyWorldMatrix(world: Matrix): void; - bind(world: Matrix, mesh?: Mesh): void; - protected _afterBind(mesh: Mesh, effect?: Effect): void; - protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean; - } -} - -declare module BABYLON { - class ShaderMaterial extends Material { - private _shaderPath; - private _options; - private _textures; - private _textureArrays; - private _floats; - private _floatsArrays; - private _colors3; - private _colors3Arrays; - private _colors4; - private _vectors2; - private _vectors3; - private _vectors4; - private _matrices; - private _matrices3x3; - private _matrices2x2; - private _vectors3Arrays; - private _cachedWorldViewMatrix; - private _renderId; - constructor(name: string, scene: Scene, shaderPath: any, options: any); getClassName(): string; - needAlphaBlending(): boolean; - needAlphaTesting(): boolean; - private _checkUniform(uniformName); - setTexture(name: string, texture: Texture): ShaderMaterial; - setTextureArray(name: string, textures: Texture[]): ShaderMaterial; - setFloat(name: string, value: number): ShaderMaterial; - setFloats(name: string, value: number[]): ShaderMaterial; - setColor3(name: string, value: Color3): ShaderMaterial; - setColor3Array(name: string, value: Color3[]): ShaderMaterial; - setColor4(name: string, value: Color4): ShaderMaterial; - setVector2(name: string, value: Vector2): ShaderMaterial; - setVector3(name: string, value: Vector3): ShaderMaterial; - setVector4(name: string, value: Vector4): ShaderMaterial; - setMatrix(name: string, value: Matrix): ShaderMaterial; - setMatrix3x3(name: string, value: Float32Array): ShaderMaterial; - setMatrix2x2(name: string, value: Float32Array): ShaderMaterial; - setArray3(name: string, value: number[]): ShaderMaterial; - private _checkCache(scene, mesh?, useInstances?); - isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean; - bindOnlyWorldMatrix(world: Matrix): void; - bind(world: Matrix, mesh?: Mesh): void; - getActiveTextures(): BaseTexture[]; - hasTexture(texture: BaseTexture): boolean; - clone(name: string): ShaderMaterial; - dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void; - serialize(): any; - static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial; - } -} - -declare module BABYLON { - class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines { - MAINUV1: boolean; - MAINUV2: boolean; - DIFFUSE: boolean; - DIFFUSEDIRECTUV: number; - AMBIENT: boolean; - AMBIENTDIRECTUV: number; - OPACITY: boolean; - OPACITYDIRECTUV: number; - OPACITYRGB: boolean; - REFLECTION: boolean; - EMISSIVE: boolean; - EMISSIVEDIRECTUV: number; - SPECULAR: boolean; - SPECULARDIRECTUV: number; - BUMP: boolean; - BUMPDIRECTUV: number; - PARALLAX: boolean; - PARALLAXOCCLUSION: boolean; - SPECULAROVERALPHA: boolean; - CLIPPLANE: boolean; - ALPHATEST: boolean; - ALPHAFROMDIFFUSE: boolean; - POINTSIZE: boolean; - FOG: boolean; - SPECULARTERM: boolean; - DIFFUSEFRESNEL: boolean; - OPACITYFRESNEL: boolean; - REFLECTIONFRESNEL: boolean; - REFRACTIONFRESNEL: boolean; - EMISSIVEFRESNEL: boolean; - FRESNEL: boolean; - NORMAL: boolean; - UV1: boolean; - UV2: boolean; - VERTEXCOLOR: boolean; - VERTEXALPHA: boolean; - NUM_BONE_INFLUENCERS: number; - BonesPerMesh: number; - INSTANCES: boolean; - GLOSSINESS: boolean; - ROUGHNESS: boolean; - EMISSIVEASILLUMINATION: boolean; - LINKEMISSIVEWITHDIFFUSE: boolean; - REFLECTIONFRESNELFROMSPECULAR: boolean; - LIGHTMAP: boolean; - LIGHTMAPDIRECTUV: number; - USELIGHTMAPASSHADOWMAP: boolean; - REFLECTIONMAP_3D: boolean; - REFLECTIONMAP_SPHERICAL: boolean; - REFLECTIONMAP_PLANAR: boolean; - REFLECTIONMAP_CUBIC: boolean; - REFLECTIONMAP_PROJECTION: boolean; - REFLECTIONMAP_SKYBOX: boolean; - REFLECTIONMAP_EXPLICIT: boolean; - REFLECTIONMAP_EQUIRECTANGULAR: boolean; - REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean; - REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean; - INVERTCUBICMAP: boolean; - LOGARITHMICDEPTH: boolean; - REFRACTION: boolean; - REFRACTIONMAP_3D: boolean; - REFLECTIONOVERALPHA: boolean; - TWOSIDEDLIGHTING: boolean; - SHADOWFLOAT: boolean; - MORPHTARGETS: boolean; - MORPHTARGETS_NORMAL: boolean; - MORPHTARGETS_TANGENT: boolean; - NUM_MORPH_INFLUENCERS: number; - USERIGHTHANDEDSYSTEM: boolean; - IMAGEPROCESSING: boolean; - VIGNETTE: boolean; - VIGNETTEBLENDMODEMULTIPLY: boolean; - VIGNETTEBLENDMODEOPAQUE: boolean; - TONEMAPPING: boolean; - CONTRAST: boolean; - COLORCURVES: boolean; - COLORGRADING: boolean; - SAMPLER3DGREENDEPTH: boolean; - SAMPLER3DBGRMAP: boolean; - IMAGEPROCESSINGPOSTPROCESS: boolean; - EXPOSURE: boolean; - constructor(); - setReflectionMode(modeToEnable: string): void; - } - class StandardMaterial extends PushMaterial { - private _diffuseTexture; - diffuseTexture: BaseTexture; - private _ambientTexture; - ambientTexture: BaseTexture; - private _opacityTexture; - opacityTexture: BaseTexture; - private _reflectionTexture; - reflectionTexture: BaseTexture; - private _emissiveTexture; - emissiveTexture: BaseTexture; - private _specularTexture; - specularTexture: BaseTexture; - private _bumpTexture; - bumpTexture: BaseTexture; - private _lightmapTexture; - lightmapTexture: BaseTexture; - private _refractionTexture; - refractionTexture: BaseTexture; - ambientColor: Color3; - diffuseColor: Color3; - specularColor: Color3; - emissiveColor: Color3; - specularPower: number; - private _useAlphaFromDiffuseTexture; - useAlphaFromDiffuseTexture: boolean; - private _useEmissiveAsIllumination; - useEmissiveAsIllumination: boolean; - private _linkEmissiveWithDiffuse; - linkEmissiveWithDiffuse: boolean; - private _useSpecularOverAlpha; - useSpecularOverAlpha: boolean; - private _useReflectionOverAlpha; - useReflectionOverAlpha: boolean; - private _disableLighting; - disableLighting: boolean; - private _useParallax; - useParallax: boolean; - private _useParallaxOcclusion; - useParallaxOcclusion: boolean; - parallaxScaleBias: number; - private _roughness; - roughness: number; - indexOfRefraction: number; - invertRefractionY: boolean; - private _useLightmapAsShadowmap; - useLightmapAsShadowmap: boolean; - private _diffuseFresnelParameters; - diffuseFresnelParameters: FresnelParameters; - private _opacityFresnelParameters; - opacityFresnelParameters: FresnelParameters; - private _reflectionFresnelParameters; - reflectionFresnelParameters: FresnelParameters; - private _refractionFresnelParameters; - refractionFresnelParameters: FresnelParameters; - private _emissiveFresnelParameters; - emissiveFresnelParameters: FresnelParameters; - private _useReflectionFresnelFromSpecular; - useReflectionFresnelFromSpecular: boolean; - private _useGlossinessFromSpecularMapAlpha; - useGlossinessFromSpecularMapAlpha: boolean; - private _maxSimultaneousLights; - maxSimultaneousLights: number; /** - * If sets to true, x component of normal map value will invert (x = 1.0 - x). + * Returns the Matrix hash code. + */ + getHashCode(): number; + /** + * Decomposes the current Matrix into : + * - a scale vector3 passed as a reference to update, + * - a rotation quaternion passed as a reference to update, + * - a translation vector3 passed as a reference to update. + * Returns the boolean `true`. + */ + decompose(scale: Vector3, rotation: Quaternion, translation: Vector3): boolean; + /** + * Returns a new Matrix as the extracted rotation matrix from the current one. + */ + getRotationMatrix(): Matrix; + /** + * Extracts the rotation matrix from the current one and sets it as the passed "result". + * Returns the current Matrix. + */ + getRotationMatrixToRef(result: Matrix): Matrix; + /** + * Returns a new Matrix set from the starting index of the passed array. + */ + static FromArray(array: ArrayLike, offset?: number): Matrix; + /** + * Sets the passed "result" matrix from the starting index of the passed array. + */ + static FromArrayToRef(array: ArrayLike, offset: number, result: Matrix): void; + /** + * Sets the passed "result" matrix from the starting index of the passed Float32Array by multiplying each element by the float "scale". + */ + static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void; + /** + * Sets the passed matrix "result" with the 16 passed floats. + */ + static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void; + /** + * Returns the index-th row of the current matrix as a new Vector4. + */ + getRow(index: number): Vector4; + /** + * Sets the index-th row of the current matrix with the passed Vector4 values. + * Returns the updated Matrix. + */ + setRow(index: number, row: Vector4): Matrix; + /** + * Sets the index-th row of the current matrix with the passed 4 x float values. + * Returns the updated Matrix. + */ + setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix; + /** + * Returns a new Matrix set from the 16 passed floats. + */ + static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix; + /** + * Returns a new Matrix composed by the passed scale (vector3), rotation (quaternion) and translation (vector3). + */ + static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix; + /** + * Update a Matrix with values composed by the passed scale (vector3), rotation (quaternion) and translation (vector3). + */ + static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void; + /** + * Returns a new indentity Matrix. + */ + static Identity(): Matrix; + /** + * Sets the passed "result" as an identity matrix. + */ + static IdentityToRef(result: Matrix): void; + /** + * Returns a new zero Matrix. + */ + static Zero(): Matrix; + /** + * Returns a new rotation matrix for "angle" radians around the X axis. + */ + static RotationX(angle: number): Matrix; + /** + * Returns a new Matrix as the passed inverted one. + */ + static Invert(source: Matrix): Matrix; + /** + * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the X axis. + */ + static RotationXToRef(angle: number, result: Matrix): void; + /** + * Returns a new rotation matrix for "angle" radians around the Y axis. + */ + static RotationY(angle: number): Matrix; + /** + * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the Y axis. */ - private _invertNormalMapX; - invertNormalMapX: boolean; + static RotationYToRef(angle: number, result: Matrix): void; /** - * If sets to true, y component of normal map value will invert (y = 1.0 - y). + * Returns a new rotation matrix for "angle" radians around the Z axis. */ - private _invertNormalMapY; - invertNormalMapY: boolean; + static RotationZ(angle: number): Matrix; /** - * If sets to true and backfaceCulling is false, normals will be flipped on the backside. + * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the Z axis. */ - private _twoSidedLighting; - twoSidedLighting: boolean; + static RotationZToRef(angle: number, result: Matrix): void; /** - * Default configuration related to image processing available in the standard Material. + * Returns a new rotation matrix for "angle" radians around the passed axis. */ - protected _imageProcessingConfiguration: ImageProcessingConfiguration; + static RotationAxis(axis: Vector3, angle: number): Matrix; /** - * Gets the image processing configuration used either in this material. + * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the passed axis. */ + static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void; /** - * Sets the Default image processing configuration used either in the this material. - * - * If sets to null, the scene one is in use. + * Returns a new Matrix as a rotation matrix from the Euler angles (y, x, z). */ - imageProcessingConfiguration: ImageProcessingConfiguration; + static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix; /** - * Keep track of the image processing observer to allow dispose and replace. + * Sets the passed matrix "result" as a rotation matrix from the Euler angles (y, x, z). */ - private _imageProcessingObserver; + static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void; /** - * Attaches a new image processing configuration to the Standard Material. - * @param configuration + * Returns a new Matrix as a scaling matrix from the passed floats (x, y, z). */ - protected _attachImageProcessingConfiguration(configuration: ImageProcessingConfiguration): void; + static Scaling(x: number, y: number, z: number): Matrix; /** - * Gets wether the color curves effect is enabled. + * Sets the passed matrix "result" as a scaling matrix from the passed floats (x, y, z). */ + static ScalingToRef(x: number, y: number, z: number, result: Matrix): void; /** - * Sets wether the color curves effect is enabled. + * Returns a new Matrix as a translation matrix from the passed floats (x, y, z). */ - cameraColorCurvesEnabled: boolean; + static Translation(x: number, y: number, z: number): Matrix; /** - * Gets wether the color grading effect is enabled. + * Sets the passed matrix "result" as a translation matrix from the passed floats (x, y, z). */ + static TranslationToRef(x: number, y: number, z: number, result: Matrix): void; /** - * Gets wether the color grading effect is enabled. + * Returns a new Matrix whose values are the interpolated values for "gradien" (float) between the ones of the matrices "startValue" and "endValue". */ - cameraColorGradingEnabled: boolean; + static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix; /** - * Gets wether tonemapping is enabled or not. + * Returns a new Matrix whose values are computed by : + * - decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices, + * - interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end, + * - recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices. */ + static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix; /** - * Sets wether tonemapping is enabled or not + * Returns a new rotation Matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up". + * This methods works for a Left-Handed system. */ - cameraToneMappingEnabled: boolean; + static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix; /** - * The camera exposure used on this material. - * This property is here and not in the camera to allow controlling exposure without full screen post process. - * This corresponds to a photographic exposure. + * Sets the passed "result" Matrix as a rotation matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up". + * This methods works for a Left-Handed system. */ + static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void; /** - * The camera exposure used on this material. - * This property is here and not in the camera to allow controlling exposure without full screen post process. - * This corresponds to a photographic exposure. + * Returns a new rotation Matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up". + * This methods works for a Right-Handed system. */ - cameraExposure: number; + static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix; /** - * Gets The camera contrast used on this material. + * Sets the passed "result" Matrix as a rotation matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up". + * This methods works for a Left-Handed system. */ + static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void; /** - * Sets The camera contrast used on this material. + * Returns a new Matrix as a left-handed orthographic projection matrix computed from the passed floats : width and height of the projection plane, z near and far limits. */ - cameraContrast: number; + static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix; /** - * Gets the Color Grading 2D Lookup Texture. + * Sets the passed matrix "result" as a left-handed orthographic projection matrix computed from the passed floats : width and height of the projection plane, z near and far limits. */ + static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void; /** - * Sets the Color Grading 2D Lookup Texture. + * Returns a new Matrix as a left-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits. */ - cameraColorGradingTexture: BaseTexture; - customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string; - protected _renderTargets: SmartArray; - protected _worldViewProjectionMatrix: Matrix; - protected _globalAmbientColor: Color3; - protected _useLogarithmicDepth: boolean; - constructor(name: string, scene: Scene); - getClassName(): string; - useLogarithmicDepth: boolean; - needAlphaBlending(): boolean; - needAlphaTesting(): boolean; - protected _shouldUseAlphaFromDiffuseTexture(): boolean; - getAlphaTestTexture(): BaseTexture; + static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix; /** - * Child classes can use it to update shaders + * Sets the passed matrix "result" as a left-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits. */ - isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean; - buildUniformLayout(): void; - unbind(): void; - bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void; - getAnimatables(): IAnimatable[]; - getActiveTextures(): BaseTexture[]; - hasTexture(texture: BaseTexture): boolean; - dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void; - clone(name: string): StandardMaterial; - serialize(): any; - static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial; - static _DiffuseTextureEnabled: boolean; - static DiffuseTextureEnabled: boolean; - static _AmbientTextureEnabled: boolean; - static AmbientTextureEnabled: boolean; - static _OpacityTextureEnabled: boolean; - static OpacityTextureEnabled: boolean; - static _ReflectionTextureEnabled: boolean; - static ReflectionTextureEnabled: boolean; - static _EmissiveTextureEnabled: boolean; - static EmissiveTextureEnabled: boolean; - static _SpecularTextureEnabled: boolean; - static SpecularTextureEnabled: boolean; - static _BumpTextureEnabled: boolean; - static BumpTextureEnabled: boolean; - static _LightmapTextureEnabled: boolean; - static LightmapTextureEnabled: boolean; - static _RefractionTextureEnabled: boolean; - static RefractionTextureEnabled: boolean; - static _ColorGradingTextureEnabled: boolean; - static ColorGradingTextureEnabled: boolean; - static _FresnelEnabled: boolean; - static FresnelEnabled: boolean; + static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void; + /** + * Returns a new Matrix as a right-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits. + */ + static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix; + /** + * Sets the passed matrix "result" as a right-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits. + */ + static OrthoOffCenterRHToRef(left: number, right: any, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void; + /** + * Returns a new Matrix as a left-handed perspective projection matrix computed from the passed floats : width and height of the projection plane, z near and far limits. + */ + static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix; + /** + * Returns a new Matrix as a left-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits. + */ + static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix; + /** + * Sets the passed matrix "result" as a left-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits. + */ + static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void; + /** + * Returns a new Matrix as a right-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits. + */ + static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix; + /** + * Sets the passed matrix "result" as a right-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits. + */ + static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void; + /** + * Sets the passed matrix "result" as a left-handed perspective projection matrix for WebVR computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits. + */ + static PerspectiveFovWebVRToRef(fov: any, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void; + /** + * Returns the final transformation matrix : world * view * projection * viewport + */ + static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix; + /** + * Returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the passed Matrix. + */ + static GetAsMatrix2x2(matrix: Matrix): Float32Array; + /** + * Returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the passed Matrix. + */ + static GetAsMatrix3x3(matrix: Matrix): Float32Array; + /** + * Compute the transpose of the passed Matrix. + * Returns a new Matrix. + */ + static Transpose(matrix: Matrix): Matrix; + /** + * Returns a new Matrix as the reflection matrix across the passed plane. + */ + static Reflection(plane: Plane): Matrix; + /** + * Sets the passed matrix "result" as the reflection matrix across the passed plane. + */ + static ReflectionToRef(plane: Plane, result: Matrix): void; + /** + * Sets the passed matrix "mat" as a rotation matrix composed from the 3 passed left handed axis. + */ + static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void; + /** + * Sets the passed matrix "result" as a rotation matrix according to the passed quaternion. + */ + static FromQuaternionToRef(quat: Quaternion, result: Matrix): void; } -} - -declare module BABYLON { - class UniformBuffer { - private _engine; - private _buffer; - private _data; - private _bufferData; - private _dynamic; - private _uniformName; - private _uniformLocations; - private _uniformSizes; - private _uniformLocationPointer; - private _needSync; - private _cache; - private _noUBO; - private _currentEffect; - private static _MAX_UNIFORM_SIZE; - private static _tempBuffer; + class Plane { + normal: Vector3; + d: number; + /** + * Creates a Plane object according to the passed floats a, b, c, d and the plane equation : ax + by + cz + d = 0 + */ + constructor(a: number, b: number, c: number, d: number); + /** + * Returns the plane coordinates as a new array of 4 elements [a, b, c, d]. + */ + asArray(): number[]; + /** + * Returns a new plane copied from the current Plane. + */ + clone(): Plane; + /** + * Returns the string "Plane". + */ + getClassName(): string; + /** + * Returns the Plane hash code. + */ + getHashCode(): number; + /** + * Normalize the current Plane in place. + * Returns the updated Plane. + */ + normalize(): Plane; + /** + * Returns a new Plane as the result of the transformation of the current Plane by the passed matrix. + */ + transform(transformation: Matrix): Plane; /** - * Wrapper for updateUniform. - * @method updateMatrix3x3 - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {Float32Array} matrix + * Returns the dot product (float) of the point coordinates and the plane normal. */ - updateMatrix3x3: (name: string, matrix: Float32Array) => void; + dotCoordinate(point: any): number; /** - * Wrapper for updateUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {Float32Array} matrix + * Updates the current Plane from the plane defined by the three passed points. + * Returns the updated Plane. */ - updateMatrix2x2: (name: string, matrix: Float32Array) => void; + copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane; /** - * Wrapper for updateUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {number} x + * Boolean : True is the vector "direction" is the same side than the plane normal. */ - updateFloat: (name: string, x: number) => void; + isFrontFacingTo(direction: Vector3, epsilon: number): boolean; /** - * Wrapper for updateUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {number} x - * @param {number} y - * @param {string} [suffix] Suffix to add to the uniform name. + * Returns the signed distance (float) from the passed point to the Plane. */ - updateFloat2: (name: string, x: number, y: number, suffix?: string) => void; + signedDistanceTo(point: Vector3): number; /** - * Wrapper for updateUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {number} x - * @param {number} y - * @param {number} z - * @param {string} [suffix] Suffix to add to the uniform name. + * Returns a new Plane from the passed array. */ - updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void; + static FromArray(array: ArrayLike): Plane; /** - * Wrapper for updateUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {number} x - * @param {number} y - * @param {number} z - * @param {number} w - * @param {string} [suffix] Suffix to add to the uniform name. + * Returns a new Plane defined by the three passed points. */ - updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void; + static FromPoints(point1: any, point2: any, point3: any): Plane; /** - * Wrapper for updateUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {Matrix} A 4x4 matrix. + * Returns a new Plane the normal vector to this plane at the passed origin point. + * Note : the vector "normal" is updated because normalized. */ - updateMatrix: (name: string, mat: Matrix) => void; + static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane; /** - * Wrapper for updateUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {Vector3} vector + * Returns the signed distance between the plane defined by the normal vector at the "origin"" point and the passed other point. */ - updateVector3: (name: string, vector: Vector3) => void; + static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number; + } + class Viewport { + x: number; + y: number; + width: number; + height: number; /** - * Wrapper for updateUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {Vector4} vector + * Creates a Viewport object located at (x, y) and sized (width, height). */ - updateVector4: (name: string, vector: Vector4) => void; + constructor(x: number, y: number, width: number, height: number); + toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport; /** - * Wrapper for updateUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {Color3} color - * @param {string} [suffix] Suffix to add to the uniform name. + * Returns a new Viewport copied from the current one. */ - updateColor3: (name: string, color: Color3, suffix?: string) => void; + clone(): Viewport; + } + class Frustum { /** - * Wrapper for updateUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {Color3} color - * @param {number} alpha - * @param {string} [suffix] Suffix to add to the uniform name. + * Returns a new array of 6 Frustum planes computed by the passed transformation matrix. */ - updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void; + static GetPlanes(transform: Matrix): Plane[]; /** - * Uniform buffer objects. - * - * Handles blocks of uniform on the GPU. - * - * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls. - * - * For more information, please refer to : - * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object + * Sets the passed array "frustumPlanes" with the 6 Frustum planes computed by the passed transformation matrix. */ - constructor(engine: Engine, data?: number[], dynamic?: boolean); + static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void; + } + enum Space { + LOCAL = 0, + WORLD = 1, + BONE = 2, + } + class Axis { + static X: Vector3; + static Y: Vector3; + static Z: Vector3; + } + class BezierCurve { /** - * Indicates if the buffer is using the WebGL2 UBO implementation, - * or just falling back on setUniformXXX calls. + * Returns the cubic Bezier interpolated value (float) at "t" (float) from the passed x1, y1, x2, y2 floats. */ - readonly useUbo: boolean; + static interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number; + } + enum Orientation { + CW = 0, + CCW = 1, + } + class Angle { + private _radians; /** - * Indicates if the WebGL underlying uniform buffer is in sync - * with the javascript cache data. + * Creates an Angle object of "radians" radians (float). */ - readonly isSync: boolean; + constructor(radians: number); /** - * Indicates if the WebGL underlying uniform buffer is dynamic. - * Also, a dynamic UniformBuffer will disable cache verification and always - * update the underlying WebGL uniform buffer to the GPU. + * Returns the Angle value in degrees (float). */ - isDynamic(): boolean; + degrees: () => number; /** - * The data cache on JS side. + * Returns the Angle value in radians (float). */ - getData(): Float32Array; + radians: () => number; /** - * The underlying WebGL Uniform buffer. + * Returns a new Angle object valued with the angle value in radians between the two passed vectors. */ - getBuffer(): WebGLBuffer; + static BetweenTwoPoints(a: Vector2, b: Vector2): Angle; /** - * std140 layout specifies how to align data within an UBO structure. - * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159 - * for specs. + * Returns a new Angle object from the passed float in radians. */ - private _fillAlignment(size); + static FromRadians(radians: number): Angle; /** - * Adds an uniform in the buffer. - * Warning : the subsequents calls of this function must be in the same order as declared in the shader - * for the layout to be correct ! - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {number|number[]} size Data size, or data directly. + * Returns a new Angle object from the passed float in degrees. */ - addUniform(name: string, size: number | number[]): void; + static FromDegrees(degrees: number): Angle; + } + class Arc2 { + startPoint: Vector2; + midPoint: Vector2; + endPoint: Vector2; + centerPoint: Vector2; + radius: number; + angle: Angle; + startAngle: Angle; + orientation: Orientation; /** - * Wrapper for addUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {Matrix} mat A 4x4 matrix. + * Creates an Arc object from the three passed points : start, middle and end. */ - addMatrix(name: string, mat: Matrix): void; + constructor(startPoint: Vector2, midPoint: Vector2, endPoint: Vector2); + } + class Path2 { + private _points; + private _length; + closed: boolean; /** - * Wrapper for addUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {number} x - * @param {number} y + * Creates a Path2 object from the starting 2D coordinates x and y. */ - addFloat2(name: string, x: number, y: number): void; + constructor(x: number, y: number); /** - * Wrapper for addUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {number} x - * @param {number} y - * @param {number} z + * Adds a new segment until the passed coordinates (x, y) to the current Path2. + * Returns the updated Path2. */ - addFloat3(name: string, x: number, y: number, z: number): void; + addLineTo(x: number, y: number): Path2; /** - * Wrapper for addUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {Color3} color + * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2. + * Returns the updated Path2. */ - addColor3(name: string, color: Color3): void; + addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2; /** - * Wrapper for addUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {Color3} color - * @param {number} alpha + * Closes the Path2. + * Returns the Path2. + */ + close(): Path2; + /** + * Returns the Path2 total length (float). + */ + length(): number; + /** + * Returns the Path2 internal array of points. + */ + getPoints(): Vector2[]; + /** + * Returns a new Vector2 located at a percentage of the Path2 total length on this path. + */ + getPointAtLengthPosition(normalizedLengthPosition: number): Vector2; + /** + * Returns a new Path2 starting at the coordinates (x, y). + */ + static StartingAt(x: number, y: number): Path2; + } + class Path3D { + path: Vector3[]; + private _curve; + private _distances; + private _tangents; + private _normals; + private _binormals; + private _raw; + /** + * new Path3D(path, normal, raw) + * Creates a Path3D. A Path3D is a logical math object, so not a mesh. + * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D + * path : an array of Vector3, the curve axis of the Path3D + * normal (optional) : Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal. + * raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed. + */ + constructor(path: Vector3[], firstNormal?: Vector3, raw?: boolean); + /** + * Returns the Path3D array of successive Vector3 designing its curve. + */ + getCurve(): Vector3[]; + /** + * Returns an array populated with tangent vectors on each Path3D curve point. + */ + getTangents(): Vector3[]; + /** + * Returns an array populated with normal vectors on each Path3D curve point. + */ + getNormals(): Vector3[]; + /** + * Returns an array populated with binormal vectors on each Path3D curve point. */ - addColor4(name: string, color: Color3, alpha: number): void; + getBinormals(): Vector3[]; /** - * Wrapper for addUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {Vector3} vector + * Returns an array populated with distances (float) of the i-th point from the first curve point. */ - addVector3(name: string, vector: Vector3): void; + getDistances(): number[]; /** - * Wrapper for addUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * Forces the Path3D tangent, normal, binormal and distance recomputation. + * Returns the same object updated. */ - addMatrix3x3(name: string): void; + update(path: Vector3[], firstNormal?: Vector3): Path3D; + private _compute(firstNormal); + private _getFirstNonNullVector(index); + private _getLastNonNullVector(index); + private _normalVector(v0, vt, va); + } + class Curve3 { + private _points; + private _length; /** - * Wrapper for addUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve + * @param v0 (Vector3) the origin point of the Quadratic Bezier + * @param v1 (Vector3) the control point + * @param v2 (Vector3) the end point of the Quadratic Bezier + * @param nbPoints (integer) the wanted number of points in the curve */ - addMatrix2x2(name: string): void; + static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3; /** - * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`. + * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve + * @param v0 (Vector3) the origin point of the Cubic Bezier + * @param v1 (Vector3) the first control point + * @param v2 (Vector3) the second control point + * @param v3 (Vector3) the end point of the Cubic Bezier + * @param nbPoints (integer) the wanted number of points in the curve */ - create(): void; + static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3; /** - * Updates the WebGL Uniform Buffer on the GPU. - * If the `dynamic` flag is set to true, no cache comparison is done. - * Otherwise, the buffer will be updated only if the cache differs. + * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline + * @param p1 (Vector3) the origin point of the Hermite Spline + * @param t1 (Vector3) the tangent vector at the origin point + * @param p2 (Vector3) the end point of the Hermite Spline + * @param t2 (Vector3) the tangent vector at the end point + * @param nbPoints (integer) the wanted number of points in the curve */ - update(): void; + static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3; /** - * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU. - * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader. - * @param {number[]|Float32Array} data Flattened data - * @param {number} size Size of the data. + * Returns a Curve3 object along a CatmullRom Spline curve : + * @param points (array of Vector3) the points the spline must pass through. At least, four points required. + * @param nbPoints (integer) the wanted number of points between each curve control points. */ - updateUniform(uniformName: string, data: number[] | Float32Array, size: number): void; - private _updateMatrix3x3ForUniform(name, matrix); - private _updateMatrix3x3ForEffect(name, matrix); - private _updateMatrix2x2ForEffect(name, matrix); - private _updateMatrix2x2ForUniform(name, matrix); - private _updateFloatForEffect(name, x); - private _updateFloatForUniform(name, x); - private _updateFloat2ForEffect(name, x, y, suffix?); - private _updateFloat2ForUniform(name, x, y, suffix?); - private _updateFloat3ForEffect(name, x, y, z, suffix?); - private _updateFloat3ForUniform(name, x, y, z, suffix?); - private _updateFloat4ForEffect(name, x, y, z, w, suffix?); - private _updateFloat4ForUniform(name, x, y, z, w, suffix?); - private _updateMatrixForEffect(name, mat); - private _updateMatrixForUniform(name, mat); - private _updateVector3ForEffect(name, vector); - private _updateVector3ForUniform(name, vector); - private _updateVector4ForEffect(name, vector); - private _updateVector4ForUniform(name, vector); - private _updateColor3ForEffect(name, color, suffix?); - private _updateColor3ForUniform(name, color, suffix?); - private _updateColor4ForEffect(name, color, alpha, suffix?); - private _updateColor4ForUniform(name, color, alpha, suffix?); + static CreateCatmullRomSpline(points: Vector3[], nbPoints: number): Curve3; /** - * Sets a sampler uniform on the effect. - * @param {string} name Name of the sampler. - * @param {Texture} texture + * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space. + * A Curve3 is designed from a series of successive Vector3. + * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object */ - setTexture(name: string, texture: BaseTexture): void; + constructor(points: Vector3[]); /** - * Directly updates the value of the uniform in the cache AND on the GPU. - * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader. - * @param {number[]|Float32Array} data Flattened data + * Returns the Curve3 stored array of successive Vector3 */ - updateUniformDirectly(uniformName: string, data: number[] | Float32Array): void; + getPoints(): Vector3[]; /** - * Binds this uniform buffer to an effect. - * @param {Effect} effect - * @param {string} name Name of the uniform block in the shader. + * Returns the computed length (float) of the curve. */ - bindToEffect(effect: Effect, name: string): void; + length(): number; /** - * Disposes the uniform buffer. + * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB); + * This new Curve3 is built by translating and sticking the curveB at the end of the curveA. + * curveA and curveB keep unchanged. */ - dispose(): void; + continue(curve: Curve3): Curve3; + private _computeLength(path); + } + class PositionNormalVertex { + position: Vector3; + normal: Vector3; + constructor(position?: Vector3, normal?: Vector3); + clone(): PositionNormalVertex; + } + class PositionNormalTextureVertex { + position: Vector3; + normal: Vector3; + uv: Vector2; + constructor(position?: Vector3, normal?: Vector3, uv?: Vector2); + clone(): PositionNormalTextureVertex; + } + class Tmp { + static Color3: Color3[]; + static Vector2: Vector2[]; + static Vector3: Vector3[]; + static Vector4: Vector4[]; + static Quaternion: Quaternion[]; + static Matrix: Matrix[]; + } +} + +declare module BABYLON { + class SphericalPolynomial { + x: Vector3; + y: Vector3; + z: Vector3; + xx: Vector3; + yy: Vector3; + zz: Vector3; + xy: Vector3; + yz: Vector3; + zx: Vector3; + addAmbient(color: Color3): void; + static getSphericalPolynomialFromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial; + scale(scale: number): void; + } + class SphericalHarmonics { + L00: Vector3; + L1_1: Vector3; + L10: Vector3; + L11: Vector3; + L2_2: Vector3; + L2_1: Vector3; + L20: Vector3; + L21: Vector3; + L22: Vector3; + addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void; + scale(scale: number): void; + convertIncidentRadianceToIrradiance(): void; + convertIrradianceToLambertianRadiance(): void; + static getsphericalHarmonicsFromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics; } } @@ -12145,96 +12145,32 @@ declare module BABYLON { dispose(): void; private static _PositionKind; private static _NormalKind; - private static _TangentKind; - private static _UVKind; - private static _UV2Kind; - private static _UV3Kind; - private static _UV4Kind; - private static _UV5Kind; - private static _UV6Kind; - private static _ColorKind; - private static _MatricesIndicesKind; - private static _MatricesWeightsKind; - private static _MatricesIndicesExtraKind; - private static _MatricesWeightsExtraKind; - static readonly PositionKind: string; - static readonly NormalKind: string; - static readonly TangentKind: string; - static readonly UVKind: string; - static readonly UV2Kind: string; - static readonly UV3Kind: string; - static readonly UV4Kind: string; - static readonly UV5Kind: string; - static readonly UV6Kind: string; - static readonly ColorKind: string; - static readonly MatricesIndicesKind: string; - static readonly MatricesWeightsKind: string; - static readonly MatricesIndicesExtraKind: string; - static readonly MatricesWeightsExtraKind: string; - } -} - -declare module BABYLON { - class MorphTarget { - name: string; - animations: Animation[]; - private _positions; - private _normals; - private _tangents; - private _influence; - onInfluenceChanged: Observable; - influence: number; - constructor(name: string, influence?: number); - readonly hasNormals: boolean; - readonly hasTangents: boolean; - setPositions(data: Float32Array | number[]): void; - getPositions(): Float32Array; - setNormals(data: Float32Array | number[]): void; - getNormals(): Float32Array; - setTangents(data: Float32Array | number[]): void; - getTangents(): Float32Array; - /** - * Serializes the current target into a Serialization object. - * Returns the serialized object. - */ - serialize(): any; - static Parse(serializationObject: any): MorphTarget; - static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget; - } -} - -declare module BABYLON { - class MorphTargetManager { - private _targets; - private _targetObservable; - private _activeTargets; - private _scene; - private _influences; - private _supportsNormals; - private _supportsTangents; - private _vertexCount; - private _uniqueId; - private _tempInfluences; - constructor(scene?: Scene); - readonly uniqueId: number; - readonly vertexCount: number; - readonly supportsNormals: boolean; - readonly supportsTangents: boolean; - readonly numTargets: number; - readonly numInfluencers: number; - readonly influences: Float32Array; - getActiveTarget(index: number): MorphTarget; - getTarget(index: number): MorphTarget; - addTarget(target: MorphTarget): void; - removeTarget(target: MorphTarget): void; - /** - * Serializes the current manager into a Serialization object. - * Returns the serialized object. - */ - serialize(): any; - private _onInfluenceChanged(needUpdate); - private _syncActiveTargets(needUpdate); - static Parse(serializationObject: any, scene: Scene): MorphTargetManager; + private static _TangentKind; + private static _UVKind; + private static _UV2Kind; + private static _UV3Kind; + private static _UV4Kind; + private static _UV5Kind; + private static _UV6Kind; + private static _ColorKind; + private static _MatricesIndicesKind; + private static _MatricesWeightsKind; + private static _MatricesIndicesExtraKind; + private static _MatricesWeightsExtraKind; + static readonly PositionKind: string; + static readonly NormalKind: string; + static readonly TangentKind: string; + static readonly UVKind: string; + static readonly UV2Kind: string; + static readonly UV3Kind: string; + static readonly UV4Kind: string; + static readonly UV5Kind: string; + static readonly UV6Kind: string; + static readonly ColorKind: string; + static readonly MatricesIndicesKind: string; + static readonly MatricesWeightsKind: string; + static readonly MatricesIndicesExtraKind: string; + static readonly MatricesWeightsExtraKind: string; } } @@ -12730,6 +12666,70 @@ declare module BABYLON { } } +declare module BABYLON { + class MorphTarget { + name: string; + animations: Animation[]; + private _positions; + private _normals; + private _tangents; + private _influence; + onInfluenceChanged: Observable; + influence: number; + constructor(name: string, influence?: number); + readonly hasNormals: boolean; + readonly hasTangents: boolean; + setPositions(data: Float32Array | number[]): void; + getPositions(): Float32Array; + setNormals(data: Float32Array | number[]): void; + getNormals(): Float32Array; + setTangents(data: Float32Array | number[]): void; + getTangents(): Float32Array; + /** + * Serializes the current target into a Serialization object. + * Returns the serialized object. + */ + serialize(): any; + static Parse(serializationObject: any): MorphTarget; + static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget; + } +} + +declare module BABYLON { + class MorphTargetManager { + private _targets; + private _targetObservable; + private _activeTargets; + private _scene; + private _influences; + private _supportsNormals; + private _supportsTangents; + private _vertexCount; + private _uniqueId; + private _tempInfluences; + constructor(scene?: Scene); + readonly uniqueId: number; + readonly vertexCount: number; + readonly supportsNormals: boolean; + readonly supportsTangents: boolean; + readonly numTargets: number; + readonly numInfluencers: number; + readonly influences: Float32Array; + getActiveTarget(index: number): MorphTarget; + getTarget(index: number): MorphTarget; + addTarget(target: MorphTarget): void; + removeTarget(target: MorphTarget): void; + /** + * Serializes the current manager into a Serialization object. + * Returns the serialized object. + */ + serialize(): any; + private _onInfluenceChanged(needUpdate); + private _syncActiveTargets(needUpdate); + static Parse(serializationObject: any, scene: Scene): MorphTargetManager; + } +} + declare module BABYLON { interface PhysicsImpostorJoint { mainImpostor: PhysicsImpostor; @@ -12889,540 +12889,272 @@ declare module BABYLON { * Gets the body that holds this impostor. Either its own, or its parent. */ /** - * Set the physics body. Used mainly by the physics engine/plugin - */ - physicsBody: any; - parent: PhysicsImpostor; - resetUpdateFlags(): void; - getObjectExtendSize(): Vector3; - getObjectCenter(): Vector3; - /** - * Get a specific parametes from the options parameter. - */ - getParam(paramName: string): any; - /** - * Sets a specific parameter in the options given to the physics plugin - */ - setParam(paramName: string, value: number): void; - /** - * Specifically change the body's mass option. Won't recreate the physics body object - */ - setMass(mass: number): void; - getLinearVelocity(): Vector3; - setLinearVelocity(velocity: Vector3): void; - getAngularVelocity(): Vector3; - setAngularVelocity(velocity: Vector3): void; - /** - * Execute a function with the physics plugin native code. - * Provide a function the will have two variables - the world object and the physics body object. - */ - executeNativeFunction(func: (world: any, physicsBody: any) => void): void; - /** - * Register a function that will be executed before the physics world is stepping forward. - */ - registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void; - unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void; - /** - * Register a function that will be executed after the physics step - */ - registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void; - unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void; - /** - * register a function that will be executed when this impostor collides against a different body. - */ - registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void; - unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array) => void): void; - private _tmpPositionWithDelta; - private _tmpRotationWithDelta; - /** - * this function is executed by the physics engine. - */ - beforeStep: () => void; - /** - * this function is executed by the physics engine. - */ - afterStep: () => void; - /** - * Legacy collision detection event support - */ - onCollideEvent: (collider: BABYLON.PhysicsImpostor, collidedWith: BABYLON.PhysicsImpostor) => void; - onCollide: (e: { - body: any; - }) => void; - /** - * Apply a force - */ - applyForce(force: Vector3, contactPoint: Vector3): void; - /** - * Apply an impulse - */ - applyImpulse(force: Vector3, contactPoint: Vector3): void; - /** - * A help function to create a joint. - */ - createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): void; - /** - * Add a joint to this impostor with a different impostor. - */ - addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): void; - /** - * Will keep this body still, in a sleep mode. - */ - sleep(): void; - /** - * Wake the body up. - */ - wakeUp(): void; - clone(newObject: IPhysicsEnabledObject): PhysicsImpostor; - dispose(): void; - setDeltaPosition(position: Vector3): void; - setDeltaRotation(rotation: Quaternion): void; - getBoxSizeToRef(result: Vector3): void; - getRadius(): number; - /** - * Sync a bone with this impostor - * @param bone The bone to sync to the impostor. - * @param boneMesh The mesh that the bone is influencing. - * @param jointPivot The pivot of the joint / bone in local space. - * @param distToJoint Optional distance from the impostor to the joint. - * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone. - */ - syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void; - /** - * Sync impostor to a bone - * @param bone The bone that the impostor will be synced to. - * @param boneMesh The mesh that the bone is influencing. - * @param jointPivot The pivot of the joint / bone in local space. - * @param distToJoint Optional distance from the impostor to the joint. - * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone. - * @param boneAxis Optional vector3 axis the bone is aligned with - */ - syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void; - static NoImpostor: number; - static SphereImpostor: number; - static BoxImpostor: number; - static PlaneImpostor: number; - static MeshImpostor: number; - static CylinderImpostor: number; - static ParticleImpostor: number; - static HeightmapImpostor: number; - } -} - -declare module BABYLON { - interface PhysicsJointData { - mainPivot?: Vector3; - connectedPivot?: Vector3; - mainAxis?: Vector3; - connectedAxis?: Vector3; - collision?: boolean; - nativeParams?: any; - } - /** - * This is a holder class for the physics joint created by the physics plugin. - * It holds a set of functions to control the underlying joint. - */ - class PhysicsJoint { - type: number; - jointData: PhysicsJointData; - private _physicsJoint; - protected _physicsPlugin: IPhysicsEnginePlugin; - constructor(type: number, jointData: PhysicsJointData); - physicsJoint: any; - physicsPlugin: IPhysicsEnginePlugin; - /** - * Execute a function that is physics-plugin specific. - * @param {Function} func the function that will be executed. - * It accepts two parameters: the physics world and the physics joint. - */ - executeNativeFunction(func: (world: any, physicsJoint: any) => void): void; - static DistanceJoint: number; - static HingeJoint: number; - static BallAndSocketJoint: number; - static WheelJoint: number; - static SliderJoint: number; - static PrismaticJoint: number; - static UniversalJoint: number; - static Hinge2Joint: number; - static PointToPointJoint: number; - static SpringJoint: number; - static LockJoint: number; - } - /** - * A class representing a physics distance joint. - */ - class DistanceJoint extends PhysicsJoint { - constructor(jointData: DistanceJointData); - /** - * Update the predefined distance. + * Set the physics body. Used mainly by the physics engine/plugin */ - updateDistance(maxDistance: number, minDistance?: number): void; - } - class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint { - constructor(type: number, jointData: PhysicsJointData); + physicsBody: any; + parent: PhysicsImpostor; + resetUpdateFlags(): void; + getObjectExtendSize(): Vector3; + getObjectCenter(): Vector3; /** - * Set the motor values. - * Attention, this function is plugin specific. Engines won't react 100% the same. - * @param {number} force the force to apply - * @param {number} maxForce max force for this motor. + * Get a specific parametes from the options parameter. */ - setMotor(force?: number, maxForce?: number): void; + getParam(paramName: string): any; /** - * Set the motor's limits. - * Attention, this function is plugin specific. Engines won't react 100% the same. + * Sets a specific parameter in the options given to the physics plugin */ - setLimit(upperLimit: number, lowerLimit?: number): void; - } - /** - * This class represents a single hinge physics joint - */ - class HingeJoint extends MotorEnabledJoint { - constructor(jointData: PhysicsJointData); + setParam(paramName: string, value: number): void; /** - * Set the motor values. - * Attention, this function is plugin specific. Engines won't react 100% the same. - * @param {number} force the force to apply - * @param {number} maxForce max force for this motor. + * Specifically change the body's mass option. Won't recreate the physics body object */ - setMotor(force?: number, maxForce?: number): void; + setMass(mass: number): void; + getLinearVelocity(): Vector3; + setLinearVelocity(velocity: Vector3): void; + getAngularVelocity(): Vector3; + setAngularVelocity(velocity: Vector3): void; /** - * Set the motor's limits. - * Attention, this function is plugin specific. Engines won't react 100% the same. + * Execute a function with the physics plugin native code. + * Provide a function the will have two variables - the world object and the physics body object. */ - setLimit(upperLimit: number, lowerLimit?: number): void; - } - /** - * This class represents a dual hinge physics joint (same as wheel joint) - */ - class Hinge2Joint extends MotorEnabledJoint { - constructor(jointData: PhysicsJointData); + executeNativeFunction(func: (world: any, physicsBody: any) => void): void; /** - * Set the motor values. - * Attention, this function is plugin specific. Engines won't react 100% the same. - * @param {number} force the force to apply - * @param {number} maxForce max force for this motor. - * @param {motorIndex} the motor's index, 0 or 1. + * Register a function that will be executed before the physics world is stepping forward. */ - setMotor(force?: number, maxForce?: number, motorIndex?: number): void; + registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void; + unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void; /** - * Set the motor limits. - * Attention, this function is plugin specific. Engines won't react 100% the same. - * @param {number} upperLimit the upper limit - * @param {number} lowerLimit lower limit - * @param {motorIndex} the motor's index, 0 or 1. + * Register a function that will be executed after the physics step */ - setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void; - } - interface IMotorEnabledJoint { - physicsJoint: any; - setMotor(force?: number, maxForce?: number, motorIndex?: number): any; - setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): any; - } - interface DistanceJointData extends PhysicsJointData { - maxDistance: number; - } - interface SpringJointData extends PhysicsJointData { - length: number; - stiffness: number; - damping: number; - } -} - -declare module BABYLON { - class ReflectionProbe { - name: string; - private _scene; - private _renderTargetTexture; - private _projectionMatrix; - private _viewMatrix; - private _target; - private _add; - private _attachedMesh; - invertYAxis: boolean; - position: Vector3; - constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean); - samples: number; - refreshRate: number; - getScene(): Scene; - readonly cubeTexture: RenderTargetTexture; - readonly renderList: AbstractMesh[]; - attachToMesh(mesh: AbstractMesh): void; + registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void; + unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): 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. + * register a function that will be executed when this impostor collides against a different body. */ - setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void; - dispose(): void; - } -} - -declare module BABYLON { - class BoundingBoxRenderer { - frontColor: Color3; - backColor: Color3; - showBackLines: boolean; - renderList: SmartArray; - private _scene; - private _colorShader; - private _vertexBuffers; - private _indexBuffer; - constructor(scene: Scene); - private _prepareRessources(); - reset(): void; - render(): void; - dispose(): void; - } -} - -declare module BABYLON { - class DepthRenderer { - private _scene; - private _depthMap; - private _effect; - private _viewMatrix; - private _projectionMatrix; - private _transformMatrix; - private _worldViewProjection; - private _cachedDefines; - constructor(scene: Scene, type?: number); - isReady(subMesh: SubMesh, useInstances: boolean): boolean; - getDepthMap(): RenderTargetTexture; - dispose(): void; - } -} - -declare module BABYLON { - class EdgesRenderer { - edgesWidthScalerForOrthographic: number; - edgesWidthScalerForPerspective: number; - private _source; - private _linesPositions; - private _linesNormals; - private _linesIndices; - private _epsilon; - private _indicesCount; - private _lineShader; - private _ib; - private _buffers; - private _checkVerticesInsteadOfIndices; - constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean); - private _prepareRessources(); - dispose(): void; - private _processEdgeForAdjacencies(pa, pb, p0, p1, p2); - private _processEdgeForAdjacenciesWithVertices(pa, pb, p0, p1, p2); - private _checkEdge(faceIndex, edge, faceNormals, p0, p1); - _generateEdgesLines(): void; - render(): void; - } -} - -declare module BABYLON { - class GeometryBufferRenderer { - private _scene; - private _multiRenderTarget; - private _effect; - private _ratio; - private _viewMatrix; - private _projectionMatrix; - private _transformMatrix; - private _worldViewProjection; - private _cachedDefines; - private _enablePosition; - renderList: Mesh[]; - readonly isSupported: boolean; - enablePosition: boolean; - constructor(scene: Scene, ratio?: number); - isReady(subMesh: SubMesh, useInstances: boolean): boolean; - getGBuffer(): MultiRenderTarget; - dispose(): void; - private _createRenderTargets(); - } -} - -declare module BABYLON { - class OutlineRenderer { - private _scene; - private _effect; - private _cachedDefines; - zOffset: number; - constructor(scene: Scene); - render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void; - isReady(subMesh: SubMesh, useInstances: boolean): boolean; - } -} - -declare module BABYLON { - class RenderingGroup { - index: number; - private _scene; - private _opaqueSubMeshes; - private _transparentSubMeshes; - private _alphaTestSubMeshes; - private _particleSystems; - private _spriteManagers; - private _activeVertices; - private _opaqueSortCompareFn; - private _alphaTestSortCompareFn; - private _transparentSortCompareFn; - private _renderOpaque; - private _renderAlphaTest; - private _renderTransparent; - private _edgesRenderers; - onBeforeTransparentRendering: () => void; + registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void; + unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array) => void): void; + private _tmpPositionWithDelta; + private _tmpRotationWithDelta; /** - * Set the opaque sort comparison function. - * If null the sub meshes will be render in the order they were created + * this function is executed by the physics engine. */ - opaqueSortCompareFn: (a: SubMesh, b: SubMesh) => number; + beforeStep: () => void; /** - * Set the alpha test sort comparison function. - * If null the sub meshes will be render in the order they were created + * this function is executed by the physics engine. */ - alphaTestSortCompareFn: (a: SubMesh, b: SubMesh) => number; + afterStep: () => void; /** - * Set the transparent sort comparison function. - * If null the sub meshes will be render in the order they were created + * Legacy collision detection event support */ - transparentSortCompareFn: (a: SubMesh, b: SubMesh) => number; + onCollideEvent: (collider: BABYLON.PhysicsImpostor, collidedWith: BABYLON.PhysicsImpostor) => void; + onCollide: (e: { + body: any; + }) => void; /** - * Creates a new rendering group. - * @param index The rendering group index - * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied - * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied - * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied + * Apply a force */ - constructor(index: number, scene: Scene, opaqueSortCompareFn?: (a: SubMesh, b: SubMesh) => number, alphaTestSortCompareFn?: (a: SubMesh, b: SubMesh) => number, transparentSortCompareFn?: (a: SubMesh, b: SubMesh) => number); + applyForce(force: Vector3, contactPoint: Vector3): void; /** - * Render all the sub meshes contained in the group. - * @param customRenderFunction Used to override the default render behaviour of the group. - * @returns true if rendered some submeshes. + * Apply an impulse */ - render(customRenderFunction: (opaqueSubMeshes: SmartArray, transparentSubMeshes: SmartArray, alphaTestSubMeshes: SmartArray) => void, renderSprites: boolean, renderParticles: boolean, activeMeshes: AbstractMesh[]): void; + applyImpulse(force: Vector3, contactPoint: Vector3): void; /** - * Renders the opaque submeshes in the order from the opaqueSortCompareFn. - * @param subMeshes The submeshes to render + * A help function to create a joint. */ - private renderOpaqueSorted(subMeshes); + createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): void; /** - * Renders the opaque submeshes in the order from the alphatestSortCompareFn. - * @param subMeshes The submeshes to render + * Add a joint to this impostor with a different impostor. */ - private renderAlphaTestSorted(subMeshes); + addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): void; /** - * Renders the opaque submeshes in the order from the transparentSortCompareFn. - * @param subMeshes The submeshes to render + * Will keep this body still, in a sleep mode. */ - private renderTransparentSorted(subMeshes); + sleep(): void; /** - * Renders the submeshes in a specified order. - * @param subMeshes The submeshes to sort before render - * @param sortCompareFn The comparison function use to sort - * @param cameraPosition The camera position use to preprocess the submeshes to help sorting - * @param transparent Specifies to activate blending if true + * Wake the body up. */ - private static renderSorted(subMeshes, sortCompareFn, cameraPosition, transparent); + wakeUp(): void; + clone(newObject: IPhysicsEnabledObject): PhysicsImpostor; + dispose(): void; + setDeltaPosition(position: Vector3): void; + setDeltaRotation(rotation: Quaternion): void; + getBoxSizeToRef(result: Vector3): void; + getRadius(): number; /** - * Renders the submeshes in the order they were dispatched (no sort applied). - * @param subMeshes The submeshes to render + * Sync a bone with this impostor + * @param bone The bone to sync to the impostor. + * @param boneMesh The mesh that the bone is influencing. + * @param jointPivot The pivot of the joint / bone in local space. + * @param distToJoint Optional distance from the impostor to the joint. + * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone. */ - private static renderUnsorted(subMeshes); + syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void; /** - * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent) - * are rendered back to front if in the same alpha index. - * - * @param a The first submesh - * @param b The second submesh - * @returns The result of the comparison + * Sync impostor to a bone + * @param bone The bone that the impostor will be synced to. + * @param boneMesh The mesh that the bone is influencing. + * @param jointPivot The pivot of the joint / bone in local space. + * @param distToJoint Optional distance from the impostor to the joint. + * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone. + * @param boneAxis Optional vector3 axis the bone is aligned with */ - static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number; + syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void; + static NoImpostor: number; + static SphereImpostor: number; + static BoxImpostor: number; + static PlaneImpostor: number; + static MeshImpostor: number; + static CylinderImpostor: number; + static ParticleImpostor: number; + static HeightmapImpostor: number; + } +} + +declare module BABYLON { + interface PhysicsJointData { + mainPivot?: Vector3; + connectedPivot?: Vector3; + mainAxis?: Vector3; + connectedAxis?: Vector3; + collision?: boolean; + nativeParams?: any; + } + /** + * This is a holder class for the physics joint created by the physics plugin. + * It holds a set of functions to control the underlying joint. + */ + class PhysicsJoint { + type: number; + jointData: PhysicsJointData; + private _physicsJoint; + protected _physicsPlugin: IPhysicsEnginePlugin; + constructor(type: number, jointData: PhysicsJointData); + physicsJoint: any; + physicsPlugin: IPhysicsEnginePlugin; /** - * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent) - * are rendered back to front. - * - * @param a The first submesh - * @param b The second submesh - * @returns The result of the comparison + * Execute a function that is physics-plugin specific. + * @param {Function} func the function that will be executed. + * It accepts two parameters: the physics world and the physics joint. */ - static backToFrontSortCompare(a: SubMesh, b: SubMesh): number; + executeNativeFunction(func: (world: any, physicsJoint: any) => void): void; + static DistanceJoint: number; + static HingeJoint: number; + static BallAndSocketJoint: number; + static WheelJoint: number; + static SliderJoint: number; + static PrismaticJoint: number; + static UniversalJoint: number; + static Hinge2Joint: number; + static PointToPointJoint: number; + static SpringJoint: number; + static LockJoint: number; + } + /** + * A class representing a physics distance joint. + */ + class DistanceJoint extends PhysicsJoint { + constructor(jointData: DistanceJointData); /** - * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent) - * are rendered front to back (prevent overdraw). - * - * @param a The first submesh - * @param b The second submesh - * @returns The result of the comparison + * Update the predefined distance. */ - static frontToBackSortCompare(a: SubMesh, b: SubMesh): number; + updateDistance(maxDistance: number, minDistance?: number): void; + } + class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint { + constructor(type: number, jointData: PhysicsJointData); /** - * Resets the different lists of submeshes to prepare a new frame. + * Set the motor values. + * Attention, this function is plugin specific. Engines won't react 100% the same. + * @param {number} force the force to apply + * @param {number} maxForce max force for this motor. */ - prepare(): void; - dispose(): void; + setMotor(force?: number, maxForce?: number): void; /** - * Inserts the submesh in its correct queue depending on its material. - * @param subMesh The submesh to dispatch + * Set the motor's limits. + * Attention, this function is plugin specific. Engines won't react 100% the same. */ - dispatch(subMesh: SubMesh): void; - dispatchSprites(spriteManager: SpriteManager): void; - dispatchParticles(particleSystem: IParticleSystem): void; - private _renderParticles(activeMeshes); - private _renderSprites(); + setLimit(upperLimit: number, lowerLimit?: number): void; } -} - -declare module BABYLON { - class RenderingManager { + /** + * This class represents a single hinge physics joint + */ + class HingeJoint extends MotorEnabledJoint { + constructor(jointData: PhysicsJointData); /** - * The max id used for rendering groups (not included) + * Set the motor values. + * Attention, this function is plugin specific. Engines won't react 100% the same. + * @param {number} force the force to apply + * @param {number} maxForce max force for this motor. */ - static MAX_RENDERINGGROUPS: number; + setMotor(force?: number, maxForce?: number): void; /** - * The min id used for rendering groups (included) + * Set the motor's limits. + * Attention, this function is plugin specific. Engines won't react 100% the same. */ - static MIN_RENDERINGGROUPS: number; + setLimit(upperLimit: number, lowerLimit?: number): void; + } + /** + * This class represents a dual hinge physics joint (same as wheel joint) + */ + class Hinge2Joint extends MotorEnabledJoint { + constructor(jointData: PhysicsJointData); /** - * Used to globally prevent autoclearing scenes. + * Set the motor values. + * Attention, this function is plugin specific. Engines won't react 100% the same. + * @param {number} force the force to apply + * @param {number} maxForce max force for this motor. + * @param {motorIndex} the motor's index, 0 or 1. */ - static AUTOCLEAR: boolean; - private _scene; - private _renderingGroups; - private _depthStencilBufferAlreadyCleaned; - private _currentIndex; - private _autoClearDepthStencil; - private _customOpaqueSortCompareFn; - private _customAlphaTestSortCompareFn; - private _customTransparentSortCompareFn; - private _renderinGroupInfo; - constructor(scene: Scene); - private _clearDepthStencilBuffer(depth?, stencil?); - render(customRenderFunction: (opaqueSubMeshes: SmartArray, transparentSubMeshes: SmartArray, alphaTestSubMeshes: SmartArray) => void, activeMeshes: AbstractMesh[], renderParticles: boolean, renderSprites: boolean): void; - reset(): void; - dispose(): void; - private _prepareRenderingGroup(renderingGroupId); - dispatchSprites(spriteManager: SpriteManager): void; - dispatchParticles(particleSystem: IParticleSystem): void; - dispatch(subMesh: SubMesh): void; + setMotor(force?: number, maxForce?: number, motorIndex?: number): void; /** - * 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. + * Set the motor limits. + * Attention, this function is plugin specific. Engines won't react 100% the same. + * @param {number} upperLimit the upper limit + * @param {number} lowerLimit lower limit + * @param {motorIndex} the motor's index, 0 or 1. */ - setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: (a: SubMesh, b: SubMesh) => number, alphaTestSortCompareFn?: (a: SubMesh, b: SubMesh) => number, transparentSortCompareFn?: (a: SubMesh, b: SubMesh) => number): void; + setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void; + } + interface IMotorEnabledJoint { + physicsJoint: any; + setMotor(force?: number, maxForce?: number, motorIndex?: number): any; + setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): any; + } + interface DistanceJointData extends PhysicsJointData { + maxDistance: number; + } + interface SpringJointData extends PhysicsJointData { + length: number; + stiffness: number; + damping: number; + } +} + +declare module BABYLON { + class ReflectionProbe { + name: string; + private _scene; + private _renderTargetTexture; + private _projectionMatrix; + private _viewMatrix; + private _target; + private _add; + private _attachedMesh; + invertYAxis: boolean; + position: Vector3; + constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean); + samples: number; + refreshRate: number; + getScene(): Scene; + readonly cubeTexture: RenderTargetTexture; + readonly renderList: AbstractMesh[]; + attachToMesh(mesh: AbstractMesh): 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; + setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void; + dispose(): void; } } @@ -13671,3104 +13403,2740 @@ declare module BABYLON { * Gets wether the input of the processing is in Gamma or Linear Space. */ /** - * Sets wether the input of the processing is in Gamma or Linear Space. - */ - fromLinearSpace: boolean; - /** - * Defines cache preventing GC. - */ - private _defines; - constructor(name: string, options: number | PostProcessOptions, camera?: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number); - getClassName(): string; - protected _updateParameters(): void; - dispose(camera?: Camera): void; - } -} - -declare module BABYLON { - class PassPostProcess extends PostProcess { - constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number); - } -} - -declare module BABYLON { - type PostProcessOptions = { - width: number; - height: number; - }; - class PostProcess { - name: string; - width: number; - height: number; - renderTargetSamplingMode: number; - clearColor: Color4; - autoClear: boolean; - alphaMode: number; - alphaConstants: Color4; - enablePixelPerfectMode: boolean; - scaleMode: number; - alwaysForcePOT: boolean; - samples: number; - private _camera; - private _scene; - private _engine; - private _options; - private _reusable; - private _textureType; - _textures: SmartArray; - _currentRenderTextureInd: number; - private _effect; - private _samplers; - private _fragmentUrl; - private _vertexUrl; - private _parameters; - private _scaleRatio; - protected _indexParameters: any; - private _shareOutputWithPostProcess; - private _texelSize; - private _forcedOutputTexture; - /** - * An event triggered when the postprocess is activated. - * @type {BABYLON.Observable} - */ - onActivateObservable: Observable; - private _onActivateObserver; - onActivate: (camera: Camera) => void; - /** - * An event triggered when the postprocess changes its size. - * @type {BABYLON.Observable} - */ - onSizeChangedObservable: Observable; - private _onSizeChangedObserver; - onSizeChanged: (postProcess: PostProcess) => void; - /** - * An event triggered when the postprocess applies its effect. - * @type {BABYLON.Observable} - */ - onApplyObservable: Observable; - private _onApplyObserver; - onApply: (effect: Effect) => void; - /** - * An event triggered before rendering the postprocess - * @type {BABYLON.Observable} - */ - onBeforeRenderObservable: Observable; - private _onBeforeRenderObserver; - onBeforeRender: (effect: Effect) => void; - /** - * An event triggered after rendering the postprocess - * @type {BABYLON.Observable} - */ - onAfterRenderObservable: Observable; - private _onAfterRenderObserver; - onAfterRender: (efect: Effect) => void; - outputTexture: WebGLTexture; - getCamera(): Camera; - readonly texelSize: Vector2; - constructor(name: string, fragmentUrl: string, parameters: string[], samplers: string[], options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: string, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean); - getEngine(): Engine; - getEffect(): Effect; - shareOutputWith(postProcess: PostProcess): PostProcess; - updateEffect(defines?: string, uniforms?: string[], samplers?: string[], indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void; - isReusable(): boolean; - /** invalidate frameBuffer to hint the postprocess to create a depth buffer */ - markTextureDirty(): void; - activate(camera: Camera, sourceTexture?: WebGLTexture, forceDepthStencil?: boolean): void; - readonly isSupported: boolean; - readonly aspectRatio: number; - apply(): Effect; - private _disposeTextures(); - dispose(camera?: Camera): void; - } -} - -declare module BABYLON { - class PostProcessManager { - private _scene; - private _indexBuffer; - private _vertexBuffers; - constructor(scene: Scene); - private _prepareBuffers(); - _prepareFrame(sourceTexture?: WebGLTexture, postProcesses?: PostProcess[]): boolean; - directRender(postProcesses: PostProcess[], targetTexture?: WebGLTexture): void; - _finalizeFrame(doNotPresent?: boolean, targetTexture?: WebGLTexture, faceIndex?: number, postProcesses?: PostProcess[]): void; - dispose(): void; - } -} - -declare module BABYLON { - class RefractionPostProcess extends PostProcess { - color: Color3; - depth: number; - colorLevel: number; - private _refRexture; - constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean); - dispose(camera: Camera): void; - } -} - -declare module BABYLON { - class StereoscopicInterlacePostProcess extends PostProcess { - private _stepSize; - private _passedProcess; - constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean); - } -} - -declare module BABYLON { - enum TonemappingOperator { - Hable = 0, - Reinhard = 1, - HejiDawson = 2, - Photographic = 3, - } - class TonemapPostProcess extends PostProcess { - private _operator; - exposureAdjustment: number; - constructor(name: string, _operator: TonemappingOperator, exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number); - } -} - -declare module BABYLON { - class VolumetricLightScatteringPostProcess extends PostProcess { - private _volumetricLightScatteringPass; - private _volumetricLightScatteringRTT; - private _viewPort; - private _screenCoordinates; - private _cachedDefines; - /** - * If not undefined, the mesh position is computed from the attached node position - * @type {{position: Vector3}} - */ - attachedNode: { - position: Vector3; - }; - /** - * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true" - * @type {Vector3} - */ - customMeshPosition: Vector3; - /** - * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false) - * @type {boolean} - */ - useCustomMeshPosition: boolean; - /** - * If the post-process should inverse the light scattering direction - * @type {boolean} - */ - invert: boolean; - /** - * The internal mesh used by the post-process - * @type {boolean} - */ - mesh: Mesh; - useDiffuseColor: boolean; - /** - * Array containing the excluded meshes not rendered in the internal pass - */ - excludedMeshes: AbstractMesh[]; - /** - * Controls the overall intensity of the post-process - * @type {number} - */ - exposure: number; - /** - * Dissipates each sample's contribution in range [0, 1] - * @type {number} - */ - decay: number; - /** - * Controls the overall intensity of each sample - * @type {number} - */ - weight: number; - /** - * Controls the density of each sample - * @type {number} - */ - density: number; - /** - * @constructor - * @param {string} name - The post-process name - * @param {any} ratio - The size of the post-process and/or internal pass (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5) - * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to - * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering - * @param {number} samples - The post-process quality, default 100 - * @param {number} samplingMode - The post-process filtering mode - * @param {BABYLON.Engine} engine - The babylon engine - * @param {boolean} reusable - If the post-process is reusable - * @param {BABYLON.Scene} scene - The constructor needs a scene reference to initialize internal components. If "camera" is null (RenderPipelineà, "scene" must be provided - */ - constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene); - getClassName(): string; - isReady(subMesh: SubMesh, useInstances: boolean): boolean; - /** - * Sets the new light position for light scattering effect - * @param {BABYLON.Vector3} The new custom light position - */ - setCustomMeshPosition(position: Vector3): void; - /** - * Returns the light position for light scattering effect - * @return {BABYLON.Vector3} The custom light position - */ - getCustomMeshPosition(): Vector3; - /** - * Disposes the internal assets and detaches the post-process from the camera - */ - dispose(camera: Camera): void; - /** - * Returns the render target texture used by the post-process - * @return {BABYLON.RenderTargetTexture} The render target texture used by the post-process - */ - getPass(): RenderTargetTexture; - private _meshExcluded(mesh); - private _createPass(scene, ratio); - private _updateMeshScreenCoordinates(scene); + * Sets wether the input of the processing is in Gamma or Linear Space. + */ + fromLinearSpace: boolean; /** - * Creates a default mesh for the Volumeric Light Scattering post-process - * @param {string} The mesh name - * @param {BABYLON.Scene} The scene where to create the mesh - * @return {BABYLON.Mesh} the default mesh - */ - static CreateDefaultMesh(name: string, scene: Scene): Mesh; + * Defines cache preventing GC. + */ + private _defines; + constructor(name: string, options: number | PostProcessOptions, camera?: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number); + getClassName(): string; + protected _updateParameters(): void; + dispose(camera?: Camera): void; } } declare module BABYLON { - class VRDistortionCorrectionPostProcess extends PostProcess { - aspectRatio: number; - private _isRightEye; - private _distortionFactors; - private _postProcessScaleFactor; - private _lensCenterOffset; - private _scaleIn; - private _scaleFactor; - private _lensCenter; - constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics); + class PassPostProcess extends PostProcess { + constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number); } } declare module BABYLON { - class Sprite { - name: string; - position: Vector3; - color: Color4; + type PostProcessOptions = { width: number; height: number; - angle: number; - cellIndex: number; - invertU: number; - invertV: number; - disposeWhenFinishedAnimating: boolean; - animations: Animation[]; - isPickable: boolean; - actionManager: ActionManager; - private _animationStarted; - private _loopAnimation; - private _fromIndex; - private _toIndex; - private _delay; - private _direction; - private _frameCount; - private _manager; - private _time; - private _onAnimationEnd; - size: number; - constructor(name: string, manager: SpriteManager); - playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void; - stopAnimation(): void; - _animate(deltaTime: number): void; - dispose(): void; - } -} - -declare module BABYLON { - class SpriteManager { + }; + class PostProcess { name: string; - sprites: Sprite[]; - renderingGroupId: number; - layerMask: number; - fogEnabled: boolean; - isPickable: boolean; - cellWidth: number; - cellHeight: number; + width: number; + height: number; + renderTargetSamplingMode: number; + clearColor: Color4; + autoClear: boolean; + alphaMode: number; + alphaConstants: Color4; + enablePixelPerfectMode: boolean; + scaleMode: number; + alwaysForcePOT: boolean; + samples: number; + private _camera; + private _scene; + private _engine; + private _options; + private _reusable; + private _textureType; + _textures: SmartArray; + _currentRenderTextureInd: number; + private _effect; + private _samplers; + private _fragmentUrl; + private _vertexUrl; + private _parameters; + private _scaleRatio; + protected _indexParameters: any; + private _shareOutputWithPostProcess; + private _texelSize; + private _forcedOutputTexture; /** - * An event triggered when the manager is disposed. + * An event triggered when the postprocess is activated. * @type {BABYLON.Observable} */ - onDisposeObservable: Observable; - private _onDisposeObserver; - onDispose: () => void; - private _capacity; - private _spriteTexture; - private _epsilon; - private _scene; - private _vertexData; - private _buffer; - private _vertexBuffers; - private _indexBuffer; - private _effectBase; - private _effectFog; - texture: Texture; - constructor(name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number); - private _appendSpriteVertex(index, sprite, offsetX, offsetY, rowSize); - intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): PickingInfo; - render(): void; - dispose(): void; - } -} - -declare module BABYLON.Internals { - class _AlphaState { - private _isAlphaBlendDirty; - private _isBlendFunctionParametersDirty; - private _isBlendEquationParametersDirty; - private _isBlendConstantsDirty; - private _alphaBlend; - private _blendFunctionParameters; - private _blendEquationParameters; - private _blendConstants; + onActivateObservable: Observable; + private _onActivateObserver; + onActivate: (camera: Camera) => void; /** - * Initializes the state. - */ - constructor(); - readonly isDirty: boolean; - alphaBlend: boolean; - setAlphaBlendConstants(r: number, g: number, b: number, a: number): void; - setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void; - setAlphaEquationParameters(rgb: number, alpha: any): void; - reset(): void; - apply(gl: WebGLRenderingContext): void; - } -} - -declare module BABYLON.Internals { - class _DepthCullingState { - private _isDepthTestDirty; - private _isDepthMaskDirty; - private _isDepthFuncDirty; - private _isCullFaceDirty; - private _isCullDirty; - private _isZOffsetDirty; - private _depthTest; - private _depthMask; - private _depthFunc; - private _cull; - private _cullFace; - private _zOffset; + * An event triggered when the postprocess changes its size. + * @type {BABYLON.Observable} + */ + onSizeChangedObservable: Observable; + private _onSizeChangedObserver; + onSizeChanged: (postProcess: PostProcess) => void; /** - * Initializes the state. - */ - constructor(); - readonly isDirty: boolean; - zOffset: number; - cullFace: number; - cull: boolean; - depthFunc: number; - depthMask: boolean; - depthTest: boolean; - reset(): void; - apply(gl: WebGLRenderingContext): void; + * An event triggered when the postprocess applies its effect. + * @type {BABYLON.Observable} + */ + onApplyObservable: Observable; + private _onApplyObserver; + onApply: (effect: Effect) => void; + /** + * An event triggered before rendering the postprocess + * @type {BABYLON.Observable} + */ + onBeforeRenderObservable: Observable; + private _onBeforeRenderObserver; + onBeforeRender: (effect: Effect) => void; + /** + * An event triggered after rendering the postprocess + * @type {BABYLON.Observable} + */ + onAfterRenderObservable: Observable; + private _onAfterRenderObserver; + onAfterRender: (efect: Effect) => void; + outputTexture: WebGLTexture; + getCamera(): Camera; + readonly texelSize: Vector2; + constructor(name: string, fragmentUrl: string, parameters: string[], samplers: string[], options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: string, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean); + getEngine(): Engine; + getEffect(): Effect; + shareOutputWith(postProcess: PostProcess): PostProcess; + updateEffect(defines?: string, uniforms?: string[], samplers?: string[], indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void; + isReusable(): boolean; + /** invalidate frameBuffer to hint the postprocess to create a depth buffer */ + markTextureDirty(): void; + activate(camera: Camera, sourceTexture?: WebGLTexture, forceDepthStencil?: boolean): void; + readonly isSupported: boolean; + readonly aspectRatio: number; + apply(): Effect; + private _disposeTextures(); + dispose(camera?: Camera): void; } } -declare module BABYLON.Internals { - class _StencilState { - private _isStencilTestDirty; - private _isStencilMaskDirty; - private _isStencilFuncDirty; - private _isStencilOpDirty; - private _stencilTest; - private _stencilMask; - private _stencilFunc; - private _stencilFuncRef; - private _stencilFuncMask; - private _stencilOpStencilFail; - private _stencilOpDepthFail; - private _stencilOpStencilDepthPass; - readonly isDirty: boolean; - stencilFunc: number; - stencilFuncRef: number; - stencilFuncMask: number; - stencilOpStencilFail: number; - stencilOpDepthFail: number; - stencilOpStencilDepthPass: number; - stencilMask: number; - stencilTest: boolean; - constructor(); - reset(): void; - apply(gl: WebGLRenderingContext): void; +declare module BABYLON { + class PostProcessManager { + private _scene; + private _indexBuffer; + private _vertexBuffers; + constructor(scene: Scene); + private _prepareBuffers(); + _prepareFrame(sourceTexture?: WebGLTexture, postProcesses?: PostProcess[]): boolean; + directRender(postProcesses: PostProcess[], targetTexture?: WebGLTexture): void; + _finalizeFrame(doNotPresent?: boolean, targetTexture?: WebGLTexture, faceIndex?: number, postProcesses?: PostProcess[]): void; + dispose(): void; } } -declare module BABYLON.Internals { - class AndOrNotEvaluator { - static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean; - private static _HandleParenthesisContent(parenthesisContent, evaluateCallback); - private static _SimplifyNegation(booleanString); +declare module BABYLON { + class RefractionPostProcess extends PostProcess { + color: Color3; + depth: number; + colorLevel: number; + private _refRexture; + constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean); + dispose(camera: Camera): void; } } declare module BABYLON { - interface IAssetTask { - onSuccess: (task: IAssetTask) => void; - onError: (task: IAssetTask) => void; - isCompleted: boolean; - run(scene: Scene, onSuccess: () => void, onError: () => void): any; - } - class MeshAssetTask implements IAssetTask { - name: string; - meshesNames: any; - rootUrl: string; - sceneFilename: string; - loadedMeshes: Array; - loadedParticleSystems: Array; - loadedSkeletons: Array; - onSuccess: (task: IAssetTask) => void; - onError: (task: IAssetTask) => void; - isCompleted: boolean; - constructor(name: string, meshesNames: any, rootUrl: string, sceneFilename: string); - run(scene: Scene, onSuccess: () => void, onError: () => void): void; - } - class TextFileAssetTask implements IAssetTask { - name: string; - url: string; - onSuccess: (task: IAssetTask) => void; - onError: (task: IAssetTask) => void; - isCompleted: boolean; - text: string; - constructor(name: string, url: string); - run(scene: Scene, onSuccess: () => void, onError: () => void): void; - } - class BinaryFileAssetTask implements IAssetTask { - name: string; - url: string; - onSuccess: (task: IAssetTask) => void; - onError: (task: IAssetTask) => void; - isCompleted: boolean; - data: ArrayBuffer; - constructor(name: string, url: string); - run(scene: Scene, onSuccess: () => void, onError: () => void): void; - } - class ImageAssetTask implements IAssetTask { - name: string; - url: string; - onSuccess: (task: IAssetTask) => void; - onError: (task: IAssetTask) => void; - isCompleted: boolean; - image: HTMLImageElement; - constructor(name: string, url: string); - run(scene: Scene, onSuccess: () => void, onError: () => void): void; + class StereoscopicInterlacePostProcess extends PostProcess { + private _stepSize; + private _passedProcess; + constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean); } - interface ITextureAssetTask extends IAssetTask { - onSuccess: (task: ITextureAssetTask) => void; - onError: (task: ITextureAssetTask) => void; - texture: Texture; +} + +declare module BABYLON { + enum TonemappingOperator { + Hable = 0, + Reinhard = 1, + HejiDawson = 2, + Photographic = 3, } - class TextureAssetTask implements ITextureAssetTask { - name: string; - url: string; - noMipmap: boolean; - invertY: boolean; - samplingMode: number; - onSuccess: (task: ITextureAssetTask) => void; - onError: (task: ITextureAssetTask) => void; - isCompleted: boolean; - texture: Texture; - constructor(name: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number); - run(scene: Scene, onSuccess: () => void, onError: () => void): void; + class TonemapPostProcess extends PostProcess { + private _operator; + exposureAdjustment: number; + constructor(name: string, _operator: TonemappingOperator, exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number); } - class CubeTextureAssetTask implements IAssetTask { - name: string; - url: string; - extensions: string[]; - noMipmap: boolean; - files: string[]; - onSuccess: (task: IAssetTask) => void; - onError: (task: IAssetTask) => void; - isCompleted: boolean; - texture: CubeTexture; - constructor(name: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]); - run(scene: Scene, onSuccess: () => void, onError: () => void): void; +} + +declare module BABYLON { + class VolumetricLightScatteringPostProcess extends PostProcess { + private _volumetricLightScatteringPass; + private _volumetricLightScatteringRTT; + private _viewPort; + private _screenCoordinates; + private _cachedDefines; + /** + * If not undefined, the mesh position is computed from the attached node position + * @type {{position: Vector3}} + */ + attachedNode: { + position: Vector3; + }; + /** + * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true" + * @type {Vector3} + */ + customMeshPosition: Vector3; + /** + * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false) + * @type {boolean} + */ + useCustomMeshPosition: boolean; + /** + * If the post-process should inverse the light scattering direction + * @type {boolean} + */ + invert: boolean; + /** + * The internal mesh used by the post-process + * @type {boolean} + */ + mesh: Mesh; + useDiffuseColor: boolean; + /** + * Array containing the excluded meshes not rendered in the internal pass + */ + excludedMeshes: AbstractMesh[]; + /** + * Controls the overall intensity of the post-process + * @type {number} + */ + exposure: number; + /** + * Dissipates each sample's contribution in range [0, 1] + * @type {number} + */ + decay: number; + /** + * Controls the overall intensity of each sample + * @type {number} + */ + weight: number; + /** + * Controls the density of each sample + * @type {number} + */ + density: number; + /** + * @constructor + * @param {string} name - The post-process name + * @param {any} ratio - The size of the post-process and/or internal pass (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5) + * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to + * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering + * @param {number} samples - The post-process quality, default 100 + * @param {number} samplingMode - The post-process filtering mode + * @param {BABYLON.Engine} engine - The babylon engine + * @param {boolean} reusable - If the post-process is reusable + * @param {BABYLON.Scene} scene - The constructor needs a scene reference to initialize internal components. If "camera" is null (RenderPipelineà, "scene" must be provided + */ + constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene); + getClassName(): string; + isReady(subMesh: SubMesh, useInstances: boolean): boolean; + /** + * Sets the new light position for light scattering effect + * @param {BABYLON.Vector3} The new custom light position + */ + setCustomMeshPosition(position: Vector3): void; + /** + * Returns the light position for light scattering effect + * @return {BABYLON.Vector3} The custom light position + */ + getCustomMeshPosition(): Vector3; + /** + * Disposes the internal assets and detaches the post-process from the camera + */ + dispose(camera: Camera): void; + /** + * Returns the render target texture used by the post-process + * @return {BABYLON.RenderTargetTexture} The render target texture used by the post-process + */ + getPass(): RenderTargetTexture; + private _meshExcluded(mesh); + private _createPass(scene, ratio); + private _updateMeshScreenCoordinates(scene); + /** + * Creates a default mesh for the Volumeric Light Scattering post-process + * @param {string} The mesh name + * @param {BABYLON.Scene} The scene where to create the mesh + * @return {BABYLON.Mesh} the default mesh + */ + static CreateDefaultMesh(name: string, scene: Scene): Mesh; } - class HDRCubeTextureAssetTask implements IAssetTask { - name: string; - url: string; - size: number; - noMipmap: boolean; - generateHarmonics: boolean; - useInGammaSpace: boolean; - usePMREMGenerator: boolean; - onSuccess: (task: IAssetTask) => void; - onError: (task: IAssetTask) => void; - isCompleted: boolean; - texture: HDRCubeTexture; - constructor(name: string, url: string, size?: number, noMipmap?: boolean, generateHarmonics?: boolean, useInGammaSpace?: boolean, usePMREMGenerator?: boolean); - run(scene: Scene, onSuccess: () => void, onError: () => void): void; +} + +declare module BABYLON { + class VRDistortionCorrectionPostProcess extends PostProcess { + aspectRatio: number; + private _isRightEye; + private _distortionFactors; + private _postProcessScaleFactor; + private _lensCenterOffset; + private _scaleIn; + private _scaleFactor; + private _lensCenter; + constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics); } - class AssetsManager { +} + +declare module BABYLON { + class BoundingBoxRenderer { + frontColor: Color3; + backColor: Color3; + showBackLines: boolean; + renderList: SmartArray; private _scene; - protected tasks: IAssetTask[]; - protected waitingTasksCount: number; - onFinish: (tasks: IAssetTask[]) => void; - onTaskSuccess: (task: IAssetTask) => void; - onTaskError: (task: IAssetTask) => void; - useDefaultLoadingScreen: boolean; + private _colorShader; + private _vertexBuffers; + private _indexBuffer; constructor(scene: Scene); - addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): IAssetTask; - addTextFileTask(taskName: string, url: string): IAssetTask; - addBinaryFileTask(taskName: string, url: string): IAssetTask; - addImageTask(taskName: string, url: string): IAssetTask; - addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): ITextureAssetTask; - addCubeTextureTask(name: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): IAssetTask; - addHDRCubeTextureTask(name: string, url: string, size?: number, noMipmap?: boolean, generateHarmonics?: boolean, useInGammaSpace?: boolean, usePMREMGenerator?: boolean): IAssetTask; - private _decreaseWaitingTasksCount(); - private _runTask(task); - reset(): AssetsManager; - load(): AssetsManager; + private _prepareRessources(); + reset(): void; + render(): void; + dispose(): void; } } declare module BABYLON { - class Database { - private callbackManifestChecked; - private currentSceneUrl; - private db; - private enableSceneOffline; - private enableTexturesOffline; - private manifestVersionFound; - private mustUpdateRessources; - private hasReachedQuota; - private isSupported; - private idbFactory; - static IsUASupportingBlobStorage: boolean; - static IDBStorageEnabled: boolean; - constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any); - static parseURL: (url: string) => string; - static ReturnFullUrlLocation: (url: string) => string; - checkManifestFile(): void; - openAsync(successCallback: any, errorCallback: any): void; - loadImageFromDB(url: string, image: HTMLImageElement): void; - private _loadImageFromDBAsync(url, image, notInDBCallback); - private _saveImageIntoDBAsync(url, image); - private _checkVersionFromDB(url, versionLoaded); - private _loadVersionFromDBAsync(url, callback, updateInDBCallback); - private _saveVersionIntoDBAsync(url, callback); - private loadFileFromDB(url, sceneLoaded, progressCallBack, errorCallback, useArrayBuffer?); - private _loadFileFromDBAsync(url, callback, notInDBCallback, useArrayBuffer?); - private _saveFileIntoDBAsync(url, callback, progressCallback, useArrayBuffer?); + class DepthRenderer { + private _scene; + private _depthMap; + private _effect; + private _viewMatrix; + private _projectionMatrix; + private _transformMatrix; + private _worldViewProjection; + private _cachedDefines; + constructor(scene: Scene, type?: number); + isReady(subMesh: SubMesh, useInstances: boolean): boolean; + getDepthMap(): RenderTargetTexture; + dispose(): void; } } -declare module BABYLON.Internals { - interface DDSInfo { - width: number; - height: number; - mipmapCount: number; - isFourCC: boolean; - isRGB: boolean; - isLuminance: boolean; - isCube: boolean; - isCompressed: boolean; - dxgiFormat: number; - textureType: number; - } - class DDSTools { - static StoreLODInAlphaChannel: boolean; - static GetDDSInfo(arrayBuffer: any): DDSInfo; - private static _FloatView; - private static _Int32View; - private static _ToHalfFloat(value); - private static _FromHalfFloat(value); - private static _GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod); - private static _GetHalfFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod); - private static _GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod); - private static _GetFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod); - private static _GetHalfFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod); - private static _GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer); - private static _GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer); - private static _GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer); - static UploadDDSLevels(engine: Engine, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number): void; +declare module BABYLON { + class EdgesRenderer { + edgesWidthScalerForOrthographic: number; + edgesWidthScalerForPerspective: number; + private _source; + private _linesPositions; + private _linesNormals; + private _linesIndices; + private _epsilon; + private _indicesCount; + private _lineShader; + private _ib; + private _buffers; + private _checkVerticesInsteadOfIndices; + constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean); + private _prepareRessources(); + dispose(): void; + private _processEdgeForAdjacencies(pa, pb, p0, p1, p2); + private _processEdgeForAdjacenciesWithVertices(pa, pb, p0, p1, p2); + private _checkEdge(faceIndex, edge, faceNormals, p0, p1); + _generateEdgesLines(): void; + render(): void; } } declare module BABYLON { - function expandToProperty(callback: string, targetKey?: string): (target: any, propertyKey: string) => void; - function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void; - function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void; - function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void; - function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void; - function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void; - function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void; - function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void; - function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void; - function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void; - function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void; - class SerializationHelper { - static Serialize(entity: T, serializationObject?: any): any; - static Parse(creationFunction: () => T, source: any, scene: Scene, rootUrl?: string): T; - static Clone(creationFunction: () => T, source: T): T; - static Instanciate(creationFunction: () => T, source: T): T; + class GeometryBufferRenderer { + private _scene; + private _multiRenderTarget; + private _effect; + private _ratio; + private _viewMatrix; + private _projectionMatrix; + private _transformMatrix; + private _worldViewProjection; + private _cachedDefines; + private _enablePosition; + renderList: Mesh[]; + readonly isSupported: boolean; + enablePosition: boolean; + constructor(scene: Scene, ratio?: number); + isReady(subMesh: SubMesh, useInstances: boolean): boolean; + getGBuffer(): MultiRenderTarget; + dispose(): void; + private _createRenderTargets(); } } declare module BABYLON { - class DynamicFloatArrayElementInfo { - offset: number; + class OutlineRenderer { + private _scene; + private _effect; + private _cachedDefines; + zOffset: number; + constructor(scene: Scene); + render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void; + isReady(subMesh: SubMesh, useInstances: boolean): boolean; } - /** - * The purpose of this class is to store float32 based elements of a given size (defined by the stride argument) in a dynamic fashion, that is, you can add/free elements. You can then access to a defragmented/packed version of the underlying Float32Array by calling the pack() method. - * The intent is to maintain through time data that will be bound to a WebGlBuffer with the ability to change add/remove elements. - * It was first built to efficiently maintain the WebGlBuffer that contain instancing based data. - * Allocating an Element will return a instance of DynamicFloatArrayElement which contains the offset into the Float32Array of where the element starts, you are then responsible to copy your data using this offset. - * Beware, calling pack() may change the offset of some Entries because this method will defragment the Float32Array to replace empty elements by moving allocated ones at their location. - * This method will return an ArrayBufferView on the existing Float32Array that describes the used elements. Use this View to update the WebGLBuffer and NOT the "buffer" field of the class. The pack() method won't shrink/reallocate the buffer to keep it GC friendly, all the empty space will be put at the end of the buffer, the method just ensure there are no "free holes". - */ - class DynamicFloatArray { +} + +declare module BABYLON { + class RenderingGroup { + index: number; + private _scene; + private _opaqueSubMeshes; + private _transparentSubMeshes; + private _alphaTestSubMeshes; + private _particleSystems; + private _spriteManagers; + private _activeVertices; + private _opaqueSortCompareFn; + private _alphaTestSortCompareFn; + private _transparentSortCompareFn; + private _renderOpaque; + private _renderAlphaTest; + private _renderTransparent; + private _edgesRenderers; + onBeforeTransparentRendering: () => void; /** - * Construct an instance of the dynamic float array - * @param stride size of one element in float (i.e. not bytes!) - * @param initialElementCount the number of available entries at construction + * Set the opaque sort comparison function. + * If null the sub meshes will be render in the order they were created */ - constructor(stride: number, initialElementCount: number); + opaqueSortCompareFn: (a: SubMesh, b: SubMesh) => number; /** - * Allocate an element in the array. - * @return the element info instance that contains the offset into the main buffer of the element's location. - * Beware, this offset may change when you call pack() + * Set the alpha test sort comparison function. + * If null the sub meshes will be render in the order they were created + */ + alphaTestSortCompareFn: (a: SubMesh, b: SubMesh) => number; + /** + * Set the transparent sort comparison function. + * If null the sub meshes will be render in the order they were created + */ + transparentSortCompareFn: (a: SubMesh, b: SubMesh) => number; + /** + * Creates a new rendering group. + * @param index The rendering group index + * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied + * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied + * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied + */ + constructor(index: number, scene: Scene, opaqueSortCompareFn?: (a: SubMesh, b: SubMesh) => number, alphaTestSortCompareFn?: (a: SubMesh, b: SubMesh) => number, transparentSortCompareFn?: (a: SubMesh, b: SubMesh) => number); + /** + * Render all the sub meshes contained in the group. + * @param customRenderFunction Used to override the default render behaviour of the group. + * @returns true if rendered some submeshes. + */ + render(customRenderFunction: (opaqueSubMeshes: SmartArray, transparentSubMeshes: SmartArray, alphaTestSubMeshes: SmartArray) => void, renderSprites: boolean, renderParticles: boolean, activeMeshes: AbstractMesh[]): void; + /** + * Renders the opaque submeshes in the order from the opaqueSortCompareFn. + * @param subMeshes The submeshes to render + */ + private renderOpaqueSorted(subMeshes); + /** + * Renders the opaque submeshes in the order from the alphatestSortCompareFn. + * @param subMeshes The submeshes to render + */ + private renderAlphaTestSorted(subMeshes); + /** + * Renders the opaque submeshes in the order from the transparentSortCompareFn. + * @param subMeshes The submeshes to render + */ + private renderTransparentSorted(subMeshes); + /** + * Renders the submeshes in a specified order. + * @param subMeshes The submeshes to sort before render + * @param sortCompareFn The comparison function use to sort + * @param cameraPosition The camera position use to preprocess the submeshes to help sorting + * @param transparent Specifies to activate blending if true + */ + private static renderSorted(subMeshes, sortCompareFn, cameraPosition, transparent); + /** + * Renders the submeshes in the order they were dispatched (no sort applied). + * @param subMeshes The submeshes to render + */ + private static renderUnsorted(subMeshes); + /** + * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent) + * are rendered back to front if in the same alpha index. + * + * @param a The first submesh + * @param b The second submesh + * @returns The result of the comparison + */ + static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number; + /** + * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent) + * are rendered back to front. + * + * @param a The first submesh + * @param b The second submesh + * @returns The result of the comparison */ - allocElement(): DynamicFloatArrayElementInfo; + static backToFrontSortCompare(a: SubMesh, b: SubMesh): number; /** - * Free the element corresponding to the given element info - * @param elInfo the element that describe the allocated element + * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent) + * are rendered front to back (prevent overdraw). + * + * @param a The first submesh + * @param b The second submesh + * @returns The result of the comparison */ - freeElement(elInfo: DynamicFloatArrayElementInfo): void; + static frontToBackSortCompare(a: SubMesh, b: SubMesh): number; /** - * This method will pack all the used elements into a linear sequence and put all the free space at the end. - * Instances of DynamicFloatArrayElement may have their 'offset' member changed as data could be copied from one location to another, so be sure to read/write your data based on the value inside this member after you called pack(). - * @return the subArray that is the view of the used elements area, you can use it as a source to update a WebGLBuffer + * Resets the different lists of submeshes to prepare a new frame. */ - pack(): Float32Array; - private _moveElement(element, destOffset); - private _growBuffer(); + prepare(): void; + dispose(): void; /** - * This is the main buffer, all elements are stored inside, you use the DynamicFloatArrayElement instance of a given element to know its location into this buffer, then you have the responsibility to perform write operations in this buffer at the right location! - * Don't use this buffer for a WebGL bufferSubData() operation, but use the one returned by the pack() method. + * Inserts the submesh in its correct queue depending on its material. + * @param subMesh The submesh to dispatch */ - buffer: Float32Array; + dispatch(subMesh: SubMesh): void; + dispatchSprites(spriteManager: SpriteManager): void; + dispatchParticles(particleSystem: IParticleSystem): void; + private _renderParticles(activeMeshes); + private _renderSprites(); + } +} + +declare module BABYLON { + class RenderingManager { /** - * Get the total count of entries that can fit in the current buffer - * @returns the elements count + * The max id used for rendering groups (not included) */ - readonly totalElementCount: number; + static MAX_RENDERINGGROUPS: number; /** - * Get the count of free entries that can still be allocated without resizing the buffer - * @returns the free elements count + * The min id used for rendering groups (included) */ - readonly freeElementCount: number; + static MIN_RENDERINGGROUPS: number; /** - * Get the count of allocated elements - * @returns the allocated elements count + * Used to globally prevent autoclearing scenes. */ - readonly usedElementCount: number; + static AUTOCLEAR: boolean; + private _scene; + private _renderingGroups; + private _depthStencilBufferAlreadyCleaned; + private _currentIndex; + private _autoClearDepthStencil; + private _customOpaqueSortCompareFn; + private _customAlphaTestSortCompareFn; + private _customTransparentSortCompareFn; + private _renderinGroupInfo; + constructor(scene: Scene); + private _clearDepthStencilBuffer(depth?, stencil?); + render(customRenderFunction: (opaqueSubMeshes: SmartArray, transparentSubMeshes: SmartArray, alphaTestSubMeshes: SmartArray) => void, activeMeshes: AbstractMesh[], renderParticles: boolean, renderSprites: boolean): void; + reset(): void; + dispose(): void; + private _prepareRenderingGroup(renderingGroupId); + dispatchSprites(spriteManager: SpriteManager): void; + dispatchParticles(particleSystem: IParticleSystem): void; + dispatch(subMesh: SubMesh): void; /** - * Return the size of one element in float - * @returns the size in float + * 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. */ - readonly stride: number; - compareValueOffset: number; - sortingAscending: boolean; - sort(): boolean; - private _allEntries; - private _freeEntries; - private _stride; - private _lastUsed; - private _firstFree; - private _sortTable; - private _sortedTable; - } -} - -declare module Earcut { - /** - * The fastest and smallest JavaScript polygon triangulation library for your WebGL apps - * @param data is a flat array of vertice coordinates like [x0, y0, x1, y1, x2, y2, ...]. - * @param holeIndices is an array of hole indices if any (e.g. [5, 8] for a 12- vertice input would mean one hole with vertices 5–7 and another with 8–11). - * @param dim is the number of coordinates per vertice in the input array (2 by default). - */ - function earcut(data: number[], holeIndices: number[], dim: number): any[]; - /** - * return a percentage difference between the polygon area and its triangulation area; - * used to verify correctness of triangulation - */ - function deviation(data: number[], holeIndices: number[], dim: number, triangles: number[]): number; - /** - * turn a polygon in a multi-dimensional array form (e.g. as in GeoJSON) into a form Earcut accepts - */ - function flatten(data: number[][][]): { - vertices: any[]; - holes: any[]; - dimensions: number; - }; -} - -declare module BABYLON { - enum PoseEnabledControllerType { - VIVE = 0, - OCULUS = 1, - WINDOWS = 2, - GENERIC = 3, - } - interface MutableGamepadButton { - value: number; - touched: boolean; - pressed: boolean; - } - class PoseEnabledControllerHelper { - static InitiateController(vrGamepad: any): OculusTouchController | ViveController | GenericController; - } - class PoseEnabledController extends Gamepad implements PoseControlled { - vrGamepad: any; - devicePosition: Vector3; - deviceRotationQuaternion: Quaternion; - deviceScaleFactor: number; - position: Vector3; - rotationQuaternion: Quaternion; - controllerType: PoseEnabledControllerType; - private _calculatedPosition; - private _calculatedRotation; - rawPose: DevicePose; - _mesh: AbstractMesh; - private _poseControlledCamera; - private _leftHandSystemQuaternion; - constructor(vrGamepad: any); - update(): void; - updateFromDevice(poseData: DevicePose): void; - attachToMesh(mesh: AbstractMesh): void; - attachToPoseControlledCamera(camera: TargetCamera): void; - detachMesh(): void; - readonly mesh: AbstractMesh; - getForwardRay(length?: number): Ray; - } - interface GamepadButtonChanges { - changed: boolean; - pressChanged: boolean; - touchChanged: boolean; - valueChanged: boolean; - } - abstract class WebVRController extends PoseEnabledController { - onTriggerStateChangedObservable: Observable; - onMainButtonStateChangedObservable: Observable; - onSecondaryButtonStateChangedObservable: Observable; - onPadStateChangedObservable: Observable; - onPadValuesChangedObservable: Observable; - protected _buttons: Array; - private _onButtonStateChange; - onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void; - pad: StickValues; - hand: string; - constructor(vrGamepad: any); - update(): void; - protected abstract handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): any; - abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): any; - private _setButtonValue(newState, currentState, buttonIndex); - private _changes; - private _checkChanges(newState, currentState); - } - class OculusTouchController extends WebVRController { - private _defaultModel; - onSecondaryTriggerStateChangedObservable: Observable; - onThumbRestChangedObservable: Observable; - constructor(vrGamepad: any); - initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void; - readonly onAButtonStateChangedObservable: Observable; - readonly onBButtonStateChangedObservable: Observable; - readonly onXButtonStateChangedObservable: Observable; - readonly onYButtonStateChangedObservable: Observable; - protected handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void; - } - class ViveController extends WebVRController { - private _defaultModel; - constructor(vrGamepad: any); - initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void; - readonly onLeftButtonStateChangedObservable: Observable; - readonly onRightButtonStateChangedObservable: Observable; - readonly onMenuButtonStateChangedObservable: Observable; + setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: (a: SubMesh, b: SubMesh) => number, alphaTestSortCompareFn?: (a: SubMesh, b: SubMesh) => number, transparentSortCompareFn?: (a: SubMesh, b: SubMesh) => number): void; /** - * Vive mapping: - * 0: touchpad - * 1: trigger - * 2: left AND right buttons - * 3: menu button + * 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. */ - protected handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void; - } - class GenericController extends WebVRController { - private _defaultModel; - constructor(vrGamepad: any); - initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void; - protected handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void; + setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void; } } -interface ExtendedGamepadButton extends GamepadButton { - readonly pressed: boolean; - readonly touched: boolean; - readonly value: number; -} declare module BABYLON { - class FilesInput { - private _engine; - private _currentScene; - private _canvas; - private _sceneLoadedCallback; - private _progressCallback; - private _additionnalRenderLoopLogicCallback; - private _textureLoadingCallback; - private _startingProcessingFilesCallback; - private _elementToMonitor; - static FilesToLoad: File[]; - private _sceneFileToLoad; - private _filesToLoad; - constructor(p_engine: Engine, p_scene: Scene, p_canvas: HTMLCanvasElement, p_sceneLoadedCallback: any, p_progressCallback: any, p_additionnalRenderLoopLogicCallback: any, p_textureLoadingCallback: any, p_startingProcessingFilesCallback: any); - monitorElementForDragNDrop(p_elementToMonitor: HTMLElement): void; - private renderFunction(); - private drag(e); - private drop(eventDrop); - private _handleFolderDrop(entry, files, callback); - private _processFiles(files); - loadFiles(event: any): void; - reload(): void; + class Sprite { + name: string; + position: Vector3; + color: Color4; + width: number; + height: number; + angle: number; + cellIndex: number; + invertU: number; + invertV: number; + disposeWhenFinishedAnimating: boolean; + animations: Animation[]; + isPickable: boolean; + actionManager: ActionManager; + private _animationStarted; + private _loopAnimation; + private _fromIndex; + private _toIndex; + private _delay; + private _direction; + private _frameCount; + private _manager; + private _time; + private _onAnimationEnd; + size: number; + constructor(name: string, manager: SpriteManager); + playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void; + stopAnimation(): void; + _animate(deltaTime: number): void; + dispose(): void; } } declare module BABYLON { - class Gamepads { - private babylonGamepads; - private oneGamepadConnected; - private isMonitoring; - private gamepadEventSupported; - private gamepadSupport; - private _callbackGamepadConnected; - private _callbackGamepadDisconnected; - private _onGamepadConnectedEvent; - private _onGamepadDisonnectedEvent; - constructor(ongamedpadconnected: (gamepad: T) => void, ongamedpaddisconnected?: (gamepad: T) => void); + class SpriteManager { + name: string; + sprites: Sprite[]; + renderingGroupId: number; + layerMask: number; + fogEnabled: boolean; + isPickable: boolean; + cellWidth: number; + cellHeight: number; + /** + * An event triggered when the manager is disposed. + * @type {BABYLON.Observable} + */ + onDisposeObservable: Observable; + private _onDisposeObserver; + onDispose: () => void; + private _capacity; + private _spriteTexture; + private _epsilon; + private _scene; + private _vertexData; + private _buffer; + private _vertexBuffers; + private _indexBuffer; + private _effectBase; + private _effectFog; + texture: Texture; + constructor(name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number); + private _appendSpriteVertex(index, sprite, offsetX, offsetY, rowSize); + intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): PickingInfo; + render(): void; dispose(): void; - private _onGamepadConnected(gamepad); - private _addNewGamepad(gamepad); - private _onGamepadDisconnected(gamepad); - private _startMonitoringGamepads(); - private _stopMonitoringGamepads(); - private _checkGamepadsStatus(); - private _updateGamepadObjects(); - } - class StickValues { - x: any; - y: any; - constructor(x: any, y: any); - } - class Gamepad { - id: string; - index: number; - browserGamepad: any; - type: number; - private _leftStick; - private _rightStick; - private _leftStickAxisX; - private _leftStickAxisY; - private _rightStickAxisX; - private _rightStickAxisY; - private _onleftstickchanged; - private _onrightstickchanged; - static GAMEPAD: number; - static GENERIC: number; - static XBOX: number; - static POSE_ENABLED: number; - constructor(id: string, index: number, browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number); - onleftstickchanged(callback: (values: StickValues) => void): void; - onrightstickchanged(callback: (values: StickValues) => void): void; - leftStick: StickValues; - rightStick: StickValues; - update(): void; - } - class GenericPad extends Gamepad { - private _buttons; - private _onbuttondown; - private _onbuttonup; - onbuttondown(callback: (buttonPressed: number) => void): void; - onbuttonup(callback: (buttonReleased: number) => void): void; - constructor(id: string, index: number, browserGamepad: any); - private _setButtonValue(newValue, currentValue, buttonIndex); - update(): void; - } - enum Xbox360Button { - A = 0, - B = 1, - X = 2, - Y = 3, - Start = 4, - Back = 5, - LB = 6, - RB = 7, - LeftStick = 8, - RightStick = 9, } - enum Xbox360Dpad { - Up = 0, - Down = 1, - Left = 2, - Right = 3, +} + +declare module BABYLON.Internals { + class _AlphaState { + private _isAlphaBlendDirty; + private _isBlendFunctionParametersDirty; + private _isBlendEquationParametersDirty; + private _isBlendConstantsDirty; + private _alphaBlend; + private _blendFunctionParameters; + private _blendEquationParameters; + private _blendConstants; + /** + * Initializes the state. + */ + constructor(); + readonly isDirty: boolean; + alphaBlend: boolean; + setAlphaBlendConstants(r: number, g: number, b: number, a: number): void; + setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void; + setAlphaEquationParameters(rgb: number, alpha: any): void; + reset(): void; + apply(gl: WebGLRenderingContext): void; } - class Xbox360Pad extends Gamepad { - private _leftTrigger; - private _rightTrigger; - private _onlefttriggerchanged; - private _onrighttriggerchanged; - private _onbuttondown; - private _onbuttonup; - private _ondpaddown; - private _ondpadup; - 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; - constructor(id: string, index: number, gamepad: any, xboxOne?: boolean); - onlefttriggerchanged(callback: (value: number) => void): void; - onrighttriggerchanged(callback: (value: number) => void): void; - leftTrigger: number; - rightTrigger: number; - onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void; - onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void; - ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void; - ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void; - private _setButtonValue(newValue, currentValue, buttonType); - private _setDPadValue(newValue, currentValue, buttonType); - buttonA: number; - buttonB: number; - buttonX: number; - buttonY: number; - buttonStart: number; - buttonBack: number; - buttonLB: number; - buttonRB: number; - buttonLeftStick: number; - buttonRightStick: number; - dPadUp: number; - dPadDown: number; - dPadLeft: number; - dPadRight: number; - update(): void; +} + +declare module BABYLON.Internals { + class _DepthCullingState { + private _isDepthTestDirty; + private _isDepthMaskDirty; + private _isDepthFuncDirty; + private _isCullFaceDirty; + private _isCullDirty; + private _isZOffsetDirty; + private _depthTest; + private _depthMask; + private _depthFunc; + private _cull; + private _cullFace; + private _zOffset; + /** + * Initializes the state. + */ + constructor(); + readonly isDirty: boolean; + zOffset: number; + cullFace: number; + cull: boolean; + depthFunc: number; + depthMask: boolean; + depthTest: boolean; + reset(): void; + apply(gl: WebGLRenderingContext): void; } } -interface Navigator { - getGamepads(func?: any): any; - webkitGetGamepads(func?: any): any; - msGetGamepads(func?: any): any; - webkitGamepads(func?: any): any; + +declare module BABYLON.Internals { + class _StencilState { + private _isStencilTestDirty; + private _isStencilMaskDirty; + private _isStencilFuncDirty; + private _isStencilOpDirty; + private _stencilTest; + private _stencilMask; + private _stencilFunc; + private _stencilFuncRef; + private _stencilFuncMask; + private _stencilOpStencilFail; + private _stencilOpDepthFail; + private _stencilOpStencilDepthPass; + readonly isDirty: boolean; + stencilFunc: number; + stencilFuncRef: number; + stencilFuncMask: number; + stencilOpStencilFail: number; + stencilOpDepthFail: number; + stencilOpStencilDepthPass: number; + stencilMask: number; + stencilTest: boolean; + constructor(); + reset(): void; + apply(gl: WebGLRenderingContext): void; + } } declare module BABYLON.Internals { - /** - * 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/ - */ - class KhronosTextureContainer { - arrayBuffer: any; - static HEADER_LEN: number; - static COMPRESSED_2D: number; - static COMPRESSED_3D: number; - static TEX_2D: number; - static TEX_3D: number; - glType: number; - glTypeSize: number; - glFormat: number; - glInternalFormat: number; - glBaseInternalFormat: number; - pixelWidth: number; - pixelHeight: number; - pixelDepth: number; - numberOfArrayElements: number; - numberOfFaces: number; - numberOfMipmapLevels: number; - bytesOfKeyValueData: number; - loadType: number; - /** - * @param {ArrayBuffer} arrayBuffer- contents of the KTX container file - * @param {number} facesExpected- should be either 1 or 6, based whether a cube texture or or - * @param {boolean} threeDExpected- provision for indicating that data should be a 3D texture, not implemented - * @param {boolean} textureArrayExpected- provision for indicating that data should be a texture array, not implemented - */ - constructor(arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean); - switchEndainness(val: number): number; - /** - * It is assumed that the texture has already been created & is currently bound - */ - uploadLevels(gl: WebGLRenderingContext, loadMipmaps: boolean): void; - private _upload2DCompressedLevels(gl, loadMipmaps); + class AndOrNotEvaluator { + static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean; + private static _HandleParenthesisContent(parenthesisContent, evaluateCallback); + private static _SimplifyNegation(booleanString); } } declare module BABYLON { - /** - * A class serves as a medium between the observable and its observers - */ - class EventState { - /** - * If the callback of a given Observer set skipNextObservers to true the following observers will be ignored - */ - constructor(mask: number, skipNextObservers?: boolean); - initalize(mask: number, skipNextObservers?: boolean): EventState; - /** - * An Observer can set this property to true to prevent subsequent observers of being notified - */ - skipNextObservers: boolean; - /** - * Get the mask value that were used to trigger the event corresponding to this EventState object - */ - mask: number; + interface IAssetTask { + onSuccess: (task: IAssetTask) => void; + onError: (task: IAssetTask) => void; + isCompleted: boolean; + run(scene: Scene, onSuccess: () => void, onError: () => void): any; } - /** - * Represent an Observer registered to a given Observable object. - */ - class Observer { - callback: (eventData: T, eventState: EventState) => void; - mask: number; - constructor(callback: (eventData: T, eventState: EventState) => void, mask: number); + class MeshAssetTask implements IAssetTask { + name: string; + meshesNames: any; + rootUrl: string; + sceneFilename: string; + loadedMeshes: Array; + loadedParticleSystems: Array; + loadedSkeletons: Array; + onSuccess: (task: IAssetTask) => void; + onError: (task: IAssetTask) => void; + isCompleted: boolean; + constructor(name: string, meshesNames: any, rootUrl: string, sceneFilename: string); + run(scene: Scene, onSuccess: () => void, onError: () => void): void; } - /** - * The Observable class is a simple implementation of the Observable pattern. - * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified. - * This enable a more fine grained execution without having to rely on multiple different Observable objects. - * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08). - * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right. - */ - class Observable { - _observers: Observer[]; - private _eventState; - constructor(); - /** - * Create a new Observer with the specified callback - * @param callback the callback that will be executed for that Observer - * @param mask the mask used to filter observers - * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present. - */ - add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean): Observer; - /** - * Remove an Observer from the Observable object - * @param observer the instance of the Observer to remove. If it doesn't belong to this Observable, false will be returned. - */ - remove(observer: Observer): boolean; - /** - * Remove a callback from the Observable object - * @param callback the callback to remove. If it doesn't belong to this Observable, false will be returned. - */ - removeCallback(callback: (eventData: T, eventState: EventState) => void): boolean; - /** - * Notify all Observers by calling their respective callback with the given data - * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute - * @param eventData - * @param mask - */ - notifyObservers(eventData: T, mask?: number): boolean; - /** - * return true is the Observable has at least one Observer registered - */ - hasObservers(): boolean; - /** - * Clear the list of observers - */ - clear(): void; - /** - * Clone the current observable - */ - clone(): Observable; - /** - * Does this observable handles observer registered with a given mask - * @param {number} trigger - the mask to be tested - * @return {boolean} whether or not one observer registered with the given mask is handeled - **/ - hasSpecificMask(mask?: number): boolean; + class TextFileAssetTask implements IAssetTask { + name: string; + url: string; + onSuccess: (task: IAssetTask) => void; + onError: (task: IAssetTask) => void; + isCompleted: boolean; + text: string; + constructor(name: string, url: string); + run(scene: Scene, onSuccess: () => void, onError: () => void): void; + } + class BinaryFileAssetTask implements IAssetTask { + name: string; + url: string; + onSuccess: (task: IAssetTask) => void; + onError: (task: IAssetTask) => void; + isCompleted: boolean; + data: ArrayBuffer; + constructor(name: string, url: string); + run(scene: Scene, onSuccess: () => void, onError: () => void): void; + } + class ImageAssetTask implements IAssetTask { + name: string; + url: string; + onSuccess: (task: IAssetTask) => void; + onError: (task: IAssetTask) => void; + isCompleted: boolean; + image: HTMLImageElement; + constructor(name: string, url: string); + run(scene: Scene, onSuccess: () => void, onError: () => void): void; + } + interface ITextureAssetTask extends IAssetTask { + onSuccess: (task: ITextureAssetTask) => void; + onError: (task: ITextureAssetTask) => void; + texture: Texture; + } + class TextureAssetTask implements ITextureAssetTask { + name: string; + url: string; + noMipmap: boolean; + invertY: boolean; + samplingMode: number; + onSuccess: (task: ITextureAssetTask) => void; + onError: (task: ITextureAssetTask) => void; + isCompleted: boolean; + texture: Texture; + constructor(name: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number); + run(scene: Scene, onSuccess: () => void, onError: () => void): void; + } + class CubeTextureAssetTask implements IAssetTask { + name: string; + url: string; + extensions: string[]; + noMipmap: boolean; + files: string[]; + onSuccess: (task: IAssetTask) => void; + onError: (task: IAssetTask) => void; + isCompleted: boolean; + texture: CubeTexture; + constructor(name: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]); + run(scene: Scene, onSuccess: () => void, onError: () => void): void; + } + class HDRCubeTextureAssetTask implements IAssetTask { + name: string; + url: string; + size: number; + noMipmap: boolean; + generateHarmonics: boolean; + useInGammaSpace: boolean; + usePMREMGenerator: boolean; + onSuccess: (task: IAssetTask) => void; + onError: (task: IAssetTask) => void; + isCompleted: boolean; + texture: HDRCubeTexture; + constructor(name: string, url: string, size?: number, noMipmap?: boolean, generateHarmonics?: boolean, useInGammaSpace?: boolean, usePMREMGenerator?: boolean); + run(scene: Scene, onSuccess: () => void, onError: () => void): void; + } + class AssetsManager { + private _scene; + protected tasks: IAssetTask[]; + protected waitingTasksCount: number; + onFinish: (tasks: IAssetTask[]) => void; + onTaskSuccess: (task: IAssetTask) => void; + onTaskError: (task: IAssetTask) => void; + useDefaultLoadingScreen: boolean; + constructor(scene: Scene); + addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): IAssetTask; + addTextFileTask(taskName: string, url: string): IAssetTask; + addBinaryFileTask(taskName: string, url: string): IAssetTask; + addImageTask(taskName: string, url: string): IAssetTask; + addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): ITextureAssetTask; + addCubeTextureTask(name: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): IAssetTask; + addHDRCubeTextureTask(name: string, url: string, size?: number, noMipmap?: boolean, generateHarmonics?: boolean, useInGammaSpace?: boolean, usePMREMGenerator?: boolean): IAssetTask; + private _decreaseWaitingTasksCount(); + private _runTask(task); + reset(): AssetsManager; + load(): AssetsManager; + } +} + +declare module BABYLON { + class Database { + private callbackManifestChecked; + private currentSceneUrl; + private db; + private enableSceneOffline; + private enableTexturesOffline; + private manifestVersionFound; + private mustUpdateRessources; + private hasReachedQuota; + private isSupported; + private idbFactory; + static IsUASupportingBlobStorage: boolean; + static IDBStorageEnabled: boolean; + constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any); + static parseURL: (url: string) => string; + static ReturnFullUrlLocation: (url: string) => string; + checkManifestFile(): void; + openAsync(successCallback: any, errorCallback: any): void; + loadImageFromDB(url: string, image: HTMLImageElement): void; + private _loadImageFromDBAsync(url, image, notInDBCallback); + private _saveImageIntoDBAsync(url, image); + private _checkVersionFromDB(url, versionLoaded); + private _loadVersionFromDBAsync(url, callback, updateInDBCallback); + private _saveVersionIntoDBAsync(url, callback); + private loadFileFromDB(url, sceneLoaded, progressCallBack, errorCallback, useArrayBuffer?); + private _loadFileFromDBAsync(url, callback, notInDBCallback, useArrayBuffer?); + private _saveFileIntoDBAsync(url, callback, progressCallback, useArrayBuffer?); } } -declare namespace BABYLON { - /** - * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window - */ - class PerformanceMonitor { - private _enabled; - private _rollingFrameTime; - private _lastFrameTimeMs; - private _lastChangeTimeMs; - /** - * constructor - * @param frameSampleSize The number of samples required to saturate the sliding window - */ - constructor(frameSampleSize?: number); - /** - * Samples current frame - * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames - */ - sampleFrame(timeMs?: number): void; - /** - * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far) - * @return Average frame time in milliseconds - */ - readonly averageFrameTime: number; - /** - * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far) - * @return Frame time variance in milliseconds squared - */ - readonly averageFrameTimeVariance: number; - /** - * Returns the frame time of the most recent frame - * @return Frame time in milliseconds - */ - readonly instantaneousFrameTime: number; - /** - * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far) - * @return Framerate in frames per second - */ - readonly averageFPS: number; - /** - * Returns the average framerate in frames per second using the most recent frame time - * @return Framerate in frames per second - */ - readonly instantaneousFPS: number; - /** - * Returns true if enough samples have been taken to completely fill the sliding window - * @return true if saturated - */ - readonly isSaturated: boolean; - /** - * Enables contributions to the sliding window sample set - */ - enable(): void; - /** - * Disables contributions to the sliding window sample set - * Samples will not be interpolated over the disabled period - */ - disable(): void; - /** - * Returns true if sampling is enabled - * @return true if enabled - */ - readonly isEnabled: boolean; - /** - * Resets performance monitor - */ - reset(): void; +declare module BABYLON.Internals { + interface DDSInfo { + width: number; + height: number; + mipmapCount: number; + isFourCC: boolean; + isRGB: boolean; + isLuminance: boolean; + isCube: boolean; + isCompressed: boolean; + dxgiFormat: number; + textureType: number; } - /** - * RollingAverage - * - * Utility to efficiently compute the rolling average and variance over a sliding window of samples - */ - class RollingAverage { - /** - * Current average - */ - average: number; - /** - * Current variance - */ - variance: number; - protected _samples: Array; - protected _sampleCount: number; - protected _pos: number; - protected _m2: number; - /** - * constructor - * @param length The number of samples required to saturate the sliding window - */ - constructor(length: number); - /** - * Adds a sample to the sample set - * @param v The sample value - */ - add(v: number): void; - /** - * Returns previously added values or null if outside of history or outside the sliding window domain - * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that - * @return Value previously recorded with add() or null if outside of range - */ - history(i: number): number; - /** - * Returns true if enough samples have been taken to completely fill the sliding window - * @return true if sample-set saturated - */ - isSaturated(): boolean; - /** - * Resets the rolling average (equivalent to 0 samples taken so far) - */ - reset(): void; - /** - * Wraps a value around the sample range boundaries - * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned. - * @return Wrapped position in sample range - */ - protected _wrapPosition(i: number): number; + class DDSTools { + static StoreLODInAlphaChannel: boolean; + static GetDDSInfo(arrayBuffer: any): DDSInfo; + private static _FloatView; + private static _Int32View; + private static _ToHalfFloat(value); + private static _FromHalfFloat(value); + private static _GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod); + private static _GetHalfFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod); + private static _GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod); + private static _GetFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod); + private static _GetHalfFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod); + private static _GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer); + private static _GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer); + private static _GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer); + static UploadDDSLevels(engine: Engine, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number): void; + } +} + +declare module BABYLON { + function expandToProperty(callback: string, targetKey?: string): (target: any, propertyKey: string) => void; + function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void; + function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void; + function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void; + function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void; + function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void; + function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void; + function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void; + function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void; + function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void; + function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void; + class SerializationHelper { + static Serialize(entity: T, serializationObject?: any): any; + static Parse(creationFunction: () => T, source: any, scene: Scene, rootUrl?: string): T; + static Clone(creationFunction: () => T, source: T): T; + static Instanciate(creationFunction: () => T, source: T): T; } } declare module BABYLON { + class DynamicFloatArrayElementInfo { + offset: number; + } /** - * This class describe a rectangle that were added to the map. - * You have access to its coordinates either in pixel or normalized (UV) - */ - class PackedRect { - constructor(root: RectPackingMap, parent: PackedRect, pos: Vector2, size: Size); - /** - * @returns the position of this node into the map - */ - readonly pos: Vector2; - /** - * @returns the size of the rectangle this node handles - */ - readonly contentSize: Size; - /** - * Retrieve the inner position (considering the margin) and stores it into the res object - * @param res must be a valid Vector2 that will contain the inner position after this call - */ - getInnerPosToRef(res: Vector2): void; - /** - * Retrieve the inner size (considering the margin) and stores it into the res object - * @param res must be a valid Size that will contain the inner size after this call - */ - getInnerSizeToRef(res: Size): void; + * The purpose of this class is to store float32 based elements of a given size (defined by the stride argument) in a dynamic fashion, that is, you can add/free elements. You can then access to a defragmented/packed version of the underlying Float32Array by calling the pack() method. + * The intent is to maintain through time data that will be bound to a WebGlBuffer with the ability to change add/remove elements. + * It was first built to efficiently maintain the WebGlBuffer that contain instancing based data. + * Allocating an Element will return a instance of DynamicFloatArrayElement which contains the offset into the Float32Array of where the element starts, you are then responsible to copy your data using this offset. + * Beware, calling pack() may change the offset of some Entries because this method will defragment the Float32Array to replace empty elements by moving allocated ones at their location. + * This method will return an ArrayBufferView on the existing Float32Array that describes the used elements. Use this View to update the WebGLBuffer and NOT the "buffer" field of the class. The pack() method won't shrink/reallocate the buffer to keep it GC friendly, all the empty space will be put at the end of the buffer, the method just ensure there are no "free holes". + */ + class DynamicFloatArray { /** - * Compute the UV of the top/left, top/right, bottom/right, bottom/left points of the rectangle this node handles into the map - * @returns And array of 4 Vector2, containing UV coordinates for the four corners of the Rectangle into the map + * Construct an instance of the dynamic float array + * @param stride size of one element in float (i.e. not bytes!) + * @param initialElementCount the number of available entries at construction */ - readonly UVs: Vector2[]; + constructor(stride: number, initialElementCount: number); /** - * You may have allocated the PackedRect using over-provisioning (you allocated more than you need in order to prevent frequent deallocations/reallocations) - * and then using only a part of the PackRect. - * This method will return the UVs for this part by given the custom size of what you really use - * @param customSize must be less/equal to the allocated size, UV will be compute from this + * Allocate an element in the array. + * @return the element info instance that contains the offset into the main buffer of the element's location. + * Beware, this offset may change when you call pack() */ - getUVsForCustomSize(customSize: Size): Vector2[]; + allocElement(): DynamicFloatArrayElementInfo; /** - * Free this rectangle from the map. - * Call this method when you no longer need the rectangle to be in the map. + * Free the element corresponding to the given element info + * @param elInfo the element that describe the allocated element */ - freeContent(): void; - protected readonly isUsed: boolean; - protected findAndSplitNode(contentSize: Size): PackedRect; - private findNode(size); - private static TpsSize; - private splitNode(contentSize); - private attemptDefrag(); - private clearNode(); - private readonly isRecursiveFree; - protected evalFreeSize(size: number): number; - protected _root: RectPackingMap; - protected _parent: PackedRect; - private _contentSize; - private _initialSize; - private _leftNode; - private _rightNode; - private _bottomNode; - private _pos; - protected _size: Size; - } - /** - * The purpose of this class is to pack several Rectangles into a big map, while trying to fit everything as optimally as possible. - * This class is typically used to build lightmaps, sprite map or to pack several little textures into a big one. - * Note that this class allows allocated Rectangles to be freed: that is the map is dynamically maintained so you can add/remove rectangle based on their life-cycle. - * In case you need a margin around the allocated rect, specify the amount in the margin argument during construction. - * In such case you will have to rely on innerPositionToRef and innerSizeToRef calls to get the proper size - */ - class RectPackingMap extends PackedRect { + freeElement(elInfo: DynamicFloatArrayElementInfo): void; /** - * Create an instance of the object with a dimension using the given size - * @param size The dimension of the rectangle that will contain all the sub ones. - * @param margin The margin (empty space) created (in pixels) around the allocated Rectangles + * This method will pack all the used elements into a linear sequence and put all the free space at the end. + * Instances of DynamicFloatArrayElement may have their 'offset' member changed as data could be copied from one location to another, so be sure to read/write your data based on the value inside this member after you called pack(). + * @return the subArray that is the view of the used elements area, you can use it as a source to update a WebGLBuffer */ - constructor(size: Size, margin?: number); + pack(): Float32Array; + private _moveElement(element, destOffset); + private _growBuffer(); /** - * Add a rectangle, finding the best location to store it into the map - * @param size the dimension of the rectangle to store - * @return the Node containing the rectangle information, or null if we couldn't find a free spot + * This is the main buffer, all elements are stored inside, you use the DynamicFloatArrayElement instance of a given element to know its location into this buffer, then you have the responsibility to perform write operations in this buffer at the right location! + * Don't use this buffer for a WebGL bufferSubData() operation, but use the one returned by the pack() method. */ - addRect(size: Size): PackedRect; + buffer: Float32Array; /** - * Return the current space free normalized between [0;1] - * @returns {} + * Get the total count of entries that can fit in the current buffer + * @returns the elements count */ - readonly freeSpace: number; - _margin: number; + readonly totalElementCount: number; + /** + * Get the count of free entries that can still be allocated without resizing the buffer + * @returns the free elements count + */ + readonly freeElementCount: number; + /** + * Get the count of allocated elements + * @returns the allocated elements count + */ + readonly usedElementCount: number; + /** + * Return the size of one element in float + * @returns the size in float + */ + readonly stride: number; + compareValueOffset: number; + sortingAscending: boolean; + sort(): boolean; + private _allEntries; + private _freeEntries; + private _stride; + private _lastUsed; + private _firstFree; + private _sortTable; + private _sortedTable; } } +declare module Earcut { + /** + * The fastest and smallest JavaScript polygon triangulation library for your WebGL apps + * @param data is a flat array of vertice coordinates like [x0, y0, x1, y1, x2, y2, ...]. + * @param holeIndices is an array of hole indices if any (e.g. [5, 8] for a 12- vertice input would mean one hole with vertices 5–7 and another with 8–11). + * @param dim is the number of coordinates per vertice in the input array (2 by default). + */ + function earcut(data: number[], holeIndices: number[], dim: number): any[]; + /** + * return a percentage difference between the polygon area and its triangulation area; + * used to verify correctness of triangulation + */ + function deviation(data: number[], holeIndices: number[], dim: number, triangles: number[]): number; + /** + * turn a polygon in a multi-dimensional array form (e.g. as in GeoJSON) into a form Earcut accepts + */ + function flatten(data: number[][][]): { + vertices: any[]; + holes: any[]; + dimensions: number; + }; +} + declare module BABYLON { - class SceneOptimization { - priority: number; - apply: (scene: Scene) => boolean; - constructor(priority?: number); + enum PoseEnabledControllerType { + VIVE = 0, + OCULUS = 1, + WINDOWS = 2, + GENERIC = 3, } - class TextureOptimization extends SceneOptimization { - priority: number; - maximumSize: number; - constructor(priority?: number, maximumSize?: number); - apply: (scene: Scene) => boolean; + interface MutableGamepadButton { + value: number; + touched: boolean; + pressed: boolean; } - class HardwareScalingOptimization extends SceneOptimization { - priority: number; - maximumScale: number; - private _currentScale; - constructor(priority?: number, maximumScale?: number); - apply: (scene: Scene) => boolean; + class PoseEnabledControllerHelper { + static InitiateController(vrGamepad: any): OculusTouchController | ViveController | GenericController; } - class ShadowsOptimization extends SceneOptimization { - apply: (scene: Scene) => boolean; + class PoseEnabledController extends Gamepad implements PoseControlled { + vrGamepad: any; + devicePosition: Vector3; + deviceRotationQuaternion: Quaternion; + deviceScaleFactor: number; + position: Vector3; + rotationQuaternion: Quaternion; + controllerType: PoseEnabledControllerType; + private _calculatedPosition; + private _calculatedRotation; + rawPose: DevicePose; + _mesh: AbstractMesh; + private _poseControlledCamera; + private _leftHandSystemQuaternion; + constructor(vrGamepad: any); + update(): void; + updateFromDevice(poseData: DevicePose): void; + attachToMesh(mesh: AbstractMesh): void; + attachToPoseControlledCamera(camera: TargetCamera): void; + detachMesh(): void; + readonly mesh: AbstractMesh; + getForwardRay(length?: number): Ray; } - class PostProcessesOptimization extends SceneOptimization { - apply: (scene: Scene) => boolean; + interface GamepadButtonChanges { + changed: boolean; + pressChanged: boolean; + touchChanged: boolean; + valueChanged: boolean; } - class LensFlaresOptimization extends SceneOptimization { - apply: (scene: Scene) => boolean; + abstract class WebVRController extends PoseEnabledController { + onTriggerStateChangedObservable: Observable; + onMainButtonStateChangedObservable: Observable; + onSecondaryButtonStateChangedObservable: Observable; + onPadStateChangedObservable: Observable; + onPadValuesChangedObservable: Observable; + protected _buttons: Array; + private _onButtonStateChange; + onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void; + pad: StickValues; + hand: string; + constructor(vrGamepad: any); + update(): void; + protected abstract handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): any; + abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): any; + private _setButtonValue(newState, currentState, buttonIndex); + private _changes; + private _checkChanges(newState, currentState); } - class ParticlesOptimization extends SceneOptimization { - apply: (scene: Scene) => boolean; + class OculusTouchController extends WebVRController { + private _defaultModel; + onSecondaryTriggerStateChangedObservable: Observable; + onThumbRestChangedObservable: Observable; + constructor(vrGamepad: any); + initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void; + readonly onAButtonStateChangedObservable: Observable; + readonly onBButtonStateChangedObservable: Observable; + readonly onXButtonStateChangedObservable: Observable; + readonly onYButtonStateChangedObservable: Observable; + protected handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void; } - class RenderTargetsOptimization extends SceneOptimization { - apply: (scene: Scene) => boolean; + class ViveController extends WebVRController { + private _defaultModel; + constructor(vrGamepad: any); + initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void; + readonly onLeftButtonStateChangedObservable: Observable; + readonly onRightButtonStateChangedObservable: Observable; + readonly onMenuButtonStateChangedObservable: Observable; + /** + * Vive mapping: + * 0: touchpad + * 1: trigger + * 2: left AND right buttons + * 3: menu button + */ + protected handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void; + } + class GenericController extends WebVRController { + private _defaultModel; + constructor(vrGamepad: any); + initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void; + protected handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void; + } +} +interface ExtendedGamepadButton extends GamepadButton { + readonly pressed: boolean; + readonly touched: boolean; + readonly value: number; +} + +declare module BABYLON { + class FilesInput { + private _engine; + private _currentScene; + private _canvas; + private _sceneLoadedCallback; + private _progressCallback; + private _additionnalRenderLoopLogicCallback; + private _textureLoadingCallback; + private _startingProcessingFilesCallback; + private _elementToMonitor; + static FilesToLoad: File[]; + private _sceneFileToLoad; + private _filesToLoad; + constructor(p_engine: Engine, p_scene: Scene, p_canvas: HTMLCanvasElement, p_sceneLoadedCallback: any, p_progressCallback: any, p_additionnalRenderLoopLogicCallback: any, p_textureLoadingCallback: any, p_startingProcessingFilesCallback: any); + monitorElementForDragNDrop(p_elementToMonitor: HTMLElement): void; + private renderFunction(); + private drag(e); + private drop(eventDrop); + private _handleFolderDrop(entry, files, callback); + private _processFiles(files); + loadFiles(event: any): void; + reload(): void; + } +} + +declare module BABYLON { + class Gamepads { + private babylonGamepads; + private oneGamepadConnected; + private isMonitoring; + private gamepadEventSupported; + private gamepadSupport; + private _callbackGamepadConnected; + private _callbackGamepadDisconnected; + private _onGamepadConnectedEvent; + private _onGamepadDisonnectedEvent; + constructor(ongamedpadconnected: (gamepad: T) => void, ongamedpaddisconnected?: (gamepad: T) => void); + dispose(): void; + private _onGamepadConnected(gamepad); + private _addNewGamepad(gamepad); + private _onGamepadDisconnected(gamepad); + private _startMonitoringGamepads(); + private _stopMonitoringGamepads(); + private _checkGamepadsStatus(); + private _updateGamepadObjects(); + } + class StickValues { + x: any; + y: any; + constructor(x: any, y: any); + } + class Gamepad { + id: string; + index: number; + browserGamepad: any; + type: number; + private _leftStick; + private _rightStick; + private _leftStickAxisX; + private _leftStickAxisY; + private _rightStickAxisX; + private _rightStickAxisY; + private _onleftstickchanged; + private _onrightstickchanged; + static GAMEPAD: number; + static GENERIC: number; + static XBOX: number; + static POSE_ENABLED: number; + constructor(id: string, index: number, browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number); + onleftstickchanged(callback: (values: StickValues) => void): void; + onrightstickchanged(callback: (values: StickValues) => void): void; + leftStick: StickValues; + rightStick: StickValues; + update(): void; } - class MergeMeshesOptimization extends SceneOptimization { - static _UpdateSelectionTree: boolean; - static UpdateSelectionTree: boolean; - private _canBeMerged; - apply: (scene: Scene, updateSelectionTree?: boolean) => boolean; + class GenericPad extends Gamepad { + private _buttons; + private _onbuttondown; + private _onbuttonup; + onbuttondown(callback: (buttonPressed: number) => void): void; + onbuttonup(callback: (buttonReleased: number) => void): void; + constructor(id: string, index: number, browserGamepad: any); + private _setButtonValue(newValue, currentValue, buttonIndex); + update(): void; } - class SceneOptimizerOptions { - targetFrameRate: number; - trackerDuration: number; - optimizations: SceneOptimization[]; - constructor(targetFrameRate?: number, trackerDuration?: number); - static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions; - static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions; - static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions; + enum Xbox360Button { + A = 0, + B = 1, + X = 2, + Y = 3, + Start = 4, + Back = 5, + LB = 6, + RB = 7, + LeftStick = 8, + RightStick = 9, } - class SceneOptimizer { - static _CheckCurrentState(scene: Scene, options: SceneOptimizerOptions, currentPriorityLevel: number, onSuccess?: () => void, onFailure?: () => void): void; - static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): void; + enum Xbox360Dpad { + Up = 0, + Down = 1, + Left = 2, + Right = 3, } -} - -declare module BABYLON { - class SceneSerializer { - static ClearCache(): void; - static Serialize(scene: Scene): any; - static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any; + class Xbox360Pad extends Gamepad { + private _leftTrigger; + private _rightTrigger; + private _onlefttriggerchanged; + private _onrighttriggerchanged; + private _onbuttondown; + private _onbuttonup; + private _ondpaddown; + private _ondpadup; + 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; + constructor(id: string, index: number, gamepad: any, xboxOne?: boolean); + onlefttriggerchanged(callback: (value: number) => void): void; + onrighttriggerchanged(callback: (value: number) => void): void; + leftTrigger: number; + rightTrigger: number; + onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void; + onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void; + ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void; + ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void; + private _setButtonValue(newValue, currentValue, buttonType); + private _setDPadValue(newValue, currentValue, buttonType); + buttonA: number; + buttonB: number; + buttonX: number; + buttonY: number; + buttonStart: number; + buttonBack: number; + buttonLB: number; + buttonRB: number; + buttonLeftStick: number; + buttonRightStick: number; + dPadUp: number; + dPadDown: number; + dPadLeft: number; + dPadRight: number; + update(): void; } } - -declare module BABYLON { - class SmartArray { - data: Array; - length: number; - private _id; - private _duplicateId; - constructor(capacity: number); - push(value: any): void; - forEach(func: (content: T) => void): void; - pushNoDuplicate(value: any): boolean; - sort(compareFn: any): void; - reset(): void; - dispose(): void; - concat(array: any): void; - concatWithNoDuplicate(array: any): void; - indexOf(value: T): number; - contains(value: T): boolean; - private static _GlobalId; - } +interface Navigator { + getGamepads(func?: any): any; + webkitGetGamepads(func?: any): any; + msGetGamepads(func?: any): any; + webkitGamepads(func?: any): any; } -declare module BABYLON { +declare module BABYLON.Internals { /** - * This class implement a typical dictionary using a string as key and the generic type T as value. - * The underlying implementation relies on an associative array to ensure the best performances. - * The value can be anything including 'null' but except 'undefined' + * 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/ */ - class StringDictionary { - /** - * This will clear this dictionary and copy the content from the 'source' one. - * If the T value is a custom object, it won't be copied/cloned, the same object will be used - * @param source the dictionary to take the content from and copy to this dictionary - */ - copyFrom(source: StringDictionary): void; - /** - * Get a value based from its key - * @param key the given key to get the matching value from - * @return the value if found, otherwise undefined is returned - */ - get(key: string): T; - /** - * Get a value from its key or add it if it doesn't exist. - * This method will ensure you that a given key/data will be present in the dictionary. - * @param key the given key to get the matching value from - * @param factory the factory that will create the value if the key is not present in the dictionary. - * The factory will only be invoked if there's no data for the given key. - * @return the value corresponding to the key. - */ - getOrAddWithFactory(key: string, factory: (key: string) => T): T; - /** - * Get a value from its key if present in the dictionary otherwise add it - * @param key the key to get the value from - * @param val if there's no such key/value pair in the dictionary add it with this value - * @return the value corresponding to the key - */ - getOrAdd(key: string, val: T): T; - /** - * Check if there's a given key in the dictionary - * @param key the key to check for - * @return true if the key is present, false otherwise - */ - contains(key: any): boolean; - /** - * Add a new key and its corresponding value - * @param key the key to add - * @param value the value corresponding to the key - * @return true if the operation completed successfully, false if we couldn't insert the key/value because there was already this key in the dictionary - */ - add(key: string, value: T): boolean; - set(key: string, value: T): boolean; - /** - * Get the element of the given key and remove it from the dictionary - * @param key - */ - getAndRemove(key: string): T; - /** - * Remove a key/value from the dictionary. - * @param key the key to remove - * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary - */ - remove(key: string): boolean; - /** - * Clear the whole content of the dictionary - */ - clear(): void; - readonly count: number; - /** - * Execute a callback on each key/val of the dictionary. - * Note that you can remove any element in this dictionary in the callback implementation - * @param callback the callback to execute on a given key/value pair - */ - forEach(callback: (key: string, val: T) => void): void; + class KhronosTextureContainer { + arrayBuffer: any; + static HEADER_LEN: number; + static COMPRESSED_2D: number; + static COMPRESSED_3D: number; + static TEX_2D: number; + static TEX_3D: number; + glType: number; + glTypeSize: number; + glFormat: number; + glInternalFormat: number; + glBaseInternalFormat: number; + pixelWidth: number; + pixelHeight: number; + pixelDepth: number; + numberOfArrayElements: number; + numberOfFaces: number; + numberOfMipmapLevels: number; + bytesOfKeyValueData: number; + loadType: number; /** - * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object. - * If the callback returns null or undefined the method will iterate to the next key/value pair - * Note that you can remove any element in this dictionary in the callback implementation - * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned - */ - first(callback: (key: string, val: T) => TRes): TRes; - private _count; - private _data; - } -} - -declare module BABYLON { - class Tags { - static EnableFor(obj: any): void; - static DisableFor(obj: any): void; - static HasTags(obj: any): boolean; - static GetTags(obj: any, asString?: boolean): any; - static AddTagsTo(obj: any, tagsString: string): void; - static _AddTagTo(obj: any, tag: string): void; - static RemoveTagsFrom(obj: any, tagsString: string): void; - static _RemoveTagFrom(obj: any, tag: string): void; - static MatchesQuery(obj: any, tagsQuery: string): boolean; - } -} - -declare module BABYLON { - class TextureTools { + * @param {ArrayBuffer} arrayBuffer- contents of the KTX container file + * @param {number} facesExpected- should be either 1 or 6, based whether a cube texture or or + * @param {boolean} threeDExpected- provision for indicating that data should be a 3D texture, not implemented + * @param {boolean} textureArrayExpected- provision for indicating that data should be a texture array, not implemented + */ + constructor(arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean); + switchEndainness(val: number): number; /** - * Uses the GPU to create a copy texture rescaled at a given size - * @param texture Texture to copy from - * @param width Desired width - * @param height Desired height - * @return Generated texture + * It is assumed that the texture has already been created & is currently bound */ - static CreateResizedCopy(texture: BABYLON.Texture, width: number, height: number, useBilinearMode?: boolean): BABYLON.Texture; - static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture; - private static _environmentBRDFBase64Texture; - } -} - -declare module BABYLON.Internals { - class TGATools { - private static _TYPE_NO_DATA; - private static _TYPE_INDEXED; - private static _TYPE_RGB; - private static _TYPE_GREY; - private static _TYPE_RLE_INDEXED; - private static _TYPE_RLE_RGB; - private static _TYPE_RLE_GREY; - private static _ORIGIN_MASK; - private static _ORIGIN_SHIFT; - private static _ORIGIN_BL; - private static _ORIGIN_BR; - private static _ORIGIN_UL; - private static _ORIGIN_UR; - static GetTGAHeader(data: Uint8Array): any; - static UploadContent(gl: WebGLRenderingContext, data: Uint8Array): void; - static _getImageData8bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array; - static _getImageData16bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array; - static _getImageData24bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array; - static _getImageData32bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array; - static _getImageDataGrey8bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array; - static _getImageDataGrey16bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array; + uploadLevels(gl: WebGLRenderingContext, loadMipmaps: boolean): void; + private _upload2DCompressedLevels(gl, loadMipmaps); } } declare module BABYLON { - interface IAnimatable { - animations: Array; - } - class Tools { - static BaseUrl: string; - static CorsBehavior: any; - static UseFallbackTexture: boolean; - private static fallbackTexture; + /** + * A class serves as a medium between the observable and its observers + */ + class EventState { /** - * Interpolates between a and b via alpha - * @param a The lower value (returned when alpha = 0) - * @param b The upper value (returned when alpha = 1) - * @param alpha The interpolation-factor - * @return The mixed value - */ - static Mix(a: number, b: number, alpha: number): number; - static Instantiate(className: string): any; - static SetImmediate(action: () => void): void; - static IsExponentOfTwo(value: number): boolean; + * If the callback of a given Observer set skipNextObservers to true the following observers will be ignored + */ + constructor(mask: number, skipNextObservers?: boolean); + initalize(mask: number, skipNextObservers?: boolean): EventState; /** - * Find the next highest power of two. - * @param x Number to start search from. - * @return Next highest power of two. + * An Observer can set this property to true to prevent subsequent observers of being notified */ - static CeilingPOT(x: number): number; + skipNextObservers: boolean; /** - * Find the next lowest power of two. - * @param x Number to start search from. - * @return Next lowest power of two. + * Get the mask value that were used to trigger the event corresponding to this EventState object */ - static FloorPOT(x: number): number; + mask: number; + } + /** + * Represent an Observer registered to a given Observable object. + */ + class Observer { + callback: (eventData: T, eventState: EventState) => void; + mask: number; + constructor(callback: (eventData: T, eventState: EventState) => void, mask: number); + } + /** + * The Observable class is a simple implementation of the Observable pattern. + * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified. + * This enable a more fine grained execution without having to rely on multiple different Observable objects. + * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08). + * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right. + */ + class Observable { + _observers: Observer[]; + private _eventState; + constructor(); /** - * Find the nearest power of two. - * @param x Number to start search from. - * @return Next nearest power of two. + * Create a new Observer with the specified callback + * @param callback the callback that will be executed for that Observer + * @param mask the mask used to filter observers + * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present. */ - static NearestPOT(x: number): number; - static GetExponentOfTwo(value: number, max: number, mode?: number): number; - static GetFilename(path: string): string; - static GetDOMTextContent(element: HTMLElement): string; - static ToDegrees(angle: number): number; - static ToRadians(angle: number): number; - static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string; - static ExtractMinAndMaxIndexed(positions: number[] | Float32Array, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Vector2): { - minimum: Vector3; - maximum: Vector3; - }; - static ExtractMinAndMax(positions: number[] | Float32Array, start: number, count: number, bias?: Vector2, stride?: number): { - minimum: Vector3; - maximum: Vector3; - }; - static Vector2ArrayFeeder(array: Array | Float32Array): (i: number) => Vector2; - static ExtractMinAndMaxVector2(feeder: (index: number) => Vector2, bias?: Vector2): { - minimum: Vector2; - maximum: Vector2; - }; - static MakeArray(obj: any, allowsNullUndefined?: boolean): Array; - static GetPointerPrefix(): string; + add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean): Observer; /** - * @param func - the function to be called - * @param requester - the object that will request the next frame. Falls back to window. + * Remove an Observer from the Observable object + * @param observer the instance of the Observer to remove. If it doesn't belong to this Observable, false will be returned. */ - static QueueNewFrame(func: any, requester?: any): void; - static RequestFullscreen(element: any): void; - static ExitFullscreen(): void; - static SetCorsBehavior(url: string, img: HTMLImageElement): void; - static CleanUrl(url: string): string; - static LoadImage(url: any, onload: any, onerror: any, database: any): HTMLImageElement; - static LoadFile(url: string, callback: (data: any) => void, progressCallBack?: (data: any) => void, database?: any, useArrayBuffer?: boolean, onError?: (request: XMLHttpRequest) => void): void; + remove(observer: Observer): boolean; /** - * Load a script (identified by an url). When the url returns, the - * content of this file is added into a new script element, attached to the DOM (body element) - */ - static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: () => void): void; - static ReadFileAsDataURL(fileToLoad: any, callback: any, progressCallback: any): void; - static ReadFile(fileToLoad: any, callback: any, progressCallBack: any, useArrayBuffer?: boolean): void; - static FileAsURL(content: string): string; - static Format(value: number, decimals?: number): string; - static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void; - static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void; - static IsEmpty(obj: any): boolean; - static RegisterTopRootEvents(events: { - name: string; - handler: EventListener; - }[]): void; - static UnregisterTopRootEvents(events: { - name: string; - handler: EventListener; - }[]): void; - static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string): void; - static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string): void; - static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void; - static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number): void; - static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean; + * Remove a callback from the Observable object + * @param callback the callback to remove. If it doesn't belong to this Observable, false will be returned. + */ + removeCallback(callback: (eventData: T, eventState: EventState) => void): boolean; /** - * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523 - * Be aware Math.random() could cause collisions, but: - * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide" + * Notify all Observers by calling their respective callback with the given data + * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute + * @param eventData + * @param mask */ - static RandomId(): string; - private static _NoneLogLevel; - private static _MessageLogLevel; - private static _WarningLogLevel; - private static _ErrorLogLevel; - private static _LogCache; - static errorsCount: number; - static OnNewCacheEntry: (entry: string) => void; - static readonly NoneLogLevel: number; - static readonly MessageLogLevel: number; - static readonly WarningLogLevel: number; - static readonly ErrorLogLevel: number; - static readonly AllLogLevel: number; - private static _AddLogEntry(entry); - private static _FormatMessage(message); - private static _LogDisabled(message); - private static _LogEnabled(message); - private static _WarnDisabled(message); - private static _WarnEnabled(message); - private static _ErrorDisabled(message); - private static _ErrorEnabled(message); - static Log: (message: string) => void; - static Warn: (message: string) => void; - static Error: (message: string) => void; - static readonly LogCache: string; - static ClearLogCache(): void; - static LogLevels: number; - private static _PerformanceNoneLogLevel; - private static _PerformanceUserMarkLogLevel; - private static _PerformanceConsoleLogLevel; - private static _performance; - static readonly PerformanceNoneLogLevel: number; - static readonly PerformanceUserMarkLogLevel: number; - static readonly PerformanceConsoleLogLevel: number; - static PerformanceLogLevel: number; - static _StartPerformanceCounterDisabled(counterName: string, condition?: boolean): void; - static _EndPerformanceCounterDisabled(counterName: string, condition?: boolean): void; - static _StartUserMark(counterName: string, condition?: boolean): void; - static _EndUserMark(counterName: string, condition?: boolean): void; - static _StartPerformanceConsole(counterName: string, condition?: boolean): void; - static _EndPerformanceConsole(counterName: string, condition?: boolean): void; - static StartPerformanceCounter: (counterName: string, condition?: boolean) => void; - static EndPerformanceCounter: (counterName: string, condition?: boolean) => void; - static readonly Now: number; + notifyObservers(eventData: T, mask?: number): boolean; /** - * This method will return the name of the class used to create the instance of the given object. - * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator. - * @param object the object to get the class name from - * @return the name of the class, will be "object" for a custom data type not using the @className decorator + * return true is the Observable has at least one Observer registered */ - static GetClassName(object: any, isType?: boolean): string; - static first(array: Array, predicate: (item: T) => boolean): T; + hasObservers(): boolean; + /** + * Clear the list of observers + */ + clear(): void; + /** + * Clone the current observable + */ + clone(): Observable; + /** + * Does this observable handles observer registered with a given mask + * @param {number} trigger - the mask to be tested + * @return {boolean} whether or not one observer registered with the given mask is handeled + **/ + hasSpecificMask(mask?: number): boolean; + } +} + +declare namespace BABYLON { + /** + * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window + */ + class PerformanceMonitor { + private _enabled; + private _rollingFrameTime; + private _lastFrameTimeMs; + private _lastChangeTimeMs; /** - * This method will return the name of the full name of the class, including its owning module (if any). - * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator or implementing a method getClassName():string (in which case the module won't be specified). - * @param object the object to get the class name from - * @return a string that can have two forms: "moduleName.className" if module was specified when the class' Name was registered or "className" if there was not module specified. + * constructor + * @param frameSampleSize The number of samples required to saturate the sliding window */ - static getFullClassName(object: any, isType?: boolean): string; + constructor(frameSampleSize?: number); /** - * This method can be used with hashCodeFromStream when your input is an array of values that are either: number, string, boolean or custom type implementing the getHashCode():number method. - * @param array + * Samples current frame + * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames */ - static arrayOrStringFeeder(array: any): (i: number) => number; + sampleFrame(timeMs?: number): void; /** - * Compute the hashCode of a stream of number - * To compute the HashCode on a string or an Array of data types implementing the getHashCode() method, use the arrayOrStringFeeder method. - * @param feeder a callback that will be called until it returns null, each valid returned values will be used to compute the hash code. - * @return the hash code computed + * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far) + * @return Average frame time in milliseconds */ - static hashCodeFromStream(feeder: (index: number) => number): number; - } - /** - * This class is used to track a performance counter which is number based. - * The user has access to many properties which give statistics of different nature - * - * The implementer can track two kinds of Performance Counter: time and count - * For time you can optionally call fetchNewFrame() to notify the start of a new frame to monitor, then call beginMonitoring() to start and endMonitoring() to record the lapsed time. endMonitoring takes a newFrame parameter for you to specify if the monitored time should be set for a new frame or accumulated to the current frame being monitored. - * For count you first have to call fetchNewFrame() to notify the start of a new frame to monitor, then call addCount() how many time required to increment the count value you monitor. - */ - class PerfCounter { - static Enabled: boolean; + readonly averageFrameTime: number; /** - * Returns the smallest value ever + * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far) + * @return Frame time variance in milliseconds squared */ - readonly min: number; + readonly averageFrameTimeVariance: number; /** - * Returns the biggest value ever + * Returns the frame time of the most recent frame + * @return Frame time in milliseconds */ - readonly max: number; + readonly instantaneousFrameTime: number; /** - * Returns the average value since the performance counter is running + * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far) + * @return Framerate in frames per second */ - readonly average: number; + readonly averageFPS: number; /** - * Returns the average value of the last second the counter was monitored + * Returns the average framerate in frames per second using the most recent frame time + * @return Framerate in frames per second */ - readonly lastSecAverage: number; + readonly instantaneousFPS: number; /** - * Returns the current value + * Returns true if enough samples have been taken to completely fill the sliding window + * @return true if saturated */ - readonly current: number; - readonly total: number; - constructor(); + readonly isSaturated: boolean; /** - * Call this method to start monitoring a new frame. - * This scenario is typically used when you accumulate monitoring time many times for a single frame, you call this method at the start of the frame, then beginMonitoring to start recording and endMonitoring(false) to accumulated the recorded time to the PerfCounter or addCount() to accumulate a monitored count. + * Enables contributions to the sliding window sample set */ - fetchNewFrame(): void; + enable(): void; /** - * Call this method to monitor a count of something (e.g. mesh drawn in viewport count) - * @param newCount the count value to add to the monitored count - * @param fetchResult true when it's the last time in the frame you add to the counter and you wish to update the statistics properties (min/max/average), false if you only want to update statistics. + * Disables contributions to the sliding window sample set + * Samples will not be interpolated over the disabled period */ - addCount(newCount: number, fetchResult: boolean): void; + disable(): void; /** - * Start monitoring this performance counter + * Returns true if sampling is enabled + * @return true if enabled */ - beginMonitoring(): void; + readonly isEnabled: boolean; /** - * Compute the time lapsed since the previous beginMonitoring() call. - * @param newFrame true by default to fetch the result and monitor a new frame, if false the time monitored will be added to the current frame counter + * Resets performance monitor */ - endMonitoring(newFrame?: boolean): void; - private _fetchResult(); - private _startMonitoringTime; - private _min; - private _max; - private _average; - private _current; - private _totalValueCount; - private _totalAccumulated; - private _lastSecAverage; - private _lastSecAccumulated; - private _lastSecTime; - private _lastSecValueCount; + reset(): void; } /** - * Use this className as a decorator on a given class definition to add it a name and optionally its module. - * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name. - * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified - * @param name The name of the class, case should be preserved - * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved. + * RollingAverage + * + * Utility to efficiently compute the rolling average and variance over a sliding window of samples */ - function className(name: string, module?: string): (target: Object) => void; - /** - * An implementation of a loop for asynchronous functions. - */ - class AsyncLoop { - iterations: number; - private _fn; - private _successCallback; - index: number; - private _done; + class RollingAverage { /** - * Constroctor. - * @param iterations the number of iterations. - * @param _fn the function to run each iteration - * @param _successCallback the callback that will be called upon succesful execution - * @param offset starting offset. + * Current average */ - constructor(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number); + average: number; /** - * Execute the next iteration. Must be called after the last iteration was finished. + * Current variance */ - executeNext(): void; + variance: number; + protected _samples: Array; + protected _sampleCount: number; + protected _pos: number; + protected _m2: number; /** - * Break the loop and run the success callback. + * constructor + * @param length The number of samples required to saturate the sliding window */ - breakLoop(): void; + constructor(length: number); /** - * Helper function + * Adds a sample to the sample set + * @param v The sample value */ - static Run(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number): AsyncLoop; + add(v: number): void; /** - * A for-loop that will run a given number of iterations synchronous and the rest async. - * @param iterations total number of iterations - * @param syncedIterations number of synchronous iterations in each async iteration. - * @param fn the function to call each iteration. - * @param callback a success call back that will be called when iterating stops. - * @param breakFunction a break condition (optional) - * @param timeout timeout settings for the setTimeout function. default - 0. - * @constructor + * Returns previously added values or null if outside of history or outside the sliding window domain + * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that + * @return Value previously recorded with add() or null if outside of range */ - static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): void; - } -} - -declare module BABYLON { - enum JoystickAxis { - X = 0, - Y = 1, - Z = 2, - } - class VirtualJoystick { - reverseLeftRight: boolean; - reverseUpDown: boolean; - deltaPosition: Vector3; - pressed: boolean; - private static _globalJoystickIndex; - private static vjCanvas; - private static vjCanvasContext; - private static vjCanvasWidth; - private static vjCanvasHeight; - private static halfWidth; - private static halfHeight; - private _action; - private _axisTargetedByLeftAndRight; - private _axisTargetedByUpAndDown; - private _joystickSensibility; - private _inversedSensibility; - private _rotationSpeed; - private _inverseRotationSpeed; - private _rotateOnAxisRelativeToMesh; - private _joystickPointerID; - private _joystickColor; - private _joystickPointerPos; - private _joystickPreviousPointerPos; - private _joystickPointerStartPos; - private _deltaJoystickVector; - private _leftJoystick; - private _joystickIndex; - private _touches; - private _onPointerDownHandlerRef; - private _onPointerMoveHandlerRef; - private _onPointerUpHandlerRef; - private _onPointerOutHandlerRef; - private _onResize; - constructor(leftJoystick?: boolean); - setJoystickSensibility(newJoystickSensibility: number): void; - private _onPointerDown(e); - private _onPointerMove(e); - private _onPointerUp(e); + history(i: number): number; /** - * Change the color of the virtual joystick - * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000") - */ - setJoystickColor(newColor: string): void; - setActionOnTouch(action: () => any): void; - setAxisForLeftRight(axis: JoystickAxis): void; - setAxisForUpDown(axis: JoystickAxis): void; - private _clearCanvas(); - private _drawVirtualJoystick(); - releaseCanvas(): void; - } -} - -declare module BABYLON { - class ArcRotateCameraGamepadInput implements ICameraInput { - camera: ArcRotateCamera; - gamepad: Gamepad; - private _gamepads; - gamepadRotationSensibility: number; - gamepadMoveSensibility: number; - attachControl(element: HTMLElement, noPreventDefault?: boolean): void; - detachControl(element: HTMLElement): void; - checkInputs(): void; - private _onNewGameConnected(gamepad); - getClassName(): string; - getSimpleName(): string; - } -} - -declare module BABYLON { - class ArcRotateCameraKeyboardMoveInput implements ICameraInput { - camera: ArcRotateCamera; - private _keys; - private _onKeyDown; - private _onKeyUp; - private _onLostFocus; - keysUp: number[]; - keysDown: number[]; - keysLeft: number[]; - keysRight: number[]; - attachControl(element: HTMLElement, noPreventDefault?: boolean): void; - detachControl(element: HTMLElement): void; - checkInputs(): void; - getClassName(): string; - getSimpleName(): string; + * Returns true if enough samples have been taken to completely fill the sliding window + * @return true if sample-set saturated + */ + isSaturated(): boolean; + /** + * Resets the rolling average (equivalent to 0 samples taken so far) + */ + reset(): void; + /** + * Wraps a value around the sample range boundaries + * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned. + * @return Wrapped position in sample range + */ + protected _wrapPosition(i: number): number; } } declare module BABYLON { - class ArcRotateCameraMouseWheelInput implements ICameraInput { - camera: ArcRotateCamera; - private _wheel; - private _observer; - wheelPrecision: number; - attachControl(element: HTMLElement, noPreventDefault?: boolean): void; - detachControl(element: HTMLElement): void; - getClassName(): string; - getSimpleName(): string; + /** + * This class describe a rectangle that were added to the map. + * You have access to its coordinates either in pixel or normalized (UV) + */ + class PackedRect { + constructor(root: RectPackingMap, parent: PackedRect, pos: Vector2, size: Size); + /** + * @returns the position of this node into the map + */ + readonly pos: Vector2; + /** + * @returns the size of the rectangle this node handles + */ + readonly contentSize: Size; + /** + * Retrieve the inner position (considering the margin) and stores it into the res object + * @param res must be a valid Vector2 that will contain the inner position after this call + */ + getInnerPosToRef(res: Vector2): void; + /** + * Retrieve the inner size (considering the margin) and stores it into the res object + * @param res must be a valid Size that will contain the inner size after this call + */ + getInnerSizeToRef(res: Size): void; + /** + * Compute the UV of the top/left, top/right, bottom/right, bottom/left points of the rectangle this node handles into the map + * @returns And array of 4 Vector2, containing UV coordinates for the four corners of the Rectangle into the map + */ + readonly UVs: Vector2[]; + /** + * You may have allocated the PackedRect using over-provisioning (you allocated more than you need in order to prevent frequent deallocations/reallocations) + * and then using only a part of the PackRect. + * This method will return the UVs for this part by given the custom size of what you really use + * @param customSize must be less/equal to the allocated size, UV will be compute from this + */ + getUVsForCustomSize(customSize: Size): Vector2[]; + /** + * Free this rectangle from the map. + * Call this method when you no longer need the rectangle to be in the map. + */ + freeContent(): void; + protected readonly isUsed: boolean; + protected findAndSplitNode(contentSize: Size): PackedRect; + private findNode(size); + private static TpsSize; + private splitNode(contentSize); + private attemptDefrag(); + private clearNode(); + private readonly isRecursiveFree; + protected evalFreeSize(size: number): number; + protected _root: RectPackingMap; + protected _parent: PackedRect; + private _contentSize; + private _initialSize; + private _leftNode; + private _rightNode; + private _bottomNode; + private _pos; + protected _size: Size; } -} - -declare module BABYLON { - class ArcRotateCameraPointersInput implements ICameraInput { - camera: ArcRotateCamera; - buttons: number[]; - angularSensibilityX: number; - angularSensibilityY: number; - pinchPrecision: number; - panningSensibility: number; - private _isPanClick; - pinchInwards: boolean; - private _pointerInput; - private _observer; - private _onMouseMove; - private _onGestureStart; - private _onGesture; - private _MSGestureHandler; - private _onLostFocus; - private _onContextMenu; - attachControl(element: HTMLElement, noPreventDefault?: boolean): void; - detachControl(element: HTMLElement): void; - getClassName(): string; - getSimpleName(): string; + /** + * The purpose of this class is to pack several Rectangles into a big map, while trying to fit everything as optimally as possible. + * This class is typically used to build lightmaps, sprite map or to pack several little textures into a big one. + * Note that this class allows allocated Rectangles to be freed: that is the map is dynamically maintained so you can add/remove rectangle based on their life-cycle. + * In case you need a margin around the allocated rect, specify the amount in the margin argument during construction. + * In such case you will have to rely on innerPositionToRef and innerSizeToRef calls to get the proper size + */ + class RectPackingMap extends PackedRect { + /** + * Create an instance of the object with a dimension using the given size + * @param size The dimension of the rectangle that will contain all the sub ones. + * @param margin The margin (empty space) created (in pixels) around the allocated Rectangles + */ + constructor(size: Size, margin?: number); + /** + * Add a rectangle, finding the best location to store it into the map + * @param size the dimension of the rectangle to store + * @return the Node containing the rectangle information, or null if we couldn't find a free spot + */ + addRect(size: Size): PackedRect; + /** + * Return the current space free normalized between [0;1] + * @returns {} + */ + readonly freeSpace: number; + _margin: number; } } declare module BABYLON { - class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput { - camera: ArcRotateCamera; - alphaCorrection: number; - betaCorrection: number; - gammaCorrection: number; - private _alpha; - private _beta; - private _gamma; - private _dirty; - private _offsetOrientation; - private _deviceOrientationHandler; - constructor(); - attachControl(element: HTMLElement, noPreventDefault?: boolean): void; - _onOrientationEvent(evt: DeviceOrientationEvent): void; - checkInputs(): void; - detachControl(element: HTMLElement): void; - getClassName(): string; - getSimpleName(): string; + class SceneOptimization { + priority: number; + apply: (scene: Scene) => boolean; + constructor(priority?: number); } -} - -declare module BABYLON { - class FreeCameraDeviceOrientationInput implements ICameraInput { - private _camera; - private _screenOrientationAngle; - private _constantTranform; - private _screenQuaternion; - private _alpha; - private _beta; - private _gamma; - constructor(); - camera: FreeCamera; - attachControl(element: HTMLElement, noPreventDefault?: boolean): void; - private _orientationChanged; - private _deviceOrientation; - detachControl(element: HTMLElement): void; - checkInputs(): void; - getClassName(): string; - getSimpleName(): string; + class TextureOptimization extends SceneOptimization { + priority: number; + maximumSize: number; + constructor(priority?: number, maximumSize?: number); + apply: (scene: Scene) => boolean; } -} - -declare module BABYLON { - class FreeCameraGamepadInput implements ICameraInput { - camera: FreeCamera; - gamepad: Gamepad; - private _gamepads; - gamepadAngularSensibility: number; - gamepadMoveSensibility: number; - private _cameraTransform; - private _deltaTransform; - private _vector3; - private _vector2; - attachControl(element: HTMLElement, noPreventDefault?: boolean): void; - detachControl(element: HTMLElement): void; - checkInputs(): void; - private _onNewGameConnected(gamepad); - getClassName(): string; - getSimpleName(): string; + class HardwareScalingOptimization extends SceneOptimization { + priority: number; + maximumScale: number; + private _currentScale; + constructor(priority?: number, maximumScale?: number); + apply: (scene: Scene) => boolean; } -} - -declare module BABYLON { - class FreeCameraKeyboardMoveInput implements ICameraInput { - camera: FreeCamera; - private _keys; - private _onKeyDown; - private _onKeyUp; - keysUp: number[]; - keysDown: number[]; - keysLeft: number[]; - keysRight: number[]; - attachControl(element: HTMLElement, noPreventDefault?: boolean): void; - detachControl(element: HTMLElement): void; - checkInputs(): void; - getClassName(): string; - _onLostFocus(e: FocusEvent): void; - getSimpleName(): string; + class ShadowsOptimization extends SceneOptimization { + apply: (scene: Scene) => boolean; } -} - -declare module BABYLON { - class FreeCameraMouseInput implements ICameraInput { - touchEnabled: boolean; - camera: FreeCamera; - buttons: number[]; - angularSensibility: number; - private _pointerInput; - private _onMouseMove; - private _observer; - private previousPosition; - constructor(touchEnabled?: boolean); - attachControl(element: HTMLElement, noPreventDefault?: boolean): void; - detachControl(element: HTMLElement): void; - getClassName(): string; - getSimpleName(): string; + class PostProcessesOptimization extends SceneOptimization { + apply: (scene: Scene) => boolean; } -} - -declare module BABYLON { - class FreeCameraTouchInput implements ICameraInput { - camera: FreeCamera; - private _offsetX; - private _offsetY; - private _pointerCount; - private _pointerPressed; - private _pointerInput; - private _observer; - private _onLostFocus; - touchAngularSensibility: number; - touchMoveSensibility: number; - attachControl(element: HTMLElement, noPreventDefault?: boolean): void; - detachControl(element: HTMLElement): void; - checkInputs(): void; - getClassName(): string; - getSimpleName(): string; + class LensFlaresOptimization extends SceneOptimization { + apply: (scene: Scene) => boolean; + } + class ParticlesOptimization extends SceneOptimization { + apply: (scene: Scene) => boolean; } -} - -declare module BABYLON { - class FreeCameraVirtualJoystickInput implements ICameraInput { - camera: FreeCamera; - private _leftjoystick; - private _rightjoystick; - getLeftJoystick(): VirtualJoystick; - getRightJoystick(): VirtualJoystick; - checkInputs(): void; - attachControl(element: HTMLElement, noPreventDefault?: boolean): void; - detachControl(element: HTMLElement): void; - getClassName(): string; - getSimpleName(): string; + class RenderTargetsOptimization extends SceneOptimization { + apply: (scene: Scene) => boolean; + } + class MergeMeshesOptimization extends SceneOptimization { + static _UpdateSelectionTree: boolean; + static UpdateSelectionTree: boolean; + private _canBeMerged; + apply: (scene: Scene, updateSelectionTree?: boolean) => boolean; + } + class SceneOptimizerOptions { + targetFrameRate: number; + trackerDuration: number; + optimizations: SceneOptimization[]; + constructor(targetFrameRate?: number, trackerDuration?: number); + static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions; + static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions; + static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions; + } + class SceneOptimizer { + static _CheckCurrentState(scene: Scene, options: SceneOptimizerOptions, currentPriorityLevel: number, onSuccess?: () => void, onFailure?: () => void): void; + static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): void; } } declare module BABYLON { - class VRCameraMetrics { - hResolution: number; - vResolution: number; - hScreenSize: number; - vScreenSize: number; - vScreenCenter: number; - eyeToScreenDistance: number; - lensSeparationDistance: number; - interpupillaryDistance: number; - distortionK: number[]; - chromaAbCorrection: number[]; - postProcessScaleFactor: number; - lensCenterOffset: number; - compensateDistortion: boolean; - readonly aspectRatio: number; - readonly aspectRatioFov: number; - readonly leftHMatrix: Matrix; - readonly rightHMatrix: Matrix; - readonly leftPreViewMatrix: Matrix; - readonly rightPreViewMatrix: Matrix; - static GetDefault(): VRCameraMetrics; + class SceneSerializer { + static ClearCache(): void; + static Serialize(scene: Scene): any; + static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any; } } declare module BABYLON { - class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera { - constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics); - getClassName(): string; - } - class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera { - constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics); - getClassName(): string; - } - class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera { - constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics); - getClassName(): string; + class SmartArray { + data: Array; + length: number; + private _id; + private _duplicateId; + constructor(capacity: number); + push(value: any): void; + forEach(func: (content: T) => void): void; + pushNoDuplicate(value: any): boolean; + sort(compareFn: any): void; + reset(): void; + dispose(): void; + concat(array: any): void; + concatWithNoDuplicate(array: any): void; + indexOf(value: T): number; + contains(value: T): boolean; + private static _GlobalId; } } -declare var HMDVRDevice: any; -declare var VRDisplay: any; -declare var VRFrameData: any; declare module BABYLON { /** - * This is a copy of VRPose. - * IMPORTANT!! The data is right-hand data. - * @export - * @interface DevicePose + * This class implement a typical dictionary using a string as key and the generic type T as value. + * The underlying implementation relies on an associative array to ensure the best performances. + * The value can be anything including 'null' but except 'undefined' */ - interface DevicePose { - readonly position?: Float32Array; - readonly linearVelocity?: Float32Array; - readonly linearAcceleration?: Float32Array; - readonly orientation?: Float32Array; - readonly angularVelocity?: Float32Array; - readonly angularAcceleration?: Float32Array; - } - interface PoseControlled { - position: Vector3; - rotationQuaternion: Quaternion; - devicePosition?: Vector3; - deviceRotationQuaternion: Quaternion; - rawPose: DevicePose; - deviceScaleFactor: number; - updateFromDevice(poseData: DevicePose): any; - } - interface WebVROptions { - trackPosition?: boolean; - positionScale?: number; - displayName?: string; - controllerMeshes?: boolean; - defaultLightningOnControllers?: boolean; - } - class WebVRFreeCamera extends FreeCamera implements PoseControlled { - private webVROptions; - _vrDevice: any; - rawPose: DevicePose; - private _vrEnabled; - private _specsVersion; - private _attached; - private _oldSize; - private _oldHardwareScaleFactor; - private _frameData; - private _quaternionCache; - private _positionOffset; - protected _descendants: Array; - devicePosition: Vector3; - deviceRotationQuaternion: any; - deviceScaleFactor: number; - controllers: Array; - nonVRControllers: Array; - private _onControllersAttached; - private _onNonVRControllerAttached; - rigParenting: boolean; - private _lightOnControllers; - constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions); - onControllersAttached: (controllers: Array) => void; - onNonVRControllerAttached: (controller: Gamepad) => void; - getControllerByName(name: string): WebVRController; - private _leftController; - readonly leftController: WebVRController; - private _rightController; - readonly rightController: WebVRController; - getForwardRay(length?: number): Ray; - _checkInputs(): void; - updateFromDevice(poseData: DevicePose): void; + class StringDictionary { /** - * WebVR's attach control will start broadcasting frames to the device. - * Note that in certain browsers (chrome for example) this function must be called - * within a user-interaction callback. Example: - *
 scene.onPointerDown = function() { camera.attachControl(canvas); }
- * - * @param {HTMLElement} element - * @param {boolean} [noPreventDefault] - * - * @memberOf WebVRFreeCamera + * This will clear this dictionary and copy the content from the 'source' one. + * If the T value is a custom object, it won't be copied/cloned, the same object will be used + * @param source the dictionary to take the content from and copy to this dictionary */ - attachControl(element: HTMLElement, noPreventDefault?: boolean): void; - detachControl(element: HTMLElement): void; - getClassName(): string; - resetToCurrentRotation(): void; - _updateRigCameras(): void; + copyFrom(source: StringDictionary): void; /** - * This function is called by the two RIG cameras. - * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance) + * Get a value based from its key + * @param key the given key to get the matching value from + * @return the value if found, otherwise undefined is returned */ - protected _getWebVRViewMatrix(): Matrix; - protected _getWebVRProjectionMatrix(): Matrix; - initControllers(): void; - } -} - -declare module BABYLON { - interface IOctreeContainer { - blocks: Array>; - } - class Octree { - maxDepth: number; - blocks: Array>; - dynamicContent: T[]; - private _maxBlockCapacity; - private _selectionContent; - private _creationFunc; - constructor(creationFunc: (entry: T, block: OctreeBlock) => void, maxBlockCapacity?: number, maxDepth?: number); - update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void; - addMesh(entry: T): void; - select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray; - intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray; - intersectsRay(ray: Ray): SmartArray; - static _CreateBlocks(worldMin: Vector3, worldMax: Vector3, entries: T[], maxBlockCapacity: number, currentDepth: number, maxDepth: number, target: IOctreeContainer, creationFunc: (entry: T, block: OctreeBlock) => void): void; - static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock) => void; - static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock) => void; + get(key: string): T; + /** + * Get a value from its key or add it if it doesn't exist. + * This method will ensure you that a given key/data will be present in the dictionary. + * @param key the given key to get the matching value from + * @param factory the factory that will create the value if the key is not present in the dictionary. + * The factory will only be invoked if there's no data for the given key. + * @return the value corresponding to the key. + */ + getOrAddWithFactory(key: string, factory: (key: string) => T): T; + /** + * Get a value from its key if present in the dictionary otherwise add it + * @param key the key to get the value from + * @param val if there's no such key/value pair in the dictionary add it with this value + * @return the value corresponding to the key + */ + getOrAdd(key: string, val: T): T; + /** + * Check if there's a given key in the dictionary + * @param key the key to check for + * @return true if the key is present, false otherwise + */ + contains(key: any): boolean; + /** + * Add a new key and its corresponding value + * @param key the key to add + * @param value the value corresponding to the key + * @return true if the operation completed successfully, false if we couldn't insert the key/value because there was already this key in the dictionary + */ + add(key: string, value: T): boolean; + set(key: string, value: T): boolean; + /** + * Get the element of the given key and remove it from the dictionary + * @param key + */ + getAndRemove(key: string): T; + /** + * Remove a key/value from the dictionary. + * @param key the key to remove + * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary + */ + remove(key: string): boolean; + /** + * Clear the whole content of the dictionary + */ + clear(): void; + readonly count: number; + /** + * Execute a callback on each key/val of the dictionary. + * Note that you can remove any element in this dictionary in the callback implementation + * @param callback the callback to execute on a given key/value pair + */ + forEach(callback: (key: string, val: T) => void): void; + /** + * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object. + * If the callback returns null or undefined the method will iterate to the next key/value pair + * Note that you can remove any element in this dictionary in the callback implementation + * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned + */ + first(callback: (key: string, val: T) => TRes): TRes; + private _count; + private _data; } } declare module BABYLON { - class OctreeBlock { - entries: T[]; - blocks: Array>; - private _depth; - private _maxDepth; - private _capacity; - private _minPoint; - private _maxPoint; - private _boundingVectors; - private _creationFunc; - constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock) => void); - readonly capacity: number; - readonly minPoint: Vector3; - readonly maxPoint: Vector3; - addEntry(entry: T): void; - addEntries(entries: T[]): void; - select(frustumPlanes: Plane[], selection: SmartArray, allowDuplicate?: boolean): void; - intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArray, allowDuplicate?: boolean): void; - intersectsRay(ray: Ray, selection: SmartArray): void; - createInnerBlocks(): void; + class Tags { + static EnableFor(obj: any): void; + static DisableFor(obj: any): void; + static HasTags(obj: any): boolean; + static GetTags(obj: any, asString?: boolean): any; + static AddTagsTo(obj: any, tagsString: string): void; + static _AddTagTo(obj: any, tag: string): void; + static RemoveTagsFrom(obj: any, tagsString: string): void; + static _RemoveTagFrom(obj: any, tag: string): void; + static MatchesQuery(obj: any, tagsQuery: string): boolean; + } +} + +declare module BABYLON { + class TextureTools { + /** + * Uses the GPU to create a copy texture rescaled at a given size + * @param texture Texture to copy from + * @param width Desired width + * @param height Desired height + * @return Generated texture + */ + static CreateResizedCopy(texture: BABYLON.Texture, width: number, height: number, useBilinearMode?: boolean): BABYLON.Texture; + static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture; + private static _environmentBRDFBase64Texture; } } declare module BABYLON.Internals { + class TGATools { + private static _TYPE_NO_DATA; + private static _TYPE_INDEXED; + private static _TYPE_RGB; + private static _TYPE_GREY; + private static _TYPE_RLE_INDEXED; + private static _TYPE_RLE_RGB; + private static _TYPE_RLE_GREY; + private static _ORIGIN_MASK; + private static _ORIGIN_SHIFT; + private static _ORIGIN_BL; + private static _ORIGIN_BR; + private static _ORIGIN_UL; + private static _ORIGIN_UR; + static GetTGAHeader(data: Uint8Array): any; + static UploadContent(gl: WebGLRenderingContext, data: Uint8Array): void; + static _getImageData8bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array; + static _getImageData16bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array; + static _getImageData24bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array; + static _getImageData32bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array; + static _getImageDataGrey8bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array; + static _getImageDataGrey16bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array; + } } declare module BABYLON { - /** - * Interface to implement to create a shadow generator compatible with BJS. - */ - interface IShadowGenerator { - getShadowMap(): RenderTargetTexture; - getShadowMapForRendering(): RenderTargetTexture; - isReady(subMesh: SubMesh, useInstances: boolean): boolean; - prepareDefines(defines: MaterialDefines, lightIndex: number): void; - bindShadowLight(lightIndex: string, effect: Effect): void; - getTransformMatrix(): Matrix; - recreateShadowMap(): void; - forceCompilation(onCompiled: (generator: ShadowGenerator) => void, options?: { - useInstances: boolean; - }): void; - serialize(): any; - dispose(): void; + interface IAnimatable { + animations: Array; } - class ShadowGenerator implements IShadowGenerator { - private static _FILTER_NONE; - private static _FILTER_EXPONENTIALSHADOWMAP; - private static _FILTER_POISSONSAMPLING; - private static _FILTER_BLUREXPONENTIALSHADOWMAP; - private static _FILTER_CLOSEEXPONENTIALSHADOWMAP; - private static _FILTER_BLURCLOSEEXPONENTIALSHADOWMAP; - static readonly FILTER_NONE: number; - static readonly FILTER_POISSONSAMPLING: number; - static readonly FILTER_EXPONENTIALSHADOWMAP: number; - static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number; - static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number; - static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number; - private _bias; - bias: number; - private _blurBoxOffset; - blurBoxOffset: number; - private _blurScale; - blurScale: number; - private _blurKernel; - blurKernel: number; - private _useKernelBlur; - useKernelBlur: boolean; - private _depthScale; - depthScale: number; - private _filter; - filter: number; - usePoissonSampling: boolean; - useVarianceShadowMap: boolean; - useBlurVarianceShadowMap: boolean; - useExponentialShadowMap: boolean; - useBlurExponentialShadowMap: boolean; - useCloseExponentialShadowMap: boolean; - useBlurCloseExponentialShadowMap: boolean; - private _darkness; - /** - * Returns the darkness value (float). - */ - getDarkness(): number; - /** - * Sets the ShadowGenerator darkness value (float <= 1.0). - * Returns the ShadowGenerator. - */ - setDarkness(darkness: number): ShadowGenerator; - private _transparencyShadow; - /** - * Sets the ability to have transparent shadow (boolean). - * Returns the ShadowGenerator. - */ - setTransparencyShadow(hasShadow: boolean): ShadowGenerator; - private _shadowMap; - private _shadowMap2; - /** - * Returns a RenderTargetTexture object : the shadow map texture. - */ - getShadowMap(): RenderTargetTexture; - /** - * Returns the most ready computed shadow map as a RenderTargetTexture object. - */ - getShadowMapForRendering(): RenderTargetTexture; + class Tools { + static BaseUrl: string; + static CorsBehavior: any; + static UseFallbackTexture: boolean; + private static fallbackTexture; /** - * Controls the extent to which the shadows fade out at the edge of the frustum - * Used only by directionals and spots + * Interpolates between a and b via alpha + * @param a The lower value (returned when alpha = 0) + * @param b The upper value (returned when alpha = 1) + * @param alpha The interpolation-factor + * @return The mixed value */ - frustumEdgeFalloff: number; - private _light; + static Mix(a: number, b: number, alpha: number): number; + static Instantiate(className: string): any; + static SetImmediate(action: () => void): void; + static IsExponentOfTwo(value: number): boolean; /** - * Returns the associated light object. + * Find the next highest power of two. + * @param x Number to start search from. + * @return Next highest power of two. */ - getLight(): IShadowLight; - forceBackFacesOnly: boolean; - private _scene; - private _lightDirection; - private _effect; - private _viewMatrix; - private _projectionMatrix; - private _transformMatrix; - private _worldViewProjection; - private _cachedPosition; - private _cachedDirection; - private _cachedDefines; - private _currentRenderID; - private _downSamplePostprocess; - private _boxBlurPostprocess; - private _kernelBlurXPostprocess; - private _kernelBlurYPostprocess; - private _blurPostProcesses; - private _mapSize; - private _currentFaceIndex; - private _currentFaceIndexCache; - private _textureType; - private _isCube; - private _defaultTextureMatrix; + static CeilingPOT(x: number): number; /** - * Creates a ShadowGenerator object. - * A ShadowGenerator is the required tool to use the shadows. - * Each light casting shadows needs to use its own ShadowGenerator. - * Required parameters : - * - `mapSize` (integer): the size of the texture what stores the shadows. Example : 1024. - * - `light`: the light object generating the shadows. - * - `useFullFloatFirst`: by default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture. - * Documentation : http://doc.babylonjs.com/tutorials/shadows + * Find the next lowest power of two. + * @param x Number to start search from. + * @return Next lowest power of two. */ - constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean); - private _initializeGenerator(); - private _initializeShadowMap(); - private _initializeBlurRTTAndPostProcesses(); - private _renderForShadowMap(opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes); - private _renderSubMeshForShadowMap(subMesh); - private _applyFilterValues(); + static FloorPOT(x: number): number; /** - * Force shader compilation including textures ready check + * Find the nearest power of two. + * @param x Number to start search from. + * @return Next nearest power of two. */ - forceCompilation(onCompiled: (generator: ShadowGenerator) => void, options?: { - useInstances: boolean; - }): void; + static NearestPOT(x: number): number; + static GetExponentOfTwo(value: number, max: number, mode?: number): number; + static GetFilename(path: string): string; + static GetDOMTextContent(element: HTMLElement): string; + static ToDegrees(angle: number): number; + static ToRadians(angle: number): number; + static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string; + static ExtractMinAndMaxIndexed(positions: number[] | Float32Array, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Vector2): { + minimum: Vector3; + maximum: Vector3; + }; + static ExtractMinAndMax(positions: number[] | Float32Array, start: number, count: number, bias?: Vector2, stride?: number): { + minimum: Vector3; + maximum: Vector3; + }; + static Vector2ArrayFeeder(array: Array | Float32Array): (i: number) => Vector2; + static ExtractMinAndMaxVector2(feeder: (index: number) => Vector2, bias?: Vector2): { + minimum: Vector2; + maximum: Vector2; + }; + static MakeArray(obj: any, allowsNullUndefined?: boolean): Array; + static GetPointerPrefix(): string; /** - * Boolean : true when the ShadowGenerator is finally computed. + * @param func - the function to be called + * @param requester - the object that will request the next frame. Falls back to window. */ - isReady(subMesh: SubMesh, useInstances: boolean): boolean; + static QueueNewFrame(func: any, requester?: any): void; + static RequestFullscreen(element: any): void; + static ExitFullscreen(): void; + static SetCorsBehavior(url: string, img: HTMLImageElement): void; + static CleanUrl(url: string): string; + static LoadImage(url: any, onload: any, onerror: any, database: any): HTMLImageElement; + static LoadFile(url: string, callback: (data: any) => void, progressCallBack?: (data: any) => void, database?: any, useArrayBuffer?: boolean, onError?: (request: XMLHttpRequest) => void): void; /** - * This creates the defines related to the standard BJS materials. + * Load a script (identified by an url). When the url returns, the + * content of this file is added into a new script element, attached to the DOM (body element) */ - prepareDefines(defines: MaterialDefines, lightIndex: number): void; + static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: () => void): void; + static ReadFileAsDataURL(fileToLoad: any, callback: any, progressCallback: any): void; + static ReadFile(fileToLoad: any, callback: any, progressCallBack: any, useArrayBuffer?: boolean): void; + static FileAsURL(content: string): string; + static Format(value: number, decimals?: number): string; + static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void; + static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void; + static IsEmpty(obj: any): boolean; + static RegisterTopRootEvents(events: { + name: string; + handler: EventListener; + }[]): void; + static UnregisterTopRootEvents(events: { + name: string; + handler: EventListener; + }[]): void; + static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string): void; + static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string): void; + static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void; + static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number): void; + static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean; /** - * This binds shadow lights related to the standard BJS materials. - * It implies the unifroms available on the materials are the standard BJS ones. + * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523 + * Be aware Math.random() could cause collisions, but: + * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide" */ - bindShadowLight(lightIndex: string, effect: Effect): void; + static RandomId(): string; + private static _NoneLogLevel; + private static _MessageLogLevel; + private static _WarningLogLevel; + private static _ErrorLogLevel; + private static _LogCache; + static errorsCount: number; + static OnNewCacheEntry: (entry: string) => void; + static readonly NoneLogLevel: number; + static readonly MessageLogLevel: number; + static readonly WarningLogLevel: number; + static readonly ErrorLogLevel: number; + static readonly AllLogLevel: number; + private static _AddLogEntry(entry); + private static _FormatMessage(message); + private static _LogDisabled(message); + private static _LogEnabled(message); + private static _WarnDisabled(message); + private static _WarnEnabled(message); + private static _ErrorDisabled(message); + private static _ErrorEnabled(message); + static Log: (message: string) => void; + static Warn: (message: string) => void; + static Error: (message: string) => void; + static readonly LogCache: string; + static ClearLogCache(): void; + static LogLevels: number; + private static _PerformanceNoneLogLevel; + private static _PerformanceUserMarkLogLevel; + private static _PerformanceConsoleLogLevel; + private static _performance; + static readonly PerformanceNoneLogLevel: number; + static readonly PerformanceUserMarkLogLevel: number; + static readonly PerformanceConsoleLogLevel: number; + static PerformanceLogLevel: number; + static _StartPerformanceCounterDisabled(counterName: string, condition?: boolean): void; + static _EndPerformanceCounterDisabled(counterName: string, condition?: boolean): void; + static _StartUserMark(counterName: string, condition?: boolean): void; + static _EndUserMark(counterName: string, condition?: boolean): void; + static _StartPerformanceConsole(counterName: string, condition?: boolean): void; + static _EndPerformanceConsole(counterName: string, condition?: boolean): void; + static StartPerformanceCounter: (counterName: string, condition?: boolean) => void; + static EndPerformanceCounter: (counterName: string, condition?: boolean) => void; + static readonly Now: number; /** - * Returns a Matrix object : the updated transformation matrix. + * This method will return the name of the class used to create the instance of the given object. + * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator. + * @param object the object to get the class name from + * @return the name of the class, will be "object" for a custom data type not using the @className decorator */ - getTransformMatrix(): Matrix; - recreateShadowMap(): void; - private _disposeBlurPostProcesses(); - private _disposeRTTandPostProcesses(); + static GetClassName(object: any, isType?: boolean): string; + static first(array: Array, predicate: (item: T) => boolean): T; /** - * Disposes the ShadowGenerator. - * Returns nothing. + * This method will return the name of the full name of the class, including its owning module (if any). + * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator or implementing a method getClassName():string (in which case the module won't be specified). + * @param object the object to get the class name from + * @return a string that can have two forms: "moduleName.className" if module was specified when the class' Name was registered or "className" if there was not module specified. */ - dispose(): void; + static getFullClassName(object: any, isType?: boolean): string; /** - * Serializes the ShadowGenerator and returns a serializationObject. + * This method can be used with hashCodeFromStream when your input is an array of values that are either: number, string, boolean or custom type implementing the getHashCode():number method. + * @param array */ - serialize(): any; + static arrayOrStringFeeder(array: any): (i: number) => number; /** - * Parses a serialized ShadowGenerator and returns a new ShadowGenerator. + * Compute the hashCode of a stream of number + * To compute the HashCode on a string or an Array of data types implementing the getHashCode() method, use the arrayOrStringFeeder method. + * @param feeder a callback that will be called until it returns null, each valid returned values will be used to compute the hash code. + * @return the hash code computed */ - static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator; - } -} - -declare module BABYLON { - class BaseTexture { - static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number; - name: string; - private _hasAlpha; - hasAlpha: boolean; - getAlphaFromRGB: boolean; - level: number; - coordinatesIndex: number; - private _coordinatesMode; - coordinatesMode: number; - wrapU: number; - wrapV: number; - anisotropicFilteringLevel: number; - isCube: boolean; - gammaSpace: boolean; - invertZ: boolean; - lodLevelInAlpha: boolean; - lodGenerationOffset: number; - lodGenerationScale: number; - isRenderTarget: boolean; - readonly uid: string; - toString(): string; - getClassName(): string; - animations: Animation[]; - /** - * An event triggered when the texture is disposed. - * @type {BABYLON.Observable} - */ - onDisposeObservable: Observable; - private _onDisposeObserver; - onDispose: () => void; - delayLoadState: number; - _cachedAnisotropicFilteringLevel: number; - private _scene; - _texture: WebGLTexture; - private _uid; - readonly isBlocking: boolean; - constructor(scene: Scene); - getScene(): Scene; - getTextureMatrix(): Matrix; - getReflectionTextureMatrix(): Matrix; - getInternalTexture(): WebGLTexture; - isReadyOrNotBlocking(): boolean; - isReady(): boolean; - getSize(): ISize; - getBaseSize(): ISize; - scale(ratio: number): void; - readonly canRescale: boolean; - _removeFromCache(url: string, noMipmap: boolean): void; - _getFromCache(url: string, noMipmap: boolean, sampling?: number): WebGLTexture; - delayLoad(): void; - clone(): BaseTexture; - readonly textureType: number; - readonly textureFormat: number; - readPixels(faceIndex?: number): ArrayBufferView; - releaseInternalTexture(): void; - sphericalPolynomial: SphericalPolynomial; - readonly _lodTextureHigh: BaseTexture; - readonly _lodTextureMid: BaseTexture; - readonly _lodTextureLow: BaseTexture; - dispose(): void; - serialize(): any; - static WhenAllReady(textures: BaseTexture[], callback: () => void): void; + static hashCodeFromStream(feeder: (index: number) => number): number; } -} - -declare module BABYLON { /** - * This represents a color grading texture. This acts as a lookup table LUT, useful during post process - * It can help converting any input color in a desired output one. This can then be used to create effects - * from sepia, black and white to sixties or futuristic rendering... + * This class is used to track a performance counter which is number based. + * The user has access to many properties which give statistics of different nature * - * The only supported format is currently 3dl. - * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table/ + * The implementer can track two kinds of Performance Counter: time and count + * For time you can optionally call fetchNewFrame() to notify the start of a new frame to monitor, then call beginMonitoring() to start and endMonitoring() to record the lapsed time. endMonitoring takes a newFrame parameter for you to specify if the monitored time should be set for a new frame or accumulated to the current frame being monitored. + * For count you first have to call fetchNewFrame() to notify the start of a new frame to monitor, then call addCount() how many time required to increment the count value you monitor. */ - class ColorGradingTexture extends BaseTexture { + class PerfCounter { + static Enabled: boolean; /** - * The current internal texture size. + * Returns the smallest value ever */ - private _size; + readonly min: number; /** - * The current texture matrix. (will always be identity in color grading texture) + * Returns the biggest value ever */ - private _textureMatrix; + readonly max: number; /** - * The texture URL. + * Returns the average value since the performance counter is running */ - url: string; + readonly average: number; /** - * Empty line regex stored for GC. + * Returns the average value of the last second the counter was monitored */ - private static _noneEmptyLineRegex; + readonly lastSecAverage: number; /** - * Instantiates a ColorGradingTexture from the following parameters. - * - * @param url The location of the color gradind data (currently only supporting 3dl) - * @param scene The scene the texture will be used in + * Returns the current value */ - constructor(url: string, scene: Scene); + readonly current: number; + readonly total: number; + constructor(); /** - * Returns the texture matrix used in most of the material. - * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in). + * Call this method to start monitoring a new frame. + * This scenario is typically used when you accumulate monitoring time many times for a single frame, you call this method at the start of the frame, then beginMonitoring to start recording and endMonitoring(false) to accumulated the recorded time to the PerfCounter or addCount() to accumulate a monitored count. */ - getTextureMatrix(): Matrix; + fetchNewFrame(): void; + /** + * Call this method to monitor a count of something (e.g. mesh drawn in viewport count) + * @param newCount the count value to add to the monitored count + * @param fetchResult true when it's the last time in the frame you add to the counter and you wish to update the statistics properties (min/max/average), false if you only want to update statistics. + */ + addCount(newCount: number, fetchResult: boolean): void; + /** + * Start monitoring this performance counter + */ + beginMonitoring(): void; + /** + * Compute the time lapsed since the previous beginMonitoring() call. + * @param newFrame true by default to fetch the result and monitor a new frame, if false the time monitored will be added to the current frame counter + */ + endMonitoring(newFrame?: boolean): void; + private _fetchResult(); + private _startMonitoringTime; + private _min; + private _max; + private _average; + private _current; + private _totalValueCount; + private _totalAccumulated; + private _lastSecAverage; + private _lastSecAccumulated; + private _lastSecTime; + private _lastSecValueCount; + } + /** + * Use this className as a decorator on a given class definition to add it a name and optionally its module. + * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name. + * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified + * @param name The name of the class, case should be preserved + * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved. + */ + function className(name: string, module?: string): (target: Object) => void; + /** + * An implementation of a loop for asynchronous functions. + */ + class AsyncLoop { + iterations: number; + private _fn; + private _successCallback; + index: number; + private _done; /** - * Occurs when the file being loaded is a .3dl LUT file. + * Constroctor. + * @param iterations the number of iterations. + * @param _fn the function to run each iteration + * @param _successCallback the callback that will be called upon succesful execution + * @param offset starting offset. */ - private load3dlTexture(); + constructor(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number); /** - * Starts the loading process of the texture. + * Execute the next iteration. Must be called after the last iteration was finished. */ - private loadTexture(); + executeNext(): void; /** - * Clones the color gradind texture. + * Break the loop and run the success callback. */ - clone(): ColorGradingTexture; + breakLoop(): void; /** - * Called during delayed load for textures. + * Helper function */ - delayLoad(): void; + static Run(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number): AsyncLoop; /** - * Parses a color grading texture serialized by Babylon. - * @param parsedTexture The texture information being parsedTexture - * @param scene The scene to load the texture in - * @param rootUrl The root url of the data assets to load - * @return A color gradind texture + * A for-loop that will run a given number of iterations synchronous and the rest async. + * @param iterations total number of iterations + * @param syncedIterations number of synchronous iterations in each async iteration. + * @param fn the function to call each iteration. + * @param callback a success call back that will be called when iterating stops. + * @param breakFunction a break condition (optional) + * @param timeout timeout settings for the setTimeout function. default - 0. + * @constructor */ - static Parse(parsedTexture: any, scene: Scene, rootUrl: string): ColorGradingTexture; + static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): void; + } +} + +declare module BABYLON { + enum JoystickAxis { + X = 0, + Y = 1, + Z = 2, + } + class VirtualJoystick { + reverseLeftRight: boolean; + reverseUpDown: boolean; + deltaPosition: Vector3; + pressed: boolean; + private static _globalJoystickIndex; + private static vjCanvas; + private static vjCanvasContext; + private static vjCanvasWidth; + private static vjCanvasHeight; + private static halfWidth; + private static halfHeight; + private _action; + private _axisTargetedByLeftAndRight; + private _axisTargetedByUpAndDown; + private _joystickSensibility; + private _inversedSensibility; + private _rotationSpeed; + private _inverseRotationSpeed; + private _rotateOnAxisRelativeToMesh; + private _joystickPointerID; + private _joystickColor; + private _joystickPointerPos; + private _joystickPreviousPointerPos; + private _joystickPointerStartPos; + private _deltaJoystickVector; + private _leftJoystick; + private _joystickIndex; + private _touches; + private _onPointerDownHandlerRef; + private _onPointerMoveHandlerRef; + private _onPointerUpHandlerRef; + private _onPointerOutHandlerRef; + private _onResize; + constructor(leftJoystick?: boolean); + setJoystickSensibility(newJoystickSensibility: number): void; + private _onPointerDown(e); + private _onPointerMove(e); + private _onPointerUp(e); /** - * Serializes the LUT texture to json format. - */ - serialize(): any; + * Change the color of the virtual joystick + * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000") + */ + setJoystickColor(newColor: string): void; + setActionOnTouch(action: () => any): void; + setAxisForLeftRight(axis: JoystickAxis): void; + setAxisForUpDown(axis: JoystickAxis): void; + private _clearCanvas(); + private _drawVirtualJoystick(); + releaseCanvas(): void; + } +} + +declare module BABYLON { + class ArcRotateCameraGamepadInput implements ICameraInput { + camera: ArcRotateCamera; + gamepad: Gamepad; + private _gamepads; + gamepadRotationSensibility: number; + gamepadMoveSensibility: number; + attachControl(element: HTMLElement, noPreventDefault?: boolean): void; + detachControl(element: HTMLElement): void; + checkInputs(): void; + private _onNewGameConnected(gamepad); + getClassName(): string; + getSimpleName(): string; + } +} + +declare module BABYLON { + class ArcRotateCameraKeyboardMoveInput implements ICameraInput { + camera: ArcRotateCamera; + private _keys; + private _onKeyDown; + private _onKeyUp; + private _onLostFocus; + keysUp: number[]; + keysDown: number[]; + keysLeft: number[]; + keysRight: number[]; + attachControl(element: HTMLElement, noPreventDefault?: boolean): void; + detachControl(element: HTMLElement): void; + checkInputs(): void; + getClassName(): string; + getSimpleName(): string; + } +} + +declare module BABYLON { + class ArcRotateCameraMouseWheelInput implements ICameraInput { + camera: ArcRotateCamera; + private _wheel; + private _observer; + wheelPrecision: number; + attachControl(element: HTMLElement, noPreventDefault?: boolean): void; + detachControl(element: HTMLElement): void; + getClassName(): string; + getSimpleName(): string; + } +} + +declare module BABYLON { + class ArcRotateCameraPointersInput implements ICameraInput { + camera: ArcRotateCamera; + buttons: number[]; + angularSensibilityX: number; + angularSensibilityY: number; + pinchPrecision: number; + panningSensibility: number; + private _isPanClick; + pinchInwards: boolean; + private _pointerInput; + private _observer; + private _onMouseMove; + private _onGestureStart; + private _onGesture; + private _MSGestureHandler; + private _onLostFocus; + private _onContextMenu; + attachControl(element: HTMLElement, noPreventDefault?: boolean): void; + detachControl(element: HTMLElement): void; + getClassName(): string; + getSimpleName(): string; + } +} + +declare module BABYLON { + class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput { + camera: ArcRotateCamera; + alphaCorrection: number; + betaCorrection: number; + gammaCorrection: number; + private _alpha; + private _beta; + private _gamma; + private _dirty; + private _offsetOrientation; + private _deviceOrientationHandler; + constructor(); + attachControl(element: HTMLElement, noPreventDefault?: boolean): void; + _onOrientationEvent(evt: DeviceOrientationEvent): void; + checkInputs(): void; + detachControl(element: HTMLElement): void; + getClassName(): string; + getSimpleName(): string; + } +} + +declare module BABYLON { + class FreeCameraDeviceOrientationInput implements ICameraInput { + private _camera; + private _screenOrientationAngle; + private _constantTranform; + private _screenQuaternion; + private _alpha; + private _beta; + private _gamma; + constructor(); + camera: FreeCamera; + attachControl(element: HTMLElement, noPreventDefault?: boolean): void; + private _orientationChanged; + private _deviceOrientation; + detachControl(element: HTMLElement): void; + checkInputs(): void; + getClassName(): string; + getSimpleName(): string; + } +} + +declare module BABYLON { + class FreeCameraGamepadInput implements ICameraInput { + camera: FreeCamera; + gamepad: Gamepad; + private _gamepads; + gamepadAngularSensibility: number; + gamepadMoveSensibility: number; + private _cameraTransform; + private _deltaTransform; + private _vector3; + private _vector2; + attachControl(element: HTMLElement, noPreventDefault?: boolean): void; + detachControl(element: HTMLElement): void; + checkInputs(): void; + private _onNewGameConnected(gamepad); + getClassName(): string; + getSimpleName(): string; + } +} + +declare module BABYLON { + class FreeCameraKeyboardMoveInput implements ICameraInput { + camera: FreeCamera; + private _keys; + private _onKeyDown; + private _onKeyUp; + keysUp: number[]; + keysDown: number[]; + keysLeft: number[]; + keysRight: number[]; + attachControl(element: HTMLElement, noPreventDefault?: boolean): void; + detachControl(element: HTMLElement): void; + checkInputs(): void; + getClassName(): string; + _onLostFocus(e: FocusEvent): void; + getSimpleName(): string; } } declare module BABYLON { - class CubeTexture extends BaseTexture { - url: string; - coordinatesMode: number; - private _noMipmap; - private _files; - private _extensions; - private _textureMatrix; - private _format; - private _prefiltered; - static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture; - static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any): CubeTexture; - constructor(rootUrl: string, scene: Scene, extensions?: string[], noMipmap?: boolean, files?: string[], onLoad?: () => void, onError?: () => void, format?: number, prefiltered?: boolean, forcedExtension?: any); - delayLoad(): void; - getReflectionTextureMatrix(): Matrix; - setReflectionTextureMatrix(value: Matrix): void; - static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture; - clone(): CubeTexture; + class FreeCameraMouseInput implements ICameraInput { + touchEnabled: boolean; + camera: FreeCamera; + buttons: number[]; + angularSensibility: number; + private _pointerInput; + private _onMouseMove; + private _observer; + private previousPosition; + constructor(touchEnabled?: boolean); + attachControl(element: HTMLElement, noPreventDefault?: boolean): void; + detachControl(element: HTMLElement): void; + getClassName(): string; + getSimpleName(): string; } } declare module BABYLON { - class DynamicTexture extends Texture { - private _generateMipMaps; - private _canvas; - private _context; - constructor(name: string, options: any, scene: Scene, generateMipMaps: boolean, samplingMode?: number, format?: number); - readonly canRescale: boolean; - private _recreate(textureSize); - scale(ratio: number): void; - scaleTo(width: number, height: number): void; - getContext(): CanvasRenderingContext2D; - clear(): void; - update(invertY?: boolean): void; - drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void; - clone(): DynamicTexture; + class FreeCameraTouchInput implements ICameraInput { + camera: FreeCamera; + private _offsetX; + private _offsetY; + private _pointerCount; + private _pointerPressed; + private _pointerInput; + private _observer; + private _onLostFocus; + touchAngularSensibility: number; + touchMoveSensibility: number; + attachControl(element: HTMLElement, noPreventDefault?: boolean): void; + detachControl(element: HTMLElement): void; + checkInputs(): void; + getClassName(): string; + getSimpleName(): string; } } declare module BABYLON { - /** - * This represents a texture coming from an HDR input. - * - * The only supported format is currently panorama picture stored in RGBE format. - * Example of such files can be found on HDRLib: http://hdrlib.com/ - */ - class HDRCubeTexture extends BaseTexture { - private static _facesMapping; - private _useInGammaSpace; - private _generateHarmonics; - private _noMipmap; - private _extensions; - private _textureMatrix; - private _size; - private _usePMREMGenerator; - private _isBABYLONPreprocessed; - private _onLoad; - private _onError; - /** - * The texture URL. - */ - url: string; - /** - * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. - */ - coordinatesMode: number; - /** - * Specifies wether the texture has been generated through the PMREMGenerator tool. - * This is usefull at run time to apply the good shader. - */ - isPMREM: boolean; - protected _isBlocking: boolean; - /** - * Gets wether or not the texture is blocking during loading. - */ - /** - * Sets wether or not the texture is blocking during loading. - */ - isBlocking: boolean; - /** - * Instantiates an HDRTexture from the following parameters. - * - * @param url The location of the HDR raw data (Panorama stored in RGBE format) - * @param scene The scene the texture will be used in - * @param size The cubemap desired size (the more it increases the longer the generation will be) If the size is omitted this implies you are using a preprocessed cubemap. - * @param noMipmap Forces to not generate the mipmap if true - * @param generateHarmonics Specifies wether you want to extract the polynomial harmonics during the generation process - * @param useInGammaSpace Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) - * @param usePMREMGenerator Specifies wether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time. - */ - constructor(url: string, scene: Scene, size?: number, noMipmap?: boolean, generateHarmonics?: boolean, useInGammaSpace?: boolean, usePMREMGenerator?: boolean, onLoad?: () => void, onError?: () => void); - /** - * Occurs when the file is a preprocessed .babylon.hdr file. - */ - private loadBabylonTexture(); - /** - * Occurs when the file is raw .hdr file. - */ - private loadHDRTexture(); - /** - * Starts the loading process of the texture. - */ - private loadTexture(); - clone(): HDRCubeTexture; - delayLoad(): void; - getReflectionTextureMatrix(): Matrix; - setReflectionTextureMatrix(value: Matrix): void; - static Parse(parsedTexture: any, scene: Scene, rootUrl: string): HDRCubeTexture; - serialize(): any; - /** - * Saves as a file the data contained in the texture in a binary format. - * This can be used to prevent the long loading tie associated with creating the seamless texture as well - * as the spherical used in the lighting. - * @param url The HDR file url. - * @param size The size of the texture data to generate (one of the cubemap face desired width). - * @param onError Method called if any error happens during download. - * @return The packed binary data. - */ - static generateBabylonHDROnDisk(url: string, size: number, onError?: (() => void)): void; - /** - * Serializes the data contained in the texture in a binary format. - * This can be used to prevent the long loading tie associated with creating the seamless texture as well - * as the spherical used in the lighting. - * @param url The HDR file url. - * @param size The size of the texture data to generate (one of the cubemap face desired width). - * @param onError Method called if any error happens during download. - * @return The packed binary data. - */ - static generateBabylonHDR(url: string, size: number, callback: ((ArrayBuffer: ArrayBuffer) => void), onError?: (() => void)): void; + class FreeCameraVirtualJoystickInput implements ICameraInput { + camera: FreeCamera; + private _leftjoystick; + private _rightjoystick; + getLeftJoystick(): VirtualJoystick; + getRightJoystick(): VirtualJoystick; + checkInputs(): void; + attachControl(element: HTMLElement, noPreventDefault?: boolean): void; + detachControl(element: HTMLElement): void; + getClassName(): string; + getSimpleName(): string; } } declare module BABYLON { - class MapTexture extends Texture { - private _rectPackingMap; - private _size; - private _replacedViewport; - constructor(name: string, scene: Scene, size: ISize, samplingMode?: number, useMipMap?: boolean, margin?: number); - /** - * Allocate a rectangle of a given size in the texture map - * @param size the size of the rectangle to allocation - * @return the PackedRect instance corresponding to the allocated rect or null is there was not enough space to allocate it. - */ - allocateRect(size: Size): PackedRect; - /** - * Free a given rectangle from the texture map - * @param rectInfo the instance corresponding to the rect to free. - */ - freeRect(rectInfo: PackedRect): void; - /** - * Return the available space in the range of [O;1]. 0 being not space left at all, 1 being an empty texture map. - * This is the cumulated space, not the biggest available surface. Due to fragmentation you may not allocate a rect corresponding to this surface. - * @returns {} - */ - readonly freeSpace: number; - /** - * Bind the texture to the rendering engine to render in the zone of a given rectangle. - * Use this method when you want to render into the texture map with a clipspace set to the location and size of the given rect. - * Don't forget to call unbindTexture when you're done rendering - * @param rect the zone to render to - * @param clear true to clear the portion's color/depth data - */ - bindTextureForRect(rect: PackedRect, clear: boolean): void; - /** - * Bind the texture to the rendering engine to render in the zone of the given size at the given position. - * Use this method when you want to render into the texture map with a clipspace set to the location and size of the given rect. - * Don't forget to call unbindTexture when you're done rendering - * @param pos the position into the texture - * @param size the portion to fit the clip space to - * @param clear true to clear the portion's color/depth data - */ - bindTextureForPosSize(pos: Vector2, size: Size, clear: boolean): void; - /** - * Unbind the texture map from the rendering engine. - * Call this method when you're done rendering. A previous call to bindTextureForRect has to be made. - * @param dumpForDebug if set to true the content of the texture map will be dumped to a picture file that will be sent to the internet browser. - */ - unbindTexture(dumpForDebug?: boolean): void; - readonly canRescale: boolean; - clone(): MapTexture; + class VRCameraMetrics { + hResolution: number; + vResolution: number; + hScreenSize: number; + vScreenSize: number; + vScreenCenter: number; + eyeToScreenDistance: number; + lensSeparationDistance: number; + interpupillaryDistance: number; + distortionK: number[]; + chromaAbCorrection: number[]; + postProcessScaleFactor: number; + lensCenterOffset: number; + compensateDistortion: boolean; + readonly aspectRatio: number; + readonly aspectRatioFov: number; + readonly leftHMatrix: Matrix; + readonly rightHMatrix: Matrix; + readonly leftPreViewMatrix: Matrix; + readonly rightPreViewMatrix: Matrix; + static GetDefault(): VRCameraMetrics; + } +} + +declare module BABYLON { + class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera { + constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics); + getClassName(): string; + } + class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera { + constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics); + getClassName(): string; + } + class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera { + constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics); + getClassName(): string; } } +declare var HMDVRDevice: any; +declare var VRDisplay: any; +declare var VRFrameData: any; declare module BABYLON { - class MirrorTexture extends RenderTargetTexture { - mirrorPlane: Plane; - private _transformMatrix; - private _mirrorMatrix; - private _savedViewMatrix; - private _blurX; - private _blurY; - private _blurKernelX; - private _blurKernelY; - private _blurRatio; - blurRatio: number; - blurKernel: number; - blurKernelX: number; - blurKernelY: number; - constructor(name: string, size: any, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean); - private _preparePostProcesses(); - clone(): MirrorTexture; - serialize(): any; + /** + * This is a copy of VRPose. + * IMPORTANT!! The data is right-hand data. + * @export + * @interface DevicePose + */ + interface DevicePose { + readonly position?: Float32Array; + readonly linearVelocity?: Float32Array; + readonly linearAcceleration?: Float32Array; + readonly orientation?: Float32Array; + readonly angularVelocity?: Float32Array; + readonly angularAcceleration?: Float32Array; + } + interface PoseControlled { + position: Vector3; + rotationQuaternion: Quaternion; + devicePosition?: Vector3; + deviceRotationQuaternion: Quaternion; + rawPose: DevicePose; + deviceScaleFactor: number; + updateFromDevice(poseData: DevicePose): any; + } + interface WebVROptions { + trackPosition?: boolean; + positionScale?: number; + displayName?: string; + controllerMeshes?: boolean; + defaultLightningOnControllers?: boolean; + } + class WebVRFreeCamera extends FreeCamera implements PoseControlled { + private webVROptions; + _vrDevice: any; + rawPose: DevicePose; + private _vrEnabled; + private _specsVersion; + private _attached; + private _oldSize; + private _oldHardwareScaleFactor; + private _frameData; + private _quaternionCache; + private _positionOffset; + protected _descendants: Array; + devicePosition: Vector3; + deviceRotationQuaternion: any; + deviceScaleFactor: number; + controllers: Array; + nonVRControllers: Array; + private _onControllersAttached; + private _onNonVRControllerAttached; + rigParenting: boolean; + private _lightOnControllers; + constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions); + onControllersAttached: (controllers: Array) => void; + onNonVRControllerAttached: (controller: Gamepad) => void; + getControllerByName(name: string): WebVRController; + private _leftController; + readonly leftController: WebVRController; + private _rightController; + readonly rightController: WebVRController; + getForwardRay(length?: number): Ray; + _checkInputs(): void; + updateFromDevice(poseData: DevicePose): void; + /** + * WebVR's attach control will start broadcasting frames to the device. + * Note that in certain browsers (chrome for example) this function must be called + * within a user-interaction callback. Example: + *
 scene.onPointerDown = function() { camera.attachControl(canvas); }
+ * + * @param {HTMLElement} element + * @param {boolean} [noPreventDefault] + * + * @memberOf WebVRFreeCamera + */ + attachControl(element: HTMLElement, noPreventDefault?: boolean): void; + detachControl(element: HTMLElement): void; + getClassName(): string; + resetToCurrentRotation(): void; + _updateRigCameras(): void; + /** + * This function is called by the two RIG cameras. + * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance) + */ + protected _getWebVRViewMatrix(): Matrix; + protected _getWebVRProjectionMatrix(): Matrix; + initControllers(): void; } } declare module BABYLON { - interface IMultiRenderTargetOptions { - generateMipMaps: boolean; - types: number[]; - samplingModes: number[]; - generateDepthBuffer: boolean; - generateStencilBuffer: boolean; - generateDepthTexture: boolean; - textureCount: number; + interface IOctreeContainer { + blocks: Array>; } - class MultiRenderTarget extends RenderTargetTexture { - private _webGLTextures; - private _textures; - private _count; - readonly isSupported: boolean; - private _multiRenderTargetOptions; - readonly textures: Texture[]; - readonly depthTexture: Texture; - constructor(name: string, size: any, count: number, scene: Scene, options?: any); - private _createInternalTextures(); - samples: number; - resize(size: any): void; - dispose(): void; - releaseInternalTextures(): void; + class Octree { + maxDepth: number; + blocks: Array>; + dynamicContent: T[]; + private _maxBlockCapacity; + private _selectionContent; + private _creationFunc; + constructor(creationFunc: (entry: T, block: OctreeBlock) => void, maxBlockCapacity?: number, maxDepth?: number); + update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void; + addMesh(entry: T): void; + select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray; + intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray; + intersectsRay(ray: Ray): SmartArray; + static _CreateBlocks(worldMin: Vector3, worldMax: Vector3, entries: T[], maxBlockCapacity: number, currentDepth: number, maxDepth: number, target: IOctreeContainer, creationFunc: (entry: T, block: OctreeBlock) => void): void; + static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock) => void; + static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock) => void; } } declare module BABYLON { - class RawTexture extends Texture { - format: number; - constructor(data: ArrayBufferView, width: number, height: number, format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number); - update(data: ArrayBufferView): void; - static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture; - static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture; - static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture; - static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture; - static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture; + class OctreeBlock { + entries: T[]; + blocks: Array>; + private _depth; + private _maxDepth; + private _capacity; + private _minPoint; + private _maxPoint; + private _boundingVectors; + private _creationFunc; + constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock) => void); + readonly capacity: number; + readonly minPoint: Vector3; + readonly maxPoint: Vector3; + addEntry(entry: T): void; + addEntries(entries: T[]): void; + select(frustumPlanes: Plane[], selection: SmartArray, allowDuplicate?: boolean): void; + intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArray, allowDuplicate?: boolean): void; + intersectsRay(ray: Ray, selection: SmartArray): void; + createInnerBlocks(): void; } } declare module BABYLON { /** - * Creates a refraction texture used by refraction channel of the standard material. - * @param name the texture name - * @param size size of the underlying texture - * @param scene root scene - */ - class RefractionTexture extends RenderTargetTexture { - refractionPlane: Plane; - depth: number; - constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean); - clone(): RefractionTexture; + * Interface to implement to create a shadow generator compatible with BJS. + */ + interface IShadowGenerator { + getShadowMap(): RenderTargetTexture; + getShadowMapForRendering(): RenderTargetTexture; + isReady(subMesh: SubMesh, useInstances: boolean): boolean; + prepareDefines(defines: MaterialDefines, lightIndex: number): void; + bindShadowLight(lightIndex: string, effect: Effect): void; + getTransformMatrix(): Matrix; + recreateShadowMap(): void; + forceCompilation(onCompiled: (generator: ShadowGenerator) => void, options?: { + useInstances: boolean; + }): void; serialize(): any; + dispose(): void; } -} - -declare module BABYLON { - interface IRenderTargetOptions { - generateMipMaps: boolean; - type: number; - samplingMode: number; - generateDepthBuffer: boolean; - generateStencilBuffer: boolean; - } - class RenderTargetTexture extends Texture { - isCube: boolean; - static _REFRESHRATE_RENDER_ONCE: number; - static _REFRESHRATE_RENDER_ONEVERYFRAME: number; - static _REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number; - static readonly REFRESHRATE_RENDER_ONCE: number; - static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number; - static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number; + class ShadowGenerator implements IShadowGenerator { + private static _FILTER_NONE; + private static _FILTER_EXPONENTIALSHADOWMAP; + private static _FILTER_POISSONSAMPLING; + private static _FILTER_BLUREXPONENTIALSHADOWMAP; + private static _FILTER_CLOSEEXPONENTIALSHADOWMAP; + private static _FILTER_BLURCLOSEEXPONENTIALSHADOWMAP; + static readonly FILTER_NONE: number; + static readonly FILTER_POISSONSAMPLING: number; + static readonly FILTER_EXPONENTIALSHADOWMAP: number; + static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number; + static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number; + static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number; + private _bias; + bias: number; + private _blurBoxOffset; + blurBoxOffset: number; + private _blurScale; + blurScale: number; + private _blurKernel; + blurKernel: number; + private _useKernelBlur; + useKernelBlur: boolean; + private _depthScale; + depthScale: number; + private _filter; + filter: number; + usePoissonSampling: boolean; + useVarianceShadowMap: boolean; + useBlurVarianceShadowMap: boolean; + useExponentialShadowMap: boolean; + useBlurExponentialShadowMap: boolean; + useCloseExponentialShadowMap: boolean; + useBlurCloseExponentialShadowMap: boolean; + private _darkness; + /** + * Returns the darkness value (float). + */ + getDarkness(): number; /** - * Use this predicate to dynamically define the list of mesh you want to render. - * If set, the renderList property will be overwritten. - */ - renderListPredicate: (AbstractMesh: AbstractMesh) => boolean; + * Sets the ShadowGenerator darkness value (float <= 1.0). + * Returns the ShadowGenerator. + */ + setDarkness(darkness: number): ShadowGenerator; + private _transparencyShadow; /** - * Use this list to define the list of mesh you want to render. - */ - renderList: AbstractMesh[]; - renderParticles: boolean; - renderSprites: boolean; - coordinatesMode: number; - activeCamera: Camera; - customRenderFunction: (opaqueSubMeshes: SmartArray, transparentSubMeshes: SmartArray, alphaTestSubMeshes: SmartArray, beforeTransparents?: () => void) => void; - useCameraPostProcesses: boolean; - private _postProcessManager; - private _postProcesses; + * Sets the ability to have transparent shadow (boolean). + * Returns the ShadowGenerator. + */ + setTransparencyShadow(hasShadow: boolean): ShadowGenerator; + private _shadowMap; + private _shadowMap2; /** - * An event triggered when the texture is unbind. - * @type {BABYLON.Observable} - */ - onBeforeBindObservable: Observable; + * Returns a RenderTargetTexture object : the shadow map texture. + */ + getShadowMap(): RenderTargetTexture; /** - * An event triggered when the texture is unbind. - * @type {BABYLON.Observable} - */ - onAfterUnbindObservable: Observable; - private _onAfterUnbindObserver; - onAfterUnbind: () => void; + * Returns the most ready computed shadow map as a RenderTargetTexture object. + */ + getShadowMapForRendering(): RenderTargetTexture; /** - * An event triggered before rendering the texture - * @type {BABYLON.Observable} - */ - onBeforeRenderObservable: Observable; - private _onBeforeRenderObserver; - onBeforeRender: (faceIndex: number) => void; + * Controls the extent to which the shadows fade out at the edge of the frustum + * Used only by directionals and spots + */ + frustumEdgeFalloff: number; + private _light; /** - * An event triggered after rendering the texture - * @type {BABYLON.Observable} - */ - onAfterRenderObservable: Observable; - private _onAfterRenderObserver; - onAfterRender: (faceIndex: number) => void; + * Returns the associated light object. + */ + getLight(): IShadowLight; + forceBackFacesOnly: boolean; + private _scene; + private _lightDirection; + private _effect; + private _viewMatrix; + private _projectionMatrix; + private _transformMatrix; + private _worldViewProjection; + private _cachedPosition; + private _cachedDirection; + private _cachedDefines; + private _currentRenderID; + private _downSamplePostprocess; + private _boxBlurPostprocess; + private _kernelBlurXPostprocess; + private _kernelBlurYPostprocess; + private _blurPostProcesses; + private _mapSize; + private _currentFaceIndex; + private _currentFaceIndexCache; + private _textureType; + private _isCube; + private _defaultTextureMatrix; /** - * An event triggered after the texture clear - * @type {BABYLON.Observable} - */ - onClearObservable: Observable; - private _onClearObserver; - onClear: (Engine: Engine) => void; - protected _size: number; - _generateMipMaps: boolean; - protected _renderingManager: RenderingManager; - _waitingRenderList: string[]; - protected _doNotChangeAspectRatio: boolean; - protected _currentRefreshId: number; - protected _refreshRate: number; - protected _textureMatrix: Matrix; - protected _samples: number; - protected _renderTargetOptions: IRenderTargetOptions; - readonly renderTargetOptions: IRenderTargetOptions; - constructor(name: string, size: any, scene: Scene, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean); - samples: number; - resetRefreshCounter(): void; - refreshRate: number; - addPostProcess(postProcess: PostProcess): void; - clearPostProcesses(dispose?: boolean): void; - removePostProcess(postProcess: PostProcess): void; - _shouldRender(): boolean; - isReady(): boolean; - getRenderSize(): number; - readonly canRescale: boolean; - scale(ratio: number): void; - getReflectionTextureMatrix(): Matrix; - resize(size: any): void; - render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void; - private renderToTarget(faceIndex, currentRenderList, currentRenderListLength, useCameraPostProcess, dumpForDebug); + * Creates a ShadowGenerator object. + * A ShadowGenerator is the required tool to use the shadows. + * Each light casting shadows needs to use its own ShadowGenerator. + * Required parameters : + * - `mapSize` (integer): the size of the texture what stores the shadows. Example : 1024. + * - `light`: the light object generating the shadows. + * - `useFullFloatFirst`: by default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture. + * Documentation : http://doc.babylonjs.com/tutorials/shadows + */ + constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean); + private _initializeGenerator(); + private _initializeShadowMap(); + private _initializeBlurRTTAndPostProcesses(); + private _renderForShadowMap(opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes); + private _renderSubMeshForShadowMap(subMesh); + private _applyFilterValues(); /** - * 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. + * Force shader compilation including textures ready check */ - setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: (a: SubMesh, b: SubMesh) => number, alphaTestSortCompareFn?: (a: SubMesh, b: SubMesh) => number, transparentSortCompareFn?: (a: SubMesh, b: SubMesh) => number): void; + forceCompilation(onCompiled: (generator: ShadowGenerator) => void, options?: { + useInstances: boolean; + }): 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. + * Boolean : true when the ShadowGenerator is finally computed. */ - setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void; - clone(): RenderTargetTexture; - serialize(): any; - disposeFramebufferObjects(): void; - dispose(): void; - } -} - -declare module BABYLON { - class Texture extends BaseTexture { - static NEAREST_SAMPLINGMODE: number; - static NEAREST_NEAREST_MIPLINEAR: number; - static BILINEAR_SAMPLINGMODE: number; - static LINEAR_LINEAR_MIPNEAREST: number; - static TRILINEAR_SAMPLINGMODE: number; - static LINEAR_LINEAR_MIPLINEAR: number; - static NEAREST_NEAREST_MIPNEAREST: number; - static NEAREST_LINEAR_MIPNEAREST: number; - static NEAREST_LINEAR_MIPLINEAR: number; - static NEAREST_LINEAR: number; - static NEAREST_NEAREST: number; - static LINEAR_NEAREST_MIPNEAREST: number; - static LINEAR_NEAREST_MIPLINEAR: number; - static LINEAR_LINEAR: number; - static LINEAR_NEAREST: number; - static EXPLICIT_MODE: number; - static SPHERICAL_MODE: number; - static PLANAR_MODE: number; - static CUBIC_MODE: number; - static PROJECTION_MODE: number; - static SKYBOX_MODE: number; - static INVCUBIC_MODE: number; - static EQUIRECTANGULAR_MODE: number; - static FIXED_EQUIRECTANGULAR_MODE: number; - static FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number; - static CLAMP_ADDRESSMODE: number; - static WRAP_ADDRESSMODE: number; - static MIRROR_ADDRESSMODE: number; - url: string; - uOffset: number; - vOffset: number; - uScale: number; - vScale: number; - uAng: number; - vAng: number; - wAng: number; - readonly noMipmap: boolean; - private _noMipmap; - _invertY: boolean; - private _rowGenerationMatrix; - private _cachedTextureMatrix; - private _projectionModeMatrix; - private _t0; - private _t1; - private _t2; - private _cachedUOffset; - private _cachedVOffset; - private _cachedUScale; - private _cachedVScale; - private _cachedUAng; - private _cachedVAng; - private _cachedWAng; - private _cachedProjectionMatrixId; - private _cachedCoordinatesMode; - _samplingMode: number; - private _buffer; - private _deleteBuffer; - protected _format: number; - private _delayedOnLoad; - private _delayedOnError; - private _onLoadObservable; - protected _isBlocking: boolean; - isBlocking: boolean; - readonly samplingMode: number; - constructor(url: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: () => void, onError?: () => void, buffer?: any, deleteBuffer?: boolean, format?: number); - updateURL(url: string): void; - delayLoad(): void; - updateSamplingMode(samplingMode: number): void; - private _prepareRowForTextureGeneration(x, y, z, t); - getTextureMatrix(): Matrix; - getReflectionTextureMatrix(): Matrix; - clone(): Texture; - readonly onLoadObservable: Observable; - serialize(): any; - getClassName(): string; - dispose(): void; - static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: () => void, onError?: () => void, format?: number): Texture; - static Parse(parsedTexture: any, scene: Scene, rootUrl: string): BaseTexture; - static LoadFromDataString(name: string, buffer: any, scene: Scene, deleteBuffer?: boolean, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: () => void, onError?: () => void, format?: number): Texture; - } -} - -declare module BABYLON { - class VideoTexture extends Texture { - video: HTMLVideoElement; - private _autoLaunch; - private _lastUpdate; - private _generateMipMaps; - private _setTextureReady; + isReady(subMesh: SubMesh, useInstances: boolean): boolean; + /** + * This creates the defines related to the standard BJS materials. + */ + prepareDefines(defines: MaterialDefines, lightIndex: number): void; /** - * Creates a video texture. - * Sample : https://doc.babylonjs.com/tutorials/01._Advanced_Texturing - * @param {Array} urlsOrVideo can be used to provide an array of urls or an already setup HTML video element. - * @param {BABYLON.Scene} scene is obviously the current scene. - * @param {boolean} generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated). - * @param {boolean} invertY is false by default but can be used to invert video on Y axis - * @param {number} samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default + * This binds shadow lights related to the standard BJS materials. + * It implies the unifroms available on the materials are the standard BJS ones. + */ + bindShadowLight(lightIndex: string, effect: Effect): void; + /** + * Returns a Matrix object : the updated transformation matrix. + */ + getTransformMatrix(): Matrix; + recreateShadowMap(): void; + private _disposeBlurPostProcesses(); + private _disposeRTTandPostProcesses(); + /** + * Disposes the ShadowGenerator. + * Returns nothing. */ - constructor(name: string, urlsOrVideo: string[] | HTMLVideoElement, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number); - private __setTextureReady(); - private _createTexture(); - update(): boolean; dispose(): void; - static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: { - minWidth: number; - maxWidth: number; - minHeight: number; - maxHeight: number; - deviceId: string; - }): void; + /** + * Serializes the ShadowGenerator and returns a serializationObject. + */ + serialize(): any; + /** + * Parses a serialized ShadowGenerator and returns a new ShadowGenerator. + */ + static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator; } } @@ -17287,289 +16655,921 @@ declare module BABYLON { */ useMetallnessFromMetallicTextureBlue: boolean; /** - * Specifies if the metallic texture contains the ambient occlusion information in its red channel. + * Specifies if the metallic texture contains the ambient occlusion information in its red channel. + */ + useAmbientOcclusionFromMetallicTextureRed: boolean; + /** + * Specifies if the ambient texture contains the ambient occlusion information in its red channel only. + */ + useAmbientInGrayScale: boolean; + /** + * In case the reflectivity map does not contain the microsurface information in its alpha channel, + * The material will try to infer what glossiness each pixel should be. + */ + useAutoMicroSurfaceFromReflectivityMap: boolean; + /** + * BJS is using an harcoded light falloff based on a manually sets up range. + * In PBR, one way to represents the fallof is to use the inverse squared root algorythm. + * This parameter can help you switch back to the BJS mode in order to create scenes using both materials. + */ + usePhysicalLightFalloff: boolean; + /** + * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones). + * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind. + */ + useRadianceOverAlpha: boolean; + /** + * Allows using the bump map in parallax mode. + */ + useParallax: boolean; + /** + * Allows using the bump map in parallax occlusion mode. + */ + useParallaxOcclusion: boolean; + /** + * Controls the scale bias of the parallax mode. + */ + parallaxScaleBias: number; + /** + * If sets to true, disables all the lights affecting the material. + */ + disableLighting: boolean; + /** + * Force the shader to compute irradiance in the fragment shader in order to take bump in account. + */ + forceIrradianceInFragment: boolean; + /** + * Number of Simultaneous lights allowed on the material. + */ + maxSimultaneousLights: number; + /** + * If sets to true, x component of normal map value will invert (x = 1.0 - x). + */ + invertNormalMapX: boolean; + /** + * If sets to true, y component of normal map value will invert (y = 1.0 - y). + */ + invertNormalMapY: boolean; + /** + * If sets to true and backfaceCulling is false, normals will be flipped on the backside. + */ + twoSidedLighting: boolean; + /** + * Specifies that the alpha is premultiplied before output (this enables alpha premultiplied blending). + * in your scene composition. + */ + preMultiplyAlpha: boolean; + /** + * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested. + * And/Or occlude the blended part. + */ + useAlphaFresnel: boolean; + /** + * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested. + * And/Or occlude the blended part. + */ + environmentBRDFTexture: BaseTexture; + /** + * Force normal to face away from face. + * (Temporary internal fix to remove before 3.1) + */ + forceNormalForward: boolean; + /** + * Gets the image processing configuration used either in this material. + */ + /** + * Sets the Default image processing configuration used either in the this material. + * + * If sets to null, the scene one is in use. + */ + imageProcessingConfiguration: ImageProcessingConfiguration; + /** + * Gets wether the color curves effect is enabled. + */ + /** + * Sets wether the color curves effect is enabled. + */ + cameraColorCurvesEnabled: boolean; + /** + * Gets wether the color grading effect is enabled. + */ + /** + * Gets wether the color grading effect is enabled. + */ + cameraColorGradingEnabled: boolean; + /** + * Gets wether tonemapping is enabled or not. + */ + /** + * Sets wether tonemapping is enabled or not + */ + cameraToneMappingEnabled: boolean; + /** + * The camera exposure used on this material. + * This property is here and not in the camera to allow controlling exposure without full screen post process. + * This corresponds to a photographic exposure. + */ + /** + * The camera exposure used on this material. + * This property is here and not in the camera to allow controlling exposure without full screen post process. + * This corresponds to a photographic exposure. + */ + cameraExposure: number; + /** + * Gets The camera contrast used on this material. + */ + /** + * Sets The camera contrast used on this material. + */ + cameraContrast: number; + /** + * Gets the Color Grading 2D Lookup Texture. + */ + /** + * Sets the Color Grading 2D Lookup Texture. + */ + cameraColorGradingTexture: BaseTexture; + /** + * 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. + */ + /** + * 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. + */ + cameraColorCurves: ColorCurves; + /** + * Instantiates a new PBRMaterial instance. + * + * @param name The material name + * @param scene The scene the material will be use in. + */ + constructor(name: string, scene: Scene); + getClassName(): string; + getActiveTextures(): BaseTexture[]; + hasTexture(texture: BaseTexture): boolean; + clone(name: string): PBRMaterial; + serialize(): any; + static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial; + } +} + +declare module BABYLON { + /** + * The PBR material of BJS following the metal roughness convention. + * + * This fits to the PBR convention in the GLTF definition: + * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0 + */ + class PBRMetallicRoughnessMaterial extends Internals.PBRBaseSimpleMaterial { + /** + * The base color has two different interpretations depending on the value of metalness. + * When the material is a metal, the base color is the specific measured reflectance value + * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color + * of the material. + */ + baseColor: Color3; + /** + * Base texture of the metallic workflow. It contains both the baseColor information in RGB as + * well as opacity information in the alpha channel. + */ + baseTexture: BaseTexture; + /** + * Specifies the metallic scalar value of the material. + * Can also be used to scale the metalness values of the metallic texture. + */ + metallic: number; + /** + * Specifies the roughness scalar value of the material. + * Can also be used to scale the roughness values of the metallic texture. + */ + roughness: number; + /** + * Texture containing both the metallic value in the B channel and the + * roughness value in the G channel to keep better precision. + */ + metallicRoughnessTexture: BaseTexture; + /** + * Instantiates a new PBRMetalRoughnessMaterial instance. + * + * @param name The material name + * @param scene The scene the material will be use in. + */ + constructor(name: string, scene: Scene); + /** + * Return the currrent class name of the material. + */ + getClassName(): string; + /** + * Return the active textures of the material. + */ + getActiveTextures(): BaseTexture[]; + hasTexture(texture: BaseTexture): boolean; + clone(name: string): PBRMetallicRoughnessMaterial; + /** + * Serialize the material to a parsable JSON object. */ - useAmbientOcclusionFromMetallicTextureRed: boolean; + serialize(): any; /** - * Specifies if the ambient texture contains the ambient occlusion information in its red channel only. + * Parses a JSON object correponding to the serialize function. */ - useAmbientInGrayScale: boolean; + static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial; + } +} + +declare module BABYLON { + /** + * The PBR material of BJS following the specular glossiness convention. + * + * This fits to the PBR convention in the GLTF definition: + * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness + */ + class PBRSpecularGlossinessMaterial extends Internals.PBRBaseSimpleMaterial { /** - * In case the reflectivity map does not contain the microsurface information in its alpha channel, - * The material will try to infer what glossiness each pixel should be. + * Specifies the diffuse color of the material. */ - useAutoMicroSurfaceFromReflectivityMap: boolean; + diffuseColor: Color3; /** - * BJS is using an harcoded light falloff based on a manually sets up range. - * In PBR, one way to represents the fallof is to use the inverse squared root algorythm. - * This parameter can help you switch back to the BJS mode in order to create scenes using both materials. + * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha + * channel. */ - usePhysicalLightFalloff: boolean; + diffuseTexture: BaseTexture; /** - * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones). - * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind. + * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror). */ - useRadianceOverAlpha: boolean; + specularColor: Color3; /** - * Allows using the bump map in parallax mode. + * Specifies the glossiness of the material. This indicates "how sharp is the reflection". */ - useParallax: boolean; + glossiness: number; /** - * Allows using the bump map in parallax occlusion mode. + * Specifies both the specular color RGB and the glossiness A of the material per pixels. */ - useParallaxOcclusion: boolean; + specularGlossinessTexture: BaseTexture; /** - * Controls the scale bias of the parallax mode. + * Instantiates a new PBRSpecularGlossinessMaterial instance. + * + * @param name The material name + * @param scene The scene the material will be use in. */ - parallaxScaleBias: number; + constructor(name: string, scene: Scene); /** - * If sets to true, disables all the lights affecting the material. + * Return the currrent class name of the material. */ - disableLighting: boolean; + getClassName(): string; /** - * Force the shader to compute irradiance in the fragment shader in order to take bump in account. + * Return the active textures of the material. */ - forceIrradianceInFragment: boolean; + getActiveTextures(): BaseTexture[]; + hasTexture(texture: BaseTexture): boolean; + clone(name: string): PBRSpecularGlossinessMaterial; /** - * Number of Simultaneous lights allowed on the material. + * Serialize the material to a parsable JSON object. */ - maxSimultaneousLights: number; + serialize(): any; /** - * If sets to true, x component of normal map value will invert (x = 1.0 - x). + * Parses a JSON object correponding to the serialize function. */ - invertNormalMapX: boolean; + static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial; + } +} + +declare module BABYLON { + class BaseTexture { + static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number; + name: string; + private _hasAlpha; + hasAlpha: boolean; + getAlphaFromRGB: boolean; + level: number; + coordinatesIndex: number; + private _coordinatesMode; + coordinatesMode: number; + wrapU: number; + wrapV: number; + anisotropicFilteringLevel: number; + isCube: boolean; + gammaSpace: boolean; + invertZ: boolean; + lodLevelInAlpha: boolean; + lodGenerationOffset: number; + lodGenerationScale: number; + isRenderTarget: boolean; + readonly uid: string; + toString(): string; + getClassName(): string; + animations: Animation[]; /** - * If sets to true, y component of normal map value will invert (y = 1.0 - y). + * An event triggered when the texture is disposed. + * @type {BABYLON.Observable} + */ + onDisposeObservable: Observable; + private _onDisposeObserver; + onDispose: () => void; + delayLoadState: number; + _cachedAnisotropicFilteringLevel: number; + private _scene; + _texture: WebGLTexture; + private _uid; + readonly isBlocking: boolean; + constructor(scene: Scene); + getScene(): Scene; + getTextureMatrix(): Matrix; + getReflectionTextureMatrix(): Matrix; + getInternalTexture(): WebGLTexture; + isReadyOrNotBlocking(): boolean; + isReady(): boolean; + getSize(): ISize; + getBaseSize(): ISize; + scale(ratio: number): void; + readonly canRescale: boolean; + _removeFromCache(url: string, noMipmap: boolean): void; + _getFromCache(url: string, noMipmap: boolean, sampling?: number): WebGLTexture; + delayLoad(): void; + clone(): BaseTexture; + readonly textureType: number; + readonly textureFormat: number; + readPixels(faceIndex?: number): ArrayBufferView; + releaseInternalTexture(): void; + sphericalPolynomial: SphericalPolynomial; + readonly _lodTextureHigh: BaseTexture; + readonly _lodTextureMid: BaseTexture; + readonly _lodTextureLow: BaseTexture; + dispose(): void; + serialize(): any; + static WhenAllReady(textures: BaseTexture[], callback: () => void): void; + } +} + +declare module BABYLON { + /** + * This represents a color grading texture. This acts as a lookup table LUT, useful during post process + * It can help converting any input color in a desired output one. This can then be used to create effects + * from sepia, black and white to sixties or futuristic rendering... + * + * The only supported format is currently 3dl. + * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table/ + */ + class ColorGradingTexture extends BaseTexture { + /** + * The current internal texture size. */ - invertNormalMapY: boolean; + private _size; /** - * If sets to true and backfaceCulling is false, normals will be flipped on the backside. + * The current texture matrix. (will always be identity in color grading texture) */ - twoSidedLighting: boolean; + private _textureMatrix; /** - * Specifies that the alpha is premultiplied before output (this enables alpha premultiplied blending). - * in your scene composition. + * The texture URL. */ - preMultiplyAlpha: boolean; + url: string; /** - * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested. - * And/Or occlude the blended part. + * Empty line regex stored for GC. */ - useAlphaFresnel: boolean; + private static _noneEmptyLineRegex; /** - * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested. - * And/Or occlude the blended part. + * Instantiates a ColorGradingTexture from the following parameters. + * + * @param url The location of the color gradind data (currently only supporting 3dl) + * @param scene The scene the texture will be used in */ - environmentBRDFTexture: BaseTexture; + constructor(url: string, scene: Scene); /** - * Force normal to face away from face. - * (Temporary internal fix to remove before 3.1) + * Returns the texture matrix used in most of the material. + * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in). */ - forceNormalForward: boolean; + getTextureMatrix(): Matrix; /** - * Gets the image processing configuration used either in this material. + * Occurs when the file being loaded is a .3dl LUT file. */ + private load3dlTexture(); /** - * Sets the Default image processing configuration used either in the this material. - * - * If sets to null, the scene one is in use. + * Starts the loading process of the texture. */ - imageProcessingConfiguration: ImageProcessingConfiguration; + private loadTexture(); /** - * Gets wether the color curves effect is enabled. + * Clones the color gradind texture. */ + clone(): ColorGradingTexture; /** - * Sets wether the color curves effect is enabled. + * Called during delayed load for textures. */ - cameraColorCurvesEnabled: boolean; + delayLoad(): void; /** - * Gets wether the color grading effect is enabled. + * Parses a color grading texture serialized by Babylon. + * @param parsedTexture The texture information being parsedTexture + * @param scene The scene to load the texture in + * @param rootUrl The root url of the data assets to load + * @return A color gradind texture */ + static Parse(parsedTexture: any, scene: Scene, rootUrl: string): ColorGradingTexture; /** - * Gets wether the color grading effect is enabled. + * Serializes the LUT texture to json format. */ - cameraColorGradingEnabled: boolean; + serialize(): any; + } +} + +declare module BABYLON { + class CubeTexture extends BaseTexture { + url: string; + coordinatesMode: number; + private _noMipmap; + private _files; + private _extensions; + private _textureMatrix; + private _format; + private _prefiltered; + static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture; + static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any): CubeTexture; + constructor(rootUrl: string, scene: Scene, extensions?: string[], noMipmap?: boolean, files?: string[], onLoad?: () => void, onError?: () => void, format?: number, prefiltered?: boolean, forcedExtension?: any); + delayLoad(): void; + getReflectionTextureMatrix(): Matrix; + setReflectionTextureMatrix(value: Matrix): void; + static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture; + clone(): CubeTexture; + } +} + +declare module BABYLON { + class DynamicTexture extends Texture { + private _generateMipMaps; + private _canvas; + private _context; + constructor(name: string, options: any, scene: Scene, generateMipMaps: boolean, samplingMode?: number, format?: number); + readonly canRescale: boolean; + private _recreate(textureSize); + scale(ratio: number): void; + scaleTo(width: number, height: number): void; + getContext(): CanvasRenderingContext2D; + clear(): void; + update(invertY?: boolean): void; + drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void; + clone(): DynamicTexture; + } +} + +declare module BABYLON { + /** + * This represents a texture coming from an HDR input. + * + * The only supported format is currently panorama picture stored in RGBE format. + * Example of such files can be found on HDRLib: http://hdrlib.com/ + */ + class HDRCubeTexture extends BaseTexture { + private static _facesMapping; + private _useInGammaSpace; + private _generateHarmonics; + private _noMipmap; + private _extensions; + private _textureMatrix; + private _size; + private _usePMREMGenerator; + private _isBABYLONPreprocessed; + private _onLoad; + private _onError; /** - * Gets wether tonemapping is enabled or not. + * The texture URL. */ + url: string; /** - * Sets wether tonemapping is enabled or not + * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */ - cameraToneMappingEnabled: boolean; + coordinatesMode: number; /** - * The camera exposure used on this material. - * This property is here and not in the camera to allow controlling exposure without full screen post process. - * This corresponds to a photographic exposure. + * Specifies wether the texture has been generated through the PMREMGenerator tool. + * This is usefull at run time to apply the good shader. */ + isPMREM: boolean; + protected _isBlocking: boolean; /** - * The camera exposure used on this material. - * This property is here and not in the camera to allow controlling exposure without full screen post process. - * This corresponds to a photographic exposure. + * Gets wether or not the texture is blocking during loading. */ - cameraExposure: number; /** - * Gets The camera contrast used on this material. + * Sets wether or not the texture is blocking during loading. */ + isBlocking: boolean; /** - * Sets The camera contrast used on this material. + * Instantiates an HDRTexture from the following parameters. + * + * @param url The location of the HDR raw data (Panorama stored in RGBE format) + * @param scene The scene the texture will be used in + * @param size The cubemap desired size (the more it increases the longer the generation will be) If the size is omitted this implies you are using a preprocessed cubemap. + * @param noMipmap Forces to not generate the mipmap if true + * @param generateHarmonics Specifies wether you want to extract the polynomial harmonics during the generation process + * @param useInGammaSpace Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) + * @param usePMREMGenerator Specifies wether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time. */ - cameraContrast: number; + constructor(url: string, scene: Scene, size?: number, noMipmap?: boolean, generateHarmonics?: boolean, useInGammaSpace?: boolean, usePMREMGenerator?: boolean, onLoad?: () => void, onError?: () => void); /** - * Gets the Color Grading 2D Lookup Texture. + * Occurs when the file is a preprocessed .babylon.hdr file. */ + private loadBabylonTexture(); /** - * Sets the Color Grading 2D Lookup Texture. + * Occurs when the file is raw .hdr file. */ - cameraColorGradingTexture: BaseTexture; + private loadHDRTexture(); /** - * 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. + * Starts the loading process of the texture. */ + private loadTexture(); + clone(): HDRCubeTexture; + delayLoad(): void; + getReflectionTextureMatrix(): Matrix; + setReflectionTextureMatrix(value: Matrix): void; + static Parse(parsedTexture: any, scene: Scene, rootUrl: string): HDRCubeTexture; + serialize(): any; /** - * 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. + * Saves as a file the data contained in the texture in a binary format. + * This can be used to prevent the long loading tie associated with creating the seamless texture as well + * as the spherical used in the lighting. + * @param url The HDR file url. + * @param size The size of the texture data to generate (one of the cubemap face desired width). + * @param onError Method called if any error happens during download. + * @return The packed binary data. */ - cameraColorCurves: ColorCurves; + static generateBabylonHDROnDisk(url: string, size: number, onError?: (() => void)): void; /** - * Instantiates a new PBRMaterial instance. - * - * @param name The material name - * @param scene The scene the material will be use in. + * Serializes the data contained in the texture in a binary format. + * This can be used to prevent the long loading tie associated with creating the seamless texture as well + * as the spherical used in the lighting. + * @param url The HDR file url. + * @param size The size of the texture data to generate (one of the cubemap face desired width). + * @param onError Method called if any error happens during download. + * @return The packed binary data. */ - constructor(name: string, scene: Scene); - getClassName(): string; - getActiveTextures(): BaseTexture[]; - hasTexture(texture: BaseTexture): boolean; - clone(name: string): PBRMaterial; - serialize(): any; - static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial; + static generateBabylonHDR(url: string, size: number, callback: ((ArrayBuffer: ArrayBuffer) => void), onError?: (() => void)): void; } } declare module BABYLON { - /** - * The PBR material of BJS following the metal roughness convention. - * - * This fits to the PBR convention in the GLTF definition: - * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0 - */ - class PBRMetallicRoughnessMaterial extends Internals.PBRBaseSimpleMaterial { - /** - * The base color has two different interpretations depending on the value of metalness. - * When the material is a metal, the base color is the specific measured reflectance value - * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color - * of the material. - */ - baseColor: Color3; - /** - * Base texture of the metallic workflow. It contains both the baseColor information in RGB as - * well as opacity information in the alpha channel. - */ - baseTexture: BaseTexture; - /** - * Specifies the metallic scalar value of the material. - * Can also be used to scale the metalness values of the metallic texture. - */ - metallic: number; + class MapTexture extends Texture { + private _rectPackingMap; + private _size; + private _replacedViewport; + constructor(name: string, scene: Scene, size: ISize, samplingMode?: number, useMipMap?: boolean, margin?: number); /** - * Specifies the roughness scalar value of the material. - * Can also be used to scale the roughness values of the metallic texture. + * Allocate a rectangle of a given size in the texture map + * @param size the size of the rectangle to allocation + * @return the PackedRect instance corresponding to the allocated rect or null is there was not enough space to allocate it. */ - roughness: number; + allocateRect(size: Size): PackedRect; /** - * Texture containing both the metallic value in the B channel and the - * roughness value in the G channel to keep better precision. + * Free a given rectangle from the texture map + * @param rectInfo the instance corresponding to the rect to free. */ - metallicRoughnessTexture: BaseTexture; + freeRect(rectInfo: PackedRect): void; /** - * Instantiates a new PBRMetalRoughnessMaterial instance. - * - * @param name The material name - * @param scene The scene the material will be use in. + * Return the available space in the range of [O;1]. 0 being not space left at all, 1 being an empty texture map. + * This is the cumulated space, not the biggest available surface. Due to fragmentation you may not allocate a rect corresponding to this surface. + * @returns {} */ - constructor(name: string, scene: Scene); + readonly freeSpace: number; /** - * Return the currrent class name of the material. + * Bind the texture to the rendering engine to render in the zone of a given rectangle. + * Use this method when you want to render into the texture map with a clipspace set to the location and size of the given rect. + * Don't forget to call unbindTexture when you're done rendering + * @param rect the zone to render to + * @param clear true to clear the portion's color/depth data */ - getClassName(): string; + bindTextureForRect(rect: PackedRect, clear: boolean): void; /** - * Return the active textures of the material. + * Bind the texture to the rendering engine to render in the zone of the given size at the given position. + * Use this method when you want to render into the texture map with a clipspace set to the location and size of the given rect. + * Don't forget to call unbindTexture when you're done rendering + * @param pos the position into the texture + * @param size the portion to fit the clip space to + * @param clear true to clear the portion's color/depth data */ - getActiveTextures(): BaseTexture[]; - hasTexture(texture: BaseTexture): boolean; - clone(name: string): PBRMetallicRoughnessMaterial; + bindTextureForPosSize(pos: Vector2, size: Size, clear: boolean): void; /** - * Serialize the material to a parsable JSON object. + * Unbind the texture map from the rendering engine. + * Call this method when you're done rendering. A previous call to bindTextureForRect has to be made. + * @param dumpForDebug if set to true the content of the texture map will be dumped to a picture file that will be sent to the internet browser. */ + unbindTexture(dumpForDebug?: boolean): void; + readonly canRescale: boolean; + clone(): MapTexture; + } +} + +declare module BABYLON { + class MirrorTexture extends RenderTargetTexture { + mirrorPlane: Plane; + private _transformMatrix; + private _mirrorMatrix; + private _savedViewMatrix; + private _blurX; + private _blurY; + private _blurKernelX; + private _blurKernelY; + private _blurRatio; + blurRatio: number; + blurKernel: number; + blurKernelX: number; + blurKernelY: number; + constructor(name: string, size: any, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean); + private _preparePostProcesses(); + clone(): MirrorTexture; + serialize(): any; + } +} + +declare module BABYLON { + interface IMultiRenderTargetOptions { + generateMipMaps: boolean; + types: number[]; + samplingModes: number[]; + generateDepthBuffer: boolean; + generateStencilBuffer: boolean; + generateDepthTexture: boolean; + textureCount: number; + } + class MultiRenderTarget extends RenderTargetTexture { + private _webGLTextures; + private _textures; + private _count; + readonly isSupported: boolean; + private _multiRenderTargetOptions; + readonly textures: Texture[]; + readonly depthTexture: Texture; + constructor(name: string, size: any, count: number, scene: Scene, options?: any); + private _createInternalTextures(); + samples: number; + resize(size: any): void; + dispose(): void; + releaseInternalTextures(): void; + } +} + +declare module BABYLON { + class RawTexture extends Texture { + format: number; + constructor(data: ArrayBufferView, width: number, height: number, format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number); + update(data: ArrayBufferView): void; + static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture; + static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture; + static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture; + static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture; + static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture; + } +} + +declare module BABYLON { + /** + * Creates a refraction texture used by refraction channel of the standard material. + * @param name the texture name + * @param size size of the underlying texture + * @param scene root scene + */ + class RefractionTexture extends RenderTargetTexture { + refractionPlane: Plane; + depth: number; + constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean); + clone(): RefractionTexture; serialize(): any; - /** - * Parses a JSON object correponding to the serialize function. - */ - static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial; } } declare module BABYLON { - /** - * The PBR material of BJS following the specular glossiness convention. - * - * This fits to the PBR convention in the GLTF definition: - * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness - */ - class PBRSpecularGlossinessMaterial extends Internals.PBRBaseSimpleMaterial { + interface IRenderTargetOptions { + generateMipMaps: boolean; + type: number; + samplingMode: number; + generateDepthBuffer: boolean; + generateStencilBuffer: boolean; + } + class RenderTargetTexture extends Texture { + isCube: boolean; + static _REFRESHRATE_RENDER_ONCE: number; + static _REFRESHRATE_RENDER_ONEVERYFRAME: number; + static _REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number; + static readonly REFRESHRATE_RENDER_ONCE: number; + static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number; + static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number; /** - * Specifies the diffuse color of the material. - */ - diffuseColor: Color3; + * Use this predicate to dynamically define the list of mesh you want to render. + * If set, the renderList property will be overwritten. + */ + renderListPredicate: (AbstractMesh: AbstractMesh) => boolean; /** - * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha - * channel. - */ - diffuseTexture: BaseTexture; + * Use this list to define the list of mesh you want to render. + */ + renderList: AbstractMesh[]; + renderParticles: boolean; + renderSprites: boolean; + coordinatesMode: number; + activeCamera: Camera; + customRenderFunction: (opaqueSubMeshes: SmartArray, transparentSubMeshes: SmartArray, alphaTestSubMeshes: SmartArray, beforeTransparents?: () => void) => void; + useCameraPostProcesses: boolean; + private _postProcessManager; + private _postProcesses; /** - * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror). - */ - specularColor: Color3; + * An event triggered when the texture is unbind. + * @type {BABYLON.Observable} + */ + onBeforeBindObservable: Observable; /** - * Specifies the glossiness of the material. This indicates "how sharp is the reflection". - */ - glossiness: number; + * An event triggered when the texture is unbind. + * @type {BABYLON.Observable} + */ + onAfterUnbindObservable: Observable; + private _onAfterUnbindObserver; + onAfterUnbind: () => void; /** - * Specifies both the specular color RGB and the glossiness A of the material per pixels. - */ - specularGlossinessTexture: BaseTexture; + * An event triggered before rendering the texture + * @type {BABYLON.Observable} + */ + onBeforeRenderObservable: Observable; + private _onBeforeRenderObserver; + onBeforeRender: (faceIndex: number) => void; /** - * Instantiates a new PBRSpecularGlossinessMaterial instance. - * - * @param name The material name - * @param scene The scene the material will be use in. - */ - constructor(name: string, scene: Scene); + * An event triggered after rendering the texture + * @type {BABYLON.Observable} + */ + onAfterRenderObservable: Observable; + private _onAfterRenderObserver; + onAfterRender: (faceIndex: number) => void; /** - * Return the currrent class name of the material. - */ - getClassName(): string; + * An event triggered after the texture clear + * @type {BABYLON.Observable} + */ + onClearObservable: Observable; + private _onClearObserver; + onClear: (Engine: Engine) => void; + protected _size: number; + _generateMipMaps: boolean; + protected _renderingManager: RenderingManager; + _waitingRenderList: string[]; + protected _doNotChangeAspectRatio: boolean; + protected _currentRefreshId: number; + protected _refreshRate: number; + protected _textureMatrix: Matrix; + protected _samples: number; + protected _renderTargetOptions: IRenderTargetOptions; + readonly renderTargetOptions: IRenderTargetOptions; + constructor(name: string, size: any, scene: Scene, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean); + samples: number; + resetRefreshCounter(): void; + refreshRate: number; + addPostProcess(postProcess: PostProcess): void; + clearPostProcesses(dispose?: boolean): void; + removePostProcess(postProcess: PostProcess): void; + _shouldRender(): boolean; + isReady(): boolean; + getRenderSize(): number; + readonly canRescale: boolean; + scale(ratio: number): void; + getReflectionTextureMatrix(): Matrix; + resize(size: any): void; + render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void; + private renderToTarget(faceIndex, currentRenderList, currentRenderListLength, useCameraPostProcess, dumpForDebug); /** - * Return the active textures of the 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. */ - getActiveTextures(): BaseTexture[]; - hasTexture(texture: BaseTexture): boolean; - clone(name: string): PBRSpecularGlossinessMaterial; + setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: (a: SubMesh, b: SubMesh) => number, alphaTestSortCompareFn?: (a: SubMesh, b: SubMesh) => number, transparentSortCompareFn?: (a: SubMesh, b: SubMesh) => number): void; /** - * Serialize the material to a parsable JSON object. + * 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. */ + setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void; + clone(): RenderTargetTexture; + serialize(): any; + disposeFramebufferObjects(): void; + dispose(): void; + } +} + +declare module BABYLON { + class Texture extends BaseTexture { + static NEAREST_SAMPLINGMODE: number; + static NEAREST_NEAREST_MIPLINEAR: number; + static BILINEAR_SAMPLINGMODE: number; + static LINEAR_LINEAR_MIPNEAREST: number; + static TRILINEAR_SAMPLINGMODE: number; + static LINEAR_LINEAR_MIPLINEAR: number; + static NEAREST_NEAREST_MIPNEAREST: number; + static NEAREST_LINEAR_MIPNEAREST: number; + static NEAREST_LINEAR_MIPLINEAR: number; + static NEAREST_LINEAR: number; + static NEAREST_NEAREST: number; + static LINEAR_NEAREST_MIPNEAREST: number; + static LINEAR_NEAREST_MIPLINEAR: number; + static LINEAR_LINEAR: number; + static LINEAR_NEAREST: number; + static EXPLICIT_MODE: number; + static SPHERICAL_MODE: number; + static PLANAR_MODE: number; + static CUBIC_MODE: number; + static PROJECTION_MODE: number; + static SKYBOX_MODE: number; + static INVCUBIC_MODE: number; + static EQUIRECTANGULAR_MODE: number; + static FIXED_EQUIRECTANGULAR_MODE: number; + static FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number; + static CLAMP_ADDRESSMODE: number; + static WRAP_ADDRESSMODE: number; + static MIRROR_ADDRESSMODE: number; + url: string; + uOffset: number; + vOffset: number; + uScale: number; + vScale: number; + uAng: number; + vAng: number; + wAng: number; + readonly noMipmap: boolean; + private _noMipmap; + _invertY: boolean; + private _rowGenerationMatrix; + private _cachedTextureMatrix; + private _projectionModeMatrix; + private _t0; + private _t1; + private _t2; + private _cachedUOffset; + private _cachedVOffset; + private _cachedUScale; + private _cachedVScale; + private _cachedUAng; + private _cachedVAng; + private _cachedWAng; + private _cachedProjectionMatrixId; + private _cachedCoordinatesMode; + _samplingMode: number; + private _buffer; + private _deleteBuffer; + protected _format: number; + private _delayedOnLoad; + private _delayedOnError; + private _onLoadObservable; + protected _isBlocking: boolean; + isBlocking: boolean; + readonly samplingMode: number; + constructor(url: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: () => void, onError?: () => void, buffer?: any, deleteBuffer?: boolean, format?: number); + updateURL(url: string): void; + delayLoad(): void; + updateSamplingMode(samplingMode: number): void; + private _prepareRowForTextureGeneration(x, y, z, t); + getTextureMatrix(): Matrix; + getReflectionTextureMatrix(): Matrix; + clone(): Texture; + readonly onLoadObservable: Observable; serialize(): any; + getClassName(): string; + dispose(): void; + static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: () => void, onError?: () => void, format?: number): Texture; + static Parse(parsedTexture: any, scene: Scene, rootUrl: string): BaseTexture; + static LoadFromDataString(name: string, buffer: any, scene: Scene, deleteBuffer?: boolean, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: () => void, onError?: () => void, format?: number): Texture; + } +} + +declare module BABYLON { + class VideoTexture extends Texture { + video: HTMLVideoElement; + private _autoLaunch; + private _lastUpdate; + private _generateMipMaps; + private _setTextureReady; /** - * Parses a JSON object correponding to the serialize function. + * Creates a video texture. + * Sample : https://doc.babylonjs.com/tutorials/01._Advanced_Texturing + * @param {Array} urlsOrVideo can be used to provide an array of urls or an already setup HTML video element. + * @param {BABYLON.Scene} scene is obviously the current scene. + * @param {boolean} generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated). + * @param {boolean} invertY is false by default but can be used to invert video on Y axis + * @param {number} samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default */ - static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial; + constructor(name: string, urlsOrVideo: string[] | HTMLVideoElement, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number); + private __setTextureReady(); + private _createTexture(); + update(): boolean; + dispose(): void; + static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: { + minWidth: number; + maxWidth: number; + minHeight: number; + maxHeight: number; + deviceId: string; + }): void; } } +declare module BABYLON.Internals { +} + declare module BABYLON { class CannonJSPlugin implements IPhysicsEnginePlugin { private _useDeltaForWorldStep; diff --git a/dist/preview release/babylon.js b/dist/preview release/babylon.js index cac12745848..5ddcbb3f81a 100644 --- a/dist/preview release/babylon.js +++ b/dist/preview release/babylon.js @@ -9,36 +9,36 @@ o._diffPositionForCollisions=new e.Vector3(0,0,0),o._newPositionForCollisions=ne return function(){return new e.StereoscopicArcRotateCamera(i,0,0,1,e.Vector3.Zero(),n,o,r)};case"StereoscopicFreeCamera":return function(){return new e.StereoscopicFreeCamera(i,e.Vector3.Zero(),n,o,r)};case"StereoscopicGamepadCamera":return function(){return new e.StereoscopicGamepadCamera(i,e.Vector3.Zero(),n,o,r)};case"StereoscopicUniversalCamera":return function(){return new e.StereoscopicUniversalCamera(i,e.Vector3.Zero(),n,o,r)};case"FreeCamera":default:return function(){return new e.UniversalCamera(i,e.Vector3.Zero(),r)}}},i.Parse=function(t,r){var n=t.type,o=i.GetConstructorFromName(n,t.name,r,t.interaxial_distance,t.isStereoscopicSideBySide),s=e.SerializationHelper.Parse(o,t,r);if(t.parentId&&(s._waitingParentId=t.parentId),s.inputs&&(s.inputs.parse(t),s._setupInputs()),s.setPosition&&(s.position.copyFromFloats(0,0,0),s.setPosition(e.Vector3.FromArray(t.position))),t.target&&s.setTarget&&s.setTarget(e.Vector3.FromArray(t.target)),t.cameraRigMode){var a=t.interaxial_distance?{interaxialDistance:t.interaxial_distance}:{};s.setCameraRigMode(t.cameraRigMode,a)}if(t.animations){for(var l=0;li._alphaIndex?1:e._alphaIndext._distanceToCamera?-1:0},t.frontToBackSortCompare=function(e,t){return e._distanceToCamerat._distanceToCamera?1:0},t.prototype.prepare=function(){this._opaqueSubMeshes.reset(),this._transparentSubMeshes.reset(),this._alphaTestSubMeshes.reset(),this._particleSystems.reset(),this._spriteManagers.reset(),this._edgesRenderers.reset()},t.prototype.dispose=function(){this._opaqueSubMeshes.dispose(),this._transparentSubMeshes.dispose(),this._alphaTestSubMeshes.dispose(),this._particleSystems.dispose(),this._spriteManagers.dispose(),this._edgesRenderers.dispose()},t.prototype.dispatch=function(e){var t=e.getMaterial(),i=e.getMesh();t.needAlphaBlending()||i.visibility<1||i.hasVertexAlpha?this._transparentSubMeshes.push(e):t.needAlphaTesting()?this._alphaTestSubMeshes.push(e):this._opaqueSubMeshes.push(e),i._edgesRenderer&&this._edgesRenderers.push(i._edgesRenderer)},t.prototype.dispatchSprites=function(e){this._spriteManagers.push(e)},t.prototype.dispatchParticles=function(e){this._particleSystems.push(e)},t.prototype._renderParticles=function(e){if(0!==this._particleSystems.length){var t=this._scene.activeCamera;this._scene._particlesDuration.beginMonitoring();for(var i=0;ir.DoubleClickDelay&&!h._doubleClickOccured||e!==h._previousButtonPressed)&&(h._doubleClickOccured=!1,t.singleClick=!0,t.ignore=!1,i(t,h._currentPickResult))},this._initClickEvent=function(n,o,s,a){var l=new t;h._currentPickResult=null;var c,u=n.hasSpecificMask(i.POINTERPICK)||o.hasSpecificMask(i.POINTERPICK)||n.hasSpecificMask(i.POINTERTAP)||o.hasSpecificMask(i.POINTERTAP)||n.hasSpecificMask(i.POINTERDOUBLETAP)||o.hasSpecificMask(i.POINTERDOUBLETAP);if(!u&&e.ActionManager&&e.ActionManager.HasPickTriggers&&(c=h._initActionManager(c,l))&&(u=c.hasPickTriggers),u){var f=s.button;if(l.hasSwiped=Math.abs(h._startingPointerPosition.x-h._pointerX)>r.DragMovementThreshold||Math.abs(h._startingPointerPosition.y-h._pointerY)>r.DragMovementThreshold,!l.hasSwiped){var d=!r.ExclusiveDoubleClickMode;d||(d=!n.hasSpecificMask(i.POINTERDOUBLETAP)&&!o.hasSpecificMask(i.POINTERDOUBLETAP))&&!e.ActionManager.HasSpecificTrigger(e.ActionManager.OnDoublePickTrigger)&&(c=h._initActionManager(c,l))&&(d=!c.hasSpecificTrigger(e.ActionManager.OnDoublePickTrigger)),d?((new Date).getTime()-h._previousStartingPointerTime>r.DoubleClickDelay||f!==h._previousButtonPressed)&&(l.singleClick=!0,a(l,h._currentPickResult)):(h._previousDelayedSimpleClickTimeout=h._delayedSimpleClickTimeout,h._delayedSimpleClickTimeout=window.setTimeout(h._delayedSimpleClick.bind(h,f,l,a),r.DoubleClickDelay));var p=n.hasSpecificMask(i.POINTERDOUBLETAP)||o.hasSpecificMask(i.POINTERDOUBLETAP);!p&&e.ActionManager.HasSpecificTrigger(e.ActionManager.OnDoublePickTrigger)&&(c=h._initActionManager(c,l))&&(p=c.hasSpecificTrigger(e.ActionManager.OnDoublePickTrigger)),p&&(f===h._previousButtonPressed&&(new Date).getTime()-h._previousStartingPointerTimer.LongPressDelay&&Math.abs(this._startingPointerPosition.x-this._pointerX)0&&(l=h.pickSprite(h._unTranslatedPointerX,h._unTranslatedPointerY,c,!1,h.cameraToUseForPointers))&&l.hit&&l.pickedSprite&&l.pickedSprite.actionManager){switch(h._pickedDownSprite=l.pickedSprite,t.button){case 0:l.pickedSprite.actionManager.processTrigger(e.ActionManager.OnLeftPickTrigger,e.ActionEvent.CreateNewFromSprite(l.pickedSprite,h,t));break;case 1:l.pickedSprite.actionManager.processTrigger(e.ActionManager.OnCenterPickTrigger,e.ActionEvent.CreateNewFromSprite(l.pickedSprite,h,t));break;case 2:l.pickedSprite.actionManager.processTrigger(e.ActionManager.OnRightPickTrigger,e.ActionEvent.CreateNewFromSprite(l.pickedSprite,h,t))}l.pickedSprite.actionManager&&l.pickedSprite.actionManager.processTrigger(e.ActionManager.OnPickDownTrigger,e.ActionEvent.CreateNewFromSprite(l.pickedSprite,h,t))}}},this._onPointerUp=function(t){h._isButtonPressed=!1,h._pickedUpMesh=null,h._meshPickProceed=!1,h._updatePointerPosition(t),h._initClickEvent(h.onPrePointerObservable,h.onPointerObservable,t,function(s,a){if(this.onPrePointerObservable.hasObservers())if(s.ignore){var l=i.POINTERUP,h=new n(l,t,this._unTranslatedPointerX,this._unTranslatedPointerY);if(this.onPrePointerObservable.notifyObservers(h,l),h.skipOnPointerObservable)return}else if(!s.hasSwiped){if(s.singleClick&&this.onPrePointerObservable.hasSpecificMask(i.POINTERTAP)){var l=i.POINTERTAP,h=new n(l,t,this._unTranslatedPointerX,this._unTranslatedPointerY);if(this.onPrePointerObservable.notifyObservers(h,l),h.skipOnPointerObservable)return}if(s.doubleClick&&this.onPrePointerObservable.hasSpecificMask(i.POINTERDOUBLETAP)){var l=i.POINTERDOUBLETAP,h=new n(l,t,this._unTranslatedPointerX,this._unTranslatedPointerY);if(this.onPrePointerObservable.notifyObservers(h,l),h.skipOnPointerObservable)return}}if(this.cameraToUseForPointers||this.activeCamera){if(this.pointerUpPredicate||(this.pointerUpPredicate=function(e){return e.isPickable&&e.isVisible&&e.isReady()&&e.isEnabled()}),!this._meshPickProceed&&(e.ActionManager&&e.ActionManager.HasTriggers||this.onPointerObservable.hasObservers())&&this._initActionManager(null,s),a||(a=this._currentPickResult),a&&a&&a.pickedMesh){if(this._pickedUpMesh=a.pickedMesh,this._pickedDownMesh===this._pickedUpMesh&&(this.onPointerPick&&this.onPointerPick(t,a),s.singleClick&&!s.ignore&&this.onPointerObservable.hasObservers())){var l=i.POINTERPICK,h=new o(l,t,a);this.onPointerObservable.notifyObservers(h,l)}a.pickedMesh.actionManager&&(s.ignore&&a.pickedMesh.actionManager.processTrigger(e.ActionManager.OnPickUpTrigger,e.ActionEvent.CreateNew(a.pickedMesh,t)),s.hasSwiped||s.ignore||!s.singleClick||a.pickedMesh.actionManager.processTrigger(e.ActionManager.OnPickTrigger,e.ActionEvent.CreateNew(a.pickedMesh,t)),s.doubleClick&&!s.ignore&&a.pickedMesh.actionManager.hasSpecificTrigger(e.ActionManager.OnDoublePickTrigger)&&a.pickedMesh.actionManager.processTrigger(e.ActionManager.OnDoublePickTrigger,e.ActionEvent.CreateNew(a.pickedMesh,t)))}if(this._pickedDownMesh&&this._pickedDownMesh.actionManager&&this._pickedDownMesh.actionManager.hasSpecificTrigger(e.ActionManager.OnPickOutTrigger)&&this._pickedDownMesh!==this._pickedUpMesh&&this._pickedDownMesh.actionManager.processTrigger(e.ActionManager.OnPickOutTrigger,e.ActionEvent.CreateNew(this._pickedDownMesh,t)),this.onPointerUp&&this.onPointerUp(t,a),this.onPointerObservable.hasObservers())if(s.ignore){var l=i.POINTERUP,h=new o(l,t,a);this.onPointerObservable.notifyObservers(h,l)}else if(!s.hasSwiped){if(s.singleClick&&this.onPointerObservable.hasSpecificMask(i.POINTERTAP)){var l=i.POINTERTAP,h=new o(l,t,a);this.onPointerObservable.notifyObservers(h,l)}if(s.doubleClick&&this.onPointerObservable.hasSpecificMask(i.POINTERDOUBLETAP)){var l=i.POINTERDOUBLETAP,h=new o(l,t,a);this.onPointerObservable.notifyObservers(h,l)}}this.spriteManagers.length>0&&(a=this.pickSprite(this._unTranslatedPointerX,this._unTranslatedPointerY,c,!1,this.cameraToUseForPointers),a.hit&&a.pickedSprite&&a.pickedSprite.actionManager&&(a.pickedSprite.actionManager.processTrigger(e.ActionManager.OnPickUpTrigger,e.ActionEvent.CreateNewFromSprite(a.pickedSprite,this,t)),a.pickedSprite.actionManager&&Math.abs(this._startingPointerPosition.x-this._pointerX)0)return!1;var t;for(t=0;tr&&o>0&&(o*=-1),this.stopAnimation(t),a||(a=new e.Animatable(this,t,i,r,n,o,s)),t.animations&&a.appendAnimations(t,t.animations),t.getAnimatables)for(var l=t.getAnimatables(),h=0;h0)return;this._animationTimeLast=t}var i=(t-this._animationTimeLast)*this.animationTimeScale;this._animationTime+=i,this._animationTimeLast=t;for(var r=0;r0?this.activeCamera=this.cameras[0]:this.activeCamera=null),this.onCameraRemovedObservable.notifyObservers(e),t},r.prototype.addLight=function(e){e.uniqueId=this.getUniqueId(),this.lights.push(e),this.sortLightsByPriority(),this.onNewLightAddedObservable.notifyObservers(e)},r.prototype.sortLightsByPriority=function(){this.requireLightSorting&&this.lights.sort(e.Light.compareLightsPriority)},r.prototype.addCamera=function(e){e.uniqueId=this.getUniqueId();this.cameras.push(e);this.onNewCameraAddedObservable.notifyObservers(e)},r.prototype.switchActiveCamera=function(e,t){void 0===t&&(t=!0);var i=this._engine.getRenderingCanvas();this.activeCamera.detachControl(i),this.activeCamera=e,t&&e.attachControl(i)},r.prototype.setActiveCameraByID=function(e){var t=this.getCameraByID(e);return t?(this.activeCamera=t,t):null},r.prototype.setActiveCameraByName=function(e){var t=this.getCameraByName(e);return t?(this.activeCamera=t,t):null},r.prototype.getMaterialByID=function(e){for(var t=0;t-1&&(this._geometries.splice(t,1),this.collisionCoordinator&&this.collisionCoordinator.onGeometryDeleted(e),this.onGeometryRemovedObservable.notifyObservers(e),!0)},r.prototype.getGeometries=function(){return this._geometries},r.prototype.getMeshByID=function(e){for(var t=0;t=0;t--)if(this.meshes[t].id===e)return this.meshes[t];return null},r.prototype.getLastEntryByID=function(e){var t;for(t=this.meshes.length-1;t>=0;t--)if(this.meshes[t].id===e)return this.meshes[t];for(t=this.cameras.length-1;t>=0;t--)if(this.cameras[t].id===e)return this.cameras[t];for(t=this.lights.length-1;t>=0;t--)if(this.lights[t].id===e)return this.lights[t];return null},r.prototype.getNodeByID=function(e){var t=this.getMeshByID(e);if(t)return t;var i=this.getLightByID(e);if(i)return i;var r=this.getCameraByID(e);return r||this.getBoneByID(e)},r.prototype.getNodeByName=function(e){var t=this.getMeshByName(e);if(t)return t;var i=this.getLightByName(e);if(i)return i;var r=this.getCameraByName(e);return r||this.getBoneByName(e)},r.prototype.getMeshByName=function(e){for(var t=0;t=0;t--)if(this.skeletons[t].id===e)return this.skeletons[t];return null},r.prototype.getSkeletonById=function(e){for(var t=0;t0&&0!=(o.layerMask&this.activeCamera.layerMask)&&o.isInFrustum(this._frustumPlanes))&&(this._activeMeshes.push(o),this.activeCamera._activeMeshes.push(o),o._activate(this._renderId),this._activeMesh(o,s)))}}this._particlesDuration.beginMonitoring();e.Tools.Now;if(this.particlesEnabled){e.Tools.StartPerformanceCounter("Particles",this.particleSystems.length>0);for(var a=0;a0)}this._particlesDuration.endMonitoring(!1)},r.prototype._activeMesh=function(e,t){if(t.skeleton&&this.skeletonsEnabled&&(this._activeSkeletons.pushNoDuplicate(t.skeleton)&&t.skeleton.prepare(),t.computeBonesUsingShaders||this._softwareSkinnedMeshes.pushNoDuplicate(t)),(e.showBoundingBox||this.forceShowBoundingBoxes)&&this.getBoundingBoxRenderer().renderList.push(e.getBoundingInfo().boundingBox),t&&t.subMeshes){var i,r;if(t._submeshesOctree&&t.useOctreeForRenderingSelection){var n=t._submeshesOctree.select(this._frustumPlanes);i=n.length,r=n.data}else r=t.subMeshes,i=r.length;for(var o=0;o0&&this._renderTargets.concatWithNoDuplicate(t.customRenderTargets),this.renderTargetsEnabled&&this._renderTargets.length>0){this._intermediateRendering=!0,e.Tools.StartPerformanceCounter("Render targets",this._renderTargets.length>0);for(var s=0;s0),this._intermediateRendering=!1,this._renderId++,o=!0}var h=this._engine.getStencilBuffer(),c=!1;if(this.renderTargetsEnabled&&this.highlightLayers&&this.highlightLayers.length>0){this._intermediateRendering=!0;for(var u=0;u-1)){c=!0;var a=f._mainTexture;a._shouldRender()&&(this._renderId++,a.render(!1,!1),o=!0)}}this._intermediateRendering=!1,this._renderId++}o&&i.restoreDefaultFramebuffer(),this._renderTargetsDuration.endMonitoring(!1),this.postProcessManager._prepareFrame(),this._renderDuration.beginMonitoring();var d,p;if(this.layers.length){for(i.setDepthBuffer(!1),d=0;d0);for(var _=0;_0)}if(this.layers.length){for(i.setDepthBuffer(!1),d=0;d-1&&(n.trigger===e.ActionManager.OnIntersectionExitTrigger&&n._executeCurrent(e.ActionEvent.CreateNew(i,null,s)),i.actionManager.hasSpecificTrigger(e.ActionManager.OnIntersectionExitTrigger)&&n.trigger!==e.ActionManager.OnIntersectionExitTrigger||i._intersectionsInProgress.splice(l,1))}}},r.prototype.render=function(){if(!this.isDisposed){this._lastFrameDuration.beginMonitoring(),this._particlesDuration.fetchNewFrame(),this._spritesDuration.fetchNewFrame(),this._activeParticles.fetchNewFrame(),this._renderDuration.fetchNewFrame(),this._renderTargetsDuration.fetchNewFrame(),this._evaluateActiveMeshesDuration.fetchNewFrame(),this._totalVertices.fetchNewFrame(),this._activeIndices.fetchNewFrame(),this._activeBones.fetchNewFrame(),this.getEngine().drawCallsPerfCounter.fetchNewFrame(),this._meshesForIntersections.reset(),this.resetCachedMaterial(),e.Tools.StartPerformanceCounter("Scene rendering"),this.actionManager&&this.actionManager.processTrigger(e.ActionManager.OnEveryFrameTrigger,null),this.simplificationQueue&&!this.simplificationQueue.running&&this.simplificationQueue.executeNext();var t=Math.max(r.MinDeltaTime,Math.min(this._engine.getDeltaTime(),r.MaxDeltaTime));this._animationRatio=.06*t,this._animate(),this._physicsEngine&&(e.Tools.StartPerformanceCounter("Physics"),this._physicsEngine._step(t/1e3),e.Tools.EndPerformanceCounter("Physics")),this.onBeforeRenderObservable.notifyObservers(this),this._renderTargetsDuration.beginMonitoring();var i=(e.Tools.Now,this.getEngine()),n=this.activeCamera;if(this.renderTargetsEnabled){e.Tools.StartPerformanceCounter("Custom render targets",this.customRenderTargets.length>0);for(var o=0;o0),this._renderId++}if(this.customRenderTargets.length>0&&i.restoreDefaultFramebuffer(),this._renderTargetsDuration.endMonitoring(),this.activeCamera=n,this.proceduralTexturesEnabled){e.Tools.StartPerformanceCounter("Procedural textures",this._proceduralTextures.length>0);for(var a=0;a0)} if((this.autoClearDepthAndStencil||this.autoClear)&&this._engine.clear(this.clearColor,this.autoClear||this.forceWireframe||this.forcePointsCloud,this.autoClearDepthAndStencil,this.autoClearDepthAndStencil),this.shadowsEnabled)for(var h=0;h0)for(var d=0;d0&&this._engine.clear(null,!1,!0,!0),this._processSubCameras(this.activeCameras[d]);else{if(!this.activeCamera)throw new Error("No camera defined");this._processSubCameras(this.activeCamera)}this._checkIntersections(),e.AudioEngine&&this._updateAudioParameters(),this.afterRender&&this.afterRender(),this.onAfterRenderObservable.notifyObservers(this);for(var p=0;p0?this.activeCameras[0]:this.activeCamera)&&i.canUseWebAudio){i.audioContext.listener.setPosition(t.position.x,t.position.y,t.position.z),t.rigCameras&&t.rigCameras.length>0&&(t=t.rigCameras[0]);var r=e.Matrix.Invert(t.getViewMatrix()),n=e.Vector3.TransformNormal(new e.Vector3(0,0,-1),r);n.normalize(),isNaN(n.x)||isNaN(n.y)||isNaN(n.z)||i.audioContext.listener.setOrientation(n.x,n.y,n.z,0,1,0);var o;for(o=0;o-1&&this._engine.scenes.splice(t,1),this._engine.wipeCaches(),this._engine=null,this.defaultMaterial=null,this.multiMaterials=null,this.materials=null},Object.defineProperty(r.prototype,"isDisposed",{get:function(){return!this._engine},enumerable:!0,configurable:!0}),r.prototype.disposeSounds=function(){this.mainSoundTrack.dispose();for(var e=0;e=n.distance))&&(n=h,r)))break}return n||new e.PickingInfo},r.prototype._internalMultiPick=function(t,i){if(!e.PickingInfo)return null;for(var r=new Array,n=0;n0)for(var s=0;s=o.distance))&&(o=l,r))break}}return o||new e.PickingInfo},r.prototype.pick=function(e,t,i,r,n){var o=this;return this._internalPick((function(i){return o.createPickingRay(e,t,i,n)}),i,r)},r.prototype.pickSprite=function(e,t,i,r,n){return this._internalPickSprites(this.createPickingRayInCameraSpace(e,t,n),i,r,n)},r.prototype.pickWithRay=function(t,i,r){var n=this;return this._internalPick((function(i){return n._pickWithRayInverseMatrix||(n._pickWithRayInverseMatrix=e.Matrix.Identity()),i.invertToRef(n._pickWithRayInverseMatrix),e.Ray.Transform(t,n._pickWithRayInverseMatrix)}),i,r)},r.prototype.multiPick=function(e,t,i,r){var n=this;return this._internalMultiPick((function(i){return n.createPickingRay(e,t,i,r)}),i)},r.prototype.multiPickWithRay=function(t,i){var r=this;return this._internalMultiPick((function(i){return r._pickWithRayInverseMatrix||(r._pickWithRayInverseMatrix=e.Matrix.Identity()),i.invertToRef(r._pickWithRayInverseMatrix),e.Ray.Transform(t,r._pickWithRayInverseMatrix)}),i)},r.prototype.setPointerOverMesh=function(t){this._pointerOverMesh!==t&&(this._pointerOverMesh&&this._pointerOverMesh.actionManager&&this._pointerOverMesh.actionManager.processTrigger(e.ActionManager.OnPointerOutTrigger,e.ActionEvent.CreateNew(this._pointerOverMesh)),this._pointerOverMesh=t,this._pointerOverMesh&&this._pointerOverMesh.actionManager&&this._pointerOverMesh.actionManager.processTrigger(e.ActionManager.OnPointerOverTrigger,e.ActionEvent.CreateNew(this._pointerOverMesh)))},r.prototype.getPointerOverMesh=function(){return this._pointerOverMesh},r.prototype.setPointerOverSprite=function(t){this._pointerOverSprite!==t&&(this._pointerOverSprite&&this._pointerOverSprite.actionManager&&this._pointerOverSprite.actionManager.processTrigger(e.ActionManager.OnPointerOutTrigger,e.ActionEvent.CreateNewFromSprite(this._pointerOverSprite,this)),this._pointerOverSprite=t,this._pointerOverSprite&&this._pointerOverSprite.actionManager&&this._pointerOverSprite.actionManager.processTrigger(e.ActionManager.OnPointerOverTrigger,e.ActionEvent.CreateNewFromSprite(this._pointerOverSprite,this)))},r.prototype.getPointerOverSprite=function(){return this._pointerOverSprite},r.prototype.getPhysicsEngine=function(){return this._physicsEngine},r.prototype.enablePhysics=function(t,i){if(this._physicsEngine)return!0;try{return this._physicsEngine=new e.PhysicsEngine(t,i),!0}catch(t){return e.Tools.Error(t.message),!1}},r.prototype.disablePhysicsEngine=function(){this._physicsEngine&&(this._physicsEngine.dispose(),this._physicsEngine=void 0)},r.prototype.isPhysicsEnabled=function(){return void 0!==this._physicsEngine},r.prototype.deleteCompoundImpostor=function(e){var t=e.parts[0].mesh;t.physicsImpostor.dispose(),t.physicsImpostor=null},r.prototype.createDefaultCameraOrLight=function(t,i,r){if(void 0===t&&(t=!1),void 0===i&&(i=!1),void 0===r&&(r=!1),i&&(this.activeCamera&&(this.activeCamera.dispose(),this.activeCamera=null),this.lights))for(var n=0;n=0&&this._scene.textures.splice(e,1),void 0!==this._texture&&(this.releaseInternalTexture(),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear())},t.prototype.serialize=function(){if(!this.name)return null;var t=e.SerializationHelper.Serialize(this);return e.Animation.AppendSerializedAnimations(this,t),t},t.WhenAllReady=function(e,t){var i=e.length;if(0===i)return void t();for(var r,n,o=0;o0},enumerable:!0,configurable:!0}),r.prototype._sortLODLevels=function(){this._LODLevels.sort((function(e,t){return e.distancet.distance?-1:0}))},r.prototype.addLODLevel=function(t,i){if(i&&i._masterMesh)return e.Tools.Warn("You cannot use a mesh as LOD level twice"),this;var r=new e.Internals.MeshLODLevel(t,i);return this._LODLevels.push(r),i&&(i._masterMesh=this),this._sortLODLevels(),this},r.prototype.getLODLevelAtDistance=function(e){for(var t=0;ti)return this.onLODLevelSelection&&this.onLODLevelSelection(i,this,this._LODLevels[this._LODLevels.length-1].mesh),this;for(var r=0;r0){var r=this.getIndices().length,n=!1;if(t)n=!0;else for(var o=0,s=this.subMeshes;o=r){n=!0;break}if(a.verticesStart+a.verticesCount>=i){n=!0;break}}if(!n)return}return this.releaseSubMeshes(),new e.SubMesh(0,0,i,0,this.getTotalIndices(),this)},r.prototype.subdivide=function(t){if(!(t<1)){for(var i=this.getTotalIndices(),r=i/t|0,n=0;r%3!=0;)r++;this.releaseSubMeshes();for(var o=0;o=i);o++)e.SubMesh.CreateFromIndices(0,n,Math.min(r,i-n),this),n+=r;this.synchronizeInstances()}},r.prototype.setVerticesData=function(t,i,r,n){if(this._geometry)this._geometry.setVerticesData(t,i,r,n);else{var o=new e.VertexData;o.set(i,t);var s=this.getScene();new e.Geometry(e.Geometry.RandomId(),s,o,r,this)}return this},r.prototype.markVerticesDataAsUpdatable=function(e,t){void 0===t&&(t=!0),this.getVertexBuffer(e).isUpdatable()!==t&&this.setVerticesData(e,this.getVerticesData(e),t)},r.prototype.setVerticesBuffer=function(t){if(!this._geometry){var i=this.getScene();new e.Geometry(e.Geometry.RandomId(),i).applyToMesh(this)}return this._geometry.setVerticesBuffer(t),this},r.prototype.updateVerticesData=function(e,t,i,r){if(this._geometry)return r?(this.makeGeometryUnique(),this.updateVerticesData(e,t,i,!1)):this._geometry.updateVerticesData(e,t,i),this},r.prototype.updateMeshPositions=function(t,i){void 0===i&&(i=!0);var r=this.getVerticesData(e.VertexBuffer.PositionKind);if(t(r),this.updateVerticesData(e.VertexBuffer.PositionKind,r,!1,!1),i){var n=this.getIndices(),o=this.getVerticesData(e.VertexBuffer.NormalKind);e.VertexData.ComputeNormals(r,n,o),this.updateVerticesData(e.VertexBuffer.NormalKind,o,!1,!1)}return this},r.prototype.makeGeometryUnique=function(){if(this._geometry){var t=this._geometry,i=this._geometry.copy(e.Geometry.RandomId());return t.releaseForMesh(this,!0),i.applyToMesh(this),this}},r.prototype.setIndices=function(t,i){if(this._geometry)this._geometry.setIndices(t,i);else{var r=new e.VertexData;r.indices=t;var n=this.getScene();new e.Geometry(e.Geometry.RandomId(),n,r,!1,this)}return this},r.prototype.toLeftHanded=function(){if(this._geometry)return this._geometry.toLeftHanded(),this},r.prototype._bind=function(t,i,r){var n,o=this.getScene().getEngine();if(this._unIndexed)n=null;else switch(r){case e.Material.PointFillMode:n=null;break;case e.Material.WireFrameFillMode:n=t.getLinesIndexBuffer(this.getIndices(),o);break;default:case e.Material.TriangleFillMode:n=this._unIndexed?null:this._geometry.getIndexBuffer()}return this._geometry._bind(i,n),this},r.prototype._draw=function(t,i,r){if(!this._geometry||!this._geometry.getVertexBuffers()||!this._geometry.getIndexBuffer())return this;this.onBeforeDrawObservable.notifyObservers(this);var n=this.getScene().getEngine();switch(i){case e.Material.PointFillMode:n.drawPointClouds(t.verticesStart,t.verticesCount,r);break;case e.Material.WireFrameFillMode:this._unIndexed?n.drawUnIndexed(!1,t.verticesStart,t.verticesCount,r):n.draw(!1,0,r>0?t.linesIndexCount/2:t.linesIndexCount,r);break;default:this._unIndexed?n.drawUnIndexed(!0,t.verticesStart,t.verticesCount,r):n.draw(!0,t.indexStart,t.indexCount,r)}return this},r.prototype.registerBeforeRender=function(e){return this.onBeforeRenderObservable.add(e),this},r.prototype.unregisterBeforeRender=function(e){return this.onBeforeRenderObservable.removeCallback(e),this},r.prototype.registerAfterRender=function(e){return this.onAfterRenderObservable.add(e),this},r.prototype.unregisterAfterRender=function(e){return this.onAfterRenderObservable.removeCallback(e),this},r.prototype._getInstancesRenderList=function(e){var t=this.getScene();if(this._batchCache.mustReturn=!1,this._batchCache.renderSelf[e]=this.isEnabled()&&this.isVisible,this._batchCache.visibleInstances[e]=null,this._visibleInstances){var i=t.getRenderId(),r=t._isInIntermediateRendering()?this._visibleInstances.intermediateDefaultRenderId:this._visibleInstances.defaultRenderId;this._batchCache.visibleInstances[e]=this._visibleInstances[i];var n=this._renderId;if(!this._batchCache.visibleInstances[e]&&r&&(this._batchCache.visibleInstances[e]=this._visibleInstances[r],i=Math.max(r,i),n=Math.max(this._visibleInstances.selfDefaultRenderId,i)),this._batchCache.visibleInstances[e]&&this._batchCache.visibleInstances[e].length){if(this._renderIdForInstances[e]===i)return this._batchCache.mustReturn=!0,this._batchCache;i!==n&&(this._batchCache.renderSelf[e]=!1)}this._renderIdForInstances[e]=i}return this._batchCache},r.prototype._renderWithInstances=function(t,i,r,n,o){for(var s=r.visibleInstances[t._id],a=s.length+1,l=16*a*4,h=this._instancesBufferSize,c=this._instancesBuffer;this._instancesBufferSize-1;t--)if(i[t].id===e)return this.material=i[t],this;var r=this.getScene().multiMaterials;for(t=r.length-1;t>-1;t--)if(r[t].id===e)return this.material=r[t],this;return this},r.prototype.getAnimatables=function(){var e=[];return this.material&&e.push(this.material),this.skeleton&&e.push(this.skeleton),e},r.prototype.bakeTransformIntoVertices=function(t){if(!this.isVerticesDataPresent(e.VertexBuffer.PositionKind))return this;var i=this.subMeshes.splice(0);this._resetPointsArrayCache();var r,n=this.getVerticesData(e.VertexBuffer.PositionKind),o=[];for(r=0;r-1&&(o.morphTargetManager=i.getMorphTargetManagerById(t.morphTargetManagerId)),t.skeletonId>-1&&(o.skeleton=i.getLastSkeletonByID(t.skeletonId),t.numBoneInfluencers&&(o.numBoneInfluencers=t.numBoneInfluencers)),t.animations){for(var s=0;s4,h=l?this.getVerticesData(e.VertexBuffer.MatricesIndicesExtraKind):null,c=l?this.getVerticesData(e.VertexBuffer.MatricesWeightsExtraKind):null,u=t.getTransformMatrices(this),f=e.Vector3.Zero(),d=new e.Matrix,p=new e.Matrix,_=0,m=0;m0;o++)e.Matrix.FromFloat32ArrayToRefScaled(u,16*s[_+o],g,p),d.addToSelf(p);if(l)for(o=0;o<4&&(g=c[_+o])>0;o++)e.Matrix.FromFloat32ArrayToRefScaled(u,16*h[_+o],g,p),d.addToSelf(p);e.Vector3.TransformCoordinatesFromFloatsToRef(this._sourcePositions[m],this._sourcePositions[m+1],this._sourcePositions[m+2],d,f),f.toArray(r,m),e.Vector3.TransformNormalFromFloatsToRef(this._sourceNormals[m],this._sourceNormals[m+1],this._sourceNormals[m+2],d,f),f.toArray(n,m),d.reset()}return this.updateVerticesData(e.VertexBuffer.PositionKind,r),this.updateVerticesData(e.VertexBuffer.NormalKind,n),this},r.MinMax=function(e){var t=null,i=null;return e.forEach((function(e,r,n){var o=e.getBoundingInfo().boundingBox;t?(t.MinimizeInPlace(o.minimumWorld),i.MaximizeInPlace(o.maximumWorld)):(t=o.minimumWorld,i=o.maximumWorld)})),{min:t,max:i}},r.Center=function(t){var i=t instanceof Array?e.Mesh.MinMax(t):t;return e.Vector3.Center(i.min,i.max)},r.MergeMeshes=function(t,i,n,o,s){void 0===i&&(i=!0);var a;if(!n){var l=0;for(a=0;a65536)return e.Tools.Warn("Cannot merge meshes because resulting mesh will have more than 65536 vertices. Please use allow32BitsIndices = true to use 32 bits indices"),null}var h,c,u,f=new Array;for(a=0;aa&&(a=c)}return new i(e,s,a-s+1,t,r,n,o)},i})(t);e.SubMesh=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(BABYLON){var EffectFallbacks=(function(){function e(){this._defines={},this._currentRank=32,this._maxRank=-1}return e.prototype.addFallback=function(e,t){this._defines[e]||(ethis._maxRank&&(this._maxRank=e),this._defines[e]=new Array),this._defines[e].push(t)},e.prototype.addCPUSkinningFallback=function(e,t){this._meshRank=e,this._mesh=t,ethis._maxRank&&(this._maxRank=e)},Object.defineProperty(e.prototype,"isMoreFallbacks",{get:function(){return this._currentRank<=this._maxRank},enumerable:!0,configurable:!0}),e.prototype.reduce=function(e){if(this._mesh&&this._mesh.computeBonesUsingShaders&&this._mesh.numBoneInfluencers>0){this._mesh.computeBonesUsingShaders=!1,e=e.replace("#define NUM_BONE_INFLUENCERS "+this._mesh.numBoneInfluencers,"#define NUM_BONE_INFLUENCERS 0"),BABYLON.Tools.Log("Falling back to CPU skinning for "+this._mesh.name);for(var t=this._mesh.getScene(),i=0;i0&&(r.computeBonesUsingShaders=!1)}}else{var n=this._defines[this._currentRank];if(n)for(var i=0;i-1?e:BABYLON.Engine.ShadersRepository+e,BABYLON.Tools.LoadFile(i+".vertex.fx",t)},Effect.prototype._loadFragmentShader=function(e,t){if(e instanceof HTMLElement){return void t(BABYLON.Tools.GetDOMTextContent(e))}if("base64:"===e.substr(0,7)){return void t(window.atob(e.substr(7)))}if(Effect.ShadersStore[e+"PixelShader"])return void t(Effect.ShadersStore[e+"PixelShader"]);if(Effect.ShadersStore[e+"FragmentShader"])return void t(Effect.ShadersStore[e+"FragmentShader"]);var i;i="."===e[0]||"/"===e[0]||e.indexOf("http")>-1?e:BABYLON.Engine.ShadersRepository+e,BABYLON.Tools.LoadFile(i+".fragment.fx",t)},Effect.prototype._dumpShadersSource=function(e,t,i){var r=this._engine.webGLVersion>1?"#version 300 es\n":"",n=r+(i?i+"\n":"");e=n+e,t=n+t;var o=2,s="\n1\t"+e.replace(/\n/gm,(function(){return"\n"+o+++"\t"}));o=2;var a="\n1\t"+t.replace(/\n/gm,(function(){return"\n"+o+++"\t"}));this.name.vertexElement?(BABYLON.Tools.Error("Vertex shader: "+this.name.vertexElement+s),BABYLON.Tools.Error("Fragment shader: "+this.name.fragmentElement+a)):this.name.vertex?(BABYLON.Tools.Error("Vertex shader: "+this.name.vertex+s),BABYLON.Tools.Error("Fragment shader: "+this.name.fragment+a)):(BABYLON.Tools.Error("Vertex shader: "+this.name+s),BABYLON.Tools.Error("Fragment shader: "+this.name+a))},Effect.prototype._processShaderConversion=function(e,t,i){var r=this._processPrecision(e);if(1==this._engine.webGLVersion)return void i(r);if(-1!==r.indexOf("#version 3"))return void i(r.replace("#version 300 es",""));var n=r.replace(/#extension.+(GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth).+enable/g,"");n=n.replace(/varying(?![\n\r])\s/g,t?"in ":"out "),n=n.replace(/attribute[ \t]/g,"in "),n=n.replace(/[ \t]attribute/g," in"),t&&(n=n.replace(/texture2DLodEXT\(/g,"textureLod("),n=n.replace(/textureCubeLodEXT\(/g,"textureLod("),n=n.replace(/texture2D\(/g,"texture("),n=n.replace(/textureCube\(/g,"texture("),n=n.replace(/gl_FragDepthEXT/g,"gl_FragDepth"),n=n.replace(/gl_FragColor/g,"glFragColor"),n=n.replace(/void\s+?main\(/g,"out vec4 glFragColor;\nvoid main(")),i(n)},Effect.prototype._processIncludes=function(e,t){for(var i=this,r=/#include<(.+)>(\((.*)\))*(\[(.*)\])*/g,n=r.exec(e),o=new String(e);null!=n;){var s=n[1];if(-1!==s.indexOf("__decl__")&&(s=s.replace(/__decl__/,""),1!=this._engine.webGLVersion&&(s=s.replace(/Vertex/,"Ubo"),s=s.replace(/Fragment/,"Ubo")),s+="Declaration"),!Effect.IncludesShadersStore[s]){var a=BABYLON.Engine.ShadersRepository+"ShadersInclude/"+s+".fx";return void BABYLON.Tools.LoadFile(a,(function(e){Effect.IncludesShadersStore[s]=e,i._processIncludes(o,t)}))}var l=Effect.IncludesShadersStore[s];if(n[2])for(var h=n[3].split(","),c=0;c1)for(var s in this._uniformBuffersNames)this.bindUniformBlock(s,this._uniformBuffersNames[s]);this._uniforms=o.getUniforms(this._program,this._uniformsNames),this._attributes=o.getAttributes(this._program,i);var a;for(a=0;a0&&(result+=line+"\r\n")}return result},Effect.prototype._evaluateDefinesOnString=function(e){for(var t={children:[]},i=t,r=e.split("\n"),n=0;n0,i.NUM_MORPH_INFLUENCERS=s.numInfluencers}else i.MORPHTARGETS_TANGENT=!1,i.MORPHTARGETS_NORMAL=!1,i.MORPHTARGETS=!1,i.NUM_MORPH_INFLUENCERS=0;return!0},t.PrepareDefinesForLights=function(t,i,r,n,o,s){if(void 0===o&&(o=4),void 0===s&&(s=!1),!r._areLightsDirty)return r._needNormals;var a=0,l=!1,h=!1,c=!1,u=!1,f=!1;if(t.lightsEnabled&&!s)for(var d=0,p=i._lightSources;d0&&t.addFallback(r,"LIGHT"+r),e["SHADOW"+r]&&t.addFallback(0,"SHADOW"+r),e["SHADOWPCF"+r]&&t.addFallback(0,"SHADOWPCF"+r),e["SHADOWESM"+r]&&t.addFallback(0,"SHADOWESM"+r)},t.PrepareAttributesForMorphTargets=function(t,i,r){var n=r.NUM_MORPH_INFLUENCERS;if(n>0)for(var o=e.Engine.LastCreatedEngine.getCaps().maxVertexAttribs,s=i.morphTargetManager,a=s.supportsNormals&&r.NORMAL,l=s.supportsTangents&&r.TANGENT,h=0;ho&&e.Tools.Error("Cannot add more vertex attributes for mesh "+i.name)},t.PrepareAttributesForBones=function(t,i,r,n){r.NUM_BONE_INFLUENCERS>0&&(n.addCPUSkinningFallback(0,i),t.push(e.VertexBuffer.MatricesIndicesKind),t.push(e.VertexBuffer.MatricesWeightsKind),r.NUM_BONE_INFLUENCERS>4&&(t.push(e.VertexBuffer.MatricesIndicesExtraKind),t.push(e.VertexBuffer.MatricesWeightsExtraKind)))},t.PrepareAttributesForInstances=function(e,t){t.INSTANCES&&(e.push("world0"),e.push("world1"),e.push("world2"),e.push("world3"))},t.BindLightShadow=function(e,t,i,r,n){if(e.shadowEnabled&&i.receiveShadows){var o=e.getShadowGenerator();o&&o.bindShadowLight(r,n)}},t.BindLightProperties=function(e,t,i){e.transferToEffect(t,i+"")},t.BindLights=function(i,r,n,o,s,a){void 0===s&&(s=4),void 0===a&&(a=!1);for(var l=0,h=0,c=r._lightSources;h1,n||this._scene.materials.push(this)}return Object.defineProperty(t,"TriangleFillMode",{get:function(){return t._TriangleFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(t,"WireFrameFillMode",{get:function(){return t._WireFrameFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(t,"PointFillMode",{get:function(){return t._PointFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(t,"ClockWiseSideOrientation",{get:function(){return t._ClockWiseSideOrientation},enumerable:!0,configurable:!0}),Object.defineProperty(t,"CounterClockWiseSideOrientation",{get:function(){return t._CounterClockWiseSideOrientation},enumerable:!0,configurable:!0}),Object.defineProperty(t,"TextureDirtyFlag",{get:function(){return t._TextureDirtyFlag},enumerable:!0,configurable:!0}),Object.defineProperty(t,"LightDirtyFlag",{get:function(){return t._LightDirtyFlag},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FresnelDirtyFlag",{get:function(){return t._FresnelDirtyFlag},enumerable:!0,configurable:!0}),Object.defineProperty(t,"AttributesDirtyFlag",{get:function(){return t._AttributesDirtyFlag},enumerable:!0,configurable:!0}),Object.defineProperty(t,"MiscDirtyFlag",{get:function(){return t._MiscDirtyFlag},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"backFaceCulling",{get:function(){return this._backFaceCulling},set:function(e){this._backFaceCulling!==e&&(this._backFaceCulling=e,this.markAsDirty(t.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onBind",{set:function(e){this._onBindObserver&&this.onBindObservable.remove(this._onBindObserver),this._onBindObserver=this.onBindObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"fogEnabled",{get:function(){return this._fogEnabled},set:function(e){this._fogEnabled!==e&&(this._fogEnabled=e,this.markAsDirty(t.MiscDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"wireframe",{get:function(){return this._fillMode===t.WireFrameFillMode},set:function(e){this._fillMode=e?t.WireFrameFillMode:t.TriangleFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"pointsCloud",{get:function(){return this._fillMode===t.PointFillMode},set:function(e){this._fillMode=e?t.PointFillMode:t.TriangleFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"fillMode",{get:function(){return this._fillMode},set:function(e){this._fillMode!==e&&(this._fillMode=e,this.markAsDirty(t.MiscDirtyFlag))},enumerable:!0,configurable:!0}),t.prototype.toString=function(e){return"Name: "+this.name},t.prototype.getClassName=function(){return"Material"},Object.defineProperty(t.prototype,"isFrozen",{get:function(){return this.checkReadyOnlyOnce},enumerable:!0,configurable:!0}),t.prototype.freeze=function(){this.checkReadyOnlyOnce=!0},t.prototype.unfreeze=function(){this.checkReadyOnlyOnce=!1},t.prototype.isReady=function(e,t){return!0},t.prototype.isReadyForSubMesh=function(e,t,i){return!1},t.prototype.getEffect=function(){return this._effect},t.prototype.getScene=function(){return this._scene},t.prototype.needAlphaBlending=function(){return this.alpha<1},t.prototype.needAlphaTesting=function(){return!1},t.prototype.getAlphaTestTexture=function(){return null},t.prototype.markDirty=function(){this._wasPreviouslyReady=!1},t.prototype._preBind=function(e){var i=this._scene.getEngine(),r=this.sideOrientation===t.ClockWiseSideOrientation;i.enableEffect(e||this._effect),i.setState(this.backFaceCulling,this.zOffset,!1,r)},t.prototype.bind=function(e,t){},t.prototype.bindForSubMesh=function(e,t,i){},t.prototype.bindOnlyWorldMatrix=function(e){},t.prototype.bindSceneUniformBuffer=function(e,t){t.bindToEffect(e,"Scene")},t.prototype.bindView=function(e){this._useUBO?this.bindSceneUniformBuffer(e,this.getScene().getSceneUniformBuffer()):e.setMatrix("view",this.getScene().getViewMatrix())},t.prototype.bindViewProjection=function(e){this._useUBO?this.bindSceneUniformBuffer(e,this.getScene().getSceneUniformBuffer()):e.setMatrix("viewProjection",this.getScene().getTransformMatrix())},t.prototype._afterBind=function(e){if(this._scene._cachedMaterial=this,this.onBindObservable.notifyObservers(e),this.disableDepthWrite){var t=this._scene.getEngine();this._cachedDepthWriteState=t.getDepthWrite(),t.setDepthWrite(!1)}},t.prototype.unbind=function(){if(this.onUnBindObservable.notifyObservers(this),this.disableDepthWrite){this._scene.getEngine().setDepthWrite(this._cachedDepthWriteState)}},t.prototype.getActiveTextures=function(){return[]},t.prototype.hasTexture=function(e){return!1},t.prototype.clone=function(e){return null},t.prototype.getBindedMeshes=function(){for(var e=new Array,t=0;t=0&&this._scene.materials.splice(i,1),i=0;ia?a:Math.floor(l);var h,c,u,f,d=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,p=i.uvs,_=i.colors,m=[],g=[],v=[],y=[],x=[],b=[],A=[],T=[],E=[],P=[];if(r.length<2){var M=[],S=[];for(u=0;u0&&(D=C[f].subtract(C[f-1]).length(),B=D+A[c],x[c].push(B),A[c]=B),f++;o&&(f--,m.push(C[0].x,C[0].y,C[0].z),D=C[f].subtract(C[0]).length(),B=D+A[c],x[c].push(B),A[c]=B),E[c]=R+I,P[c]=O,O+=R+I}var L,w,F,N;for(u=0;u1?1:i.arc||1,l=i.slice<=0?1:i.slice||1,h=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,c=new e.Vector3(n/2,o/2,s/2),u=2+r,f=2*u,d=[],p=[],_=[],m=[],g=0;g<=u;g++){for(var v=g/u,y=v*Math.PI*l,x=0;x<=f;x++){var b=x/f,A=b*Math.PI*2*a,T=e.Matrix.RotationZ(-y),E=e.Matrix.RotationY(A),P=e.Vector3.TransformCoordinates(e.Vector3.Up(),T),M=e.Vector3.TransformCoordinates(P,E),S=M.multiply(c),C=M.divide(c).normalize();p.push(S.x,S.y,S.z),_.push(C.x,C.y,C.z),m.push(b,v)}if(g>0)for(var R=p.length/3,O=R-2*(f+1);O+f+21?1:i.arc||1,f=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,d=i.faceUV||new Array(3),p=i.faceColors,_=1!==u&&c?2:0,m=h?l:1,g=2+(1+_)*m;for(r=0;r0&&(i.push(o-1),i.push(o)),o++;var h=new t;return h.indices=i,h.positions=r,h},t.CreateDashedLines=function(i){var r=i.dashSize||3,n=i.gapSize||1,o=i.dashNb||200,s=i.points,a=new Array,l=new Array,h=e.Vector3.Zero(),c=0,u=0,f=0,d=0,p=0,_=0,m=0;for(m=0;m1?1:i.arc||1,c=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE;r.push(0,0,0),s.push(.5,.5);for(var u=2*Math.PI*h,f=u/l,d=0;d=r.length?0:i.type||0,u=i.size,f=i.sizeX||u||1,d=i.sizeY||u||1,p=i.sizeZ||u||1,_=i.custom||r[c],m=_.face.length,g=i.faceUV||new Array(m),v=i.faceColors,y=void 0===i.flat||i.flat,x=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,b=[],A=[],T=[],E=[],P=[],M=0,S=0,C=[],R=0,O=0;if(y)for(O=0;Or.bbSize.y?r.bbSize.x:r.bbSize.y;H=H>r.bbSize.z?H:r.bbSize.z;var W=r.subDiv.X*r.ratio/r.bbSize.x,j=r.subDiv.Y*r.ratio/r.bbSize.y,X=r.subDiv.Z*r.ratio/r.bbSize.z,K=r.subDiv.max*r.subDiv.max;r.facetPartitioning.length=0}for(n=0;n0&&(this._indexBuffer=this._engine.createIndexBuffer(this._indices)),this._indexBuffer&&(this._indexBuffer.references=i)},t.prototype.notifyUpdate=function(e){this.onGeometryUpdated&&this.onGeometryUpdated(this,e);for(var t=0,i=this._meshes;t0){for(var i=0;i0){for(var i=0;i0){for(var i=0;i0){var l=new Float32Array(i,a.positionsAttrDesc.offset,a.positionsAttrDesc.count);r.setVerticesData(e.VertexBuffer.PositionKind,l,!1)}if(a.normalsAttrDesc&&a.normalsAttrDesc.count>0){var h=new Float32Array(i,a.normalsAttrDesc.offset,a.normalsAttrDesc.count);r.setVerticesData(e.VertexBuffer.NormalKind,h,!1)}if(a.uvsAttrDesc&&a.uvsAttrDesc.count>0){var c=new Float32Array(i,a.uvsAttrDesc.offset,a.uvsAttrDesc.count);r.setVerticesData(e.VertexBuffer.UVKind,c,!1)}if(a.uvs2AttrDesc&&a.uvs2AttrDesc.count>0){var u=new Float32Array(i,a.uvs2AttrDesc.offset,a.uvs2AttrDesc.count);r.setVerticesData(e.VertexBuffer.UV2Kind,u,!1)}if(a.uvs3AttrDesc&&a.uvs3AttrDesc.count>0){var f=new Float32Array(i,a.uvs3AttrDesc.offset,a.uvs3AttrDesc.count);r.setVerticesData(e.VertexBuffer.UV3Kind,f,!1)}if(a.uvs4AttrDesc&&a.uvs4AttrDesc.count>0){var d=new Float32Array(i,a.uvs4AttrDesc.offset,a.uvs4AttrDesc.count);r.setVerticesData(e.VertexBuffer.UV4Kind,d,!1)}if(a.uvs5AttrDesc&&a.uvs5AttrDesc.count>0){var p=new Float32Array(i,a.uvs5AttrDesc.offset,a.uvs5AttrDesc.count);r.setVerticesData(e.VertexBuffer.UV5Kind,p,!1)}if(a.uvs6AttrDesc&&a.uvs6AttrDesc.count>0){var _=new Float32Array(i,a.uvs6AttrDesc.offset,a.uvs6AttrDesc.count);r.setVerticesData(e.VertexBuffer.UV6Kind,_,!1)}if(a.colorsAttrDesc&&a.colorsAttrDesc.count>0){var m=new Float32Array(i,a.colorsAttrDesc.offset,a.colorsAttrDesc.count);r.setVerticesData(e.VertexBuffer.ColorKind,m,!1,a.colorsAttrDesc.stride)}if(a.matricesIndicesAttrDesc&&a.matricesIndicesAttrDesc.count>0){var g=new Int32Array(i,a.matricesIndicesAttrDesc.offset,a.matricesIndicesAttrDesc.count);r.setVerticesData(e.VertexBuffer.MatricesIndicesKind,g,!1)}if(a.matricesWeightsAttrDesc&&a.matricesWeightsAttrDesc.count>0){var v=new Float32Array(i,a.matricesWeightsAttrDesc.offset,a.matricesWeightsAttrDesc.count);r.setVerticesData(e.VertexBuffer.MatricesWeightsKind,v,!1)}if(a.indicesAttrDesc&&a.indicesAttrDesc.count>0){var y=new Int32Array(i,a.indicesAttrDesc.offset,a.indicesAttrDesc.count);r.setIndices(y)}if(a.subMeshesAttrDesc&&a.subMeshesAttrDesc.count>0){var x=new Int32Array(i,a.subMeshesAttrDesc.offset,5*a.subMeshesAttrDesc.count);r.subMeshes=[];for(var b=0;b>8),S.push((16711680&C)>>16),S.push(C>>24)}r.setVerticesData(e.VertexBuffer.MatricesIndicesKind,S,i.matricesIndices._updatable)}if(i.matricesIndicesExtra)if(i.matricesIndicesExtra._isExpanded)delete i.matricesIndices._isExpanded,r.setVerticesData(e.VertexBuffer.MatricesIndicesExtraKind,i.matricesIndicesExtra,i.matricesIndicesExtra._updatable);else{for(var S=[],b=0;b>8),S.push((16711680&C)>>16),S.push(C>>24)}r.setVerticesData(e.VertexBuffer.MatricesIndicesExtraKind,S,i.matricesIndicesExtra._updatable)}i.matricesWeights&&(t._CleanMatricesWeights(i.matricesWeights,i.numBoneInfluencers),r.setVerticesData(e.VertexBuffer.MatricesWeightsKind,i.matricesWeights,i.matricesWeights._updatable)),i.matricesWeightsExtra&&(t._CleanMatricesWeights(i.matricesWeightsExtra,i.numBoneInfluencers),r.setVerticesData(e.VertexBuffer.MatricesWeightsExtraKind,i.matricesWeightsExtra,i.matricesWeights._updatable)),r.setIndices(i.indices)}if(i.subMeshes){r.subMeshes=[];for(var R=0;Ra&&(a=t[n+l],s=n+l);t[s]+=Math.max(0,1-o)}},t.Parse=function(i,r,n){if(r.getGeometryByID(i.id))return null;var o=new t(i.id,r,null,i.updatable);return e.Tags&&e.Tags.AddTagsTo(o,i.tags),i.delayLoadingFile?(o.delayLoadState=e.Engine.DELAYLOADSTATE_NOTLOADED,o.delayLoadingFile=n+i.delayLoadingFile,o._boundingInfo=new e.BoundingInfo(e.Vector3.FromArray(i.boundingBoxMinimum),e.Vector3.FromArray(i.boundingBoxMaximum)),o._delayInfo=[],i.hasUVs&&o._delayInfo.push(e.VertexBuffer.UVKind),i.hasUVs2&&o._delayInfo.push(e.VertexBuffer.UV2Kind),i.hasUVs3&&o._delayInfo.push(e.VertexBuffer.UV3Kind),i.hasUVs4&&o._delayInfo.push(e.VertexBuffer.UV4Kind),i.hasUVs5&&o._delayInfo.push(e.VertexBuffer.UV5Kind),i.hasUVs6&&o._delayInfo.push(e.VertexBuffer.UV6Kind),i.hasColors&&o._delayInfo.push(e.VertexBuffer.ColorKind),i.hasMatricesIndices&&o._delayInfo.push(e.VertexBuffer.MatricesIndicesKind),i.hasMatricesWeights&&o._delayInfo.push(e.VertexBuffer.MatricesWeightsKind),o._delayLoadingFunction=e.VertexData.ImportVertexData):e.VertexData.ImportVertexData(i,o),r.pushGeometry(o,!0),o},t})();e.Geometry=t,(function(t){!(function(i){var r=(function(e){function t(t,i,r,n){var o=e.call(this,t,i,null,!1,n)||this;return o._canBeRegenerated=r,o._beingRegenerated=!0,o.regenerate(),o._beingRegenerated=!1,o}return __extends(t,e),t.prototype.canBeRegenerated=function(){return this._canBeRegenerated},t.prototype.regenerate=function(){this._canBeRegenerated&&(this._beingRegenerated=!0,this.setAllVerticesData(this._regenerateVertexData(),!1),this._beingRegenerated=!1)},t.prototype.asNewGeometry=function(t){return e.prototype.copy.call(this,t)},t.prototype.setAllVerticesData=function(t,i){this._beingRegenerated&&e.prototype.setAllVerticesData.call(this,t,!1)},t.prototype.setVerticesData=function(t,i,r){this._beingRegenerated&&e.prototype.setVerticesData.call(this,t,i,!1)},t.prototype._regenerateVertexData=function(){throw new Error("Abstract method")},t.prototype.copy=function(e){throw new Error("Must be overriden in sub-classes.")},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.canBeRegenerated=this.canBeRegenerated(),t},t})(t);i._Primitive=r;var n=(function(t){function i(i,r,n,o,s,a,l,h,c){void 0===c&&(c=e.Mesh.DEFAULTSIDE);var u=t.call(this,i,r,l,h)||this;return u.pathArray=n,u.closeArray=o,u.closePath=s,u.offset=a,u.side=c,u}return __extends(i,t),i.prototype._regenerateVertexData=function(){return e.VertexData.CreateRibbon({pathArray:this.pathArray,closeArray:this.closeArray,closePath:this.closePath,offset:this.offset,sideOrientation:this.side})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.pathArray,this.closeArray,this.closePath,this.offset,this.canBeRegenerated(),null,this.side)},i})(r);i.Ribbon=n;var o=(function(i){function r(t,r,n,o,s,a){void 0===a&&(a=e.Mesh.DEFAULTSIDE);var l=i.call(this,t,r,o,s)||this;return l.size=n,l.side=a,l}return __extends(r,i),r.prototype._regenerateVertexData=function(){return e.VertexData.CreateBox({size:this.size,sideOrientation:this.side})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.size,this.canBeRegenerated(),null,this.side)},r.prototype.serialize=function(){var e=i.prototype.serialize.call(this);return e.size=this.size,e},r.Parse=function(i,r){if(r.getGeometryByID(i.id))return null;var n=new t.Primitives.Box(i.id,r,i.size,i.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,i.tags),r.pushGeometry(n,!0),n},r})(r);i.Box=o;var s=(function(i){function r(t,r,n,o,s,a,l){void 0===l&&(l=e.Mesh.DEFAULTSIDE);var h=i.call(this,t,r,s,a)||this;return h.segments=n,h.diameter=o,h.side=l,h}return __extends(r,i),r.prototype._regenerateVertexData=function(){return e.VertexData.CreateSphere({segments:this.segments,diameter:this.diameter,sideOrientation:this.side})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.segments,this.diameter,this.canBeRegenerated(),null,this.side)},r.prototype.serialize=function(){var e=i.prototype.serialize.call(this);return e.segments=this.segments,e.diameter=this.diameter,e},r.Parse=function(i,r){if(r.getGeometryByID(i.id))return null;var n=new t.Primitives.Sphere(i.id,r,i.segments,i.diameter,i.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,i.tags),r.pushGeometry(n,!0),n},r})(r);i.Sphere=s;var a=(function(t){function i(i,r,n,o,s,a,l){void 0===l&&(l=e.Mesh.DEFAULTSIDE);var h=t.call(this,i,r,s,a)||this;return h.radius=n,h.tessellation=o,h.side=l,h}return __extends(i,t),i.prototype._regenerateVertexData=function(){return e.VertexData.CreateDisc({radius:this.radius,tessellation:this.tessellation,sideOrientation:this.side})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.radius,this.tessellation,this.canBeRegenerated(),null,this.side)},i})(r);i.Disc=a;var l=(function(i){function r(t,r,n,o,s,a,l,h,c,u){void 0===l&&(l=1),void 0===u&&(u=e.Mesh.DEFAULTSIDE);var f=i.call(this,t,r,h,c)||this;return f.height=n,f.diameterTop=o,f.diameterBottom=s,f.tessellation=a,f.subdivisions=l,f.side=u,f}return __extends(r,i),r.prototype._regenerateVertexData=function(){return e.VertexData.CreateCylinder({height:this.height,diameterTop:this.diameterTop,diameterBottom:this.diameterBottom,tessellation:this.tessellation,subdivisions:this.subdivisions,sideOrientation:this.side})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.height,this.diameterTop,this.diameterBottom,this.tessellation,this.subdivisions,this.canBeRegenerated(),null,this.side)},r.prototype.serialize=function(){var e=i.prototype.serialize.call(this);return e.height=this.height,e.diameterTop=this.diameterTop,e.diameterBottom=this.diameterBottom,e.tessellation=this.tessellation,e},r.Parse=function(i,r){if(r.getGeometryByID(i.id))return null;var n=new t.Primitives.Cylinder(i.id,r,i.height,i.diameterTop,i.diameterBottom,i.tessellation,i.subdivisions,i.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,i.tags),r.pushGeometry(n,!0),n},r})(r);i.Cylinder=l;var h=(function(i){function r(t,r,n,o,s,a,l,h){void 0===h&&(h=e.Mesh.DEFAULTSIDE);var c=i.call(this,t,r,a,l)||this;return c.diameter=n,c.thickness=o,c.tessellation=s,c.side=h,c}return __extends(r,i),r.prototype._regenerateVertexData=function(){return e.VertexData.CreateTorus({diameter:this.diameter,thickness:this.thickness,tessellation:this.tessellation,sideOrientation:this.side})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.diameter,this.thickness,this.tessellation,this.canBeRegenerated(),null,this.side)},r.prototype.serialize=function(){var e=i.prototype.serialize.call(this);return e.diameter=this.diameter,e.thickness=this.thickness,e.tessellation=this.tessellation,e},r.Parse=function(i,r){if(r.getGeometryByID(i.id))return null;var n=new t.Primitives.Torus(i.id,r,i.diameter,i.thickness,i.tessellation,i.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,i.tags),r.pushGeometry(n,!0),n},r})(r);i.Torus=h;var c=(function(i){function r(e,t,r,n,o,s,a){var l=i.call(this,e,t,s,a)||this;return l.width=r,l.height=n,l.subdivisions=o,l}return __extends(r,i),r.prototype._regenerateVertexData=function(){return e.VertexData.CreateGround({width:this.width,height:this.height,subdivisions:this.subdivisions})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.width,this.height,this.subdivisions,this.canBeRegenerated(),null)},r.prototype.serialize=function(){var e=i.prototype.serialize.call(this);return e.width=this.width,e.height=this.height,e.subdivisions=this.subdivisions,e},r.Parse=function(i,r){if(r.getGeometryByID(i.id))return null;var n=new t.Primitives.Ground(i.id,r,i.width,i.height,i.subdivisions,i.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,i.tags),r.pushGeometry(n,!0),n},r})(r);i.Ground=c;var u=(function(t){function i(e,i,r,n,o,s,a,l,h,c){var u=t.call(this,e,i,h,c)||this;return u.xmin=r,u.zmin=n,u.xmax=o,u.zmax=s,u.subdivisions=a,u.precision=l,u}return __extends(i,t),i.prototype._regenerateVertexData=function(){return e.VertexData.CreateTiledGround({xmin:this.xmin,zmin:this.zmin,xmax:this.xmax,zmax:this.zmax,subdivisions:this.subdivisions,precision:this.precision})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.xmin,this.zmin,this.xmax,this.zmax,this.subdivisions,this.precision,this.canBeRegenerated(),null)},i})(r);i.TiledGround=u;var f=(function(i){function r(t,r,n,o,s,a){void 0===a&&(a=e.Mesh.DEFAULTSIDE);var l=i.call(this,t,r,o,s)||this;return l.size=n,l.side=a,l}return __extends(r,i),r.prototype._regenerateVertexData=function(){return e.VertexData.CreatePlane({size:this.size,sideOrientation:this.side})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.size,this.canBeRegenerated(),null,this.side)},r.prototype.serialize=function(){var e=i.prototype.serialize.call(this);return e.size=this.size,e},r.Parse=function(i,r){if(r.getGeometryByID(i.id))return null;var n=new t.Primitives.Plane(i.id,r,i.size,i.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,i.tags),r.pushGeometry(n,!0),n},r})(r);i.Plane=f;var d=(function(i){function r(t,r,n,o,s,a,l,h,c,u,f){void 0===f&&(f=e.Mesh.DEFAULTSIDE);var d=i.call(this,t,r,c,u)||this;return d.radius=n,d.tube=o,d.radialSegments=s,d.tubularSegments=a,d.p=l,d.q=h,d.side=f,d}return __extends(r,i),r.prototype._regenerateVertexData=function(){return e.VertexData.CreateTorusKnot({radius:this.radius,tube:this.tube,radialSegments:this.radialSegments,tubularSegments:this.tubularSegments,p:this.p,q:this.q,sideOrientation:this.side})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.radius,this.tube,this.radialSegments,this.tubularSegments,this.p,this.q,this.canBeRegenerated(),null,this.side)},r.prototype.serialize=function(){var e=i.prototype.serialize.call(this);return e.radius=this.radius,e.tube=this.tube,e.radialSegments=this.radialSegments,e.tubularSegments=this.tubularSegments,e.p=this.p,e.q=this.q,e},r.Parse=function(i,r){if(r.getGeometryByID(i.id))return null;var n=new t.Primitives.TorusKnot(i.id,r,i.radius,i.tube,i.radialSegments,i.tubularSegments,i.p,i.q,i.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,i.tags),r.pushGeometry(n,!0),n},r})(r);i.TorusKnot=d})(t.Primitives||(t.Primitives={}))})(t=e.Geometry||(e.Geometry={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e){this._vertexBuffers={},this._scene=e}return t.prototype._prepareBuffers=function(){if(!this._vertexBuffers[e.VertexBuffer.PositionKind]){var t=[];t.push(1,1),t.push(-1,1),t.push(-1,-1),t.push(1,-1),this._vertexBuffers[e.VertexBuffer.PositionKind]=new e.VertexBuffer(this._scene.getEngine(),t,e.VertexBuffer.PositionKind,!1,!1,2);var i=[];i.push(0),i.push(1),i.push(2),i.push(0),i.push(2),i.push(3),this._indexBuffer=this._scene.getEngine().createIndexBuffer(i)}},t.prototype._prepareFrame=function(e,t){var t=t||this._scene.activeCamera._postProcesses;return!(0===t.length||!this._scene.postProcessesEnabled)&&(t[0].activate(this._scene.activeCamera,e,null!==t&&void 0!==t),!0)},t.prototype.directRender=function(e,t){for(var i=this._scene.getEngine(),r=0;r=this._sampleCount||e>=this._samples.length)return null;var t=this._wrapPosition(this._pos-1);return this._samples[this._wrapPosition(t-e)]},e.prototype.isSaturated=function(){return this._sampleCount>=this._samples.length},e.prototype.reset=function(){this.average=0,this.variance=0,this._sampleCount=0,this._pos=0,this._m2=0},e.prototype._wrapPosition=function(e){var t=this._samples.length;return(e%t+t)%t},e})();e.RollingAverage=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(e){function t(){var t=e.call(this)||this;return t.MAINUV1=!1,t.MAINUV2=!1,t.DIFFUSE=!1,t.DIFFUSEDIRECTUV=0,t.AMBIENT=!1,t.AMBIENTDIRECTUV=0,t.OPACITY=!1,t.OPACITYDIRECTUV=0,t.OPACITYRGB=!1,t.REFLECTION=!1,t.EMISSIVE=!1,t.EMISSIVEDIRECTUV=0,t.SPECULAR=!1,t.SPECULARDIRECTUV=0,t.BUMP=!1,t.BUMPDIRECTUV=0,t.PARALLAX=!1,t.PARALLAXOCCLUSION=!1,t.SPECULAROVERALPHA=!1,t.CLIPPLANE=!1,t.ALPHATEST=!1,t.ALPHAFROMDIFFUSE=!1,t.POINTSIZE=!1,t.FOG=!1,t.SPECULARTERM=!1,t.DIFFUSEFRESNEL=!1,t.OPACITYFRESNEL=!1,t.REFLECTIONFRESNEL=!1,t.REFRACTIONFRESNEL=!1,t.EMISSIVEFRESNEL=!1,t.FRESNEL=!1,t.NORMAL=!1,t.UV1=!1,t.UV2=!1,t.VERTEXCOLOR=!1,t.VERTEXALPHA=!1,t.NUM_BONE_INFLUENCERS=0,t.BonesPerMesh=0,t.INSTANCES=!1,t.GLOSSINESS=!1,t.ROUGHNESS=!1,t.EMISSIVEASILLUMINATION=!1,t.LINKEMISSIVEWITHDIFFUSE=!1,t.REFLECTIONFRESNELFROMSPECULAR=!1,t.LIGHTMAP=!1,t.LIGHTMAPDIRECTUV=0,t.USELIGHTMAPASSHADOWMAP=!1,t.REFLECTIONMAP_3D=!1,t.REFLECTIONMAP_SPHERICAL=!1,t.REFLECTIONMAP_PLANAR=!1,t.REFLECTIONMAP_CUBIC=!1,t.REFLECTIONMAP_PROJECTION=!1,t.REFLECTIONMAP_SKYBOX=!1,t.REFLECTIONMAP_EXPLICIT=!1,t.REFLECTIONMAP_EQUIRECTANGULAR=!1,t.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,t.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,t.INVERTCUBICMAP=!1,t.LOGARITHMICDEPTH=!1,t.REFRACTION=!1,t.REFRACTIONMAP_3D=!1,t.REFLECTIONOVERALPHA=!1,t.TWOSIDEDLIGHTING=!1,t.SHADOWFLOAT=!1,t.MORPHTARGETS=!1,t.MORPHTARGETS_NORMAL=!1,t.MORPHTARGETS_TANGENT=!1,t.NUM_MORPH_INFLUENCERS=0,t.USERIGHTHANDEDSYSTEM=!1,t.IMAGEPROCESSING=!1,t.VIGNETTE=!1,t.VIGNETTEBLENDMODEMULTIPLY=!1,t.VIGNETTEBLENDMODEOPAQUE=!1,t.TONEMAPPING=!1,t.CONTRAST=!1,t.COLORCURVES=!1,t.COLORGRADING=!1,t.SAMPLER3DGREENDEPTH=!1,t.SAMPLER3DBGRMAP=!1,t.IMAGEPROCESSINGPOSTPROCESS=!1,t.EXPOSURE=!1,t.rebuild(),t}return __extends(t,e),t.prototype.setReflectionMode=function(e){for(var t=["REFLECTIONMAP_CUBIC","REFLECTIONMAP_EXPLICIT","REFLECTIONMAP_PLANAR","REFLECTIONMAP_PROJECTION","REFLECTIONMAP_PROJECTION","REFLECTIONMAP_SKYBOX","REFLECTIONMAP_SPHERICAL","REFLECTIONMAP_EQUIRECTANGULAR","REFLECTIONMAP_EQUIRECTANGULAR_FIXED","REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED"],i=0,r=t;i0,a.REFLECTIONOVERALPHA=this._useReflectionOverAlpha,a.INVERTCUBICMAP=this._reflectionTexture.coordinatesMode===e.Texture.INVCUBIC_MODE,a.REFLECTIONMAP_3D=this._reflectionTexture.isCube,this._reflectionTexture.coordinatesMode){case e.Texture.CUBIC_MODE:case e.Texture.INVCUBIC_MODE:a.setReflectionMode("REFLECTIONMAP_CUBIC");break;case e.Texture.EXPLICIT_MODE:a.setReflectionMode("REFLECTIONMAP_EXPLICIT");break;case e.Texture.PLANAR_MODE:a.setReflectionMode("REFLECTIONMAP_PLANAR");break;case e.Texture.PROJECTION_MODE:a.setReflectionMode("REFLECTIONMAP_PROJECTION");break;case e.Texture.SKYBOX_MODE:a.setReflectionMode("REFLECTIONMAP_SKYBOX");break;case e.Texture.SPHERICAL_MODE:a.setReflectionMode("REFLECTIONMAP_SPHERICAL");break;case e.Texture.EQUIRECTANGULAR_MODE:a.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR");break;case e.Texture.FIXED_EQUIRECTANGULAR_MODE:a.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR_FIXED");break;case e.Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:a.setReflectionMode("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED")}}else a.REFLECTION=!1;if(this._emissiveTexture&&r.EmissiveTextureEnabled){if(!this._emissiveTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._emissiveTexture,a,"EMISSIVE")}else a.EMISSIVE=!1;if(this._lightmapTexture&&r.LightmapTextureEnabled){if(!this._lightmapTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._lightmapTexture,a,"LIGHTMAP"),a.USELIGHTMAPASSHADOWMAP=this._useLightmapAsShadowmap}else a.LIGHTMAP=!1;if(this._specularTexture&&r.SpecularTextureEnabled){if(!this._specularTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._specularTexture,a,"SPECULAR"),a.GLOSSINESS=this._useGlossinessFromSpecularMapAlpha}else a.SPECULAR=!1;if(s.getEngine().getCaps().standardDerivatives&&this._bumpTexture&&r.BumpTextureEnabled){if(!this._bumpTexture.isReady())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._bumpTexture,a,"BUMP"),a.PARALLAX=this._useParallax,a.PARALLAXOCCLUSION=this._useParallaxOcclusion}else a.BUMP=!1;if(this._refractionTexture&&r.RefractionTextureEnabled){if(!this._refractionTexture.isReadyOrNotBlocking())return!1;a._needUVs=!0,a.REFRACTION=!0,a.REFRACTIONMAP_3D=this._refractionTexture.isCube}else a.REFRACTION=!1;a.TWOSIDEDLIGHTING=!this._backFaceCulling&&this._twoSidedLighting}else a.DIFFUSE=!1,a.AMBIENT=!1,a.OPACITY=!1,a.REFLECTION=!1,a.EMISSIVE=!1,a.LIGHTMAP=!1,a.BUMP=!1,a.REFRACTION=!1;a.ALPHAFROMDIFFUSE=this._shouldUseAlphaFromDiffuseTexture(),a.EMISSIVEASILLUMINATION=this._useEmissiveAsIllumination,a.LINKEMISSIVEWITHDIFFUSE=this._linkEmissiveWithDiffuse,a.SPECULAROVERALPHA=this._useSpecularOverAlpha}if(a._areImageProcessingDirty){if(!this._imageProcessingConfiguration.isReady())return!1;this._imageProcessingConfiguration.prepareDefines(a)}if(a._areFresnelDirty&&(r.FresnelEnabled?(this._diffuseFresnelParameters||this._opacityFresnelParameters||this._emissiveFresnelParameters||this._refractionFresnelParameters||this._reflectionFresnelParameters)&&(a.DIFFUSEFRESNEL=this._diffuseFresnelParameters&&this._diffuseFresnelParameters.isEnabled,a.OPACITYFRESNEL=this._opacityFresnelParameters&&this._opacityFresnelParameters.isEnabled,a.REFLECTIONFRESNEL=this._reflectionFresnelParameters&&this._reflectionFresnelParameters.isEnabled,a.REFLECTIONFRESNELFROMSPECULAR=this._useReflectionFresnelFromSpecular,a.REFRACTIONFRESNEL=this._refractionFresnelParameters&&this._refractionFresnelParameters.isEnabled,a.EMISSIVEFRESNEL=this._emissiveFresnelParameters&&this._emissiveFresnelParameters.isEnabled,a._needNormals=!0,a.FRESNEL=!0):a.FRESNEL=!1),e.MaterialHelper.PrepareDefinesForMisc(i,s,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,a),e.MaterialHelper.PrepareDefinesForAttributes(i,a,!0,!0,!0),e.MaterialHelper.PrepareDefinesForFrameBoundValues(s,l,a,o),a.isDirty){a.markAsProcessed(),s.resetCachedMaterial();var h=new e.EffectFallbacks;a.REFLECTION&&h.addFallback(0,"REFLECTION"),a.SPECULAR&&h.addFallback(0,"SPECULAR"),a.BUMP&&h.addFallback(0,"BUMP"),a.PARALLAX&&h.addFallback(1,"PARALLAX"),a.PARALLAXOCCLUSION&&h.addFallback(0,"PARALLAXOCCLUSION"),a.SPECULAROVERALPHA&&h.addFallback(0,"SPECULAROVERALPHA"),a.FOG&&h.addFallback(1,"FOG"),a.POINTSIZE&&h.addFallback(0,"POINTSIZE"),a.LOGARITHMICDEPTH&&h.addFallback(0,"LOGARITHMICDEPTH"),e.MaterialHelper.HandleFallbacksForShadows(a,h,this._maxSimultaneousLights),a.SPECULARTERM&&h.addFallback(0,"SPECULARTERM"),a.DIFFUSEFRESNEL&&h.addFallback(1,"DIFFUSEFRESNEL"),a.OPACITYFRESNEL&&h.addFallback(2,"OPACITYFRESNEL"),a.REFLECTIONFRESNEL&&h.addFallback(3,"REFLECTIONFRESNEL"),a.EMISSIVEFRESNEL&&h.addFallback(4,"EMISSIVEFRESNEL"),a.FRESNEL&&h.addFallback(4,"FRESNEL");var c=[e.VertexBuffer.PositionKind];a.NORMAL&&c.push(e.VertexBuffer.NormalKind),a.UV1&&c.push(e.VertexBuffer.UVKind),a.UV2&&c.push(e.VertexBuffer.UV2Kind),a.VERTEXCOLOR&&c.push(e.VertexBuffer.ColorKind),e.MaterialHelper.PrepareAttributesForBones(c,i,a,h),e.MaterialHelper.PrepareAttributesForInstances(c,a),e.MaterialHelper.PrepareAttributesForMorphTargets(c,i,a);var u="default",f=["world","view","viewProjection","vEyePosition","vLightsType","vAmbientColor","vDiffuseColor","vSpecularColor","vEmissiveColor","vFogInfos","vFogColor","pointSize","vDiffuseInfos","vAmbientInfos","vOpacityInfos","vReflectionInfos","vEmissiveInfos","vSpecularInfos","vBumpInfos","vLightmapInfos","vRefractionInfos","mBones","vClipPlane","diffuseMatrix","ambientMatrix","opacityMatrix","reflectionMatrix","emissiveMatrix","specularMatrix","bumpMatrix","lightmapMatrix","refractionMatrix","diffuseLeftColor","diffuseRightColor","opacityParts","reflectionLeftColor","reflectionRightColor","emissiveLeftColor","emissiveRightColor","refractionLeftColor","refractionRightColor","logarithmicDepthConstant","vNormalReoderParams"],d=["diffuseSampler","ambientSampler","opacitySampler","reflectionCubeSampler","reflection2DSampler","emissiveSampler","specularSampler","bumpSampler","lightmapSampler","refractionCubeSampler","refraction2DSampler"],p=["Material","Scene"];e.ImageProcessingConfiguration.PrepareUniforms(f,a),e.ImageProcessingConfiguration.PrepareSamplers(d,a),e.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:f,uniformBuffersNames:p,samplers:d,defines:a,maxSimultaneousLights:this._maxSimultaneousLights}),this.customShaderNameResolve&&(u=this.customShaderNameResolve(u,f,p,d,a));var _=a.toString();n.setEffect(s.getEngine().createEffect(u,{attributes:c,uniformsNames:f,uniformBuffersNames:p,samplers:d,defines:_,fallbacks:h,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights,maxSimultaneousMorphTargets:a.NUM_MORPH_INFLUENCERS}},l),a),this.buildUniformLayout()}return!!n.effect.isReady()&&(a._renderId=s.getRenderId(),this._wasPreviouslyReady=!0,!0)},r.prototype.buildUniformLayout=function(){this._uniformBuffer.addUniform("diffuseLeftColor",4),this._uniformBuffer.addUniform("diffuseRightColor",4),this._uniformBuffer.addUniform("opacityParts",4),this._uniformBuffer.addUniform("reflectionLeftColor",4),this._uniformBuffer.addUniform("reflectionRightColor",4),this._uniformBuffer.addUniform("refractionLeftColor",4),this._uniformBuffer.addUniform("refractionRightColor",4),this._uniformBuffer.addUniform("emissiveLeftColor",4),this._uniformBuffer.addUniform("emissiveRightColor",4),this._uniformBuffer.addUniform("vDiffuseInfos",2),this._uniformBuffer.addUniform("vAmbientInfos",2),this._uniformBuffer.addUniform("vOpacityInfos",2),this._uniformBuffer.addUniform("vReflectionInfos",2),this._uniformBuffer.addUniform("vEmissiveInfos",2),this._uniformBuffer.addUniform("vLightmapInfos",2),this._uniformBuffer.addUniform("vSpecularInfos",2),this._uniformBuffer.addUniform("vBumpInfos",3),this._uniformBuffer.addUniform("diffuseMatrix",16),this._uniformBuffer.addUniform("ambientMatrix",16),this._uniformBuffer.addUniform("opacityMatrix",16),this._uniformBuffer.addUniform("reflectionMatrix",16),this._uniformBuffer.addUniform("emissiveMatrix",16),this._uniformBuffer.addUniform("lightmapMatrix",16),this._uniformBuffer.addUniform("specularMatrix",16),this._uniformBuffer.addUniform("bumpMatrix",16),this._uniformBuffer.addUniform("vNormalReoderParams",4),this._uniformBuffer.addUniform("refractionMatrix",16),this._uniformBuffer.addUniform("vRefractionInfos",4),this._uniformBuffer.addUniform("vSpecularColor",4),this._uniformBuffer.addUniform("vEmissiveColor",3),this._uniformBuffer.addUniform("vDiffuseColor",4),this._uniformBuffer.addUniform("pointSize",1),this._uniformBuffer.create()},r.prototype.unbind=function(){this._activeEffect&&(this._reflectionTexture&&this._reflectionTexture.isRenderTarget&&this._activeEffect.setTexture("reflection2DSampler",null),this._refractionTexture&&this._refractionTexture.isRenderTarget&&this._activeEffect.setTexture("refraction2DSampler",null)),i.prototype.unbind.call(this)},r.prototype.bindForSubMesh=function(t,i,n){var o=this.getScene(),s=n._materialDefines;if(s){var a=n.effect;if(this._activeEffect=a,this.bindOnlyWorldMatrix(t),e.MaterialHelper.BindBonesParameters(i,a),this._mustRebind(o,a,i.visibility)){if(this._uniformBuffer.bindToEffect(a,"Material"),this.bindViewProjection(a),!this._uniformBuffer.useUbo||!this.isFrozen||!this._uniformBuffer.isSync){if(r.FresnelEnabled&&s.FRESNEL&&(this.diffuseFresnelParameters&&this.diffuseFresnelParameters.isEnabled&&(this._uniformBuffer.updateColor4("diffuseLeftColor",this.diffuseFresnelParameters.leftColor,this.diffuseFresnelParameters.power),this._uniformBuffer.updateColor4("diffuseRightColor",this.diffuseFresnelParameters.rightColor,this.diffuseFresnelParameters.bias)),this.opacityFresnelParameters&&this.opacityFresnelParameters.isEnabled&&this._uniformBuffer.updateColor4("opacityParts",new e.Color3(this.opacityFresnelParameters.leftColor.toLuminance(),this.opacityFresnelParameters.rightColor.toLuminance(),this.opacityFresnelParameters.bias),this.opacityFresnelParameters.power),this.reflectionFresnelParameters&&this.reflectionFresnelParameters.isEnabled&&(this._uniformBuffer.updateColor4("reflectionLeftColor",this.reflectionFresnelParameters.leftColor,this.reflectionFresnelParameters.power),this._uniformBuffer.updateColor4("reflectionRightColor",this.reflectionFresnelParameters.rightColor,this.reflectionFresnelParameters.bias)),this.refractionFresnelParameters&&this.refractionFresnelParameters.isEnabled&&(this._uniformBuffer.updateColor4("refractionLeftColor",this.refractionFresnelParameters.leftColor,this.refractionFresnelParameters.power),this._uniformBuffer.updateColor4("refractionRightColor",this.refractionFresnelParameters.rightColor,this.refractionFresnelParameters.bias)),this.emissiveFresnelParameters&&this.emissiveFresnelParameters.isEnabled&&(this._uniformBuffer.updateColor4("emissiveLeftColor",this.emissiveFresnelParameters.leftColor,this.emissiveFresnelParameters.power),this._uniformBuffer.updateColor4("emissiveRightColor",this.emissiveFresnelParameters.rightColor,this.emissiveFresnelParameters.bias))),o.texturesEnabled&&(this._diffuseTexture&&r.DiffuseTextureEnabled&&(this._uniformBuffer.updateFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),e.MaterialHelper.BindTextureMatrix(this._diffuseTexture,this._uniformBuffer,"diffuse")),this._ambientTexture&&r.AmbientTextureEnabled&&(this._uniformBuffer.updateFloat2("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level),e.MaterialHelper.BindTextureMatrix(this._ambientTexture,this._uniformBuffer,"ambient")),this._opacityTexture&&r.OpacityTextureEnabled&&(this._uniformBuffer.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),e.MaterialHelper.BindTextureMatrix(this._opacityTexture,this._uniformBuffer,"opacity")),this._reflectionTexture&&r.ReflectionTextureEnabled&&(this._uniformBuffer.updateFloat2("vReflectionInfos",this._reflectionTexture.level,this.roughness),this._uniformBuffer.updateMatrix("reflectionMatrix",this._reflectionTexture.getReflectionTextureMatrix())),this._emissiveTexture&&r.EmissiveTextureEnabled&&(this._uniformBuffer.updateFloat2("vEmissiveInfos",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),e.MaterialHelper.BindTextureMatrix(this._emissiveTexture,this._uniformBuffer,"emissive")),this._lightmapTexture&&r.LightmapTextureEnabled&&(this._uniformBuffer.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),e.MaterialHelper.BindTextureMatrix(this._lightmapTexture,this._uniformBuffer,"lightmap")),this._specularTexture&&r.SpecularTextureEnabled&&(this._uniformBuffer.updateFloat2("vSpecularInfos",this._specularTexture.coordinatesIndex,this._specularTexture.level),e.MaterialHelper.BindTextureMatrix(this._specularTexture,this._uniformBuffer,"specular")),this._bumpTexture&&o.getEngine().getCaps().standardDerivatives&&r.BumpTextureEnabled&&(this._uniformBuffer.updateFloat3("vBumpInfos",this._bumpTexture.coordinatesIndex,1/this._bumpTexture.level,this.parallaxScaleBias),e.MaterialHelper.BindTextureMatrix(this._bumpTexture,this._uniformBuffer,"bump"),o._mirroredCameraPosition?this._uniformBuffer.updateFloat4("vNormalReoderParams",this.invertNormalMapX?0:1,this.invertNormalMapX?1:-1,this.invertNormalMapY?0:1,this.invertNormalMapY?1:-1):this._uniformBuffer.updateFloat4("vNormalReoderParams",this.invertNormalMapX?1:0,this.invertNormalMapX?-1:1,this.invertNormalMapY?1:0,this.invertNormalMapY?-1:1)),this._refractionTexture&&r.RefractionTextureEnabled)){var l=1;this._refractionTexture.isCube||(this._uniformBuffer.updateMatrix("refractionMatrix",this._refractionTexture.getReflectionTextureMatrix()),this._refractionTexture.depth&&(l=this._refractionTexture.depth)),this._uniformBuffer.updateFloat4("vRefractionInfos",this._refractionTexture.level,this.indexOfRefraction,l,this.invertRefractionY?-1:1)}this.pointsCloud&&this._uniformBuffer.updateFloat("pointSize",this.pointSize),s.SPECULARTERM&&this._uniformBuffer.updateColor4("vSpecularColor",this.specularColor,this.specularPower),this._uniformBuffer.updateColor3("vEmissiveColor",this.emissiveColor),this._uniformBuffer.updateColor4("vDiffuseColor",this.diffuseColor,this.alpha*i.visibility)}if(o.texturesEnabled&&(this._diffuseTexture&&r.DiffuseTextureEnabled&&a.setTexture("diffuseSampler",this._diffuseTexture),this._ambientTexture&&r.AmbientTextureEnabled&&a.setTexture("ambientSampler",this._ambientTexture),this._opacityTexture&&r.OpacityTextureEnabled&&a.setTexture("opacitySampler",this._opacityTexture),this._reflectionTexture&&r.ReflectionTextureEnabled&&(this._reflectionTexture.isCube?a.setTexture("reflectionCubeSampler",this._reflectionTexture):a.setTexture("reflection2DSampler",this._reflectionTexture)),this._emissiveTexture&&r.EmissiveTextureEnabled&&a.setTexture("emissiveSampler",this._emissiveTexture),this._lightmapTexture&&r.LightmapTextureEnabled&&a.setTexture("lightmapSampler",this._lightmapTexture),this._specularTexture&&r.SpecularTextureEnabled&&a.setTexture("specularSampler",this._specularTexture),this._bumpTexture&&o.getEngine().getCaps().standardDerivatives&&r.BumpTextureEnabled&&a.setTexture("bumpSampler",this._bumpTexture),this._refractionTexture&&r.RefractionTextureEnabled)){var l=1;this._refractionTexture.isCube?a.setTexture("refractionCubeSampler",this._refractionTexture):a.setTexture("refraction2DSampler",this._refractionTexture)}e.MaterialHelper.BindClipPlane(a,o),o.ambientColor.multiplyToRef(this.ambientColor,this._globalAmbientColor),a.setVector3("vEyePosition",o._mirroredCameraPosition?o._mirroredCameraPosition:o.activeCamera.globalPosition),a.setColor3("vAmbientColor",this._globalAmbientColor)}!this._mustRebind(o,a)&&this.isFrozen||(o.lightsEnabled&&!this._disableLighting&&e.MaterialHelper.BindLights(o,i,a,s,this._maxSimultaneousLights),(o.fogEnabled&&i.applyFog&&o.fogMode!==e.Scene.FOGMODE_NONE||this._reflectionTexture||this._refractionTexture)&&this.bindView(a),e.MaterialHelper.BindFogParameters(o,i,a),s.NUM_MORPH_INFLUENCERS&&e.MaterialHelper.BindMorphTargetParameters(i,a),e.MaterialHelper.BindLogDepth(s,a,o),this._imageProcessingConfiguration.bind(this._activeEffect)),this._uniformBuffer.update(),this._afterBind(i,this._activeEffect)}},r.prototype.getAnimatables=function(){var e=[];return this._diffuseTexture&&this._diffuseTexture.animations&&this._diffuseTexture.animations.length>0&&e.push(this._diffuseTexture),this._ambientTexture&&this._ambientTexture.animations&&this._ambientTexture.animations.length>0&&e.push(this._ambientTexture),this._opacityTexture&&this._opacityTexture.animations&&this._opacityTexture.animations.length>0&&e.push(this._opacityTexture),this._reflectionTexture&&this._reflectionTexture.animations&&this._reflectionTexture.animations.length>0&&e.push(this._reflectionTexture),this._emissiveTexture&&this._emissiveTexture.animations&&this._emissiveTexture.animations.length>0&&e.push(this._emissiveTexture),this._specularTexture&&this._specularTexture.animations&&this._specularTexture.animations.length>0&&e.push(this._specularTexture),this._bumpTexture&&this._bumpTexture.animations&&this._bumpTexture.animations.length>0&&e.push(this._bumpTexture),this._lightmapTexture&&this._lightmapTexture.animations&&this._lightmapTexture.animations.length>0&&e.push(this._lightmapTexture),this._refractionTexture&&this._refractionTexture.animations&&this._refractionTexture.animations.length>0&&e.push(this._refractionTexture),e},r.prototype.getActiveTextures=function(){var e=i.prototype.getActiveTextures.call(this);return this._diffuseTexture&&e.push(this._diffuseTexture),this._ambientTexture&&e.push(this._ambientTexture),this._opacityTexture&&e.push(this._opacityTexture),this._reflectionTexture&&e.push(this._reflectionTexture),this._emissiveTexture&&e.push(this._emissiveTexture),this._specularTexture&&e.push(this._specularTexture),this._bumpTexture&&e.push(this._bumpTexture),this._lightmapTexture&&e.push(this._lightmapTexture),this._refractionTexture&&e.push(this._refractionTexture),e},r.prototype.hasTexture=function(e){return!!i.prototype.hasTexture.call(this,e)||(this._diffuseTexture===e||(this._ambientTexture===e||(this._opacityTexture===e||(this._reflectionTexture===e||(this._emissiveTexture===e||(this._specularTexture===e||(this._bumpTexture===e||(this._lightmapTexture===e||this._refractionTexture===e))))))))},r.prototype.dispose=function(e,t){t&&(this._diffuseTexture&&this._diffuseTexture.dispose(),this._ambientTexture&&this._ambientTexture.dispose(),this._opacityTexture&&this._opacityTexture.dispose(),this._reflectionTexture&&this._reflectionTexture.dispose(),this._emissiveTexture&&this._emissiveTexture.dispose(),this._specularTexture&&this._specularTexture.dispose(),this._bumpTexture&&this._bumpTexture.dispose(),this._lightmapTexture&&this._lightmapTexture.dispose(),this._refractionTexture&&this._refractionTexture.dispose()),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),i.prototype.dispose.call(this,e,t)},r.prototype.clone=function(t){var i=this,n=e.SerializationHelper.Clone((function(){return new r(t,i.getScene())}),this);return n.name=t,n.id=t,n},r.prototype.serialize=function(){return e.SerializationHelper.Serialize(this)},r.Parse=function(t,i,n){return e.SerializationHelper.Parse((function(){return new r(t.name,i)}),t,i,n)},Object.defineProperty(r,"DiffuseTextureEnabled",{get:function(){return r._DiffuseTextureEnabled},set:function(t){r._DiffuseTextureEnabled!==t&&(r._DiffuseTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"AmbientTextureEnabled",{get:function(){return r._AmbientTextureEnabled},set:function(t){r._AmbientTextureEnabled!==t&&(r._AmbientTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"OpacityTextureEnabled",{get:function(){return r._OpacityTextureEnabled},set:function(t){r._OpacityTextureEnabled!==t&&(r._OpacityTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"ReflectionTextureEnabled",{get:function(){return r._ReflectionTextureEnabled},set:function(t){r._ReflectionTextureEnabled!==t&&(r._ReflectionTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"EmissiveTextureEnabled",{get:function(){return r._EmissiveTextureEnabled},set:function(t){r._EmissiveTextureEnabled!==t&&(r._EmissiveTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"SpecularTextureEnabled",{get:function(){return r._SpecularTextureEnabled},set:function(t){r._SpecularTextureEnabled!==t&&(r._SpecularTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"BumpTextureEnabled",{get:function(){return r._BumpTextureEnabled},set:function(t){r._BumpTextureEnabled!==t&&(r._BumpTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"LightmapTextureEnabled",{get:function(){return r._LightmapTextureEnabled},set:function(t){r._LightmapTextureEnabled!==t&&(r._LightmapTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"RefractionTextureEnabled",{get:function(){return r._RefractionTextureEnabled},set:function(t){r._RefractionTextureEnabled!==t&&(r._RefractionTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"ColorGradingTextureEnabled",{get:function(){return r._ColorGradingTextureEnabled},set:function(t){r._ColorGradingTextureEnabled!==t&&(r._ColorGradingTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"FresnelEnabled",{get:function(){return r._FresnelEnabled},set:function(t){r._FresnelEnabled!==t&&(r._FresnelEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.FresnelDirtyFlag))},enumerable:!0,configurable:!0}),r})(e.PushMaterial);i._DiffuseTextureEnabled=!0,i._AmbientTextureEnabled=!0,i._OpacityTextureEnabled=!0,i._ReflectionTextureEnabled=!0,i._EmissiveTextureEnabled=!0,i._SpecularTextureEnabled=!0,i._BumpTextureEnabled=!0,i._LightmapTextureEnabled=!0,i._RefractionTextureEnabled=!0,i._ColorGradingTextureEnabled=!0,i._FresnelEnabled=!0,__decorate([e.serializeAsTexture("diffuseTexture")],i.prototype,"_diffuseTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"diffuseTexture",void 0),__decorate([e.serializeAsTexture("ambientTexture")],i.prototype,"_ambientTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"ambientTexture",void 0),__decorate([e.serializeAsTexture("opacityTexture")],i.prototype,"_opacityTexture",void 0), -__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"opacityTexture",void 0),__decorate([e.serializeAsTexture("reflectionTexture")],i.prototype,"_reflectionTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"reflectionTexture",void 0),__decorate([e.serializeAsTexture("emissiveTexture")],i.prototype,"_emissiveTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"emissiveTexture",void 0),__decorate([e.serializeAsTexture("specularTexture")],i.prototype,"_specularTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"specularTexture",void 0),__decorate([e.serializeAsTexture("bumpTexture")],i.prototype,"_bumpTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"bumpTexture",void 0),__decorate([e.serializeAsTexture("lightmapTexture")],i.prototype,"_lightmapTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"lightmapTexture",void 0),__decorate([e.serializeAsTexture("refractionTexture")],i.prototype,"_refractionTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"refractionTexture",void 0),__decorate([e.serializeAsColor3("ambient")],i.prototype,"ambientColor",void 0),__decorate([e.serializeAsColor3("diffuse")],i.prototype,"diffuseColor",void 0),__decorate([e.serializeAsColor3("specular")],i.prototype,"specularColor",void 0),__decorate([e.serializeAsColor3("emissive")],i.prototype,"emissiveColor",void 0),__decorate([e.serialize()],i.prototype,"specularPower",void 0),__decorate([e.serialize("useAlphaFromDiffuseTexture")],i.prototype,"_useAlphaFromDiffuseTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useAlphaFromDiffuseTexture",void 0),__decorate([e.serialize("useEmissiveAsIllumination")],i.prototype,"_useEmissiveAsIllumination",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useEmissiveAsIllumination",void 0),__decorate([e.serialize("linkEmissiveWithDiffuse")],i.prototype,"_linkEmissiveWithDiffuse",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"linkEmissiveWithDiffuse",void 0),__decorate([e.serialize("useSpecularOverAlpha")],i.prototype,"_useSpecularOverAlpha",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useSpecularOverAlpha",void 0),__decorate([e.serialize("useReflectionOverAlpha")],i.prototype,"_useReflectionOverAlpha",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useReflectionOverAlpha",void 0),__decorate([e.serialize("disableLighting")],i.prototype,"_disableLighting",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsLightsDirty")],i.prototype,"disableLighting",void 0),__decorate([e.serialize("useParallax")],i.prototype,"_useParallax",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useParallax",void 0),__decorate([e.serialize("useParallaxOcclusion")],i.prototype,"_useParallaxOcclusion",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useParallaxOcclusion",void 0),__decorate([e.serialize()],i.prototype,"parallaxScaleBias",void 0),__decorate([e.serialize("roughness")],i.prototype,"_roughness",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"roughness",void 0),__decorate([e.serialize()],i.prototype,"indexOfRefraction",void 0),__decorate([e.serialize()],i.prototype,"invertRefractionY",void 0),__decorate([e.serialize("useLightmapAsShadowmap")],i.prototype,"_useLightmapAsShadowmap",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useLightmapAsShadowmap",void 0),__decorate([e.serializeAsFresnelParameters("diffuseFresnelParameters")],i.prototype,"_diffuseFresnelParameters",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],i.prototype,"diffuseFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters("opacityFresnelParameters")],i.prototype,"_opacityFresnelParameters",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],i.prototype,"opacityFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters("reflectionFresnelParameters")],i.prototype,"_reflectionFresnelParameters",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],i.prototype,"reflectionFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters("refractionFresnelParameters")],i.prototype,"_refractionFresnelParameters",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],i.prototype,"refractionFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters("emissiveFresnelParameters")],i.prototype,"_emissiveFresnelParameters",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],i.prototype,"emissiveFresnelParameters",void 0),__decorate([e.serialize("useReflectionFresnelFromSpecular")],i.prototype,"_useReflectionFresnelFromSpecular",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],i.prototype,"useReflectionFresnelFromSpecular",void 0),__decorate([e.serialize("useGlossinessFromSpecularMapAlpha")],i.prototype,"_useGlossinessFromSpecularMapAlpha",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useGlossinessFromSpecularMapAlpha",void 0),__decorate([e.serialize("maxSimultaneousLights")],i.prototype,"_maxSimultaneousLights",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsLightsDirty")],i.prototype,"maxSimultaneousLights",void 0),__decorate([e.serialize("invertNormalMapX")],i.prototype,"_invertNormalMapX",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"invertNormalMapX",void 0),__decorate([e.serialize("invertNormalMapY")],i.prototype,"_invertNormalMapY",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"invertNormalMapY",void 0),__decorate([e.serialize("twoSidedLighting")],i.prototype,"_twoSidedLighting",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"twoSidedLighting",void 0),__decorate([e.serialize()],i.prototype,"useLogarithmicDepth",null),e.StandardMaterial=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(e){function t(){var t=e.call(this)||this;return t.PBR=!0,t.MAINUV1=!1,t.MAINUV2=!1,t.UV1=!1,t.UV2=!1,t.ALBEDO=!1,t.ALBEDODIRECTUV=0,t.VERTEXCOLOR=!1,t.AMBIENT=!1,t.AMBIENTDIRECTUV=0,t.AMBIENTINGRAYSCALE=!1,t.OPACITY=!1,t.VERTEXALPHA=!1,t.OPACITYDIRECTUV=0,t.OPACITYRGB=!1,t.ALPHATEST=!1,t.ALPHABLEND=!1,t.ALPHAFROMALBEDO=!1,t.ALPHATESTVALUE=.5,t.SPECULAROVERALPHA=!1,t.RADIANCEOVERALPHA=!1,t.ALPHAFRESNEL=!1,t.PREMULTIPLYALPHA=!1,t.EMISSIVE=!1,t.EMISSIVEDIRECTUV=0,t.REFLECTIVITY=!1,t.REFLECTIVITYDIRECTUV=0,t.SPECULARTERM=!1,t.MICROSURFACEFROMREFLECTIVITYMAP=!1,t.MICROSURFACEAUTOMATIC=!1,t.LODBASEDMICROSFURACE=!1,t.MICROSURFACEMAP=!1,t.MICROSURFACEMAPDIRECTUV=0,t.METALLICWORKFLOW=!1,t.ROUGHNESSSTOREINMETALMAPALPHA=!1,t.ROUGHNESSSTOREINMETALMAPGREEN=!1,t.METALLNESSSTOREINMETALMAPBLUE=!1,t.AOSTOREINMETALMAPRED=!1,t.ENVIRONMENTBRDF=!1,t.NORMAL=!1,t.TANGENT=!1,t.BUMP=!1,t.BUMPDIRECTUV=0,t.PARALLAX=!1,t.PARALLAXOCCLUSION=!1,t.NORMALXYSCALE=!0,t.LIGHTMAP=!1,t.LIGHTMAPDIRECTUV=0,t.USELIGHTMAPASSHADOWMAP=!1,t.REFLECTION=!1,t.REFLECTIONMAP_3D=!1,t.REFLECTIONMAP_SPHERICAL=!1,t.REFLECTIONMAP_PLANAR=!1,t.REFLECTIONMAP_CUBIC=!1,t.REFLECTIONMAP_PROJECTION=!1,t.REFLECTIONMAP_SKYBOX=!1,t.REFLECTIONMAP_EXPLICIT=!1,t.REFLECTIONMAP_EQUIRECTANGULAR=!1,t.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,t.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,t.INVERTCUBICMAP=!1,t.USESPHERICALFROMREFLECTIONMAP=!1,t.USESPHERICALINFRAGMENT=!1,t.REFLECTIONMAP_OPPOSITEZ=!1,t.LODINREFLECTIONALPHA=!1,t.GAMMAREFLECTION=!1,t.REFRACTION=!1,t.REFRACTIONMAP_3D=!1,t.REFRACTIONMAP_OPPOSITEZ=!1,t.LODINREFRACTIONALPHA=!1,t.GAMMAREFRACTION=!1,t.LINKREFRACTIONTOTRANSPARENCY=!1,t.INSTANCES=!1,t.NUM_BONE_INFLUENCERS=0,t.BonesPerMesh=0,t.MORPHTARGETS=!1,t.MORPHTARGETS_NORMAL=!1,t.MORPHTARGETS_TANGENT=!1,t.NUM_MORPH_INFLUENCERS=0,t.IMAGEPROCESSING=!1,t.VIGNETTE=!1,t.VIGNETTEBLENDMODEMULTIPLY=!1,t.VIGNETTEBLENDMODEOPAQUE=!1,t.TONEMAPPING=!1,t.CONTRAST=!1,t.COLORCURVES=!1,t.COLORGRADING=!1,t.SAMPLER3DGREENDEPTH=!1,t.SAMPLER3DBGRMAP=!1,t.IMAGEPROCESSINGPOSTPROCESS=!1,t.EXPOSURE=!1,t.USEPHYSICALLIGHTFALLOFF=!1,t.TWOSIDEDLIGHTING=!1,t.SHADOWFLOAT=!1,t.USERIGHTHANDEDSYSTEM=!1,t.CLIPPLANE=!1,t.POINTSIZE=!1,t.FOG=!1,t.LOGARITHMICDEPTH=!1,t.FORCENORMALFORWARD=!1,t.rebuild(),t}return __extends(t,e),t.prototype.reset=function(){e.prototype.reset.call(this),this.ALPHATESTVALUE=.5,this.PBR=!0},t})(e.MaterialDefines),i=(function(i){function r(t,r){var n=i.call(this,t,r)||this;return n._directIntensity=1,n._emissiveIntensity=1,n._environmentIntensity=1,n._specularIntensity=1,n._lightingInfos=new e.Vector4(n._directIntensity,n._emissiveIntensity,n._environmentIntensity,n._specularIntensity),n._disableBumpMap=!1,n._ambientTextureStrength=1,n._ambientColor=new e.Color3(0,0,0),n._albedoColor=new e.Color3(1,1,1),n._reflectivityColor=new e.Color3(1,1,1),n._reflectionColor=new e.Color3(1,1,1),n._emissiveColor=new e.Color3(0,0,0),n._microSurface=.9,n._indexOfRefraction=.66,n._invertRefractionY=!1,n._linkRefractionWithTransparency=!1,n._useLightmapAsShadowmap=!1,n._useAlphaFromAlbedoTexture=!1,n._useSpecularOverAlpha=!0,n._useMicroSurfaceFromReflectivityMapAlpha=!1,n._useRoughnessFromMetallicTextureAlpha=!0,n._useRoughnessFromMetallicTextureGreen=!1,n._useMetallnessFromMetallicTextureBlue=!1,n._useAmbientOcclusionFromMetallicTextureRed=!1,n._useAmbientInGrayScale=!1,n._useAutoMicroSurfaceFromReflectivityMap=!1,n._usePhysicalLightFalloff=!0,n._useRadianceOverAlpha=!0,n._useParallax=!1,n._useParallaxOcclusion=!1,n._parallaxScaleBias=.05,n._disableLighting=!1,n._maxSimultaneousLights=4,n._invertNormalMapX=!1,n._invertNormalMapY=!1,n._twoSidedLighting=!1,n._alphaCutOff=.4,n._forceAlphaTest=!1,n._preMultiplyAlpha=!1,n._useAlphaFresnel=!1,n._environmentBRDFTexture=null,n._forceIrradianceInFragment=!1,n._forceNormalForward=!1,n._renderTargets=new e.SmartArray(16),n._worldViewProjectionMatrix=e.Matrix.Zero(),n._globalAmbientColor=new e.Color3(0,0,0),n._tempColor=new e.Color3,n._attachImageProcessingConfiguration(null),n.getRenderTargetTextures=function(){return n._renderTargets.reset(),e.StandardMaterial.ReflectionTextureEnabled&&n._reflectionTexture&&n._reflectionTexture.isRenderTarget&&n._renderTargets.push(n._reflectionTexture),e.StandardMaterial.RefractionTextureEnabled&&n._refractionTexture&&n._refractionTexture.isRenderTarget&&n._renderTargets.push(n._refractionTexture),n._renderTargets},n._environmentBRDFTexture=e.TextureTools.GetEnvironmentBRDFTexture(r),n}return __extends(r,i),r.prototype._attachImageProcessingConfiguration=function(e){var t=this;e!==this._imageProcessingConfiguration&&(this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),this._imageProcessingConfiguration=e||this.getScene().imageProcessingConfiguration,this._imageProcessingObserver=this._imageProcessingConfiguration.onUpdateParameters.add((function(e){t._markAllSubMeshesAsImageProcessingDirty()})))},r.prototype.getClassName=function(){return"PBRBaseMaterial"},Object.defineProperty(r.prototype,"useLogarithmicDepth",{get:function(){return this._useLogarithmicDepth},set:function(e){this._useLogarithmicDepth=e&&this.getScene().getEngine().getCaps().fragmentDepthSupported},enumerable:!0,configurable:!0}),r.prototype.needAlphaBlending=function(){return!this._linkRefractionWithTransparency&&(this.alpha<1||null!=this._opacityTexture||this._shouldUseAlphaFromAlbedoTexture())},r.prototype.needAlphaTesting=function(){return!!this._forceAlphaTest||!this._linkRefractionWithTransparency&&(null!=this._albedoTexture&&this._albedoTexture.hasAlpha)},r.prototype._shouldUseAlphaFromAlbedoTexture=function(){return null!=this._albedoTexture&&this._albedoTexture.hasAlpha&&this._useAlphaFromAlbedoTexture},r.prototype.getAlphaTestTexture=function(){return this._albedoTexture},r.prototype.isReadyForSubMesh=function(i,r,n){if(this.isFrozen&&this._wasPreviouslyReady)return!0;r._materialDefines||(r._materialDefines=new t);var o=this.getScene(),s=r._materialDefines;if(!this.checkReadyOnEveryCall&&r.effect&&s._renderId===o.getRenderId())return!0;var a=o.getEngine();if(e.MaterialHelper.PrepareDefinesForLights(o,i,s,!0,this._maxSimultaneousLights,this._disableLighting),s._needNormals=!0,s._areTexturesDirty){if(s._needUVs=!1,o.texturesEnabled){if(o.getEngine().getCaps().textureLOD&&(s.LODBASEDMICROSFURACE=!0),this._albedoTexture&&e.StandardMaterial.DiffuseTextureEnabled){if(!this._albedoTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._albedoTexture,s,"ALBEDO")}else s.ALBEDO=!1;if(this._ambientTexture&&e.StandardMaterial.AmbientTextureEnabled){if(!this._ambientTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._ambientTexture,s,"AMBIENT"),s.AMBIENTINGRAYSCALE=this._useAmbientInGrayScale}else s.AMBIENT=!1;if(this._opacityTexture&&e.StandardMaterial.OpacityTextureEnabled){if(!this._opacityTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._opacityTexture,s,"OPACITY"),s.OPACITYRGB=this._opacityTexture.getAlphaFromRGB}else s.OPACITY=!1;var l=this._getReflectionTexture();if(l&&e.StandardMaterial.ReflectionTextureEnabled){if(!l.isReadyOrNotBlocking())return!1;switch(s.REFLECTION=!0,s.GAMMAREFLECTION=l.gammaSpace,s.REFLECTIONMAP_OPPOSITEZ=this.getScene().useRightHandedSystem?!l.invertZ:l.invertZ,s.LODINREFLECTIONALPHA=l.lodLevelInAlpha,l.coordinatesMode===e.Texture.INVCUBIC_MODE&&(s.INVERTCUBICMAP=!0),s.REFLECTIONMAP_3D=l.isCube,l.coordinatesMode){case e.Texture.CUBIC_MODE:case e.Texture.INVCUBIC_MODE:s.REFLECTIONMAP_CUBIC=!0;break;case e.Texture.EXPLICIT_MODE:s.REFLECTIONMAP_EXPLICIT=!0;break;case e.Texture.PLANAR_MODE:s.REFLECTIONMAP_PLANAR=!0;break;case e.Texture.PROJECTION_MODE:s.REFLECTIONMAP_PROJECTION=!0;break;case e.Texture.SKYBOX_MODE:s.REFLECTIONMAP_SKYBOX=!0;break;case e.Texture.SPHERICAL_MODE:s.REFLECTIONMAP_SPHERICAL=!0;break;case e.Texture.EQUIRECTANGULAR_MODE:s.REFLECTIONMAP_EQUIRECTANGULAR=!0;break;case e.Texture.FIXED_EQUIRECTANGULAR_MODE:s.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!0;break;case e.Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:s.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!0}l.coordinatesMode!==e.Texture.SKYBOX_MODE&&l.sphericalPolynomial&&(s.USESPHERICALFROMREFLECTIONMAP=!0,(this._forceIrradianceInFragment||o.getEngine().getCaps().maxVaryingVectors<=8)&&(s.USESPHERICALINFRAGMENT=!0))}else s.REFLECTION=!1,s.REFLECTIONMAP_3D=!1,s.REFLECTIONMAP_SPHERICAL=!1,s.REFLECTIONMAP_PLANAR=!1,s.REFLECTIONMAP_CUBIC=!1,s.REFLECTIONMAP_PROJECTION=!1,s.REFLECTIONMAP_SKYBOX=!1,s.REFLECTIONMAP_EXPLICIT=!1,s.REFLECTIONMAP_EQUIRECTANGULAR=!1,s.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,s.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,s.INVERTCUBICMAP=!1,s.USESPHERICALFROMREFLECTIONMAP=!1,s.USESPHERICALINFRAGMENT=!1,s.REFLECTIONMAP_OPPOSITEZ=!1,s.LODINREFLECTIONALPHA=!1,s.GAMMAREFLECTION=!1;if(this._lightmapTexture&&e.StandardMaterial.LightmapTextureEnabled){if(!this._lightmapTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._lightmapTexture,s,"LIGHTMAP"),s.USELIGHTMAPASSHADOWMAP=this._useLightmapAsShadowmap}else s.LIGHTMAP=!1;if(this._emissiveTexture&&e.StandardMaterial.EmissiveTextureEnabled){if(!this._emissiveTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._emissiveTexture,s,"EMISSIVE")}else s.EMISSIVE=!1;if(e.StandardMaterial.SpecularTextureEnabled){if(this._metallicTexture){if(!this._metallicTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._metallicTexture,s,"REFLECTIVITY"),s.METALLICWORKFLOW=!0,s.ROUGHNESSSTOREINMETALMAPALPHA=this._useRoughnessFromMetallicTextureAlpha,s.ROUGHNESSSTOREINMETALMAPGREEN=!this._useRoughnessFromMetallicTextureAlpha&&this._useRoughnessFromMetallicTextureGreen,s.METALLNESSSTOREINMETALMAPBLUE=this._useMetallnessFromMetallicTextureBlue,s.AOSTOREINMETALMAPRED=this._useAmbientOcclusionFromMetallicTextureRed}else if(this._reflectivityTexture){if(!this._reflectivityTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._reflectivityTexture,s,"REFLECTIVITY"),s.MICROSURFACEFROMREFLECTIVITYMAP=this._useMicroSurfaceFromReflectivityMapAlpha,s.MICROSURFACEAUTOMATIC=this._useAutoMicroSurfaceFromReflectivityMap}else s.REFLECTIVITY=!1;if(this._microSurfaceTexture){if(!this._microSurfaceTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._microSurfaceTexture,s,"MICROSURFACEMAP")}else s.MICROSURFACEMAP=!1}else s.REFLECTIVITY=!1,s.MICROSURFACEMAP=!1;if(o.getEngine().getCaps().standardDerivatives&&this._bumpTexture&&e.StandardMaterial.BumpTextureEnabled&&!this._disableBumpMap){if(!this._bumpTexture.isReady())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._bumpTexture,s,"BUMP"),this._useParallax&&this._albedoTexture&&e.StandardMaterial.DiffuseTextureEnabled?(s.PARALLAX=!0,s.PARALLAXOCCLUSION=!!this._useParallaxOcclusion):s.PARALLAX=!1,s.USERIGHTHANDEDSYSTEM=o.useRightHandedSystem}else s.BUMP=!1;var h=this._getRefractionTexture();if(h&&e.StandardMaterial.RefractionTextureEnabled){if(!h.isReadyOrNotBlocking())return!1;s.REFRACTION=!0,s.REFRACTIONMAP_3D=h.isCube,s.GAMMAREFRACTION=h.gammaSpace,s.REFRACTIONMAP_OPPOSITEZ=l.invertZ,s.LODINREFRACTIONALPHA=l.lodLevelInAlpha,this._linkRefractionWithTransparency&&(s.LINKREFRACTIONTOTRANSPARENCY=!0)}else s.REFRACTION=!1;if(this._environmentBRDFTexture&&e.StandardMaterial.ReflectionTextureEnabled){if(!this._environmentBRDFTexture.isReady())return!1;s.ENVIRONMENTBRDF=!0}this._shouldUseAlphaFromAlbedoTexture()&&(s.ALPHAFROMALBEDO=!0)}this._useSpecularOverAlpha&&(s.SPECULAROVERALPHA=!0),this._usePhysicalLightFalloff&&(s.USEPHYSICALLIGHTFALLOFF=!0),this._useRadianceOverAlpha&&(s.RADIANCEOVERALPHA=!0),(void 0!==this._metallic&&null!==this._metallic||void 0!==this._roughness&&null!==this._roughness)&&(s.METALLICWORKFLOW=!0),!this.backFaceCulling&&this._twoSidedLighting&&(s.TWOSIDEDLIGHTING=!0),s.ALPHATESTVALUE=this._alphaCutOff,s.PREMULTIPLYALPHA=this._preMultiplyAlpha,s.ALPHABLEND=this.needAlphaBlending(),s.ALPHAFRESNEL=this._useAlphaFresnel}if(s._areImageProcessingDirty){if(!this._imageProcessingConfiguration.isReady())return!1;this._imageProcessingConfiguration.prepareDefines(s)}if(s.FORCENORMALFORWARD=this._forceNormalForward,e.MaterialHelper.PrepareDefinesForMisc(i,o,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,s),e.MaterialHelper.PrepareDefinesForFrameBoundValues(o,a,s,n,this._forceAlphaTest),e.MaterialHelper.PrepareDefinesForAttributes(i,s,!0,!0,!0)&&i&&(o.getEngine().getCaps().standardDerivatives||i.isVerticesDataPresent(e.VertexBuffer.NormalKind)||(i.createNormals(!0),e.Tools.Warn("PBRMaterial: Normals have been created for the mesh: "+i.name))),s.isDirty){s.markAsProcessed(),o.resetCachedMaterial();var c=new e.EffectFallbacks;s.ENVIRONMENTBRDF&&c.addFallback(0,"ENVIRONMENTBRDF"),s.REFLECTION&&c.addFallback(0,"REFLECTION"),s.REFRACTION&&c.addFallback(0,"REFRACTION"),s.REFLECTIVITY&&c.addFallback(0,"REFLECTIVITY"),s.BUMP&&c.addFallback(0,"BUMP"),s.PARALLAX&&c.addFallback(1,"PARALLAX"),s.PARALLAXOCCLUSION&&c.addFallback(0,"PARALLAXOCCLUSION"),s.SPECULAROVERALPHA&&c.addFallback(0,"SPECULAROVERALPHA"),s.FOG&&c.addFallback(1,"FOG"),s.POINTSIZE&&c.addFallback(0,"POINTSIZE"),s.LOGARITHMICDEPTH&&c.addFallback(0,"LOGARITHMICDEPTH"),e.MaterialHelper.HandleFallbacksForShadows(s,c,this._maxSimultaneousLights),s.SPECULARTERM&&c.addFallback(0,"SPECULARTERM"),s.NUM_BONE_INFLUENCERS>0&&c.addCPUSkinningFallback(0,i);var u=[e.VertexBuffer.PositionKind];s.NORMAL&&u.push(e.VertexBuffer.NormalKind),s.TANGENT&&u.push(e.VertexBuffer.TangentKind),s.UV1&&u.push(e.VertexBuffer.UVKind),s.UV2&&u.push(e.VertexBuffer.UV2Kind),s.VERTEXCOLOR&&u.push(e.VertexBuffer.ColorKind),e.MaterialHelper.PrepareAttributesForBones(u,i,s,c),e.MaterialHelper.PrepareAttributesForInstances(u,s),e.MaterialHelper.PrepareAttributesForMorphTargets(u,i,s);var f=["world","view","viewProjection","vEyePosition","vLightsType","vAmbientColor","vAlbedoColor","vReflectivityColor","vEmissiveColor","vReflectionColor","vFogInfos","vFogColor","pointSize","vAlbedoInfos","vAmbientInfos","vOpacityInfos","vReflectionInfos","vEmissiveInfos","vReflectivityInfos","vMicroSurfaceSamplerInfos","vBumpInfos","vLightmapInfos","vRefractionInfos","mBones","vClipPlane","albedoMatrix","ambientMatrix","opacityMatrix","reflectionMatrix","emissiveMatrix","reflectivityMatrix","microSurfaceSamplerMatrix","bumpMatrix","lightmapMatrix","refractionMatrix","vLightingIntensity","logarithmicDepthConstant","vSphericalX","vSphericalY","vSphericalZ","vSphericalXX","vSphericalYY","vSphericalZZ","vSphericalXY","vSphericalYZ","vSphericalZX","vReflectionMicrosurfaceInfos","vRefractionMicrosurfaceInfos","vNormalReoderParams"],d=["albedoSampler","reflectivitySampler","ambientSampler","emissiveSampler","bumpSampler","lightmapSampler","opacitySampler","refractionSampler","refractionSamplerLow","refractionSamplerHigh","reflectionSampler","reflectionSamplerLow","reflectionSamplerHigh","microSurfaceSampler","environmentBrdfSampler"],p=["Material","Scene"];e.ImageProcessingConfiguration.PrepareUniforms(f,s),e.ImageProcessingConfiguration.PrepareSamplers(d,s),e.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:f,uniformBuffersNames:p,samplers:d,defines:s,maxSimultaneousLights:this._maxSimultaneousLights});var _=function(e){this.onCompiled&&this.onCompiled(e),this.bindSceneUniformBuffer(e,o.getSceneUniformBuffer())}.bind(this),m=s.toString();r.setEffect(o.getEngine().createEffect("pbr",{attributes:u,uniformsNames:f,uniformBuffersNames:p,samplers:d,defines:m,fallbacks:c,onCompiled:_,onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights,maxSimultaneousMorphTargets:s.NUM_MORPH_INFLUENCERS}},a),s),this.buildUniformLayout()}return!!r.effect.isReady()&&(s._renderId=o.getRenderId(),this._wasPreviouslyReady=!0,!0)},r.prototype.buildUniformLayout=function(){this._uniformBuffer.addUniform("vAlbedoInfos",2),this._uniformBuffer.addUniform("vAmbientInfos",3),this._uniformBuffer.addUniform("vOpacityInfos",2),this._uniformBuffer.addUniform("vEmissiveInfos",2),this._uniformBuffer.addUniform("vLightmapInfos",2),this._uniformBuffer.addUniform("vReflectivityInfos",3),this._uniformBuffer.addUniform("vMicroSurfaceSamplerInfos",2),this._uniformBuffer.addUniform("vRefractionInfos",4),this._uniformBuffer.addUniform("vReflectionInfos",2),this._uniformBuffer.addUniform("vBumpInfos",3),this._uniformBuffer.addUniform("albedoMatrix",16),this._uniformBuffer.addUniform("ambientMatrix",16),this._uniformBuffer.addUniform("opacityMatrix",16),this._uniformBuffer.addUniform("emissiveMatrix",16),this._uniformBuffer.addUniform("lightmapMatrix",16),this._uniformBuffer.addUniform("reflectivityMatrix",16),this._uniformBuffer.addUniform("microSurfaceSamplerMatrix",16),this._uniformBuffer.addUniform("bumpMatrix",16),this._uniformBuffer.addUniform("vNormalReoderParams",4),this._uniformBuffer.addUniform("refractionMatrix",16),this._uniformBuffer.addUniform("reflectionMatrix",16),this._uniformBuffer.addUniform("vReflectionColor",3),this._uniformBuffer.addUniform("vAlbedoColor",4),this._uniformBuffer.addUniform("vLightingIntensity",4),this._uniformBuffer.addUniform("vRefractionMicrosurfaceInfos",3),this._uniformBuffer.addUniform("vReflectionMicrosurfaceInfos",3),this._uniformBuffer.addUniform("vReflectivityColor",4),this._uniformBuffer.addUniform("vEmissiveColor",3),this._uniformBuffer.addUniform("pointSize",1),this._uniformBuffer.create()},r.prototype.unbind=function(){this._reflectionTexture&&this._reflectionTexture.isRenderTarget&&this._uniformBuffer.setTexture("reflectionSampler",null),this._refractionTexture&&this._refractionTexture.isRenderTarget&&this._uniformBuffer.setTexture("refractionSampler",null),i.prototype.unbind.call(this)},r.prototype.bindOnlyWorldMatrix=function(e){this._activeEffect.setMatrix("world",e)},r.prototype.bindForSubMesh=function(t,i,r){var n=this.getScene(),o=r._materialDefines;if(o){var s=r.effect;if(this._activeEffect=s,this.bindOnlyWorldMatrix(t),e.MaterialHelper.BindBonesParameters(i,this._activeEffect),this._mustRebind(n,s,i.visibility)){if(this._uniformBuffer.bindToEffect(s,"Material"),this.bindViewProjection(s),!this._uniformBuffer.useUbo||!this.isFrozen||!this._uniformBuffer.isSync){if(n.texturesEnabled){this._albedoTexture&&e.StandardMaterial.DiffuseTextureEnabled&&(this._uniformBuffer.updateFloat2("vAlbedoInfos",this._albedoTexture.coordinatesIndex,this._albedoTexture.level),e.MaterialHelper.BindTextureMatrix(this._albedoTexture,this._uniformBuffer,"albedo")),this._ambientTexture&&e.StandardMaterial.AmbientTextureEnabled&&(this._uniformBuffer.updateFloat3("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level,this._ambientTextureStrength),e.MaterialHelper.BindTextureMatrix(this._ambientTexture,this._uniformBuffer,"ambient")),this._opacityTexture&&e.StandardMaterial.OpacityTextureEnabled&&(this._uniformBuffer.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),e.MaterialHelper.BindTextureMatrix(this._opacityTexture,this._uniformBuffer,"opacity"));var a=this._getReflectionTexture();if(a&&e.StandardMaterial.ReflectionTextureEnabled){if(this._uniformBuffer.updateMatrix("reflectionMatrix",a.getReflectionTextureMatrix()),this._uniformBuffer.updateFloat2("vReflectionInfos",a.level,0),o.USESPHERICALFROMREFLECTIONMAP){var l=a.sphericalPolynomial;this._activeEffect.setFloat3("vSphericalX",l.x.x,l.x.y,l.x.z),this._activeEffect.setFloat3("vSphericalY",l.y.x,l.y.y,l.y.z),this._activeEffect.setFloat3("vSphericalZ",l.z.x,l.z.y,l.z.z),this._activeEffect.setFloat3("vSphericalXX_ZZ",l.xx.x-l.zz.x,l.xx.y-l.zz.y,l.xx.z-l.zz.z),this._activeEffect.setFloat3("vSphericalYY_ZZ",l.yy.x-l.zz.x,l.yy.y-l.zz.y,l.yy.z-l.zz.z),this._activeEffect.setFloat3("vSphericalZZ",l.zz.x,l.zz.y,l.zz.z),this._activeEffect.setFloat3("vSphericalXY",l.xy.x,l.xy.y,l.xy.z),this._activeEffect.setFloat3("vSphericalYZ",l.yz.x,l.yz.y,l.yz.z),this._activeEffect.setFloat3("vSphericalZX",l.zx.x,l.zx.y,l.zx.z)}this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos",a.getSize().width,a.lodGenerationScale,a.lodGenerationOffset)}this._emissiveTexture&&e.StandardMaterial.EmissiveTextureEnabled&&(this._uniformBuffer.updateFloat2("vEmissiveInfos",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),e.MaterialHelper.BindTextureMatrix(this._emissiveTexture,this._uniformBuffer,"emissive")),this._lightmapTexture&&e.StandardMaterial.LightmapTextureEnabled&&(this._uniformBuffer.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),e.MaterialHelper.BindTextureMatrix(this._lightmapTexture,this._uniformBuffer,"lightmap")),e.StandardMaterial.SpecularTextureEnabled&&(this._metallicTexture?(this._uniformBuffer.updateFloat3("vReflectivityInfos",this._metallicTexture.coordinatesIndex,this._metallicTexture.level,this._ambientTextureStrength),e.MaterialHelper.BindTextureMatrix(this._metallicTexture,this._uniformBuffer,"reflectivity")):this._reflectivityTexture&&(this._uniformBuffer.updateFloat3("vReflectivityInfos",this._reflectivityTexture.coordinatesIndex,this._reflectivityTexture.level,1),e.MaterialHelper.BindTextureMatrix(this._reflectivityTexture,this._uniformBuffer,"reflectivity")),this._microSurfaceTexture&&(this._uniformBuffer.updateFloat2("vMicroSurfaceSamplerInfos",this._microSurfaceTexture.coordinatesIndex,this._microSurfaceTexture.level),e.MaterialHelper.BindTextureMatrix(this._microSurfaceTexture,this._uniformBuffer,"microSurfaceSampler"))),this._bumpTexture&&n.getEngine().getCaps().standardDerivatives&&e.StandardMaterial.BumpTextureEnabled&&!this._disableBumpMap&&(this._uniformBuffer.updateFloat3("vBumpInfos",this._bumpTexture.coordinatesIndex,this._bumpTexture.level,this._parallaxScaleBias),e.MaterialHelper.BindTextureMatrix(this._bumpTexture,this._uniformBuffer,"bump"),n._mirroredCameraPosition?this._uniformBuffer.updateFloat4("vNormalReoderParams",this._invertNormalMapX?0:1,this._invertNormalMapX?1:-1,this._invertNormalMapY?0:1,this._invertNormalMapY?1:-1):this._uniformBuffer.updateFloat4("vNormalReoderParams",this._invertNormalMapX?1:0,this._invertNormalMapX?-1:1,this._invertNormalMapY?1:0,this._invertNormalMapY?-1:1));var h=this._getRefractionTexture();if(h&&e.StandardMaterial.RefractionTextureEnabled){this._uniformBuffer.updateMatrix("refractionMatrix",h.getReflectionTextureMatrix());var c=1;h.isCube||h.depth&&(c=h.depth),this._uniformBuffer.updateFloat4("vRefractionInfos",h.level,this._indexOfRefraction,c,this._invertRefractionY?-1:1),this._uniformBuffer.updateFloat3("vRefractionMicrosurfaceInfos",h.getSize().width,h.lodGenerationScale,h.lodGenerationOffset)}}this.pointsCloud&&this._uniformBuffer.updateFloat("pointSize",this.pointSize),o.METALLICWORKFLOW?(e.PBRMaterial._scaledReflectivity.r=void 0===this._metallic||null===this._metallic?1:this._metallic,e.PBRMaterial._scaledReflectivity.g=void 0===this._roughness||null===this._roughness?1:this._roughness,this._uniformBuffer.updateColor4("vReflectivityColor",e.PBRMaterial._scaledReflectivity,0)):this._uniformBuffer.updateColor4("vReflectivityColor",this._reflectivityColor,this._microSurface),this._uniformBuffer.updateColor3("vEmissiveColor",this._emissiveColor),this._uniformBuffer.updateColor3("vReflectionColor",this._reflectionColor),this._uniformBuffer.updateColor4("vAlbedoColor",this._albedoColor,this.alpha*i.visibility),this._lightingInfos.x=this._directIntensity,this._lightingInfos.y=this._emissiveIntensity,this._lightingInfos.z=this._environmentIntensity,this._lightingInfos.w=this._specularIntensity,this._uniformBuffer.updateVector4("vLightingIntensity",this._lightingInfos)}n.texturesEnabled&&(this._albedoTexture&&e.StandardMaterial.DiffuseTextureEnabled&&this._uniformBuffer.setTexture("albedoSampler",this._albedoTexture),this._ambientTexture&&e.StandardMaterial.AmbientTextureEnabled&&this._uniformBuffer.setTexture("ambientSampler",this._ambientTexture),this._opacityTexture&&e.StandardMaterial.OpacityTextureEnabled&&this._uniformBuffer.setTexture("opacitySampler",this._opacityTexture),a&&e.StandardMaterial.ReflectionTextureEnabled&&(o.LODBASEDMICROSFURACE?this._uniformBuffer.setTexture("reflectionSampler",a):(this._uniformBuffer.setTexture("reflectionSampler",a._lodTextureMid||a),this._uniformBuffer.setTexture("reflectionSamplerLow",a._lodTextureLow||a),this._uniformBuffer.setTexture("reflectionSamplerHigh",a._lodTextureHigh||a))),o.ENVIRONMENTBRDF&&this._uniformBuffer.setTexture("environmentBrdfSampler",this._environmentBRDFTexture),h&&e.StandardMaterial.RefractionTextureEnabled&&(o.LODBASEDMICROSFURACE?this._uniformBuffer.setTexture("refractionSampler",h):(this._uniformBuffer.setTexture("refractionSampler",h._lodTextureMid||h),this._uniformBuffer.setTexture("refractionSamplerLow",h._lodTextureLow||h),this._uniformBuffer.setTexture("refractionSamplerHigh",h._lodTextureHigh||h))),this._emissiveTexture&&e.StandardMaterial.EmissiveTextureEnabled&&this._uniformBuffer.setTexture("emissiveSampler",this._emissiveTexture),this._lightmapTexture&&e.StandardMaterial.LightmapTextureEnabled&&this._uniformBuffer.setTexture("lightmapSampler",this._lightmapTexture), -e.StandardMaterial.SpecularTextureEnabled&&(this._metallicTexture?this._uniformBuffer.setTexture("reflectivitySampler",this._metallicTexture):this._reflectivityTexture&&this._uniformBuffer.setTexture("reflectivitySampler",this._reflectivityTexture),this._microSurfaceTexture&&this._uniformBuffer.setTexture("microSurfaceSampler",this._microSurfaceTexture)),this._bumpTexture&&n.getEngine().getCaps().standardDerivatives&&e.StandardMaterial.BumpTextureEnabled&&!this._disableBumpMap&&this._uniformBuffer.setTexture("bumpSampler",this._bumpTexture)),e.MaterialHelper.BindClipPlane(this._activeEffect,n),n.ambientColor.multiplyToRef(this._ambientColor,this._globalAmbientColor);var u=n._mirroredCameraPosition?n._mirroredCameraPosition:n.activeCamera.globalPosition;s.setFloat4("vEyePosition",u.x,u.y,u.z,n._mirroredCameraPosition?-1:1),s.setColor3("vAmbientColor",this._globalAmbientColor)}!this._mustRebind(n,s)&&this.isFrozen||(n.lightsEnabled&&!this._disableLighting&&e.MaterialHelper.BindLights(n,i,this._activeEffect,o,this._maxSimultaneousLights,this._usePhysicalLightFalloff),(n.fogEnabled&&i.applyFog&&n.fogMode!==e.Scene.FOGMODE_NONE||a)&&this.bindView(s),e.MaterialHelper.BindFogParameters(n,i,this._activeEffect),o.NUM_MORPH_INFLUENCERS&&e.MaterialHelper.BindMorphTargetParameters(i,this._activeEffect),this._imageProcessingConfiguration.bind(this._activeEffect),e.MaterialHelper.BindLogDepth(o,this._activeEffect,n)),this._uniformBuffer.update(),this._afterBind(i),n=null}},r.prototype.getAnimatables=function(){var e=[];return this._albedoTexture&&this._albedoTexture.animations&&this._albedoTexture.animations.length>0&&e.push(this._albedoTexture),this._ambientTexture&&this._ambientTexture.animations&&this._ambientTexture.animations.length>0&&e.push(this._ambientTexture),this._opacityTexture&&this._opacityTexture.animations&&this._opacityTexture.animations.length>0&&e.push(this._opacityTexture),this._reflectionTexture&&this._reflectionTexture.animations&&this._reflectionTexture.animations.length>0&&e.push(this._reflectionTexture),this._emissiveTexture&&this._emissiveTexture.animations&&this._emissiveTexture.animations.length>0&&e.push(this._emissiveTexture),this._metallicTexture&&this._metallicTexture.animations&&this._metallicTexture.animations.length>0?e.push(this._metallicTexture):this._reflectivityTexture&&this._reflectivityTexture.animations&&this._reflectivityTexture.animations.length>0&&e.push(this._reflectivityTexture),this._bumpTexture&&this._bumpTexture.animations&&this._bumpTexture.animations.length>0&&e.push(this._bumpTexture),this._lightmapTexture&&this._lightmapTexture.animations&&this._lightmapTexture.animations.length>0&&e.push(this._lightmapTexture),this._refractionTexture&&this._refractionTexture.animations&&this._refractionTexture.animations.length>0&&e.push(this._refractionTexture),e},r.prototype._getReflectionTexture=function(){return this._reflectionTexture?this._reflectionTexture:this.getScene().environmentTexture},r.prototype._getRefractionTexture=function(){return this._refractionTexture?this._refractionTexture:this._linkRefractionWithTransparency?this.getScene().environmentTexture:null},r.prototype.dispose=function(e,t){t&&(this._albedoTexture&&this._albedoTexture.dispose(),this._ambientTexture&&this._ambientTexture.dispose(),this._opacityTexture&&this._opacityTexture.dispose(),this._reflectionTexture&&this._reflectionTexture.dispose(),this._environmentBRDFTexture&&this._environmentBRDFTexture.dispose(),this._emissiveTexture&&this._emissiveTexture.dispose(),this._metallicTexture&&this._metallicTexture.dispose(),this._reflectivityTexture&&this._reflectivityTexture.dispose(),this._bumpTexture&&this._bumpTexture.dispose(),this._lightmapTexture&&this._lightmapTexture.dispose(),this._refractionTexture&&this._refractionTexture.dispose()),this._renderTargets.dispose(),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),i.prototype.dispose.call(this,e,t)},r})(e.PushMaterial);i._scaledReflectivity=new e.Color3,__decorate([e.serializeAsImageProcessingConfiguration()],i.prototype,"_imageProcessingConfiguration",void 0),__decorate([e.serialize()],i.prototype,"useLogarithmicDepth",null),e.PBRBaseMaterial=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){var i=(function(t){function i(i,r){var n=t.call(this,i,r)||this;return n.maxSimultaneousLights=4,n.disableLighting=!1,n.invertNormalMapX=!1,n.invertNormalMapY=!1,n.emissiveColor=new e.Color3(0,0,0),n.occlusionStrength=1,n._transparencyMode=e.PBRMaterial.PBRMATERIAL_OPAQUE,n._useAmbientInGrayScale=!0,n}return __extends(i,t),Object.defineProperty(i.prototype,"transparencyMode",{get:function(){return this._transparencyMode},set:function(t){this._transparencyMode!==t&&(this._transparencyMode=t,t===e.PBRMaterial.PBRMATERIAL_ALPHATESTANDBLEND?this._forceAlphaTest=!0:this._forceAlphaTest=!1,this._markAllSubMeshesAsTexturesDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"doubleSided",{get:function(){return this._twoSidedLighting},set:function(e){this._twoSidedLighting!==e&&(this._twoSidedLighting=e,this.backFaceCulling=!e,this._markAllSubMeshesAsTexturesDirty())},enumerable:!0,configurable:!0}),i.prototype._shouldUseAlphaFromAlbedoTexture=function(){return this._albedoTexture&&this._albedoTexture.hasAlpha&&this._transparencyMode!==e.PBRMaterial.PBRMATERIAL_OPAQUE},i.prototype.needAlphaBlending=function(){return!this._linkRefractionWithTransparency&&(this.alpha<1||this._shouldUseAlphaFromAlbedoTexture()&&(this._transparencyMode===e.PBRMaterial.PBRMATERIAL_ALPHABLEND||this._transparencyMode===e.PBRMaterial.PBRMATERIAL_ALPHATESTANDBLEND))},i.prototype.needAlphaTesting=function(){return!this._linkRefractionWithTransparency&&(this._shouldUseAlphaFromAlbedoTexture()&&this._transparencyMode===e.PBRMaterial.PBRMATERIAL_ALPHATEST)},i.prototype.getActiveTextures=function(){var e=t.prototype.getActiveTextures.call(this);return this.environmentTexture&&e.push(this.environmentTexture),this.normalTexture&&e.push(this.normalTexture),this.emissiveTexture&&e.push(this.emissiveTexture),this.occlusionTexture&&e.push(this.occlusionTexture),e},i.prototype.getClassName=function(){return"PBRBaseSimpleMaterial"},i})(e.PBRBaseMaterial);__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsLightsDirty")],i.prototype,"maxSimultaneousLights",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsLightsDirty")],i.prototype,"disableLighting",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_reflectionTexture")],i.prototype,"environmentTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"invertNormalMapX",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"invertNormalMapY",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_bumpTexture")],i.prototype,"normalTexture",void 0),__decorate([e.serializeAsColor3("emissive"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"emissiveColor",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"emissiveTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_ambientTextureStrength")],i.prototype,"occlusionStrength",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_ambientTexture")],i.prototype,"occlusionTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_alphaCutOff")],i.prototype,"alphaCutOff",void 0),__decorate([e.serialize()],i.prototype,"transparencyMode",null),__decorate([e.serialize()],i.prototype,"doubleSided",null),t.PBRBaseSimpleMaterial=i})(e.Internals||(e.Internals={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r){var n=t.call(this,i,r)||this;return n.directIntensity=1,n.emissiveIntensity=1,n.environmentIntensity=1,n.specularIntensity=1,n.disableBumpMap=!1,n.ambientTextureStrength=1,n.ambientColor=new e.Color3(0,0,0),n.albedoColor=new e.Color3(1,1,1),n.reflectivityColor=new e.Color3(1,1,1),n.reflectionColor=new e.Color3(1,1,1),n.emissiveColor=new e.Color3(0,0,0),n.microSurface=1,n.indexOfRefraction=.66,n.invertRefractionY=!1,n.linkRefractionWithTransparency=!1,n.useLightmapAsShadowmap=!1,n.useAlphaFromAlbedoTexture=!1,n.forceAlphaTest=!1,n.alphaCutOff=.4,n.useSpecularOverAlpha=!0,n.useMicroSurfaceFromReflectivityMapAlpha=!1,n.useRoughnessFromMetallicTextureAlpha=!0,n.useRoughnessFromMetallicTextureGreen=!1,n.useMetallnessFromMetallicTextureBlue=!1,n.useAmbientOcclusionFromMetallicTextureRed=!1,n.useAmbientInGrayScale=!1,n.useAutoMicroSurfaceFromReflectivityMap=!1,n.usePhysicalLightFalloff=!0,n.useRadianceOverAlpha=!0,n.useParallax=!1,n.useParallaxOcclusion=!1,n.parallaxScaleBias=.05,n.disableLighting=!1,n.forceIrradianceInFragment=!1,n.maxSimultaneousLights=4,n.invertNormalMapX=!1,n.invertNormalMapY=!1,n.twoSidedLighting=!1,n.preMultiplyAlpha=!1,n.useAlphaFresnel=!1,n.environmentBRDFTexture=null,n.forceNormalForward=!1,n._environmentBRDFTexture=e.TextureTools.GetEnvironmentBRDFTexture(r),n}return __extends(i,t),Object.defineProperty(i,"PBRMATERIAL_OPAQUE",{get:function(){return this._PBRMATERIAL_OPAQUE},enumerable:!0,configurable:!0}),Object.defineProperty(i,"PBRMATERIAL_ALPHATEST",{get:function(){return this._PBRMATERIAL_ALPHATEST},enumerable:!0,configurable:!0}),Object.defineProperty(i,"PBRMATERIAL_ALPHABLEND",{get:function(){return this._PBRMATERIAL_ALPHABLEND},enumerable:!0,configurable:!0}),Object.defineProperty(i,"PBRMATERIAL_ALPHATESTANDBLEND",{get:function(){return this._PBRMATERIAL_ALPHATESTANDBLEND},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(e){this._attachImageProcessingConfiguration(e),this._markAllSubMeshesAsTexturesDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"cameraColorCurvesEnabled",{get:function(){return this.imageProcessingConfiguration.colorCurvesEnabled},set:function(e){this.imageProcessingConfiguration.colorCurvesEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"cameraColorGradingEnabled",{get:function(){return this.imageProcessingConfiguration.colorGradingEnabled},set:function(e){this.imageProcessingConfiguration.colorGradingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"cameraToneMappingEnabled",{get:function(){return this._imageProcessingConfiguration.toneMappingEnabled},set:function(e){this._imageProcessingConfiguration.toneMappingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"cameraExposure",{get:function(){return this._imageProcessingConfiguration.exposure},set:function(e){this._imageProcessingConfiguration.exposure=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"cameraContrast",{get:function(){return this._imageProcessingConfiguration.contrast},set:function(e){this._imageProcessingConfiguration.contrast=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"cameraColorGradingTexture",{get:function(){return this._imageProcessingConfiguration.colorGradingTexture},set:function(e){this._imageProcessingConfiguration.colorGradingTexture=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"cameraColorCurves",{get:function(){return this._imageProcessingConfiguration.colorCurves},set:function(e){this._imageProcessingConfiguration.colorCurves=e},enumerable:!0,configurable:!0}),i.prototype.getClassName=function(){return"PBRMaterial"},i.prototype.getActiveTextures=function(){var e=t.prototype.getActiveTextures.call(this);return this._albedoTexture&&e.push(this._albedoTexture),this._ambientTexture&&e.push(this._ambientTexture),this._opacityTexture&&e.push(this._opacityTexture),this._reflectionTexture&&e.push(this._reflectionTexture),this._emissiveTexture&&e.push(this._emissiveTexture),this._reflectivityTexture&&e.push(this._reflectivityTexture),this._metallicTexture&&e.push(this._metallicTexture),this._microSurfaceTexture&&e.push(this._microSurfaceTexture),this._bumpTexture&&e.push(this._bumpTexture),this._lightmapTexture&&e.push(this._lightmapTexture),this._refractionTexture&&e.push(this._refractionTexture),e},i.prototype.hasTexture=function(e){return!!t.prototype.hasTexture.call(this,e)||(this._albedoTexture===e||(this._ambientTexture===e||(this._opacityTexture===e||(this._reflectionTexture===e||(this._reflectivityTexture===e||(this._metallicTexture===e||(this._microSurfaceTexture===e||(this._bumpTexture===e||(this._lightmapTexture===e||this._refractionTexture===e)))))))))},i.prototype.clone=function(t){var r=this;return e.SerializationHelper.Clone((function(){return new i(t,r.getScene())}),this)},i.prototype.serialize=function(){var t=e.SerializationHelper.Serialize(this);return t.customType="BABYLON.PBRMaterial",t},i.Parse=function(t,r,n){return e.SerializationHelper.Parse((function(){return new i(t.name,r)}),t,r,n)},i})(e.PBRBaseMaterial);t._PBRMATERIAL_OPAQUE=0,t._PBRMATERIAL_ALPHATEST=1,t._PBRMATERIAL_ALPHABLEND=2,t._PBRMATERIAL_ALPHATESTANDBLEND=3,__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"directIntensity",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveIntensity",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"environmentIntensity",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"specularIntensity",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"disableBumpMap",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"albedoTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientTextureStrength",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"opacityTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectivityTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallicTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallic",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"roughness",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"microSurfaceTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"bumpTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty",null)],t.prototype,"lightmapTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"refractionTexture",void 0),__decorate([e.serializeAsColor3("ambient"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientColor",void 0),__decorate([e.serializeAsColor3("albedo"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"albedoColor",void 0),__decorate([e.serializeAsColor3("reflectivity"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectivityColor",void 0),__decorate([e.serializeAsColor3("reflection"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionColor",void 0),__decorate([e.serializeAsColor3("emissive"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveColor",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"microSurface",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"indexOfRefraction",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertRefractionY",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"linkRefractionWithTransparency",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useLightmapAsShadowmap",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAlphaFromAlbedoTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"forceAlphaTest",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"alphaCutOff",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useSpecularOverAlpha",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useMicroSurfaceFromReflectivityMapAlpha",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRoughnessFromMetallicTextureAlpha",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRoughnessFromMetallicTextureGreen",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useMetallnessFromMetallicTextureBlue",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAmbientOcclusionFromMetallicTextureRed",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAmbientInGrayScale",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAutoMicroSurfaceFromReflectivityMap",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"usePhysicalLightFalloff",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRadianceOverAlpha",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useParallax",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useParallaxOcclusion",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"parallaxScaleBias",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsLightsDirty")],t.prototype,"disableLighting",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"forceIrradianceInFragment",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsLightsDirty")],t.prototype,"maxSimultaneousLights",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapX",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapY",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"twoSidedLighting",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"preMultiplyAlpha",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAlphaFresnel",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"environmentBRDFTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"forceNormalForward",void 0),e.PBRMaterial=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e,i){var r=t.call(this,e,i)||this;return r._useRoughnessFromMetallicTextureAlpha=!1,r._useRoughnessFromMetallicTextureGreen=!0,r._useMetallnessFromMetallicTextureBlue=!0,r}return __extends(i,t),i.prototype.getClassName=function(){return"PBRMetallicRoughnessMaterial"},i.prototype.getActiveTextures=function(){var e=t.prototype.getActiveTextures.call(this);return this.baseTexture&&e.push(this.baseTexture),this.metallicRoughnessTexture&&e.push(this.metallicRoughnessTexture),e},i.prototype.hasTexture=function(e){return!!t.prototype.hasTexture.call(this,e)||(this.baseTexture===e||this.metallicRoughnessTexture===e)},i.prototype.clone=function(t){var r=this;return e.SerializationHelper.Clone((function(){return new i(t,r.getScene())}),this)},i.prototype.serialize=function(){var t=e.SerializationHelper.Serialize(this);return t.customType="BABYLON.PBRMetallicRoughnessMaterial",t},i.Parse=function(t,r,n){return e.SerializationHelper.Parse((function(){return new i(t.name,r)}),t,r,n)},i})(e.Internals.PBRBaseSimpleMaterial);__decorate([e.serializeAsColor3(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_albedoColor")],t.prototype,"baseColor",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_albedoTexture")],t.prototype,"baseTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallic",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"roughness",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_metallicTexture")],t.prototype,"metallicRoughnessTexture",void 0),e.PBRMetallicRoughnessMaterial=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e,i){var r=t.call(this,e,i)||this;return r._useMicroSurfaceFromReflectivityMapAlpha=!0,r}return __extends(i,t),i.prototype.getClassName=function(){return"PBRSpecularGlossinessMaterial"},i.prototype.getActiveTextures=function(){var e=t.prototype.getActiveTextures.call(this);return this.diffuseTexture&&e.push(this.diffuseTexture),this.specularGlossinessTexture&&e.push(this.specularGlossinessTexture),e},i.prototype.hasTexture=function(e){return!!t.prototype.hasTexture.call(this,e)||(this.diffuseTexture===e||this.specularGlossinessTexture===e)},i.prototype.clone=function(t){var r=this;return e.SerializationHelper.Clone((function(){return new i(t,r.getScene())}),this)},i.prototype.serialize=function(){var t=e.SerializationHelper.Serialize(this);return t.customType="BABYLON.PBRSpecularGlossinessMaterial",t},i.Parse=function(t,r,n){return e.SerializationHelper.Parse((function(){return new i(t.name,r)}),t,r,n)},i})(e.Internals.PBRBaseSimpleMaterial);__decorate([e.serializeAsColor3("diffuse"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_albedoColor")],t.prototype,"diffuseColor",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_albedoTexture")],t.prototype,"diffuseTexture",void 0),__decorate([e.serializeAsColor3("specular"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_reflectivityColor")],t.prototype,"specularColor",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_microSurface")],t.prototype,"glossiness",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_reflectivityTexture")],t.prototype,"specularGlossinessTexture",void 0),e.PBRSpecularGlossinessMaterial=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){e.CameraInputTypes={};var t=(function(){function t(e){this.attached={},this.camera=e,this.checkInputs=function(){}}return t.prototype.add=function(t){var i=t.getSimpleName();if(this.attached[i])return void e.Tools.Warn("camera input of type "+i+" already exists on camera");this.attached[i]=t,t.camera=this.camera,t.checkInputs&&(this.checkInputs=this._addCheckInputs(t.checkInputs.bind(t))),this.attachedElement&&t.attachControl(this.attachedElement)},t.prototype.remove=function(e){for(var t in this.attached){var i=this.attached[t];i===e&&(i.detachControl(this.attachedElement),delete this.attached[t],this.rebuildInputCheck())}},t.prototype.removeByType=function(e){for(var t in this.attached){var i=this.attached[t];i.getClassName()===e&&(i.detachControl(this.attachedElement),delete this.attached[t],this.rebuildInputCheck())}},t.prototype._addCheckInputs=function(e){var t=this.checkInputs;return function(){t(),e()}},t.prototype.attachInput=function(e){e.attachControl(this.attachedElement,this.noPreventDefault)},t.prototype.attachElement=function(t,i){if(!this.attachedElement){i=!e.Camera.ForceAttachControlToAlwaysPreventDefault&&i,this.attachedElement=t,this.noPreventDefault=i;for(var r in this.attached){this.attached[r];this.attached[r].attachControl(t,i)}}},t.prototype.detachElement=function(e){if(this.attachedElement===e){for(var t in this.attached){this.attached[t];this.attached[t].detachControl(e)}this.attachedElement=null}},t.prototype.rebuildInputCheck=function(){this.checkInputs=function(){};for(var e in this.attached){var t=this.attached[e];t.checkInputs&&(this.checkInputs=this._addCheckInputs(t.checkInputs.bind(t)))}},t.prototype.clear=function(){this.attachedElement&&this.detachElement(this.attachedElement),this.attached={},this.attachedElement=null,this.checkInputs=function(){}},t.prototype.serialize=function(t){var i={};for(var r in this.attached){var n=this.attached[r],o=e.SerializationHelper.Serialize(n);i[n.getClassName()]=o}t.inputsmgr=i},t.prototype.parse=function(t){var i=t.inputsmgr;if(i){this.clear();for(var r in i){var n=e.CameraInputTypes[r];if(n){var o=i[r],s=e.SerializationHelper.Parse((function(){return new n}),o,null);this.add(s)}}}else for(var r in this.attached){var n=e.CameraInputTypes[this.attached[r].getClassName()];if(n){var s=e.SerializationHelper.Parse((function(){return new n}),t,null);this.remove(this.attached[r]),this.add(s)}}},t})();e.CameraInputsManager=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e){void 0===e&&(e=!0),this.touchEnabled=e,this.buttons=[0,1,2],this.angularSensibility=2e3}return t.prototype.attachControl=function(t,i){var r=this,n=this.camera.getEngine();this._pointerInput||(this._pointerInput=function(o,s){var a=o.event;if((r.touchEnabled||"touch"!==a.pointerType)&&(o.type===e.PointerEventTypes.POINTERMOVE||-1!==r.buttons.indexOf(a.button)))if(o.type===e.PointerEventTypes.POINTERDOWN){try{a.srcElement.setPointerCapture(a.pointerId)}catch(e){}r.previousPosition={x:a.clientX,y:a.clientY},i||(a.preventDefault(),t.focus())}else if(o.type===e.PointerEventTypes.POINTERUP){try{a.srcElement.releasePointerCapture(a.pointerId)}catch(e){}r.previousPosition=null,i||a.preventDefault()}else if(o.type===e.PointerEventTypes.POINTERMOVE){if(!r.previousPosition||n.isPointerLock)return;var l=a.clientX-r.previousPosition.x,h=a.clientY-r.previousPosition.y;r.camera.getScene().useRightHandedSystem?r.camera.cameraRotation.y-=l/r.angularSensibility:r.camera.cameraRotation.y+=l/r.angularSensibility,r.camera.cameraRotation.x+=h/r.angularSensibility,r.previousPosition={x:a.clientX,y:a.clientY},i||a.preventDefault()}}),this._onMouseMove=function(e){if(n.isPointerLock){var t=e.movementX||e.mozMovementX||e.webkitMovementX||e.msMovementX||0,o=e.movementY||e.mozMovementY||e.webkitMovementY||e.msMovementY||0;r.camera.getScene().useRightHandedSystem?r.camera.cameraRotation.y-=t/r.angularSensibility:r.camera.cameraRotation.y+=t/r.angularSensibility,r.camera.cameraRotation.x+=o/r.angularSensibility,r.previousPosition=null,i||e.preventDefault()}},this._observer=this.camera.getScene().onPointerObservable.add(this._pointerInput,e.PointerEventTypes.POINTERDOWN|e.PointerEventTypes.POINTERUP|e.PointerEventTypes.POINTERMOVE),t.addEventListener("mousemove",this._onMouseMove,!1)},t.prototype.detachControl=function(e){this._observer&&e&&(this.camera.getScene().onPointerObservable.remove(this._observer),e.removeEventListener("mousemove",this._onMouseMove),this._observer=null,this._onMouseMove=null,this.previousPosition=null)},t.prototype.getClassName=function(){return"FreeCameraMouseInput"},t.prototype.getSimpleName=function(){return"mouse"},t})();__decorate([e.serialize()],t.prototype,"buttons",void 0),__decorate([e.serialize()],t.prototype,"angularSensibility",void 0),e.FreeCameraMouseInput=t,e.CameraInputTypes.FreeCameraMouseInput=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this._keys=[],this.keysUp=[38],this.keysDown=[40],this.keysLeft=[37],this.keysRight=[39]}return t.prototype.attachControl=function(t,i){var r=this;this._onKeyDown||(t.tabIndex=1,this._onKeyDown=function(e){if(-1!==r.keysUp.indexOf(e.keyCode)||-1!==r.keysDown.indexOf(e.keyCode)||-1!==r.keysLeft.indexOf(e.keyCode)||-1!==r.keysRight.indexOf(e.keyCode)){-1===r._keys.indexOf(e.keyCode)&&r._keys.push(e.keyCode),i||e.preventDefault()}},this._onKeyUp=function(e){if(-1!==r.keysUp.indexOf(e.keyCode)||-1!==r.keysDown.indexOf(e.keyCode)||-1!==r.keysLeft.indexOf(e.keyCode)||-1!==r.keysRight.indexOf(e.keyCode)){var t=r._keys.indexOf(e.keyCode);t>=0&&r._keys.splice(t,1),i||e.preventDefault()}},t.addEventListener("keydown",this._onKeyDown,!1),t.addEventListener("keyup",this._onKeyUp,!1),e.Tools.RegisterTopRootEvents([{name:"blur",handler:this._onLostFocus}]))},t.prototype.detachControl=function(t){this._onKeyDown&&(t.removeEventListener("keydown",this._onKeyDown),t.removeEventListener("keyup",this._onKeyUp),e.Tools.UnregisterTopRootEvents([{name:"blur",handler:this._onLostFocus}]),this._keys=[],this._onKeyDown=null,this._onKeyUp=null)},t.prototype.checkInputs=function(){if(this._onKeyDown)for(var t=this.camera,i=0;i=0?this.rotation.y=-Math.atan(i.z/i.x)+Math.PI/2:this.rotation.y=-Math.atan(i.z/i.x)-Math.PI/2,this.rotation.z=0,isNaN(this.rotation.x)&&(this.rotation.x=0),isNaN(this.rotation.y)&&(this.rotation.y=0),isNaN(this.rotation.z)&&(this.rotation.z=0),this.rotationQuaternion&&e.Quaternion.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this.rotationQuaternion)},i.prototype.getTarget=function(){return this._currentTarget},i.prototype._decideIfNeedsToMove=function(){return Math.abs(this.cameraDirection.x)>0||Math.abs(this.cameraDirection.y)>0||Math.abs(this.cameraDirection.z)>0},i.prototype._updatePosition=function(){if(this.parent)return this.parent.getWorldMatrix().invertToRef(e.Tmp.Matrix[0]),e.Vector3.TransformNormalToRef(this.cameraDirection,e.Tmp.Matrix[0],e.Tmp.Vector3[0]),void this.position.addInPlace(e.Tmp.Vector3[0]);this.position.addInPlace(this.cameraDirection)},i.prototype._checkInputs=function(){var i=this._decideIfNeedsToMove(),r=Math.abs(this.cameraRotation.x)>0||Math.abs(this.cameraRotation.y)>0;if(i&&this._updatePosition(),r){if(this.rotation.x+=this.cameraRotation.x,this.rotation.y+=this.cameraRotation.y,this.rotationQuaternion){this.rotation.lengthSquared()&&e.Quaternion.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this.rotationQuaternion)}if(!this.noRotationConstraint){var n=Math.PI/2*.95;this.rotation.x>n&&(this.rotation.x=n),this.rotation.x<-n&&(this.rotation.x=-n)}}i&&(Math.abs(this.cameraDirection.x)e.Engine.CollisionsEpsilon&&(o.position.addInPlace(o._diffPosition),o.onCollide&&r&&o.onCollide(r))})(i)},o.inputs=new e.FreeCameraInputsManager(o),o.inputs.addKeyboard().addMouse(),o}return __extends(i,t),Object.defineProperty(i.prototype,"angularSensibility",{get:function(){var e=this.inputs.attached.mouse;if(e)return e.angularSensibility},set:function(e){var t=this.inputs.attached.mouse;t&&(t.angularSensibility=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"keysUp",{get:function(){var e=this.inputs.attached.keyboard;if(e)return e.keysUp},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysUp=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"keysDown",{get:function(){var e=this.inputs.attached.keyboard;if(e)return e.keysDown},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysDown=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"keysLeft",{get:function(){var e=this.inputs.attached.keyboard;if(e)return e.keysLeft},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysLeft=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"keysRight",{get:function(){var e=this.inputs.attached.keyboard;if(e)return e.keysRight},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysRight=e)},enumerable:!0,configurable:!0}),i.prototype.attachControl=function(e,t){this.inputs.attachElement(e,t)},i.prototype.detachControl=function(t){this.inputs.detachElement(t),this.cameraDirection=new e.Vector3(0,0,0),this.cameraRotation=new e.Vector2(0,0)},Object.defineProperty(i.prototype,"collisionMask",{get:function(){return this._collisionMask},set:function(e){this._collisionMask=isNaN(e)?-1:e},enumerable:!0,configurable:!0}),i.prototype._collideWithWorld=function(t){var i;i=this.parent?e.Vector3.TransformCoordinates(this.position,this.parent.getWorldMatrix()):this.position,i.subtractFromFloatsToRef(0,this.ellipsoid.y,0,this._oldPosition),this._collider||(this._collider=new e.Collider),this._collider.radius=this.ellipsoid,this._collider.collisionMask=this._collisionMask;var r=t;this.applyGravity&&(r=t.add(this.getScene().gravity)),this.getScene().collisionCoordinator.getNewPosition(this._oldPosition,r,this._collider,3,null,this._onCollisionPositionChange,this.uniqueId)},i.prototype._checkInputs=function(){this._localDirection||(this._localDirection=e.Vector3.Zero(),this._transformedDirection=e.Vector3.Zero()),this.inputs.checkInputs(),t.prototype._checkInputs.call(this)},i.prototype._decideIfNeedsToMove=function(){return this._needMoveForGravity||Math.abs(this.cameraDirection.x)>0||Math.abs(this.cameraDirection.y)>0||Math.abs(this.cameraDirection.z)>0},i.prototype._updatePosition=function(){this.checkCollisions&&this.getScene().collisionsEnabled?this._collideWithWorld(this.cameraDirection):t.prototype._updatePosition.call(this)},i.prototype.dispose=function(){this.inputs.clear(),t.prototype.dispose.call(this)},i.prototype.getClassName=function(){return"FreeCamera"},i})(e.TargetCamera);__decorate([e.serializeAsVector3()],t.prototype,"ellipsoid",void 0),__decorate([e.serialize()],t.prototype,"checkCollisions",void 0),__decorate([e.serialize()],t.prototype,"applyGravity",void 0),e.FreeCamera=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this._keys=[],this.keysUp=[38],this.keysDown=[40],this.keysLeft=[37],this.keysRight=[39]}return t.prototype.attachControl=function(t,i){var r=this;t.tabIndex=1,this._onKeyDown=function(e){if(-1!==r.keysUp.indexOf(e.keyCode)||-1!==r.keysDown.indexOf(e.keyCode)||-1!==r.keysLeft.indexOf(e.keyCode)||-1!==r.keysRight.indexOf(e.keyCode)){-1===r._keys.indexOf(e.keyCode)&&r._keys.push(e.keyCode),e.preventDefault&&(i||e.preventDefault())}},this._onKeyUp=function(e){if(-1!==r.keysUp.indexOf(e.keyCode)||-1!==r.keysDown.indexOf(e.keyCode)||-1!==r.keysLeft.indexOf(e.keyCode)||-1!==r.keysRight.indexOf(e.keyCode)){var t=r._keys.indexOf(e.keyCode);t>=0&&r._keys.splice(t,1),e.preventDefault&&(i||e.preventDefault())}},this._onLostFocus=function(){r._keys=[]},t.addEventListener("keydown",this._onKeyDown,!1),t.addEventListener("keyup",this._onKeyUp,!1),e.Tools.RegisterTopRootEvents([{name:"blur",handler:this._onLostFocus}])},t.prototype.detachControl=function(t){t&&(t.removeEventListener("keydown",this._onKeyDown),t.removeEventListener("keyup",this._onKeyUp)),e.Tools.UnregisterTopRootEvents([{name:"blur",handler:this._onLostFocus}]),this._keys=[],this._onKeyDown=null,this._onKeyUp=null,this._onLostFocus=null},t.prototype.checkInputs=function(){if(this._onKeyDown)for(var e=this.camera,t=0;tMath.PI&&(this.beta=this.beta-2*Math.PI):this.betathis.upperBetaLimit&&(this.beta=this.upperBetaLimit),this.lowerAlphaLimit&&this.alphathis.upperAlphaLimit&&(this.alpha=this.upperAlphaLimit),this.lowerRadiusLimit&&this.radiusthis.upperRadiusLimit&&(this.radius=this.upperRadiusLimit)},i.prototype.rebuildAnglesAndRadius=function(){var e=this.position.subtract(this._getTargetPosition());this.radius=e.length(),this.alpha=Math.acos(e.x/Math.sqrt(Math.pow(e.x,2)+Math.pow(e.z,2))),e.z<0&&(this.alpha=2*Math.PI-this.alpha),this.beta=Math.acos(e.y/this.radius),this._checkLimits()},i.prototype.setPosition=function(e){this.position.equals(e)||(this.position.copyFrom(e),this.rebuildAnglesAndRadius())},i.prototype.setTarget=function(e,t,i){if(void 0===t&&(t=!1),void 0===i&&(i=!1),e.getBoundingInfo)this._targetBoundingCenter=t?e.getBoundingInfo().boundingBox.centerWorld.clone():null,this._targetHost=e,this._target=this._getTargetPosition();else{var r=e,n=this._getTargetPosition();if(n&&!i&&n.equals(r))return;this._target=r,this._targetBoundingCenter=null}this.rebuildAnglesAndRadius()},i.prototype._getViewMatrix=function(){var t=Math.cos(this.alpha),i=Math.sin(this.alpha),r=Math.cos(this.beta),n=Math.sin(this.beta);0===n&&(n=1e-4);var o=this._getTargetPosition();if(o.addToRef(new e.Vector3(this.radius*t*n,this.radius*r,this.radius*i*n),this._newPosition),this.getScene().collisionsEnabled&&this.checkCollisions)this._collider||(this._collider=new e.Collider),this._collider.radius=this.collisionRadius,this._newPosition.subtractToRef(this.position,this._collisionVelocity),this._collisionTriggered=!0,this.getScene().collisionCoordinator.getNewPosition(this.position,this._collisionVelocity,this._collider,3,null,this._onCollisionPositionChange,this.uniqueId);else{this.position.copyFrom(this._newPosition);var s=this.upVector;this.allowUpsideDown&&n<0&&(s=s.clone(),s=s.negate()),this.getScene().useRightHandedSystem?e.Matrix.LookAtRHToRef(this.position,o,s,this._viewMatrix):e.Matrix.LookAtLHToRef(this.position,o,s,this._viewMatrix),this._viewMatrix.m[12]+=this.targetScreenOffset.x,this._viewMatrix.m[13]+=this.targetScreenOffset.y}return this._currentTarget=o,this._viewMatrix},i.prototype.zoomOn=function(t,i){void 0===i&&(i=!1),t=t||this.getScene().meshes;var r=e.Mesh.MinMax(t),n=e.Vector3.Distance(r.min,r.max);this.radius=n*this.zoomOnFactor,this.focusOn({min:r.min,max:r.max,distance:n},i)},i.prototype.focusOn=function(t,i){void 0===i&&(i=!1);var r,n;void 0===t.min?(r=t||this.getScene().meshes,r=e.Mesh.MinMax(r),n=e.Vector3.Distance(r.min,r.max)):(r=t,n=t.distance),this._target=e.Mesh.Center(r),i||(this.maxZ=2*n)},i.prototype.createRigCamera=function(t,r){var n;switch(this.cameraRigMode){case e.Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case e.Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER:case e.Camera.RIG_MODE_VR:n=this._cameraRigParams.stereoHalfAngle*(0===r?1:-1);break;case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:n=this._cameraRigParams.stereoHalfAngle*(0===r?-1:1)}var o=new i(t,this.alpha+n,this.beta,this.radius,this._target,this.getScene());return o._cameraRigParams={},o},i.prototype._updateRigCameras=function(){var i=this._rigCameras[0],r=this._rigCameras[1];switch(i.beta=r.beta=this.beta,i.radius=r.radius=this.radius,this.cameraRigMode){case e.Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case e.Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER:case e.Camera.RIG_MODE_VR:i.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle,r.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle;break;case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:i.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle,r.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle}t.prototype._updateRigCameras.call(this)},i.prototype.dispose=function(){this.inputs.clear(),t.prototype.dispose.call(this)},i.prototype.getClassName=function(){return"ArcRotateCamera"},i})(e.TargetCamera);__decorate([e.serialize()],t.prototype,"alpha",void 0),__decorate([e.serialize()],t.prototype,"beta",void 0),__decorate([e.serialize()],t.prototype,"radius",void 0),__decorate([e.serializeAsVector3("target")],t.prototype,"_target",void 0),__decorate([e.serialize()],t.prototype,"inertialAlphaOffset",void 0),__decorate([e.serialize()],t.prototype,"inertialBetaOffset",void 0),__decorate([e.serialize()],t.prototype,"inertialRadiusOffset",void 0),__decorate([e.serialize()],t.prototype,"lowerAlphaLimit",void 0),__decorate([e.serialize()],t.prototype,"upperAlphaLimit",void 0),__decorate([e.serialize()],t.prototype,"lowerBetaLimit",void 0),__decorate([e.serialize()],t.prototype,"upperBetaLimit",void 0),__decorate([e.serialize()],t.prototype,"lowerRadiusLimit",void 0),__decorate([e.serialize()],t.prototype,"upperRadiusLimit",void 0),__decorate([e.serialize()],t.prototype,"inertialPanningX",void 0),__decorate([e.serialize()],t.prototype,"inertialPanningY",void 0),__decorate([e.serialize()],t.prototype,"panningInertia",void 0),__decorate([e.serialize()],t.prototype,"zoomOnFactor",void 0),__decorate([e.serialize()],t.prototype,"allowUpsideDown",void 0),e.ArcRotateCamera=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e){return t.call(this,e)||this}return __extends(i,t), -i.prototype.addMouseWheel=function(){return this.add(new e.ArcRotateCameraMouseWheelInput),this},i.prototype.addPointers=function(){return this.add(new e.ArcRotateCameraPointersInput),this},i.prototype.addKeyboard=function(){return this.add(new e.ArcRotateCameraKeyboardMoveInput),this},i.prototype.addGamepad=function(){return this.add(new e.ArcRotateCameraGamepadInput),this},i.prototype.addVRDeviceOrientation=function(){return this.add(new e.ArcRotateCameraVRDeviceOrientationInput),this},i})(e.CameraInputsManager);e.ArcRotateCameraInputsManager=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n){var o=t.call(this,i,n)||this;return o.groundColor=new e.Color3(0,0,0),o.direction=r||e.Vector3.Up(),o}return __extends(i,t),i.prototype._buildUniformLayout=function(){this._uniformBuffer.addUniform("vLightData",4),this._uniformBuffer.addUniform("vLightDiffuse",4),this._uniformBuffer.addUniform("vLightSpecular",3),this._uniformBuffer.addUniform("vLightGround",3),this._uniformBuffer.addUniform("shadowsInfo",3),this._uniformBuffer.addUniform("depthValues",2),this._uniformBuffer.create()},i.prototype.getClassName=function(){return"HemisphericLight"},i.prototype.setDirectionToTarget=function(t){return this.direction=e.Vector3.Normalize(t.subtract(e.Vector3.Zero())),this.direction},i.prototype.getShadowGenerator=function(){return null},i.prototype.transferToEffect=function(t,i){var r=e.Vector3.Normalize(this.direction);return this._uniformBuffer.updateFloat4("vLightData",r.x,r.y,r.z,0,i),this._uniformBuffer.updateColor3("vLightGround",this.groundColor.scale(this.intensity),i),this},i.prototype._getWorldMatrix=function(){return this._worldMatrix||(this._worldMatrix=e.Matrix.Identity()),this._worldMatrix},i.prototype.getTypeID=function(){return e.Light.LIGHTTYPEID_HEMISPHERICLIGHT},i})(e.Light);__decorate([e.serializeAsColor3()],t.prototype,"groundColor",void 0),__decorate([e.serializeAsVector3()],t.prototype,"direction",void 0),e.HemisphericLight=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(){var e=null!==t&&t.apply(this,arguments)||this;return e._needProjectionMatrixCompute=!0,e}return __extends(i,t),Object.defineProperty(i.prototype,"direction",{get:function(){return this._direction},set:function(e){this._direction=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"shadowMinZ",{get:function(){return this._shadowMinZ},set:function(e){this._shadowMinZ=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"shadowMaxZ",{get:function(){return this._shadowMaxZ},set:function(e){this._shadowMaxZ=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),i.prototype.computeTransformedInformation=function(){return!(!this.parent||!this.parent.getWorldMatrix)&&(this.transformedPosition||(this.transformedPosition=e.Vector3.Zero()),e.Vector3.TransformCoordinatesToRef(this.position,this.parent.getWorldMatrix(),this.transformedPosition),this.direction&&(this.transformedDirection||(this.transformedDirection=e.Vector3.Zero()),e.Vector3.TransformNormalToRef(this.direction,this.parent.getWorldMatrix(),this.transformedDirection)),!0)},i.prototype.getDepthScale=function(){return 50},i.prototype.getShadowDirection=function(e){return this.transformedDirection?this.transformedDirection:this.direction},i.prototype.getAbsolutePosition=function(){return this.transformedPosition?this.transformedPosition:this.position},i.prototype.setDirectionToTarget=function(t){return this.direction=e.Vector3.Normalize(t.subtract(this.position)),this.direction},i.prototype.getRotation=function(){this.direction.normalize();var t=e.Vector3.Cross(this.direction,e.Axis.Y),i=e.Vector3.Cross(t,this.direction);return e.Vector3.RotationFromAxis(t,i,this.direction)},i.prototype.needCube=function(){return!1},i.prototype.needProjectionMatrixCompute=function(){return this._needProjectionMatrixCompute},i.prototype.forceProjectionMatrixCompute=function(){this._needProjectionMatrixCompute=!0},i.prototype._getWorldMatrix=function(){return this._worldMatrix||(this._worldMatrix=e.Matrix.Identity()),e.Matrix.TranslationToRef(this.position.x,this.position.y,this.position.z,this._worldMatrix),this._worldMatrix},i.prototype.getDepthMinZ=function(e){return void 0!==this.shadowMinZ?this.shadowMinZ:e.minZ},i.prototype.getDepthMaxZ=function(e){return void 0!==this.shadowMaxZ?this.shadowMaxZ:e.maxZ},i.prototype.setShadowProjectionMatrix=function(e,t,i){return this.customProjectionMatrixBuilder?this.customProjectionMatrixBuilder(t,i,e):this._setDefaultShadowProjectionMatrix(e,t,i),this},i})(e.Light);__decorate([e.serializeAsVector3()],t.prototype,"position",void 0),__decorate([e.serializeAsVector3()],t.prototype,"direction",null),__decorate([e.serialize()],t.prototype,"shadowMinZ",null),__decorate([e.serialize()],t.prototype,"shadowMaxZ",null),e.ShadowLight=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e,i,r){var n=t.call(this,e,r)||this;return n._shadowAngle=Math.PI/2,n.position=i,n}return __extends(i,t),Object.defineProperty(i.prototype,"shadowAngle",{get:function(){return this._shadowAngle},set:function(e){this._shadowAngle=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"direction",{get:function(){return this._direction},set:function(e){var t=this.needCube();this._direction=e,this.needCube()!==t&&this._shadowGenerator&&this._shadowGenerator.recreateShadowMap()},enumerable:!0,configurable:!0}),i.prototype.getClassName=function(){return"PointLight"},i.prototype.getTypeID=function(){return e.Light.LIGHTTYPEID_POINTLIGHT},i.prototype.needCube=function(){return!this.direction},i.prototype.getShadowDirection=function(i){if(this.direction)return t.prototype.getShadowDirection.call(this,i);switch(i){case 0:return new e.Vector3(1,0,0);case 1:return new e.Vector3(-1,0,0);case 2:return new e.Vector3(0,-1,0);case 3:return new e.Vector3(0,1,0);case 4:return new e.Vector3(0,0,1);case 5:return new e.Vector3(0,0,-1)}return e.Vector3.Zero()},i.prototype._setDefaultShadowProjectionMatrix=function(t,i,r){var n=this.getScene().activeCamera;e.Matrix.PerspectiveFovLHToRef(this.shadowAngle,1,this.getDepthMinZ(n),this.getDepthMaxZ(n),t)},i.prototype._buildUniformLayout=function(){this._uniformBuffer.addUniform("vLightData",4),this._uniformBuffer.addUniform("vLightDiffuse",4),this._uniformBuffer.addUniform("vLightSpecular",3),this._uniformBuffer.addUniform("shadowsInfo",3),this._uniformBuffer.addUniform("depthValues",2),this._uniformBuffer.create()},i.prototype.transferToEffect=function(e,t){return this.computeTransformedInformation()?(this._uniformBuffer.updateFloat4("vLightData",this.transformedPosition.x,this.transformedPosition.y,this.transformedPosition.z,0,t),this):(this._uniformBuffer.updateFloat4("vLightData",this.position.x,this.position.y,this.position.z,0,t),this)},i})(e.ShadowLight);__decorate([e.serialize()],t.prototype,"shadowAngle",null),e.PointLight=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e,i,r){var n=t.call(this,e,r)||this;return n._shadowFrustumSize=0,n._shadowOrthoScale=.5,n.autoUpdateExtends=!0,n._orthoLeft=Number.MAX_VALUE,n._orthoRight=Number.MIN_VALUE,n._orthoTop=Number.MIN_VALUE,n._orthoBottom=Number.MAX_VALUE,n.position=i.scale(-1),n.direction=i,n}return __extends(i,t),Object.defineProperty(i.prototype,"shadowFrustumSize",{get:function(){return this._shadowFrustumSize},set:function(e){this._shadowFrustumSize=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"shadowOrthoScale",{get:function(){return this._shadowOrthoScale},set:function(e){this._shadowOrthoScale=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),i.prototype.getClassName=function(){return"DirectionalLight"},i.prototype.getTypeID=function(){return e.Light.LIGHTTYPEID_DIRECTIONALLIGHT},i.prototype._setDefaultShadowProjectionMatrix=function(e,t,i){this.shadowFrustumSize>0?this._setDefaultFixedFrustumShadowProjectionMatrix(e,t):this._setDefaultAutoExtendShadowProjectionMatrix(e,t,i)},i.prototype._setDefaultFixedFrustumShadowProjectionMatrix=function(t,i){var r=this.getScene().activeCamera;e.Matrix.OrthoLHToRef(this.shadowFrustumSize,this.shadowFrustumSize,void 0!==this.shadowMinZ?this.shadowMinZ:r.minZ,void 0!==this.shadowMaxZ?this.shadowMaxZ:r.maxZ,t)},i.prototype._setDefaultAutoExtendShadowProjectionMatrix=function(t,i,r){var n=this.getScene().activeCamera;if(this.autoUpdateExtends||this._orthoLeft===Number.MAX_VALUE){var o=e.Vector3.Zero();this._orthoLeft=Number.MAX_VALUE,this._orthoRight=Number.MIN_VALUE,this._orthoTop=Number.MIN_VALUE,this._orthoBottom=Number.MAX_VALUE;for(var s=0;sthis._orthoRight&&(this._orthoRight=o.x),o.y>this._orthoTop&&(this._orthoTop=o.y)}}}var u=this._orthoRight-this._orthoLeft,f=this._orthoTop-this._orthoBottom;e.Matrix.OrthoOffCenterLHToRef(this._orthoLeft-u*this.shadowOrthoScale,this._orthoRight+u*this.shadowOrthoScale,this._orthoBottom-f*this.shadowOrthoScale,this._orthoTop+f*this.shadowOrthoScale,void 0!==this.shadowMinZ?this.shadowMinZ:n.minZ,void 0!==this.shadowMaxZ?this.shadowMaxZ:n.maxZ,t)},i.prototype._buildUniformLayout=function(){this._uniformBuffer.addUniform("vLightData",4),this._uniformBuffer.addUniform("vLightDiffuse",4),this._uniformBuffer.addUniform("vLightSpecular",3),this._uniformBuffer.addUniform("shadowsInfo",3),this._uniformBuffer.addUniform("depthValues",2),this._uniformBuffer.create()},i.prototype.transferToEffect=function(e,t){return this.computeTransformedInformation()?(this._uniformBuffer.updateFloat4("vLightData",this.transformedDirection.x,this.transformedDirection.y,this.transformedDirection.z,1,t),this):(this._uniformBuffer.updateFloat4("vLightData",this.direction.x,this.direction.y,this.direction.z,1,t),this)},i.prototype.getDepthMinZ=function(e){return 1},i.prototype.getDepthMaxZ=function(e){return 1},i})(e.ShadowLight);__decorate([e.serialize()],t.prototype,"shadowFrustumSize",null),__decorate([e.serialize()],t.prototype,"shadowOrthoScale",null),__decorate([e.serialize()],t.prototype,"autoUpdateExtends",void 0),e.DirectionalLight=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e,i,r,n,o,s){var a=t.call(this,e,s)||this;return a.position=i,a.direction=r,a.angle=n,a.exponent=o,a}return __extends(i,t),Object.defineProperty(i.prototype,"angle",{get:function(){return this._angle},set:function(e){this._angle=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"shadowAngleScale",{get:function(){return this._shadowAngleScale},set:function(e){this._shadowAngleScale=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),i.prototype.getClassName=function(){return"SpotLight"},i.prototype.getTypeID=function(){return e.Light.LIGHTTYPEID_SPOTLIGHT},i.prototype._setDefaultShadowProjectionMatrix=function(t,i,r){var n=this.getScene().activeCamera;this._shadowAngleScale=this._shadowAngleScale||1;var o=this._shadowAngleScale*this._angle;e.Matrix.PerspectiveFovLHToRef(o,1,this.getDepthMinZ(n),this.getDepthMaxZ(n),t)},i.prototype._buildUniformLayout=function(){this._uniformBuffer.addUniform("vLightData",4),this._uniformBuffer.addUniform("vLightDiffuse",4),this._uniformBuffer.addUniform("vLightSpecular",3),this._uniformBuffer.addUniform("vLightDirection",3),this._uniformBuffer.addUniform("shadowsInfo",3),this._uniformBuffer.addUniform("depthValues",2),this._uniformBuffer.create()},i.prototype.transferToEffect=function(t,i){var r;return this.computeTransformedInformation()?(this._uniformBuffer.updateFloat4("vLightData",this.transformedPosition.x,this.transformedPosition.y,this.transformedPosition.z,this.exponent,i),r=e.Vector3.Normalize(this.transformedDirection)):(this._uniformBuffer.updateFloat4("vLightData",this.position.x,this.position.y,this.position.z,this.exponent,i),r=e.Vector3.Normalize(this.direction)),this._uniformBuffer.updateFloat4("vLightDirection",r.x,r.y,r.z,Math.cos(.5*this.angle),i),this},i})(e.ShadowLight);__decorate([e.serialize()],t.prototype,"angle",null),__decorate([e.serialize()],t.prototype,"shadowAngleScale",null),__decorate([e.serialize()],t.prototype,"exponent",void 0),e.SpotLight=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(e,t,i){this.name=e,this.from=t,this.to=i}return e.prototype.clone=function(){return new e(this.name,this.from,this.to)},e})();e.AnimationRange=t;var i=(function(){function e(e,t,i){this.frame=e,this.action=t,this.onlyOnce=i,this.isDone=!1}return e})();e.AnimationEvent=i;var r=(function(){function t(e){this.path=e,this._onchange=new Array,this.value=0,this.animations=new Array}return t.prototype.getPoint=function(){var t=this.path.getPointAtLengthPosition(this.value);return new e.Vector3(t.x,0,t.y)},t.prototype.moveAhead=function(e){return void 0===e&&(e=.002),this.move(e),this},t.prototype.moveBack=function(e){return void 0===e&&(e=.002),this.move(-e),this},t.prototype.move=function(e){if(Math.abs(e)>1)throw"step size should be less than 1.";return this.value+=e,this.ensureLimits(),this.raiseOnChange(),this},t.prototype.ensureLimits=function(){for(;this.value>1;)this.value-=1;for(;this.value<0;)this.value+=1;return this},t.prototype.markAsDirty=function(e){return this.ensureLimits(),this.raiseOnChange(),this},t.prototype.raiseOnChange=function(){var e=this;return this._onchange.forEach((function(t){return t(e)})),this},t.prototype.onchange=function(e){return this._onchange.push(e),this},t})();e.PathCursor=r;var n=(function(){function i(e,t,r,n,o,s){this.name=e,this.targetProperty=t,this.framePerSecond=r,this.dataType=n,this.loopMode=o,this.enableBlending=s,this._offsetsCache={},this._highLimitsCache={},this._stopped=!1,this._blendingFactor=0,this._events=new Array,this.allowMatricesInterpolation=!1,this.blendingSpeed=.01,this._ranges={},this.targetPropertyPath=t.split("."),this.dataType=n,this.loopMode=void 0===o?i.ANIMATIONLOOPMODE_CYCLE:o}return i._PrepareAnimation=function(t,r,n,o,s,a,l,h){var c=void 0;if(!isNaN(parseFloat(s))&&isFinite(s)?c=i.ANIMATIONTYPE_FLOAT:s instanceof e.Quaternion?c=i.ANIMATIONTYPE_QUATERNION:s instanceof e.Vector3?c=i.ANIMATIONTYPE_VECTOR3:s instanceof e.Vector2?c=i.ANIMATIONTYPE_VECTOR2:s instanceof e.Color3?c=i.ANIMATIONTYPE_COLOR3:s instanceof e.Size&&(c=i.ANIMATIONTYPE_SIZE),void 0==c)return null;var u=new i(t,r,n,c,l),f=[{frame:0,value:s},{frame:o,value:a}];return u.setKeys(f),void 0!==h&&u.setEasingFunction(h),u},i.CreateAndStartAnimation=function(e,t,r,n,o,s,a,l,h,c){var u=i._PrepareAnimation(e,r,n,o,s,a,l,h);return t.getScene().beginDirectAnimation(t,[u],0,o,1===u.loopMode,1,c)},i.CreateMergeAndStartAnimation=function(e,t,r,n,o,s,a,l,h,c){var u=i._PrepareAnimation(e,r,n,o,s,a,l,h);return t.animations.push(u),t.getScene().beginAnimation(t,0,o,1===u.loopMode,1,c)},i.prototype.toString=function(e){var t="Name: "+this.name+", property: "+this.targetProperty;if(t+=", datatype: "+["Float","Vector3","Quaternion","Matrix","Color3","Vector2"][this.dataType],t+=", nKeys: "+(this._keys?this._keys.length:"none"),t+=", nRanges: "+(this._ranges?Object.keys(this._ranges).length:"none"),e){t+=", Ranges: {";var i=!0;for(var r in this._ranges)i&&(t+=", ",i=!1),t+=r;t+="}"}return t},i.prototype.addEvent=function(e){this._events.push(e)},i.prototype.removeEvents=function(e){for(var t=0;t=0;n--)this._keys[n].frame>=i&&this._keys[n].frame<=r&&this._keys.splice(n,1);this._ranges[e]=void 0}},i.prototype.getRange=function(e){return this._ranges[e]},i.prototype.reset=function(){this._offsetsCache={},this._highLimitsCache={},this.currentFrame=0,this._blendingFactor=0,this._originalBlendValue=null},i.prototype.isStopped=function(){return this._stopped},i.prototype.getKeys=function(){return this._keys},i.prototype.getHighestFrame=function(){for(var e=0,t=0,i=this._keys.length;t0)return o.clone?o.clone():o;this.currentFrame=e;var s=Math.max(0,Math.min(this._keys.length-1,Math.floor(this._keys.length*(e-this._keys[0].frame)/(this._keys[this._keys.length-1].frame-this._keys[0].frame))-1));if(this._keys[s].frame>=e)for(;s-1>=0&&this._keys[s].frame>=e;)s--;for(var a=s;a=e){var h=this._keys[a],c=this._getKeyValue(h.value),u=this._getKeyValue(l.value),f=void 0!==h.outTangent&&void 0!==l.inTangent,d=l.frame-h.frame,p=(e-h.frame)/d;switch(null!=this._easingFunction&&(p=this._easingFunction.ease(p)),this.dataType){case i.ANIMATIONTYPE_FLOAT:var _=f?this.floatInterpolateFunctionWithTangents(c,h.outTangent*d,u,l.inTangent*d,p):this.floatInterpolateFunction(c,u,p);switch(r){case i.ANIMATIONLOOPMODE_CYCLE:case i.ANIMATIONLOOPMODE_CONSTANT:return _;case i.ANIMATIONLOOPMODE_RELATIVE:return n*t+_}break;case i.ANIMATIONTYPE_QUATERNION:var m=f?this.quaternionInterpolateFunctionWithTangents(c,h.outTangent.scale(d),u,l.inTangent.scale(d),p):this.quaternionInterpolateFunction(c,u,p);switch(r){case i.ANIMATIONLOOPMODE_CYCLE:case i.ANIMATIONLOOPMODE_CONSTANT:return m;case i.ANIMATIONLOOPMODE_RELATIVE:return m.add(n.scale(t))}return m;case i.ANIMATIONTYPE_VECTOR3:var g=f?this.vector3InterpolateFunctionWithTangents(c,h.outTangent.scale(d),u,l.inTangent.scale(d),p):this.vector3InterpolateFunction(c,u,p);switch(r){case i.ANIMATIONLOOPMODE_CYCLE:case i.ANIMATIONLOOPMODE_CONSTANT:return g;case i.ANIMATIONLOOPMODE_RELATIVE:return g.add(n.scale(t))}case i.ANIMATIONTYPE_VECTOR2:var v=f?this.vector2InterpolateFunctionWithTangents(c,h.outTangent.scale(d),u,l.inTangent.scale(d),p):this.vector2InterpolateFunction(c,u,p);switch(r){case i.ANIMATIONLOOPMODE_CYCLE:case i.ANIMATIONLOOPMODE_CONSTANT:return v;case i.ANIMATIONLOOPMODE_RELATIVE:return v.add(n.scale(t))}case i.ANIMATIONTYPE_SIZE:switch(r){case i.ANIMATIONLOOPMODE_CYCLE:case i.ANIMATIONLOOPMODE_CONSTANT:return this.sizeInterpolateFunction(c,u,p);case i.ANIMATIONLOOPMODE_RELATIVE:return this.sizeInterpolateFunction(c,u,p).add(n.scale(t))}case i.ANIMATIONTYPE_COLOR3:switch(r){case i.ANIMATIONLOOPMODE_CYCLE:case i.ANIMATIONLOOPMODE_CONSTANT:return this.color3InterpolateFunction(c,u,p);case i.ANIMATIONLOOPMODE_RELATIVE:return this.color3InterpolateFunction(c,u,p).add(n.scale(t))}case i.ANIMATIONTYPE_MATRIX:switch(r){case i.ANIMATIONLOOPMODE_CYCLE:case i.ANIMATIONLOOPMODE_CONSTANT:if(this.allowMatricesInterpolation)return this.matrixInterpolateFunction(c,u,p);case i.ANIMATIONLOOPMODE_RELATIVE:return c}}break}}return this._getKeyValue(this._keys[this._keys.length-1].value)},i.prototype.setValue=function(t,i){void 0===i&&(i=!1);var r,n;if(this.targetPropertyPath.length>1){for(var o=this._target[this.targetPropertyPath[0]],s=1;sthis._keys[this._keys.length-1].frame&&(e=this._keys[this._keys.length-1].frame);var t=this._interpolate(e,0,this.loopMode);this.setValue(t)},i.prototype.animate=function(t,r,n,o,s,a){if(void 0===a&&(a=!1),!this.targetPropertyPath||this.targetPropertyPath.length<1)return this._stopped=!0,!1;var l=!0;if(0!==this._keys[0].frame){var h={frame:0,value:this._keys[0].value};this._keys.splice(0,0,h)}(rthis._keys[this._keys.length-1].frame)&&(r=this._keys[0].frame),(nthis._keys[this._keys.length-1].frame)&&(n=this._keys[this._keys.length-1].frame),r===n&&r++;var c,u=n-r,f=t*(this.framePerSecond*s)/1e3,d=0;if((n>r&&f>u||r>n&&f>0,v=l?r+f%u:n,y=this._interpolate(v,g,this.loopMode,c,d);this.setValue(y);for(var x=0;x0&&v>=this._events[x].frame&&this._events[x].frame>=r||u<0&&v<=this._events[x].frame&&this._events[x].frame<=r){var b=this._events[x];b.isDone||(b.onlyOnce&&(this._events.splice(x,1),x--),b.isDone=!0,b.action())}else this._events[x].isDone&&!this._events[x].onlyOnce&&(this._events[x].isDone=!1);return l||(this._stopped=!0),l},i.prototype.serialize=function(){var e={};e.name=this.name,e.property=this.targetProperty,e.framePerSecond=this.framePerSecond,e.dataType=this.dataType,e.loopBehavior=this.loopMode,e.enableBlending=this.enableBlending,e.blendingSpeed=this.blendingSpeed;var t=this.dataType;e.keys=[];for(var r=this.getKeys(),n=0;n-1){for(var i=this._animations,r=i.length-1;r>=0;r--)"string"==typeof e&&i[r].name!=e||(i[r].reset(),i.splice(r,1));0==i.length&&(this._scene._activeAnimatables.splice(t,1),this.onAnimationEnd&&this.onAnimationEnd())}}else{var r=this._scene._activeAnimatables.indexOf(this);if(r>-1){this._scene._activeAnimatables.splice(r,1);for(var i=this._animations,r=0;r=.5?.5*(1-this.easeInCore(2*(1-t)))+.5:.5*this.easeInCore(2*t)},e})();t._EASINGMODE_EASEIN=0,t._EASINGMODE_EASEOUT=1,t._EASINGMODE_EASEINOUT=2,e.EasingFunction=t;var i=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.easeInCore=function(e){return e=Math.max(0,Math.min(1,e)),1-Math.sqrt(1-e*e)},t})(t);e.CircleEase=i;var r=(function(e){function t(t){void 0===t&&(t=1);var i=e.call(this)||this;return i.amplitude=t,i}return __extends(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.amplitude);return Math.pow(e,3)-e*t*Math.sin(3.141592653589793*e)},t})(t);e.BackEase=r;var n=(function(e){function t(t,i){void 0===t&&(t=3),void 0===i&&(i=2);var r=e.call(this)||this;return r.bounces=t,r.bounciness=i,r}return __extends(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.bounces),i=this.bounciness -;i<=1&&(i=1.001);var r=Math.pow(i,t),n=1-i,o=(1-r)/n+.5*r,s=e*o,a=Math.log(-s*(1-i)+1)/Math.log(i),l=Math.floor(a),h=l+1,c=(1-Math.pow(i,l))/(n*o),u=(1-Math.pow(i,h))/(n*o),f=.5*(c+u),d=e-f,p=f-c;return-Math.pow(1/i,t-l)/(p*p)*(d-p)*(d+p)},t})(t);e.BounceEase=n;var o=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.easeInCore=function(e){return e*e*e},t})(t);e.CubicEase=o;var s=(function(e){function t(t,i){void 0===t&&(t=3),void 0===i&&(i=3);var r=e.call(this)||this;return r.oscillations=t,r.springiness=i,r}return __extends(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.oscillations),i=Math.max(0,this.springiness);return(0==i?e:(Math.exp(i*e)-1)/(Math.exp(i)-1))*Math.sin((6.283185307179586*t+1.5707963267948966)*e)},t})(t);e.ElasticEase=s;var a=(function(e){function t(t){void 0===t&&(t=2);var i=e.call(this)||this;return i.exponent=t,i}return __extends(t,e),t.prototype.easeInCore=function(e){return this.exponent<=0?e:(Math.exp(this.exponent*e)-1)/(Math.exp(this.exponent)-1)},t})(t);e.ExponentialEase=a;var l=(function(e){function t(t){void 0===t&&(t=2);var i=e.call(this)||this;return i.power=t,i}return __extends(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.power);return Math.pow(e,t)},t})(t);e.PowerEase=l;var h=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.easeInCore=function(e){return e*e},t})(t);e.QuadraticEase=h;var c=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.easeInCore=function(e){return e*e*e*e},t})(t);e.QuarticEase=c;var u=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.easeInCore=function(e){return e*e*e*e*e},t})(t);e.QuinticEase=u;var f=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.easeInCore=function(e){return 1-Math.sin(1.5707963267948966*(1-e))},t})(t);e.SineEase=f;var d=(function(t){function i(e,i,r,n){void 0===e&&(e=0),void 0===i&&(i=0),void 0===r&&(r=1),void 0===n&&(n=1);var o=t.call(this)||this;return o.x1=e,o.y1=i,o.x2=r,o.y2=n,o}return __extends(i,t),i.prototype.easeInCore=function(t){return e.BezierCurve.interpolate(t,this.x1,this.y1,this.x2,this.y2)},i})(t);e.BezierCurveEase=d})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(e){this._actionManager=e}return e.prototype.isValid=function(){return!0},e.prototype._getProperty=function(e){return this._actionManager._getProperty(e)},e.prototype._getEffectiveTarget=function(e,t){return this._actionManager._getEffectiveTarget(e,t)},e.prototype.serialize=function(){},e.prototype._serialize=function(e){return{type:2,children:[],name:e.name,properties:e.properties}},e})();e.Condition=t;var i=(function(t){function i(e,r,n,o,s){void 0===s&&(s=i.IsEqual);var a=t.call(this,e)||this;return a.propertyPath=n,a.value=o,a.operator=s,a._target=r,a._effectiveTarget=a._getEffectiveTarget(r,a.propertyPath),a._property=a._getProperty(a.propertyPath),a}return __extends(i,t),Object.defineProperty(i,"IsEqual",{get:function(){return i._IsEqual},enumerable:!0,configurable:!0}),Object.defineProperty(i,"IsDifferent",{get:function(){return i._IsDifferent},enumerable:!0,configurable:!0}),Object.defineProperty(i,"IsGreater",{get:function(){return i._IsGreater},enumerable:!0,configurable:!0}),Object.defineProperty(i,"IsLesser",{get:function(){return i._IsLesser},enumerable:!0,configurable:!0}),i.prototype.isValid=function(){switch(this.operator){case i.IsGreater:return this._effectiveTarget[this._property]>this.value;case i.IsLesser:return this._effectiveTarget[this._property]-1&&this._scene._actionManagers.splice(e,1)},t.prototype.getScene=function(){return this._scene},t.prototype.hasSpecificTriggers=function(e){for(var t=0;t-1)return!0}return!1},t.prototype.hasSpecificTrigger=function(e){for(var t=0;t=t._OnPickTrigger&&i.trigger<=t._OnPointerOutTrigger)return!0}return!1},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"hasPickTriggers",{get:function(){for(var e=0;e=t._OnPickTrigger&&i.trigger<=t._OnPickUpTrigger)return!0}return!1},enumerable:!0,configurable:!0}),Object.defineProperty(t,"HasTriggers",{get:function(){for(var e in t.Triggers)if(t.Triggers.hasOwnProperty(e))return!0;return!1},enumerable:!0,configurable:!0}),Object.defineProperty(t,"HasPickTriggers",{get:function(){for(var e in t.Triggers)if(t.Triggers.hasOwnProperty(e)){var i=parseInt(e);if(i>=t._OnPickTrigger&&i<=t._OnPickUpTrigger)return!0}return!1},enumerable:!0,configurable:!0}),t.HasSpecificTrigger=function(e){for(var i in t.Triggers)if(t.Triggers.hasOwnProperty(i)){var r=parseInt(i);if(r===e)return!0}return!1},t.prototype.registerAction=function(i){return i.trigger===t.OnEveryFrameTrigger&&this.getScene().actionManager!==this?(e.Tools.Warn("OnEveryFrameTrigger can only be used with scene.actionManager"),null):(this.actions.push(i),t.Triggers[i.trigger]?t.Triggers[i.trigger]++:t.Triggers[i.trigger]=1,i._actionManager=this,i._prepare(),i)},t.prototype.processTrigger=function(e,i){for(var r=0;r0;if(2===i.type?f.push(o):f.push(r),_){for(var m=new Array,g=0;g0){var f=u.properties[0].value,d=null===u.properties[0].targetType?f:n.getMeshByName(f);d._meshId&&(d.mesh=n.getMeshByID(d._meshId)),c={trigger:e.ActionManager[u.name],parameter:d}}else c=e.ActionManager[u.name];for(var p=0;p>0;this._vertexData[o+10]=t.cellIndex-s*n,this._vertexData[o+11]=s,this._vertexData[o+12]=t.color.r,this._vertexData[o+13]=t.color.g,this._vertexData[o+14]=t.color.b,this._vertexData[o+15]=t.color.a},t.prototype.intersects=function(t,i,r,n){for(var o,s=Math.min(this._capacity,this.sprites.length),a=e.Vector3.Zero(),l=e.Vector3.Zero(),h=Number.MAX_VALUE,c=e.Vector3.Zero(),u=i.getViewMatrix(),f=0;fp&&(h=p,o=d,n))break}}}if(o){var _=new e.PickingInfo;return _.hit=!0,_.pickedSprite=o,_.distance=h,_}return null},t.prototype.render=function(){if(this._effectBase.isReady()&&this._effectFog.isReady()&&this._spriteTexture&&this._spriteTexture.isReady()){for(var t=this._scene.getEngine(),i=this._spriteTexture.getBaseSize(),r=t.getDeltaTime(),n=Math.min(this._capacity,this.sprites.length),o=i.width/this.cellWidth,s=0,a=0;athis._delay&&(this._time=this._time%this._delay,this.cellIndex+=this._direction,this.cellIndex===this._toIndex&&(this._loopAnimation?this.cellIndex=this._fromIndex:(this._animationStarted=!1,this._onAnimationEnd&&this._onAnimationEnd(),this.disposeWhenFinishedAnimating&&this.dispose()))))},t.prototype.dispose=function(){for(var e=0;et.x)return!1}else if(i=1/this.direction.x,r=(e.x-this.origin.x)*i,n=(t.x-this.origin.x)*i,n===-1/0&&(n=1/0),r>n&&(o=r,r=n,n=o),s=Math.max(r,s),a=Math.min(n,a),s>a)return!1;if(Math.abs(this.direction.y)<1e-7){if(this.origin.yt.y)return!1}else if(i=1/this.direction.y,r=(e.y-this.origin.y)*i,n=(t.y-this.origin.y)*i,n===-1/0&&(n=1/0),r>n&&(o=r,r=n,n=o),s=Math.max(r,s),a=Math.min(n,a),s>a)return!1;if(Math.abs(this.direction.z)<1e-7){if(this.origin.zt.z)return!1}else if(i=1/this.direction.z,r=(e.z-this.origin.z)*i,n=(t.z-this.origin.z)*i,n===-1/0&&(n=1/0),r>n&&(o=r,r=n,n=o),s=Math.max(r,s),a=Math.min(n,a),s>a)return!1;return!0},t.prototype.intersectsBox=function(e){return this.intersectsBoxMinMax(e.minimum,e.maximum)},t.prototype.intersectsSphere=function(e){var t=e.center.x-this.origin.x,i=e.center.y-this.origin.y,r=e.center.z-this.origin.z,n=t*t+i*i+r*r,o=e.radius*e.radius;if(n<=o)return!0;var s=t*this.direction.x+i*this.direction.y+r*this.direction.z;return!(s<0)&&n-s*s<=o},t.prototype.intersectsTriangle=function(t,i,r){this._edge1||(this._edge1=e.Vector3.Zero(),this._edge2=e.Vector3.Zero(),this._pvec=e.Vector3.Zero(),this._tvec=e.Vector3.Zero(),this._qvec=e.Vector3.Zero()),i.subtractToRef(t,this._edge1),r.subtractToRef(t,this._edge2),e.Vector3.CrossToRef(this.direction,this._edge2,this._pvec);var n=e.Vector3.Dot(this._edge1,this._pvec);if(0===n)return null;var o=1/n;this.origin.subtractToRef(t,this._tvec);var s=e.Vector3.Dot(this._tvec,this._pvec)*o;if(s<0||s>1)return null;e.Vector3.CrossToRef(this._tvec,this._edge1,this._qvec);var a=e.Vector3.Dot(this.direction,this._qvec)*o;if(a<0||s+a>1)return null;var l=e.Vector3.Dot(this._edge2,this._qvec)*o;return l>this.length?null:new e.IntersectionInfo(s,a,l)},t.prototype.intersectsPlane=function(t){var i,r=e.Vector3.Dot(t.normal,this.direction);if(Math.abs(r)<9.99999997475243e-7)return null;var n=e.Vector3.Dot(t.normal,this.origin);return i=(-t.d-n)/r,i<0?i<-9.99999997475243e-7?null:0:i},t.prototype.intersectsMesh=function(i,r){var n=e.Tmp.Matrix[0];return i.getWorldMatrix().invertToRef(n),this._tmpRay?t.TransformToRef(this,n,this._tmpRay):this._tmpRay=t.Transform(this,n),i.intersects(this._tmpRay,r)},t.prototype.intersectsMeshes=function(e,t,i){i?i.length=0:i=[];for(var r=0;rt.distance?1:0},t.prototype.intersectionSegment=function(i,r,n){var o,s,a,l,h=this.origin.add(this.direction.multiplyByFloats(t.rayl,t.rayl,t.rayl)),c=r.subtract(i),u=h.subtract(this.origin),f=i.subtract(this.origin),d=e.Vector3.Dot(c,c),p=e.Vector3.Dot(c,u),_=e.Vector3.Dot(u,u),m=e.Vector3.Dot(c,f),g=e.Vector3.Dot(u,f),v=d*_-p*p,y=v,x=v;vy&&(s=y,l=g+p,x=_)),l<0?(l=0,-m<0?s=0:-m>d?s=y:(s=-m,y=d)):l>x&&(l=x,-m+p<0?s=0:-m+p>d?s=y:(s=-m+p,y=d)),o=Math.abs(s)0&&a<=this.length&&A.lengthSquared()i.x+r)&&(!(i.x-r>t.x)&&(!(e.y>i.y+r)&&(!(i.y-r>t.y)&&(!(e.z>i.z+r)&&!(i.z-r>t.z)))))},i=(function(){var e={root:0,found:!1};return function(t,i,r,n){e.root=0,e.found=!1;var o=i*i-4*t*r;if(o<0)return e;var s=Math.sqrt(o),a=(-i-s)/(2*t),l=(-i+s)/(2*t);if(a>l){var h=l;l=a,a=h}return a>0&&a0&&l=0))},r.prototype._canDoCollision=function(i,r,n,o){var s=e.Vector3.Distance(this.basePointWorld,i),a=Math.max(this.radius.x,this.radius.y,this.radius.z);return!(s>this.velocityWorldLength+a+r)&&!!t(n,o,this.basePointWorld,this.velocityWorldLength+a)},r.prototype._testTriangle=function(t,r,n,o,s,a){var l,h=!1;r||(r=[]),r[t]||(r[t]=new e.Plane(0,0,0,0),r[t].copyFromPoints(n,o,s));var c=r[t];if(a||c.isFrontFacingTo(this.normalizedVelocity,0)){var u=c.signedDistanceTo(this.basePoint),f=e.Vector3.Dot(c.normal,this.velocity);if(0==f){if(Math.abs(u)>=1)return;h=!0,l=0}else{l=(-1-u)/f;var d=(1-u)/f;if(l>d){var p=d;d=l,l=p}if(l>1||d<0)return;l<0&&(l=0),l>1&&(l=1)}this._collisionPoint.copyFromFloats(0,0,0);var _=!1,m=1;if(h||(this.basePoint.subtractToRef(c.normal,this._planeIntersectionPoint),this.velocity.scaleToRef(l,this._tempVector),this._planeIntersectionPoint.addInPlace(this._tempVector),this._checkPointInTriangle(this._planeIntersectionPoint,n,o,s,c.normal)&&(_=!0,m=l,this._collisionPoint.copyFrom(this._planeIntersectionPoint))),!_){var g=this.velocity.lengthSquared(),v=g;this.basePoint.subtractToRef(n,this._tempVector);var y=2*e.Vector3.Dot(this.velocity,this._tempVector),x=this._tempVector.lengthSquared()-1,b=i(v,y,x,m);b.found&&(m=b.root,_=!0,this._collisionPoint.copyFrom(n)),this.basePoint.subtractToRef(o,this._tempVector),y=2*e.Vector3.Dot(this.velocity,this._tempVector),x=this._tempVector.lengthSquared()-1,b=i(v,y,x,m),b.found&&(m=b.root,_=!0,this._collisionPoint.copyFrom(o)),this.basePoint.subtractToRef(s,this._tempVector),y=2*e.Vector3.Dot(this.velocity,this._tempVector),x=this._tempVector.lengthSquared()-1,b=i(v,y,x,m),b.found&&(m=b.root,_=!0,this._collisionPoint.copyFrom(s)),o.subtractToRef(n,this._edge),n.subtractToRef(this.basePoint,this._baseToVertex);var A=this._edge.lengthSquared(),T=e.Vector3.Dot(this._edge,this.velocity),E=e.Vector3.Dot(this._edge,this._baseToVertex);if(v=A*-g+T*T,y=A*(2*e.Vector3.Dot(this.velocity,this._baseToVertex))-2*T*E,x=A*(1-this._baseToVertex.lengthSquared())+E*E,b=i(v,y,x,m),b.found){var P=(T*b.root-E)/A;P>=0&&P<=1&&(m=b.root,_=!0,this._edge.scaleInPlace(P),n.addToRef(this._edge,this._collisionPoint))}s.subtractToRef(o,this._edge),o.subtractToRef(this.basePoint,this._baseToVertex),A=this._edge.lengthSquared(),T=e.Vector3.Dot(this._edge,this.velocity),E=e.Vector3.Dot(this._edge,this._baseToVertex),v=A*-g+T*T,y=A*(2*e.Vector3.Dot(this.velocity,this._baseToVertex))-2*T*E,x=A*(1-this._baseToVertex.lengthSquared())+E*E,b=i(v,y,x,m),b.found&&(P=(T*b.root-E)/A)>=0&&P<=1&&(m=b.root,_=!0,this._edge.scaleInPlace(P),o.addToRef(this._edge,this._collisionPoint)),n.subtractToRef(s,this._edge),s.subtractToRef(this.basePoint,this._baseToVertex),A=this._edge.lengthSquared(),T=e.Vector3.Dot(this._edge,this.velocity),E=e.Vector3.Dot(this._edge,this._baseToVertex),v=A*-g+T*T,y=A*(2*e.Vector3.Dot(this.velocity,this._baseToVertex))-2*T*E,x=A*(1-this._baseToVertex.lengthSquared())+E*E,b=i(v,y,x,m),b.found&&(P=(T*b.root-E)/A)>=0&&P<=1&&(m=b.root,_=!0,this._edge.scaleInPlace(P),s.addToRef(this._edge,this._collisionPoint))}if(_){var M=m*this.velocity.length();(!this.collisionFound||M4)){++n._runningUpdated;var e={updatedMeshes:n._addUpdateMeshesList,updatedGeometries:n._addUpdateGeometriesList,removedGeometries:n._toRemoveGeometryArray,removedMeshes:n._toRemoveMeshesArray},i={payload:e,taskType:t.UPDATE},r=[];for(var o in e.updatedGeometries)e.updatedGeometries.hasOwnProperty(o)&&(r.push(i.payload.updatedGeometries[o].indices.buffer),r.push(i.payload.updatedGeometries[o].normals.buffer),r.push(i.payload.updatedGeometries[o].positions.buffer));n._worker.postMessage(i,r),n._addUpdateMeshesList={},n._addUpdateGeometriesList={},n._toRemoveGeometryArray=[],n._toRemoveMeshesArray=[]}},this._onMessageFromWorker=function(r){var o=r.data;if(o.error!=i.SUCCESS)return void e.Tools.Warn("error returned from worker!");switch(o.taskType){case t.INIT:n._init=!0,n._scene.meshes.forEach((function(e){n.onMeshAdded(e)})),n._scene.getGeometries().forEach((function(e){n.onGeometryAdded(e)}));break;case t.UPDATE:n._runningUpdated--;break;case t.COLLIDE:n._runningCollisionTask=!1;var s=o.payload;if(!n._collisionsCallbackArray[s.collisionId])return;n._collisionsCallbackArray[s.collisionId](s.collisionId,e.Vector3.FromArray(s.newPosition),n._scene.getMeshByUniqueID(s.collidedMeshUniqueId)),n._collisionsCallbackArray[s.collisionId]=void 0}},this._collisionsCallbackArray=[],this._init=!1,this._runningUpdated=0,this._runningCollisionTask=!1,this._addUpdateMeshesList={},this._addUpdateGeometriesList={},this._toRemoveGeometryArray=[],this._toRemoveMeshesArray=[]}return r.prototype.getNewPosition=function(e,i,r,n,o,s,a){if(this._init&&!this._collisionsCallbackArray[a]&&!this._collisionsCallbackArray[a+1e5]){e.divideToRef(r.radius,this._scaledPosition),i.divideToRef(r.radius,this._scaledVelocity),this._collisionsCallbackArray[a]=s;var l={collider:{position:this._scaledPosition.asArray(),velocity:this._scaledVelocity.asArray(),radius:r.radius.asArray()},collisionId:a,excludedMeshUniqueId:o?o.uniqueId:null,maximumRetry:n},h={payload:l,taskType:t.COLLIDE};this._worker.postMessage(h)}},r.prototype.init=function(i){this._scene=i,this._scene.registerAfterRender(this._afterRender);var r=e.WorkerIncluded?e.Engine.CodeRepository+"Collisions/babylon.collisionWorker.js":URL.createObjectURL(new Blob([e.CollisionWorker],{type:"application/javascript"}));this._worker=new Worker(r),this._worker.onmessage=this._onMessageFromWorker;var n={payload:{},taskType:t.INIT};this._worker.postMessage(n)},r.prototype.destroy=function(){this._scene.unregisterAfterRender(this._afterRender),this._worker.terminate()},r.prototype.onMeshAdded=function(e){e.registerAfterWorldMatrixUpdate(this.onMeshUpdated),this.onMeshUpdated(e)},r.prototype.onMeshRemoved=function(e){this._toRemoveMeshesArray.push(e.uniqueId)},r.prototype.onGeometryAdded=function(e){e.onGeometryUpdated=this.onGeometryUpdated,this.onGeometryUpdated(e)},r.prototype.onGeometryDeleted=function(e){this._toRemoveGeometryArray.push(e.id)},r})();r.SerializeMesh=function(t){var i=[];t.subMeshes&&(i=t.subMeshes.map((function(e,t){return{position:t,verticesStart:e.verticesStart,verticesCount:e.verticesCount,indexStart:e.indexStart,indexCount:e.indexCount,hasMaterial:!!e.getMaterial(),sphereCenter:e.getBoundingInfo().boundingSphere.centerWorld.asArray(),sphereRadius:e.getBoundingInfo().boundingSphere.radiusWorld,boxMinimum:e.getBoundingInfo().boundingBox.minimumWorld.asArray(),boxMaximum:e.getBoundingInfo().boundingBox.maximumWorld.asArray()}})));var r=null;return t instanceof e.Mesh?r=t.geometry?t.geometry.id:null:t instanceof e.InstancedMesh&&(r=t.sourceMesh&&t.sourceMesh.geometry?t.sourceMesh.geometry.id:null),{uniqueId:t.uniqueId,id:t.id,name:t.name,geometryId:r,sphereCenter:t.getBoundingInfo().boundingSphere.centerWorld.asArray(),sphereRadius:t.getBoundingInfo().boundingSphere.radiusWorld,boxMinimum:t.getBoundingInfo().boundingBox.minimumWorld.asArray(),boxMaximum:t.getBoundingInfo().boundingBox.maximumWorld.asArray(),worldMatrixFromCache:t.worldMatrixFromCache.asArray(),subMeshes:i,checkCollisions:t.checkCollisions}},r.SerializeGeometry=function(t){return{id:t.id,positions:new Float32Array(t.getVerticesData(e.VertexBuffer.PositionKind)||[]),normals:new Float32Array(t.getVerticesData(e.VertexBuffer.NormalKind)||[]),indices:new Uint32Array(t.getIndices()||[])}},e.CollisionCoordinatorWorker=r;var n=(function(){function t(){this._scaledPosition=e.Vector3.Zero(),this._scaledVelocity=e.Vector3.Zero(),this._finalPosition=e.Vector3.Zero()}return t.prototype.getNewPosition=function(e,t,i,r,n,o,s){e.divideToRef(i.radius,this._scaledPosition),t.divideToRef(i.radius,this._scaledVelocity),i.collidedMesh=null,i.retry=0,i.initialVelocity=this._scaledVelocity,i.initialPosition=this._scaledPosition,this._collideWithWorld(this._scaledPosition,this._scaledVelocity,i,r,this._finalPosition,n),this._finalPosition.multiplyInPlace(i.radius),o(s,this._finalPosition,i.collidedMesh)},t.prototype.init=function(e){this._scene=e},t.prototype.destroy=function(){},t.prototype.onMeshAdded=function(e){},t.prototype.onMeshUpdated=function(e){},t.prototype.onMeshRemoved=function(e){},t.prototype.onGeometryAdded=function(e){},t.prototype.onGeometryUpdated=function(e){},t.prototype.onGeometryDeleted=function(e){},t.prototype._collideWithWorld=function(t,i,r,n,o,s){void 0===s&&(s=null);var a=10*e.Engine.CollisionsEpsilon;if(r.retry>=n)return void o.copyFrom(t);var l=s?s.collisionMask:r.collisionMask;r._initialize(t,i,a);for(var h=0;h=i.lifeTime?(a.recycleParticle(i),t--):(i.colorStep.scaleToRef(a._scaledUpdateSpeed,a._scaledColorStep),i.color.addInPlace(a._scaledColorStep),i.color.a<0&&(i.color.a=0),i.angle+=i.angularSpeed*a._scaledUpdateSpeed,i.direction.scaleToRef(a._scaledUpdateSpeed,a._scaledDirection),i.position.addInPlace(a._scaledDirection),a.gravity.scaleToRef(a._scaledUpdateSpeed,a._scaledGravity),i.direction.addInPlace(a._scaledGravity))}}}return Object.defineProperty(i.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!0,configurable:!0}),i.prototype.recycleParticle=function(e){var t=this.particles.pop();t!==e&&(t.copyTo(e),this._stockParticles.push(t))},i.prototype.getCapacity=function(){return this._capacity},i.prototype.isAlive=function(){return this._alive},i.prototype.isStarted=function(){return this._started},i.prototype.start=function(){this._started=!0,this._stopped=!1,this._actualFrame=0},i.prototype.stop=function(){this._stopped=!0},i.prototype._appendParticleVertex=function(e,t,i,r){var n=11*e;this._vertexData[n]=t.position.x,this._vertexData[n+1]=t.position.y,this._vertexData[n+2]=t.position.z,this._vertexData[n+3]=t.color.r,this._vertexData[n+4]=t.color.g,this._vertexData[n+5]=t.color.b,this._vertexData[n+6]=t.color.a,this._vertexData[n+7]=t.angle,this._vertexData[n+8]=t.size,this._vertexData[n+9]=i,this._vertexData[n+10]=r},i.prototype._update=function(i){this._alive=this.particles.length>0,this.updateFunction(this.particles);var r;if(this.emitter.position){r=this.emitter.getWorldMatrix()}else{var n=this.emitter;r=e.Matrix.Translation(n.x,n.y,n.z)}for(var o,s=0;s-1?(t=this.manualEmitCount,this._newPartsExcess=0,this.manualEmitCount=0):(t=this.emitRate*this._scaledUpdateSpeed>>0,this._newPartsExcess+=this.emitRate*this._scaledUpdateSpeed-t),this._newPartsExcess>1&&(t+=this._newPartsExcess>>0,this._newPartsExcess-=this._newPartsExcess>>0),this._alive=!1,this._stopped?t=0:(this._actualFrame+=this._scaledUpdateSpeed,this.targetStopDuration&&this._actualFrame>=this.targetStopDuration&&this.stop()),this._update(t),this._stopped&&(this._alive||(this._started=!1,this.onAnimationEnd&&this.onAnimationEnd(),this.disposeOnStop&&this._scene._toBeDisposed.push(this)));for(var i=0,r=0;r-1&&this._scene.particleSystems.splice(e,1),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear()},i.prototype.clone=function(t,r){var n=null,o=null;if(null!=this.customShader){o=this.customShader;var s=o.shaderOptions.defines.length>0?o.shaderOptions.defines.join("\n"):"";n=this._scene.getEngine().createEffectForParticles(o.shaderPath.fragmentElement,o.shaderOptions.uniforms,o.shaderOptions.samplers,s)}var a=new i(t,this._capacity,this._scene,n);return a.customShader=o,e.Tools.DeepCopy(this,a,["particles","customShader"]),void 0===r&&(r=this.emitter),a.emitter=r,this.particleTexture&&(a.particleTexture=new e.Texture(this.particleTexture.url,this._scene)),this.preventAutoStart||a.start(),a},i.prototype.serialize=function(){var t={};if(t.name=this.name,t.id=this.id,this.emitter.position){var i=this.emitter;t.emitterId=i.id}else{var r=this.emitter;t.emitter=r.asArray()}return t.capacity=this.getCapacity(),this.particleTexture&&(t.textureName=this.particleTexture.name),e.Animation.AppendSerializedAnimations(this,t),t.minAngularSpeed=this.minAngularSpeed,t.maxAngularSpeed=this.maxAngularSpeed,t.minSize=this.minSize,t.maxSize=this.maxSize,t.minEmitPower=this.minEmitPower,t.maxEmitPower=this.maxEmitPower,t.minLifeTime=this.minLifeTime,t.maxLifeTime=this.maxLifeTime,t.emitRate=this.emitRate,t.minEmitBox=this.minEmitBox.asArray(),t.maxEmitBox=this.maxEmitBox.asArray(),t.gravity=this.gravity.asArray(),t.direction1=this.direction1.asArray(),t.direction2=this.direction2.asArray(),t.color1=this.color1.asArray(),t.color2=this.color2.asArray(),t.colorDead=this.colorDead.asArray(),t.updateSpeed=this.updateSpeed,t.targetStopDuration=this.targetStopDuration,t.textureMask=this.textureMask.asArray(),t.blendMode=this.blendMode,t.customShader=this.customShader,t.preventAutoStart=this.preventAutoStart,t},i.Parse=function(t,r,n){var o=t.name,s=null,a=null;if(t.customShader){a=t.customShader;var l=a.shaderOptions.defines.length>0?a.shaderOptions.defines.join("\n"):"";s=r.getEngine().createEffectForParticles(a.shaderPath.fragmentElement,a.shaderOptions.uniforms,a.shaderOptions.samplers,l)}var h=new i(o,t.capacity,r,s);if(h.customShader=a,t.id&&(h.id=t.id),t.preventAutoStart&&(h.preventAutoStart=t.preventAutoStart),t.textureName&&(h.particleTexture=new e.Texture(n+t.textureName,r),h.particleTexture.name=t.textureName),t.emitterId?h.emitter=r.getLastMeshByID(t.emitterId):h.emitter=e.Vector3.FromArray(t.emitter),t.animations)for(var c=0;cf?f:n,r=Math.round(f/n),o=0):r=r>f?f:r;for(var d=[],p=[],_=[],m=[],g=e.Tmp.Vector3[0],v=r;uf-r&&(r=f-u),d.length=0,p.length=0,_.length=0,m.length=0;for(var y=0,x=3*u;x<3*(u+r);x++){p.push(y);var b=a[x];d.push(s[3*b],s[3*b+1],s[3*b+2]),l&&_.push(l[2*b],l[2*b+1]),h&&m.push(h[4*b],h[4*b+1],h[4*b+2],h[4*b+3]),y++}var A,T=this.nbParticles,E=this._posToShape(d),P=this._uvsToShapeUV(_);for(A=0;A=this.nbParticles?this.nbParticles-1:i,this._computeBoundingBox&&(0==t&&i==this.nbParticles-1?(e.Vector3.FromFloatsToRef(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,this._minimum),e.Vector3.FromFloatsToRef(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE,this._maximum)):(this._minimum.copyFrom(this.mesh._boundingInfo.boundingBox.minimum),this._maximum.copyFrom(this.mesh._boundingInfo.boundingBox.maximum))),s=this.particles[t]._pos;var f=s/3|0;l=4*f,c=2*f;for(var d=t;d<=i;d++){if(this._particle=this.particles[d],this._shape=this._particle._model._shape,this._shapeUV=this._particle._model._shapeUV,this.updateParticle(this._particle),this._particle.isVisible)for(this.billboard&&(this._particle.rotation.x=0,this._particle.rotation.y=0),(this._computeParticleRotation||this.billboard)&&(this._particle.rotationQuaternion?this._quaternion.copyFrom(this._particle.rotationQuaternion):(this._yaw=this._particle.rotation.y,this._pitch=this._particle.rotation.x,this._roll=this._particle.rotation.z,this._quaternionRotationYPR()),this._quaternionToRotationMatrix()),u=0;uthis._maximum.x&&(this._maximum.x=this._positions32[o]),this._positions32[o+1]this._maximum.y&&(this._maximum.y=this._positions32[o+1]),this._positions32[o+2]this._maximum.z&&(this._maximum.z=this._positions32[o+2])),this._computeParticleVertex||(this._normal.x=this._fixedNormal32[o],this._normal.y=this._fixedNormal32[o+1],this._normal.z=this._fixedNormal32[o+2],this._rotated.x=this._normal.x*this._rotMatrix.m[0]+this._normal.y*this._rotMatrix.m[4]+this._normal.z*this._rotMatrix.m[8]+this._rotMatrix.m[12],this._rotated.y=this._normal.x*this._rotMatrix.m[1]+this._normal.y*this._rotMatrix.m[5]+this._normal.z*this._rotMatrix.m[9]+this._rotMatrix.m[13],this._rotated.z=this._normal.x*this._rotMatrix.m[2]+this._normal.y*this._rotMatrix.m[6]+this._normal.z*this._rotMatrix.m[10]+this._rotMatrix.m[14],this._normals32[o]=this._cam_axisX.x*this._rotated.x+this._cam_axisY.x*this._rotated.y+this._cam_axisZ.x*this._rotated.z,this._normals32[o+1]=this._cam_axisX.y*this._rotated.x+this._cam_axisY.y*this._rotated.y+this._cam_axisZ.y*this._rotated.z,this._normals32[o+2]=this._cam_axisX.z*this._rotated.x+this._cam_axisY.z*this._rotated.y+this._cam_axisZ.z*this._rotated.z),this._computeParticleColor&&(this._colors32[a]=this._particle.color.r,this._colors32[a+1]=this._particle.color.g,this._colors32[a+2]=this._particle.color.b,this._colors32[a+3]=this._particle.color.a),this._computeParticleTexture&&(this._uvs32[h]=this._shapeUV[2*u]*(this._particle.uvs.z-this._particle.uvs.x)+this._particle.uvs.x,this._uvs32[h+1]=this._shapeUV[2*u+1]*(this._particle.uvs.w-this._particle.uvs.y)+this._particle.uvs.y);else for(u=0;uthis._maxX||ithis._maxZ)return this.position.y;this._heightQuads&&0!=this._heightQuads.length||(this._initHeightQuads(),this._computeHeightQuads());var s=this._getFacetAt(t,i),a=-(s.x*t+s.z*i+s.w)/s.y;return e.Vector3.TransformCoordinatesFromFloatsToRef(0,a,0,r,o),o.y},i.prototype.getNormalAtCoordinates=function(t,i){var r=new e.Vector3(0,1,0);return this.getNormalAtCoordinatesToRef(t,i,r),r},i.prototype.getNormalAtCoordinatesToRef=function(t,i,r){var n=this.getWorldMatrix(),o=e.Tmp.Matrix[5];n.invertToRef(o);var s=e.Tmp.Vector3[8];if(e.Vector3.TransformCoordinatesFromFloatsToRef(t,0,i,o,s),t=s.x,i=s.z,tthis._maxX||ithis._maxZ)return this;this._heightQuads&&0!=this._heightQuads.length||(this._initHeightQuads(),this._computeHeightQuads());var a=this._getFacetAt(t,i);return e.Vector3.TransformNormalFromFloatsToRef(a.x,a.y,a.z,n,r),this},i.prototype.updateCoordinateHeights=function(){return this._heightQuads&&0!=this._heightQuads.length||this._initHeightQuads(),this._computeHeightQuads(),this},i.prototype._getFacetAt=function(e,t){var i=(this._subdivisionsX,this._subdivisionsY,Math.floor((e+this._maxX)*this._subdivisionsX/this._width)),r=Math.floor(-(t+this._maxZ)*this._subdivisionsY/this._height+this._subdivisionsY),n=this._heightQuads[r*this._subdivisionsX+i];return t4&&(s.push(e.VertexBuffer.MatricesIndicesExtraKind),s.push(e.VertexBuffer.MatricesWeightsExtraKind)),o.push("#define NUM_BONE_INFLUENCERS "+t.numBoneInfluencers),o.push("#define BonesPerMesh "+(t.skeleton.bones.length+1)),a.addCPUSkinningFallback(0,t),-1===this._options.uniforms.indexOf("mBones")&&this._options.uniforms.push("mBones")):o.push("#define NUM_BONE_INFLUENCERS 0");for(var h in this._textures)if(!this._textures[h].isReady())return!1;n.getAlphaTesting()&&o.push("#define ALPHATEST");var c=this._effect,u=o.join("\n");return this._effect=n.createEffect(this._shaderPath,{attributes:s,uniformsNames:this._options.uniforms,uniformBuffersNames:this._options.uniformBuffers,samplers:this._options.samplers,defines:u,fallbacks:a,onCompiled:this.onCompiled,onError:this.onError},n),!!this._effect.isReady()&&(c!==this._effect&&r.resetCachedMaterial(),this._renderId=r.getRenderId(),!0)},i.prototype.bindOnlyWorldMatrix=function(e){var t=this.getScene();-1!==this._options.uniforms.indexOf("world")&&this._effect.setMatrix("world",e),-1!==this._options.uniforms.indexOf("worldView")&&(e.multiplyToRef(t.getViewMatrix(),this._cachedWorldViewMatrix),this._effect.setMatrix("worldView",this._cachedWorldViewMatrix)),-1!==this._options.uniforms.indexOf("worldViewProjection")&&this._effect.setMatrix("worldViewProjection",e.multiply(t.getTransformMatrix()))},i.prototype.bind=function(t,i){if(this.bindOnlyWorldMatrix(t),this.getScene().getCachedMaterial()!==this){-1!==this._options.uniforms.indexOf("view")&&this._effect.setMatrix("view",this.getScene().getViewMatrix()),-1!==this._options.uniforms.indexOf("projection")&&this._effect.setMatrix("projection",this.getScene().getProjectionMatrix()),-1!==this._options.uniforms.indexOf("viewProjection")&&this._effect.setMatrix("viewProjection",this.getScene().getTransformMatrix()),e.MaterialHelper.BindBonesParameters(i,this._effect);var r;for(r in this._textures)this._effect.setTexture(r,this._textures[r]);for(r in this._textureArrays)this._effect.setTextureArray(r,this._textureArrays[r]);for(r in this._floats)this._effect.setFloat(r,this._floats[r]);for(r in this._floatsArrays)this._effect.setArray(r,this._floatsArrays[r]);for(r in this._colors3)this._effect.setColor3(r,this._colors3[r]);for(r in this._colors3Arrays)this._effect.setArray3(r,this._colors3Arrays[r]);for(r in this._colors4){var n=this._colors4[r];this._effect.setFloat4(r,n.r,n.g,n.b,n.a)}for(r in this._vectors2)this._effect.setVector2(r,this._vectors2[r]);for(r in this._vectors3)this._effect.setVector3(r,this._vectors3[r]);for(r in this._vectors4)this._effect.setVector4(r,this._vectors4[r]);for(r in this._matrices)this._effect.setMatrix(r,this._matrices[r]);for(r in this._matrices3x3)this._effect.setMatrix3x3(r,this._matrices3x3[r]);for(r in this._matrices2x2)this._effect.setMatrix2x2(r,this._matrices2x2[r]);for(r in this._vectors3Arrays)this._effect.setArray3(r,this._vectors3Arrays[r])}this._afterBind(i)},i.prototype.getActiveTextures=function(){var e=t.prototype.getActiveTextures.call(this);for(var i in this._textures)e.push(this._textures[i]);for(var i in this._textureArrays)for(var r=this._textureArrays[i],n=0;ne.Tmp.Vector3[1].x&&(e.Tmp.Vector3[1].x=l[u].x),l[u].ye.Tmp.Vector3[1].y&&(e.Tmp.Vector3[1].y=l[u].y),l[u].ze.Tmp.Vector3[1].z&&(e.Tmp.Vector3[1].z=l[u].z),u++,r+=3;h._closePath&&(t[r]=l[0].x,t[r+1]=l[0].y,t[r+2]=l[0].z,r+=3)}}(u),h._boundingInfo=new e.BoundingInfo(e.Tmp.Vector3[0],e.Tmp.Vector3[1]),h._boundingInfo.update(h._worldMatrix),h.updateVerticesData(e.VertexBuffer.PositionKind,u,!1,!1),r.colors){for(var f=h.getVerticesData(e.VertexBuffer.ColorKind),d=0;d1?1:r.arc:1,a=void 0===r.closed||r.closed,l=r.shape,h=r.radius||1,c=r.tessellation||64,u=r.updatable,f=t.updateSideOrientation(r.sideOrientation,n),d=r.cap||e.Mesh.NO_CAP,p=2*Math.PI,_=new Array,m=r.invertUV||!1,g=0,v=0,y=p/c*s,x=new Array;for(g=0;g<=c;g++){var x=[];for(d!=e.Mesh.CAP_START&&d!=e.Mesh.CAP_ALL||(x.push(new e.Vector3(0,l[0].y,0)),x.push(new e.Vector3(Math.cos(g*y)*l[0].x*h,l[0].y,Math.sin(g*y)*l[0].x*h))),v=0;v1?1:r.arc||1;var p,_,m=function(t,i,r,n,o,s,a,l){for(var h,c,u,f,d=i.getTangents(),p=i.getNormals(),_=i.getDistances(),m=2*Math.PI,g=m/o*l,v=function(){return n},y=s||v,x=e.Tmp.Matrix[0],b=a===e.Mesh._NO_CAP||a===e.Mesh.CAP_END?0:2,A=0;A3?0:h,_=m(o,p,v,s,a,l,h,r.arc);var y=t.CreateRibbon(i,{pathArray:_,closePath:!0,closeArray:!1,updatable:u,sideOrientation:f,invertUV:c,frontUVs:r.frontUVs,backUVs:r.backUVs},n);return y.pathArray=_,y.path3D=p,y.tessellation=a,y.cap=h,y.arc=r.arc,y},t.CreatePolyhedron=function(i,r,n){var o=new e.Mesh(i,n);return r.sideOrientation=t.updateSideOrientation(r.sideOrientation,n),o.sideOrientation=r.sideOrientation,e.VertexData.CreatePolyhedron(r).applyToMesh(o,r.updatable),o},t.CreateDecal=function(t,i,r){var n=i.getIndices(),o=i.getVerticesData(e.VertexBuffer.PositionKind),s=i.getVerticesData(e.VertexBuffer.NormalKind),a=r.position||e.Vector3.Zero(),l=r.normal||e.Vector3.Up(),h=r.size||e.Vector3.One(),c=r.angle||0;if(!l){var u=new e.Vector3(0,0,1),f=i.getScene().activeCamera,d=e.Vector3.TransformCoordinates(u,f.getWorldMatrix());l=f.globalPosition.subtract(d)}var p=-Math.atan2(l.z,l.x)-Math.PI/2,_=Math.sqrt(l.x*l.x+l.z*l.z),m=Math.atan2(l.y,_),g=e.Matrix.RotationYawPitchRoll(p,m,c).multiply(e.Matrix.Translation(a.x,a.y,a.z)),v=e.Matrix.Invert(g),y=i.getWorldMatrix(),x=y.multiply(v),b=new e.VertexData;b.indices=[],b.positions=[],b.normals=[],b.uvs=[];for(var A=0,T=function(t){var i=n[t],r=new e.PositionNormalVertex;return r.position=new e.Vector3(o[3*i],o[3*i+1],o[3*i+2]),r.position=e.Vector3.TransformCoordinates(r.position,x),r.normal=new e.Vector3(s[3*i],s[3*i+1],s[3*i+2]),r.normal=e.Vector3.TransformNormal(r.normal,x),r},E=function(t,i){if(0===t.length)return t;for(var r=.5*Math.abs(e.Vector3.Dot(h,i)),n=function(t,n){var o=e.Vector3.GetClipFactor(t.position,n.position,i,r);return new e.PositionNormalVertex(e.Vector3.Lerp(t.position,n.position,o),e.Vector3.Lerp(t.normal,n.normal,o))},o=new Array,s=0;s0,l=m>0,c=g>0,(a?1:0)+(l?1:0)+(c?1:0)){case 0:o.push(t[s]),o.push(t[s+1]),o.push(t[s+2]);break;case 1:if(a&&(u=t[s+1],f=t[s+2],d=n(t[s],u),p=n(t[s],f)),l){u=t[s],f=t[s+2],d=n(t[s+1],u),p=n(t[s+1],f),o.push(d),o.push(f.clone()),o.push(u.clone()),o.push(f.clone()),o.push(d.clone()),o.push(p);break}c&&(u=t[s],f=t[s+1],d=n(t[s+2],u),p=n(t[s+2],f)),o.push(u.clone()),o.push(f.clone()),o.push(d),o.push(p),o.push(d.clone()),o.push(f.clone());break;case 2:a||(u=t[s].clone(),f=n(u,t[s+1]),d=n(u,t[s+2]),o.push(u),o.push(f),o.push(d)),l||(u=t[s+1].clone(),f=n(u,t[s+2]),d=n(u,t[s]),o.push(u),o.push(f),o.push(d)),c||(u=t[s+2].clone(),f=n(u,t[s]),d=n(u,t[s+1]),o.push(u),o.push(f),o.push(d))}}return o},P=0;P3?0:u,b=A(r,n,x,T,o,s,a,l,u,f);var E=t.CreateRibbon(i,{pathArray:b,closeArray:h,closePath:c,updatable:p,sideOrientation:_,invertUV:g,frontUVs:v,backUVs:y},d);return E.pathArray=b,E.path3D=x,E.cap=u,E},t})();e.MeshBuilder=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this._audioContext=null,this._audioContextInitialized=!1,this.canUseWebAudio=!1,this.WarnedWebAudioUnsupported=!1,this.unlocked=!1,this.isMP3supported=!1,this.isOGGsupported=!1,void 0===window.AudioContext&&void 0===window.webkitAudioContext||(window.AudioContext=window.AudioContext||window.webkitAudioContext,this.canUseWebAudio=!0);var e=document.createElement("audio");try{e&&e.canPlayType&&e.canPlayType('audio/mpeg; codecs="mp3"').replace(/^no$/,"")&&(this.isMP3supported=!0)}catch(e){}try{e&&e.canPlayType&&e.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,"")&&(this.isOGGsupported=!0)}catch(e){}/iPad|iPhone|iPod/.test(navigator.platform)?this._unlockiOSaudio():this.unlocked=!0}return Object.defineProperty(t.prototype,"audioContext",{get:function(){return this._audioContextInitialized||this._initializeAudioContext(),this._audioContext},enumerable:!0,configurable:!0}),t.prototype._unlockiOSaudio=function(){var e=this,t=function(){var i=e.audioContext.createBuffer(1,1,22050),r=e.audioContext.createBufferSource();r.buffer=i,r.connect(e.audioContext.destination),r.start(0),setTimeout((function(){r.playbackState!==r.PLAYING_STATE&&r.playbackState!==r.FINISHED_STATE||(e.unlocked=!0,window.removeEventListener("touchend",t,!1),e.onAudioUnlocked&&e.onAudioUnlocked())}),0)};window.addEventListener("touchend",t,!1)},t.prototype._initializeAudioContext=function(){try{this.canUseWebAudio&&(this._audioContext=new AudioContext,this.masterGain=this._audioContext.createGain(),this.masterGain.gain.value=1,this.masterGain.connect(this._audioContext.destination),this._audioContextInitialized=!0)}catch(t){this.canUseWebAudio=!1,e.Tools.Error("Web Audio: "+t.message)}},t.prototype.dispose=function(){this.canUseWebAudio&&this._audioContextInitialized&&(this._connectedAnalyser&&(this._connectedAnalyser.stopDebugCanvas(),this._connectedAnalyser.dispose(),this.masterGain.disconnect(),this.masterGain.connect(this._audioContext.destination),this._connectedAnalyser=null),this.masterGain.gain.value=1),this.WarnedWebAudioUnsupported=!1},t.prototype.getGlobalVolume=function(){return this.canUseWebAudio&&this._audioContextInitialized?this.masterGain.gain.value:-1},t.prototype.setGlobalVolume=function(e){this.canUseWebAudio&&this._audioContextInitialized&&(this.masterGain.gain.value=e)},t.prototype.connectToAnalyser=function(e){this._connectedAnalyser&&this._connectedAnalyser.stopDebugCanvas(),this.canUseWebAudio&&this._audioContextInitialized&&(this._connectedAnalyser=e,this.masterGain.disconnect(),this._connectedAnalyser.connectAudioNodes(this.masterGain,this._audioContext.destination))},t})();e.AudioEngine=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t,i,r,n,o){var s=this;if(this.autoplay=!1,this.loop=!1,this.useCustomAttenuation=!1,this.spatialSound=!1,this.refDistance=1,this.rolloffFactor=1,this.maxDistance=100,this.distanceModel="linear",this._panningModel="equalpower",this._playbackRate=1,this._streaming=!1,this._startTime=0,this._startOffset=0,this._position=e.Vector3.Zero(),this._localDirection=new e.Vector3(1,0,0),this._volume=1,this._isLoaded=!1,this._isReadyToPlay=!1,this.isPlaying=!1,this.isPaused=!1,this._isDirectional=!1,this._coneInnerAngle=360,this._coneOuterAngle=360,this._coneOuterGain=0,this._isOutputConnected=!1,this._urlType="Unknown",this.name=t,this._scene=r,this._readyToPlayCallback=n,this._customAttenuationFunction=function(e,t,i,r,n){return t0&&(h=!0,this._soundLoaded(i));break;case"String":l.push(i);case"Array":0===l.length&&(l=i);for(var c=0;c0&&(this._htmlAudioElement.currentTime=0);else{var i=t?e.Engine.audioEngine.audioContext.currentTime+t:e.Engine.audioEngine.audioContext.currentTime;this._soundSource.stop(i),this._soundSource.onended=null,this.isPaused||(this._startOffset=0)}this.isPlaying=!1}},t.prototype.pause=function(){this.isPlaying&&(this.isPaused=!0,this._streaming?this._htmlAudioElement.pause():(this.stop(0),this._startOffset+=e.Engine.audioEngine.audioContext.currentTime-this._startTime))},t.prototype.setVolume=function(t,i){e.Engine.audioEngine.canUseWebAudio&&(i?(this._soundGain.gain.cancelScheduledValues(e.Engine.audioEngine.audioContext.currentTime),this._soundGain.gain.setValueAtTime(this._soundGain.gain.value,e.Engine.audioEngine.audioContext.currentTime),this._soundGain.gain.linearRampToValueAtTime(t,e.Engine.audioEngine.audioContext.currentTime+i)):this._soundGain.gain.value=t),this._volume=t},t.prototype.setPlaybackRate=function(e){this._playbackRate=e,this.isPlaying&&(this._streaming?this._htmlAudioElement.playbackRate=this._playbackRate:this._soundSource.playbackRate.value=this._playbackRate)},t.prototype.getVolume=function(){return this._volume},t.prototype.attachToMesh=function(e){var t=this;this._connectedMesh&&(this._connectedMesh.unregisterAfterWorldMatrixUpdate(this._registerFunc),this._registerFunc=null),this._connectedMesh=e,this.spatialSound||(this.spatialSound=!0,this._createSpatialParameters(),this.isPlaying&&this.loop&&(this.stop(),this.play())),this._onRegisterAfterWorldMatrixUpdate(this._connectedMesh),this._registerFunc=function(e){return t._onRegisterAfterWorldMatrixUpdate(e)},e.registerAfterWorldMatrixUpdate(this._registerFunc)},t.prototype.detachFromMesh=function(){this._connectedMesh&&(this._connectedMesh.unregisterAfterWorldMatrixUpdate(this._registerFunc),this._registerFunc=null,this._connectedMesh=null)},t.prototype._onRegisterAfterWorldMatrixUpdate=function(t){this.setPosition(t.getBoundingInfo().boundingSphere.centerWorld),e.Engine.audioEngine.canUseWebAudio&&this._isDirectional&&this.isPlaying&&this._updateDirection()},t.prototype.clone=function(){var e=this;if(this._streaming)return null;var i=function(){e._isReadyToPlay?(n._audioBuffer=e.getAudioBuffer(),n._isReadyToPlay=!0,n.autoplay&&n.play()):window.setTimeout(i,300)},r={autoplay:this.autoplay,loop:this.loop,volume:this._volume,spatialSound:this.spatialSound,maxDistance:this.maxDistance,useCustomAttenuation:this.useCustomAttenuation,rolloffFactor:this.rolloffFactor,refDistance:this.refDistance,distanceModel:this.distanceModel},n=new t(this.name+"_cloned",new ArrayBuffer(0),this._scene,null,r);return this.useCustomAttenuation&&n.setAttenuationFunction(this._customAttenuationFunction),n.setPosition(this._position),n.setPlaybackRate(this._playbackRate),i(),n},t.prototype.getAudioBuffer=function(){return this._audioBuffer},t.prototype.serialize=function(){var e={name:this.name,url:this.name,autoplay:this.autoplay,loop:this.loop,volume:this._volume,spatialSound:this.spatialSound,maxDistance:this.maxDistance,rolloffFactor:this.rolloffFactor,refDistance:this.refDistance,distanceModel:this.distanceModel,playbackRate:this._playbackRate,panningModel:this._panningModel,soundTrackId:this.soundTrackId};return this.spatialSound&&(this._connectedMesh&&(e.connectedMeshId=this._connectedMesh.id),e.position=this._position.asArray(),e.refDistance=this.refDistance,e.distanceModel=this.distanceModel,e.isDirectional=this._isDirectional,e.localDirectionToMesh=this._localDirection.asArray(),e.coneInnerAngle=this._coneInnerAngle,e.coneOuterAngle=this._coneOuterAngle,e.coneOuterGain=this._coneOuterGain),e},t.Parse=function(i,r,n,o){var s,a=i.name;s=i.url?n+i.url:n+a;var l,h={autoplay:i.autoplay,loop:i.loop,volume:i.volume,spatialSound:i.spatialSound,maxDistance:i.maxDistance,rolloffFactor:i.rolloffFactor,refDistance:i.refDistance,distanceModel:i.distanceModel,playbackRate:i.playbackRate};if(o){var c=function(){o._isReadyToPlay?(l._audioBuffer=o.getAudioBuffer(),l._isReadyToPlay=!0,l.autoplay&&l.play()):window.setTimeout(c,300)};l=new t(a,new ArrayBuffer(0),r,null,h),c()}else l=new t(a,s,r,function(){r._removePendingData(l)},h),r._addPendingData(l);if(i.position){var u=e.Vector3.FromArray(i.position);l.setPosition(u)}if(i.isDirectional&&(l.setDirectionalCone(i.coneInnerAngle||360,i.coneOuterAngle||360,i.coneOuterGain||0),i.localDirectionToMesh)){var f=e.Vector3.FromArray(i.localDirectionToMesh);l.setLocalDirectionToMesh(f)}if(i.connectedMeshId){var d=r.getMeshByID(i.connectedMeshId);d&&l.attachToMesh(d)}return l},t})();e.Sound=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e,t){this.id=-1,this._isMainTrack=!1,this._isInitialized=!1,this._scene=e,this.soundCollection=new Array,this._options=t,this._isMainTrack||(this._scene.soundTracks.push(this),this.id=this._scene.soundTracks.length-1)}return t.prototype._initializeSoundTrackAudioGraph=function(){e.Engine.audioEngine.canUseWebAudio&&(this._outputAudioNode=e.Engine.audioEngine.audioContext.createGain(),this._outputAudioNode.connect(e.Engine.audioEngine.masterGain),this._options&&(this._options.volume&&(this._outputAudioNode.gain.value=this._options.volume),this._options.mainTrack&&(this._isMainTrack=this._options.mainTrack)),this._isInitialized=!0)},t.prototype.dispose=function(){if(e.Engine.audioEngine.canUseWebAudio){for(this._connectedAnalyser&&this._connectedAnalyser.stopDebugCanvas();this.soundCollection.length;)this.soundCollection[0].dispose();this._outputAudioNode&&this._outputAudioNode.disconnect(),this._outputAudioNode=null}},t.prototype.AddSound=function(t){this._isInitialized||this._initializeSoundTrackAudioGraph(),e.Engine.audioEngine.canUseWebAudio&&t.connectToSoundTrackAudioNode(this._outputAudioNode),t.soundTrackId&&(-1===t.soundTrackId?this._scene.mainSoundTrack.RemoveSound(t):this._scene.soundTracks[t.soundTrackId].RemoveSound(t)),this.soundCollection.push(t),t.soundTrackId=this.id},t.prototype.RemoveSound=function(e){var t=this.soundCollection.indexOf(e);-1!==t&&this.soundCollection.splice(t,1)},t.prototype.setVolume=function(t){e.Engine.audioEngine.canUseWebAudio&&(this._outputAudioNode.gain.value=t)},t.prototype.switchPanningModelToHRTF=function(){if(e.Engine.audioEngine.canUseWebAudio)for(var t=0;t0&&(this._postProcesses[0].autoClear=!1))}},i.prototype._shouldRender=function(){return-1===this._currentRefreshId?(this._currentRefreshId=1,!0):this.refreshRate===this._currentRefreshId?(this._currentRefreshId=1,!0):(this._currentRefreshId++,!1)},i.prototype.isReady=function(){return!!this.getScene().renderTargetsEnabled&&t.prototype.isReady.call(this)},i.prototype.getRenderSize=function(){return this._size},Object.defineProperty(i.prototype,"canRescale",{get:function(){return!0},enumerable:!0,configurable:!0}),i.prototype.scale=function(e){var t=this._size*e;this.resize(t)},i.prototype.getReflectionTextureMatrix=function(){return this.isCube?this._textureMatrix:t.prototype.getReflectionTextureMatrix.call(this)},i.prototype.resize=function(e){this.releaseInternalTexture(),this.isCube?this._texture=this.getScene().getEngine().createRenderTargetCubeTexture(e,this._renderTargetOptions):this._texture=this.getScene().getEngine().createRenderTargetTexture(e,this._renderTargetOptions)},i.prototype.render=function(e,t){var i=this.getScene(),r=i.getEngine();if(void 0!==this.useCameraPostProcesses&&(e=this.useCameraPostProcesses),this._waitingRenderList){this.renderList=[];for(var n=0;n=0&&this._renderingManager.dispatchParticles(g))}if(this.isCube)for(var y=0;y<6;y++)this.renderToTarget(y,h,c,e,t),i.incrementRenderId(),i.resetCachedMaterial();else this.renderToTarget(0,h,c,e,t);this.onAfterUnbindObservable.notifyObservers(this),this.activeCamera&&this.activeCamera!==i.activeCamera&&i.setTransformMatrix(i.activeCamera.getViewMatrix(),i.activeCamera.getProjectionMatrix(!0)),r.setViewport(i.activeCamera.viewport),i.resetCachedMaterial()}},i.prototype.renderToTarget=function(t,i,r,n,o){var s=this,a=this.getScene(),l=a.getEngine();this._postProcessManager?this._postProcessManager._prepareFrame(this._texture,this._postProcesses):n&&a.postProcessManager._prepareFrame(this._texture)||(this.isCube?l.bindFramebuffer(this._texture,t):l.bindFramebuffer(this._texture)),this.onBeforeRenderObservable.notifyObservers(t),this.onClearObservable.hasObservers()?this.onClearObservable.notifyObservers(l):l.clear(a.clearColor,!0,!0,!0),this._doNotChangeAspectRatio||a.updateTransformMatrix(!0),this._renderingManager.render(this.customRenderFunction,i,this.renderParticles,this.renderSprites),this._postProcessManager?this._postProcessManager._finalizeFrame(!1,this._texture,t,this._postProcesses):n&&a.postProcessManager._finalizeFrame(!1,this._texture,t),this._doNotChangeAspectRatio||a.updateTransformMatrix(!0),o&&e.Tools.DumpFramebuffer(this._size,this._size,l),this.isCube&&5!==t?this.onAfterRenderObservable.notifyObservers(t):(this.isCube&&5===t&&l.generateMipMapsForCubemap(this._texture),l.unBindFramebuffer(this._texture,this.isCube,(function(){s.onAfterRenderObservable.notifyObservers(t)})))},i.prototype.setRenderingOrder=function(e,t,i,r){void 0===t&&(t=null),void 0===i&&(i=null),void 0===r&&(r=null),this._renderingManager.setRenderingOrder(e,t,i,r)},i.prototype.setRenderingAutoClearDepthStencil=function(e,t){this._renderingManager.setRenderingAutoClearDepthStencil(e,t)},i.prototype.clone=function(){var e=this.getSize(),t=new i(this.name,e.width,this.getScene(),this._renderTargetOptions.generateMipMaps,this._doNotChangeAspectRatio,this._renderTargetOptions.type,this.isCube,this._renderTargetOptions.samplingMode,this._renderTargetOptions.generateDepthBuffer,this._renderTargetOptions.generateStencilBuffer);return t.hasAlpha=this.hasAlpha,t.level=this.level,t.coordinatesMode=this.coordinatesMode,t.renderList=this.renderList.slice(0),t},i.prototype.serialize=function(){if(!this.name)return null;var e=t.prototype.serialize.call(this);e.renderTargetSize=this.getRenderSize(),e.renderList=[];for(var i=0;i=0&&e.customRenderTargets.splice(i,1);for(var r=0,n=e.cameras;r=0&&o.customRenderTargets.splice(i,1)}t.prototype.dispose.call(this)},i})(e.Texture);t._REFRESHRATE_RENDER_ONCE=0,t._REFRESHRATE_RENDER_ONEVERYFRAME=1,t._REFRESHRATE_RENDER_ONEVERYTWOFRAMES=2,e.RenderTargetTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o,s){var a=this;s=s||{};var l=!!s.generateMipMaps&&s.generateMipMaps,h=!!s.generateDepthTexture&&s.generateDepthTexture,c=void 0===s.doNotChangeAspectRatio||s.doNotChangeAspectRatio;if(a=t.call(this,i,r,o,l,c)||this,!a.isSupported)return void a.dispose();for(var u=[],f=[],d=0;d1||e.getCaps().drawBuffersExtension},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"textures",{get:function(){return this._textures},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"depthTexture",{get:function(){return this._textures[this._textures.length-1]},enumerable:!0,configurable:!0}),i.prototype._createInternalTextures=function(){this._textures=[];for(var t=0;t=0;e--)void 0!==this._webGLTextures[e]&&(this.getScene().getEngine().releaseInternalTexture(this._webGLTextures[e]),this._webGLTextures.splice(e,1))},i})(e.RenderTargetTexture);e.MultiRenderTarget=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o,s,a,l){void 0===s&&(s=e.Engine.TEXTURETYPE_UNSIGNED_INT),void 0===a&&(a=e.Texture.BILINEAR_SAMPLINGMODE),void 0===l&&(l=!0);var h=t.call(this,i,r,n,o,!0,s,!1,a,l)||this;return h.mirrorPlane=new e.Plane(0,1,0,1),h._transformMatrix=e.Matrix.Zero(),h._mirrorMatrix=e.Matrix.Zero(),h._blurKernelX=0,h._blurKernelY=0,h._blurRatio=1,h.onBeforeRenderObservable.add((function(){e.Matrix.ReflectionToRef(h.mirrorPlane,h._mirrorMatrix),h._savedViewMatrix=n.getViewMatrix(),h._mirrorMatrix.multiplyToRef(h._savedViewMatrix,h._transformMatrix),n.setTransformMatrix(h._transformMatrix,n.getProjectionMatrix()),n.clipPlane=h.mirrorPlane,n.getEngine().cullBackFaces=!1,n._mirroredCameraPosition=e.Vector3.TransformCoordinates(n.activeCamera.globalPosition,h._mirrorMatrix)})),h.onAfterRenderObservable.add((function(){n.setTransformMatrix(h._savedViewMatrix,n.getProjectionMatrix()),n.getEngine().cullBackFaces=!0,n._mirroredCameraPosition=null,delete n.clipPlane})),h}return __extends(i,t),Object.defineProperty(i.prototype,"blurRatio",{get:function(){return this._blurRatio},set:function(e){this._blurRatio!==e&&(this._blurRatio=e,this._preparePostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"blurKernel",{set:function(e){this.blurKernelX=e,this.blurKernelY=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"blurKernelX",{get:function(){return this._blurKernelX},set:function(e){this._blurKernelX!==e&&(this._blurKernelX=e,this._preparePostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"blurKernelY",{get:function(){return this._blurKernelY},set:function(e){this._blurKernelY!==e&&(this._blurKernelY=e,this._preparePostProcesses())},enumerable:!0,configurable:!0}),i.prototype._preparePostProcesses=function(){if(this.clearPostProcesses(!0),this._blurKernelX&&this._blurKernelY){var t=this.getScene().getEngine(),i=t.getCaps().textureFloatRender?e.Engine.TEXTURETYPE_FLOAT:e.Engine.TEXTURETYPE_HALF_FLOAT;this._blurX=new e.BlurPostProcess("horizontal blur",new e.Vector2(1,0),this._blurKernelX,this._blurRatio,null,e.Texture.BILINEAR_SAMPLINGMODE,t,!1,i),this._blurX.autoClear=!1,1===this._blurRatio&&this.samples<2?this._blurX.outputTexture=this._texture:this._blurX.alwaysForcePOT=!0,this._blurY=new e.BlurPostProcess("vertical blur",new e.Vector2(0,1),this._blurKernelY,this._blurRatio,null,e.Texture.BILINEAR_SAMPLINGMODE,t,!1,i),this._blurY.autoClear=!1,this._blurY.alwaysForcePOT=1!==this._blurRatio,this.addPostProcess(this._blurX),this.addPostProcess(this._blurY)}},i.prototype.clone=function(){var e=this.getSize(),t=new i(this.name,e.width,this.getScene(),this._renderTargetOptions.generateMipMaps,this._renderTargetOptions.type,this._renderTargetOptions.samplingMode,this._renderTargetOptions.generateDepthBuffer);return t.hasAlpha=this.hasAlpha,t.level=this.level,t.mirrorPlane=this.mirrorPlane.clone(),t.renderList=this.renderList.slice(0),t},i.prototype.serialize=function(){if(!this.name)return null;var e=t.prototype.serialize.call(this);return e.mirrorPlane=this.mirrorPlane.asArray(),e},i})(e.RenderTargetTexture);e.MirrorTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o){var s=t.call(this,i,r,n,o,!0)||this;return s.refractionPlane=new e.Plane(0,1,0,1),s.depth=2,s.onBeforeRenderObservable.add((function(){n.clipPlane=s.refractionPlane})),s.onAfterRenderObservable.add((function(){delete n.clipPlane})),s}return __extends(i,t),i.prototype.clone=function(){var e=this.getSize(),t=new i(this.name,e.width,this.getScene(),this._generateMipMaps);return t.hasAlpha=this.hasAlpha,t.level=this.level,t.refractionPlane=this.refractionPlane.clone(),t.renderList=this.renderList.slice(0),t.depth=this.depth,t},i.prototype.serialize=function(){if(!this.name)return null;var e=t.prototype.serialize.call(this);return e.mirrorPlane=this.refractionPlane.asArray(),e.depth=this.depth,e},i})(e.RenderTargetTexture);e.RefractionTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o,s,a){void 0===s&&(s=e.Texture.TRILINEAR_SAMPLINGMODE),void 0===a&&(a=e.Engine.TEXTUREFORMAT_RGBA);var l=t.call(this,null,n,!o,void 0,s,void 0,void 0,void 0,void 0,a)||this;l.name=i;var h=l.getScene().getEngine();l.wrapU=e.Texture.CLAMP_ADDRESSMODE,l.wrapV=e.Texture.CLAMP_ADDRESSMODE,l._generateMipMaps=o,r.getContext?(l._canvas=r,l._texture=h.createDynamicTexture(r.width,r.height,o,s)):(l._canvas=document.createElement("canvas"),r.width?l._texture=h.createDynamicTexture(r.width,r.height,o,s):l._texture=h.createDynamicTexture(r,r,o,s));var c=l.getSize();return l._canvas.width=c.width,l._canvas.height=c.height,l._context=l._canvas.getContext("2d"),l}return __extends(i,t),Object.defineProperty(i.prototype,"canRescale",{get:function(){return!0},enumerable:!0,configurable:!0}),i.prototype._recreate=function(e){this._canvas.width=e.width,this._canvas.height=e.height,this.releaseInternalTexture(),this._texture=this.getScene().getEngine().createDynamicTexture(e.width,e.height,this._generateMipMaps,this._samplingMode)},i.prototype.scale=function(e){var t=this.getSize();t.width*=e,t.height*=e,this._recreate(t)},i.prototype.scaleTo=function(e,t){var i=this.getSize();i.width=e,i.height=t,this._recreate(i)},i.prototype.getContext=function(){return this._context},i.prototype.clear=function(){var e=this.getSize();this._context.fillRect(0,0,e.width,e.height)},i.prototype.update=function(e){this.getScene().getEngine().updateDynamicTexture(this._texture,this._canvas,void 0===e||e,void 0,this._format)},i.prototype.drawText=function(e,t,i,r,n,o,s,a){void 0===a&&(a=!0);var l=this.getSize();if(o&&(this._context.fillStyle=o,this._context.fillRect(0,0,l.width,l.height)),this._context.font=r,null===t||void 0===t){var h=this._context.measureText(e);t=(l.width-h.width)/2}if(null===i||void 0===i){var c=parseInt(r.replace(/\D/g,""));i=l.height/2+c/3.65}this._context.fillStyle=n,this._context.fillText(e,t,i),a&&this.update(s)},i.prototype.clone=function(){var e=this.getSize(),t=new i(this.name,e,this.getScene(),this._generateMipMaps);return t.hasAlpha=this.hasAlpha,t.level=this.level,t.wrapU=this.wrapU,t.wrapV=this.wrapV,t},i})(e.Texture);e.DynamicTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o,s,a){void 0===o&&(o=!1),void 0===s&&(s=!1),void 0===a&&(a=e.Texture.TRILINEAR_SAMPLINGMODE);var l=t.call(this,null,n,!o,s)||this;l._autoLaunch=!0;var h;return l.name=i,r instanceof HTMLVideoElement?l.video=r:(h=r,l.video=document.createElement("video"),l.video.autoplay=!1,l.video.loop=!0),l._generateMipMaps=o,l._samplingMode=a,!l.getScene().getEngine().needPOTTextures||e.Tools.IsExponentOfTwo(l.video.videoWidth)&&e.Tools.IsExponentOfTwo(l.video.videoHeight)?(l.wrapU=e.Texture.WRAP_ADDRESSMODE,l.wrapV=e.Texture.WRAP_ADDRESSMODE):(l.wrapU=e.Texture.CLAMP_ADDRESSMODE,l.wrapV=e.Texture.CLAMP_ADDRESSMODE,l._generateMipMaps=!1),h?(l.video.addEventListener("canplay",(function(){l._createTexture()})),h.forEach((function(e){var t=document.createElement("source");t.src=e,l.video.appendChild(t)}))):l._createTexture(),l._lastUpdate=e.Tools.Now,l}return __extends(i,t),i.prototype.__setTextureReady=function(){this._texture.isReady=!0},i.prototype._createTexture=function(){this._texture=this.getScene().getEngine().createDynamicTexture(this.video.videoWidth,this.video.videoHeight,this._generateMipMaps,this._samplingMode),this._autoLaunch&&(this._autoLaunch=!1,this.video.play()),this._setTextureReady=this.__setTextureReady.bind(this),this.video.addEventListener("playing",this._setTextureReady)},i.prototype.update=function(){var t=e.Tools.Now;return!(t-this._lastUpdate<15||this.video.readyState!==this.video.HAVE_ENOUGH_DATA)&&(this._lastUpdate=t,this.getScene().getEngine().updateVideoTexture(this._texture,this.video,this._invertY),!0)},i.prototype.dispose=function(){t.prototype.dispose.call(this),this.video.removeEventListener("playing",this._setTextureReady)},i.CreateFromWebCam=function(t,i,r){var n,o=document.createElement("video");r&&r.deviceId&&(n={exact:r.deviceId}),navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia,window.URL=window.URL||window.webkitURL||window.mozURL||window.msURL,navigator.getUserMedia&&navigator.getUserMedia({video:{deviceId:n,width:{min:r&&r.minWidth||256,max:r&&r.maxWidth||640},height:{min:r&&r.minHeight||256,max:r&&r.maxHeight||480}}},(function(r){void 0!==o.mozSrcObject?o.mozSrcObject=r:o.src=window.URL&&window.URL.createObjectURL(r)||r,o.play(),i&&i(new e.VideoTexture("video",o,t,!0,!0))}),(function(t){e.Tools.Error(t.name)}))},i})(e.Texture);e.VideoTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o,s,a,l,h){void 0===a&&(a=!0),void 0===l&&(l=!1),void 0===h&&(h=e.Texture.TRILINEAR_SAMPLINGMODE);var c=t.call(this,null,s,!a,l)||this;return c.format=o,c._texture=s.getEngine().createRawTexture(i,r,n,o,a,l,h),c.wrapU=e.Texture.CLAMP_ADDRESSMODE,c.wrapV=e.Texture.CLAMP_ADDRESSMODE,c}return __extends(i,t),i.prototype.update=function(e){this.getScene().getEngine().updateRawTexture(this._texture,e,this.format,this._invertY)},i.CreateLuminanceTexture=function(t,r,n,o,s,a,l){return void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===l&&(l=e.Texture.TRILINEAR_SAMPLINGMODE),new i(t,r,n,e.Engine.TEXTUREFORMAT_LUMINANCE,o,s,a,l)},i.CreateLuminanceAlphaTexture=function(t,r,n,o,s,a,l){return void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===l&&(l=e.Texture.TRILINEAR_SAMPLINGMODE),new i(t,r,n,e.Engine.TEXTUREFORMAT_LUMINANCE_ALPHA,o,s,a,l)},i.CreateAlphaTexture=function(t,r,n,o,s,a,l){return void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===l&&(l=e.Texture.TRILINEAR_SAMPLINGMODE),new i(t,r,n,e.Engine.TEXTUREFORMAT_ALPHA,o,s,a,l)},i.CreateRGBTexture=function(t,r,n,o,s,a,l){return void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===l&&(l=e.Texture.TRILINEAR_SAMPLINGMODE),new i(t,r,n,e.Engine.TEXTUREFORMAT_RGB,o,s,a,l)},i.CreateRGBATexture=function(t,r,n,o,s,a,l){return void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===l&&(l=e.Texture.TRILINEAR_SAMPLINGMODE),new i(t,r,n,e.Engine.TEXTUREFORMAT_RGBA,o,s,a,l)},i})(e.Texture);e.RawTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t,i,r,n,o,s,a,l,h,c,u,f,d,p){void 0===a&&(a=e.Texture.NEAREST_SAMPLINGMODE),void 0===u&&(u=e.Engine.TEXTURETYPE_UNSIGNED_INT),void 0===f&&(f="postprocess"),void 0===p&&(p=!1),this.name=t,this.width=-1,this.height=-1,this.autoClear=!0,this.alphaMode=e.Engine.ALPHA_DISABLE,this.enablePixelPerfectMode=!1,this.scaleMode=e.Engine.SCALEMODE_FLOOR,this.alwaysForcePOT=!1,this.samples=1,this._reusable=!1,this._textures=new e.SmartArray(2),this._currentRenderTextureInd=0,this._scaleRatio=new e.Vector2(1,1),this._texelSize=e.Vector2.Zero(),this.onActivateObservable=new e.Observable,this.onSizeChangedObservable=new e.Observable,this.onApplyObservable=new e.Observable,this.onBeforeRenderObservable=new e.Observable,this.onAfterRenderObservable=new e.Observable,null!=s?(this._camera=s,this._scene=s.getScene(),s.attachPostProcess(this),this._engine=this._scene.getEngine()):this._engine=l,this._options=o,this.renderTargetSamplingMode=a||e.Texture.NEAREST_SAMPLINGMODE,this._reusable=h||!1,this._textureType=u,this._samplers=n||[],this._samplers.push("textureSampler"),this._fragmentUrl=i,this._vertexUrl=f,this._parameters=r||[],this._parameters.push("scale"),this._indexParameters=d,p||this.updateEffect(c)}return Object.defineProperty(t.prototype,"onActivate",{set:function(e){this._onActivateObserver&&this.onActivateObservable.remove(this._onActivateObserver),this._onActivateObserver=this.onActivateObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onSizeChanged",{set:function(e){this._onSizeChangedObserver&&this.onSizeChangedObservable.remove(this._onSizeChangedObserver),this._onSizeChangedObserver=this.onSizeChangedObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onApply",{set:function(e){this._onApplyObserver&&this.onApplyObservable.remove(this._onApplyObserver),this._onApplyObserver=this.onApplyObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onBeforeRender",{set:function(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onAfterRender",{set:function(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=this.onAfterRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"outputTexture",{get:function(){return this._textures.data[this._currentRenderTextureInd]},set:function(e){this._forcedOutputTexture=e},enumerable:!0,configurable:!0}),t.prototype.getCamera=function(){return this._camera},Object.defineProperty(t.prototype,"texelSize",{get:function(){return this._shareOutputWithPostProcess?this._shareOutputWithPostProcess.texelSize:(this._forcedOutputTexture&&this._texelSize.copyFromFloats(1/this._forcedOutputTexture._width,1/this._forcedOutputTexture._height),this._texelSize)},enumerable:!0,configurable:!0}),t.prototype.getEngine=function(){return this._engine},t.prototype.getEffect=function(){return this._effect},t.prototype.shareOutputWith=function(e){return this._disposeTextures(),this._shareOutputWithPostProcess=e,this},t.prototype.updateEffect=function(e,t,i,r,n,o){this._effect=this._engine.createEffect({vertex:this._vertexUrl,fragment:this._fragmentUrl},["position"],t||this._parameters,i||this._samplers,void 0!==e?e:"",null,n,o,r||this._indexParameters)},t.prototype.isReusable=function(){return this._reusable},t.prototype.markTextureDirty=function(){this.width=-1},t.prototype.activate=function(t,i,r){var n=this;if(!this._shareOutputWithPostProcess&&!this._forcedOutputTexture){t=t||this._camera;var o=t.getScene(),s=o.getEngine(),a=s.getCaps().maxTextureSize,l=(i?i._width:this._engine.getRenderingCanvas().width)*this._options|0,h=(i?i._height:this._engine.getRenderingCanvas().height)*this._options|0,c=this._options.width||l,u=this._options.height||h;if((this.renderTargetSamplingMode===e.Texture.TRILINEAR_SAMPLINGMODE||this.alwaysForcePOT)&&(this._options.width||(c=s.needPOTTextures?e.Tools.GetExponentOfTwo(c,a,this.scaleMode):c),this._options.height||(u=s.needPOTTextures?e.Tools.GetExponentOfTwo(u,a,this.scaleMode):u)),this.width!==c||this.height!==u){if(this._textures.length>0){for(var f=0;f0)for(var e=0;e0&&this._camera._postProcesses[0].markTextureDirty(),this.onActivateObservable.clear(),this.onAfterRenderObservable.clear(),this.onApplyObservable.clear(),this.onBeforeRenderObservable.clear(),this.onSizeChangedObservable.clear()}},t})();e.PostProcess=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o,s,a,l){return void 0===l&&(l=e.Engine.TEXTURETYPE_UNSIGNED_INT),t.call(this,i,"pass",null,null,r,n,o,s,a,null,l)||this}return __extends(i,t),i})(e.PostProcess);e.PassPostProcess=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(i,r,n){this._bias=5e-5,this._blurBoxOffset=1,this._blurScale=2,this._blurKernel=1,this._useKernelBlur=!1,this._filter=t.FILTER_NONE,this._darkness=0,this._transparencyShadow=!1,this.frustumEdgeFalloff=0,this.forceBackFacesOnly=!1,this._lightDirection=e.Vector3.Zero(),this._viewMatrix=e.Matrix.Zero(),this._projectionMatrix=e.Matrix.Zero(),this._transformMatrix=e.Matrix.Zero(),this._worldViewProjection=e.Matrix.Zero(),this._currentFaceIndex=0,this._currentFaceIndexCache=0,this._isCube=!1,this._defaultTextureMatrix=e.Matrix.Identity(),this._mapSize=i,this._light=r,this._scene=r.getScene(),r._shadowGenerator=this;var o=this._scene.getEngine().getCaps();n?o.textureFloatRender&&o.textureFloatLinearFiltering?this._textureType=e.Engine.TEXTURETYPE_FLOAT:o.textureHalfFloatRender&&o.textureHalfFloatLinearFiltering?this._textureType=e.Engine.TEXTURETYPE_HALF_FLOAT:this._textureType=e.Engine.TEXTURETYPE_UNSIGNED_INT:o.textureHalfFloatRender&&o.textureHalfFloatLinearFiltering?this._textureType=e.Engine.TEXTURETYPE_HALF_FLOAT:o.textureFloatRender&&o.textureFloatLinearFiltering?this._textureType=e.Engine.TEXTURETYPE_FLOAT:this._textureType=e.Engine.TEXTURETYPE_UNSIGNED_INT,this._initializeGenerator()}return Object.defineProperty(t,"FILTER_NONE",{get:function(){return t._FILTER_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FILTER_POISSONSAMPLING",{get:function(){return t._FILTER_POISSONSAMPLING},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FILTER_EXPONENTIALSHADOWMAP",{get:function(){return t._FILTER_EXPONENTIALSHADOWMAP},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FILTER_BLUREXPONENTIALSHADOWMAP",{get:function(){return t._FILTER_BLUREXPONENTIALSHADOWMAP},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FILTER_CLOSEEXPONENTIALSHADOWMAP",{get:function(){return t._FILTER_CLOSEEXPONENTIALSHADOWMAP},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FILTER_BLURCLOSEEXPONENTIALSHADOWMAP",{get:function(){return t._FILTER_BLURCLOSEEXPONENTIALSHADOWMAP},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"bias",{get:function(){return this._bias},set:function(e){this._bias=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"blurBoxOffset",{get:function(){return this._blurBoxOffset},set:function(e){this._blurBoxOffset!==e&&(this._blurBoxOffset=e,this._disposeBlurPostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"blurScale",{get:function(){return this._blurScale},set:function(e){this._blurScale!==e&&(this._blurScale=e,this._disposeBlurPostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"blurKernel",{get:function(){return this._blurKernel},set:function(e){this._blurKernel!==e&&(this._blurKernel=e,this._disposeBlurPostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useKernelBlur",{get:function(){return this._useKernelBlur},set:function(e){this._useKernelBlur!==e&&(this._useKernelBlur=e,this._disposeBlurPostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"depthScale",{get:function(){return void 0!==this._depthScale?this._depthScale:this._light.getDepthScale()},set:function(e){this._depthScale=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"filter",{get:function(){return this._filter},set:function(e){if(this._light.needCube()){if(e===t.FILTER_BLUREXPONENTIALSHADOWMAP)return void(this.useExponentialShadowMap=!0);if(e===t.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP)return void(this.useCloseExponentialShadowMap=!0)}this._filter!==e&&(this._filter=e,this._disposeBlurPostProcesses(),this._applyFilterValues(),this._light._markMeshesAsLightDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"usePoissonSampling",{get:function(){return this.filter===t.FILTER_POISSONSAMPLING},set:function(e){this.filter=e?t.FILTER_POISSONSAMPLING:t.FILTER_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useVarianceShadowMap",{get:function(){return e.Tools.Warn("VSM are now replaced by ESM. Please use useExponentialShadowMap instead."),this.useExponentialShadowMap},set:function(t){e.Tools.Warn("VSM are now replaced by ESM. Please use useExponentialShadowMap instead."),this.useExponentialShadowMap=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useBlurVarianceShadowMap",{get:function(){return e.Tools.Warn("VSM are now replaced by ESM. Please use useBlurExponentialShadowMap instead."),this.useBlurExponentialShadowMap},set:function(t){e.Tools.Warn("VSM are now replaced by ESM. Please use useBlurExponentialShadowMap instead."),this.useBlurExponentialShadowMap=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useExponentialShadowMap",{get:function(){return this.filter===t.FILTER_EXPONENTIALSHADOWMAP},set:function(e){this.filter=e?t.FILTER_EXPONENTIALSHADOWMAP:t.FILTER_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useBlurExponentialShadowMap",{get:function(){return this.filter===t.FILTER_BLUREXPONENTIALSHADOWMAP},set:function(e){this.filter=e?t.FILTER_BLUREXPONENTIALSHADOWMAP:t.FILTER_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useCloseExponentialShadowMap",{get:function(){return this.filter===t.FILTER_CLOSEEXPONENTIALSHADOWMAP},set:function(e){this.filter=e?t.FILTER_CLOSEEXPONENTIALSHADOWMAP:t.FILTER_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useBlurCloseExponentialShadowMap",{get:function(){return this.filter===t.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP},set:function(e){this.filter=e?t.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP:t.FILTER_NONE},enumerable:!0,configurable:!0}),t.prototype.getDarkness=function(){return this._darkness},t.prototype.setDarkness=function(e){return this._darkness=e>=1?1:e<=0?0:e,this},t.prototype.setTransparencyShadow=function(e){return this._transparencyShadow=e,this},t.prototype.getShadowMap=function(){return this._shadowMap},t.prototype.getShadowMapForRendering=function(){return this._shadowMap2?this._shadowMap2:this._shadowMap},t.prototype.getLight=function(){return this._light},t.prototype._initializeGenerator=function(){this._light._markMeshesAsLightDirty(),this._initializeShadowMap()},t.prototype._initializeShadowMap=function(){var t=this;this._shadowMap=new e.RenderTargetTexture(this._light.name+"_shadowMap",this._mapSize,this._scene,!1,!0,this._textureType,this._light.needCube()),this._shadowMap.wrapU=e.Texture.CLAMP_ADDRESSMODE,this._shadowMap.wrapV=e.Texture.CLAMP_ADDRESSMODE,this._shadowMap.anisotropicFilteringLevel=1,this._shadowMap.updateSamplingMode(e.Texture.BILINEAR_SAMPLINGMODE),this._shadowMap.renderParticles=!1,this._shadowMap.onBeforeRenderObservable.add((function(e){t._currentFaceIndex=e})),this._shadowMap.customRenderFunction=this._renderForShadowMap.bind(this),this._shadowMap.onAfterUnbindObservable.add((function(){(t.useBlurExponentialShadowMap||t.useBlurCloseExponentialShadowMap)&&(t._blurPostProcesses||t._initializeBlurRTTAndPostProcesses(),t._scene.postProcessManager.directRender(t._blurPostProcesses,t.getShadowMapForRendering().getInternalTexture()))})),this._shadowMap.onClearObservable.add((function(i){t.useExponentialShadowMap||t.useBlurExponentialShadowMap?i.clear(new e.Color4(0,0,0,0),!0,!0,!0):i.clear(new e.Color4(1,1,1,1),!0,!0,!0)}))},t.prototype._initializeBlurRTTAndPostProcesses=function(){var t=this,i=this._scene.getEngine(),r=this._mapSize/this.blurScale;this.useKernelBlur&&1===this.blurScale||(this._shadowMap2=new e.RenderTargetTexture(this._light.name+"_shadowMap2",r,this._scene,!1,!0,this._textureType),this._shadowMap2.wrapU=e.Texture.CLAMP_ADDRESSMODE,this._shadowMap2.wrapV=e.Texture.CLAMP_ADDRESSMODE,this._shadowMap2.updateSamplingMode(e.Texture.BILINEAR_SAMPLINGMODE)),this.useKernelBlur?(this._kernelBlurXPostprocess=new e.BlurPostProcess(this._light.name+"KernelBlurX",new e.Vector2(1,0),this.blurKernel,1,null,e.Texture.BILINEAR_SAMPLINGMODE,i,!1,this._textureType),this._kernelBlurXPostprocess.width=r,this._kernelBlurXPostprocess.height=r,this._kernelBlurXPostprocess.onApplyObservable.add((function(e){e.setTexture("textureSampler",t._shadowMap)})),this._kernelBlurYPostprocess=new e.BlurPostProcess(this._light.name+"KernelBlurY",new e.Vector2(0,1),this.blurKernel,1,null,e.Texture.BILINEAR_SAMPLINGMODE,i,!1,this._textureType),this._kernelBlurXPostprocess.autoClear=!1,this._kernelBlurYPostprocess.autoClear=!1,this._textureType===e.Engine.TEXTURETYPE_UNSIGNED_INT&&(this._kernelBlurXPostprocess.packedFloat=!0,this._kernelBlurYPostprocess.packedFloat=!0),this._blurPostProcesses=[this._kernelBlurXPostprocess,this._kernelBlurYPostprocess]):(this._boxBlurPostprocess=new e.PostProcess(this._light.name+"DepthBoxBlur","depthBoxBlur",["screenSize","boxOffset"],[],1,null,e.Texture.BILINEAR_SAMPLINGMODE,i,!1,"#define OFFSET "+this._blurBoxOffset,this._textureType),this._boxBlurPostprocess.onApplyObservable.add((function(e){e.setFloat2("screenSize",r,r),e.setTexture("textureSampler",t._shadowMap)})),this._boxBlurPostprocess.autoClear=!1,this._blurPostProcesses=[this._boxBlurPostprocess])},t.prototype._renderForShadowMap=function(e,t,i){var r;for(r=0;r=n.length)return void(e&&e(i));setTimeout(h,16)}};n.length>0&&h()},t.prototype.isReady=function(t,i){var r=[];this._textureType!==e.Engine.TEXTURETYPE_UNSIGNED_INT&&r.push("#define FLOAT"),(this.useExponentialShadowMap||this.useBlurExponentialShadowMap)&&r.push("#define ESM");var n=[e.VertexBuffer.PositionKind],o=t.getMesh(),s=t.getMaterial();if(s&&s.needAlphaTesting()){var a=s.getAlphaTestTexture();a&&(r.push("#define ALPHATEST"),o.isVerticesDataPresent(e.VertexBuffer.UVKind)&&(n.push(e.VertexBuffer.UVKind),r.push("#define UV1")),o.isVerticesDataPresent(e.VertexBuffer.UV2Kind)&&1===a.coordinatesIndex&&(n.push(e.VertexBuffer.UV2Kind),r.push("#define UV2")))}o.useBones&&o.computeBonesUsingShaders?(n.push(e.VertexBuffer.MatricesIndicesKind),n.push(e.VertexBuffer.MatricesWeightsKind),o.numBoneInfluencers>4&&(n.push(e.VertexBuffer.MatricesIndicesExtraKind),n.push(e.VertexBuffer.MatricesWeightsExtraKind)),r.push("#define NUM_BONE_INFLUENCERS "+o.numBoneInfluencers),r.push("#define BonesPerMesh "+(o.skeleton.bones.length+1))):r.push("#define NUM_BONE_INFLUENCERS 0"),i&&(r.push("#define INSTANCES"),n.push("world0"),n.push("world1"),n.push("world2"),n.push("world3"));var l=r.join("\n");return this._cachedDefines!==l&&(this._cachedDefines=l,this._effect=this._scene.getEngine().createEffect("shadowMap",n,["world","mBones","viewProjection","diffuseMatrix","lightPosition","depthValues","biasAndScale"],["diffuseSampler"],l)),this._effect.isReady()},t.prototype.prepareDefines=function(e,t){var i=this._scene,r=this._light;i.shadowsEnabled&&r.shadowEnabled&&(e["SHADOW"+t]=!0,this.usePoissonSampling?e["SHADOWPCF"+t]=!0:this.useExponentialShadowMap||this.useBlurExponentialShadowMap?e["SHADOWESM"+t]=!0:(this.useCloseExponentialShadowMap||this.useBlurCloseExponentialShadowMap)&&(e["SHADOWCLOSEESM"+t]=!0),r.needCube()&&(e["SHADOWCUBE"+t]=!0))},t.prototype.bindShadowLight=function(e,t){var i=this._light,r=this._scene;r.shadowsEnabled&&i.shadowEnabled&&(i.needCube()||t.setMatrix("lightMatrix"+e,this.getTransformMatrix()), -t.setTexture("shadowSampler"+e,this.getShadowMapForRendering()),i._uniformBuffer.updateFloat4("shadowsInfo",this.getDarkness(),this.blurScale/this.getShadowMap().getSize().width,this.depthScale,this.frustumEdgeFalloff,e),i._uniformBuffer.updateFloat2("depthValues",this.getLight().getDepthMinZ(r.activeCamera),this.getLight().getDepthMinZ(r.activeCamera)+this.getLight().getDepthMaxZ(r.activeCamera),e))},t.prototype.getTransformMatrix=function(){var t=this._scene;if(this._currentRenderID===t.getRenderId()&&this._currentFaceIndexCache===this._currentFaceIndex)return this._transformMatrix;this._currentRenderID=t.getRenderId(),this._currentFaceIndexCache=this._currentFaceIndex;var i=this._light.position;return this._light.computeTransformedInformation()&&(i=this._light.transformedPosition),e.Vector3.NormalizeToRef(this._light.getShadowDirection(this._currentFaceIndex),this._lightDirection),1===Math.abs(e.Vector3.Dot(this._lightDirection,e.Vector3.Up()))&&(this._lightDirection.z=1e-13),!this._light.needProjectionMatrixCompute()&&this._cachedPosition&&this._cachedDirection&&i.equals(this._cachedPosition)&&this._lightDirection.equals(this._cachedDirection)||(this._cachedPosition=i.clone(),this._cachedDirection=this._lightDirection.clone(),e.Matrix.LookAtLHToRef(i,i.add(this._lightDirection),e.Vector3.Up(),this._viewMatrix),this._light.setShadowProjectionMatrix(this._projectionMatrix,this._viewMatrix,this.getShadowMap().renderList),this._viewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix)),this._transformMatrix},t.prototype.recreateShadowMap=function(){var e=this._shadowMap.renderList;this._disposeRTTandPostProcesses(),this._initializeGenerator(),this.filter=this.filter,this._applyFilterValues(),this._shadowMap.renderList=e},t.prototype._disposeBlurPostProcesses=function(){this._shadowMap2&&(this._shadowMap2.dispose(),this._shadowMap2=null),this._downSamplePostprocess&&(this._downSamplePostprocess.dispose(),this._downSamplePostprocess=null),this._boxBlurPostprocess&&(this._boxBlurPostprocess.dispose(),this._boxBlurPostprocess=null),this._kernelBlurXPostprocess&&(this._kernelBlurXPostprocess.dispose(),this._kernelBlurXPostprocess=null),this._kernelBlurYPostprocess&&(this._kernelBlurYPostprocess.dispose(),this._kernelBlurYPostprocess=null),this._blurPostProcesses=null},t.prototype._disposeRTTandPostProcesses=function(){this._shadowMap&&(this._shadowMap.dispose(),this._shadowMap=null),this._disposeBlurPostProcesses()},t.prototype.dispose=function(){this._disposeRTTandPostProcesses(),this._light._shadowGenerator=null,this._light._markMeshesAsLightDirty()},t.prototype.serialize=function(){var e={},t=this.getShadowMap();e.lightId=this._light.id,e.mapSize=t.getRenderSize(),e.useExponentialShadowMap=this.useExponentialShadowMap,e.useBlurExponentialShadowMap=this.useBlurExponentialShadowMap,e.useCloseExponentialShadowMap=this.useBlurExponentialShadowMap,e.useBlurCloseExponentialShadowMap=this.useBlurExponentialShadowMap,e.usePoissonSampling=this.usePoissonSampling,e.forceBackFacesOnly=this.forceBackFacesOnly,e.depthScale=this.depthScale,e.darkness=this.getDarkness(),e.blurBoxOffset=this.blurBoxOffset,e.blurKernel=this.blurKernel,e.blurScale=this.blurScale,e.useKernelBlur=this.useKernelBlur,e.transparencyShadow=this._transparencyShadow,e.renderList=[];for(var i=0;i-1&&void 0!==f.skeletons&&null!==f.skeletons){if(!1===m.indexOf(y.skeletonId)>-1)for(var O=0,I=f.skeletons.length;O0){for(var $=0;$0){for(var te=0;te0&&this._textureLoadingCallback(e)}this._currentScene.render()}},t.prototype.drag=function(e){e.stopPropagation(),e.preventDefault()},t.prototype.drop=function(e){e.stopPropagation(),e.preventDefault(),this.loadFiles(e)},t.prototype._handleFolderDrop=function(e,t,i){ -var r=e.createReader(),n=e.fullPath.replace(/^\//,"").replace(/(.+?)\/?$/,"$1/");r.readEntries((function(e){for(var r=e.length,o=0,s=e;o0){for(var i=[],r=[],n=0;n0&&(e.Tools.ClearLogCache(),e.Tools.Log("Babylon.js engine (v"+e.Engine.Version+") launched")),this._engine.stopRenderLoop(),this._currentScene.dispose()),e.SceneLoader.Load("file:",this._sceneFileToLoad,this._engine,(function(e){i._currentScene=e,i._currentScene.executeWhenReady((function(){i._sceneLoadedCallback&&i._sceneLoadedCallback(t._sceneFileToLoad,i._currentScene),i._engine.runRenderLoop((function(){i.renderFunction()}))}))}),(function(e){t._progressCallback&&t._progressCallback(e)}))):e.Tools.Error("Please provide a valid .babylon file.")},t})();t.FilesToLoad=new Array,e.FilesInput=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(){this._count=0,this._data={}}return e.prototype.copyFrom=function(e){var t=this;this.clear(),e.forEach((function(e,i){return t.add(e,i)}))},e.prototype.get=function(e){var t=this._data[e];if(void 0!==t)return t},e.prototype.getOrAddWithFactory=function(e,t){var i=this.get(e);return void 0!==i?i:(i=t(e),i&&this.add(e,i),i)},e.prototype.getOrAdd=function(e,t){var i=this.get(e);return void 0!==i?i:(this.add(e,t),t)},e.prototype.contains=function(e){return void 0!==this._data[e]},e.prototype.add=function(e,t){return void 0===this._data[e]&&(this._data[e]=t,++this._count,!0)},e.prototype.set=function(e,t){return void 0!==this._data[e]&&(this._data[e]=t,!0)},e.prototype.getAndRemove=function(e){var t=this.get(e);return void 0!==t?(delete this._data[e],--this._count,t):null},e.prototype.remove=function(e){return!!this.contains(e)&&(delete this._data[e],--this._count,!0)},e.prototype.clear=function(){this._data={},this._count=0},Object.defineProperty(e.prototype,"count",{get:function(){return this._count},enumerable:!0,configurable:!0}),e.prototype.forEach=function(e){for(var t in this._data){e(t,this._data[t])}},e.prototype.first=function(e){for(var t in this._data){var i=this._data[t],r=e(t,i);if(r)return r}return null},e})();e.StringDictionary=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){}return t.EnableFor=function(e){e._tags=e._tags||{},e.hasTags=function(){return t.HasTags(e)},e.addTags=function(i){return t.AddTagsTo(e,i)},e.removeTags=function(i){return t.RemoveTagsFrom(e,i)},e.matchesTagsQuery=function(i){return t.MatchesQuery(e,i)}},t.DisableFor=function(e){delete e._tags,delete e.hasTags,delete e.addTags,delete e.removeTags,delete e.matchesTagsQuery},t.HasTags=function(t){return!!t._tags&&!e.Tools.IsEmpty(t._tags)},t.GetTags=function(e,t){if(void 0===t&&(t=!0),!e._tags)return null;if(t){var i=[];for(var r in e._tags)e._tags.hasOwnProperty(r)&&!0===e._tags[r]&&i.push(r);return i.join(" ")}return e._tags},t.AddTagsTo=function(e,i){if(i&&"string"==typeof i){i.split(" ").forEach((function(i,r,n){t._AddTagTo(e,i)}))}},t._AddTagTo=function(e,i){""!==(i=i.trim())&&"true"!==i&&"false"!==i&&(i.match(/[\s]/)||i.match(/^([!]|([|]|[&]){2})/)||(t.EnableFor(e),e._tags[i]=!0))},t.RemoveTagsFrom=function(e,i){if(t.HasTags(e)){var r=i.split(" ");for(var n in r)t._RemoveTagFrom(e,r[n])}},t._RemoveTagFrom=function(e,t){delete e._tags[t]},t.MatchesQuery=function(i,r){return void 0===r||(""===r?t.HasTags(i):e.Internals.AndOrNotEvaluator.Eval(r,(function(e){return t.HasTags(i)&&i._tags[e]})))},t})();e.Tags=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(e){var t=(function(){function e(){}return e.Eval=function(t,i){return"true"===(t=t.match(/\([^\(\)]*\)/g)?t.replace(/\([^\(\)]*\)/g,(function(t){return t=t.slice(1,t.length-1),e._HandleParenthesisContent(t,i)})):e._HandleParenthesisContent(t,i))||"false"!==t&&e.Eval(t,i)},e._HandleParenthesisContent=function(t,i){i=i||function(e){return"true"===e};var r,n=t.split("||");for(var o in n)if(n.hasOwnProperty(o)){var s=e._SimplifyNegation(n[o].trim()),a=s.split("&&");if(a.length>1)for(var l=0;lo.data?(n.mustUpdateRessources=!0,r()):i(o.data):(n.mustUpdateRessources=!0,r())},s.onabort=function(e){i(-1)};var a=s.objectStore("versions").get(t);a.onsuccess=function(e){o=e.target.result},a.onerror=function(r){e.Tools.Error("Error loading version for scene "+t+" from DB."),i(-1)}}catch(t){e.Tools.Error("Error while accessing 'versions' object store (READ OP). Exception: "+t.message),i(-1)}}else e.Tools.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."),i(-1)},t.prototype._saveVersionIntoDBAsync=function(t,i){var r=this;if(this.isSupported&&!this.hasReachedQuota)try{var n=this.db.transaction(["versions"],"readwrite");n.onabort=function(e){try{e.srcElement.error&&"QuotaExceededError"===e.srcElement.error.name&&(r.hasReachedQuota=!0)}catch(e){}i(-1)},n.oncomplete=function(e){i(r.manifestVersionFound)};var o={sceneUrl:t,data:this.manifestVersionFound},s=n.objectStore("versions").put(o);s.onsuccess=function(e){},s.onerror=function(t){e.Tools.Error("Error in DB add version request in BABYLON.Database.")}}catch(t){e.Tools.Error("Error while accessing 'versions' object store (WRITE OP). Exception: "+t.message),i(-1)}else i(-1)},t.prototype.loadFileFromDB=function(e,i,r,n,o){var s=this,a=t.ReturnFullUrlLocation(e),l=function(e){s._saveFileIntoDBAsync(a,i,r)};this._checkVersionFromDB(a,(function(e){-1!==e?s.mustUpdateRessources?s._saveFileIntoDBAsync(a,i,r,o):s._loadFileFromDBAsync(a,i,l,o):n()}))},t.prototype._loadFileFromDBAsync=function(t,i,r,n){if(this.isSupported){var o;o=-1!==t.indexOf(".babylon")?"scenes":"textures";var s,a=this.db.transaction([o]);a.oncomplete=function(e){s?i(s.data):r()},a.onabort=function(e){r()};var l=a.objectStore(o).get(t);l.onsuccess=function(e){s=e.target.result},l.onerror=function(i){e.Tools.Error("Error loading file "+t+" from DB."),r()}}else e.Tools.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."),i()},t.prototype._saveFileIntoDBAsync=function(t,i,r,n){var o=this;if(this.isSupported){var s;s=-1!==t.indexOf(".babylon")?"scenes":"textures";var a,l=new XMLHttpRequest;l.open("GET",t,!0),n&&(l.responseType="arraybuffer"),l.onprogress=r,l.addEventListener("load",(function(){if(200===l.status||e.Tools.ValidateXHRData(l,n?6:1))if(a=n?l.response:l.responseText,o.hasReachedQuota)i(a);else{var r=o.db.transaction([s],"readwrite");r.onabort=function(e){try{e.srcElement.error&&"QuotaExceededError"===e.srcElement.error.name&&(o.hasReachedQuota=!0)}catch(e){}i(a)},r.oncomplete=function(e){i(a)};var h;h="scenes"===s?{sceneUrl:t,data:a,version:o.manifestVersionFound}:{textureUrl:t,data:a};try{var c=r.objectStore(s).put(h);c.onsuccess=function(e){},c.onerror=function(t){e.Tools.Error("Error in DB add file request in BABYLON.Database.")}}catch(e){i(a)}}else i()}),!1),l.addEventListener("error",(function(t){e.Tools.Error("error on XHR request."),i()}),!1),l.send()}else e.Tools.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."),i()},t})();t.IsUASupportingBlobStorage=!0,t.IDBStorageEnabled=!0,t.parseURL=function(e){document.createElement("a").href=e;var t=e.substring(0,e.lastIndexOf("#")),i=e.substring(t.lastIndexOf("/")+1,e.length);return e.substring(0,e.indexOf(i,0))},t.ReturnFullUrlLocation=function(e){return-1===e.indexOf("http:/")&&-1===e.indexOf("https:/")?t.parseURL(window.location.href)+e:e},e.Database=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this._isEnabled=!0,this.leftColor=e.Color3.White(),this.rightColor=e.Color3.Black(),this.bias=0,this.power=1}return Object.defineProperty(t.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(t){this._isEnabled!==t&&(this._isEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.FresnelDirtyFlag))},enumerable:!0,configurable:!0}),t.prototype.clone=function(){var i=new t;return e.Tools.DeepCopy(this,i),i},t.prototype.serialize=function(){var e={};return e.isEnabled=this.isEnabled,e.leftColor=this.leftColor,e.rightColor=this.rightColor,e.bias=this.bias,e.power=this.power,e},t.Parse=function(i){var r=new t;return r.isEnabled=i.isEnabled,r.leftColor=e.Color3.FromArray(i.leftColor),r.rightColor=e.Color3.FromArray(i.rightColor),r.bias=i.bias,r.power=i.power||1,r},t})();e.FresnelParameters=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e,i){var r=t.call(this,e,i,!0)||this;return i.multiMaterials.push(r),r.subMaterials=new Array,r.storeEffectOnSubMeshes=!0,r}return __extends(i,t),Object.defineProperty(i.prototype,"subMaterials",{get:function(){return this._subMaterials},set:function(e){this._subMaterials=e,this._hookArray(e)},enumerable:!0,configurable:!0}),i.prototype._hookArray=function(e){var t=this,i=e.push;e.push=function(){for(var r=[],n=0;n=this.subMaterials.length?this.getScene().defaultMaterial:this.subMaterials[e]},i.prototype.getActiveTextures=function(){return(e=t.prototype.getActiveTextures.call(this)).concat.apply(e,this.subMaterials.map((function(e){return e.getActiveTextures()})));var e},i.prototype.getClassName=function(){return"MultiMaterial"},i.prototype.isReadyForSubMesh=function(e,t,i){for(var r=0;r=0&&r.multiMaterials.splice(n,1),t.prototype.dispose.call(this,e,i)}},i})(e.Material);e.MultiMaterial=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this._offsetX=null,this._offsetY=null,this._pointerCount=0,this._pointerPressed=[],this.touchAngularSensibility=2e5,this.touchMoveSensibility=250}return t.prototype.attachControl=function(t,i){var r,n=this;void 0===this._pointerInput&&(this._onLostFocus=function(e){n._offsetX=null,n._offsetY=null},this._pointerInput=function(t,o){var s=t.event;if("mouse"!==s.pointerType)if(t.type===e.PointerEventTypes.POINTERDOWN){if(i||s.preventDefault(),n._pointerPressed.push(s.pointerId),1!==n._pointerPressed.length)return;r={x:s.clientX,y:s.clientY}}else if(t.type===e.PointerEventTypes.POINTERUP){i||s.preventDefault();var a=n._pointerPressed.indexOf(s.pointerId);if(-1===a)return;if(n._pointerPressed.splice(a,1),0!=a)return;r=null,n._offsetX=null,n._offsetY=null}else if(t.type===e.PointerEventTypes.POINTERMOVE){if(i||s.preventDefault(),!r)return;var a=n._pointerPressed.indexOf(s.pointerId);if(0!=a)return;n._offsetX=s.clientX-r.x,n._offsetY=-(s.clientY-r.y)}}),this._observer=this.camera.getScene().onPointerObservable.add(this._pointerInput,e.PointerEventTypes.POINTERDOWN|e.PointerEventTypes.POINTERUP|e.PointerEventTypes.POINTERMOVE),t.addEventListener("blur",this._onLostFocus)},t.prototype.detachControl=function(e){this._pointerInput&&e&&(this.camera.getScene().onPointerObservable.remove(this._observer),this._observer=null,e.removeEventListener("blur",this._onLostFocus),this._onLostFocus=null,this._pointerPressed=[],this._offsetX=null,this._offsetY=null,this._pointerCount=0)},t.prototype.checkInputs=function(){if(this._offsetX){var t=this.camera;if(t.cameraRotation.y+=this._offsetX/this.touchAngularSensibility,this._pointerPressed.length>1)t.cameraRotation.x+=-this._offsetY/this.touchAngularSensibility;else{var i=t._computeLocalCameraSpeed(),r=new e.Vector3(0,0,i*this._offsetY/this.touchMoveSensibility);e.Matrix.RotationYawPitchRollToRef(t.rotation.y,t.rotation.x,0,t._cameraRotationMatrix),t.cameraDirection.addInPlace(e.Vector3.TransformCoordinates(r,t._cameraRotationMatrix))}}},t.prototype.getClassName=function(){return"FreeCameraTouchInput"},t.prototype.getSimpleName=function(){return"touch"},t})();__decorate([e.serialize()],t.prototype,"touchAngularSensibility",void 0),__decorate([e.serialize()],t.prototype,"touchMoveSensibility",void 0),e.FreeCameraTouchInput=t,e.CameraInputTypes.FreeCameraTouchInput=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(e){function t(t,i,r){var n=e.call(this,t,i,r)||this;return n.inputs.addTouch(),n._setupInputs(),n}return __extends(t,e),Object.defineProperty(t.prototype,"touchAngularSensibility",{get:function(){var e=this.inputs.attached.touch;if(e)return e.touchAngularSensibility},set:function(e){var t=this.inputs.attached.touch;t&&(t.touchAngularSensibility=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"touchMoveSensibility",{get:function(){var e=this.inputs.attached.touch;if(e)return e.touchMoveSensibility},set:function(e){var t=this.inputs.attached.touch;t&&(t.touchMoveSensibility=e)},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return"TouchCamera"},t.prototype._setupInputs=function(){var e=this.inputs.attached.mouse;e&&(e.touchEnabled=!1)},t})(e.FreeCamera);e.TouchCamera=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o,s,a,l){void 0===a&&(a=!0),void 0===l&&(l=!1);var h=t.call(this,null,o,!a)||this;h.isCube=l,h.isEnabled=!0,h._currentRefreshId=-1,h._refreshRate=1,h._vertexBuffers={},h._uniforms=new Array,h._samplers=new Array,h._textures=new Array,h._floats=new Array,h._floatsArrays={},h._colors3=new Array,h._colors4=new Array,h._vectors2=new Array,h._vectors3=new Array,h._matrices=new Array,h._fallbackTextureUsed=!1,o._proceduralTextures.push(h),h.name=i,h.isRenderTarget=!0,h._size=r,h._generateMipMaps=a,h.setFragment(n),h._fallbackTexture=s;var c=o.getEngine();l?(h._texture=c.createRenderTargetCubeTexture(r,{generateMipMaps:a}),h.setFloat("face",0)):h._texture=c.createRenderTargetTexture(r,a);var u=[];u.push(1,1),u.push(-1,1),u.push(-1,-1),u.push(1,-1),h._vertexBuffers[e.VertexBuffer.PositionKind]=new e.VertexBuffer(c,u,e.VertexBuffer.PositionKind,!1,!1,2);var f=[];return f.push(0),f.push(1),f.push(2),f.push(0),f.push(2),f.push(3),h._indexBuffer=c.createIndexBuffer(f),h}return __extends(i,t),i.prototype.reset=function(){if(void 0!==this._effect){this.getScene().getEngine()._releaseEffect(this._effect)}},i.prototype.isReady=function(){var t,i=this,r=this.getScene().getEngine();return!!this._fragment&&(!!this._fallbackTextureUsed||(t=void 0!==this._fragment.fragmentElement?{vertex:"procedural",fragmentElement:this._fragment.fragmentElement}:{vertex:"procedural",fragment:this._fragment},this._effect=r.createEffect(t,[e.VertexBuffer.PositionKind],this._uniforms,this._samplers,"",null,null,(function(){i.releaseInternalTexture(),i._fallbackTexture&&(i._texture=i._fallbackTexture._texture,i._texture.references++),i._fallbackTextureUsed=!0})),this._effect.isReady()))},i.prototype.resetRefreshCounter=function(){this._currentRefreshId=-1},i.prototype.setFragment=function(e){this._fragment=e},Object.defineProperty(i.prototype,"refreshRate",{get:function(){return this._refreshRate},set:function(e){this._refreshRate=e,this.resetRefreshCounter()},enumerable:!0,configurable:!0}),i.prototype._shouldRender=function(){return!!(this.isEnabled&&this.isReady()&&this._texture)&&(!this._fallbackTextureUsed&&(-1===this._currentRefreshId?(this._currentRefreshId=1,!0):this.refreshRate===this._currentRefreshId?(this._currentRefreshId=1,!0):(this._currentRefreshId++,!1)))},i.prototype.getRenderSize=function(){return this._size},i.prototype.resize=function(e,t){this._fallbackTextureUsed||(this.releaseInternalTexture(),this._texture=this.getScene().getEngine().createRenderTargetTexture(e,t))},i.prototype._checkUniform=function(e){-1===this._uniforms.indexOf(e)&&this._uniforms.push(e)},i.prototype.setTexture=function(e,t){return-1===this._samplers.indexOf(e)&&this._samplers.push(e),this._textures[e]=t,this},i.prototype.setFloat=function(e,t){return this._checkUniform(e),this._floats[e]=t,this},i.prototype.setFloats=function(e,t){return this._checkUniform(e),this._floatsArrays[e]=t,this},i.prototype.setColor3=function(e,t){return this._checkUniform(e),this._colors3[e]=t,this},i.prototype.setColor4=function(e,t){return this._checkUniform(e),this._colors4[e]=t,this},i.prototype.setVector2=function(e,t){return this._checkUniform(e),this._vectors2[e]=t,this},i.prototype.setVector3=function(e,t){return this._checkUniform(e),this._vectors3[e]=t,this},i.prototype.setMatrix=function(e,t){return this._checkUniform(e),this._matrices[e]=t,this},i.prototype.render=function(e){var t=this.getScene(),i=t.getEngine();i.enableEffect(this._effect),i.setState(!1);for(var r in this._textures)this._effect.setTexture(r,this._textures[r]);for(r in this._floats)this._effect.setFloat(r,this._floats[r]);for(r in this._floatsArrays)this._effect.setArray(r,this._floatsArrays[r]);for(r in this._colors3)this._effect.setColor3(r,this._colors3[r]);for(r in this._colors4){var n=this._colors4[r];this._effect.setFloat4(r,n.r,n.g,n.b,n.a)}for(r in this._vectors2)this._effect.setVector2(r,this._vectors2[r]);for(r in this._vectors3)this._effect.setVector3(r,this._vectors3[r]);for(r in this._matrices)this._effect.setMatrix(r,this._matrices[r]);if(this.isCube)for(var o=0;o<6;o++)i.bindFramebuffer(this._texture,o),i.bindBuffers(this._vertexBuffers,this._indexBuffer,this._effect),this._effect.setFloat("face",o),i.clear(t.clearColor,!0,!0,!0),i.draw(!0,0,6),5===o&&i.generateMipMapsForCubemap(this._texture);else i.bindFramebuffer(this._texture),i.bindBuffers(this._vertexBuffers,this._indexBuffer,this._effect),i.clear(t.clearColor,!0,!0,!0),i.draw(!0,0,6);i.unBindFramebuffer(this._texture,this.isCube),this.onGenerated&&this.onGenerated()},i.prototype.clone=function(){var e=this.getSize(),t=new i(this.name,e.width,this._fragment,this.getScene(),this._fallbackTexture,this._generateMipMaps);return t.hasAlpha=this.hasAlpha,t.level=this.level,t.coordinatesMode=this.coordinatesMode,t},i.prototype.dispose=function(){var i=this.getScene()._proceduralTextures.indexOf(this);i>=0&&this.getScene()._proceduralTextures.splice(i,1);var r=this._vertexBuffers[e.VertexBuffer.PositionKind];r&&(r.dispose(),this._vertexBuffers[e.VertexBuffer.PositionKind]=null),this._indexBuffer&&this.getScene().getEngine()._releaseBuffer(this._indexBuffer)&&(this._indexBuffer=null),t.prototype.dispose.call(this)},i})(e.Texture);e.ProceduralTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e,i,r,n,o,s){var a=t.call(this,e,r,null,n,o,s)||this;return a._animate=!0,a._time=0,a._texturePath=i,a.loadJson(i),a.refreshRate=1,a}return __extends(i,t),i.prototype.loadJson=function(t){function i(){e.Tools.Log("No config file found in "+t+" trying to use ShadersStore or DOM element");try{n.setFragment(n._texturePath)}catch(t){e.Tools.Error("No json or ShaderStore or DOM element found for CustomProceduralTexture")}}var r=this,n=this,o=t+"/config.json",s=new XMLHttpRequest;s.open("GET",o,!0),s.addEventListener("load",(function(){if(200===s.status||e.Tools.ValidateXHRData(s,1))try{r._config=JSON.parse(s.response),r.updateShaderUniforms(),r.updateTextures(),r.setFragment(r._texturePath+"/custom"),r._animate=r._config.animate,r.refreshRate=r._config.refreshrate}catch(e){i()}else i()}),!1),s.addEventListener("error",(function(){i()}),!1);try{s.send()}catch(t){e.Tools.Error("CustomProceduralTexture: Error on XHR send request.")}},i.prototype.isReady=function(){if(!t.prototype.isReady.call(this))return!1;for(var e in this._textures){if(!this._textures[e].isReady())return!1}return!0},i.prototype.render=function(e){this._animate&&(this._time+=.03*this.getScene().getAnimationRatio(),this.updateShaderUniforms()),t.prototype.render.call(this,e)},i.prototype.updateTextures=function(){for(var t=0;t.005?0+r:0,i.y=Math.abs(n)>.005?0+n:0;var o=this.gamepad.rightStick;if(o){var s=o.x/this.gamepadAngularSensibility,a=o.y/this.gamepadAngularSensibility;o.x=Math.abs(s)>.001?0+s:0,o.y=Math.abs(a)>.001?0+a:0}else o={x:0,y:0};t.rotationQuaternion?t.rotationQuaternion.toRotationMatrix(this._cameraTransform):e.Matrix.RotationYawPitchRollToRef(t.rotation.y,t.rotation.x,0,this._cameraTransform);var l=50*t._computeLocalCameraSpeed();this._vector3.copyFromFloats(i.x*l,0,-i.y*l),e.Vector3.TransformCoordinatesToRef(this._vector3,this._cameraTransform,this._deltaTransform),t.cameraDirection.addInPlace(this._deltaTransform),this._vector2.copyFromFloats(o.y,o.x),t.cameraRotation.addInPlace(this._vector2)}},t.prototype._onNewGameConnected=function(t){t.type!==e.Gamepad.POSE_ENABLED&&(this.gamepad&&t.type!==e.Gamepad.XBOX||(this.gamepad=t))},t.prototype.getClassName=function(){return"FreeCameraGamepadInput"},t.prototype.getSimpleName=function(){return"gamepad"},t})();__decorate([e.serialize()],t.prototype,"gamepadAngularSensibility",void 0),__decorate([e.serialize()],t.prototype,"gamepadMoveSensibility",void 0),e.FreeCameraGamepadInput=t,e.CameraInputTypes.FreeCameraGamepadInput=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this.gamepadRotationSensibility=80,this.gamepadMoveSensibility=40}return t.prototype.attachControl=function(t,i){var r=this;this._gamepads=new e.Gamepads(function(e){r._onNewGameConnected(e)})},t.prototype.detachControl=function(e){this._gamepads&&this._gamepads.dispose(),this.gamepad=null},t.prototype.checkInputs=function(){if(this.gamepad){var e=this.camera,t=this.gamepad.rightStick;if(t){if(0!=t.x){var i=t.x/this.gamepadRotationSensibility;0!=i&&Math.abs(i)>.005&&(e.inertialAlphaOffset+=i)}if(0!=t.y){var r=t.y/this.gamepadRotationSensibility;0!=r&&Math.abs(r)>.005&&(e.inertialBetaOffset+=r)}}var n=this.gamepad.leftStick;if(n&&0!=n.y){var o=n.y/this.gamepadMoveSensibility;0!=o&&Math.abs(o)>.005&&(this.camera.inertialRadiusOffset-=o)}}},t.prototype._onNewGameConnected=function(t){t.type!==e.Gamepad.POSE_ENABLED&&(this.gamepad&&t.type!==e.Gamepad.XBOX||(this.gamepad=t))},t.prototype.getClassName=function(){return"ArcRotateCameraGamepadInput"},t.prototype.getSimpleName=function(){return"gamepad"},t})();__decorate([e.serialize()],t.prototype,"gamepadRotationSensibility",void 0),__decorate([e.serialize()],t.prototype,"gamepadMoveSensibility",void 0),e.ArcRotateCameraGamepadInput=t,e.CameraInputTypes.ArcRotateCameraGamepadInput=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e,t){var i=this;this.babylonGamepads=[],this.oneGamepadConnected=!1,this.isMonitoring=!1,this.gamepadEventSupported="GamepadEvent"in window,this.gamepadSupport=navigator.getGamepads||navigator.webkitGetGamepads||navigator.msGetGamepads||navigator.webkitGamepads,this._callbackGamepadConnected=e,this._callbackGamepadDisconnected=t,this.gamepadSupport&&(this._updateGamepadObjects(),this.babylonGamepads.length&&this._startMonitoringGamepads(),this.gamepadEventSupported?(this._onGamepadConnectedEvent=function(e){i._onGamepadConnected(e.gamepad)},this._onGamepadDisonnectedEvent=function(e){i._onGamepadDisconnected(e.gamepad)},window.addEventListener("gamepadconnected",this._onGamepadConnectedEvent,!1),window.addEventListener("gamepaddisconnected",this._onGamepadDisonnectedEvent,!1)):this._startMonitoringGamepads())}return t.prototype.dispose=function(){this._onGamepadConnectedEvent&&(window.removeEventListener("gamepadconnected",this._onGamepadConnectedEvent,!1),window.removeEventListener("gamepaddisconnected",this._onGamepadDisonnectedEvent,!1),this._onGamepadConnectedEvent=null,this._onGamepadDisonnectedEvent=null),this.oneGamepadConnected=!1, -this._stopMonitoringGamepads(),this.babylonGamepads=[]},t.prototype._onGamepadConnected=function(e){if(!(e.index in this.babylonGamepads)){var t=this._addNewGamepad(e);this._callbackGamepadConnected&&this._callbackGamepadConnected(t),this._startMonitoringGamepads()}},t.prototype._addNewGamepad=function(t){this.oneGamepadConnected||(this.oneGamepadConnected=!0);var i,r=-1!==t.id.search("Xbox One");return i=r||-1!==t.id.search("Xbox 360")||-1!==t.id.search("xinput")?new a(t.id,t.index,t,r):t.pose?e.PoseEnabledControllerHelper.InitiateController(t):new n(t.id,t.index,t),this.babylonGamepads.push(i),i},t.prototype._onGamepadDisconnected=function(e){for(var t in this.babylonGamepads)if(this.babylonGamepads[t].index==e.index){this.babylonGamepads.splice(+t,1);break}0==this.babylonGamepads.length&&(this._stopMonitoringGamepads(),this.oneGamepadConnected=!1),this._callbackGamepadDisconnected&&this._callbackGamepadDisconnected(e)},t.prototype._startMonitoringGamepads=function(){this.isMonitoring||(this.isMonitoring=!0,this._checkGamepadsStatus())},t.prototype._stopMonitoringGamepads=function(){this.isMonitoring=!1},t.prototype._checkGamepadsStatus=function(){var e=this;this._updateGamepadObjects();for(var t in this.babylonGamepads)this.babylonGamepads[t].update();this.isMonitoring&&(window.requestAnimationFrame?window.requestAnimationFrame((function(){e._checkGamepadsStatus()})):window.mozRequestAnimationFrame?window.mozRequestAnimationFrame((function(){e._checkGamepadsStatus()})):window.webkitRequestAnimationFrame&&window.webkitRequestAnimationFrame((function(){e._checkGamepadsStatus()})))},t.prototype._updateGamepadObjects=function(){for(var e=navigator.getGamepads?navigator.getGamepads():navigator.webkitGetGamepads?navigator.webkitGetGamepads():[],t=0;t=2&&(this._leftStick={x:this.browserGamepad.axes[this._leftStickAxisX],y:this.browserGamepad.axes[this._leftStickAxisY]}),this.browserGamepad.axes.length>=4&&(this._rightStick={x:this.browserGamepad.axes[this._rightStickAxisX],y:this.browserGamepad.axes[this._rightStickAxisY]})}return e.prototype.onleftstickchanged=function(e){this._onleftstickchanged=e},e.prototype.onrightstickchanged=function(e){this._onrightstickchanged=e},Object.defineProperty(e.prototype,"leftStick",{get:function(){return this._leftStick},set:function(e){!this._onleftstickchanged||this._leftStick.x===e.x&&this._leftStick.y===e.y||this._onleftstickchanged(e),this._leftStick=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rightStick",{get:function(){return this._rightStick},set:function(e){!this._onrightstickchanged||this._rightStick.x===e.x&&this._rightStick.y===e.y||this._onrightstickchanged(e),this._rightStick=e},enumerable:!0,configurable:!0}),e.prototype.update=function(){this._leftStick&&(this.leftStick={x:this.browserGamepad.axes[this._leftStickAxisX],y:this.browserGamepad.axes[this._leftStickAxisY]}),this._rightStick&&(this.rightStick={x:this.browserGamepad.axes[this._rightStickAxisX],y:this.browserGamepad.axes[this._rightStickAxisY]})},e})();r.GAMEPAD=0,r.GENERIC=1,r.XBOX=2,r.POSE_ENABLED=3,e.Gamepad=r;var n=(function(e){function t(t,i,n){var o=e.call(this,t,i,n)||this;return o.type=r.GENERIC,o._buttons=new Array(n.buttons.length),o}return __extends(t,e),t.prototype.onbuttondown=function(e){this._onbuttondown=e},t.prototype.onbuttonup=function(e){this._onbuttonup=e},t.prototype._setButtonValue=function(e,t,i){return e!==t&&(this._onbuttondown&&1===e&&this._onbuttondown(i),this._onbuttonup&&0===e&&this._onbuttonup(i)),e},t.prototype.update=function(){e.prototype.update.call(this);for(var t=0;tthis.maxCameraSpeed||u<-this.maxCameraSpeed)&&(u=u<1?-this.maxCameraSpeed:this.maxCameraSpeed),(f>this.maxCameraSpeed||f<-this.maxCameraSpeed)&&(f=f<1?-this.maxCameraSpeed:this.maxCameraSpeed),(d>this.maxCameraSpeed||d<-this.maxCameraSpeed)&&(d=d<1?-this.maxCameraSpeed:this.maxCameraSpeed),this.position=new e.Vector3(this.position.x+u,this.position.y+f,this.position.z+d),this.setTarget(o)}},i.prototype._checkInputs=function(){t.prototype._checkInputs.call(this),this.follow(this.lockedTarget)},i.prototype.getClassName=function(){return"FollowCamera"},i})(e.TargetCamera);__decorate([e.serialize()],t.prototype,"radius",void 0),__decorate([e.serialize()],t.prototype,"rotationOffset",void 0),__decorate([e.serialize()],t.prototype,"heightOffset",void 0),__decorate([e.serialize()],t.prototype,"cameraAcceleration",void 0),__decorate([e.serialize()],t.prototype,"maxCameraSpeed",void 0),__decorate([e.serializeAsMeshReference("lockedTargetId")],t.prototype,"lockedTarget",void 0),e.FollowCamera=t;var i=(function(t){function i(i,r,n,o,s,a){var l=t.call(this,i,e.Vector3.Zero(),a)||this;return l.alpha=r,l.beta=n,l.radius=o,l.target=s,l._cartesianCoordinates=e.Vector3.Zero(),l.follow(),l}return __extends(i,t),i.prototype.follow=function(){this._cartesianCoordinates.x=this.radius*Math.cos(this.alpha)*Math.cos(this.beta),this._cartesianCoordinates.y=this.radius*Math.sin(this.beta),this._cartesianCoordinates.z=this.radius*Math.sin(this.alpha)*Math.cos(this.beta);var e=this.target.getAbsolutePosition();this.position=e.add(this._cartesianCoordinates),this.setTarget(e)},i.prototype._checkInputs=function(){t.prototype._checkInputs.call(this),this.follow()},i.prototype.getClassName=function(){return"ArcFollowCamera"},i})(e.TargetCamera);e.ArcFollowCamera=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(e){function t(t,i,r){var n=e.call(this,t,i,r)||this;return n.inputs.addGamepad(),n}return __extends(t,e),Object.defineProperty(t.prototype,"gamepadAngularSensibility",{get:function(){var e=this.inputs.attached.gamepad;if(e)return e.gamepadAngularSensibility},set:function(e){var t=this.inputs.attached.gamepad;t&&(t.gamepadAngularSensibility=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"gamepadMoveSensibility",{get:function(){var e=this.inputs.attached.gamepad;if(e)return e.gamepadMoveSensibility},set:function(e){var t=this.inputs.attached.gamepad;t&&(t.gamepadMoveSensibility=e)},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return"UniversalCamera"},t})(e.TouchCamera);e.UniversalCamera=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(e){function t(t,i,r){return e.call(this,t,i,r)||this}return __extends(t,e),Object.defineProperty(t.prototype,"gamepadAngularSensibility",{get:function(){var e=this.inputs.attached.gamepad;if(e)return e.gamepadAngularSensibility},set:function(e){var t=this.inputs.attached.gamepad;t&&(t.gamepadAngularSensibility=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"gamepadMoveSensibility",{get:function(){var e=this.inputs.attached.gamepad;if(e)return e.gamepadMoveSensibility},set:function(e){var t=this.inputs.attached.gamepad;t&&(t.gamepadMoveSensibility=e)},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return"GamepadCamera"},t})(e.UniversalCamera);e.GamepadCamera=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(){this._renderPipelines={}}return e.prototype.addPipeline=function(e){this._renderPipelines[e._name]=e},e.prototype.attachCamerasToRenderPipeline=function(e,t,i){var r=this._renderPipelines[e];r&&r._attachCameras(t,i)},e.prototype.detachCamerasFromRenderPipeline=function(e,t){var i=this._renderPipelines[e];i&&i._detachCameras(t)},e.prototype.enableEffectInPipeline=function(e,t,i){var r=this._renderPipelines[e];r&&r._enableEffect(t,i)},e.prototype.disableEffectInPipeline=function(e,t,i){var r=this._renderPipelines[e];r&&r._disableEffect(t,i)},e.prototype.enableDisplayOnlyPassInPipeline=function(e,t,i){var r=this._renderPipelines[e];r&&r._enableDisplayOnlyPass(t,i)},e.prototype.disableDisplayOnlyPassInPipeline=function(e,t){var i=this._renderPipelines[e];i&&i._disableDisplayOnlyPass(t)},e.prototype.update=function(){for(var e in this._renderPipelines){var t=this._renderPipelines[e];t.isSupported?t._update():(t.dispose(),delete this._renderPipelines[e])}},e})();e.PostProcessRenderPipelineManager=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t,i,r,n,o,s){this._enabled=!0,this._refCount=0,this._name=i,this._renderTexture=new e.RenderTargetTexture(i,r,t),this.setRenderList(n),this._renderTexture.onBeforeRenderObservable.add(o),this._renderTexture.onAfterRenderObservable.add(s),this._scene=t,this._renderList=n}return t.prototype._incRefCount=function(){return 0===this._refCount&&this._scene.customRenderTargets.push(this._renderTexture),++this._refCount},t.prototype._decRefCount=function(){return this._refCount--,this._refCount<=0&&this._scene.customRenderTargets.splice(this._scene.customRenderTargets.indexOf(this._renderTexture),1),this._refCount},t.prototype._update=function(){this.setRenderList(this._renderList)},t.prototype.setRenderList=function(e){this._renderTexture.renderList=e},t.prototype.getRenderTexture=function(){return this._renderTexture},t})();e.PostProcessRenderPass=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e,t,i,r){this._engine=e,this._name=t,this._singleInstance=r||!0,this._getPostProcess=i,this._cameras=[],this._indicesForCamera=[],this._postProcesses={},this._renderPasses={},this._renderEffectAsPasses={}}return Object.defineProperty(t.prototype,"isSupported",{get:function(){for(var e in this._postProcesses)if(!this._postProcesses[e].isSupported)return!1;return!0},enumerable:!0,configurable:!0}),t.prototype._update=function(){for(var e in this._renderPasses)this._renderPasses[e]._update()},t.prototype.addPass=function(e){this._renderPasses[e._name]=e,this._linkParameters()},t.prototype.removePass=function(e){delete this._renderPasses[e._name],this._linkParameters()},t.prototype.addRenderEffectAsPass=function(e){this._renderEffectAsPasses[e._name]=e,this._linkParameters()},t.prototype.getPass=function(e){for(var t in this._renderPasses)if(t===e)return this._renderPasses[e]},t.prototype.emptyPasses=function(){this._renderPasses={},this._linkParameters()},t.prototype._attachCameras=function(t){for(var i,r=e.Tools.MakeArray(t||this._cameras),n=0;n4&&(o.push(e.VertexBuffer.MatricesIndicesExtraKind),o.push(e.VertexBuffer.MatricesWeightsExtraKind)),n.push("#define NUM_BONE_INFLUENCERS "+s.numBoneInfluencers),n.push("#define BonesPerMesh "+(s.skeleton.bones.length+1))):n.push("#define NUM_BONE_INFLUENCERS 0"),i&&(n.push("#define INSTANCES"),o.push("world0"),o.push("world1"),o.push("world2"),o.push("world3"));var a=n.join("\n");return this._cachedDefines!==a&&(this._cachedDefines=a,this._effect=this._scene.getEngine().createEffect("depth",o,["world","mBones","viewProjection","diffuseMatrix","depthValues"],["diffuseSampler"],a)),this._effect.isReady()},t.prototype.getDepthMap=function(){return this._depthMap},t.prototype.dispose=function(){this._depthMap.dispose()},t})();e.DepthRenderer=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o){var s=t.call(this,r.getEngine(),i)||this;s.SSAOOriginalSceneColorEffect="SSAOOriginalSceneColorEffect",s.SSAORenderEffect="SSAORenderEffect",s.SSAOBlurHRenderEffect="SSAOBlurHRenderEffect",s.SSAOBlurVRenderEffect="SSAOBlurVRenderEffect",s.SSAOCombineRenderEffect="SSAOCombineRenderEffect",s.totalStrength=1,s.radius=1e-4,s.area=.0075,s.fallOff=1e-6,s.base=.5,s._firstUpdate=!0,s._scene=r,s._createRandomTexture(),s._depthTexture=r.enableDepthRenderer().getDepthMap();var a=n.ssaoRatio||n,l=n.combineRatio||n;return s._ratio={ssaoRatio:a,combineRatio:l},s._originalColorPostProcess=new e.PassPostProcess("SSAOOriginalSceneColor",l,null,e.Texture.BILINEAR_SAMPLINGMODE,r.getEngine(),!1),s._createSSAOPostProcess(a),s._createBlurPostProcess(a),s._createSSAOCombinePostProcess(l),s.addEffect(new e.PostProcessRenderEffect(r.getEngine(),s.SSAOOriginalSceneColorEffect,function(){return s._originalColorPostProcess},!0)),s.addEffect(new e.PostProcessRenderEffect(r.getEngine(),s.SSAORenderEffect,function(){return s._ssaoPostProcess},!0)),s.addEffect(new e.PostProcessRenderEffect(r.getEngine(),s.SSAOBlurHRenderEffect,function(){return s._blurHPostProcess},!0)),s.addEffect(new e.PostProcessRenderEffect(r.getEngine(),s.SSAOBlurVRenderEffect,function(){return s._blurVPostProcess},!0)),s.addEffect(new e.PostProcessRenderEffect(r.getEngine(),s.SSAOCombineRenderEffect,function(){return s._ssaoCombinePostProcess},!0)),r.postProcessRenderPipelineManager.addPipeline(s),o&&r.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(i,o),s}return __extends(i,t),i.prototype.dispose=function(e){void 0===e&&(e=!1);for(var i=0;i1},enumerable:!0,configurable:!0}),i.prototype.dispose=function(e){void 0===e&&(e=!1);for(var i=0;i=0;a--){var o=Math.pow(3,a),l="#define LUMINANCE_DOWN_SAMPLE\n";0===a&&(l+="#define FINAL_DOWN_SAMPLER");var h=new e.PostProcess("HDRLuminanceDownSample"+a,"standard",["dsOffsets","halfDestPixelSize"],[],{width:o,height:o},null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,l,r);this.luminanceDownSamplePostProcesses.push(h)}var c=this.luminancePostProcess;this.luminanceDownSamplePostProcesses.forEach((function(i,r){var o=new Array(18);i.onApply=function(e){for(var t=0,s=-1;s<2;s++)for(var a=-1;a<2;a++)o[t]=s/c.width,o[t+1]=a/c.height,t+=2;e.setArray2("dsOffsets",o),e.setFloat("halfDestPixelSize",.5/c.width),c=r===n.luminanceDownSamplePostProcesses.length-1?n.luminancePostProcess:i},r===n.luminanceDownSamplePostProcesses.length-1&&(i.onAfterRender=function(i){var r=t.getEngine().readPixels(0,0,1,1),o=new e.Vector4(1/16581375,1/65025,1/255,1);n._hdrCurrentLuminance=(r[0]*o.x+r[1]*o.y+r[2]*o.z+r[3]*o.w)/100}),n.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRLuminanceDownSample"+r,function(){return i},!0))}))},i.prototype._createHdrPostProcess=function(t,i){var r=this;this.hdrPostProcess=new e.PostProcess("HDR","standard",["averageLuminance"],["textureAdderSampler"],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,"#define HDR",e.Engine.TEXTURETYPE_UNSIGNED_INT);var n=1,o=0,s=0;this.hdrPostProcess.onApply=function(i){if(i.setTextureFromPostProcess("textureAdderSampler",r._currentDepthOfFieldSource),o+=t.getEngine().getDeltaTime(),n<0)n=r._hdrCurrentLuminance;else{var a=(s-o)/1e3;r._hdrCurrentLuminancen-r.hdrIncreaseRate*a?n-=r.hdrIncreaseRate*a:n=r._hdrCurrentLuminance}n=e.Scalar.Clamp(n,r.hdrMinimumLuminance,1e20),i.setFloat("averageLuminance",n),s=o,r._currentDepthOfFieldSource=r.hdrFinalPostProcess},this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDR",function(){return r.hdrPostProcess},!0))},i.prototype._createLensFlarePostProcess=function(t,i){var r=this;this.lensFlarePostProcess=new e.PostProcess("HDRLensFlare","standard",["strength","ghostDispersal","haloWidth","resolution","distortionStrength"],["lensColorSampler"],i/2,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,"#define LENS_FLARE",e.Engine.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRLensFlare",function(){return r.lensFlarePostProcess},!0)),this._createBlurPostProcesses(t,i/4,2),this.lensFlareComposePostProcess=new e.PostProcess("HDRLensFlareCompose","standard",["lensStarMatrix"],["otherSampler","lensDirtSampler","lensStarSampler"],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,"#define LENS_FLARE_COMPOSE",e.Engine.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRLensFlareCompose",function(){return r.lensFlareComposePostProcess},!0));var n=new e.Vector2(0,0);this.lensFlarePostProcess.onApply=function(e){e.setTextureFromPostProcess("textureSampler",r._bloomEnabled?r.blurHPostProcesses[0]:r.originalPostProcess),e.setTexture("lensColorSampler",r.lensColorTexture),e.setFloat("strength",r.lensFlareStrength),e.setFloat("ghostDispersal",r.lensFlareGhostDispersal),e.setFloat("haloWidth",r.lensFlareHaloWidth),n.x=r.lensFlarePostProcess.width,n.y=r.lensFlarePostProcess.height,e.setVector2("resolution",n),e.setFloat("distortionStrength",r.lensFlareDistortionStrength)};var o=e.Matrix.FromValues(2,0,-1,0,0,2,-1,0,0,0,1,0,0,0,0,1),s=e.Matrix.FromValues(.5,0,.5,0,0,.5,.5,0,0,0,1,0,0,0,0,1);this.lensFlareComposePostProcess.onApply=function(t){t.setTextureFromPostProcess("otherSampler",r._currentDepthOfFieldSource),t.setTexture("lensDirtSampler",r.lensFlareDirtTexture),t.setTexture("lensStarSampler",r.lensStarTexture);var i=r._scene.activeCamera.getViewMatrix().getRow(0),n=r._scene.activeCamera.getViewMatrix().getRow(2),a=e.Vector3.Dot(i.toVector3(),new e.Vector3(1,0,0))+e.Vector3.Dot(n.toVector3(),new e.Vector3(0,0,1));a*=4;var l=e.Matrix.FromValues(.5*Math.cos(a),-Math.sin(a),0,0,Math.sin(a),.5*Math.cos(a),0,0,0,0,1,0,0,0,0,1),h=s.multiply(l).multiply(o);t.setMatrix("lensStarMatrix",h),r._currentDepthOfFieldSource=r.lensFlareFinalPostProcess}},i.prototype._createDepthOfFieldPostProcess=function(t,i){var r=this;this.depthOfFieldPostProcess=new e.PostProcess("HDRDepthOfField","standard",["distance"],["otherSampler","depthSampler"],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,"#define DEPTH_OF_FIELD",e.Engine.TEXTURETYPE_UNSIGNED_INT),this.depthOfFieldPostProcess.onApply=function(e){e.setTextureFromPostProcess("otherSampler",r._currentDepthOfFieldSource),e.setTexture("depthSampler",r._getDepthTexture()),e.setFloat("distance",r.depthOfFieldDistance)},this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRDepthOfField",function(){return r.depthOfFieldPostProcess},!0))},i.prototype._createMotionBlurPostProcess=function(t,i){var r=this;this.motionBlurPostProcess=new e.PostProcess("HDRMotionBlur","standard",["inverseViewProjection","prevViewProjection","screenSize","motionScale","motionStrength"],["depthSampler"],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,"#define MOTION_BLUR\n#define MAX_MOTION_SAMPLES "+this.motionBlurSamples.toFixed(1),e.Engine.TEXTURETYPE_UNSIGNED_INT);var n=0,o=e.Matrix.Identity(),s=e.Matrix.Identity(),a=e.Matrix.Identity(),l=e.Vector2.Zero();this.motionBlurPostProcess.onApply=function(e){a=t.getProjectionMatrix().multiply(t.getViewMatrix()),a.invertToRef(s),e.setMatrix("inverseViewProjection",s),e.setMatrix("prevViewProjection",o),o=a,l.x=r.motionBlurPostProcess.width,l.y=r.motionBlurPostProcess.height,e.setVector2("screenSize",l),n=t.getEngine().getFps()/60,e.setFloat("motionScale",n),e.setFloat("motionStrength",r.motionStrength),e.setTexture("depthSampler",r._getDepthTexture())},this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRMotionBlur",function(){return r.motionBlurPostProcess},!0))},i.prototype._getDepthTexture=function(){var e=this._scene.enableGeometryBufferRenderer();return e?e.getGBuffer().textures[0]:this._scene.enableDepthRenderer().getDepthMap()},i.prototype._disposePostProcesses=function(){for(var e=0;e4&&(o.push(e.VertexBuffer.MatricesIndicesExtraKind),o.push(e.VertexBuffer.MatricesWeightsExtraKind)),n.push("#define NUM_BONE_INFLUENCERS "+s.numBoneInfluencers),n.push("#define BonesPerMesh "+(s.skeleton.bones.length+1))):n.push("#define NUM_BONE_INFLUENCERS 0"),i&&(n.push("#define INSTANCES"),o.push("world0"),o.push("world1"),o.push("world2"),o.push("world3"));var a=n.join("\n");return this._cachedDefines!==a&&(this._cachedDefines=a,this._effect=this._scene.getEngine().createEffect("geometry",o,["world","mBones","viewProjection","diffuseMatrix","view"],["diffuseSampler"],a)),this._effect.isReady()},t.prototype.getGBuffer=function(){return this._multiRenderTarget},t.prototype.dispose=function(){this.getGBuffer().dispose()},t.prototype._createRenderTargets=function(){var t=this,i=this._scene.getEngine(),r=this._enablePosition?3:2;if(this._multiRenderTarget=new e.MultiRenderTarget("gBuffer",{width:i.getRenderWidth()*this._ratio,height:i.getRenderHeight()*this._ratio},r,this._scene,{generateMipMaps:!1,generateDepthTexture:!0}),!this.isSupported)return null;this._multiRenderTarget.wrapU=e.Texture.CLAMP_ADDRESSMODE,this._multiRenderTarget.wrapV=e.Texture.CLAMP_ADDRESSMODE,this._multiRenderTarget.refreshRate=1,this._multiRenderTarget.renderParticles=!1,this._multiRenderTarget.renderList=null,this._multiRenderTarget.onClearObservable.add((function(t){t.clear(new e.Color4(0,0,0,1),!0,!0,!0)}));var n=function(i){var r=i.getRenderingMesh(),n=t._scene,o=n.getEngine();o.setState(i.getMaterial().backFaceCulling);var s=r._getInstancesRenderList(i._id);if(!s.mustReturn){var a=o.getCaps().instancedArrays&&null!==s.visibleInstances[i._id];if(t.isReady(i,a)){o.enableEffect(t._effect),r._bind(i,t._effect,e.Material.TriangleFillMode);var l=i.getMaterial();if(t._effect.setMatrix("viewProjection",n.getTransformMatrix()),t._effect.setMatrix("view",n.getViewMatrix()),l&&l.needAlphaTesting()){var h=l.getAlphaTestTexture();t._effect.setTexture("diffuseSampler",h),t._effect.setMatrix("diffuseMatrix",h.getTextureMatrix())}r.useBones&&r.computeBonesUsingShaders&&t._effect.setMatrices("mBones",r.skeleton.getTransformMatrices(r)),r._processRendering(i,t._effect,e.Material.TriangleFillMode,s,a,(function(e,i){return t._effect.setMatrix("world",i)}))}}};this._multiRenderTarget.customRenderFunction=function(e,t){var i;for(i=0;i0&&-1!==this.excludedMeshes.indexOf(e)},i.prototype._createPass=function(t,i){var r=this,n=t.getEngine();this._volumetricLightScatteringRTT=new e.RenderTargetTexture("volumetricLightScatteringMap",{width:n.getRenderWidth()*i,height:n.getRenderHeight()*i},t,!1,!0,e.Engine.TEXTURETYPE_UNSIGNED_INT),this._volumetricLightScatteringRTT.wrapU=e.Texture.CLAMP_ADDRESSMODE,this._volumetricLightScatteringRTT.wrapV=e.Texture.CLAMP_ADDRESSMODE,this._volumetricLightScatteringRTT.renderList=null,this._volumetricLightScatteringRTT.renderParticles=!1,t.customRenderTargets.push(this._volumetricLightScatteringRTT);var o,s=function(t){var i=t.getRenderingMesh();if(!r._meshExcluded(i)){var n=i.getScene(),o=n.getEngine();o.setState(t.getMaterial().backFaceCulling);var s=i._getInstancesRenderList(t._id);if(!s.mustReturn){var a=o.getCaps().instancedArrays&&null!==s.visibleInstances[t._id];if(r.isReady(t,a)){var l=r._volumetricLightScatteringPass;if(i===r.mesh&&(l=t.effect?t.effect:t.getMaterial().getEffect()),o.enableEffect(l),i._bind(t,l,e.Material.TriangleFillMode),i===r.mesh)t.getMaterial().bind(i.getWorldMatrix(),i);else{var h=t.getMaterial();if(r._volumetricLightScatteringPass.setMatrix("viewProjection",n.getTransformMatrix()),h&&h.needAlphaTesting()){var c=h.getAlphaTestTexture();r._volumetricLightScatteringPass.setTexture("diffuseSampler",c),c&&r._volumetricLightScatteringPass.setMatrix("diffuseMatrix",c.getTextureMatrix())}i.useBones&&i.computeBonesUsingShaders&&r._volumetricLightScatteringPass.setMatrices("mBones",i.skeleton.getTransformMatrices(i))}i._processRendering(t,r._volumetricLightScatteringPass,e.Material.TriangleFillMode,s,a,(function(e,t){return l.setMatrix("world",t)}))}}}},a=new e.Color4(0,0,0,1);this._volumetricLightScatteringRTT.onBeforeRenderObservable.add((function(){o=t.clearColor,t.clearColor=a})),this._volumetricLightScatteringRTT.onAfterRenderObservable.add((function(){t.clearColor=o})),this._volumetricLightScatteringRTT.customRenderFunction=function(i,r,n){var o,a=t.getEngine();for(o=0;ot._alphaIndex?1:e._alphaIndext._distanceToCamera?-1:0})),a.setAlphaMode(e.Engine.ALPHA_COMBINE),o=0;o0)return Math.max(n,3)}return Math.max(t,3)},i.prototype._gaussianWeight=function(e){var t=Math.sqrt(2*Math.PI)*(1/3),i=-e*e/(1/3*2*(1/3));return 1/t*Math.exp(i)},i.prototype._glslFloat=function(e,t){return void 0===t&&(t=8),e.toFixed(t).replace(/0+$/,"")},i})(e.PostProcess);e.BlurPostProcess=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o,s){void 0===n&&(n=null);var a=t.call(this,i,r.getScene())||this;return a.name=i,a.children=new Array,a.animations=new Array,a._worldTransform=new e.Matrix,a._absoluteTransform=new e.Matrix,a._invertedAbsoluteTransform=new e.Matrix,a._scaleMatrix=e.Matrix.Identity(),a._scaleVector=e.Vector3.One(),a._negateScaleChildren=e.Vector3.One(),a._scalingDeterminant=1,a._skeleton=r,a._localMatrix=o||e.Matrix.Identity(),a._baseMatrix=a._localMatrix.clone(),a._restPose=s||a._localMatrix.clone(),r.bones.push(a),a.setParent(n,!1),a._updateDifferenceMatrix(),a}return __extends(i,t),Object.defineProperty(i.prototype,"_matrix",{get:function(){return this._localMatrix},set:function(e){this._localMatrix?this._localMatrix.copyFrom(e):this._localMatrix=e},enumerable:!0,configurable:!0}),i.prototype.getSkeleton=function(){return this._skeleton},i.prototype.getParent=function(){return this._parent},i.prototype.setParent=function(e,t){if(void 0===t&&(t=!0),this._parent!==e){if(this._parent){var i=this._parent.children.indexOf(this);-1!==i&&this._parent.children.splice(i)}this._parent=e,this._parent&&this._parent.children.push(this),t&&this._updateDifferenceMatrix()}},i.prototype.getLocalMatrix=function(){return this._localMatrix},i.prototype.getBaseMatrix=function(){return this._baseMatrix},i.prototype.getRestPose=function(){return this._restPose},i.prototype.returnToRest=function(){this.updateMatrix(this._restPose.clone())},i.prototype.getWorldMatrix=function(){return this._worldTransform},i.prototype.getInvertedAbsoluteTransform=function(){return this._invertedAbsoluteTransform},i.prototype.getAbsoluteTransform=function(){return this._absoluteTransform},Object.defineProperty(i.prototype,"position",{get:function(){return this.getPosition()},set:function(e){this.setPosition(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"rotation",{get:function(){return this.getRotation()},set:function(e){this.setRotation(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"rotationQuaternion",{get:function(){return this.getRotationQuaternion()},set:function(e){this.setRotationQuaternion(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"scaling",{get:function(){return this.getScale()},set:function(e){this.setScale(e.x,e.y,e.z)},enumerable:!0,configurable:!0}),i.prototype.updateMatrix=function(e,t){void 0===t&&(t=!0),this._baseMatrix=e.clone(),this._localMatrix=e.clone(),this._skeleton._markAsDirty(),t&&this._updateDifferenceMatrix()},i.prototype._updateDifferenceMatrix=function(e){e||(e=this._baseMatrix),this._parent?e.multiplyToRef(this._parent._absoluteTransform,this._absoluteTransform):this._absoluteTransform.copyFrom(e),this._absoluteTransform.invertToRef(this._invertedAbsoluteTransform);for(var t=0;t=c&&a.frame<=u&&(n?(h=a.value.clone(),m?(l=h.getTranslation(),h.setTranslation(l.scaleInPlace(g))):v?(l=h.getTranslation(),h.setTranslation(l.multiplyInPlace(o))):h=a.value):h=a.value,y.push({frame:a.frame+r,value:h}));return this.animations[0].createRange(i,c+r,u+r),!0},i.prototype.translate=function(t,r,n){void 0===r&&(r=e.Space.LOCAL);var o=this.getLocalMatrix();if(r==e.Space.LOCAL)o.m[12]+=t.x,o.m[13]+=t.y,o.m[14]+=t.z;else{var s;n&&(s=n.getWorldMatrix()),this._skeleton.computeAbsoluteTransforms();var a=i._tmpMats[0],l=i._tmpVecs[0];n?(a.copyFrom(this._parent.getAbsoluteTransform()),a.multiplyToRef(s,a)):a.copyFrom(this._parent.getAbsoluteTransform()),a.m[12]=0,a.m[13]=0,a.m[14]=0,a.invert(),e.Vector3.TransformCoordinatesToRef(t,a,l),o.m[12]+=l.x,o.m[13]+=l.y,o.m[14]+=l.z}this.markAsDirty()},i.prototype.setPosition=function(t,r,n){void 0===r&&(r=e.Space.LOCAL);var o=this.getLocalMatrix();if(r==e.Space.LOCAL)o.m[12]=t.x,o.m[13]=t.y,o.m[14]=t.z;else{var s;n&&(s=n.getWorldMatrix()),this._skeleton.computeAbsoluteTransforms();var a=i._tmpMats[0],l=i._tmpVecs[0];n?(a.copyFrom(this._parent.getAbsoluteTransform()),a.multiplyToRef(s,a)):a.copyFrom(this._parent.getAbsoluteTransform()),a.invert(),e.Vector3.TransformCoordinatesToRef(t,a,l),o.m[12]=l.x,o.m[13]=l.y,o.m[14]=l.z}this.markAsDirty()},i.prototype.setAbsolutePosition=function(t,i){this.setPosition(t,e.Space.WORLD,i)},i.prototype.setScale=function(e,t,i,r){void 0===r&&(r=!1),this.animations[0]&&!this.animations[0].isStopped()&&(r||(this._negateScaleChildren.x=1/e,this._negateScaleChildren.y=1/t,this._negateScaleChildren.z=1/i),this._syncScaleVector()),this.scale(e/this._scaleVector.x,t/this._scaleVector.y,i/this._scaleVector.z,r)},i.prototype.scale=function(t,r,n,o){void 0===o&&(o=!1);var s=this.getLocalMatrix(),a=i._tmpMats[0];a.copyFrom(s);var l=i._tmpMats[1];l.copyFrom(a),l.invert();var h=i._tmpMats[2];e.Matrix.FromValuesToRef(t,0,0,0,0,r,0,0,0,0,n,0,0,0,0,1,h),this._scaleMatrix.multiplyToRef(h,this._scaleMatrix),this._scaleVector.x*=t,this._scaleVector.y*=r,this._scaleVector.z*=n,s.multiplyToRef(l,s),s.multiplyToRef(h,s),s.multiplyToRef(a,s);var c=this.getParent();c?s.multiplyToRef(c.getAbsoluteTransform(),this.getAbsoluteTransform()):this.getAbsoluteTransform().copyFrom(s);var u=this.children.length;h.invert();for(var f=0;f0&&(this._rightHandedSystem=!0,this._bendAxis.x=0,this._bendAxis.y=0,this._bendAxis.z=-1,n.x>n.y&&n.x>n.z&&(this._adjustRoll=.5*Math.PI,this._bendAxis.z=1)),this._bone1.length){var o=this._bone1.getScale(),s=this._bone2.getScale();this._bone1Length=this._bone1.length*o.y*this.mesh.scaling.y,this._bone2Length=this._bone2.length*s.y*this.mesh.scaling.y}else if(this._bone1.children[0]){t.computeWorldMatrix(!0);var a=this._bone2.children[0].getAbsolutePosition(t),l=this._bone2.getAbsolutePosition(t),h=this._bone1.getAbsolutePosition(t);this._bone1Length=e.Vector3.Distance(a,l),this._bone2Length=e.Vector3.Distance(l,h)}this._bone1.getRotationMatrixToRef(e.Space.WORLD,t,this._bone1Mat),this.maxAngle=Math.PI,r&&(r.targetMesh&&(this.targetMesh=r.targetMesh,this.targetMesh.computeWorldMatrix(!0)),r.poleTargetMesh?(this.poleTargetMesh=r.poleTargetMesh,this.poleTargetMesh.computeWorldMatrix(!0)):r.poleTargetBone?this.poleTargetBone=r.poleTargetBone:this._bone1.getParent()&&(this.poleTargetBone=this._bone1.getParent()),r.poleTargetLocalOffset&&this.poleTargetLocalOffset.copyFrom(r.poleTargetLocalOffset),r.poleAngle&&(this.poleAngle=r.poleAngle),r.bendAxis&&this._bendAxis.copyFrom(r.bendAxis),r.maxAngle&&(this.maxAngle=r.maxAngle),r.slerpAmount&&(this.slerpAmount=r.slerpAmount))}return Object.defineProperty(t.prototype,"maxAngle",{get:function(){return this._maxAngle},set:function(e){this._setMaxAngle(e)},enumerable:!0,configurable:!0}),t.prototype._setMaxAngle=function(e){e<0&&(e=0),(e>Math.PI||void 0==e)&&(e=Math.PI),this._maxAngle=e;var t=this._bone1Length,i=this._bone2Length;this._maxReach=Math.sqrt(t*t+i*i-2*t*i*Math.cos(e))},t.prototype.update=function(){var i=this._bone1,r=this.targetPosition,n=this.poleTargetPosition,o=t._tmpMats[0],s=t._tmpMats[1];this.targetMesh&&r.copyFrom(this.targetMesh.getAbsolutePosition()),this.poleTargetBone?this.poleTargetBone.getAbsolutePositionFromLocalToRef(this.poleTargetLocalOffset,this.mesh,n):this.poleTargetMesh&&e.Vector3.TransformCoordinatesToRef(this.poleTargetLocalOffset,this.poleTargetMesh.getWorldMatrix(),n);var a=t._tmpVecs[0],l=t._tmpVecs[1],h=t._tmpVecs[2],c=t._tmpVecs[3],u=t._tmpVecs[4],f=t._tmpQuat;i.getAbsolutePositionToRef(this.mesh,a),n.subtractToRef(a,u),0==u.x&&0==u.y&&0==u.z?u.y=1:u.normalize(),r.subtractToRef(a,c),c.normalize(),e.Vector3.CrossToRef(c,u,l),l.normalize(),e.Vector3.CrossToRef(c,l,h),h.normalize(),e.Matrix.FromXYZAxesToRef(h,c,l,o);var d=this._bone1Length,p=this._bone2Length,_=e.Vector3.Distance(a,r);this._maxReach>0&&(_=Math.min(this._maxReach,_));var m=(p*p+_*_-d*d)/(2*p*_),g=(_*_+d*d-p*p)/(2*_*d);m>1&&(m=1),g>1&&(g=1),m<-1&&(m=-1),g<-1&&(g=-1);var v=Math.acos(m),y=Math.acos(g),x=-v-y;if(this._rightHandedSystem)e.Matrix.RotationYawPitchRollToRef(0,0,this._adjustRoll,s),s.multiplyToRef(o,o),e.Matrix.RotationAxisToRef(this._bendAxis,y,s),s.multiplyToRef(o,o);else{ -var b=t._tmpVecs[5];b.copyFrom(this._bendAxis),b.x*=-1,e.Matrix.RotationAxisToRef(b,-y,s),s.multiplyToRef(o,o)}this.poleAngle&&(e.Matrix.RotationAxisToRef(c,this.poleAngle,s),o.multiplyToRef(s,o)),this.slerpAmount<1?(this._slerping||e.Quaternion.FromRotationMatrixToRef(this._bone1Mat,this._bone1Quat),e.Quaternion.FromRotationMatrixToRef(o,f),e.Quaternion.SlerpToRef(this._bone1Quat,f,this.slerpAmount,this._bone1Quat),x=this._bone2Ang*(1-this.slerpAmount)+x*this.slerpAmount,this._bone1.setRotationQuaternion(this._bone1Quat,e.Space.WORLD,this.mesh),this._slerping=!0):(this._bone1.setRotationMatrix(o,e.Space.WORLD,this.mesh),this._bone1Mat.copyFrom(o),this._slerping=!1),this._bone2.setAxisAngle(this._bendAxis,x,e.Space.LOCAL),this._bone2Ang=x},t})();t._tmpVecs=[e.Vector3.Zero(),e.Vector3.Zero(),e.Vector3.Zero(),e.Vector3.Zero(),e.Vector3.Zero(),e.Vector3.Zero()],t._tmpQuat=e.Quaternion.Identity(),t._tmpMats=[e.Matrix.Identity(),e.Matrix.Identity()],e.BoneIKController=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t,i,r,n){if(this.upAxis=e.Vector3.Up(),this.upAxisSpace=e.Space.LOCAL,this.adjustYaw=0,this.adjustPitch=0,this.adjustRoll=0,this.slerpAmount=1,this._boneQuat=e.Quaternion.Identity(),this._slerping=!1,this._firstFrameSkipped=!1,this._fowardAxis=e.Vector3.Forward(),this.mesh=t,this.bone=i,this.target=r,n&&(n.adjustYaw&&(this.adjustYaw=n.adjustYaw),n.adjustPitch&&(this.adjustPitch=n.adjustPitch),n.adjustRoll&&(this.adjustRoll=n.adjustRoll),null!=n.maxYaw?this.maxYaw=n.maxYaw:this.maxYaw=Math.PI,null!=n.minYaw?this.minYaw=n.minYaw:this.minYaw=-Math.PI,null!=n.maxPitch?this.maxPitch=n.maxPitch:this.maxPitch=Math.PI,null!=n.minPitch?this.minPitch=n.minPitch:this.minPitch=-Math.PI,null!=n.slerpAmount&&(this.slerpAmount=n.slerpAmount),null!=n.upAxis&&(this.upAxis=n.upAxis),null!=n.upAxisSpace&&(this.upAxisSpace=n.upAxisSpace),null!=n.yawAxis||null!=n.pitchAxis)){var o=e.Axis.Y,s=e.Axis.X;null!=n.yawAxis&&(o=n.yawAxis.clone(),o.normalize()),null!=n.pitchAxis&&(s=n.pitchAxis.clone(),s.normalize());var a=e.Vector3.Cross(s,o);this._transformYawPitch=e.Matrix.Identity(),e.Matrix.FromXYZAxesToRef(s,o,a,this._transformYawPitch),this._transformYawPitchInv=this._transformYawPitch.clone(),this._transformYawPitch.invert()}i.getParent()||this.upAxisSpace!=e.Space.BONE||(this.upAxisSpace=e.Space.LOCAL)}return Object.defineProperty(t.prototype,"minYaw",{get:function(){return this._minYaw},set:function(e){this._minYaw=e,this._minYawSin=Math.sin(e),this._minYawCos=Math.cos(e),null!=this._maxYaw&&(this._midYawConstraint=.5*this._getAngleDiff(this._minYaw,this._maxYaw)+this._minYaw,this._yawRange=this._maxYaw-this._minYaw)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"maxYaw",{get:function(){return this._maxYaw},set:function(e){this._maxYaw=e,this._maxYawSin=Math.sin(e),this._maxYawCos=Math.cos(e),null!=this._minYaw&&(this._midYawConstraint=.5*this._getAngleDiff(this._minYaw,this._maxYaw)+this._minYaw,this._yawRange=this._maxYaw-this._minYaw)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"minPitch",{get:function(){return this._minPitch},set:function(e){this._minPitch=e,this._minPitchTan=Math.tan(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"maxPitch",{get:function(){return this._maxPitch},set:function(e){this._maxPitch=e,this._maxPitchTan=Math.tan(e)},enumerable:!0,configurable:!0}),t.prototype.update=function(){if(this.slerpAmount<1&&!this._firstFrameSkipped)return void(this._firstFrameSkipped=!0);var i=this.bone,r=t._tmpVecs[0];i.getAbsolutePositionToRef(this.mesh,r);var n=this.target,o=t._tmpMats[0],s=t._tmpMats[1],a=this.mesh,l=i.getParent(),h=t._tmpVecs[1];h.copyFrom(this.upAxis),this.upAxisSpace==e.Space.BONE?(this._transformYawPitch&&e.Vector3.TransformCoordinatesToRef(h,this._transformYawPitchInv,h),l.getDirectionToRef(h,this.mesh,h)):this.upAxisSpace==e.Space.LOCAL&&(a.getDirectionToRef(h,h),1==a.scaling.x&&1==a.scaling.y&&1==a.scaling.z||h.normalize());var c=!1,u=!1;if(this._maxYaw==Math.PI&&this._minYaw==-Math.PI||(c=!0),this._maxPitch==Math.PI&&this._minPitch==-Math.PI||(u=!0),c||u){var f=t._tmpMats[2],d=t._tmpMats[3];if(this.upAxisSpace==e.Space.BONE&&1==h.y)l.getRotationMatrixToRef(e.Space.WORLD,this.mesh,f);else if(this.upAxisSpace!=e.Space.LOCAL||1!=h.y||l){var p=t._tmpVecs[2];p.copyFrom(this._fowardAxis),this._transformYawPitch&&e.Vector3.TransformCoordinatesToRef(p,this._transformYawPitchInv,p),l?l.getDirectionToRef(p,this.mesh,p):a.getDirectionToRef(p,p);var _=e.Vector3.Cross(h,p);_.normalize();var p=e.Vector3.Cross(_,h);e.Matrix.FromXYZAxesToRef(_,h,p,f)}else f.copyFrom(a.getWorldMatrix());f.invertToRef(d);var m;if(u){var g=t._tmpVecs[3];n.subtractToRef(r,g),e.Vector3.TransformCoordinatesToRef(g,d,g);var m=Math.sqrt(g.x*g.x+g.z*g.z),v=Math.atan2(g.y,m),y=v;v>this._maxPitch?(g.y=this._maxPitchTan*m,y=this._maxPitch):vthis._maxYaw||xMath.PI?this._isAngleBetween(x,this._maxYaw,this._midYawConstraint)?(g.z=this._maxYawCos*m,g.x=this._maxYawSin*m,b=this._maxYaw):this._isAngleBetween(x,this._midYawConstraint,this._minYaw)&&(g.z=this._minYawCos*m,g.x=this._minYawSin*m,b=this._minYaw):x>this._maxYaw?(g.z=this._maxYawCos*m,g.x=this._maxYawSin*m,b=this._maxYaw):xMath.PI){var A=t._tmpVecs[8];A.copyFrom(e.Axis.Z),this._transformYawPitch&&e.Vector3.TransformCoordinatesToRef(A,this._transformYawPitchInv,A);var T=e.BoneLookController._tmpMats[4];this._boneQuat.toRotationMatrix(T),this.mesh.getWorldMatrix().multiplyToRef(T,T),e.Vector3.TransformCoordinatesToRef(A,T,A),e.Vector3.TransformCoordinatesToRef(A,d,A);var E=Math.atan2(A.x,A.z);if(this._getAngleBetween(E,x)>this._getAngleBetween(E,this._midYawConstraint)){null==m&&(m=Math.sqrt(g.x*g.x+g.z*g.z));var P=this._getAngleBetween(E,this._maxYaw);this._getAngleBetween(E,this._minYaw)Math.PI?i-=2*Math.PI:i<-Math.PI&&(i+=2*Math.PI),i},t.prototype._getAngleBetween=function(e,t){e%=2*Math.PI,e=e<0?e+2*Math.PI:e,t%=2*Math.PI,t=t<0?t+2*Math.PI:t;var i=0;return i=eMath.PI&&(i=2*Math.PI-i),i},t.prototype._isAngleBetween=function(e,t,i){if(e%=2*Math.PI,e=e<0?e+2*Math.PI:e,t%=2*Math.PI,t=t<0?t+2*Math.PI:t,i%=2*Math.PI,i=i<0?i+2*Math.PI:i,tt&&ei&&e-1&&this._meshesWithPoseMatrix.splice(t,1)},t.prototype._computeTransformMatrices=function(e,t){this.onBeforeComputeObservable.notifyObservers(this);for(var i=0;i0&&(r.animation=i.animations[0].serialize()),e.ranges=[];for(var n in this._ranges){var o={};o.name=n,o.from=this._ranges[n].from,o.to=this._ranges[n].to,e.ranges.push(o)}}return e},t.Parse=function(i,r){var n=new t(i.name,i.id,r);i.dimensionsAtRest&&(n.dimensionsAtRest=e.Vector3.FromArray(i.dimensionsAtRest)),n.needInitialSkinMatrix=i.needInitialSkinMatrix;var o;for(o=0;o-1&&(a=n.bones[s.parentBoneIndex]);var l=s.rest?e.Matrix.FromArray(s.rest):null,h=new e.Bone(s.name,n,a,e.Matrix.FromArray(s.matrix),l);s.length&&(h.length=s.length),s.animation&&h.animations.push(e.Animation.Parse(s.animation))}if(i.ranges)for(o=0;o0&&(e=this._meshesWithPoseMatrix[0].getPoseMatrix()),e},t})();e.Skeleton=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this.x=e.Vector3.Zero(),this.y=e.Vector3.Zero(),this.z=e.Vector3.Zero(),this.xx=e.Vector3.Zero(),this.yy=e.Vector3.Zero(),this.zz=e.Vector3.Zero(),this.xy=e.Vector3.Zero(),this.yz=e.Vector3.Zero(),this.zx=e.Vector3.Zero()}return t.prototype.addAmbient=function(t){var i=new e.Vector3(t.r,t.g,t.b);this.xx=this.xx.add(i),this.yy=this.yy.add(i),this.zz=this.zz.add(i)},t.getSphericalPolynomialFromHarmonics=function(e){var i=new t;return i.x=e.L11.scale(1.02333),i.y=e.L1_1.scale(1.02333),i.z=e.L10.scale(1.02333),i.xx=e.L00.scale(.886277).subtract(e.L20.scale(.247708)).add(e.L22.scale(.429043)),i.yy=e.L00.scale(.886277).subtract(e.L20.scale(.247708)).subtract(e.L22.scale(.429043)),i.zz=e.L00.scale(.886277).add(e.L20.scale(.495417)),i.yz=e.L2_1.scale(.858086),i.zx=e.L21.scale(.858086),i.xy=e.L2_2.scale(.858086),i.scale(1/Math.PI),i},t.prototype.scale=function(e){this.x=this.x.scale(e),this.y=this.y.scale(e),this.z=this.z.scale(e),this.xx=this.xx.scale(e),this.yy=this.yy.scale(e),this.zz=this.zz.scale(e),this.yz=this.yz.scale(e),this.zx=this.zx.scale(e),this.xy=this.xy.scale(e)},t})();e.SphericalPolynomial=t;var i=(function(){function t(){this.L00=e.Vector3.Zero(),this.L1_1=e.Vector3.Zero(),this.L10=e.Vector3.Zero(),this.L11=e.Vector3.Zero(),this.L2_2=e.Vector3.Zero(),this.L2_1=e.Vector3.Zero(),this.L20=e.Vector3.Zero(),this.L21=e.Vector3.Zero(),this.L22=e.Vector3.Zero()}return t.prototype.addLight=function(t,i,r){var n=new e.Vector3(i.r,i.g,i.b),o=n.scale(r);this.L00=this.L00.add(o.scale(.282095)),this.L1_1=this.L1_1.add(o.scale(.488603*t.y)),this.L10=this.L10.add(o.scale(.488603*t.z)),this.L11=this.L11.add(o.scale(.488603*t.x)),this.L2_2=this.L2_2.add(o.scale(1.092548*t.x*t.y)),this.L2_1=this.L2_1.add(o.scale(1.092548*t.y*t.z)),this.L21=this.L21.add(o.scale(1.092548*t.x*t.z)),this.L20=this.L20.add(o.scale(.315392*(3*t.z*t.z-1))),this.L22=this.L22.add(o.scale(.546274*(t.x*t.x-t.y*t.y)))},t.prototype.scale=function(e){this.L00=this.L00.scale(e),this.L1_1=this.L1_1.scale(e),this.L10=this.L10.scale(e),this.L11=this.L11.scale(e),this.L2_2=this.L2_2.scale(e),this.L2_1=this.L2_1.scale(e),this.L20=this.L20.scale(e),this.L21=this.L21.scale(e),this.L22=this.L22.scale(e)},t.prototype.convertIncidentRadianceToIrradiance=function(){this.L00=this.L00.scale(3.141593),this.L1_1=this.L1_1.scale(2.094395),this.L10=this.L10.scale(2.094395),this.L11=this.L11.scale(2.094395),this.L2_2=this.L2_2.scale(.785398),this.L2_1=this.L2_1.scale(.785398),this.L20=this.L20.scale(.785398),this.L21=this.L21.scale(.785398),this.L22=this.L22.scale(.785398)},t.prototype.convertIrradianceToLambertianRadiance=function(){this.scale(1/Math.PI)},t.getsphericalHarmonicsFromPolynomial=function(e){var i=new t;return i.L00=e.xx.scale(.376127).add(e.yy.scale(.376127)).add(e.zz.scale(.376126)),i.L1_1=e.y.scale(.977204),i.L10=e.z.scale(.977204),i.L11=e.x.scale(.977204),i.L2_2=e.xy.scale(1.16538),i.L2_1=e.yz.scale(1.16538),i.L20=e.zz.scale(1.34567).subtract(e.xx.scale(.672834)).subtract(e.yy.scale(.672834)),i.L21=e.zx.scale(1.16538),i.L22=e.xx.scale(1.16538).subtract(e.yy.scale(1.16538)),i.scale(Math.PI),i},t})();e.SphericalHarmonics=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){var i=(function(){function e(e,t,i,r){this.name=e,this.worldAxisForNormal=t,this.worldAxisForFileX=i,this.worldAxisForFileY=r}return e})(),r=(function(){function t(){}return t.ConvertCubeMapTextureToSphericalPolynomial=function(t){if(!t.isCube)return null;var i,r,n=t.getSize().width,o=t.readPixels(0),s=t.readPixels(1);t.isRenderTarget?(i=t.readPixels(3),r=t.readPixels(2)):(i=t.readPixels(2),r=t.readPixels(3));var a=t.readPixels(4),l=t.readPixels(5),h=t.gammaSpace,c=e.Engine.TEXTUREFORMAT_RGBA,u=e.Engine.TEXTURETYPE_UNSIGNED_INT;t.textureType&&t.textureType!==e.Engine.TEXTURETYPE_UNSIGNED_INT&&(u=e.Engine.TEXTURETYPE_FLOAT);var f={size:n,right:o,left:s,up:i,down:r,front:a,back:l,format:c,type:u,gammaSpace:h};return this.ConvertCubeMapToSphericalPolynomial(f)},t.ConvertCubeMapToSphericalPolynomial=function(t){for(var i=new e.SphericalHarmonics,r=0,n=2/t.size,o=n,s=.5*n-1,a=0;a<6;a++)for(var l=this.FileFaces[a],h=t[l.name],c=s,u=t.format===e.Engine.TEXTUREFORMAT_RGBA?4:3,f=0;fMath.PI;)n-=2*Math.PI;var s=n/Math.PI,a=o/Math.PI;s=.5*s+.5;var l=Math.round(s*i);l<0?l=0:l>=i&&(l=i-1);var h=Math.round(a*r);h<0?h=0:h>=r&&(h=r-1);var c=r-h-1;return{r:t[c*i*3+3*l+0],g:t[c*i*3+3*l+1],b:t[c*i*3+3*l+2]}},t})();i.FACE_FRONT=[new e.Vector3(-1,-1,-1),new e.Vector3(1,-1,-1),new e.Vector3(-1,1,-1),new e.Vector3(1,1,-1)],i.FACE_BACK=[new e.Vector3(1,-1,1),new e.Vector3(-1,-1,1),new e.Vector3(1,1,1),new e.Vector3(-1,1,1)],i.FACE_RIGHT=[new e.Vector3(1,-1,-1),new e.Vector3(1,-1,1),new e.Vector3(1,1,-1),new e.Vector3(1,1,1)],i.FACE_LEFT=[new e.Vector3(-1,-1,1),new e.Vector3(-1,-1,-1),new e.Vector3(-1,1,1),new e.Vector3(-1,1,-1)],i.FACE_DOWN=[new e.Vector3(-1,1,-1),new e.Vector3(1,1,-1),new e.Vector3(-1,1,1),new e.Vector3(1,1,1)],i.FACE_UP=[new e.Vector3(-1,-1,1),new e.Vector3(1,-1,1),new e.Vector3(-1,-1,-1),new e.Vector3(1,-1,-1)],t.PanoramaToCubeMapTools=i})(e.Internals||(e.Internals={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(e){var t=(function(){function t(){}return t.Ldexp=function(e,t){return t>1023?e*Math.pow(2,1023)*Math.pow(2,t-1023):t<-1074?e*Math.pow(2,-1074)*Math.pow(2,t+1074):e*Math.pow(2,t)},t.Rgbe2float=function(e,t,i,r,n,o){n>0?(n=this.Ldexp(1,n-136),e[o+0]=t*n,e[o+1]=i*n,e[o+2]=r*n):(e[o+0]=0,e[o+1]=0,e[o+2]=0)},t.readStringLine=function(e,t){for(var i="",r="",n=t;n32767)throw"HDR Bad header format, unsupported size";return s+=r.length+1,{height:t,width:i,dataPosition:s}},t.GetCubeMapTextureData=function(t,i){var r=new Uint8Array(t),n=this.RGBE_ReadHeader(r),o=this.RGBE_ReadPixels_RLE(r,n);return e.PanoramaToCubeMapTools.ConvertPanoramaToCubemap(o,n.width,n.height,i)},t.RGBE_ReadPixels=function(e,t){return this.RGBE_ReadPixels_RLE(e,t)},t.RGBE_ReadPixels_RLE=function(e,t){for(var i,r,n,o,s,a=t.height,l=t.width,h=t.dataPosition,c=0,u=0,f=0,d=new ArrayBuffer(4*l),p=new Uint8Array(d),_=new ArrayBuffer(t.width*t.height*4*3),m=new Float32Array(_);a>0;){if(i=e[h++],r=e[h++],n=e[h++],o=e[h++],2!=i||2!=r||128&n)throw"HDR Bad header format, not RLE";if((n<<8|o)!=l)throw"HDR Bad header format, wrong scan line width";for(c=0,f=0;f<4;f++)for(u=(f+1)*l;c128){if(0==(s=i-128)||s>u-c)throw"HDR Bad Format, bad scanline data (run)";for(;s-- >0;)p[c++]=r}else{if(0==(s=i)||s>u-c)throw"HDR Bad Format, bad scanline data (non-run)";if(p[c++]=r,--s>0)for(var g=0;g>s,2),l=0;l<6;l++){var h=r.subarray(o,o+a);n[s].push(h),o+=a}}return n}:null,o=function(o){var s=new Int32Array(o);r=new Float32Array(o);var a=s[0];t._size=s[1],t.getScene().getEngine().updateTextureSize(t._texture,t._size,t._size);var l=new e.SphericalPolynomial;l.x.copyFromFloats(r[2],r[3],r[4]),l.y.copyFromFloats(r[5],r[6],r[7]),l.z.copyFromFloats(r[8],r[9],r[10]),l.xx.copyFromFloats(r[11],r[12],r[13]),l.yy.copyFromFloats(r[14],r[15],r[16]),l.zz.copyFromFloats(r[17],r[18],r[19]),l.xy.copyFromFloats(r[20],r[21],r[22]),l.yz.copyFromFloats(r[23],r[24],r[25]),l.zx.copyFromFloats(r[26],r[27],r[28]),t.sphericalPolynomial=l,i=s[29];for(var h=30,c=[],u=3*Math.pow(t._size,2),f=0;f<6;f++)c.push(r.subarray(h,h+u)),h+=u;for(var d=[],p=null,_=0;_<6;_++){var m=null;if(1===a){m=c[[0,2,4,1,3,5][_]]}if(!n){if(!t.getScene().getEngine().getCaps().textureFloat){var g=new ArrayBuffer(u);p=new Uint8Array(g)}for(var v=0;v255){var T=255/A;y*=T,x*=T,b*=T}p[3*v+0]=y,p[3*v+1]=x,p[3*v+2]=b}}p?d.push(p):d.push(m)}return d};this._texture=this.getScene().getEngine().createRawCubeTextureFromUrl(this.url,this.getScene(),this._size,e.Engine.TEXTUREFORMAT_RGB,this.getScene().getEngine().getCaps().textureFloat?e.Engine.TEXTURETYPE_FLOAT:e.Engine.TEXTURETYPE_UNSIGNED_INT,this._noMipmap,o,n,this._onLoad,this._onError)},i.prototype.loadHDRTexture=function(){var t=this,r=function(r){var n=e.Internals.HDRTools.GetCubeMapTextureData(r,t._size);if(t._generateHarmonics){var o=e.Internals.CubeMapToSphericalPolynomialTools.ConvertCubeMapToSphericalPolynomial(n);t.sphericalPolynomial=o}for(var s=[],a=null,l=0;l<6;l++){if(!t.getScene().getEngine().getCaps().textureFloat){var h=new ArrayBuffer(t._size*t._size*3);a=new Uint8Array(h)}var c=n[i._facesMapping[l]];if(t._useInGammaSpace||a)for(var u=0;u255){var m=255/_;f*=m,d*=m,p*=m}a[3*u+0]=f,a[3*u+1]=d,a[3*u+2]=p}a?s.push(a):s.push(c)}return s};this._texture=this.getScene().getEngine().createRawCubeTextureFromUrl(this.url,this.getScene(),this._size,e.Engine.TEXTUREFORMAT_RGB,this.getScene().getEngine().getCaps().textureFloat?e.Engine.TEXTURETYPE_FLOAT:e.Engine.TEXTURETYPE_UNSIGNED_INT,this._noMipmap,r,null,this._onLoad,this._onError)},i.prototype.loadTexture=function(){this._isBABYLONPreprocessed?this.loadBabylonTexture():this.loadHDRTexture()},i.prototype.clone=function(){var e=this._isBABYLONPreprocessed?null:this._size,t=new i(this.url,this.getScene(),e,this._noMipmap,this._generateHarmonics,this._useInGammaSpace,this._usePMREMGenerator);return t.level=this.level,t.wrapU=this.wrapU,t.wrapV=this.wrapV,t.coordinatesIndex=this.coordinatesIndex,t.coordinatesMode=this.coordinatesMode,t},i.prototype.delayLoad=function(){this.delayLoadState===e.Engine.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=e.Engine.DELAYLOADSTATE_LOADED,this._texture=this._getFromCache(this.url,this._noMipmap),this._texture||this.loadTexture())},i.prototype.getReflectionTextureMatrix=function(){return this._textureMatrix},i.prototype.setReflectionTextureMatrix=function(e){this._textureMatrix=e},i.Parse=function(t,i,r){var n=null;if(t.name&&!t.isRenderTarget){var o=t.isBABYLONPreprocessed?null:t.size;n=new e.HDRCubeTexture(r+t.name,i,o,t.noMipmap,t.generateHarmonics,t.useInGammaSpace,t.usePMREMGenerator),n.name=t.name,n.hasAlpha=t.hasAlpha,n.level=t.level,n.coordinatesMode=t.coordinatesMode,n.isBlocking=t.isBlocking}return n},i.prototype.serialize=function(){if(!this.name)return null;var e={};return e.name=this.name,e.hasAlpha=this.hasAlpha,e.isCube=!0,e.level=this.level,e.size=this._size,e.coordinatesMode=this.coordinatesMode,e.useInGammaSpace=this._useInGammaSpace,e.generateHarmonics=this._generateHarmonics,e.usePMREMGenerator=this._usePMREMGenerator,e.isBABYLONPreprocessed=this._isBABYLONPreprocessed,e.customType="BABYLON.HDRCubeTexture",e.noMipmap=this._noMipmap,e.isBlocking=this._isBlocking,e},i.generateBabylonHDROnDisk=function(e,t,r){void 0===r&&(r=null);var n=function(e){var t=new Blob([e],{type:"application/octet-stream"}),i=window.URL.createObjectURL(t),r=document.createElement("a");document.body.appendChild(r),r.style.display="none",r.href=i,r.download="envmap.babylon.hdr",r.click()};i.generateBabylonHDR(e,t,n,r)},i.generateBabylonHDR=function(t,i,r,n){return void 0===n&&(n=null),t&&e.Tools.IsExponentOfTwo(i)?(e.Tools.Error("Generation of Babylon HDR is coming back in 3.1."),null):null},i})(e.BaseTexture) -;t._facesMapping=["right","left","up","down","front","back"],e.HDRCubeTexture=t})(BABYLON||(BABYLON={}));var Earcut;!(function(e){function t(e,t,r){r=r||2;var o=t&&t.length,s=o?t[0]*r:e.length,a=i(e,0,s,r,!0),l=[];if(!a)return l;var c,u,f,d,p,_,m;if(o&&(a=h(e,t,a,r)),e.length>80*r){c=f=e[0],u=d=e[1];for(var g=r;gf&&(f=p),_>d&&(d=_);m=Math.max(f-c,d-u)}return n(a,l,r,c,u,m,void 0),l}function i(e,t,i,r,n){var o,s;if(n===O(e,t,i,r)>0)for(o=t;o=t;o-=r)s=M(o,e[o],e[o+1],s);return s&&x(s,s.next)&&(S(s),s=s.next),s}function r(e,t){if(!e)return e;t||(t=e);var i,r=e;do{if(i=!1,r.steiner||!x(r,r.next)&&0!==y(r.prev,r,r.next))r=r.next;else{if(S(r),(r=t=r.prev)===r.next)return null;i=!0}}while(i||r!==t);return t}function n(e,t,i,h,c,u,f){if(e){!f&&u&&d(e,h,c,u);for(var p,_,m=e;e.prev!==e.next;)if(p=e.prev,_=e.next,u?s(e,h,c,u):o(e))t.push(p.i/i),t.push(e.i/i),t.push(_.i/i),S(e),e=_.next,m=_.next;else if((e=_)===m){f?1===f?(e=a(e,t,i),n(e,t,i,h,c,u,2)):2===f&&l(e,t,i,h,c,u):n(r(e,void 0),t,i,h,c,u,1);break}}}function o(e){var t=e.prev,i=e,r=e.next;if(y(t,i,r)>=0)return!1;for(var n=e.next.next;n!==e.prev;){if(g(t.x,t.y,i.x,i.y,r.x,r.y,n.x,n.y)&&y(n.prev,n,n.next)>=0)return!1;n=n.next}return!0}function s(e,t,i,r){var n=e.prev,o=e,s=e.next;if(y(n,o,s)>=0)return!1;for(var a=n.xo.x?n.x>s.x?n.x:s.x:o.x>s.x?o.x:s.x,c=n.y>o.y?n.y>s.y?n.y:s.y:o.y>s.y?o.y:s.y,u=_(a,l,t,i,r),f=_(h,c,t,i,r),d=e.nextZ;d&&d.z<=f;){if(d!==e.prev&&d!==e.next&&g(n.x,n.y,o.x,o.y,s.x,s.y,d.x,d.y)&&y(d.prev,d,d.next)>=0)return!1;d=d.nextZ}for(d=e.prevZ;d&&d.z>=u;){if(d!==e.prev&&d!==e.next&&g(n.x,n.y,o.x,o.y,s.x,s.y,d.x,d.y)&&y(d.prev,d,d.next)>=0)return!1;d=d.prevZ}return!0}function a(e,t,i){var r=e;do{var n=r.prev,o=r.next.next;!x(n,o)&&b(n,r,r.next,o)&&T(n,o)&&T(o,n)&&(t.push(n.i/i),t.push(r.i/i),t.push(o.i/i),S(r),S(r.next),r=e=o),r=r.next}while(r!==e);return r}function l(e,t,i,o,s,a){var l=e;do{for(var h=l.next.next;h!==l.prev;){if(l.i!==h.i&&v(l,h)){var c=P(l,h);return l=r(l,l.next),c=r(c,c.next),n(l,t,i,o,s,a,void 0),void n(c,t,i,o,s,a,void 0)}h=h.next}l=l.next}while(l!==e)}function h(e,t,n,o){var s,a,l,h,f,d=[];for(s=0,a=t.length;s=r.next.y){var a=r.x+(o-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(a<=n&&a>s){if(s=a,a===n){if(o===r.y)return r;if(o===r.next.y)return r.next}i=r.x=r.x&&r.x>=c&&g(oi.x)&&T(r,e)&&(i=r,f=l),r=r.next;return i}function d(e,t,i,r){var n=e;do{null===n.z&&(n.z=_(n.x,n.y,t,i,r)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next}while(n!==e);n.prevZ.nextZ=null,n.prevZ=null,p(n)}function p(e){var t,i,r,n,o,s,a,l,h=1;do{for(i=e,e=null,o=null,s=0;i;){for(s++,r=i,a=0,t=0;t0||l>0&&r;)0===a?(n=r,r=r.nextZ,l--):0!==l&&r?i.z<=r.z?(n=i,i=i.nextZ,a--):(n=r,r=r.nextZ,l--):(n=i,i=i.nextZ,a--),o?o.nextZ=n:e=n,n.prevZ=o,o=n;i=r}o.nextZ=null,h*=2}while(s>1);return e}function _(e,t,i,r,n){return e=32767*(e-i)/n,t=32767*(t-r)/n,e=16711935&(e|e<<8),e=252645135&(e|e<<4),e=858993459&(e|e<<2),e=1431655765&(e|e<<1),t=16711935&(t|t<<8),t=252645135&(t|t<<4),t=858993459&(t|t<<2),t=1431655765&(t|t<<1),e|t<<1}function m(e){var t=e,i=e;do{t.x=0&&(e-s)*(r-a)-(i-s)*(t-a)>=0&&(i-s)*(o-a)-(n-s)*(r-a)>=0}function v(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!A(e,t)&&T(e,t)&&T(t,e)&&E(e,t)}function y(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function x(e,t){return e.x===t.x&&e.y===t.y}function b(e,t,i,r){return!!(x(e,t)&&x(i,r)||x(e,r)&&x(i,t))||y(e,t,i)>0!=y(e,t,r)>0&&y(i,r,e)>0!=y(i,r,t)>0}function A(e,t){var i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&b(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}function T(e,t){return y(e.prev,e,e.next)<0?y(e,t,e.next)>=0&&y(e,e.prev,t)>=0:y(e,t,e.prev)<0||y(e,e.next,t)<0}function E(e,t){var i=e,r=!1,n=(e.x+t.x)/2,o=(e.y+t.y)/2;do{i.y>o!=i.next.y>o&&n<(i.next.x-i.x)*(o-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next}while(i!==e);return r}function P(e,t){var i=new C(e.i,e.x,e.y),r=new C(t.i,t.x,t.y),n=e.next,o=t.prev;return e.next=t,t.prev=e,i.next=n,n.prev=i,r.next=i,i.prev=r,o.next=r,r.prev=o,r}function M(e,t,i,r){var n=new C(e,t,i);return r?(n.next=r.next,n.prev=r,r.next.prev=n,r.next=n):(n.prev=n,n.next=n),n}function S(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function C(e,t,i){this.i=e,this.x=t,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function R(e,t,i,r){var n=t&&t.length,o=n?t[0]*i:e.length,s=Math.abs(O(e,0,o,i));if(n)for(var a=0,l=t.length;a0&&(r+=e[n-1].length,i.holes.push(r))}return i}e.earcut=t,e.deviation=R,e.flatten=I})(Earcut||(Earcut={}));var BABYLON;!(function(e){var t=(function(e){function t(t,i){var r=e.call(this,t.x,t.y)||this;return r.index=i,r}return __extends(t,e),t})(e.Vector2),i=(function(){function i(){this.elements=new Array}return i.prototype.add=function(e){var i=this,r=new Array;return e.forEach((function(e){if(0===r.length||!e.equalsWithEpsilon(r[0])){var n=new t(e,i.elements.length);r.push(n),i.elements.push(n)}})),r},i.prototype.computeBounds=function(){var t=new e.Vector2(this.elements[0].x,this.elements[0].y),i=new e.Vector2(this.elements[0].x,this.elements[0].y);return this.elements.forEach((function(e){e.xi.x&&(i.x=e.x),e.yi.y&&(i.y=e.y)})),{min:t,max:i,width:i.x-t.x,height:i.y-t.y}},i})(),r=(function(){function t(){}return t.Rectangle=function(t,i,r,n){return[new e.Vector2(t,i),new e.Vector2(r,i),new e.Vector2(r,n),new e.Vector2(t,n)]},t.Circle=function(t,i,r,n){void 0===i&&(i=0),void 0===r&&(r=0),void 0===n&&(n=32);for(var o=new Array,s=0,a=2*Math.PI/n,l=0;l0){var f=s.length/3;this._points.elements.forEach((function(e){o.push(0,-1,0),s.push(e.x,-i,e.y),a.push(1-(e.x-l.min.x)/l.width,1-(e.y-l.min.y)/l.height)}));for(var d=h.length,u=0;us.elements.length-1?s.elements[0]:s.elements[u+1],t.push(d.x,0,d.y),t.push(d.x,-a,d.y),t.push(f.x,0,f.y),t.push(f.x,-a,f.y);var p=new e.Vector3(d.x,0,d.y),_=new e.Vector3(f.x,0,f.y),m=_.subtract(p),g=new e.Vector3(0,1,0),v=e.Vector3.Cross(m,g);v=v.normalize(),r.push(c/o.width,0),r.push(c/o.width,1),c+=m.length(),r.push(c/o.width,0),r.push(c/o.width,1),l?(i.push(v.x,v.y,v.z),i.push(v.x,v.y,v.z),i.push(v.x,v.y,v.z),i.push(v.x,v.y,v.z),n.push(h),n.push(h+2),n.push(h+1),n.push(h+1),n.push(h+2),n.push(h+3)):(i.push(-v.x,-v.y,-v.z),i.push(-v.x,-v.y,-v.z),i.push(-v.x,-v.y,-v.z),i.push(-v.x,-v.y,-v.z),n.push(h),n.push(h+1),n.push(h+2),n.push(h+1),n.push(h+3),n.push(h+2)),h+=4}},t})();e.PolygonMeshBuilder=n})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=0,i=(function(){function t(e,t,i){this.pos=e,this.normal=t,this.uv=i}return t.prototype.clone=function(){return new t(this.pos.clone(),this.normal.clone(),this.uv.clone())},t.prototype.flip=function(){this.normal=this.normal.scale(-1)},t.prototype.interpolate=function(i,r){return new t(e.Vector3.Lerp(this.pos,i.pos,r),e.Vector3.Lerp(this.normal,i.normal,r),e.Vector2.Lerp(this.uv,i.uv,r))},t})(),r=(function(){function t(e,t){this.normal=e,this.w=t}return t.FromPoints=function(i,r,n){var o=n.subtract(i),s=r.subtract(i);if(0===o.lengthSquared()||0===s.lengthSquared())return null;var a=e.Vector3.Normalize(e.Vector3.Cross(o,s));return new t(a,e.Vector3.Dot(a,i))},t.prototype.clone=function(){return new t(this.normal.clone(),this.w)},t.prototype.flip=function(){this.normal.scaleInPlace(-1),this.w=-this.w},t.prototype.splitPolygon=function(i,r,o,s,a){var l,h,c=0,u=[];for(l=0;lt.EPSILON?1:0;c|=f,u.push(f)}switch(c){case 0:(e.Vector3.Dot(this.normal,i.plane.normal)>0?r:o).push(i);break;case 1:s.push(i);break;case 2:a.push(i);break;case 3:var d=[],p=[];for(l=0;l=3&&(b=new n(d,i.shared),b.plane&&s.push(b)),p.length>=3&&(b=new n(p,i.shared),b.plane&&a.push(b))}},t})();r.EPSILON=1e-5;var n=(function(){function e(e,t){this.vertices=e,this.shared=t,this.plane=r.FromPoints(e[0].pos,e[1].pos,e[2].pos)}return e.prototype.clone=function(){return new e(this.vertices.map((function(e){return e.clone()})),this.shared)},e.prototype.flip=function(){this.vertices.reverse().map((function(e){e.flip()})),this.plane.flip()},e})(),o=(function(){function e(e){this.plane=null,this.front=null,this.back=null,this.polygons=[],e&&this.build(e)}return e.prototype.clone=function(){var t=new e;return t.plane=this.plane&&this.plane.clone(),t.front=this.front&&this.front.clone(),t.back=this.back&&this.back.clone(),t.polygons=this.polygons.map((function(e){return e.clone()})),t},e.prototype.invert=function(){for(var e=0;e0&&(t.x-=this.viewportBorder,t.y-=this.viewportBorder,t.width+=2*this.viewportBorder,t.height+=2*this.viewportBorder,i.x+=this.viewportBorder,i.y+=this.viewportBorder,this._positionX+=this.viewportBorder,this._positionY+=this.viewportBorder),i.z>0&&(this._positionX>t.x&&this._positionXt.y&&(this._positionY,t.y,t.height),!0)},t.prototype._isVisible=function(){if(!this._isEnabled)return!1;var t=this.getEmitterPosition(),i=t.subtract(this._scene.activeCamera.globalPosition),r=i.length();i.normalize();var n=new e.Ray(this._scene.activeCamera.globalPosition,i),o=this._scene.pickWithRay(n,this.meshesSelectionPredicate,!0);return!o.hit||o.distance>r},t.prototype.render=function(){if(!this._effect.isReady())return!1;var t=this._scene.getEngine(),i=this._scene.activeCamera.viewport,r=i.toGlobal(t.getRenderWidth(!0),t.getRenderHeight(!0));if(!this.computeEffectivePosition(r))return!1;if(!this._isVisible())return!1;var n,o;n=this._positionXr.x+r.width-this.borderLimit?this._positionX-r.x-r.width+this.borderLimit:0,o=this._positionYr.y+r.height-this.borderLimit?this._positionY-r.y-r.height+this.borderLimit:0;var s=n>o?n:o;(s-=this.viewportBorder)>this.borderLimit&&(s=this.borderLimit);var a=1-s/this.borderLimit;if(a<0)return!1;a>1&&(a=1),this.viewportBorder>0&&(r.x+=this.viewportBorder,r.y+=this.viewportBorder,r.width-=2*this.viewportBorder,r.height-=2*this.viewportBorder,this._positionX-=this.viewportBorder,this._positionY-=this.viewportBorder);var l=r.x+r.width/2,h=r.y+r.height/2,c=l-this._positionX,u=h-this._positionY;t.enableEffect(this._effect),t.setState(!1),t.setDepthBuffer(!1),t.bindBuffers(this._vertexBuffers,this._indexBuffer,this._effect);for(var f=0;f-1?this._onBeforePhysicsStepCallbacks.splice(i,1):e.Tools.Warn("Function to remove was not found")},t.prototype.registerAfterPhysicsStep=function(e){this._onAfterPhysicsStepCallbacks.push(e)},t.prototype.unregisterAfterPhysicsStep=function(t){var i=this._onAfterPhysicsStepCallbacks.indexOf(t);i>-1?this._onAfterPhysicsStepCallbacks.splice(i,1):e.Tools.Warn("Function to remove was not found")},t.prototype.registerOnPhysicsCollide=function(e,t){var i=e instanceof Array?e:[e] -;this._onPhysicsCollideCallbacks.push({callback:t,otherImpostors:i})},t.prototype.unregisterOnPhysicsCollide=function(t,i){var r=t instanceof Array?t:[t],n=this._onPhysicsCollideCallbacks.indexOf({callback:i,otherImpostors:r});n>-1?this._onPhysicsCollideCallbacks.splice(n,1):e.Tools.Warn("Function to remove was not found")},t.prototype.applyForce=function(e,t){this._physicsEngine.getPhysicsPlugin().applyForce(this,e,t)},t.prototype.applyImpulse=function(e,t){this._physicsEngine.getPhysicsPlugin().applyImpulse(this,e,t)},t.prototype.createJoint=function(t,i,r){var n=new e.PhysicsJoint(i,r);this.addJoint(t,n)},t.prototype.addJoint=function(e,t){this._joints.push({otherImpostor:e,joint:t}),this._physicsEngine.addJoint(this,e,t)},t.prototype.sleep=function(){this._physicsEngine.getPhysicsPlugin().sleepBody(this)},t.prototype.wakeUp=function(){this._physicsEngine.getPhysicsPlugin().wakeUpBody(this)},t.prototype.clone=function(e){return e?new t(e,this.type,this._options,this._scene):null},t.prototype.dispose=function(){var e=this;this._physicsEngine&&(this._joints.forEach((function(t){e._physicsEngine.removeJoint(e,t.otherImpostor,t.joint)})),this._physicsEngine.removeImpostor(this),this.parent&&this.parent.forceUpdate(),this._isDisposed=!0)},t.prototype.setDeltaPosition=function(e){this._deltaPosition.copyFrom(e)},t.prototype.setDeltaRotation=function(t){this._deltaRotation||(this._deltaRotation=new e.Quaternion),this._deltaRotation.copyFrom(t),this._deltaRotationConjugated=this._deltaRotation.conjugate()},t.prototype.getBoxSizeToRef=function(e){this._physicsEngine.getPhysicsPlugin().getBoxSizeToRef(this,e)},t.prototype.getRadius=function(){return this._physicsEngine.getPhysicsPlugin().getRadius(this)},t.prototype.syncBoneWithImpostor=function(i,r,n,o,s){var a=t._tmpVecs[0],l=this.object;if(s){var h=t._tmpQuat;l.rotationQuaternion.multiplyToRef(s,h),i.setRotationQuaternion(h,e.Space.WORLD,r)}else i.setRotationQuaternion(l.rotationQuaternion,e.Space.WORLD,r);a.x=0,a.y=0,a.z=0,n&&(a.x=n.x,a.y=n.y,a.z=n.z,i.getDirectionToRef(a,r,a),void 0!==o&&null!==o||(o=n.length()),a.x*=o,a.y*=o,a.z*=o),i.getParent()?(a.addInPlace(l.getAbsolutePosition()),i.setAbsolutePosition(a,r)):(r.setAbsolutePosition(l.getAbsolutePosition()),r.position.x-=a.x,r.position.y-=a.y,r.position.z-=a.z)},t.prototype.syncImpostorWithBone=function(i,r,n,o,s,a){var l=this.object;if(s){var h=t._tmpQuat;i.getRotationQuaternionToRef(e.Space.WORLD,r,h),h.multiplyToRef(s,l.rotationQuaternion)}else i.getRotationQuaternionToRef(e.Space.WORLD,r,l.rotationQuaternion);var c=t._tmpVecs[0],u=t._tmpVecs[1];a||(a=t._tmpVecs[2],a.x=0,a.y=1,a.z=0),i.getDirectionToRef(a,r,u),i.getAbsolutePositionToRef(r,c),void 0!==o&&null!==o||!n||(o=n.length()),void 0!==o&&null!==o&&(c.x+=u.x*o,c.y+=u.y*o,c.z+=u.z*o),l.setAbsolutePosition(c)},t})();t.DEFAULT_OBJECT_SIZE=new e.Vector3(1,1,1),t.IDENTITY_QUATERNION=e.Quaternion.Identity(),t._tmpVecs=[e.Vector3.Zero(),e.Vector3.Zero(),e.Vector3.Zero()],t._tmpQuat=e.Quaternion.Identity(),t.NoImpostor=0,t.SphereImpostor=1,t.BoxImpostor=2,t.PlaneImpostor=3,t.MeshImpostor=4,t.CylinderImpostor=7,t.ParticleImpostor=8,t.HeightmapImpostor=9,e.PhysicsImpostor=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t,i){if(void 0===i&&(i=new e.CannonJSPlugin),this._physicsPlugin=i,this._impostors=[],this._joints=[],!this._physicsPlugin.isSupported())throw new Error("Physics Engine "+this._physicsPlugin.name+" cannot be found. Please make sure it is included.");t=t||new e.Vector3(0,-9.807,0),this.setGravity(t),this.setTimeStep()}return t.prototype.setGravity=function(e){this.gravity=e,this._physicsPlugin.setGravity(this.gravity)},t.prototype.setTimeStep=function(e){void 0===e&&(e=1/60),this._physicsPlugin.setTimeStep(e)},t.prototype.dispose=function(){this._impostors.forEach((function(e){e.dispose()})),this._physicsPlugin.dispose()},t.prototype.getPhysicsPluginName=function(){return this._physicsPlugin.name},t.prototype.addImpostor=function(e){e.uniqueId=this._impostors.push(e),e.parent||this._physicsPlugin.generatePhysicsBody(e)},t.prototype.removeImpostor=function(e){var t=this._impostors.indexOf(e);if(t>-1){var i=this._impostors.splice(t,1);i.length&&(i[0].physicsBody=null)}},t.prototype.addJoint=function(e,t,i){var r={mainImpostor:e,connectedImpostor:t,joint:i};i.physicsPlugin=this._physicsPlugin,this._joints.push(r),this._physicsPlugin.generateJoint(r)},t.prototype.removeJoint=function(e,t,i){var r=this._joints.filter((function(r){return r.connectedImpostor===t&&r.joint===i&&r.mainImpostor===e}));r.length&&this._physicsPlugin.removeJoint(r[0])},t.prototype._step=function(e){var t=this;this._impostors.forEach((function(e){e.isBodyInitRequired()&&t._physicsPlugin.generatePhysicsBody(e)})),e>.1?e=.1:e<=0&&(e=1/60),this._physicsPlugin.executeStep(e,this._impostors)},t.prototype.getPhysicsPlugin=function(){return this._physicsPlugin},t.prototype.getImpostorForPhysicsObject=function(e){for(var t=0;tr.length)return void e.Tools.Error("Unable to load TGA file - Not enough data");n+=o.id_length;var s=!1,a=!1,l=!1;switch(o.image_type){case t._TYPE_RLE_INDEXED:s=!0;case t._TYPE_INDEXED:a=!0;break;case t._TYPE_RLE_RGB:s=!0;case t._TYPE_RGB:!0;break;case t._TYPE_RLE_GREY:s=!0;case t._TYPE_GREY:l=!0}var h,c,u=(o.flags,o.pixel_size>>3),f=o.width*o.height*u;if(a&&(c=r.subarray(n,n+=o.colormap_length*(o.colormap_size>>3))),s){h=new Uint8Array(f);for(var d,p,_,m=0,g=new Uint8Array(u);n>t._ORIGIN_SHIFT){default:case t._ORIGIN_UL:v=0,x=1,T=o.width,y=0,b=1,A=o.height;break;case t._ORIGIN_BL:v=0,x=1,T=o.width,y=o.height-1,b=-1,A=-1;break;case t._ORIGIN_UR:v=o.width-1,x=-1,T=-1,y=0,b=1,A=o.height;break;case t._ORIGIN_BR:v=o.width-1,x=-1,T=-1,y=o.height-1,b=-1,A=-1}var E="_getImageData"+(l?"Grey":"")+o.pixel_size+"bits",P=t[E](o,c,h,y,b,A,v,x,T);i.texImage2D(i.TEXTURE_2D,0,i.RGBA,o.width,o.height,0,i.RGBA,i.UNSIGNED_BYTE,P)},t._getImageData8bits=function(e,t,i,r,n,o,s,a,l){var h,c,u,f=i,d=t,p=e.width,_=e.height,m=0,g=new Uint8Array(p*_*4);for(u=r;u!==o;u+=n)for(c=s;c!==l;c+=a,m++)h=f[m],g[4*(c+p*u)+3]=255,g[4*(c+p*u)+2]=d[3*h+0],g[4*(c+p*u)+1]=d[3*h+1],g[4*(c+p*u)+0]=d[3*h+2];return g},t._getImageData16bits=function(e,t,i,r,n,o,s,a,l){var h,c,u,f=i,d=e.width,p=e.height,_=0,m=new Uint8Array(d*p*4);for(u=r;u!==o;u+=n)for(c=s;c!==l;c+=a,_+=2)h=f[_+0]+(f[_+1]<<8),m[4*(c+d*u)+0]=(31744&h)>>7,m[4*(c+d*u)+1]=(992&h)>>2,m[4*(c+d*u)+2]=(31&h)>>3,m[4*(c+d*u)+3]=32768&h?0:255;return m},t._getImageData24bits=function(e,t,i,r,n,o,s,a,l){var h,c,u=i,f=e.width,d=e.height,p=0,_=new Uint8Array(f*d*4);for(c=r;c!==o;c+=n)for(h=s;h!==l;h+=a,p+=3)_[4*(h+f*c)+3]=255,_[4*(h+f*c)+2]=u[p+0],_[4*(h+f*c)+1]=u[p+1],_[4*(h+f*c)+0]=u[p+2];return _},t._getImageData32bits=function(e,t,i,r,n,o,s,a,l){var h,c,u=i,f=e.width,d=e.height,p=0,_=new Uint8Array(f*d*4);for(c=r;c!==o;c+=n)for(h=s;h!==l;h+=a,p+=4)_[4*(h+f*c)+2]=u[p+0],_[4*(h+f*c)+1]=u[p+1],_[4*(h+f*c)+0]=u[p+2],_[4*(h+f*c)+3]=u[p+3];return _},t._getImageDataGrey8bits=function(e,t,i,r,n,o,s,a,l){var h,c,u,f=i,d=e.width,p=e.height,_=0,m=new Uint8Array(d*p*4);for(u=r;u!==o;u+=n)for(c=s;c!==l;c+=a,_++)h=f[_],m[4*(c+d*u)+0]=h,m[4*(c+d*u)+1]=h,m[4*(c+d*u)+2]=h,m[4*(c+d*u)+3]=255;return m},t._getImageDataGrey16bits=function(e,t,i,r,n,o,s,a,l){var h,c,u=i,f=e.width,d=e.height,p=0,_=new Uint8Array(f*d*4);for(c=r;c!==o;c+=n)for(h=s;h!==l;h+=a,p+=2)_[4*(h+f*c)+0]=u[p+0],_[4*(h+f*c)+1]=u[p+0],_[4*(h+f*c)+2]=u[p+0],_[4*(h+f*c)+3]=u[p+1];return _},t})();i._TYPE_NO_DATA=0,i._TYPE_INDEXED=1,i._TYPE_RGB=2,i._TYPE_GREY=3,i._TYPE_RLE_INDEXED=9,i._TYPE_RLE_RGB=10,i._TYPE_RLE_GREY=11,i._ORIGIN_MASK=48,i._ORIGIN_SHIFT=4,i._ORIGIN_BL=0,i._ORIGIN_BR=1,i._ORIGIN_UL=2,i._ORIGIN_UR=3,t.TGATools=i})(e.Internals||(e.Internals={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){function i(e){return e.charCodeAt(0)+(e.charCodeAt(1)<<8)+(e.charCodeAt(2)<<16)+(e.charCodeAt(3)<<24)}function r(e){return String.fromCharCode(255&e,e>>8&255,e>>16&255,e>>24&255)}var n=i("DXT1"),o=i("DXT3"),s=i("DXT5"),a=i("DX10"),l=(function(){function t(){}return t.GetDDSInfo=function(t){var i=new Int32Array(t,0,31),r=new Int32Array(t,0,35),l=1;131072&i[2]&&(l=Math.max(1,i[7]));var h=i[21],c=h===a?r[32]:0,u=e.Engine.TEXTURETYPE_UNSIGNED_INT;switch(h){case 113:u=e.Engine.TEXTURETYPE_HALF_FLOAT;break;case 116:u=e.Engine.TEXTURETYPE_FLOAT;break;case a:if(10===c){u=e.Engine.TEXTURETYPE_HALF_FLOAT;break}}return{width:i[4],height:i[3],mipmapCount:l,isFourCC:4==(4&i[20]),isRGB:64==(64&i[20]),isLuminance:131072==(131072&i[20]),isCube:512==(512&i[28]),isCompressed:h===n||h===o||n===s,dxgiFormat:c,textureType:u}},t._ToHalfFloat=function(e){t._FloatView||(t._FloatView=new Float32Array(1),t._Int32View=new Int32Array(t._FloatView.buffer)),t._FloatView[0]=e;var i=t._Int32View[0],r=i>>16&32768,n=i>>12&2047,o=i>>23&255;return o<103?r:o>142?(r|=31744,r|=(255==o?0:1)&&8388607&i):o<113?(n|=2048,r|=(n>>114-o)+(n>>113-o&1)):(r|=o-112<<10|n>>1,r+=1&n)},t._FromHalfFloat=function(e){var t=(32768&e)>>15,i=(31744&e)>>10,r=1023&e;return 0===i?(t?-1:1)*Math.pow(2,-14)*(r/Math.pow(2,10)):31==i?r?NaN:1/0*(t?-1:1):(t?-1:1)*Math.pow(2,i-15)*(1+r/Math.pow(2,10))},t._GetHalfFloatAsFloatRGBAArrayBuffer=function(e,i,r,n,o,s){for(var a=new Float32Array(n),l=new Uint16Array(o,r),h=0,c=0;c>8&65280|e>>24&255},t.prototype.uploadLevels=function(e,i){switch(this.loadType){case t.COMPRESSED_2D:this._upload2DCompressedLevels(e,i);break;case t.TEX_2D:case t.COMPRESSED_3D:case t.TEX_3D:}},t.prototype._upload2DCompressedLevels=function(e,i){for(var r=t.HEADER_LEN+this.bytesOfKeyValueData,n=this.pixelWidth,o=this.pixelHeight,s=i?this.numberOfMipmapLevels:1,a=0;a0?this._firstFree=this._freeEntries[this._freeEntries.length-1].offset:this._firstFree+=this._stride),e},e.prototype.freeElement=function(e){this._firstFree=Math.min(e.offset,this._firstFree),this._freeEntries.push(e)},e.prototype.pack=function(){if(0===this._freeEntries.length)return this.buffer;if(this._lastUsed=a);h++){var c=r[h],u=c.offset,f=u-l;if(f!==e){for(var d=f/e-1,p=u-e,_=Math.min(s,d),m=0;m<_;m++){var g=o/e,v=p/e,y=n[v];this._moveElement(y,o);var x=n[g];x.offset=p,n[g]=y,n[v]=x,p-=e,o+=e}s<=d?(o=p+e,s=1+_):s=(u-o)/e+1,l=u}else++s,l=u}var b=this.buffer.subarray(0,o);return this._lastUsed=o-e,this._firstFree=o,r.pop(),this._freeEntries=r.sort((function(e,t){return t.offset-e.offset})),this._allEntries=n,b},e.prototype._moveElement=function(e,t){for(var i=0;i=0;s--){var a=t[s],l=a.getParent();if(l){var h=this._debugLines[n];h||(h=[e.Vector3.Zero(),e.Vector3.Zero()],this._debugLines[n]=h),a.getAbsolutePositionToRef(this.mesh,h[0]),l.getAbsolutePositionToRef(this.mesh,h[1]),h[0].subtractInPlace(o),h[1].subtractInPlace(o),n++}}},t.prototype.update=function(){this.autoUpdateBonesMatrices&&this.skeleton.computeAbsoluteTransforms(),void 0===this.skeleton.bones[0].length?this._getLinesForBonesNoLength(this.skeleton.bones,this.mesh.getWorldMatrix()):this._getLinesForBonesWithLength(this.skeleton.bones,this.mesh.getWorldMatrix()),this._debugMesh?e.MeshBuilder.CreateLineSystem(null,{lines:this._debugLines,updatable:!0,instance:this._debugMesh},this._scene):(this._debugMesh=e.MeshBuilder.CreateLineSystem(null,{lines:this._debugLines,updatable:!0},this._scene),this._debugMesh.renderingGroupId=this.renderingGroupId),this._debugMesh.position.copyFrom(this.mesh.position),this._debugMesh.color=this.color},t.prototype.dispose=function(){this._debugMesh&&(this.isEnabled=!1,this._debugMesh.dispose(),this._debugMesh=null)},t})();t.SkeletonViewer=i})(e.Debug||(e.Debug={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){var i=(function(){function t(t,i){void 0===i&&(i=1),this._xline=[e.Vector3.Zero(),e.Vector3.Zero()],this._yline=[e.Vector3.Zero(),e.Vector3.Zero()],this._zline=[e.Vector3.Zero(),e.Vector3.Zero()],this.scaleLines=1,this.scaleLines=i,this._xmesh=e.Mesh.CreateLines("xline",this._xline,t,!0),this._ymesh=e.Mesh.CreateLines("yline",this._yline,t,!0),this._zmesh=e.Mesh.CreateLines("zline",this._zline,t,!0),this._xmesh.renderingGroupId=2,this._ymesh.renderingGroupId=2,this._zmesh.renderingGroupId=2,this._xmesh.material.checkReadyOnlyOnce=!0,this._xmesh.color=new e.Color3(1,0,0),this._ymesh.material.checkReadyOnlyOnce=!0,this._ymesh.color=new e.Color3(0,1,0),this._zmesh.material.checkReadyOnlyOnce=!0,this._zmesh.color=new e.Color3(0,0,1),this.scene=t}return t.prototype.update=function(t,i,r,n){var o=this.scaleLines;this._xmesh.position.copyFrom(t),this._ymesh.position.copyFrom(t),this._zmesh.position.copyFrom(t);var s=this._xline[1];s.x=i.x*o,s.y=i.y*o,s.z=i.z*o,e.Mesh.CreateLines(null,this._xline,null,null,this._xmesh),s=this._yline[1],s.x=r.x*o,s.y=r.y*o,s.z=r.z*o,e.Mesh.CreateLines(null,this._yline,null,null,this._ymesh),s=this._zline[1],s.x=n.x*o,s.y=n.y*o,s.z=n.z*o,e.Mesh.CreateLines(null,this._zline,null,null,this._zmesh)},t.prototype.dispose=function(){this._xmesh&&(this._xmesh.dispose(),this._ymesh.dispose(),this._zmesh.dispose(),this._xmesh=null,this._ymesh=null,this._zmesh=null,this._xline=null,this._yline=null,this._zline=null,this.scene=null)},t})();t.AxesViewer=i})(e.Debug||(e.Debug={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){var i=(function(t){function i(i,r,n,o){void 0===o&&(o=1);var s=t.call(this,i,o)||this;return s.pos=e.Vector3.Zero(),s.xaxis=e.Vector3.Zero(),s.yaxis=e.Vector3.Zero(),s.zaxis=e.Vector3.Zero(),s.mesh=n,s.bone=r,s}return __extends(i,t),i.prototype.update=function(){var i=this.bone;i.getAbsolutePositionToRef(this.mesh,this.pos),i.getDirectionToRef(e.Axis.X,this.mesh,this.xaxis),i.getDirectionToRef(e.Axis.Y,this.mesh,this.yaxis),i.getDirectionToRef(e.Axis.Z,this.mesh,this.zaxis),t.prototype.update.call(this,this.pos,this.xaxis,this.yaxis,this.zaxis)},i.prototype.dispose=function(){this.pos&&(this.pos=null,this.xaxis=null,this.yaxis=null,this.zaxis=null,this.mesh=null,this.bone=null,t.prototype.dispose.call(this))},i})(t.AxesViewer);t.BoneAxesViewer=i})(e.Debug||(e.Debug={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e){this.ray=e}return t.CreateAndShow=function(e,i,r){var n=new t(e);return n.show(i,r),n},t.prototype.show=function(t,i){if(!this._renderFunction){var r=this.ray;this._renderFunction=this._render.bind(this),this._scene=t,this._renderPoints=[r.origin,r.origin.add(r.direction.scale(r.length))],this._renderLine=e.Mesh.CreateLines("ray",this._renderPoints,t,!0),this._scene.registerBeforeRender(this._renderFunction)}i&&this._renderLine.color.copyFrom(i)},t.prototype.hide=function(){this._renderFunction&&(this._scene.unregisterBeforeRender(this._renderFunction),this._scene=null,this._renderFunction=null,this._renderLine.dispose(),this._renderLine=null,this._renderPoints=null)},t.prototype._render=function(){var t=this.ray,i=this._renderPoints[1],r=Math.min(t.length,1e6);i.copyFrom(t.direction),i.scaleInPlace(r),i.addInPlace(t.origin),e.Mesh.CreateLines("ray",this._renderPoints,this._scene,!0,this._renderLine)},t.prototype.attachToMesh=function(t,i,r,n){this._attachedToMesh=t;var o=this.ray;o.direction||(o.direction=e.Vector3.Zero()),o.origin||(o.origin=e.Vector3.Zero()),n&&(o.length=n),r||(r=e.Vector3.Zero()),i||(i=new e.Vector3(0,0,-1)),this._meshSpaceDirection?(this._meshSpaceDirection.copyFrom(i),this._meshSpaceOrigin.copyFrom(r)):(this._meshSpaceDirection=i.clone(),this._meshSpaceOrigin=r.clone()),this._updateToMeshFunction||(this._updateToMeshFunction=this._updateToMesh.bind(this),this._attachedToMesh.getScene().registerBeforeRender(this._updateToMeshFunction)),this._updateToMesh()},t.prototype.detachFromMesh=function(){this._attachedToMesh&&(this._attachedToMesh.getScene().unregisterBeforeRender(this._updateToMeshFunction),this._attachedToMesh=null,this._updateToMeshFunction=null)},t.prototype._updateToMesh=function(){var t=this.ray;if(this._attachedToMesh._isDisposed)return void this.detachFromMesh();this._attachedToMesh.getDirectionToRef(this._meshSpaceDirection,t.direction),e.Vector3.TransformCoordinatesToRef(this._meshSpaceOrigin,this._attachedToMesh.getWorldMatrix(),t.origin)},t.prototype.dispose=function(){this.hide(),this.detachFromMesh(),this.ray=null},t})();e.RayHelper=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e){this._scene=e}return t.prototype._createInspector=function(e){void 0===e&&(e={});var t=e.popup||!1,i=e.initialTab||0,r=e.parentElement||null;this._inspector||(this._inspector=new INSPECTOR.Inspector(this._scene,t,i,r,e.newColors))},t.prototype.isVisible=function(){return!!this._inspector},t.prototype.hide=function(){if(this._inspector){try{this._inspector.dispose()}catch(e){}this._inspector=null}},t.prototype.show=function(i){void 0===i&&(i={}),"undefined"==typeof INSPECTOR?e.Tools.LoadScript(t.InspectorURL,this._createInspector.bind(this,i)):this._createInspector(i)},t})();t.InspectorURL=window.location.href.split("/")[0]+"//preview.babylonjs.com/inspector/babylon.inspector.bundle.js",e.DebugLayer=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){var i=(function(){function t(t){this._impostors=[],this._meshes=[],this._numMeshes=0,this._scene=t||e.Engine.LastCreatedScene,this._physicsEnginePlugin=this._scene.getPhysicsEngine().getPhysicsPlugin()}return t.prototype._updateDebugMeshes=function(){for(var e=this._physicsEnginePlugin,t=0;t0?(this._meshes[i]=this._meshes[this._numMeshes],this._impostors[i]=this._impostors[this._numMeshes],this._meshes[this._numMeshes]=null,this._impostors[this._numMeshes]=null):(this._meshes[0]=null,this._impostors[0]=null),t=!0;break}t&&0===this._numMeshes&&this._scene.unregisterBeforeRender(this._renderFunction)},t.prototype._getDebugMaterial=function(t){return this._debugMaterial||(this._debugMaterial=new e.StandardMaterial("",t),this._debugMaterial.wireframe=!0),this._debugMaterial},t.prototype._getDebugBoxMesh=function(t){return this._debugBoxMesh||(this._debugBoxMesh=e.MeshBuilder.CreateBox("physicsBodyBoxViewMesh",{size:1},t),this._debugBoxMesh.renderingGroupId=1,this._debugBoxMesh.rotationQuaternion=e.Quaternion.Identity(),this._debugBoxMesh.material=this._getDebugMaterial(t),t.removeMesh(this._debugBoxMesh)),this._debugBoxMesh.createInstance("physicsBodyBoxViewInstance")},t.prototype._getDebugSphereMesh=function(t){return this._debugSphereMesh||(this._debugSphereMesh=e.MeshBuilder.CreateSphere("physicsBodySphereViewMesh",{diameter:1},t),this._debugSphereMesh.renderingGroupId=1,this._debugSphereMesh.rotationQuaternion=e.Quaternion.Identity(),this._debugSphereMesh.material=this._getDebugMaterial(t),t.removeMesh(this._debugSphereMesh)),this._debugSphereMesh.createInstance("physicsBodyBoxViewInstance")},t.prototype._getDebugMesh=function(t,i){var r,n=t.physicsBody;n.shapes[0];if(t.type==e.PhysicsImpostor.BoxImpostor)r=this._getDebugBoxMesh(i),t.getBoxSizeToRef(r.scaling);else if(t.type==e.PhysicsImpostor.SphereImpostor){r=this._getDebugSphereMesh(i);var o=t.getRadius();r.scaling.x=2*o,r.scaling.y=2*o,r.scaling.z=2*o}return r},t.prototype.dispose=function(){for(var e=0;e=0&&(this._targets.splice(t,1),e.onInfluenceChanged.remove(this._targetObservable.splice(t,1)[0]),this._vertexCount=0,this._syncActiveTargets(!0))},t.prototype.serialize=function(){var e={};e.id=this.uniqueId,e.targets=[];for(var t=0,i=this._targets;t0&&(this._activeTargets.push(n),this._tempInfluences[t++]=n.influence,this._supportsNormals=this._supportsNormals&&n.hasNormals,this._supportsTangents=this._supportsTangents&&n.hasTangents,0===this._vertexCount&&(this._vertexCount=n.getPositions().length/3))}this._influences&&this._influences.length===t||(this._influences=new Float32Array(t));for(var o=0;o0&&(p+1)%4==0)o[p]=255;else{var x=s[p];o[p]=x/d*255}t.getScene().getEngine().updateTextureSize(r,h*h,h),t.getScene().getEngine().updateRawTexture(r,o,e.Engine.TEXTUREFORMAT_RGBA,!1)};return e.Tools.LoadFile(this.url,n),this._texture},i.prototype.loadTexture=function(){this.url&&this.url.toLocaleLowerCase().indexOf(".3dl")==this.url.length-4&&this.load3dlTexture()},i.prototype.clone=function(){var e=new i(this.url,this.getScene());return e.level=this.level,e},i.prototype.delayLoad=function(){this.delayLoadState===e.Engine.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=e.Engine.DELAYLOADSTATE_LOADED,this._texture=this._getFromCache(this.url,!0),this._texture||this.loadTexture())},i.Parse=function(t,i,r){var n=null;return t.name&&!t.isRenderTarget&&(n=new e.ColorGradingTexture(t.name,i),n.name=t.name,n.level=t.level),n},i.prototype.serialize=function(){if(!this.name)return null;var e={};return e.name=this.name,e.level=this.level,e.customType="BABYLON.ColorGradingTexture",e},i})(e.BaseTexture);t._noneEmptyLineRegex=/\S+/,e.ColorGradingTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this._dirty=!0,this._tempColor=new e.Color4(0,0,0,0),this._globalCurve=new e.Color4(0,0,0,0),this._highlightsCurve=new e.Color4(0,0,0,0),this._midtonesCurve=new e.Color4(0,0,0,0),this._shadowsCurve=new e.Color4(0,0,0,0),this._positiveCurve=new e.Color4(0,0,0,0),this._negativeCurve=new e.Color4(0,0,0,0),this._globalHue=30,this._globalDensity=0,this._globalSaturation=0,this._globalExposure=0,this._highlightsHue=30,this._highlightsDensity=0,this._highlightsSaturation=0,this._highlightsExposure=0,this._midtonesHue=30,this._midtonesDensity=0,this._midtonesSaturation=0,this._midtonesExposure=0,this._shadowsHue=30,this._shadowsDensity=0,this._shadowsSaturation=0,this._shadowsExposure=0}return Object.defineProperty(t.prototype,"globalHue",{get:function(){return this._globalHue},set:function(e){this._globalHue=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"globalDensity",{get:function(){return this._globalDensity},set:function(e){this._globalDensity=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"globalSaturation",{get:function(){return this._globalSaturation},set:function(e){this._globalSaturation=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"highlightsHue",{get:function(){return this._highlightsHue},set:function(e){this._highlightsHue=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"highlightsDensity",{get:function(){return this._highlightsDensity},set:function(e){this._highlightsDensity=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"highlightsSaturation",{get:function(){return this._highlightsSaturation},set:function(e){this._highlightsSaturation=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"highlightsExposure",{get:function(){return this._highlightsExposure},set:function(e){this._highlightsExposure=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"midtonesHue",{get:function(){return this._midtonesHue},set:function(e){this._midtonesHue=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"midtonesDensity",{get:function(){return this._midtonesDensity},set:function(e){this._midtonesDensity=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"midtonesSaturation",{get:function(){return this._midtonesSaturation},set:function(e){this._midtonesSaturation=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"midtonesExposure",{get:function(){return this._midtonesExposure},set:function(e){this._midtonesExposure=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"shadowsHue",{get:function(){return this._shadowsHue},set:function(e){this._shadowsHue=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"shadowsDensity",{get:function(){return this._shadowsDensity},set:function(e){this._shadowsDensity=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"shadowsSaturation",{get:function(){return this._shadowsSaturation},set:function(e){this._shadowsSaturation=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"shadowsExposure",{get:function(){return this._shadowsExposure},set:function(e){this._shadowsExposure=e,this._dirty=!0},enumerable:!0, -configurable:!0}),t.prototype.getClassName=function(){return"ColorCurves"},t.Bind=function(e,t,i,r,n){void 0===i&&(i="vCameraColorCurvePositive"),void 0===r&&(r="vCameraColorCurveNeutral"),void 0===n&&(n="vCameraColorCurveNegative"),e._dirty&&(e._dirty=!1,e.getColorGradingDataToRef(e._globalHue,e._globalDensity,e._globalSaturation,e._globalExposure,e._globalCurve),e.getColorGradingDataToRef(e._highlightsHue,e._highlightsDensity,e._highlightsSaturation,e._highlightsExposure,e._tempColor),e._tempColor.multiplyToRef(e._globalCurve,e._highlightsCurve),e.getColorGradingDataToRef(e._midtonesHue,e._midtonesDensity,e._midtonesSaturation,e._midtonesExposure,e._tempColor),e._tempColor.multiplyToRef(e._globalCurve,e._midtonesCurve),e.getColorGradingDataToRef(e._shadowsHue,e._shadowsDensity,e._shadowsSaturation,e._shadowsExposure,e._tempColor),e._tempColor.multiplyToRef(e._globalCurve,e._shadowsCurve),e._highlightsCurve.subtractToRef(e._midtonesCurve,e._positiveCurve),e._midtonesCurve.subtractToRef(e._shadowsCurve,e._negativeCurve)),t&&(t.setFloat4(i,e._positiveCurve.r,e._positiveCurve.g,e._positiveCurve.b,e._positiveCurve.a),t.setFloat4(r,e._midtonesCurve.r,e._midtonesCurve.g,e._midtonesCurve.b,e._midtonesCurve.a),t.setFloat4(n,e._negativeCurve.r,e._negativeCurve.g,e._negativeCurve.b,e._negativeCurve.a))},t.PrepareUniforms=function(e){e.push("vCameraColorCurveNeutral","vCameraColorCurvePositive","vCameraColorCurveNegative")},t.prototype.getColorGradingDataToRef=function(e,i,r,n,o){null!=e&&(e=t.clamp(e,0,360),i=t.clamp(i,-100,100),r=t.clamp(r,-100,100),n=t.clamp(n,-100,100),i=t.applyColorGradingSliderNonlinear(i),i*=.5,n=t.applyColorGradingSliderNonlinear(n),i<0&&(i*=-1,e=(e+180)%360),t.fromHSBToRef(e,i,50+.25*n,o),o.scaleToRef(2,o),o.a=1+.01*r)},t.applyColorGradingSliderNonlinear=function(e){e/=100;var t=Math.abs(e);return t=Math.pow(t,2),e<0&&(t*=-1),t*=100},t.fromHSBToRef=function(e,i,r,n){var o=t.clamp(e,0,360),s=t.clamp(i/100,0,1),a=t.clamp(r/100,0,1);if(0===s)n.r=a,n.g=a,n.b=a;else{o/=60;var l=Math.floor(o),h=o-l,c=a*(1-s),u=a*(1-s*h),f=a*(1-s*(1-h));switch(l){case 0:n.r=a,n.g=f,n.b=c;break;case 1:n.r=u,n.g=a,n.b=c;break;case 2:n.r=c,n.g=a,n.b=f;break;case 3:n.r=c,n.g=u,n.b=a;break;case 4:n.r=f,n.g=c,n.b=a;break;default:n.r=a,n.g=c,n.b=u}}n.a=1},t.clamp=function(e,t,i){return Math.min(Math.max(e,t),i)},t.prototype.clone=function(){return e.SerializationHelper.Clone((function(){return new t}),this)},t.prototype.serialize=function(){return e.SerializationHelper.Serialize(this)},t.Parse=function(i){return e.SerializationHelper.Parse((function(){return new t}),i,null,null)},t})();__decorate([e.serialize()],t.prototype,"_globalHue",void 0),__decorate([e.serialize()],t.prototype,"_globalDensity",void 0),__decorate([e.serialize()],t.prototype,"_globalSaturation",void 0),__decorate([e.serialize()],t.prototype,"_globalExposure",void 0),__decorate([e.serialize()],t.prototype,"_highlightsHue",void 0),__decorate([e.serialize()],t.prototype,"_highlightsDensity",void 0),__decorate([e.serialize()],t.prototype,"_highlightsSaturation",void 0),__decorate([e.serialize()],t.prototype,"_highlightsExposure",void 0),__decorate([e.serialize()],t.prototype,"_midtonesHue",void 0),__decorate([e.serialize()],t.prototype,"_midtonesDensity",void 0),__decorate([e.serialize()],t.prototype,"_midtonesSaturation",void 0),__decorate([e.serialize()],t.prototype,"_midtonesExposure",void 0),e.ColorCurves=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t,i,r){void 0===r&&(r=2),this.maxDepth=r,this.dynamicContent=new Array,this._maxBlockCapacity=i||64,this._selectionContent=new e.SmartArray(1024),this._creationFunc=t}return t.prototype.update=function(e,i,r){t._CreateBlocks(e,i,r,this._maxBlockCapacity,0,this.maxDepth,this,this._creationFunc)},t.prototype.addMesh=function(e){for(var t=0;tthis.capacity&&this._depth>>16&65535,r=65535&e,n=t>>>16&65535,o=65535&t;return r*o+(i*o+r*n<<16>>>0)|0}),e.Matrix.prototype.multiplyToArray=i.prototype.multiplyToArraySIMD,e.Matrix.prototype.invertToRef=i.prototype.invertToRefSIMD,e.Matrix.LookAtLHToRef=i.LookAtLHToRefSIMD,e.Vector3.TransformCoordinatesToRef=t.TransformCoordinatesToRefSIMD,e.Vector3.TransformCoordinatesFromFloatsToRef=t.TransformCoordinatesFromFloatsToRefSIMD,l._isEnabled=!0)},l})();l._isEnabled=!1,e.SIMDHelper=l})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o){var s=t.call(this,i,"vrDistortionCorrection",["LensCenter","Scale","ScaleIn","HmdWarpParam"],null,o.postProcessScaleFactor,r,e.Texture.BILINEAR_SAMPLINGMODE,null,null)||this;return s._isRightEye=n,s._distortionFactors=o.distortionK,s._postProcessScaleFactor=o.postProcessScaleFactor,s._lensCenterOffset=o.lensCenterOffset,s.onSizeChangedObservable.add((function(){s.aspectRatio=.5*s.width/s.height,s._scaleIn=new e.Vector2(2,2/s.aspectRatio),s._scaleFactor=new e.Vector2(1/s._postProcessScaleFactor*.5,1/s._postProcessScaleFactor*.5*s.aspectRatio),s._lensCenter=new e.Vector2(s._isRightEye?.5-.5*s._lensCenterOffset:.5+.5*s._lensCenterOffset,.5)})),s.onApplyObservable.add((function(e){e.setFloat2("LensCenter",s._lensCenter.x,s._lensCenter.y),e.setFloat2("Scale",s._scaleFactor.x,s._scaleFactor.y),e.setFloat2("ScaleIn",s._scaleIn.x,s._scaleIn.y),e.setFloat4("HmdWarpParam",s._distortionFactors[0],s._distortionFactors[1],s._distortionFactors[2],s._distortionFactors[3])})),s}return __extends(i,t),i})(e.PostProcess);e.VRDistortionCorrectionPostProcess=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(e){function t(t,i,r,n,o,s){var a=e.call(this,t,"anaglyph",null,["leftSampler"],i,r[1],n,o,s)||this;return a._passedProcess=r[0]._rigPostProcess,a.onApplyObservable.add((function(e){e.setTextureFromPostProcess("leftSampler",a._passedProcess)})),a}return __extends(t,e),t})(e.PostProcess);e.AnaglyphPostProcess=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o,s,a){var l=t.call(this,i,"stereoscopicInterlace",["stepSize"],["camASampler"],1,r[1],o,s,a,n?"#define IS_STEREOSCOPIC_HORIZ 1":void 0)||this;return l._passedProcess=r[0]._rigPostProcess,l._stepSize=new e.Vector2(1/l.width,1/l.height),l.onSizeChangedObservable.add((function(){l._stepSize=new e.Vector2(1/l.width,1/l.height)})),l.onApplyObservable.add((function(e){e.setTextureFromPostProcess("camASampler",l._passedProcess),e.setFloat2("stepSize",l._stepSize.x,l._stepSize.y)})),l}return __extends(i,t),i})(e.PostProcess);e.StereoscopicInterlacePostProcess=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){var t=this;this._screenOrientationAngle=0,this._screenQuaternion=new e.Quaternion,this._alpha=0,this._beta=0,this._gamma=0,this._orientationChanged=function(){t._screenOrientationAngle=void 0!==window.orientation?+window.orientation:window.screen.orientation&&window.screen.orientation.angle?window.screen.orientation.angle:0,t._screenOrientationAngle=-e.Tools.ToRadians(t._screenOrientationAngle/2),t._screenQuaternion.copyFromFloats(0,Math.sin(t._screenOrientationAngle),0,Math.cos(t._screenOrientationAngle))},this._deviceOrientation=function(e){t._alpha=e.alpha,t._beta=e.beta,t._gamma=e.gamma},this._constantTranform=new e.Quaternion(-Math.sqrt(.5),0,0,Math.sqrt(.5)),this._orientationChanged()}return Object.defineProperty(t.prototype,"camera",{get:function(){return this._camera},set:function(t){this._camera=t,this._camera.rotationQuaternion||(this._camera.rotationQuaternion=new e.Quaternion)},enumerable:!0,configurable:!0}),t.prototype.attachControl=function(e,t){window.addEventListener("orientationchange",this._orientationChanged),window.addEventListener("deviceorientation",this._deviceOrientation),this._orientationChanged()},t.prototype.detachControl=function(e){window.removeEventListener("orientationchange",this._orientationChanged),window.removeEventListener("deviceorientation",this._deviceOrientation)},t.prototype.checkInputs=function(){this._alpha&&(e.Quaternion.RotationYawPitchRollToRef(e.Tools.ToRadians(this._alpha),e.Tools.ToRadians(this._beta),-e.Tools.ToRadians(this._gamma),this.camera.rotationQuaternion),this._camera.rotationQuaternion.multiplyInPlace(this._screenQuaternion),this._camera.rotationQuaternion.multiplyInPlace(this._constantTranform),this._camera.rotationQuaternion.z*=-1,this._camera.rotationQuaternion.w*=-1)},t.prototype.getClassName=function(){return"FreeCameraDeviceOrientationInput"},t.prototype.getSimpleName=function(){return"deviceOrientation"},t})();e.FreeCameraDeviceOrientationInput=t,e.CameraInputTypes.FreeCameraDeviceOrientationInput=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(){this.alphaCorrection=1,this.betaCorrection=1,this.gammaCorrection=1,this._alpha=0,this._beta=0,this._gamma=0,this._dirty=!1,this._deviceOrientationHandler=this._onOrientationEvent.bind(this)}return e.prototype.attachControl=function(e,t){this.camera.attachControl(e,t),window.addEventListener("deviceorientation",this._deviceOrientationHandler)},e.prototype._onOrientationEvent=function(e){this.camera;this._alpha=0|+e.alpha,this._beta=0|+e.beta,this._gamma=0|+e.gamma,this._dirty=!0},e.prototype.checkInputs=function(){this._dirty&&(this._dirty=!1,this._gamma<0&&(this._gamma=180+this._gamma),this.camera.alpha=-this._alpha/180*Math.PI%Math.PI*2,this.camera.beta=this._gamma/180*Math.PI)},e.prototype.detachControl=function(e){window.removeEventListener("deviceorientation",this._deviceOrientationHandler)},e.prototype.getClassName=function(){return"ArcRotateCameraVRDeviceOrientationInput"},e.prototype.getSimpleName=function(){return"VRDeviceOrientation"},e})();e.ArcRotateCameraVRDeviceOrientationInput=t,e.CameraInputTypes.ArcRotateCameraVRDeviceOrientationInput=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this.compensateDistortion=!0}return Object.defineProperty(t.prototype,"aspectRatio",{get:function(){return this.hResolution/(2*this.vResolution)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"aspectRatioFov",{get:function(){return 2*Math.atan(this.postProcessScaleFactor*this.vScreenSize/(2*this.eyeToScreenDistance))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"leftHMatrix",{get:function(){var t=this.hScreenSize/4-this.lensSeparationDistance/2,i=4*t/this.hScreenSize;return e.Matrix.Translation(i,0,0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rightHMatrix",{get:function(){var t=this.hScreenSize/4-this.lensSeparationDistance/2,i=4*t/this.hScreenSize;return e.Matrix.Translation(-i,0,0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"leftPreViewMatrix",{get:function(){return e.Matrix.Translation(.5*this.interpupillaryDistance,0,0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rightPreViewMatrix",{get:function(){return e.Matrix.Translation(-.5*this.interpupillaryDistance,0,0)},enumerable:!0,configurable:!0}),t.GetDefault=function(){var e=new t;return e.hResolution=1280,e.vResolution=800,e.hScreenSize=.149759993,e.vScreenSize=.0935999975,e.vScreenCenter=.0467999987,e.eyeToScreenDistance=.0410000011,e.lensSeparationDistance=.063500002,e.interpupillaryDistance=.064000003,e.distortionK=[1,.219999999,.239999995,0],e.chromaAbCorrection=[.995999992,-.00400000019,1.01400006,0],e.postProcessScaleFactor=1.714605507808412,e.lensCenterOffset=.151976421,e},t})();e.VRCameraMetrics=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o){void 0===o&&(o={});var s=t.call(this,i,r,n)||this;return s.webVROptions=o,s._vrDevice=null,s.rawPose=null,s._vrEnabled=!1,s._specsVersion=1.1,s._attached=!1,s._positionOffset=e.Vector3.Zero(),s._descendants=[],s.devicePosition=e.Vector3.Zero(),s.deviceScaleFactor=1,s.controllers=[],s.nonVRControllers=[],s.rigParenting=!0,5===arguments.length&&(s.webVROptions=arguments[4]),void 0==s.webVROptions.trackPosition&&(s.webVROptions.trackPosition=!0),void 0==s.webVROptions.controllerMeshes&&(s.webVROptions.controllerMeshes=!0),void 0==s.webVROptions.defaultLightningOnControllers&&(s.webVROptions.defaultLightningOnControllers=!0),s.rotationQuaternion=new e.Quaternion,s.deviceRotationQuaternion=new e.Quaternion,s.webVROptions&&s.webVROptions.positionScale&&(s.deviceScaleFactor=s.webVROptions.positionScale),s.getEngine().initWebVR(),window.VRFrameData?s._frameData=new VRFrameData:(s._specsVersion=1,s._frameData={}),s.getEngine().getVRDevice(s.webVROptions.displayName,(function(t){t&&(s._vrEnabled=!0,s._vrDevice=t,s.setCameraRigMode(e.Camera.RIG_MODE_WEBVR,{parentCamera:s,vrDisplay:s._vrDevice,frameData:s._frameData,specs:s._specsVersion}),s._attached&&s.getEngine().enableVR(s._vrDevice))})),s.initControllers(),n.onBeforeCameraRenderObservable.add((function(e){e.parent===s&&s.rigParenting&&(s._descendants=s.getDescendants(!0,(function(e){var t=s.controllers.some((function(t){return t._mesh===e})),i=-1!==s._rigCameras.indexOf(e);return!t&&!i})),s._descendants.forEach((function(t){t.parent=e})))})),n.onAfterCameraRenderObservable.add((function(e){e.parent===s&&s.rigParenting&&s._descendants.forEach((function(e){e.parent=s}))})),s}return __extends(i,t),Object.defineProperty(i.prototype,"onControllersAttached",{set:function(e){this._onControllersAttached=e,this.controllers.length>=2&&e(this.controllers)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"onNonVRControllerAttached",{set:function(e){this._onNonVRControllerAttached=e,this.nonVRControllers.forEach((function(t){e(t)}))},enumerable:!0,configurable:!0}),i.prototype.getControllerByName=function(e){for(var t=0,i=this.controllers;t=2)){for(var n=!1,o=0;oi.halfWidth,t&&this._joystickPointerID<0?(this._joystickPointerID=e.pointerId,this._joystickPointerStartPos.x=e.clientX,this._joystickPointerStartPos.y=e.clientY,this._joystickPointerPos=this._joystickPointerStartPos.clone(),this._joystickPreviousPointerPos=this._joystickPointerStartPos.clone(),this._deltaJoystickVector.x=0,this._deltaJoystickVector.y=0,this.pressed=!0,this._touches.add(e.pointerId.toString(),e)):i._globalJoystickIndex<2&&this._action&&(this._action(),this._touches.add(e.pointerId.toString(),{x:e.clientX,y:e.clientY,prevX:e.clientX,prevY:e.clientY}))},i.prototype._onPointerMove=function(e){if(this._joystickPointerID==e.pointerId){this._joystickPointerPos.x=e.clientX,this._joystickPointerPos.y=e.clientY,this._deltaJoystickVector=this._joystickPointerPos.clone(),this._deltaJoystickVector=this._deltaJoystickVector.subtract(this._joystickPointerStartPos);var i=this.reverseLeftRight?-1:1,r=i*this._deltaJoystickVector.x/this._inversedSensibility;switch(this._axisTargetedByLeftAndRight){case t.X:this.deltaPosition.x=Math.min(1,Math.max(-1,r));break;case t.Y:this.deltaPosition.y=Math.min(1,Math.max(-1,r));break;case t.Z:this.deltaPosition.z=Math.min(1,Math.max(-1,r))}var n=this.reverseUpDown?1:-1,o=n*this._deltaJoystickVector.y/this._inversedSensibility;switch(this._axisTargetedByUpAndDown){case t.X:this.deltaPosition.x=Math.min(1,Math.max(-1,o));break;case t.Y:this.deltaPosition.y=Math.min(1,Math.max(-1,o));break;case t.Z:this.deltaPosition.z=Math.min(1,Math.max(-1,o))}}else{var s=this._touches.get(e.pointerId.toString());s&&(s.x=e.clientX,s.y=e.clientY)}},i.prototype._onPointerUp=function(e){if(this._joystickPointerID==e.pointerId)i.vjCanvasContext.clearRect(this._joystickPointerStartPos.x-64,this._joystickPointerStartPos.y-64,128,128),i.vjCanvasContext.clearRect(this._joystickPreviousPointerPos.x-42,this._joystickPreviousPointerPos.y-42,84,84),this._joystickPointerID=-1,this.pressed=!1;else{var t=this._touches.get(e.pointerId.toString());t&&i.vjCanvasContext.clearRect(t.prevX-44,t.prevY-44,88,88)}this._deltaJoystickVector.x=0,this._deltaJoystickVector.y=0,this._touches.remove(e.pointerId.toString())},i.prototype.setJoystickColor=function(e){this._joystickColor=e},i.prototype.setActionOnTouch=function(e){this._action=e},i.prototype.setAxisForLeftRight=function(e){switch(e){case t.X:case t.Y:case t.Z:this._axisTargetedByLeftAndRight=e;break;default:this._axisTargetedByLeftAndRight=t.X}},i.prototype.setAxisForUpDown=function(e){switch(e){case t.X:case t.Y:case t.Z:this._axisTargetedByUpAndDown=e;break;default:this._axisTargetedByUpAndDown=t.Y}},i.prototype._clearCanvas=function(){this._leftJoystick?i.vjCanvasContext.clearRect(0,0,i.vjCanvasWidth/2,i.vjCanvasHeight):i.vjCanvasContext.clearRect(i.vjCanvasWidth/2,0,i.vjCanvasWidth,i.vjCanvasHeight)},i.prototype._drawVirtualJoystick=function(){var e=this;this.pressed&&this._touches.forEach((function(t,r){r.pointerId===e._joystickPointerID?(i.vjCanvasContext.clearRect(e._joystickPointerStartPos.x-64,e._joystickPointerStartPos.y-64,128,128),i.vjCanvasContext.clearRect(e._joystickPreviousPointerPos.x-42,e._joystickPreviousPointerPos.y-42,84,84),i.vjCanvasContext.beginPath(),i.vjCanvasContext.lineWidth=6,i.vjCanvasContext.strokeStyle=e._joystickColor,i.vjCanvasContext.arc(e._joystickPointerStartPos.x,e._joystickPointerStartPos.y,40,0,2*Math.PI,!0),i.vjCanvasContext.stroke(),i.vjCanvasContext.closePath(),i.vjCanvasContext.beginPath(),i.vjCanvasContext.strokeStyle=e._joystickColor,i.vjCanvasContext.lineWidth=2,i.vjCanvasContext.arc(e._joystickPointerStartPos.x,e._joystickPointerStartPos.y,60,0,2*Math.PI,!0),i.vjCanvasContext.stroke(),i.vjCanvasContext.closePath(),i.vjCanvasContext.beginPath(),i.vjCanvasContext.strokeStyle=e._joystickColor,i.vjCanvasContext.arc(e._joystickPointerPos.x,e._joystickPointerPos.y,40,0,2*Math.PI,!0),i.vjCanvasContext.stroke(),i.vjCanvasContext.closePath(),e._joystickPreviousPointerPos=e._joystickPointerPos.clone()):(i.vjCanvasContext.clearRect(r.prevX-44,r.prevY-44,88,88),i.vjCanvasContext.beginPath(),i.vjCanvasContext.fillStyle="white",i.vjCanvasContext.beginPath(),i.vjCanvasContext.strokeStyle="red",i.vjCanvasContext.lineWidth=6,i.vjCanvasContext.arc(r.x,r.y,40,0,2*Math.PI,!0),i.vjCanvasContext.stroke(),i.vjCanvasContext.closePath(),r.prevX=r.x,r.prevY=r.y)})),requestAnimationFrame((function(){e._drawVirtualJoystick()}))},i.prototype.releaseCanvas=function(){i.vjCanvas&&(i.vjCanvas.removeEventListener("pointerdown",this._onPointerDownHandlerRef),i.vjCanvas.removeEventListener("pointermove",this._onPointerMoveHandlerRef),i.vjCanvas.removeEventListener("pointerup",this._onPointerUpHandlerRef),i.vjCanvas.removeEventListener("pointerout",this._onPointerUpHandlerRef),window.removeEventListener("resize",this._onResize),document.body.removeChild(i.vjCanvas),i.vjCanvas=null)},i})();i._globalJoystickIndex=0,e.VirtualJoystick=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(e){function t(t,i,r){var n=e.call(this,t,i,r)||this;return n.inputs.addVirtualJoystick(),n}return __extends(t,e),t.prototype.getClassName=function(){return"VirtualJoysticksCamera"},t})(e.FreeCamera);e.VirtualJoysticksCamera=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){}return t.prototype.getLeftJoystick=function(){return this._leftjoystick},t.prototype.getRightJoystick=function(){return this._rightjoystick},t.prototype.checkInputs=function(){if(this._leftjoystick){var t=this.camera,i=50*t._computeLocalCameraSpeed(),r=e.Matrix.RotationYawPitchRoll(t.rotation.y,t.rotation.x,0),n=e.Vector3.TransformCoordinates(new e.Vector3(this._leftjoystick.deltaPosition.x*i,this._leftjoystick.deltaPosition.y*i,this._leftjoystick.deltaPosition.z*i),r);t.cameraDirection=t.cameraDirection.add(n),t.cameraRotation=t.cameraRotation.addVector3(this._rightjoystick.deltaPosition),this._leftjoystick.pressed||(this._leftjoystick.deltaPosition=this._leftjoystick.deltaPosition.scale(.9)),this._rightjoystick.pressed||(this._rightjoystick.deltaPosition=this._rightjoystick.deltaPosition.scale(.9))}},t.prototype.attachControl=function(t,i){this._leftjoystick=new e.VirtualJoystick(!0),this._leftjoystick.setAxisForUpDown(e.JoystickAxis.Z),this._leftjoystick.setAxisForLeftRight(e.JoystickAxis.X),this._leftjoystick.setJoystickSensibility(.15),this._rightjoystick=new e.VirtualJoystick(!1),this._rightjoystick.setAxisForUpDown(e.JoystickAxis.X),this._rightjoystick.setAxisForLeftRight(e.JoystickAxis.Y),this._rightjoystick.reverseUpDown=!0,this._rightjoystick.setJoystickSensibility(.05),this._rightjoystick.setJoystickColor("yellow")},t.prototype.detachControl=function(e){this._leftjoystick.releaseCanvas(),this._rightjoystick.releaseCanvas()},t.prototype.getClassName=function(){return"FreeCameraVirtualJoystickInput"},t.prototype.getSimpleName=function(){return"virtualJoystick"},t})();e.FreeCameraVirtualJoystickInput=t,e.CameraInputTypes.FreeCameraVirtualJoystickInput=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(e,t,i){this.quality=e,this.distance=t,this.optimizeMesh=i}return e})();e.SimplificationSettings=t;var i=(function(){function t(){this.running=!1,this._simplificationArray=[]}return t.prototype.addTask=function(e){this._simplificationArray.push(e)},t.prototype.executeNext=function(){var e=this._simplificationArray.pop();e?(this.running=!0,this.runSimplification(e)):this.running=!1},t.prototype.runSimplification=function(t){var i=this;if(t.parallelProcessing)t.settings.forEach((function(e){i.getSimplifier(t).simplify(e,(function(r){t.mesh.addLODLevel(e.distance,r),r.isVisible=!0,e.quality===t.settings[t.settings.length-1].quality&&t.successCallback&&t.successCallback(),i.executeNext()}))}));else{var r=this.getSimplifier(t),n=function(e,i){r.simplify(e,(function(r){t.mesh.addLODLevel(e.distance,r),r.isVisible=!0,i()}))};e.AsyncLoop.Run(t.settings.length,(function(e){n(t.settings[e.index],(function(){e.executeNext()}))}),(function(){t.successCallback&&t.successCallback(),i.executeNext()}))}},t.prototype.getSimplifier=function(e){switch(e.simplificationType){case r.QUADRATIC:default:return new l(e.mesh)}},t})();e.SimplificationQueue=i;var r;!(function(e){e[e.QUADRATIC=0]="QUADRATIC"})(r=e.SimplificationType||(e.SimplificationType={}));var n=(function(){function e(e){this.vertices=e,this.error=new Array(4),this.deleted=!1,this.isDirty=!1,this.deletePending=!1,this.borderFactor=0}return e})();e.DecimationTriangle=n;var o=(function(){function e(e,t){this.position=e,this.id=t,this.isBorder=!0,this.q=new s,this.triangleCount=0,this.triangleStart=0,this.originalOffsets=[]}return e.prototype.updatePosition=function(e){this.position.copyFrom(e)},e})();e.DecimationVertex=o;var s=(function(){function e(e){this.data=new Array(10);for(var t=0;t<10;++t)e&&e[t]?this.data[t]=e[t]:this.data[t]=0}return e.prototype.det=function(e,t,i,r,n,o,s,a,l){return this.data[e]*this.data[n]*this.data[l]+this.data[i]*this.data[r]*this.data[a]+this.data[t]*this.data[o]*this.data[s]-this.data[i]*this.data[n]*this.data[s]-this.data[e]*this.data[o]*this.data[a]-this.data[t]*this.data[r]*this.data[l]},e.prototype.addInPlace=function(e){for(var t=0;t<10;++t)this.data[t]+=e.data[t]},e.prototype.addArrayInPlace=function(e){for(var t=0;t<10;++t)this.data[t]+=e[t]},e.prototype.add=function(t){for(var i=new e,r=0;r<10;++r)i.data[r]=this.data[r]+t.data[r];return i},e.FromData=function(t,i,r,n){return new e(e.DataFromNumbers(t,i,r,n))},e.DataFromNumbers=function(e,t,i,r){return[e*e,e*t,e*i,e*r,t*t,t*i,t*r,i*i,i*r,r*r]},e})();e.QuadraticMatrix=s;var a=(function(){function e(e,t){this.vertexId=e,this.triangleId=t}return e})();e.Reference=a;var l=(function(){function t(t){this._mesh=t,this.initialized=!1,this.syncIterations=5e3,this.aggressiveness=7,this.decimationIterations=100,this.boundingBoxEpsilon=e.Epsilon}return t.prototype.simplify=function(t,i){var r=this;this.initDecimatedMesh(),e.AsyncLoop.Run(this._mesh.subMeshes.length,(function(e){r.initWithMesh(e.index,(function(){r.runDecimation(t,e.index,(function(){e.executeNext()}))}),t.optimizeMesh)}),(function(){setTimeout((function(){i(r._reconstructedMesh)}),0)}))},t.prototype.isTriangleOnBoundingBox=function(e){var t=this,i=0;return e.vertices.forEach((function(e){var r=0,n=e.position,o=t._mesh.getBoundingInfo().boundingBox;(o.maximum.x-n.xt.boundingBoxEpsilon)&&++r,o.maximum.y!==n.y&&n.y!==o.minimum.y||++r,o.maximum.z!==n.z&&n.z!==o.minimum.z||++r,r>1&&++i})),i>1&&console.log(e,i),i>1},t.prototype.runDecimation=function(t,i,r){var n=this,o=~~(this.triangles.length*t.quality),s=0,a=this.triangles.length,l=function(t,i){setTimeout((function(){t%5==0&&n.updateMesh(0===t);for(var r=0;rl||r.deleted||r.isDirty))for(var o=0;o<3;++o)if(r.error[o]>0,f,(function(){var t=function(e){var t=h.indexStart/3+e,i=3*t,r=l[i+0],o=l[i+1],a=l[i+2],c=s.vertices[u[r-h.verticesStart]],f=s.vertices[u[o-h.verticesStart]],d=s.vertices[u[a-h.verticesStart]],p=new n([c,f,d]);p.originalOffset=i,s.triangles.push(p)};e.AsyncLoop.SyncAsyncForLoop(h.indexCount/3,s.syncIterations,t,(function(){s.init(i)}))}))},t.prototype.init=function(t){var i=this,r=function(t){var r=i.triangles[t];r.normal=e.Vector3.Cross(r.vertices[1].position.subtract(r.vertices[0].position),r.vertices[2].position.subtract(r.vertices[0].position)).normalize();for(var n=0;n<3;n++)r.vertices[n].q.addArrayInPlace(s.DataFromNumbers(r.normal.x,r.normal.y,r.normal.z,-e.Vector3.Dot(r.normal,r.vertices[0].position)))};e.AsyncLoop.SyncAsyncForLoop(this.triangles.length,this.syncIterations,r,(function(){var r=function(e){for(var t=i.triangles[e],r=0;r<3;++r)t.error[r]=i.calculateError(t.vertices[r],t.vertices[(r+1)%3]);t.error[3]=Math.min(t.error[0],t.error[1],t.error[2])};e.AsyncLoop.SyncAsyncForLoop(i.triangles.length,i.syncIterations,r,(function(){i.initialized=!0,t()}))}))},t.prototype.reconstructMesh=function(t){var i,r=[];for(i=0;i0&&this._reconstructedMesh.setVerticesData(e.VertexBuffer.UVKind,l),h.length>0&&this._reconstructedMesh.setVerticesData(e.VertexBuffer.ColorKind,h);var x=this._mesh.subMeshes[t];if(t>0){this._reconstructedMesh.subMeshes=[],g.forEach((function(t){new e.SubMesh(t.materialIndex,t.verticesStart,t.verticesCount,t.indexStart,t.indexCount,t.getMesh())}));new e.SubMesh(x.materialIndex,m,d,_,3*r.length,this._reconstructedMesh)}},t.prototype.initDecimatedMesh=function(){this._reconstructedMesh=new e.Mesh(this._mesh.name+"Decimated",this._mesh.getScene()),this._reconstructedMesh.material=this._mesh.material,this._reconstructedMesh.parent=this._mesh.parent,this._reconstructedMesh.isVisible=!1,this._reconstructedMesh.renderingGroupId=this._mesh.renderingGroupId},t.prototype.isFlipped=function(t,i,r,n,o,s){for(var a=0;a.999)return!0;var p=e.Vector3.Cross(f,d).normalize();if(n[a]=!1,e.Vector3.Dot(p,l.normal)<.2)return!0}else n[a]=!0,s.push(l)}}return!1},t.prototype.updateTriangles=function(e,t,i,r){for(var n=r,o=0;or.maximumSize&&(n.scale(.5),t=!1)}}return t},r}return __extends(t,e),t})(t);e.TextureOptimization=i;var r=(function(e){function t(t,i){void 0===t&&(t=0),void 0===i&&(i=2);var r=e.call(this,t)||this;return r.priority=t,r.maximumScale=i,r._currentScale=1,r.apply=function(e){return r._currentScale++,e.getEngine().setHardwareScalingLevel(r._currentScale),r._currentScale>=r.maximumScale},r}return __extends(t,e),t})(t);e.HardwareScalingOptimization=r;var n=(function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.apply=function(e){return e.shadowsEnabled=!1,!0},t}return __extends(t,e),t})(t);e.ShadowsOptimization=n;var o=(function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.apply=function(e){return e.postProcessesEnabled=!1,!0},t}return __extends(t,e),t})(t);e.PostProcessesOptimization=o;var s=(function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.apply=function(e){return e.lensFlaresEnabled=!1,!0},t}return __extends(t,e),t})(t);e.LensFlaresOptimization=s;var a=(function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.apply=function(e){return e.particlesEnabled=!1,!0},t}return __extends(t,e),t})(t);e.ParticlesOptimization=a;var l=(function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.apply=function(e){return e.renderTargetsEnabled=!1,!0},t}return __extends(t,e),t})(t);e.RenderTargetsOptimization=l;var h=(function(t){function i(){var r=null!==t&&t.apply(this,arguments)||this;return r._canBeMerged=function(t){if(!(t instanceof e.Mesh))return!1;var i=t;return!(!i.isVisible||!i.isEnabled())&&(!(i.instances.length>0)&&(!i.skeleton&&!i.hasLODLevels&&!i.parent))},r.apply=function(t,n){for(var o=t.meshes.slice(0),s=o.length,a=0;a=i.targetFrameRate)return void(n&&n());for(var s=!0,a=!0,l=0;l4&&(n.push(e.VertexBuffer.MatricesIndicesExtraKind),n.push(e.VertexBuffer.MatricesWeightsExtraKind)),r.push("#define NUM_BONE_INFLUENCERS "+o.numBoneInfluencers),r.push("#define BonesPerMesh "+(o.skeleton.bones.length+1))):r.push("#define NUM_BONE_INFLUENCERS 0"),i&&(r.push("#define INSTANCES"),n.push("world0"),n.push("world1"),n.push("world2"),n.push("world3"));var a=r.join("\n");return this._cachedDefines!==a&&(this._cachedDefines=a,this._effect=this._scene.getEngine().createEffect("outline",n,["world","mBones","viewProjection","diffuseMatrix","offset","color"],["diffuseSampler"],a)),this._effect.isReady()},t})();e.OutlineRenderer=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(){this.edges=new Array,this.edgesConnectedCount=0}return e})(),i=(function(){function i(e,t,i){void 0===t&&(t=.95),void 0===i&&(i=!1),this.edgesWidthScalerForOrthographic=1e3,this.edgesWidthScalerForPerspective=50,this._linesPositions=new Array,this._linesNormals=new Array,this._linesIndices=new Array,this._buffers={},this._checkVerticesInsteadOfIndices=!1,this._source=e,this._checkVerticesInsteadOfIndices=i,this._epsilon=t,this._prepareRessources(),this._generateEdgesLines()}return i.prototype._prepareRessources=function(){this._lineShader||(this._lineShader=new e.ShaderMaterial("lineShader",this._source.getScene(),"line",{attributes:["position","normal"],uniforms:["worldViewProjection","color","width","aspectRatio"]}),this._lineShader.disableDepthWrite=!0,this._lineShader.backFaceCulling=!1)},i.prototype.dispose=function(){var t=this._buffers[e.VertexBuffer.PositionKind];t&&(t.dispose(),this._buffers[e.VertexBuffer.PositionKind]=null),t=this._buffers[e.VertexBuffer.NormalKind],t&&(t.dispose(),this._buffers[e.VertexBuffer.NormalKind]=null),this._source.getScene().getEngine()._releaseBuffer(this._ib),this._lineShader.dispose()},i.prototype._processEdgeForAdjacencies=function(e,t,i,r,n){return e===i&&t===r||e===r&&t===i?0:e===r&&t===n||e===n&&t===r?1:e===n&&t===i||e===i&&t===n?2:-1},i.prototype._processEdgeForAdjacenciesWithVertices=function(e,t,i,r,n){return e.equalsWithEpsilon(i)&&t.equalsWithEpsilon(r)||e.equalsWithEpsilon(r)&&t.equalsWithEpsilon(i)?0:e.equalsWithEpsilon(r)&&t.equalsWithEpsilon(n)||e.equalsWithEpsilon(n)&&t.equalsWithEpsilon(r)?1:e.equalsWithEpsilon(n)&&t.equalsWithEpsilon(i)||e.equalsWithEpsilon(i)&&t.equalsWithEpsilon(n)?2:-1},i.prototype._checkEdge=function(t,i,r,n,o){var s;if(void 0===i)s=!0;else{s=e.Vector3.Dot(r[t],r[i])4&&(o.push(e.VertexBuffer.MatricesIndicesExtraKind),o.push(e.VertexBuffer.MatricesWeightsExtraKind)),n.push("#define NUM_BONE_INFLUENCERS "+s.numBoneInfluencers),n.push("#define BonesPerMesh "+(s.skeleton.bones.length+1))):n.push("#define NUM_BONE_INFLUENCERS 0"),i&&(n.push("#define INSTANCES"),o.push("world0"),o.push("world1"),o.push("world2"),o.push("world3"));var u=n.join("\n");return this._cachedDefines!==u&&(this._cachedDefines=u,this._glowMapGenerationEffect=this._scene.getEngine().createEffect("glowMapGeneration",o,["world","mBones","viewProjection","diffuseMatrix","color","emissiveMatrix"],["diffuseSampler","emissiveSampler"],u)),this._glowMapGenerationEffect.isReady()},i.prototype.render=function(){var t=this._glowMapMergeEffect;if(t.isReady()&&this._blurTexture.isReady()){var i=this._scene.getEngine();this.onBeforeComposeObservable.notifyObservers(this),i.enableEffect(t),i.setState(!1);var r=i.getStencilBuffer(),n=i.getStencilFunction(),o=i.getStencilMask(),s=i.getStencilOperationPass(),a=i.getStencilOperationFail(),l=i.getStencilOperationDepthFail(),h=i.getAlphaMode();t.setTexture("textureSampler",this._blurTexture),i.bindBuffers(this._vertexBuffers,this._indexBuffer,t),i.setStencilOperationPass(e.Engine.REPLACE),i.setStencilOperationFail(e.Engine.KEEP),i.setStencilOperationDepthFail(e.Engine.KEEP),i.setAlphaMode(this._options.alphaBlendingMode),i.setStencilMask(0),i.setStencilBuffer(!0),i.setStencilFunctionReference(this._instanceGlowingMeshStencilReference),this.outerGlow&&(t.setFloat("offset",0),i.setStencilFunction(e.Engine.NOTEQUAL),i.draw(!0,0,6)),this.innerGlow&&(t.setFloat("offset",1),i.setStencilFunction(e.Engine.EQUAL),i.draw(!0,0,6)),i.setStencilFunction(n),i.setStencilMask(o),i.setAlphaMode(h),i.setStencilBuffer(r),i.setStencilOperationPass(s),i.setStencilOperationFail(a),i.setStencilOperationDepthFail(l),i._stencilState.reset(),this.onAfterComposeObservable.notifyObservers(this);var c=this._mainTexture.getSize();this.setMainTextureSize(),c.width===this._mainTextureDesiredSize.width&&c.height===this._mainTextureDesiredSize.height||(this.onSizeChangedObservable.notifyObservers(this),this.disposeTextureAndPostProcesses(),this.createTextureAndPostProcesses())}},i.prototype.addExcludedMesh=function(e){this._excludedMeshes[e.uniqueId]||(this._excludedMeshes[e.uniqueId]={mesh:e,beforeRender:e.onBeforeRenderObservable.add((function(e){e.getEngine().setStencilBuffer(!1)})),afterRender:e.onAfterRenderObservable.add((function(e){e.getEngine().setStencilBuffer(!0)}))})},i.prototype.removeExcludedMesh=function(e){var t=this._excludedMeshes[e.uniqueId];t&&(e.onBeforeRenderObservable.remove(t.beforeRender),e.onAfterRenderObservable.remove(t.afterRender)),this._excludedMeshes[e.uniqueId]=void 0},i.prototype.addMesh=function(e,t,i){var r=this;void 0===i&&(i=!1);var n=this._meshes[e.uniqueId];n?n.color=t:this._meshes[e.uniqueId]={mesh:e,color:t,observerHighlight:e.onBeforeRenderObservable.add((function(e){r._excludedMeshes[e.uniqueId]?r.defaultStencilReference(e):e.getScene().getEngine().setStencilFunctionReference(r._instanceGlowingMeshStencilReference)})),observerDefault:e.onAfterRenderObservable.add(this.defaultStencilReference),glowEmissiveOnly:i},this._shouldRender=!0},i.prototype.removeMesh=function(e){var t=this._meshes[e.uniqueId];t&&(e.onBeforeRenderObservable.remove(t.observerHighlight),e.onAfterRenderObservable.remove(t.observerDefault)),this._meshes[e.uniqueId]=void 0,this._shouldRender=!1;for(var i in this._meshes)if(i){this._shouldRender=!0;break}},i.prototype.shouldRender=function(){return this.isEnabled&&this._shouldRender},i.prototype.setMainTextureSize=function(){this._options.mainTextureFixedSize?(this._mainTextureDesiredSize.width=this._options.mainTextureFixedSize,this._mainTextureDesiredSize.height=this._options.mainTextureFixedSize):(this._mainTextureDesiredSize.width=this._engine.getRenderingCanvas().width*this._options.mainTextureRatio,this._mainTextureDesiredSize.height=this._engine.getRenderingCanvas().height*this._options.mainTextureRatio,this._mainTextureDesiredSize.width=this._engine.needPOTTextures?e.Tools.GetExponentOfTwo(this._mainTextureDesiredSize.width,this._maxSize):this._mainTextureDesiredSize.width,this._mainTextureDesiredSize.height=this._engine.needPOTTextures?e.Tools.GetExponentOfTwo(this._mainTextureDesiredSize.height,this._maxSize):this._mainTextureDesiredSize.height)},i.prototype.defaultStencilReference=function(e){e.getScene().getEngine().setStencilFunctionReference(i.normalMeshStencilReference)},i.prototype.disposeTextureAndPostProcesses=function(){this._blurTexture.dispose(),this._mainTexture.dispose(),this._downSamplePostprocess.dispose(),this._horizontalBlurPostprocess.dispose(),this._verticalBlurPostprocess.dispose()},i.prototype.dispose=function(){var t=this._vertexBuffers[e.VertexBuffer.PositionKind];t&&(t.dispose(),this._vertexBuffers[e.VertexBuffer.PositionKind]=null),this._indexBuffer&&(this._scene.getEngine()._releaseBuffer(this._indexBuffer),this._indexBuffer=null),this.disposeTextureAndPostProcesses();for(var i in this._meshes){var r=this._meshes[i];r&&r.mesh&&(r.mesh.onBeforeRenderObservable.remove(r.observerHighlight),r.mesh.onAfterRenderObservable.remove(r.observerDefault))}this._meshes=null;for(var i in this._excludedMeshes){var r=this._excludedMeshes[i];r&&(r.mesh.onBeforeRenderObservable.remove(r.beforeRender),r.mesh.onAfterRenderObservable.remove(r.afterRender))}this._excludedMeshes=null;var n=this._scene.highlightLayers.indexOf(this,0);n>-1&&this._scene.highlightLayers.splice(n,1),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onBeforeRenderMainTextureObservable.clear(),this.onBeforeBlurObservable.clear(),this.onBeforeComposeObservable.clear(),this.onAfterComposeObservable.clear(),this.onSizeChangedObservable.clear()},i})();i.neutralColor=new e.Color4(0,0,0,0),i.glowingMeshStencilReference=2,i.normalMeshStencilReference=1,e.HighlightLayer=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e,t,i,r){this.name=e,this.meshesNames=t,this.rootUrl=i,this.sceneFilename=r,this.isCompleted=!1}return t.prototype.run=function(t,i,r){var n=this;e.SceneLoader.ImportMesh(this.meshesNames,this.rootUrl,this.sceneFilename,t,(function(e,t,r){n.loadedMeshes=e,n.loadedParticleSystems=t,n.loadedSkeletons=r,n.isCompleted=!0,n.onSuccess&&n.onSuccess(n),i()}),null,(function(){n.onError&&n.onError(n),r()}))},t})();e.MeshAssetTask=t;var i=(function(){function t(e,t){this.name=e,this.url=t,this.isCompleted=!1}return t.prototype.run=function(t,i,r){var n=this;e.Tools.LoadFile(this.url,(function(e){n.text=e,n.isCompleted=!0,n.onSuccess&&n.onSuccess(n),i()}),null,t.database,!1,(function(){n.onError&&n.onError(n),r()}))},t})();e.TextFileAssetTask=i;var r=(function(){function t(e,t){this.name=e,this.url=t,this.isCompleted=!1}return t.prototype.run=function(t,i,r){var n=this;e.Tools.LoadFile(this.url,(function(e){n.data=e,n.isCompleted=!0,n.onSuccess&&n.onSuccess(n),i()}),null,t.database,!0,(function(){n.onError&&n.onError(n),r()}))},t})();e.BinaryFileAssetTask=r;var n=(function(){function t(e,t){this.name=e,this.url=t,this.isCompleted=!1}return t.prototype.run=function(t,i,r){var n=this,o=new Image;e.Tools.SetCorsBehavior(this.url,o),o.onload=function(){n.image=o,n.isCompleted=!0,n.onSuccess&&n.onSuccess(n),i()},o.onerror=function(){n.onError&&n.onError(n),r()},o.src=this.url},t})();e.ImageAssetTask=n;var o=(function(){function t(t,i,r,n,o){void 0===o&&(o=e.Texture.TRILINEAR_SAMPLINGMODE),this.name=t,this.url=i,this.noMipmap=r,this.invertY=n,this.samplingMode=o,this.isCompleted=!1}return t.prototype.run=function(t,i,r){var n=this,o=function(){n.isCompleted=!0,n.onSuccess&&n.onSuccess(n),i()},s=function(){n.onError&&n.onError(n),r()};this.texture=new e.Texture(this.url,t,this.noMipmap,this.invertY,this.samplingMode,o,s)},t})();e.TextureAssetTask=o;var s=(function(){function t(e,t,i,r,n){this.name=e,this.url=t,this.extensions=i,this.noMipmap=r,this.files=n,this.isCompleted=!1}return t.prototype.run=function(t,i,r){var n=this,o=function(){n.isCompleted=!0,n.onSuccess&&n.onSuccess(n),i()},s=function(){n.onError&&n.onError(n),r()};this.texture=new e.CubeTexture(this.url,t,this.extensions,this.noMipmap,this.files,o,s)},t})();e.CubeTextureAssetTask=s;var a=(function(){function t(e,t,i,r,n,o,s){void 0===r&&(r=!1),void 0===n&&(n=!0),void 0===o&&(o=!1),void 0===s&&(s=!1),this.name=e,this.url=t,this.size=i,this.noMipmap=r,this.generateHarmonics=n,this.useInGammaSpace=o,this.usePMREMGenerator=s,this.isCompleted=!1}return t.prototype.run=function(t,i,r){var n=this,o=function(){n.isCompleted=!0,n.onSuccess&&n.onSuccess(n),i()},s=function(){n.onError&&n.onError(n),r()};this.texture=new e.HDRCubeTexture(this.url,t,this.size,this.noMipmap,this.generateHarmonics,this.useInGammaSpace,this.usePMREMGenerator,o,s)},t})();e.HDRCubeTextureAssetTask=a;var l=(function(){function l(e){this.tasks=new Array,this.waitingTasksCount=0,this.useDefaultLoadingScreen=!0,this._scene=e}return l.prototype.addMeshTask=function(e,i,r,n){var o=new t(e,i,r,n);return this.tasks.push(o),o},l.prototype.addTextFileTask=function(e,t){var r=new i(e,t);return this.tasks.push(r),r},l.prototype.addBinaryFileTask=function(e,t){var i=new r(e,t);return this.tasks.push(i),i},l.prototype.addImageTask=function(e,t){var i=new n(e,t);return this.tasks.push(i),i},l.prototype.addTextureTask=function(t,i,r,n,s){void 0===s&&(s=e.Texture.TRILINEAR_SAMPLINGMODE);var a=new o(t,i,r,n,s);return this.tasks.push(a),a},l.prototype.addCubeTextureTask=function(e,t,i,r,n){var o=new s(e,t,i,r,n);return this.tasks.push(o),o},l.prototype.addHDRCubeTextureTask=function(e,t,i,r,n,o,s){void 0===r&&(r=!1),void 0===n&&(n=!0),void 0===o&&(o=!1),void 0===s&&(s=!1);var l=new a(e,t,i,r,n,o,s);return this.tasks.push(l),l},l.prototype._decreaseWaitingTasksCount=function(){0===--this.waitingTasksCount&&(this.onFinish&&this.onFinish(this.tasks),this._scene.getEngine().hideLoadingUI())},l.prototype._runTask=function(e){var t=this;e.run(this._scene,(function(){t.onTaskSuccess&&t.onTaskSuccess(e),t._decreaseWaitingTasksCount()}),(function(){t.onTaskError&&t.onTaskError(e),t._decreaseWaitingTasksCount()}))},l.prototype.reset=function(){return this.tasks=new Array,this},l.prototype.load=function(){if(this.waitingTasksCount=this.tasks.length,0===this.waitingTasksCount)return this.onFinish&&this.onFinish(this.tasks),this;this.useDefaultLoadingScreen&&this._scene.getEngine().displayLoadingUI();for(var e=0;e0},enumerable:!0,configurable:!0}),r.prototype._sortLODLevels=function(){this._LODLevels.sort((function(e,t){return e.distancet.distance?-1:0}))},r.prototype.addLODLevel=function(t,i){if(i&&i._masterMesh)return e.Tools.Warn("You cannot use a mesh as LOD level twice"),this;var r=new e.Internals.MeshLODLevel(t,i);return this._LODLevels.push(r),i&&(i._masterMesh=this),this._sortLODLevels(),this},r.prototype.getLODLevelAtDistance=function(e){for(var t=0;ti)return this.onLODLevelSelection&&this.onLODLevelSelection(i,this,this._LODLevels[this._LODLevels.length-1].mesh),this;for(var r=0;r0){var r=this.getIndices().length,n=!1;if(t)n=!0;else for(var o=0,s=this.subMeshes;o=r){n=!0;break}if(a.verticesStart+a.verticesCount>=i){n=!0;break}}if(!n)return}return this.releaseSubMeshes(),new e.SubMesh(0,0,i,0,this.getTotalIndices(),this)},r.prototype.subdivide=function(t){if(!(t<1)){for(var i=this.getTotalIndices(),r=i/t|0,n=0;r%3!=0;)r++;this.releaseSubMeshes();for(var o=0;o=i);o++)e.SubMesh.CreateFromIndices(0,n,Math.min(r,i-n),this),n+=r;this.synchronizeInstances()}},r.prototype.setVerticesData=function(t,i,r,n){if(this._geometry)this._geometry.setVerticesData(t,i,r,n);else{var o=new e.VertexData;o.set(i,t);var s=this.getScene();new e.Geometry(e.Geometry.RandomId(),s,o,r,this)}return this},r.prototype.markVerticesDataAsUpdatable=function(e,t){void 0===t&&(t=!0),this.getVertexBuffer(e).isUpdatable()!==t&&this.setVerticesData(e,this.getVerticesData(e),t)},r.prototype.setVerticesBuffer=function(t){if(!this._geometry){var i=this.getScene();new e.Geometry(e.Geometry.RandomId(),i).applyToMesh(this)}return this._geometry.setVerticesBuffer(t),this},r.prototype.updateVerticesData=function(e,t,i,r){if(this._geometry)return r?(this.makeGeometryUnique(),this.updateVerticesData(e,t,i,!1)):this._geometry.updateVerticesData(e,t,i),this},r.prototype.updateMeshPositions=function(t,i){void 0===i&&(i=!0);var r=this.getVerticesData(e.VertexBuffer.PositionKind);if(t(r),this.updateVerticesData(e.VertexBuffer.PositionKind,r,!1,!1),i){var n=this.getIndices(),o=this.getVerticesData(e.VertexBuffer.NormalKind);e.VertexData.ComputeNormals(r,n,o),this.updateVerticesData(e.VertexBuffer.NormalKind,o,!1,!1)}return this},r.prototype.makeGeometryUnique=function(){if(this._geometry){var t=this._geometry,i=this._geometry.copy(e.Geometry.RandomId());return t.releaseForMesh(this,!0),i.applyToMesh(this),this}},r.prototype.setIndices=function(t,i){if(this._geometry)this._geometry.setIndices(t,i);else{var r=new e.VertexData;r.indices=t;var n=this.getScene();new e.Geometry(e.Geometry.RandomId(),n,r,!1,this)}return this},r.prototype.toLeftHanded=function(){if(this._geometry)return this._geometry.toLeftHanded(),this},r.prototype._bind=function(t,i,r){var n,o=this.getScene().getEngine();if(this._unIndexed)n=null;else switch(r){case e.Material.PointFillMode:n=null;break;case e.Material.WireFrameFillMode:n=t.getLinesIndexBuffer(this.getIndices(),o);break;default:case e.Material.TriangleFillMode:n=this._unIndexed?null:this._geometry.getIndexBuffer()}return this._geometry._bind(i,n),this},r.prototype._draw=function(t,i,r){if(!this._geometry||!this._geometry.getVertexBuffers()||!this._geometry.getIndexBuffer())return this;this.onBeforeDrawObservable.notifyObservers(this);var n=this.getScene().getEngine();switch(i){case e.Material.PointFillMode:n.drawPointClouds(t.verticesStart,t.verticesCount,r);break;case e.Material.WireFrameFillMode:this._unIndexed?n.drawUnIndexed(!1,t.verticesStart,t.verticesCount,r):n.draw(!1,0,r>0?t.linesIndexCount/2:t.linesIndexCount,r);break;default:this._unIndexed?n.drawUnIndexed(!0,t.verticesStart,t.verticesCount,r):n.draw(!0,t.indexStart,t.indexCount,r)}return this},r.prototype.registerBeforeRender=function(e){return this.onBeforeRenderObservable.add(e),this},r.prototype.unregisterBeforeRender=function(e){return this.onBeforeRenderObservable.removeCallback(e),this},r.prototype.registerAfterRender=function(e){return this.onAfterRenderObservable.add(e),this},r.prototype.unregisterAfterRender=function(e){return this.onAfterRenderObservable.removeCallback(e),this},r.prototype._getInstancesRenderList=function(e){var t=this.getScene();if(this._batchCache.mustReturn=!1,this._batchCache.renderSelf[e]=this.isEnabled()&&this.isVisible,this._batchCache.visibleInstances[e]=null,this._visibleInstances){var i=t.getRenderId(),r=t._isInIntermediateRendering()?this._visibleInstances.intermediateDefaultRenderId:this._visibleInstances.defaultRenderId;this._batchCache.visibleInstances[e]=this._visibleInstances[i];var n=this._renderId;if(!this._batchCache.visibleInstances[e]&&r&&(this._batchCache.visibleInstances[e]=this._visibleInstances[r],i=Math.max(r,i),n=Math.max(this._visibleInstances.selfDefaultRenderId,i)),this._batchCache.visibleInstances[e]&&this._batchCache.visibleInstances[e].length){if(this._renderIdForInstances[e]===i)return this._batchCache.mustReturn=!0,this._batchCache;i!==n&&(this._batchCache.renderSelf[e]=!1)}this._renderIdForInstances[e]=i}return this._batchCache},r.prototype._renderWithInstances=function(t,i,r,n,o){for(var s=r.visibleInstances[t._id],a=s.length+1,l=16*a*4,h=this._instancesBufferSize,c=this._instancesBuffer;this._instancesBufferSize-1;t--)if(i[t].id===e)return this.material=i[t],this;var r=this.getScene().multiMaterials;for(t=r.length-1;t>-1;t--)if(r[t].id===e)return this.material=r[t],this;return this},r.prototype.getAnimatables=function(){var e=[];return this.material&&e.push(this.material),this.skeleton&&e.push(this.skeleton),e},r.prototype.bakeTransformIntoVertices=function(t){if(!this.isVerticesDataPresent(e.VertexBuffer.PositionKind))return this;var i=this.subMeshes.splice(0);this._resetPointsArrayCache();var r,n=this.getVerticesData(e.VertexBuffer.PositionKind),o=[];for(r=0;r-1&&(o.morphTargetManager=i.getMorphTargetManagerById(t.morphTargetManagerId)),t.skeletonId>-1&&(o.skeleton=i.getLastSkeletonByID(t.skeletonId),t.numBoneInfluencers&&(o.numBoneInfluencers=t.numBoneInfluencers)),t.animations){for(var s=0;s4,h=l?this.getVerticesData(e.VertexBuffer.MatricesIndicesExtraKind):null,c=l?this.getVerticesData(e.VertexBuffer.MatricesWeightsExtraKind):null,u=t.getTransformMatrices(this),f=e.Vector3.Zero(),d=new e.Matrix,p=new e.Matrix,_=0,m=0;m0;o++)e.Matrix.FromFloat32ArrayToRefScaled(u,16*s[_+o],g,p),d.addToSelf(p);if(l)for(o=0;o<4&&(g=c[_+o])>0;o++)e.Matrix.FromFloat32ArrayToRefScaled(u,16*h[_+o],g,p),d.addToSelf(p);e.Vector3.TransformCoordinatesFromFloatsToRef(this._sourcePositions[m],this._sourcePositions[m+1],this._sourcePositions[m+2],d,f),f.toArray(r,m),e.Vector3.TransformNormalFromFloatsToRef(this._sourceNormals[m],this._sourceNormals[m+1],this._sourceNormals[m+2],d,f),f.toArray(n,m),d.reset()}return this.updateVerticesData(e.VertexBuffer.PositionKind,r),this.updateVerticesData(e.VertexBuffer.NormalKind,n),this},r.MinMax=function(e){var t=null,i=null;return e.forEach((function(e,r,n){var o=e.getBoundingInfo().boundingBox;t?(t.MinimizeInPlace(o.minimumWorld),i.MaximizeInPlace(o.maximumWorld)):(t=o.minimumWorld,i=o.maximumWorld)})),{min:t,max:i}},r.Center=function(t){var i=t instanceof Array?e.Mesh.MinMax(t):t;return e.Vector3.Center(i.min,i.max)},r.MergeMeshes=function(t,i,n,o,s){void 0===i&&(i=!0);var a;if(!n){var l=0;for(a=0;a65536)return e.Tools.Warn("Cannot merge meshes because resulting mesh will have more than 65536 vertices. Please use allow32BitsIndices = true to use 32 bits indices"),null}var h,c,u,f=new Array;for(a=0;aa&&(a=c)}return new i(e,s,a-s+1,t,r,n,o)},i})(t);e.SubMesh=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(BABYLON){var EffectFallbacks=(function(){function e(){this._defines={},this._currentRank=32,this._maxRank=-1}return e.prototype.addFallback=function(e,t){this._defines[e]||(ethis._maxRank&&(this._maxRank=e),this._defines[e]=new Array),this._defines[e].push(t)},e.prototype.addCPUSkinningFallback=function(e,t){this._meshRank=e,this._mesh=t,ethis._maxRank&&(this._maxRank=e)},Object.defineProperty(e.prototype,"isMoreFallbacks",{get:function(){return this._currentRank<=this._maxRank},enumerable:!0,configurable:!0}),e.prototype.reduce=function(e){if(this._mesh&&this._mesh.computeBonesUsingShaders&&this._mesh.numBoneInfluencers>0){this._mesh.computeBonesUsingShaders=!1,e=e.replace("#define NUM_BONE_INFLUENCERS "+this._mesh.numBoneInfluencers,"#define NUM_BONE_INFLUENCERS 0"),BABYLON.Tools.Log("Falling back to CPU skinning for "+this._mesh.name);for(var t=this._mesh.getScene(),i=0;i0&&(r.computeBonesUsingShaders=!1)}}else{var n=this._defines[this._currentRank];if(n)for(var i=0;i-1?e:BABYLON.Engine.ShadersRepository+e,BABYLON.Tools.LoadFile(i+".vertex.fx",t)},Effect.prototype._loadFragmentShader=function(e,t){if(e instanceof HTMLElement){return void t(BABYLON.Tools.GetDOMTextContent(e))}if("base64:"===e.substr(0,7)){return void t(window.atob(e.substr(7)))}if(Effect.ShadersStore[e+"PixelShader"])return void t(Effect.ShadersStore[e+"PixelShader"]);if(Effect.ShadersStore[e+"FragmentShader"])return void t(Effect.ShadersStore[e+"FragmentShader"]);var i;i="."===e[0]||"/"===e[0]||e.indexOf("http")>-1?e:BABYLON.Engine.ShadersRepository+e,BABYLON.Tools.LoadFile(i+".fragment.fx",t)},Effect.prototype._dumpShadersSource=function(e,t,i){var r=this._engine.webGLVersion>1?"#version 300 es\n":"",n=r+(i?i+"\n":"");e=n+e,t=n+t;var o=2,s="\n1\t"+e.replace(/\n/gm,(function(){return"\n"+o+++"\t"}));o=2;var a="\n1\t"+t.replace(/\n/gm,(function(){return"\n"+o+++"\t"}));this.name.vertexElement?(BABYLON.Tools.Error("Vertex shader: "+this.name.vertexElement+s),BABYLON.Tools.Error("Fragment shader: "+this.name.fragmentElement+a)):this.name.vertex?(BABYLON.Tools.Error("Vertex shader: "+this.name.vertex+s),BABYLON.Tools.Error("Fragment shader: "+this.name.fragment+a)):(BABYLON.Tools.Error("Vertex shader: "+this.name+s),BABYLON.Tools.Error("Fragment shader: "+this.name+a))},Effect.prototype._processShaderConversion=function(e,t,i){var r=this._processPrecision(e);if(1==this._engine.webGLVersion)return void i(r);if(-1!==r.indexOf("#version 3"))return void i(r.replace("#version 300 es",""));var n=r.replace(/#extension.+(GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth).+enable/g,"");n=n.replace(/varying(?![\n\r])\s/g,t?"in ":"out "),n=n.replace(/attribute[ \t]/g,"in "),n=n.replace(/[ \t]attribute/g," in"),t&&(n=n.replace(/texture2DLodEXT\(/g,"textureLod("),n=n.replace(/textureCubeLodEXT\(/g,"textureLod("),n=n.replace(/texture2D\(/g,"texture("),n=n.replace(/textureCube\(/g,"texture("),n=n.replace(/gl_FragDepthEXT/g,"gl_FragDepth"),n=n.replace(/gl_FragColor/g,"glFragColor"),n=n.replace(/void\s+?main\(/g,"out vec4 glFragColor;\nvoid main(")),i(n)},Effect.prototype._processIncludes=function(e,t){for(var i=this,r=/#include<(.+)>(\((.*)\))*(\[(.*)\])*/g,n=r.exec(e),o=new String(e);null!=n;){var s=n[1];if(-1!==s.indexOf("__decl__")&&(s=s.replace(/__decl__/,""),1!=this._engine.webGLVersion&&(s=s.replace(/Vertex/,"Ubo"),s=s.replace(/Fragment/,"Ubo")),s+="Declaration"),!Effect.IncludesShadersStore[s]){var a=BABYLON.Engine.ShadersRepository+"ShadersInclude/"+s+".fx";return void BABYLON.Tools.LoadFile(a,(function(e){Effect.IncludesShadersStore[s]=e,i._processIncludes(o,t)}))}var l=Effect.IncludesShadersStore[s];if(n[2])for(var h=n[3].split(","),c=0;c1)for(var s in this._uniformBuffersNames)this.bindUniformBlock(s,this._uniformBuffersNames[s]);this._uniforms=o.getUniforms(this._program,this._uniformsNames),this._attributes=o.getAttributes(this._program,i);var a;for(a=0;a0&&(result+=line+"\r\n")}return result}, +Effect.prototype._evaluateDefinesOnString=function(e){for(var t={children:[]},i=t,r=e.split("\n"),n=0;n0,i.NUM_MORPH_INFLUENCERS=s.numInfluencers}else i.MORPHTARGETS_TANGENT=!1,i.MORPHTARGETS_NORMAL=!1,i.MORPHTARGETS=!1,i.NUM_MORPH_INFLUENCERS=0;return!0},t.PrepareDefinesForLights=function(t,i,r,n,o,s){if(void 0===o&&(o=4),void 0===s&&(s=!1),!r._areLightsDirty)return r._needNormals;var a=0,l=!1,h=!1,c=!1,u=!1,f=!1;if(t.lightsEnabled&&!s)for(var d=0,p=i._lightSources;d0&&t.addFallback(r,"LIGHT"+r),e["SHADOW"+r]&&t.addFallback(0,"SHADOW"+r),e["SHADOWPCF"+r]&&t.addFallback(0,"SHADOWPCF"+r),e["SHADOWESM"+r]&&t.addFallback(0,"SHADOWESM"+r)},t.PrepareAttributesForMorphTargets=function(t,i,r){var n=r.NUM_MORPH_INFLUENCERS;if(n>0)for(var o=e.Engine.LastCreatedEngine.getCaps().maxVertexAttribs,s=i.morphTargetManager,a=s.supportsNormals&&r.NORMAL,l=s.supportsTangents&&r.TANGENT,h=0;ho&&e.Tools.Error("Cannot add more vertex attributes for mesh "+i.name)},t.PrepareAttributesForBones=function(t,i,r,n){r.NUM_BONE_INFLUENCERS>0&&(n.addCPUSkinningFallback(0,i),t.push(e.VertexBuffer.MatricesIndicesKind),t.push(e.VertexBuffer.MatricesWeightsKind),r.NUM_BONE_INFLUENCERS>4&&(t.push(e.VertexBuffer.MatricesIndicesExtraKind),t.push(e.VertexBuffer.MatricesWeightsExtraKind)))},t.PrepareAttributesForInstances=function(e,t){t.INSTANCES&&(e.push("world0"),e.push("world1"),e.push("world2"),e.push("world3"))},t.BindLightShadow=function(e,t,i,r,n){if(e.shadowEnabled&&i.receiveShadows){var o=e.getShadowGenerator();o&&o.bindShadowLight(r,n)}},t.BindLightProperties=function(e,t,i){e.transferToEffect(t,i+"")},t.BindLights=function(i,r,n,o,s,a){void 0===s&&(s=4),void 0===a&&(a=!1);for(var l=0,h=0,c=r._lightSources;h1,n||this._scene.materials.push(this)}return Object.defineProperty(t,"TriangleFillMode",{get:function(){return t._TriangleFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(t,"WireFrameFillMode",{get:function(){return t._WireFrameFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(t,"PointFillMode",{get:function(){return t._PointFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(t,"ClockWiseSideOrientation",{get:function(){return t._ClockWiseSideOrientation},enumerable:!0,configurable:!0}),Object.defineProperty(t,"CounterClockWiseSideOrientation",{get:function(){return t._CounterClockWiseSideOrientation},enumerable:!0,configurable:!0}),Object.defineProperty(t,"TextureDirtyFlag",{get:function(){return t._TextureDirtyFlag},enumerable:!0,configurable:!0}),Object.defineProperty(t,"LightDirtyFlag",{get:function(){return t._LightDirtyFlag},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FresnelDirtyFlag",{get:function(){return t._FresnelDirtyFlag},enumerable:!0,configurable:!0}),Object.defineProperty(t,"AttributesDirtyFlag",{get:function(){return t._AttributesDirtyFlag},enumerable:!0,configurable:!0}),Object.defineProperty(t,"MiscDirtyFlag",{get:function(){return t._MiscDirtyFlag},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"backFaceCulling",{get:function(){return this._backFaceCulling},set:function(e){this._backFaceCulling!==e&&(this._backFaceCulling=e,this.markAsDirty(t.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onBind",{set:function(e){this._onBindObserver&&this.onBindObservable.remove(this._onBindObserver),this._onBindObserver=this.onBindObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"fogEnabled",{get:function(){return this._fogEnabled},set:function(e){this._fogEnabled!==e&&(this._fogEnabled=e,this.markAsDirty(t.MiscDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"wireframe",{get:function(){return this._fillMode===t.WireFrameFillMode},set:function(e){this._fillMode=e?t.WireFrameFillMode:t.TriangleFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"pointsCloud",{get:function(){return this._fillMode===t.PointFillMode},set:function(e){this._fillMode=e?t.PointFillMode:t.TriangleFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"fillMode",{get:function(){return this._fillMode},set:function(e){this._fillMode!==e&&(this._fillMode=e,this.markAsDirty(t.MiscDirtyFlag))},enumerable:!0,configurable:!0}),t.prototype.toString=function(e){return"Name: "+this.name},t.prototype.getClassName=function(){return"Material"},Object.defineProperty(t.prototype,"isFrozen",{get:function(){return this.checkReadyOnlyOnce},enumerable:!0,configurable:!0}),t.prototype.freeze=function(){this.checkReadyOnlyOnce=!0},t.prototype.unfreeze=function(){this.checkReadyOnlyOnce=!1},t.prototype.isReady=function(e,t){return!0},t.prototype.isReadyForSubMesh=function(e,t,i){return!1},t.prototype.getEffect=function(){return this._effect},t.prototype.getScene=function(){return this._scene},t.prototype.needAlphaBlending=function(){return this.alpha<1},t.prototype.needAlphaTesting=function(){return!1},t.prototype.getAlphaTestTexture=function(){return null},t.prototype.markDirty=function(){this._wasPreviouslyReady=!1},t.prototype._preBind=function(e){var i=this._scene.getEngine(),r=this.sideOrientation===t.ClockWiseSideOrientation;i.enableEffect(e||this._effect),i.setState(this.backFaceCulling,this.zOffset,!1,r)},t.prototype.bind=function(e,t){},t.prototype.bindForSubMesh=function(e,t,i){},t.prototype.bindOnlyWorldMatrix=function(e){},t.prototype.bindSceneUniformBuffer=function(e,t){t.bindToEffect(e,"Scene")},t.prototype.bindView=function(e){this._useUBO?this.bindSceneUniformBuffer(e,this.getScene().getSceneUniformBuffer()):e.setMatrix("view",this.getScene().getViewMatrix())},t.prototype.bindViewProjection=function(e){this._useUBO?this.bindSceneUniformBuffer(e,this.getScene().getSceneUniformBuffer()):e.setMatrix("viewProjection",this.getScene().getTransformMatrix())},t.prototype._afterBind=function(e){if(this._scene._cachedMaterial=this,this.onBindObservable.notifyObservers(e),this.disableDepthWrite){var t=this._scene.getEngine();this._cachedDepthWriteState=t.getDepthWrite(),t.setDepthWrite(!1)}},t.prototype.unbind=function(){if(this.onUnBindObservable.notifyObservers(this),this.disableDepthWrite){this._scene.getEngine().setDepthWrite(this._cachedDepthWriteState)}},t.prototype.getActiveTextures=function(){return[]},t.prototype.hasTexture=function(e){return!1},t.prototype.clone=function(e){return null},t.prototype.getBindedMeshes=function(){for(var e=new Array,t=0;t=0&&this._scene.materials.splice(i,1),i=0;ia?a:Math.floor(l);var h,c,u,f,d=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,p=i.uvs,_=i.colors,m=[],g=[],v=[],y=[],x=[],b=[],A=[],T=[],E=[],P=[];if(r.length<2){var M=[],S=[];for(u=0;u0&&(D=C[f].subtract(C[f-1]).length(),B=D+A[c],x[c].push(B),A[c]=B),f++;o&&(f--,m.push(C[0].x,C[0].y,C[0].z),D=C[f].subtract(C[0]).length(),B=D+A[c],x[c].push(B),A[c]=B),E[c]=R+I,P[c]=O,O+=R+I}var L,w,F,N;for(u=0;u1?1:i.arc||1,l=i.slice<=0?1:i.slice||1,h=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,c=new e.Vector3(n/2,o/2,s/2),u=2+r,f=2*u,d=[],p=[],_=[],m=[],g=0;g<=u;g++){for(var v=g/u,y=v*Math.PI*l,x=0;x<=f;x++){var b=x/f,A=b*Math.PI*2*a,T=e.Matrix.RotationZ(-y),E=e.Matrix.RotationY(A),P=e.Vector3.TransformCoordinates(e.Vector3.Up(),T),M=e.Vector3.TransformCoordinates(P,E),S=M.multiply(c),C=M.divide(c).normalize();p.push(S.x,S.y,S.z),_.push(C.x,C.y,C.z),m.push(b,v)}if(g>0)for(var R=p.length/3,O=R-2*(f+1);O+f+21?1:i.arc||1,f=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,d=i.faceUV||new Array(3),p=i.faceColors,_=1!==u&&c?2:0,m=h?l:1,g=2+(1+_)*m;for(r=0;r0&&(i.push(o-1),i.push(o)),o++;var h=new t;return h.indices=i,h.positions=r,h},t.CreateDashedLines=function(i){var r=i.dashSize||3,n=i.gapSize||1,o=i.dashNb||200,s=i.points,a=new Array,l=new Array,h=e.Vector3.Zero(),c=0,u=0,f=0,d=0,p=0,_=0,m=0;for(m=0;m1?1:i.arc||1,c=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE;r.push(0,0,0),s.push(.5,.5);for(var u=2*Math.PI*h,f=u/l,d=0;d=r.length?0:i.type||0,u=i.size,f=i.sizeX||u||1,d=i.sizeY||u||1,p=i.sizeZ||u||1,_=i.custom||r[c],m=_.face.length,g=i.faceUV||new Array(m),v=i.faceColors,y=void 0===i.flat||i.flat,x=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,b=[],A=[],T=[],E=[],P=[],M=0,S=0,C=[],R=0,O=0;if(y)for(O=0;Or.bbSize.y?r.bbSize.x:r.bbSize.y;H=H>r.bbSize.z?H:r.bbSize.z;var W=r.subDiv.X*r.ratio/r.bbSize.x,j=r.subDiv.Y*r.ratio/r.bbSize.y,X=r.subDiv.Z*r.ratio/r.bbSize.z,K=r.subDiv.max*r.subDiv.max;r.facetPartitioning.length=0}for(n=0;n0&&(this._indexBuffer=this._engine.createIndexBuffer(this._indices)),this._indexBuffer&&(this._indexBuffer.references=i)},t.prototype.notifyUpdate=function(e){this.onGeometryUpdated&&this.onGeometryUpdated(this,e);for(var t=0,i=this._meshes;t0){for(var i=0;i0){for(var i=0;i0){for(var i=0;i0){var l=new Float32Array(i,a.positionsAttrDesc.offset,a.positionsAttrDesc.count);r.setVerticesData(e.VertexBuffer.PositionKind,l,!1)}if(a.normalsAttrDesc&&a.normalsAttrDesc.count>0){var h=new Float32Array(i,a.normalsAttrDesc.offset,a.normalsAttrDesc.count);r.setVerticesData(e.VertexBuffer.NormalKind,h,!1)}if(a.uvsAttrDesc&&a.uvsAttrDesc.count>0){var c=new Float32Array(i,a.uvsAttrDesc.offset,a.uvsAttrDesc.count);r.setVerticesData(e.VertexBuffer.UVKind,c,!1)}if(a.uvs2AttrDesc&&a.uvs2AttrDesc.count>0){var u=new Float32Array(i,a.uvs2AttrDesc.offset,a.uvs2AttrDesc.count);r.setVerticesData(e.VertexBuffer.UV2Kind,u,!1)}if(a.uvs3AttrDesc&&a.uvs3AttrDesc.count>0){var f=new Float32Array(i,a.uvs3AttrDesc.offset,a.uvs3AttrDesc.count);r.setVerticesData(e.VertexBuffer.UV3Kind,f,!1)}if(a.uvs4AttrDesc&&a.uvs4AttrDesc.count>0){var d=new Float32Array(i,a.uvs4AttrDesc.offset,a.uvs4AttrDesc.count);r.setVerticesData(e.VertexBuffer.UV4Kind,d,!1)}if(a.uvs5AttrDesc&&a.uvs5AttrDesc.count>0){var p=new Float32Array(i,a.uvs5AttrDesc.offset,a.uvs5AttrDesc.count);r.setVerticesData(e.VertexBuffer.UV5Kind,p,!1)}if(a.uvs6AttrDesc&&a.uvs6AttrDesc.count>0){var _=new Float32Array(i,a.uvs6AttrDesc.offset,a.uvs6AttrDesc.count);r.setVerticesData(e.VertexBuffer.UV6Kind,_,!1)}if(a.colorsAttrDesc&&a.colorsAttrDesc.count>0){var m=new Float32Array(i,a.colorsAttrDesc.offset,a.colorsAttrDesc.count);r.setVerticesData(e.VertexBuffer.ColorKind,m,!1,a.colorsAttrDesc.stride)}if(a.matricesIndicesAttrDesc&&a.matricesIndicesAttrDesc.count>0){var g=new Int32Array(i,a.matricesIndicesAttrDesc.offset,a.matricesIndicesAttrDesc.count);r.setVerticesData(e.VertexBuffer.MatricesIndicesKind,g,!1)}if(a.matricesWeightsAttrDesc&&a.matricesWeightsAttrDesc.count>0){var v=new Float32Array(i,a.matricesWeightsAttrDesc.offset,a.matricesWeightsAttrDesc.count);r.setVerticesData(e.VertexBuffer.MatricesWeightsKind,v,!1)}if(a.indicesAttrDesc&&a.indicesAttrDesc.count>0){var y=new Int32Array(i,a.indicesAttrDesc.offset,a.indicesAttrDesc.count);r.setIndices(y)}if(a.subMeshesAttrDesc&&a.subMeshesAttrDesc.count>0){var x=new Int32Array(i,a.subMeshesAttrDesc.offset,5*a.subMeshesAttrDesc.count);r.subMeshes=[];for(var b=0;b>8),S.push((16711680&C)>>16),S.push(C>>24)}r.setVerticesData(e.VertexBuffer.MatricesIndicesKind,S,i.matricesIndices._updatable)}if(i.matricesIndicesExtra)if(i.matricesIndicesExtra._isExpanded)delete i.matricesIndices._isExpanded,r.setVerticesData(e.VertexBuffer.MatricesIndicesExtraKind,i.matricesIndicesExtra,i.matricesIndicesExtra._updatable);else{for(var S=[],b=0;b>8),S.push((16711680&C)>>16),S.push(C>>24)}r.setVerticesData(e.VertexBuffer.MatricesIndicesExtraKind,S,i.matricesIndicesExtra._updatable)}i.matricesWeights&&(t._CleanMatricesWeights(i.matricesWeights,i.numBoneInfluencers),r.setVerticesData(e.VertexBuffer.MatricesWeightsKind,i.matricesWeights,i.matricesWeights._updatable)),i.matricesWeightsExtra&&(t._CleanMatricesWeights(i.matricesWeightsExtra,i.numBoneInfluencers),r.setVerticesData(e.VertexBuffer.MatricesWeightsExtraKind,i.matricesWeightsExtra,i.matricesWeights._updatable)),r.setIndices(i.indices)}if(i.subMeshes){r.subMeshes=[];for(var R=0;Ra&&(a=t[n+l],s=n+l);t[s]+=Math.max(0,1-o)}},t.Parse=function(i,r,n){if(r.getGeometryByID(i.id))return null;var o=new t(i.id,r,null,i.updatable);return e.Tags&&e.Tags.AddTagsTo(o,i.tags),i.delayLoadingFile?(o.delayLoadState=e.Engine.DELAYLOADSTATE_NOTLOADED,o.delayLoadingFile=n+i.delayLoadingFile,o._boundingInfo=new e.BoundingInfo(e.Vector3.FromArray(i.boundingBoxMinimum),e.Vector3.FromArray(i.boundingBoxMaximum)),o._delayInfo=[],i.hasUVs&&o._delayInfo.push(e.VertexBuffer.UVKind),i.hasUVs2&&o._delayInfo.push(e.VertexBuffer.UV2Kind),i.hasUVs3&&o._delayInfo.push(e.VertexBuffer.UV3Kind),i.hasUVs4&&o._delayInfo.push(e.VertexBuffer.UV4Kind),i.hasUVs5&&o._delayInfo.push(e.VertexBuffer.UV5Kind),i.hasUVs6&&o._delayInfo.push(e.VertexBuffer.UV6Kind),i.hasColors&&o._delayInfo.push(e.VertexBuffer.ColorKind),i.hasMatricesIndices&&o._delayInfo.push(e.VertexBuffer.MatricesIndicesKind),i.hasMatricesWeights&&o._delayInfo.push(e.VertexBuffer.MatricesWeightsKind),o._delayLoadingFunction=e.VertexData.ImportVertexData):e.VertexData.ImportVertexData(i,o),r.pushGeometry(o,!0),o},t})();e.Geometry=t,(function(t){!(function(i){var r=(function(e){function t(t,i,r,n){var o=e.call(this,t,i,null,!1,n)||this;return o._canBeRegenerated=r,o._beingRegenerated=!0,o.regenerate(),o._beingRegenerated=!1,o}return __extends(t,e),t.prototype.canBeRegenerated=function(){return this._canBeRegenerated},t.prototype.regenerate=function(){this._canBeRegenerated&&(this._beingRegenerated=!0,this.setAllVerticesData(this._regenerateVertexData(),!1),this._beingRegenerated=!1)},t.prototype.asNewGeometry=function(t){return e.prototype.copy.call(this,t)},t.prototype.setAllVerticesData=function(t,i){this._beingRegenerated&&e.prototype.setAllVerticesData.call(this,t,!1)},t.prototype.setVerticesData=function(t,i,r){this._beingRegenerated&&e.prototype.setVerticesData.call(this,t,i,!1)},t.prototype._regenerateVertexData=function(){throw new Error("Abstract method")},t.prototype.copy=function(e){throw new Error("Must be overriden in sub-classes.")},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.canBeRegenerated=this.canBeRegenerated(),t},t})(t);i._Primitive=r;var n=(function(t){function i(i,r,n,o,s,a,l,h,c){void 0===c&&(c=e.Mesh.DEFAULTSIDE);var u=t.call(this,i,r,l,h)||this;return u.pathArray=n,u.closeArray=o,u.closePath=s,u.offset=a,u.side=c,u}return __extends(i,t),i.prototype._regenerateVertexData=function(){return e.VertexData.CreateRibbon({pathArray:this.pathArray,closeArray:this.closeArray,closePath:this.closePath,offset:this.offset,sideOrientation:this.side})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.pathArray,this.closeArray,this.closePath,this.offset,this.canBeRegenerated(),null,this.side)},i})(r);i.Ribbon=n;var o=(function(i){function r(t,r,n,o,s,a){void 0===a&&(a=e.Mesh.DEFAULTSIDE);var l=i.call(this,t,r,o,s)||this;return l.size=n,l.side=a,l}return __extends(r,i),r.prototype._regenerateVertexData=function(){return e.VertexData.CreateBox({size:this.size,sideOrientation:this.side})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.size,this.canBeRegenerated(),null,this.side)},r.prototype.serialize=function(){var e=i.prototype.serialize.call(this);return e.size=this.size,e},r.Parse=function(i,r){if(r.getGeometryByID(i.id))return null;var n=new t.Primitives.Box(i.id,r,i.size,i.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,i.tags),r.pushGeometry(n,!0),n},r})(r);i.Box=o;var s=(function(i){function r(t,r,n,o,s,a,l){void 0===l&&(l=e.Mesh.DEFAULTSIDE);var h=i.call(this,t,r,s,a)||this;return h.segments=n,h.diameter=o,h.side=l,h}return __extends(r,i),r.prototype._regenerateVertexData=function(){return e.VertexData.CreateSphere({segments:this.segments,diameter:this.diameter,sideOrientation:this.side})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.segments,this.diameter,this.canBeRegenerated(),null,this.side)},r.prototype.serialize=function(){var e=i.prototype.serialize.call(this);return e.segments=this.segments,e.diameter=this.diameter,e},r.Parse=function(i,r){if(r.getGeometryByID(i.id))return null;var n=new t.Primitives.Sphere(i.id,r,i.segments,i.diameter,i.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,i.tags),r.pushGeometry(n,!0),n},r})(r);i.Sphere=s;var a=(function(t){function i(i,r,n,o,s,a,l){void 0===l&&(l=e.Mesh.DEFAULTSIDE);var h=t.call(this,i,r,s,a)||this;return h.radius=n,h.tessellation=o,h.side=l,h}return __extends(i,t),i.prototype._regenerateVertexData=function(){return e.VertexData.CreateDisc({radius:this.radius,tessellation:this.tessellation,sideOrientation:this.side})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.radius,this.tessellation,this.canBeRegenerated(),null,this.side)},i})(r);i.Disc=a;var l=(function(i){function r(t,r,n,o,s,a,l,h,c,u){void 0===l&&(l=1),void 0===u&&(u=e.Mesh.DEFAULTSIDE);var f=i.call(this,t,r,h,c)||this;return f.height=n,f.diameterTop=o,f.diameterBottom=s,f.tessellation=a,f.subdivisions=l,f.side=u,f}return __extends(r,i),r.prototype._regenerateVertexData=function(){return e.VertexData.CreateCylinder({height:this.height,diameterTop:this.diameterTop,diameterBottom:this.diameterBottom,tessellation:this.tessellation,subdivisions:this.subdivisions,sideOrientation:this.side})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.height,this.diameterTop,this.diameterBottom,this.tessellation,this.subdivisions,this.canBeRegenerated(),null,this.side)},r.prototype.serialize=function(){var e=i.prototype.serialize.call(this);return e.height=this.height,e.diameterTop=this.diameterTop,e.diameterBottom=this.diameterBottom,e.tessellation=this.tessellation,e},r.Parse=function(i,r){if(r.getGeometryByID(i.id))return null;var n=new t.Primitives.Cylinder(i.id,r,i.height,i.diameterTop,i.diameterBottom,i.tessellation,i.subdivisions,i.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,i.tags),r.pushGeometry(n,!0),n},r})(r);i.Cylinder=l;var h=(function(i){function r(t,r,n,o,s,a,l,h){void 0===h&&(h=e.Mesh.DEFAULTSIDE);var c=i.call(this,t,r,a,l)||this;return c.diameter=n,c.thickness=o,c.tessellation=s,c.side=h,c}return __extends(r,i),r.prototype._regenerateVertexData=function(){return e.VertexData.CreateTorus({diameter:this.diameter,thickness:this.thickness,tessellation:this.tessellation,sideOrientation:this.side})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.diameter,this.thickness,this.tessellation,this.canBeRegenerated(),null,this.side)},r.prototype.serialize=function(){var e=i.prototype.serialize.call(this);return e.diameter=this.diameter,e.thickness=this.thickness,e.tessellation=this.tessellation,e},r.Parse=function(i,r){if(r.getGeometryByID(i.id))return null;var n=new t.Primitives.Torus(i.id,r,i.diameter,i.thickness,i.tessellation,i.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,i.tags),r.pushGeometry(n,!0),n},r})(r);i.Torus=h;var c=(function(i){function r(e,t,r,n,o,s,a){var l=i.call(this,e,t,s,a)||this;return l.width=r,l.height=n,l.subdivisions=o,l}return __extends(r,i),r.prototype._regenerateVertexData=function(){return e.VertexData.CreateGround({width:this.width,height:this.height,subdivisions:this.subdivisions})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.width,this.height,this.subdivisions,this.canBeRegenerated(),null)},r.prototype.serialize=function(){var e=i.prototype.serialize.call(this);return e.width=this.width,e.height=this.height,e.subdivisions=this.subdivisions,e},r.Parse=function(i,r){if(r.getGeometryByID(i.id))return null;var n=new t.Primitives.Ground(i.id,r,i.width,i.height,i.subdivisions,i.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,i.tags),r.pushGeometry(n,!0),n},r})(r);i.Ground=c;var u=(function(t){function i(e,i,r,n,o,s,a,l,h,c){var u=t.call(this,e,i,h,c)||this;return u.xmin=r,u.zmin=n,u.xmax=o,u.zmax=s,u.subdivisions=a,u.precision=l,u}return __extends(i,t),i.prototype._regenerateVertexData=function(){return e.VertexData.CreateTiledGround({xmin:this.xmin,zmin:this.zmin,xmax:this.xmax,zmax:this.zmax,subdivisions:this.subdivisions,precision:this.precision})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.xmin,this.zmin,this.xmax,this.zmax,this.subdivisions,this.precision,this.canBeRegenerated(),null)},i})(r);i.TiledGround=u;var f=(function(i){function r(t,r,n,o,s,a){void 0===a&&(a=e.Mesh.DEFAULTSIDE);var l=i.call(this,t,r,o,s)||this;return l.size=n,l.side=a,l}return __extends(r,i),r.prototype._regenerateVertexData=function(){return e.VertexData.CreatePlane({size:this.size,sideOrientation:this.side})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.size,this.canBeRegenerated(),null,this.side)},r.prototype.serialize=function(){var e=i.prototype.serialize.call(this);return e.size=this.size,e},r.Parse=function(i,r){if(r.getGeometryByID(i.id))return null;var n=new t.Primitives.Plane(i.id,r,i.size,i.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,i.tags),r.pushGeometry(n,!0),n},r})(r);i.Plane=f;var d=(function(i){function r(t,r,n,o,s,a,l,h,c,u,f){void 0===f&&(f=e.Mesh.DEFAULTSIDE);var d=i.call(this,t,r,c,u)||this;return d.radius=n,d.tube=o,d.radialSegments=s,d.tubularSegments=a,d.p=l,d.q=h,d.side=f,d}return __extends(r,i),r.prototype._regenerateVertexData=function(){return e.VertexData.CreateTorusKnot({radius:this.radius,tube:this.tube,radialSegments:this.radialSegments,tubularSegments:this.tubularSegments,p:this.p,q:this.q,sideOrientation:this.side})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.radius,this.tube,this.radialSegments,this.tubularSegments,this.p,this.q,this.canBeRegenerated(),null,this.side)},r.prototype.serialize=function(){var e=i.prototype.serialize.call(this);return e.radius=this.radius,e.tube=this.tube,e.radialSegments=this.radialSegments,e.tubularSegments=this.tubularSegments,e.p=this.p,e.q=this.q,e},r.Parse=function(i,r){if(r.getGeometryByID(i.id))return null;var n=new t.Primitives.TorusKnot(i.id,r,i.radius,i.tube,i.radialSegments,i.tubularSegments,i.p,i.q,i.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,i.tags),r.pushGeometry(n,!0),n},r})(r);i.TorusKnot=d})(t.Primitives||(t.Primitives={}))})(t=e.Geometry||(e.Geometry={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e){this._vertexBuffers={},this._scene=e}return t.prototype._prepareBuffers=function(){if(!this._vertexBuffers[e.VertexBuffer.PositionKind]){var t=[];t.push(1,1),t.push(-1,1),t.push(-1,-1),t.push(1,-1),this._vertexBuffers[e.VertexBuffer.PositionKind]=new e.VertexBuffer(this._scene.getEngine(),t,e.VertexBuffer.PositionKind,!1,!1,2);var i=[];i.push(0),i.push(1),i.push(2),i.push(0),i.push(2),i.push(3),this._indexBuffer=this._scene.getEngine().createIndexBuffer(i)}},t.prototype._prepareFrame=function(e,t){var t=t||this._scene.activeCamera._postProcesses;return!(0===t.length||!this._scene.postProcessesEnabled)&&(t[0].activate(this._scene.activeCamera,e,null!==t&&void 0!==t),!0)},t.prototype.directRender=function(e,t){for(var i=this._scene.getEngine(),r=0;r=this._sampleCount||e>=this._samples.length)return null;var t=this._wrapPosition(this._pos-1);return this._samples[this._wrapPosition(t-e)]},e.prototype.isSaturated=function(){return this._sampleCount>=this._samples.length},e.prototype.reset=function(){this.average=0,this.variance=0,this._sampleCount=0,this._pos=0,this._m2=0},e.prototype._wrapPosition=function(e){var t=this._samples.length;return(e%t+t)%t},e})();e.RollingAverage=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(e){function t(){var t=e.call(this)||this;return t.MAINUV1=!1,t.MAINUV2=!1,t.DIFFUSE=!1,t.DIFFUSEDIRECTUV=0,t.AMBIENT=!1,t.AMBIENTDIRECTUV=0,t.OPACITY=!1,t.OPACITYDIRECTUV=0,t.OPACITYRGB=!1,t.REFLECTION=!1,t.EMISSIVE=!1,t.EMISSIVEDIRECTUV=0,t.SPECULAR=!1,t.SPECULARDIRECTUV=0,t.BUMP=!1,t.BUMPDIRECTUV=0,t.PARALLAX=!1,t.PARALLAXOCCLUSION=!1,t.SPECULAROVERALPHA=!1,t.CLIPPLANE=!1,t.ALPHATEST=!1,t.ALPHAFROMDIFFUSE=!1,t.POINTSIZE=!1,t.FOG=!1,t.SPECULARTERM=!1,t.DIFFUSEFRESNEL=!1,t.OPACITYFRESNEL=!1,t.REFLECTIONFRESNEL=!1,t.REFRACTIONFRESNEL=!1,t.EMISSIVEFRESNEL=!1,t.FRESNEL=!1,t.NORMAL=!1,t.UV1=!1,t.UV2=!1,t.VERTEXCOLOR=!1,t.VERTEXALPHA=!1,t.NUM_BONE_INFLUENCERS=0,t.BonesPerMesh=0,t.INSTANCES=!1,t.GLOSSINESS=!1,t.ROUGHNESS=!1,t.EMISSIVEASILLUMINATION=!1,t.LINKEMISSIVEWITHDIFFUSE=!1,t.REFLECTIONFRESNELFROMSPECULAR=!1,t.LIGHTMAP=!1,t.LIGHTMAPDIRECTUV=0,t.USELIGHTMAPASSHADOWMAP=!1,t.REFLECTIONMAP_3D=!1,t.REFLECTIONMAP_SPHERICAL=!1,t.REFLECTIONMAP_PLANAR=!1,t.REFLECTIONMAP_CUBIC=!1,t.REFLECTIONMAP_PROJECTION=!1,t.REFLECTIONMAP_SKYBOX=!1,t.REFLECTIONMAP_EXPLICIT=!1,t.REFLECTIONMAP_EQUIRECTANGULAR=!1,t.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,t.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,t.INVERTCUBICMAP=!1,t.LOGARITHMICDEPTH=!1,t.REFRACTION=!1,t.REFRACTIONMAP_3D=!1,t.REFLECTIONOVERALPHA=!1,t.TWOSIDEDLIGHTING=!1,t.SHADOWFLOAT=!1,t.MORPHTARGETS=!1,t.MORPHTARGETS_NORMAL=!1,t.MORPHTARGETS_TANGENT=!1,t.NUM_MORPH_INFLUENCERS=0,t.USERIGHTHANDEDSYSTEM=!1,t.IMAGEPROCESSING=!1,t.VIGNETTE=!1,t.VIGNETTEBLENDMODEMULTIPLY=!1,t.VIGNETTEBLENDMODEOPAQUE=!1,t.TONEMAPPING=!1,t.CONTRAST=!1,t.COLORCURVES=!1,t.COLORGRADING=!1,t.SAMPLER3DGREENDEPTH=!1,t.SAMPLER3DBGRMAP=!1,t.IMAGEPROCESSINGPOSTPROCESS=!1,t.EXPOSURE=!1,t.rebuild(),t}return __extends(t,e),t.prototype.setReflectionMode=function(e){for(var t=["REFLECTIONMAP_CUBIC","REFLECTIONMAP_EXPLICIT","REFLECTIONMAP_PLANAR","REFLECTIONMAP_PROJECTION","REFLECTIONMAP_PROJECTION","REFLECTIONMAP_SKYBOX","REFLECTIONMAP_SPHERICAL","REFLECTIONMAP_EQUIRECTANGULAR","REFLECTIONMAP_EQUIRECTANGULAR_FIXED","REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED"],i=0,r=t;i0,a.REFLECTIONOVERALPHA=this._useReflectionOverAlpha,a.INVERTCUBICMAP=this._reflectionTexture.coordinatesMode===e.Texture.INVCUBIC_MODE,a.REFLECTIONMAP_3D=this._reflectionTexture.isCube,this._reflectionTexture.coordinatesMode){case e.Texture.CUBIC_MODE:case e.Texture.INVCUBIC_MODE:a.setReflectionMode("REFLECTIONMAP_CUBIC");break;case e.Texture.EXPLICIT_MODE:a.setReflectionMode("REFLECTIONMAP_EXPLICIT");break;case e.Texture.PLANAR_MODE:a.setReflectionMode("REFLECTIONMAP_PLANAR");break;case e.Texture.PROJECTION_MODE:a.setReflectionMode("REFLECTIONMAP_PROJECTION");break;case e.Texture.SKYBOX_MODE:a.setReflectionMode("REFLECTIONMAP_SKYBOX");break;case e.Texture.SPHERICAL_MODE:a.setReflectionMode("REFLECTIONMAP_SPHERICAL");break;case e.Texture.EQUIRECTANGULAR_MODE:a.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR");break;case e.Texture.FIXED_EQUIRECTANGULAR_MODE:a.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR_FIXED");break;case e.Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:a.setReflectionMode("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED")}}else a.REFLECTION=!1;if(this._emissiveTexture&&r.EmissiveTextureEnabled){if(!this._emissiveTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._emissiveTexture,a,"EMISSIVE")}else a.EMISSIVE=!1;if(this._lightmapTexture&&r.LightmapTextureEnabled){if(!this._lightmapTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._lightmapTexture,a,"LIGHTMAP"),a.USELIGHTMAPASSHADOWMAP=this._useLightmapAsShadowmap}else a.LIGHTMAP=!1;if(this._specularTexture&&r.SpecularTextureEnabled){if(!this._specularTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._specularTexture,a,"SPECULAR"),a.GLOSSINESS=this._useGlossinessFromSpecularMapAlpha}else a.SPECULAR=!1;if(s.getEngine().getCaps().standardDerivatives&&this._bumpTexture&&r.BumpTextureEnabled){if(!this._bumpTexture.isReady())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._bumpTexture,a,"BUMP"),a.PARALLAX=this._useParallax,a.PARALLAXOCCLUSION=this._useParallaxOcclusion}else a.BUMP=!1;if(this._refractionTexture&&r.RefractionTextureEnabled){if(!this._refractionTexture.isReadyOrNotBlocking())return!1;a._needUVs=!0,a.REFRACTION=!0,a.REFRACTIONMAP_3D=this._refractionTexture.isCube}else a.REFRACTION=!1;a.TWOSIDEDLIGHTING=!this._backFaceCulling&&this._twoSidedLighting}else a.DIFFUSE=!1,a.AMBIENT=!1,a.OPACITY=!1,a.REFLECTION=!1,a.EMISSIVE=!1,a.LIGHTMAP=!1,a.BUMP=!1,a.REFRACTION=!1;a.ALPHAFROMDIFFUSE=this._shouldUseAlphaFromDiffuseTexture(),a.EMISSIVEASILLUMINATION=this._useEmissiveAsIllumination,a.LINKEMISSIVEWITHDIFFUSE=this._linkEmissiveWithDiffuse,a.SPECULAROVERALPHA=this._useSpecularOverAlpha}if(a._areImageProcessingDirty){if(!this._imageProcessingConfiguration.isReady())return!1;this._imageProcessingConfiguration.prepareDefines(a)}if(a._areFresnelDirty&&(r.FresnelEnabled?(this._diffuseFresnelParameters||this._opacityFresnelParameters||this._emissiveFresnelParameters||this._refractionFresnelParameters||this._reflectionFresnelParameters)&&(a.DIFFUSEFRESNEL=this._diffuseFresnelParameters&&this._diffuseFresnelParameters.isEnabled,a.OPACITYFRESNEL=this._opacityFresnelParameters&&this._opacityFresnelParameters.isEnabled,a.REFLECTIONFRESNEL=this._reflectionFresnelParameters&&this._reflectionFresnelParameters.isEnabled,a.REFLECTIONFRESNELFROMSPECULAR=this._useReflectionFresnelFromSpecular,a.REFRACTIONFRESNEL=this._refractionFresnelParameters&&this._refractionFresnelParameters.isEnabled,a.EMISSIVEFRESNEL=this._emissiveFresnelParameters&&this._emissiveFresnelParameters.isEnabled,a._needNormals=!0,a.FRESNEL=!0):a.FRESNEL=!1),e.MaterialHelper.PrepareDefinesForMisc(i,s,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,a),e.MaterialHelper.PrepareDefinesForAttributes(i,a,!0,!0,!0),e.MaterialHelper.PrepareDefinesForFrameBoundValues(s,l,a,o),a.isDirty){a.markAsProcessed(),s.resetCachedMaterial();var h=new e.EffectFallbacks;a.REFLECTION&&h.addFallback(0,"REFLECTION"),a.SPECULAR&&h.addFallback(0,"SPECULAR"),a.BUMP&&h.addFallback(0,"BUMP"),a.PARALLAX&&h.addFallback(1,"PARALLAX"),a.PARALLAXOCCLUSION&&h.addFallback(0,"PARALLAXOCCLUSION"),a.SPECULAROVERALPHA&&h.addFallback(0,"SPECULAROVERALPHA"),a.FOG&&h.addFallback(1,"FOG"),a.POINTSIZE&&h.addFallback(0,"POINTSIZE"),a.LOGARITHMICDEPTH&&h.addFallback(0,"LOGARITHMICDEPTH"),e.MaterialHelper.HandleFallbacksForShadows(a,h,this._maxSimultaneousLights),a.SPECULARTERM&&h.addFallback(0,"SPECULARTERM"),a.DIFFUSEFRESNEL&&h.addFallback(1,"DIFFUSEFRESNEL"),a.OPACITYFRESNEL&&h.addFallback(2,"OPACITYFRESNEL"),a.REFLECTIONFRESNEL&&h.addFallback(3,"REFLECTIONFRESNEL"),a.EMISSIVEFRESNEL&&h.addFallback(4,"EMISSIVEFRESNEL"),a.FRESNEL&&h.addFallback(4,"FRESNEL");var c=[e.VertexBuffer.PositionKind];a.NORMAL&&c.push(e.VertexBuffer.NormalKind),a.UV1&&c.push(e.VertexBuffer.UVKind),a.UV2&&c.push(e.VertexBuffer.UV2Kind),a.VERTEXCOLOR&&c.push(e.VertexBuffer.ColorKind),e.MaterialHelper.PrepareAttributesForBones(c,i,a,h),e.MaterialHelper.PrepareAttributesForInstances(c,a),e.MaterialHelper.PrepareAttributesForMorphTargets(c,i,a);var u="default",f=["world","view","viewProjection","vEyePosition","vLightsType","vAmbientColor","vDiffuseColor","vSpecularColor","vEmissiveColor","vFogInfos","vFogColor","pointSize","vDiffuseInfos","vAmbientInfos","vOpacityInfos","vReflectionInfos","vEmissiveInfos","vSpecularInfos","vBumpInfos","vLightmapInfos","vRefractionInfos","mBones","vClipPlane","diffuseMatrix","ambientMatrix","opacityMatrix","reflectionMatrix","emissiveMatrix","specularMatrix","bumpMatrix","lightmapMatrix","refractionMatrix","diffuseLeftColor","diffuseRightColor","opacityParts","reflectionLeftColor","reflectionRightColor","emissiveLeftColor","emissiveRightColor","refractionLeftColor","refractionRightColor","logarithmicDepthConstant","vNormalReoderParams"],d=["diffuseSampler","ambientSampler","opacitySampler","reflectionCubeSampler","reflection2DSampler","emissiveSampler","specularSampler","bumpSampler","lightmapSampler","refractionCubeSampler","refraction2DSampler"],p=["Material","Scene"];e.ImageProcessingConfiguration.PrepareUniforms(f,a),e.ImageProcessingConfiguration.PrepareSamplers(d,a),e.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:f,uniformBuffersNames:p,samplers:d,defines:a,maxSimultaneousLights:this._maxSimultaneousLights}),this.customShaderNameResolve&&(u=this.customShaderNameResolve(u,f,p,d,a));var _=a.toString();n.setEffect(s.getEngine().createEffect(u,{attributes:c,uniformsNames:f,uniformBuffersNames:p,samplers:d,defines:_,fallbacks:h,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights,maxSimultaneousMorphTargets:a.NUM_MORPH_INFLUENCERS}},l),a),this.buildUniformLayout()}return!!n.effect.isReady()&&(a._renderId=s.getRenderId(),this._wasPreviouslyReady=!0,!0)},r.prototype.buildUniformLayout=function(){this._uniformBuffer.addUniform("diffuseLeftColor",4),this._uniformBuffer.addUniform("diffuseRightColor",4),this._uniformBuffer.addUniform("opacityParts",4),this._uniformBuffer.addUniform("reflectionLeftColor",4),this._uniformBuffer.addUniform("reflectionRightColor",4),this._uniformBuffer.addUniform("refractionLeftColor",4),this._uniformBuffer.addUniform("refractionRightColor",4),this._uniformBuffer.addUniform("emissiveLeftColor",4),this._uniformBuffer.addUniform("emissiveRightColor",4),this._uniformBuffer.addUniform("vDiffuseInfos",2),this._uniformBuffer.addUniform("vAmbientInfos",2),this._uniformBuffer.addUniform("vOpacityInfos",2),this._uniformBuffer.addUniform("vReflectionInfos",2),this._uniformBuffer.addUniform("vEmissiveInfos",2),this._uniformBuffer.addUniform("vLightmapInfos",2),this._uniformBuffer.addUniform("vSpecularInfos",2),this._uniformBuffer.addUniform("vBumpInfos",3),this._uniformBuffer.addUniform("diffuseMatrix",16),this._uniformBuffer.addUniform("ambientMatrix",16),this._uniformBuffer.addUniform("opacityMatrix",16),this._uniformBuffer.addUniform("reflectionMatrix",16),this._uniformBuffer.addUniform("emissiveMatrix",16),this._uniformBuffer.addUniform("lightmapMatrix",16),this._uniformBuffer.addUniform("specularMatrix",16),this._uniformBuffer.addUniform("bumpMatrix",16),this._uniformBuffer.addUniform("vNormalReoderParams",4),this._uniformBuffer.addUniform("refractionMatrix",16),this._uniformBuffer.addUniform("vRefractionInfos",4),this._uniformBuffer.addUniform("vSpecularColor",4),this._uniformBuffer.addUniform("vEmissiveColor",3),this._uniformBuffer.addUniform("vDiffuseColor",4),this._uniformBuffer.addUniform("pointSize",1),this._uniformBuffer.create()},r.prototype.unbind=function(){this._activeEffect&&(this._reflectionTexture&&this._reflectionTexture.isRenderTarget&&this._activeEffect.setTexture("reflection2DSampler",null),this._refractionTexture&&this._refractionTexture.isRenderTarget&&this._activeEffect.setTexture("refraction2DSampler",null)),i.prototype.unbind.call(this)},r.prototype.bindForSubMesh=function(t,i,n){var o=this.getScene(),s=n._materialDefines;if(s){var a=n.effect;if(this._activeEffect=a,this.bindOnlyWorldMatrix(t),e.MaterialHelper.BindBonesParameters(i,a),this._mustRebind(o,a,i.visibility)){if(this._uniformBuffer.bindToEffect(a,"Material"),this.bindViewProjection(a),!this._uniformBuffer.useUbo||!this.isFrozen||!this._uniformBuffer.isSync){if(r.FresnelEnabled&&s.FRESNEL&&(this.diffuseFresnelParameters&&this.diffuseFresnelParameters.isEnabled&&(this._uniformBuffer.updateColor4("diffuseLeftColor",this.diffuseFresnelParameters.leftColor,this.diffuseFresnelParameters.power),this._uniformBuffer.updateColor4("diffuseRightColor",this.diffuseFresnelParameters.rightColor,this.diffuseFresnelParameters.bias)),this.opacityFresnelParameters&&this.opacityFresnelParameters.isEnabled&&this._uniformBuffer.updateColor4("opacityParts",new e.Color3(this.opacityFresnelParameters.leftColor.toLuminance(),this.opacityFresnelParameters.rightColor.toLuminance(),this.opacityFresnelParameters.bias),this.opacityFresnelParameters.power),this.reflectionFresnelParameters&&this.reflectionFresnelParameters.isEnabled&&(this._uniformBuffer.updateColor4("reflectionLeftColor",this.reflectionFresnelParameters.leftColor,this.reflectionFresnelParameters.power),this._uniformBuffer.updateColor4("reflectionRightColor",this.reflectionFresnelParameters.rightColor,this.reflectionFresnelParameters.bias)),this.refractionFresnelParameters&&this.refractionFresnelParameters.isEnabled&&(this._uniformBuffer.updateColor4("refractionLeftColor",this.refractionFresnelParameters.leftColor,this.refractionFresnelParameters.power),this._uniformBuffer.updateColor4("refractionRightColor",this.refractionFresnelParameters.rightColor,this.refractionFresnelParameters.bias)),this.emissiveFresnelParameters&&this.emissiveFresnelParameters.isEnabled&&(this._uniformBuffer.updateColor4("emissiveLeftColor",this.emissiveFresnelParameters.leftColor,this.emissiveFresnelParameters.power),this._uniformBuffer.updateColor4("emissiveRightColor",this.emissiveFresnelParameters.rightColor,this.emissiveFresnelParameters.bias))),o.texturesEnabled&&(this._diffuseTexture&&r.DiffuseTextureEnabled&&(this._uniformBuffer.updateFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),e.MaterialHelper.BindTextureMatrix(this._diffuseTexture,this._uniformBuffer,"diffuse")),this._ambientTexture&&r.AmbientTextureEnabled&&(this._uniformBuffer.updateFloat2("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level),e.MaterialHelper.BindTextureMatrix(this._ambientTexture,this._uniformBuffer,"ambient")),this._opacityTexture&&r.OpacityTextureEnabled&&(this._uniformBuffer.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),e.MaterialHelper.BindTextureMatrix(this._opacityTexture,this._uniformBuffer,"opacity")),this._reflectionTexture&&r.ReflectionTextureEnabled&&(this._uniformBuffer.updateFloat2("vReflectionInfos",this._reflectionTexture.level,this.roughness),this._uniformBuffer.updateMatrix("reflectionMatrix",this._reflectionTexture.getReflectionTextureMatrix())),this._emissiveTexture&&r.EmissiveTextureEnabled&&(this._uniformBuffer.updateFloat2("vEmissiveInfos",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),e.MaterialHelper.BindTextureMatrix(this._emissiveTexture,this._uniformBuffer,"emissive")),this._lightmapTexture&&r.LightmapTextureEnabled&&(this._uniformBuffer.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),e.MaterialHelper.BindTextureMatrix(this._lightmapTexture,this._uniformBuffer,"lightmap")),this._specularTexture&&r.SpecularTextureEnabled&&(this._uniformBuffer.updateFloat2("vSpecularInfos",this._specularTexture.coordinatesIndex,this._specularTexture.level),e.MaterialHelper.BindTextureMatrix(this._specularTexture,this._uniformBuffer,"specular")),this._bumpTexture&&o.getEngine().getCaps().standardDerivatives&&r.BumpTextureEnabled&&(this._uniformBuffer.updateFloat3("vBumpInfos",this._bumpTexture.coordinatesIndex,1/this._bumpTexture.level,this.parallaxScaleBias),e.MaterialHelper.BindTextureMatrix(this._bumpTexture,this._uniformBuffer,"bump"),o._mirroredCameraPosition?this._uniformBuffer.updateFloat4("vNormalReoderParams",this.invertNormalMapX?0:1,this.invertNormalMapX?1:-1,this.invertNormalMapY?0:1,this.invertNormalMapY?1:-1):this._uniformBuffer.updateFloat4("vNormalReoderParams",this.invertNormalMapX?1:0,this.invertNormalMapX?-1:1,this.invertNormalMapY?1:0,this.invertNormalMapY?-1:1)),this._refractionTexture&&r.RefractionTextureEnabled)){var l=1;this._refractionTexture.isCube||(this._uniformBuffer.updateMatrix("refractionMatrix",this._refractionTexture.getReflectionTextureMatrix()),this._refractionTexture.depth&&(l=this._refractionTexture.depth)),this._uniformBuffer.updateFloat4("vRefractionInfos",this._refractionTexture.level,this.indexOfRefraction,l,this.invertRefractionY?-1:1)}this.pointsCloud&&this._uniformBuffer.updateFloat("pointSize",this.pointSize),s.SPECULARTERM&&this._uniformBuffer.updateColor4("vSpecularColor",this.specularColor,this.specularPower),this._uniformBuffer.updateColor3("vEmissiveColor",this.emissiveColor),this._uniformBuffer.updateColor4("vDiffuseColor",this.diffuseColor,this.alpha*i.visibility)}if(o.texturesEnabled&&(this._diffuseTexture&&r.DiffuseTextureEnabled&&a.setTexture("diffuseSampler",this._diffuseTexture),this._ambientTexture&&r.AmbientTextureEnabled&&a.setTexture("ambientSampler",this._ambientTexture),this._opacityTexture&&r.OpacityTextureEnabled&&a.setTexture("opacitySampler",this._opacityTexture),this._reflectionTexture&&r.ReflectionTextureEnabled&&(this._reflectionTexture.isCube?a.setTexture("reflectionCubeSampler",this._reflectionTexture):a.setTexture("reflection2DSampler",this._reflectionTexture)),this._emissiveTexture&&r.EmissiveTextureEnabled&&a.setTexture("emissiveSampler",this._emissiveTexture),this._lightmapTexture&&r.LightmapTextureEnabled&&a.setTexture("lightmapSampler",this._lightmapTexture),this._specularTexture&&r.SpecularTextureEnabled&&a.setTexture("specularSampler",this._specularTexture),this._bumpTexture&&o.getEngine().getCaps().standardDerivatives&&r.BumpTextureEnabled&&a.setTexture("bumpSampler",this._bumpTexture),this._refractionTexture&&r.RefractionTextureEnabled)){var l=1;this._refractionTexture.isCube?a.setTexture("refractionCubeSampler",this._refractionTexture):a.setTexture("refraction2DSampler",this._refractionTexture)}e.MaterialHelper.BindClipPlane(a,o),o.ambientColor.multiplyToRef(this.ambientColor,this._globalAmbientColor),a.setVector3("vEyePosition",o._mirroredCameraPosition?o._mirroredCameraPosition:o.activeCamera.globalPosition),a.setColor3("vAmbientColor",this._globalAmbientColor)}!this._mustRebind(o,a)&&this.isFrozen||(o.lightsEnabled&&!this._disableLighting&&e.MaterialHelper.BindLights(o,i,a,s,this._maxSimultaneousLights),(o.fogEnabled&&i.applyFog&&o.fogMode!==e.Scene.FOGMODE_NONE||this._reflectionTexture||this._refractionTexture)&&this.bindView(a),e.MaterialHelper.BindFogParameters(o,i,a),s.NUM_MORPH_INFLUENCERS&&e.MaterialHelper.BindMorphTargetParameters(i,a),e.MaterialHelper.BindLogDepth(s,a,o),this._imageProcessingConfiguration.bind(this._activeEffect)),this._uniformBuffer.update(),this._afterBind(i,this._activeEffect)}},r.prototype.getAnimatables=function(){var e=[];return this._diffuseTexture&&this._diffuseTexture.animations&&this._diffuseTexture.animations.length>0&&e.push(this._diffuseTexture),this._ambientTexture&&this._ambientTexture.animations&&this._ambientTexture.animations.length>0&&e.push(this._ambientTexture),this._opacityTexture&&this._opacityTexture.animations&&this._opacityTexture.animations.length>0&&e.push(this._opacityTexture),this._reflectionTexture&&this._reflectionTexture.animations&&this._reflectionTexture.animations.length>0&&e.push(this._reflectionTexture),this._emissiveTexture&&this._emissiveTexture.animations&&this._emissiveTexture.animations.length>0&&e.push(this._emissiveTexture),this._specularTexture&&this._specularTexture.animations&&this._specularTexture.animations.length>0&&e.push(this._specularTexture),this._bumpTexture&&this._bumpTexture.animations&&this._bumpTexture.animations.length>0&&e.push(this._bumpTexture),this._lightmapTexture&&this._lightmapTexture.animations&&this._lightmapTexture.animations.length>0&&e.push(this._lightmapTexture),this._refractionTexture&&this._refractionTexture.animations&&this._refractionTexture.animations.length>0&&e.push(this._refractionTexture),e},r.prototype.getActiveTextures=function(){var e=i.prototype.getActiveTextures.call(this);return this._diffuseTexture&&e.push(this._diffuseTexture),this._ambientTexture&&e.push(this._ambientTexture),this._opacityTexture&&e.push(this._opacityTexture),this._reflectionTexture&&e.push(this._reflectionTexture),this._emissiveTexture&&e.push(this._emissiveTexture),this._specularTexture&&e.push(this._specularTexture),this._bumpTexture&&e.push(this._bumpTexture),this._lightmapTexture&&e.push(this._lightmapTexture),this._refractionTexture&&e.push(this._refractionTexture),e},r.prototype.hasTexture=function(e){return!!i.prototype.hasTexture.call(this,e)||(this._diffuseTexture===e||(this._ambientTexture===e||(this._opacityTexture===e||(this._reflectionTexture===e||(this._emissiveTexture===e||(this._specularTexture===e||(this._bumpTexture===e||(this._lightmapTexture===e||this._refractionTexture===e))))))))},r.prototype.dispose=function(e,t){t&&(this._diffuseTexture&&this._diffuseTexture.dispose(),this._ambientTexture&&this._ambientTexture.dispose(),this._opacityTexture&&this._opacityTexture.dispose(),this._reflectionTexture&&this._reflectionTexture.dispose(),this._emissiveTexture&&this._emissiveTexture.dispose(),this._specularTexture&&this._specularTexture.dispose(),this._bumpTexture&&this._bumpTexture.dispose(),this._lightmapTexture&&this._lightmapTexture.dispose(),this._refractionTexture&&this._refractionTexture.dispose()),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),i.prototype.dispose.call(this,e,t)},r.prototype.clone=function(t){var i=this,n=e.SerializationHelper.Clone((function(){return new r(t,i.getScene())}),this);return n.name=t,n.id=t,n},r.prototype.serialize=function(){return e.SerializationHelper.Serialize(this)},r.Parse=function(t,i,n){return e.SerializationHelper.Parse((function(){return new r(t.name,i)}),t,i,n)},Object.defineProperty(r,"DiffuseTextureEnabled",{get:function(){return r._DiffuseTextureEnabled},set:function(t){r._DiffuseTextureEnabled!==t&&(r._DiffuseTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"AmbientTextureEnabled",{get:function(){return r._AmbientTextureEnabled},set:function(t){r._AmbientTextureEnabled!==t&&(r._AmbientTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"OpacityTextureEnabled",{get:function(){return r._OpacityTextureEnabled},set:function(t){r._OpacityTextureEnabled!==t&&(r._OpacityTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"ReflectionTextureEnabled",{get:function(){return r._ReflectionTextureEnabled},set:function(t){r._ReflectionTextureEnabled!==t&&(r._ReflectionTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"EmissiveTextureEnabled",{get:function(){return r._EmissiveTextureEnabled},set:function(t){r._EmissiveTextureEnabled!==t&&(r._EmissiveTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"SpecularTextureEnabled",{get:function(){return r._SpecularTextureEnabled},set:function(t){r._SpecularTextureEnabled!==t&&(r._SpecularTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"BumpTextureEnabled",{get:function(){return r._BumpTextureEnabled},set:function(t){r._BumpTextureEnabled!==t&&(r._BumpTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"LightmapTextureEnabled",{get:function(){return r._LightmapTextureEnabled},set:function(t){r._LightmapTextureEnabled!==t&&(r._LightmapTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"RefractionTextureEnabled",{get:function(){return r._RefractionTextureEnabled},set:function(t){r._RefractionTextureEnabled!==t&&(r._RefractionTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"ColorGradingTextureEnabled",{get:function(){return r._ColorGradingTextureEnabled},set:function(t){r._ColorGradingTextureEnabled!==t&&(r._ColorGradingTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"FresnelEnabled",{get:function(){return r._FresnelEnabled},set:function(t){r._FresnelEnabled!==t&&(r._FresnelEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.FresnelDirtyFlag))},enumerable:!0,configurable:!0}),r})(e.PushMaterial);i._DiffuseTextureEnabled=!0,i._AmbientTextureEnabled=!0,i._OpacityTextureEnabled=!0,i._ReflectionTextureEnabled=!0,i._EmissiveTextureEnabled=!0,i._SpecularTextureEnabled=!0,i._BumpTextureEnabled=!0,i._LightmapTextureEnabled=!0,i._RefractionTextureEnabled=!0,i._ColorGradingTextureEnabled=!0,i._FresnelEnabled=!0,__decorate([e.serializeAsTexture("diffuseTexture")],i.prototype,"_diffuseTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"diffuseTexture",void 0),__decorate([e.serializeAsTexture("ambientTexture")],i.prototype,"_ambientTexture",void 0), +__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"ambientTexture",void 0),__decorate([e.serializeAsTexture("opacityTexture")],i.prototype,"_opacityTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"opacityTexture",void 0),__decorate([e.serializeAsTexture("reflectionTexture")],i.prototype,"_reflectionTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"reflectionTexture",void 0),__decorate([e.serializeAsTexture("emissiveTexture")],i.prototype,"_emissiveTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"emissiveTexture",void 0),__decorate([e.serializeAsTexture("specularTexture")],i.prototype,"_specularTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"specularTexture",void 0),__decorate([e.serializeAsTexture("bumpTexture")],i.prototype,"_bumpTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"bumpTexture",void 0),__decorate([e.serializeAsTexture("lightmapTexture")],i.prototype,"_lightmapTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"lightmapTexture",void 0),__decorate([e.serializeAsTexture("refractionTexture")],i.prototype,"_refractionTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"refractionTexture",void 0),__decorate([e.serializeAsColor3("ambient")],i.prototype,"ambientColor",void 0),__decorate([e.serializeAsColor3("diffuse")],i.prototype,"diffuseColor",void 0),__decorate([e.serializeAsColor3("specular")],i.prototype,"specularColor",void 0),__decorate([e.serializeAsColor3("emissive")],i.prototype,"emissiveColor",void 0),__decorate([e.serialize()],i.prototype,"specularPower",void 0),__decorate([e.serialize("useAlphaFromDiffuseTexture")],i.prototype,"_useAlphaFromDiffuseTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useAlphaFromDiffuseTexture",void 0),__decorate([e.serialize("useEmissiveAsIllumination")],i.prototype,"_useEmissiveAsIllumination",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useEmissiveAsIllumination",void 0),__decorate([e.serialize("linkEmissiveWithDiffuse")],i.prototype,"_linkEmissiveWithDiffuse",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"linkEmissiveWithDiffuse",void 0),__decorate([e.serialize("useSpecularOverAlpha")],i.prototype,"_useSpecularOverAlpha",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useSpecularOverAlpha",void 0),__decorate([e.serialize("useReflectionOverAlpha")],i.prototype,"_useReflectionOverAlpha",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useReflectionOverAlpha",void 0),__decorate([e.serialize("disableLighting")],i.prototype,"_disableLighting",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsLightsDirty")],i.prototype,"disableLighting",void 0),__decorate([e.serialize("useParallax")],i.prototype,"_useParallax",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useParallax",void 0),__decorate([e.serialize("useParallaxOcclusion")],i.prototype,"_useParallaxOcclusion",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useParallaxOcclusion",void 0),__decorate([e.serialize()],i.prototype,"parallaxScaleBias",void 0),__decorate([e.serialize("roughness")],i.prototype,"_roughness",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"roughness",void 0),__decorate([e.serialize()],i.prototype,"indexOfRefraction",void 0),__decorate([e.serialize()],i.prototype,"invertRefractionY",void 0),__decorate([e.serialize("useLightmapAsShadowmap")],i.prototype,"_useLightmapAsShadowmap",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useLightmapAsShadowmap",void 0),__decorate([e.serializeAsFresnelParameters("diffuseFresnelParameters")],i.prototype,"_diffuseFresnelParameters",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],i.prototype,"diffuseFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters("opacityFresnelParameters")],i.prototype,"_opacityFresnelParameters",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],i.prototype,"opacityFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters("reflectionFresnelParameters")],i.prototype,"_reflectionFresnelParameters",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],i.prototype,"reflectionFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters("refractionFresnelParameters")],i.prototype,"_refractionFresnelParameters",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],i.prototype,"refractionFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters("emissiveFresnelParameters")],i.prototype,"_emissiveFresnelParameters",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],i.prototype,"emissiveFresnelParameters",void 0),__decorate([e.serialize("useReflectionFresnelFromSpecular")],i.prototype,"_useReflectionFresnelFromSpecular",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],i.prototype,"useReflectionFresnelFromSpecular",void 0),__decorate([e.serialize("useGlossinessFromSpecularMapAlpha")],i.prototype,"_useGlossinessFromSpecularMapAlpha",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useGlossinessFromSpecularMapAlpha",void 0),__decorate([e.serialize("maxSimultaneousLights")],i.prototype,"_maxSimultaneousLights",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsLightsDirty")],i.prototype,"maxSimultaneousLights",void 0),__decorate([e.serialize("invertNormalMapX")],i.prototype,"_invertNormalMapX",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"invertNormalMapX",void 0),__decorate([e.serialize("invertNormalMapY")],i.prototype,"_invertNormalMapY",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"invertNormalMapY",void 0),__decorate([e.serialize("twoSidedLighting")],i.prototype,"_twoSidedLighting",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"twoSidedLighting",void 0),__decorate([e.serialize()],i.prototype,"useLogarithmicDepth",null),e.StandardMaterial=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(e){function t(){var t=e.call(this)||this;return t.PBR=!0,t.MAINUV1=!1,t.MAINUV2=!1,t.UV1=!1,t.UV2=!1,t.ALBEDO=!1,t.ALBEDODIRECTUV=0,t.VERTEXCOLOR=!1,t.AMBIENT=!1,t.AMBIENTDIRECTUV=0,t.AMBIENTINGRAYSCALE=!1,t.OPACITY=!1,t.VERTEXALPHA=!1,t.OPACITYDIRECTUV=0,t.OPACITYRGB=!1,t.ALPHATEST=!1,t.ALPHABLEND=!1,t.ALPHAFROMALBEDO=!1,t.ALPHATESTVALUE=.5,t.SPECULAROVERALPHA=!1,t.RADIANCEOVERALPHA=!1,t.ALPHAFRESNEL=!1,t.PREMULTIPLYALPHA=!1,t.EMISSIVE=!1,t.EMISSIVEDIRECTUV=0,t.REFLECTIVITY=!1,t.REFLECTIVITYDIRECTUV=0,t.SPECULARTERM=!1,t.MICROSURFACEFROMREFLECTIVITYMAP=!1,t.MICROSURFACEAUTOMATIC=!1,t.LODBASEDMICROSFURACE=!1,t.MICROSURFACEMAP=!1,t.MICROSURFACEMAPDIRECTUV=0,t.METALLICWORKFLOW=!1,t.ROUGHNESSSTOREINMETALMAPALPHA=!1,t.ROUGHNESSSTOREINMETALMAPGREEN=!1,t.METALLNESSSTOREINMETALMAPBLUE=!1,t.AOSTOREINMETALMAPRED=!1,t.ENVIRONMENTBRDF=!1,t.NORMAL=!1,t.TANGENT=!1,t.BUMP=!1,t.BUMPDIRECTUV=0,t.PARALLAX=!1,t.PARALLAXOCCLUSION=!1,t.NORMALXYSCALE=!0,t.LIGHTMAP=!1,t.LIGHTMAPDIRECTUV=0,t.USELIGHTMAPASSHADOWMAP=!1,t.REFLECTION=!1,t.REFLECTIONMAP_3D=!1,t.REFLECTIONMAP_SPHERICAL=!1,t.REFLECTIONMAP_PLANAR=!1,t.REFLECTIONMAP_CUBIC=!1,t.REFLECTIONMAP_PROJECTION=!1,t.REFLECTIONMAP_SKYBOX=!1,t.REFLECTIONMAP_EXPLICIT=!1,t.REFLECTIONMAP_EQUIRECTANGULAR=!1,t.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,t.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,t.INVERTCUBICMAP=!1,t.USESPHERICALFROMREFLECTIONMAP=!1,t.USESPHERICALINFRAGMENT=!1,t.REFLECTIONMAP_OPPOSITEZ=!1,t.LODINREFLECTIONALPHA=!1,t.GAMMAREFLECTION=!1,t.REFRACTION=!1,t.REFRACTIONMAP_3D=!1,t.REFRACTIONMAP_OPPOSITEZ=!1,t.LODINREFRACTIONALPHA=!1,t.GAMMAREFRACTION=!1,t.LINKREFRACTIONTOTRANSPARENCY=!1,t.INSTANCES=!1,t.NUM_BONE_INFLUENCERS=0,t.BonesPerMesh=0,t.MORPHTARGETS=!1,t.MORPHTARGETS_NORMAL=!1,t.MORPHTARGETS_TANGENT=!1,t.NUM_MORPH_INFLUENCERS=0,t.IMAGEPROCESSING=!1,t.VIGNETTE=!1,t.VIGNETTEBLENDMODEMULTIPLY=!1,t.VIGNETTEBLENDMODEOPAQUE=!1,t.TONEMAPPING=!1,t.CONTRAST=!1,t.COLORCURVES=!1,t.COLORGRADING=!1,t.SAMPLER3DGREENDEPTH=!1,t.SAMPLER3DBGRMAP=!1,t.IMAGEPROCESSINGPOSTPROCESS=!1,t.EXPOSURE=!1,t.USEPHYSICALLIGHTFALLOFF=!1,t.TWOSIDEDLIGHTING=!1,t.SHADOWFLOAT=!1,t.USERIGHTHANDEDSYSTEM=!1,t.CLIPPLANE=!1,t.POINTSIZE=!1,t.FOG=!1,t.LOGARITHMICDEPTH=!1,t.FORCENORMALFORWARD=!1,t.rebuild(),t}return __extends(t,e),t.prototype.reset=function(){e.prototype.reset.call(this),this.ALPHATESTVALUE=.5,this.PBR=!0},t})(e.MaterialDefines),i=(function(i){function r(t,r){var n=i.call(this,t,r)||this;return n._directIntensity=1,n._emissiveIntensity=1,n._environmentIntensity=1,n._specularIntensity=1,n._lightingInfos=new e.Vector4(n._directIntensity,n._emissiveIntensity,n._environmentIntensity,n._specularIntensity),n._disableBumpMap=!1,n._ambientTextureStrength=1,n._ambientColor=new e.Color3(0,0,0),n._albedoColor=new e.Color3(1,1,1),n._reflectivityColor=new e.Color3(1,1,1),n._reflectionColor=new e.Color3(1,1,1),n._emissiveColor=new e.Color3(0,0,0),n._microSurface=.9,n._indexOfRefraction=.66,n._invertRefractionY=!1,n._linkRefractionWithTransparency=!1,n._useLightmapAsShadowmap=!1,n._useAlphaFromAlbedoTexture=!1,n._useSpecularOverAlpha=!0,n._useMicroSurfaceFromReflectivityMapAlpha=!1,n._useRoughnessFromMetallicTextureAlpha=!0,n._useRoughnessFromMetallicTextureGreen=!1,n._useMetallnessFromMetallicTextureBlue=!1,n._useAmbientOcclusionFromMetallicTextureRed=!1,n._useAmbientInGrayScale=!1,n._useAutoMicroSurfaceFromReflectivityMap=!1,n._usePhysicalLightFalloff=!0,n._useRadianceOverAlpha=!0,n._useParallax=!1,n._useParallaxOcclusion=!1,n._parallaxScaleBias=.05,n._disableLighting=!1,n._maxSimultaneousLights=4,n._invertNormalMapX=!1,n._invertNormalMapY=!1,n._twoSidedLighting=!1,n._alphaCutOff=.4,n._forceAlphaTest=!1,n._preMultiplyAlpha=!1,n._useAlphaFresnel=!1,n._environmentBRDFTexture=null,n._forceIrradianceInFragment=!1,n._forceNormalForward=!1,n._renderTargets=new e.SmartArray(16),n._worldViewProjectionMatrix=e.Matrix.Zero(),n._globalAmbientColor=new e.Color3(0,0,0),n._tempColor=new e.Color3,n._attachImageProcessingConfiguration(null),n.getRenderTargetTextures=function(){return n._renderTargets.reset(),e.StandardMaterial.ReflectionTextureEnabled&&n._reflectionTexture&&n._reflectionTexture.isRenderTarget&&n._renderTargets.push(n._reflectionTexture),e.StandardMaterial.RefractionTextureEnabled&&n._refractionTexture&&n._refractionTexture.isRenderTarget&&n._renderTargets.push(n._refractionTexture),n._renderTargets},n._environmentBRDFTexture=e.TextureTools.GetEnvironmentBRDFTexture(r),n}return __extends(r,i),r.prototype._attachImageProcessingConfiguration=function(e){var t=this;e!==this._imageProcessingConfiguration&&(this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),this._imageProcessingConfiguration=e||this.getScene().imageProcessingConfiguration,this._imageProcessingObserver=this._imageProcessingConfiguration.onUpdateParameters.add((function(e){t._markAllSubMeshesAsImageProcessingDirty()})))},r.prototype.getClassName=function(){return"PBRBaseMaterial"},Object.defineProperty(r.prototype,"useLogarithmicDepth",{get:function(){return this._useLogarithmicDepth},set:function(e){this._useLogarithmicDepth=e&&this.getScene().getEngine().getCaps().fragmentDepthSupported},enumerable:!0,configurable:!0}),r.prototype.needAlphaBlending=function(){return!this._linkRefractionWithTransparency&&(this.alpha<1||null!=this._opacityTexture||this._shouldUseAlphaFromAlbedoTexture())},r.prototype.needAlphaTesting=function(){return!!this._forceAlphaTest||!this._linkRefractionWithTransparency&&(null!=this._albedoTexture&&this._albedoTexture.hasAlpha)},r.prototype._shouldUseAlphaFromAlbedoTexture=function(){return null!=this._albedoTexture&&this._albedoTexture.hasAlpha&&this._useAlphaFromAlbedoTexture},r.prototype.getAlphaTestTexture=function(){return this._albedoTexture},r.prototype.isReadyForSubMesh=function(i,r,n){if(this.isFrozen&&this._wasPreviouslyReady)return!0;r._materialDefines||(r._materialDefines=new t);var o=this.getScene(),s=r._materialDefines;if(!this.checkReadyOnEveryCall&&r.effect&&s._renderId===o.getRenderId())return!0;var a=o.getEngine();if(e.MaterialHelper.PrepareDefinesForLights(o,i,s,!0,this._maxSimultaneousLights,this._disableLighting),s._needNormals=!0,s._areTexturesDirty){if(s._needUVs=!1,o.texturesEnabled){if(o.getEngine().getCaps().textureLOD&&(s.LODBASEDMICROSFURACE=!0),this._albedoTexture&&e.StandardMaterial.DiffuseTextureEnabled){if(!this._albedoTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._albedoTexture,s,"ALBEDO")}else s.ALBEDO=!1;if(this._ambientTexture&&e.StandardMaterial.AmbientTextureEnabled){if(!this._ambientTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._ambientTexture,s,"AMBIENT"),s.AMBIENTINGRAYSCALE=this._useAmbientInGrayScale}else s.AMBIENT=!1;if(this._opacityTexture&&e.StandardMaterial.OpacityTextureEnabled){if(!this._opacityTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._opacityTexture,s,"OPACITY"),s.OPACITYRGB=this._opacityTexture.getAlphaFromRGB}else s.OPACITY=!1;var l=this._getReflectionTexture();if(l&&e.StandardMaterial.ReflectionTextureEnabled){if(!l.isReadyOrNotBlocking())return!1;switch(s.REFLECTION=!0,s.GAMMAREFLECTION=l.gammaSpace,s.REFLECTIONMAP_OPPOSITEZ=this.getScene().useRightHandedSystem?!l.invertZ:l.invertZ,s.LODINREFLECTIONALPHA=l.lodLevelInAlpha,l.coordinatesMode===e.Texture.INVCUBIC_MODE&&(s.INVERTCUBICMAP=!0),s.REFLECTIONMAP_3D=l.isCube,l.coordinatesMode){case e.Texture.CUBIC_MODE:case e.Texture.INVCUBIC_MODE:s.REFLECTIONMAP_CUBIC=!0;break;case e.Texture.EXPLICIT_MODE:s.REFLECTIONMAP_EXPLICIT=!0;break;case e.Texture.PLANAR_MODE:s.REFLECTIONMAP_PLANAR=!0;break;case e.Texture.PROJECTION_MODE:s.REFLECTIONMAP_PROJECTION=!0;break;case e.Texture.SKYBOX_MODE:s.REFLECTIONMAP_SKYBOX=!0;break;case e.Texture.SPHERICAL_MODE:s.REFLECTIONMAP_SPHERICAL=!0;break;case e.Texture.EQUIRECTANGULAR_MODE:s.REFLECTIONMAP_EQUIRECTANGULAR=!0;break;case e.Texture.FIXED_EQUIRECTANGULAR_MODE:s.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!0;break;case e.Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:s.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!0}l.coordinatesMode!==e.Texture.SKYBOX_MODE&&l.sphericalPolynomial&&(s.USESPHERICALFROMREFLECTIONMAP=!0,(this._forceIrradianceInFragment||o.getEngine().getCaps().maxVaryingVectors<=8)&&(s.USESPHERICALINFRAGMENT=!0))}else s.REFLECTION=!1,s.REFLECTIONMAP_3D=!1,s.REFLECTIONMAP_SPHERICAL=!1,s.REFLECTIONMAP_PLANAR=!1,s.REFLECTIONMAP_CUBIC=!1,s.REFLECTIONMAP_PROJECTION=!1,s.REFLECTIONMAP_SKYBOX=!1,s.REFLECTIONMAP_EXPLICIT=!1,s.REFLECTIONMAP_EQUIRECTANGULAR=!1,s.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,s.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,s.INVERTCUBICMAP=!1,s.USESPHERICALFROMREFLECTIONMAP=!1,s.USESPHERICALINFRAGMENT=!1,s.REFLECTIONMAP_OPPOSITEZ=!1,s.LODINREFLECTIONALPHA=!1,s.GAMMAREFLECTION=!1;if(this._lightmapTexture&&e.StandardMaterial.LightmapTextureEnabled){if(!this._lightmapTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._lightmapTexture,s,"LIGHTMAP"),s.USELIGHTMAPASSHADOWMAP=this._useLightmapAsShadowmap}else s.LIGHTMAP=!1;if(this._emissiveTexture&&e.StandardMaterial.EmissiveTextureEnabled){if(!this._emissiveTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._emissiveTexture,s,"EMISSIVE")}else s.EMISSIVE=!1;if(e.StandardMaterial.SpecularTextureEnabled){if(this._metallicTexture){if(!this._metallicTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._metallicTexture,s,"REFLECTIVITY"),s.METALLICWORKFLOW=!0,s.ROUGHNESSSTOREINMETALMAPALPHA=this._useRoughnessFromMetallicTextureAlpha,s.ROUGHNESSSTOREINMETALMAPGREEN=!this._useRoughnessFromMetallicTextureAlpha&&this._useRoughnessFromMetallicTextureGreen,s.METALLNESSSTOREINMETALMAPBLUE=this._useMetallnessFromMetallicTextureBlue,s.AOSTOREINMETALMAPRED=this._useAmbientOcclusionFromMetallicTextureRed}else if(this._reflectivityTexture){if(!this._reflectivityTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._reflectivityTexture,s,"REFLECTIVITY"),s.MICROSURFACEFROMREFLECTIVITYMAP=this._useMicroSurfaceFromReflectivityMapAlpha,s.MICROSURFACEAUTOMATIC=this._useAutoMicroSurfaceFromReflectivityMap}else s.REFLECTIVITY=!1;if(this._microSurfaceTexture){if(!this._microSurfaceTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._microSurfaceTexture,s,"MICROSURFACEMAP")}else s.MICROSURFACEMAP=!1}else s.REFLECTIVITY=!1,s.MICROSURFACEMAP=!1;if(o.getEngine().getCaps().standardDerivatives&&this._bumpTexture&&e.StandardMaterial.BumpTextureEnabled&&!this._disableBumpMap){if(!this._bumpTexture.isReady())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._bumpTexture,s,"BUMP"),this._useParallax&&this._albedoTexture&&e.StandardMaterial.DiffuseTextureEnabled?(s.PARALLAX=!0,s.PARALLAXOCCLUSION=!!this._useParallaxOcclusion):s.PARALLAX=!1,s.USERIGHTHANDEDSYSTEM=o.useRightHandedSystem}else s.BUMP=!1;var h=this._getRefractionTexture();if(h&&e.StandardMaterial.RefractionTextureEnabled){if(!h.isReadyOrNotBlocking())return!1;s.REFRACTION=!0,s.REFRACTIONMAP_3D=h.isCube,s.GAMMAREFRACTION=h.gammaSpace,s.REFRACTIONMAP_OPPOSITEZ=l.invertZ,s.LODINREFRACTIONALPHA=l.lodLevelInAlpha,this._linkRefractionWithTransparency&&(s.LINKREFRACTIONTOTRANSPARENCY=!0)}else s.REFRACTION=!1;if(this._environmentBRDFTexture&&e.StandardMaterial.ReflectionTextureEnabled){if(!this._environmentBRDFTexture.isReady())return!1;s.ENVIRONMENTBRDF=!0}this._shouldUseAlphaFromAlbedoTexture()&&(s.ALPHAFROMALBEDO=!0)}this._useSpecularOverAlpha&&(s.SPECULAROVERALPHA=!0),this._usePhysicalLightFalloff&&(s.USEPHYSICALLIGHTFALLOFF=!0),this._useRadianceOverAlpha&&(s.RADIANCEOVERALPHA=!0),(void 0!==this._metallic&&null!==this._metallic||void 0!==this._roughness&&null!==this._roughness)&&(s.METALLICWORKFLOW=!0),!this.backFaceCulling&&this._twoSidedLighting&&(s.TWOSIDEDLIGHTING=!0),s.ALPHATESTVALUE=this._alphaCutOff,s.PREMULTIPLYALPHA=this._preMultiplyAlpha,s.ALPHABLEND=this.needAlphaBlending(),s.ALPHAFRESNEL=this._useAlphaFresnel}if(s._areImageProcessingDirty){if(!this._imageProcessingConfiguration.isReady())return!1;this._imageProcessingConfiguration.prepareDefines(s)}if(s.FORCENORMALFORWARD=this._forceNormalForward,e.MaterialHelper.PrepareDefinesForMisc(i,o,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,s),e.MaterialHelper.PrepareDefinesForFrameBoundValues(o,a,s,n,this._forceAlphaTest),e.MaterialHelper.PrepareDefinesForAttributes(i,s,!0,!0,!0)&&i&&(o.getEngine().getCaps().standardDerivatives||i.isVerticesDataPresent(e.VertexBuffer.NormalKind)||(i.createNormals(!0),e.Tools.Warn("PBRMaterial: Normals have been created for the mesh: "+i.name))),s.isDirty){s.markAsProcessed(),o.resetCachedMaterial();var c=new e.EffectFallbacks;s.ENVIRONMENTBRDF&&c.addFallback(0,"ENVIRONMENTBRDF"),s.REFLECTION&&c.addFallback(0,"REFLECTION"),s.REFRACTION&&c.addFallback(0,"REFRACTION"),s.REFLECTIVITY&&c.addFallback(0,"REFLECTIVITY"),s.BUMP&&c.addFallback(0,"BUMP"),s.PARALLAX&&c.addFallback(1,"PARALLAX"),s.PARALLAXOCCLUSION&&c.addFallback(0,"PARALLAXOCCLUSION"),s.SPECULAROVERALPHA&&c.addFallback(0,"SPECULAROVERALPHA"),s.FOG&&c.addFallback(1,"FOG"),s.POINTSIZE&&c.addFallback(0,"POINTSIZE"),s.LOGARITHMICDEPTH&&c.addFallback(0,"LOGARITHMICDEPTH"),e.MaterialHelper.HandleFallbacksForShadows(s,c,this._maxSimultaneousLights),s.SPECULARTERM&&c.addFallback(0,"SPECULARTERM"),s.NUM_BONE_INFLUENCERS>0&&c.addCPUSkinningFallback(0,i);var u=[e.VertexBuffer.PositionKind];s.NORMAL&&u.push(e.VertexBuffer.NormalKind),s.TANGENT&&u.push(e.VertexBuffer.TangentKind),s.UV1&&u.push(e.VertexBuffer.UVKind),s.UV2&&u.push(e.VertexBuffer.UV2Kind),s.VERTEXCOLOR&&u.push(e.VertexBuffer.ColorKind),e.MaterialHelper.PrepareAttributesForBones(u,i,s,c),e.MaterialHelper.PrepareAttributesForInstances(u,s),e.MaterialHelper.PrepareAttributesForMorphTargets(u,i,s);var f=["world","view","viewProjection","vEyePosition","vLightsType","vAmbientColor","vAlbedoColor","vReflectivityColor","vEmissiveColor","vReflectionColor","vFogInfos","vFogColor","pointSize","vAlbedoInfos","vAmbientInfos","vOpacityInfos","vReflectionInfos","vEmissiveInfos","vReflectivityInfos","vMicroSurfaceSamplerInfos","vBumpInfos","vLightmapInfos","vRefractionInfos","mBones","vClipPlane","albedoMatrix","ambientMatrix","opacityMatrix","reflectionMatrix","emissiveMatrix","reflectivityMatrix","microSurfaceSamplerMatrix","bumpMatrix","lightmapMatrix","refractionMatrix","vLightingIntensity","logarithmicDepthConstant","vSphericalX","vSphericalY","vSphericalZ","vSphericalXX","vSphericalYY","vSphericalZZ","vSphericalXY","vSphericalYZ","vSphericalZX","vReflectionMicrosurfaceInfos","vRefractionMicrosurfaceInfos","vNormalReoderParams"],d=["albedoSampler","reflectivitySampler","ambientSampler","emissiveSampler","bumpSampler","lightmapSampler","opacitySampler","refractionSampler","refractionSamplerLow","refractionSamplerHigh","reflectionSampler","reflectionSamplerLow","reflectionSamplerHigh","microSurfaceSampler","environmentBrdfSampler"],p=["Material","Scene"];e.ImageProcessingConfiguration.PrepareUniforms(f,s),e.ImageProcessingConfiguration.PrepareSamplers(d,s),e.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:f,uniformBuffersNames:p,samplers:d,defines:s,maxSimultaneousLights:this._maxSimultaneousLights});var _=function(e){this.onCompiled&&this.onCompiled(e),this.bindSceneUniformBuffer(e,o.getSceneUniformBuffer())}.bind(this),m=s.toString();r.setEffect(o.getEngine().createEffect("pbr",{attributes:u,uniformsNames:f,uniformBuffersNames:p,samplers:d,defines:m,fallbacks:c,onCompiled:_,onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights,maxSimultaneousMorphTargets:s.NUM_MORPH_INFLUENCERS}},a),s),this.buildUniformLayout()}return!!r.effect.isReady()&&(s._renderId=o.getRenderId(),this._wasPreviouslyReady=!0,!0)},r.prototype.buildUniformLayout=function(){this._uniformBuffer.addUniform("vAlbedoInfos",2),this._uniformBuffer.addUniform("vAmbientInfos",3),this._uniformBuffer.addUniform("vOpacityInfos",2),this._uniformBuffer.addUniform("vEmissiveInfos",2),this._uniformBuffer.addUniform("vLightmapInfos",2),this._uniformBuffer.addUniform("vReflectivityInfos",3),this._uniformBuffer.addUniform("vMicroSurfaceSamplerInfos",2),this._uniformBuffer.addUniform("vRefractionInfos",4),this._uniformBuffer.addUniform("vReflectionInfos",2),this._uniformBuffer.addUniform("vBumpInfos",3),this._uniformBuffer.addUniform("albedoMatrix",16),this._uniformBuffer.addUniform("ambientMatrix",16),this._uniformBuffer.addUniform("opacityMatrix",16),this._uniformBuffer.addUniform("emissiveMatrix",16),this._uniformBuffer.addUniform("lightmapMatrix",16),this._uniformBuffer.addUniform("reflectivityMatrix",16),this._uniformBuffer.addUniform("microSurfaceSamplerMatrix",16),this._uniformBuffer.addUniform("bumpMatrix",16),this._uniformBuffer.addUniform("vNormalReoderParams",4),this._uniformBuffer.addUniform("refractionMatrix",16),this._uniformBuffer.addUniform("reflectionMatrix",16),this._uniformBuffer.addUniform("vReflectionColor",3),this._uniformBuffer.addUniform("vAlbedoColor",4),this._uniformBuffer.addUniform("vLightingIntensity",4),this._uniformBuffer.addUniform("vRefractionMicrosurfaceInfos",3),this._uniformBuffer.addUniform("vReflectionMicrosurfaceInfos",3),this._uniformBuffer.addUniform("vReflectivityColor",4),this._uniformBuffer.addUniform("vEmissiveColor",3),this._uniformBuffer.addUniform("pointSize",1),this._uniformBuffer.create()},r.prototype.unbind=function(){this._reflectionTexture&&this._reflectionTexture.isRenderTarget&&this._uniformBuffer.setTexture("reflectionSampler",null),this._refractionTexture&&this._refractionTexture.isRenderTarget&&this._uniformBuffer.setTexture("refractionSampler",null),i.prototype.unbind.call(this)},r.prototype.bindOnlyWorldMatrix=function(e){this._activeEffect.setMatrix("world",e)},r.prototype.bindForSubMesh=function(t,i,r){var n=this.getScene(),o=r._materialDefines;if(o){var s=r.effect;if(this._activeEffect=s,this.bindOnlyWorldMatrix(t),e.MaterialHelper.BindBonesParameters(i,this._activeEffect),this._mustRebind(n,s,i.visibility)){if(this._uniformBuffer.bindToEffect(s,"Material"),this.bindViewProjection(s),!this._uniformBuffer.useUbo||!this.isFrozen||!this._uniformBuffer.isSync){if(n.texturesEnabled){this._albedoTexture&&e.StandardMaterial.DiffuseTextureEnabled&&(this._uniformBuffer.updateFloat2("vAlbedoInfos",this._albedoTexture.coordinatesIndex,this._albedoTexture.level),e.MaterialHelper.BindTextureMatrix(this._albedoTexture,this._uniformBuffer,"albedo")),this._ambientTexture&&e.StandardMaterial.AmbientTextureEnabled&&(this._uniformBuffer.updateFloat3("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level,this._ambientTextureStrength),e.MaterialHelper.BindTextureMatrix(this._ambientTexture,this._uniformBuffer,"ambient")),this._opacityTexture&&e.StandardMaterial.OpacityTextureEnabled&&(this._uniformBuffer.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),e.MaterialHelper.BindTextureMatrix(this._opacityTexture,this._uniformBuffer,"opacity"));var a=this._getReflectionTexture();if(a&&e.StandardMaterial.ReflectionTextureEnabled){if(this._uniformBuffer.updateMatrix("reflectionMatrix",a.getReflectionTextureMatrix()),this._uniformBuffer.updateFloat2("vReflectionInfos",a.level,0),o.USESPHERICALFROMREFLECTIONMAP){var l=a.sphericalPolynomial;this._activeEffect.setFloat3("vSphericalX",l.x.x,l.x.y,l.x.z),this._activeEffect.setFloat3("vSphericalY",l.y.x,l.y.y,l.y.z),this._activeEffect.setFloat3("vSphericalZ",l.z.x,l.z.y,l.z.z),this._activeEffect.setFloat3("vSphericalXX_ZZ",l.xx.x-l.zz.x,l.xx.y-l.zz.y,l.xx.z-l.zz.z),this._activeEffect.setFloat3("vSphericalYY_ZZ",l.yy.x-l.zz.x,l.yy.y-l.zz.y,l.yy.z-l.zz.z),this._activeEffect.setFloat3("vSphericalZZ",l.zz.x,l.zz.y,l.zz.z),this._activeEffect.setFloat3("vSphericalXY",l.xy.x,l.xy.y,l.xy.z),this._activeEffect.setFloat3("vSphericalYZ",l.yz.x,l.yz.y,l.yz.z),this._activeEffect.setFloat3("vSphericalZX",l.zx.x,l.zx.y,l.zx.z)}this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos",a.getSize().width,a.lodGenerationScale,a.lodGenerationOffset)}this._emissiveTexture&&e.StandardMaterial.EmissiveTextureEnabled&&(this._uniformBuffer.updateFloat2("vEmissiveInfos",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),e.MaterialHelper.BindTextureMatrix(this._emissiveTexture,this._uniformBuffer,"emissive")),this._lightmapTexture&&e.StandardMaterial.LightmapTextureEnabled&&(this._uniformBuffer.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),e.MaterialHelper.BindTextureMatrix(this._lightmapTexture,this._uniformBuffer,"lightmap")),e.StandardMaterial.SpecularTextureEnabled&&(this._metallicTexture?(this._uniformBuffer.updateFloat3("vReflectivityInfos",this._metallicTexture.coordinatesIndex,this._metallicTexture.level,this._ambientTextureStrength),e.MaterialHelper.BindTextureMatrix(this._metallicTexture,this._uniformBuffer,"reflectivity")):this._reflectivityTexture&&(this._uniformBuffer.updateFloat3("vReflectivityInfos",this._reflectivityTexture.coordinatesIndex,this._reflectivityTexture.level,1),e.MaterialHelper.BindTextureMatrix(this._reflectivityTexture,this._uniformBuffer,"reflectivity")),this._microSurfaceTexture&&(this._uniformBuffer.updateFloat2("vMicroSurfaceSamplerInfos",this._microSurfaceTexture.coordinatesIndex,this._microSurfaceTexture.level),e.MaterialHelper.BindTextureMatrix(this._microSurfaceTexture,this._uniformBuffer,"microSurfaceSampler"))),this._bumpTexture&&n.getEngine().getCaps().standardDerivatives&&e.StandardMaterial.BumpTextureEnabled&&!this._disableBumpMap&&(this._uniformBuffer.updateFloat3("vBumpInfos",this._bumpTexture.coordinatesIndex,this._bumpTexture.level,this._parallaxScaleBias),e.MaterialHelper.BindTextureMatrix(this._bumpTexture,this._uniformBuffer,"bump"),n._mirroredCameraPosition?this._uniformBuffer.updateFloat4("vNormalReoderParams",this._invertNormalMapX?0:1,this._invertNormalMapX?1:-1,this._invertNormalMapY?0:1,this._invertNormalMapY?1:-1):this._uniformBuffer.updateFloat4("vNormalReoderParams",this._invertNormalMapX?1:0,this._invertNormalMapX?-1:1,this._invertNormalMapY?1:0,this._invertNormalMapY?-1:1));var h=this._getRefractionTexture();if(h&&e.StandardMaterial.RefractionTextureEnabled){this._uniformBuffer.updateMatrix("refractionMatrix",h.getReflectionTextureMatrix());var c=1;h.isCube||h.depth&&(c=h.depth),this._uniformBuffer.updateFloat4("vRefractionInfos",h.level,this._indexOfRefraction,c,this._invertRefractionY?-1:1),this._uniformBuffer.updateFloat3("vRefractionMicrosurfaceInfos",h.getSize().width,h.lodGenerationScale,h.lodGenerationOffset)}}this.pointsCloud&&this._uniformBuffer.updateFloat("pointSize",this.pointSize),o.METALLICWORKFLOW?(e.PBRMaterial._scaledReflectivity.r=void 0===this._metallic||null===this._metallic?1:this._metallic,e.PBRMaterial._scaledReflectivity.g=void 0===this._roughness||null===this._roughness?1:this._roughness,this._uniformBuffer.updateColor4("vReflectivityColor",e.PBRMaterial._scaledReflectivity,0)):this._uniformBuffer.updateColor4("vReflectivityColor",this._reflectivityColor,this._microSurface),this._uniformBuffer.updateColor3("vEmissiveColor",this._emissiveColor),this._uniformBuffer.updateColor3("vReflectionColor",this._reflectionColor),this._uniformBuffer.updateColor4("vAlbedoColor",this._albedoColor,this.alpha*i.visibility),this._lightingInfos.x=this._directIntensity,this._lightingInfos.y=this._emissiveIntensity,this._lightingInfos.z=this._environmentIntensity,this._lightingInfos.w=this._specularIntensity,this._uniformBuffer.updateVector4("vLightingIntensity",this._lightingInfos)}n.texturesEnabled&&(this._albedoTexture&&e.StandardMaterial.DiffuseTextureEnabled&&this._uniformBuffer.setTexture("albedoSampler",this._albedoTexture),this._ambientTexture&&e.StandardMaterial.AmbientTextureEnabled&&this._uniformBuffer.setTexture("ambientSampler",this._ambientTexture),this._opacityTexture&&e.StandardMaterial.OpacityTextureEnabled&&this._uniformBuffer.setTexture("opacitySampler",this._opacityTexture),a&&e.StandardMaterial.ReflectionTextureEnabled&&(o.LODBASEDMICROSFURACE?this._uniformBuffer.setTexture("reflectionSampler",a):(this._uniformBuffer.setTexture("reflectionSampler",a._lodTextureMid||a),this._uniformBuffer.setTexture("reflectionSamplerLow",a._lodTextureLow||a),this._uniformBuffer.setTexture("reflectionSamplerHigh",a._lodTextureHigh||a))),o.ENVIRONMENTBRDF&&this._uniformBuffer.setTexture("environmentBrdfSampler",this._environmentBRDFTexture),h&&e.StandardMaterial.RefractionTextureEnabled&&(o.LODBASEDMICROSFURACE?this._uniformBuffer.setTexture("refractionSampler",h):(this._uniformBuffer.setTexture("refractionSampler",h._lodTextureMid||h),this._uniformBuffer.setTexture("refractionSamplerLow",h._lodTextureLow||h),this._uniformBuffer.setTexture("refractionSamplerHigh",h._lodTextureHigh||h))),this._emissiveTexture&&e.StandardMaterial.EmissiveTextureEnabled&&this._uniformBuffer.setTexture("emissiveSampler",this._emissiveTexture), +this._lightmapTexture&&e.StandardMaterial.LightmapTextureEnabled&&this._uniformBuffer.setTexture("lightmapSampler",this._lightmapTexture),e.StandardMaterial.SpecularTextureEnabled&&(this._metallicTexture?this._uniformBuffer.setTexture("reflectivitySampler",this._metallicTexture):this._reflectivityTexture&&this._uniformBuffer.setTexture("reflectivitySampler",this._reflectivityTexture),this._microSurfaceTexture&&this._uniformBuffer.setTexture("microSurfaceSampler",this._microSurfaceTexture)),this._bumpTexture&&n.getEngine().getCaps().standardDerivatives&&e.StandardMaterial.BumpTextureEnabled&&!this._disableBumpMap&&this._uniformBuffer.setTexture("bumpSampler",this._bumpTexture)),e.MaterialHelper.BindClipPlane(this._activeEffect,n),n.ambientColor.multiplyToRef(this._ambientColor,this._globalAmbientColor);var u=n._mirroredCameraPosition?n._mirroredCameraPosition:n.activeCamera.globalPosition;s.setFloat4("vEyePosition",u.x,u.y,u.z,n._mirroredCameraPosition?-1:1),s.setColor3("vAmbientColor",this._globalAmbientColor)}!this._mustRebind(n,s)&&this.isFrozen||(n.lightsEnabled&&!this._disableLighting&&e.MaterialHelper.BindLights(n,i,this._activeEffect,o,this._maxSimultaneousLights,this._usePhysicalLightFalloff),(n.fogEnabled&&i.applyFog&&n.fogMode!==e.Scene.FOGMODE_NONE||a)&&this.bindView(s),e.MaterialHelper.BindFogParameters(n,i,this._activeEffect),o.NUM_MORPH_INFLUENCERS&&e.MaterialHelper.BindMorphTargetParameters(i,this._activeEffect),this._imageProcessingConfiguration.bind(this._activeEffect),e.MaterialHelper.BindLogDepth(o,this._activeEffect,n)),this._uniformBuffer.update(),this._afterBind(i),n=null}},r.prototype.getAnimatables=function(){var e=[];return this._albedoTexture&&this._albedoTexture.animations&&this._albedoTexture.animations.length>0&&e.push(this._albedoTexture),this._ambientTexture&&this._ambientTexture.animations&&this._ambientTexture.animations.length>0&&e.push(this._ambientTexture),this._opacityTexture&&this._opacityTexture.animations&&this._opacityTexture.animations.length>0&&e.push(this._opacityTexture),this._reflectionTexture&&this._reflectionTexture.animations&&this._reflectionTexture.animations.length>0&&e.push(this._reflectionTexture),this._emissiveTexture&&this._emissiveTexture.animations&&this._emissiveTexture.animations.length>0&&e.push(this._emissiveTexture),this._metallicTexture&&this._metallicTexture.animations&&this._metallicTexture.animations.length>0?e.push(this._metallicTexture):this._reflectivityTexture&&this._reflectivityTexture.animations&&this._reflectivityTexture.animations.length>0&&e.push(this._reflectivityTexture),this._bumpTexture&&this._bumpTexture.animations&&this._bumpTexture.animations.length>0&&e.push(this._bumpTexture),this._lightmapTexture&&this._lightmapTexture.animations&&this._lightmapTexture.animations.length>0&&e.push(this._lightmapTexture),this._refractionTexture&&this._refractionTexture.animations&&this._refractionTexture.animations.length>0&&e.push(this._refractionTexture),e},r.prototype._getReflectionTexture=function(){return this._reflectionTexture?this._reflectionTexture:this.getScene().environmentTexture},r.prototype._getRefractionTexture=function(){return this._refractionTexture?this._refractionTexture:this._linkRefractionWithTransparency?this.getScene().environmentTexture:null},r.prototype.dispose=function(e,t){t&&(this._albedoTexture&&this._albedoTexture.dispose(),this._ambientTexture&&this._ambientTexture.dispose(),this._opacityTexture&&this._opacityTexture.dispose(),this._reflectionTexture&&this._reflectionTexture.dispose(),this._environmentBRDFTexture&&this._environmentBRDFTexture.dispose(),this._emissiveTexture&&this._emissiveTexture.dispose(),this._metallicTexture&&this._metallicTexture.dispose(),this._reflectivityTexture&&this._reflectivityTexture.dispose(),this._bumpTexture&&this._bumpTexture.dispose(),this._lightmapTexture&&this._lightmapTexture.dispose(),this._refractionTexture&&this._refractionTexture.dispose()),this._renderTargets.dispose(),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),i.prototype.dispose.call(this,e,t)},r})(e.PushMaterial);i._scaledReflectivity=new e.Color3,__decorate([e.serializeAsImageProcessingConfiguration()],i.prototype,"_imageProcessingConfiguration",void 0),__decorate([e.serialize()],i.prototype,"useLogarithmicDepth",null),e.PBRBaseMaterial=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){var i=(function(t){function i(i,r){var n=t.call(this,i,r)||this;return n.maxSimultaneousLights=4,n.disableLighting=!1,n.invertNormalMapX=!1,n.invertNormalMapY=!1,n.emissiveColor=new e.Color3(0,0,0),n.occlusionStrength=1,n._transparencyMode=e.PBRMaterial.PBRMATERIAL_OPAQUE,n._useAmbientInGrayScale=!0,n}return __extends(i,t),Object.defineProperty(i.prototype,"transparencyMode",{get:function(){return this._transparencyMode},set:function(t){this._transparencyMode!==t&&(this._transparencyMode=t,t===e.PBRMaterial.PBRMATERIAL_ALPHATESTANDBLEND?this._forceAlphaTest=!0:this._forceAlphaTest=!1,this._markAllSubMeshesAsTexturesDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"doubleSided",{get:function(){return this._twoSidedLighting},set:function(e){this._twoSidedLighting!==e&&(this._twoSidedLighting=e,this.backFaceCulling=!e,this._markAllSubMeshesAsTexturesDirty())},enumerable:!0,configurable:!0}),i.prototype._shouldUseAlphaFromAlbedoTexture=function(){return this._albedoTexture&&this._albedoTexture.hasAlpha&&this._transparencyMode!==e.PBRMaterial.PBRMATERIAL_OPAQUE},i.prototype.needAlphaBlending=function(){return!this._linkRefractionWithTransparency&&(this.alpha<1||this._shouldUseAlphaFromAlbedoTexture()&&(this._transparencyMode===e.PBRMaterial.PBRMATERIAL_ALPHABLEND||this._transparencyMode===e.PBRMaterial.PBRMATERIAL_ALPHATESTANDBLEND))},i.prototype.needAlphaTesting=function(){return!this._linkRefractionWithTransparency&&(this._shouldUseAlphaFromAlbedoTexture()&&this._transparencyMode===e.PBRMaterial.PBRMATERIAL_ALPHATEST)},i.prototype.getActiveTextures=function(){var e=t.prototype.getActiveTextures.call(this);return this.environmentTexture&&e.push(this.environmentTexture),this.normalTexture&&e.push(this.normalTexture),this.emissiveTexture&&e.push(this.emissiveTexture),this.occlusionTexture&&e.push(this.occlusionTexture),e},i.prototype.getClassName=function(){return"PBRBaseSimpleMaterial"},i})(e.PBRBaseMaterial);__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsLightsDirty")],i.prototype,"maxSimultaneousLights",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsLightsDirty")],i.prototype,"disableLighting",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_reflectionTexture")],i.prototype,"environmentTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"invertNormalMapX",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"invertNormalMapY",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_bumpTexture")],i.prototype,"normalTexture",void 0),__decorate([e.serializeAsColor3("emissive"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"emissiveColor",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"emissiveTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_ambientTextureStrength")],i.prototype,"occlusionStrength",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_ambientTexture")],i.prototype,"occlusionTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_alphaCutOff")],i.prototype,"alphaCutOff",void 0),__decorate([e.serialize()],i.prototype,"transparencyMode",null),__decorate([e.serialize()],i.prototype,"doubleSided",null),t.PBRBaseSimpleMaterial=i})(e.Internals||(e.Internals={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r){var n=t.call(this,i,r)||this;return n.directIntensity=1,n.emissiveIntensity=1,n.environmentIntensity=1,n.specularIntensity=1,n.disableBumpMap=!1,n.ambientTextureStrength=1,n.ambientColor=new e.Color3(0,0,0),n.albedoColor=new e.Color3(1,1,1),n.reflectivityColor=new e.Color3(1,1,1),n.reflectionColor=new e.Color3(1,1,1),n.emissiveColor=new e.Color3(0,0,0),n.microSurface=1,n.indexOfRefraction=.66,n.invertRefractionY=!1,n.linkRefractionWithTransparency=!1,n.useLightmapAsShadowmap=!1,n.useAlphaFromAlbedoTexture=!1,n.forceAlphaTest=!1,n.alphaCutOff=.4,n.useSpecularOverAlpha=!0,n.useMicroSurfaceFromReflectivityMapAlpha=!1,n.useRoughnessFromMetallicTextureAlpha=!0,n.useRoughnessFromMetallicTextureGreen=!1,n.useMetallnessFromMetallicTextureBlue=!1,n.useAmbientOcclusionFromMetallicTextureRed=!1,n.useAmbientInGrayScale=!1,n.useAutoMicroSurfaceFromReflectivityMap=!1,n.usePhysicalLightFalloff=!0,n.useRadianceOverAlpha=!0,n.useParallax=!1,n.useParallaxOcclusion=!1,n.parallaxScaleBias=.05,n.disableLighting=!1,n.forceIrradianceInFragment=!1,n.maxSimultaneousLights=4,n.invertNormalMapX=!1,n.invertNormalMapY=!1,n.twoSidedLighting=!1,n.preMultiplyAlpha=!1,n.useAlphaFresnel=!1,n.environmentBRDFTexture=null,n.forceNormalForward=!1,n._environmentBRDFTexture=e.TextureTools.GetEnvironmentBRDFTexture(r),n}return __extends(i,t),Object.defineProperty(i,"PBRMATERIAL_OPAQUE",{get:function(){return this._PBRMATERIAL_OPAQUE},enumerable:!0,configurable:!0}),Object.defineProperty(i,"PBRMATERIAL_ALPHATEST",{get:function(){return this._PBRMATERIAL_ALPHATEST},enumerable:!0,configurable:!0}),Object.defineProperty(i,"PBRMATERIAL_ALPHABLEND",{get:function(){return this._PBRMATERIAL_ALPHABLEND},enumerable:!0,configurable:!0}),Object.defineProperty(i,"PBRMATERIAL_ALPHATESTANDBLEND",{get:function(){return this._PBRMATERIAL_ALPHATESTANDBLEND},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(e){this._attachImageProcessingConfiguration(e),this._markAllSubMeshesAsTexturesDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"cameraColorCurvesEnabled",{get:function(){return this.imageProcessingConfiguration.colorCurvesEnabled},set:function(e){this.imageProcessingConfiguration.colorCurvesEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"cameraColorGradingEnabled",{get:function(){return this.imageProcessingConfiguration.colorGradingEnabled},set:function(e){this.imageProcessingConfiguration.colorGradingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"cameraToneMappingEnabled",{get:function(){return this._imageProcessingConfiguration.toneMappingEnabled},set:function(e){this._imageProcessingConfiguration.toneMappingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"cameraExposure",{get:function(){return this._imageProcessingConfiguration.exposure},set:function(e){this._imageProcessingConfiguration.exposure=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"cameraContrast",{get:function(){return this._imageProcessingConfiguration.contrast},set:function(e){this._imageProcessingConfiguration.contrast=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"cameraColorGradingTexture",{get:function(){return this._imageProcessingConfiguration.colorGradingTexture},set:function(e){this._imageProcessingConfiguration.colorGradingTexture=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"cameraColorCurves",{get:function(){return this._imageProcessingConfiguration.colorCurves},set:function(e){this._imageProcessingConfiguration.colorCurves=e},enumerable:!0,configurable:!0}),i.prototype.getClassName=function(){return"PBRMaterial"},i.prototype.getActiveTextures=function(){var e=t.prototype.getActiveTextures.call(this);return this._albedoTexture&&e.push(this._albedoTexture),this._ambientTexture&&e.push(this._ambientTexture),this._opacityTexture&&e.push(this._opacityTexture),this._reflectionTexture&&e.push(this._reflectionTexture),this._emissiveTexture&&e.push(this._emissiveTexture),this._reflectivityTexture&&e.push(this._reflectivityTexture),this._metallicTexture&&e.push(this._metallicTexture),this._microSurfaceTexture&&e.push(this._microSurfaceTexture),this._bumpTexture&&e.push(this._bumpTexture),this._lightmapTexture&&e.push(this._lightmapTexture),this._refractionTexture&&e.push(this._refractionTexture),e},i.prototype.hasTexture=function(e){return!!t.prototype.hasTexture.call(this,e)||(this._albedoTexture===e||(this._ambientTexture===e||(this._opacityTexture===e||(this._reflectionTexture===e||(this._reflectivityTexture===e||(this._metallicTexture===e||(this._microSurfaceTexture===e||(this._bumpTexture===e||(this._lightmapTexture===e||this._refractionTexture===e)))))))))},i.prototype.clone=function(t){var r=this;return e.SerializationHelper.Clone((function(){return new i(t,r.getScene())}),this)},i.prototype.serialize=function(){var t=e.SerializationHelper.Serialize(this);return t.customType="BABYLON.PBRMaterial",t},i.Parse=function(t,r,n){return e.SerializationHelper.Parse((function(){return new i(t.name,r)}),t,r,n)},i})(e.PBRBaseMaterial);t._PBRMATERIAL_OPAQUE=0,t._PBRMATERIAL_ALPHATEST=1,t._PBRMATERIAL_ALPHABLEND=2,t._PBRMATERIAL_ALPHATESTANDBLEND=3,__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"directIntensity",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveIntensity",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"environmentIntensity",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"specularIntensity",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"disableBumpMap",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"albedoTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientTextureStrength",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"opacityTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectivityTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallicTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallic",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"roughness",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"microSurfaceTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"bumpTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty",null)],t.prototype,"lightmapTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"refractionTexture",void 0),__decorate([e.serializeAsColor3("ambient"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientColor",void 0),__decorate([e.serializeAsColor3("albedo"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"albedoColor",void 0),__decorate([e.serializeAsColor3("reflectivity"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectivityColor",void 0),__decorate([e.serializeAsColor3("reflection"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionColor",void 0),__decorate([e.serializeAsColor3("emissive"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveColor",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"microSurface",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"indexOfRefraction",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertRefractionY",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"linkRefractionWithTransparency",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useLightmapAsShadowmap",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAlphaFromAlbedoTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"forceAlphaTest",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"alphaCutOff",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useSpecularOverAlpha",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useMicroSurfaceFromReflectivityMapAlpha",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRoughnessFromMetallicTextureAlpha",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRoughnessFromMetallicTextureGreen",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useMetallnessFromMetallicTextureBlue",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAmbientOcclusionFromMetallicTextureRed",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAmbientInGrayScale",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAutoMicroSurfaceFromReflectivityMap",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"usePhysicalLightFalloff",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRadianceOverAlpha",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useParallax",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useParallaxOcclusion",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"parallaxScaleBias",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsLightsDirty")],t.prototype,"disableLighting",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"forceIrradianceInFragment",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsLightsDirty")],t.prototype,"maxSimultaneousLights",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapX",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapY",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"twoSidedLighting",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"preMultiplyAlpha",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAlphaFresnel",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"environmentBRDFTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"forceNormalForward",void 0),e.PBRMaterial=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e,i){var r=t.call(this,e,i)||this;return r._useRoughnessFromMetallicTextureAlpha=!1,r._useRoughnessFromMetallicTextureGreen=!0,r._useMetallnessFromMetallicTextureBlue=!0,r}return __extends(i,t),i.prototype.getClassName=function(){return"PBRMetallicRoughnessMaterial"},i.prototype.getActiveTextures=function(){var e=t.prototype.getActiveTextures.call(this);return this.baseTexture&&e.push(this.baseTexture),this.metallicRoughnessTexture&&e.push(this.metallicRoughnessTexture),e},i.prototype.hasTexture=function(e){return!!t.prototype.hasTexture.call(this,e)||(this.baseTexture===e||this.metallicRoughnessTexture===e)},i.prototype.clone=function(t){var r=this;return e.SerializationHelper.Clone((function(){return new i(t,r.getScene())}),this)},i.prototype.serialize=function(){var t=e.SerializationHelper.Serialize(this);return t.customType="BABYLON.PBRMetallicRoughnessMaterial",t},i.Parse=function(t,r,n){return e.SerializationHelper.Parse((function(){return new i(t.name,r)}),t,r,n)},i})(e.Internals.PBRBaseSimpleMaterial);__decorate([e.serializeAsColor3(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_albedoColor")],t.prototype,"baseColor",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_albedoTexture")],t.prototype,"baseTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallic",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"roughness",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_metallicTexture")],t.prototype,"metallicRoughnessTexture",void 0),e.PBRMetallicRoughnessMaterial=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e,i){var r=t.call(this,e,i)||this;return r._useMicroSurfaceFromReflectivityMapAlpha=!0,r}return __extends(i,t),i.prototype.getClassName=function(){return"PBRSpecularGlossinessMaterial"},i.prototype.getActiveTextures=function(){var e=t.prototype.getActiveTextures.call(this);return this.diffuseTexture&&e.push(this.diffuseTexture),this.specularGlossinessTexture&&e.push(this.specularGlossinessTexture),e},i.prototype.hasTexture=function(e){return!!t.prototype.hasTexture.call(this,e)||(this.diffuseTexture===e||this.specularGlossinessTexture===e)},i.prototype.clone=function(t){var r=this;return e.SerializationHelper.Clone((function(){return new i(t,r.getScene())}),this)},i.prototype.serialize=function(){var t=e.SerializationHelper.Serialize(this);return t.customType="BABYLON.PBRSpecularGlossinessMaterial",t},i.Parse=function(t,r,n){return e.SerializationHelper.Parse((function(){return new i(t.name,r)}),t,r,n)},i})(e.Internals.PBRBaseSimpleMaterial);__decorate([e.serializeAsColor3("diffuse"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_albedoColor")],t.prototype,"diffuseColor",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_albedoTexture")],t.prototype,"diffuseTexture",void 0),__decorate([e.serializeAsColor3("specular"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_reflectivityColor")],t.prototype,"specularColor",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_microSurface")],t.prototype,"glossiness",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_reflectivityTexture")],t.prototype,"specularGlossinessTexture",void 0),e.PBRSpecularGlossinessMaterial=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){e.CameraInputTypes={};var t=(function(){function t(e){this.attached={},this.camera=e,this.checkInputs=function(){}}return t.prototype.add=function(t){var i=t.getSimpleName();if(this.attached[i])return void e.Tools.Warn("camera input of type "+i+" already exists on camera");this.attached[i]=t,t.camera=this.camera,t.checkInputs&&(this.checkInputs=this._addCheckInputs(t.checkInputs.bind(t))),this.attachedElement&&t.attachControl(this.attachedElement)},t.prototype.remove=function(e){for(var t in this.attached){var i=this.attached[t];i===e&&(i.detachControl(this.attachedElement),delete this.attached[t],this.rebuildInputCheck())}},t.prototype.removeByType=function(e){for(var t in this.attached){var i=this.attached[t];i.getClassName()===e&&(i.detachControl(this.attachedElement),delete this.attached[t],this.rebuildInputCheck())}},t.prototype._addCheckInputs=function(e){var t=this.checkInputs;return function(){t(),e()}},t.prototype.attachInput=function(e){e.attachControl(this.attachedElement,this.noPreventDefault)},t.prototype.attachElement=function(t,i){if(!this.attachedElement){i=!e.Camera.ForceAttachControlToAlwaysPreventDefault&&i,this.attachedElement=t,this.noPreventDefault=i;for(var r in this.attached){this.attached[r];this.attached[r].attachControl(t,i)}}},t.prototype.detachElement=function(e){if(this.attachedElement===e){for(var t in this.attached){this.attached[t];this.attached[t].detachControl(e)}this.attachedElement=null}},t.prototype.rebuildInputCheck=function(){this.checkInputs=function(){};for(var e in this.attached){var t=this.attached[e];t.checkInputs&&(this.checkInputs=this._addCheckInputs(t.checkInputs.bind(t)))}},t.prototype.clear=function(){this.attachedElement&&this.detachElement(this.attachedElement),this.attached={},this.attachedElement=null,this.checkInputs=function(){}},t.prototype.serialize=function(t){var i={};for(var r in this.attached){var n=this.attached[r],o=e.SerializationHelper.Serialize(n);i[n.getClassName()]=o}t.inputsmgr=i},t.prototype.parse=function(t){var i=t.inputsmgr;if(i){this.clear();for(var r in i){var n=e.CameraInputTypes[r];if(n){var o=i[r],s=e.SerializationHelper.Parse((function(){return new n}),o,null);this.add(s)}}}else for(var r in this.attached){var n=e.CameraInputTypes[this.attached[r].getClassName()];if(n){var s=e.SerializationHelper.Parse((function(){return new n}),t,null);this.remove(this.attached[r]),this.add(s)}}},t})();e.CameraInputsManager=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e){void 0===e&&(e=!0),this.touchEnabled=e,this.buttons=[0,1,2],this.angularSensibility=2e3}return t.prototype.attachControl=function(t,i){var r=this,n=this.camera.getEngine();this._pointerInput||(this._pointerInput=function(o,s){var a=o.event;if((r.touchEnabled||"touch"!==a.pointerType)&&(o.type===e.PointerEventTypes.POINTERMOVE||-1!==r.buttons.indexOf(a.button)))if(o.type===e.PointerEventTypes.POINTERDOWN){try{a.srcElement.setPointerCapture(a.pointerId)}catch(e){}r.previousPosition={x:a.clientX,y:a.clientY},i||(a.preventDefault(),t.focus())}else if(o.type===e.PointerEventTypes.POINTERUP){try{a.srcElement.releasePointerCapture(a.pointerId)}catch(e){}r.previousPosition=null,i||a.preventDefault()}else if(o.type===e.PointerEventTypes.POINTERMOVE){if(!r.previousPosition||n.isPointerLock)return;var l=a.clientX-r.previousPosition.x,h=a.clientY-r.previousPosition.y;r.camera.getScene().useRightHandedSystem?r.camera.cameraRotation.y-=l/r.angularSensibility:r.camera.cameraRotation.y+=l/r.angularSensibility,r.camera.cameraRotation.x+=h/r.angularSensibility,r.previousPosition={x:a.clientX,y:a.clientY},i||a.preventDefault()}}),this._onMouseMove=function(e){if(n.isPointerLock){var t=e.movementX||e.mozMovementX||e.webkitMovementX||e.msMovementX||0,o=e.movementY||e.mozMovementY||e.webkitMovementY||e.msMovementY||0;r.camera.getScene().useRightHandedSystem?r.camera.cameraRotation.y-=t/r.angularSensibility:r.camera.cameraRotation.y+=t/r.angularSensibility,r.camera.cameraRotation.x+=o/r.angularSensibility,r.previousPosition=null,i||e.preventDefault()}},this._observer=this.camera.getScene().onPointerObservable.add(this._pointerInput,e.PointerEventTypes.POINTERDOWN|e.PointerEventTypes.POINTERUP|e.PointerEventTypes.POINTERMOVE),t.addEventListener("mousemove",this._onMouseMove,!1)},t.prototype.detachControl=function(e){this._observer&&e&&(this.camera.getScene().onPointerObservable.remove(this._observer),e.removeEventListener("mousemove",this._onMouseMove),this._observer=null,this._onMouseMove=null,this.previousPosition=null)},t.prototype.getClassName=function(){return"FreeCameraMouseInput"},t.prototype.getSimpleName=function(){return"mouse"},t})();__decorate([e.serialize()],t.prototype,"buttons",void 0),__decorate([e.serialize()],t.prototype,"angularSensibility",void 0),e.FreeCameraMouseInput=t,e.CameraInputTypes.FreeCameraMouseInput=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this._keys=[],this.keysUp=[38],this.keysDown=[40],this.keysLeft=[37],this.keysRight=[39]}return t.prototype.attachControl=function(t,i){var r=this;this._onKeyDown||(t.tabIndex=1,this._onKeyDown=function(e){if(-1!==r.keysUp.indexOf(e.keyCode)||-1!==r.keysDown.indexOf(e.keyCode)||-1!==r.keysLeft.indexOf(e.keyCode)||-1!==r.keysRight.indexOf(e.keyCode)){-1===r._keys.indexOf(e.keyCode)&&r._keys.push(e.keyCode),i||e.preventDefault()}},this._onKeyUp=function(e){if(-1!==r.keysUp.indexOf(e.keyCode)||-1!==r.keysDown.indexOf(e.keyCode)||-1!==r.keysLeft.indexOf(e.keyCode)||-1!==r.keysRight.indexOf(e.keyCode)){var t=r._keys.indexOf(e.keyCode);t>=0&&r._keys.splice(t,1),i||e.preventDefault()}},t.addEventListener("keydown",this._onKeyDown,!1),t.addEventListener("keyup",this._onKeyUp,!1),e.Tools.RegisterTopRootEvents([{name:"blur",handler:this._onLostFocus}]))},t.prototype.detachControl=function(t){this._onKeyDown&&(t.removeEventListener("keydown",this._onKeyDown),t.removeEventListener("keyup",this._onKeyUp),e.Tools.UnregisterTopRootEvents([{name:"blur",handler:this._onLostFocus}]),this._keys=[],this._onKeyDown=null,this._onKeyUp=null)},t.prototype.checkInputs=function(){if(this._onKeyDown)for(var t=this.camera,i=0;i=0?this.rotation.y=-Math.atan(i.z/i.x)+Math.PI/2:this.rotation.y=-Math.atan(i.z/i.x)-Math.PI/2,this.rotation.z=0,isNaN(this.rotation.x)&&(this.rotation.x=0),isNaN(this.rotation.y)&&(this.rotation.y=0),isNaN(this.rotation.z)&&(this.rotation.z=0),this.rotationQuaternion&&e.Quaternion.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this.rotationQuaternion)},i.prototype.getTarget=function(){return this._currentTarget},i.prototype._decideIfNeedsToMove=function(){return Math.abs(this.cameraDirection.x)>0||Math.abs(this.cameraDirection.y)>0||Math.abs(this.cameraDirection.z)>0},i.prototype._updatePosition=function(){if(this.parent)return this.parent.getWorldMatrix().invertToRef(e.Tmp.Matrix[0]),e.Vector3.TransformNormalToRef(this.cameraDirection,e.Tmp.Matrix[0],e.Tmp.Vector3[0]),void this.position.addInPlace(e.Tmp.Vector3[0]);this.position.addInPlace(this.cameraDirection)},i.prototype._checkInputs=function(){var i=this._decideIfNeedsToMove(),r=Math.abs(this.cameraRotation.x)>0||Math.abs(this.cameraRotation.y)>0;if(i&&this._updatePosition(),r){if(this.rotation.x+=this.cameraRotation.x,this.rotation.y+=this.cameraRotation.y,this.rotationQuaternion){this.rotation.lengthSquared()&&e.Quaternion.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this.rotationQuaternion)}if(!this.noRotationConstraint){var n=Math.PI/2*.95;this.rotation.x>n&&(this.rotation.x=n),this.rotation.x<-n&&(this.rotation.x=-n)}}i&&(Math.abs(this.cameraDirection.x)e.Engine.CollisionsEpsilon&&(o.position.addInPlace(o._diffPosition),o.onCollide&&r&&o.onCollide(r))})(i)},o.inputs=new e.FreeCameraInputsManager(o),o.inputs.addKeyboard().addMouse(),o}return __extends(i,t),Object.defineProperty(i.prototype,"angularSensibility",{get:function(){var e=this.inputs.attached.mouse;if(e)return e.angularSensibility},set:function(e){var t=this.inputs.attached.mouse;t&&(t.angularSensibility=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"keysUp",{get:function(){var e=this.inputs.attached.keyboard;if(e)return e.keysUp},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysUp=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"keysDown",{get:function(){var e=this.inputs.attached.keyboard;if(e)return e.keysDown},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysDown=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"keysLeft",{get:function(){var e=this.inputs.attached.keyboard;if(e)return e.keysLeft},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysLeft=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"keysRight",{get:function(){var e=this.inputs.attached.keyboard;if(e)return e.keysRight},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysRight=e)},enumerable:!0,configurable:!0}),i.prototype.attachControl=function(e,t){this.inputs.attachElement(e,t)},i.prototype.detachControl=function(t){this.inputs.detachElement(t),this.cameraDirection=new e.Vector3(0,0,0),this.cameraRotation=new e.Vector2(0,0)},Object.defineProperty(i.prototype,"collisionMask",{get:function(){return this._collisionMask},set:function(e){this._collisionMask=isNaN(e)?-1:e},enumerable:!0,configurable:!0}),i.prototype._collideWithWorld=function(t){var i;i=this.parent?e.Vector3.TransformCoordinates(this.position,this.parent.getWorldMatrix()):this.position,i.subtractFromFloatsToRef(0,this.ellipsoid.y,0,this._oldPosition),this._collider||(this._collider=new e.Collider),this._collider.radius=this.ellipsoid,this._collider.collisionMask=this._collisionMask;var r=t;this.applyGravity&&(r=t.add(this.getScene().gravity)),this.getScene().collisionCoordinator.getNewPosition(this._oldPosition,r,this._collider,3,null,this._onCollisionPositionChange,this.uniqueId)},i.prototype._checkInputs=function(){this._localDirection||(this._localDirection=e.Vector3.Zero(),this._transformedDirection=e.Vector3.Zero()),this.inputs.checkInputs(),t.prototype._checkInputs.call(this)},i.prototype._decideIfNeedsToMove=function(){return this._needMoveForGravity||Math.abs(this.cameraDirection.x)>0||Math.abs(this.cameraDirection.y)>0||Math.abs(this.cameraDirection.z)>0},i.prototype._updatePosition=function(){this.checkCollisions&&this.getScene().collisionsEnabled?this._collideWithWorld(this.cameraDirection):t.prototype._updatePosition.call(this)},i.prototype.dispose=function(){this.inputs.clear(),t.prototype.dispose.call(this)},i.prototype.getClassName=function(){return"FreeCamera"},i})(e.TargetCamera);__decorate([e.serializeAsVector3()],t.prototype,"ellipsoid",void 0),__decorate([e.serialize()],t.prototype,"checkCollisions",void 0),__decorate([e.serialize()],t.prototype,"applyGravity",void 0),e.FreeCamera=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this._keys=[],this.keysUp=[38],this.keysDown=[40],this.keysLeft=[37],this.keysRight=[39]}return t.prototype.attachControl=function(t,i){var r=this;t.tabIndex=1,this._onKeyDown=function(e){if(-1!==r.keysUp.indexOf(e.keyCode)||-1!==r.keysDown.indexOf(e.keyCode)||-1!==r.keysLeft.indexOf(e.keyCode)||-1!==r.keysRight.indexOf(e.keyCode)){-1===r._keys.indexOf(e.keyCode)&&r._keys.push(e.keyCode),e.preventDefault&&(i||e.preventDefault())}},this._onKeyUp=function(e){if(-1!==r.keysUp.indexOf(e.keyCode)||-1!==r.keysDown.indexOf(e.keyCode)||-1!==r.keysLeft.indexOf(e.keyCode)||-1!==r.keysRight.indexOf(e.keyCode)){var t=r._keys.indexOf(e.keyCode);t>=0&&r._keys.splice(t,1),e.preventDefault&&(i||e.preventDefault())}},this._onLostFocus=function(){r._keys=[]},t.addEventListener("keydown",this._onKeyDown,!1),t.addEventListener("keyup",this._onKeyUp,!1),e.Tools.RegisterTopRootEvents([{name:"blur",handler:this._onLostFocus}])},t.prototype.detachControl=function(t){t&&(t.removeEventListener("keydown",this._onKeyDown),t.removeEventListener("keyup",this._onKeyUp)),e.Tools.UnregisterTopRootEvents([{name:"blur",handler:this._onLostFocus}]),this._keys=[],this._onKeyDown=null,this._onKeyUp=null,this._onLostFocus=null},t.prototype.checkInputs=function(){if(this._onKeyDown)for(var e=this.camera,t=0;tMath.PI&&(this.beta=this.beta-2*Math.PI):this.betathis.upperBetaLimit&&(this.beta=this.upperBetaLimit),this.lowerAlphaLimit&&this.alphathis.upperAlphaLimit&&(this.alpha=this.upperAlphaLimit),this.lowerRadiusLimit&&this.radiusthis.upperRadiusLimit&&(this.radius=this.upperRadiusLimit)},i.prototype.rebuildAnglesAndRadius=function(){var e=this.position.subtract(this._getTargetPosition());this.radius=e.length(),this.alpha=Math.acos(e.x/Math.sqrt(Math.pow(e.x,2)+Math.pow(e.z,2))),e.z<0&&(this.alpha=2*Math.PI-this.alpha),this.beta=Math.acos(e.y/this.radius),this._checkLimits()},i.prototype.setPosition=function(e){this.position.equals(e)||(this.position.copyFrom(e),this.rebuildAnglesAndRadius())},i.prototype.setTarget=function(e,t,i){if(void 0===t&&(t=!1),void 0===i&&(i=!1),e.getBoundingInfo)this._targetBoundingCenter=t?e.getBoundingInfo().boundingBox.centerWorld.clone():null,this._targetHost=e,this._target=this._getTargetPosition();else{var r=e,n=this._getTargetPosition();if(n&&!i&&n.equals(r))return;this._target=r,this._targetBoundingCenter=null}this.rebuildAnglesAndRadius()},i.prototype._getViewMatrix=function(){var t=Math.cos(this.alpha),i=Math.sin(this.alpha),r=Math.cos(this.beta),n=Math.sin(this.beta);0===n&&(n=1e-4);var o=this._getTargetPosition();if(o.addToRef(new e.Vector3(this.radius*t*n,this.radius*r,this.radius*i*n),this._newPosition),this.getScene().collisionsEnabled&&this.checkCollisions)this._collider||(this._collider=new e.Collider),this._collider.radius=this.collisionRadius,this._newPosition.subtractToRef(this.position,this._collisionVelocity),this._collisionTriggered=!0,this.getScene().collisionCoordinator.getNewPosition(this.position,this._collisionVelocity,this._collider,3,null,this._onCollisionPositionChange,this.uniqueId);else{this.position.copyFrom(this._newPosition);var s=this.upVector;this.allowUpsideDown&&n<0&&(s=s.clone(),s=s.negate()),this.getScene().useRightHandedSystem?e.Matrix.LookAtRHToRef(this.position,o,s,this._viewMatrix):e.Matrix.LookAtLHToRef(this.position,o,s,this._viewMatrix),this._viewMatrix.m[12]+=this.targetScreenOffset.x,this._viewMatrix.m[13]+=this.targetScreenOffset.y}return this._currentTarget=o,this._viewMatrix},i.prototype.zoomOn=function(t,i){void 0===i&&(i=!1),t=t||this.getScene().meshes;var r=e.Mesh.MinMax(t),n=e.Vector3.Distance(r.min,r.max);this.radius=n*this.zoomOnFactor,this.focusOn({min:r.min,max:r.max,distance:n},i)},i.prototype.focusOn=function(t,i){void 0===i&&(i=!1);var r,n;void 0===t.min?(r=t||this.getScene().meshes,r=e.Mesh.MinMax(r),n=e.Vector3.Distance(r.min,r.max)):(r=t,n=t.distance),this._target=e.Mesh.Center(r),i||(this.maxZ=2*n)},i.prototype.createRigCamera=function(t,r){var n;switch(this.cameraRigMode){case e.Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case e.Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER:case e.Camera.RIG_MODE_VR:n=this._cameraRigParams.stereoHalfAngle*(0===r?1:-1);break;case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:n=this._cameraRigParams.stereoHalfAngle*(0===r?-1:1)}var o=new i(t,this.alpha+n,this.beta,this.radius,this._target,this.getScene());return o._cameraRigParams={},o},i.prototype._updateRigCameras=function(){var i=this._rigCameras[0],r=this._rigCameras[1];switch(i.beta=r.beta=this.beta,i.radius=r.radius=this.radius,this.cameraRigMode){case e.Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case e.Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER:case e.Camera.RIG_MODE_VR:i.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle,r.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle;break;case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:i.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle,r.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle}t.prototype._updateRigCameras.call(this)},i.prototype.dispose=function(){this.inputs.clear(),t.prototype.dispose.call(this)},i.prototype.getClassName=function(){return"ArcRotateCamera"},i})(e.TargetCamera);__decorate([e.serialize()],t.prototype,"alpha",void 0),__decorate([e.serialize()],t.prototype,"beta",void 0),__decorate([e.serialize()],t.prototype,"radius",void 0),__decorate([e.serializeAsVector3("target")],t.prototype,"_target",void 0),__decorate([e.serialize()],t.prototype,"inertialAlphaOffset",void 0),__decorate([e.serialize()],t.prototype,"inertialBetaOffset",void 0),__decorate([e.serialize()],t.prototype,"inertialRadiusOffset",void 0),__decorate([e.serialize()],t.prototype,"lowerAlphaLimit",void 0),__decorate([e.serialize()],t.prototype,"upperAlphaLimit",void 0),__decorate([e.serialize()],t.prototype,"lowerBetaLimit",void 0),__decorate([e.serialize()],t.prototype,"upperBetaLimit",void 0),__decorate([e.serialize()],t.prototype,"lowerRadiusLimit",void 0),__decorate([e.serialize()],t.prototype,"upperRadiusLimit",void 0),__decorate([e.serialize()],t.prototype,"inertialPanningX",void 0),__decorate([e.serialize()],t.prototype,"inertialPanningY",void 0),__decorate([e.serialize()],t.prototype,"panningInertia",void 0),__decorate([e.serialize()],t.prototype,"zoomOnFactor",void 0),__decorate([e.serialize()],t.prototype,"allowUpsideDown",void 0),e.ArcRotateCamera=t +})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e){return t.call(this,e)||this}return __extends(i,t),i.prototype.addMouseWheel=function(){return this.add(new e.ArcRotateCameraMouseWheelInput),this},i.prototype.addPointers=function(){return this.add(new e.ArcRotateCameraPointersInput),this},i.prototype.addKeyboard=function(){return this.add(new e.ArcRotateCameraKeyboardMoveInput),this},i.prototype.addGamepad=function(){return this.add(new e.ArcRotateCameraGamepadInput),this},i.prototype.addVRDeviceOrientation=function(){return this.add(new e.ArcRotateCameraVRDeviceOrientationInput),this},i})(e.CameraInputsManager);e.ArcRotateCameraInputsManager=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n){var o=t.call(this,i,n)||this;return o.groundColor=new e.Color3(0,0,0),o.direction=r||e.Vector3.Up(),o}return __extends(i,t),i.prototype._buildUniformLayout=function(){this._uniformBuffer.addUniform("vLightData",4),this._uniformBuffer.addUniform("vLightDiffuse",4),this._uniformBuffer.addUniform("vLightSpecular",3),this._uniformBuffer.addUniform("vLightGround",3),this._uniformBuffer.addUniform("shadowsInfo",3),this._uniformBuffer.addUniform("depthValues",2),this._uniformBuffer.create()},i.prototype.getClassName=function(){return"HemisphericLight"},i.prototype.setDirectionToTarget=function(t){return this.direction=e.Vector3.Normalize(t.subtract(e.Vector3.Zero())),this.direction},i.prototype.getShadowGenerator=function(){return null},i.prototype.transferToEffect=function(t,i){var r=e.Vector3.Normalize(this.direction);return this._uniformBuffer.updateFloat4("vLightData",r.x,r.y,r.z,0,i),this._uniformBuffer.updateColor3("vLightGround",this.groundColor.scale(this.intensity),i),this},i.prototype._getWorldMatrix=function(){return this._worldMatrix||(this._worldMatrix=e.Matrix.Identity()),this._worldMatrix},i.prototype.getTypeID=function(){return e.Light.LIGHTTYPEID_HEMISPHERICLIGHT},i})(e.Light);__decorate([e.serializeAsColor3()],t.prototype,"groundColor",void 0),__decorate([e.serializeAsVector3()],t.prototype,"direction",void 0),e.HemisphericLight=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(){var e=null!==t&&t.apply(this,arguments)||this;return e._needProjectionMatrixCompute=!0,e}return __extends(i,t),Object.defineProperty(i.prototype,"direction",{get:function(){return this._direction},set:function(e){this._direction=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"shadowMinZ",{get:function(){return this._shadowMinZ},set:function(e){this._shadowMinZ=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"shadowMaxZ",{get:function(){return this._shadowMaxZ},set:function(e){this._shadowMaxZ=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),i.prototype.computeTransformedInformation=function(){return!(!this.parent||!this.parent.getWorldMatrix)&&(this.transformedPosition||(this.transformedPosition=e.Vector3.Zero()),e.Vector3.TransformCoordinatesToRef(this.position,this.parent.getWorldMatrix(),this.transformedPosition),this.direction&&(this.transformedDirection||(this.transformedDirection=e.Vector3.Zero()),e.Vector3.TransformNormalToRef(this.direction,this.parent.getWorldMatrix(),this.transformedDirection)),!0)},i.prototype.getDepthScale=function(){return 50},i.prototype.getShadowDirection=function(e){return this.transformedDirection?this.transformedDirection:this.direction},i.prototype.getAbsolutePosition=function(){return this.transformedPosition?this.transformedPosition:this.position},i.prototype.setDirectionToTarget=function(t){return this.direction=e.Vector3.Normalize(t.subtract(this.position)),this.direction},i.prototype.getRotation=function(){this.direction.normalize();var t=e.Vector3.Cross(this.direction,e.Axis.Y),i=e.Vector3.Cross(t,this.direction);return e.Vector3.RotationFromAxis(t,i,this.direction)},i.prototype.needCube=function(){return!1},i.prototype.needProjectionMatrixCompute=function(){return this._needProjectionMatrixCompute},i.prototype.forceProjectionMatrixCompute=function(){this._needProjectionMatrixCompute=!0},i.prototype._getWorldMatrix=function(){return this._worldMatrix||(this._worldMatrix=e.Matrix.Identity()),e.Matrix.TranslationToRef(this.position.x,this.position.y,this.position.z,this._worldMatrix),this._worldMatrix},i.prototype.getDepthMinZ=function(e){return void 0!==this.shadowMinZ?this.shadowMinZ:e.minZ},i.prototype.getDepthMaxZ=function(e){return void 0!==this.shadowMaxZ?this.shadowMaxZ:e.maxZ},i.prototype.setShadowProjectionMatrix=function(e,t,i){return this.customProjectionMatrixBuilder?this.customProjectionMatrixBuilder(t,i,e):this._setDefaultShadowProjectionMatrix(e,t,i),this},i})(e.Light);__decorate([e.serializeAsVector3()],t.prototype,"position",void 0),__decorate([e.serializeAsVector3()],t.prototype,"direction",null),__decorate([e.serialize()],t.prototype,"shadowMinZ",null),__decorate([e.serialize()],t.prototype,"shadowMaxZ",null),e.ShadowLight=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e,i,r){var n=t.call(this,e,r)||this;return n._shadowAngle=Math.PI/2,n.position=i,n}return __extends(i,t),Object.defineProperty(i.prototype,"shadowAngle",{get:function(){return this._shadowAngle},set:function(e){this._shadowAngle=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"direction",{get:function(){return this._direction},set:function(e){var t=this.needCube();this._direction=e,this.needCube()!==t&&this._shadowGenerator&&this._shadowGenerator.recreateShadowMap()},enumerable:!0,configurable:!0}),i.prototype.getClassName=function(){return"PointLight"},i.prototype.getTypeID=function(){return e.Light.LIGHTTYPEID_POINTLIGHT},i.prototype.needCube=function(){return!this.direction},i.prototype.getShadowDirection=function(i){if(this.direction)return t.prototype.getShadowDirection.call(this,i);switch(i){case 0:return new e.Vector3(1,0,0);case 1:return new e.Vector3(-1,0,0);case 2:return new e.Vector3(0,-1,0);case 3:return new e.Vector3(0,1,0);case 4:return new e.Vector3(0,0,1);case 5:return new e.Vector3(0,0,-1)}return e.Vector3.Zero()},i.prototype._setDefaultShadowProjectionMatrix=function(t,i,r){var n=this.getScene().activeCamera;e.Matrix.PerspectiveFovLHToRef(this.shadowAngle,1,this.getDepthMinZ(n),this.getDepthMaxZ(n),t)},i.prototype._buildUniformLayout=function(){this._uniformBuffer.addUniform("vLightData",4),this._uniformBuffer.addUniform("vLightDiffuse",4),this._uniformBuffer.addUniform("vLightSpecular",3),this._uniformBuffer.addUniform("shadowsInfo",3),this._uniformBuffer.addUniform("depthValues",2),this._uniformBuffer.create()},i.prototype.transferToEffect=function(e,t){return this.computeTransformedInformation()?(this._uniformBuffer.updateFloat4("vLightData",this.transformedPosition.x,this.transformedPosition.y,this.transformedPosition.z,0,t),this):(this._uniformBuffer.updateFloat4("vLightData",this.position.x,this.position.y,this.position.z,0,t),this)},i})(e.ShadowLight);__decorate([e.serialize()],t.prototype,"shadowAngle",null),e.PointLight=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e,i,r){var n=t.call(this,e,r)||this;return n._shadowFrustumSize=0,n._shadowOrthoScale=.5,n.autoUpdateExtends=!0,n._orthoLeft=Number.MAX_VALUE,n._orthoRight=Number.MIN_VALUE,n._orthoTop=Number.MIN_VALUE,n._orthoBottom=Number.MAX_VALUE,n.position=i.scale(-1),n.direction=i,n}return __extends(i,t),Object.defineProperty(i.prototype,"shadowFrustumSize",{get:function(){return this._shadowFrustumSize},set:function(e){this._shadowFrustumSize=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"shadowOrthoScale",{get:function(){return this._shadowOrthoScale},set:function(e){this._shadowOrthoScale=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),i.prototype.getClassName=function(){return"DirectionalLight"},i.prototype.getTypeID=function(){return e.Light.LIGHTTYPEID_DIRECTIONALLIGHT},i.prototype._setDefaultShadowProjectionMatrix=function(e,t,i){this.shadowFrustumSize>0?this._setDefaultFixedFrustumShadowProjectionMatrix(e,t):this._setDefaultAutoExtendShadowProjectionMatrix(e,t,i)},i.prototype._setDefaultFixedFrustumShadowProjectionMatrix=function(t,i){var r=this.getScene().activeCamera;e.Matrix.OrthoLHToRef(this.shadowFrustumSize,this.shadowFrustumSize,void 0!==this.shadowMinZ?this.shadowMinZ:r.minZ,void 0!==this.shadowMaxZ?this.shadowMaxZ:r.maxZ,t)},i.prototype._setDefaultAutoExtendShadowProjectionMatrix=function(t,i,r){var n=this.getScene().activeCamera;if(this.autoUpdateExtends||this._orthoLeft===Number.MAX_VALUE){var o=e.Vector3.Zero();this._orthoLeft=Number.MAX_VALUE,this._orthoRight=Number.MIN_VALUE,this._orthoTop=Number.MIN_VALUE,this._orthoBottom=Number.MAX_VALUE;for(var s=0;sthis._orthoRight&&(this._orthoRight=o.x),o.y>this._orthoTop&&(this._orthoTop=o.y)}}}var u=this._orthoRight-this._orthoLeft,f=this._orthoTop-this._orthoBottom;e.Matrix.OrthoOffCenterLHToRef(this._orthoLeft-u*this.shadowOrthoScale,this._orthoRight+u*this.shadowOrthoScale,this._orthoBottom-f*this.shadowOrthoScale,this._orthoTop+f*this.shadowOrthoScale,void 0!==this.shadowMinZ?this.shadowMinZ:n.minZ,void 0!==this.shadowMaxZ?this.shadowMaxZ:n.maxZ,t)},i.prototype._buildUniformLayout=function(){this._uniformBuffer.addUniform("vLightData",4),this._uniformBuffer.addUniform("vLightDiffuse",4),this._uniformBuffer.addUniform("vLightSpecular",3),this._uniformBuffer.addUniform("shadowsInfo",3),this._uniformBuffer.addUniform("depthValues",2),this._uniformBuffer.create()},i.prototype.transferToEffect=function(e,t){return this.computeTransformedInformation()?(this._uniformBuffer.updateFloat4("vLightData",this.transformedDirection.x,this.transformedDirection.y,this.transformedDirection.z,1,t),this):(this._uniformBuffer.updateFloat4("vLightData",this.direction.x,this.direction.y,this.direction.z,1,t),this)},i.prototype.getDepthMinZ=function(e){return 1},i.prototype.getDepthMaxZ=function(e){return 1},i})(e.ShadowLight);__decorate([e.serialize()],t.prototype,"shadowFrustumSize",null),__decorate([e.serialize()],t.prototype,"shadowOrthoScale",null),__decorate([e.serialize()],t.prototype,"autoUpdateExtends",void 0),e.DirectionalLight=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e,i,r,n,o,s){var a=t.call(this,e,s)||this;return a.position=i,a.direction=r,a.angle=n,a.exponent=o,a}return __extends(i,t),Object.defineProperty(i.prototype,"angle",{get:function(){return this._angle},set:function(e){this._angle=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"shadowAngleScale",{get:function(){return this._shadowAngleScale},set:function(e){this._shadowAngleScale=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),i.prototype.getClassName=function(){return"SpotLight"},i.prototype.getTypeID=function(){return e.Light.LIGHTTYPEID_SPOTLIGHT},i.prototype._setDefaultShadowProjectionMatrix=function(t,i,r){var n=this.getScene().activeCamera;this._shadowAngleScale=this._shadowAngleScale||1;var o=this._shadowAngleScale*this._angle;e.Matrix.PerspectiveFovLHToRef(o,1,this.getDepthMinZ(n),this.getDepthMaxZ(n),t)},i.prototype._buildUniformLayout=function(){this._uniformBuffer.addUniform("vLightData",4),this._uniformBuffer.addUniform("vLightDiffuse",4),this._uniformBuffer.addUniform("vLightSpecular",3),this._uniformBuffer.addUniform("vLightDirection",3),this._uniformBuffer.addUniform("shadowsInfo",3),this._uniformBuffer.addUniform("depthValues",2),this._uniformBuffer.create()},i.prototype.transferToEffect=function(t,i){var r;return this.computeTransformedInformation()?(this._uniformBuffer.updateFloat4("vLightData",this.transformedPosition.x,this.transformedPosition.y,this.transformedPosition.z,this.exponent,i),r=e.Vector3.Normalize(this.transformedDirection)):(this._uniformBuffer.updateFloat4("vLightData",this.position.x,this.position.y,this.position.z,this.exponent,i),r=e.Vector3.Normalize(this.direction)),this._uniformBuffer.updateFloat4("vLightDirection",r.x,r.y,r.z,Math.cos(.5*this.angle),i),this},i})(e.ShadowLight);__decorate([e.serialize()],t.prototype,"angle",null),__decorate([e.serialize()],t.prototype,"shadowAngleScale",null),__decorate([e.serialize()],t.prototype,"exponent",void 0),e.SpotLight=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(e,t,i){this.name=e,this.from=t,this.to=i}return e.prototype.clone=function(){return new e(this.name,this.from,this.to)},e})();e.AnimationRange=t;var i=(function(){function e(e,t,i){this.frame=e,this.action=t,this.onlyOnce=i,this.isDone=!1}return e})();e.AnimationEvent=i;var r=(function(){function t(e){this.path=e,this._onchange=new Array,this.value=0,this.animations=new Array}return t.prototype.getPoint=function(){var t=this.path.getPointAtLengthPosition(this.value);return new e.Vector3(t.x,0,t.y)},t.prototype.moveAhead=function(e){return void 0===e&&(e=.002),this.move(e),this},t.prototype.moveBack=function(e){return void 0===e&&(e=.002),this.move(-e),this},t.prototype.move=function(e){if(Math.abs(e)>1)throw"step size should be less than 1.";return this.value+=e,this.ensureLimits(),this.raiseOnChange(),this},t.prototype.ensureLimits=function(){for(;this.value>1;)this.value-=1;for(;this.value<0;)this.value+=1;return this},t.prototype.markAsDirty=function(e){return this.ensureLimits(),this.raiseOnChange(),this},t.prototype.raiseOnChange=function(){var e=this;return this._onchange.forEach((function(t){return t(e)})),this},t.prototype.onchange=function(e){return this._onchange.push(e),this},t})();e.PathCursor=r;var n=(function(){function i(e,t,r,n,o,s){this.name=e,this.targetProperty=t,this.framePerSecond=r,this.dataType=n,this.loopMode=o,this.enableBlending=s,this._offsetsCache={},this._highLimitsCache={},this._stopped=!1,this._blendingFactor=0,this._events=new Array,this.allowMatricesInterpolation=!1,this.blendingSpeed=.01,this._ranges={},this.targetPropertyPath=t.split("."),this.dataType=n,this.loopMode=void 0===o?i.ANIMATIONLOOPMODE_CYCLE:o}return i._PrepareAnimation=function(t,r,n,o,s,a,l,h){var c=void 0;if(!isNaN(parseFloat(s))&&isFinite(s)?c=i.ANIMATIONTYPE_FLOAT:s instanceof e.Quaternion?c=i.ANIMATIONTYPE_QUATERNION:s instanceof e.Vector3?c=i.ANIMATIONTYPE_VECTOR3:s instanceof e.Vector2?c=i.ANIMATIONTYPE_VECTOR2:s instanceof e.Color3?c=i.ANIMATIONTYPE_COLOR3:s instanceof e.Size&&(c=i.ANIMATIONTYPE_SIZE),void 0==c)return null;var u=new i(t,r,n,c,l),f=[{frame:0,value:s},{frame:o,value:a}];return u.setKeys(f),void 0!==h&&u.setEasingFunction(h),u},i.CreateAndStartAnimation=function(e,t,r,n,o,s,a,l,h,c){var u=i._PrepareAnimation(e,r,n,o,s,a,l,h);return t.getScene().beginDirectAnimation(t,[u],0,o,1===u.loopMode,1,c)},i.CreateMergeAndStartAnimation=function(e,t,r,n,o,s,a,l,h,c){var u=i._PrepareAnimation(e,r,n,o,s,a,l,h);return t.animations.push(u),t.getScene().beginAnimation(t,0,o,1===u.loopMode,1,c)},i.prototype.toString=function(e){var t="Name: "+this.name+", property: "+this.targetProperty;if(t+=", datatype: "+["Float","Vector3","Quaternion","Matrix","Color3","Vector2"][this.dataType],t+=", nKeys: "+(this._keys?this._keys.length:"none"),t+=", nRanges: "+(this._ranges?Object.keys(this._ranges).length:"none"),e){t+=", Ranges: {";var i=!0;for(var r in this._ranges)i&&(t+=", ",i=!1),t+=r;t+="}"}return t},i.prototype.addEvent=function(e){this._events.push(e)},i.prototype.removeEvents=function(e){for(var t=0;t=0;n--)this._keys[n].frame>=i&&this._keys[n].frame<=r&&this._keys.splice(n,1);this._ranges[e]=void 0}},i.prototype.getRange=function(e){return this._ranges[e]},i.prototype.reset=function(){this._offsetsCache={},this._highLimitsCache={},this.currentFrame=0,this._blendingFactor=0,this._originalBlendValue=null},i.prototype.isStopped=function(){return this._stopped},i.prototype.getKeys=function(){return this._keys},i.prototype.getHighestFrame=function(){for(var e=0,t=0,i=this._keys.length;t0)return o.clone?o.clone():o;this.currentFrame=e;var s=Math.max(0,Math.min(this._keys.length-1,Math.floor(this._keys.length*(e-this._keys[0].frame)/(this._keys[this._keys.length-1].frame-this._keys[0].frame))-1));if(this._keys[s].frame>=e)for(;s-1>=0&&this._keys[s].frame>=e;)s--;for(var a=s;a=e){var h=this._keys[a],c=this._getKeyValue(h.value),u=this._getKeyValue(l.value),f=void 0!==h.outTangent&&void 0!==l.inTangent,d=l.frame-h.frame,p=(e-h.frame)/d;switch(null!=this._easingFunction&&(p=this._easingFunction.ease(p)),this.dataType){case i.ANIMATIONTYPE_FLOAT:var _=f?this.floatInterpolateFunctionWithTangents(c,h.outTangent*d,u,l.inTangent*d,p):this.floatInterpolateFunction(c,u,p);switch(r){case i.ANIMATIONLOOPMODE_CYCLE:case i.ANIMATIONLOOPMODE_CONSTANT:return _;case i.ANIMATIONLOOPMODE_RELATIVE:return n*t+_}break;case i.ANIMATIONTYPE_QUATERNION:var m=f?this.quaternionInterpolateFunctionWithTangents(c,h.outTangent.scale(d),u,l.inTangent.scale(d),p):this.quaternionInterpolateFunction(c,u,p);switch(r){case i.ANIMATIONLOOPMODE_CYCLE:case i.ANIMATIONLOOPMODE_CONSTANT:return m;case i.ANIMATIONLOOPMODE_RELATIVE:return m.add(n.scale(t))}return m;case i.ANIMATIONTYPE_VECTOR3:var g=f?this.vector3InterpolateFunctionWithTangents(c,h.outTangent.scale(d),u,l.inTangent.scale(d),p):this.vector3InterpolateFunction(c,u,p);switch(r){case i.ANIMATIONLOOPMODE_CYCLE:case i.ANIMATIONLOOPMODE_CONSTANT:return g;case i.ANIMATIONLOOPMODE_RELATIVE:return g.add(n.scale(t))}case i.ANIMATIONTYPE_VECTOR2:var v=f?this.vector2InterpolateFunctionWithTangents(c,h.outTangent.scale(d),u,l.inTangent.scale(d),p):this.vector2InterpolateFunction(c,u,p);switch(r){case i.ANIMATIONLOOPMODE_CYCLE:case i.ANIMATIONLOOPMODE_CONSTANT:return v;case i.ANIMATIONLOOPMODE_RELATIVE:return v.add(n.scale(t))}case i.ANIMATIONTYPE_SIZE:switch(r){case i.ANIMATIONLOOPMODE_CYCLE:case i.ANIMATIONLOOPMODE_CONSTANT:return this.sizeInterpolateFunction(c,u,p);case i.ANIMATIONLOOPMODE_RELATIVE:return this.sizeInterpolateFunction(c,u,p).add(n.scale(t))}case i.ANIMATIONTYPE_COLOR3:switch(r){case i.ANIMATIONLOOPMODE_CYCLE:case i.ANIMATIONLOOPMODE_CONSTANT:return this.color3InterpolateFunction(c,u,p);case i.ANIMATIONLOOPMODE_RELATIVE:return this.color3InterpolateFunction(c,u,p).add(n.scale(t))}case i.ANIMATIONTYPE_MATRIX:switch(r){case i.ANIMATIONLOOPMODE_CYCLE:case i.ANIMATIONLOOPMODE_CONSTANT:if(this.allowMatricesInterpolation)return this.matrixInterpolateFunction(c,u,p);case i.ANIMATIONLOOPMODE_RELATIVE:return c}}break}}return this._getKeyValue(this._keys[this._keys.length-1].value)},i.prototype.setValue=function(t,i){void 0===i&&(i=!1);var r,n;if(this.targetPropertyPath.length>1){for(var o=this._target[this.targetPropertyPath[0]],s=1;sthis._keys[this._keys.length-1].frame&&(e=this._keys[this._keys.length-1].frame);var t=this._interpolate(e,0,this.loopMode);this.setValue(t)},i.prototype.animate=function(t,r,n,o,s,a){if(void 0===a&&(a=!1),!this.targetPropertyPath||this.targetPropertyPath.length<1)return this._stopped=!0,!1;var l=!0;if(0!==this._keys[0].frame){var h={frame:0,value:this._keys[0].value};this._keys.splice(0,0,h)}(rthis._keys[this._keys.length-1].frame)&&(r=this._keys[0].frame),(nthis._keys[this._keys.length-1].frame)&&(n=this._keys[this._keys.length-1].frame),r===n&&r++;var c,u=n-r,f=t*(this.framePerSecond*s)/1e3,d=0;if((n>r&&f>u||r>n&&f>0,v=l?r+f%u:n,y=this._interpolate(v,g,this.loopMode,c,d);this.setValue(y);for(var x=0;x0&&v>=this._events[x].frame&&this._events[x].frame>=r||u<0&&v<=this._events[x].frame&&this._events[x].frame<=r){var b=this._events[x];b.isDone||(b.onlyOnce&&(this._events.splice(x,1),x--),b.isDone=!0,b.action())}else this._events[x].isDone&&!this._events[x].onlyOnce&&(this._events[x].isDone=!1);return l||(this._stopped=!0),l},i.prototype.serialize=function(){var e={};e.name=this.name,e.property=this.targetProperty,e.framePerSecond=this.framePerSecond,e.dataType=this.dataType,e.loopBehavior=this.loopMode,e.enableBlending=this.enableBlending,e.blendingSpeed=this.blendingSpeed;var t=this.dataType;e.keys=[];for(var r=this.getKeys(),n=0;n-1){for(var i=this._animations,r=i.length-1;r>=0;r--)"string"==typeof e&&i[r].name!=e||(i[r].reset(),i.splice(r,1));0==i.length&&(this._scene._activeAnimatables.splice(t,1),this.onAnimationEnd&&this.onAnimationEnd())}}else{var r=this._scene._activeAnimatables.indexOf(this);if(r>-1){this._scene._activeAnimatables.splice(r,1);for(var i=this._animations,r=0;r=.5?.5*(1-this.easeInCore(2*(1-t)))+.5:.5*this.easeInCore(2*t)},e})();t._EASINGMODE_EASEIN=0,t._EASINGMODE_EASEOUT=1,t._EASINGMODE_EASEINOUT=2,e.EasingFunction=t;var i=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.easeInCore=function(e){return e=Math.max(0,Math.min(1,e)),1-Math.sqrt(1-e*e)},t})(t);e.CircleEase=i;var r=(function(e){function t(t){void 0===t&&(t=1);var i=e.call(this)||this;return i.amplitude=t,i}return __extends(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.amplitude);return Math.pow(e,3)-e*t*Math.sin(3.141592653589793*e)},t})(t);e.BackEase=r;var n=(function(e){function t(t,i){void 0===t&&(t=3),void 0===i&&(i=2);var r=e.call(this)||this +;return r.bounces=t,r.bounciness=i,r}return __extends(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.bounces),i=this.bounciness;i<=1&&(i=1.001);var r=Math.pow(i,t),n=1-i,o=(1-r)/n+.5*r,s=e*o,a=Math.log(-s*(1-i)+1)/Math.log(i),l=Math.floor(a),h=l+1,c=(1-Math.pow(i,l))/(n*o),u=(1-Math.pow(i,h))/(n*o),f=.5*(c+u),d=e-f,p=f-c;return-Math.pow(1/i,t-l)/(p*p)*(d-p)*(d+p)},t})(t);e.BounceEase=n;var o=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.easeInCore=function(e){return e*e*e},t})(t);e.CubicEase=o;var s=(function(e){function t(t,i){void 0===t&&(t=3),void 0===i&&(i=3);var r=e.call(this)||this;return r.oscillations=t,r.springiness=i,r}return __extends(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.oscillations),i=Math.max(0,this.springiness);return(0==i?e:(Math.exp(i*e)-1)/(Math.exp(i)-1))*Math.sin((6.283185307179586*t+1.5707963267948966)*e)},t})(t);e.ElasticEase=s;var a=(function(e){function t(t){void 0===t&&(t=2);var i=e.call(this)||this;return i.exponent=t,i}return __extends(t,e),t.prototype.easeInCore=function(e){return this.exponent<=0?e:(Math.exp(this.exponent*e)-1)/(Math.exp(this.exponent)-1)},t})(t);e.ExponentialEase=a;var l=(function(e){function t(t){void 0===t&&(t=2);var i=e.call(this)||this;return i.power=t,i}return __extends(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.power);return Math.pow(e,t)},t})(t);e.PowerEase=l;var h=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.easeInCore=function(e){return e*e},t})(t);e.QuadraticEase=h;var c=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.easeInCore=function(e){return e*e*e*e},t})(t);e.QuarticEase=c;var u=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.easeInCore=function(e){return e*e*e*e*e},t})(t);e.QuinticEase=u;var f=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.easeInCore=function(e){return 1-Math.sin(1.5707963267948966*(1-e))},t})(t);e.SineEase=f;var d=(function(t){function i(e,i,r,n){void 0===e&&(e=0),void 0===i&&(i=0),void 0===r&&(r=1),void 0===n&&(n=1);var o=t.call(this)||this;return o.x1=e,o.y1=i,o.x2=r,o.y2=n,o}return __extends(i,t),i.prototype.easeInCore=function(t){return e.BezierCurve.interpolate(t,this.x1,this.y1,this.x2,this.y2)},i})(t);e.BezierCurveEase=d})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(e){this._actionManager=e}return e.prototype.isValid=function(){return!0},e.prototype._getProperty=function(e){return this._actionManager._getProperty(e)},e.prototype._getEffectiveTarget=function(e,t){return this._actionManager._getEffectiveTarget(e,t)},e.prototype.serialize=function(){},e.prototype._serialize=function(e){return{type:2,children:[],name:e.name,properties:e.properties}},e})();e.Condition=t;var i=(function(t){function i(e,r,n,o,s){void 0===s&&(s=i.IsEqual);var a=t.call(this,e)||this;return a.propertyPath=n,a.value=o,a.operator=s,a._target=r,a._effectiveTarget=a._getEffectiveTarget(r,a.propertyPath),a._property=a._getProperty(a.propertyPath),a}return __extends(i,t),Object.defineProperty(i,"IsEqual",{get:function(){return i._IsEqual},enumerable:!0,configurable:!0}),Object.defineProperty(i,"IsDifferent",{get:function(){return i._IsDifferent},enumerable:!0,configurable:!0}),Object.defineProperty(i,"IsGreater",{get:function(){return i._IsGreater},enumerable:!0,configurable:!0}),Object.defineProperty(i,"IsLesser",{get:function(){return i._IsLesser},enumerable:!0,configurable:!0}),i.prototype.isValid=function(){switch(this.operator){case i.IsGreater:return this._effectiveTarget[this._property]>this.value;case i.IsLesser:return this._effectiveTarget[this._property]-1&&this._scene._actionManagers.splice(e,1)},t.prototype.getScene=function(){return this._scene},t.prototype.hasSpecificTriggers=function(e){for(var t=0;t-1)return!0}return!1},t.prototype.hasSpecificTrigger=function(e){for(var t=0;t=t._OnPickTrigger&&i.trigger<=t._OnPointerOutTrigger)return!0}return!1},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"hasPickTriggers",{get:function(){for(var e=0;e=t._OnPickTrigger&&i.trigger<=t._OnPickUpTrigger)return!0}return!1},enumerable:!0,configurable:!0}),Object.defineProperty(t,"HasTriggers",{get:function(){for(var e in t.Triggers)if(t.Triggers.hasOwnProperty(e))return!0;return!1},enumerable:!0,configurable:!0}),Object.defineProperty(t,"HasPickTriggers",{get:function(){for(var e in t.Triggers)if(t.Triggers.hasOwnProperty(e)){var i=parseInt(e);if(i>=t._OnPickTrigger&&i<=t._OnPickUpTrigger)return!0}return!1},enumerable:!0,configurable:!0}),t.HasSpecificTrigger=function(e){for(var i in t.Triggers)if(t.Triggers.hasOwnProperty(i)){var r=parseInt(i);if(r===e)return!0}return!1},t.prototype.registerAction=function(i){return i.trigger===t.OnEveryFrameTrigger&&this.getScene().actionManager!==this?(e.Tools.Warn("OnEveryFrameTrigger can only be used with scene.actionManager"),null):(this.actions.push(i),t.Triggers[i.trigger]?t.Triggers[i.trigger]++:t.Triggers[i.trigger]=1,i._actionManager=this,i._prepare(),i)},t.prototype.processTrigger=function(e,i){for(var r=0;r0;if(2===i.type?f.push(o):f.push(r),_){for(var m=new Array,g=0;g0){var f=u.properties[0].value,d=null===u.properties[0].targetType?f:n.getMeshByName(f);d._meshId&&(d.mesh=n.getMeshByID(d._meshId)),c={trigger:e.ActionManager[u.name],parameter:d}}else c=e.ActionManager[u.name];for(var p=0;p>0;this._vertexData[o+10]=t.cellIndex-s*n,this._vertexData[o+11]=s,this._vertexData[o+12]=t.color.r,this._vertexData[o+13]=t.color.g,this._vertexData[o+14]=t.color.b,this._vertexData[o+15]=t.color.a},t.prototype.intersects=function(t,i,r,n){for(var o,s=Math.min(this._capacity,this.sprites.length),a=e.Vector3.Zero(),l=e.Vector3.Zero(),h=Number.MAX_VALUE,c=e.Vector3.Zero(),u=i.getViewMatrix(),f=0;fp&&(h=p,o=d,n))break}}}if(o){var _=new e.PickingInfo;return _.hit=!0,_.pickedSprite=o,_.distance=h,_}return null},t.prototype.render=function(){if(this._effectBase.isReady()&&this._effectFog.isReady()&&this._spriteTexture&&this._spriteTexture.isReady()){for(var t=this._scene.getEngine(),i=this._spriteTexture.getBaseSize(),r=t.getDeltaTime(),n=Math.min(this._capacity,this.sprites.length),o=i.width/this.cellWidth,s=0,a=0;athis._delay&&(this._time=this._time%this._delay,this.cellIndex+=this._direction,this.cellIndex===this._toIndex&&(this._loopAnimation?this.cellIndex=this._fromIndex:(this._animationStarted=!1,this._onAnimationEnd&&this._onAnimationEnd(),this.disposeWhenFinishedAnimating&&this.dispose()))))},t.prototype.dispose=function(){for(var e=0;et.x)return!1}else if(i=1/this.direction.x,r=(e.x-this.origin.x)*i,n=(t.x-this.origin.x)*i,n===-1/0&&(n=1/0),r>n&&(o=r,r=n,n=o),s=Math.max(r,s),a=Math.min(n,a),s>a)return!1;if(Math.abs(this.direction.y)<1e-7){if(this.origin.yt.y)return!1}else if(i=1/this.direction.y,r=(e.y-this.origin.y)*i,n=(t.y-this.origin.y)*i,n===-1/0&&(n=1/0),r>n&&(o=r,r=n,n=o),s=Math.max(r,s),a=Math.min(n,a),s>a)return!1;if(Math.abs(this.direction.z)<1e-7){if(this.origin.zt.z)return!1}else if(i=1/this.direction.z,r=(e.z-this.origin.z)*i,n=(t.z-this.origin.z)*i,n===-1/0&&(n=1/0),r>n&&(o=r,r=n,n=o),s=Math.max(r,s),a=Math.min(n,a),s>a)return!1;return!0},t.prototype.intersectsBox=function(e){return this.intersectsBoxMinMax(e.minimum,e.maximum)},t.prototype.intersectsSphere=function(e){var t=e.center.x-this.origin.x,i=e.center.y-this.origin.y,r=e.center.z-this.origin.z,n=t*t+i*i+r*r,o=e.radius*e.radius;if(n<=o)return!0;var s=t*this.direction.x+i*this.direction.y+r*this.direction.z;return!(s<0)&&n-s*s<=o},t.prototype.intersectsTriangle=function(t,i,r){this._edge1||(this._edge1=e.Vector3.Zero(),this._edge2=e.Vector3.Zero(),this._pvec=e.Vector3.Zero(),this._tvec=e.Vector3.Zero(),this._qvec=e.Vector3.Zero()),i.subtractToRef(t,this._edge1),r.subtractToRef(t,this._edge2),e.Vector3.CrossToRef(this.direction,this._edge2,this._pvec);var n=e.Vector3.Dot(this._edge1,this._pvec);if(0===n)return null;var o=1/n;this.origin.subtractToRef(t,this._tvec);var s=e.Vector3.Dot(this._tvec,this._pvec)*o;if(s<0||s>1)return null;e.Vector3.CrossToRef(this._tvec,this._edge1,this._qvec);var a=e.Vector3.Dot(this.direction,this._qvec)*o;if(a<0||s+a>1)return null;var l=e.Vector3.Dot(this._edge2,this._qvec)*o;return l>this.length?null:new e.IntersectionInfo(s,a,l)},t.prototype.intersectsPlane=function(t){var i,r=e.Vector3.Dot(t.normal,this.direction);if(Math.abs(r)<9.99999997475243e-7)return null;var n=e.Vector3.Dot(t.normal,this.origin);return i=(-t.d-n)/r,i<0?i<-9.99999997475243e-7?null:0:i},t.prototype.intersectsMesh=function(i,r){var n=e.Tmp.Matrix[0];return i.getWorldMatrix().invertToRef(n),this._tmpRay?t.TransformToRef(this,n,this._tmpRay):this._tmpRay=t.Transform(this,n),i.intersects(this._tmpRay,r)},t.prototype.intersectsMeshes=function(e,t,i){i?i.length=0:i=[];for(var r=0;rt.distance?1:0},t.prototype.intersectionSegment=function(i,r,n){var o,s,a,l,h=this.origin.add(this.direction.multiplyByFloats(t.rayl,t.rayl,t.rayl)),c=r.subtract(i),u=h.subtract(this.origin),f=i.subtract(this.origin),d=e.Vector3.Dot(c,c),p=e.Vector3.Dot(c,u),_=e.Vector3.Dot(u,u),m=e.Vector3.Dot(c,f),g=e.Vector3.Dot(u,f),v=d*_-p*p,y=v,x=v;vy&&(s=y,l=g+p,x=_)),l<0?(l=0,-m<0?s=0:-m>d?s=y:(s=-m,y=d)):l>x&&(l=x,-m+p<0?s=0:-m+p>d?s=y:(s=-m+p,y=d)),o=Math.abs(s)0&&a<=this.length&&A.lengthSquared()i.x+r)&&(!(i.x-r>t.x)&&(!(e.y>i.y+r)&&(!(i.y-r>t.y)&&(!(e.z>i.z+r)&&!(i.z-r>t.z)))))},i=(function(){var e={root:0,found:!1};return function(t,i,r,n){e.root=0,e.found=!1;var o=i*i-4*t*r;if(o<0)return e;var s=Math.sqrt(o),a=(-i-s)/(2*t),l=(-i+s)/(2*t);if(a>l){var h=l;l=a,a=h}return a>0&&a0&&l=0))},r.prototype._canDoCollision=function(i,r,n,o){var s=e.Vector3.Distance(this.basePointWorld,i),a=Math.max(this.radius.x,this.radius.y,this.radius.z);return!(s>this.velocityWorldLength+a+r)&&!!t(n,o,this.basePointWorld,this.velocityWorldLength+a)},r.prototype._testTriangle=function(t,r,n,o,s,a){var l,h=!1;r||(r=[]),r[t]||(r[t]=new e.Plane(0,0,0,0),r[t].copyFromPoints(n,o,s));var c=r[t];if(a||c.isFrontFacingTo(this.normalizedVelocity,0)){var u=c.signedDistanceTo(this.basePoint),f=e.Vector3.Dot(c.normal,this.velocity);if(0==f){if(Math.abs(u)>=1)return;h=!0,l=0}else{l=(-1-u)/f;var d=(1-u)/f;if(l>d){var p=d;d=l,l=p}if(l>1||d<0)return;l<0&&(l=0),l>1&&(l=1)}this._collisionPoint.copyFromFloats(0,0,0);var _=!1,m=1;if(h||(this.basePoint.subtractToRef(c.normal,this._planeIntersectionPoint),this.velocity.scaleToRef(l,this._tempVector),this._planeIntersectionPoint.addInPlace(this._tempVector),this._checkPointInTriangle(this._planeIntersectionPoint,n,o,s,c.normal)&&(_=!0,m=l,this._collisionPoint.copyFrom(this._planeIntersectionPoint))),!_){var g=this.velocity.lengthSquared(),v=g;this.basePoint.subtractToRef(n,this._tempVector);var y=2*e.Vector3.Dot(this.velocity,this._tempVector),x=this._tempVector.lengthSquared()-1,b=i(v,y,x,m);b.found&&(m=b.root,_=!0,this._collisionPoint.copyFrom(n)),this.basePoint.subtractToRef(o,this._tempVector),y=2*e.Vector3.Dot(this.velocity,this._tempVector),x=this._tempVector.lengthSquared()-1,b=i(v,y,x,m),b.found&&(m=b.root,_=!0,this._collisionPoint.copyFrom(o)),this.basePoint.subtractToRef(s,this._tempVector),y=2*e.Vector3.Dot(this.velocity,this._tempVector),x=this._tempVector.lengthSquared()-1,b=i(v,y,x,m),b.found&&(m=b.root,_=!0,this._collisionPoint.copyFrom(s)),o.subtractToRef(n,this._edge),n.subtractToRef(this.basePoint,this._baseToVertex);var A=this._edge.lengthSquared(),T=e.Vector3.Dot(this._edge,this.velocity),E=e.Vector3.Dot(this._edge,this._baseToVertex);if(v=A*-g+T*T,y=A*(2*e.Vector3.Dot(this.velocity,this._baseToVertex))-2*T*E,x=A*(1-this._baseToVertex.lengthSquared())+E*E,b=i(v,y,x,m),b.found){var P=(T*b.root-E)/A;P>=0&&P<=1&&(m=b.root,_=!0,this._edge.scaleInPlace(P),n.addToRef(this._edge,this._collisionPoint))}s.subtractToRef(o,this._edge),o.subtractToRef(this.basePoint,this._baseToVertex),A=this._edge.lengthSquared(),T=e.Vector3.Dot(this._edge,this.velocity),E=e.Vector3.Dot(this._edge,this._baseToVertex),v=A*-g+T*T,y=A*(2*e.Vector3.Dot(this.velocity,this._baseToVertex))-2*T*E,x=A*(1-this._baseToVertex.lengthSquared())+E*E,b=i(v,y,x,m),b.found&&(P=(T*b.root-E)/A)>=0&&P<=1&&(m=b.root,_=!0,this._edge.scaleInPlace(P),o.addToRef(this._edge,this._collisionPoint)),n.subtractToRef(s,this._edge),s.subtractToRef(this.basePoint,this._baseToVertex),A=this._edge.lengthSquared(),T=e.Vector3.Dot(this._edge,this.velocity),E=e.Vector3.Dot(this._edge,this._baseToVertex),v=A*-g+T*T,y=A*(2*e.Vector3.Dot(this.velocity,this._baseToVertex))-2*T*E,x=A*(1-this._baseToVertex.lengthSquared())+E*E,b=i(v,y,x,m),b.found&&(P=(T*b.root-E)/A)>=0&&P<=1&&(m=b.root,_=!0,this._edge.scaleInPlace(P),s.addToRef(this._edge,this._collisionPoint))}if(_){var M=m*this.velocity.length();(!this.collisionFound||M4)){++n._runningUpdated;var e={updatedMeshes:n._addUpdateMeshesList,updatedGeometries:n._addUpdateGeometriesList,removedGeometries:n._toRemoveGeometryArray,removedMeshes:n._toRemoveMeshesArray},i={payload:e,taskType:t.UPDATE},r=[];for(var o in e.updatedGeometries)e.updatedGeometries.hasOwnProperty(o)&&(r.push(i.payload.updatedGeometries[o].indices.buffer),r.push(i.payload.updatedGeometries[o].normals.buffer),r.push(i.payload.updatedGeometries[o].positions.buffer));n._worker.postMessage(i,r),n._addUpdateMeshesList={},n._addUpdateGeometriesList={},n._toRemoveGeometryArray=[],n._toRemoveMeshesArray=[]}},this._onMessageFromWorker=function(r){var o=r.data;if(o.error!=i.SUCCESS)return void e.Tools.Warn("error returned from worker!");switch(o.taskType){case t.INIT:n._init=!0,n._scene.meshes.forEach((function(e){n.onMeshAdded(e)})),n._scene.getGeometries().forEach((function(e){n.onGeometryAdded(e)}));break;case t.UPDATE:n._runningUpdated--;break;case t.COLLIDE:n._runningCollisionTask=!1;var s=o.payload;if(!n._collisionsCallbackArray[s.collisionId])return;n._collisionsCallbackArray[s.collisionId](s.collisionId,e.Vector3.FromArray(s.newPosition),n._scene.getMeshByUniqueID(s.collidedMeshUniqueId)),n._collisionsCallbackArray[s.collisionId]=void 0}},this._collisionsCallbackArray=[],this._init=!1,this._runningUpdated=0,this._runningCollisionTask=!1,this._addUpdateMeshesList={},this._addUpdateGeometriesList={},this._toRemoveGeometryArray=[],this._toRemoveMeshesArray=[]}return r.prototype.getNewPosition=function(e,i,r,n,o,s,a){if(this._init&&!this._collisionsCallbackArray[a]&&!this._collisionsCallbackArray[a+1e5]){e.divideToRef(r.radius,this._scaledPosition),i.divideToRef(r.radius,this._scaledVelocity),this._collisionsCallbackArray[a]=s;var l={collider:{position:this._scaledPosition.asArray(),velocity:this._scaledVelocity.asArray(),radius:r.radius.asArray()},collisionId:a,excludedMeshUniqueId:o?o.uniqueId:null,maximumRetry:n},h={payload:l,taskType:t.COLLIDE};this._worker.postMessage(h)}},r.prototype.init=function(i){this._scene=i,this._scene.registerAfterRender(this._afterRender);var r=e.WorkerIncluded?e.Engine.CodeRepository+"Collisions/babylon.collisionWorker.js":URL.createObjectURL(new Blob([e.CollisionWorker],{type:"application/javascript"}));this._worker=new Worker(r),this._worker.onmessage=this._onMessageFromWorker;var n={payload:{},taskType:t.INIT};this._worker.postMessage(n)},r.prototype.destroy=function(){this._scene.unregisterAfterRender(this._afterRender),this._worker.terminate()},r.prototype.onMeshAdded=function(e){e.registerAfterWorldMatrixUpdate(this.onMeshUpdated),this.onMeshUpdated(e)},r.prototype.onMeshRemoved=function(e){this._toRemoveMeshesArray.push(e.uniqueId)},r.prototype.onGeometryAdded=function(e){e.onGeometryUpdated=this.onGeometryUpdated,this.onGeometryUpdated(e)},r.prototype.onGeometryDeleted=function(e){this._toRemoveGeometryArray.push(e.id)},r})();r.SerializeMesh=function(t){var i=[];t.subMeshes&&(i=t.subMeshes.map((function(e,t){return{position:t,verticesStart:e.verticesStart,verticesCount:e.verticesCount,indexStart:e.indexStart,indexCount:e.indexCount,hasMaterial:!!e.getMaterial(),sphereCenter:e.getBoundingInfo().boundingSphere.centerWorld.asArray(),sphereRadius:e.getBoundingInfo().boundingSphere.radiusWorld,boxMinimum:e.getBoundingInfo().boundingBox.minimumWorld.asArray(),boxMaximum:e.getBoundingInfo().boundingBox.maximumWorld.asArray()}})));var r=null;return t instanceof e.Mesh?r=t.geometry?t.geometry.id:null:t instanceof e.InstancedMesh&&(r=t.sourceMesh&&t.sourceMesh.geometry?t.sourceMesh.geometry.id:null),{uniqueId:t.uniqueId,id:t.id,name:t.name,geometryId:r,sphereCenter:t.getBoundingInfo().boundingSphere.centerWorld.asArray(),sphereRadius:t.getBoundingInfo().boundingSphere.radiusWorld,boxMinimum:t.getBoundingInfo().boundingBox.minimumWorld.asArray(),boxMaximum:t.getBoundingInfo().boundingBox.maximumWorld.asArray(),worldMatrixFromCache:t.worldMatrixFromCache.asArray(),subMeshes:i,checkCollisions:t.checkCollisions}},r.SerializeGeometry=function(t){return{id:t.id,positions:new Float32Array(t.getVerticesData(e.VertexBuffer.PositionKind)||[]),normals:new Float32Array(t.getVerticesData(e.VertexBuffer.NormalKind)||[]),indices:new Uint32Array(t.getIndices()||[])}},e.CollisionCoordinatorWorker=r;var n=(function(){function t(){this._scaledPosition=e.Vector3.Zero(),this._scaledVelocity=e.Vector3.Zero(),this._finalPosition=e.Vector3.Zero()}return t.prototype.getNewPosition=function(e,t,i,r,n,o,s){e.divideToRef(i.radius,this._scaledPosition),t.divideToRef(i.radius,this._scaledVelocity),i.collidedMesh=null,i.retry=0,i.initialVelocity=this._scaledVelocity,i.initialPosition=this._scaledPosition,this._collideWithWorld(this._scaledPosition,this._scaledVelocity,i,r,this._finalPosition,n),this._finalPosition.multiplyInPlace(i.radius),o(s,this._finalPosition,i.collidedMesh)},t.prototype.init=function(e){this._scene=e},t.prototype.destroy=function(){},t.prototype.onMeshAdded=function(e){},t.prototype.onMeshUpdated=function(e){},t.prototype.onMeshRemoved=function(e){},t.prototype.onGeometryAdded=function(e){},t.prototype.onGeometryUpdated=function(e){},t.prototype.onGeometryDeleted=function(e){},t.prototype._collideWithWorld=function(t,i,r,n,o,s){void 0===s&&(s=null);var a=10*e.Engine.CollisionsEpsilon;if(r.retry>=n)return void o.copyFrom(t);var l=s?s.collisionMask:r.collisionMask;r._initialize(t,i,a);for(var h=0;h=i.lifeTime?(a.recycleParticle(i),t--):(i.colorStep.scaleToRef(a._scaledUpdateSpeed,a._scaledColorStep),i.color.addInPlace(a._scaledColorStep),i.color.a<0&&(i.color.a=0),i.angle+=i.angularSpeed*a._scaledUpdateSpeed,i.direction.scaleToRef(a._scaledUpdateSpeed,a._scaledDirection),i.position.addInPlace(a._scaledDirection),a.gravity.scaleToRef(a._scaledUpdateSpeed,a._scaledGravity),i.direction.addInPlace(a._scaledGravity))}}}return Object.defineProperty(i.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!0,configurable:!0}),i.prototype.recycleParticle=function(e){var t=this.particles.pop();t!==e&&(t.copyTo(e),this._stockParticles.push(t))},i.prototype.getCapacity=function(){return this._capacity},i.prototype.isAlive=function(){return this._alive},i.prototype.isStarted=function(){return this._started},i.prototype.start=function(){this._started=!0,this._stopped=!1,this._actualFrame=0},i.prototype.stop=function(){this._stopped=!0},i.prototype._appendParticleVertex=function(e,t,i,r){var n=11*e;this._vertexData[n]=t.position.x,this._vertexData[n+1]=t.position.y,this._vertexData[n+2]=t.position.z,this._vertexData[n+3]=t.color.r,this._vertexData[n+4]=t.color.g,this._vertexData[n+5]=t.color.b,this._vertexData[n+6]=t.color.a,this._vertexData[n+7]=t.angle,this._vertexData[n+8]=t.size,this._vertexData[n+9]=i,this._vertexData[n+10]=r},i.prototype._update=function(i){this._alive=this.particles.length>0,this.updateFunction(this.particles);var r;if(this.emitter.position){r=this.emitter.getWorldMatrix()}else{var n=this.emitter;r=e.Matrix.Translation(n.x,n.y,n.z)}for(var o,s=0;s-1?(t=this.manualEmitCount,this._newPartsExcess=0,this.manualEmitCount=0):(t=this.emitRate*this._scaledUpdateSpeed>>0,this._newPartsExcess+=this.emitRate*this._scaledUpdateSpeed-t),this._newPartsExcess>1&&(t+=this._newPartsExcess>>0,this._newPartsExcess-=this._newPartsExcess>>0),this._alive=!1,this._stopped?t=0:(this._actualFrame+=this._scaledUpdateSpeed,this.targetStopDuration&&this._actualFrame>=this.targetStopDuration&&this.stop()),this._update(t),this._stopped&&(this._alive||(this._started=!1,this.onAnimationEnd&&this.onAnimationEnd(),this.disposeOnStop&&this._scene._toBeDisposed.push(this)));for(var i=0,r=0;r-1&&this._scene.particleSystems.splice(e,1),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear()},i.prototype.clone=function(t,r){var n=null,o=null;if(null!=this.customShader){o=this.customShader;var s=o.shaderOptions.defines.length>0?o.shaderOptions.defines.join("\n"):"";n=this._scene.getEngine().createEffectForParticles(o.shaderPath.fragmentElement,o.shaderOptions.uniforms,o.shaderOptions.samplers,s)}var a=new i(t,this._capacity,this._scene,n);return a.customShader=o,e.Tools.DeepCopy(this,a,["particles","customShader"]),void 0===r&&(r=this.emitter),a.emitter=r,this.particleTexture&&(a.particleTexture=new e.Texture(this.particleTexture.url,this._scene)),this.preventAutoStart||a.start(),a},i.prototype.serialize=function(){var t={};if(t.name=this.name,t.id=this.id,this.emitter.position){var i=this.emitter;t.emitterId=i.id}else{var r=this.emitter;t.emitter=r.asArray()}return t.capacity=this.getCapacity(),this.particleTexture&&(t.textureName=this.particleTexture.name),e.Animation.AppendSerializedAnimations(this,t),t.minAngularSpeed=this.minAngularSpeed,t.maxAngularSpeed=this.maxAngularSpeed,t.minSize=this.minSize,t.maxSize=this.maxSize,t.minEmitPower=this.minEmitPower,t.maxEmitPower=this.maxEmitPower,t.minLifeTime=this.minLifeTime,t.maxLifeTime=this.maxLifeTime,t.emitRate=this.emitRate,t.minEmitBox=this.minEmitBox.asArray(),t.maxEmitBox=this.maxEmitBox.asArray(),t.gravity=this.gravity.asArray(),t.direction1=this.direction1.asArray(),t.direction2=this.direction2.asArray(),t.color1=this.color1.asArray(),t.color2=this.color2.asArray(),t.colorDead=this.colorDead.asArray(),t.updateSpeed=this.updateSpeed,t.targetStopDuration=this.targetStopDuration,t.textureMask=this.textureMask.asArray(),t.blendMode=this.blendMode,t.customShader=this.customShader,t.preventAutoStart=this.preventAutoStart,t},i.Parse=function(t,r,n){var o=t.name,s=null,a=null;if(t.customShader){a=t.customShader;var l=a.shaderOptions.defines.length>0?a.shaderOptions.defines.join("\n"):"";s=r.getEngine().createEffectForParticles(a.shaderPath.fragmentElement,a.shaderOptions.uniforms,a.shaderOptions.samplers,l)}var h=new i(o,t.capacity,r,s);if(h.customShader=a,t.id&&(h.id=t.id),t.preventAutoStart&&(h.preventAutoStart=t.preventAutoStart),t.textureName&&(h.particleTexture=new e.Texture(n+t.textureName,r),h.particleTexture.name=t.textureName),t.emitterId?h.emitter=r.getLastMeshByID(t.emitterId):h.emitter=e.Vector3.FromArray(t.emitter),t.animations)for(var c=0;cf?f:n,r=Math.round(f/n),o=0):r=r>f?f:r;for(var d=[],p=[],_=[],m=[],g=e.Tmp.Vector3[0],v=r;uf-r&&(r=f-u),d.length=0,p.length=0,_.length=0,m.length=0;for(var y=0,x=3*u;x<3*(u+r);x++){p.push(y);var b=a[x];d.push(s[3*b],s[3*b+1],s[3*b+2]),l&&_.push(l[2*b],l[2*b+1]),h&&m.push(h[4*b],h[4*b+1],h[4*b+2],h[4*b+3]),y++}var A,T=this.nbParticles,E=this._posToShape(d),P=this._uvsToShapeUV(_);for(A=0;A=this.nbParticles?this.nbParticles-1:i,this._computeBoundingBox&&(0==t&&i==this.nbParticles-1?(e.Vector3.FromFloatsToRef(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,this._minimum),e.Vector3.FromFloatsToRef(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE,this._maximum)):(this._minimum.copyFrom(this.mesh._boundingInfo.boundingBox.minimum),this._maximum.copyFrom(this.mesh._boundingInfo.boundingBox.maximum))),s=this.particles[t]._pos;var f=s/3|0;l=4*f,c=2*f;for(var d=t;d<=i;d++){if(this._particle=this.particles[d],this._shape=this._particle._model._shape,this._shapeUV=this._particle._model._shapeUV,this.updateParticle(this._particle),this._particle.isVisible)for(this.billboard&&(this._particle.rotation.x=0,this._particle.rotation.y=0),(this._computeParticleRotation||this.billboard)&&(this._particle.rotationQuaternion?this._quaternion.copyFrom(this._particle.rotationQuaternion):(this._yaw=this._particle.rotation.y,this._pitch=this._particle.rotation.x,this._roll=this._particle.rotation.z,this._quaternionRotationYPR()),this._quaternionToRotationMatrix()),u=0;uthis._maximum.x&&(this._maximum.x=this._positions32[o]),this._positions32[o+1]this._maximum.y&&(this._maximum.y=this._positions32[o+1]),this._positions32[o+2]this._maximum.z&&(this._maximum.z=this._positions32[o+2])),this._computeParticleVertex||(this._normal.x=this._fixedNormal32[o],this._normal.y=this._fixedNormal32[o+1],this._normal.z=this._fixedNormal32[o+2],this._rotated.x=this._normal.x*this._rotMatrix.m[0]+this._normal.y*this._rotMatrix.m[4]+this._normal.z*this._rotMatrix.m[8]+this._rotMatrix.m[12],this._rotated.y=this._normal.x*this._rotMatrix.m[1]+this._normal.y*this._rotMatrix.m[5]+this._normal.z*this._rotMatrix.m[9]+this._rotMatrix.m[13],this._rotated.z=this._normal.x*this._rotMatrix.m[2]+this._normal.y*this._rotMatrix.m[6]+this._normal.z*this._rotMatrix.m[10]+this._rotMatrix.m[14],this._normals32[o]=this._cam_axisX.x*this._rotated.x+this._cam_axisY.x*this._rotated.y+this._cam_axisZ.x*this._rotated.z,this._normals32[o+1]=this._cam_axisX.y*this._rotated.x+this._cam_axisY.y*this._rotated.y+this._cam_axisZ.y*this._rotated.z,this._normals32[o+2]=this._cam_axisX.z*this._rotated.x+this._cam_axisY.z*this._rotated.y+this._cam_axisZ.z*this._rotated.z),this._computeParticleColor&&(this._colors32[a]=this._particle.color.r,this._colors32[a+1]=this._particle.color.g,this._colors32[a+2]=this._particle.color.b,this._colors32[a+3]=this._particle.color.a),this._computeParticleTexture&&(this._uvs32[h]=this._shapeUV[2*u]*(this._particle.uvs.z-this._particle.uvs.x)+this._particle.uvs.x,this._uvs32[h+1]=this._shapeUV[2*u+1]*(this._particle.uvs.w-this._particle.uvs.y)+this._particle.uvs.y);else for(u=0;uthis._maxX||ithis._maxZ)return this.position.y;this._heightQuads&&0!=this._heightQuads.length||(this._initHeightQuads(),this._computeHeightQuads());var s=this._getFacetAt(t,i),a=-(s.x*t+s.z*i+s.w)/s.y;return e.Vector3.TransformCoordinatesFromFloatsToRef(0,a,0,r,o),o.y},i.prototype.getNormalAtCoordinates=function(t,i){var r=new e.Vector3(0,1,0);return this.getNormalAtCoordinatesToRef(t,i,r),r},i.prototype.getNormalAtCoordinatesToRef=function(t,i,r){var n=this.getWorldMatrix(),o=e.Tmp.Matrix[5];n.invertToRef(o);var s=e.Tmp.Vector3[8];if(e.Vector3.TransformCoordinatesFromFloatsToRef(t,0,i,o,s),t=s.x,i=s.z,tthis._maxX||ithis._maxZ)return this;this._heightQuads&&0!=this._heightQuads.length||(this._initHeightQuads(),this._computeHeightQuads());var a=this._getFacetAt(t,i);return e.Vector3.TransformNormalFromFloatsToRef(a.x,a.y,a.z,n,r),this},i.prototype.updateCoordinateHeights=function(){return this._heightQuads&&0!=this._heightQuads.length||this._initHeightQuads(),this._computeHeightQuads(),this},i.prototype._getFacetAt=function(e,t){var i=(this._subdivisionsX,this._subdivisionsY,Math.floor((e+this._maxX)*this._subdivisionsX/this._width)),r=Math.floor(-(t+this._maxZ)*this._subdivisionsY/this._height+this._subdivisionsY),n=this._heightQuads[r*this._subdivisionsX+i];return t4&&(s.push(e.VertexBuffer.MatricesIndicesExtraKind),s.push(e.VertexBuffer.MatricesWeightsExtraKind)),o.push("#define NUM_BONE_INFLUENCERS "+t.numBoneInfluencers),o.push("#define BonesPerMesh "+(t.skeleton.bones.length+1)),a.addCPUSkinningFallback(0,t),-1===this._options.uniforms.indexOf("mBones")&&this._options.uniforms.push("mBones")):o.push("#define NUM_BONE_INFLUENCERS 0");for(var h in this._textures)if(!this._textures[h].isReady())return!1;n.getAlphaTesting()&&o.push("#define ALPHATEST");var c=this._effect,u=o.join("\n");return this._effect=n.createEffect(this._shaderPath,{attributes:s,uniformsNames:this._options.uniforms,uniformBuffersNames:this._options.uniformBuffers,samplers:this._options.samplers,defines:u,fallbacks:a,onCompiled:this.onCompiled,onError:this.onError},n),!!this._effect.isReady()&&(c!==this._effect&&r.resetCachedMaterial(),this._renderId=r.getRenderId(),!0)},i.prototype.bindOnlyWorldMatrix=function(e){var t=this.getScene();-1!==this._options.uniforms.indexOf("world")&&this._effect.setMatrix("world",e),-1!==this._options.uniforms.indexOf("worldView")&&(e.multiplyToRef(t.getViewMatrix(),this._cachedWorldViewMatrix),this._effect.setMatrix("worldView",this._cachedWorldViewMatrix)),-1!==this._options.uniforms.indexOf("worldViewProjection")&&this._effect.setMatrix("worldViewProjection",e.multiply(t.getTransformMatrix()))},i.prototype.bind=function(t,i){if(this.bindOnlyWorldMatrix(t),this.getScene().getCachedMaterial()!==this){-1!==this._options.uniforms.indexOf("view")&&this._effect.setMatrix("view",this.getScene().getViewMatrix()),-1!==this._options.uniforms.indexOf("projection")&&this._effect.setMatrix("projection",this.getScene().getProjectionMatrix()),-1!==this._options.uniforms.indexOf("viewProjection")&&this._effect.setMatrix("viewProjection",this.getScene().getTransformMatrix()),e.MaterialHelper.BindBonesParameters(i,this._effect);var r;for(r in this._textures)this._effect.setTexture(r,this._textures[r]);for(r in this._textureArrays)this._effect.setTextureArray(r,this._textureArrays[r]);for(r in this._floats)this._effect.setFloat(r,this._floats[r]);for(r in this._floatsArrays)this._effect.setArray(r,this._floatsArrays[r]);for(r in this._colors3)this._effect.setColor3(r,this._colors3[r]);for(r in this._colors3Arrays)this._effect.setArray3(r,this._colors3Arrays[r]);for(r in this._colors4){var n=this._colors4[r];this._effect.setFloat4(r,n.r,n.g,n.b,n.a)}for(r in this._vectors2)this._effect.setVector2(r,this._vectors2[r]);for(r in this._vectors3)this._effect.setVector3(r,this._vectors3[r]);for(r in this._vectors4)this._effect.setVector4(r,this._vectors4[r]);for(r in this._matrices)this._effect.setMatrix(r,this._matrices[r]);for(r in this._matrices3x3)this._effect.setMatrix3x3(r,this._matrices3x3[r]);for(r in this._matrices2x2)this._effect.setMatrix2x2(r,this._matrices2x2[r]);for(r in this._vectors3Arrays)this._effect.setArray3(r,this._vectors3Arrays[r])}this._afterBind(i)},i.prototype.getActiveTextures=function(){var e=t.prototype.getActiveTextures.call(this);for(var i in this._textures)e.push(this._textures[i]);for(var i in this._textureArrays)for(var r=this._textureArrays[i],n=0;ne.Tmp.Vector3[1].x&&(e.Tmp.Vector3[1].x=l[u].x),l[u].ye.Tmp.Vector3[1].y&&(e.Tmp.Vector3[1].y=l[u].y),l[u].ze.Tmp.Vector3[1].z&&(e.Tmp.Vector3[1].z=l[u].z),u++,r+=3;h._closePath&&(t[r]=l[0].x,t[r+1]=l[0].y,t[r+2]=l[0].z,r+=3)}}(u),h._boundingInfo=new e.BoundingInfo(e.Tmp.Vector3[0],e.Tmp.Vector3[1]),h._boundingInfo.update(h._worldMatrix),h.updateVerticesData(e.VertexBuffer.PositionKind,u,!1,!1),r.colors){for(var f=h.getVerticesData(e.VertexBuffer.ColorKind),d=0;d1?1:r.arc:1,a=void 0===r.closed||r.closed,l=r.shape,h=r.radius||1,c=r.tessellation||64,u=r.updatable,f=t.updateSideOrientation(r.sideOrientation,n),d=r.cap||e.Mesh.NO_CAP,p=2*Math.PI,_=new Array,m=r.invertUV||!1,g=0,v=0,y=p/c*s,x=new Array;for(g=0;g<=c;g++){var x=[];for(d!=e.Mesh.CAP_START&&d!=e.Mesh.CAP_ALL||(x.push(new e.Vector3(0,l[0].y,0)),x.push(new e.Vector3(Math.cos(g*y)*l[0].x*h,l[0].y,Math.sin(g*y)*l[0].x*h))),v=0;v1?1:r.arc||1;var p,_,m=function(t,i,r,n,o,s,a,l){for(var h,c,u,f,d=i.getTangents(),p=i.getNormals(),_=i.getDistances(),m=2*Math.PI,g=m/o*l,v=function(){return n},y=s||v,x=e.Tmp.Matrix[0],b=a===e.Mesh._NO_CAP||a===e.Mesh.CAP_END?0:2,A=0;A3?0:h,_=m(o,p,v,s,a,l,h,r.arc);var y=t.CreateRibbon(i,{pathArray:_,closePath:!0,closeArray:!1,updatable:u,sideOrientation:f,invertUV:c,frontUVs:r.frontUVs,backUVs:r.backUVs},n);return y.pathArray=_,y.path3D=p,y.tessellation=a,y.cap=h,y.arc=r.arc,y},t.CreatePolyhedron=function(i,r,n){var o=new e.Mesh(i,n);return r.sideOrientation=t.updateSideOrientation(r.sideOrientation,n),o.sideOrientation=r.sideOrientation,e.VertexData.CreatePolyhedron(r).applyToMesh(o,r.updatable),o},t.CreateDecal=function(t,i,r){var n=i.getIndices(),o=i.getVerticesData(e.VertexBuffer.PositionKind),s=i.getVerticesData(e.VertexBuffer.NormalKind),a=r.position||e.Vector3.Zero(),l=r.normal||e.Vector3.Up(),h=r.size||e.Vector3.One(),c=r.angle||0;if(!l){var u=new e.Vector3(0,0,1),f=i.getScene().activeCamera,d=e.Vector3.TransformCoordinates(u,f.getWorldMatrix());l=f.globalPosition.subtract(d)}var p=-Math.atan2(l.z,l.x)-Math.PI/2,_=Math.sqrt(l.x*l.x+l.z*l.z),m=Math.atan2(l.y,_),g=e.Matrix.RotationYawPitchRoll(p,m,c).multiply(e.Matrix.Translation(a.x,a.y,a.z)),v=e.Matrix.Invert(g),y=i.getWorldMatrix(),x=y.multiply(v),b=new e.VertexData;b.indices=[],b.positions=[],b.normals=[],b.uvs=[];for(var A=0,T=function(t){var i=n[t],r=new e.PositionNormalVertex;return r.position=new e.Vector3(o[3*i],o[3*i+1],o[3*i+2]),r.position=e.Vector3.TransformCoordinates(r.position,x),r.normal=new e.Vector3(s[3*i],s[3*i+1],s[3*i+2]),r.normal=e.Vector3.TransformNormal(r.normal,x),r},E=function(t,i){if(0===t.length)return t;for(var r=.5*Math.abs(e.Vector3.Dot(h,i)),n=function(t,n){var o=e.Vector3.GetClipFactor(t.position,n.position,i,r);return new e.PositionNormalVertex(e.Vector3.Lerp(t.position,n.position,o),e.Vector3.Lerp(t.normal,n.normal,o))},o=new Array,s=0;s0,l=m>0,c=g>0,(a?1:0)+(l?1:0)+(c?1:0)){case 0:o.push(t[s]),o.push(t[s+1]),o.push(t[s+2]);break;case 1:if(a&&(u=t[s+1],f=t[s+2],d=n(t[s],u),p=n(t[s],f)),l){u=t[s],f=t[s+2],d=n(t[s+1],u),p=n(t[s+1],f),o.push(d),o.push(f.clone()),o.push(u.clone()),o.push(f.clone()),o.push(d.clone()),o.push(p);break}c&&(u=t[s],f=t[s+1],d=n(t[s+2],u),p=n(t[s+2],f)),o.push(u.clone()),o.push(f.clone()),o.push(d),o.push(p),o.push(d.clone()),o.push(f.clone());break;case 2:a||(u=t[s].clone(),f=n(u,t[s+1]),d=n(u,t[s+2]),o.push(u),o.push(f),o.push(d)),l||(u=t[s+1].clone(),f=n(u,t[s+2]),d=n(u,t[s]),o.push(u),o.push(f),o.push(d)),c||(u=t[s+2].clone(),f=n(u,t[s]),d=n(u,t[s+1]),o.push(u),o.push(f),o.push(d))}}return o},P=0;P3?0:u,b=A(r,n,x,T,o,s,a,l,u,f);var E=t.CreateRibbon(i,{pathArray:b,closeArray:h,closePath:c,updatable:p,sideOrientation:_,invertUV:g,frontUVs:v,backUVs:y},d);return E.pathArray=b,E.path3D=x,E.cap=u,E},t})();e.MeshBuilder=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this._audioContext=null,this._audioContextInitialized=!1,this.canUseWebAudio=!1,this.WarnedWebAudioUnsupported=!1,this.unlocked=!1,this.isMP3supported=!1,this.isOGGsupported=!1,void 0===window.AudioContext&&void 0===window.webkitAudioContext||(window.AudioContext=window.AudioContext||window.webkitAudioContext,this.canUseWebAudio=!0);var e=document.createElement("audio");try{e&&e.canPlayType&&e.canPlayType('audio/mpeg; codecs="mp3"').replace(/^no$/,"")&&(this.isMP3supported=!0)}catch(e){}try{e&&e.canPlayType&&e.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,"")&&(this.isOGGsupported=!0)}catch(e){}/iPad|iPhone|iPod/.test(navigator.platform)?this._unlockiOSaudio():this.unlocked=!0}return Object.defineProperty(t.prototype,"audioContext",{get:function(){return this._audioContextInitialized||this._initializeAudioContext(),this._audioContext},enumerable:!0,configurable:!0}),t.prototype._unlockiOSaudio=function(){var e=this,t=function(){var i=e.audioContext.createBuffer(1,1,22050),r=e.audioContext.createBufferSource();r.buffer=i,r.connect(e.audioContext.destination),r.start(0),setTimeout((function(){r.playbackState!==r.PLAYING_STATE&&r.playbackState!==r.FINISHED_STATE||(e.unlocked=!0,window.removeEventListener("touchend",t,!1),e.onAudioUnlocked&&e.onAudioUnlocked())}),0)};window.addEventListener("touchend",t,!1)},t.prototype._initializeAudioContext=function(){try{this.canUseWebAudio&&(this._audioContext=new AudioContext,this.masterGain=this._audioContext.createGain(),this.masterGain.gain.value=1,this.masterGain.connect(this._audioContext.destination),this._audioContextInitialized=!0)}catch(t){this.canUseWebAudio=!1,e.Tools.Error("Web Audio: "+t.message)}},t.prototype.dispose=function(){this.canUseWebAudio&&this._audioContextInitialized&&(this._connectedAnalyser&&(this._connectedAnalyser.stopDebugCanvas(),this._connectedAnalyser.dispose(),this.masterGain.disconnect(),this.masterGain.connect(this._audioContext.destination),this._connectedAnalyser=null),this.masterGain.gain.value=1),this.WarnedWebAudioUnsupported=!1},t.prototype.getGlobalVolume=function(){return this.canUseWebAudio&&this._audioContextInitialized?this.masterGain.gain.value:-1},t.prototype.setGlobalVolume=function(e){this.canUseWebAudio&&this._audioContextInitialized&&(this.masterGain.gain.value=e)},t.prototype.connectToAnalyser=function(e){this._connectedAnalyser&&this._connectedAnalyser.stopDebugCanvas(),this.canUseWebAudio&&this._audioContextInitialized&&(this._connectedAnalyser=e,this.masterGain.disconnect(),this._connectedAnalyser.connectAudioNodes(this.masterGain,this._audioContext.destination))},t})();e.AudioEngine=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t,i,r,n,o){var s=this;if(this.autoplay=!1,this.loop=!1,this.useCustomAttenuation=!1,this.spatialSound=!1,this.refDistance=1,this.rolloffFactor=1,this.maxDistance=100,this.distanceModel="linear",this._panningModel="equalpower",this._playbackRate=1,this._streaming=!1,this._startTime=0,this._startOffset=0,this._position=e.Vector3.Zero(),this._localDirection=new e.Vector3(1,0,0),this._volume=1,this._isLoaded=!1,this._isReadyToPlay=!1,this.isPlaying=!1,this.isPaused=!1,this._isDirectional=!1,this._coneInnerAngle=360,this._coneOuterAngle=360,this._coneOuterGain=0,this._isOutputConnected=!1,this._urlType="Unknown",this.name=t,this._scene=r,this._readyToPlayCallback=n,this._customAttenuationFunction=function(e,t,i,r,n){return t0&&(h=!0,this._soundLoaded(i));break;case"String":l.push(i);case"Array":0===l.length&&(l=i);for(var c=0;c0&&(this._htmlAudioElement.currentTime=0);else{var i=t?e.Engine.audioEngine.audioContext.currentTime+t:e.Engine.audioEngine.audioContext.currentTime;this._soundSource.stop(i),this._soundSource.onended=null,this.isPaused||(this._startOffset=0)}this.isPlaying=!1}},t.prototype.pause=function(){this.isPlaying&&(this.isPaused=!0,this._streaming?this._htmlAudioElement.pause():(this.stop(0),this._startOffset+=e.Engine.audioEngine.audioContext.currentTime-this._startTime))},t.prototype.setVolume=function(t,i){e.Engine.audioEngine.canUseWebAudio&&(i?(this._soundGain.gain.cancelScheduledValues(e.Engine.audioEngine.audioContext.currentTime),this._soundGain.gain.setValueAtTime(this._soundGain.gain.value,e.Engine.audioEngine.audioContext.currentTime),this._soundGain.gain.linearRampToValueAtTime(t,e.Engine.audioEngine.audioContext.currentTime+i)):this._soundGain.gain.value=t),this._volume=t},t.prototype.setPlaybackRate=function(e){this._playbackRate=e,this.isPlaying&&(this._streaming?this._htmlAudioElement.playbackRate=this._playbackRate:this._soundSource.playbackRate.value=this._playbackRate)},t.prototype.getVolume=function(){return this._volume},t.prototype.attachToMesh=function(e){var t=this;this._connectedMesh&&(this._connectedMesh.unregisterAfterWorldMatrixUpdate(this._registerFunc),this._registerFunc=null),this._connectedMesh=e,this.spatialSound||(this.spatialSound=!0,this._createSpatialParameters(),this.isPlaying&&this.loop&&(this.stop(),this.play())),this._onRegisterAfterWorldMatrixUpdate(this._connectedMesh),this._registerFunc=function(e){return t._onRegisterAfterWorldMatrixUpdate(e)},e.registerAfterWorldMatrixUpdate(this._registerFunc)},t.prototype.detachFromMesh=function(){this._connectedMesh&&(this._connectedMesh.unregisterAfterWorldMatrixUpdate(this._registerFunc),this._registerFunc=null,this._connectedMesh=null)},t.prototype._onRegisterAfterWorldMatrixUpdate=function(t){this.setPosition(t.getBoundingInfo().boundingSphere.centerWorld),e.Engine.audioEngine.canUseWebAudio&&this._isDirectional&&this.isPlaying&&this._updateDirection()},t.prototype.clone=function(){var e=this;if(this._streaming)return null;var i=function(){e._isReadyToPlay?(n._audioBuffer=e.getAudioBuffer(),n._isReadyToPlay=!0,n.autoplay&&n.play()):window.setTimeout(i,300)},r={autoplay:this.autoplay,loop:this.loop,volume:this._volume,spatialSound:this.spatialSound,maxDistance:this.maxDistance,useCustomAttenuation:this.useCustomAttenuation,rolloffFactor:this.rolloffFactor,refDistance:this.refDistance,distanceModel:this.distanceModel},n=new t(this.name+"_cloned",new ArrayBuffer(0),this._scene,null,r);return this.useCustomAttenuation&&n.setAttenuationFunction(this._customAttenuationFunction),n.setPosition(this._position),n.setPlaybackRate(this._playbackRate),i(),n},t.prototype.getAudioBuffer=function(){return this._audioBuffer},t.prototype.serialize=function(){var e={name:this.name,url:this.name,autoplay:this.autoplay,loop:this.loop,volume:this._volume,spatialSound:this.spatialSound,maxDistance:this.maxDistance,rolloffFactor:this.rolloffFactor,refDistance:this.refDistance,distanceModel:this.distanceModel,playbackRate:this._playbackRate,panningModel:this._panningModel,soundTrackId:this.soundTrackId};return this.spatialSound&&(this._connectedMesh&&(e.connectedMeshId=this._connectedMesh.id),e.position=this._position.asArray(),e.refDistance=this.refDistance,e.distanceModel=this.distanceModel,e.isDirectional=this._isDirectional,e.localDirectionToMesh=this._localDirection.asArray(),e.coneInnerAngle=this._coneInnerAngle,e.coneOuterAngle=this._coneOuterAngle,e.coneOuterGain=this._coneOuterGain),e},t.Parse=function(i,r,n,o){var s,a=i.name;s=i.url?n+i.url:n+a;var l,h={autoplay:i.autoplay,loop:i.loop,volume:i.volume,spatialSound:i.spatialSound,maxDistance:i.maxDistance,rolloffFactor:i.rolloffFactor,refDistance:i.refDistance,distanceModel:i.distanceModel,playbackRate:i.playbackRate};if(o){var c=function(){o._isReadyToPlay?(l._audioBuffer=o.getAudioBuffer(),l._isReadyToPlay=!0,l.autoplay&&l.play()):window.setTimeout(c,300)};l=new t(a,new ArrayBuffer(0),r,null,h),c()}else l=new t(a,s,r,function(){r._removePendingData(l)},h),r._addPendingData(l);if(i.position){var u=e.Vector3.FromArray(i.position);l.setPosition(u)}if(i.isDirectional&&(l.setDirectionalCone(i.coneInnerAngle||360,i.coneOuterAngle||360,i.coneOuterGain||0),i.localDirectionToMesh)){var f=e.Vector3.FromArray(i.localDirectionToMesh);l.setLocalDirectionToMesh(f)}if(i.connectedMeshId){var d=r.getMeshByID(i.connectedMeshId);d&&l.attachToMesh(d)}return l},t})();e.Sound=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e,t){this.id=-1,this._isMainTrack=!1,this._isInitialized=!1,this._scene=e,this.soundCollection=new Array,this._options=t,this._isMainTrack||(this._scene.soundTracks.push(this),this.id=this._scene.soundTracks.length-1)}return t.prototype._initializeSoundTrackAudioGraph=function(){e.Engine.audioEngine.canUseWebAudio&&(this._outputAudioNode=e.Engine.audioEngine.audioContext.createGain(),this._outputAudioNode.connect(e.Engine.audioEngine.masterGain),this._options&&(this._options.volume&&(this._outputAudioNode.gain.value=this._options.volume),this._options.mainTrack&&(this._isMainTrack=this._options.mainTrack)),this._isInitialized=!0)},t.prototype.dispose=function(){if(e.Engine.audioEngine.canUseWebAudio){for(this._connectedAnalyser&&this._connectedAnalyser.stopDebugCanvas();this.soundCollection.length;)this.soundCollection[0].dispose();this._outputAudioNode&&this._outputAudioNode.disconnect(),this._outputAudioNode=null}},t.prototype.AddSound=function(t){this._isInitialized||this._initializeSoundTrackAudioGraph(),e.Engine.audioEngine.canUseWebAudio&&t.connectToSoundTrackAudioNode(this._outputAudioNode),t.soundTrackId&&(-1===t.soundTrackId?this._scene.mainSoundTrack.RemoveSound(t):this._scene.soundTracks[t.soundTrackId].RemoveSound(t)),this.soundCollection.push(t),t.soundTrackId=this.id},t.prototype.RemoveSound=function(e){var t=this.soundCollection.indexOf(e);-1!==t&&this.soundCollection.splice(t,1)},t.prototype.setVolume=function(t){e.Engine.audioEngine.canUseWebAudio&&(this._outputAudioNode.gain.value=t)},t.prototype.switchPanningModelToHRTF=function(){if(e.Engine.audioEngine.canUseWebAudio)for(var t=0;t0&&(this._postProcesses[0].autoClear=!1))}},i.prototype._shouldRender=function(){return-1===this._currentRefreshId?(this._currentRefreshId=1,!0):this.refreshRate===this._currentRefreshId?(this._currentRefreshId=1,!0):(this._currentRefreshId++,!1)},i.prototype.isReady=function(){return!!this.getScene().renderTargetsEnabled&&t.prototype.isReady.call(this)},i.prototype.getRenderSize=function(){return this._size},Object.defineProperty(i.prototype,"canRescale",{get:function(){return!0},enumerable:!0,configurable:!0}),i.prototype.scale=function(e){var t=this._size*e;this.resize(t)},i.prototype.getReflectionTextureMatrix=function(){return this.isCube?this._textureMatrix:t.prototype.getReflectionTextureMatrix.call(this)},i.prototype.resize=function(e){this.releaseInternalTexture(),this.isCube?this._texture=this.getScene().getEngine().createRenderTargetCubeTexture(e,this._renderTargetOptions):this._texture=this.getScene().getEngine().createRenderTargetTexture(e,this._renderTargetOptions)},i.prototype.render=function(e,t){var i=this.getScene(),r=i.getEngine();if(void 0!==this.useCameraPostProcesses&&(e=this.useCameraPostProcesses),this._waitingRenderList){this.renderList=[];for(var n=0;n=0&&this._renderingManager.dispatchParticles(g))}if(this.isCube)for(var y=0;y<6;y++)this.renderToTarget(y,h,c,e,t),i.incrementRenderId(),i.resetCachedMaterial();else this.renderToTarget(0,h,c,e,t);this.onAfterUnbindObservable.notifyObservers(this),this.activeCamera&&this.activeCamera!==i.activeCamera&&i.setTransformMatrix(i.activeCamera.getViewMatrix(),i.activeCamera.getProjectionMatrix(!0)),r.setViewport(i.activeCamera.viewport),i.resetCachedMaterial()}},i.prototype.renderToTarget=function(t,i,r,n,o){var s=this,a=this.getScene(),l=a.getEngine();this._postProcessManager?this._postProcessManager._prepareFrame(this._texture,this._postProcesses):n&&a.postProcessManager._prepareFrame(this._texture)||(this.isCube?l.bindFramebuffer(this._texture,t):l.bindFramebuffer(this._texture)),this.onBeforeRenderObservable.notifyObservers(t),this.onClearObservable.hasObservers()?this.onClearObservable.notifyObservers(l):l.clear(a.clearColor,!0,!0,!0),this._doNotChangeAspectRatio||a.updateTransformMatrix(!0),this._renderingManager.render(this.customRenderFunction,i,this.renderParticles,this.renderSprites),this._postProcessManager?this._postProcessManager._finalizeFrame(!1,this._texture,t,this._postProcesses):n&&a.postProcessManager._finalizeFrame(!1,this._texture,t),this._doNotChangeAspectRatio||a.updateTransformMatrix(!0),o&&e.Tools.DumpFramebuffer(this._size,this._size,l),this.isCube&&5!==t?this.onAfterRenderObservable.notifyObservers(t):(this.isCube&&5===t&&l.generateMipMapsForCubemap(this._texture),l.unBindFramebuffer(this._texture,this.isCube,(function(){s.onAfterRenderObservable.notifyObservers(t)})))},i.prototype.setRenderingOrder=function(e,t,i,r){void 0===t&&(t=null),void 0===i&&(i=null),void 0===r&&(r=null),this._renderingManager.setRenderingOrder(e,t,i,r)},i.prototype.setRenderingAutoClearDepthStencil=function(e,t){this._renderingManager.setRenderingAutoClearDepthStencil(e,t)},i.prototype.clone=function(){var e=this.getSize(),t=new i(this.name,e.width,this.getScene(),this._renderTargetOptions.generateMipMaps,this._doNotChangeAspectRatio,this._renderTargetOptions.type,this.isCube,this._renderTargetOptions.samplingMode,this._renderTargetOptions.generateDepthBuffer,this._renderTargetOptions.generateStencilBuffer);return t.hasAlpha=this.hasAlpha,t.level=this.level,t.coordinatesMode=this.coordinatesMode,t.renderList=this.renderList.slice(0),t},i.prototype.serialize=function(){if(!this.name)return null;var e=t.prototype.serialize.call(this);e.renderTargetSize=this.getRenderSize(),e.renderList=[];for(var i=0;i=0&&e.customRenderTargets.splice(i,1);for(var r=0,n=e.cameras;r=0&&o.customRenderTargets.splice(i,1)}t.prototype.dispose.call(this)},i})(e.Texture);t._REFRESHRATE_RENDER_ONCE=0,t._REFRESHRATE_RENDER_ONEVERYFRAME=1,t._REFRESHRATE_RENDER_ONEVERYTWOFRAMES=2,e.RenderTargetTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o,s){var a=this;s=s||{};var l=!!s.generateMipMaps&&s.generateMipMaps,h=!!s.generateDepthTexture&&s.generateDepthTexture,c=void 0===s.doNotChangeAspectRatio||s.doNotChangeAspectRatio;if(a=t.call(this,i,r,o,l,c)||this,!a.isSupported)return void a.dispose();for(var u=[],f=[],d=0;d1||e.getCaps().drawBuffersExtension},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"textures",{get:function(){return this._textures},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"depthTexture",{get:function(){return this._textures[this._textures.length-1]},enumerable:!0,configurable:!0}),i.prototype._createInternalTextures=function(){this._textures=[];for(var t=0;t=0;e--)void 0!==this._webGLTextures[e]&&(this.getScene().getEngine().releaseInternalTexture(this._webGLTextures[e]),this._webGLTextures.splice(e,1))},i})(e.RenderTargetTexture);e.MultiRenderTarget=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o,s,a,l){void 0===s&&(s=e.Engine.TEXTURETYPE_UNSIGNED_INT),void 0===a&&(a=e.Texture.BILINEAR_SAMPLINGMODE),void 0===l&&(l=!0);var h=t.call(this,i,r,n,o,!0,s,!1,a,l)||this;return h.mirrorPlane=new e.Plane(0,1,0,1),h._transformMatrix=e.Matrix.Zero(),h._mirrorMatrix=e.Matrix.Zero(),h._blurKernelX=0,h._blurKernelY=0,h._blurRatio=1,h.onBeforeRenderObservable.add((function(){e.Matrix.ReflectionToRef(h.mirrorPlane,h._mirrorMatrix),h._savedViewMatrix=n.getViewMatrix(),h._mirrorMatrix.multiplyToRef(h._savedViewMatrix,h._transformMatrix),n.setTransformMatrix(h._transformMatrix,n.getProjectionMatrix()),n.clipPlane=h.mirrorPlane,n.getEngine().cullBackFaces=!1,n._mirroredCameraPosition=e.Vector3.TransformCoordinates(n.activeCamera.globalPosition,h._mirrorMatrix)})),h.onAfterRenderObservable.add((function(){n.setTransformMatrix(h._savedViewMatrix,n.getProjectionMatrix()),n.getEngine().cullBackFaces=!0,n._mirroredCameraPosition=null,delete n.clipPlane})),h}return __extends(i,t),Object.defineProperty(i.prototype,"blurRatio",{get:function(){return this._blurRatio},set:function(e){this._blurRatio!==e&&(this._blurRatio=e,this._preparePostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"blurKernel",{set:function(e){this.blurKernelX=e,this.blurKernelY=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"blurKernelX",{get:function(){return this._blurKernelX},set:function(e){this._blurKernelX!==e&&(this._blurKernelX=e,this._preparePostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"blurKernelY",{get:function(){return this._blurKernelY},set:function(e){this._blurKernelY!==e&&(this._blurKernelY=e,this._preparePostProcesses())},enumerable:!0,configurable:!0}),i.prototype._preparePostProcesses=function(){if(this.clearPostProcesses(!0),this._blurKernelX&&this._blurKernelY){var t=this.getScene().getEngine(),i=t.getCaps().textureFloatRender?e.Engine.TEXTURETYPE_FLOAT:e.Engine.TEXTURETYPE_HALF_FLOAT;this._blurX=new e.BlurPostProcess("horizontal blur",new e.Vector2(1,0),this._blurKernelX,this._blurRatio,null,e.Texture.BILINEAR_SAMPLINGMODE,t,!1,i),this._blurX.autoClear=!1,1===this._blurRatio&&this.samples<2?this._blurX.outputTexture=this._texture:this._blurX.alwaysForcePOT=!0,this._blurY=new e.BlurPostProcess("vertical blur",new e.Vector2(0,1),this._blurKernelY,this._blurRatio,null,e.Texture.BILINEAR_SAMPLINGMODE,t,!1,i),this._blurY.autoClear=!1,this._blurY.alwaysForcePOT=1!==this._blurRatio,this.addPostProcess(this._blurX),this.addPostProcess(this._blurY)}},i.prototype.clone=function(){var e=this.getSize(),t=new i(this.name,e.width,this.getScene(),this._renderTargetOptions.generateMipMaps,this._renderTargetOptions.type,this._renderTargetOptions.samplingMode,this._renderTargetOptions.generateDepthBuffer);return t.hasAlpha=this.hasAlpha,t.level=this.level,t.mirrorPlane=this.mirrorPlane.clone(),t.renderList=this.renderList.slice(0),t},i.prototype.serialize=function(){if(!this.name)return null;var e=t.prototype.serialize.call(this);return e.mirrorPlane=this.mirrorPlane.asArray(),e},i})(e.RenderTargetTexture);e.MirrorTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o){var s=t.call(this,i,r,n,o,!0)||this;return s.refractionPlane=new e.Plane(0,1,0,1),s.depth=2,s.onBeforeRenderObservable.add((function(){n.clipPlane=s.refractionPlane})),s.onAfterRenderObservable.add((function(){delete n.clipPlane})),s}return __extends(i,t),i.prototype.clone=function(){var e=this.getSize(),t=new i(this.name,e.width,this.getScene(),this._generateMipMaps);return t.hasAlpha=this.hasAlpha,t.level=this.level,t.refractionPlane=this.refractionPlane.clone(),t.renderList=this.renderList.slice(0),t.depth=this.depth,t},i.prototype.serialize=function(){if(!this.name)return null;var e=t.prototype.serialize.call(this);return e.mirrorPlane=this.refractionPlane.asArray(),e.depth=this.depth,e},i})(e.RenderTargetTexture);e.RefractionTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o,s,a){void 0===s&&(s=e.Texture.TRILINEAR_SAMPLINGMODE),void 0===a&&(a=e.Engine.TEXTUREFORMAT_RGBA);var l=t.call(this,null,n,!o,void 0,s,void 0,void 0,void 0,void 0,a)||this;l.name=i;var h=l.getScene().getEngine();l.wrapU=e.Texture.CLAMP_ADDRESSMODE,l.wrapV=e.Texture.CLAMP_ADDRESSMODE,l._generateMipMaps=o,r.getContext?(l._canvas=r,l._texture=h.createDynamicTexture(r.width,r.height,o,s)):(l._canvas=document.createElement("canvas"),r.width?l._texture=h.createDynamicTexture(r.width,r.height,o,s):l._texture=h.createDynamicTexture(r,r,o,s));var c=l.getSize();return l._canvas.width=c.width,l._canvas.height=c.height,l._context=l._canvas.getContext("2d"),l}return __extends(i,t),Object.defineProperty(i.prototype,"canRescale",{get:function(){return!0},enumerable:!0,configurable:!0}),i.prototype._recreate=function(e){this._canvas.width=e.width,this._canvas.height=e.height,this.releaseInternalTexture(),this._texture=this.getScene().getEngine().createDynamicTexture(e.width,e.height,this._generateMipMaps,this._samplingMode)},i.prototype.scale=function(e){var t=this.getSize();t.width*=e,t.height*=e,this._recreate(t)},i.prototype.scaleTo=function(e,t){var i=this.getSize();i.width=e,i.height=t,this._recreate(i)},i.prototype.getContext=function(){return this._context},i.prototype.clear=function(){var e=this.getSize();this._context.fillRect(0,0,e.width,e.height)},i.prototype.update=function(e){this.getScene().getEngine().updateDynamicTexture(this._texture,this._canvas,void 0===e||e,void 0,this._format)},i.prototype.drawText=function(e,t,i,r,n,o,s,a){void 0===a&&(a=!0);var l=this.getSize();if(o&&(this._context.fillStyle=o,this._context.fillRect(0,0,l.width,l.height)),this._context.font=r,null===t||void 0===t){var h=this._context.measureText(e);t=(l.width-h.width)/2}if(null===i||void 0===i){var c=parseInt(r.replace(/\D/g,""));i=l.height/2+c/3.65}this._context.fillStyle=n,this._context.fillText(e,t,i),a&&this.update(s)},i.prototype.clone=function(){var e=this.getSize(),t=new i(this.name,e,this.getScene(),this._generateMipMaps);return t.hasAlpha=this.hasAlpha,t.level=this.level,t.wrapU=this.wrapU,t.wrapV=this.wrapV,t},i})(e.Texture);e.DynamicTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o,s,a){void 0===o&&(o=!1),void 0===s&&(s=!1),void 0===a&&(a=e.Texture.TRILINEAR_SAMPLINGMODE);var l=t.call(this,null,n,!o,s)||this;l._autoLaunch=!0;var h;return l.name=i,r instanceof HTMLVideoElement?l.video=r:(h=r,l.video=document.createElement("video"),l.video.autoplay=!1,l.video.loop=!0),l._generateMipMaps=o,l._samplingMode=a,!l.getScene().getEngine().needPOTTextures||e.Tools.IsExponentOfTwo(l.video.videoWidth)&&e.Tools.IsExponentOfTwo(l.video.videoHeight)?(l.wrapU=e.Texture.WRAP_ADDRESSMODE,l.wrapV=e.Texture.WRAP_ADDRESSMODE):(l.wrapU=e.Texture.CLAMP_ADDRESSMODE,l.wrapV=e.Texture.CLAMP_ADDRESSMODE,l._generateMipMaps=!1),h?(l.video.addEventListener("canplay",(function(){l._createTexture()})),h.forEach((function(e){var t=document.createElement("source");t.src=e,l.video.appendChild(t)}))):l._createTexture(),l._lastUpdate=e.Tools.Now,l}return __extends(i,t),i.prototype.__setTextureReady=function(){this._texture.isReady=!0},i.prototype._createTexture=function(){this._texture=this.getScene().getEngine().createDynamicTexture(this.video.videoWidth,this.video.videoHeight,this._generateMipMaps,this._samplingMode),this._autoLaunch&&(this._autoLaunch=!1,this.video.play()),this._setTextureReady=this.__setTextureReady.bind(this),this.video.addEventListener("playing",this._setTextureReady)},i.prototype.update=function(){var t=e.Tools.Now;return!(t-this._lastUpdate<15||this.video.readyState!==this.video.HAVE_ENOUGH_DATA)&&(this._lastUpdate=t,this.getScene().getEngine().updateVideoTexture(this._texture,this.video,this._invertY),!0)},i.prototype.dispose=function(){t.prototype.dispose.call(this),this.video.removeEventListener("playing",this._setTextureReady)},i.CreateFromWebCam=function(t,i,r){var n,o=document.createElement("video");r&&r.deviceId&&(n={exact:r.deviceId}),navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia,window.URL=window.URL||window.webkitURL||window.mozURL||window.msURL,navigator.getUserMedia&&navigator.getUserMedia({video:{deviceId:n,width:{min:r&&r.minWidth||256,max:r&&r.maxWidth||640},height:{min:r&&r.minHeight||256,max:r&&r.maxHeight||480}}},(function(r){void 0!==o.mozSrcObject?o.mozSrcObject=r:o.src=window.URL&&window.URL.createObjectURL(r)||r,o.play(),i&&i(new e.VideoTexture("video",o,t,!0,!0))}),(function(t){e.Tools.Error(t.name)}))},i})(e.Texture);e.VideoTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o,s,a,l,h){void 0===a&&(a=!0),void 0===l&&(l=!1),void 0===h&&(h=e.Texture.TRILINEAR_SAMPLINGMODE);var c=t.call(this,null,s,!a,l)||this;return c.format=o,c._texture=s.getEngine().createRawTexture(i,r,n,o,a,l,h),c.wrapU=e.Texture.CLAMP_ADDRESSMODE,c.wrapV=e.Texture.CLAMP_ADDRESSMODE,c}return __extends(i,t),i.prototype.update=function(e){this.getScene().getEngine().updateRawTexture(this._texture,e,this.format,this._invertY)},i.CreateLuminanceTexture=function(t,r,n,o,s,a,l){return void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===l&&(l=e.Texture.TRILINEAR_SAMPLINGMODE),new i(t,r,n,e.Engine.TEXTUREFORMAT_LUMINANCE,o,s,a,l)},i.CreateLuminanceAlphaTexture=function(t,r,n,o,s,a,l){return void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===l&&(l=e.Texture.TRILINEAR_SAMPLINGMODE),new i(t,r,n,e.Engine.TEXTUREFORMAT_LUMINANCE_ALPHA,o,s,a,l)},i.CreateAlphaTexture=function(t,r,n,o,s,a,l){return void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===l&&(l=e.Texture.TRILINEAR_SAMPLINGMODE),new i(t,r,n,e.Engine.TEXTUREFORMAT_ALPHA,o,s,a,l)},i.CreateRGBTexture=function(t,r,n,o,s,a,l){return void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===l&&(l=e.Texture.TRILINEAR_SAMPLINGMODE),new i(t,r,n,e.Engine.TEXTUREFORMAT_RGB,o,s,a,l)},i.CreateRGBATexture=function(t,r,n,o,s,a,l){return void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===l&&(l=e.Texture.TRILINEAR_SAMPLINGMODE),new i(t,r,n,e.Engine.TEXTUREFORMAT_RGBA,o,s,a,l)},i})(e.Texture);e.RawTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t,i,r,n,o,s,a,l,h,c,u,f,d,p){void 0===a&&(a=e.Texture.NEAREST_SAMPLINGMODE),void 0===u&&(u=e.Engine.TEXTURETYPE_UNSIGNED_INT),void 0===f&&(f="postprocess"),void 0===p&&(p=!1),this.name=t,this.width=-1,this.height=-1,this.autoClear=!0,this.alphaMode=e.Engine.ALPHA_DISABLE,this.enablePixelPerfectMode=!1,this.scaleMode=e.Engine.SCALEMODE_FLOOR,this.alwaysForcePOT=!1,this.samples=1,this._reusable=!1,this._textures=new e.SmartArray(2),this._currentRenderTextureInd=0,this._scaleRatio=new e.Vector2(1,1),this._texelSize=e.Vector2.Zero(),this.onActivateObservable=new e.Observable,this.onSizeChangedObservable=new e.Observable,this.onApplyObservable=new e.Observable,this.onBeforeRenderObservable=new e.Observable,this.onAfterRenderObservable=new e.Observable,null!=s?(this._camera=s,this._scene=s.getScene(),s.attachPostProcess(this),this._engine=this._scene.getEngine()):this._engine=l,this._options=o,this.renderTargetSamplingMode=a||e.Texture.NEAREST_SAMPLINGMODE,this._reusable=h||!1,this._textureType=u,this._samplers=n||[],this._samplers.push("textureSampler"),this._fragmentUrl=i,this._vertexUrl=f,this._parameters=r||[],this._parameters.push("scale"),this._indexParameters=d,p||this.updateEffect(c)}return Object.defineProperty(t.prototype,"onActivate",{set:function(e){this._onActivateObserver&&this.onActivateObservable.remove(this._onActivateObserver),this._onActivateObserver=this.onActivateObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onSizeChanged",{set:function(e){this._onSizeChangedObserver&&this.onSizeChangedObservable.remove(this._onSizeChangedObserver),this._onSizeChangedObserver=this.onSizeChangedObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onApply",{set:function(e){this._onApplyObserver&&this.onApplyObservable.remove(this._onApplyObserver),this._onApplyObserver=this.onApplyObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onBeforeRender",{set:function(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onAfterRender",{set:function(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=this.onAfterRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"outputTexture",{get:function(){return this._textures.data[this._currentRenderTextureInd]},set:function(e){this._forcedOutputTexture=e},enumerable:!0,configurable:!0}),t.prototype.getCamera=function(){return this._camera},Object.defineProperty(t.prototype,"texelSize",{get:function(){return this._shareOutputWithPostProcess?this._shareOutputWithPostProcess.texelSize:(this._forcedOutputTexture&&this._texelSize.copyFromFloats(1/this._forcedOutputTexture._width,1/this._forcedOutputTexture._height),this._texelSize)},enumerable:!0,configurable:!0}),t.prototype.getEngine=function(){return this._engine},t.prototype.getEffect=function(){return this._effect},t.prototype.shareOutputWith=function(e){return this._disposeTextures(),this._shareOutputWithPostProcess=e,this},t.prototype.updateEffect=function(e,t,i,r,n,o){this._effect=this._engine.createEffect({vertex:this._vertexUrl,fragment:this._fragmentUrl},["position"],t||this._parameters,i||this._samplers,void 0!==e?e:"",null,n,o,r||this._indexParameters)},t.prototype.isReusable=function(){return this._reusable},t.prototype.markTextureDirty=function(){this.width=-1},t.prototype.activate=function(t,i,r){var n=this;if(!this._shareOutputWithPostProcess&&!this._forcedOutputTexture){t=t||this._camera;var o=t.getScene(),s=o.getEngine(),a=s.getCaps().maxTextureSize,l=(i?i._width:this._engine.getRenderingCanvas().width)*this._options|0,h=(i?i._height:this._engine.getRenderingCanvas().height)*this._options|0,c=this._options.width||l,u=this._options.height||h;if((this.renderTargetSamplingMode===e.Texture.TRILINEAR_SAMPLINGMODE||this.alwaysForcePOT)&&(this._options.width||(c=s.needPOTTextures?e.Tools.GetExponentOfTwo(c,a,this.scaleMode):c),this._options.height||(u=s.needPOTTextures?e.Tools.GetExponentOfTwo(u,a,this.scaleMode):u)),this.width!==c||this.height!==u){if(this._textures.length>0){for(var f=0;f0)for(var e=0;e0&&this._camera._postProcesses[0].markTextureDirty(),this.onActivateObservable.clear(),this.onAfterRenderObservable.clear(),this.onApplyObservable.clear(),this.onBeforeRenderObservable.clear(),this.onSizeChangedObservable.clear()}},t})();e.PostProcess=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o,s,a,l){return void 0===l&&(l=e.Engine.TEXTURETYPE_UNSIGNED_INT),t.call(this,i,"pass",null,null,r,n,o,s,a,null,l)||this}return __extends(i,t),i})(e.PostProcess);e.PassPostProcess=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(i,r,n){this._bias=5e-5,this._blurBoxOffset=1,this._blurScale=2,this._blurKernel=1,this._useKernelBlur=!1,this._filter=t.FILTER_NONE,this._darkness=0,this._transparencyShadow=!1,this.frustumEdgeFalloff=0,this.forceBackFacesOnly=!1,this._lightDirection=e.Vector3.Zero(),this._viewMatrix=e.Matrix.Zero(),this._projectionMatrix=e.Matrix.Zero(),this._transformMatrix=e.Matrix.Zero(),this._worldViewProjection=e.Matrix.Zero(),this._currentFaceIndex=0,this._currentFaceIndexCache=0,this._isCube=!1,this._defaultTextureMatrix=e.Matrix.Identity(),this._mapSize=i,this._light=r,this._scene=r.getScene(),r._shadowGenerator=this;var o=this._scene.getEngine().getCaps();n?o.textureFloatRender&&o.textureFloatLinearFiltering?this._textureType=e.Engine.TEXTURETYPE_FLOAT:o.textureHalfFloatRender&&o.textureHalfFloatLinearFiltering?this._textureType=e.Engine.TEXTURETYPE_HALF_FLOAT:this._textureType=e.Engine.TEXTURETYPE_UNSIGNED_INT:o.textureHalfFloatRender&&o.textureHalfFloatLinearFiltering?this._textureType=e.Engine.TEXTURETYPE_HALF_FLOAT:o.textureFloatRender&&o.textureFloatLinearFiltering?this._textureType=e.Engine.TEXTURETYPE_FLOAT:this._textureType=e.Engine.TEXTURETYPE_UNSIGNED_INT,this._initializeGenerator()}return Object.defineProperty(t,"FILTER_NONE",{get:function(){return t._FILTER_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FILTER_POISSONSAMPLING",{get:function(){return t._FILTER_POISSONSAMPLING},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FILTER_EXPONENTIALSHADOWMAP",{get:function(){return t._FILTER_EXPONENTIALSHADOWMAP},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FILTER_BLUREXPONENTIALSHADOWMAP",{get:function(){return t._FILTER_BLUREXPONENTIALSHADOWMAP},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FILTER_CLOSEEXPONENTIALSHADOWMAP",{get:function(){return t._FILTER_CLOSEEXPONENTIALSHADOWMAP},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FILTER_BLURCLOSEEXPONENTIALSHADOWMAP",{get:function(){return t._FILTER_BLURCLOSEEXPONENTIALSHADOWMAP},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"bias",{get:function(){return this._bias},set:function(e){this._bias=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"blurBoxOffset",{get:function(){return this._blurBoxOffset},set:function(e){this._blurBoxOffset!==e&&(this._blurBoxOffset=e,this._disposeBlurPostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"blurScale",{get:function(){return this._blurScale},set:function(e){this._blurScale!==e&&(this._blurScale=e,this._disposeBlurPostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"blurKernel",{get:function(){return this._blurKernel},set:function(e){this._blurKernel!==e&&(this._blurKernel=e,this._disposeBlurPostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useKernelBlur",{get:function(){return this._useKernelBlur},set:function(e){this._useKernelBlur!==e&&(this._useKernelBlur=e,this._disposeBlurPostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"depthScale",{get:function(){return void 0!==this._depthScale?this._depthScale:this._light.getDepthScale()},set:function(e){this._depthScale=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"filter",{get:function(){return this._filter},set:function(e){if(this._light.needCube()){if(e===t.FILTER_BLUREXPONENTIALSHADOWMAP)return void(this.useExponentialShadowMap=!0);if(e===t.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP)return void(this.useCloseExponentialShadowMap=!0)}this._filter!==e&&(this._filter=e,this._disposeBlurPostProcesses(),this._applyFilterValues(),this._light._markMeshesAsLightDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"usePoissonSampling",{get:function(){return this.filter===t.FILTER_POISSONSAMPLING},set:function(e){this.filter=e?t.FILTER_POISSONSAMPLING:t.FILTER_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useVarianceShadowMap",{get:function(){return e.Tools.Warn("VSM are now replaced by ESM. Please use useExponentialShadowMap instead."),this.useExponentialShadowMap},set:function(t){e.Tools.Warn("VSM are now replaced by ESM. Please use useExponentialShadowMap instead."),this.useExponentialShadowMap=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useBlurVarianceShadowMap",{get:function(){return e.Tools.Warn("VSM are now replaced by ESM. Please use useBlurExponentialShadowMap instead."),this.useBlurExponentialShadowMap},set:function(t){e.Tools.Warn("VSM are now replaced by ESM. Please use useBlurExponentialShadowMap instead."),this.useBlurExponentialShadowMap=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useExponentialShadowMap",{get:function(){return this.filter===t.FILTER_EXPONENTIALSHADOWMAP},set:function(e){this.filter=e?t.FILTER_EXPONENTIALSHADOWMAP:t.FILTER_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useBlurExponentialShadowMap",{get:function(){return this.filter===t.FILTER_BLUREXPONENTIALSHADOWMAP},set:function(e){this.filter=e?t.FILTER_BLUREXPONENTIALSHADOWMAP:t.FILTER_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useCloseExponentialShadowMap",{get:function(){return this.filter===t.FILTER_CLOSEEXPONENTIALSHADOWMAP},set:function(e){this.filter=e?t.FILTER_CLOSEEXPONENTIALSHADOWMAP:t.FILTER_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useBlurCloseExponentialShadowMap",{get:function(){return this.filter===t.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP},set:function(e){this.filter=e?t.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP:t.FILTER_NONE},enumerable:!0,configurable:!0}),t.prototype.getDarkness=function(){return this._darkness},t.prototype.setDarkness=function(e){return this._darkness=e>=1?1:e<=0?0:e,this},t.prototype.setTransparencyShadow=function(e){return this._transparencyShadow=e,this},t.prototype.getShadowMap=function(){return this._shadowMap},t.prototype.getShadowMapForRendering=function(){return this._shadowMap2?this._shadowMap2:this._shadowMap},t.prototype.getLight=function(){return this._light},t.prototype._initializeGenerator=function(){this._light._markMeshesAsLightDirty(),this._initializeShadowMap()},t.prototype._initializeShadowMap=function(){var t=this;this._shadowMap=new e.RenderTargetTexture(this._light.name+"_shadowMap",this._mapSize,this._scene,!1,!0,this._textureType,this._light.needCube()),this._shadowMap.wrapU=e.Texture.CLAMP_ADDRESSMODE,this._shadowMap.wrapV=e.Texture.CLAMP_ADDRESSMODE,this._shadowMap.anisotropicFilteringLevel=1,this._shadowMap.updateSamplingMode(e.Texture.BILINEAR_SAMPLINGMODE),this._shadowMap.renderParticles=!1,this._shadowMap.onBeforeRenderObservable.add((function(e){t._currentFaceIndex=e})),this._shadowMap.customRenderFunction=this._renderForShadowMap.bind(this),this._shadowMap.onAfterUnbindObservable.add((function(){(t.useBlurExponentialShadowMap||t.useBlurCloseExponentialShadowMap)&&(t._blurPostProcesses||t._initializeBlurRTTAndPostProcesses(),t._scene.postProcessManager.directRender(t._blurPostProcesses,t.getShadowMapForRendering().getInternalTexture()))})),this._shadowMap.onClearObservable.add((function(i){t.useExponentialShadowMap||t.useBlurExponentialShadowMap?i.clear(new e.Color4(0,0,0,0),!0,!0,!0):i.clear(new e.Color4(1,1,1,1),!0,!0,!0)}))},t.prototype._initializeBlurRTTAndPostProcesses=function(){var t=this,i=this._scene.getEngine(),r=this._mapSize/this.blurScale;this.useKernelBlur&&1===this.blurScale||(this._shadowMap2=new e.RenderTargetTexture(this._light.name+"_shadowMap2",r,this._scene,!1,!0,this._textureType),this._shadowMap2.wrapU=e.Texture.CLAMP_ADDRESSMODE,this._shadowMap2.wrapV=e.Texture.CLAMP_ADDRESSMODE,this._shadowMap2.updateSamplingMode(e.Texture.BILINEAR_SAMPLINGMODE)),this.useKernelBlur?(this._kernelBlurXPostprocess=new e.BlurPostProcess(this._light.name+"KernelBlurX",new e.Vector2(1,0),this.blurKernel,1,null,e.Texture.BILINEAR_SAMPLINGMODE,i,!1,this._textureType),this._kernelBlurXPostprocess.width=r,this._kernelBlurXPostprocess.height=r,this._kernelBlurXPostprocess.onApplyObservable.add((function(e){e.setTexture("textureSampler",t._shadowMap)})),this._kernelBlurYPostprocess=new e.BlurPostProcess(this._light.name+"KernelBlurY",new e.Vector2(0,1),this.blurKernel,1,null,e.Texture.BILINEAR_SAMPLINGMODE,i,!1,this._textureType),this._kernelBlurXPostprocess.autoClear=!1,this._kernelBlurYPostprocess.autoClear=!1,this._textureType===e.Engine.TEXTURETYPE_UNSIGNED_INT&&(this._kernelBlurXPostprocess.packedFloat=!0,this._kernelBlurYPostprocess.packedFloat=!0),this._blurPostProcesses=[this._kernelBlurXPostprocess,this._kernelBlurYPostprocess]):(this._boxBlurPostprocess=new e.PostProcess(this._light.name+"DepthBoxBlur","depthBoxBlur",["screenSize","boxOffset"],[],1,null,e.Texture.BILINEAR_SAMPLINGMODE,i,!1,"#define OFFSET "+this._blurBoxOffset,this._textureType),this._boxBlurPostprocess.onApplyObservable.add((function(e){e.setFloat2("screenSize",r,r),e.setTexture("textureSampler",t._shadowMap)})),this._boxBlurPostprocess.autoClear=!1,this._blurPostProcesses=[this._boxBlurPostprocess])},t.prototype._renderForShadowMap=function(e,t,i){var r;for(r=0;r=n.length)return void(e&&e(i));setTimeout(h,16)}};n.length>0&&h()},t.prototype.isReady=function(t,i){var r=[];this._textureType!==e.Engine.TEXTURETYPE_UNSIGNED_INT&&r.push("#define FLOAT"),(this.useExponentialShadowMap||this.useBlurExponentialShadowMap)&&r.push("#define ESM");var n=[e.VertexBuffer.PositionKind],o=t.getMesh(),s=t.getMaterial();if(s&&s.needAlphaTesting()){var a=s.getAlphaTestTexture();a&&(r.push("#define ALPHATEST"),o.isVerticesDataPresent(e.VertexBuffer.UVKind)&&(n.push(e.VertexBuffer.UVKind),r.push("#define UV1")),o.isVerticesDataPresent(e.VertexBuffer.UV2Kind)&&1===a.coordinatesIndex&&(n.push(e.VertexBuffer.UV2Kind),r.push("#define UV2")))}o.useBones&&o.computeBonesUsingShaders?(n.push(e.VertexBuffer.MatricesIndicesKind),n.push(e.VertexBuffer.MatricesWeightsKind),o.numBoneInfluencers>4&&(n.push(e.VertexBuffer.MatricesIndicesExtraKind),n.push(e.VertexBuffer.MatricesWeightsExtraKind)),r.push("#define NUM_BONE_INFLUENCERS "+o.numBoneInfluencers),r.push("#define BonesPerMesh "+(o.skeleton.bones.length+1))):r.push("#define NUM_BONE_INFLUENCERS 0"),i&&(r.push("#define INSTANCES"),n.push("world0"),n.push("world1"),n.push("world2"),n.push("world3"));var l=r.join("\n");return this._cachedDefines!==l&&(this._cachedDefines=l,this._effect=this._scene.getEngine().createEffect("shadowMap",n,["world","mBones","viewProjection","diffuseMatrix","lightPosition","depthValues","biasAndScale"],["diffuseSampler"],l)),this._effect.isReady()},t.prototype.prepareDefines=function(e,t){var i=this._scene,r=this._light;i.shadowsEnabled&&r.shadowEnabled&&(e["SHADOW"+t]=!0,this.usePoissonSampling?e["SHADOWPCF"+t]=!0:this.useExponentialShadowMap||this.useBlurExponentialShadowMap?e["SHADOWESM"+t]=!0:(this.useCloseExponentialShadowMap||this.useBlurCloseExponentialShadowMap)&&(e["SHADOWCLOSEESM"+t]=!0),r.needCube()&&(e["SHADOWCUBE"+t]=!0))},t.prototype.bindShadowLight=function(e,t){ +var i=this._light,r=this._scene;r.shadowsEnabled&&i.shadowEnabled&&(i.needCube()||t.setMatrix("lightMatrix"+e,this.getTransformMatrix()),t.setTexture("shadowSampler"+e,this.getShadowMapForRendering()),i._uniformBuffer.updateFloat4("shadowsInfo",this.getDarkness(),this.blurScale/this.getShadowMap().getSize().width,this.depthScale,this.frustumEdgeFalloff,e),i._uniformBuffer.updateFloat2("depthValues",this.getLight().getDepthMinZ(r.activeCamera),this.getLight().getDepthMinZ(r.activeCamera)+this.getLight().getDepthMaxZ(r.activeCamera),e))},t.prototype.getTransformMatrix=function(){var t=this._scene;if(this._currentRenderID===t.getRenderId()&&this._currentFaceIndexCache===this._currentFaceIndex)return this._transformMatrix;this._currentRenderID=t.getRenderId(),this._currentFaceIndexCache=this._currentFaceIndex;var i=this._light.position;return this._light.computeTransformedInformation()&&(i=this._light.transformedPosition),e.Vector3.NormalizeToRef(this._light.getShadowDirection(this._currentFaceIndex),this._lightDirection),1===Math.abs(e.Vector3.Dot(this._lightDirection,e.Vector3.Up()))&&(this._lightDirection.z=1e-13),!this._light.needProjectionMatrixCompute()&&this._cachedPosition&&this._cachedDirection&&i.equals(this._cachedPosition)&&this._lightDirection.equals(this._cachedDirection)||(this._cachedPosition=i.clone(),this._cachedDirection=this._lightDirection.clone(),e.Matrix.LookAtLHToRef(i,i.add(this._lightDirection),e.Vector3.Up(),this._viewMatrix),this._light.setShadowProjectionMatrix(this._projectionMatrix,this._viewMatrix,this.getShadowMap().renderList),this._viewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix)),this._transformMatrix},t.prototype.recreateShadowMap=function(){var e=this._shadowMap.renderList;this._disposeRTTandPostProcesses(),this._initializeGenerator(),this.filter=this.filter,this._applyFilterValues(),this._shadowMap.renderList=e},t.prototype._disposeBlurPostProcesses=function(){this._shadowMap2&&(this._shadowMap2.dispose(),this._shadowMap2=null),this._downSamplePostprocess&&(this._downSamplePostprocess.dispose(),this._downSamplePostprocess=null),this._boxBlurPostprocess&&(this._boxBlurPostprocess.dispose(),this._boxBlurPostprocess=null),this._kernelBlurXPostprocess&&(this._kernelBlurXPostprocess.dispose(),this._kernelBlurXPostprocess=null),this._kernelBlurYPostprocess&&(this._kernelBlurYPostprocess.dispose(),this._kernelBlurYPostprocess=null),this._blurPostProcesses=null},t.prototype._disposeRTTandPostProcesses=function(){this._shadowMap&&(this._shadowMap.dispose(),this._shadowMap=null),this._disposeBlurPostProcesses()},t.prototype.dispose=function(){this._disposeRTTandPostProcesses(),this._light._shadowGenerator=null,this._light._markMeshesAsLightDirty()},t.prototype.serialize=function(){var e={},t=this.getShadowMap();e.lightId=this._light.id,e.mapSize=t.getRenderSize(),e.useExponentialShadowMap=this.useExponentialShadowMap,e.useBlurExponentialShadowMap=this.useBlurExponentialShadowMap,e.useCloseExponentialShadowMap=this.useBlurExponentialShadowMap,e.useBlurCloseExponentialShadowMap=this.useBlurExponentialShadowMap,e.usePoissonSampling=this.usePoissonSampling,e.forceBackFacesOnly=this.forceBackFacesOnly,e.depthScale=this.depthScale,e.darkness=this.getDarkness(),e.blurBoxOffset=this.blurBoxOffset,e.blurKernel=this.blurKernel,e.blurScale=this.blurScale,e.useKernelBlur=this.useKernelBlur,e.transparencyShadow=this._transparencyShadow,e.renderList=[];for(var i=0;i-1&&void 0!==f.skeletons&&null!==f.skeletons){if(!1===m.indexOf(y.skeletonId)>-1)for(var O=0,I=f.skeletons.length;O0){for(var $=0;$0){for(var te=0;te0&&this._textureLoadingCallback(e)}this._currentScene.render()}},t.prototype.drag=function(e){e.stopPropagation(),e.preventDefault()},t.prototype.drop=function(e){ +e.stopPropagation(),e.preventDefault(),this.loadFiles(e)},t.prototype._handleFolderDrop=function(e,t,i){var r=e.createReader(),n=e.fullPath.replace(/^\//,"").replace(/(.+?)\/?$/,"$1/");r.readEntries((function(e){for(var r=e.length,o=0,s=e;o0){for(var i=[],r=[],n=0;n0&&(e.Tools.ClearLogCache(),e.Tools.Log("Babylon.js engine (v"+e.Engine.Version+") launched")),this._engine.stopRenderLoop(),this._currentScene.dispose()),e.SceneLoader.Load("file:",this._sceneFileToLoad,this._engine,(function(e){i._currentScene=e,i._currentScene.executeWhenReady((function(){i._sceneLoadedCallback&&i._sceneLoadedCallback(t._sceneFileToLoad,i._currentScene),i._engine.runRenderLoop((function(){i.renderFunction()}))}))}),(function(e){t._progressCallback&&t._progressCallback(e)}))):e.Tools.Error("Please provide a valid .babylon file.")},t})();t.FilesToLoad=new Array,e.FilesInput=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(){this._count=0,this._data={}}return e.prototype.copyFrom=function(e){var t=this;this.clear(),e.forEach((function(e,i){return t.add(e,i)}))},e.prototype.get=function(e){var t=this._data[e];if(void 0!==t)return t},e.prototype.getOrAddWithFactory=function(e,t){var i=this.get(e);return void 0!==i?i:(i=t(e),i&&this.add(e,i),i)},e.prototype.getOrAdd=function(e,t){var i=this.get(e);return void 0!==i?i:(this.add(e,t),t)},e.prototype.contains=function(e){return void 0!==this._data[e]},e.prototype.add=function(e,t){return void 0===this._data[e]&&(this._data[e]=t,++this._count,!0)},e.prototype.set=function(e,t){return void 0!==this._data[e]&&(this._data[e]=t,!0)},e.prototype.getAndRemove=function(e){var t=this.get(e);return void 0!==t?(delete this._data[e],--this._count,t):null},e.prototype.remove=function(e){return!!this.contains(e)&&(delete this._data[e],--this._count,!0)},e.prototype.clear=function(){this._data={},this._count=0},Object.defineProperty(e.prototype,"count",{get:function(){return this._count},enumerable:!0,configurable:!0}),e.prototype.forEach=function(e){for(var t in this._data){e(t,this._data[t])}},e.prototype.first=function(e){for(var t in this._data){var i=this._data[t],r=e(t,i);if(r)return r}return null},e})();e.StringDictionary=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){}return t.EnableFor=function(e){e._tags=e._tags||{},e.hasTags=function(){return t.HasTags(e)},e.addTags=function(i){return t.AddTagsTo(e,i)},e.removeTags=function(i){return t.RemoveTagsFrom(e,i)},e.matchesTagsQuery=function(i){return t.MatchesQuery(e,i)}},t.DisableFor=function(e){delete e._tags,delete e.hasTags,delete e.addTags,delete e.removeTags,delete e.matchesTagsQuery},t.HasTags=function(t){return!!t._tags&&!e.Tools.IsEmpty(t._tags)},t.GetTags=function(e,t){if(void 0===t&&(t=!0),!e._tags)return null;if(t){var i=[];for(var r in e._tags)e._tags.hasOwnProperty(r)&&!0===e._tags[r]&&i.push(r);return i.join(" ")}return e._tags},t.AddTagsTo=function(e,i){if(i&&"string"==typeof i){i.split(" ").forEach((function(i,r,n){t._AddTagTo(e,i)}))}},t._AddTagTo=function(e,i){""!==(i=i.trim())&&"true"!==i&&"false"!==i&&(i.match(/[\s]/)||i.match(/^([!]|([|]|[&]){2})/)||(t.EnableFor(e),e._tags[i]=!0))},t.RemoveTagsFrom=function(e,i){if(t.HasTags(e)){var r=i.split(" ");for(var n in r)t._RemoveTagFrom(e,r[n])}},t._RemoveTagFrom=function(e,t){delete e._tags[t]},t.MatchesQuery=function(i,r){return void 0===r||(""===r?t.HasTags(i):e.Internals.AndOrNotEvaluator.Eval(r,(function(e){return t.HasTags(i)&&i._tags[e]})))},t})();e.Tags=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(e){var t=(function(){function e(){}return e.Eval=function(t,i){return"true"===(t=t.match(/\([^\(\)]*\)/g)?t.replace(/\([^\(\)]*\)/g,(function(t){return t=t.slice(1,t.length-1),e._HandleParenthesisContent(t,i)})):e._HandleParenthesisContent(t,i))||"false"!==t&&e.Eval(t,i)},e._HandleParenthesisContent=function(t,i){i=i||function(e){return"true"===e};var r,n=t.split("||");for(var o in n)if(n.hasOwnProperty(o)){var s=e._SimplifyNegation(n[o].trim()),a=s.split("&&");if(a.length>1)for(var l=0;lo.data?(n.mustUpdateRessources=!0,r()):i(o.data):(n.mustUpdateRessources=!0,r())},s.onabort=function(e){i(-1)};var a=s.objectStore("versions").get(t);a.onsuccess=function(e){o=e.target.result},a.onerror=function(r){e.Tools.Error("Error loading version for scene "+t+" from DB."),i(-1)}}catch(t){e.Tools.Error("Error while accessing 'versions' object store (READ OP). Exception: "+t.message),i(-1)}}else e.Tools.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."),i(-1)},t.prototype._saveVersionIntoDBAsync=function(t,i){var r=this;if(this.isSupported&&!this.hasReachedQuota)try{var n=this.db.transaction(["versions"],"readwrite");n.onabort=function(e){try{e.srcElement.error&&"QuotaExceededError"===e.srcElement.error.name&&(r.hasReachedQuota=!0)}catch(e){}i(-1)},n.oncomplete=function(e){i(r.manifestVersionFound)};var o={sceneUrl:t,data:this.manifestVersionFound},s=n.objectStore("versions").put(o);s.onsuccess=function(e){},s.onerror=function(t){e.Tools.Error("Error in DB add version request in BABYLON.Database.")}}catch(t){e.Tools.Error("Error while accessing 'versions' object store (WRITE OP). Exception: "+t.message),i(-1)}else i(-1)},t.prototype.loadFileFromDB=function(e,i,r,n,o){var s=this,a=t.ReturnFullUrlLocation(e),l=function(e){s._saveFileIntoDBAsync(a,i,r)};this._checkVersionFromDB(a,(function(e){-1!==e?s.mustUpdateRessources?s._saveFileIntoDBAsync(a,i,r,o):s._loadFileFromDBAsync(a,i,l,o):n()}))},t.prototype._loadFileFromDBAsync=function(t,i,r,n){if(this.isSupported){var o;o=-1!==t.indexOf(".babylon")?"scenes":"textures";var s,a=this.db.transaction([o]);a.oncomplete=function(e){s?i(s.data):r()},a.onabort=function(e){r()};var l=a.objectStore(o).get(t);l.onsuccess=function(e){s=e.target.result},l.onerror=function(i){e.Tools.Error("Error loading file "+t+" from DB."),r()}}else e.Tools.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."),i()},t.prototype._saveFileIntoDBAsync=function(t,i,r,n){var o=this;if(this.isSupported){var s;s=-1!==t.indexOf(".babylon")?"scenes":"textures";var a,l=new XMLHttpRequest;l.open("GET",t,!0),n&&(l.responseType="arraybuffer"),l.onprogress=r,l.addEventListener("load",(function(){if(200===l.status||e.Tools.ValidateXHRData(l,n?6:1))if(a=n?l.response:l.responseText,o.hasReachedQuota)i(a);else{var r=o.db.transaction([s],"readwrite");r.onabort=function(e){try{e.srcElement.error&&"QuotaExceededError"===e.srcElement.error.name&&(o.hasReachedQuota=!0)}catch(e){}i(a)},r.oncomplete=function(e){i(a)};var h;h="scenes"===s?{sceneUrl:t,data:a,version:o.manifestVersionFound}:{textureUrl:t,data:a};try{var c=r.objectStore(s).put(h);c.onsuccess=function(e){},c.onerror=function(t){e.Tools.Error("Error in DB add file request in BABYLON.Database.")}}catch(e){i(a)}}else i()}),!1),l.addEventListener("error",(function(t){e.Tools.Error("error on XHR request."),i()}),!1),l.send()}else e.Tools.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."),i()},t})();t.IsUASupportingBlobStorage=!0,t.IDBStorageEnabled=!0,t.parseURL=function(e){document.createElement("a").href=e;var t=e.substring(0,e.lastIndexOf("#")),i=e.substring(t.lastIndexOf("/")+1,e.length);return e.substring(0,e.indexOf(i,0))},t.ReturnFullUrlLocation=function(e){return-1===e.indexOf("http:/")&&-1===e.indexOf("https:/")?t.parseURL(window.location.href)+e:e},e.Database=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this._isEnabled=!0,this.leftColor=e.Color3.White(),this.rightColor=e.Color3.Black(),this.bias=0,this.power=1}return Object.defineProperty(t.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(t){this._isEnabled!==t&&(this._isEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.FresnelDirtyFlag))},enumerable:!0,configurable:!0}),t.prototype.clone=function(){var i=new t;return e.Tools.DeepCopy(this,i),i},t.prototype.serialize=function(){var e={};return e.isEnabled=this.isEnabled,e.leftColor=this.leftColor,e.rightColor=this.rightColor,e.bias=this.bias,e.power=this.power,e},t.Parse=function(i){var r=new t;return r.isEnabled=i.isEnabled,r.leftColor=e.Color3.FromArray(i.leftColor),r.rightColor=e.Color3.FromArray(i.rightColor),r.bias=i.bias,r.power=i.power||1,r},t})();e.FresnelParameters=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e,i){var r=t.call(this,e,i,!0)||this;return i.multiMaterials.push(r),r.subMaterials=new Array,r.storeEffectOnSubMeshes=!0,r}return __extends(i,t),Object.defineProperty(i.prototype,"subMaterials",{get:function(){return this._subMaterials},set:function(e){this._subMaterials=e,this._hookArray(e)},enumerable:!0,configurable:!0}),i.prototype._hookArray=function(e){var t=this,i=e.push;e.push=function(){for(var r=[],n=0;n=this.subMaterials.length?this.getScene().defaultMaterial:this.subMaterials[e]},i.prototype.getActiveTextures=function(){return(e=t.prototype.getActiveTextures.call(this)).concat.apply(e,this.subMaterials.map((function(e){return e.getActiveTextures()})));var e},i.prototype.getClassName=function(){return"MultiMaterial"},i.prototype.isReadyForSubMesh=function(e,t,i){for(var r=0;r=0&&r.multiMaterials.splice(n,1),t.prototype.dispose.call(this,e,i)}},i})(e.Material);e.MultiMaterial=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this._offsetX=null,this._offsetY=null,this._pointerCount=0,this._pointerPressed=[],this.touchAngularSensibility=2e5,this.touchMoveSensibility=250}return t.prototype.attachControl=function(t,i){var r,n=this;void 0===this._pointerInput&&(this._onLostFocus=function(e){n._offsetX=null,n._offsetY=null},this._pointerInput=function(t,o){var s=t.event;if("mouse"!==s.pointerType)if(t.type===e.PointerEventTypes.POINTERDOWN){if(i||s.preventDefault(),n._pointerPressed.push(s.pointerId),1!==n._pointerPressed.length)return;r={x:s.clientX,y:s.clientY}}else if(t.type===e.PointerEventTypes.POINTERUP){i||s.preventDefault();var a=n._pointerPressed.indexOf(s.pointerId);if(-1===a)return;if(n._pointerPressed.splice(a,1),0!=a)return;r=null,n._offsetX=null,n._offsetY=null}else if(t.type===e.PointerEventTypes.POINTERMOVE){if(i||s.preventDefault(),!r)return;var a=n._pointerPressed.indexOf(s.pointerId);if(0!=a)return;n._offsetX=s.clientX-r.x,n._offsetY=-(s.clientY-r.y)}}),this._observer=this.camera.getScene().onPointerObservable.add(this._pointerInput,e.PointerEventTypes.POINTERDOWN|e.PointerEventTypes.POINTERUP|e.PointerEventTypes.POINTERMOVE),t.addEventListener("blur",this._onLostFocus)},t.prototype.detachControl=function(e){this._pointerInput&&e&&(this.camera.getScene().onPointerObservable.remove(this._observer),this._observer=null,e.removeEventListener("blur",this._onLostFocus),this._onLostFocus=null,this._pointerPressed=[],this._offsetX=null,this._offsetY=null,this._pointerCount=0)},t.prototype.checkInputs=function(){if(this._offsetX){var t=this.camera;if(t.cameraRotation.y+=this._offsetX/this.touchAngularSensibility,this._pointerPressed.length>1)t.cameraRotation.x+=-this._offsetY/this.touchAngularSensibility;else{var i=t._computeLocalCameraSpeed(),r=new e.Vector3(0,0,i*this._offsetY/this.touchMoveSensibility);e.Matrix.RotationYawPitchRollToRef(t.rotation.y,t.rotation.x,0,t._cameraRotationMatrix),t.cameraDirection.addInPlace(e.Vector3.TransformCoordinates(r,t._cameraRotationMatrix))}}},t.prototype.getClassName=function(){return"FreeCameraTouchInput"},t.prototype.getSimpleName=function(){return"touch"},t})();__decorate([e.serialize()],t.prototype,"touchAngularSensibility",void 0),__decorate([e.serialize()],t.prototype,"touchMoveSensibility",void 0),e.FreeCameraTouchInput=t,e.CameraInputTypes.FreeCameraTouchInput=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(e){function t(t,i,r){var n=e.call(this,t,i,r)||this;return n.inputs.addTouch(),n._setupInputs(),n}return __extends(t,e),Object.defineProperty(t.prototype,"touchAngularSensibility",{get:function(){var e=this.inputs.attached.touch;if(e)return e.touchAngularSensibility},set:function(e){var t=this.inputs.attached.touch;t&&(t.touchAngularSensibility=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"touchMoveSensibility",{get:function(){var e=this.inputs.attached.touch;if(e)return e.touchMoveSensibility},set:function(e){var t=this.inputs.attached.touch;t&&(t.touchMoveSensibility=e)},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return"TouchCamera"},t.prototype._setupInputs=function(){var e=this.inputs.attached.mouse;e&&(e.touchEnabled=!1)},t})(e.FreeCamera);e.TouchCamera=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o,s,a,l){void 0===a&&(a=!0),void 0===l&&(l=!1);var h=t.call(this,null,o,!a)||this;h.isCube=l,h.isEnabled=!0,h._currentRefreshId=-1,h._refreshRate=1,h._vertexBuffers={},h._uniforms=new Array,h._samplers=new Array,h._textures=new Array,h._floats=new Array,h._floatsArrays={},h._colors3=new Array,h._colors4=new Array,h._vectors2=new Array,h._vectors3=new Array,h._matrices=new Array,h._fallbackTextureUsed=!1,o._proceduralTextures.push(h),h.name=i,h.isRenderTarget=!0,h._size=r,h._generateMipMaps=a,h.setFragment(n),h._fallbackTexture=s;var c=o.getEngine();l?(h._texture=c.createRenderTargetCubeTexture(r,{generateMipMaps:a}),h.setFloat("face",0)):h._texture=c.createRenderTargetTexture(r,a);var u=[];u.push(1,1),u.push(-1,1),u.push(-1,-1),u.push(1,-1),h._vertexBuffers[e.VertexBuffer.PositionKind]=new e.VertexBuffer(c,u,e.VertexBuffer.PositionKind,!1,!1,2);var f=[];return f.push(0),f.push(1),f.push(2),f.push(0),f.push(2),f.push(3),h._indexBuffer=c.createIndexBuffer(f),h}return __extends(i,t),i.prototype.reset=function(){if(void 0!==this._effect){this.getScene().getEngine()._releaseEffect(this._effect)}},i.prototype.isReady=function(){var t,i=this,r=this.getScene().getEngine();return!!this._fragment&&(!!this._fallbackTextureUsed||(t=void 0!==this._fragment.fragmentElement?{vertex:"procedural",fragmentElement:this._fragment.fragmentElement}:{vertex:"procedural",fragment:this._fragment},this._effect=r.createEffect(t,[e.VertexBuffer.PositionKind],this._uniforms,this._samplers,"",null,null,(function(){i.releaseInternalTexture(),i._fallbackTexture&&(i._texture=i._fallbackTexture._texture,i._texture.references++),i._fallbackTextureUsed=!0})),this._effect.isReady()))},i.prototype.resetRefreshCounter=function(){this._currentRefreshId=-1},i.prototype.setFragment=function(e){this._fragment=e},Object.defineProperty(i.prototype,"refreshRate",{get:function(){return this._refreshRate},set:function(e){this._refreshRate=e,this.resetRefreshCounter()},enumerable:!0,configurable:!0}),i.prototype._shouldRender=function(){return!!(this.isEnabled&&this.isReady()&&this._texture)&&(!this._fallbackTextureUsed&&(-1===this._currentRefreshId?(this._currentRefreshId=1,!0):this.refreshRate===this._currentRefreshId?(this._currentRefreshId=1,!0):(this._currentRefreshId++,!1)))},i.prototype.getRenderSize=function(){return this._size},i.prototype.resize=function(e,t){this._fallbackTextureUsed||(this.releaseInternalTexture(),this._texture=this.getScene().getEngine().createRenderTargetTexture(e,t))},i.prototype._checkUniform=function(e){-1===this._uniforms.indexOf(e)&&this._uniforms.push(e)},i.prototype.setTexture=function(e,t){return-1===this._samplers.indexOf(e)&&this._samplers.push(e),this._textures[e]=t,this},i.prototype.setFloat=function(e,t){return this._checkUniform(e),this._floats[e]=t,this},i.prototype.setFloats=function(e,t){return this._checkUniform(e),this._floatsArrays[e]=t,this},i.prototype.setColor3=function(e,t){return this._checkUniform(e),this._colors3[e]=t,this},i.prototype.setColor4=function(e,t){return this._checkUniform(e),this._colors4[e]=t,this},i.prototype.setVector2=function(e,t){return this._checkUniform(e),this._vectors2[e]=t,this},i.prototype.setVector3=function(e,t){return this._checkUniform(e),this._vectors3[e]=t,this},i.prototype.setMatrix=function(e,t){return this._checkUniform(e),this._matrices[e]=t,this},i.prototype.render=function(e){var t=this.getScene(),i=t.getEngine();i.enableEffect(this._effect),i.setState(!1);for(var r in this._textures)this._effect.setTexture(r,this._textures[r]);for(r in this._floats)this._effect.setFloat(r,this._floats[r]);for(r in this._floatsArrays)this._effect.setArray(r,this._floatsArrays[r]);for(r in this._colors3)this._effect.setColor3(r,this._colors3[r]);for(r in this._colors4){var n=this._colors4[r];this._effect.setFloat4(r,n.r,n.g,n.b,n.a)}for(r in this._vectors2)this._effect.setVector2(r,this._vectors2[r]);for(r in this._vectors3)this._effect.setVector3(r,this._vectors3[r]);for(r in this._matrices)this._effect.setMatrix(r,this._matrices[r]);if(this.isCube)for(var o=0;o<6;o++)i.bindFramebuffer(this._texture,o),i.bindBuffers(this._vertexBuffers,this._indexBuffer,this._effect),this._effect.setFloat("face",o),i.clear(t.clearColor,!0,!0,!0),i.draw(!0,0,6),5===o&&i.generateMipMapsForCubemap(this._texture);else i.bindFramebuffer(this._texture),i.bindBuffers(this._vertexBuffers,this._indexBuffer,this._effect),i.clear(t.clearColor,!0,!0,!0),i.draw(!0,0,6);i.unBindFramebuffer(this._texture,this.isCube),this.onGenerated&&this.onGenerated()},i.prototype.clone=function(){var e=this.getSize(),t=new i(this.name,e.width,this._fragment,this.getScene(),this._fallbackTexture,this._generateMipMaps);return t.hasAlpha=this.hasAlpha,t.level=this.level,t.coordinatesMode=this.coordinatesMode,t},i.prototype.dispose=function(){var i=this.getScene()._proceduralTextures.indexOf(this);i>=0&&this.getScene()._proceduralTextures.splice(i,1);var r=this._vertexBuffers[e.VertexBuffer.PositionKind];r&&(r.dispose(),this._vertexBuffers[e.VertexBuffer.PositionKind]=null),this._indexBuffer&&this.getScene().getEngine()._releaseBuffer(this._indexBuffer)&&(this._indexBuffer=null),t.prototype.dispose.call(this)},i})(e.Texture);e.ProceduralTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e,i,r,n,o,s){var a=t.call(this,e,r,null,n,o,s)||this;return a._animate=!0,a._time=0,a._texturePath=i,a.loadJson(i),a.refreshRate=1,a}return __extends(i,t),i.prototype.loadJson=function(t){function i(){e.Tools.Log("No config file found in "+t+" trying to use ShadersStore or DOM element");try{n.setFragment(n._texturePath)}catch(t){e.Tools.Error("No json or ShaderStore or DOM element found for CustomProceduralTexture")}}var r=this,n=this,o=t+"/config.json",s=new XMLHttpRequest;s.open("GET",o,!0),s.addEventListener("load",(function(){if(200===s.status||e.Tools.ValidateXHRData(s,1))try{r._config=JSON.parse(s.response),r.updateShaderUniforms(),r.updateTextures(),r.setFragment(r._texturePath+"/custom"),r._animate=r._config.animate,r.refreshRate=r._config.refreshrate}catch(e){i()}else i()}),!1),s.addEventListener("error",(function(){i()}),!1);try{s.send()}catch(t){e.Tools.Error("CustomProceduralTexture: Error on XHR send request.")}},i.prototype.isReady=function(){if(!t.prototype.isReady.call(this))return!1;for(var e in this._textures){if(!this._textures[e].isReady())return!1}return!0},i.prototype.render=function(e){this._animate&&(this._time+=.03*this.getScene().getAnimationRatio(),this.updateShaderUniforms()),t.prototype.render.call(this,e)},i.prototype.updateTextures=function(){for(var t=0;t.005?0+r:0,i.y=Math.abs(n)>.005?0+n:0;var o=this.gamepad.rightStick;if(o){var s=o.x/this.gamepadAngularSensibility,a=o.y/this.gamepadAngularSensibility;o.x=Math.abs(s)>.001?0+s:0,o.y=Math.abs(a)>.001?0+a:0}else o={x:0,y:0};t.rotationQuaternion?t.rotationQuaternion.toRotationMatrix(this._cameraTransform):e.Matrix.RotationYawPitchRollToRef(t.rotation.y,t.rotation.x,0,this._cameraTransform);var l=50*t._computeLocalCameraSpeed();this._vector3.copyFromFloats(i.x*l,0,-i.y*l),e.Vector3.TransformCoordinatesToRef(this._vector3,this._cameraTransform,this._deltaTransform),t.cameraDirection.addInPlace(this._deltaTransform),this._vector2.copyFromFloats(o.y,o.x),t.cameraRotation.addInPlace(this._vector2)}},t.prototype._onNewGameConnected=function(t){t.type!==e.Gamepad.POSE_ENABLED&&(this.gamepad&&t.type!==e.Gamepad.XBOX||(this.gamepad=t))},t.prototype.getClassName=function(){return"FreeCameraGamepadInput"},t.prototype.getSimpleName=function(){return"gamepad"},t})();__decorate([e.serialize()],t.prototype,"gamepadAngularSensibility",void 0),__decorate([e.serialize()],t.prototype,"gamepadMoveSensibility",void 0),e.FreeCameraGamepadInput=t,e.CameraInputTypes.FreeCameraGamepadInput=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this.gamepadRotationSensibility=80,this.gamepadMoveSensibility=40}return t.prototype.attachControl=function(t,i){var r=this;this._gamepads=new e.Gamepads(function(e){r._onNewGameConnected(e)})},t.prototype.detachControl=function(e){this._gamepads&&this._gamepads.dispose(),this.gamepad=null},t.prototype.checkInputs=function(){if(this.gamepad){var e=this.camera,t=this.gamepad.rightStick;if(t){if(0!=t.x){var i=t.x/this.gamepadRotationSensibility;0!=i&&Math.abs(i)>.005&&(e.inertialAlphaOffset+=i)}if(0!=t.y){var r=t.y/this.gamepadRotationSensibility;0!=r&&Math.abs(r)>.005&&(e.inertialBetaOffset+=r)}}var n=this.gamepad.leftStick;if(n&&0!=n.y){var o=n.y/this.gamepadMoveSensibility;0!=o&&Math.abs(o)>.005&&(this.camera.inertialRadiusOffset-=o)}}},t.prototype._onNewGameConnected=function(t){t.type!==e.Gamepad.POSE_ENABLED&&(this.gamepad&&t.type!==e.Gamepad.XBOX||(this.gamepad=t))},t.prototype.getClassName=function(){return"ArcRotateCameraGamepadInput"},t.prototype.getSimpleName=function(){return"gamepad"},t})();__decorate([e.serialize()],t.prototype,"gamepadRotationSensibility",void 0),__decorate([e.serialize()],t.prototype,"gamepadMoveSensibility",void 0),e.ArcRotateCameraGamepadInput=t,e.CameraInputTypes.ArcRotateCameraGamepadInput=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e,t){var i=this;this.babylonGamepads=[],this.oneGamepadConnected=!1,this.isMonitoring=!1,this.gamepadEventSupported="GamepadEvent"in window,this.gamepadSupport=navigator.getGamepads||navigator.webkitGetGamepads||navigator.msGetGamepads||navigator.webkitGamepads,this._callbackGamepadConnected=e,this._callbackGamepadDisconnected=t,this.gamepadSupport&&(this._updateGamepadObjects(),this.babylonGamepads.length&&this._startMonitoringGamepads(),this.gamepadEventSupported?(this._onGamepadConnectedEvent=function(e){i._onGamepadConnected(e.gamepad)},this._onGamepadDisonnectedEvent=function(e){i._onGamepadDisconnected(e.gamepad)},window.addEventListener("gamepadconnected",this._onGamepadConnectedEvent,!1),window.addEventListener("gamepaddisconnected",this._onGamepadDisonnectedEvent,!1)):this._startMonitoringGamepads())}return t.prototype.dispose=function(){this._onGamepadConnectedEvent&&(window.removeEventListener("gamepadconnected",this._onGamepadConnectedEvent,!1),window.removeEventListener("gamepaddisconnected",this._onGamepadDisonnectedEvent,!1), +this._onGamepadConnectedEvent=null,this._onGamepadDisonnectedEvent=null),this.oneGamepadConnected=!1,this._stopMonitoringGamepads(),this.babylonGamepads=[]},t.prototype._onGamepadConnected=function(e){if(!(e.index in this.babylonGamepads)){var t=this._addNewGamepad(e);this._callbackGamepadConnected&&this._callbackGamepadConnected(t),this._startMonitoringGamepads()}},t.prototype._addNewGamepad=function(t){this.oneGamepadConnected||(this.oneGamepadConnected=!0);var i,r=-1!==t.id.search("Xbox One");return i=r||-1!==t.id.search("Xbox 360")||-1!==t.id.search("xinput")?new a(t.id,t.index,t,r):t.pose?e.PoseEnabledControllerHelper.InitiateController(t):new n(t.id,t.index,t),this.babylonGamepads.push(i),i},t.prototype._onGamepadDisconnected=function(e){for(var t in this.babylonGamepads)if(this.babylonGamepads[t].index==e.index){this.babylonGamepads.splice(+t,1);break}0==this.babylonGamepads.length&&(this._stopMonitoringGamepads(),this.oneGamepadConnected=!1),this._callbackGamepadDisconnected&&this._callbackGamepadDisconnected(e)},t.prototype._startMonitoringGamepads=function(){this.isMonitoring||(this.isMonitoring=!0,this._checkGamepadsStatus())},t.prototype._stopMonitoringGamepads=function(){this.isMonitoring=!1},t.prototype._checkGamepadsStatus=function(){var e=this;this._updateGamepadObjects();for(var t in this.babylonGamepads)this.babylonGamepads[t].update();this.isMonitoring&&(window.requestAnimationFrame?window.requestAnimationFrame((function(){e._checkGamepadsStatus()})):window.mozRequestAnimationFrame?window.mozRequestAnimationFrame((function(){e._checkGamepadsStatus()})):window.webkitRequestAnimationFrame&&window.webkitRequestAnimationFrame((function(){e._checkGamepadsStatus()})))},t.prototype._updateGamepadObjects=function(){for(var e=navigator.getGamepads?navigator.getGamepads():navigator.webkitGetGamepads?navigator.webkitGetGamepads():[],t=0;t=2&&(this._leftStick={x:this.browserGamepad.axes[this._leftStickAxisX],y:this.browserGamepad.axes[this._leftStickAxisY]}),this.browserGamepad.axes.length>=4&&(this._rightStick={x:this.browserGamepad.axes[this._rightStickAxisX],y:this.browserGamepad.axes[this._rightStickAxisY]})}return e.prototype.onleftstickchanged=function(e){this._onleftstickchanged=e},e.prototype.onrightstickchanged=function(e){this._onrightstickchanged=e},Object.defineProperty(e.prototype,"leftStick",{get:function(){return this._leftStick},set:function(e){!this._onleftstickchanged||this._leftStick.x===e.x&&this._leftStick.y===e.y||this._onleftstickchanged(e),this._leftStick=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rightStick",{get:function(){return this._rightStick},set:function(e){!this._onrightstickchanged||this._rightStick.x===e.x&&this._rightStick.y===e.y||this._onrightstickchanged(e),this._rightStick=e},enumerable:!0,configurable:!0}),e.prototype.update=function(){this._leftStick&&(this.leftStick={x:this.browserGamepad.axes[this._leftStickAxisX],y:this.browserGamepad.axes[this._leftStickAxisY]}),this._rightStick&&(this.rightStick={x:this.browserGamepad.axes[this._rightStickAxisX],y:this.browserGamepad.axes[this._rightStickAxisY]})},e})();r.GAMEPAD=0,r.GENERIC=1,r.XBOX=2,r.POSE_ENABLED=3,e.Gamepad=r;var n=(function(e){function t(t,i,n){var o=e.call(this,t,i,n)||this;return o.type=r.GENERIC,o._buttons=new Array(n.buttons.length),o}return __extends(t,e),t.prototype.onbuttondown=function(e){this._onbuttondown=e},t.prototype.onbuttonup=function(e){this._onbuttonup=e},t.prototype._setButtonValue=function(e,t,i){return e!==t&&(this._onbuttondown&&1===e&&this._onbuttondown(i),this._onbuttonup&&0===e&&this._onbuttonup(i)),e},t.prototype.update=function(){e.prototype.update.call(this);for(var t=0;tthis.maxCameraSpeed||u<-this.maxCameraSpeed)&&(u=u<1?-this.maxCameraSpeed:this.maxCameraSpeed),(f>this.maxCameraSpeed||f<-this.maxCameraSpeed)&&(f=f<1?-this.maxCameraSpeed:this.maxCameraSpeed),(d>this.maxCameraSpeed||d<-this.maxCameraSpeed)&&(d=d<1?-this.maxCameraSpeed:this.maxCameraSpeed),this.position=new e.Vector3(this.position.x+u,this.position.y+f,this.position.z+d),this.setTarget(o)}},i.prototype._checkInputs=function(){t.prototype._checkInputs.call(this),this.follow(this.lockedTarget)},i.prototype.getClassName=function(){return"FollowCamera"},i})(e.TargetCamera);__decorate([e.serialize()],t.prototype,"radius",void 0),__decorate([e.serialize()],t.prototype,"rotationOffset",void 0),__decorate([e.serialize()],t.prototype,"heightOffset",void 0),__decorate([e.serialize()],t.prototype,"cameraAcceleration",void 0),__decorate([e.serialize()],t.prototype,"maxCameraSpeed",void 0),__decorate([e.serializeAsMeshReference("lockedTargetId")],t.prototype,"lockedTarget",void 0),e.FollowCamera=t;var i=(function(t){function i(i,r,n,o,s,a){var l=t.call(this,i,e.Vector3.Zero(),a)||this;return l.alpha=r,l.beta=n,l.radius=o,l.target=s,l._cartesianCoordinates=e.Vector3.Zero(),l.follow(),l}return __extends(i,t),i.prototype.follow=function(){this._cartesianCoordinates.x=this.radius*Math.cos(this.alpha)*Math.cos(this.beta),this._cartesianCoordinates.y=this.radius*Math.sin(this.beta),this._cartesianCoordinates.z=this.radius*Math.sin(this.alpha)*Math.cos(this.beta);var e=this.target.getAbsolutePosition();this.position=e.add(this._cartesianCoordinates),this.setTarget(e)},i.prototype._checkInputs=function(){t.prototype._checkInputs.call(this),this.follow()},i.prototype.getClassName=function(){return"ArcFollowCamera"},i})(e.TargetCamera);e.ArcFollowCamera=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(e){function t(t,i,r){var n=e.call(this,t,i,r)||this;return n.inputs.addGamepad(),n}return __extends(t,e),Object.defineProperty(t.prototype,"gamepadAngularSensibility",{get:function(){var e=this.inputs.attached.gamepad;if(e)return e.gamepadAngularSensibility},set:function(e){var t=this.inputs.attached.gamepad;t&&(t.gamepadAngularSensibility=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"gamepadMoveSensibility",{get:function(){var e=this.inputs.attached.gamepad;if(e)return e.gamepadMoveSensibility},set:function(e){var t=this.inputs.attached.gamepad;t&&(t.gamepadMoveSensibility=e)},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return"UniversalCamera"},t})(e.TouchCamera);e.UniversalCamera=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(e){function t(t,i,r){return e.call(this,t,i,r)||this}return __extends(t,e),Object.defineProperty(t.prototype,"gamepadAngularSensibility",{get:function(){var e=this.inputs.attached.gamepad;if(e)return e.gamepadAngularSensibility},set:function(e){var t=this.inputs.attached.gamepad;t&&(t.gamepadAngularSensibility=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"gamepadMoveSensibility",{get:function(){var e=this.inputs.attached.gamepad;if(e)return e.gamepadMoveSensibility},set:function(e){var t=this.inputs.attached.gamepad;t&&(t.gamepadMoveSensibility=e)},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return"GamepadCamera"},t})(e.UniversalCamera);e.GamepadCamera=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(){this._renderPipelines={}}return e.prototype.addPipeline=function(e){this._renderPipelines[e._name]=e},e.prototype.attachCamerasToRenderPipeline=function(e,t,i){var r=this._renderPipelines[e];r&&r._attachCameras(t,i)},e.prototype.detachCamerasFromRenderPipeline=function(e,t){var i=this._renderPipelines[e];i&&i._detachCameras(t)},e.prototype.enableEffectInPipeline=function(e,t,i){var r=this._renderPipelines[e];r&&r._enableEffect(t,i)},e.prototype.disableEffectInPipeline=function(e,t,i){var r=this._renderPipelines[e];r&&r._disableEffect(t,i)},e.prototype.enableDisplayOnlyPassInPipeline=function(e,t,i){var r=this._renderPipelines[e];r&&r._enableDisplayOnlyPass(t,i)},e.prototype.disableDisplayOnlyPassInPipeline=function(e,t){var i=this._renderPipelines[e];i&&i._disableDisplayOnlyPass(t)},e.prototype.update=function(){for(var e in this._renderPipelines){var t=this._renderPipelines[e];t.isSupported?t._update():(t.dispose(),delete this._renderPipelines[e])}},e})();e.PostProcessRenderPipelineManager=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t,i,r,n,o,s){this._enabled=!0,this._refCount=0,this._name=i,this._renderTexture=new e.RenderTargetTexture(i,r,t),this.setRenderList(n),this._renderTexture.onBeforeRenderObservable.add(o),this._renderTexture.onAfterRenderObservable.add(s),this._scene=t,this._renderList=n}return t.prototype._incRefCount=function(){return 0===this._refCount&&this._scene.customRenderTargets.push(this._renderTexture),++this._refCount},t.prototype._decRefCount=function(){return this._refCount--,this._refCount<=0&&this._scene.customRenderTargets.splice(this._scene.customRenderTargets.indexOf(this._renderTexture),1),this._refCount},t.prototype._update=function(){this.setRenderList(this._renderList)},t.prototype.setRenderList=function(e){this._renderTexture.renderList=e},t.prototype.getRenderTexture=function(){return this._renderTexture},t})();e.PostProcessRenderPass=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e,t,i,r){this._engine=e,this._name=t,this._singleInstance=r||!0,this._getPostProcess=i,this._cameras=[],this._indicesForCamera=[],this._postProcesses={},this._renderPasses={},this._renderEffectAsPasses={}}return Object.defineProperty(t.prototype,"isSupported",{get:function(){for(var e in this._postProcesses)if(!this._postProcesses[e].isSupported)return!1;return!0},enumerable:!0,configurable:!0}),t.prototype._update=function(){for(var e in this._renderPasses)this._renderPasses[e]._update()},t.prototype.addPass=function(e){this._renderPasses[e._name]=e,this._linkParameters()},t.prototype.removePass=function(e){delete this._renderPasses[e._name],this._linkParameters()},t.prototype.addRenderEffectAsPass=function(e){this._renderEffectAsPasses[e._name]=e,this._linkParameters()},t.prototype.getPass=function(e){for(var t in this._renderPasses)if(t===e)return this._renderPasses[e]},t.prototype.emptyPasses=function(){this._renderPasses={},this._linkParameters()},t.prototype._attachCameras=function(t){for(var i,r=e.Tools.MakeArray(t||this._cameras),n=0;n4&&(o.push(e.VertexBuffer.MatricesIndicesExtraKind),o.push(e.VertexBuffer.MatricesWeightsExtraKind)),n.push("#define NUM_BONE_INFLUENCERS "+s.numBoneInfluencers),n.push("#define BonesPerMesh "+(s.skeleton.bones.length+1))):n.push("#define NUM_BONE_INFLUENCERS 0"),i&&(n.push("#define INSTANCES"),o.push("world0"),o.push("world1"),o.push("world2"),o.push("world3"));var a=n.join("\n");return this._cachedDefines!==a&&(this._cachedDefines=a,this._effect=this._scene.getEngine().createEffect("depth",o,["world","mBones","viewProjection","diffuseMatrix","depthValues"],["diffuseSampler"],a)),this._effect.isReady()},t.prototype.getDepthMap=function(){return this._depthMap},t.prototype.dispose=function(){this._depthMap.dispose()},t})();e.DepthRenderer=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o){var s=t.call(this,r.getEngine(),i)||this;s.SSAOOriginalSceneColorEffect="SSAOOriginalSceneColorEffect",s.SSAORenderEffect="SSAORenderEffect",s.SSAOBlurHRenderEffect="SSAOBlurHRenderEffect",s.SSAOBlurVRenderEffect="SSAOBlurVRenderEffect",s.SSAOCombineRenderEffect="SSAOCombineRenderEffect",s.totalStrength=1,s.radius=1e-4,s.area=.0075,s.fallOff=1e-6,s.base=.5,s._firstUpdate=!0,s._scene=r,s._createRandomTexture(),s._depthTexture=r.enableDepthRenderer().getDepthMap();var a=n.ssaoRatio||n,l=n.combineRatio||n;return s._ratio={ssaoRatio:a,combineRatio:l},s._originalColorPostProcess=new e.PassPostProcess("SSAOOriginalSceneColor",l,null,e.Texture.BILINEAR_SAMPLINGMODE,r.getEngine(),!1),s._createSSAOPostProcess(a),s._createBlurPostProcess(a),s._createSSAOCombinePostProcess(l),s.addEffect(new e.PostProcessRenderEffect(r.getEngine(),s.SSAOOriginalSceneColorEffect,function(){return s._originalColorPostProcess},!0)),s.addEffect(new e.PostProcessRenderEffect(r.getEngine(),s.SSAORenderEffect,function(){return s._ssaoPostProcess},!0)),s.addEffect(new e.PostProcessRenderEffect(r.getEngine(),s.SSAOBlurHRenderEffect,function(){return s._blurHPostProcess},!0)),s.addEffect(new e.PostProcessRenderEffect(r.getEngine(),s.SSAOBlurVRenderEffect,function(){return s._blurVPostProcess},!0)),s.addEffect(new e.PostProcessRenderEffect(r.getEngine(),s.SSAOCombineRenderEffect,function(){return s._ssaoCombinePostProcess},!0)),r.postProcessRenderPipelineManager.addPipeline(s),o&&r.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(i,o),s}return __extends(i,t),i.prototype.dispose=function(e){void 0===e&&(e=!1);for(var i=0;i1},enumerable:!0,configurable:!0}),i.prototype.dispose=function(e){void 0===e&&(e=!1);for(var i=0;i=0;a--){var o=Math.pow(3,a),l="#define LUMINANCE_DOWN_SAMPLE\n";0===a&&(l+="#define FINAL_DOWN_SAMPLER");var h=new e.PostProcess("HDRLuminanceDownSample"+a,"standard",["dsOffsets","halfDestPixelSize"],[],{width:o,height:o},null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,l,r);this.luminanceDownSamplePostProcesses.push(h)}var c=this.luminancePostProcess;this.luminanceDownSamplePostProcesses.forEach((function(i,r){var o=new Array(18);i.onApply=function(e){for(var t=0,s=-1;s<2;s++)for(var a=-1;a<2;a++)o[t]=s/c.width,o[t+1]=a/c.height,t+=2;e.setArray2("dsOffsets",o),e.setFloat("halfDestPixelSize",.5/c.width),c=r===n.luminanceDownSamplePostProcesses.length-1?n.luminancePostProcess:i},r===n.luminanceDownSamplePostProcesses.length-1&&(i.onAfterRender=function(i){var r=t.getEngine().readPixels(0,0,1,1),o=new e.Vector4(1/16581375,1/65025,1/255,1);n._hdrCurrentLuminance=(r[0]*o.x+r[1]*o.y+r[2]*o.z+r[3]*o.w)/100}),n.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRLuminanceDownSample"+r,function(){return i},!0))}))},i.prototype._createHdrPostProcess=function(t,i){var r=this;this.hdrPostProcess=new e.PostProcess("HDR","standard",["averageLuminance"],["textureAdderSampler"],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,"#define HDR",e.Engine.TEXTURETYPE_UNSIGNED_INT);var n=1,o=0,s=0;this.hdrPostProcess.onApply=function(i){if(i.setTextureFromPostProcess("textureAdderSampler",r._currentDepthOfFieldSource),o+=t.getEngine().getDeltaTime(),n<0)n=r._hdrCurrentLuminance;else{var a=(s-o)/1e3;r._hdrCurrentLuminancen-r.hdrIncreaseRate*a?n-=r.hdrIncreaseRate*a:n=r._hdrCurrentLuminance}n=e.Scalar.Clamp(n,r.hdrMinimumLuminance,1e20),i.setFloat("averageLuminance",n),s=o,r._currentDepthOfFieldSource=r.hdrFinalPostProcess},this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDR",function(){return r.hdrPostProcess},!0))},i.prototype._createLensFlarePostProcess=function(t,i){var r=this;this.lensFlarePostProcess=new e.PostProcess("HDRLensFlare","standard",["strength","ghostDispersal","haloWidth","resolution","distortionStrength"],["lensColorSampler"],i/2,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,"#define LENS_FLARE",e.Engine.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRLensFlare",function(){return r.lensFlarePostProcess},!0)),this._createBlurPostProcesses(t,i/4,2),this.lensFlareComposePostProcess=new e.PostProcess("HDRLensFlareCompose","standard",["lensStarMatrix"],["otherSampler","lensDirtSampler","lensStarSampler"],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,"#define LENS_FLARE_COMPOSE",e.Engine.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRLensFlareCompose",function(){return r.lensFlareComposePostProcess},!0));var n=new e.Vector2(0,0);this.lensFlarePostProcess.onApply=function(e){e.setTextureFromPostProcess("textureSampler",r._bloomEnabled?r.blurHPostProcesses[0]:r.originalPostProcess),e.setTexture("lensColorSampler",r.lensColorTexture),e.setFloat("strength",r.lensFlareStrength),e.setFloat("ghostDispersal",r.lensFlareGhostDispersal),e.setFloat("haloWidth",r.lensFlareHaloWidth),n.x=r.lensFlarePostProcess.width,n.y=r.lensFlarePostProcess.height,e.setVector2("resolution",n),e.setFloat("distortionStrength",r.lensFlareDistortionStrength)};var o=e.Matrix.FromValues(2,0,-1,0,0,2,-1,0,0,0,1,0,0,0,0,1),s=e.Matrix.FromValues(.5,0,.5,0,0,.5,.5,0,0,0,1,0,0,0,0,1);this.lensFlareComposePostProcess.onApply=function(t){t.setTextureFromPostProcess("otherSampler",r._currentDepthOfFieldSource),t.setTexture("lensDirtSampler",r.lensFlareDirtTexture),t.setTexture("lensStarSampler",r.lensStarTexture);var i=r._scene.activeCamera.getViewMatrix().getRow(0),n=r._scene.activeCamera.getViewMatrix().getRow(2),a=e.Vector3.Dot(i.toVector3(),new e.Vector3(1,0,0))+e.Vector3.Dot(n.toVector3(),new e.Vector3(0,0,1));a*=4;var l=e.Matrix.FromValues(.5*Math.cos(a),-Math.sin(a),0,0,Math.sin(a),.5*Math.cos(a),0,0,0,0,1,0,0,0,0,1),h=s.multiply(l).multiply(o);t.setMatrix("lensStarMatrix",h),r._currentDepthOfFieldSource=r.lensFlareFinalPostProcess}},i.prototype._createDepthOfFieldPostProcess=function(t,i){var r=this;this.depthOfFieldPostProcess=new e.PostProcess("HDRDepthOfField","standard",["distance"],["otherSampler","depthSampler"],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,"#define DEPTH_OF_FIELD",e.Engine.TEXTURETYPE_UNSIGNED_INT),this.depthOfFieldPostProcess.onApply=function(e){e.setTextureFromPostProcess("otherSampler",r._currentDepthOfFieldSource),e.setTexture("depthSampler",r._getDepthTexture()),e.setFloat("distance",r.depthOfFieldDistance)},this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRDepthOfField",function(){return r.depthOfFieldPostProcess},!0))},i.prototype._createMotionBlurPostProcess=function(t,i){var r=this;this.motionBlurPostProcess=new e.PostProcess("HDRMotionBlur","standard",["inverseViewProjection","prevViewProjection","screenSize","motionScale","motionStrength"],["depthSampler"],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,"#define MOTION_BLUR\n#define MAX_MOTION_SAMPLES "+this.motionBlurSamples.toFixed(1),e.Engine.TEXTURETYPE_UNSIGNED_INT);var n=0,o=e.Matrix.Identity(),s=e.Matrix.Identity(),a=e.Matrix.Identity(),l=e.Vector2.Zero();this.motionBlurPostProcess.onApply=function(e){a=t.getProjectionMatrix().multiply(t.getViewMatrix()),a.invertToRef(s),e.setMatrix("inverseViewProjection",s),e.setMatrix("prevViewProjection",o),o=a,l.x=r.motionBlurPostProcess.width,l.y=r.motionBlurPostProcess.height,e.setVector2("screenSize",l),n=t.getEngine().getFps()/60,e.setFloat("motionScale",n),e.setFloat("motionStrength",r.motionStrength),e.setTexture("depthSampler",r._getDepthTexture())},this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRMotionBlur",function(){return r.motionBlurPostProcess},!0))},i.prototype._getDepthTexture=function(){var e=this._scene.enableGeometryBufferRenderer();return e?e.getGBuffer().textures[0]:this._scene.enableDepthRenderer().getDepthMap()},i.prototype._disposePostProcesses=function(){for(var e=0;e4&&(o.push(e.VertexBuffer.MatricesIndicesExtraKind),o.push(e.VertexBuffer.MatricesWeightsExtraKind)),n.push("#define NUM_BONE_INFLUENCERS "+s.numBoneInfluencers),n.push("#define BonesPerMesh "+(s.skeleton.bones.length+1))):n.push("#define NUM_BONE_INFLUENCERS 0"),i&&(n.push("#define INSTANCES"),o.push("world0"),o.push("world1"),o.push("world2"),o.push("world3"));var a=n.join("\n");return this._cachedDefines!==a&&(this._cachedDefines=a,this._effect=this._scene.getEngine().createEffect("geometry",o,["world","mBones","viewProjection","diffuseMatrix","view"],["diffuseSampler"],a)),this._effect.isReady()},t.prototype.getGBuffer=function(){return this._multiRenderTarget},t.prototype.dispose=function(){this.getGBuffer().dispose()},t.prototype._createRenderTargets=function(){var t=this,i=this._scene.getEngine(),r=this._enablePosition?3:2;if(this._multiRenderTarget=new e.MultiRenderTarget("gBuffer",{width:i.getRenderWidth()*this._ratio,height:i.getRenderHeight()*this._ratio},r,this._scene,{generateMipMaps:!1,generateDepthTexture:!0}),!this.isSupported)return null;this._multiRenderTarget.wrapU=e.Texture.CLAMP_ADDRESSMODE,this._multiRenderTarget.wrapV=e.Texture.CLAMP_ADDRESSMODE,this._multiRenderTarget.refreshRate=1,this._multiRenderTarget.renderParticles=!1,this._multiRenderTarget.renderList=null,this._multiRenderTarget.onClearObservable.add((function(t){t.clear(new e.Color4(0,0,0,1),!0,!0,!0)}));var n=function(i){var r=i.getRenderingMesh(),n=t._scene,o=n.getEngine();o.setState(i.getMaterial().backFaceCulling);var s=r._getInstancesRenderList(i._id);if(!s.mustReturn){var a=o.getCaps().instancedArrays&&null!==s.visibleInstances[i._id];if(t.isReady(i,a)){o.enableEffect(t._effect),r._bind(i,t._effect,e.Material.TriangleFillMode);var l=i.getMaterial();if(t._effect.setMatrix("viewProjection",n.getTransformMatrix()),t._effect.setMatrix("view",n.getViewMatrix()),l&&l.needAlphaTesting()){var h=l.getAlphaTestTexture();t._effect.setTexture("diffuseSampler",h),t._effect.setMatrix("diffuseMatrix",h.getTextureMatrix())}r.useBones&&r.computeBonesUsingShaders&&t._effect.setMatrices("mBones",r.skeleton.getTransformMatrices(r)),r._processRendering(i,t._effect,e.Material.TriangleFillMode,s,a,(function(e,i){return t._effect.setMatrix("world",i)}))}}};this._multiRenderTarget.customRenderFunction=function(e,t){var i;for(i=0;i0&&-1!==this.excludedMeshes.indexOf(e)},i.prototype._createPass=function(t,i){var r=this,n=t.getEngine();this._volumetricLightScatteringRTT=new e.RenderTargetTexture("volumetricLightScatteringMap",{width:n.getRenderWidth()*i,height:n.getRenderHeight()*i},t,!1,!0,e.Engine.TEXTURETYPE_UNSIGNED_INT),this._volumetricLightScatteringRTT.wrapU=e.Texture.CLAMP_ADDRESSMODE,this._volumetricLightScatteringRTT.wrapV=e.Texture.CLAMP_ADDRESSMODE,this._volumetricLightScatteringRTT.renderList=null,this._volumetricLightScatteringRTT.renderParticles=!1,t.customRenderTargets.push(this._volumetricLightScatteringRTT);var o,s=function(t){var i=t.getRenderingMesh();if(!r._meshExcluded(i)){var n=i.getScene(),o=n.getEngine();o.setState(t.getMaterial().backFaceCulling);var s=i._getInstancesRenderList(t._id);if(!s.mustReturn){var a=o.getCaps().instancedArrays&&null!==s.visibleInstances[t._id];if(r.isReady(t,a)){var l=r._volumetricLightScatteringPass;if(i===r.mesh&&(l=t.effect?t.effect:t.getMaterial().getEffect()),o.enableEffect(l),i._bind(t,l,e.Material.TriangleFillMode),i===r.mesh)t.getMaterial().bind(i.getWorldMatrix(),i);else{var h=t.getMaterial();if(r._volumetricLightScatteringPass.setMatrix("viewProjection",n.getTransformMatrix()),h&&h.needAlphaTesting()){var c=h.getAlphaTestTexture();r._volumetricLightScatteringPass.setTexture("diffuseSampler",c),c&&r._volumetricLightScatteringPass.setMatrix("diffuseMatrix",c.getTextureMatrix())}i.useBones&&i.computeBonesUsingShaders&&r._volumetricLightScatteringPass.setMatrices("mBones",i.skeleton.getTransformMatrices(i))}i._processRendering(t,r._volumetricLightScatteringPass,e.Material.TriangleFillMode,s,a,(function(e,t){return l.setMatrix("world",t)}))}}}},a=new e.Color4(0,0,0,1);this._volumetricLightScatteringRTT.onBeforeRenderObservable.add((function(){o=t.clearColor,t.clearColor=a})),this._volumetricLightScatteringRTT.onAfterRenderObservable.add((function(){t.clearColor=o})),this._volumetricLightScatteringRTT.customRenderFunction=function(i,r,n){var o,a=t.getEngine();for(o=0;ot._alphaIndex?1:e._alphaIndext._distanceToCamera?-1:0})),a.setAlphaMode(e.Engine.ALPHA_COMBINE),o=0;o0)return Math.max(n,3)}return Math.max(t,3)},i.prototype._gaussianWeight=function(e){var t=Math.sqrt(2*Math.PI)*(1/3),i=-e*e/(1/3*2*(1/3));return 1/t*Math.exp(i)},i.prototype._glslFloat=function(e,t){return void 0===t&&(t=8),e.toFixed(t).replace(/0+$/,"")},i})(e.PostProcess);e.BlurPostProcess=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o,s){void 0===n&&(n=null);var a=t.call(this,i,r.getScene())||this;return a.name=i,a.children=new Array,a.animations=new Array,a._worldTransform=new e.Matrix,a._absoluteTransform=new e.Matrix,a._invertedAbsoluteTransform=new e.Matrix,a._scaleMatrix=e.Matrix.Identity(),a._scaleVector=e.Vector3.One(),a._negateScaleChildren=e.Vector3.One(),a._scalingDeterminant=1,a._skeleton=r,a._localMatrix=o||e.Matrix.Identity(),a._baseMatrix=a._localMatrix.clone(),a._restPose=s||a._localMatrix.clone(),r.bones.push(a),a.setParent(n,!1),a._updateDifferenceMatrix(),a}return __extends(i,t),Object.defineProperty(i.prototype,"_matrix",{get:function(){return this._localMatrix},set:function(e){this._localMatrix?this._localMatrix.copyFrom(e):this._localMatrix=e},enumerable:!0,configurable:!0}),i.prototype.getSkeleton=function(){return this._skeleton},i.prototype.getParent=function(){return this._parent},i.prototype.setParent=function(e,t){if(void 0===t&&(t=!0),this._parent!==e){if(this._parent){var i=this._parent.children.indexOf(this);-1!==i&&this._parent.children.splice(i)}this._parent=e,this._parent&&this._parent.children.push(this),t&&this._updateDifferenceMatrix()}},i.prototype.getLocalMatrix=function(){return this._localMatrix},i.prototype.getBaseMatrix=function(){return this._baseMatrix},i.prototype.getRestPose=function(){return this._restPose},i.prototype.returnToRest=function(){this.updateMatrix(this._restPose.clone())},i.prototype.getWorldMatrix=function(){return this._worldTransform},i.prototype.getInvertedAbsoluteTransform=function(){return this._invertedAbsoluteTransform},i.prototype.getAbsoluteTransform=function(){return this._absoluteTransform},Object.defineProperty(i.prototype,"position",{get:function(){return this.getPosition()},set:function(e){this.setPosition(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"rotation",{get:function(){return this.getRotation()},set:function(e){this.setRotation(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"rotationQuaternion",{get:function(){return this.getRotationQuaternion()},set:function(e){this.setRotationQuaternion(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"scaling",{get:function(){return this.getScale()},set:function(e){this.setScale(e.x,e.y,e.z)},enumerable:!0,configurable:!0}),i.prototype.updateMatrix=function(e,t){void 0===t&&(t=!0),this._baseMatrix=e.clone(),this._localMatrix=e.clone(),this._skeleton._markAsDirty(),t&&this._updateDifferenceMatrix()},i.prototype._updateDifferenceMatrix=function(e){e||(e=this._baseMatrix),this._parent?e.multiplyToRef(this._parent._absoluteTransform,this._absoluteTransform):this._absoluteTransform.copyFrom(e),this._absoluteTransform.invertToRef(this._invertedAbsoluteTransform);for(var t=0;t=c&&a.frame<=u&&(n?(h=a.value.clone(),m?(l=h.getTranslation(),h.setTranslation(l.scaleInPlace(g))):v?(l=h.getTranslation(),h.setTranslation(l.multiplyInPlace(o))):h=a.value):h=a.value,y.push({frame:a.frame+r,value:h}));return this.animations[0].createRange(i,c+r,u+r),!0},i.prototype.translate=function(t,r,n){void 0===r&&(r=e.Space.LOCAL);var o=this.getLocalMatrix();if(r==e.Space.LOCAL)o.m[12]+=t.x,o.m[13]+=t.y,o.m[14]+=t.z;else{var s;n&&(s=n.getWorldMatrix()),this._skeleton.computeAbsoluteTransforms();var a=i._tmpMats[0],l=i._tmpVecs[0];n?(a.copyFrom(this._parent.getAbsoluteTransform()),a.multiplyToRef(s,a)):a.copyFrom(this._parent.getAbsoluteTransform()),a.m[12]=0,a.m[13]=0,a.m[14]=0,a.invert(),e.Vector3.TransformCoordinatesToRef(t,a,l),o.m[12]+=l.x,o.m[13]+=l.y,o.m[14]+=l.z}this.markAsDirty()},i.prototype.setPosition=function(t,r,n){void 0===r&&(r=e.Space.LOCAL);var o=this.getLocalMatrix();if(r==e.Space.LOCAL)o.m[12]=t.x,o.m[13]=t.y,o.m[14]=t.z;else{var s;n&&(s=n.getWorldMatrix()),this._skeleton.computeAbsoluteTransforms();var a=i._tmpMats[0],l=i._tmpVecs[0];n?(a.copyFrom(this._parent.getAbsoluteTransform()),a.multiplyToRef(s,a)):a.copyFrom(this._parent.getAbsoluteTransform()),a.invert(),e.Vector3.TransformCoordinatesToRef(t,a,l),o.m[12]=l.x,o.m[13]=l.y,o.m[14]=l.z}this.markAsDirty()},i.prototype.setAbsolutePosition=function(t,i){this.setPosition(t,e.Space.WORLD,i)},i.prototype.setScale=function(e,t,i,r){void 0===r&&(r=!1),this.animations[0]&&!this.animations[0].isStopped()&&(r||(this._negateScaleChildren.x=1/e,this._negateScaleChildren.y=1/t,this._negateScaleChildren.z=1/i),this._syncScaleVector()),this.scale(e/this._scaleVector.x,t/this._scaleVector.y,i/this._scaleVector.z,r)},i.prototype.scale=function(t,r,n,o){void 0===o&&(o=!1);var s=this.getLocalMatrix(),a=i._tmpMats[0];a.copyFrom(s);var l=i._tmpMats[1];l.copyFrom(a),l.invert();var h=i._tmpMats[2];e.Matrix.FromValuesToRef(t,0,0,0,0,r,0,0,0,0,n,0,0,0,0,1,h),this._scaleMatrix.multiplyToRef(h,this._scaleMatrix),this._scaleVector.x*=t,this._scaleVector.y*=r,this._scaleVector.z*=n,s.multiplyToRef(l,s),s.multiplyToRef(h,s),s.multiplyToRef(a,s);var c=this.getParent();c?s.multiplyToRef(c.getAbsoluteTransform(),this.getAbsoluteTransform()):this.getAbsoluteTransform().copyFrom(s);var u=this.children.length;h.invert();for(var f=0;f0&&(this._rightHandedSystem=!0,this._bendAxis.x=0,this._bendAxis.y=0,this._bendAxis.z=-1,n.x>n.y&&n.x>n.z&&(this._adjustRoll=.5*Math.PI,this._bendAxis.z=1)),this._bone1.length){var o=this._bone1.getScale(),s=this._bone2.getScale();this._bone1Length=this._bone1.length*o.y*this.mesh.scaling.y,this._bone2Length=this._bone2.length*s.y*this.mesh.scaling.y}else if(this._bone1.children[0]){t.computeWorldMatrix(!0);var a=this._bone2.children[0].getAbsolutePosition(t),l=this._bone2.getAbsolutePosition(t),h=this._bone1.getAbsolutePosition(t);this._bone1Length=e.Vector3.Distance(a,l),this._bone2Length=e.Vector3.Distance(l,h)}this._bone1.getRotationMatrixToRef(e.Space.WORLD,t,this._bone1Mat),this.maxAngle=Math.PI,r&&(r.targetMesh&&(this.targetMesh=r.targetMesh,this.targetMesh.computeWorldMatrix(!0)),r.poleTargetMesh?(this.poleTargetMesh=r.poleTargetMesh,this.poleTargetMesh.computeWorldMatrix(!0)):r.poleTargetBone?this.poleTargetBone=r.poleTargetBone:this._bone1.getParent()&&(this.poleTargetBone=this._bone1.getParent()),r.poleTargetLocalOffset&&this.poleTargetLocalOffset.copyFrom(r.poleTargetLocalOffset),r.poleAngle&&(this.poleAngle=r.poleAngle),r.bendAxis&&this._bendAxis.copyFrom(r.bendAxis),r.maxAngle&&(this.maxAngle=r.maxAngle),r.slerpAmount&&(this.slerpAmount=r.slerpAmount))}return Object.defineProperty(t.prototype,"maxAngle",{get:function(){return this._maxAngle},set:function(e){this._setMaxAngle(e)},enumerable:!0,configurable:!0}),t.prototype._setMaxAngle=function(e){e<0&&(e=0),(e>Math.PI||void 0==e)&&(e=Math.PI),this._maxAngle=e;var t=this._bone1Length,i=this._bone2Length;this._maxReach=Math.sqrt(t*t+i*i-2*t*i*Math.cos(e))},t.prototype.update=function(){var i=this._bone1,r=this.targetPosition,n=this.poleTargetPosition,o=t._tmpMats[0],s=t._tmpMats[1];this.targetMesh&&r.copyFrom(this.targetMesh.getAbsolutePosition()),this.poleTargetBone?this.poleTargetBone.getAbsolutePositionFromLocalToRef(this.poleTargetLocalOffset,this.mesh,n):this.poleTargetMesh&&e.Vector3.TransformCoordinatesToRef(this.poleTargetLocalOffset,this.poleTargetMesh.getWorldMatrix(),n);var a=t._tmpVecs[0],l=t._tmpVecs[1],h=t._tmpVecs[2],c=t._tmpVecs[3],u=t._tmpVecs[4],f=t._tmpQuat;i.getAbsolutePositionToRef(this.mesh,a),n.subtractToRef(a,u),0==u.x&&0==u.y&&0==u.z?u.y=1:u.normalize(),r.subtractToRef(a,c),c.normalize(),e.Vector3.CrossToRef(c,u,l),l.normalize(),e.Vector3.CrossToRef(c,l,h),h.normalize(),e.Matrix.FromXYZAxesToRef(h,c,l,o);var d=this._bone1Length,p=this._bone2Length,_=e.Vector3.Distance(a,r);this._maxReach>0&&(_=Math.min(this._maxReach,_));var m=(p*p+_*_-d*d)/(2*p*_),g=(_*_+d*d-p*p)/(2*_*d);m>1&&(m=1),g>1&&(g=1),m<-1&&(m=-1),g<-1&&(g=-1);var v=Math.acos(m),y=Math.acos(g),x=-v-y;if(this._rightHandedSystem)e.Matrix.RotationYawPitchRollToRef(0,0,this._adjustRoll,s),s.multiplyToRef(o,o), +e.Matrix.RotationAxisToRef(this._bendAxis,y,s),s.multiplyToRef(o,o);else{var b=t._tmpVecs[5];b.copyFrom(this._bendAxis),b.x*=-1,e.Matrix.RotationAxisToRef(b,-y,s),s.multiplyToRef(o,o)}this.poleAngle&&(e.Matrix.RotationAxisToRef(c,this.poleAngle,s),o.multiplyToRef(s,o)),this.slerpAmount<1?(this._slerping||e.Quaternion.FromRotationMatrixToRef(this._bone1Mat,this._bone1Quat),e.Quaternion.FromRotationMatrixToRef(o,f),e.Quaternion.SlerpToRef(this._bone1Quat,f,this.slerpAmount,this._bone1Quat),x=this._bone2Ang*(1-this.slerpAmount)+x*this.slerpAmount,this._bone1.setRotationQuaternion(this._bone1Quat,e.Space.WORLD,this.mesh),this._slerping=!0):(this._bone1.setRotationMatrix(o,e.Space.WORLD,this.mesh),this._bone1Mat.copyFrom(o),this._slerping=!1),this._bone2.setAxisAngle(this._bendAxis,x,e.Space.LOCAL),this._bone2Ang=x},t})();t._tmpVecs=[e.Vector3.Zero(),e.Vector3.Zero(),e.Vector3.Zero(),e.Vector3.Zero(),e.Vector3.Zero(),e.Vector3.Zero()],t._tmpQuat=e.Quaternion.Identity(),t._tmpMats=[e.Matrix.Identity(),e.Matrix.Identity()],e.BoneIKController=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t,i,r,n){if(this.upAxis=e.Vector3.Up(),this.upAxisSpace=e.Space.LOCAL,this.adjustYaw=0,this.adjustPitch=0,this.adjustRoll=0,this.slerpAmount=1,this._boneQuat=e.Quaternion.Identity(),this._slerping=!1,this._firstFrameSkipped=!1,this._fowardAxis=e.Vector3.Forward(),this.mesh=t,this.bone=i,this.target=r,n&&(n.adjustYaw&&(this.adjustYaw=n.adjustYaw),n.adjustPitch&&(this.adjustPitch=n.adjustPitch),n.adjustRoll&&(this.adjustRoll=n.adjustRoll),null!=n.maxYaw?this.maxYaw=n.maxYaw:this.maxYaw=Math.PI,null!=n.minYaw?this.minYaw=n.minYaw:this.minYaw=-Math.PI,null!=n.maxPitch?this.maxPitch=n.maxPitch:this.maxPitch=Math.PI,null!=n.minPitch?this.minPitch=n.minPitch:this.minPitch=-Math.PI,null!=n.slerpAmount&&(this.slerpAmount=n.slerpAmount),null!=n.upAxis&&(this.upAxis=n.upAxis),null!=n.upAxisSpace&&(this.upAxisSpace=n.upAxisSpace),null!=n.yawAxis||null!=n.pitchAxis)){var o=e.Axis.Y,s=e.Axis.X;null!=n.yawAxis&&(o=n.yawAxis.clone(),o.normalize()),null!=n.pitchAxis&&(s=n.pitchAxis.clone(),s.normalize());var a=e.Vector3.Cross(s,o);this._transformYawPitch=e.Matrix.Identity(),e.Matrix.FromXYZAxesToRef(s,o,a,this._transformYawPitch),this._transformYawPitchInv=this._transformYawPitch.clone(),this._transformYawPitch.invert()}i.getParent()||this.upAxisSpace!=e.Space.BONE||(this.upAxisSpace=e.Space.LOCAL)}return Object.defineProperty(t.prototype,"minYaw",{get:function(){return this._minYaw},set:function(e){this._minYaw=e,this._minYawSin=Math.sin(e),this._minYawCos=Math.cos(e),null!=this._maxYaw&&(this._midYawConstraint=.5*this._getAngleDiff(this._minYaw,this._maxYaw)+this._minYaw,this._yawRange=this._maxYaw-this._minYaw)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"maxYaw",{get:function(){return this._maxYaw},set:function(e){this._maxYaw=e,this._maxYawSin=Math.sin(e),this._maxYawCos=Math.cos(e),null!=this._minYaw&&(this._midYawConstraint=.5*this._getAngleDiff(this._minYaw,this._maxYaw)+this._minYaw,this._yawRange=this._maxYaw-this._minYaw)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"minPitch",{get:function(){return this._minPitch},set:function(e){this._minPitch=e,this._minPitchTan=Math.tan(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"maxPitch",{get:function(){return this._maxPitch},set:function(e){this._maxPitch=e,this._maxPitchTan=Math.tan(e)},enumerable:!0,configurable:!0}),t.prototype.update=function(){if(this.slerpAmount<1&&!this._firstFrameSkipped)return void(this._firstFrameSkipped=!0);var i=this.bone,r=t._tmpVecs[0];i.getAbsolutePositionToRef(this.mesh,r);var n=this.target,o=t._tmpMats[0],s=t._tmpMats[1],a=this.mesh,l=i.getParent(),h=t._tmpVecs[1];h.copyFrom(this.upAxis),this.upAxisSpace==e.Space.BONE?(this._transformYawPitch&&e.Vector3.TransformCoordinatesToRef(h,this._transformYawPitchInv,h),l.getDirectionToRef(h,this.mesh,h)):this.upAxisSpace==e.Space.LOCAL&&(a.getDirectionToRef(h,h),1==a.scaling.x&&1==a.scaling.y&&1==a.scaling.z||h.normalize());var c=!1,u=!1;if(this._maxYaw==Math.PI&&this._minYaw==-Math.PI||(c=!0),this._maxPitch==Math.PI&&this._minPitch==-Math.PI||(u=!0),c||u){var f=t._tmpMats[2],d=t._tmpMats[3];if(this.upAxisSpace==e.Space.BONE&&1==h.y)l.getRotationMatrixToRef(e.Space.WORLD,this.mesh,f);else if(this.upAxisSpace!=e.Space.LOCAL||1!=h.y||l){var p=t._tmpVecs[2];p.copyFrom(this._fowardAxis),this._transformYawPitch&&e.Vector3.TransformCoordinatesToRef(p,this._transformYawPitchInv,p),l?l.getDirectionToRef(p,this.mesh,p):a.getDirectionToRef(p,p);var _=e.Vector3.Cross(h,p);_.normalize();var p=e.Vector3.Cross(_,h);e.Matrix.FromXYZAxesToRef(_,h,p,f)}else f.copyFrom(a.getWorldMatrix());f.invertToRef(d);var m;if(u){var g=t._tmpVecs[3];n.subtractToRef(r,g),e.Vector3.TransformCoordinatesToRef(g,d,g);var m=Math.sqrt(g.x*g.x+g.z*g.z),v=Math.atan2(g.y,m),y=v;v>this._maxPitch?(g.y=this._maxPitchTan*m,y=this._maxPitch):vthis._maxYaw||xMath.PI?this._isAngleBetween(x,this._maxYaw,this._midYawConstraint)?(g.z=this._maxYawCos*m,g.x=this._maxYawSin*m,b=this._maxYaw):this._isAngleBetween(x,this._midYawConstraint,this._minYaw)&&(g.z=this._minYawCos*m,g.x=this._minYawSin*m,b=this._minYaw):x>this._maxYaw?(g.z=this._maxYawCos*m,g.x=this._maxYawSin*m,b=this._maxYaw):xMath.PI){var A=t._tmpVecs[8];A.copyFrom(e.Axis.Z),this._transformYawPitch&&e.Vector3.TransformCoordinatesToRef(A,this._transformYawPitchInv,A);var T=e.BoneLookController._tmpMats[4];this._boneQuat.toRotationMatrix(T),this.mesh.getWorldMatrix().multiplyToRef(T,T),e.Vector3.TransformCoordinatesToRef(A,T,A),e.Vector3.TransformCoordinatesToRef(A,d,A);var E=Math.atan2(A.x,A.z);if(this._getAngleBetween(E,x)>this._getAngleBetween(E,this._midYawConstraint)){null==m&&(m=Math.sqrt(g.x*g.x+g.z*g.z));var P=this._getAngleBetween(E,this._maxYaw);this._getAngleBetween(E,this._minYaw)Math.PI?i-=2*Math.PI:i<-Math.PI&&(i+=2*Math.PI),i},t.prototype._getAngleBetween=function(e,t){e%=2*Math.PI,e=e<0?e+2*Math.PI:e,t%=2*Math.PI,t=t<0?t+2*Math.PI:t;var i=0;return i=eMath.PI&&(i=2*Math.PI-i),i},t.prototype._isAngleBetween=function(e,t,i){if(e%=2*Math.PI,e=e<0?e+2*Math.PI:e,t%=2*Math.PI,t=t<0?t+2*Math.PI:t,i%=2*Math.PI,i=i<0?i+2*Math.PI:i,tt&&ei&&e-1&&this._meshesWithPoseMatrix.splice(t,1)},t.prototype._computeTransformMatrices=function(e,t){this.onBeforeComputeObservable.notifyObservers(this);for(var i=0;i0&&(r.animation=i.animations[0].serialize()),e.ranges=[];for(var n in this._ranges){var o={};o.name=n,o.from=this._ranges[n].from,o.to=this._ranges[n].to,e.ranges.push(o)}}return e},t.Parse=function(i,r){var n=new t(i.name,i.id,r);i.dimensionsAtRest&&(n.dimensionsAtRest=e.Vector3.FromArray(i.dimensionsAtRest)),n.needInitialSkinMatrix=i.needInitialSkinMatrix;var o;for(o=0;o-1&&(a=n.bones[s.parentBoneIndex]);var l=s.rest?e.Matrix.FromArray(s.rest):null,h=new e.Bone(s.name,n,a,e.Matrix.FromArray(s.matrix),l);s.length&&(h.length=s.length),s.animation&&h.animations.push(e.Animation.Parse(s.animation))}if(i.ranges)for(o=0;o0&&(e=this._meshesWithPoseMatrix[0].getPoseMatrix()),e},t})();e.Skeleton=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this.x=e.Vector3.Zero(),this.y=e.Vector3.Zero(),this.z=e.Vector3.Zero(),this.xx=e.Vector3.Zero(),this.yy=e.Vector3.Zero(),this.zz=e.Vector3.Zero(),this.xy=e.Vector3.Zero(),this.yz=e.Vector3.Zero(),this.zx=e.Vector3.Zero()}return t.prototype.addAmbient=function(t){var i=new e.Vector3(t.r,t.g,t.b);this.xx=this.xx.add(i),this.yy=this.yy.add(i),this.zz=this.zz.add(i)},t.getSphericalPolynomialFromHarmonics=function(e){var i=new t;return i.x=e.L11.scale(1.02333),i.y=e.L1_1.scale(1.02333),i.z=e.L10.scale(1.02333),i.xx=e.L00.scale(.886277).subtract(e.L20.scale(.247708)).add(e.L22.scale(.429043)),i.yy=e.L00.scale(.886277).subtract(e.L20.scale(.247708)).subtract(e.L22.scale(.429043)),i.zz=e.L00.scale(.886277).add(e.L20.scale(.495417)),i.yz=e.L2_1.scale(.858086),i.zx=e.L21.scale(.858086),i.xy=e.L2_2.scale(.858086),i.scale(1/Math.PI),i},t.prototype.scale=function(e){this.x=this.x.scale(e),this.y=this.y.scale(e),this.z=this.z.scale(e),this.xx=this.xx.scale(e),this.yy=this.yy.scale(e),this.zz=this.zz.scale(e),this.yz=this.yz.scale(e),this.zx=this.zx.scale(e),this.xy=this.xy.scale(e)},t})();e.SphericalPolynomial=t;var i=(function(){function t(){this.L00=e.Vector3.Zero(),this.L1_1=e.Vector3.Zero(),this.L10=e.Vector3.Zero(),this.L11=e.Vector3.Zero(),this.L2_2=e.Vector3.Zero(),this.L2_1=e.Vector3.Zero(),this.L20=e.Vector3.Zero(),this.L21=e.Vector3.Zero(),this.L22=e.Vector3.Zero()}return t.prototype.addLight=function(t,i,r){var n=new e.Vector3(i.r,i.g,i.b),o=n.scale(r);this.L00=this.L00.add(o.scale(.282095)),this.L1_1=this.L1_1.add(o.scale(.488603*t.y)),this.L10=this.L10.add(o.scale(.488603*t.z)),this.L11=this.L11.add(o.scale(.488603*t.x)),this.L2_2=this.L2_2.add(o.scale(1.092548*t.x*t.y)),this.L2_1=this.L2_1.add(o.scale(1.092548*t.y*t.z)),this.L21=this.L21.add(o.scale(1.092548*t.x*t.z)),this.L20=this.L20.add(o.scale(.315392*(3*t.z*t.z-1))),this.L22=this.L22.add(o.scale(.546274*(t.x*t.x-t.y*t.y)))},t.prototype.scale=function(e){this.L00=this.L00.scale(e),this.L1_1=this.L1_1.scale(e),this.L10=this.L10.scale(e),this.L11=this.L11.scale(e),this.L2_2=this.L2_2.scale(e),this.L2_1=this.L2_1.scale(e),this.L20=this.L20.scale(e),this.L21=this.L21.scale(e),this.L22=this.L22.scale(e)},t.prototype.convertIncidentRadianceToIrradiance=function(){this.L00=this.L00.scale(3.141593),this.L1_1=this.L1_1.scale(2.094395),this.L10=this.L10.scale(2.094395),this.L11=this.L11.scale(2.094395),this.L2_2=this.L2_2.scale(.785398),this.L2_1=this.L2_1.scale(.785398),this.L20=this.L20.scale(.785398),this.L21=this.L21.scale(.785398),this.L22=this.L22.scale(.785398)},t.prototype.convertIrradianceToLambertianRadiance=function(){this.scale(1/Math.PI)},t.getsphericalHarmonicsFromPolynomial=function(e){var i=new t;return i.L00=e.xx.scale(.376127).add(e.yy.scale(.376127)).add(e.zz.scale(.376126)),i.L1_1=e.y.scale(.977204),i.L10=e.z.scale(.977204),i.L11=e.x.scale(.977204),i.L2_2=e.xy.scale(1.16538),i.L2_1=e.yz.scale(1.16538),i.L20=e.zz.scale(1.34567).subtract(e.xx.scale(.672834)).subtract(e.yy.scale(.672834)),i.L21=e.zx.scale(1.16538),i.L22=e.xx.scale(1.16538).subtract(e.yy.scale(1.16538)),i.scale(Math.PI),i},t})();e.SphericalHarmonics=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){var i=(function(){function e(e,t,i,r){this.name=e,this.worldAxisForNormal=t,this.worldAxisForFileX=i,this.worldAxisForFileY=r}return e})(),r=(function(){function t(){}return t.ConvertCubeMapTextureToSphericalPolynomial=function(t){if(!t.isCube)return null;var i,r,n=t.getSize().width,o=t.readPixels(0),s=t.readPixels(1);t.isRenderTarget?(i=t.readPixels(3),r=t.readPixels(2)):(i=t.readPixels(2),r=t.readPixels(3));var a=t.readPixels(4),l=t.readPixels(5),h=t.gammaSpace,c=e.Engine.TEXTUREFORMAT_RGBA,u=e.Engine.TEXTURETYPE_UNSIGNED_INT;t.textureType&&t.textureType!==e.Engine.TEXTURETYPE_UNSIGNED_INT&&(u=e.Engine.TEXTURETYPE_FLOAT);var f={size:n,right:o,left:s,up:i,down:r,front:a,back:l,format:c,type:u,gammaSpace:h};return this.ConvertCubeMapToSphericalPolynomial(f)},t.ConvertCubeMapToSphericalPolynomial=function(t){for(var i=new e.SphericalHarmonics,r=0,n=2/t.size,o=n,s=.5*n-1,a=0;a<6;a++)for(var l=this.FileFaces[a],h=t[l.name],c=s,u=t.format===e.Engine.TEXTUREFORMAT_RGBA?4:3,f=0;fMath.PI;)n-=2*Math.PI;var s=n/Math.PI,a=o/Math.PI;s=.5*s+.5;var l=Math.round(s*i);l<0?l=0:l>=i&&(l=i-1);var h=Math.round(a*r);h<0?h=0:h>=r&&(h=r-1);var c=r-h-1;return{r:t[c*i*3+3*l+0],g:t[c*i*3+3*l+1],b:t[c*i*3+3*l+2]}},t})();i.FACE_FRONT=[new e.Vector3(-1,-1,-1),new e.Vector3(1,-1,-1),new e.Vector3(-1,1,-1),new e.Vector3(1,1,-1)],i.FACE_BACK=[new e.Vector3(1,-1,1),new e.Vector3(-1,-1,1),new e.Vector3(1,1,1),new e.Vector3(-1,1,1)],i.FACE_RIGHT=[new e.Vector3(1,-1,-1),new e.Vector3(1,-1,1),new e.Vector3(1,1,-1),new e.Vector3(1,1,1)],i.FACE_LEFT=[new e.Vector3(-1,-1,1),new e.Vector3(-1,-1,-1),new e.Vector3(-1,1,1),new e.Vector3(-1,1,-1)],i.FACE_DOWN=[new e.Vector3(-1,1,-1),new e.Vector3(1,1,-1),new e.Vector3(-1,1,1),new e.Vector3(1,1,1)],i.FACE_UP=[new e.Vector3(-1,-1,1),new e.Vector3(1,-1,1),new e.Vector3(-1,-1,-1),new e.Vector3(1,-1,-1)],t.PanoramaToCubeMapTools=i})(e.Internals||(e.Internals={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(e){var t=(function(){function t(){}return t.Ldexp=function(e,t){return t>1023?e*Math.pow(2,1023)*Math.pow(2,t-1023):t<-1074?e*Math.pow(2,-1074)*Math.pow(2,t+1074):e*Math.pow(2,t)},t.Rgbe2float=function(e,t,i,r,n,o){n>0?(n=this.Ldexp(1,n-136),e[o+0]=t*n,e[o+1]=i*n,e[o+2]=r*n):(e[o+0]=0,e[o+1]=0,e[o+2]=0)},t.readStringLine=function(e,t){for(var i="",r="",n=t;n32767)throw"HDR Bad header format, unsupported size";return s+=r.length+1,{height:t,width:i,dataPosition:s}},t.GetCubeMapTextureData=function(t,i){var r=new Uint8Array(t),n=this.RGBE_ReadHeader(r),o=this.RGBE_ReadPixels_RLE(r,n);return e.PanoramaToCubeMapTools.ConvertPanoramaToCubemap(o,n.width,n.height,i)},t.RGBE_ReadPixels=function(e,t){return this.RGBE_ReadPixels_RLE(e,t)},t.RGBE_ReadPixels_RLE=function(e,t){for(var i,r,n,o,s,a=t.height,l=t.width,h=t.dataPosition,c=0,u=0,f=0,d=new ArrayBuffer(4*l),p=new Uint8Array(d),_=new ArrayBuffer(t.width*t.height*4*3),m=new Float32Array(_);a>0;){if(i=e[h++],r=e[h++],n=e[h++],o=e[h++],2!=i||2!=r||128&n)throw"HDR Bad header format, not RLE";if((n<<8|o)!=l)throw"HDR Bad header format, wrong scan line width";for(c=0,f=0;f<4;f++)for(u=(f+1)*l;c128){if(0==(s=i-128)||s>u-c)throw"HDR Bad Format, bad scanline data (run)";for(;s-- >0;)p[c++]=r}else{if(0==(s=i)||s>u-c)throw"HDR Bad Format, bad scanline data (non-run)";if(p[c++]=r,--s>0)for(var g=0;g>s,2),l=0;l<6;l++){var h=r.subarray(o,o+a);n[s].push(h),o+=a}}return n}:null,o=function(o){var s=new Int32Array(o);r=new Float32Array(o);var a=s[0];t._size=s[1],t.getScene().getEngine().updateTextureSize(t._texture,t._size,t._size);var l=new e.SphericalPolynomial;l.x.copyFromFloats(r[2],r[3],r[4]),l.y.copyFromFloats(r[5],r[6],r[7]),l.z.copyFromFloats(r[8],r[9],r[10]),l.xx.copyFromFloats(r[11],r[12],r[13]),l.yy.copyFromFloats(r[14],r[15],r[16]),l.zz.copyFromFloats(r[17],r[18],r[19]),l.xy.copyFromFloats(r[20],r[21],r[22]),l.yz.copyFromFloats(r[23],r[24],r[25]),l.zx.copyFromFloats(r[26],r[27],r[28]),t.sphericalPolynomial=l,i=s[29];for(var h=30,c=[],u=3*Math.pow(t._size,2),f=0;f<6;f++)c.push(r.subarray(h,h+u)),h+=u;for(var d=[],p=null,_=0;_<6;_++){var m=null;if(1===a){m=c[[0,2,4,1,3,5][_]]}if(!n){if(!t.getScene().getEngine().getCaps().textureFloat){var g=new ArrayBuffer(u);p=new Uint8Array(g)}for(var v=0;v255){var T=255/A;y*=T,x*=T,b*=T}p[3*v+0]=y,p[3*v+1]=x,p[3*v+2]=b}}p?d.push(p):d.push(m)}return d};this._texture=this.getScene().getEngine().createRawCubeTextureFromUrl(this.url,this.getScene(),this._size,e.Engine.TEXTUREFORMAT_RGB,this.getScene().getEngine().getCaps().textureFloat?e.Engine.TEXTURETYPE_FLOAT:e.Engine.TEXTURETYPE_UNSIGNED_INT,this._noMipmap,o,n,this._onLoad,this._onError)},i.prototype.loadHDRTexture=function(){var t=this,r=function(r){var n=e.Internals.HDRTools.GetCubeMapTextureData(r,t._size);if(t._generateHarmonics){var o=e.Internals.CubeMapToSphericalPolynomialTools.ConvertCubeMapToSphericalPolynomial(n);t.sphericalPolynomial=o}for(var s=[],a=null,l=0;l<6;l++){if(!t.getScene().getEngine().getCaps().textureFloat){var h=new ArrayBuffer(t._size*t._size*3);a=new Uint8Array(h)}var c=n[i._facesMapping[l]];if(t._useInGammaSpace||a)for(var u=0;u255){var m=255/_;f*=m,d*=m,p*=m}a[3*u+0]=f,a[3*u+1]=d,a[3*u+2]=p}a?s.push(a):s.push(c)}return s};this._texture=this.getScene().getEngine().createRawCubeTextureFromUrl(this.url,this.getScene(),this._size,e.Engine.TEXTUREFORMAT_RGB,this.getScene().getEngine().getCaps().textureFloat?e.Engine.TEXTURETYPE_FLOAT:e.Engine.TEXTURETYPE_UNSIGNED_INT,this._noMipmap,r,null,this._onLoad,this._onError)},i.prototype.loadTexture=function(){this._isBABYLONPreprocessed?this.loadBabylonTexture():this.loadHDRTexture()},i.prototype.clone=function(){var e=this._isBABYLONPreprocessed?null:this._size,t=new i(this.url,this.getScene(),e,this._noMipmap,this._generateHarmonics,this._useInGammaSpace,this._usePMREMGenerator);return t.level=this.level,t.wrapU=this.wrapU,t.wrapV=this.wrapV,t.coordinatesIndex=this.coordinatesIndex,t.coordinatesMode=this.coordinatesMode,t},i.prototype.delayLoad=function(){this.delayLoadState===e.Engine.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=e.Engine.DELAYLOADSTATE_LOADED,this._texture=this._getFromCache(this.url,this._noMipmap),this._texture||this.loadTexture())},i.prototype.getReflectionTextureMatrix=function(){return this._textureMatrix},i.prototype.setReflectionTextureMatrix=function(e){this._textureMatrix=e},i.Parse=function(t,i,r){var n=null;if(t.name&&!t.isRenderTarget){var o=t.isBABYLONPreprocessed?null:t.size;n=new e.HDRCubeTexture(r+t.name,i,o,t.noMipmap,t.generateHarmonics,t.useInGammaSpace,t.usePMREMGenerator),n.name=t.name,n.hasAlpha=t.hasAlpha,n.level=t.level,n.coordinatesMode=t.coordinatesMode,n.isBlocking=t.isBlocking}return n},i.prototype.serialize=function(){if(!this.name)return null;var e={};return e.name=this.name,e.hasAlpha=this.hasAlpha,e.isCube=!0,e.level=this.level,e.size=this._size,e.coordinatesMode=this.coordinatesMode,e.useInGammaSpace=this._useInGammaSpace,e.generateHarmonics=this._generateHarmonics,e.usePMREMGenerator=this._usePMREMGenerator,e.isBABYLONPreprocessed=this._isBABYLONPreprocessed,e.customType="BABYLON.HDRCubeTexture",e.noMipmap=this._noMipmap,e.isBlocking=this._isBlocking,e},i.generateBabylonHDROnDisk=function(e,t,r){void 0===r&&(r=null);var n=function(e){var t=new Blob([e],{type:"application/octet-stream"}),i=window.URL.createObjectURL(t),r=document.createElement("a");document.body.appendChild(r),r.style.display="none",r.href=i,r.download="envmap.babylon.hdr",r.click()};i.generateBabylonHDR(e,t,n,r)},i.generateBabylonHDR=function(t,i,r,n){return void 0===n&&(n=null),t&&e.Tools.IsExponentOfTwo(i)?(e.Tools.Error("Generation of Babylon HDR is coming back in 3.1."),null):null},i +})(e.BaseTexture);t._facesMapping=["right","left","up","down","front","back"],e.HDRCubeTexture=t})(BABYLON||(BABYLON={}));var Earcut;!(function(e){function t(e,t,r){r=r||2;var o=t&&t.length,s=o?t[0]*r:e.length,a=i(e,0,s,r,!0),l=[];if(!a)return l;var c,u,f,d,p,_,m;if(o&&(a=h(e,t,a,r)),e.length>80*r){c=f=e[0],u=d=e[1];for(var g=r;gf&&(f=p),_>d&&(d=_);m=Math.max(f-c,d-u)}return n(a,l,r,c,u,m,void 0),l}function i(e,t,i,r,n){var o,s;if(n===O(e,t,i,r)>0)for(o=t;o=t;o-=r)s=M(o,e[o],e[o+1],s);return s&&x(s,s.next)&&(S(s),s=s.next),s}function r(e,t){if(!e)return e;t||(t=e);var i,r=e;do{if(i=!1,r.steiner||!x(r,r.next)&&0!==y(r.prev,r,r.next))r=r.next;else{if(S(r),(r=t=r.prev)===r.next)return null;i=!0}}while(i||r!==t);return t}function n(e,t,i,h,c,u,f){if(e){!f&&u&&d(e,h,c,u);for(var p,_,m=e;e.prev!==e.next;)if(p=e.prev,_=e.next,u?s(e,h,c,u):o(e))t.push(p.i/i),t.push(e.i/i),t.push(_.i/i),S(e),e=_.next,m=_.next;else if((e=_)===m){f?1===f?(e=a(e,t,i),n(e,t,i,h,c,u,2)):2===f&&l(e,t,i,h,c,u):n(r(e,void 0),t,i,h,c,u,1);break}}}function o(e){var t=e.prev,i=e,r=e.next;if(y(t,i,r)>=0)return!1;for(var n=e.next.next;n!==e.prev;){if(g(t.x,t.y,i.x,i.y,r.x,r.y,n.x,n.y)&&y(n.prev,n,n.next)>=0)return!1;n=n.next}return!0}function s(e,t,i,r){var n=e.prev,o=e,s=e.next;if(y(n,o,s)>=0)return!1;for(var a=n.xo.x?n.x>s.x?n.x:s.x:o.x>s.x?o.x:s.x,c=n.y>o.y?n.y>s.y?n.y:s.y:o.y>s.y?o.y:s.y,u=_(a,l,t,i,r),f=_(h,c,t,i,r),d=e.nextZ;d&&d.z<=f;){if(d!==e.prev&&d!==e.next&&g(n.x,n.y,o.x,o.y,s.x,s.y,d.x,d.y)&&y(d.prev,d,d.next)>=0)return!1;d=d.nextZ}for(d=e.prevZ;d&&d.z>=u;){if(d!==e.prev&&d!==e.next&&g(n.x,n.y,o.x,o.y,s.x,s.y,d.x,d.y)&&y(d.prev,d,d.next)>=0)return!1;d=d.prevZ}return!0}function a(e,t,i){var r=e;do{var n=r.prev,o=r.next.next;!x(n,o)&&b(n,r,r.next,o)&&T(n,o)&&T(o,n)&&(t.push(n.i/i),t.push(r.i/i),t.push(o.i/i),S(r),S(r.next),r=e=o),r=r.next}while(r!==e);return r}function l(e,t,i,o,s,a){var l=e;do{for(var h=l.next.next;h!==l.prev;){if(l.i!==h.i&&v(l,h)){var c=P(l,h);return l=r(l,l.next),c=r(c,c.next),n(l,t,i,o,s,a,void 0),void n(c,t,i,o,s,a,void 0)}h=h.next}l=l.next}while(l!==e)}function h(e,t,n,o){var s,a,l,h,f,d=[];for(s=0,a=t.length;s=r.next.y){var a=r.x+(o-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(a<=n&&a>s){if(s=a,a===n){if(o===r.y)return r;if(o===r.next.y)return r.next}i=r.x=r.x&&r.x>=c&&g(oi.x)&&T(r,e)&&(i=r,f=l),r=r.next;return i}function d(e,t,i,r){var n=e;do{null===n.z&&(n.z=_(n.x,n.y,t,i,r)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next}while(n!==e);n.prevZ.nextZ=null,n.prevZ=null,p(n)}function p(e){var t,i,r,n,o,s,a,l,h=1;do{for(i=e,e=null,o=null,s=0;i;){for(s++,r=i,a=0,t=0;t0||l>0&&r;)0===a?(n=r,r=r.nextZ,l--):0!==l&&r?i.z<=r.z?(n=i,i=i.nextZ,a--):(n=r,r=r.nextZ,l--):(n=i,i=i.nextZ,a--),o?o.nextZ=n:e=n,n.prevZ=o,o=n;i=r}o.nextZ=null,h*=2}while(s>1);return e}function _(e,t,i,r,n){return e=32767*(e-i)/n,t=32767*(t-r)/n,e=16711935&(e|e<<8),e=252645135&(e|e<<4),e=858993459&(e|e<<2),e=1431655765&(e|e<<1),t=16711935&(t|t<<8),t=252645135&(t|t<<4),t=858993459&(t|t<<2),t=1431655765&(t|t<<1),e|t<<1}function m(e){var t=e,i=e;do{t.x=0&&(e-s)*(r-a)-(i-s)*(t-a)>=0&&(i-s)*(o-a)-(n-s)*(r-a)>=0}function v(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!A(e,t)&&T(e,t)&&T(t,e)&&E(e,t)}function y(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function x(e,t){return e.x===t.x&&e.y===t.y}function b(e,t,i,r){return!!(x(e,t)&&x(i,r)||x(e,r)&&x(i,t))||y(e,t,i)>0!=y(e,t,r)>0&&y(i,r,e)>0!=y(i,r,t)>0}function A(e,t){var i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&b(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}function T(e,t){return y(e.prev,e,e.next)<0?y(e,t,e.next)>=0&&y(e,e.prev,t)>=0:y(e,t,e.prev)<0||y(e,e.next,t)<0}function E(e,t){var i=e,r=!1,n=(e.x+t.x)/2,o=(e.y+t.y)/2;do{i.y>o!=i.next.y>o&&n<(i.next.x-i.x)*(o-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next}while(i!==e);return r}function P(e,t){var i=new C(e.i,e.x,e.y),r=new C(t.i,t.x,t.y),n=e.next,o=t.prev;return e.next=t,t.prev=e,i.next=n,n.prev=i,r.next=i,i.prev=r,o.next=r,r.prev=o,r}function M(e,t,i,r){var n=new C(e,t,i);return r?(n.next=r.next,n.prev=r,r.next.prev=n,r.next=n):(n.prev=n,n.next=n),n}function S(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function C(e,t,i){this.i=e,this.x=t,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function R(e,t,i,r){var n=t&&t.length,o=n?t[0]*i:e.length,s=Math.abs(O(e,0,o,i));if(n)for(var a=0,l=t.length;a0&&(r+=e[n-1].length,i.holes.push(r))}return i}e.earcut=t,e.deviation=R,e.flatten=I})(Earcut||(Earcut={}));var BABYLON;!(function(e){var t=(function(e){function t(t,i){var r=e.call(this,t.x,t.y)||this;return r.index=i,r}return __extends(t,e),t})(e.Vector2),i=(function(){function i(){this.elements=new Array}return i.prototype.add=function(e){var i=this,r=new Array;return e.forEach((function(e){if(0===r.length||!e.equalsWithEpsilon(r[0])){var n=new t(e,i.elements.length);r.push(n),i.elements.push(n)}})),r},i.prototype.computeBounds=function(){var t=new e.Vector2(this.elements[0].x,this.elements[0].y),i=new e.Vector2(this.elements[0].x,this.elements[0].y);return this.elements.forEach((function(e){e.xi.x&&(i.x=e.x),e.yi.y&&(i.y=e.y)})),{min:t,max:i,width:i.x-t.x,height:i.y-t.y}},i})(),r=(function(){function t(){}return t.Rectangle=function(t,i,r,n){return[new e.Vector2(t,i),new e.Vector2(r,i),new e.Vector2(r,n),new e.Vector2(t,n)]},t.Circle=function(t,i,r,n){void 0===i&&(i=0),void 0===r&&(r=0),void 0===n&&(n=32);for(var o=new Array,s=0,a=2*Math.PI/n,l=0;l0){var f=s.length/3;this._points.elements.forEach((function(e){o.push(0,-1,0),s.push(e.x,-i,e.y),a.push(1-(e.x-l.min.x)/l.width,1-(e.y-l.min.y)/l.height)}));for(var d=h.length,u=0;us.elements.length-1?s.elements[0]:s.elements[u+1],t.push(d.x,0,d.y),t.push(d.x,-a,d.y),t.push(f.x,0,f.y),t.push(f.x,-a,f.y);var p=new e.Vector3(d.x,0,d.y),_=new e.Vector3(f.x,0,f.y),m=_.subtract(p),g=new e.Vector3(0,1,0),v=e.Vector3.Cross(m,g);v=v.normalize(),r.push(c/o.width,0),r.push(c/o.width,1),c+=m.length(),r.push(c/o.width,0),r.push(c/o.width,1),l?(i.push(v.x,v.y,v.z),i.push(v.x,v.y,v.z),i.push(v.x,v.y,v.z),i.push(v.x,v.y,v.z),n.push(h),n.push(h+2),n.push(h+1),n.push(h+1),n.push(h+2),n.push(h+3)):(i.push(-v.x,-v.y,-v.z),i.push(-v.x,-v.y,-v.z),i.push(-v.x,-v.y,-v.z),i.push(-v.x,-v.y,-v.z),n.push(h),n.push(h+1),n.push(h+2),n.push(h+1),n.push(h+3),n.push(h+2)),h+=4}},t})();e.PolygonMeshBuilder=n})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=0,i=(function(){function t(e,t,i){this.pos=e,this.normal=t,this.uv=i}return t.prototype.clone=function(){return new t(this.pos.clone(),this.normal.clone(),this.uv.clone())},t.prototype.flip=function(){this.normal=this.normal.scale(-1)},t.prototype.interpolate=function(i,r){return new t(e.Vector3.Lerp(this.pos,i.pos,r),e.Vector3.Lerp(this.normal,i.normal,r),e.Vector2.Lerp(this.uv,i.uv,r))},t})(),r=(function(){function t(e,t){this.normal=e,this.w=t}return t.FromPoints=function(i,r,n){var o=n.subtract(i),s=r.subtract(i);if(0===o.lengthSquared()||0===s.lengthSquared())return null;var a=e.Vector3.Normalize(e.Vector3.Cross(o,s));return new t(a,e.Vector3.Dot(a,i))},t.prototype.clone=function(){return new t(this.normal.clone(),this.w)},t.prototype.flip=function(){this.normal.scaleInPlace(-1),this.w=-this.w},t.prototype.splitPolygon=function(i,r,o,s,a){var l,h,c=0,u=[];for(l=0;lt.EPSILON?1:0;c|=f,u.push(f)}switch(c){case 0:(e.Vector3.Dot(this.normal,i.plane.normal)>0?r:o).push(i);break;case 1:s.push(i);break;case 2:a.push(i);break;case 3:var d=[],p=[];for(l=0;l=3&&(b=new n(d,i.shared),b.plane&&s.push(b)),p.length>=3&&(b=new n(p,i.shared),b.plane&&a.push(b))}},t})();r.EPSILON=1e-5;var n=(function(){function e(e,t){this.vertices=e,this.shared=t,this.plane=r.FromPoints(e[0].pos,e[1].pos,e[2].pos)}return e.prototype.clone=function(){return new e(this.vertices.map((function(e){return e.clone()})),this.shared)},e.prototype.flip=function(){this.vertices.reverse().map((function(e){e.flip()})),this.plane.flip()},e})(),o=(function(){function e(e){this.plane=null,this.front=null,this.back=null,this.polygons=[],e&&this.build(e)}return e.prototype.clone=function(){var t=new e;return t.plane=this.plane&&this.plane.clone(),t.front=this.front&&this.front.clone(),t.back=this.back&&this.back.clone(),t.polygons=this.polygons.map((function(e){return e.clone()})),t},e.prototype.invert=function(){for(var e=0;e0&&(t.x-=this.viewportBorder,t.y-=this.viewportBorder,t.width+=2*this.viewportBorder,t.height+=2*this.viewportBorder,i.x+=this.viewportBorder,i.y+=this.viewportBorder,this._positionX+=this.viewportBorder,this._positionY+=this.viewportBorder),i.z>0&&(this._positionX>t.x&&this._positionXt.y&&(this._positionY,t.y,t.height),!0)},t.prototype._isVisible=function(){if(!this._isEnabled)return!1;var t=this.getEmitterPosition(),i=t.subtract(this._scene.activeCamera.globalPosition),r=i.length();i.normalize();var n=new e.Ray(this._scene.activeCamera.globalPosition,i),o=this._scene.pickWithRay(n,this.meshesSelectionPredicate,!0);return!o.hit||o.distance>r},t.prototype.render=function(){if(!this._effect.isReady())return!1;var t=this._scene.getEngine(),i=this._scene.activeCamera.viewport,r=i.toGlobal(t.getRenderWidth(!0),t.getRenderHeight(!0));if(!this.computeEffectivePosition(r))return!1;if(!this._isVisible())return!1;var n,o;n=this._positionXr.x+r.width-this.borderLimit?this._positionX-r.x-r.width+this.borderLimit:0,o=this._positionYr.y+r.height-this.borderLimit?this._positionY-r.y-r.height+this.borderLimit:0;var s=n>o?n:o;(s-=this.viewportBorder)>this.borderLimit&&(s=this.borderLimit);var a=1-s/this.borderLimit;if(a<0)return!1;a>1&&(a=1),this.viewportBorder>0&&(r.x+=this.viewportBorder,r.y+=this.viewportBorder,r.width-=2*this.viewportBorder,r.height-=2*this.viewportBorder,this._positionX-=this.viewportBorder,this._positionY-=this.viewportBorder);var l=r.x+r.width/2,h=r.y+r.height/2,c=l-this._positionX,u=h-this._positionY;t.enableEffect(this._effect),t.setState(!1),t.setDepthBuffer(!1),t.bindBuffers(this._vertexBuffers,this._indexBuffer,this._effect);for(var f=0;f-1?this._onBeforePhysicsStepCallbacks.splice(i,1):e.Tools.Warn("Function to remove was not found")},t.prototype.registerAfterPhysicsStep=function(e){this._onAfterPhysicsStepCallbacks.push(e)},t.prototype.unregisterAfterPhysicsStep=function(t){var i=this._onAfterPhysicsStepCallbacks.indexOf(t);i>-1?this._onAfterPhysicsStepCallbacks.splice(i,1):e.Tools.Warn("Function to remove was not found")},t.prototype.registerOnPhysicsCollide=function(e,t){ +var i=e instanceof Array?e:[e];this._onPhysicsCollideCallbacks.push({callback:t,otherImpostors:i})},t.prototype.unregisterOnPhysicsCollide=function(t,i){var r=t instanceof Array?t:[t],n=this._onPhysicsCollideCallbacks.indexOf({callback:i,otherImpostors:r});n>-1?this._onPhysicsCollideCallbacks.splice(n,1):e.Tools.Warn("Function to remove was not found")},t.prototype.applyForce=function(e,t){this._physicsEngine.getPhysicsPlugin().applyForce(this,e,t)},t.prototype.applyImpulse=function(e,t){this._physicsEngine.getPhysicsPlugin().applyImpulse(this,e,t)},t.prototype.createJoint=function(t,i,r){var n=new e.PhysicsJoint(i,r);this.addJoint(t,n)},t.prototype.addJoint=function(e,t){this._joints.push({otherImpostor:e,joint:t}),this._physicsEngine.addJoint(this,e,t)},t.prototype.sleep=function(){this._physicsEngine.getPhysicsPlugin().sleepBody(this)},t.prototype.wakeUp=function(){this._physicsEngine.getPhysicsPlugin().wakeUpBody(this)},t.prototype.clone=function(e){return e?new t(e,this.type,this._options,this._scene):null},t.prototype.dispose=function(){var e=this;this._physicsEngine&&(this._joints.forEach((function(t){e._physicsEngine.removeJoint(e,t.otherImpostor,t.joint)})),this._physicsEngine.removeImpostor(this),this.parent&&this.parent.forceUpdate(),this._isDisposed=!0)},t.prototype.setDeltaPosition=function(e){this._deltaPosition.copyFrom(e)},t.prototype.setDeltaRotation=function(t){this._deltaRotation||(this._deltaRotation=new e.Quaternion),this._deltaRotation.copyFrom(t),this._deltaRotationConjugated=this._deltaRotation.conjugate()},t.prototype.getBoxSizeToRef=function(e){this._physicsEngine.getPhysicsPlugin().getBoxSizeToRef(this,e)},t.prototype.getRadius=function(){return this._physicsEngine.getPhysicsPlugin().getRadius(this)},t.prototype.syncBoneWithImpostor=function(i,r,n,o,s){var a=t._tmpVecs[0],l=this.object;if(s){var h=t._tmpQuat;l.rotationQuaternion.multiplyToRef(s,h),i.setRotationQuaternion(h,e.Space.WORLD,r)}else i.setRotationQuaternion(l.rotationQuaternion,e.Space.WORLD,r);a.x=0,a.y=0,a.z=0,n&&(a.x=n.x,a.y=n.y,a.z=n.z,i.getDirectionToRef(a,r,a),void 0!==o&&null!==o||(o=n.length()),a.x*=o,a.y*=o,a.z*=o),i.getParent()?(a.addInPlace(l.getAbsolutePosition()),i.setAbsolutePosition(a,r)):(r.setAbsolutePosition(l.getAbsolutePosition()),r.position.x-=a.x,r.position.y-=a.y,r.position.z-=a.z)},t.prototype.syncImpostorWithBone=function(i,r,n,o,s,a){var l=this.object;if(s){var h=t._tmpQuat;i.getRotationQuaternionToRef(e.Space.WORLD,r,h),h.multiplyToRef(s,l.rotationQuaternion)}else i.getRotationQuaternionToRef(e.Space.WORLD,r,l.rotationQuaternion);var c=t._tmpVecs[0],u=t._tmpVecs[1];a||(a=t._tmpVecs[2],a.x=0,a.y=1,a.z=0),i.getDirectionToRef(a,r,u),i.getAbsolutePositionToRef(r,c),void 0!==o&&null!==o||!n||(o=n.length()),void 0!==o&&null!==o&&(c.x+=u.x*o,c.y+=u.y*o,c.z+=u.z*o),l.setAbsolutePosition(c)},t})();t.DEFAULT_OBJECT_SIZE=new e.Vector3(1,1,1),t.IDENTITY_QUATERNION=e.Quaternion.Identity(),t._tmpVecs=[e.Vector3.Zero(),e.Vector3.Zero(),e.Vector3.Zero()],t._tmpQuat=e.Quaternion.Identity(),t.NoImpostor=0,t.SphereImpostor=1,t.BoxImpostor=2,t.PlaneImpostor=3,t.MeshImpostor=4,t.CylinderImpostor=7,t.ParticleImpostor=8,t.HeightmapImpostor=9,e.PhysicsImpostor=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t,i){if(void 0===i&&(i=new e.CannonJSPlugin),this._physicsPlugin=i,this._impostors=[],this._joints=[],!this._physicsPlugin.isSupported())throw new Error("Physics Engine "+this._physicsPlugin.name+" cannot be found. Please make sure it is included.");t=t||new e.Vector3(0,-9.807,0),this.setGravity(t),this.setTimeStep()}return t.prototype.setGravity=function(e){this.gravity=e,this._physicsPlugin.setGravity(this.gravity)},t.prototype.setTimeStep=function(e){void 0===e&&(e=1/60),this._physicsPlugin.setTimeStep(e)},t.prototype.dispose=function(){this._impostors.forEach((function(e){e.dispose()})),this._physicsPlugin.dispose()},t.prototype.getPhysicsPluginName=function(){return this._physicsPlugin.name},t.prototype.addImpostor=function(e){e.uniqueId=this._impostors.push(e),e.parent||this._physicsPlugin.generatePhysicsBody(e)},t.prototype.removeImpostor=function(e){var t=this._impostors.indexOf(e);if(t>-1){var i=this._impostors.splice(t,1);i.length&&(i[0].physicsBody=null)}},t.prototype.addJoint=function(e,t,i){var r={mainImpostor:e,connectedImpostor:t,joint:i};i.physicsPlugin=this._physicsPlugin,this._joints.push(r),this._physicsPlugin.generateJoint(r)},t.prototype.removeJoint=function(e,t,i){var r=this._joints.filter((function(r){return r.connectedImpostor===t&&r.joint===i&&r.mainImpostor===e}));r.length&&this._physicsPlugin.removeJoint(r[0])},t.prototype._step=function(e){var t=this;this._impostors.forEach((function(e){e.isBodyInitRequired()&&t._physicsPlugin.generatePhysicsBody(e)})),e>.1?e=.1:e<=0&&(e=1/60),this._physicsPlugin.executeStep(e,this._impostors)},t.prototype.getPhysicsPlugin=function(){return this._physicsPlugin},t.prototype.getImpostorForPhysicsObject=function(e){for(var t=0;tr.length)return void e.Tools.Error("Unable to load TGA file - Not enough data");n+=o.id_length;var s=!1,a=!1,l=!1;switch(o.image_type){case t._TYPE_RLE_INDEXED:s=!0;case t._TYPE_INDEXED:a=!0;break;case t._TYPE_RLE_RGB:s=!0;case t._TYPE_RGB:!0;break;case t._TYPE_RLE_GREY:s=!0;case t._TYPE_GREY:l=!0}var h,c,u=(o.flags,o.pixel_size>>3),f=o.width*o.height*u;if(a&&(c=r.subarray(n,n+=o.colormap_length*(o.colormap_size>>3))),s){h=new Uint8Array(f);for(var d,p,_,m=0,g=new Uint8Array(u);n>t._ORIGIN_SHIFT){default:case t._ORIGIN_UL:v=0,x=1,T=o.width,y=0,b=1,A=o.height;break;case t._ORIGIN_BL:v=0,x=1,T=o.width,y=o.height-1,b=-1,A=-1;break;case t._ORIGIN_UR:v=o.width-1,x=-1,T=-1,y=0,b=1,A=o.height;break;case t._ORIGIN_BR:v=o.width-1,x=-1,T=-1,y=o.height-1,b=-1,A=-1}var E="_getImageData"+(l?"Grey":"")+o.pixel_size+"bits",P=t[E](o,c,h,y,b,A,v,x,T);i.texImage2D(i.TEXTURE_2D,0,i.RGBA,o.width,o.height,0,i.RGBA,i.UNSIGNED_BYTE,P)},t._getImageData8bits=function(e,t,i,r,n,o,s,a,l){var h,c,u,f=i,d=t,p=e.width,_=e.height,m=0,g=new Uint8Array(p*_*4);for(u=r;u!==o;u+=n)for(c=s;c!==l;c+=a,m++)h=f[m],g[4*(c+p*u)+3]=255,g[4*(c+p*u)+2]=d[3*h+0],g[4*(c+p*u)+1]=d[3*h+1],g[4*(c+p*u)+0]=d[3*h+2];return g},t._getImageData16bits=function(e,t,i,r,n,o,s,a,l){var h,c,u,f=i,d=e.width,p=e.height,_=0,m=new Uint8Array(d*p*4);for(u=r;u!==o;u+=n)for(c=s;c!==l;c+=a,_+=2)h=f[_+0]+(f[_+1]<<8),m[4*(c+d*u)+0]=(31744&h)>>7,m[4*(c+d*u)+1]=(992&h)>>2,m[4*(c+d*u)+2]=(31&h)>>3,m[4*(c+d*u)+3]=32768&h?0:255;return m},t._getImageData24bits=function(e,t,i,r,n,o,s,a,l){var h,c,u=i,f=e.width,d=e.height,p=0,_=new Uint8Array(f*d*4);for(c=r;c!==o;c+=n)for(h=s;h!==l;h+=a,p+=3)_[4*(h+f*c)+3]=255,_[4*(h+f*c)+2]=u[p+0],_[4*(h+f*c)+1]=u[p+1],_[4*(h+f*c)+0]=u[p+2];return _},t._getImageData32bits=function(e,t,i,r,n,o,s,a,l){var h,c,u=i,f=e.width,d=e.height,p=0,_=new Uint8Array(f*d*4);for(c=r;c!==o;c+=n)for(h=s;h!==l;h+=a,p+=4)_[4*(h+f*c)+2]=u[p+0],_[4*(h+f*c)+1]=u[p+1],_[4*(h+f*c)+0]=u[p+2],_[4*(h+f*c)+3]=u[p+3];return _},t._getImageDataGrey8bits=function(e,t,i,r,n,o,s,a,l){var h,c,u,f=i,d=e.width,p=e.height,_=0,m=new Uint8Array(d*p*4);for(u=r;u!==o;u+=n)for(c=s;c!==l;c+=a,_++)h=f[_],m[4*(c+d*u)+0]=h,m[4*(c+d*u)+1]=h,m[4*(c+d*u)+2]=h,m[4*(c+d*u)+3]=255;return m},t._getImageDataGrey16bits=function(e,t,i,r,n,o,s,a,l){var h,c,u=i,f=e.width,d=e.height,p=0,_=new Uint8Array(f*d*4);for(c=r;c!==o;c+=n)for(h=s;h!==l;h+=a,p+=2)_[4*(h+f*c)+0]=u[p+0],_[4*(h+f*c)+1]=u[p+0],_[4*(h+f*c)+2]=u[p+0],_[4*(h+f*c)+3]=u[p+1];return _},t})();i._TYPE_NO_DATA=0,i._TYPE_INDEXED=1,i._TYPE_RGB=2,i._TYPE_GREY=3,i._TYPE_RLE_INDEXED=9,i._TYPE_RLE_RGB=10,i._TYPE_RLE_GREY=11,i._ORIGIN_MASK=48,i._ORIGIN_SHIFT=4,i._ORIGIN_BL=0,i._ORIGIN_BR=1,i._ORIGIN_UL=2,i._ORIGIN_UR=3,t.TGATools=i})(e.Internals||(e.Internals={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){function i(e){return e.charCodeAt(0)+(e.charCodeAt(1)<<8)+(e.charCodeAt(2)<<16)+(e.charCodeAt(3)<<24)}function r(e){return String.fromCharCode(255&e,e>>8&255,e>>16&255,e>>24&255)}var n=i("DXT1"),o=i("DXT3"),s=i("DXT5"),a=i("DX10"),l=(function(){function t(){}return t.GetDDSInfo=function(t){var i=new Int32Array(t,0,31),r=new Int32Array(t,0,35),l=1;131072&i[2]&&(l=Math.max(1,i[7]));var h=i[21],c=h===a?r[32]:0,u=e.Engine.TEXTURETYPE_UNSIGNED_INT;switch(h){case 113:u=e.Engine.TEXTURETYPE_HALF_FLOAT;break;case 116:u=e.Engine.TEXTURETYPE_FLOAT;break;case a:if(10===c){u=e.Engine.TEXTURETYPE_HALF_FLOAT;break}}return{width:i[4],height:i[3],mipmapCount:l,isFourCC:4==(4&i[20]),isRGB:64==(64&i[20]),isLuminance:131072==(131072&i[20]),isCube:512==(512&i[28]),isCompressed:h===n||h===o||n===s,dxgiFormat:c,textureType:u}},t._ToHalfFloat=function(e){t._FloatView||(t._FloatView=new Float32Array(1),t._Int32View=new Int32Array(t._FloatView.buffer)),t._FloatView[0]=e;var i=t._Int32View[0],r=i>>16&32768,n=i>>12&2047,o=i>>23&255;return o<103?r:o>142?(r|=31744,r|=(255==o?0:1)&&8388607&i):o<113?(n|=2048,r|=(n>>114-o)+(n>>113-o&1)):(r|=o-112<<10|n>>1,r+=1&n)},t._FromHalfFloat=function(e){var t=(32768&e)>>15,i=(31744&e)>>10,r=1023&e;return 0===i?(t?-1:1)*Math.pow(2,-14)*(r/Math.pow(2,10)):31==i?r?NaN:1/0*(t?-1:1):(t?-1:1)*Math.pow(2,i-15)*(1+r/Math.pow(2,10))},t._GetHalfFloatAsFloatRGBAArrayBuffer=function(e,i,r,n,o,s){for(var a=new Float32Array(n),l=new Uint16Array(o,r),h=0,c=0;c>8&65280|e>>24&255},t.prototype.uploadLevels=function(e,i){switch(this.loadType){case t.COMPRESSED_2D:this._upload2DCompressedLevels(e,i);break;case t.TEX_2D:case t.COMPRESSED_3D:case t.TEX_3D:}},t.prototype._upload2DCompressedLevels=function(e,i){for(var r=t.HEADER_LEN+this.bytesOfKeyValueData,n=this.pixelWidth,o=this.pixelHeight,s=i?this.numberOfMipmapLevels:1,a=0;a0?this._firstFree=this._freeEntries[this._freeEntries.length-1].offset:this._firstFree+=this._stride),e},e.prototype.freeElement=function(e){this._firstFree=Math.min(e.offset,this._firstFree),this._freeEntries.push(e)},e.prototype.pack=function(){if(0===this._freeEntries.length)return this.buffer;if(this._lastUsed=a);h++){var c=r[h],u=c.offset,f=u-l;if(f!==e){for(var d=f/e-1,p=u-e,_=Math.min(s,d),m=0;m<_;m++){var g=o/e,v=p/e,y=n[v];this._moveElement(y,o);var x=n[g];x.offset=p,n[g]=y,n[v]=x,p-=e,o+=e}s<=d?(o=p+e,s=1+_):s=(u-o)/e+1,l=u}else++s,l=u}var b=this.buffer.subarray(0,o);return this._lastUsed=o-e,this._firstFree=o,r.pop(),this._freeEntries=r.sort((function(e,t){return t.offset-e.offset})),this._allEntries=n,b},e.prototype._moveElement=function(e,t){for(var i=0;i=0;s--){var a=t[s],l=a.getParent();if(l){var h=this._debugLines[n];h||(h=[e.Vector3.Zero(),e.Vector3.Zero()],this._debugLines[n]=h),a.getAbsolutePositionToRef(this.mesh,h[0]),l.getAbsolutePositionToRef(this.mesh,h[1]),h[0].subtractInPlace(o),h[1].subtractInPlace(o),n++}}},t.prototype.update=function(){this.autoUpdateBonesMatrices&&this.skeleton.computeAbsoluteTransforms(),void 0===this.skeleton.bones[0].length?this._getLinesForBonesNoLength(this.skeleton.bones,this.mesh.getWorldMatrix()):this._getLinesForBonesWithLength(this.skeleton.bones,this.mesh.getWorldMatrix()),this._debugMesh?e.MeshBuilder.CreateLineSystem(null,{lines:this._debugLines,updatable:!0,instance:this._debugMesh},this._scene):(this._debugMesh=e.MeshBuilder.CreateLineSystem(null,{lines:this._debugLines,updatable:!0},this._scene),this._debugMesh.renderingGroupId=this.renderingGroupId),this._debugMesh.position.copyFrom(this.mesh.position),this._debugMesh.color=this.color},t.prototype.dispose=function(){this._debugMesh&&(this.isEnabled=!1,this._debugMesh.dispose(),this._debugMesh=null)},t})();t.SkeletonViewer=i})(e.Debug||(e.Debug={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){var i=(function(){function t(t,i){void 0===i&&(i=1),this._xline=[e.Vector3.Zero(),e.Vector3.Zero()],this._yline=[e.Vector3.Zero(),e.Vector3.Zero()],this._zline=[e.Vector3.Zero(),e.Vector3.Zero()],this.scaleLines=1,this.scaleLines=i,this._xmesh=e.Mesh.CreateLines("xline",this._xline,t,!0),this._ymesh=e.Mesh.CreateLines("yline",this._yline,t,!0),this._zmesh=e.Mesh.CreateLines("zline",this._zline,t,!0),this._xmesh.renderingGroupId=2,this._ymesh.renderingGroupId=2,this._zmesh.renderingGroupId=2,this._xmesh.material.checkReadyOnlyOnce=!0,this._xmesh.color=new e.Color3(1,0,0),this._ymesh.material.checkReadyOnlyOnce=!0,this._ymesh.color=new e.Color3(0,1,0),this._zmesh.material.checkReadyOnlyOnce=!0,this._zmesh.color=new e.Color3(0,0,1),this.scene=t}return t.prototype.update=function(t,i,r,n){var o=this.scaleLines;this._xmesh.position.copyFrom(t),this._ymesh.position.copyFrom(t),this._zmesh.position.copyFrom(t);var s=this._xline[1];s.x=i.x*o,s.y=i.y*o,s.z=i.z*o,e.Mesh.CreateLines(null,this._xline,null,null,this._xmesh),s=this._yline[1],s.x=r.x*o,s.y=r.y*o,s.z=r.z*o,e.Mesh.CreateLines(null,this._yline,null,null,this._ymesh),s=this._zline[1],s.x=n.x*o,s.y=n.y*o,s.z=n.z*o,e.Mesh.CreateLines(null,this._zline,null,null,this._zmesh)},t.prototype.dispose=function(){this._xmesh&&(this._xmesh.dispose(),this._ymesh.dispose(),this._zmesh.dispose(),this._xmesh=null,this._ymesh=null,this._zmesh=null,this._xline=null,this._yline=null,this._zline=null,this.scene=null)},t})();t.AxesViewer=i})(e.Debug||(e.Debug={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){var i=(function(t){function i(i,r,n,o){void 0===o&&(o=1);var s=t.call(this,i,o)||this;return s.pos=e.Vector3.Zero(),s.xaxis=e.Vector3.Zero(),s.yaxis=e.Vector3.Zero(),s.zaxis=e.Vector3.Zero(),s.mesh=n,s.bone=r,s}return __extends(i,t),i.prototype.update=function(){var i=this.bone;i.getAbsolutePositionToRef(this.mesh,this.pos),i.getDirectionToRef(e.Axis.X,this.mesh,this.xaxis),i.getDirectionToRef(e.Axis.Y,this.mesh,this.yaxis),i.getDirectionToRef(e.Axis.Z,this.mesh,this.zaxis),t.prototype.update.call(this,this.pos,this.xaxis,this.yaxis,this.zaxis)},i.prototype.dispose=function(){this.pos&&(this.pos=null,this.xaxis=null,this.yaxis=null,this.zaxis=null,this.mesh=null,this.bone=null,t.prototype.dispose.call(this))},i})(t.AxesViewer);t.BoneAxesViewer=i})(e.Debug||(e.Debug={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e){this.ray=e}return t.CreateAndShow=function(e,i,r){var n=new t(e);return n.show(i,r),n},t.prototype.show=function(t,i){if(!this._renderFunction){var r=this.ray;this._renderFunction=this._render.bind(this),this._scene=t,this._renderPoints=[r.origin,r.origin.add(r.direction.scale(r.length))],this._renderLine=e.Mesh.CreateLines("ray",this._renderPoints,t,!0),this._scene.registerBeforeRender(this._renderFunction)}i&&this._renderLine.color.copyFrom(i)},t.prototype.hide=function(){this._renderFunction&&(this._scene.unregisterBeforeRender(this._renderFunction),this._scene=null,this._renderFunction=null,this._renderLine.dispose(),this._renderLine=null,this._renderPoints=null)},t.prototype._render=function(){var t=this.ray,i=this._renderPoints[1],r=Math.min(t.length,1e6);i.copyFrom(t.direction),i.scaleInPlace(r),i.addInPlace(t.origin),e.Mesh.CreateLines("ray",this._renderPoints,this._scene,!0,this._renderLine)},t.prototype.attachToMesh=function(t,i,r,n){this._attachedToMesh=t;var o=this.ray;o.direction||(o.direction=e.Vector3.Zero()),o.origin||(o.origin=e.Vector3.Zero()),n&&(o.length=n),r||(r=e.Vector3.Zero()),i||(i=new e.Vector3(0,0,-1)),this._meshSpaceDirection?(this._meshSpaceDirection.copyFrom(i),this._meshSpaceOrigin.copyFrom(r)):(this._meshSpaceDirection=i.clone(),this._meshSpaceOrigin=r.clone()),this._updateToMeshFunction||(this._updateToMeshFunction=this._updateToMesh.bind(this),this._attachedToMesh.getScene().registerBeforeRender(this._updateToMeshFunction)),this._updateToMesh()},t.prototype.detachFromMesh=function(){this._attachedToMesh&&(this._attachedToMesh.getScene().unregisterBeforeRender(this._updateToMeshFunction),this._attachedToMesh=null,this._updateToMeshFunction=null)},t.prototype._updateToMesh=function(){var t=this.ray;if(this._attachedToMesh._isDisposed)return void this.detachFromMesh();this._attachedToMesh.getDirectionToRef(this._meshSpaceDirection,t.direction),e.Vector3.TransformCoordinatesToRef(this._meshSpaceOrigin,this._attachedToMesh.getWorldMatrix(),t.origin)},t.prototype.dispose=function(){this.hide(),this.detachFromMesh(),this.ray=null},t})();e.RayHelper=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e){this._scene=e}return t.prototype._createInspector=function(e){void 0===e&&(e={});var t=e.popup||!1,i=e.initialTab||0,r=e.parentElement||null;this._inspector||(this._inspector=new INSPECTOR.Inspector(this._scene,t,i,r,e.newColors))},t.prototype.isVisible=function(){return!!this._inspector},t.prototype.hide=function(){if(this._inspector){try{this._inspector.dispose()}catch(e){}this._inspector=null}},t.prototype.show=function(i){void 0===i&&(i={}),"undefined"==typeof INSPECTOR?e.Tools.LoadScript(t.InspectorURL,this._createInspector.bind(this,i)):this._createInspector(i)},t})();t.InspectorURL=window.location.href.split("/")[0]+"//preview.babylonjs.com/inspector/babylon.inspector.bundle.js",e.DebugLayer=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){var i=(function(){function t(t){this._impostors=[],this._meshes=[],this._numMeshes=0,this._scene=t||e.Engine.LastCreatedScene,this._physicsEnginePlugin=this._scene.getPhysicsEngine().getPhysicsPlugin()}return t.prototype._updateDebugMeshes=function(){for(var e=this._physicsEnginePlugin,t=0;t0?(this._meshes[i]=this._meshes[this._numMeshes],this._impostors[i]=this._impostors[this._numMeshes],this._meshes[this._numMeshes]=null,this._impostors[this._numMeshes]=null):(this._meshes[0]=null,this._impostors[0]=null),t=!0;break}t&&0===this._numMeshes&&this._scene.unregisterBeforeRender(this._renderFunction)},t.prototype._getDebugMaterial=function(t){return this._debugMaterial||(this._debugMaterial=new e.StandardMaterial("",t),this._debugMaterial.wireframe=!0),this._debugMaterial},t.prototype._getDebugBoxMesh=function(t){return this._debugBoxMesh||(this._debugBoxMesh=e.MeshBuilder.CreateBox("physicsBodyBoxViewMesh",{size:1},t),this._debugBoxMesh.renderingGroupId=1,this._debugBoxMesh.rotationQuaternion=e.Quaternion.Identity(),this._debugBoxMesh.material=this._getDebugMaterial(t),t.removeMesh(this._debugBoxMesh)),this._debugBoxMesh.createInstance("physicsBodyBoxViewInstance")},t.prototype._getDebugSphereMesh=function(t){return this._debugSphereMesh||(this._debugSphereMesh=e.MeshBuilder.CreateSphere("physicsBodySphereViewMesh",{diameter:1},t),this._debugSphereMesh.renderingGroupId=1,this._debugSphereMesh.rotationQuaternion=e.Quaternion.Identity(),this._debugSphereMesh.material=this._getDebugMaterial(t),t.removeMesh(this._debugSphereMesh)),this._debugSphereMesh.createInstance("physicsBodyBoxViewInstance")},t.prototype._getDebugMesh=function(t,i){var r,n=t.physicsBody;n.shapes[0];if(t.type==e.PhysicsImpostor.BoxImpostor)r=this._getDebugBoxMesh(i),t.getBoxSizeToRef(r.scaling);else if(t.type==e.PhysicsImpostor.SphereImpostor){r=this._getDebugSphereMesh(i);var o=t.getRadius();r.scaling.x=2*o,r.scaling.y=2*o,r.scaling.z=2*o}return r},t.prototype.dispose=function(){for(var e=0;e=0&&(this._targets.splice(t,1),e.onInfluenceChanged.remove(this._targetObservable.splice(t,1)[0]),this._vertexCount=0,this._syncActiveTargets(!0))},t.prototype.serialize=function(){var e={};e.id=this.uniqueId,e.targets=[];for(var t=0,i=this._targets;t0&&(this._activeTargets.push(n),this._tempInfluences[t++]=n.influence,this._supportsNormals=this._supportsNormals&&n.hasNormals,this._supportsTangents=this._supportsTangents&&n.hasTangents,0===this._vertexCount&&(this._vertexCount=n.getPositions().length/3))}this._influences&&this._influences.length===t||(this._influences=new Float32Array(t));for(var o=0;o0&&(p+1)%4==0)o[p]=255;else{var x=s[p];o[p]=x/d*255}t.getScene().getEngine().updateTextureSize(r,h*h,h),t.getScene().getEngine().updateRawTexture(r,o,e.Engine.TEXTUREFORMAT_RGBA,!1)};return e.Tools.LoadFile(this.url,n),this._texture},i.prototype.loadTexture=function(){this.url&&this.url.toLocaleLowerCase().indexOf(".3dl")==this.url.length-4&&this.load3dlTexture()},i.prototype.clone=function(){var e=new i(this.url,this.getScene());return e.level=this.level,e},i.prototype.delayLoad=function(){this.delayLoadState===e.Engine.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=e.Engine.DELAYLOADSTATE_LOADED,this._texture=this._getFromCache(this.url,!0),this._texture||this.loadTexture())},i.Parse=function(t,i,r){var n=null;return t.name&&!t.isRenderTarget&&(n=new e.ColorGradingTexture(t.name,i),n.name=t.name,n.level=t.level),n},i.prototype.serialize=function(){if(!this.name)return null;var e={};return e.name=this.name,e.level=this.level,e.customType="BABYLON.ColorGradingTexture",e},i})(e.BaseTexture);t._noneEmptyLineRegex=/\S+/,e.ColorGradingTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this._dirty=!0,this._tempColor=new e.Color4(0,0,0,0),this._globalCurve=new e.Color4(0,0,0,0),this._highlightsCurve=new e.Color4(0,0,0,0),this._midtonesCurve=new e.Color4(0,0,0,0),this._shadowsCurve=new e.Color4(0,0,0,0),this._positiveCurve=new e.Color4(0,0,0,0),this._negativeCurve=new e.Color4(0,0,0,0),this._globalHue=30,this._globalDensity=0,this._globalSaturation=0,this._globalExposure=0,this._highlightsHue=30,this._highlightsDensity=0,this._highlightsSaturation=0,this._highlightsExposure=0,this._midtonesHue=30,this._midtonesDensity=0,this._midtonesSaturation=0,this._midtonesExposure=0,this._shadowsHue=30,this._shadowsDensity=0,this._shadowsSaturation=0,this._shadowsExposure=0}return Object.defineProperty(t.prototype,"globalHue",{get:function(){return this._globalHue},set:function(e){this._globalHue=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"globalDensity",{get:function(){return this._globalDensity},set:function(e){this._globalDensity=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"globalSaturation",{get:function(){return this._globalSaturation},set:function(e){this._globalSaturation=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"highlightsHue",{get:function(){return this._highlightsHue},set:function(e){this._highlightsHue=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"highlightsDensity",{get:function(){return this._highlightsDensity},set:function(e){this._highlightsDensity=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"highlightsSaturation",{get:function(){return this._highlightsSaturation},set:function(e){this._highlightsSaturation=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"highlightsExposure",{get:function(){return this._highlightsExposure},set:function(e){this._highlightsExposure=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"midtonesHue",{get:function(){return this._midtonesHue},set:function(e){this._midtonesHue=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"midtonesDensity",{get:function(){return this._midtonesDensity},set:function(e){this._midtonesDensity=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"midtonesSaturation",{get:function(){return this._midtonesSaturation},set:function(e){this._midtonesSaturation=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"midtonesExposure",{get:function(){return this._midtonesExposure},set:function(e){this._midtonesExposure=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"shadowsHue",{get:function(){return this._shadowsHue},set:function(e){this._shadowsHue=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"shadowsDensity",{get:function(){return this._shadowsDensity},set:function(e){this._shadowsDensity=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"shadowsSaturation",{get:function(){return this._shadowsSaturation},set:function(e){this._shadowsSaturation=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"shadowsExposure",{get:function(){return this._shadowsExposure},set:function(e){ +this._shadowsExposure=e,this._dirty=!0},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return"ColorCurves"},t.Bind=function(e,t,i,r,n){void 0===i&&(i="vCameraColorCurvePositive"),void 0===r&&(r="vCameraColorCurveNeutral"),void 0===n&&(n="vCameraColorCurveNegative"),e._dirty&&(e._dirty=!1,e.getColorGradingDataToRef(e._globalHue,e._globalDensity,e._globalSaturation,e._globalExposure,e._globalCurve),e.getColorGradingDataToRef(e._highlightsHue,e._highlightsDensity,e._highlightsSaturation,e._highlightsExposure,e._tempColor),e._tempColor.multiplyToRef(e._globalCurve,e._highlightsCurve),e.getColorGradingDataToRef(e._midtonesHue,e._midtonesDensity,e._midtonesSaturation,e._midtonesExposure,e._tempColor),e._tempColor.multiplyToRef(e._globalCurve,e._midtonesCurve),e.getColorGradingDataToRef(e._shadowsHue,e._shadowsDensity,e._shadowsSaturation,e._shadowsExposure,e._tempColor),e._tempColor.multiplyToRef(e._globalCurve,e._shadowsCurve),e._highlightsCurve.subtractToRef(e._midtonesCurve,e._positiveCurve),e._midtonesCurve.subtractToRef(e._shadowsCurve,e._negativeCurve)),t&&(t.setFloat4(i,e._positiveCurve.r,e._positiveCurve.g,e._positiveCurve.b,e._positiveCurve.a),t.setFloat4(r,e._midtonesCurve.r,e._midtonesCurve.g,e._midtonesCurve.b,e._midtonesCurve.a),t.setFloat4(n,e._negativeCurve.r,e._negativeCurve.g,e._negativeCurve.b,e._negativeCurve.a))},t.PrepareUniforms=function(e){e.push("vCameraColorCurveNeutral","vCameraColorCurvePositive","vCameraColorCurveNegative")},t.prototype.getColorGradingDataToRef=function(e,i,r,n,o){null!=e&&(e=t.clamp(e,0,360),i=t.clamp(i,-100,100),r=t.clamp(r,-100,100),n=t.clamp(n,-100,100),i=t.applyColorGradingSliderNonlinear(i),i*=.5,n=t.applyColorGradingSliderNonlinear(n),i<0&&(i*=-1,e=(e+180)%360),t.fromHSBToRef(e,i,50+.25*n,o),o.scaleToRef(2,o),o.a=1+.01*r)},t.applyColorGradingSliderNonlinear=function(e){e/=100;var t=Math.abs(e);return t=Math.pow(t,2),e<0&&(t*=-1),t*=100},t.fromHSBToRef=function(e,i,r,n){var o=t.clamp(e,0,360),s=t.clamp(i/100,0,1),a=t.clamp(r/100,0,1);if(0===s)n.r=a,n.g=a,n.b=a;else{o/=60;var l=Math.floor(o),h=o-l,c=a*(1-s),u=a*(1-s*h),f=a*(1-s*(1-h));switch(l){case 0:n.r=a,n.g=f,n.b=c;break;case 1:n.r=u,n.g=a,n.b=c;break;case 2:n.r=c,n.g=a,n.b=f;break;case 3:n.r=c,n.g=u,n.b=a;break;case 4:n.r=f,n.g=c,n.b=a;break;default:n.r=a,n.g=c,n.b=u}}n.a=1},t.clamp=function(e,t,i){return Math.min(Math.max(e,t),i)},t.prototype.clone=function(){return e.SerializationHelper.Clone((function(){return new t}),this)},t.prototype.serialize=function(){return e.SerializationHelper.Serialize(this)},t.Parse=function(i){return e.SerializationHelper.Parse((function(){return new t}),i,null,null)},t})();__decorate([e.serialize()],t.prototype,"_globalHue",void 0),__decorate([e.serialize()],t.prototype,"_globalDensity",void 0),__decorate([e.serialize()],t.prototype,"_globalSaturation",void 0),__decorate([e.serialize()],t.prototype,"_globalExposure",void 0),__decorate([e.serialize()],t.prototype,"_highlightsHue",void 0),__decorate([e.serialize()],t.prototype,"_highlightsDensity",void 0),__decorate([e.serialize()],t.prototype,"_highlightsSaturation",void 0),__decorate([e.serialize()],t.prototype,"_highlightsExposure",void 0),__decorate([e.serialize()],t.prototype,"_midtonesHue",void 0),__decorate([e.serialize()],t.prototype,"_midtonesDensity",void 0),__decorate([e.serialize()],t.prototype,"_midtonesSaturation",void 0),__decorate([e.serialize()],t.prototype,"_midtonesExposure",void 0),e.ColorCurves=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t,i,r){void 0===r&&(r=2),this.maxDepth=r,this.dynamicContent=new Array,this._maxBlockCapacity=i||64,this._selectionContent=new e.SmartArray(1024),this._creationFunc=t}return t.prototype.update=function(e,i,r){t._CreateBlocks(e,i,r,this._maxBlockCapacity,0,this.maxDepth,this,this._creationFunc)},t.prototype.addMesh=function(e){for(var t=0;tthis.capacity&&this._depth>>16&65535,r=65535&e,n=t>>>16&65535,o=65535&t;return r*o+(i*o+r*n<<16>>>0)|0}),e.Matrix.prototype.multiplyToArray=i.prototype.multiplyToArraySIMD,e.Matrix.prototype.invertToRef=i.prototype.invertToRefSIMD,e.Matrix.LookAtLHToRef=i.LookAtLHToRefSIMD,e.Vector3.TransformCoordinatesToRef=t.TransformCoordinatesToRefSIMD,e.Vector3.TransformCoordinatesFromFloatsToRef=t.TransformCoordinatesFromFloatsToRefSIMD,l._isEnabled=!0)},l})();l._isEnabled=!1,e.SIMDHelper=l})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o){var s=t.call(this,i,"vrDistortionCorrection",["LensCenter","Scale","ScaleIn","HmdWarpParam"],null,o.postProcessScaleFactor,r,e.Texture.BILINEAR_SAMPLINGMODE,null,null)||this;return s._isRightEye=n,s._distortionFactors=o.distortionK,s._postProcessScaleFactor=o.postProcessScaleFactor,s._lensCenterOffset=o.lensCenterOffset,s.onSizeChangedObservable.add((function(){s.aspectRatio=.5*s.width/s.height,s._scaleIn=new e.Vector2(2,2/s.aspectRatio),s._scaleFactor=new e.Vector2(1/s._postProcessScaleFactor*.5,1/s._postProcessScaleFactor*.5*s.aspectRatio),s._lensCenter=new e.Vector2(s._isRightEye?.5-.5*s._lensCenterOffset:.5+.5*s._lensCenterOffset,.5)})),s.onApplyObservable.add((function(e){e.setFloat2("LensCenter",s._lensCenter.x,s._lensCenter.y),e.setFloat2("Scale",s._scaleFactor.x,s._scaleFactor.y),e.setFloat2("ScaleIn",s._scaleIn.x,s._scaleIn.y),e.setFloat4("HmdWarpParam",s._distortionFactors[0],s._distortionFactors[1],s._distortionFactors[2],s._distortionFactors[3])})),s}return __extends(i,t),i})(e.PostProcess);e.VRDistortionCorrectionPostProcess=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(e){function t(t,i,r,n,o,s){var a=e.call(this,t,"anaglyph",null,["leftSampler"],i,r[1],n,o,s)||this;return a._passedProcess=r[0]._rigPostProcess,a.onApplyObservable.add((function(e){e.setTextureFromPostProcess("leftSampler",a._passedProcess)})),a}return __extends(t,e),t})(e.PostProcess);e.AnaglyphPostProcess=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o,s,a){var l=t.call(this,i,"stereoscopicInterlace",["stepSize"],["camASampler"],1,r[1],o,s,a,n?"#define IS_STEREOSCOPIC_HORIZ 1":void 0)||this;return l._passedProcess=r[0]._rigPostProcess,l._stepSize=new e.Vector2(1/l.width,1/l.height),l.onSizeChangedObservable.add((function(){l._stepSize=new e.Vector2(1/l.width,1/l.height)})),l.onApplyObservable.add((function(e){e.setTextureFromPostProcess("camASampler",l._passedProcess),e.setFloat2("stepSize",l._stepSize.x,l._stepSize.y)})),l}return __extends(i,t),i})(e.PostProcess);e.StereoscopicInterlacePostProcess=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){var t=this;this._screenOrientationAngle=0,this._screenQuaternion=new e.Quaternion,this._alpha=0,this._beta=0,this._gamma=0,this._orientationChanged=function(){t._screenOrientationAngle=void 0!==window.orientation?+window.orientation:window.screen.orientation&&window.screen.orientation.angle?window.screen.orientation.angle:0,t._screenOrientationAngle=-e.Tools.ToRadians(t._screenOrientationAngle/2),t._screenQuaternion.copyFromFloats(0,Math.sin(t._screenOrientationAngle),0,Math.cos(t._screenOrientationAngle))},this._deviceOrientation=function(e){t._alpha=e.alpha,t._beta=e.beta,t._gamma=e.gamma},this._constantTranform=new e.Quaternion(-Math.sqrt(.5),0,0,Math.sqrt(.5)),this._orientationChanged()}return Object.defineProperty(t.prototype,"camera",{get:function(){return this._camera},set:function(t){this._camera=t,this._camera.rotationQuaternion||(this._camera.rotationQuaternion=new e.Quaternion)},enumerable:!0,configurable:!0}),t.prototype.attachControl=function(e,t){window.addEventListener("orientationchange",this._orientationChanged),window.addEventListener("deviceorientation",this._deviceOrientation),this._orientationChanged()},t.prototype.detachControl=function(e){window.removeEventListener("orientationchange",this._orientationChanged),window.removeEventListener("deviceorientation",this._deviceOrientation)},t.prototype.checkInputs=function(){this._alpha&&(e.Quaternion.RotationYawPitchRollToRef(e.Tools.ToRadians(this._alpha),e.Tools.ToRadians(this._beta),-e.Tools.ToRadians(this._gamma),this.camera.rotationQuaternion),this._camera.rotationQuaternion.multiplyInPlace(this._screenQuaternion),this._camera.rotationQuaternion.multiplyInPlace(this._constantTranform),this._camera.rotationQuaternion.z*=-1,this._camera.rotationQuaternion.w*=-1)},t.prototype.getClassName=function(){return"FreeCameraDeviceOrientationInput"},t.prototype.getSimpleName=function(){return"deviceOrientation"},t})();e.FreeCameraDeviceOrientationInput=t,e.CameraInputTypes.FreeCameraDeviceOrientationInput=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(){this.alphaCorrection=1,this.betaCorrection=1,this.gammaCorrection=1,this._alpha=0,this._beta=0,this._gamma=0,this._dirty=!1,this._deviceOrientationHandler=this._onOrientationEvent.bind(this)}return e.prototype.attachControl=function(e,t){this.camera.attachControl(e,t),window.addEventListener("deviceorientation",this._deviceOrientationHandler)},e.prototype._onOrientationEvent=function(e){this.camera;this._alpha=0|+e.alpha,this._beta=0|+e.beta,this._gamma=0|+e.gamma,this._dirty=!0},e.prototype.checkInputs=function(){this._dirty&&(this._dirty=!1,this._gamma<0&&(this._gamma=180+this._gamma),this.camera.alpha=-this._alpha/180*Math.PI%Math.PI*2,this.camera.beta=this._gamma/180*Math.PI)},e.prototype.detachControl=function(e){window.removeEventListener("deviceorientation",this._deviceOrientationHandler)},e.prototype.getClassName=function(){return"ArcRotateCameraVRDeviceOrientationInput"},e.prototype.getSimpleName=function(){return"VRDeviceOrientation"},e})();e.ArcRotateCameraVRDeviceOrientationInput=t,e.CameraInputTypes.ArcRotateCameraVRDeviceOrientationInput=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this.compensateDistortion=!0}return Object.defineProperty(t.prototype,"aspectRatio",{get:function(){return this.hResolution/(2*this.vResolution)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"aspectRatioFov",{get:function(){return 2*Math.atan(this.postProcessScaleFactor*this.vScreenSize/(2*this.eyeToScreenDistance))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"leftHMatrix",{get:function(){var t=this.hScreenSize/4-this.lensSeparationDistance/2,i=4*t/this.hScreenSize;return e.Matrix.Translation(i,0,0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rightHMatrix",{get:function(){var t=this.hScreenSize/4-this.lensSeparationDistance/2,i=4*t/this.hScreenSize;return e.Matrix.Translation(-i,0,0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"leftPreViewMatrix",{get:function(){return e.Matrix.Translation(.5*this.interpupillaryDistance,0,0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rightPreViewMatrix",{get:function(){return e.Matrix.Translation(-.5*this.interpupillaryDistance,0,0)},enumerable:!0,configurable:!0}),t.GetDefault=function(){var e=new t;return e.hResolution=1280,e.vResolution=800,e.hScreenSize=.149759993,e.vScreenSize=.0935999975,e.vScreenCenter=.0467999987,e.eyeToScreenDistance=.0410000011,e.lensSeparationDistance=.063500002,e.interpupillaryDistance=.064000003,e.distortionK=[1,.219999999,.239999995,0],e.chromaAbCorrection=[.995999992,-.00400000019,1.01400006,0],e.postProcessScaleFactor=1.714605507808412,e.lensCenterOffset=.151976421,e},t})();e.VRCameraMetrics=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o){void 0===o&&(o={});var s=t.call(this,i,r,n)||this;return s.webVROptions=o,s._vrDevice=null,s.rawPose=null,s._vrEnabled=!1,s._specsVersion=1.1,s._attached=!1,s._positionOffset=e.Vector3.Zero(),s._descendants=[],s.devicePosition=e.Vector3.Zero(),s.deviceScaleFactor=1,s.controllers=[],s.nonVRControllers=[],s.rigParenting=!0,5===arguments.length&&(s.webVROptions=arguments[4]),void 0==s.webVROptions.trackPosition&&(s.webVROptions.trackPosition=!0),void 0==s.webVROptions.controllerMeshes&&(s.webVROptions.controllerMeshes=!0),void 0==s.webVROptions.defaultLightningOnControllers&&(s.webVROptions.defaultLightningOnControllers=!0),s.rotationQuaternion=new e.Quaternion,s.deviceRotationQuaternion=new e.Quaternion,s.webVROptions&&s.webVROptions.positionScale&&(s.deviceScaleFactor=s.webVROptions.positionScale),s.getEngine().initWebVR(),window.VRFrameData?s._frameData=new VRFrameData:(s._specsVersion=1,s._frameData={}),s.getEngine().getVRDevice(s.webVROptions.displayName,(function(t){t&&(s._vrEnabled=!0,s._vrDevice=t,s.setCameraRigMode(e.Camera.RIG_MODE_WEBVR,{parentCamera:s,vrDisplay:s._vrDevice,frameData:s._frameData,specs:s._specsVersion}),s._attached&&s.getEngine().enableVR(s._vrDevice))})),s.initControllers(),n.onBeforeCameraRenderObservable.add((function(e){e.parent===s&&s.rigParenting&&(s._descendants=s.getDescendants(!0,(function(e){var t=s.controllers.some((function(t){return t._mesh===e})),i=-1!==s._rigCameras.indexOf(e);return!t&&!i})),s._descendants.forEach((function(t){t.parent=e})))})),n.onAfterCameraRenderObservable.add((function(e){e.parent===s&&s.rigParenting&&s._descendants.forEach((function(e){e.parent=s}))})),s}return __extends(i,t),Object.defineProperty(i.prototype,"onControllersAttached",{set:function(e){this._onControllersAttached=e,this.controllers.length>=2&&e(this.controllers)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"onNonVRControllerAttached",{set:function(e){this._onNonVRControllerAttached=e,this.nonVRControllers.forEach((function(t){e(t)}))},enumerable:!0,configurable:!0}),i.prototype.getControllerByName=function(e){for(var t=0,i=this.controllers;t=2)){for(var n=!1,o=0;oi.halfWidth,t&&this._joystickPointerID<0?(this._joystickPointerID=e.pointerId,this._joystickPointerStartPos.x=e.clientX,this._joystickPointerStartPos.y=e.clientY,this._joystickPointerPos=this._joystickPointerStartPos.clone(),this._joystickPreviousPointerPos=this._joystickPointerStartPos.clone(),this._deltaJoystickVector.x=0,this._deltaJoystickVector.y=0,this.pressed=!0,this._touches.add(e.pointerId.toString(),e)):i._globalJoystickIndex<2&&this._action&&(this._action(),this._touches.add(e.pointerId.toString(),{x:e.clientX,y:e.clientY,prevX:e.clientX,prevY:e.clientY}))},i.prototype._onPointerMove=function(e){if(this._joystickPointerID==e.pointerId){this._joystickPointerPos.x=e.clientX,this._joystickPointerPos.y=e.clientY,this._deltaJoystickVector=this._joystickPointerPos.clone(),this._deltaJoystickVector=this._deltaJoystickVector.subtract(this._joystickPointerStartPos);var i=this.reverseLeftRight?-1:1,r=i*this._deltaJoystickVector.x/this._inversedSensibility;switch(this._axisTargetedByLeftAndRight){case t.X:this.deltaPosition.x=Math.min(1,Math.max(-1,r));break;case t.Y:this.deltaPosition.y=Math.min(1,Math.max(-1,r));break;case t.Z:this.deltaPosition.z=Math.min(1,Math.max(-1,r))}var n=this.reverseUpDown?1:-1,o=n*this._deltaJoystickVector.y/this._inversedSensibility;switch(this._axisTargetedByUpAndDown){case t.X:this.deltaPosition.x=Math.min(1,Math.max(-1,o));break;case t.Y:this.deltaPosition.y=Math.min(1,Math.max(-1,o));break;case t.Z:this.deltaPosition.z=Math.min(1,Math.max(-1,o))}}else{var s=this._touches.get(e.pointerId.toString());s&&(s.x=e.clientX,s.y=e.clientY)}},i.prototype._onPointerUp=function(e){if(this._joystickPointerID==e.pointerId)i.vjCanvasContext.clearRect(this._joystickPointerStartPos.x-64,this._joystickPointerStartPos.y-64,128,128),i.vjCanvasContext.clearRect(this._joystickPreviousPointerPos.x-42,this._joystickPreviousPointerPos.y-42,84,84),this._joystickPointerID=-1,this.pressed=!1;else{var t=this._touches.get(e.pointerId.toString());t&&i.vjCanvasContext.clearRect(t.prevX-44,t.prevY-44,88,88)}this._deltaJoystickVector.x=0,this._deltaJoystickVector.y=0,this._touches.remove(e.pointerId.toString())},i.prototype.setJoystickColor=function(e){this._joystickColor=e},i.prototype.setActionOnTouch=function(e){this._action=e},i.prototype.setAxisForLeftRight=function(e){switch(e){case t.X:case t.Y:case t.Z:this._axisTargetedByLeftAndRight=e;break;default:this._axisTargetedByLeftAndRight=t.X}},i.prototype.setAxisForUpDown=function(e){switch(e){case t.X:case t.Y:case t.Z:this._axisTargetedByUpAndDown=e;break;default:this._axisTargetedByUpAndDown=t.Y}},i.prototype._clearCanvas=function(){this._leftJoystick?i.vjCanvasContext.clearRect(0,0,i.vjCanvasWidth/2,i.vjCanvasHeight):i.vjCanvasContext.clearRect(i.vjCanvasWidth/2,0,i.vjCanvasWidth,i.vjCanvasHeight)},i.prototype._drawVirtualJoystick=function(){var e=this;this.pressed&&this._touches.forEach((function(t,r){r.pointerId===e._joystickPointerID?(i.vjCanvasContext.clearRect(e._joystickPointerStartPos.x-64,e._joystickPointerStartPos.y-64,128,128),i.vjCanvasContext.clearRect(e._joystickPreviousPointerPos.x-42,e._joystickPreviousPointerPos.y-42,84,84),i.vjCanvasContext.beginPath(),i.vjCanvasContext.lineWidth=6,i.vjCanvasContext.strokeStyle=e._joystickColor,i.vjCanvasContext.arc(e._joystickPointerStartPos.x,e._joystickPointerStartPos.y,40,0,2*Math.PI,!0),i.vjCanvasContext.stroke(),i.vjCanvasContext.closePath(),i.vjCanvasContext.beginPath(),i.vjCanvasContext.strokeStyle=e._joystickColor,i.vjCanvasContext.lineWidth=2,i.vjCanvasContext.arc(e._joystickPointerStartPos.x,e._joystickPointerStartPos.y,60,0,2*Math.PI,!0),i.vjCanvasContext.stroke(),i.vjCanvasContext.closePath(),i.vjCanvasContext.beginPath(),i.vjCanvasContext.strokeStyle=e._joystickColor,i.vjCanvasContext.arc(e._joystickPointerPos.x,e._joystickPointerPos.y,40,0,2*Math.PI,!0),i.vjCanvasContext.stroke(),i.vjCanvasContext.closePath(),e._joystickPreviousPointerPos=e._joystickPointerPos.clone()):(i.vjCanvasContext.clearRect(r.prevX-44,r.prevY-44,88,88),i.vjCanvasContext.beginPath(),i.vjCanvasContext.fillStyle="white",i.vjCanvasContext.beginPath(),i.vjCanvasContext.strokeStyle="red",i.vjCanvasContext.lineWidth=6,i.vjCanvasContext.arc(r.x,r.y,40,0,2*Math.PI,!0),i.vjCanvasContext.stroke(),i.vjCanvasContext.closePath(),r.prevX=r.x,r.prevY=r.y)})),requestAnimationFrame((function(){e._drawVirtualJoystick()}))},i.prototype.releaseCanvas=function(){i.vjCanvas&&(i.vjCanvas.removeEventListener("pointerdown",this._onPointerDownHandlerRef),i.vjCanvas.removeEventListener("pointermove",this._onPointerMoveHandlerRef),i.vjCanvas.removeEventListener("pointerup",this._onPointerUpHandlerRef),i.vjCanvas.removeEventListener("pointerout",this._onPointerUpHandlerRef),window.removeEventListener("resize",this._onResize),document.body.removeChild(i.vjCanvas),i.vjCanvas=null)},i})();i._globalJoystickIndex=0,e.VirtualJoystick=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(e){function t(t,i,r){var n=e.call(this,t,i,r)||this;return n.inputs.addVirtualJoystick(),n}return __extends(t,e),t.prototype.getClassName=function(){return"VirtualJoysticksCamera"},t})(e.FreeCamera);e.VirtualJoysticksCamera=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){}return t.prototype.getLeftJoystick=function(){return this._leftjoystick},t.prototype.getRightJoystick=function(){return this._rightjoystick},t.prototype.checkInputs=function(){if(this._leftjoystick){var t=this.camera,i=50*t._computeLocalCameraSpeed(),r=e.Matrix.RotationYawPitchRoll(t.rotation.y,t.rotation.x,0),n=e.Vector3.TransformCoordinates(new e.Vector3(this._leftjoystick.deltaPosition.x*i,this._leftjoystick.deltaPosition.y*i,this._leftjoystick.deltaPosition.z*i),r);t.cameraDirection=t.cameraDirection.add(n),t.cameraRotation=t.cameraRotation.addVector3(this._rightjoystick.deltaPosition),this._leftjoystick.pressed||(this._leftjoystick.deltaPosition=this._leftjoystick.deltaPosition.scale(.9)),this._rightjoystick.pressed||(this._rightjoystick.deltaPosition=this._rightjoystick.deltaPosition.scale(.9))}},t.prototype.attachControl=function(t,i){this._leftjoystick=new e.VirtualJoystick(!0),this._leftjoystick.setAxisForUpDown(e.JoystickAxis.Z),this._leftjoystick.setAxisForLeftRight(e.JoystickAxis.X),this._leftjoystick.setJoystickSensibility(.15),this._rightjoystick=new e.VirtualJoystick(!1),this._rightjoystick.setAxisForUpDown(e.JoystickAxis.X),this._rightjoystick.setAxisForLeftRight(e.JoystickAxis.Y),this._rightjoystick.reverseUpDown=!0,this._rightjoystick.setJoystickSensibility(.05),this._rightjoystick.setJoystickColor("yellow")},t.prototype.detachControl=function(e){this._leftjoystick.releaseCanvas(),this._rightjoystick.releaseCanvas()},t.prototype.getClassName=function(){return"FreeCameraVirtualJoystickInput"},t.prototype.getSimpleName=function(){return"virtualJoystick"},t})();e.FreeCameraVirtualJoystickInput=t,e.CameraInputTypes.FreeCameraVirtualJoystickInput=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(e,t,i){this.quality=e,this.distance=t,this.optimizeMesh=i}return e})();e.SimplificationSettings=t;var i=(function(){function t(){this.running=!1,this._simplificationArray=[]}return t.prototype.addTask=function(e){this._simplificationArray.push(e)},t.prototype.executeNext=function(){var e=this._simplificationArray.pop();e?(this.running=!0,this.runSimplification(e)):this.running=!1},t.prototype.runSimplification=function(t){var i=this;if(t.parallelProcessing)t.settings.forEach((function(e){i.getSimplifier(t).simplify(e,(function(r){t.mesh.addLODLevel(e.distance,r),r.isVisible=!0,e.quality===t.settings[t.settings.length-1].quality&&t.successCallback&&t.successCallback(),i.executeNext()}))}));else{var r=this.getSimplifier(t),n=function(e,i){r.simplify(e,(function(r){t.mesh.addLODLevel(e.distance,r),r.isVisible=!0,i()}))};e.AsyncLoop.Run(t.settings.length,(function(e){n(t.settings[e.index],(function(){e.executeNext()}))}),(function(){t.successCallback&&t.successCallback(),i.executeNext()}))}},t.prototype.getSimplifier=function(e){switch(e.simplificationType){case r.QUADRATIC:default:return new l(e.mesh)}},t})();e.SimplificationQueue=i;var r;!(function(e){e[e.QUADRATIC=0]="QUADRATIC"})(r=e.SimplificationType||(e.SimplificationType={}));var n=(function(){function e(e){this.vertices=e,this.error=new Array(4),this.deleted=!1,this.isDirty=!1,this.deletePending=!1,this.borderFactor=0}return e})();e.DecimationTriangle=n;var o=(function(){function e(e,t){this.position=e,this.id=t,this.isBorder=!0,this.q=new s,this.triangleCount=0,this.triangleStart=0,this.originalOffsets=[]}return e.prototype.updatePosition=function(e){this.position.copyFrom(e)},e})();e.DecimationVertex=o;var s=(function(){function e(e){this.data=new Array(10);for(var t=0;t<10;++t)e&&e[t]?this.data[t]=e[t]:this.data[t]=0}return e.prototype.det=function(e,t,i,r,n,o,s,a,l){return this.data[e]*this.data[n]*this.data[l]+this.data[i]*this.data[r]*this.data[a]+this.data[t]*this.data[o]*this.data[s]-this.data[i]*this.data[n]*this.data[s]-this.data[e]*this.data[o]*this.data[a]-this.data[t]*this.data[r]*this.data[l]},e.prototype.addInPlace=function(e){for(var t=0;t<10;++t)this.data[t]+=e.data[t]},e.prototype.addArrayInPlace=function(e){for(var t=0;t<10;++t)this.data[t]+=e[t]},e.prototype.add=function(t){for(var i=new e,r=0;r<10;++r)i.data[r]=this.data[r]+t.data[r];return i},e.FromData=function(t,i,r,n){return new e(e.DataFromNumbers(t,i,r,n))},e.DataFromNumbers=function(e,t,i,r){return[e*e,e*t,e*i,e*r,t*t,t*i,t*r,i*i,i*r,r*r]},e})();e.QuadraticMatrix=s;var a=(function(){function e(e,t){this.vertexId=e,this.triangleId=t}return e})();e.Reference=a;var l=(function(){function t(t){this._mesh=t,this.initialized=!1,this.syncIterations=5e3,this.aggressiveness=7,this.decimationIterations=100,this.boundingBoxEpsilon=e.Epsilon}return t.prototype.simplify=function(t,i){var r=this;this.initDecimatedMesh(),e.AsyncLoop.Run(this._mesh.subMeshes.length,(function(e){r.initWithMesh(e.index,(function(){r.runDecimation(t,e.index,(function(){e.executeNext()}))}),t.optimizeMesh)}),(function(){setTimeout((function(){i(r._reconstructedMesh)}),0)}))},t.prototype.isTriangleOnBoundingBox=function(e){var t=this,i=0;return e.vertices.forEach((function(e){var r=0,n=e.position,o=t._mesh.getBoundingInfo().boundingBox;(o.maximum.x-n.xt.boundingBoxEpsilon)&&++r,o.maximum.y!==n.y&&n.y!==o.minimum.y||++r,o.maximum.z!==n.z&&n.z!==o.minimum.z||++r,r>1&&++i})),i>1&&console.log(e,i),i>1},t.prototype.runDecimation=function(t,i,r){var n=this,o=~~(this.triangles.length*t.quality),s=0,a=this.triangles.length,l=function(t,i){setTimeout((function(){t%5==0&&n.updateMesh(0===t);for(var r=0;rl||r.deleted||r.isDirty))for(var o=0;o<3;++o)if(r.error[o]>0,f,(function(){var t=function(e){var t=h.indexStart/3+e,i=3*t,r=l[i+0],o=l[i+1],a=l[i+2],c=s.vertices[u[r-h.verticesStart]],f=s.vertices[u[o-h.verticesStart]],d=s.vertices[u[a-h.verticesStart]],p=new n([c,f,d]);p.originalOffset=i,s.triangles.push(p)};e.AsyncLoop.SyncAsyncForLoop(h.indexCount/3,s.syncIterations,t,(function(){s.init(i)}))}))},t.prototype.init=function(t){var i=this,r=function(t){var r=i.triangles[t];r.normal=e.Vector3.Cross(r.vertices[1].position.subtract(r.vertices[0].position),r.vertices[2].position.subtract(r.vertices[0].position)).normalize();for(var n=0;n<3;n++)r.vertices[n].q.addArrayInPlace(s.DataFromNumbers(r.normal.x,r.normal.y,r.normal.z,-e.Vector3.Dot(r.normal,r.vertices[0].position)))};e.AsyncLoop.SyncAsyncForLoop(this.triangles.length,this.syncIterations,r,(function(){var r=function(e){for(var t=i.triangles[e],r=0;r<3;++r)t.error[r]=i.calculateError(t.vertices[r],t.vertices[(r+1)%3]);t.error[3]=Math.min(t.error[0],t.error[1],t.error[2])};e.AsyncLoop.SyncAsyncForLoop(i.triangles.length,i.syncIterations,r,(function(){i.initialized=!0,t()}))}))},t.prototype.reconstructMesh=function(t){var i,r=[];for(i=0;i0&&this._reconstructedMesh.setVerticesData(e.VertexBuffer.UVKind,l),h.length>0&&this._reconstructedMesh.setVerticesData(e.VertexBuffer.ColorKind,h);var x=this._mesh.subMeshes[t];if(t>0){this._reconstructedMesh.subMeshes=[],g.forEach((function(t){new e.SubMesh(t.materialIndex,t.verticesStart,t.verticesCount,t.indexStart,t.indexCount,t.getMesh())}));new e.SubMesh(x.materialIndex,m,d,_,3*r.length,this._reconstructedMesh)}},t.prototype.initDecimatedMesh=function(){this._reconstructedMesh=new e.Mesh(this._mesh.name+"Decimated",this._mesh.getScene()),this._reconstructedMesh.material=this._mesh.material,this._reconstructedMesh.parent=this._mesh.parent,this._reconstructedMesh.isVisible=!1,this._reconstructedMesh.renderingGroupId=this._mesh.renderingGroupId},t.prototype.isFlipped=function(t,i,r,n,o,s){for(var a=0;a.999)return!0;var p=e.Vector3.Cross(f,d).normalize();if(n[a]=!1,e.Vector3.Dot(p,l.normal)<.2)return!0}else n[a]=!0,s.push(l)}}return!1},t.prototype.updateTriangles=function(e,t,i,r){for(var n=r,o=0;or.maximumSize&&(n.scale(.5),t=!1)}}return t},r}return __extends(t,e),t})(t);e.TextureOptimization=i;var r=(function(e){function t(t,i){void 0===t&&(t=0),void 0===i&&(i=2);var r=e.call(this,t)||this;return r.priority=t,r.maximumScale=i,r._currentScale=1,r.apply=function(e){return r._currentScale++,e.getEngine().setHardwareScalingLevel(r._currentScale),r._currentScale>=r.maximumScale},r}return __extends(t,e),t})(t);e.HardwareScalingOptimization=r;var n=(function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.apply=function(e){return e.shadowsEnabled=!1,!0},t}return __extends(t,e),t})(t);e.ShadowsOptimization=n;var o=(function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.apply=function(e){return e.postProcessesEnabled=!1,!0},t}return __extends(t,e),t})(t);e.PostProcessesOptimization=o;var s=(function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.apply=function(e){return e.lensFlaresEnabled=!1,!0},t}return __extends(t,e),t})(t);e.LensFlaresOptimization=s;var a=(function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.apply=function(e){return e.particlesEnabled=!1,!0},t}return __extends(t,e),t})(t);e.ParticlesOptimization=a;var l=(function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.apply=function(e){return e.renderTargetsEnabled=!1,!0},t}return __extends(t,e),t})(t);e.RenderTargetsOptimization=l;var h=(function(t){function i(){var r=null!==t&&t.apply(this,arguments)||this;return r._canBeMerged=function(t){if(!(t instanceof e.Mesh))return!1;var i=t;return!(!i.isVisible||!i.isEnabled())&&(!(i.instances.length>0)&&(!i.skeleton&&!i.hasLODLevels&&!i.parent))},r.apply=function(t,n){for(var o=t.meshes.slice(0),s=o.length,a=0;a=i.targetFrameRate)return void(n&&n());for(var s=!0,a=!0,l=0;l4&&(n.push(e.VertexBuffer.MatricesIndicesExtraKind),n.push(e.VertexBuffer.MatricesWeightsExtraKind)),r.push("#define NUM_BONE_INFLUENCERS "+o.numBoneInfluencers),r.push("#define BonesPerMesh "+(o.skeleton.bones.length+1))):r.push("#define NUM_BONE_INFLUENCERS 0"),i&&(r.push("#define INSTANCES"),n.push("world0"),n.push("world1"),n.push("world2"),n.push("world3"));var a=r.join("\n");return this._cachedDefines!==a&&(this._cachedDefines=a,this._effect=this._scene.getEngine().createEffect("outline",n,["world","mBones","viewProjection","diffuseMatrix","offset","color"],["diffuseSampler"],a)),this._effect.isReady()},t})();e.OutlineRenderer=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(){this.edges=new Array,this.edgesConnectedCount=0}return e})(),i=(function(){function i(e,t,i){void 0===t&&(t=.95),void 0===i&&(i=!1),this.edgesWidthScalerForOrthographic=1e3,this.edgesWidthScalerForPerspective=50,this._linesPositions=new Array,this._linesNormals=new Array,this._linesIndices=new Array,this._buffers={},this._checkVerticesInsteadOfIndices=!1,this._source=e,this._checkVerticesInsteadOfIndices=i,this._epsilon=t,this._prepareRessources(),this._generateEdgesLines()}return i.prototype._prepareRessources=function(){this._lineShader||(this._lineShader=new e.ShaderMaterial("lineShader",this._source.getScene(),"line",{attributes:["position","normal"],uniforms:["worldViewProjection","color","width","aspectRatio"]}),this._lineShader.disableDepthWrite=!0,this._lineShader.backFaceCulling=!1)},i.prototype.dispose=function(){var t=this._buffers[e.VertexBuffer.PositionKind];t&&(t.dispose(),this._buffers[e.VertexBuffer.PositionKind]=null),t=this._buffers[e.VertexBuffer.NormalKind],t&&(t.dispose(),this._buffers[e.VertexBuffer.NormalKind]=null),this._source.getScene().getEngine()._releaseBuffer(this._ib),this._lineShader.dispose()},i.prototype._processEdgeForAdjacencies=function(e,t,i,r,n){return e===i&&t===r||e===r&&t===i?0:e===r&&t===n||e===n&&t===r?1:e===n&&t===i||e===i&&t===n?2:-1},i.prototype._processEdgeForAdjacenciesWithVertices=function(e,t,i,r,n){return e.equalsWithEpsilon(i)&&t.equalsWithEpsilon(r)||e.equalsWithEpsilon(r)&&t.equalsWithEpsilon(i)?0:e.equalsWithEpsilon(r)&&t.equalsWithEpsilon(n)||e.equalsWithEpsilon(n)&&t.equalsWithEpsilon(r)?1:e.equalsWithEpsilon(n)&&t.equalsWithEpsilon(i)||e.equalsWithEpsilon(i)&&t.equalsWithEpsilon(n)?2:-1},i.prototype._checkEdge=function(t,i,r,n,o){var s;if(void 0===i)s=!0;else{s=e.Vector3.Dot(r[t],r[i])4&&(o.push(e.VertexBuffer.MatricesIndicesExtraKind),o.push(e.VertexBuffer.MatricesWeightsExtraKind)),n.push("#define NUM_BONE_INFLUENCERS "+s.numBoneInfluencers),n.push("#define BonesPerMesh "+(s.skeleton.bones.length+1))):n.push("#define NUM_BONE_INFLUENCERS 0"),i&&(n.push("#define INSTANCES"),o.push("world0"),o.push("world1"),o.push("world2"),o.push("world3"));var u=n.join("\n");return this._cachedDefines!==u&&(this._cachedDefines=u,this._glowMapGenerationEffect=this._scene.getEngine().createEffect("glowMapGeneration",o,["world","mBones","viewProjection","diffuseMatrix","color","emissiveMatrix"],["diffuseSampler","emissiveSampler"],u)),this._glowMapGenerationEffect.isReady()},i.prototype.render=function(){var t=this._glowMapMergeEffect;if(t.isReady()&&this._blurTexture.isReady()){var i=this._scene.getEngine();this.onBeforeComposeObservable.notifyObservers(this),i.enableEffect(t),i.setState(!1);var r=i.getStencilBuffer(),n=i.getStencilFunction(),o=i.getStencilMask(),s=i.getStencilOperationPass(),a=i.getStencilOperationFail(),l=i.getStencilOperationDepthFail(),h=i.getAlphaMode();t.setTexture("textureSampler",this._blurTexture),i.bindBuffers(this._vertexBuffers,this._indexBuffer,t),i.setStencilOperationPass(e.Engine.REPLACE),i.setStencilOperationFail(e.Engine.KEEP),i.setStencilOperationDepthFail(e.Engine.KEEP),i.setAlphaMode(this._options.alphaBlendingMode),i.setStencilMask(0),i.setStencilBuffer(!0),i.setStencilFunctionReference(this._instanceGlowingMeshStencilReference),this.outerGlow&&(t.setFloat("offset",0),i.setStencilFunction(e.Engine.NOTEQUAL),i.draw(!0,0,6)),this.innerGlow&&(t.setFloat("offset",1),i.setStencilFunction(e.Engine.EQUAL),i.draw(!0,0,6)),i.setStencilFunction(n),i.setStencilMask(o),i.setAlphaMode(h),i.setStencilBuffer(r),i.setStencilOperationPass(s),i.setStencilOperationFail(a),i.setStencilOperationDepthFail(l),i._stencilState.reset(),this.onAfterComposeObservable.notifyObservers(this);var c=this._mainTexture.getSize();this.setMainTextureSize(),c.width===this._mainTextureDesiredSize.width&&c.height===this._mainTextureDesiredSize.height||(this.onSizeChangedObservable.notifyObservers(this),this.disposeTextureAndPostProcesses(),this.createTextureAndPostProcesses())}},i.prototype.addExcludedMesh=function(e){this._excludedMeshes[e.uniqueId]||(this._excludedMeshes[e.uniqueId]={mesh:e,beforeRender:e.onBeforeRenderObservable.add((function(e){e.getEngine().setStencilBuffer(!1)})),afterRender:e.onAfterRenderObservable.add((function(e){e.getEngine().setStencilBuffer(!0)}))})},i.prototype.removeExcludedMesh=function(e){var t=this._excludedMeshes[e.uniqueId];t&&(e.onBeforeRenderObservable.remove(t.beforeRender),e.onAfterRenderObservable.remove(t.afterRender)),this._excludedMeshes[e.uniqueId]=void 0},i.prototype.addMesh=function(e,t,i){var r=this;void 0===i&&(i=!1);var n=this._meshes[e.uniqueId];n?n.color=t:this._meshes[e.uniqueId]={mesh:e,color:t,observerHighlight:e.onBeforeRenderObservable.add((function(e){r._excludedMeshes[e.uniqueId]?r.defaultStencilReference(e):e.getScene().getEngine().setStencilFunctionReference(r._instanceGlowingMeshStencilReference)})),observerDefault:e.onAfterRenderObservable.add(this.defaultStencilReference),glowEmissiveOnly:i},this._shouldRender=!0},i.prototype.removeMesh=function(e){var t=this._meshes[e.uniqueId];t&&(e.onBeforeRenderObservable.remove(t.observerHighlight),e.onAfterRenderObservable.remove(t.observerDefault)),this._meshes[e.uniqueId]=void 0,this._shouldRender=!1;for(var i in this._meshes)if(i){this._shouldRender=!0;break}},i.prototype.shouldRender=function(){return this.isEnabled&&this._shouldRender},i.prototype.setMainTextureSize=function(){this._options.mainTextureFixedSize?(this._mainTextureDesiredSize.width=this._options.mainTextureFixedSize,this._mainTextureDesiredSize.height=this._options.mainTextureFixedSize):(this._mainTextureDesiredSize.width=this._engine.getRenderingCanvas().width*this._options.mainTextureRatio,this._mainTextureDesiredSize.height=this._engine.getRenderingCanvas().height*this._options.mainTextureRatio,this._mainTextureDesiredSize.width=this._engine.needPOTTextures?e.Tools.GetExponentOfTwo(this._mainTextureDesiredSize.width,this._maxSize):this._mainTextureDesiredSize.width,this._mainTextureDesiredSize.height=this._engine.needPOTTextures?e.Tools.GetExponentOfTwo(this._mainTextureDesiredSize.height,this._maxSize):this._mainTextureDesiredSize.height)},i.prototype.defaultStencilReference=function(e){e.getScene().getEngine().setStencilFunctionReference(i.normalMeshStencilReference)},i.prototype.disposeTextureAndPostProcesses=function(){this._blurTexture.dispose(),this._mainTexture.dispose(),this._downSamplePostprocess.dispose(),this._horizontalBlurPostprocess.dispose(),this._verticalBlurPostprocess.dispose()},i.prototype.dispose=function(){var t=this._vertexBuffers[e.VertexBuffer.PositionKind];t&&(t.dispose(),this._vertexBuffers[e.VertexBuffer.PositionKind]=null),this._indexBuffer&&(this._scene.getEngine()._releaseBuffer(this._indexBuffer),this._indexBuffer=null),this.disposeTextureAndPostProcesses();for(var i in this._meshes){var r=this._meshes[i];r&&r.mesh&&(r.mesh.onBeforeRenderObservable.remove(r.observerHighlight),r.mesh.onAfterRenderObservable.remove(r.observerDefault))}this._meshes=null;for(var i in this._excludedMeshes){var r=this._excludedMeshes[i];r&&(r.mesh.onBeforeRenderObservable.remove(r.beforeRender),r.mesh.onAfterRenderObservable.remove(r.afterRender))}this._excludedMeshes=null;var n=this._scene.highlightLayers.indexOf(this,0);n>-1&&this._scene.highlightLayers.splice(n,1),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onBeforeRenderMainTextureObservable.clear(),this.onBeforeBlurObservable.clear(),this.onBeforeComposeObservable.clear(),this.onAfterComposeObservable.clear(),this.onSizeChangedObservable.clear()},i})();i.neutralColor=new e.Color4(0,0,0,0),i.glowingMeshStencilReference=2,i.normalMeshStencilReference=1,e.HighlightLayer=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e,t,i,r){this.name=e,this.meshesNames=t,this.rootUrl=i,this.sceneFilename=r,this.isCompleted=!1}return t.prototype.run=function(t,i,r){var n=this;e.SceneLoader.ImportMesh(this.meshesNames,this.rootUrl,this.sceneFilename,t,(function(e,t,r){n.loadedMeshes=e,n.loadedParticleSystems=t,n.loadedSkeletons=r,n.isCompleted=!0,n.onSuccess&&n.onSuccess(n),i()}),null,(function(){n.onError&&n.onError(n),r()}))},t})();e.MeshAssetTask=t;var i=(function(){function t(e,t){this.name=e,this.url=t,this.isCompleted=!1}return t.prototype.run=function(t,i,r){var n=this;e.Tools.LoadFile(this.url,(function(e){n.text=e,n.isCompleted=!0,n.onSuccess&&n.onSuccess(n),i()}),null,t.database,!1,(function(){n.onError&&n.onError(n),r()}))},t})();e.TextFileAssetTask=i;var r=(function(){function t(e,t){this.name=e,this.url=t,this.isCompleted=!1}return t.prototype.run=function(t,i,r){var n=this;e.Tools.LoadFile(this.url,(function(e){n.data=e,n.isCompleted=!0,n.onSuccess&&n.onSuccess(n),i()}),null,t.database,!0,(function(){n.onError&&n.onError(n),r()}))},t})();e.BinaryFileAssetTask=r;var n=(function(){function t(e,t){this.name=e,this.url=t,this.isCompleted=!1}return t.prototype.run=function(t,i,r){var n=this,o=new Image;e.Tools.SetCorsBehavior(this.url,o),o.onload=function(){n.image=o,n.isCompleted=!0,n.onSuccess&&n.onSuccess(n),i()},o.onerror=function(){n.onError&&n.onError(n),r()},o.src=this.url},t})();e.ImageAssetTask=n;var o=(function(){function t(t,i,r,n,o){void 0===o&&(o=e.Texture.TRILINEAR_SAMPLINGMODE),this.name=t,this.url=i,this.noMipmap=r,this.invertY=n,this.samplingMode=o,this.isCompleted=!1}return t.prototype.run=function(t,i,r){var n=this,o=function(){n.isCompleted=!0,n.onSuccess&&n.onSuccess(n),i()},s=function(){n.onError&&n.onError(n),r()};this.texture=new e.Texture(this.url,t,this.noMipmap,this.invertY,this.samplingMode,o,s)},t})();e.TextureAssetTask=o;var s=(function(){function t(e,t,i,r,n){this.name=e,this.url=t,this.extensions=i,this.noMipmap=r,this.files=n,this.isCompleted=!1}return t.prototype.run=function(t,i,r){var n=this,o=function(){n.isCompleted=!0,n.onSuccess&&n.onSuccess(n),i()},s=function(){n.onError&&n.onError(n),r()};this.texture=new e.CubeTexture(this.url,t,this.extensions,this.noMipmap,this.files,o,s)},t})();e.CubeTextureAssetTask=s;var a=(function(){function t(e,t,i,r,n,o,s){void 0===r&&(r=!1),void 0===n&&(n=!0),void 0===o&&(o=!1),void 0===s&&(s=!1),this.name=e,this.url=t,this.size=i,this.noMipmap=r,this.generateHarmonics=n,this.useInGammaSpace=o,this.usePMREMGenerator=s,this.isCompleted=!1}return t.prototype.run=function(t,i,r){var n=this,o=function(){n.isCompleted=!0,n.onSuccess&&n.onSuccess(n),i()},s=function(){n.onError&&n.onError(n),r()};this.texture=new e.HDRCubeTexture(this.url,t,this.size,this.noMipmap,this.generateHarmonics,this.useInGammaSpace,this.usePMREMGenerator,o,s)},t})();e.HDRCubeTextureAssetTask=a;var l=(function(){function l(e){this.tasks=new Array,this.waitingTasksCount=0,this.useDefaultLoadingScreen=!0,this._scene=e}return l.prototype.addMeshTask=function(e,i,r,n){var o=new t(e,i,r,n);return this.tasks.push(o),o},l.prototype.addTextFileTask=function(e,t){var r=new i(e,t);return this.tasks.push(r),r},l.prototype.addBinaryFileTask=function(e,t){var i=new r(e,t);return this.tasks.push(i),i},l.prototype.addImageTask=function(e,t){var i=new n(e,t);return this.tasks.push(i),i},l.prototype.addTextureTask=function(t,i,r,n,s){void 0===s&&(s=e.Texture.TRILINEAR_SAMPLINGMODE);var a=new o(t,i,r,n,s);return this.tasks.push(a),a},l.prototype.addCubeTextureTask=function(e,t,i,r,n){var o=new s(e,t,i,r,n);return this.tasks.push(o),o},l.prototype.addHDRCubeTextureTask=function(e,t,i,r,n,o,s){void 0===r&&(r=!1),void 0===n&&(n=!0),void 0===o&&(o=!1),void 0===s&&(s=!1);var l=new a(e,t,i,r,n,o,s);return this.tasks.push(l),l},l.prototype._decreaseWaitingTasksCount=function(){0===--this.waitingTasksCount&&(this.onFinish&&this.onFinish(this.tasks),this._scene.getEngine().hideLoadingUI())},l.prototype._runTask=function(e){var t=this;e.run(this._scene,(function(){t.onTaskSuccess&&t.onTaskSuccess(e),t._decreaseWaitingTasksCount()}),(function(){t.onTaskError&&t.onTaskError(e),t._decreaseWaitingTasksCount()}))},l.prototype.reset=function(){return this.tasks=new Array,this},l.prototype.load=function(){if(this.waitingTasksCount=this.tasks.length,0===this.waitingTasksCount)return this.onFinish&&this.onFinish(this.tasks),this;this.useDefaultLoadingScreen&&this._scene.getEngine().displayLoadingUI();for(var e=0;e\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef TANGENT\nattribute vec4 tangent;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include\n\n#include\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0\nvarying vec2 vDiffuseUV;\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nvarying vec2 vAmbientUV;\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nvarying vec2 vOpacityUV;\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nvarying vec2 vEmissiveUV;\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nvarying vec2 vLightmapUV;\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM) && SPECULARDIRECTUV == 0\nvarying vec2 vSpecularUV;\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nvarying vec2 vBumpUV;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include\n#include\n#include\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include\n#include[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#include\nvoid main(void) {\nvec3 positionUpdated=position;\n#ifdef NORMAL \nvec3 normalUpdated=normal;\n#endif\n#ifdef TANGENT\nvec4 tangentUpdated=tangent;\n#endif\n#include[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvPositionUVW=positionUpdated;\n#endif \n#include\n#include\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normalUpdated,0.0)));\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef MAINUV1\nvMainUV1=uv;\n#endif\n#ifdef MAINUV2\nvMainUV2=uv2;\n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0\nif (vDiffuseInfos.x == 0.)\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nif (vAmbientInfos.x == 0.)\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nif (vOpacityInfos.x == 0.)\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nif (vEmissiveInfos.x == 0.)\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nif (vLightmapInfos.x == 0.)\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM) && SPECULARDIRECTUV == 0\nif (vSpecularInfos.x == 0.)\n{\nvSpecularUV=vec2(specularMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvSpecularUV=vec2(specularMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nif (vBumpInfos.x == 0.)\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#include\n#include\n#include\n#include[0..maxSimultaneousLights]\n#ifdef VERTEXCOLOR\n\nvColor=color;\n#endif\n#include\n#include\n}",defaultPixelShader:"#include<__decl__defaultFragment>\n#if defined(BUMP) || !defined(NORMAL)\n#extension GL_OES_standard_derivatives : enable\n#endif\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\n\n#define RECIPROCAL_PI2 0.15915494\nuniform vec3 vEyePosition;\nuniform vec3 vAmbientColor;\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n\n#include\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include\n#include\n\n#ifdef DIFFUSE\n#if DIFFUSEDIRECTUV == 1\n#define vDiffuseUV vMainUV1\n#elif DIFFUSEDIRECTUV == 2\n#define vDiffuseUV vMainUV2\n#else\nvarying vec2 vDiffuseUV;\n#endif\nuniform sampler2D diffuseSampler;\n#endif\n#ifdef AMBIENT\n#if AMBIENTDIRECTUV == 1\n#define vAmbientUV vMainUV1\n#elif AMBIENTDIRECTUV == 2\n#define vAmbientUV vMainUV2\n#else\nvarying vec2 vAmbientUV;\n#endif\nuniform sampler2D ambientSampler;\n#endif\n#ifdef OPACITY \n#if OPACITYDIRECTUV == 1\n#define vOpacityUV vMainUV1\n#elif OPACITYDIRECTUV == 2\n#define vOpacityUV vMainUV2\n#else\nvarying vec2 vOpacityUV;\n#endif\nuniform sampler2D opacitySampler;\n#endif\n#ifdef EMISSIVE\n#if EMISSIVEDIRECTUV == 1\n#define vEmissiveUV vMainUV1\n#elif EMISSIVEDIRECTUV == 2\n#define vEmissiveUV vMainUV2\n#else\nvarying vec2 vEmissiveUV;\n#endif\nuniform sampler2D emissiveSampler;\n#endif\n#ifdef LIGHTMAP\n#if LIGHTMAPDIRECTUV == 1\n#define vLightmapUV vMainUV1\n#elif LIGHTMAPDIRECTUV == 2\n#define vLightmapUV vMainUV2\n#else\nvarying vec2 vLightmapUV;\n#endif\nuniform sampler2D lightmapSampler;\n#endif\n#ifdef REFRACTION\n#ifdef REFRACTIONMAP_3D\nuniform samplerCube refractionCubeSampler;\n#else\nuniform sampler2D refraction2DSampler;\n#endif\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\n#if SPECULARDIRECTUV == 1\n#define vSpecularUV vMainUV1\n#elif SPECULARDIRECTUV == 2\n#define vSpecularUV vMainUV2\n#else\nvarying vec2 vSpecularUV;\n#endif\nuniform sampler2D specularSampler;\n#endif\n\n#include\n\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\nuniform samplerCube reflectionCubeSampler;\n#else\nuniform sampler2D reflection2DSampler;\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#endif\n#include\n#endif\n#include\n#include\n#include\n#include\n#include\n#include\nvoid main(void) {\n#include\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\nvec4 baseColor=vec4(1.,1.,1.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\n\nfloat alpha=vDiffuseColor.a;\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=normalize(-cross(dFdx(vPositionW),dFdy(vPositionW)));\n#endif\n#include\n#ifdef TWOSIDEDLIGHTING\nnormalW=gl_FrontFacing ? normalW : -normalW;\n#endif\n#ifdef DIFFUSE\nbaseColor=texture2D(diffuseSampler,vDiffuseUV+uvOffset);\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\n#ifdef ALPHAFROMDIFFUSE\nalpha*=baseColor.a;\n#endif\nbaseColor.rgb*=vDiffuseInfos.y;\n#endif\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n\nvec3 baseAmbientColor=vec3(1.,1.,1.);\n#ifdef AMBIENT\nbaseAmbientColor=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb*vAmbientInfos.y;\n#endif\n\n#ifdef SPECULARTERM\nfloat glossiness=vSpecularColor.a;\nvec3 specularColor=vSpecularColor.rgb;\n#ifdef SPECULAR\nvec4 specularMapColor=texture2D(specularSampler,vSpecularUV+uvOffset);\nspecularColor=specularMapColor.rgb;\n#ifdef GLOSSINESS\nglossiness=glossiness*specularMapColor.a;\n#endif\n#endif\n#else\nfloat glossiness=0.;\n#endif\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\nfloat shadow=1.;\n#ifdef LIGHTMAP\nvec3 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset).rgb*vLightmapInfos.y;\n#endif\n#include[0..maxSimultaneousLights]\n\nvec3 refractionColor=vec3(0.,0.,0.);\n#ifdef REFRACTION\nvec3 refractionVector=normalize(refract(-viewDirectionW,normalW,vRefractionInfos.y));\n#ifdef REFRACTIONMAP_3D\nrefractionVector.y=refractionVector.y*vRefractionInfos.w;\nif (dot(refractionVector,viewDirectionW)<1.0)\n{\nrefractionColor=textureCube(refractionCubeSampler,refractionVector).rgb*vRefractionInfos.x;\n}\n#else\nvec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));\nvec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;\nrefractionCoords.y=1.0-refractionCoords.y;\nrefractionColor=texture2D(refraction2DSampler,refractionCoords).rgb*vRefractionInfos.x;\n#endif\n#endif\n\nvec3 reflectionColor=vec3(0.,0.,0.);\n#ifdef REFLECTION\nvec3 vReflectionUVW=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#ifdef REFLECTIONMAP_3D\n#ifdef ROUGHNESS\nfloat bias=vReflectionInfos.y;\n#ifdef SPECULARTERM\n#ifdef SPECULAR\n#ifdef GLOSSINESS\nbias*=(1.0-specularMapColor.a);\n#endif\n#endif\n#endif\nreflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW,bias).rgb*vReflectionInfos.x;\n#else\nreflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW).rgb*vReflectionInfos.x;\n#endif\n#else\nvec2 coords=vReflectionUVW.xy;\n#ifdef REFLECTIONMAP_PROJECTION\ncoords/=vReflectionUVW.z;\n#endif\ncoords.y=1.0-coords.y;\nreflectionColor=texture2D(reflection2DSampler,coords).rgb*vReflectionInfos.x;\n#endif\n#ifdef REFLECTIONFRESNEL\nfloat reflectionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,reflectionRightColor.a,reflectionLeftColor.a);\n#ifdef REFLECTIONFRESNELFROMSPECULAR\n#ifdef SPECULARTERM\nreflectionColor*=specularColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#else\nreflectionColor*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#endif\n#else\nreflectionColor*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#endif\n#endif\n#endif\n#ifdef REFRACTIONFRESNEL\nfloat refractionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,refractionRightColor.a,refractionLeftColor.a);\nrefractionColor*=refractionLeftColor.rgb*(1.0-refractionFresnelTerm)+refractionFresnelTerm*refractionRightColor.rgb;\n#endif\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);\n#ifdef OPACITYRGB\nopacityMap.rgb=opacityMap.rgb*vec3(0.3,0.59,0.11);\nalpha*=(opacityMap.x+opacityMap.y+opacityMap.z)* vOpacityInfos.y;\n#else\nalpha*=opacityMap.a*vOpacityInfos.y;\n#endif\n#endif\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#ifdef OPACITYFRESNEL\nfloat opacityFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,opacityParts.z,opacityParts.w);\nalpha+=opacityParts.x*(1.0-opacityFresnelTerm)+opacityFresnelTerm*opacityParts.y;\n#endif\n\nvec3 emissiveColor=vEmissiveColor;\n#ifdef EMISSIVE\nemissiveColor+=texture2D(emissiveSampler,vEmissiveUV+uvOffset).rgb*vEmissiveInfos.y;\n#endif\n#ifdef EMISSIVEFRESNEL\nfloat emissiveFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,emissiveRightColor.a,emissiveLeftColor.a);\nemissiveColor*=emissiveLeftColor.rgb*(1.0-emissiveFresnelTerm)+emissiveFresnelTerm*emissiveRightColor.rgb;\n#endif\n\n#ifdef DIFFUSEFRESNEL\nfloat diffuseFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,diffuseRightColor.a,diffuseLeftColor.a);\ndiffuseBase*=diffuseLeftColor.rgb*(1.0-diffuseFresnelTerm)+diffuseFresnelTerm*diffuseRightColor.rgb;\n#endif\n\n#ifdef EMISSIVEASILLUMINATION\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#else\n#ifdef LINKEMISSIVEWITHDIFFUSE\nvec3 finalDiffuse=clamp((diffuseBase+emissiveColor)*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#else\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor+emissiveColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#endif\n#endif\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase*specularColor;\n#ifdef SPECULAROVERALPHA\nalpha=clamp(alpha+dot(finalSpecular,vec3(0.3,0.59,0.11)),0.,1.);\n#endif\n#else\nvec3 finalSpecular=vec3(0.0);\n#endif\n#ifdef REFLECTIONOVERALPHA\nalpha=clamp(alpha+dot(reflectionColor,vec3(0.3,0.59,0.11)),0.,1.);\n#endif\n\n#ifdef EMISSIVEASILLUMINATION\nvec4 color=vec4(clamp(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor+emissiveColor+refractionColor,0.0,1.0),alpha);\n#else\nvec4 color=vec4(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor+refractionColor,alpha);\n#endif\n\n#ifdef LIGHTMAP\n#ifndef LIGHTMAPEXCLUDED\n#ifdef USELIGHTMAPASSHADOWMAP\ncolor.rgb*=lightmapColor;\n#else\ncolor.rgb+=lightmapColor;\n#endif\n#endif\n#endif\n#include\n#include\n\n\n#ifdef IMAGEPROCESSINGPOSTPROCESS\ncolor.rgb=toLinearSpace(color.rgb);\n#else\n#ifdef IMAGEPROCESSING\ncolor.rgb=toLinearSpace(color.rgb);\ncolor=applyImageProcessing(color);\n#endif\n#endif\ngl_FragColor=color;\n}",pbrVertexShader:"precision highp float;\n#include<__decl__pbrVertex>\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef TANGENT\nattribute vec4 tangent;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2; \n#endif \n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include\n\n#include\n#if defined(ALBEDO) && ALBEDODIRECTUV == 0\nvarying vec2 vAlbedoUV;\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nvarying vec2 vAmbientUV;\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nvarying vec2 vOpacityUV;\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nvarying vec2 vEmissiveUV;\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nvarying vec2 vLightmapUV;\n#endif\n#if defined(REFLECTIVITY) && REFLECTIVITYDIRECTUV == 0\nvarying vec2 vReflectivityUV;\n#endif\n#if defined(MICROSURFACEMAP) && MICROSURFACEMAPDIRECTUV == 0\nvarying vec2 vMicroSurfaceSamplerUV;\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nvarying vec2 vBumpUV;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#if defined(USESPHERICALFROMREFLECTIONMAP) && !defined(USESPHERICALINFRAGMENT)\nvarying vec3 vEnvironmentIrradiance;\n#include\n#endif\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include\n#include\n#include\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include\n#include[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#include\nvoid main(void) {\nvec3 positionUpdated=position;\n#ifdef NORMAL\nvec3 normalUpdated=normal;\n#endif\n#ifdef TANGENT\nvec4 tangentUpdated=tangent;\n#endif\n#include[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvPositionUVW=positionUpdated;\n#endif \n#include\n#include\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normalUpdated,0.0)));\n#if defined(USESPHERICALFROMREFLECTIONMAP) && !defined(USESPHERICALINFRAGMENT)\nvec3 reflectionVector=vec3(reflectionMatrix*vec4(vNormalW,0)).xyz;\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\nvEnvironmentIrradiance=environmentIrradianceJones(reflectionVector);\n#endif\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef MAINUV1\nvMainUV1=uv;\n#endif \n#ifdef MAINUV2\nvMainUV2=uv2;\n#endif \n#if defined(ALBEDO) && ALBEDODIRECTUV == 0 \nif (vAlbedoInfos.x == 0.)\n{\nvAlbedoUV=vec2(albedoMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAlbedoUV=vec2(albedoMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0 \nif (vAmbientInfos.x == 0.)\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0 \nif (vOpacityInfos.x == 0.)\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0 \nif (vEmissiveInfos.x == 0.)\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0 \nif (vLightmapInfos.x == 0.)\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(REFLECTIVITY) && REFLECTIVITYDIRECTUV == 0 \nif (vReflectivityInfos.x == 0.)\n{\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(MICROSURFACEMAP) && MICROSURFACEMAPDIRECTUV == 0 \nif (vMicroSurfaceSamplerInfos.x == 0.)\n{\nvMicroSurfaceSamplerUV=vec2(microSurfaceSamplerMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvMicroSurfaceSamplerUV=vec2(microSurfaceSamplerMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0 \nif (vBumpInfos.x == 0.)\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n\n#include\n\n#include\n\n#include\n\n#include[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n\n#include\n}", pbrPixelShader:"#if defined(BUMP) || !defined(NORMAL) || defined(FORCENORMALFORWARD)\n#extension GL_OES_standard_derivatives : enable\n#endif\n#ifdef LODBASEDMICROSFURACE\n#extension GL_EXT_shader_texture_lod : enable\n#endif\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\nprecision highp float;\n#include<__decl__pbrFragment>\nuniform vec4 vEyePosition;\nuniform vec3 vAmbientColor;\nuniform vec4 vCameraInfos;\n\nvarying vec3 vPositionW;\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif \n#ifdef MAINUV2 \nvarying vec2 vMainUV2; \n#endif \n#ifdef NORMAL\nvarying vec3 vNormalW;\n#if defined(USESPHERICALFROMREFLECTIONMAP) && !defined(USESPHERICALINFRAGMENT)\nvarying vec3 vEnvironmentIrradiance;\n#endif\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n\n#ifdef ALBEDO\n#if ALBEDODIRECTUV == 1\n#define vAlbedoUV vMainUV1\n#elif ALBEDODIRECTUV == 2\n#define vAlbedoUV vMainUV2\n#else\nvarying vec2 vAlbedoUV;\n#endif\nuniform sampler2D albedoSampler;\n#endif\n#ifdef AMBIENT\n#if AMBIENTDIRECTUV == 1\n#define vAmbientUV vMainUV1\n#elif AMBIENTDIRECTUV == 2\n#define vAmbientUV vMainUV2\n#else\nvarying vec2 vAmbientUV;\n#endif\nuniform sampler2D ambientSampler;\n#endif\n#ifdef OPACITY\n#if OPACITYDIRECTUV == 1\n#define vOpacityUV vMainUV1\n#elif OPACITYDIRECTUV == 2\n#define vOpacityUV vMainUV2\n#else\nvarying vec2 vOpacityUV;\n#endif\nuniform sampler2D opacitySampler;\n#endif\n#ifdef EMISSIVE\n#if EMISSIVEDIRECTUV == 1\n#define vEmissiveUV vMainUV1\n#elif EMISSIVEDIRECTUV == 2\n#define vEmissiveUV vMainUV2\n#else\nvarying vec2 vEmissiveUV;\n#endif\nuniform sampler2D emissiveSampler;\n#endif\n#ifdef LIGHTMAP\n#if LIGHTMAPDIRECTUV == 1\n#define vLightmapUV vMainUV1\n#elif LIGHTMAPDIRECTUV == 2\n#define vLightmapUV vMainUV2\n#else\nvarying vec2 vLightmapUV;\n#endif\nuniform sampler2D lightmapSampler;\n#endif\n#ifdef REFLECTIVITY\n#if REFLECTIVITYDIRECTUV == 1\n#define vReflectivityUV vMainUV1\n#elif REFLECTIVITYDIRECTUV == 2\n#define vReflectivityUV vMainUV2\n#else\nvarying vec2 vReflectivityUV;\n#endif\nuniform sampler2D reflectivitySampler;\n#endif\n#ifdef MICROSURFACEMAP\n#if MICROSURFACEMAPDIRECTUV == 1\n#define vMicroSurfaceSamplerUV vMainUV1\n#elif MICROSURFACEMAPDIRECTUV == 2\n#define vMicroSurfaceSamplerUV vMainUV2\n#else\nvarying vec2 vMicroSurfaceSamplerUV;\n#endif\nuniform sampler2D microSurfaceSampler;\n#endif\n\n#ifdef REFRACTION\n#ifdef REFRACTIONMAP_3D\n#define sampleRefraction(s,c) textureCube(s,c)\nuniform samplerCube refractionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleRefractionLod(s,c,l) textureCubeLodEXT(s,c,l)\n#else\nuniform samplerCube refractionSamplerLow;\nuniform samplerCube refractionSamplerHigh;\n#endif\n#else\n#define sampleRefraction(s,c) texture2D(s,c)\nuniform sampler2D refractionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleRefractionLod(s,c,l) texture2DLodEXT(s,c,l)\n#else\nuniform samplerCube refractionSamplerLow;\nuniform samplerCube refractionSamplerHigh;\n#endif\n#endif\n#endif\n\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\n#define sampleReflection(s,c) textureCube(s,c)\nuniform samplerCube reflectionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleReflectionLod(s,c,l) textureCubeLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#else\n#define sampleReflection(s,c) texture2D(s,c)\nuniform sampler2D reflectionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleReflectionLod(s,c,l) texture2DLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#endif\n#include\n#endif\n#ifdef ENVIRONMENTBRDF\nuniform sampler2D environmentBrdfSampler;\n#endif\n\n#ifndef FROMLINEARSPACE\n#define FROMLINEARSPACE;\n#endif\n#include\n#include\n#include\n\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n\n#include\nvoid main(void) {\n#include\n\n\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;\n#endif\n#include\n#if defined(FORCENORMALFORWARD) && defined(NORMAL)\nvec3 faceNormal=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;\n#if defined(TWOSIDEDLIGHTING)\nfaceNormal=gl_FrontFacing ? faceNormal : -faceNormal;\n#endif\nfloat comp=sign(dot(normalW,faceNormal));\nnormalW*=-comp;\n#endif\n#if defined(TWOSIDEDLIGHTING) && defined(NORMAL)\nnormalW=gl_FrontFacing ? normalW : -normalW;\n#endif\n\n\nvec3 surfaceAlbedo=vAlbedoColor.rgb;\n\nfloat alpha=vAlbedoColor.a;\n#ifdef ALBEDO\nvec4 albedoTexture=texture2D(albedoSampler,vAlbedoUV+uvOffset);\n#if defined(ALPHAFROMALBEDO) || defined(ALPHATEST)\nalpha*=albedoTexture.a;\n#endif\nsurfaceAlbedo*=toLinearSpace(albedoTexture.rgb);\nsurfaceAlbedo*=vAlbedoInfos.y;\n#endif\n\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);\n#ifdef OPACITYRGB\nalpha=getLuminance(opacityMap.rgb);\n#else\nalpha*=opacityMap.a;\n#endif\nalpha*=vOpacityInfos.y;\n#endif\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#if !defined(LINKREFRACTIONTOTRANSPARENCY) && !defined(ALPHAFRESNEL)\n#ifdef ALPHATEST\nif (alpha<=ALPHATESTVALUE)\ndiscard;\n#ifndef ALPHABLEND\n\nalpha=1.0;\n#endif\n#endif\n#endif\n#ifdef VERTEXCOLOR\nsurfaceAlbedo*=vColor.rgb;\n#endif\n\nvec3 ambientOcclusionColor=vec3(1.,1.,1.);\n#ifdef AMBIENT\nvec3 ambientOcclusionColorMap=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb*vAmbientInfos.y;\n#ifdef AMBIENTINGRAYSCALE\nambientOcclusionColorMap=vec3(ambientOcclusionColorMap.r,ambientOcclusionColorMap.r,ambientOcclusionColorMap.r);\n#endif\nambientOcclusionColor=mix(ambientOcclusionColor,ambientOcclusionColorMap,vAmbientInfos.z);\n#endif\n\nfloat microSurface=vReflectivityColor.a;\nvec3 surfaceReflectivityColor=vReflectivityColor.rgb;\n#ifdef METALLICWORKFLOW\nvec2 metallicRoughness=surfaceReflectivityColor.rg;\n#ifdef REFLECTIVITY\nvec4 surfaceMetallicColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset);\n#ifdef AOSTOREINMETALMAPRED\nvec3 aoStoreInMetalMap=vec3(surfaceMetallicColorMap.r,surfaceMetallicColorMap.r,surfaceMetallicColorMap.r);\nambientOcclusionColor=mix(ambientOcclusionColor,aoStoreInMetalMap,vReflectivityInfos.z);\n#endif\n#ifdef METALLNESSSTOREINMETALMAPBLUE\nmetallicRoughness.r*=surfaceMetallicColorMap.b;\n#else\nmetallicRoughness.r*=surfaceMetallicColorMap.r;\n#endif\n#ifdef ROUGHNESSSTOREINMETALMAPALPHA\nmetallicRoughness.g*=surfaceMetallicColorMap.a;\n#else\n#ifdef ROUGHNESSSTOREINMETALMAPGREEN\nmetallicRoughness.g*=surfaceMetallicColorMap.g;\n#endif\n#endif\n#endif\n#ifdef MICROSURFACEMAP\nvec4 microSurfaceTexel=texture2D(microSurfaceSampler,vMicroSurfaceSamplerUV+uvOffset)*vMicroSurfaceSamplerInfos.y;\nmetallicRoughness.g*=microSurfaceTexel.r;\n#endif\n\nmicroSurface=1.0-metallicRoughness.g;\n\nvec3 baseColor=surfaceAlbedo;\n\n\nconst vec3 DefaultSpecularReflectanceDielectric=vec3(0.04,0.04,0.04);\n\nsurfaceAlbedo=mix(baseColor.rgb*(1.0-DefaultSpecularReflectanceDielectric.r),vec3(0.,0.,0.),metallicRoughness.r);\n\nsurfaceReflectivityColor=mix(DefaultSpecularReflectanceDielectric,baseColor,metallicRoughness.r);\n#else\n#ifdef REFLECTIVITY\nvec4 surfaceReflectivityColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset);\nsurfaceReflectivityColor*=toLinearSpace(surfaceReflectivityColorMap.rgb);\nsurfaceReflectivityColor*=vReflectivityInfos.y;\n#ifdef MICROSURFACEFROMREFLECTIVITYMAP\nmicroSurface*=surfaceReflectivityColorMap.a;\nmicroSurface*=vReflectivityInfos.z;\n#else\n#ifdef MICROSURFACEAUTOMATIC\nmicroSurface*=computeDefaultMicroSurface(microSurface,surfaceReflectivityColor);\n#endif\n#ifdef MICROSURFACEMAP\nvec4 microSurfaceTexel=texture2D(microSurfaceSampler,vMicroSurfaceSamplerUV+uvOffset)*vMicroSurfaceSamplerInfos.y;\nmicroSurface*=microSurfaceTexel.r;\n#endif\n#endif\n#endif\n#endif\n\nmicroSurface=clamp(microSurface,0.,1.);\n\nfloat roughness=1.-microSurface;\n\n#ifdef ALPHAFRESNEL\n#if defined(ALPHATEST) || defined(ALPHABLEND)\n\n\n\nfloat opacityPerceptual=alpha;\nfloat opacity0=opacityPerceptual*opacityPerceptual;\nfloat opacity90=fresnelGrazingReflectance(opacity0);\nvec3 normalForward=faceforward(normalW,-viewDirectionW,normalW);\n\nalpha=fresnelSchlickEnvironmentGGX(clamp(dot(viewDirectionW,normalForward),0.0,1.0),vec3(opacity0),vec3(opacity90),sqrt(microSurface)).x;\n#ifdef ALPHATEST\nif (alpha<=ALPHATESTVALUE)\ndiscard;\n#ifndef ALPHABLEND\n\nalpha=1.0;\n#endif\n#endif\n#endif\n#endif\n\n\nfloat NdotVUnclamped=dot(normalW,viewDirectionW);\nfloat NdotV=clamp(NdotVUnclamped,0.,1.)+0.00001;\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\n\n#ifdef REFRACTION\nvec3 environmentRefraction=vec3(0.,0.,0.);\nvec3 refractionVector=refract(-viewDirectionW,normalW,vRefractionInfos.y);\n#ifdef REFRACTIONMAP_OPPOSITEZ\nrefractionVector.z*=-1.0;\n#endif\n\n#ifdef REFRACTIONMAP_3D\nrefractionVector.y=refractionVector.y*vRefractionInfos.w;\nvec3 refractionCoords=refractionVector;\nrefractionCoords=vec3(refractionMatrix*vec4(refractionCoords,0));\n#else\nvec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));\nvec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;\nrefractionCoords.y=1.0-refractionCoords.y;\n#endif\n#ifdef LODINREFRACTIONALPHA\nfloat refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,alphaG,NdotVUnclamped);\n#else\nfloat refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,alphaG,1.0);\n#endif\n#ifdef LODBASEDMICROSFURACE\n\nrefractionLOD=refractionLOD*vRefractionMicrosurfaceInfos.y+vRefractionMicrosurfaceInfos.z;\n#ifdef LODINREFRACTIONALPHA\n\n\n\n\n\n\n\n\n\nfloat automaticRefractionLOD=UNPACK_LOD(sampleRefraction(refractionSampler,refractionCoords).a);\nfloat requestedRefractionLOD=max(automaticRefractionLOD,refractionLOD);\n#else\nfloat requestedRefractionLOD=refractionLOD;\n#endif\nenvironmentRefraction=sampleRefractionLod(refractionSampler,refractionCoords,requestedRefractionLOD).rgb;\n#else\nfloat lodRefractionNormalized=clamp(refractionLOD/log2(vRefractionMicrosurfaceInfos.x),0.,1.);\nfloat lodRefractionNormalizedDoubled=lodRefractionNormalized*2.0;\nvec3 environmentRefractionMid=sampleRefraction(refractionSampler,refractionCoords).rgb;\nif(lodRefractionNormalizedDoubled<1.0){\nenvironmentRefraction=mix(\nsampleRefraction(refractionSamplerHigh,refractionCoords).rgb,\nenvironmentRefractionMid,\nlodRefractionNormalizedDoubled\n);\n}else{\nenvironmentRefraction=mix(\nenvironmentRefractionMid,\nsampleRefraction(refractionSamplerLow,refractionCoords).rgb,\nlodRefractionNormalizedDoubled-1.0\n);\n}\n#endif\n#ifdef GAMMAREFRACTION\nenvironmentRefraction=toLinearSpace(environmentRefraction.rgb);\n#endif\n\nenvironmentRefraction*=vRefractionInfos.x;\n#endif\n\n#ifdef REFLECTION\nvec3 environmentRadiance=vec3(0.,0.,0.);\nvec3 environmentIrradiance=vec3(0.,0.,0.);\nvec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\n\n#ifdef REFLECTIONMAP_3D\nvec3 reflectionCoords=reflectionVector;\n#else\nvec2 reflectionCoords=reflectionVector.xy;\n#ifdef REFLECTIONMAP_PROJECTION\nreflectionCoords/=reflectionVector.z;\n#endif\nreflectionCoords.y=1.0-reflectionCoords.y;\n#endif\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nfloat reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG,NdotVUnclamped);\n#else\nfloat reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG,1.);\n#endif\n#ifdef LODBASEDMICROSFURACE\n\nreflectionLOD=reflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;\n#ifdef LODINREFLECTIONALPHA\n\n\n\n\n\n\n\n\n\nfloat automaticReflectionLOD=UNPACK_LOD(sampleReflection(reflectionSampler,reflectionCoords).a);\nfloat requestedReflectionLOD=max(automaticReflectionLOD,reflectionLOD);\n#else\nfloat requestedReflectionLOD=reflectionLOD;\n#endif\nenvironmentRadiance=sampleReflectionLod(reflectionSampler,reflectionCoords,requestedReflectionLOD).rgb;\n#else\nfloat lodReflectionNormalized=clamp(reflectionLOD/log2(vReflectionMicrosurfaceInfos.x),0.,1.);\nfloat lodReflectionNormalizedDoubled=lodReflectionNormalized*2.0;\nvec3 environmentSpecularMid=sampleReflection(reflectionSampler,reflectionCoords).rgb;\nif(lodReflectionNormalizedDoubled<1.0){\nenvironmentRadiance=mix(\nsampleReflection(reflectionSamplerHigh,reflectionCoords).rgb,\nenvironmentSpecularMid,\nlodReflectionNormalizedDoubled\n);\n}else{\nenvironmentRadiance=mix(\nenvironmentSpecularMid,\nsampleReflection(reflectionSamplerLow,reflectionCoords).rgb,\nlodReflectionNormalizedDoubled-1.0\n);\n}\n#endif\n#ifdef GAMMAREFLECTION\nenvironmentRadiance=toLinearSpace(environmentRadiance.rgb);\n#endif\n\n#ifdef USESPHERICALFROMREFLECTIONMAP\n#if defined(NORMAL) && !defined(USESPHERICALINFRAGMENT)\nenvironmentIrradiance=vEnvironmentIrradiance;\n#else\nvec3 irradianceVector=vec3(reflectionMatrix*vec4(normalW,0)).xyz;\n#ifdef REFLECTIONMAP_OPPOSITEZ\nirradianceVector.z*=-1.0;\n#endif\nenvironmentIrradiance=environmentIrradianceJones(irradianceVector);\n#endif\n#endif\n\nenvironmentRadiance*=vReflectionInfos.x;\nenvironmentRadiance*=vReflectionColor.rgb;\nenvironmentIrradiance*=vReflectionColor.rgb;\n#endif\n\n\n\nfloat reflectance=max(max(surfaceReflectivityColor.r,surfaceReflectivityColor.g),surfaceReflectivityColor.b);\nfloat reflectance90=fresnelGrazingReflectance(reflectance);\nvec3 specularEnvironmentR0=surfaceReflectivityColor.rgb;\nvec3 specularEnvironmentR90=vec3(1.0,1.0,1.0)*reflectance90;\n\nvec3 diffuseBase=vec3(0.,0.,0.);\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\n#ifdef LIGHTMAP\nvec3 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset).rgb*vLightmapInfos.y;\n#endif\nlightingInfo info;\nfloat shadow=1.; \nfloat NdotL=-1.;\n#include[0..maxSimultaneousLights]\n\n#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\n\nvec2 brdfSamplerUV=vec2(NdotV,roughness);\n\nvec4 environmentBrdf=texture2D(environmentBrdfSampler,brdfSamplerUV);\nvec3 specularEnvironmentReflectance=specularEnvironmentR0*environmentBrdf.x+environmentBrdf.y;\n#ifdef AMBIENTINGRAYSCALE\nfloat ambientMonochrome=ambientOcclusionColor.r;\n#else\nfloat ambientMonochrome=getLuminance(ambientOcclusionColor);\n#endif\nfloat seo=environmentRadianceOcclusion(ambientMonochrome,NdotVUnclamped);\nspecularEnvironmentReflectance*=seo;\n#ifdef BUMP\n#ifdef REFLECTIONMAP_3D\nfloat eho=environmentHorizonOcclusion(reflectionCoords,normalW);\nspecularEnvironmentReflectance*=eho;\n#endif\n#endif\n#else\n\nvec3 specularEnvironmentReflectance=fresnelSchlickEnvironmentGGX(NdotV,specularEnvironmentR0,specularEnvironmentR90,sqrt(microSurface));\n#endif\n\n#ifdef REFRACTION\nvec3 refractance=vec3(0.0,0.0,0.0);\nvec3 transmission=vec3(1.0,1.0,1.0);\n#ifdef LINKREFRACTIONTOTRANSPARENCY\n\ntransmission*=(1.0-alpha);\n\n\nvec3 mixedAlbedo=surfaceAlbedo;\nfloat maxChannel=max(max(mixedAlbedo.r,mixedAlbedo.g),mixedAlbedo.b);\nvec3 tint=clamp(maxChannel*mixedAlbedo,0.0,1.0);\n\nsurfaceAlbedo*=alpha;\n\nenvironmentIrradiance*=alpha;\n\nenvironmentRefraction*=tint;\n\nalpha=1.0;\n#endif\n\nvec3 bounceSpecularEnvironmentReflectance=(2.0*specularEnvironmentReflectance)/(1.0+specularEnvironmentReflectance);\nspecularEnvironmentReflectance=mix(bounceSpecularEnvironmentReflectance,specularEnvironmentReflectance,alpha);\n\ntransmission*=1.0-specularEnvironmentReflectance;\n\nrefractance=transmission;\n#endif\n\n\n\n\nsurfaceAlbedo.rgb=(1.-reflectance)*surfaceAlbedo.rgb;\n\nvec3 finalDiffuse=diffuseBase;\nfinalDiffuse.rgb+=vAmbientColor;\nfinalDiffuse*=surfaceAlbedo.rgb;\nfinalDiffuse=max(finalDiffuse,0.0);\n\n#ifdef REFLECTION\nvec3 finalIrradiance=environmentIrradiance;\nfinalIrradiance*=surfaceAlbedo.rgb;\n#endif\n\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase;\nfinalSpecular=max(finalSpecular,0.0);\n\nvec3 finalSpecularScaled=finalSpecular*vLightingIntensity.x*vLightingIntensity.w;\n#endif\n\n#ifdef REFLECTION\nvec3 finalRadiance=environmentRadiance;\nfinalRadiance*=specularEnvironmentReflectance;\n\nvec3 finalRadianceScaled=finalRadiance*vLightingIntensity.z;\n#endif\n\n#ifdef REFRACTION\nvec3 finalRefraction=environmentRefraction;\nfinalRefraction*=refractance;\n#endif\n\nvec3 finalEmissive=vEmissiveColor;\n#ifdef EMISSIVE\nvec3 emissiveColorTex=texture2D(emissiveSampler,vEmissiveUV+uvOffset).rgb;\nfinalEmissive*=toLinearSpace(emissiveColorTex.rgb);\nfinalEmissive*=vEmissiveInfos.y;\n#endif\n\n#ifdef ALPHABLEND\nfloat luminanceOverAlpha=0.0;\n#if defined(REFLECTION) && defined(RADIANCEOVERALPHA)\nluminanceOverAlpha+=getLuminance(finalRadianceScaled);\n#endif\n#if defined(SPECULARTERM) && defined(SPECULAROVERALPHA)\nluminanceOverAlpha+=getLuminance(finalSpecularScaled);\n#endif\n#if defined(RADIANCEOVERALPHA) || defined(SPECULAROVERALPHA)\nalpha=clamp(alpha+luminanceOverAlpha*luminanceOverAlpha,0.,1.);\n#endif\n#endif\n\n\n\nvec4 finalColor=vec4(finalDiffuse*ambientOcclusionColor*vLightingIntensity.x +\n#ifdef REFLECTION\nfinalIrradiance*ambientOcclusionColor*vLightingIntensity.z +\n#endif\n#ifdef SPECULARTERM\n\n\nfinalSpecularScaled +\n#endif\n#ifdef REFLECTION\n\n\nfinalRadianceScaled +\n#endif\n#ifdef REFRACTION\nfinalRefraction*vLightingIntensity.z +\n#endif\nfinalEmissive*vLightingIntensity.y,\nalpha);\n\n#ifdef LIGHTMAP\n#ifndef LIGHTMAPEXCLUDED\n#ifdef USELIGHTMAPASSHADOWMAP\nfinalColor.rgb*=lightmapColor;\n#else\nfinalColor.rgb+=lightmapColor;\n#endif\n#endif\n#endif\n\nfinalColor=max(finalColor,0.0);\n#include\n#include(color,finalColor)\n#ifdef IMAGEPROCESSINGPOSTPROCESS\n\n\nfinalColor.rgb=clamp(finalColor.rgb,0.,30.0);\n#else\n\nfinalColor=applyImageProcessing(finalColor);\n#endif\n#ifdef PREMULTIPLYALPHA\n\nfinalColor.rgb*=finalColor.a;\n#endif\ngl_FragColor=finalColor;\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n}",spritesVertexShader:"\nattribute vec4 position;\nattribute vec4 options;\nattribute vec4 cellInfo;\nattribute vec4 color;\n\nuniform vec2 textureInfos;\nuniform mat4 view;\nuniform mat4 projection;\n\nvarying vec2 vUV;\nvarying vec4 vColor;\n#include\nvoid main(void) { \nvec3 viewPos=(view*vec4(position.xyz,1.0)).xyz; \nvec2 cornerPos;\nfloat angle=position.w;\nvec2 size=vec2(options.x,options.y);\nvec2 offset=options.zw;\nvec2 uvScale=textureInfos.xy;\ncornerPos=vec2(offset.x-0.5,offset.y-0.5)*size;\n\nvec3 rotatedCorner;\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.z=0.;\n\nviewPos+=rotatedCorner;\ngl_Position=projection*vec4(viewPos,1.0); \n\nvColor=color;\n\nvec2 uvOffset=vec2(abs(offset.x-cellInfo.x),1.0-abs(offset.y-cellInfo.y));\nvUV=(uvOffset+cellInfo.zw)*uvScale;\n\n#ifdef FOG\nvFogDistance=viewPos;\n#endif\n}",spritesPixelShader:"uniform bool alphaTest;\nvarying vec4 vColor;\n\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n\n#include\nvoid main(void) {\nvec4 color=texture2D(diffuseSampler,vUV);\nif (alphaTest) \n{\nif (color.a<0.95)\ndiscard;\n}\ncolor*=vColor;\n#include\ngl_FragColor=color;\n}",particlesVertexShader:"\nattribute vec3 position;\nattribute vec4 color;\nattribute vec4 options;\n\nuniform mat4 view;\nuniform mat4 projection;\n\nvarying vec2 vUV;\nvarying vec4 vColor;\n#ifdef CLIPPLANE\nuniform vec4 vClipPlane;\nuniform mat4 invView;\nvarying float fClipDistance;\n#endif\nvoid main(void) { \nvec3 viewPos=(view*vec4(position,1.0)).xyz; \nvec3 cornerPos;\nfloat size=options.y;\nfloat angle=options.x;\nvec2 offset=options.zw;\ncornerPos=vec3(offset.x-0.5,offset.y-0.5,0.)*size;\n\nvec3 rotatedCorner;\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.z=0.;\n\nviewPos+=rotatedCorner;\ngl_Position=projection*vec4(viewPos,1.0); \nvColor=color;\nvUV=offset;\n\n#ifdef CLIPPLANE\nvec4 worldPos=invView*vec4(viewPos,1.0);\nfClipDistance=dot(worldPos,vClipPlane);\n#endif\n}",particlesPixelShader:"\nvarying vec2 vUV;\nvarying vec4 vColor;\nuniform vec4 textureMask;\nuniform sampler2D diffuseSampler;\n#ifdef CLIPPLANE\nvarying float fClipDistance;\n#endif\nvoid main(void) {\n#ifdef CLIPPLANE\nif (fClipDistance>0.0)\ndiscard;\n#endif\nvec4 baseColor=texture2D(diffuseSampler,vUV);\ngl_FragColor=(baseColor*textureMask+(vec4(1.,1.,1.,1.)-textureMask))*vColor;\n}",colorVertexShader:"\nattribute vec3 position;\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include\n\nuniform mat4 viewProjection;\nuniform mat4 world;\n\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\nvoid main(void) {\nmat4 finalWorld=world;\n#include\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\n#ifdef VERTEXCOLOR\n\nvColor=color;\n#endif\n}",colorPixelShader:"#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#else\nuniform vec4 color;\n#endif\nvoid main(void) {\n#ifdef VERTEXCOLOR\ngl_FragColor=vColor;\n#else\ngl_FragColor=color;\n#endif\n}",postprocessVertexShader:"\nattribute vec2 position;\nuniform vec2 scale;\n\nvarying vec2 vUV;\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) { \nvUV=(position*madd+madd)*scale;\ngl_Position=vec4(position,0.0,1.0);\n}",passPixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nvoid main(void) \n{\ngl_FragColor=texture2D(textureSampler,vUV);\n}",shadowMapVertexShader:"\nattribute vec3 position;\n#include\n\n#include\nuniform mat4 viewProjection;\nuniform vec2 biasAndScale;\nuniform vec2 depthValues;\nvarying float vDepthMetric;\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform mat4 diffuseMatrix;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#endif\nvoid main(void)\n{\n#include\n#include\nvec4 worldPos=finalWorld*vec4(position,1.0);\ngl_Position=viewProjection*worldPos;\nvDepthMetric=((gl_Position.z+depthValues.x)/(depthValues.y))+biasAndScale.x;\n#ifdef ALPHATEST\n#ifdef UV1\nvUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n#endif\n#ifdef UV2\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n}",shadowMapPixelShader:"#ifndef FLOAT\nvec4 pack(float depth)\n{\nconst vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);\nconst vec4 bit_mask=vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);\nvec4 res=fract(depth*bit_shift);\nres-=res.xxyz*bit_mask;\nreturn res;\n}\n#endif\nvarying float vDepthMetric;\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n#endif\nuniform vec2 biasAndScale;\nuniform vec2 depthValues;\nvoid main(void)\n{\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\nfloat depth=vDepthMetric;\n#ifdef ESM\ndepth=clamp(exp(-min(87.,biasAndScale.y*depth)),0.,1.);\n#endif\n#ifdef FLOAT\ngl_FragColor=vec4(depth,1.0,1.0,1.0);\n#else\ngl_FragColor=pack(depth);\n#endif\n}",depthBoxBlurPixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n\nuniform vec2 screenSize;\nvoid main(void)\n{\nvec4 colorDepth=vec4(0.0);\nfor (int x=-OFFSET; x<=OFFSET; x++)\nfor (int y=-OFFSET; y<=OFFSET; y++)\ncolorDepth+=texture2D(textureSampler,vUV+vec2(x,y)/screenSize);\ngl_FragColor=(colorDepth/float((OFFSET*2+1)*(OFFSET*2+1)));\n}",proceduralVertexShader:"\nattribute vec2 position;\n\nvarying vec2 vPosition;\nvarying vec2 vUV;\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) { \nvPosition=position;\nvUV=position*madd+madd;\ngl_Position=vec4(position,0.0,1.0);\n}",depthVertexShader:"\nattribute vec3 position;\n#include\n\n#include\nuniform mat4 viewProjection;\nuniform vec2 depthValues;\n#if defined(ALPHATEST) || defined(NEED_UV)\nvarying vec2 vUV;\nuniform mat4 diffuseMatrix;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#endif\nvarying float vDepthMetric;\nvoid main(void)\n{\n#include\n#include\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\nvDepthMetric=((gl_Position.z+depthValues.x)/(depthValues.y));\n#if defined(ALPHATEST) || defined(BASIC_RENDER)\n#ifdef UV1\nvUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n#endif\n#ifdef UV2\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n}",depthPixelShader:"#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n#endif\nvarying float vDepthMetric;\nvoid main(void)\n{\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\ngl_FragColor=vec4(vDepthMetric,vDepthMetric*vDepthMetric,0.0,1.0);\n}",ssaoPixelShader:"\nuniform sampler2D textureSampler;\nvarying vec2 vUV;\n#ifdef SSAO\nuniform sampler2D randomSampler;\nuniform float randTextureTiles;\nuniform float samplesFactor;\nuniform vec3 sampleSphere[SAMPLES];\nuniform float totalStrength;\nuniform float radius;\nuniform float area;\nuniform float fallOff;\nuniform float base;\nvec3 normalFromDepth(float depth,vec2 coords)\n{\nvec2 offset1=vec2(0.0,radius);\nvec2 offset2=vec2(radius,0.0);\nfloat depth1=texture2D(textureSampler,coords+offset1).r;\nfloat depth2=texture2D(textureSampler,coords+offset2).r;\nvec3 p1=vec3(offset1,depth1-depth);\nvec3 p2=vec3(offset2,depth2-depth);\nvec3 normal=cross(p1,p2);\nnormal.z=-normal.z;\nreturn normalize(normal);\n}\nvoid main()\n{\nvec3 random=normalize(texture2D(randomSampler,vUV*randTextureTiles).rgb);\nfloat depth=texture2D(textureSampler,vUV).r;\nvec3 position=vec3(vUV,depth);\nvec3 normal=normalFromDepth(depth,vUV);\nfloat radiusDepth=radius/depth;\nfloat occlusion=0.0;\nvec3 ray;\nvec3 hemiRay;\nfloat occlusionDepth;\nfloat difference;\nfor (int i=0; i, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void; - _collide(trianglePlaneArray: Array, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void; - _getResponse(pos: Vector3, vel: Vector3): void; - } -} - -declare module BABYLON { - var CollisionWorker: string; - interface ICollisionCoordinator { - getNewPosition(position: Vector3, velocity: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh?: AbstractMesh) => void, collisionIndex: number): void; - init(scene: Scene): void; - destroy(): void; - onMeshAdded(mesh: AbstractMesh): any; - onMeshUpdated(mesh: AbstractMesh): any; - onMeshRemoved(mesh: AbstractMesh): any; - onGeometryAdded(geometry: Geometry): any; - onGeometryUpdated(geometry: Geometry): any; - onGeometryDeleted(geometry: Geometry): any; - } - interface SerializedMesh { - id: string; - name: string; - uniqueId: number; - geometryId: string; - sphereCenter: Array; - sphereRadius: number; - boxMinimum: Array; - boxMaximum: Array; - worldMatrixFromCache: any; - subMeshes: Array; - checkCollisions: boolean; - } - interface SerializedSubMesh { - position: number; - verticesStart: number; - verticesCount: number; - indexStart: number; - indexCount: number; - hasMaterial: boolean; - sphereCenter: Array; - sphereRadius: number; - boxMinimum: Array; - boxMaximum: Array; - } - interface SerializedGeometry { - id: string; - positions: Float32Array; - indices: Uint32Array; - normals: Float32Array; - } - interface BabylonMessage { - taskType: WorkerTaskType; - payload: InitPayload | CollidePayload | UpdatePayload; - } - interface SerializedColliderToWorker { - position: Array; - velocity: Array; - radius: Array; - } - enum WorkerTaskType { - INIT = 0, - UPDATE = 1, - COLLIDE = 2, - } - interface WorkerReply { - error: WorkerReplyType; - taskType: WorkerTaskType; - payload?: any; - } - interface CollisionReplyPayload { - newPosition: Array; - collisionId: number; - collidedMeshUniqueId: number; - } - interface InitPayload { - } - interface CollidePayload { - collisionId: number; - collider: SerializedColliderToWorker; - maximumRetry: number; - excludedMeshUniqueId?: number; - } - interface UpdatePayload { - updatedMeshes: { - [n: number]: SerializedMesh; - }; - updatedGeometries: { - [s: string]: SerializedGeometry; - }; - removedMeshes: Array; - removedGeometries: Array; - } - enum WorkerReplyType { - SUCCESS = 0, - UNKNOWN_ERROR = 1, - } - class CollisionCoordinatorWorker implements ICollisionCoordinator { - private _scene; - private _scaledPosition; - private _scaledVelocity; - private _collisionsCallbackArray; - private _init; - private _runningUpdated; - private _runningCollisionTask; - private _worker; - private _addUpdateMeshesList; - private _addUpdateGeometriesList; - private _toRemoveMeshesArray; - private _toRemoveGeometryArray; - constructor(); - static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh; - static SerializeGeometry: (geometry: Geometry) => SerializedGeometry; - getNewPosition(position: Vector3, velocity: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh?: AbstractMesh) => 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 _afterRender; - private _onMessageFromWorker; - } - class CollisionCoordinatorLegacy implements ICollisionCoordinator { - private _scene; - private _scaledPosition; - private _scaledVelocity; - private _finalPosition; - getNewPosition(position: Vector3, velocity: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh?: AbstractMesh) => 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(position, velocity, collider, maximumRetry, finalPosition, excludedMesh?); - } -} - -declare module BABYLON { - var WorkerIncluded: boolean; - 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; - } - 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?: number): void; - private checkCollision(mesh); - private processCollisionsForSubMeshes(transformMatrix, mesh); - private collideForSubMesh(subMesh, transformMatrix, meshGeometry); - private checkSubmeshCollision(subMesh); - } - interface ICollisionDetector { - onInit(payload: InitPayload): void; - onUpdate(payload: UpdatePayload): void; - onCollision(payload: CollidePayload): void; - } - class CollisionDetectorTransferable implements ICollisionDetector { - private _collisionCache; - onInit(payload: InitPayload): void; - onUpdate(payload: UpdatePayload): void; - onCollision(payload: CollidePayload): void; - } -} - -declare module BABYLON { - class IntersectionInfo { - bu: number; - bv: number; - distance: number; - faceId: number; - subMeshId: number; - constructor(bu: number, bv: number, distance: number); - } - class PickingInfo { - hit: boolean; - distance: number; - pickedPoint: Vector3; - pickedMesh: AbstractMesh; - bu: number; - bv: number; - faceId: number; - subMeshId: number; - pickedSprite: Sprite; - getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Vector3; - getTextureCoordinates(): Vector2; - } -} - declare module BABYLON { class BoundingBox implements ICullable { minimum: Vector3; @@ -4477,19 +4234,262 @@ declare module BABYLON { } declare module BABYLON { - class LensFlare { - size: number; - position: number; - color: Color3; - texture: Texture; - alphaMode: number; - private _system; - constructor(size: number, position: number, color: any, imgUrl: string, system: LensFlareSystem); - dispose: () => void; - } -} - -declare module BABYLON { + class Collider { + radius: Vector3; + retry: number; + velocity: Vector3; + basePoint: Vector3; + epsilon: number; + collisionFound: boolean; + velocityWorldLength: number; + basePointWorld: Vector3; + velocityWorld: Vector3; + normalizedVelocity: Vector3; + initialVelocity: Vector3; + initialPosition: Vector3; + nearestDistance: number; + intersectionPoint: Vector3; + collidedMesh: AbstractMesh; + private _collisionPoint; + private _planeIntersectionPoint; + private _tempVector; + private _tempVector2; + private _tempVector3; + private _tempVector4; + private _edge; + private _baseToVertex; + private _destinationPoint; + private _slidePlaneNormal; + private _displacementVector; + private _collisionMask; + collisionMask: number; + _initialize(source: Vector3, dir: Vector3, e: number): void; + _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean; + _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean; + _testTriangle(faceIndex: number, trianglePlaneArray: Array, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void; + _collide(trianglePlaneArray: Array, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void; + _getResponse(pos: Vector3, vel: Vector3): void; + } +} + +declare module BABYLON { + var CollisionWorker: string; + interface ICollisionCoordinator { + getNewPosition(position: Vector3, velocity: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh?: AbstractMesh) => void, collisionIndex: number): void; + init(scene: Scene): void; + destroy(): void; + onMeshAdded(mesh: AbstractMesh): any; + onMeshUpdated(mesh: AbstractMesh): any; + onMeshRemoved(mesh: AbstractMesh): any; + onGeometryAdded(geometry: Geometry): any; + onGeometryUpdated(geometry: Geometry): any; + onGeometryDeleted(geometry: Geometry): any; + } + interface SerializedMesh { + id: string; + name: string; + uniqueId: number; + geometryId: string; + sphereCenter: Array; + sphereRadius: number; + boxMinimum: Array; + boxMaximum: Array; + worldMatrixFromCache: any; + subMeshes: Array; + checkCollisions: boolean; + } + interface SerializedSubMesh { + position: number; + verticesStart: number; + verticesCount: number; + indexStart: number; + indexCount: number; + hasMaterial: boolean; + sphereCenter: Array; + sphereRadius: number; + boxMinimum: Array; + boxMaximum: Array; + } + interface SerializedGeometry { + id: string; + positions: Float32Array; + indices: Uint32Array; + normals: Float32Array; + } + interface BabylonMessage { + taskType: WorkerTaskType; + payload: InitPayload | CollidePayload | UpdatePayload; + } + interface SerializedColliderToWorker { + position: Array; + velocity: Array; + radius: Array; + } + enum WorkerTaskType { + INIT = 0, + UPDATE = 1, + COLLIDE = 2, + } + interface WorkerReply { + error: WorkerReplyType; + taskType: WorkerTaskType; + payload?: any; + } + interface CollisionReplyPayload { + newPosition: Array; + collisionId: number; + collidedMeshUniqueId: number; + } + interface InitPayload { + } + interface CollidePayload { + collisionId: number; + collider: SerializedColliderToWorker; + maximumRetry: number; + excludedMeshUniqueId?: number; + } + interface UpdatePayload { + updatedMeshes: { + [n: number]: SerializedMesh; + }; + updatedGeometries: { + [s: string]: SerializedGeometry; + }; + removedMeshes: Array; + removedGeometries: Array; + } + enum WorkerReplyType { + SUCCESS = 0, + UNKNOWN_ERROR = 1, + } + class CollisionCoordinatorWorker implements ICollisionCoordinator { + private _scene; + private _scaledPosition; + private _scaledVelocity; + private _collisionsCallbackArray; + private _init; + private _runningUpdated; + private _runningCollisionTask; + private _worker; + private _addUpdateMeshesList; + private _addUpdateGeometriesList; + private _toRemoveMeshesArray; + private _toRemoveGeometryArray; + constructor(); + static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh; + static SerializeGeometry: (geometry: Geometry) => SerializedGeometry; + getNewPosition(position: Vector3, velocity: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh?: AbstractMesh) => 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 _afterRender; + private _onMessageFromWorker; + } + class CollisionCoordinatorLegacy implements ICollisionCoordinator { + private _scene; + private _scaledPosition; + private _scaledVelocity; + private _finalPosition; + getNewPosition(position: Vector3, velocity: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh?: AbstractMesh) => 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(position, velocity, collider, maximumRetry, finalPosition, excludedMesh?); + } +} + +declare module BABYLON { + var WorkerIncluded: boolean; + 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; + } + 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?: number): void; + private checkCollision(mesh); + private processCollisionsForSubMeshes(transformMatrix, mesh); + private collideForSubMesh(subMesh, transformMatrix, meshGeometry); + private checkSubmeshCollision(subMesh); + } + interface ICollisionDetector { + onInit(payload: InitPayload): void; + onUpdate(payload: UpdatePayload): void; + onCollision(payload: CollidePayload): void; + } + class CollisionDetectorTransferable implements ICollisionDetector { + private _collisionCache; + onInit(payload: InitPayload): void; + onUpdate(payload: UpdatePayload): void; + onCollision(payload: CollidePayload): void; + } +} + +declare module BABYLON { + class IntersectionInfo { + bu: number; + bv: number; + distance: number; + faceId: number; + subMeshId: number; + constructor(bu: number, bv: number, distance: number); + } + class PickingInfo { + hit: boolean; + distance: number; + pickedPoint: Vector3; + pickedMesh: AbstractMesh; + bu: number; + bv: number; + faceId: number; + subMeshId: number; + pickedSprite: Sprite; + getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Vector3; + getTextureCoordinates(): Vector2; + } +} + +declare module BABYLON { + class LensFlare { + size: number; + position: number; + color: Color3; + texture: Texture; + alphaMode: number; + private _system; + constructor(size: number, position: number, color: any, imgUrl: string, system: LensFlareSystem); + dispose: () => void; + } +} + +declare module BABYLON { class LensFlareSystem { name: string; lensFlares: LensFlare[]; @@ -4649,105 +4649,6 @@ declare module BABYLON.Debug { } } -declare module BABYLON { - interface ILoadingScreen { - displayLoadingUI: () => void; - hideLoadingUI: () => void; - loadingUIBackgroundColor: string; - loadingUIText: string; - } - class DefaultLoadingScreen implements ILoadingScreen { - private _renderingCanvas; - private _loadingText; - private _loadingDivBackgroundColor; - private _loadingDiv; - private _loadingTextDiv; - constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string); - displayLoadingUI(): void; - hideLoadingUI(): void; - loadingUIText: string; - loadingUIBackgroundColor: string; - private _resizeLoadingUI; - } -} - -declare module BABYLON { - interface ISceneLoaderPluginExtensions { - [extension: string]: { - isBinary: boolean; - }; - } - interface ISceneLoaderPlugin { - name: string; - extensions: string | ISceneLoaderPluginExtensions; - importMesh: (meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[], onError: (message: string) => void) => boolean; - load: (scene: Scene, data: string, rootUrl: string, onError: (message: string) => void) => boolean; - canDirectLoad?: (data: string) => boolean; - } - interface ISceneLoaderPluginAsync { - name: string; - extensions: string | ISceneLoaderPluginExtensions; - importMeshAsync: (meshesNames: any, scene: Scene, data: any, rootUrl: string, onSuccess: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, onProgress: (event: ProgressEvent) => void, onError: (message: string) => void) => void; - loadAsync: (scene: Scene, data: string, rootUrl: string, onSuccess: () => void, onProgress: (event: ProgressEvent) => void, onError: (message: string) => void) => void; - canDirectLoad?: (data: string) => boolean; - } - class SceneLoader { - private static _ForceFullSceneLoadingForIncremental; - private static _ShowLoadingScreen; - private static _CleanBoneMatrixWeights; - static readonly NO_LOGGING: number; - static readonly MINIMAL_LOGGING: number; - static readonly SUMMARY_LOGGING: number; - static readonly DETAILED_LOGGING: number; - private static _loggingLevel; - static ForceFullSceneLoadingForIncremental: boolean; - static ShowLoadingScreen: boolean; - static loggingLevel: number; - static CleanBoneMatrixWeights: boolean; - static OnPluginActivatedObservable: Observable; - private static _registeredPlugins; - private static _getDefaultPlugin(); - private static _getPluginForExtension(extension); - private static _getPluginForDirectLoad(data); - private static _getPluginForFilename(sceneFilename); - private static _getDirectLoad(sceneFilename); - private static _loadData(rootUrl, sceneFilename, scene, onSuccess, onProgress, onError); - static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync; - 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 scene and resources - * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene - * @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 - */ - static ImportMesh(meshNames: any, rootUrl: string, sceneFilename: string, scene: Scene, onSuccess?: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, onProgress?: (event: ProgressEvent) => void, onError?: (scene: Scene, message: string, exception?: any) => void): void; - /** - * Load a scene - * @param rootUrl a string that defines the root url for scene and resources - * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene - * @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 - */ - static Load(rootUrl: string, sceneFilename: any, engine: Engine, onSuccess?: (scene: Scene) => void, onProgress?: (event: ProgressEvent) => void, onError?: (scene: Scene, message: string, exception?: any) => void): void; - /** - * Append a scene - * @param rootUrl a string that defines the root url for scene and resources - * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene - * @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 - */ - static Append(rootUrl: string, sceneFilename: any, scene: Scene, onSuccess?: (scene: Scene) => void, onProgress?: (event: ProgressEvent) => void, onError?: (scene: Scene, message: string, exception?: any) => void): void; - } -} - declare module BABYLON { class DirectionalLight extends ShadowLight { private _shadowFrustumSize; @@ -5282,3528 +5183,3627 @@ declare module BABYLON { } declare module BABYLON { - class Scalar { + /** + * 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; /** - * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45) + * 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). */ - static WithinEpsilon(a: number, b: number, epsilon?: number): boolean; /** - * Returns a string : the upper case translation of the number i to hexadecimal. + * 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). */ - static ToHex(i: number): string; + globalHue: number; /** - * Returns -1 if value is negative and +1 is value is positive. - * Returns the value itself if it's equal to zero. + * 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. */ - static Sign(value: number): number; /** - * Returns the value itself if it's between min and max. - * Returns min if the value is lower than min. - * Returns max if the value is greater than max. + * 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. */ - static Clamp(value: number, min?: number, max?: number): number; + globalDensity: number; /** - * Returns the log2 of value. + * 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. */ - static Log2(value: number): number; - /** - * Loops the value, so that it is never larger than length and never smaller than 0. - * - * This is similar to the modulo operator but it works with floating point numbers. - * For example, using 3.0 for t and 2.5 for length, the result would be 0.5. - * With t = 5 and length = 2.5, the result would be 0.0. - * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator - */ - static Repeat(value: number, length: number): number; /** - * Normalize the value between 0.0 and 1.0 using min and max values - */ - static Normalize(value: number, min: number, max: number): number; + * 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; + private _highlightsHue; + private _highlightsDensity; + private _highlightsSaturation; + private _highlightsExposure; /** - * Denormalize the value from 0.0 and 1.0 using min and max values - */ - static Denormalize(normalized: number, min: number, max: number): number; + * 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). + */ /** - * Calculates the shortest difference between two given angles given in degrees. - */ - static DeltaAngle(current: number, target: number): number; + * 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; /** - * PingPongs the value t, so that it is never larger than length and never smaller than 0. - * - * The returned value will move back and forth between 0 and length - */ - static PingPong(tx: number, length: number): 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. + */ /** - * Interpolates between min and max with smoothing at the limits. - * - * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up - * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions. - */ - static SmoothStep(from: number, to: number, tx: number): number; + * 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; /** - * Moves a value current towards target. - * - * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta. - * Negative values of maxDelta pushes the value away from target. - */ - static MoveTowards(current: number, target: number, maxDelta: number): 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. + */ /** - * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees. - * - * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta - * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead. - */ - static MoveTowardsAngle(current: number, target: number, maxDelta: number): number; + * 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; /** - * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar. - */ - static Lerp(start: number, end: number, amount: number): 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. + */ /** - * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees. - * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees. - */ - static LerpAngle(start: number, end: number, amount: number): number; + * 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; /** - * Calculates the linear parameter t that produces the interpolant value within the range [a, b]. - */ - static InverseLerp(a: number, b: number, value: number): number; + * 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). + */ /** - * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2". + * 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). */ - static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number; + midtonesHue: number; /** - * Returns a random float number between and min and max values - */ - static RandomRange(min: number, max: number): 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. + */ /** - * This function returns percentage of a number in a given range. - * - * RangeToPercent(40,20,60) will return 0.5 (50%) - * RangeToPercent(34,0,100) will return 0.34 (34%) - */ - static RangeToPercent(number: number, min: number, max: number): number; - /** - * This function returns number that corresponds to the percentage in a given range. - * - * PercentToRange(0.34,0,100) will return 34. - */ - static PercentToRange(percent: number, min: number, max: number): number; - } -} - -declare module BABYLON { - class SIMDHelper { - private static _isEnabled; - static readonly IsEnabled: boolean; - static DisableSIMD(): void; - static EnableSIMD(): void; - } -} - -declare module BABYLON { - const ToGammaSpace: number; - const ToLinearSpace = 2.2; - const Epsilon = 0.001; - class Color3 { - r: number; - g: number; - b: number; - /** - * Creates a new Color3 object from red, green, blue values, all between 0 and 1. - */ - constructor(r?: number, g?: number, b?: number); - /** - * Returns a string with the Color3 current values. - */ - toString(): string; - /** - * Returns the string "Color3". - */ - getClassName(): string; - /** - * Returns the Color3 hash code. - */ - getHashCode(): number; - /** - * Stores in the passed array from the passed starting index the red, green, blue values as successive elements. - * Returns the Color3. - */ - toArray(array: number[] | Float32Array, index?: number): Color3; - /** - * Returns a new Color4 object from the current Color3 and the passed alpha. - */ - toColor4(alpha?: number): Color4; - /** - * Returns a new array populated with 3 numeric elements : red, green and blue values. - */ - asArray(): number[]; - /** - * Returns the luminance value (float). - */ - toLuminance(): number; - /** - * Multiply each Color3 rgb values by the passed Color3 rgb values in a new Color3 object. - * Returns this new object. - */ - multiply(otherColor: Color3): Color3; - /** - * Multiply the rgb values of the Color3 and the passed Color3 and stores the result in the object "result". - * Returns the current Color3. + * 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. */ - multiplyToRef(otherColor: Color3, result: Color3): Color3; + midtonesDensity: number; /** - * Boolean : True if the rgb values are equal to the passed ones. + * 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. */ - equals(otherColor: Color3): boolean; /** - * Boolean : True if the rgb values are equal to the passed ones. + * 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. */ - equalsFloats(r: number, g: number, b: number): boolean; + midtonesSaturation: number; /** - * Multiplies in place each rgb value by scale. - * Returns the updated Color3. + * 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. */ - scale(scale: number): Color3; /** - * Multiplies the rgb values by scale and stores the result into "result". - * Returns the unmodified current Color3. + * 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. */ - scaleToRef(scale: number, result: Color3): Color3; + midtonesExposure: number; + private _shadowsHue; + private _shadowsDensity; + private _shadowsSaturation; + private _shadowsExposure; /** - * Returns a new Color3 set with the added values of the current Color3 and of the passed one. + * 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). */ - add(otherColor: Color3): Color3; /** - * Stores the result of the addition of the current Color3 and passed one rgb values into "result". - * Returns the unmodified current Color3. + * 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). */ - addToRef(otherColor: Color3, result: Color3): Color3; + shadowsHue: number; /** - * Returns a new Color3 set with the subtracted values of the passed one from the current Color3 . + * 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. */ - subtract(otherColor: Color3): Color3; /** - * Stores the result of the subtraction of passed one from the current Color3 rgb values into "result". - * Returns the unmodified current Color3. + * 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. */ - subtractToRef(otherColor: Color3, result: Color3): Color3; + shadowsDensity: number; /** - * Returns a new Color3 copied the current one. + * 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. */ - clone(): Color3; /** - * Copies the rgb values from the source in the current Color3. - * Returns the updated Color3. + * 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. */ - copyFrom(source: Color3): Color3; + shadowsSaturation: number; /** - * Updates the Color3 rgb values from the passed floats. - * Returns the Color3. + * 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. */ - copyFromFloats(r: number, g: number, b: number): Color3; /** - * Updates the Color3 rgb values from the passed floats. - * Returns the Color3. + * 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. */ - set(r: number, g: number, b: number): Color3; + shadowsExposure: number; + getClassName(): string; /** - * Returns the Color3 hexadecimal code as a string. + * Binds the color curves to the shader. + * @param colorCurves The color curve to bind + * @param effect The effect to bind to */ - toHexString(): string; + static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void; /** - * Returns a new Color3 converted to linear space. + * Prepare the list of uniforms associated with the ColorCurves effects. + * @param uniformsList The list of uniforms used in the effect */ - toLinearSpace(): Color3; + static PrepareUniforms(uniformsList: string[]): void; /** - * Converts the Color3 values to linear space and stores the result in "convertedColor". - * Returns the unmodified Color3. + * 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. */ - toLinearSpaceToRef(convertedColor: Color3): Color3; + private getColorGradingDataToRef(hue, density, saturation, exposure, result); /** - * Returns a new Color3 converted to gamma space. + * 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. */ - toGammaSpace(): Color3; + private static applyColorGradingSliderNonlinear(value); /** - * Converts the Color3 values to gamma space and stores the result in "convertedColor". - * Returns the unmodified Color3. + * 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. */ - toGammaSpaceToRef(convertedColor: Color3): Color3; + private static fromHSBToRef(hue, saturation, brightness, result); /** - * Creates a new Color3 from the string containing valid hexadecimal values. + * 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. */ - static FromHexString(hex: string): Color3; + private static clamp(value, min, max); /** - * Creates a new Vector3 from the startind index of the passed array. + * Clones the current color curve instance. + * @return The cloned curves */ - static FromArray(array: ArrayLike, offset?: number): Color3; + clone(): ColorCurves; /** - * Creates a new Color3 from integer values ( < 256). + * Serializes the current color curve instance to a json representation. + * @return a JSON representation */ - static FromInts(r: number, g: number, b: number): Color3; + serialize(): any; /** - * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3. + * Parses the color curve from a json representation. + * @param source the JSON source to parse + * @return The parsed curves */ - static Lerp(start: Color3, end: Color3, amount: number): Color3; - static Red(): Color3; - static Green(): Color3; - static Blue(): Color3; - static Black(): Color3; - static White(): Color3; - static Purple(): Color3; - static Magenta(): Color3; - static Yellow(): Color3; - static Gray(): Color3; - static Teal(): Color3; - static Random(): Color3; + static Parse(source: any): ColorCurves; } - class Color4 { - r: number; - g: number; - b: number; - a: number; - /** - * Creates a new Color4 object from the passed float values ( < 1) : red, green, blue, alpha. - */ - constructor(r?: number, g?: number, b?: number, a?: number); - /** - * Adds in place the passed Color4 values to the current Color4. - * Returns the updated Color4. - */ - addInPlace(right: any): Color4; - /** - * Returns a new array populated with 4 numeric elements : red, green, blue, alpha values. - */ - asArray(): number[]; - /** - * Stores from the starting index in the passed array the Color4 successive values. - * Returns the Color4. - */ - toArray(array: number[], index?: number): Color4; - /** - * Returns a new Color4 set with the added values of the current Color4 and of the passed one. - */ - add(right: Color4): Color4; - /** - * Returns a new Color4 set with the subtracted values of the passed one from the current Color4. - */ - subtract(right: Color4): Color4; - /** - * Subtracts the passed ones from the current Color4 values and stores the results in "result". - * Returns the Color4. - */ - subtractToRef(right: Color4, result: Color4): Color4; - /** - * Creates a new Color4 with the current Color4 values multiplied by scale. - */ - scale(scale: number): Color4; - /** - * Multiplies the current Color4 values by scale and stores the result in "result". - * Returns the Color4. - */ - scaleToRef(scale: number, result: Color4): Color4; - /** - * Multipy an RGBA Color4 value by another and return a new Color4 object - * @param color The Color4 (RGBA) value to multiply by - * @returns A new Color4. - */ - multiply(color: Color4): Color4; +} + +declare module BABYLON { + class EffectFallbacks { + private _defines; + private _currentRank; + private _maxRank; + private _mesh; + private _meshRank; + addFallback(rank: number, define: string): void; + addCPUSkinningFallback(rank: number, mesh: BABYLON.AbstractMesh): void; + readonly isMoreFallbacks: boolean; + reduce(currentDefines: string): string; + } + class EffectCreationOptions { + attributes: string[]; + uniformsNames: string[]; + uniformBuffersNames: string[]; + samplers: string[]; + defines: any; + fallbacks: EffectFallbacks; + onCompiled: (effect: Effect) => void; + onError: (effect: Effect, errors: string) => void; + indexParameters: any; + maxSimultaneousLights: number; + } + class Effect { + name: any; + defines: string; + onCompiled: (effect: Effect) => void; + onError: (effect: Effect, errors: string) => void; + onBind: (effect: Effect) => void; + uniqueId: number; + onCompileObservable: Observable; + onErrorObservable: Observable; + onBindObservable: Observable; + private static _uniqueIdSeed; + private _engine; + private _uniformBuffersNames; + private _uniformsNames; + private _samplers; + private _isReady; + private _compilationError; + private _attributesNames; + private _attributes; + private _uniforms; + _key: string; + private _indexParameters; + private _fallbacks; + private _program; + private _valueCache; + private static _baseCache; + constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], engine?: Engine, defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, indexParameters?: any); + readonly key: string; + isReady(): boolean; + getEngine(): Engine; + getProgram(): WebGLProgram; + getAttributesNames(): string[]; + getAttributeLocation(index: number): number; + getAttributeLocationByName(name: string): number; + getAttributesCount(): number; + getUniformIndex(uniformName: string): number; + getUniform(uniformName: string): WebGLUniformLocation; + getSamplers(): string[]; + getCompilationError(): string; + getVertexShaderSource(): string; + getFragmentShaderSource(): string; + executeWhenCompiled(func: (effect: Effect) => void): void; + _loadVertexShader(vertex: any, callback: (data: any) => void): void; + _loadFragmentShader(fragment: any, callback: (data: any) => void): void; + private _dumpShadersSource(vertexCode, fragmentCode, defines); + private _processShaderConversion(sourceCode, isFragment, callback); + private _processIncludes(sourceCode, callback); + private _processPrecision(source); + private _prepareEffect(vertexSourceCode, fragmentSourceCode, attributesNames, defines, fallbacks?); + readonly isSupported: boolean; + _bindTexture(channel: string, texture: WebGLTexture): void; + setTexture(channel: string, texture: BaseTexture): void; + setTextureArray(channel: string, textures: BaseTexture[]): void; + setTextureFromPostProcess(channel: string, postProcess: PostProcess): void; + _cacheMatrix(uniformName: string, matrix: Matrix): boolean; + _cacheFloat2(uniformName: string, x: number, y: number): boolean; + _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean; + _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean; + bindUniformBuffer(buffer: WebGLBuffer, name: string): void; + bindUniformBlock(blockName: string, index: number): void; + setIntArray(uniformName: string, array: Int32Array): Effect; + setIntArray2(uniformName: string, array: Int32Array): Effect; + setIntArray3(uniformName: string, array: Int32Array): Effect; + setIntArray4(uniformName: string, array: Int32Array): Effect; + setFloatArray(uniformName: string, array: Float32Array): Effect; + setFloatArray2(uniformName: string, array: Float32Array): Effect; + setFloatArray3(uniformName: string, array: Float32Array): Effect; + setFloatArray4(uniformName: string, array: Float32Array): Effect; + setArray(uniformName: string, array: number[]): Effect; + setArray2(uniformName: string, array: number[]): Effect; + setArray3(uniformName: string, array: number[]): Effect; + setArray4(uniformName: string, array: number[]): Effect; + setMatrices(uniformName: string, matrices: Float32Array): Effect; + setMatrix(uniformName: string, matrix: Matrix): Effect; + setMatrix3x3(uniformName: string, matrix: Float32Array): Effect; + setMatrix2x2(uniformName: string, matrix: Float32Array): Effect; + setFloat(uniformName: string, value: number): Effect; + setBool(uniformName: string, bool: boolean): Effect; + setVector2(uniformName: string, vector2: Vector2): Effect; + setFloat2(uniformName: string, x: number, y: number): Effect; + setVector3(uniformName: string, vector3: Vector3): Effect; + setFloat3(uniformName: string, x: number, y: number, z: number): Effect; + setVector4(uniformName: string, vector4: Vector4): Effect; + setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect; + setColor3(uniformName: string, color3: Color3): Effect; + setColor4(uniformName: string, color3: Color3, alpha: number): Effect; + private _recombineShader(node); + private _evaluateDefinesOnString(shaderString); + static ShadersStore: {}; + static IncludesShadersStore: {}; + static ResetCache(): void; + } +} + +declare module BABYLON { + class FresnelParameters { + private _isEnabled; + isEnabled: boolean; + leftColor: Color3; + rightColor: Color3; + bias: number; + power: number; + clone(): FresnelParameters; + serialize(): any; + static Parse(parsedFresnelParameters: any): FresnelParameters; + } +} + +declare module BABYLON { + /** + * Interface to follow in your material defines to integrate easily the + * Image proccessing functions. + */ + interface IImageProcessingConfigurationDefines { + IMAGEPROCESSING: boolean; + VIGNETTE: boolean; + VIGNETTEBLENDMODEMULTIPLY: boolean; + VIGNETTEBLENDMODEOPAQUE: boolean; + TONEMAPPING: boolean; + CONTRAST: boolean; + EXPOSURE: boolean; + COLORCURVES: boolean; + COLORGRADING: boolean; + SAMPLER3DGREENDEPTH: boolean; + SAMPLER3DBGRMAP: boolean; + IMAGEPROCESSINGPOSTPROCESS: boolean; + } + /** + * 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 { /** - * Multipy an RGBA Color4 value by another and push the result in a reference value - * @param color The Color4 (RGBA) value to multiply by - * @param result The Color4 (RGBA) to fill the result in - * @returns the result Color4. + * Color curves setup used in the effect if colorCurvesEnabled is set to true */ - multiplyToRef(color: Color4, result: Color4): Color4; + colorCurves: ColorCurves; + private _colorCurvesEnabled; /** - * Returns a string with the Color4 values. + * Gets wether the color curves effect is enabled. */ - toString(): string; /** - * Returns the string "Color4" + * Sets wether the color curves effect is enabled. */ - getClassName(): string; + colorCurvesEnabled: boolean; /** - * Return the Color4 hash code as a number. + * Color grading LUT texture used in the effect if colorGradingEnabled is set to true */ - getHashCode(): number; + colorGradingTexture: BaseTexture; + private _colorGradingEnabled; /** - * Creates a new Color4 copied from the current one. + * Gets wether the color grading effect is enabled. */ - clone(): Color4; /** - * Copies the passed Color4 values into the current one. - * Returns the updated Color4. + * Sets wether the color grading effect is enabled. */ - copyFrom(source: Color4): Color4; + colorGradingEnabled: boolean; + private _colorGradingWithGreenDepth; /** - * Copies the passed float values into the current one. - * Returns the updated Color4. + * Gets wether the color grading effect is using a green depth for the 3d Texture. */ - copyFromFloats(r: number, g: number, b: number, a: number): Color4; /** - * Copies the passed float values into the current one. - * Returns the updated Color4. + * Sets wether the color grading effect is using a green depth for the 3d Texture. */ - set(r: number, g: number, b: number, a: number): Color4; + colorGradingWithGreenDepth: boolean; + private _colorGradingBGR; /** - * Returns a string containing the hexadecimal Color4 code. + * Gets wether the color grading texture contains BGR values. */ - toHexString(): string; /** - * Returns a new Color4 converted to linear space. + * Sets wether the color grading texture contains BGR values. */ - toLinearSpace(): Color4; + colorGradingBGR: boolean; + _exposure: number; /** - * Converts the Color4 values to linear space and stores the result in "convertedColor". - * Returns the unmodified Color4. + * Gets the Exposure used in the effect. */ - toLinearSpaceToRef(convertedColor: Color4): Color4; /** - * Returns a new Color4 converted to gamma space. + * Sets the Exposure used in the effect. */ - toGammaSpace(): Color4; + exposure: number; + private _toneMappingEnabled; /** - * Converts the Color4 values to gamma space and stores the result in "convertedColor". - * Returns the unmodified Color4. + * Gets wether the tone mapping effect is enabled. */ - toGammaSpaceToRef(convertedColor: Color4): Color4; /** - * Creates a new Color4 from the valid hexadecimal value contained in the passed string. + * Sets wether the tone mapping effect is enabled. */ - static FromHexString(hex: string): Color4; + toneMappingEnabled: boolean; + protected _contrast: number; /** - * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 and the right Color4. + * Gets the contrast used in the effect. */ - static Lerp(left: Color4, right: Color4, amount: number): Color4; /** - * Set the passed "result" with the linearly interpolated values of "amount" between the left Color4 and the right Color4. + * Sets the contrast used in the effect. */ - static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void; + contrast: number; /** - * Creates a new Color4 from the starting index element of the passed array. + * Vignette stretch size. */ - static FromArray(array: ArrayLike, offset?: number): Color4; + vignetteStretch: number; /** - * Creates a new Color4 from the passed integers ( < 256 ). + * Vignette centre X Offset. */ - static FromInts(r: number, g: number, b: number, a: number): Color4; - static CheckColors4(colors: number[], count: number): number[]; - } - class Vector2 { - x: number; - y: number; + vignetteCentreX: number; /** - * Creates a new Vector2 from the passed x and y coordinates. + * Vignette centre Y Offset. */ - constructor(x: number, y: number); - /** - * Returns a string with the Vector2 coordinates. - */ - toString(): string; - /** - * Returns the string "Vector2" - */ - getClassName(): string; - /** - * Returns the Vector2 hash code as a number. - */ - getHashCode(): number; - /** - * Sets the Vector2 coordinates in the passed array or Float32Array from the passed index. - * Returns the Vector2. - */ - toArray(array: number[] | Float32Array, index?: number): Vector2; - /** - * Returns a new array with 2 elements : the Vector2 coordinates. - */ - asArray(): number[]; + vignetteCentreY: number; /** - * Sets the Vector2 coordinates with the passed Vector2 coordinates. - * Returns the updated Vector2. + * Vignette weight or intensity of the vignette effect. */ - copyFrom(source: Vector2): Vector2; + vignetteWeight: number; /** - * Sets the Vector2 coordinates with the passed floats. - * Returns the updated Vector2. + * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode) + * if vignetteEnabled is set to true. */ - copyFromFloats(x: number, y: number): Vector2; + vignetteColor: BABYLON.Color4; /** - * Sets the Vector2 coordinates with the passed floats. - * Returns the updated Vector2. + * Camera field of view used by the Vignette effect. */ - set(x: number, y: number): Vector2; + vignetteCameraFov: number; + private _vignetteBlendMode; /** - * Returns a new Vector2 set with the addition of the current Vector2 and the passed one coordinates. + * Gets the vignette blend mode allowing different kind of effect. */ - add(otherVector: Vector2): Vector2; /** - * Sets the "result" coordinates with the addition of the current Vector2 and the passed one coordinates. - * Returns the Vector2. + * Sets the vignette blend mode allowing different kind of effect. */ - addToRef(otherVector: Vector2, result: Vector2): Vector2; + vignetteBlendMode: number; + private _vignetteEnabled; /** - * Set the Vector2 coordinates by adding the passed Vector2 coordinates. - * Returns the updated Vector2. + * Gets wether the vignette effect is enabled. */ - addInPlace(otherVector: Vector2): Vector2; /** - * Returns a new Vector2 by adding the current Vector2 coordinates to the passed Vector3 x, y coordinates. + * Sets wether the vignette effect is enabled. */ - addVector3(otherVector: Vector3): Vector2; + vignetteEnabled: boolean; + private _applyByPostProcess; /** - * Returns a new Vector2 set with the subtracted coordinates of the passed one from the current Vector2. + * Gets wether the image processing is applied through a post process or not. */ - subtract(otherVector: Vector2): Vector2; /** - * Sets the "result" coordinates with the subtraction of the passed one from the current Vector2 coordinates. - * Returns the Vector2. + * Sets wether the image processing is applied through a post process or not. */ - subtractToRef(otherVector: Vector2, result: Vector2): Vector2; + applyByPostProcess: boolean; /** - * Sets the current Vector2 coordinates by subtracting from it the passed one coordinates. - * Returns the updated Vector2. - */ - subtractInPlace(otherVector: Vector2): Vector2; + * An event triggered when the configuration changes and requires Shader to Update some parameters. + * @type {BABYLON.Observable} + */ + onUpdateParameters: Observable; /** - * Multiplies in place the current Vector2 coordinates by the passed ones. - * Returns the updated Vector2. + * Method called each time the image processing information changes requires to recompile the effect. */ - multiplyInPlace(otherVector: Vector2): Vector2; + protected _updateParameters(): void; + getClassName(): string; /** - * Returns a new Vector2 set with the multiplication of the current Vector2 and the passed one coordinates. + * Prepare the list of uniforms associated with the Image Processing effects. + * @param uniformsList The list of uniforms used in the effect + * @param defines the list of defines currently in use */ - multiply(otherVector: Vector2): Vector2; + static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void; /** - * Sets "result" coordinates with the multiplication of the current Vector2 and the passed one coordinates. - * Returns the Vector2. + * Prepare the list of samplers associated with the Image Processing effects. + * @param uniformsList The list of uniforms used in the effect + * @param defines the list of defines currently in use */ - multiplyToRef(otherVector: Vector2, result: Vector2): Vector2; + static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void; /** - * Returns a new Vector2 set with the Vector2 coordinates multiplied by the passed floats. + * Prepare the list of defines associated to the shader. + * @param defines the list of defines to complete */ - multiplyByFloats(x: number, y: number): Vector2; + prepareDefines(defines: IImageProcessingConfigurationDefines): void; /** - * Returns a new Vector2 set with the Vector2 coordinates divided by the passed one coordinates. + * Returns true if all the image processing information are ready. */ - divide(otherVector: Vector2): Vector2; + isReady(): boolean; /** - * Sets the "result" coordinates with the Vector2 divided by the passed one coordinates. - * Returns the Vector2. + * Binds the image processing to the shader. + * @param effect The effect to bind to */ - divideToRef(otherVector: Vector2, result: Vector2): Vector2; + bind(effect: Effect, aspectRatio?: number): void; /** - * Returns a new Vector2 with current Vector2 negated coordinates. + * Clones the current image processing instance. + * @return The cloned image processing */ - negate(): Vector2; + clone(): ImageProcessingConfiguration; /** - * Multiply the Vector2 coordinates by scale. - * Returns the updated Vector2. + * Serializes the current image processing instance to a json representation. + * @return a JSON representation */ - scaleInPlace(scale: number): Vector2; + serialize(): any; /** - * Returns a new Vector2 scaled by "scale" from the current Vector2. + * Parses the image processing from a json representation. + * @param source the JSON source to parse + * @return The parsed image processing */ - scale(scale: number): Vector2; + static Parse(source: any): ImageProcessingConfiguration; + private static _VIGNETTEMODE_MULTIPLY; + private static _VIGNETTEMODE_OPAQUE; /** - * Boolean : True if the passed vector coordinates strictly equal the current Vector2 ones. + * Used to apply the vignette as a mix with the pixel color. */ - equals(otherVector: Vector2): boolean; + static readonly VIGNETTEMODE_MULTIPLY: number; /** - * Boolean : True if the passed vector coordinates are close to the current ones by a distance of epsilon. + * Used to apply the vignette as a replacement of the pixel color. */ - equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean; + static readonly VIGNETTEMODE_OPAQUE: number; + } +} + +declare module BABYLON { + class MaterialDefines { + private _keys; + private _isDirty; + _renderId: number; + _areLightsDirty: boolean; + _areAttributesDirty: boolean; + _areTexturesDirty: boolean; + _areFresnelDirty: boolean; + _areMiscDirty: boolean; + _areImageProcessingDirty: boolean; + _normals: boolean; + _uvs: boolean; + _needNormals: boolean; + _needUVs: boolean; + readonly isDirty: boolean; + markAsProcessed(): void; + markAsUnprocessed(): void; + markAllAsDirty(): void; + markAsImageProcessingDirty(): void; + markAsLightDirty(): void; + markAsAttributesDirty(): void; + markAsTexturesDirty(): void; + markAsFresnelDirty(): void; + markAsMiscDirty(): void; + rebuild(): void; + isEqual(other: MaterialDefines): boolean; + cloneTo(other: MaterialDefines): void; + reset(): void; + toString(): string; + } + class Material { + private static _TriangleFillMode; + private static _WireFrameFillMode; + private static _PointFillMode; + static readonly TriangleFillMode: number; + static readonly WireFrameFillMode: number; + static readonly PointFillMode: number; + private static _ClockWiseSideOrientation; + private static _CounterClockWiseSideOrientation; + static readonly ClockWiseSideOrientation: number; + static readonly CounterClockWiseSideOrientation: number; + private static _TextureDirtyFlag; + private static _LightDirtyFlag; + private static _FresnelDirtyFlag; + private static _AttributesDirtyFlag; + private static _MiscDirtyFlag; + static readonly TextureDirtyFlag: number; + static readonly LightDirtyFlag: number; + static readonly FresnelDirtyFlag: number; + static readonly AttributesDirtyFlag: number; + static readonly MiscDirtyFlag: number; + id: string; + name: string; + checkReadyOnEveryCall: boolean; + checkReadyOnlyOnce: boolean; + state: string; + alpha: number; + protected _backFaceCulling: boolean; + backFaceCulling: boolean; + sideOrientation: number; + onCompiled: (effect: Effect) => void; + onError: (effect: Effect, errors: string) => void; + getRenderTargetTextures: () => SmartArray; + doNotSerialize: boolean; + storeEffectOnSubMeshes: boolean; /** - * Returns the vector length (float). - */ - length(): number; + * An event triggered when the material is disposed. + * @type {BABYLON.Observable} + */ + onDisposeObservable: Observable; + private _onDisposeObserver; + onDispose: () => void; /** - * Returns the vector squared length (float); - */ - lengthSquared(): number; + * An event triggered when the material is bound. + * @type {BABYLON.Observable} + */ + onBindObservable: Observable; + private _onBindObserver; + onBind: (Mesh: AbstractMesh) => void; /** - * Normalize the vector. - * Returns the updated Vector2. - */ - normalize(): Vector2; + * An event triggered when the material is unbound. + * @type {BABYLON.Observable} + */ + onUnBindObservable: Observable; + alphaMode: number; + disableDepthWrite: boolean; + private _fogEnabled; + fogEnabled: boolean; + pointSize: number; + zOffset: number; + wireframe: boolean; + pointsCloud: boolean; + fillMode: number; + _effect: Effect; + _wasPreviouslyReady: boolean; + private _useUBO; + private _scene; + private _fillMode; + private _cachedDepthWriteState; + protected _uniformBuffer: UniformBuffer; + constructor(name: string, scene: Scene, doNotAdd?: boolean); /** - * Returns a new Vector2 copied from the Vector2. + * @param {boolean} fullDetails - support for multiple levels of logging within scene loading + * subclasses should override adding information pertainent to themselves */ - clone(): Vector2; + toString(fullDetails?: boolean): string; /** - * Returns a new Vector2(0, 0) + * Child classes can use it to update shaders */ - static Zero(): Vector2; - /** - * Returns a new Vector2(1, 1) - */ - static One(): Vector2; - /** - * Returns a new Vector2 set from the passed index element of the passed array. - */ - static FromArray(array: ArrayLike, offset?: number): Vector2; - /** - * Sets "result" from the passed index element of the passed array. - */ - static FromArrayToRef(array: ArrayLike, offset: number, result: Vector2): void; - /** - * Retuns a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the passed four Vector2. - */ - static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2; - /** - * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max". - * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate. - * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate. - */ - static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2; - /** - * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2". - */ - static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2; - /** - * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end". - */ - static Lerp(start: Vector2, end: Vector2, amount: number): Vector2; - /** - * Returns the dot product (float) of the vector "left" and the vector "right". - */ - static Dot(left: Vector2, right: Vector2): number; - /** - * Returns a new Vector2 equal to the normalized passed vector. - */ - static Normalize(vector: Vector2): Vector2; - /** - * Returns a new Vecto2 set with the minimal coordinate values from the "left" and "right" vectors. - */ - static Minimize(left: Vector2, right: Vector2): Vector2; - /** - * Returns a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors. - */ - static Maximize(left: Vector2, right: Vector2): Vector2; - /** - * Returns a new Vecto2 set with the transformed coordinates of the passed vector by the passed transformation matrix. - */ - static Transform(vector: Vector2, transformation: Matrix): Vector2; - /** - * Transforms the passed vector coordinates by the passed transformation matrix and stores the result in the vector "result" coordinates. - */ - static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void; - /** - * Boolean : True if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2" - */ - static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean; - /** - * Returns the distance (float) between the vectors "value1" and "value2". - */ - static Distance(value1: Vector2, value2: Vector2): number; - /** - * Returns the squared distance (float) between the vectors "value1" and "value2". - */ - static DistanceSquared(value1: Vector2, value2: Vector2): number; - /** - * Returns a new Vecto2 located at the center of the vectors "value1" and "value2". - */ - static Center(value1: Vector2, value2: Vector2): Vector2; + getClassName(): string; + readonly isFrozen: boolean; + freeze(): void; + unfreeze(): void; + isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean; + isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean; + getEffect(): Effect; + getScene(): Scene; + needAlphaBlending(): boolean; + needAlphaTesting(): boolean; + getAlphaTestTexture(): BaseTexture; + markDirty(): void; + _preBind(effect?: Effect): void; + bind(world: Matrix, mesh?: Mesh): void; + bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void; + bindOnlyWorldMatrix(world: Matrix): void; + bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void; + bindView(effect: Effect): void; + bindViewProjection(effect: Effect): void; + protected _afterBind(mesh: Mesh): void; + unbind(): void; + getActiveTextures(): BaseTexture[]; + hasTexture(texture: BaseTexture): boolean; + clone(name: string): Material; + getBindedMeshes(): AbstractMesh[]; /** - * Returns the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB". + * Force shader compilation including textures ready check */ - static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number; + forceCompilation(mesh: AbstractMesh, onCompiled: (material: Material) => void, options?: { + alphaTest: boolean; + clipPlane: boolean; + }): void; + markAsDirty(flag: number): void; + protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void; + protected _markAllSubMeshesAsImageProcessingDirty(): void; + protected _markAllSubMeshesAsTexturesDirty(): void; + protected _markAllSubMeshesAsFresnelDirty(): void; + protected _markAllSubMeshesAsLightsDirty(): void; + protected _markAllSubMeshesAsAttributesDirty(): void; + protected _markAllSubMeshesAsMiscDirty(): void; + dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void; + serialize(): any; + static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial; + static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any; } - class Vector3 { - x: number; - y: number; - z: number; - /** - * Creates a new Vector3 object from the passed x, y, z (floats) coordinates. - * A Vector3 is the main object used in 3D geometry. - * It can represent etiher the coordinates of a point the space, either a direction. - */ - constructor(x: number, y: number, z: number); - /** - * Returns a string with the Vector3 coordinates. - */ - toString(): string; - /** - * Returns the string "Vector3" - */ +} + +declare module BABYLON { + class MaterialHelper { + static PrepareDefinesForMergedUV(texture: BaseTexture, defines: MaterialDefines, key: string): void; + static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void; + static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: any, fogEnabled: boolean, defines: MaterialDefines): void; + static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: MaterialDefines, useInstances: boolean, forceAlphaTest?: boolean): void; + static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: MaterialDefines, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean): boolean; + static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: MaterialDefines, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean; + static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: MaterialDefines, maxSimultaneousLights?: number): void; + static HandleFallbacksForShadows(defines: MaterialDefines, fallbacks: EffectFallbacks, maxSimultaneousLights?: number): void; + static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: MaterialDefines): void; + static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: MaterialDefines, fallbacks: EffectFallbacks): void; + static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void; + static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void; + static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void; + static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: MaterialDefines, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void; + static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect): void; + static BindBonesParameters(mesh: AbstractMesh, effect: Effect): void; + static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void; + static BindLogDepth(defines: MaterialDefines, effect: Effect, scene: Scene): void; + static BindClipPlane(effect: Effect, scene: Scene): void; + } +} + +declare module BABYLON { + class MultiMaterial extends Material { + private _subMaterials; + subMaterials: Material[]; + constructor(name: string, scene: Scene); + private _hookArray(array); + getSubMaterial(index: any): Material; + getActiveTextures(): BaseTexture[]; getClassName(): string; + isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean; + clone(name: string, cloneChildren?: boolean): MultiMaterial; + serialize(): any; + dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void; + } +} + +declare module BABYLON { + class PushMaterial extends Material { + protected _activeEffect: Effect; + constructor(name: string, scene: Scene); + getEffect(): Effect; + isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean; + bindOnlyWorldMatrix(world: Matrix): void; + bind(world: Matrix, mesh?: Mesh): void; + protected _afterBind(mesh: Mesh, effect?: Effect): void; + protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean; + } +} + +declare module BABYLON { + class ShaderMaterial extends Material { + private _shaderPath; + private _options; + private _textures; + private _textureArrays; + private _floats; + private _floatsArrays; + private _colors3; + private _colors3Arrays; + private _colors4; + private _vectors2; + private _vectors3; + private _vectors4; + private _matrices; + private _matrices3x3; + private _matrices2x2; + private _vectors3Arrays; + private _cachedWorldViewMatrix; + private _renderId; + constructor(name: string, scene: Scene, shaderPath: any, options: any); + getClassName(): string; + needAlphaBlending(): boolean; + needAlphaTesting(): boolean; + private _checkUniform(uniformName); + setTexture(name: string, texture: Texture): ShaderMaterial; + setTextureArray(name: string, textures: Texture[]): ShaderMaterial; + setFloat(name: string, value: number): ShaderMaterial; + setFloats(name: string, value: number[]): ShaderMaterial; + setColor3(name: string, value: Color3): ShaderMaterial; + setColor3Array(name: string, value: Color3[]): ShaderMaterial; + setColor4(name: string, value: Color4): ShaderMaterial; + setVector2(name: string, value: Vector2): ShaderMaterial; + setVector3(name: string, value: Vector3): ShaderMaterial; + setVector4(name: string, value: Vector4): ShaderMaterial; + setMatrix(name: string, value: Matrix): ShaderMaterial; + setMatrix3x3(name: string, value: Float32Array): ShaderMaterial; + setMatrix2x2(name: string, value: Float32Array): ShaderMaterial; + setArray3(name: string, value: number[]): ShaderMaterial; + private _checkCache(scene, mesh?, useInstances?); + isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean; + bindOnlyWorldMatrix(world: Matrix): void; + bind(world: Matrix, mesh?: Mesh): void; + getActiveTextures(): BaseTexture[]; + hasTexture(texture: BaseTexture): boolean; + clone(name: string): ShaderMaterial; + dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void; + serialize(): any; + static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial; + } +} + +declare module BABYLON { + class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines { + MAINUV1: boolean; + MAINUV2: boolean; + DIFFUSE: boolean; + DIFFUSEDIRECTUV: number; + AMBIENT: boolean; + AMBIENTDIRECTUV: number; + OPACITY: boolean; + OPACITYDIRECTUV: number; + OPACITYRGB: boolean; + REFLECTION: boolean; + EMISSIVE: boolean; + EMISSIVEDIRECTUV: number; + SPECULAR: boolean; + SPECULARDIRECTUV: number; + BUMP: boolean; + BUMPDIRECTUV: number; + PARALLAX: boolean; + PARALLAXOCCLUSION: boolean; + SPECULAROVERALPHA: boolean; + CLIPPLANE: boolean; + ALPHATEST: boolean; + ALPHAFROMDIFFUSE: boolean; + POINTSIZE: boolean; + FOG: boolean; + SPECULARTERM: boolean; + DIFFUSEFRESNEL: boolean; + OPACITYFRESNEL: boolean; + REFLECTIONFRESNEL: boolean; + REFRACTIONFRESNEL: boolean; + EMISSIVEFRESNEL: boolean; + FRESNEL: boolean; + NORMAL: boolean; + UV1: boolean; + UV2: boolean; + VERTEXCOLOR: boolean; + VERTEXALPHA: boolean; + NUM_BONE_INFLUENCERS: number; + BonesPerMesh: number; + INSTANCES: boolean; + GLOSSINESS: boolean; + ROUGHNESS: boolean; + EMISSIVEASILLUMINATION: boolean; + LINKEMISSIVEWITHDIFFUSE: boolean; + REFLECTIONFRESNELFROMSPECULAR: boolean; + LIGHTMAP: boolean; + LIGHTMAPDIRECTUV: number; + USELIGHTMAPASSHADOWMAP: boolean; + REFLECTIONMAP_3D: boolean; + REFLECTIONMAP_SPHERICAL: boolean; + REFLECTIONMAP_PLANAR: boolean; + REFLECTIONMAP_CUBIC: boolean; + REFLECTIONMAP_PROJECTION: boolean; + REFLECTIONMAP_SKYBOX: boolean; + REFLECTIONMAP_EXPLICIT: boolean; + REFLECTIONMAP_EQUIRECTANGULAR: boolean; + REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean; + REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean; + INVERTCUBICMAP: boolean; + LOGARITHMICDEPTH: boolean; + REFRACTION: boolean; + REFRACTIONMAP_3D: boolean; + REFLECTIONOVERALPHA: boolean; + TWOSIDEDLIGHTING: boolean; + SHADOWFLOAT: boolean; + MORPHTARGETS: boolean; + MORPHTARGETS_NORMAL: boolean; + MORPHTARGETS_TANGENT: boolean; + NUM_MORPH_INFLUENCERS: number; + USERIGHTHANDEDSYSTEM: boolean; + IMAGEPROCESSING: boolean; + VIGNETTE: boolean; + VIGNETTEBLENDMODEMULTIPLY: boolean; + VIGNETTEBLENDMODEOPAQUE: boolean; + TONEMAPPING: boolean; + CONTRAST: boolean; + COLORCURVES: boolean; + COLORGRADING: boolean; + SAMPLER3DGREENDEPTH: boolean; + SAMPLER3DBGRMAP: boolean; + IMAGEPROCESSINGPOSTPROCESS: boolean; + EXPOSURE: boolean; + constructor(); + setReflectionMode(modeToEnable: string): void; + } + class StandardMaterial extends PushMaterial { + private _diffuseTexture; + diffuseTexture: BaseTexture; + private _ambientTexture; + ambientTexture: BaseTexture; + private _opacityTexture; + opacityTexture: BaseTexture; + private _reflectionTexture; + reflectionTexture: BaseTexture; + private _emissiveTexture; + emissiveTexture: BaseTexture; + private _specularTexture; + specularTexture: BaseTexture; + private _bumpTexture; + bumpTexture: BaseTexture; + private _lightmapTexture; + lightmapTexture: BaseTexture; + private _refractionTexture; + refractionTexture: BaseTexture; + ambientColor: Color3; + diffuseColor: Color3; + specularColor: Color3; + emissiveColor: Color3; + specularPower: number; + private _useAlphaFromDiffuseTexture; + useAlphaFromDiffuseTexture: boolean; + private _useEmissiveAsIllumination; + useEmissiveAsIllumination: boolean; + private _linkEmissiveWithDiffuse; + linkEmissiveWithDiffuse: boolean; + private _useSpecularOverAlpha; + useSpecularOverAlpha: boolean; + private _useReflectionOverAlpha; + useReflectionOverAlpha: boolean; + private _disableLighting; + disableLighting: boolean; + private _useParallax; + useParallax: boolean; + private _useParallaxOcclusion; + useParallaxOcclusion: boolean; + parallaxScaleBias: number; + private _roughness; + roughness: number; + indexOfRefraction: number; + invertRefractionY: boolean; + private _useLightmapAsShadowmap; + useLightmapAsShadowmap: boolean; + private _diffuseFresnelParameters; + diffuseFresnelParameters: FresnelParameters; + private _opacityFresnelParameters; + opacityFresnelParameters: FresnelParameters; + private _reflectionFresnelParameters; + reflectionFresnelParameters: FresnelParameters; + private _refractionFresnelParameters; + refractionFresnelParameters: FresnelParameters; + private _emissiveFresnelParameters; + emissiveFresnelParameters: FresnelParameters; + private _useReflectionFresnelFromSpecular; + useReflectionFresnelFromSpecular: boolean; + private _useGlossinessFromSpecularMapAlpha; + useGlossinessFromSpecularMapAlpha: boolean; + private _maxSimultaneousLights; + maxSimultaneousLights: number; /** - * Returns the Vector hash code. - */ - getHashCode(): number; - /** - * Returns a new array with three elements : the coordinates the Vector3. - */ - asArray(): number[]; - /** - * Populates the passed array or Float32Array from the passed index with the successive coordinates of the Vector3. - * Returns the Vector3. - */ - toArray(array: number[] | Float32Array, index?: number): Vector3; - /** - * Returns a new Quaternion object, computed from the Vector3 coordinates. - */ - toQuaternion(): Quaternion; - /** - * Adds the passed vector to the current Vector3. - * Returns the updated Vector3. - */ - addInPlace(otherVector: Vector3): Vector3; - /** - * Returns a new Vector3, result of the addition the current Vector3 and the passed vector. - */ - add(otherVector: Vector3): Vector3; - /** - * Adds the current Vector3 to the passed one and stores the result in the vector "result". - * Returns the current Vector3. - */ - addToRef(otherVector: Vector3, result: Vector3): Vector3; - /** - * Subtract the passed vector from the current Vector3. - * Returns the updated Vector3. - */ - subtractInPlace(otherVector: Vector3): Vector3; - /** - * Returns a new Vector3, result of the subtraction of the passed vector from the current Vector3. - */ - subtract(otherVector: Vector3): Vector3; - /** - * Subtracts the passed vector from the current Vector3 and stores the result in the vector "result". - * Returns the current Vector3. - */ - subtractToRef(otherVector: Vector3, result: Vector3): Vector3; - /** - * Returns a new Vector3 set with the subtraction of the passed floats from the current Vector3 coordinates. - */ - subtractFromFloats(x: number, y: number, z: number): Vector3; - /** - * Subtracts the passed floats from the current Vector3 coordinates and set the passed vector "result" with this result. - * Returns the current Vector3. - */ - subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3; - /** - * Returns a new Vector3 set with the current Vector3 negated coordinates. - */ - negate(): Vector3; - /** - * Multiplies the Vector3 coordinates by the float "scale". - * Returns the updated Vector3. - */ - scaleInPlace(scale: number): Vector3; - /** - * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale". - */ - scale(scale: number): Vector3; - /** - * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the passed vector "result" coordinates. - * Returns the current Vector3. - */ - scaleToRef(scale: number, result: Vector3): Vector3; - /** - * Boolean : True if the current Vector3 and the passed vector coordinates are strictly equal. - */ - equals(otherVector: Vector3): boolean; - /** - * Boolean : True if the current Vector3 and the passed vector coordinates are distant less than epsilon. - */ - equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean; - /** - * Boolean : True if the current Vector3 coordinate equal the passed floats. - */ - equalsToFloats(x: number, y: number, z: number): boolean; - /** - * Muliplies the current Vector3 coordinates by the passed ones. - * Returns the updated Vector3. - */ - multiplyInPlace(otherVector: Vector3): Vector3; - /** - * Returns a new Vector3, result of the multiplication of the current Vector3 by the passed vector. - */ - multiply(otherVector: Vector3): Vector3; - /** - * Multiplies the current Vector3 by the passed one and stores the result in the passed vector "result". - * Returns the current Vector3. + * If sets to true, x component of normal map value will invert (x = 1.0 - x). */ - multiplyToRef(otherVector: Vector3, result: Vector3): Vector3; + private _invertNormalMapX; + invertNormalMapX: boolean; /** - * Returns a new Vector3 set witth the result of the mulliplication of the current Vector3 coordinates by the passed floats. + * If sets to true, y component of normal map value will invert (y = 1.0 - y). */ - multiplyByFloats(x: number, y: number, z: number): Vector3; + private _invertNormalMapY; + invertNormalMapY: boolean; /** - * Returns a new Vector3 set witth the result of the division of the current Vector3 coordinates by the passed ones. + * If sets to true and backfaceCulling is false, normals will be flipped on the backside. */ - divide(otherVector: Vector3): Vector3; + private _twoSidedLighting; + twoSidedLighting: boolean; /** - * Divides the current Vector3 coordinates by the passed ones and stores the result in the passed vector "result". - * Returns the current Vector3. + * Default configuration related to image processing available in the standard Material. */ - divideToRef(otherVector: Vector3, result: Vector3): Vector3; + protected _imageProcessingConfiguration: ImageProcessingConfiguration; /** - * Updates the current Vector3 with the minimal coordinate values between its and the passed vector ones. - * Returns the updated Vector3. + * Gets the image processing configuration used either in this material. */ - MinimizeInPlace(other: Vector3): Vector3; /** - * Updates the current Vector3 with the maximal coordinate values between its and the passed vector ones. - * Returns the updated Vector3. + * Sets the Default image processing configuration used either in the this material. + * + * If sets to null, the scene one is in use. */ - MaximizeInPlace(other: Vector3): Vector3; + imageProcessingConfiguration: ImageProcessingConfiguration; /** - * Returns the length of the Vector3 (float). + * Keep track of the image processing observer to allow dispose and replace. */ - length(): number; + private _imageProcessingObserver; /** - * Returns the squared length of the Vector3 (float). + * Attaches a new image processing configuration to the Standard Material. + * @param configuration */ - lengthSquared(): number; + protected _attachImageProcessingConfiguration(configuration: ImageProcessingConfiguration): void; /** - * Normalize the current Vector3. - * Returns the updated Vector3. + * Gets wether the color curves effect is enabled. */ - normalize(): Vector3; /** - * Returns a new Vector3 copied from the current Vector3. + * Sets wether the color curves effect is enabled. */ - clone(): Vector3; + cameraColorCurvesEnabled: boolean; /** - * Copies the passed vector coordinates to the current Vector3 ones. - * Returns the updated Vector3. + * Gets wether the color grading effect is enabled. */ - copyFrom(source: Vector3): Vector3; /** - * Copies the passed floats to the current Vector3 coordinates. - * Returns the updated Vector3. + * Gets wether the color grading effect is enabled. */ - copyFromFloats(x: number, y: number, z: number): Vector3; + cameraColorGradingEnabled: boolean; /** - * Copies the passed floats to the current Vector3 coordinates. - * Returns the updated Vector3. + * Gets wether tonemapping is enabled or not. */ - set(x: number, y: number, z: number): Vector3; /** - * + * Sets wether tonemapping is enabled or not */ - static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: any): number; + cameraToneMappingEnabled: boolean; /** - * Returns a new Vector3 set from the index "offset" of the passed array. + * The camera exposure used on this material. + * This property is here and not in the camera to allow controlling exposure without full screen post process. + * This corresponds to a photographic exposure. */ - static FromArray(array: ArrayLike, offset?: number): Vector3; /** - * Returns a new Vector3 set from the index "offset" of the passed Float32Array. - * This function is deprecated. Use FromArray instead. + * The camera exposure used on this material. + * This property is here and not in the camera to allow controlling exposure without full screen post process. + * This corresponds to a photographic exposure. */ - static FromFloatArray(array: Float32Array, offset?: number): Vector3; + cameraExposure: number; /** - * Sets the passed vector "result" with the element values from the index "offset" of the passed array. + * Gets The camera contrast used on this material. */ - static FromArrayToRef(array: ArrayLike, offset: number, result: Vector3): void; /** - * Sets the passed vector "result" with the element values from the index "offset" of the passed Float32Array. - * This function is deprecated. Use FromArrayToRef instead. + * Sets The camera contrast used on this material. */ - static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void; + cameraContrast: number; /** - * Sets the passed vector "result" with the passed floats. + * Gets the Color Grading 2D Lookup Texture. */ - static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void; /** - * Returns a new Vector3 set to (0.0, 0.0, 0.0). + * Sets the Color Grading 2D Lookup Texture. */ - static Zero(): Vector3; + cameraColorGradingTexture: BaseTexture; + customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string; + protected _renderTargets: SmartArray; + protected _worldViewProjectionMatrix: Matrix; + protected _globalAmbientColor: Color3; + protected _useLogarithmicDepth: boolean; + constructor(name: string, scene: Scene); + getClassName(): string; + useLogarithmicDepth: boolean; + needAlphaBlending(): boolean; + needAlphaTesting(): boolean; + protected _shouldUseAlphaFromDiffuseTexture(): boolean; + getAlphaTestTexture(): BaseTexture; /** - * Returns a new Vector3 set to (1.0, 1.0, 1.0). + * Child classes can use it to update shaders */ - static One(): Vector3; + isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean; + buildUniformLayout(): void; + unbind(): void; + bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void; + getAnimatables(): IAnimatable[]; + getActiveTextures(): BaseTexture[]; + hasTexture(texture: BaseTexture): boolean; + dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void; + clone(name: string): StandardMaterial; + serialize(): any; + static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial; + static _DiffuseTextureEnabled: boolean; + static DiffuseTextureEnabled: boolean; + static _AmbientTextureEnabled: boolean; + static AmbientTextureEnabled: boolean; + static _OpacityTextureEnabled: boolean; + static OpacityTextureEnabled: boolean; + static _ReflectionTextureEnabled: boolean; + static ReflectionTextureEnabled: boolean; + static _EmissiveTextureEnabled: boolean; + static EmissiveTextureEnabled: boolean; + static _SpecularTextureEnabled: boolean; + static SpecularTextureEnabled: boolean; + static _BumpTextureEnabled: boolean; + static BumpTextureEnabled: boolean; + static _LightmapTextureEnabled: boolean; + static LightmapTextureEnabled: boolean; + static _RefractionTextureEnabled: boolean; + static RefractionTextureEnabled: boolean; + static _ColorGradingTextureEnabled: boolean; + static ColorGradingTextureEnabled: boolean; + static _FresnelEnabled: boolean; + static FresnelEnabled: boolean; + } +} + +declare module BABYLON { + class UniformBuffer { + private _engine; + private _buffer; + private _data; + private _bufferData; + private _dynamic; + private _uniformName; + private _uniformLocations; + private _uniformSizes; + private _uniformLocationPointer; + private _needSync; + private _cache; + private _noUBO; + private _currentEffect; + private static _MAX_UNIFORM_SIZE; + private static _tempBuffer; /** - * Returns a new Vector3 set to (0.0, 1.0, 0.0) + * Wrapper for updateUniform. + * @method updateMatrix3x3 + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {Float32Array} matrix */ - static Up(): Vector3; + updateMatrix3x3: (name: string, matrix: Float32Array) => void; /** - * Returns a new Vector3 set to (0.0, 0.0, 1.0) + * Wrapper for updateUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {Float32Array} matrix */ - static Forward(): Vector3; + updateMatrix2x2: (name: string, matrix: Float32Array) => void; /** - * Returns a new Vector3 set to (1.0, 0.0, 0.0) + * Wrapper for updateUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {number} x */ - static Right(): Vector3; + updateFloat: (name: string, x: number) => void; /** - * Returns a new Vector3 set to (-1.0, 0.0, 0.0) + * Wrapper for updateUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {number} x + * @param {number} y + * @param {string} [suffix] Suffix to add to the uniform name. */ - static Left(): Vector3; + updateFloat2: (name: string, x: number, y: number, suffix?: string) => void; /** - * Returns a new Vector3 set with the result of the transformation by the passed matrix of the passed vector. - * This method computes tranformed coordinates only, not transformed direction vectors. + * Wrapper for updateUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {number} x + * @param {number} y + * @param {number} z + * @param {string} [suffix] Suffix to add to the uniform name. */ - static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3; + updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void; /** - * Sets the passed vector "result" coordinates with the result of the transformation by the passed matrix of the passed vector. - * This method computes tranformed coordinates only, not transformed direction vectors. + * Wrapper for updateUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {number} x + * @param {number} y + * @param {number} z + * @param {number} w + * @param {string} [suffix] Suffix to add to the uniform name. */ - static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void; + updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void; /** - * Sets the passed vector "result" coordinates with the result of the transformation by the passed matrix of the passed floats (x, y, z). - * This method computes tranformed coordinates only, not transformed direction vectors. + * Wrapper for updateUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {Matrix} A 4x4 matrix. */ - static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void; + updateMatrix: (name: string, mat: Matrix) => void; /** - * Returns a new Vector3 set with the result of the normal transformation by the passed matrix of the passed vector. - * This methods computes transformed normalized direction vectors only. + * Wrapper for updateUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {Vector3} vector */ - static TransformNormal(vector: Vector3, transformation: Matrix): Vector3; + updateVector3: (name: string, vector: Vector3) => void; /** - * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed vector. - * This methods computes transformed normalized direction vectors only. + * Wrapper for updateUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {Vector4} vector */ - static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void; + updateVector4: (name: string, vector: Vector4) => void; /** - * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed floats (x, y, z). - * This methods computes transformed normalized direction vectors only. + * Wrapper for updateUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {Color3} color + * @param {string} [suffix] Suffix to add to the uniform name. */ - static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void; + updateColor3: (name: string, color: Color3, suffix?: string) => void; /** - * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4". + * Wrapper for updateUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {Color3} color + * @param {number} alpha + * @param {string} [suffix] Suffix to add to the uniform name. */ - static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3; + updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void; /** - * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max". - * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one. - * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one. + * Uniform buffer objects. + * + * Handles blocks of uniform on the GPU. + * + * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls. + * + * For more information, please refer to : + * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object */ - static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3; + constructor(engine: Engine, data?: number[], dynamic?: boolean); /** - * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2". + * Indicates if the buffer is using the WebGL2 UBO implementation, + * or just falling back on setUniformXXX calls. */ - static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3; + readonly useUbo: boolean; /** - * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end". + * Indicates if the WebGL underlying uniform buffer is in sync + * with the javascript cache data. */ - static Lerp(start: Vector3, end: Vector3, amount: number): Vector3; + readonly isSync: boolean; /** - * Sets the passed vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end". + * Indicates if the WebGL underlying uniform buffer is dynamic. + * Also, a dynamic UniformBuffer will disable cache verification and always + * update the underlying WebGL uniform buffer to the GPU. */ - static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void; + isDynamic(): boolean; /** - * Returns the dot product (float) between the vectors "left" and "right". + * The data cache on JS side. */ - static Dot(left: Vector3, right: Vector3): number; + getData(): Float32Array; /** - * Returns a new Vector3 as the cross product of the vectors "left" and "right". - * The cross product is then orthogonal to both "left" and "right". + * The underlying WebGL Uniform buffer. */ - static Cross(left: Vector3, right: Vector3): Vector3; + getBuffer(): WebGLBuffer; /** - * Sets the passed vector "result" with the cross product of "left" and "right". - * The cross product is then orthogonal to both "left" and "right". + * std140 layout specifies how to align data within an UBO structure. + * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159 + * for specs. */ - static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void; + private _fillAlignment(size); /** - * Returns a new Vector3 as the normalization of the passed vector. + * Adds an uniform in the buffer. + * Warning : the subsequents calls of this function must be in the same order as declared in the shader + * for the layout to be correct ! + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {number|number[]} size Data size, or data directly. */ - static Normalize(vector: Vector3): Vector3; + addUniform(name: string, size: number | number[]): void; /** - * Sets the passed vector "result" with the normalization of the passed first vector. + * Wrapper for addUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {Matrix} mat A 4x4 matrix. */ - static NormalizeToRef(vector: Vector3, result: Vector3): void; - private static _viewportMatrixCache; - static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3; - static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3; - static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3; - static Minimize(left: Vector3, right: Vector3): Vector3; - static Maximize(left: Vector3, right: Vector3): Vector3; + addMatrix(name: string, mat: Matrix): void; /** - * Returns the distance (float) between the vectors "value1" and "value2". + * Wrapper for addUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {number} x + * @param {number} y */ - static Distance(value1: Vector3, value2: Vector3): number; + addFloat2(name: string, x: number, y: number): void; /** - * Returns the squared distance (float) between the vectors "value1" and "value2". + * Wrapper for addUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {number} x + * @param {number} y + * @param {number} z */ - static DistanceSquared(value1: Vector3, value2: Vector3): number; + addFloat3(name: string, x: number, y: number, z: number): void; /** - * Returns a new Vector3 located at the center between "value1" and "value2". + * Wrapper for addUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {Color3} color */ - static Center(value1: Vector3, value2: Vector3): Vector3; + addColor3(name: string, color: Color3): void; /** - * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system), - * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply - * to something in order to rotate it from its local system to the given target system. - * Note : axis1, axis2 and axis3 are normalized during this operation. - * Returns a new Vector3. + * Wrapper for addUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {Color3} color + * @param {number} alpha */ - static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3; + addColor4(name: string, color: Color3, alpha: number): void; /** - * The same than RotationFromAxis but updates the passed ref Vector3 parameter instead of returning a new Vector3. + * Wrapper for addUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {Vector3} vector */ - static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void; - } - class Vector4 { - x: number; - y: number; - z: number; - w: number; + addVector3(name: string, vector: Vector3): void; /** - * Creates a Vector4 object from the passed floats. + * Wrapper for addUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. */ - constructor(x: number, y: number, z: number, w: number); + addMatrix3x3(name: string): void; /** - * Returns the string with the Vector4 coordinates. + * Wrapper for addUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. */ - toString(): string; + addMatrix2x2(name: string): void; /** - * Returns the string "Vector4". + * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`. */ - getClassName(): string; + create(): void; /** - * Returns the Vector4 hash code. + * Updates the WebGL Uniform Buffer on the GPU. + * If the `dynamic` flag is set to true, no cache comparison is done. + * Otherwise, the buffer will be updated only if the cache differs. */ - getHashCode(): number; + update(): void; /** - * Returns a new array populated with 4 elements : the Vector4 coordinates. + * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU. + * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader. + * @param {number[]|Float32Array} data Flattened data + * @param {number} size Size of the data. */ - asArray(): number[]; + updateUniform(uniformName: string, data: number[] | Float32Array, size: number): void; + private _updateMatrix3x3ForUniform(name, matrix); + private _updateMatrix3x3ForEffect(name, matrix); + private _updateMatrix2x2ForEffect(name, matrix); + private _updateMatrix2x2ForUniform(name, matrix); + private _updateFloatForEffect(name, x); + private _updateFloatForUniform(name, x); + private _updateFloat2ForEffect(name, x, y, suffix?); + private _updateFloat2ForUniform(name, x, y, suffix?); + private _updateFloat3ForEffect(name, x, y, z, suffix?); + private _updateFloat3ForUniform(name, x, y, z, suffix?); + private _updateFloat4ForEffect(name, x, y, z, w, suffix?); + private _updateFloat4ForUniform(name, x, y, z, w, suffix?); + private _updateMatrixForEffect(name, mat); + private _updateMatrixForUniform(name, mat); + private _updateVector3ForEffect(name, vector); + private _updateVector3ForUniform(name, vector); + private _updateVector4ForEffect(name, vector); + private _updateVector4ForUniform(name, vector); + private _updateColor3ForEffect(name, color, suffix?); + private _updateColor3ForUniform(name, color, suffix?); + private _updateColor4ForEffect(name, color, alpha, suffix?); + private _updateColor4ForUniform(name, color, alpha, suffix?); /** - * Populates the passed array from the passed index with the Vector4 coordinates. - * Returns the Vector4. + * Sets a sampler uniform on the effect. + * @param {string} name Name of the sampler. + * @param {Texture} texture */ - toArray(array: number[] | Float32Array, index?: number): Vector4; + setTexture(name: string, texture: BaseTexture): void; /** - * Adds the passed vector to the current Vector4. - * Returns the updated Vector4. + * Directly updates the value of the uniform in the cache AND on the GPU. + * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader. + * @param {number[]|Float32Array} data Flattened data */ - addInPlace(otherVector: Vector4): Vector4; + updateUniformDirectly(uniformName: string, data: number[] | Float32Array): void; /** - * Returns a new Vector4 as the result of the addition of the current Vector4 and the passed one. + * Binds this uniform buffer to an effect. + * @param {Effect} effect + * @param {string} name Name of the uniform block in the shader. */ - add(otherVector: Vector4): Vector4; + bindToEffect(effect: Effect, name: string): void; /** - * Updates the passed vector "result" with the result of the addition of the current Vector4 and the passed one. - * Returns the current Vector4. + * Disposes the uniform buffer. */ - addToRef(otherVector: Vector4, result: Vector4): Vector4; + dispose(): void; + } +} + +declare module BABYLON { + interface ILoadingScreen { + displayLoadingUI: () => void; + hideLoadingUI: () => void; + loadingUIBackgroundColor: string; + loadingUIText: string; + } + class DefaultLoadingScreen implements ILoadingScreen { + private _renderingCanvas; + private _loadingText; + private _loadingDivBackgroundColor; + private _loadingDiv; + private _loadingTextDiv; + constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string); + displayLoadingUI(): void; + hideLoadingUI(): void; + loadingUIText: string; + loadingUIBackgroundColor: string; + private _resizeLoadingUI; + } +} + +declare module BABYLON { + interface ISceneLoaderPluginExtensions { + [extension: string]: { + isBinary: boolean; + }; + } + interface ISceneLoaderPlugin { + name: string; + extensions: string | ISceneLoaderPluginExtensions; + importMesh: (meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[], onError: (message: string) => void) => boolean; + load: (scene: Scene, data: string, rootUrl: string, onError: (message: string) => void) => boolean; + canDirectLoad?: (data: string) => boolean; + } + interface ISceneLoaderPluginAsync { + name: string; + extensions: string | ISceneLoaderPluginExtensions; + importMeshAsync: (meshesNames: any, scene: Scene, data: any, rootUrl: string, onSuccess: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, onProgress: (event: ProgressEvent) => void, onError: (message: string) => void) => void; + loadAsync: (scene: Scene, data: string, rootUrl: string, onSuccess: () => void, onProgress: (event: ProgressEvent) => void, onError: (message: string) => void) => void; + canDirectLoad?: (data: string) => boolean; + } + class SceneLoader { + private static _ForceFullSceneLoadingForIncremental; + private static _ShowLoadingScreen; + private static _CleanBoneMatrixWeights; + static readonly NO_LOGGING: number; + static readonly MINIMAL_LOGGING: number; + static readonly SUMMARY_LOGGING: number; + static readonly DETAILED_LOGGING: number; + private static _loggingLevel; + static ForceFullSceneLoadingForIncremental: boolean; + static ShowLoadingScreen: boolean; + static loggingLevel: number; + static CleanBoneMatrixWeights: boolean; + static OnPluginActivatedObservable: Observable; + private static _registeredPlugins; + private static _getDefaultPlugin(); + private static _getPluginForExtension(extension); + private static _getPluginForDirectLoad(data); + private static _getPluginForFilename(sceneFilename); + private static _getDirectLoad(sceneFilename); + private static _loadData(rootUrl, sceneFilename, scene, onSuccess, onProgress, onError); + static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync; + static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void; /** - * Subtract in place the passed vector from the current Vector4. - * Returns the updated Vector4. - */ - subtractInPlace(otherVector: Vector4): Vector4; + * 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 scene and resources + * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene + * @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 + */ + static ImportMesh(meshNames: any, rootUrl: string, sceneFilename: string, scene: Scene, onSuccess?: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, onProgress?: (event: ProgressEvent) => void, onError?: (scene: Scene, message: string, exception?: any) => void): void; /** - * Returns a new Vector4 with the result of the subtraction of the passed vector from the current Vector4. - */ - subtract(otherVector: Vector4): Vector4; + * Load a scene + * @param rootUrl a string that defines the root url for scene and resources + * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene + * @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 + */ + static Load(rootUrl: string, sceneFilename: any, engine: Engine, onSuccess?: (scene: Scene) => void, onProgress?: (event: ProgressEvent) => void, onError?: (scene: Scene, message: string, exception?: any) => void): void; /** - * Sets the passed vector "result" with the result of the subtraction of the passed vector from the current Vector4. - * Returns the current Vector4. - */ - subtractToRef(otherVector: Vector4, result: Vector4): Vector4; + * Append a scene + * @param rootUrl a string that defines the root url for scene and resources + * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene + * @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 + */ + static Append(rootUrl: string, sceneFilename: any, scene: Scene, onSuccess?: (scene: Scene) => void, onProgress?: (event: ProgressEvent) => void, onError?: (scene: Scene, message: string, exception?: any) => void): void; + } +} + +declare module BABYLON { + class Scalar { /** - * Returns a new Vector4 set with the result of the subtraction of the passed floats from the current Vector4 coordinates. + * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45) */ - subtractFromFloats(x: number, y: number, z: number, w: number): Vector4; + static WithinEpsilon(a: number, b: number, epsilon?: number): boolean; /** - * Sets the passed vector "result" set with the result of the subtraction of the passed floats from the current Vector4 coordinates. - * Returns the current Vector4. + * Returns a string : the upper case translation of the number i to hexadecimal. */ - subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4; + static ToHex(i: number): string; /** - * Returns a new Vector4 set with the current Vector4 negated coordinates. + * Returns -1 if value is negative and +1 is value is positive. + * Returns the value itself if it's equal to zero. */ - negate(): Vector4; + static Sign(value: number): number; /** - * Multiplies the current Vector4 coordinates by scale (float). - * Returns the updated Vector4. + * Returns the value itself if it's between min and max. + * Returns min if the value is lower than min. + * Returns max if the value is greater than max. */ - scaleInPlace(scale: number): Vector4; + static Clamp(value: number, min?: number, max?: number): number; /** - * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float). + * Returns the log2 of value. */ - scale(scale: number): Vector4; + static Log2(value: number): number; /** - * Sets the passed vector "result" with the current Vector4 coordinates multiplied by scale (float). - * Returns the current Vector4. - */ - scaleToRef(scale: number, result: Vector4): Vector4; + * Loops the value, so that it is never larger than length and never smaller than 0. + * + * This is similar to the modulo operator but it works with floating point numbers. + * For example, using 3.0 for t and 2.5 for length, the result would be 0.5. + * With t = 5 and length = 2.5, the result would be 0.0. + * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator + */ + static Repeat(value: number, length: number): number; /** - * Boolean : True if the current Vector4 coordinates are stricly equal to the passed ones. - */ - equals(otherVector: Vector4): boolean; + * Normalize the value between 0.0 and 1.0 using min and max values + */ + static Normalize(value: number, min: number, max: number): number; /** - * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the passed vector ones. - */ - equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean; + * Denormalize the value from 0.0 and 1.0 using min and max values + */ + static Denormalize(normalized: number, min: number, max: number): number; /** - * Boolean : True if the passed floats are strictly equal to the current Vector4 coordinates. - */ - equalsToFloats(x: number, y: number, z: number, w: number): boolean; + * Calculates the shortest difference between two given angles given in degrees. + */ + static DeltaAngle(current: number, target: number): number; /** - * Multiplies in place the current Vector4 by the passed one. - * Returns the updated Vector4. - */ - multiplyInPlace(otherVector: Vector4): Vector4; + * PingPongs the value t, so that it is never larger than length and never smaller than 0. + * + * The returned value will move back and forth between 0 and length + */ + static PingPong(tx: number, length: number): number; /** - * Returns a new Vector4 set with the multiplication result of the current Vector4 and the passed one. - */ - multiply(otherVector: Vector4): Vector4; + * Interpolates between min and max with smoothing at the limits. + * + * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up + * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions. + */ + static SmoothStep(from: number, to: number, tx: number): number; /** - * Updates the passed vector "result" with the multiplication result of the current Vector4 and the passed one. - * Returns the current Vector4. - */ - multiplyToRef(otherVector: Vector4, result: Vector4): Vector4; + * Moves a value current towards target. + * + * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta. + * Negative values of maxDelta pushes the value away from target. + */ + static MoveTowards(current: number, target: number, maxDelta: number): number; /** - * Returns a new Vector4 set with the multiplication result of the passed floats and the current Vector4 coordinates. - */ - multiplyByFloats(x: number, y: number, z: number, w: number): Vector4; + * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees. + * + * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta + * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead. + */ + static MoveTowardsAngle(current: number, target: number, maxDelta: number): number; /** - * Returns a new Vector4 set with the division result of the current Vector4 by the passed one. + * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar. + */ + static Lerp(start: number, end: number, amount: number): number; + /** + * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees. + * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees. + */ + static LerpAngle(start: number, end: number, amount: number): number; + /** + * Calculates the linear parameter t that produces the interpolant value within the range [a, b]. + */ + static InverseLerp(a: number, b: number, value: number): number; + /** + * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2". */ - divide(otherVector: Vector4): Vector4; + static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number; /** - * Updates the passed vector "result" with the division result of the current Vector4 by the passed one. - * Returns the current Vector4. + * Returns a random float number between and min and max values + */ + static RandomRange(min: number, max: number): number; + /** + * This function returns percentage of a number in a given range. + * + * RangeToPercent(40,20,60) will return 0.5 (50%) + * RangeToPercent(34,0,100) will return 0.34 (34%) + */ + static RangeToPercent(number: number, min: number, max: number): number; + /** + * This function returns number that corresponds to the percentage in a given range. + * + * PercentToRange(0.34,0,100) will return 34. + */ + static PercentToRange(percent: number, min: number, max: number): number; + } +} + +declare module BABYLON { + class SIMDHelper { + private static _isEnabled; + static readonly IsEnabled: boolean; + static DisableSIMD(): void; + static EnableSIMD(): void; + } +} + +declare module BABYLON { + const ToGammaSpace: number; + const ToLinearSpace = 2.2; + const Epsilon = 0.001; + class Color3 { + r: number; + g: number; + b: number; + /** + * Creates a new Color3 object from red, green, blue values, all between 0 and 1. */ - divideToRef(otherVector: Vector4, result: Vector4): Vector4; + constructor(r?: number, g?: number, b?: number); /** - * Updates the Vector4 coordinates with the minimum values between its own and the passed vector ones. + * Returns a string with the Color3 current values. */ - MinimizeInPlace(other: Vector4): Vector4; + toString(): string; /** - * Updates the Vector4 coordinates with the maximum values between its own and the passed vector ones. + * Returns the string "Color3". */ - MaximizeInPlace(other: Vector4): Vector4; + getClassName(): string; /** - * Returns the Vector4 length (float). + * Returns the Color3 hash code. */ - length(): number; + getHashCode(): number; /** - * Returns the Vector4 squared length (float). + * Stores in the passed array from the passed starting index the red, green, blue values as successive elements. + * Returns the Color3. */ - lengthSquared(): number; + toArray(array: number[] | Float32Array, index?: number): Color3; /** - * Normalizes in place the Vector4. - * Returns the updated Vector4. + * Returns a new Color4 object from the current Color3 and the passed alpha. */ - normalize(): Vector4; + toColor4(alpha?: number): Color4; /** - * Returns a new Vector3 from the Vector4 (x, y, z) coordinates. + * Returns a new array populated with 3 numeric elements : red, green and blue values. */ - toVector3(): Vector3; + asArray(): number[]; /** - * Returns a new Vector4 copied from the current one. + * Returns the luminance value (float). */ - clone(): Vector4; + toLuminance(): number; /** - * Updates the current Vector4 with the passed one coordinates. - * Returns the updated Vector4. + * Multiply each Color3 rgb values by the passed Color3 rgb values in a new Color3 object. + * Returns this new object. */ - copyFrom(source: Vector4): Vector4; + multiply(otherColor: Color3): Color3; /** - * Updates the current Vector4 coordinates with the passed floats. - * Returns the updated Vector4. + * Multiply the rgb values of the Color3 and the passed Color3 and stores the result in the object "result". + * Returns the current Color3. */ - copyFromFloats(x: number, y: number, z: number, w: number): Vector4; + multiplyToRef(otherColor: Color3, result: Color3): Color3; /** - * Updates the current Vector4 coordinates with the passed floats. - * Returns the updated Vector4. + * Boolean : True if the rgb values are equal to the passed ones. */ - set(x: number, y: number, z: number, w: number): Vector4; + equals(otherColor: Color3): boolean; /** - * Returns a new Vector4 set from the starting index of the passed array. + * Boolean : True if the rgb values are equal to the passed ones. */ - static FromArray(array: ArrayLike, offset?: number): Vector4; + equalsFloats(r: number, g: number, b: number): boolean; /** - * Updates the passed vector "result" from the starting index of the passed array. + * Multiplies in place each rgb value by scale. + * Returns the updated Color3. */ - static FromArrayToRef(array: ArrayLike, offset: number, result: Vector4): void; + scale(scale: number): Color3; /** - * Updates the passed vector "result" from the starting index of the passed Float32Array. + * Multiplies the rgb values by scale and stores the result into "result". + * Returns the unmodified current Color3. */ - static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void; + scaleToRef(scale: number, result: Color3): Color3; /** - * Updates the passed vector "result" coordinates from the passed floats. + * Returns a new Color3 set with the added values of the current Color3 and of the passed one. */ - static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void; + add(otherColor: Color3): Color3; /** - * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0) + * Stores the result of the addition of the current Color3 and passed one rgb values into "result". + * Returns the unmodified current Color3. */ - static Zero(): Vector4; + addToRef(otherColor: Color3, result: Color3): Color3; /** - * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0) + * Returns a new Color3 set with the subtracted values of the passed one from the current Color3 . */ - static One(): Vector4; + subtract(otherColor: Color3): Color3; /** - * Returns a new normalized Vector4 from the passed one. + * Stores the result of the subtraction of passed one from the current Color3 rgb values into "result". + * Returns the unmodified current Color3. */ - static Normalize(vector: Vector4): Vector4; + subtractToRef(otherColor: Color3, result: Color3): Color3; /** - * Updates the passed vector "result" from the normalization of the passed one. + * Returns a new Color3 copied the current one. */ - static NormalizeToRef(vector: Vector4, result: Vector4): void; - static Minimize(left: Vector4, right: Vector4): Vector4; - static Maximize(left: Vector4, right: Vector4): Vector4; + clone(): Color3; /** - * Returns the distance (float) between the vectors "value1" and "value2". + * Copies the rgb values from the source in the current Color3. + * Returns the updated Color3. */ - static Distance(value1: Vector4, value2: Vector4): number; + copyFrom(source: Color3): Color3; /** - * Returns the squared distance (float) between the vectors "value1" and "value2". + * Updates the Color3 rgb values from the passed floats. + * Returns the Color3. */ - static DistanceSquared(value1: Vector4, value2: Vector4): number; + copyFromFloats(r: number, g: number, b: number): Color3; /** - * Returns a new Vector4 located at the center between the vectors "value1" and "value2". + * Updates the Color3 rgb values from the passed floats. + * Returns the Color3. */ - static Center(value1: Vector4, value2: Vector4): Vector4; + set(r: number, g: number, b: number): Color3; /** - * Returns a new Vector4 set with the result of the normal transformation by the passed matrix of the passed vector. - * This methods computes transformed normalized direction vectors only. + * Returns the Color3 hexadecimal code as a string. */ - static TransformNormal(vector: Vector4, transformation: Matrix): Vector4; + toHexString(): string; /** - * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed vector. - * This methods computes transformed normalized direction vectors only. + * Returns a new Color3 converted to linear space. */ - static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void; + toLinearSpace(): Color3; /** - * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed floats (x, y, z, w). - * This methods computes transformed normalized direction vectors only. + * Converts the Color3 values to linear space and stores the result in "convertedColor". + * Returns the unmodified Color3. */ - static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void; - } - interface ISize { - width: number; - height: number; - } - class Size implements ISize { - width: number; - height: number; + toLinearSpaceToRef(convertedColor: Color3): Color3; /** - * Creates a Size object from the passed width and height (floats). + * Returns a new Color3 converted to gamma space. */ - constructor(width: number, height: number); - toString(): string; + toGammaSpace(): Color3; /** - * Returns the string "Size" + * Converts the Color3 values to gamma space and stores the result in "convertedColor". + * Returns the unmodified Color3. */ - getClassName(): string; + toGammaSpaceToRef(convertedColor: Color3): Color3; /** - * Returns the Size hash code. + * Creates a new Color3 from the string containing valid hexadecimal values. */ - getHashCode(): number; + static FromHexString(hex: string): Color3; /** - * Updates the current size from the passed one. - * Returns the updated Size. + * Creates a new Vector3 from the startind index of the passed array. */ - copyFrom(src: Size): void; + static FromArray(array: ArrayLike, offset?: number): Color3; /** - * Updates in place the current Size from the passed floats. - * Returns the updated Size. + * Creates a new Color3 from integer values ( < 256). */ - copyFromFloats(width: number, height: number): Size; + static FromInts(r: number, g: number, b: number): Color3; /** - * Updates in place the current Size from the passed floats. - * Returns the updated Size. + * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3. */ - set(width: number, height: number): Size; + static Lerp(start: Color3, end: Color3, amount: number): Color3; + static Red(): Color3; + static Green(): Color3; + static Blue(): Color3; + static Black(): Color3; + static White(): Color3; + static Purple(): Color3; + static Magenta(): Color3; + static Yellow(): Color3; + static Gray(): Color3; + static Teal(): Color3; + static Random(): Color3; + } + class Color4 { + r: number; + g: number; + b: number; + a: number; /** - * Returns a new Size set with the multiplication result of the current Size and the passed floats. + * Creates a new Color4 object from the passed float values ( < 1) : red, green, blue, alpha. */ - multiplyByFloats(w: number, h: number): Size; + constructor(r?: number, g?: number, b?: number, a?: number); /** - * Returns a new Size copied from the passed one. + * Adds in place the passed Color4 values to the current Color4. + * Returns the updated Color4. */ - clone(): Size; + addInPlace(right: any): Color4; /** - * Boolean : True if the current Size and the passed one width and height are strictly equal. + * Returns a new array populated with 4 numeric elements : red, green, blue, alpha values. */ - equals(other: Size): boolean; + asArray(): number[]; /** - * Returns the surface of the Size : width * height (float). + * Stores from the starting index in the passed array the Color4 successive values. + * Returns the Color4. */ - readonly surface: number; + toArray(array: number[], index?: number): Color4; /** - * Returns a new Size set to (0.0, 0.0) + * Returns a new Color4 set with the added values of the current Color4 and of the passed one. */ - static Zero(): Size; + add(right: Color4): Color4; /** - * Returns a new Size set as the addition result of the current Size and the passed one. + * Returns a new Color4 set with the subtracted values of the passed one from the current Color4. */ - add(otherSize: Size): Size; + subtract(right: Color4): Color4; /** - * Returns a new Size set as the subtraction result of the passed one from the current Size. + * Subtracts the passed ones from the current Color4 values and stores the results in "result". + * Returns the Color4. */ - subtract(otherSize: Size): Size; + subtractToRef(right: Color4, result: Color4): Color4; /** - * Returns a new Size set at the linear interpolation "amount" between "start" and "end". + * Creates a new Color4 with the current Color4 values multiplied by scale. */ - static Lerp(start: Size, end: Size, amount: number): Size; - } - class Quaternion { - x: number; - y: number; - z: number; - w: number; + scale(scale: number): Color4; /** - * Creates a new Quaternion from the passed floats. + * Multiplies the current Color4 values by scale and stores the result in "result". + * Returns the Color4. */ - constructor(x?: number, y?: number, z?: number, w?: number); + scaleToRef(scale: number, result: Color4): Color4; /** - * Returns a string with the Quaternion coordinates. + * Multipy an RGBA Color4 value by another and return a new Color4 object + * @param color The Color4 (RGBA) value to multiply by + * @returns A new Color4. + */ + multiply(color: Color4): Color4; + /** + * Multipy an RGBA Color4 value by another and push the result in a reference value + * @param color The Color4 (RGBA) value to multiply by + * @param result The Color4 (RGBA) to fill the result in + * @returns the result Color4. + */ + multiplyToRef(color: Color4, result: Color4): Color4; + /** + * Returns a string with the Color4 values. */ toString(): string; /** - * Returns the string "Quaternion". + * Returns the string "Color4" */ getClassName(): string; /** - * Returns the Quaternion hash code. + * Return the Color4 hash code as a number. */ getHashCode(): number; /** - * Returns a new array populated with 4 elements : the Quaternion coordinates. + * Creates a new Color4 copied from the current one. */ - asArray(): number[]; + clone(): Color4; /** - * Boolean : True if the current Quaterion and the passed one coordinates are strictly equal. + * Copies the passed Color4 values into the current one. + * Returns the updated Color4. */ - equals(otherQuaternion: Quaternion): boolean; + copyFrom(source: Color4): Color4; /** - * Returns a new Quaternion copied from the current one. + * Copies the passed float values into the current one. + * Returns the updated Color4. */ - clone(): Quaternion; + copyFromFloats(r: number, g: number, b: number, a: number): Color4; /** - * Updates the current Quaternion from the passed one coordinates. - * Returns the updated Quaterion. + * Copies the passed float values into the current one. + * Returns the updated Color4. */ - copyFrom(other: Quaternion): Quaternion; + set(r: number, g: number, b: number, a: number): Color4; /** - * Updates the current Quaternion from the passed float coordinates. - * Returns the updated Quaterion. + * Returns a string containing the hexadecimal Color4 code. */ - copyFromFloats(x: number, y: number, z: number, w: number): Quaternion; + toHexString(): string; /** - * Updates the current Quaternion from the passed float coordinates. - * Returns the updated Quaterion. + * Returns a new Color4 converted to linear space. */ - set(x: number, y: number, z: number, w: number): Quaternion; + toLinearSpace(): Color4; /** - * Returns a new Quaternion as the addition result of the passed one and the current Quaternion. + * Converts the Color4 values to linear space and stores the result in "convertedColor". + * Returns the unmodified Color4. */ - add(other: Quaternion): Quaternion; + toLinearSpaceToRef(convertedColor: Color4): Color4; /** - * Returns a new Quaternion as the subtraction result of the passed one from the current Quaternion. + * Returns a new Color4 converted to gamma space. */ - subtract(other: Quaternion): Quaternion; + toGammaSpace(): Color4; /** - * Returns a new Quaternion set by multiplying the current Quaterion coordinates by the float "scale". + * Converts the Color4 values to gamma space and stores the result in "convertedColor". + * Returns the unmodified Color4. */ - scale(value: number): Quaternion; + toGammaSpaceToRef(convertedColor: Color4): Color4; /** - * Returns a new Quaternion set as the quaternion mulplication result of the current one with the passed one "q1". + * Creates a new Color4 from the valid hexadecimal value contained in the passed string. */ - multiply(q1: Quaternion): Quaternion; + static FromHexString(hex: string): Color4; /** - * Sets the passed "result" as the quaternion mulplication result of the current one with the passed one "q1". - * Returns the current Quaternion. + * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 and the right Color4. */ - multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion; + static Lerp(left: Color4, right: Color4, amount: number): Color4; /** - * Updates the current Quaternion with the quaternion mulplication result of itself with the passed one "q1". - * Returns the updated Quaternion. + * Set the passed "result" with the linearly interpolated values of "amount" between the left Color4 and the right Color4. */ - multiplyInPlace(q1: Quaternion): Quaternion; + static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void; /** - * Sets the passed "ref" with the conjugation of the current Quaternion. - * Returns the current Quaternion. + * Creates a new Color4 from the starting index element of the passed array. */ - conjugateToRef(ref: Quaternion): Quaternion; + static FromArray(array: ArrayLike, offset?: number): Color4; /** - * Conjugates in place the current Quaternion. - * Returns the updated Quaternion. + * Creates a new Color4 from the passed integers ( < 256 ). */ - conjugateInPlace(): Quaternion; + static FromInts(r: number, g: number, b: number, a: number): Color4; + static CheckColors4(colors: number[], count: number): number[]; + } + class Vector2 { + x: number; + y: number; /** - * Returns a new Quaternion as the conjugate of the current Quaternion. + * Creates a new Vector2 from the passed x and y coordinates. */ - conjugate(): Quaternion; + constructor(x: number, y: number); /** - * Returns the Quaternion length (float). + * Returns a string with the Vector2 coordinates. */ - length(): number; + toString(): string; /** - * Normalize in place the current Quaternion. - * Returns the updated Quaternion. + * Returns the string "Vector2" */ - normalize(): Quaternion; + getClassName(): string; /** - * Returns a new Vector3 set with the Euler angles translated from the current Quaternion. + * Returns the Vector2 hash code as a number. */ - toEulerAngles(order?: string): Vector3; + getHashCode(): number; /** - * Sets the passed vector3 "result" with the Euler angles translated from the current Quaternion. - * Returns the current Quaternion. + * Sets the Vector2 coordinates in the passed array or Float32Array from the passed index. + * Returns the Vector2. */ - toEulerAnglesToRef(result: Vector3, order?: string): Quaternion; + toArray(array: number[] | Float32Array, index?: number): Vector2; /** - * Updates the passed rotation matrix with the current Quaternion values. - * Returns the current Quaternion. + * Returns a new array with 2 elements : the Vector2 coordinates. */ - toRotationMatrix(result: Matrix): Quaternion; + asArray(): number[]; /** - * Updates the current Quaternion from the passed rotation matrix values. - * Returns the updated Quaternion. + * Sets the Vector2 coordinates with the passed Vector2 coordinates. + * Returns the updated Vector2. */ - fromRotationMatrix(matrix: Matrix): Quaternion; + copyFrom(source: Vector2): Vector2; /** - * Returns a new Quaternion set from the passed rotation matrix values. + * Sets the Vector2 coordinates with the passed floats. + * Returns the updated Vector2. */ - static FromRotationMatrix(matrix: Matrix): Quaternion; + copyFromFloats(x: number, y: number): Vector2; /** - * Updates the passed quaternion "result" with the passed rotation matrix values. + * Sets the Vector2 coordinates with the passed floats. + * Returns the updated Vector2. */ - static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void; + set(x: number, y: number): Vector2; /** - * Returns a new Quaternion set to (0.0, 0.0, 0.0). + * Returns a new Vector2 set with the addition of the current Vector2 and the passed one coordinates. */ - static Zero(): Quaternion; + add(otherVector: Vector2): Vector2; /** - * Returns a new Quaternion as the inverted current Quaternion. + * Sets the "result" coordinates with the addition of the current Vector2 and the passed one coordinates. + * Returns the Vector2. */ - static Inverse(q: Quaternion): Quaternion; + addToRef(otherVector: Vector2, result: Vector2): Vector2; /** - * Returns the identity Quaternion. + * Set the Vector2 coordinates by adding the passed Vector2 coordinates. + * Returns the updated Vector2. */ - static Identity(): Quaternion; - static IsIdentity(quaternion: Quaternion): boolean; + addInPlace(otherVector: Vector2): Vector2; /** - * Returns a new Quaternion set from the passed axis (Vector3) and angle in radians (float). + * Returns a new Vector2 by adding the current Vector2 coordinates to the passed Vector3 x, y coordinates. */ - static RotationAxis(axis: Vector3, angle: number): Quaternion; + addVector3(otherVector: Vector3): Vector2; /** - * Sets the passed quaternion "result" from the passed axis (Vector3) and angle in radians (float). + * Returns a new Vector2 set with the subtracted coordinates of the passed one from the current Vector2. */ - static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion; + subtract(otherVector: Vector2): Vector2; /** - * Retuns a new Quaternion set from the starting index of the passed array. + * Sets the "result" coordinates with the subtraction of the passed one from the current Vector2 coordinates. + * Returns the Vector2. */ - static FromArray(array: ArrayLike, offset?: number): Quaternion; + subtractToRef(otherVector: Vector2, result: Vector2): Vector2; /** - * Returns a new Quaternion set from the passed Euler float angles (y, x, z). + * Sets the current Vector2 coordinates by subtracting from it the passed one coordinates. + * Returns the updated Vector2. */ - static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion; + subtractInPlace(otherVector: Vector2): Vector2; /** - * Sets the passed quaternion "result" from the passed float Euler angles (y, x, z). + * Multiplies in place the current Vector2 coordinates by the passed ones. + * Returns the updated Vector2. */ - static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void; + multiplyInPlace(otherVector: Vector2): Vector2; /** - * Returns a new Quaternion from the passed float Euler angles expressed in z-x-z orientation + * Returns a new Vector2 set with the multiplication of the current Vector2 and the passed one coordinates. */ - static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion; + multiply(otherVector: Vector2): Vector2; /** - * Sets the passed quaternion "result" from the passed float Euler angles expressed in z-x-z orientation + * Sets "result" coordinates with the multiplication of the current Vector2 and the passed one coordinates. + * Returns the Vector2. */ - static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void; + multiplyToRef(otherVector: Vector2, result: Vector2): Vector2; /** - * Returns a new Quaternion as the quaternion rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system. - * cf to Vector3.RotationFromAxis() documentation. - * Note : axis1, axis2 and axis3 are normalized during this operation. + * Returns a new Vector2 set with the Vector2 coordinates multiplied by the passed floats. */ - static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): Quaternion; + multiplyByFloats(x: number, y: number): Vector2; /** - * Sets the passed quaternion "ref" with the quaternion rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system. - * cf to Vector3.RotationFromAxis() documentation. - * Note : axis1, axis2 and axis3 are normalized during this operation. + * Returns a new Vector2 set with the Vector2 coordinates divided by the passed one coordinates. */ - static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void; - static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion; - static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void; + divide(otherVector: Vector2): Vector2; /** - * Returns a new Quaternion located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2". + * Sets the "result" coordinates with the Vector2 divided by the passed one coordinates. + * Returns the Vector2. */ - static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion; - } - class Matrix { - private static _tempQuaternion; - private static _xAxis; - private static _yAxis; - private static _zAxis; - private static _updateFlagSeed; - private _isIdentity; - private _isIdentityDirty; - updateFlag: number; - m: Float32Array; - _markAsUpdated(): void; - constructor(); + divideToRef(otherVector: Vector2, result: Vector2): Vector2; /** - * Boolean : True is the matrix is the identity matrix + * Returns a new Vector2 with current Vector2 negated coordinates. */ - isIdentity(considerAsTextureMatrix?: boolean): boolean; + negate(): Vector2; /** - * Returns the matrix determinant (float). + * Multiply the Vector2 coordinates by scale. + * Returns the updated Vector2. */ - determinant(): number; + scaleInPlace(scale: number): Vector2; /** - * Returns the matrix underlying array. + * Returns a new Vector2 scaled by "scale" from the current Vector2. */ - toArray(): Float32Array; - /** - * Returns the matrix underlying array. - */ - asArray(): Float32Array; + scale(scale: number): Vector2; /** - * Inverts in place the Matrix. - * Returns the Matrix inverted. + * Boolean : True if the passed vector coordinates strictly equal the current Vector2 ones. */ - invert(): Matrix; + equals(otherVector: Vector2): boolean; /** - * Sets all the matrix elements to zero. - * Returns the Matrix. + * Boolean : True if the passed vector coordinates are close to the current ones by a distance of epsilon. */ - reset(): Matrix; + equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean; /** - * Returns a new Matrix as the addition result of the current Matrix and the passed one. + * Returns the vector length (float). */ - add(other: Matrix): Matrix; + length(): number; /** - * Sets the passed matrix "result" with the ddition result of the current Matrix and the passed one. - * Returns the Matrix. + * Returns the vector squared length (float); */ - addToRef(other: Matrix, result: Matrix): Matrix; + lengthSquared(): number; /** - * Adds in place the passed matrix to the current Matrix. - * Returns the updated Matrix. + * Normalize the vector. + * Returns the updated Vector2. */ - addToSelf(other: Matrix): Matrix; + normalize(): Vector2; /** - * Sets the passed matrix with the current inverted Matrix. - * Returns the unmodified current Matrix. + * Returns a new Vector2 copied from the Vector2. */ - invertToRef(other: Matrix): Matrix; + clone(): Vector2; /** - * Inserts the translation vector (using 3 x floats) in the current Matrix. - * Returns the updated Matrix. + * Returns a new Vector2(0, 0) */ - setTranslationFromFloats(x: number, y: number, z: number): Matrix; - /** - * Inserts the translation vector in the current Matrix. - * Returns the updated Matrix. - */ - setTranslation(vector3: Vector3): Matrix; + static Zero(): Vector2; /** - * Returns a new Vector3 as the extracted translation from the Matrix. + * Returns a new Vector2(1, 1) */ - getTranslation(): Vector3; + static One(): Vector2; /** - * Fill a Vector3 with the extracted translation from the Matrix. + * Returns a new Vector2 set from the passed index element of the passed array. */ - getTranslationToRef(result: Vector3): Matrix; + static FromArray(array: ArrayLike, offset?: number): Vector2; /** - * Remove rotation and scaling part from the Matrix. - * Returns the updated Matrix. + * Sets "result" from the passed index element of the passed array. */ - removeRotationAndScaling(): Matrix; + static FromArrayToRef(array: ArrayLike, offset: number, result: Vector2): void; /** - * Returns a new Matrix set with the multiplication result of the current Matrix and the passed one. + * Retuns a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the passed four Vector2. */ - multiply(other: Matrix): Matrix; + static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2; /** - * Updates the current Matrix from the passed one values. - * Returns the updated Matrix. + * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max". + * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate. + * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate. */ - copyFrom(other: Matrix): Matrix; + static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2; /** - * Populates the passed array from the starting index with the Matrix values. - * Returns the Matrix. + * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2". */ - copyToArray(array: Float32Array, offset?: number): Matrix; + static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2; /** - * Sets the passed matrix "result" with the multiplication result of the current Matrix and the passed one. + * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end". */ - multiplyToRef(other: Matrix, result: Matrix): Matrix; + static Lerp(start: Vector2, end: Vector2, amount: number): Vector2; /** - * Sets the Float32Array "result" from the passed index "offset" with the multiplication result of the current Matrix and the passed one. + * Returns the dot product (float) of the vector "left" and the vector "right". */ - multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix; + static Dot(left: Vector2, right: Vector2): number; /** - * Boolean : True is the current Matrix and the passed one values are strictly equal. + * Returns a new Vector2 equal to the normalized passed vector. */ - equals(value: Matrix): boolean; + static Normalize(vector: Vector2): Vector2; /** - * Returns a new Matrix from the current Matrix. + * Returns a new Vecto2 set with the minimal coordinate values from the "left" and "right" vectors. */ - clone(): Matrix; + static Minimize(left: Vector2, right: Vector2): Vector2; /** - * Returns the string "Matrix" + * Returns a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors. */ - getClassName(): string; + static Maximize(left: Vector2, right: Vector2): Vector2; /** - * Returns the Matrix hash code. + * Returns a new Vecto2 set with the transformed coordinates of the passed vector by the passed transformation matrix. */ - getHashCode(): number; + static Transform(vector: Vector2, transformation: Matrix): Vector2; /** - * Decomposes the current Matrix into : - * - a scale vector3 passed as a reference to update, - * - a rotation quaternion passed as a reference to update, - * - a translation vector3 passed as a reference to update. - * Returns the boolean `true`. + * Transforms the passed vector coordinates by the passed transformation matrix and stores the result in the vector "result" coordinates. */ - decompose(scale: Vector3, rotation: Quaternion, translation: Vector3): boolean; + static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void; /** - * Returns a new Matrix as the extracted rotation matrix from the current one. + * Boolean : True if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2" */ - getRotationMatrix(): Matrix; + static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean; /** - * Extracts the rotation matrix from the current one and sets it as the passed "result". - * Returns the current Matrix. + * Returns the distance (float) between the vectors "value1" and "value2". */ - getRotationMatrixToRef(result: Matrix): Matrix; + static Distance(value1: Vector2, value2: Vector2): number; /** - * Returns a new Matrix set from the starting index of the passed array. + * Returns the squared distance (float) between the vectors "value1" and "value2". */ - static FromArray(array: ArrayLike, offset?: number): Matrix; + static DistanceSquared(value1: Vector2, value2: Vector2): number; /** - * Sets the passed "result" matrix from the starting index of the passed array. + * Returns a new Vecto2 located at the center of the vectors "value1" and "value2". */ - static FromArrayToRef(array: ArrayLike, offset: number, result: Matrix): void; + static Center(value1: Vector2, value2: Vector2): Vector2; /** - * Sets the passed "result" matrix from the starting index of the passed Float32Array by multiplying each element by the float "scale". + * Returns the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB". */ - static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void; + static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number; + } + class Vector3 { + x: number; + y: number; + z: number; /** - * Sets the passed matrix "result" with the 16 passed floats. + * Creates a new Vector3 object from the passed x, y, z (floats) coordinates. + * A Vector3 is the main object used in 3D geometry. + * It can represent etiher the coordinates of a point the space, either a direction. */ - static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void; + constructor(x: number, y: number, z: number); /** - * Returns the index-th row of the current matrix as a new Vector4. + * Returns a string with the Vector3 coordinates. */ - getRow(index: number): Vector4; + toString(): string; /** - * Sets the index-th row of the current matrix with the passed Vector4 values. - * Returns the updated Matrix. + * Returns the string "Vector3" */ - setRow(index: number, row: Vector4): Matrix; + getClassName(): string; /** - * Sets the index-th row of the current matrix with the passed 4 x float values. - * Returns the updated Matrix. + * Returns the Vector hash code. */ - setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix; + getHashCode(): number; /** - * Returns a new Matrix set from the 16 passed floats. + * Returns a new array with three elements : the coordinates the Vector3. */ - static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix; + asArray(): number[]; /** - * Returns a new Matrix composed by the passed scale (vector3), rotation (quaternion) and translation (vector3). + * Populates the passed array or Float32Array from the passed index with the successive coordinates of the Vector3. + * Returns the Vector3. */ - static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix; - /** - * Update a Matrix with values composed by the passed scale (vector3), rotation (quaternion) and translation (vector3). - */ - static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void; + toArray(array: number[] | Float32Array, index?: number): Vector3; /** - * Returns a new indentity Matrix. + * Returns a new Quaternion object, computed from the Vector3 coordinates. */ - static Identity(): Matrix; + toQuaternion(): Quaternion; /** - * Sets the passed "result" as an identity matrix. + * Adds the passed vector to the current Vector3. + * Returns the updated Vector3. */ - static IdentityToRef(result: Matrix): void; + addInPlace(otherVector: Vector3): Vector3; /** - * Returns a new zero Matrix. + * Returns a new Vector3, result of the addition the current Vector3 and the passed vector. */ - static Zero(): Matrix; + add(otherVector: Vector3): Vector3; /** - * Returns a new rotation matrix for "angle" radians around the X axis. + * Adds the current Vector3 to the passed one and stores the result in the vector "result". + * Returns the current Vector3. */ - static RotationX(angle: number): Matrix; + addToRef(otherVector: Vector3, result: Vector3): Vector3; /** - * Returns a new Matrix as the passed inverted one. + * Subtract the passed vector from the current Vector3. + * Returns the updated Vector3. */ - static Invert(source: Matrix): Matrix; + subtractInPlace(otherVector: Vector3): Vector3; /** - * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the X axis. + * Returns a new Vector3, result of the subtraction of the passed vector from the current Vector3. */ - static RotationXToRef(angle: number, result: Matrix): void; + subtract(otherVector: Vector3): Vector3; /** - * Returns a new rotation matrix for "angle" radians around the Y axis. + * Subtracts the passed vector from the current Vector3 and stores the result in the vector "result". + * Returns the current Vector3. */ - static RotationY(angle: number): Matrix; + subtractToRef(otherVector: Vector3, result: Vector3): Vector3; /** - * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the Y axis. + * Returns a new Vector3 set with the subtraction of the passed floats from the current Vector3 coordinates. */ - static RotationYToRef(angle: number, result: Matrix): void; + subtractFromFloats(x: number, y: number, z: number): Vector3; /** - * Returns a new rotation matrix for "angle" radians around the Z axis. + * Subtracts the passed floats from the current Vector3 coordinates and set the passed vector "result" with this result. + * Returns the current Vector3. */ - static RotationZ(angle: number): Matrix; + subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3; /** - * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the Z axis. + * Returns a new Vector3 set with the current Vector3 negated coordinates. */ - static RotationZToRef(angle: number, result: Matrix): void; + negate(): Vector3; /** - * Returns a new rotation matrix for "angle" radians around the passed axis. + * Multiplies the Vector3 coordinates by the float "scale". + * Returns the updated Vector3. */ - static RotationAxis(axis: Vector3, angle: number): Matrix; + scaleInPlace(scale: number): Vector3; /** - * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the passed axis. + * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale". */ - static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void; + scale(scale: number): Vector3; /** - * Returns a new Matrix as a rotation matrix from the Euler angles (y, x, z). + * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the passed vector "result" coordinates. + * Returns the current Vector3. */ - static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix; + scaleToRef(scale: number, result: Vector3): Vector3; /** - * Sets the passed matrix "result" as a rotation matrix from the Euler angles (y, x, z). + * Boolean : True if the current Vector3 and the passed vector coordinates are strictly equal. */ - static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void; + equals(otherVector: Vector3): boolean; /** - * Returns a new Matrix as a scaling matrix from the passed floats (x, y, z). + * Boolean : True if the current Vector3 and the passed vector coordinates are distant less than epsilon. */ - static Scaling(x: number, y: number, z: number): Matrix; + equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean; /** - * Sets the passed matrix "result" as a scaling matrix from the passed floats (x, y, z). + * Boolean : True if the current Vector3 coordinate equal the passed floats. */ - static ScalingToRef(x: number, y: number, z: number, result: Matrix): void; + equalsToFloats(x: number, y: number, z: number): boolean; /** - * Returns a new Matrix as a translation matrix from the passed floats (x, y, z). + * Muliplies the current Vector3 coordinates by the passed ones. + * Returns the updated Vector3. */ - static Translation(x: number, y: number, z: number): Matrix; + multiplyInPlace(otherVector: Vector3): Vector3; /** - * Sets the passed matrix "result" as a translation matrix from the passed floats (x, y, z). + * Returns a new Vector3, result of the multiplication of the current Vector3 by the passed vector. */ - static TranslationToRef(x: number, y: number, z: number, result: Matrix): void; + multiply(otherVector: Vector3): Vector3; /** - * Returns a new Matrix whose values are the interpolated values for "gradien" (float) between the ones of the matrices "startValue" and "endValue". + * Multiplies the current Vector3 by the passed one and stores the result in the passed vector "result". + * Returns the current Vector3. */ - static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix; + multiplyToRef(otherVector: Vector3, result: Vector3): Vector3; /** - * Returns a new Matrix whose values are computed by : - * - decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices, - * - interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end, - * - recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices. + * Returns a new Vector3 set witth the result of the mulliplication of the current Vector3 coordinates by the passed floats. */ - static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix; + multiplyByFloats(x: number, y: number, z: number): Vector3; /** - * Returns a new rotation Matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up". - * This methods works for a Left-Handed system. + * Returns a new Vector3 set witth the result of the division of the current Vector3 coordinates by the passed ones. */ - static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix; + divide(otherVector: Vector3): Vector3; /** - * Sets the passed "result" Matrix as a rotation matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up". - * This methods works for a Left-Handed system. + * Divides the current Vector3 coordinates by the passed ones and stores the result in the passed vector "result". + * Returns the current Vector3. */ - static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void; + divideToRef(otherVector: Vector3, result: Vector3): Vector3; /** - * Returns a new rotation Matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up". - * This methods works for a Right-Handed system. + * Updates the current Vector3 with the minimal coordinate values between its and the passed vector ones. + * Returns the updated Vector3. */ - static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix; + MinimizeInPlace(other: Vector3): Vector3; /** - * Sets the passed "result" Matrix as a rotation matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up". - * This methods works for a Left-Handed system. + * Updates the current Vector3 with the maximal coordinate values between its and the passed vector ones. + * Returns the updated Vector3. */ - static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void; + MaximizeInPlace(other: Vector3): Vector3; /** - * Returns a new Matrix as a left-handed orthographic projection matrix computed from the passed floats : width and height of the projection plane, z near and far limits. + * Returns the length of the Vector3 (float). */ - static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix; + length(): number; /** - * Sets the passed matrix "result" as a left-handed orthographic projection matrix computed from the passed floats : width and height of the projection plane, z near and far limits. + * Returns the squared length of the Vector3 (float). */ - static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void; + lengthSquared(): number; /** - * Returns a new Matrix as a left-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits. + * Normalize the current Vector3. + * Returns the updated Vector3. */ - static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix; + normalize(): Vector3; /** - * Sets the passed matrix "result" as a left-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits. + * Returns a new Vector3 copied from the current Vector3. */ - static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void; + clone(): Vector3; /** - * Returns a new Matrix as a right-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits. + * Copies the passed vector coordinates to the current Vector3 ones. + * Returns the updated Vector3. */ - static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix; + copyFrom(source: Vector3): Vector3; /** - * Sets the passed matrix "result" as a right-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits. + * Copies the passed floats to the current Vector3 coordinates. + * Returns the updated Vector3. */ - static OrthoOffCenterRHToRef(left: number, right: any, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void; + copyFromFloats(x: number, y: number, z: number): Vector3; /** - * Returns a new Matrix as a left-handed perspective projection matrix computed from the passed floats : width and height of the projection plane, z near and far limits. + * Copies the passed floats to the current Vector3 coordinates. + * Returns the updated Vector3. */ - static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix; + set(x: number, y: number, z: number): Vector3; /** - * Returns a new Matrix as a left-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits. + * */ - static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix; + static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: any): number; /** - * Sets the passed matrix "result" as a left-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits. + * Returns a new Vector3 set from the index "offset" of the passed array. */ - static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void; + static FromArray(array: ArrayLike, offset?: number): Vector3; /** - * Returns a new Matrix as a right-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits. + * Returns a new Vector3 set from the index "offset" of the passed Float32Array. + * This function is deprecated. Use FromArray instead. */ - static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix; + static FromFloatArray(array: Float32Array, offset?: number): Vector3; /** - * Sets the passed matrix "result" as a right-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits. + * Sets the passed vector "result" with the element values from the index "offset" of the passed array. */ - static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void; + static FromArrayToRef(array: ArrayLike, offset: number, result: Vector3): void; /** - * Sets the passed matrix "result" as a left-handed perspective projection matrix for WebVR computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits. + * Sets the passed vector "result" with the element values from the index "offset" of the passed Float32Array. + * This function is deprecated. Use FromArrayToRef instead. */ - static PerspectiveFovWebVRToRef(fov: any, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void; + static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void; /** - * Returns the final transformation matrix : world * view * projection * viewport + * Sets the passed vector "result" with the passed floats. */ - static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix; + static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void; /** - * Returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the passed Matrix. + * Returns a new Vector3 set to (0.0, 0.0, 0.0). */ - static GetAsMatrix2x2(matrix: Matrix): Float32Array; + static Zero(): Vector3; /** - * Returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the passed Matrix. + * Returns a new Vector3 set to (1.0, 1.0, 1.0). */ - static GetAsMatrix3x3(matrix: Matrix): Float32Array; + static One(): Vector3; /** - * Compute the transpose of the passed Matrix. - * Returns a new Matrix. + * Returns a new Vector3 set to (0.0, 1.0, 0.0) */ - static Transpose(matrix: Matrix): Matrix; + static Up(): Vector3; /** - * Returns a new Matrix as the reflection matrix across the passed plane. + * Returns a new Vector3 set to (0.0, 0.0, 1.0) */ - static Reflection(plane: Plane): Matrix; + static Forward(): Vector3; /** - * Sets the passed matrix "result" as the reflection matrix across the passed plane. + * Returns a new Vector3 set to (1.0, 0.0, 0.0) */ - static ReflectionToRef(plane: Plane, result: Matrix): void; + static Right(): Vector3; /** - * Sets the passed matrix "mat" as a rotation matrix composed from the 3 passed left handed axis. + * Returns a new Vector3 set to (-1.0, 0.0, 0.0) */ - static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void; + static Left(): Vector3; /** - * Sets the passed matrix "result" as a rotation matrix according to the passed quaternion. + * Returns a new Vector3 set with the result of the transformation by the passed matrix of the passed vector. + * This method computes tranformed coordinates only, not transformed direction vectors. */ - static FromQuaternionToRef(quat: Quaternion, result: Matrix): void; - } - class Plane { - normal: Vector3; - d: number; + static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3; /** - * Creates a Plane object according to the passed floats a, b, c, d and the plane equation : ax + by + cz + d = 0 + * Sets the passed vector "result" coordinates with the result of the transformation by the passed matrix of the passed vector. + * This method computes tranformed coordinates only, not transformed direction vectors. */ - constructor(a: number, b: number, c: number, d: number); + static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void; /** - * Returns the plane coordinates as a new array of 4 elements [a, b, c, d]. + * Sets the passed vector "result" coordinates with the result of the transformation by the passed matrix of the passed floats (x, y, z). + * This method computes tranformed coordinates only, not transformed direction vectors. */ - asArray(): number[]; + static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void; /** - * Returns a new plane copied from the current Plane. + * Returns a new Vector3 set with the result of the normal transformation by the passed matrix of the passed vector. + * This methods computes transformed normalized direction vectors only. */ - clone(): Plane; + static TransformNormal(vector: Vector3, transformation: Matrix): Vector3; /** - * Returns the string "Plane". + * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed vector. + * This methods computes transformed normalized direction vectors only. */ - getClassName(): string; + static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void; /** - * Returns the Plane hash code. + * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed floats (x, y, z). + * This methods computes transformed normalized direction vectors only. */ - getHashCode(): number; + static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void; /** - * Normalize the current Plane in place. - * Returns the updated Plane. + * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4". */ - normalize(): Plane; + static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3; /** - * Returns a new Plane as the result of the transformation of the current Plane by the passed matrix. + * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max". + * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one. + * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one. */ - transform(transformation: Matrix): Plane; + static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3; /** - * Returns the dot product (float) of the point coordinates and the plane normal. + * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2". */ - dotCoordinate(point: any): number; + static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3; /** - * Updates the current Plane from the plane defined by the three passed points. - * Returns the updated Plane. + * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end". */ - copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane; + static Lerp(start: Vector3, end: Vector3, amount: number): Vector3; /** - * Boolean : True is the vector "direction" is the same side than the plane normal. + * Sets the passed vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end". */ - isFrontFacingTo(direction: Vector3, epsilon: number): boolean; + static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void; /** - * Returns the signed distance (float) from the passed point to the Plane. + * Returns the dot product (float) between the vectors "left" and "right". */ - signedDistanceTo(point: Vector3): number; + static Dot(left: Vector3, right: Vector3): number; /** - * Returns a new Plane from the passed array. + * Returns a new Vector3 as the cross product of the vectors "left" and "right". + * The cross product is then orthogonal to both "left" and "right". */ - static FromArray(array: ArrayLike): Plane; + static Cross(left: Vector3, right: Vector3): Vector3; /** - * Returns a new Plane defined by the three passed points. + * Sets the passed vector "result" with the cross product of "left" and "right". + * The cross product is then orthogonal to both "left" and "right". */ - static FromPoints(point1: any, point2: any, point3: any): Plane; + static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void; /** - * Returns a new Plane the normal vector to this plane at the passed origin point. - * Note : the vector "normal" is updated because normalized. + * Returns a new Vector3 as the normalization of the passed vector. */ - static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane; + static Normalize(vector: Vector3): Vector3; /** - * Returns the signed distance between the plane defined by the normal vector at the "origin"" point and the passed other point. + * Sets the passed vector "result" with the normalization of the passed first vector. */ - static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number; - } - class Viewport { - x: number; - y: number; - width: number; - height: number; + static NormalizeToRef(vector: Vector3, result: Vector3): void; + private static _viewportMatrixCache; + static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3; + static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3; + static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3; + static Minimize(left: Vector3, right: Vector3): Vector3; + static Maximize(left: Vector3, right: Vector3): Vector3; /** - * Creates a Viewport object located at (x, y) and sized (width, height). + * Returns the distance (float) between the vectors "value1" and "value2". */ - constructor(x: number, y: number, width: number, height: number); - toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport; + static Distance(value1: Vector3, value2: Vector3): number; /** - * Returns a new Viewport copied from the current one. + * Returns the squared distance (float) between the vectors "value1" and "value2". */ - clone(): Viewport; - } - class Frustum { + static DistanceSquared(value1: Vector3, value2: Vector3): number; /** - * Returns a new array of 6 Frustum planes computed by the passed transformation matrix. + * Returns a new Vector3 located at the center between "value1" and "value2". */ - static GetPlanes(transform: Matrix): Plane[]; + static Center(value1: Vector3, value2: Vector3): Vector3; /** - * Sets the passed array "frustumPlanes" with the 6 Frustum planes computed by the passed transformation matrix. + * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system), + * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply + * to something in order to rotate it from its local system to the given target system. + * Note : axis1, axis2 and axis3 are normalized during this operation. + * Returns a new Vector3. */ - static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void; - } - enum Space { - LOCAL = 0, - WORLD = 1, - BONE = 2, - } - class Axis { - static X: Vector3; - static Y: Vector3; - static Z: Vector3; - } - class BezierCurve { + static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3; /** - * Returns the cubic Bezier interpolated value (float) at "t" (float) from the passed x1, y1, x2, y2 floats. + * The same than RotationFromAxis but updates the passed ref Vector3 parameter instead of returning a new Vector3. */ - static interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number; - } - enum Orientation { - CW = 0, - CCW = 1, + static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void; } - class Angle { - private _radians; + class Vector4 { + x: number; + y: number; + z: number; + w: number; /** - * Creates an Angle object of "radians" radians (float). + * Creates a Vector4 object from the passed floats. */ - constructor(radians: number); + constructor(x: number, y: number, z: number, w: number); /** - * Returns the Angle value in degrees (float). + * Returns the string with the Vector4 coordinates. */ - degrees: () => number; + toString(): string; /** - * Returns the Angle value in radians (float). + * Returns the string "Vector4". */ - radians: () => number; + getClassName(): string; /** - * Returns a new Angle object valued with the angle value in radians between the two passed vectors. + * Returns the Vector4 hash code. */ - static BetweenTwoPoints(a: Vector2, b: Vector2): Angle; + getHashCode(): number; /** - * Returns a new Angle object from the passed float in radians. + * Returns a new array populated with 4 elements : the Vector4 coordinates. */ - static FromRadians(radians: number): Angle; + asArray(): number[]; /** - * Returns a new Angle object from the passed float in degrees. + * Populates the passed array from the passed index with the Vector4 coordinates. + * Returns the Vector4. */ - static FromDegrees(degrees: number): Angle; - } - class Arc2 { - startPoint: Vector2; - midPoint: Vector2; - endPoint: Vector2; - centerPoint: Vector2; - radius: number; - angle: Angle; - startAngle: Angle; - orientation: Orientation; + toArray(array: number[] | Float32Array, index?: number): Vector4; /** - * Creates an Arc object from the three passed points : start, middle and end. + * Adds the passed vector to the current Vector4. + * Returns the updated Vector4. */ - constructor(startPoint: Vector2, midPoint: Vector2, endPoint: Vector2); - } - class Path2 { - private _points; - private _length; - closed: boolean; + addInPlace(otherVector: Vector4): Vector4; /** - * Creates a Path2 object from the starting 2D coordinates x and y. + * Returns a new Vector4 as the result of the addition of the current Vector4 and the passed one. */ - constructor(x: number, y: number); + add(otherVector: Vector4): Vector4; /** - * Adds a new segment until the passed coordinates (x, y) to the current Path2. - * Returns the updated Path2. + * Updates the passed vector "result" with the result of the addition of the current Vector4 and the passed one. + * Returns the current Vector4. */ - addLineTo(x: number, y: number): Path2; + addToRef(otherVector: Vector4, result: Vector4): Vector4; /** - * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2. - * Returns the updated Path2. + * Subtract in place the passed vector from the current Vector4. + * Returns the updated Vector4. */ - addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2; + subtractInPlace(otherVector: Vector4): Vector4; /** - * Closes the Path2. - * Returns the Path2. + * Returns a new Vector4 with the result of the subtraction of the passed vector from the current Vector4. */ - close(): Path2; + subtract(otherVector: Vector4): Vector4; /** - * Returns the Path2 total length (float). + * Sets the passed vector "result" with the result of the subtraction of the passed vector from the current Vector4. + * Returns the current Vector4. */ - length(): number; + subtractToRef(otherVector: Vector4, result: Vector4): Vector4; /** - * Returns the Path2 internal array of points. + * Returns a new Vector4 set with the result of the subtraction of the passed floats from the current Vector4 coordinates. */ - getPoints(): Vector2[]; + subtractFromFloats(x: number, y: number, z: number, w: number): Vector4; /** - * Returns a new Vector2 located at a percentage of the Path2 total length on this path. + * Sets the passed vector "result" set with the result of the subtraction of the passed floats from the current Vector4 coordinates. + * Returns the current Vector4. */ - getPointAtLengthPosition(normalizedLengthPosition: number): Vector2; + subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4; /** - * Returns a new Path2 starting at the coordinates (x, y). + * Returns a new Vector4 set with the current Vector4 negated coordinates. */ - static StartingAt(x: number, y: number): Path2; - } - class Path3D { - path: Vector3[]; - private _curve; - private _distances; - private _tangents; - private _normals; - private _binormals; - private _raw; - /** - * new Path3D(path, normal, raw) - * Creates a Path3D. A Path3D is a logical math object, so not a mesh. - * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D - * path : an array of Vector3, the curve axis of the Path3D - * normal (optional) : Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal. - * raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed. - */ - constructor(path: Vector3[], firstNormal?: Vector3, raw?: boolean); + negate(): Vector4; /** - * Returns the Path3D array of successive Vector3 designing its curve. + * Multiplies the current Vector4 coordinates by scale (float). + * Returns the updated Vector4. */ - getCurve(): Vector3[]; + scaleInPlace(scale: number): Vector4; /** - * Returns an array populated with tangent vectors on each Path3D curve point. + * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float). */ - getTangents(): Vector3[]; + scale(scale: number): Vector4; /** - * Returns an array populated with normal vectors on each Path3D curve point. + * Sets the passed vector "result" with the current Vector4 coordinates multiplied by scale (float). + * Returns the current Vector4. */ - getNormals(): Vector3[]; + scaleToRef(scale: number, result: Vector4): Vector4; /** - * Returns an array populated with binormal vectors on each Path3D curve point. + * Boolean : True if the current Vector4 coordinates are stricly equal to the passed ones. */ - getBinormals(): Vector3[]; + equals(otherVector: Vector4): boolean; /** - * Returns an array populated with distances (float) of the i-th point from the first curve point. + * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the passed vector ones. */ - getDistances(): number[]; + equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean; /** - * Forces the Path3D tangent, normal, binormal and distance recomputation. - * Returns the same object updated. + * Boolean : True if the passed floats are strictly equal to the current Vector4 coordinates. */ - update(path: Vector3[], firstNormal?: Vector3): Path3D; - private _compute(firstNormal); - private _getFirstNonNullVector(index); - private _getLastNonNullVector(index); - private _normalVector(v0, vt, va); - } - class Curve3 { - private _points; - private _length; + equalsToFloats(x: number, y: number, z: number, w: number): boolean; /** - * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve - * @param v0 (Vector3) the origin point of the Quadratic Bezier - * @param v1 (Vector3) the control point - * @param v2 (Vector3) the end point of the Quadratic Bezier - * @param nbPoints (integer) the wanted number of points in the curve + * Multiplies in place the current Vector4 by the passed one. + * Returns the updated Vector4. */ - static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3; + multiplyInPlace(otherVector: Vector4): Vector4; /** - * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve - * @param v0 (Vector3) the origin point of the Cubic Bezier - * @param v1 (Vector3) the first control point - * @param v2 (Vector3) the second control point - * @param v3 (Vector3) the end point of the Cubic Bezier - * @param nbPoints (integer) the wanted number of points in the curve + * Returns a new Vector4 set with the multiplication result of the current Vector4 and the passed one. */ - static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3; + multiply(otherVector: Vector4): Vector4; /** - * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline - * @param p1 (Vector3) the origin point of the Hermite Spline - * @param t1 (Vector3) the tangent vector at the origin point - * @param p2 (Vector3) the end point of the Hermite Spline - * @param t2 (Vector3) the tangent vector at the end point - * @param nbPoints (integer) the wanted number of points in the curve + * Updates the passed vector "result" with the multiplication result of the current Vector4 and the passed one. + * Returns the current Vector4. */ - static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3; + multiplyToRef(otherVector: Vector4, result: Vector4): Vector4; /** - * Returns a Curve3 object along a CatmullRom Spline curve : - * @param points (array of Vector3) the points the spline must pass through. At least, four points required. - * @param nbPoints (integer) the wanted number of points between each curve control points. + * Returns a new Vector4 set with the multiplication result of the passed floats and the current Vector4 coordinates. */ - static CreateCatmullRomSpline(points: Vector3[], nbPoints: number): Curve3; + multiplyByFloats(x: number, y: number, z: number, w: number): Vector4; /** - * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space. - * A Curve3 is designed from a series of successive Vector3. - * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object + * Returns a new Vector4 set with the division result of the current Vector4 by the passed one. */ - constructor(points: Vector3[]); + divide(otherVector: Vector4): Vector4; /** - * Returns the Curve3 stored array of successive Vector3 + * Updates the passed vector "result" with the division result of the current Vector4 by the passed one. + * Returns the current Vector4. */ - getPoints(): Vector3[]; + divideToRef(otherVector: Vector4, result: Vector4): Vector4; /** - * Returns the computed length (float) of the curve. + * Updates the Vector4 coordinates with the minimum values between its own and the passed vector ones. */ - length(): number; + MinimizeInPlace(other: Vector4): Vector4; /** - * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB); - * This new Curve3 is built by translating and sticking the curveB at the end of the curveA. - * curveA and curveB keep unchanged. + * Updates the Vector4 coordinates with the maximum values between its own and the passed vector ones. */ - continue(curve: Curve3): Curve3; - private _computeLength(path); - } - class PositionNormalVertex { - position: Vector3; - normal: Vector3; - constructor(position?: Vector3, normal?: Vector3); - clone(): PositionNormalVertex; - } - class PositionNormalTextureVertex { - position: Vector3; - normal: Vector3; - uv: Vector2; - constructor(position?: Vector3, normal?: Vector3, uv?: Vector2); - clone(): PositionNormalTextureVertex; - } - class Tmp { - static Color3: Color3[]; - static Vector2: Vector2[]; - static Vector3: Vector3[]; - static Vector4: Vector4[]; - static Quaternion: Quaternion[]; - static Matrix: Matrix[]; - } -} - -declare module BABYLON { - class SphericalPolynomial { - x: Vector3; - y: Vector3; - z: Vector3; - xx: Vector3; - yy: Vector3; - zz: Vector3; - xy: Vector3; - yz: Vector3; - zx: Vector3; - addAmbient(color: Color3): void; - static getSphericalPolynomialFromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial; - scale(scale: number): void; - } - class SphericalHarmonics { - L00: Vector3; - L1_1: Vector3; - L10: Vector3; - L11: Vector3; - L2_2: Vector3; - L2_1: Vector3; - L20: Vector3; - L21: Vector3; - L22: Vector3; - addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void; - scale(scale: number): void; - convertIncidentRadianceToIrradiance(): void; - convertIrradianceToLambertianRadiance(): void; - static getsphericalHarmonicsFromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics; - } -} - -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; + MaximizeInPlace(other: Vector4): Vector4; /** - * 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). + * Returns the Vector4 length (float). */ + length(): number; /** - * 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). + * Returns the Vector4 squared length (float). */ - globalHue: number; + lengthSquared(): 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. + * Normalizes in place the Vector4. + * Returns the updated Vector4. */ + normalize(): Vector4; /** - * 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. + * Returns a new Vector3 from the Vector4 (x, y, z) coordinates. */ - globalDensity: number; + toVector3(): Vector3; /** - * 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. + * Returns a new Vector4 copied from the current one. */ + clone(): Vector4; /** - * 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. + * Updates the current Vector4 with the passed one coordinates. + * Returns the updated Vector4. */ - globalSaturation: number; - private _highlightsHue; - private _highlightsDensity; - private _highlightsSaturation; - private _highlightsExposure; + copyFrom(source: Vector4): Vector4; /** - * 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). + * Updates the current Vector4 coordinates with the passed floats. + * Returns the updated Vector4. */ + copyFromFloats(x: number, y: number, z: number, w: number): Vector4; /** - * 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). + * Updates the current Vector4 coordinates with the passed floats. + * Returns the updated Vector4. */ - highlightsHue: number; + set(x: number, y: number, z: number, w: number): Vector4; /** - * 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. + * Returns a new Vector4 set from the starting index of the passed array. */ + static FromArray(array: ArrayLike, offset?: number): Vector4; /** - * 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. + * Updates the passed vector "result" from the starting index of the passed array. */ - highlightsDensity: number; + static FromArrayToRef(array: ArrayLike, offset: number, result: Vector4): void; /** - * 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. + * Updates the passed vector "result" from the starting index of the passed Float32Array. */ + static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void; /** - * 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. + * Updates the passed vector "result" coordinates from the passed floats. */ - highlightsSaturation: number; + static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void; /** - * 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. + * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0) */ + static Zero(): Vector4; /** - * 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. + * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0) */ - highlightsExposure: number; - private _midtonesHue; - private _midtonesDensity; - private _midtonesSaturation; - private _midtonesExposure; + static One(): Vector4; /** - * 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). + * Returns a new normalized Vector4 from the passed one. */ + static Normalize(vector: Vector4): Vector4; /** - * 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). + * Updates the passed vector "result" from the normalization of the passed one. */ - midtonesHue: number; + static NormalizeToRef(vector: Vector4, result: Vector4): void; + static Minimize(left: Vector4, right: Vector4): Vector4; + static Maximize(left: Vector4, right: Vector4): Vector4; /** - * 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. + * Returns the distance (float) between the vectors "value1" and "value2". */ + static Distance(value1: Vector4, value2: Vector4): number; /** - * 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. + * Returns the squared distance (float) between the vectors "value1" and "value2". */ - midtonesDensity: number; + static DistanceSquared(value1: Vector4, value2: Vector4): 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. + * Returns a new Vector4 located at the center between the vectors "value1" and "value2". */ + static Center(value1: Vector4, value2: Vector4): Vector4; /** - * 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. + * Returns a new Vector4 set with the result of the normal transformation by the passed matrix of the passed vector. + * This methods computes transformed normalized direction vectors only. */ - midtonesSaturation: number; + static TransformNormal(vector: Vector4, transformation: Matrix): Vector4; /** - * 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 passed vector "result" with the result of the normal transformation by the passed matrix of the passed vector. + * This methods computes transformed normalized direction vectors only. */ + static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void; /** - * 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. + * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed floats (x, y, z, w). + * This methods computes transformed normalized direction vectors only. */ - midtonesExposure: number; - private _shadowsHue; - private _shadowsDensity; - private _shadowsSaturation; - private _shadowsExposure; + static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void; + } + interface ISize { + width: number; + height: number; + } + class Size implements ISize { + width: number; + height: number; /** - * 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). + * Creates a Size object from the passed width and height (floats). */ + constructor(width: number, height: number); + toString(): string; /** - * 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). + * Returns the string "Size" */ - shadowsHue: number; + getClassName(): string; /** - * 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. + * Returns the Size hash code. */ + getHashCode(): number; /** - * 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. + * Updates the current size from the passed one. + * Returns the updated Size. */ - shadowsDensity: number; + copyFrom(src: Size): void; /** - * 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. + * Updates in place the current Size from the passed floats. + * Returns the updated Size. */ + copyFromFloats(width: number, height: number): Size; /** - * 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. + * Updates in place the current Size from the passed floats. + * Returns the updated Size. */ - shadowsSaturation: number; + set(width: number, height: number): Size; /** - * 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. + * Returns a new Size set with the multiplication result of the current Size and the passed floats. */ + multiplyByFloats(w: number, h: number): Size; /** - * 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. + * Returns a new Size copied from the passed one. */ - shadowsExposure: number; - getClassName(): string; + clone(): Size; /** - * Binds the color curves to the shader. - * @param colorCurves The color curve to bind - * @param effect The effect to bind to + * Boolean : True if the current Size and the passed one width and height are strictly equal. */ - static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void; + equals(other: Size): boolean; /** - * Prepare the list of uniforms associated with the ColorCurves effects. - * @param uniformsList The list of uniforms used in the effect + * Returns the surface of the Size : width * height (float). */ - static PrepareUniforms(uniformsList: string[]): void; + readonly surface: number; /** - * 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. + * Returns a new Size set to (0.0, 0.0) */ - private getColorGradingDataToRef(hue, density, saturation, exposure, result); + static Zero(): Size; /** - * 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. + * Returns a new Size set as the addition result of the current Size and the passed one. */ - private static applyColorGradingSliderNonlinear(value); + add(otherSize: Size): Size; /** - * 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. + * Returns a new Size set as the subtraction result of the passed one from the current Size. */ - private static fromHSBToRef(hue, saturation, brightness, result); + subtract(otherSize: Size): Size; /** - * 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. + * Returns a new Size set at the linear interpolation "amount" between "start" and "end". */ - private static clamp(value, min, max); + static Lerp(start: Size, end: Size, amount: number): Size; + } + class Quaternion { + x: number; + y: number; + z: number; + w: number; /** - * Clones the current color curve instance. - * @return The cloned curves + * Creates a new Quaternion from the passed floats. */ - clone(): ColorCurves; + constructor(x?: number, y?: number, z?: number, w?: number); /** - * Serializes the current color curve instance to a json representation. - * @return a JSON representation + * Returns a string with the Quaternion coordinates. */ - serialize(): any; + toString(): string; /** - * Parses the color curve from a json representation. - * @param source the JSON source to parse - * @return The parsed curves + * Returns the string "Quaternion". */ - static Parse(source: any): ColorCurves; - } -} - -declare module BABYLON { - class EffectFallbacks { - private _defines; - private _currentRank; - private _maxRank; - private _mesh; - private _meshRank; - addFallback(rank: number, define: string): void; - addCPUSkinningFallback(rank: number, mesh: BABYLON.AbstractMesh): void; - readonly isMoreFallbacks: boolean; - reduce(currentDefines: string): string; - } - class EffectCreationOptions { - attributes: string[]; - uniformsNames: string[]; - uniformBuffersNames: string[]; - samplers: string[]; - defines: any; - fallbacks: EffectFallbacks; - onCompiled: (effect: Effect) => void; - onError: (effect: Effect, errors: string) => void; - indexParameters: any; - maxSimultaneousLights: number; - } - class Effect { - name: any; - defines: string; - onCompiled: (effect: Effect) => void; - onError: (effect: Effect, errors: string) => void; - onBind: (effect: Effect) => void; - uniqueId: number; - onCompileObservable: Observable; - onErrorObservable: Observable; - onBindObservable: Observable; - private static _uniqueIdSeed; - private _engine; - private _uniformBuffersNames; - private _uniformsNames; - private _samplers; - private _isReady; - private _compilationError; - private _attributesNames; - private _attributes; - private _uniforms; - _key: string; - private _indexParameters; - private _fallbacks; - private _program; - private _valueCache; - private static _baseCache; - constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], engine?: Engine, defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, indexParameters?: any); - readonly key: string; - isReady(): boolean; - getEngine(): Engine; - getProgram(): WebGLProgram; - getAttributesNames(): string[]; - getAttributeLocation(index: number): number; - getAttributeLocationByName(name: string): number; - getAttributesCount(): number; - getUniformIndex(uniformName: string): number; - getUniform(uniformName: string): WebGLUniformLocation; - getSamplers(): string[]; - getCompilationError(): string; - getVertexShaderSource(): string; - getFragmentShaderSource(): string; - executeWhenCompiled(func: (effect: Effect) => void): void; - _loadVertexShader(vertex: any, callback: (data: any) => void): void; - _loadFragmentShader(fragment: any, callback: (data: any) => void): void; - private _dumpShadersSource(vertexCode, fragmentCode, defines); - private _processShaderConversion(sourceCode, isFragment, callback); - private _processIncludes(sourceCode, callback); - private _processPrecision(source); - private _prepareEffect(vertexSourceCode, fragmentSourceCode, attributesNames, defines, fallbacks?); - readonly isSupported: boolean; - _bindTexture(channel: string, texture: WebGLTexture): void; - setTexture(channel: string, texture: BaseTexture): void; - setTextureArray(channel: string, textures: BaseTexture[]): void; - setTextureFromPostProcess(channel: string, postProcess: PostProcess): void; - _cacheMatrix(uniformName: string, matrix: Matrix): boolean; - _cacheFloat2(uniformName: string, x: number, y: number): boolean; - _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean; - _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean; - bindUniformBuffer(buffer: WebGLBuffer, name: string): void; - bindUniformBlock(blockName: string, index: number): void; - setIntArray(uniformName: string, array: Int32Array): Effect; - setIntArray2(uniformName: string, array: Int32Array): Effect; - setIntArray3(uniformName: string, array: Int32Array): Effect; - setIntArray4(uniformName: string, array: Int32Array): Effect; - setFloatArray(uniformName: string, array: Float32Array): Effect; - setFloatArray2(uniformName: string, array: Float32Array): Effect; - setFloatArray3(uniformName: string, array: Float32Array): Effect; - setFloatArray4(uniformName: string, array: Float32Array): Effect; - setArray(uniformName: string, array: number[]): Effect; - setArray2(uniformName: string, array: number[]): Effect; - setArray3(uniformName: string, array: number[]): Effect; - setArray4(uniformName: string, array: number[]): Effect; - setMatrices(uniformName: string, matrices: Float32Array): Effect; - setMatrix(uniformName: string, matrix: Matrix): Effect; - setMatrix3x3(uniformName: string, matrix: Float32Array): Effect; - setMatrix2x2(uniformName: string, matrix: Float32Array): Effect; - setFloat(uniformName: string, value: number): Effect; - setBool(uniformName: string, bool: boolean): Effect; - setVector2(uniformName: string, vector2: Vector2): Effect; - setFloat2(uniformName: string, x: number, y: number): Effect; - setVector3(uniformName: string, vector3: Vector3): Effect; - setFloat3(uniformName: string, x: number, y: number, z: number): Effect; - setVector4(uniformName: string, vector4: Vector4): Effect; - setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect; - setColor3(uniformName: string, color3: Color3): Effect; - setColor4(uniformName: string, color3: Color3, alpha: number): Effect; - private _recombineShader(node); - private _evaluateDefinesOnString(shaderString); - static ShadersStore: {}; - static IncludesShadersStore: {}; - static ResetCache(): void; - } -} - -declare module BABYLON { - class FresnelParameters { - private _isEnabled; - isEnabled: boolean; - leftColor: Color3; - rightColor: Color3; - bias: number; - power: number; - clone(): FresnelParameters; - serialize(): any; - static Parse(parsedFresnelParameters: any): FresnelParameters; - } -} - -declare module BABYLON { - /** - * Interface to follow in your material defines to integrate easily the - * Image proccessing functions. - */ - interface IImageProcessingConfigurationDefines { - IMAGEPROCESSING: boolean; - VIGNETTE: boolean; - VIGNETTEBLENDMODEMULTIPLY: boolean; - VIGNETTEBLENDMODEOPAQUE: boolean; - TONEMAPPING: boolean; - CONTRAST: boolean; - EXPOSURE: boolean; - COLORCURVES: boolean; - COLORGRADING: boolean; - SAMPLER3DGREENDEPTH: boolean; - SAMPLER3DBGRMAP: boolean; - IMAGEPROCESSINGPOSTPROCESS: boolean; - } - /** - * 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 { + getClassName(): string; /** - * Color curves setup used in the effect if colorCurvesEnabled is set to true + * Returns the Quaternion hash code. */ - colorCurves: ColorCurves; - private _colorCurvesEnabled; + getHashCode(): number; /** - * Gets wether the color curves effect is enabled. + * Returns a new array populated with 4 elements : the Quaternion coordinates. */ + asArray(): number[]; /** - * Sets wether the color curves effect is enabled. + * Boolean : True if the current Quaterion and the passed one coordinates are strictly equal. */ - colorCurvesEnabled: boolean; + equals(otherQuaternion: Quaternion): boolean; /** - * Color grading LUT texture used in the effect if colorGradingEnabled is set to true + * Returns a new Quaternion copied from the current one. */ - colorGradingTexture: BaseTexture; - private _colorGradingEnabled; + clone(): Quaternion; /** - * Gets wether the color grading effect is enabled. + * Updates the current Quaternion from the passed one coordinates. + * Returns the updated Quaterion. */ + copyFrom(other: Quaternion): Quaternion; /** - * Sets wether the color grading effect is enabled. + * Updates the current Quaternion from the passed float coordinates. + * Returns the updated Quaterion. */ - colorGradingEnabled: boolean; - private _colorGradingWithGreenDepth; + copyFromFloats(x: number, y: number, z: number, w: number): Quaternion; /** - * Gets wether the color grading effect is using a green depth for the 3d Texture. + * Updates the current Quaternion from the passed float coordinates. + * Returns the updated Quaterion. */ + set(x: number, y: number, z: number, w: number): Quaternion; /** - * Sets wether the color grading effect is using a green depth for the 3d Texture. + * Returns a new Quaternion as the addition result of the passed one and the current Quaternion. */ - colorGradingWithGreenDepth: boolean; - private _colorGradingBGR; + add(other: Quaternion): Quaternion; /** - * Gets wether the color grading texture contains BGR values. + * Returns a new Quaternion as the subtraction result of the passed one from the current Quaternion. */ + subtract(other: Quaternion): Quaternion; /** - * Sets wether the color grading texture contains BGR values. + * Returns a new Quaternion set by multiplying the current Quaterion coordinates by the float "scale". */ - colorGradingBGR: boolean; - _exposure: number; + scale(value: number): Quaternion; /** - * Gets the Exposure used in the effect. + * Returns a new Quaternion set as the quaternion mulplication result of the current one with the passed one "q1". */ + multiply(q1: Quaternion): Quaternion; /** - * Sets the Exposure used in the effect. + * Sets the passed "result" as the quaternion mulplication result of the current one with the passed one "q1". + * Returns the current Quaternion. */ - exposure: number; - private _toneMappingEnabled; + multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion; /** - * Gets wether the tone mapping effect is enabled. + * Updates the current Quaternion with the quaternion mulplication result of itself with the passed one "q1". + * Returns the updated Quaternion. */ + multiplyInPlace(q1: Quaternion): Quaternion; /** - * Sets wether the tone mapping effect is enabled. + * Sets the passed "ref" with the conjugation of the current Quaternion. + * Returns the current Quaternion. */ - toneMappingEnabled: boolean; - protected _contrast: number; + conjugateToRef(ref: Quaternion): Quaternion; /** - * Gets the contrast used in the effect. + * Conjugates in place the current Quaternion. + * Returns the updated Quaternion. */ + conjugateInPlace(): Quaternion; /** - * Sets the contrast used in the effect. + * Returns a new Quaternion as the conjugate of the current Quaternion. */ - contrast: number; + conjugate(): Quaternion; /** - * Vignette stretch size. + * Returns the Quaternion length (float). */ - vignetteStretch: number; + length(): number; /** - * Vignette centre X Offset. + * Normalize in place the current Quaternion. + * Returns the updated Quaternion. */ - vignetteCentreX: number; + normalize(): Quaternion; /** - * Vignette centre Y Offset. + * Returns a new Vector3 set with the Euler angles translated from the current Quaternion. */ - vignetteCentreY: number; + toEulerAngles(order?: string): Vector3; /** - * Vignette weight or intensity of the vignette effect. + * Sets the passed vector3 "result" with the Euler angles translated from the current Quaternion. + * Returns the current Quaternion. */ - vignetteWeight: number; + toEulerAnglesToRef(result: Vector3, order?: string): Quaternion; /** - * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode) - * if vignetteEnabled is set to true. + * Updates the passed rotation matrix with the current Quaternion values. + * Returns the current Quaternion. */ - vignetteColor: BABYLON.Color4; + toRotationMatrix(result: Matrix): Quaternion; /** - * Camera field of view used by the Vignette effect. + * Updates the current Quaternion from the passed rotation matrix values. + * Returns the updated Quaternion. */ - vignetteCameraFov: number; - private _vignetteBlendMode; + fromRotationMatrix(matrix: Matrix): Quaternion; /** - * Gets the vignette blend mode allowing different kind of effect. + * Returns a new Quaternion set from the passed rotation matrix values. */ + static FromRotationMatrix(matrix: Matrix): Quaternion; /** - * Sets the vignette blend mode allowing different kind of effect. + * Updates the passed quaternion "result" with the passed rotation matrix values. */ - vignetteBlendMode: number; - private _vignetteEnabled; + static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void; /** - * Gets wether the vignette effect is enabled. + * Returns a new Quaternion set to (0.0, 0.0, 0.0). */ + static Zero(): Quaternion; /** - * Sets wether the vignette effect is enabled. + * Returns a new Quaternion as the inverted current Quaternion. */ - vignetteEnabled: boolean; - private _applyByPostProcess; + static Inverse(q: Quaternion): Quaternion; /** - * Gets wether the image processing is applied through a post process or not. + * Returns the identity Quaternion. */ + static Identity(): Quaternion; + static IsIdentity(quaternion: Quaternion): boolean; /** - * Sets wether the image processing is applied through a post process or not. + * Returns a new Quaternion set from the passed axis (Vector3) and angle in radians (float). */ - applyByPostProcess: boolean; + static RotationAxis(axis: Vector3, angle: number): Quaternion; /** - * An event triggered when the configuration changes and requires Shader to Update some parameters. - * @type {BABYLON.Observable} - */ - onUpdateParameters: Observable; + * Sets the passed quaternion "result" from the passed axis (Vector3) and angle in radians (float). + */ + static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion; /** - * Method called each time the image processing information changes requires to recompile the effect. + * Retuns a new Quaternion set from the starting index of the passed array. */ - protected _updateParameters(): void; - getClassName(): string; + static FromArray(array: ArrayLike, offset?: number): Quaternion; /** - * Prepare the list of uniforms associated with the Image Processing effects. - * @param uniformsList The list of uniforms used in the effect - * @param defines the list of defines currently in use + * Returns a new Quaternion set from the passed Euler float angles (y, x, z). */ - static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void; + static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion; /** - * Prepare the list of samplers associated with the Image Processing effects. - * @param uniformsList The list of uniforms used in the effect - * @param defines the list of defines currently in use + * Sets the passed quaternion "result" from the passed float Euler angles (y, x, z). */ - static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void; + static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void; /** - * Prepare the list of defines associated to the shader. - * @param defines the list of defines to complete + * Returns a new Quaternion from the passed float Euler angles expressed in z-x-z orientation */ - prepareDefines(defines: IImageProcessingConfigurationDefines): void; + static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion; /** - * Returns true if all the image processing information are ready. + * Sets the passed quaternion "result" from the passed float Euler angles expressed in z-x-z orientation */ - isReady(): boolean; + static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void; /** - * Binds the image processing to the shader. - * @param effect The effect to bind to + * Returns a new Quaternion as the quaternion rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system. + * cf to Vector3.RotationFromAxis() documentation. + * Note : axis1, axis2 and axis3 are normalized during this operation. */ - bind(effect: Effect, aspectRatio?: number): void; + static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): Quaternion; /** - * Clones the current image processing instance. - * @return The cloned image processing + * Sets the passed quaternion "ref" with the quaternion rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system. + * cf to Vector3.RotationFromAxis() documentation. + * Note : axis1, axis2 and axis3 are normalized during this operation. */ - clone(): ImageProcessingConfiguration; + static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void; + static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion; + static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void; /** - * Serializes the current image processing instance to a json representation. - * @return a JSON representation + * Returns a new Quaternion located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2". */ - serialize(): any; + static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion; + } + class Matrix { + private static _tempQuaternion; + private static _xAxis; + private static _yAxis; + private static _zAxis; + private static _updateFlagSeed; + private _isIdentity; + private _isIdentityDirty; + updateFlag: number; + m: Float32Array; + _markAsUpdated(): void; + constructor(); /** - * Parses the image processing from a json representation. - * @param source the JSON source to parse - * @return The parsed image processing + * Boolean : True is the matrix is the identity matrix */ - static Parse(source: any): ImageProcessingConfiguration; - private static _VIGNETTEMODE_MULTIPLY; - private static _VIGNETTEMODE_OPAQUE; + isIdentity(considerAsTextureMatrix?: boolean): boolean; /** - * Used to apply the vignette as a mix with the pixel color. + * Returns the matrix determinant (float). */ - static readonly VIGNETTEMODE_MULTIPLY: number; + determinant(): number; /** - * Used to apply the vignette as a replacement of the pixel color. + * Returns the matrix underlying array. */ - static readonly VIGNETTEMODE_OPAQUE: number; - } -} - -declare module BABYLON { - class MaterialDefines { - private _keys; - private _isDirty; - _renderId: number; - _areLightsDirty: boolean; - _areAttributesDirty: boolean; - _areTexturesDirty: boolean; - _areFresnelDirty: boolean; - _areMiscDirty: boolean; - _areImageProcessingDirty: boolean; - _normals: boolean; - _uvs: boolean; - _needNormals: boolean; - _needUVs: boolean; - readonly isDirty: boolean; - markAsProcessed(): void; - markAsUnprocessed(): void; - markAllAsDirty(): void; - markAsImageProcessingDirty(): void; - markAsLightDirty(): void; - markAsAttributesDirty(): void; - markAsTexturesDirty(): void; - markAsFresnelDirty(): void; - markAsMiscDirty(): void; - rebuild(): void; - isEqual(other: MaterialDefines): boolean; - cloneTo(other: MaterialDefines): void; - reset(): void; - toString(): string; - } - class Material { - private static _TriangleFillMode; - private static _WireFrameFillMode; - private static _PointFillMode; - static readonly TriangleFillMode: number; - static readonly WireFrameFillMode: number; - static readonly PointFillMode: number; - private static _ClockWiseSideOrientation; - private static _CounterClockWiseSideOrientation; - static readonly ClockWiseSideOrientation: number; - static readonly CounterClockWiseSideOrientation: number; - private static _TextureDirtyFlag; - private static _LightDirtyFlag; - private static _FresnelDirtyFlag; - private static _AttributesDirtyFlag; - private static _MiscDirtyFlag; - static readonly TextureDirtyFlag: number; - static readonly LightDirtyFlag: number; - static readonly FresnelDirtyFlag: number; - static readonly AttributesDirtyFlag: number; - static readonly MiscDirtyFlag: number; - id: string; - name: string; - checkReadyOnEveryCall: boolean; - checkReadyOnlyOnce: boolean; - state: string; - alpha: number; - protected _backFaceCulling: boolean; - backFaceCulling: boolean; - sideOrientation: number; - onCompiled: (effect: Effect) => void; - onError: (effect: Effect, errors: string) => void; - getRenderTargetTextures: () => SmartArray; - doNotSerialize: boolean; - storeEffectOnSubMeshes: boolean; + toArray(): Float32Array; /** - * An event triggered when the material is disposed. - * @type {BABYLON.Observable} + * Returns the matrix underlying array. */ - onDisposeObservable: Observable; - private _onDisposeObserver; - onDispose: () => void; + asArray(): Float32Array; /** - * An event triggered when the material is bound. - * @type {BABYLON.Observable} - */ - onBindObservable: Observable; - private _onBindObserver; - onBind: (Mesh: AbstractMesh) => void; + * Inverts in place the Matrix. + * Returns the Matrix inverted. + */ + invert(): Matrix; /** - * An event triggered when the material is unbound. - * @type {BABYLON.Observable} - */ - onUnBindObservable: Observable; - alphaMode: number; - disableDepthWrite: boolean; - private _fogEnabled; - fogEnabled: boolean; - pointSize: number; - zOffset: number; - wireframe: boolean; - pointsCloud: boolean; - fillMode: number; - _effect: Effect; - _wasPreviouslyReady: boolean; - private _useUBO; - private _scene; - private _fillMode; - private _cachedDepthWriteState; - protected _uniformBuffer: UniformBuffer; - constructor(name: string, scene: Scene, doNotAdd?: boolean); + * Sets all the matrix elements to zero. + * Returns the Matrix. + */ + reset(): Matrix; /** - * @param {boolean} fullDetails - support for multiple levels of logging within scene loading - * subclasses should override adding information pertainent to themselves + * Returns a new Matrix as the addition result of the current Matrix and the passed one. */ - toString(fullDetails?: boolean): string; + add(other: Matrix): Matrix; /** - * Child classes can use it to update shaders + * Sets the passed matrix "result" with the ddition result of the current Matrix and the passed one. + * Returns the Matrix. */ - getClassName(): string; - readonly isFrozen: boolean; - freeze(): void; - unfreeze(): void; - isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean; - isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean; - getEffect(): Effect; - getScene(): Scene; - needAlphaBlending(): boolean; - needAlphaTesting(): boolean; - getAlphaTestTexture(): BaseTexture; - markDirty(): void; - _preBind(effect?: Effect): void; - bind(world: Matrix, mesh?: Mesh): void; - bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void; - bindOnlyWorldMatrix(world: Matrix): void; - bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void; - bindView(effect: Effect): void; - bindViewProjection(effect: Effect): void; - protected _afterBind(mesh: Mesh): void; - unbind(): void; - getActiveTextures(): BaseTexture[]; - hasTexture(texture: BaseTexture): boolean; - clone(name: string): Material; - getBindedMeshes(): AbstractMesh[]; + addToRef(other: Matrix, result: Matrix): Matrix; /** - * Force shader compilation including textures ready check + * Adds in place the passed matrix to the current Matrix. + * Returns the updated Matrix. + */ + addToSelf(other: Matrix): Matrix; + /** + * Sets the passed matrix with the current inverted Matrix. + * Returns the unmodified current Matrix. + */ + invertToRef(other: Matrix): Matrix; + /** + * Inserts the translation vector (using 3 x floats) in the current Matrix. + * Returns the updated Matrix. + */ + setTranslationFromFloats(x: number, y: number, z: number): Matrix; + /** + * Inserts the translation vector in the current Matrix. + * Returns the updated Matrix. + */ + setTranslation(vector3: Vector3): Matrix; + /** + * Returns a new Vector3 as the extracted translation from the Matrix. + */ + getTranslation(): Vector3; + /** + * Fill a Vector3 with the extracted translation from the Matrix. + */ + getTranslationToRef(result: Vector3): Matrix; + /** + * Remove rotation and scaling part from the Matrix. + * Returns the updated Matrix. + */ + removeRotationAndScaling(): Matrix; + /** + * Returns a new Matrix set with the multiplication result of the current Matrix and the passed one. + */ + multiply(other: Matrix): Matrix; + /** + * Updates the current Matrix from the passed one values. + * Returns the updated Matrix. + */ + copyFrom(other: Matrix): Matrix; + /** + * Populates the passed array from the starting index with the Matrix values. + * Returns the Matrix. + */ + copyToArray(array: Float32Array, offset?: number): Matrix; + /** + * Sets the passed matrix "result" with the multiplication result of the current Matrix and the passed one. + */ + multiplyToRef(other: Matrix, result: Matrix): Matrix; + /** + * Sets the Float32Array "result" from the passed index "offset" with the multiplication result of the current Matrix and the passed one. + */ + multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix; + /** + * Boolean : True is the current Matrix and the passed one values are strictly equal. + */ + equals(value: Matrix): boolean; + /** + * Returns a new Matrix from the current Matrix. + */ + clone(): Matrix; + /** + * Returns the string "Matrix" */ - forceCompilation(mesh: AbstractMesh, onCompiled: (material: Material) => void, options?: { - alphaTest: boolean; - clipPlane: boolean; - }): void; - markAsDirty(flag: number): void; - protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void; - protected _markAllSubMeshesAsImageProcessingDirty(): void; - protected _markAllSubMeshesAsTexturesDirty(): void; - protected _markAllSubMeshesAsFresnelDirty(): void; - protected _markAllSubMeshesAsLightsDirty(): void; - protected _markAllSubMeshesAsAttributesDirty(): void; - protected _markAllSubMeshesAsMiscDirty(): void; - dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void; - serialize(): any; - static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial; - static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any; - } -} - -declare module BABYLON { - class MaterialHelper { - static PrepareDefinesForMergedUV(texture: BaseTexture, defines: MaterialDefines, key: string): void; - static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void; - static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: any, fogEnabled: boolean, defines: MaterialDefines): void; - static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: MaterialDefines, useInstances: boolean, forceAlphaTest?: boolean): void; - static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: MaterialDefines, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean): boolean; - static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: MaterialDefines, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean; - static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: MaterialDefines, maxSimultaneousLights?: number): void; - static HandleFallbacksForShadows(defines: MaterialDefines, fallbacks: EffectFallbacks, maxSimultaneousLights?: number): void; - static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: MaterialDefines): void; - static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: MaterialDefines, fallbacks: EffectFallbacks): void; - static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void; - static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void; - static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void; - static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: MaterialDefines, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void; - static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect): void; - static BindBonesParameters(mesh: AbstractMesh, effect: Effect): void; - static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void; - static BindLogDepth(defines: MaterialDefines, effect: Effect, scene: Scene): void; - static BindClipPlane(effect: Effect, scene: Scene): void; - } -} - -declare module BABYLON { - class MultiMaterial extends Material { - private _subMaterials; - subMaterials: Material[]; - constructor(name: string, scene: Scene); - private _hookArray(array); - getSubMaterial(index: any): Material; - getActiveTextures(): BaseTexture[]; - getClassName(): string; - isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean; - clone(name: string, cloneChildren?: boolean): MultiMaterial; - serialize(): any; - dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void; - } -} - -declare module BABYLON { - class PushMaterial extends Material { - protected _activeEffect: Effect; - constructor(name: string, scene: Scene); - getEffect(): Effect; - isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean; - bindOnlyWorldMatrix(world: Matrix): void; - bind(world: Matrix, mesh?: Mesh): void; - protected _afterBind(mesh: Mesh, effect?: Effect): void; - protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean; - } -} - -declare module BABYLON { - class ShaderMaterial extends Material { - private _shaderPath; - private _options; - private _textures; - private _textureArrays; - private _floats; - private _floatsArrays; - private _colors3; - private _colors3Arrays; - private _colors4; - private _vectors2; - private _vectors3; - private _vectors4; - private _matrices; - private _matrices3x3; - private _matrices2x2; - private _vectors3Arrays; - private _cachedWorldViewMatrix; - private _renderId; - constructor(name: string, scene: Scene, shaderPath: any, options: any); getClassName(): string; - needAlphaBlending(): boolean; - needAlphaTesting(): boolean; - private _checkUniform(uniformName); - setTexture(name: string, texture: Texture): ShaderMaterial; - setTextureArray(name: string, textures: Texture[]): ShaderMaterial; - setFloat(name: string, value: number): ShaderMaterial; - setFloats(name: string, value: number[]): ShaderMaterial; - setColor3(name: string, value: Color3): ShaderMaterial; - setColor3Array(name: string, value: Color3[]): ShaderMaterial; - setColor4(name: string, value: Color4): ShaderMaterial; - setVector2(name: string, value: Vector2): ShaderMaterial; - setVector3(name: string, value: Vector3): ShaderMaterial; - setVector4(name: string, value: Vector4): ShaderMaterial; - setMatrix(name: string, value: Matrix): ShaderMaterial; - setMatrix3x3(name: string, value: Float32Array): ShaderMaterial; - setMatrix2x2(name: string, value: Float32Array): ShaderMaterial; - setArray3(name: string, value: number[]): ShaderMaterial; - private _checkCache(scene, mesh?, useInstances?); - isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean; - bindOnlyWorldMatrix(world: Matrix): void; - bind(world: Matrix, mesh?: Mesh): void; - getActiveTextures(): BaseTexture[]; - hasTexture(texture: BaseTexture): boolean; - clone(name: string): ShaderMaterial; - dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void; - serialize(): any; - static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial; - } -} - -declare module BABYLON { - class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines { - MAINUV1: boolean; - MAINUV2: boolean; - DIFFUSE: boolean; - DIFFUSEDIRECTUV: number; - AMBIENT: boolean; - AMBIENTDIRECTUV: number; - OPACITY: boolean; - OPACITYDIRECTUV: number; - OPACITYRGB: boolean; - REFLECTION: boolean; - EMISSIVE: boolean; - EMISSIVEDIRECTUV: number; - SPECULAR: boolean; - SPECULARDIRECTUV: number; - BUMP: boolean; - BUMPDIRECTUV: number; - PARALLAX: boolean; - PARALLAXOCCLUSION: boolean; - SPECULAROVERALPHA: boolean; - CLIPPLANE: boolean; - ALPHATEST: boolean; - ALPHAFROMDIFFUSE: boolean; - POINTSIZE: boolean; - FOG: boolean; - SPECULARTERM: boolean; - DIFFUSEFRESNEL: boolean; - OPACITYFRESNEL: boolean; - REFLECTIONFRESNEL: boolean; - REFRACTIONFRESNEL: boolean; - EMISSIVEFRESNEL: boolean; - FRESNEL: boolean; - NORMAL: boolean; - UV1: boolean; - UV2: boolean; - VERTEXCOLOR: boolean; - VERTEXALPHA: boolean; - NUM_BONE_INFLUENCERS: number; - BonesPerMesh: number; - INSTANCES: boolean; - GLOSSINESS: boolean; - ROUGHNESS: boolean; - EMISSIVEASILLUMINATION: boolean; - LINKEMISSIVEWITHDIFFUSE: boolean; - REFLECTIONFRESNELFROMSPECULAR: boolean; - LIGHTMAP: boolean; - LIGHTMAPDIRECTUV: number; - USELIGHTMAPASSHADOWMAP: boolean; - REFLECTIONMAP_3D: boolean; - REFLECTIONMAP_SPHERICAL: boolean; - REFLECTIONMAP_PLANAR: boolean; - REFLECTIONMAP_CUBIC: boolean; - REFLECTIONMAP_PROJECTION: boolean; - REFLECTIONMAP_SKYBOX: boolean; - REFLECTIONMAP_EXPLICIT: boolean; - REFLECTIONMAP_EQUIRECTANGULAR: boolean; - REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean; - REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean; - INVERTCUBICMAP: boolean; - LOGARITHMICDEPTH: boolean; - REFRACTION: boolean; - REFRACTIONMAP_3D: boolean; - REFLECTIONOVERALPHA: boolean; - TWOSIDEDLIGHTING: boolean; - SHADOWFLOAT: boolean; - MORPHTARGETS: boolean; - MORPHTARGETS_NORMAL: boolean; - MORPHTARGETS_TANGENT: boolean; - NUM_MORPH_INFLUENCERS: number; - USERIGHTHANDEDSYSTEM: boolean; - IMAGEPROCESSING: boolean; - VIGNETTE: boolean; - VIGNETTEBLENDMODEMULTIPLY: boolean; - VIGNETTEBLENDMODEOPAQUE: boolean; - TONEMAPPING: boolean; - CONTRAST: boolean; - COLORCURVES: boolean; - COLORGRADING: boolean; - SAMPLER3DGREENDEPTH: boolean; - SAMPLER3DBGRMAP: boolean; - IMAGEPROCESSINGPOSTPROCESS: boolean; - EXPOSURE: boolean; - constructor(); - setReflectionMode(modeToEnable: string): void; - } - class StandardMaterial extends PushMaterial { - private _diffuseTexture; - diffuseTexture: BaseTexture; - private _ambientTexture; - ambientTexture: BaseTexture; - private _opacityTexture; - opacityTexture: BaseTexture; - private _reflectionTexture; - reflectionTexture: BaseTexture; - private _emissiveTexture; - emissiveTexture: BaseTexture; - private _specularTexture; - specularTexture: BaseTexture; - private _bumpTexture; - bumpTexture: BaseTexture; - private _lightmapTexture; - lightmapTexture: BaseTexture; - private _refractionTexture; - refractionTexture: BaseTexture; - ambientColor: Color3; - diffuseColor: Color3; - specularColor: Color3; - emissiveColor: Color3; - specularPower: number; - private _useAlphaFromDiffuseTexture; - useAlphaFromDiffuseTexture: boolean; - private _useEmissiveAsIllumination; - useEmissiveAsIllumination: boolean; - private _linkEmissiveWithDiffuse; - linkEmissiveWithDiffuse: boolean; - private _useSpecularOverAlpha; - useSpecularOverAlpha: boolean; - private _useReflectionOverAlpha; - useReflectionOverAlpha: boolean; - private _disableLighting; - disableLighting: boolean; - private _useParallax; - useParallax: boolean; - private _useParallaxOcclusion; - useParallaxOcclusion: boolean; - parallaxScaleBias: number; - private _roughness; - roughness: number; - indexOfRefraction: number; - invertRefractionY: boolean; - private _useLightmapAsShadowmap; - useLightmapAsShadowmap: boolean; - private _diffuseFresnelParameters; - diffuseFresnelParameters: FresnelParameters; - private _opacityFresnelParameters; - opacityFresnelParameters: FresnelParameters; - private _reflectionFresnelParameters; - reflectionFresnelParameters: FresnelParameters; - private _refractionFresnelParameters; - refractionFresnelParameters: FresnelParameters; - private _emissiveFresnelParameters; - emissiveFresnelParameters: FresnelParameters; - private _useReflectionFresnelFromSpecular; - useReflectionFresnelFromSpecular: boolean; - private _useGlossinessFromSpecularMapAlpha; - useGlossinessFromSpecularMapAlpha: boolean; - private _maxSimultaneousLights; - maxSimultaneousLights: number; /** - * If sets to true, x component of normal map value will invert (x = 1.0 - x). + * Returns the Matrix hash code. + */ + getHashCode(): number; + /** + * Decomposes the current Matrix into : + * - a scale vector3 passed as a reference to update, + * - a rotation quaternion passed as a reference to update, + * - a translation vector3 passed as a reference to update. + * Returns the boolean `true`. + */ + decompose(scale: Vector3, rotation: Quaternion, translation: Vector3): boolean; + /** + * Returns a new Matrix as the extracted rotation matrix from the current one. + */ + getRotationMatrix(): Matrix; + /** + * Extracts the rotation matrix from the current one and sets it as the passed "result". + * Returns the current Matrix. + */ + getRotationMatrixToRef(result: Matrix): Matrix; + /** + * Returns a new Matrix set from the starting index of the passed array. + */ + static FromArray(array: ArrayLike, offset?: number): Matrix; + /** + * Sets the passed "result" matrix from the starting index of the passed array. + */ + static FromArrayToRef(array: ArrayLike, offset: number, result: Matrix): void; + /** + * Sets the passed "result" matrix from the starting index of the passed Float32Array by multiplying each element by the float "scale". + */ + static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void; + /** + * Sets the passed matrix "result" with the 16 passed floats. + */ + static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void; + /** + * Returns the index-th row of the current matrix as a new Vector4. + */ + getRow(index: number): Vector4; + /** + * Sets the index-th row of the current matrix with the passed Vector4 values. + * Returns the updated Matrix. + */ + setRow(index: number, row: Vector4): Matrix; + /** + * Sets the index-th row of the current matrix with the passed 4 x float values. + * Returns the updated Matrix. + */ + setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix; + /** + * Returns a new Matrix set from the 16 passed floats. + */ + static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix; + /** + * Returns a new Matrix composed by the passed scale (vector3), rotation (quaternion) and translation (vector3). + */ + static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix; + /** + * Update a Matrix with values composed by the passed scale (vector3), rotation (quaternion) and translation (vector3). + */ + static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void; + /** + * Returns a new indentity Matrix. + */ + static Identity(): Matrix; + /** + * Sets the passed "result" as an identity matrix. + */ + static IdentityToRef(result: Matrix): void; + /** + * Returns a new zero Matrix. + */ + static Zero(): Matrix; + /** + * Returns a new rotation matrix for "angle" radians around the X axis. + */ + static RotationX(angle: number): Matrix; + /** + * Returns a new Matrix as the passed inverted one. + */ + static Invert(source: Matrix): Matrix; + /** + * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the X axis. + */ + static RotationXToRef(angle: number, result: Matrix): void; + /** + * Returns a new rotation matrix for "angle" radians around the Y axis. + */ + static RotationY(angle: number): Matrix; + /** + * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the Y axis. */ - private _invertNormalMapX; - invertNormalMapX: boolean; + static RotationYToRef(angle: number, result: Matrix): void; /** - * If sets to true, y component of normal map value will invert (y = 1.0 - y). + * Returns a new rotation matrix for "angle" radians around the Z axis. */ - private _invertNormalMapY; - invertNormalMapY: boolean; + static RotationZ(angle: number): Matrix; /** - * If sets to true and backfaceCulling is false, normals will be flipped on the backside. + * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the Z axis. */ - private _twoSidedLighting; - twoSidedLighting: boolean; + static RotationZToRef(angle: number, result: Matrix): void; /** - * Default configuration related to image processing available in the standard Material. + * Returns a new rotation matrix for "angle" radians around the passed axis. */ - protected _imageProcessingConfiguration: ImageProcessingConfiguration; + static RotationAxis(axis: Vector3, angle: number): Matrix; /** - * Gets the image processing configuration used either in this material. + * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the passed axis. */ + static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void; /** - * Sets the Default image processing configuration used either in the this material. - * - * If sets to null, the scene one is in use. + * Returns a new Matrix as a rotation matrix from the Euler angles (y, x, z). */ - imageProcessingConfiguration: ImageProcessingConfiguration; + static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix; /** - * Keep track of the image processing observer to allow dispose and replace. + * Sets the passed matrix "result" as a rotation matrix from the Euler angles (y, x, z). */ - private _imageProcessingObserver; + static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void; /** - * Attaches a new image processing configuration to the Standard Material. - * @param configuration + * Returns a new Matrix as a scaling matrix from the passed floats (x, y, z). */ - protected _attachImageProcessingConfiguration(configuration: ImageProcessingConfiguration): void; + static Scaling(x: number, y: number, z: number): Matrix; /** - * Gets wether the color curves effect is enabled. + * Sets the passed matrix "result" as a scaling matrix from the passed floats (x, y, z). */ + static ScalingToRef(x: number, y: number, z: number, result: Matrix): void; /** - * Sets wether the color curves effect is enabled. + * Returns a new Matrix as a translation matrix from the passed floats (x, y, z). */ - cameraColorCurvesEnabled: boolean; + static Translation(x: number, y: number, z: number): Matrix; /** - * Gets wether the color grading effect is enabled. + * Sets the passed matrix "result" as a translation matrix from the passed floats (x, y, z). */ + static TranslationToRef(x: number, y: number, z: number, result: Matrix): void; /** - * Gets wether the color grading effect is enabled. + * Returns a new Matrix whose values are the interpolated values for "gradien" (float) between the ones of the matrices "startValue" and "endValue". */ - cameraColorGradingEnabled: boolean; + static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix; /** - * Gets wether tonemapping is enabled or not. + * Returns a new Matrix whose values are computed by : + * - decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices, + * - interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end, + * - recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices. */ + static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix; /** - * Sets wether tonemapping is enabled or not + * Returns a new rotation Matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up". + * This methods works for a Left-Handed system. */ - cameraToneMappingEnabled: boolean; + static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix; /** - * The camera exposure used on this material. - * This property is here and not in the camera to allow controlling exposure without full screen post process. - * This corresponds to a photographic exposure. + * Sets the passed "result" Matrix as a rotation matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up". + * This methods works for a Left-Handed system. */ + static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void; /** - * The camera exposure used on this material. - * This property is here and not in the camera to allow controlling exposure without full screen post process. - * This corresponds to a photographic exposure. + * Returns a new rotation Matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up". + * This methods works for a Right-Handed system. */ - cameraExposure: number; + static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix; /** - * Gets The camera contrast used on this material. + * Sets the passed "result" Matrix as a rotation matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up". + * This methods works for a Left-Handed system. */ + static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void; /** - * Sets The camera contrast used on this material. + * Returns a new Matrix as a left-handed orthographic projection matrix computed from the passed floats : width and height of the projection plane, z near and far limits. */ - cameraContrast: number; + static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix; /** - * Gets the Color Grading 2D Lookup Texture. + * Sets the passed matrix "result" as a left-handed orthographic projection matrix computed from the passed floats : width and height of the projection plane, z near and far limits. */ + static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void; /** - * Sets the Color Grading 2D Lookup Texture. + * Returns a new Matrix as a left-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits. */ - cameraColorGradingTexture: BaseTexture; - customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string; - protected _renderTargets: SmartArray; - protected _worldViewProjectionMatrix: Matrix; - protected _globalAmbientColor: Color3; - protected _useLogarithmicDepth: boolean; - constructor(name: string, scene: Scene); - getClassName(): string; - useLogarithmicDepth: boolean; - needAlphaBlending(): boolean; - needAlphaTesting(): boolean; - protected _shouldUseAlphaFromDiffuseTexture(): boolean; - getAlphaTestTexture(): BaseTexture; + static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix; /** - * Child classes can use it to update shaders + * Sets the passed matrix "result" as a left-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits. */ - isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean; - buildUniformLayout(): void; - unbind(): void; - bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void; - getAnimatables(): IAnimatable[]; - getActiveTextures(): BaseTexture[]; - hasTexture(texture: BaseTexture): boolean; - dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void; - clone(name: string): StandardMaterial; - serialize(): any; - static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial; - static _DiffuseTextureEnabled: boolean; - static DiffuseTextureEnabled: boolean; - static _AmbientTextureEnabled: boolean; - static AmbientTextureEnabled: boolean; - static _OpacityTextureEnabled: boolean; - static OpacityTextureEnabled: boolean; - static _ReflectionTextureEnabled: boolean; - static ReflectionTextureEnabled: boolean; - static _EmissiveTextureEnabled: boolean; - static EmissiveTextureEnabled: boolean; - static _SpecularTextureEnabled: boolean; - static SpecularTextureEnabled: boolean; - static _BumpTextureEnabled: boolean; - static BumpTextureEnabled: boolean; - static _LightmapTextureEnabled: boolean; - static LightmapTextureEnabled: boolean; - static _RefractionTextureEnabled: boolean; - static RefractionTextureEnabled: boolean; - static _ColorGradingTextureEnabled: boolean; - static ColorGradingTextureEnabled: boolean; - static _FresnelEnabled: boolean; - static FresnelEnabled: boolean; + static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void; + /** + * Returns a new Matrix as a right-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits. + */ + static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix; + /** + * Sets the passed matrix "result" as a right-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits. + */ + static OrthoOffCenterRHToRef(left: number, right: any, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void; + /** + * Returns a new Matrix as a left-handed perspective projection matrix computed from the passed floats : width and height of the projection plane, z near and far limits. + */ + static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix; + /** + * Returns a new Matrix as a left-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits. + */ + static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix; + /** + * Sets the passed matrix "result" as a left-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits. + */ + static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void; + /** + * Returns a new Matrix as a right-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits. + */ + static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix; + /** + * Sets the passed matrix "result" as a right-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits. + */ + static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void; + /** + * Sets the passed matrix "result" as a left-handed perspective projection matrix for WebVR computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits. + */ + static PerspectiveFovWebVRToRef(fov: any, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void; + /** + * Returns the final transformation matrix : world * view * projection * viewport + */ + static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix; + /** + * Returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the passed Matrix. + */ + static GetAsMatrix2x2(matrix: Matrix): Float32Array; + /** + * Returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the passed Matrix. + */ + static GetAsMatrix3x3(matrix: Matrix): Float32Array; + /** + * Compute the transpose of the passed Matrix. + * Returns a new Matrix. + */ + static Transpose(matrix: Matrix): Matrix; + /** + * Returns a new Matrix as the reflection matrix across the passed plane. + */ + static Reflection(plane: Plane): Matrix; + /** + * Sets the passed matrix "result" as the reflection matrix across the passed plane. + */ + static ReflectionToRef(plane: Plane, result: Matrix): void; + /** + * Sets the passed matrix "mat" as a rotation matrix composed from the 3 passed left handed axis. + */ + static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void; + /** + * Sets the passed matrix "result" as a rotation matrix according to the passed quaternion. + */ + static FromQuaternionToRef(quat: Quaternion, result: Matrix): void; } -} - -declare module BABYLON { - class UniformBuffer { - private _engine; - private _buffer; - private _data; - private _bufferData; - private _dynamic; - private _uniformName; - private _uniformLocations; - private _uniformSizes; - private _uniformLocationPointer; - private _needSync; - private _cache; - private _noUBO; - private _currentEffect; - private static _MAX_UNIFORM_SIZE; - private static _tempBuffer; + class Plane { + normal: Vector3; + d: number; + /** + * Creates a Plane object according to the passed floats a, b, c, d and the plane equation : ax + by + cz + d = 0 + */ + constructor(a: number, b: number, c: number, d: number); + /** + * Returns the plane coordinates as a new array of 4 elements [a, b, c, d]. + */ + asArray(): number[]; + /** + * Returns a new plane copied from the current Plane. + */ + clone(): Plane; + /** + * Returns the string "Plane". + */ + getClassName(): string; + /** + * Returns the Plane hash code. + */ + getHashCode(): number; + /** + * Normalize the current Plane in place. + * Returns the updated Plane. + */ + normalize(): Plane; + /** + * Returns a new Plane as the result of the transformation of the current Plane by the passed matrix. + */ + transform(transformation: Matrix): Plane; /** - * Wrapper for updateUniform. - * @method updateMatrix3x3 - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {Float32Array} matrix + * Returns the dot product (float) of the point coordinates and the plane normal. */ - updateMatrix3x3: (name: string, matrix: Float32Array) => void; + dotCoordinate(point: any): number; /** - * Wrapper for updateUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {Float32Array} matrix + * Updates the current Plane from the plane defined by the three passed points. + * Returns the updated Plane. */ - updateMatrix2x2: (name: string, matrix: Float32Array) => void; + copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane; /** - * Wrapper for updateUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {number} x + * Boolean : True is the vector "direction" is the same side than the plane normal. */ - updateFloat: (name: string, x: number) => void; + isFrontFacingTo(direction: Vector3, epsilon: number): boolean; /** - * Wrapper for updateUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {number} x - * @param {number} y - * @param {string} [suffix] Suffix to add to the uniform name. + * Returns the signed distance (float) from the passed point to the Plane. */ - updateFloat2: (name: string, x: number, y: number, suffix?: string) => void; + signedDistanceTo(point: Vector3): number; /** - * Wrapper for updateUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {number} x - * @param {number} y - * @param {number} z - * @param {string} [suffix] Suffix to add to the uniform name. + * Returns a new Plane from the passed array. */ - updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void; + static FromArray(array: ArrayLike): Plane; /** - * Wrapper for updateUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {number} x - * @param {number} y - * @param {number} z - * @param {number} w - * @param {string} [suffix] Suffix to add to the uniform name. + * Returns a new Plane defined by the three passed points. */ - updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void; + static FromPoints(point1: any, point2: any, point3: any): Plane; /** - * Wrapper for updateUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {Matrix} A 4x4 matrix. + * Returns a new Plane the normal vector to this plane at the passed origin point. + * Note : the vector "normal" is updated because normalized. */ - updateMatrix: (name: string, mat: Matrix) => void; + static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane; /** - * Wrapper for updateUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {Vector3} vector + * Returns the signed distance between the plane defined by the normal vector at the "origin"" point and the passed other point. */ - updateVector3: (name: string, vector: Vector3) => void; + static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number; + } + class Viewport { + x: number; + y: number; + width: number; + height: number; /** - * Wrapper for updateUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {Vector4} vector + * Creates a Viewport object located at (x, y) and sized (width, height). */ - updateVector4: (name: string, vector: Vector4) => void; + constructor(x: number, y: number, width: number, height: number); + toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport; /** - * Wrapper for updateUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {Color3} color - * @param {string} [suffix] Suffix to add to the uniform name. + * Returns a new Viewport copied from the current one. */ - updateColor3: (name: string, color: Color3, suffix?: string) => void; + clone(): Viewport; + } + class Frustum { /** - * Wrapper for updateUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {Color3} color - * @param {number} alpha - * @param {string} [suffix] Suffix to add to the uniform name. + * Returns a new array of 6 Frustum planes computed by the passed transformation matrix. */ - updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void; + static GetPlanes(transform: Matrix): Plane[]; /** - * Uniform buffer objects. - * - * Handles blocks of uniform on the GPU. - * - * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls. - * - * For more information, please refer to : - * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object + * Sets the passed array "frustumPlanes" with the 6 Frustum planes computed by the passed transformation matrix. */ - constructor(engine: Engine, data?: number[], dynamic?: boolean); + static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void; + } + enum Space { + LOCAL = 0, + WORLD = 1, + BONE = 2, + } + class Axis { + static X: Vector3; + static Y: Vector3; + static Z: Vector3; + } + class BezierCurve { /** - * Indicates if the buffer is using the WebGL2 UBO implementation, - * or just falling back on setUniformXXX calls. + * Returns the cubic Bezier interpolated value (float) at "t" (float) from the passed x1, y1, x2, y2 floats. */ - readonly useUbo: boolean; + static interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number; + } + enum Orientation { + CW = 0, + CCW = 1, + } + class Angle { + private _radians; /** - * Indicates if the WebGL underlying uniform buffer is in sync - * with the javascript cache data. + * Creates an Angle object of "radians" radians (float). */ - readonly isSync: boolean; + constructor(radians: number); /** - * Indicates if the WebGL underlying uniform buffer is dynamic. - * Also, a dynamic UniformBuffer will disable cache verification and always - * update the underlying WebGL uniform buffer to the GPU. + * Returns the Angle value in degrees (float). */ - isDynamic(): boolean; + degrees: () => number; /** - * The data cache on JS side. + * Returns the Angle value in radians (float). */ - getData(): Float32Array; + radians: () => number; /** - * The underlying WebGL Uniform buffer. + * Returns a new Angle object valued with the angle value in radians between the two passed vectors. */ - getBuffer(): WebGLBuffer; + static BetweenTwoPoints(a: Vector2, b: Vector2): Angle; /** - * std140 layout specifies how to align data within an UBO structure. - * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159 - * for specs. + * Returns a new Angle object from the passed float in radians. */ - private _fillAlignment(size); + static FromRadians(radians: number): Angle; /** - * Adds an uniform in the buffer. - * Warning : the subsequents calls of this function must be in the same order as declared in the shader - * for the layout to be correct ! - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {number|number[]} size Data size, or data directly. + * Returns a new Angle object from the passed float in degrees. */ - addUniform(name: string, size: number | number[]): void; + static FromDegrees(degrees: number): Angle; + } + class Arc2 { + startPoint: Vector2; + midPoint: Vector2; + endPoint: Vector2; + centerPoint: Vector2; + radius: number; + angle: Angle; + startAngle: Angle; + orientation: Orientation; /** - * Wrapper for addUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {Matrix} mat A 4x4 matrix. + * Creates an Arc object from the three passed points : start, middle and end. */ - addMatrix(name: string, mat: Matrix): void; + constructor(startPoint: Vector2, midPoint: Vector2, endPoint: Vector2); + } + class Path2 { + private _points; + private _length; + closed: boolean; /** - * Wrapper for addUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {number} x - * @param {number} y + * Creates a Path2 object from the starting 2D coordinates x and y. */ - addFloat2(name: string, x: number, y: number): void; + constructor(x: number, y: number); /** - * Wrapper for addUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {number} x - * @param {number} y - * @param {number} z + * Adds a new segment until the passed coordinates (x, y) to the current Path2. + * Returns the updated Path2. */ - addFloat3(name: string, x: number, y: number, z: number): void; + addLineTo(x: number, y: number): Path2; /** - * Wrapper for addUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {Color3} color + * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2. + * Returns the updated Path2. */ - addColor3(name: string, color: Color3): void; + addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2; /** - * Wrapper for addUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {Color3} color - * @param {number} alpha + * Closes the Path2. + * Returns the Path2. + */ + close(): Path2; + /** + * Returns the Path2 total length (float). + */ + length(): number; + /** + * Returns the Path2 internal array of points. + */ + getPoints(): Vector2[]; + /** + * Returns a new Vector2 located at a percentage of the Path2 total length on this path. + */ + getPointAtLengthPosition(normalizedLengthPosition: number): Vector2; + /** + * Returns a new Path2 starting at the coordinates (x, y). + */ + static StartingAt(x: number, y: number): Path2; + } + class Path3D { + path: Vector3[]; + private _curve; + private _distances; + private _tangents; + private _normals; + private _binormals; + private _raw; + /** + * new Path3D(path, normal, raw) + * Creates a Path3D. A Path3D is a logical math object, so not a mesh. + * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D + * path : an array of Vector3, the curve axis of the Path3D + * normal (optional) : Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal. + * raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed. + */ + constructor(path: Vector3[], firstNormal?: Vector3, raw?: boolean); + /** + * Returns the Path3D array of successive Vector3 designing its curve. + */ + getCurve(): Vector3[]; + /** + * Returns an array populated with tangent vectors on each Path3D curve point. + */ + getTangents(): Vector3[]; + /** + * Returns an array populated with normal vectors on each Path3D curve point. + */ + getNormals(): Vector3[]; + /** + * Returns an array populated with binormal vectors on each Path3D curve point. */ - addColor4(name: string, color: Color3, alpha: number): void; + getBinormals(): Vector3[]; /** - * Wrapper for addUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {Vector3} vector + * Returns an array populated with distances (float) of the i-th point from the first curve point. */ - addVector3(name: string, vector: Vector3): void; + getDistances(): number[]; /** - * Wrapper for addUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * Forces the Path3D tangent, normal, binormal and distance recomputation. + * Returns the same object updated. */ - addMatrix3x3(name: string): void; + update(path: Vector3[], firstNormal?: Vector3): Path3D; + private _compute(firstNormal); + private _getFirstNonNullVector(index); + private _getLastNonNullVector(index); + private _normalVector(v0, vt, va); + } + class Curve3 { + private _points; + private _length; /** - * Wrapper for addUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve + * @param v0 (Vector3) the origin point of the Quadratic Bezier + * @param v1 (Vector3) the control point + * @param v2 (Vector3) the end point of the Quadratic Bezier + * @param nbPoints (integer) the wanted number of points in the curve */ - addMatrix2x2(name: string): void; + static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3; /** - * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`. + * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve + * @param v0 (Vector3) the origin point of the Cubic Bezier + * @param v1 (Vector3) the first control point + * @param v2 (Vector3) the second control point + * @param v3 (Vector3) the end point of the Cubic Bezier + * @param nbPoints (integer) the wanted number of points in the curve */ - create(): void; + static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3; /** - * Updates the WebGL Uniform Buffer on the GPU. - * If the `dynamic` flag is set to true, no cache comparison is done. - * Otherwise, the buffer will be updated only if the cache differs. + * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline + * @param p1 (Vector3) the origin point of the Hermite Spline + * @param t1 (Vector3) the tangent vector at the origin point + * @param p2 (Vector3) the end point of the Hermite Spline + * @param t2 (Vector3) the tangent vector at the end point + * @param nbPoints (integer) the wanted number of points in the curve */ - update(): void; + static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3; /** - * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU. - * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader. - * @param {number[]|Float32Array} data Flattened data - * @param {number} size Size of the data. + * Returns a Curve3 object along a CatmullRom Spline curve : + * @param points (array of Vector3) the points the spline must pass through. At least, four points required. + * @param nbPoints (integer) the wanted number of points between each curve control points. */ - updateUniform(uniformName: string, data: number[] | Float32Array, size: number): void; - private _updateMatrix3x3ForUniform(name, matrix); - private _updateMatrix3x3ForEffect(name, matrix); - private _updateMatrix2x2ForEffect(name, matrix); - private _updateMatrix2x2ForUniform(name, matrix); - private _updateFloatForEffect(name, x); - private _updateFloatForUniform(name, x); - private _updateFloat2ForEffect(name, x, y, suffix?); - private _updateFloat2ForUniform(name, x, y, suffix?); - private _updateFloat3ForEffect(name, x, y, z, suffix?); - private _updateFloat3ForUniform(name, x, y, z, suffix?); - private _updateFloat4ForEffect(name, x, y, z, w, suffix?); - private _updateFloat4ForUniform(name, x, y, z, w, suffix?); - private _updateMatrixForEffect(name, mat); - private _updateMatrixForUniform(name, mat); - private _updateVector3ForEffect(name, vector); - private _updateVector3ForUniform(name, vector); - private _updateVector4ForEffect(name, vector); - private _updateVector4ForUniform(name, vector); - private _updateColor3ForEffect(name, color, suffix?); - private _updateColor3ForUniform(name, color, suffix?); - private _updateColor4ForEffect(name, color, alpha, suffix?); - private _updateColor4ForUniform(name, color, alpha, suffix?); + static CreateCatmullRomSpline(points: Vector3[], nbPoints: number): Curve3; /** - * Sets a sampler uniform on the effect. - * @param {string} name Name of the sampler. - * @param {Texture} texture + * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space. + * A Curve3 is designed from a series of successive Vector3. + * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object */ - setTexture(name: string, texture: BaseTexture): void; + constructor(points: Vector3[]); /** - * Directly updates the value of the uniform in the cache AND on the GPU. - * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader. - * @param {number[]|Float32Array} data Flattened data + * Returns the Curve3 stored array of successive Vector3 */ - updateUniformDirectly(uniformName: string, data: number[] | Float32Array): void; + getPoints(): Vector3[]; /** - * Binds this uniform buffer to an effect. - * @param {Effect} effect - * @param {string} name Name of the uniform block in the shader. + * Returns the computed length (float) of the curve. */ - bindToEffect(effect: Effect, name: string): void; + length(): number; /** - * Disposes the uniform buffer. + * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB); + * This new Curve3 is built by translating and sticking the curveB at the end of the curveA. + * curveA and curveB keep unchanged. */ - dispose(): void; + continue(curve: Curve3): Curve3; + private _computeLength(path); + } + class PositionNormalVertex { + position: Vector3; + normal: Vector3; + constructor(position?: Vector3, normal?: Vector3); + clone(): PositionNormalVertex; + } + class PositionNormalTextureVertex { + position: Vector3; + normal: Vector3; + uv: Vector2; + constructor(position?: Vector3, normal?: Vector3, uv?: Vector2); + clone(): PositionNormalTextureVertex; + } + class Tmp { + static Color3: Color3[]; + static Vector2: Vector2[]; + static Vector3: Vector3[]; + static Vector4: Vector4[]; + static Quaternion: Quaternion[]; + static Matrix: Matrix[]; + } +} + +declare module BABYLON { + class SphericalPolynomial { + x: Vector3; + y: Vector3; + z: Vector3; + xx: Vector3; + yy: Vector3; + zz: Vector3; + xy: Vector3; + yz: Vector3; + zx: Vector3; + addAmbient(color: Color3): void; + static getSphericalPolynomialFromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial; + scale(scale: number): void; + } + class SphericalHarmonics { + L00: Vector3; + L1_1: Vector3; + L10: Vector3; + L11: Vector3; + L2_2: Vector3; + L2_1: Vector3; + L20: Vector3; + L21: Vector3; + L22: Vector3; + addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void; + scale(scale: number): void; + convertIncidentRadianceToIrradiance(): void; + convertIrradianceToLambertianRadiance(): void; + static getsphericalHarmonicsFromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics; } } @@ -12145,96 +12145,32 @@ declare module BABYLON { dispose(): void; private static _PositionKind; private static _NormalKind; - private static _TangentKind; - private static _UVKind; - private static _UV2Kind; - private static _UV3Kind; - private static _UV4Kind; - private static _UV5Kind; - private static _UV6Kind; - private static _ColorKind; - private static _MatricesIndicesKind; - private static _MatricesWeightsKind; - private static _MatricesIndicesExtraKind; - private static _MatricesWeightsExtraKind; - static readonly PositionKind: string; - static readonly NormalKind: string; - static readonly TangentKind: string; - static readonly UVKind: string; - static readonly UV2Kind: string; - static readonly UV3Kind: string; - static readonly UV4Kind: string; - static readonly UV5Kind: string; - static readonly UV6Kind: string; - static readonly ColorKind: string; - static readonly MatricesIndicesKind: string; - static readonly MatricesWeightsKind: string; - static readonly MatricesIndicesExtraKind: string; - static readonly MatricesWeightsExtraKind: string; - } -} - -declare module BABYLON { - class MorphTarget { - name: string; - animations: Animation[]; - private _positions; - private _normals; - private _tangents; - private _influence; - onInfluenceChanged: Observable; - influence: number; - constructor(name: string, influence?: number); - readonly hasNormals: boolean; - readonly hasTangents: boolean; - setPositions(data: Float32Array | number[]): void; - getPositions(): Float32Array; - setNormals(data: Float32Array | number[]): void; - getNormals(): Float32Array; - setTangents(data: Float32Array | number[]): void; - getTangents(): Float32Array; - /** - * Serializes the current target into a Serialization object. - * Returns the serialized object. - */ - serialize(): any; - static Parse(serializationObject: any): MorphTarget; - static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget; - } -} - -declare module BABYLON { - class MorphTargetManager { - private _targets; - private _targetObservable; - private _activeTargets; - private _scene; - private _influences; - private _supportsNormals; - private _supportsTangents; - private _vertexCount; - private _uniqueId; - private _tempInfluences; - constructor(scene?: Scene); - readonly uniqueId: number; - readonly vertexCount: number; - readonly supportsNormals: boolean; - readonly supportsTangents: boolean; - readonly numTargets: number; - readonly numInfluencers: number; - readonly influences: Float32Array; - getActiveTarget(index: number): MorphTarget; - getTarget(index: number): MorphTarget; - addTarget(target: MorphTarget): void; - removeTarget(target: MorphTarget): void; - /** - * Serializes the current manager into a Serialization object. - * Returns the serialized object. - */ - serialize(): any; - private _onInfluenceChanged(needUpdate); - private _syncActiveTargets(needUpdate); - static Parse(serializationObject: any, scene: Scene): MorphTargetManager; + private static _TangentKind; + private static _UVKind; + private static _UV2Kind; + private static _UV3Kind; + private static _UV4Kind; + private static _UV5Kind; + private static _UV6Kind; + private static _ColorKind; + private static _MatricesIndicesKind; + private static _MatricesWeightsKind; + private static _MatricesIndicesExtraKind; + private static _MatricesWeightsExtraKind; + static readonly PositionKind: string; + static readonly NormalKind: string; + static readonly TangentKind: string; + static readonly UVKind: string; + static readonly UV2Kind: string; + static readonly UV3Kind: string; + static readonly UV4Kind: string; + static readonly UV5Kind: string; + static readonly UV6Kind: string; + static readonly ColorKind: string; + static readonly MatricesIndicesKind: string; + static readonly MatricesWeightsKind: string; + static readonly MatricesIndicesExtraKind: string; + static readonly MatricesWeightsExtraKind: string; } } @@ -12730,6 +12666,70 @@ declare module BABYLON { } } +declare module BABYLON { + class MorphTarget { + name: string; + animations: Animation[]; + private _positions; + private _normals; + private _tangents; + private _influence; + onInfluenceChanged: Observable; + influence: number; + constructor(name: string, influence?: number); + readonly hasNormals: boolean; + readonly hasTangents: boolean; + setPositions(data: Float32Array | number[]): void; + getPositions(): Float32Array; + setNormals(data: Float32Array | number[]): void; + getNormals(): Float32Array; + setTangents(data: Float32Array | number[]): void; + getTangents(): Float32Array; + /** + * Serializes the current target into a Serialization object. + * Returns the serialized object. + */ + serialize(): any; + static Parse(serializationObject: any): MorphTarget; + static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget; + } +} + +declare module BABYLON { + class MorphTargetManager { + private _targets; + private _targetObservable; + private _activeTargets; + private _scene; + private _influences; + private _supportsNormals; + private _supportsTangents; + private _vertexCount; + private _uniqueId; + private _tempInfluences; + constructor(scene?: Scene); + readonly uniqueId: number; + readonly vertexCount: number; + readonly supportsNormals: boolean; + readonly supportsTangents: boolean; + readonly numTargets: number; + readonly numInfluencers: number; + readonly influences: Float32Array; + getActiveTarget(index: number): MorphTarget; + getTarget(index: number): MorphTarget; + addTarget(target: MorphTarget): void; + removeTarget(target: MorphTarget): void; + /** + * Serializes the current manager into a Serialization object. + * Returns the serialized object. + */ + serialize(): any; + private _onInfluenceChanged(needUpdate); + private _syncActiveTargets(needUpdate); + static Parse(serializationObject: any, scene: Scene): MorphTargetManager; + } +} + declare module BABYLON { interface PhysicsImpostorJoint { mainImpostor: PhysicsImpostor; @@ -12889,540 +12889,272 @@ declare module BABYLON { * Gets the body that holds this impostor. Either its own, or its parent. */ /** - * Set the physics body. Used mainly by the physics engine/plugin - */ - physicsBody: any; - parent: PhysicsImpostor; - resetUpdateFlags(): void; - getObjectExtendSize(): Vector3; - getObjectCenter(): Vector3; - /** - * Get a specific parametes from the options parameter. - */ - getParam(paramName: string): any; - /** - * Sets a specific parameter in the options given to the physics plugin - */ - setParam(paramName: string, value: number): void; - /** - * Specifically change the body's mass option. Won't recreate the physics body object - */ - setMass(mass: number): void; - getLinearVelocity(): Vector3; - setLinearVelocity(velocity: Vector3): void; - getAngularVelocity(): Vector3; - setAngularVelocity(velocity: Vector3): void; - /** - * Execute a function with the physics plugin native code. - * Provide a function the will have two variables - the world object and the physics body object. - */ - executeNativeFunction(func: (world: any, physicsBody: any) => void): void; - /** - * Register a function that will be executed before the physics world is stepping forward. - */ - registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void; - unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void; - /** - * Register a function that will be executed after the physics step - */ - registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void; - unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void; - /** - * register a function that will be executed when this impostor collides against a different body. - */ - registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void; - unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array) => void): void; - private _tmpPositionWithDelta; - private _tmpRotationWithDelta; - /** - * this function is executed by the physics engine. - */ - beforeStep: () => void; - /** - * this function is executed by the physics engine. - */ - afterStep: () => void; - /** - * Legacy collision detection event support - */ - onCollideEvent: (collider: BABYLON.PhysicsImpostor, collidedWith: BABYLON.PhysicsImpostor) => void; - onCollide: (e: { - body: any; - }) => void; - /** - * Apply a force - */ - applyForce(force: Vector3, contactPoint: Vector3): void; - /** - * Apply an impulse - */ - applyImpulse(force: Vector3, contactPoint: Vector3): void; - /** - * A help function to create a joint. - */ - createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): void; - /** - * Add a joint to this impostor with a different impostor. - */ - addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): void; - /** - * Will keep this body still, in a sleep mode. - */ - sleep(): void; - /** - * Wake the body up. - */ - wakeUp(): void; - clone(newObject: IPhysicsEnabledObject): PhysicsImpostor; - dispose(): void; - setDeltaPosition(position: Vector3): void; - setDeltaRotation(rotation: Quaternion): void; - getBoxSizeToRef(result: Vector3): void; - getRadius(): number; - /** - * Sync a bone with this impostor - * @param bone The bone to sync to the impostor. - * @param boneMesh The mesh that the bone is influencing. - * @param jointPivot The pivot of the joint / bone in local space. - * @param distToJoint Optional distance from the impostor to the joint. - * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone. - */ - syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void; - /** - * Sync impostor to a bone - * @param bone The bone that the impostor will be synced to. - * @param boneMesh The mesh that the bone is influencing. - * @param jointPivot The pivot of the joint / bone in local space. - * @param distToJoint Optional distance from the impostor to the joint. - * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone. - * @param boneAxis Optional vector3 axis the bone is aligned with - */ - syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void; - static NoImpostor: number; - static SphereImpostor: number; - static BoxImpostor: number; - static PlaneImpostor: number; - static MeshImpostor: number; - static CylinderImpostor: number; - static ParticleImpostor: number; - static HeightmapImpostor: number; - } -} - -declare module BABYLON { - interface PhysicsJointData { - mainPivot?: Vector3; - connectedPivot?: Vector3; - mainAxis?: Vector3; - connectedAxis?: Vector3; - collision?: boolean; - nativeParams?: any; - } - /** - * This is a holder class for the physics joint created by the physics plugin. - * It holds a set of functions to control the underlying joint. - */ - class PhysicsJoint { - type: number; - jointData: PhysicsJointData; - private _physicsJoint; - protected _physicsPlugin: IPhysicsEnginePlugin; - constructor(type: number, jointData: PhysicsJointData); - physicsJoint: any; - physicsPlugin: IPhysicsEnginePlugin; - /** - * Execute a function that is physics-plugin specific. - * @param {Function} func the function that will be executed. - * It accepts two parameters: the physics world and the physics joint. - */ - executeNativeFunction(func: (world: any, physicsJoint: any) => void): void; - static DistanceJoint: number; - static HingeJoint: number; - static BallAndSocketJoint: number; - static WheelJoint: number; - static SliderJoint: number; - static PrismaticJoint: number; - static UniversalJoint: number; - static Hinge2Joint: number; - static PointToPointJoint: number; - static SpringJoint: number; - static LockJoint: number; - } - /** - * A class representing a physics distance joint. - */ - class DistanceJoint extends PhysicsJoint { - constructor(jointData: DistanceJointData); - /** - * Update the predefined distance. + * Set the physics body. Used mainly by the physics engine/plugin */ - updateDistance(maxDistance: number, minDistance?: number): void; - } - class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint { - constructor(type: number, jointData: PhysicsJointData); + physicsBody: any; + parent: PhysicsImpostor; + resetUpdateFlags(): void; + getObjectExtendSize(): Vector3; + getObjectCenter(): Vector3; /** - * Set the motor values. - * Attention, this function is plugin specific. Engines won't react 100% the same. - * @param {number} force the force to apply - * @param {number} maxForce max force for this motor. + * Get a specific parametes from the options parameter. */ - setMotor(force?: number, maxForce?: number): void; + getParam(paramName: string): any; /** - * Set the motor's limits. - * Attention, this function is plugin specific. Engines won't react 100% the same. + * Sets a specific parameter in the options given to the physics plugin */ - setLimit(upperLimit: number, lowerLimit?: number): void; - } - /** - * This class represents a single hinge physics joint - */ - class HingeJoint extends MotorEnabledJoint { - constructor(jointData: PhysicsJointData); + setParam(paramName: string, value: number): void; /** - * Set the motor values. - * Attention, this function is plugin specific. Engines won't react 100% the same. - * @param {number} force the force to apply - * @param {number} maxForce max force for this motor. + * Specifically change the body's mass option. Won't recreate the physics body object */ - setMotor(force?: number, maxForce?: number): void; + setMass(mass: number): void; + getLinearVelocity(): Vector3; + setLinearVelocity(velocity: Vector3): void; + getAngularVelocity(): Vector3; + setAngularVelocity(velocity: Vector3): void; /** - * Set the motor's limits. - * Attention, this function is plugin specific. Engines won't react 100% the same. + * Execute a function with the physics plugin native code. + * Provide a function the will have two variables - the world object and the physics body object. */ - setLimit(upperLimit: number, lowerLimit?: number): void; - } - /** - * This class represents a dual hinge physics joint (same as wheel joint) - */ - class Hinge2Joint extends MotorEnabledJoint { - constructor(jointData: PhysicsJointData); + executeNativeFunction(func: (world: any, physicsBody: any) => void): void; /** - * Set the motor values. - * Attention, this function is plugin specific. Engines won't react 100% the same. - * @param {number} force the force to apply - * @param {number} maxForce max force for this motor. - * @param {motorIndex} the motor's index, 0 or 1. + * Register a function that will be executed before the physics world is stepping forward. */ - setMotor(force?: number, maxForce?: number, motorIndex?: number): void; + registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void; + unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void; /** - * Set the motor limits. - * Attention, this function is plugin specific. Engines won't react 100% the same. - * @param {number} upperLimit the upper limit - * @param {number} lowerLimit lower limit - * @param {motorIndex} the motor's index, 0 or 1. + * Register a function that will be executed after the physics step */ - setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void; - } - interface IMotorEnabledJoint { - physicsJoint: any; - setMotor(force?: number, maxForce?: number, motorIndex?: number): any; - setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): any; - } - interface DistanceJointData extends PhysicsJointData { - maxDistance: number; - } - interface SpringJointData extends PhysicsJointData { - length: number; - stiffness: number; - damping: number; - } -} - -declare module BABYLON { - class ReflectionProbe { - name: string; - private _scene; - private _renderTargetTexture; - private _projectionMatrix; - private _viewMatrix; - private _target; - private _add; - private _attachedMesh; - invertYAxis: boolean; - position: Vector3; - constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean); - samples: number; - refreshRate: number; - getScene(): Scene; - readonly cubeTexture: RenderTargetTexture; - readonly renderList: AbstractMesh[]; - attachToMesh(mesh: AbstractMesh): void; + registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void; + unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): 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. + * register a function that will be executed when this impostor collides against a different body. */ - setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void; - dispose(): void; - } -} - -declare module BABYLON { - class BoundingBoxRenderer { - frontColor: Color3; - backColor: Color3; - showBackLines: boolean; - renderList: SmartArray; - private _scene; - private _colorShader; - private _vertexBuffers; - private _indexBuffer; - constructor(scene: Scene); - private _prepareRessources(); - reset(): void; - render(): void; - dispose(): void; - } -} - -declare module BABYLON { - class DepthRenderer { - private _scene; - private _depthMap; - private _effect; - private _viewMatrix; - private _projectionMatrix; - private _transformMatrix; - private _worldViewProjection; - private _cachedDefines; - constructor(scene: Scene, type?: number); - isReady(subMesh: SubMesh, useInstances: boolean): boolean; - getDepthMap(): RenderTargetTexture; - dispose(): void; - } -} - -declare module BABYLON { - class EdgesRenderer { - edgesWidthScalerForOrthographic: number; - edgesWidthScalerForPerspective: number; - private _source; - private _linesPositions; - private _linesNormals; - private _linesIndices; - private _epsilon; - private _indicesCount; - private _lineShader; - private _ib; - private _buffers; - private _checkVerticesInsteadOfIndices; - constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean); - private _prepareRessources(); - dispose(): void; - private _processEdgeForAdjacencies(pa, pb, p0, p1, p2); - private _processEdgeForAdjacenciesWithVertices(pa, pb, p0, p1, p2); - private _checkEdge(faceIndex, edge, faceNormals, p0, p1); - _generateEdgesLines(): void; - render(): void; - } -} - -declare module BABYLON { - class GeometryBufferRenderer { - private _scene; - private _multiRenderTarget; - private _effect; - private _ratio; - private _viewMatrix; - private _projectionMatrix; - private _transformMatrix; - private _worldViewProjection; - private _cachedDefines; - private _enablePosition; - renderList: Mesh[]; - readonly isSupported: boolean; - enablePosition: boolean; - constructor(scene: Scene, ratio?: number); - isReady(subMesh: SubMesh, useInstances: boolean): boolean; - getGBuffer(): MultiRenderTarget; - dispose(): void; - private _createRenderTargets(); - } -} - -declare module BABYLON { - class OutlineRenderer { - private _scene; - private _effect; - private _cachedDefines; - zOffset: number; - constructor(scene: Scene); - render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void; - isReady(subMesh: SubMesh, useInstances: boolean): boolean; - } -} - -declare module BABYLON { - class RenderingGroup { - index: number; - private _scene; - private _opaqueSubMeshes; - private _transparentSubMeshes; - private _alphaTestSubMeshes; - private _particleSystems; - private _spriteManagers; - private _activeVertices; - private _opaqueSortCompareFn; - private _alphaTestSortCompareFn; - private _transparentSortCompareFn; - private _renderOpaque; - private _renderAlphaTest; - private _renderTransparent; - private _edgesRenderers; - onBeforeTransparentRendering: () => void; + registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void; + unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array) => void): void; + private _tmpPositionWithDelta; + private _tmpRotationWithDelta; /** - * Set the opaque sort comparison function. - * If null the sub meshes will be render in the order they were created + * this function is executed by the physics engine. */ - opaqueSortCompareFn: (a: SubMesh, b: SubMesh) => number; + beforeStep: () => void; /** - * Set the alpha test sort comparison function. - * If null the sub meshes will be render in the order they were created + * this function is executed by the physics engine. */ - alphaTestSortCompareFn: (a: SubMesh, b: SubMesh) => number; + afterStep: () => void; /** - * Set the transparent sort comparison function. - * If null the sub meshes will be render in the order they were created + * Legacy collision detection event support */ - transparentSortCompareFn: (a: SubMesh, b: SubMesh) => number; + onCollideEvent: (collider: BABYLON.PhysicsImpostor, collidedWith: BABYLON.PhysicsImpostor) => void; + onCollide: (e: { + body: any; + }) => void; /** - * Creates a new rendering group. - * @param index The rendering group index - * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied - * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied - * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied + * Apply a force */ - constructor(index: number, scene: Scene, opaqueSortCompareFn?: (a: SubMesh, b: SubMesh) => number, alphaTestSortCompareFn?: (a: SubMesh, b: SubMesh) => number, transparentSortCompareFn?: (a: SubMesh, b: SubMesh) => number); + applyForce(force: Vector3, contactPoint: Vector3): void; /** - * Render all the sub meshes contained in the group. - * @param customRenderFunction Used to override the default render behaviour of the group. - * @returns true if rendered some submeshes. + * Apply an impulse */ - render(customRenderFunction: (opaqueSubMeshes: SmartArray, transparentSubMeshes: SmartArray, alphaTestSubMeshes: SmartArray) => void, renderSprites: boolean, renderParticles: boolean, activeMeshes: AbstractMesh[]): void; + applyImpulse(force: Vector3, contactPoint: Vector3): void; /** - * Renders the opaque submeshes in the order from the opaqueSortCompareFn. - * @param subMeshes The submeshes to render + * A help function to create a joint. */ - private renderOpaqueSorted(subMeshes); + createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): void; /** - * Renders the opaque submeshes in the order from the alphatestSortCompareFn. - * @param subMeshes The submeshes to render + * Add a joint to this impostor with a different impostor. */ - private renderAlphaTestSorted(subMeshes); + addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): void; /** - * Renders the opaque submeshes in the order from the transparentSortCompareFn. - * @param subMeshes The submeshes to render + * Will keep this body still, in a sleep mode. */ - private renderTransparentSorted(subMeshes); + sleep(): void; /** - * Renders the submeshes in a specified order. - * @param subMeshes The submeshes to sort before render - * @param sortCompareFn The comparison function use to sort - * @param cameraPosition The camera position use to preprocess the submeshes to help sorting - * @param transparent Specifies to activate blending if true + * Wake the body up. */ - private static renderSorted(subMeshes, sortCompareFn, cameraPosition, transparent); + wakeUp(): void; + clone(newObject: IPhysicsEnabledObject): PhysicsImpostor; + dispose(): void; + setDeltaPosition(position: Vector3): void; + setDeltaRotation(rotation: Quaternion): void; + getBoxSizeToRef(result: Vector3): void; + getRadius(): number; /** - * Renders the submeshes in the order they were dispatched (no sort applied). - * @param subMeshes The submeshes to render + * Sync a bone with this impostor + * @param bone The bone to sync to the impostor. + * @param boneMesh The mesh that the bone is influencing. + * @param jointPivot The pivot of the joint / bone in local space. + * @param distToJoint Optional distance from the impostor to the joint. + * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone. */ - private static renderUnsorted(subMeshes); + syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void; /** - * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent) - * are rendered back to front if in the same alpha index. - * - * @param a The first submesh - * @param b The second submesh - * @returns The result of the comparison + * Sync impostor to a bone + * @param bone The bone that the impostor will be synced to. + * @param boneMesh The mesh that the bone is influencing. + * @param jointPivot The pivot of the joint / bone in local space. + * @param distToJoint Optional distance from the impostor to the joint. + * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone. + * @param boneAxis Optional vector3 axis the bone is aligned with */ - static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number; + syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void; + static NoImpostor: number; + static SphereImpostor: number; + static BoxImpostor: number; + static PlaneImpostor: number; + static MeshImpostor: number; + static CylinderImpostor: number; + static ParticleImpostor: number; + static HeightmapImpostor: number; + } +} + +declare module BABYLON { + interface PhysicsJointData { + mainPivot?: Vector3; + connectedPivot?: Vector3; + mainAxis?: Vector3; + connectedAxis?: Vector3; + collision?: boolean; + nativeParams?: any; + } + /** + * This is a holder class for the physics joint created by the physics plugin. + * It holds a set of functions to control the underlying joint. + */ + class PhysicsJoint { + type: number; + jointData: PhysicsJointData; + private _physicsJoint; + protected _physicsPlugin: IPhysicsEnginePlugin; + constructor(type: number, jointData: PhysicsJointData); + physicsJoint: any; + physicsPlugin: IPhysicsEnginePlugin; /** - * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent) - * are rendered back to front. - * - * @param a The first submesh - * @param b The second submesh - * @returns The result of the comparison + * Execute a function that is physics-plugin specific. + * @param {Function} func the function that will be executed. + * It accepts two parameters: the physics world and the physics joint. */ - static backToFrontSortCompare(a: SubMesh, b: SubMesh): number; + executeNativeFunction(func: (world: any, physicsJoint: any) => void): void; + static DistanceJoint: number; + static HingeJoint: number; + static BallAndSocketJoint: number; + static WheelJoint: number; + static SliderJoint: number; + static PrismaticJoint: number; + static UniversalJoint: number; + static Hinge2Joint: number; + static PointToPointJoint: number; + static SpringJoint: number; + static LockJoint: number; + } + /** + * A class representing a physics distance joint. + */ + class DistanceJoint extends PhysicsJoint { + constructor(jointData: DistanceJointData); /** - * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent) - * are rendered front to back (prevent overdraw). - * - * @param a The first submesh - * @param b The second submesh - * @returns The result of the comparison + * Update the predefined distance. */ - static frontToBackSortCompare(a: SubMesh, b: SubMesh): number; + updateDistance(maxDistance: number, minDistance?: number): void; + } + class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint { + constructor(type: number, jointData: PhysicsJointData); /** - * Resets the different lists of submeshes to prepare a new frame. + * Set the motor values. + * Attention, this function is plugin specific. Engines won't react 100% the same. + * @param {number} force the force to apply + * @param {number} maxForce max force for this motor. */ - prepare(): void; - dispose(): void; + setMotor(force?: number, maxForce?: number): void; /** - * Inserts the submesh in its correct queue depending on its material. - * @param subMesh The submesh to dispatch + * Set the motor's limits. + * Attention, this function is plugin specific. Engines won't react 100% the same. */ - dispatch(subMesh: SubMesh): void; - dispatchSprites(spriteManager: SpriteManager): void; - dispatchParticles(particleSystem: IParticleSystem): void; - private _renderParticles(activeMeshes); - private _renderSprites(); + setLimit(upperLimit: number, lowerLimit?: number): void; } -} - -declare module BABYLON { - class RenderingManager { + /** + * This class represents a single hinge physics joint + */ + class HingeJoint extends MotorEnabledJoint { + constructor(jointData: PhysicsJointData); /** - * The max id used for rendering groups (not included) + * Set the motor values. + * Attention, this function is plugin specific. Engines won't react 100% the same. + * @param {number} force the force to apply + * @param {number} maxForce max force for this motor. */ - static MAX_RENDERINGGROUPS: number; + setMotor(force?: number, maxForce?: number): void; /** - * The min id used for rendering groups (included) + * Set the motor's limits. + * Attention, this function is plugin specific. Engines won't react 100% the same. */ - static MIN_RENDERINGGROUPS: number; + setLimit(upperLimit: number, lowerLimit?: number): void; + } + /** + * This class represents a dual hinge physics joint (same as wheel joint) + */ + class Hinge2Joint extends MotorEnabledJoint { + constructor(jointData: PhysicsJointData); /** - * Used to globally prevent autoclearing scenes. + * Set the motor values. + * Attention, this function is plugin specific. Engines won't react 100% the same. + * @param {number} force the force to apply + * @param {number} maxForce max force for this motor. + * @param {motorIndex} the motor's index, 0 or 1. */ - static AUTOCLEAR: boolean; - private _scene; - private _renderingGroups; - private _depthStencilBufferAlreadyCleaned; - private _currentIndex; - private _autoClearDepthStencil; - private _customOpaqueSortCompareFn; - private _customAlphaTestSortCompareFn; - private _customTransparentSortCompareFn; - private _renderinGroupInfo; - constructor(scene: Scene); - private _clearDepthStencilBuffer(depth?, stencil?); - render(customRenderFunction: (opaqueSubMeshes: SmartArray, transparentSubMeshes: SmartArray, alphaTestSubMeshes: SmartArray) => void, activeMeshes: AbstractMesh[], renderParticles: boolean, renderSprites: boolean): void; - reset(): void; - dispose(): void; - private _prepareRenderingGroup(renderingGroupId); - dispatchSprites(spriteManager: SpriteManager): void; - dispatchParticles(particleSystem: IParticleSystem): void; - dispatch(subMesh: SubMesh): void; + setMotor(force?: number, maxForce?: number, motorIndex?: number): void; /** - * 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. + * Set the motor limits. + * Attention, this function is plugin specific. Engines won't react 100% the same. + * @param {number} upperLimit the upper limit + * @param {number} lowerLimit lower limit + * @param {motorIndex} the motor's index, 0 or 1. */ - setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: (a: SubMesh, b: SubMesh) => number, alphaTestSortCompareFn?: (a: SubMesh, b: SubMesh) => number, transparentSortCompareFn?: (a: SubMesh, b: SubMesh) => number): void; + setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void; + } + interface IMotorEnabledJoint { + physicsJoint: any; + setMotor(force?: number, maxForce?: number, motorIndex?: number): any; + setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): any; + } + interface DistanceJointData extends PhysicsJointData { + maxDistance: number; + } + interface SpringJointData extends PhysicsJointData { + length: number; + stiffness: number; + damping: number; + } +} + +declare module BABYLON { + class ReflectionProbe { + name: string; + private _scene; + private _renderTargetTexture; + private _projectionMatrix; + private _viewMatrix; + private _target; + private _add; + private _attachedMesh; + invertYAxis: boolean; + position: Vector3; + constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean); + samples: number; + refreshRate: number; + getScene(): Scene; + readonly cubeTexture: RenderTargetTexture; + readonly renderList: AbstractMesh[]; + attachToMesh(mesh: AbstractMesh): 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; + setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void; + dispose(): void; } } @@ -13671,3104 +13403,2740 @@ declare module BABYLON { * Gets wether the input of the processing is in Gamma or Linear Space. */ /** - * Sets wether the input of the processing is in Gamma or Linear Space. - */ - fromLinearSpace: boolean; - /** - * Defines cache preventing GC. - */ - private _defines; - constructor(name: string, options: number | PostProcessOptions, camera?: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number); - getClassName(): string; - protected _updateParameters(): void; - dispose(camera?: Camera): void; - } -} - -declare module BABYLON { - class PassPostProcess extends PostProcess { - constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number); - } -} - -declare module BABYLON { - type PostProcessOptions = { - width: number; - height: number; - }; - class PostProcess { - name: string; - width: number; - height: number; - renderTargetSamplingMode: number; - clearColor: Color4; - autoClear: boolean; - alphaMode: number; - alphaConstants: Color4; - enablePixelPerfectMode: boolean; - scaleMode: number; - alwaysForcePOT: boolean; - samples: number; - private _camera; - private _scene; - private _engine; - private _options; - private _reusable; - private _textureType; - _textures: SmartArray; - _currentRenderTextureInd: number; - private _effect; - private _samplers; - private _fragmentUrl; - private _vertexUrl; - private _parameters; - private _scaleRatio; - protected _indexParameters: any; - private _shareOutputWithPostProcess; - private _texelSize; - private _forcedOutputTexture; - /** - * An event triggered when the postprocess is activated. - * @type {BABYLON.Observable} - */ - onActivateObservable: Observable; - private _onActivateObserver; - onActivate: (camera: Camera) => void; - /** - * An event triggered when the postprocess changes its size. - * @type {BABYLON.Observable} - */ - onSizeChangedObservable: Observable; - private _onSizeChangedObserver; - onSizeChanged: (postProcess: PostProcess) => void; - /** - * An event triggered when the postprocess applies its effect. - * @type {BABYLON.Observable} - */ - onApplyObservable: Observable; - private _onApplyObserver; - onApply: (effect: Effect) => void; - /** - * An event triggered before rendering the postprocess - * @type {BABYLON.Observable} - */ - onBeforeRenderObservable: Observable; - private _onBeforeRenderObserver; - onBeforeRender: (effect: Effect) => void; - /** - * An event triggered after rendering the postprocess - * @type {BABYLON.Observable} - */ - onAfterRenderObservable: Observable; - private _onAfterRenderObserver; - onAfterRender: (efect: Effect) => void; - outputTexture: WebGLTexture; - getCamera(): Camera; - readonly texelSize: Vector2; - constructor(name: string, fragmentUrl: string, parameters: string[], samplers: string[], options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: string, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean); - getEngine(): Engine; - getEffect(): Effect; - shareOutputWith(postProcess: PostProcess): PostProcess; - updateEffect(defines?: string, uniforms?: string[], samplers?: string[], indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void; - isReusable(): boolean; - /** invalidate frameBuffer to hint the postprocess to create a depth buffer */ - markTextureDirty(): void; - activate(camera: Camera, sourceTexture?: WebGLTexture, forceDepthStencil?: boolean): void; - readonly isSupported: boolean; - readonly aspectRatio: number; - apply(): Effect; - private _disposeTextures(); - dispose(camera?: Camera): void; - } -} - -declare module BABYLON { - class PostProcessManager { - private _scene; - private _indexBuffer; - private _vertexBuffers; - constructor(scene: Scene); - private _prepareBuffers(); - _prepareFrame(sourceTexture?: WebGLTexture, postProcesses?: PostProcess[]): boolean; - directRender(postProcesses: PostProcess[], targetTexture?: WebGLTexture): void; - _finalizeFrame(doNotPresent?: boolean, targetTexture?: WebGLTexture, faceIndex?: number, postProcesses?: PostProcess[]): void; - dispose(): void; - } -} - -declare module BABYLON { - class RefractionPostProcess extends PostProcess { - color: Color3; - depth: number; - colorLevel: number; - private _refRexture; - constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean); - dispose(camera: Camera): void; - } -} - -declare module BABYLON { - class StereoscopicInterlacePostProcess extends PostProcess { - private _stepSize; - private _passedProcess; - constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean); - } -} - -declare module BABYLON { - enum TonemappingOperator { - Hable = 0, - Reinhard = 1, - HejiDawson = 2, - Photographic = 3, - } - class TonemapPostProcess extends PostProcess { - private _operator; - exposureAdjustment: number; - constructor(name: string, _operator: TonemappingOperator, exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number); - } -} - -declare module BABYLON { - class VolumetricLightScatteringPostProcess extends PostProcess { - private _volumetricLightScatteringPass; - private _volumetricLightScatteringRTT; - private _viewPort; - private _screenCoordinates; - private _cachedDefines; - /** - * If not undefined, the mesh position is computed from the attached node position - * @type {{position: Vector3}} - */ - attachedNode: { - position: Vector3; - }; - /** - * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true" - * @type {Vector3} - */ - customMeshPosition: Vector3; - /** - * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false) - * @type {boolean} - */ - useCustomMeshPosition: boolean; - /** - * If the post-process should inverse the light scattering direction - * @type {boolean} - */ - invert: boolean; - /** - * The internal mesh used by the post-process - * @type {boolean} - */ - mesh: Mesh; - useDiffuseColor: boolean; - /** - * Array containing the excluded meshes not rendered in the internal pass - */ - excludedMeshes: AbstractMesh[]; - /** - * Controls the overall intensity of the post-process - * @type {number} - */ - exposure: number; - /** - * Dissipates each sample's contribution in range [0, 1] - * @type {number} - */ - decay: number; - /** - * Controls the overall intensity of each sample - * @type {number} - */ - weight: number; - /** - * Controls the density of each sample - * @type {number} - */ - density: number; - /** - * @constructor - * @param {string} name - The post-process name - * @param {any} ratio - The size of the post-process and/or internal pass (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5) - * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to - * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering - * @param {number} samples - The post-process quality, default 100 - * @param {number} samplingMode - The post-process filtering mode - * @param {BABYLON.Engine} engine - The babylon engine - * @param {boolean} reusable - If the post-process is reusable - * @param {BABYLON.Scene} scene - The constructor needs a scene reference to initialize internal components. If "camera" is null (RenderPipelineà, "scene" must be provided - */ - constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene); - getClassName(): string; - isReady(subMesh: SubMesh, useInstances: boolean): boolean; - /** - * Sets the new light position for light scattering effect - * @param {BABYLON.Vector3} The new custom light position - */ - setCustomMeshPosition(position: Vector3): void; - /** - * Returns the light position for light scattering effect - * @return {BABYLON.Vector3} The custom light position - */ - getCustomMeshPosition(): Vector3; - /** - * Disposes the internal assets and detaches the post-process from the camera - */ - dispose(camera: Camera): void; - /** - * Returns the render target texture used by the post-process - * @return {BABYLON.RenderTargetTexture} The render target texture used by the post-process - */ - getPass(): RenderTargetTexture; - private _meshExcluded(mesh); - private _createPass(scene, ratio); - private _updateMeshScreenCoordinates(scene); + * Sets wether the input of the processing is in Gamma or Linear Space. + */ + fromLinearSpace: boolean; /** - * Creates a default mesh for the Volumeric Light Scattering post-process - * @param {string} The mesh name - * @param {BABYLON.Scene} The scene where to create the mesh - * @return {BABYLON.Mesh} the default mesh - */ - static CreateDefaultMesh(name: string, scene: Scene): Mesh; + * Defines cache preventing GC. + */ + private _defines; + constructor(name: string, options: number | PostProcessOptions, camera?: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number); + getClassName(): string; + protected _updateParameters(): void; + dispose(camera?: Camera): void; } } declare module BABYLON { - class VRDistortionCorrectionPostProcess extends PostProcess { - aspectRatio: number; - private _isRightEye; - private _distortionFactors; - private _postProcessScaleFactor; - private _lensCenterOffset; - private _scaleIn; - private _scaleFactor; - private _lensCenter; - constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics); + class PassPostProcess extends PostProcess { + constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number); } } declare module BABYLON { - class Sprite { - name: string; - position: Vector3; - color: Color4; + type PostProcessOptions = { width: number; height: number; - angle: number; - cellIndex: number; - invertU: number; - invertV: number; - disposeWhenFinishedAnimating: boolean; - animations: Animation[]; - isPickable: boolean; - actionManager: ActionManager; - private _animationStarted; - private _loopAnimation; - private _fromIndex; - private _toIndex; - private _delay; - private _direction; - private _frameCount; - private _manager; - private _time; - private _onAnimationEnd; - size: number; - constructor(name: string, manager: SpriteManager); - playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void; - stopAnimation(): void; - _animate(deltaTime: number): void; - dispose(): void; - } -} - -declare module BABYLON { - class SpriteManager { + }; + class PostProcess { name: string; - sprites: Sprite[]; - renderingGroupId: number; - layerMask: number; - fogEnabled: boolean; - isPickable: boolean; - cellWidth: number; - cellHeight: number; + width: number; + height: number; + renderTargetSamplingMode: number; + clearColor: Color4; + autoClear: boolean; + alphaMode: number; + alphaConstants: Color4; + enablePixelPerfectMode: boolean; + scaleMode: number; + alwaysForcePOT: boolean; + samples: number; + private _camera; + private _scene; + private _engine; + private _options; + private _reusable; + private _textureType; + _textures: SmartArray; + _currentRenderTextureInd: number; + private _effect; + private _samplers; + private _fragmentUrl; + private _vertexUrl; + private _parameters; + private _scaleRatio; + protected _indexParameters: any; + private _shareOutputWithPostProcess; + private _texelSize; + private _forcedOutputTexture; /** - * An event triggered when the manager is disposed. + * An event triggered when the postprocess is activated. * @type {BABYLON.Observable} */ - onDisposeObservable: Observable; - private _onDisposeObserver; - onDispose: () => void; - private _capacity; - private _spriteTexture; - private _epsilon; - private _scene; - private _vertexData; - private _buffer; - private _vertexBuffers; - private _indexBuffer; - private _effectBase; - private _effectFog; - texture: Texture; - constructor(name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number); - private _appendSpriteVertex(index, sprite, offsetX, offsetY, rowSize); - intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): PickingInfo; - render(): void; - dispose(): void; - } -} - -declare module BABYLON.Internals { - class _AlphaState { - private _isAlphaBlendDirty; - private _isBlendFunctionParametersDirty; - private _isBlendEquationParametersDirty; - private _isBlendConstantsDirty; - private _alphaBlend; - private _blendFunctionParameters; - private _blendEquationParameters; - private _blendConstants; + onActivateObservable: Observable; + private _onActivateObserver; + onActivate: (camera: Camera) => void; /** - * Initializes the state. - */ - constructor(); - readonly isDirty: boolean; - alphaBlend: boolean; - setAlphaBlendConstants(r: number, g: number, b: number, a: number): void; - setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void; - setAlphaEquationParameters(rgb: number, alpha: any): void; - reset(): void; - apply(gl: WebGLRenderingContext): void; - } -} - -declare module BABYLON.Internals { - class _DepthCullingState { - private _isDepthTestDirty; - private _isDepthMaskDirty; - private _isDepthFuncDirty; - private _isCullFaceDirty; - private _isCullDirty; - private _isZOffsetDirty; - private _depthTest; - private _depthMask; - private _depthFunc; - private _cull; - private _cullFace; - private _zOffset; + * An event triggered when the postprocess changes its size. + * @type {BABYLON.Observable} + */ + onSizeChangedObservable: Observable; + private _onSizeChangedObserver; + onSizeChanged: (postProcess: PostProcess) => void; /** - * Initializes the state. - */ - constructor(); - readonly isDirty: boolean; - zOffset: number; - cullFace: number; - cull: boolean; - depthFunc: number; - depthMask: boolean; - depthTest: boolean; - reset(): void; - apply(gl: WebGLRenderingContext): void; + * An event triggered when the postprocess applies its effect. + * @type {BABYLON.Observable} + */ + onApplyObservable: Observable; + private _onApplyObserver; + onApply: (effect: Effect) => void; + /** + * An event triggered before rendering the postprocess + * @type {BABYLON.Observable} + */ + onBeforeRenderObservable: Observable; + private _onBeforeRenderObserver; + onBeforeRender: (effect: Effect) => void; + /** + * An event triggered after rendering the postprocess + * @type {BABYLON.Observable} + */ + onAfterRenderObservable: Observable; + private _onAfterRenderObserver; + onAfterRender: (efect: Effect) => void; + outputTexture: WebGLTexture; + getCamera(): Camera; + readonly texelSize: Vector2; + constructor(name: string, fragmentUrl: string, parameters: string[], samplers: string[], options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: string, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean); + getEngine(): Engine; + getEffect(): Effect; + shareOutputWith(postProcess: PostProcess): PostProcess; + updateEffect(defines?: string, uniforms?: string[], samplers?: string[], indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void; + isReusable(): boolean; + /** invalidate frameBuffer to hint the postprocess to create a depth buffer */ + markTextureDirty(): void; + activate(camera: Camera, sourceTexture?: WebGLTexture, forceDepthStencil?: boolean): void; + readonly isSupported: boolean; + readonly aspectRatio: number; + apply(): Effect; + private _disposeTextures(); + dispose(camera?: Camera): void; } } -declare module BABYLON.Internals { - class _StencilState { - private _isStencilTestDirty; - private _isStencilMaskDirty; - private _isStencilFuncDirty; - private _isStencilOpDirty; - private _stencilTest; - private _stencilMask; - private _stencilFunc; - private _stencilFuncRef; - private _stencilFuncMask; - private _stencilOpStencilFail; - private _stencilOpDepthFail; - private _stencilOpStencilDepthPass; - readonly isDirty: boolean; - stencilFunc: number; - stencilFuncRef: number; - stencilFuncMask: number; - stencilOpStencilFail: number; - stencilOpDepthFail: number; - stencilOpStencilDepthPass: number; - stencilMask: number; - stencilTest: boolean; - constructor(); - reset(): void; - apply(gl: WebGLRenderingContext): void; +declare module BABYLON { + class PostProcessManager { + private _scene; + private _indexBuffer; + private _vertexBuffers; + constructor(scene: Scene); + private _prepareBuffers(); + _prepareFrame(sourceTexture?: WebGLTexture, postProcesses?: PostProcess[]): boolean; + directRender(postProcesses: PostProcess[], targetTexture?: WebGLTexture): void; + _finalizeFrame(doNotPresent?: boolean, targetTexture?: WebGLTexture, faceIndex?: number, postProcesses?: PostProcess[]): void; + dispose(): void; } } -declare module BABYLON.Internals { - class AndOrNotEvaluator { - static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean; - private static _HandleParenthesisContent(parenthesisContent, evaluateCallback); - private static _SimplifyNegation(booleanString); +declare module BABYLON { + class RefractionPostProcess extends PostProcess { + color: Color3; + depth: number; + colorLevel: number; + private _refRexture; + constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean); + dispose(camera: Camera): void; } } declare module BABYLON { - interface IAssetTask { - onSuccess: (task: IAssetTask) => void; - onError: (task: IAssetTask) => void; - isCompleted: boolean; - run(scene: Scene, onSuccess: () => void, onError: () => void): any; - } - class MeshAssetTask implements IAssetTask { - name: string; - meshesNames: any; - rootUrl: string; - sceneFilename: string; - loadedMeshes: Array; - loadedParticleSystems: Array; - loadedSkeletons: Array; - onSuccess: (task: IAssetTask) => void; - onError: (task: IAssetTask) => void; - isCompleted: boolean; - constructor(name: string, meshesNames: any, rootUrl: string, sceneFilename: string); - run(scene: Scene, onSuccess: () => void, onError: () => void): void; - } - class TextFileAssetTask implements IAssetTask { - name: string; - url: string; - onSuccess: (task: IAssetTask) => void; - onError: (task: IAssetTask) => void; - isCompleted: boolean; - text: string; - constructor(name: string, url: string); - run(scene: Scene, onSuccess: () => void, onError: () => void): void; - } - class BinaryFileAssetTask implements IAssetTask { - name: string; - url: string; - onSuccess: (task: IAssetTask) => void; - onError: (task: IAssetTask) => void; - isCompleted: boolean; - data: ArrayBuffer; - constructor(name: string, url: string); - run(scene: Scene, onSuccess: () => void, onError: () => void): void; - } - class ImageAssetTask implements IAssetTask { - name: string; - url: string; - onSuccess: (task: IAssetTask) => void; - onError: (task: IAssetTask) => void; - isCompleted: boolean; - image: HTMLImageElement; - constructor(name: string, url: string); - run(scene: Scene, onSuccess: () => void, onError: () => void): void; + class StereoscopicInterlacePostProcess extends PostProcess { + private _stepSize; + private _passedProcess; + constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean); } - interface ITextureAssetTask extends IAssetTask { - onSuccess: (task: ITextureAssetTask) => void; - onError: (task: ITextureAssetTask) => void; - texture: Texture; +} + +declare module BABYLON { + enum TonemappingOperator { + Hable = 0, + Reinhard = 1, + HejiDawson = 2, + Photographic = 3, } - class TextureAssetTask implements ITextureAssetTask { - name: string; - url: string; - noMipmap: boolean; - invertY: boolean; - samplingMode: number; - onSuccess: (task: ITextureAssetTask) => void; - onError: (task: ITextureAssetTask) => void; - isCompleted: boolean; - texture: Texture; - constructor(name: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number); - run(scene: Scene, onSuccess: () => void, onError: () => void): void; + class TonemapPostProcess extends PostProcess { + private _operator; + exposureAdjustment: number; + constructor(name: string, _operator: TonemappingOperator, exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number); } - class CubeTextureAssetTask implements IAssetTask { - name: string; - url: string; - extensions: string[]; - noMipmap: boolean; - files: string[]; - onSuccess: (task: IAssetTask) => void; - onError: (task: IAssetTask) => void; - isCompleted: boolean; - texture: CubeTexture; - constructor(name: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]); - run(scene: Scene, onSuccess: () => void, onError: () => void): void; +} + +declare module BABYLON { + class VolumetricLightScatteringPostProcess extends PostProcess { + private _volumetricLightScatteringPass; + private _volumetricLightScatteringRTT; + private _viewPort; + private _screenCoordinates; + private _cachedDefines; + /** + * If not undefined, the mesh position is computed from the attached node position + * @type {{position: Vector3}} + */ + attachedNode: { + position: Vector3; + }; + /** + * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true" + * @type {Vector3} + */ + customMeshPosition: Vector3; + /** + * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false) + * @type {boolean} + */ + useCustomMeshPosition: boolean; + /** + * If the post-process should inverse the light scattering direction + * @type {boolean} + */ + invert: boolean; + /** + * The internal mesh used by the post-process + * @type {boolean} + */ + mesh: Mesh; + useDiffuseColor: boolean; + /** + * Array containing the excluded meshes not rendered in the internal pass + */ + excludedMeshes: AbstractMesh[]; + /** + * Controls the overall intensity of the post-process + * @type {number} + */ + exposure: number; + /** + * Dissipates each sample's contribution in range [0, 1] + * @type {number} + */ + decay: number; + /** + * Controls the overall intensity of each sample + * @type {number} + */ + weight: number; + /** + * Controls the density of each sample + * @type {number} + */ + density: number; + /** + * @constructor + * @param {string} name - The post-process name + * @param {any} ratio - The size of the post-process and/or internal pass (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5) + * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to + * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering + * @param {number} samples - The post-process quality, default 100 + * @param {number} samplingMode - The post-process filtering mode + * @param {BABYLON.Engine} engine - The babylon engine + * @param {boolean} reusable - If the post-process is reusable + * @param {BABYLON.Scene} scene - The constructor needs a scene reference to initialize internal components. If "camera" is null (RenderPipelineà, "scene" must be provided + */ + constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene); + getClassName(): string; + isReady(subMesh: SubMesh, useInstances: boolean): boolean; + /** + * Sets the new light position for light scattering effect + * @param {BABYLON.Vector3} The new custom light position + */ + setCustomMeshPosition(position: Vector3): void; + /** + * Returns the light position for light scattering effect + * @return {BABYLON.Vector3} The custom light position + */ + getCustomMeshPosition(): Vector3; + /** + * Disposes the internal assets and detaches the post-process from the camera + */ + dispose(camera: Camera): void; + /** + * Returns the render target texture used by the post-process + * @return {BABYLON.RenderTargetTexture} The render target texture used by the post-process + */ + getPass(): RenderTargetTexture; + private _meshExcluded(mesh); + private _createPass(scene, ratio); + private _updateMeshScreenCoordinates(scene); + /** + * Creates a default mesh for the Volumeric Light Scattering post-process + * @param {string} The mesh name + * @param {BABYLON.Scene} The scene where to create the mesh + * @return {BABYLON.Mesh} the default mesh + */ + static CreateDefaultMesh(name: string, scene: Scene): Mesh; } - class HDRCubeTextureAssetTask implements IAssetTask { - name: string; - url: string; - size: number; - noMipmap: boolean; - generateHarmonics: boolean; - useInGammaSpace: boolean; - usePMREMGenerator: boolean; - onSuccess: (task: IAssetTask) => void; - onError: (task: IAssetTask) => void; - isCompleted: boolean; - texture: HDRCubeTexture; - constructor(name: string, url: string, size?: number, noMipmap?: boolean, generateHarmonics?: boolean, useInGammaSpace?: boolean, usePMREMGenerator?: boolean); - run(scene: Scene, onSuccess: () => void, onError: () => void): void; +} + +declare module BABYLON { + class VRDistortionCorrectionPostProcess extends PostProcess { + aspectRatio: number; + private _isRightEye; + private _distortionFactors; + private _postProcessScaleFactor; + private _lensCenterOffset; + private _scaleIn; + private _scaleFactor; + private _lensCenter; + constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics); } - class AssetsManager { +} + +declare module BABYLON { + class BoundingBoxRenderer { + frontColor: Color3; + backColor: Color3; + showBackLines: boolean; + renderList: SmartArray; private _scene; - protected tasks: IAssetTask[]; - protected waitingTasksCount: number; - onFinish: (tasks: IAssetTask[]) => void; - onTaskSuccess: (task: IAssetTask) => void; - onTaskError: (task: IAssetTask) => void; - useDefaultLoadingScreen: boolean; + private _colorShader; + private _vertexBuffers; + private _indexBuffer; constructor(scene: Scene); - addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): IAssetTask; - addTextFileTask(taskName: string, url: string): IAssetTask; - addBinaryFileTask(taskName: string, url: string): IAssetTask; - addImageTask(taskName: string, url: string): IAssetTask; - addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): ITextureAssetTask; - addCubeTextureTask(name: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): IAssetTask; - addHDRCubeTextureTask(name: string, url: string, size?: number, noMipmap?: boolean, generateHarmonics?: boolean, useInGammaSpace?: boolean, usePMREMGenerator?: boolean): IAssetTask; - private _decreaseWaitingTasksCount(); - private _runTask(task); - reset(): AssetsManager; - load(): AssetsManager; + private _prepareRessources(); + reset(): void; + render(): void; + dispose(): void; } } declare module BABYLON { - class Database { - private callbackManifestChecked; - private currentSceneUrl; - private db; - private enableSceneOffline; - private enableTexturesOffline; - private manifestVersionFound; - private mustUpdateRessources; - private hasReachedQuota; - private isSupported; - private idbFactory; - static IsUASupportingBlobStorage: boolean; - static IDBStorageEnabled: boolean; - constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any); - static parseURL: (url: string) => string; - static ReturnFullUrlLocation: (url: string) => string; - checkManifestFile(): void; - openAsync(successCallback: any, errorCallback: any): void; - loadImageFromDB(url: string, image: HTMLImageElement): void; - private _loadImageFromDBAsync(url, image, notInDBCallback); - private _saveImageIntoDBAsync(url, image); - private _checkVersionFromDB(url, versionLoaded); - private _loadVersionFromDBAsync(url, callback, updateInDBCallback); - private _saveVersionIntoDBAsync(url, callback); - private loadFileFromDB(url, sceneLoaded, progressCallBack, errorCallback, useArrayBuffer?); - private _loadFileFromDBAsync(url, callback, notInDBCallback, useArrayBuffer?); - private _saveFileIntoDBAsync(url, callback, progressCallback, useArrayBuffer?); + class DepthRenderer { + private _scene; + private _depthMap; + private _effect; + private _viewMatrix; + private _projectionMatrix; + private _transformMatrix; + private _worldViewProjection; + private _cachedDefines; + constructor(scene: Scene, type?: number); + isReady(subMesh: SubMesh, useInstances: boolean): boolean; + getDepthMap(): RenderTargetTexture; + dispose(): void; } } -declare module BABYLON.Internals { - interface DDSInfo { - width: number; - height: number; - mipmapCount: number; - isFourCC: boolean; - isRGB: boolean; - isLuminance: boolean; - isCube: boolean; - isCompressed: boolean; - dxgiFormat: number; - textureType: number; - } - class DDSTools { - static StoreLODInAlphaChannel: boolean; - static GetDDSInfo(arrayBuffer: any): DDSInfo; - private static _FloatView; - private static _Int32View; - private static _ToHalfFloat(value); - private static _FromHalfFloat(value); - private static _GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod); - private static _GetHalfFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod); - private static _GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod); - private static _GetFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod); - private static _GetHalfFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod); - private static _GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer); - private static _GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer); - private static _GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer); - static UploadDDSLevels(engine: Engine, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number): void; +declare module BABYLON { + class EdgesRenderer { + edgesWidthScalerForOrthographic: number; + edgesWidthScalerForPerspective: number; + private _source; + private _linesPositions; + private _linesNormals; + private _linesIndices; + private _epsilon; + private _indicesCount; + private _lineShader; + private _ib; + private _buffers; + private _checkVerticesInsteadOfIndices; + constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean); + private _prepareRessources(); + dispose(): void; + private _processEdgeForAdjacencies(pa, pb, p0, p1, p2); + private _processEdgeForAdjacenciesWithVertices(pa, pb, p0, p1, p2); + private _checkEdge(faceIndex, edge, faceNormals, p0, p1); + _generateEdgesLines(): void; + render(): void; } } declare module BABYLON { - function expandToProperty(callback: string, targetKey?: string): (target: any, propertyKey: string) => void; - function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void; - function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void; - function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void; - function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void; - function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void; - function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void; - function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void; - function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void; - function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void; - function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void; - class SerializationHelper { - static Serialize(entity: T, serializationObject?: any): any; - static Parse(creationFunction: () => T, source: any, scene: Scene, rootUrl?: string): T; - static Clone(creationFunction: () => T, source: T): T; - static Instanciate(creationFunction: () => T, source: T): T; + class GeometryBufferRenderer { + private _scene; + private _multiRenderTarget; + private _effect; + private _ratio; + private _viewMatrix; + private _projectionMatrix; + private _transformMatrix; + private _worldViewProjection; + private _cachedDefines; + private _enablePosition; + renderList: Mesh[]; + readonly isSupported: boolean; + enablePosition: boolean; + constructor(scene: Scene, ratio?: number); + isReady(subMesh: SubMesh, useInstances: boolean): boolean; + getGBuffer(): MultiRenderTarget; + dispose(): void; + private _createRenderTargets(); } } declare module BABYLON { - class DynamicFloatArrayElementInfo { - offset: number; + class OutlineRenderer { + private _scene; + private _effect; + private _cachedDefines; + zOffset: number; + constructor(scene: Scene); + render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void; + isReady(subMesh: SubMesh, useInstances: boolean): boolean; } - /** - * The purpose of this class is to store float32 based elements of a given size (defined by the stride argument) in a dynamic fashion, that is, you can add/free elements. You can then access to a defragmented/packed version of the underlying Float32Array by calling the pack() method. - * The intent is to maintain through time data that will be bound to a WebGlBuffer with the ability to change add/remove elements. - * It was first built to efficiently maintain the WebGlBuffer that contain instancing based data. - * Allocating an Element will return a instance of DynamicFloatArrayElement which contains the offset into the Float32Array of where the element starts, you are then responsible to copy your data using this offset. - * Beware, calling pack() may change the offset of some Entries because this method will defragment the Float32Array to replace empty elements by moving allocated ones at their location. - * This method will return an ArrayBufferView on the existing Float32Array that describes the used elements. Use this View to update the WebGLBuffer and NOT the "buffer" field of the class. The pack() method won't shrink/reallocate the buffer to keep it GC friendly, all the empty space will be put at the end of the buffer, the method just ensure there are no "free holes". - */ - class DynamicFloatArray { +} + +declare module BABYLON { + class RenderingGroup { + index: number; + private _scene; + private _opaqueSubMeshes; + private _transparentSubMeshes; + private _alphaTestSubMeshes; + private _particleSystems; + private _spriteManagers; + private _activeVertices; + private _opaqueSortCompareFn; + private _alphaTestSortCompareFn; + private _transparentSortCompareFn; + private _renderOpaque; + private _renderAlphaTest; + private _renderTransparent; + private _edgesRenderers; + onBeforeTransparentRendering: () => void; /** - * Construct an instance of the dynamic float array - * @param stride size of one element in float (i.e. not bytes!) - * @param initialElementCount the number of available entries at construction + * Set the opaque sort comparison function. + * If null the sub meshes will be render in the order they were created */ - constructor(stride: number, initialElementCount: number); + opaqueSortCompareFn: (a: SubMesh, b: SubMesh) => number; /** - * Allocate an element in the array. - * @return the element info instance that contains the offset into the main buffer of the element's location. - * Beware, this offset may change when you call pack() + * Set the alpha test sort comparison function. + * If null the sub meshes will be render in the order they were created + */ + alphaTestSortCompareFn: (a: SubMesh, b: SubMesh) => number; + /** + * Set the transparent sort comparison function. + * If null the sub meshes will be render in the order they were created + */ + transparentSortCompareFn: (a: SubMesh, b: SubMesh) => number; + /** + * Creates a new rendering group. + * @param index The rendering group index + * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied + * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied + * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied + */ + constructor(index: number, scene: Scene, opaqueSortCompareFn?: (a: SubMesh, b: SubMesh) => number, alphaTestSortCompareFn?: (a: SubMesh, b: SubMesh) => number, transparentSortCompareFn?: (a: SubMesh, b: SubMesh) => number); + /** + * Render all the sub meshes contained in the group. + * @param customRenderFunction Used to override the default render behaviour of the group. + * @returns true if rendered some submeshes. + */ + render(customRenderFunction: (opaqueSubMeshes: SmartArray, transparentSubMeshes: SmartArray, alphaTestSubMeshes: SmartArray) => void, renderSprites: boolean, renderParticles: boolean, activeMeshes: AbstractMesh[]): void; + /** + * Renders the opaque submeshes in the order from the opaqueSortCompareFn. + * @param subMeshes The submeshes to render + */ + private renderOpaqueSorted(subMeshes); + /** + * Renders the opaque submeshes in the order from the alphatestSortCompareFn. + * @param subMeshes The submeshes to render + */ + private renderAlphaTestSorted(subMeshes); + /** + * Renders the opaque submeshes in the order from the transparentSortCompareFn. + * @param subMeshes The submeshes to render + */ + private renderTransparentSorted(subMeshes); + /** + * Renders the submeshes in a specified order. + * @param subMeshes The submeshes to sort before render + * @param sortCompareFn The comparison function use to sort + * @param cameraPosition The camera position use to preprocess the submeshes to help sorting + * @param transparent Specifies to activate blending if true + */ + private static renderSorted(subMeshes, sortCompareFn, cameraPosition, transparent); + /** + * Renders the submeshes in the order they were dispatched (no sort applied). + * @param subMeshes The submeshes to render + */ + private static renderUnsorted(subMeshes); + /** + * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent) + * are rendered back to front if in the same alpha index. + * + * @param a The first submesh + * @param b The second submesh + * @returns The result of the comparison + */ + static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number; + /** + * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent) + * are rendered back to front. + * + * @param a The first submesh + * @param b The second submesh + * @returns The result of the comparison */ - allocElement(): DynamicFloatArrayElementInfo; + static backToFrontSortCompare(a: SubMesh, b: SubMesh): number; /** - * Free the element corresponding to the given element info - * @param elInfo the element that describe the allocated element + * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent) + * are rendered front to back (prevent overdraw). + * + * @param a The first submesh + * @param b The second submesh + * @returns The result of the comparison */ - freeElement(elInfo: DynamicFloatArrayElementInfo): void; + static frontToBackSortCompare(a: SubMesh, b: SubMesh): number; /** - * This method will pack all the used elements into a linear sequence and put all the free space at the end. - * Instances of DynamicFloatArrayElement may have their 'offset' member changed as data could be copied from one location to another, so be sure to read/write your data based on the value inside this member after you called pack(). - * @return the subArray that is the view of the used elements area, you can use it as a source to update a WebGLBuffer + * Resets the different lists of submeshes to prepare a new frame. */ - pack(): Float32Array; - private _moveElement(element, destOffset); - private _growBuffer(); + prepare(): void; + dispose(): void; /** - * This is the main buffer, all elements are stored inside, you use the DynamicFloatArrayElement instance of a given element to know its location into this buffer, then you have the responsibility to perform write operations in this buffer at the right location! - * Don't use this buffer for a WebGL bufferSubData() operation, but use the one returned by the pack() method. + * Inserts the submesh in its correct queue depending on its material. + * @param subMesh The submesh to dispatch */ - buffer: Float32Array; + dispatch(subMesh: SubMesh): void; + dispatchSprites(spriteManager: SpriteManager): void; + dispatchParticles(particleSystem: IParticleSystem): void; + private _renderParticles(activeMeshes); + private _renderSprites(); + } +} + +declare module BABYLON { + class RenderingManager { /** - * Get the total count of entries that can fit in the current buffer - * @returns the elements count + * The max id used for rendering groups (not included) */ - readonly totalElementCount: number; + static MAX_RENDERINGGROUPS: number; /** - * Get the count of free entries that can still be allocated without resizing the buffer - * @returns the free elements count + * The min id used for rendering groups (included) */ - readonly freeElementCount: number; + static MIN_RENDERINGGROUPS: number; /** - * Get the count of allocated elements - * @returns the allocated elements count + * Used to globally prevent autoclearing scenes. */ - readonly usedElementCount: number; + static AUTOCLEAR: boolean; + private _scene; + private _renderingGroups; + private _depthStencilBufferAlreadyCleaned; + private _currentIndex; + private _autoClearDepthStencil; + private _customOpaqueSortCompareFn; + private _customAlphaTestSortCompareFn; + private _customTransparentSortCompareFn; + private _renderinGroupInfo; + constructor(scene: Scene); + private _clearDepthStencilBuffer(depth?, stencil?); + render(customRenderFunction: (opaqueSubMeshes: SmartArray, transparentSubMeshes: SmartArray, alphaTestSubMeshes: SmartArray) => void, activeMeshes: AbstractMesh[], renderParticles: boolean, renderSprites: boolean): void; + reset(): void; + dispose(): void; + private _prepareRenderingGroup(renderingGroupId); + dispatchSprites(spriteManager: SpriteManager): void; + dispatchParticles(particleSystem: IParticleSystem): void; + dispatch(subMesh: SubMesh): void; /** - * Return the size of one element in float - * @returns the size in float + * 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. */ - readonly stride: number; - compareValueOffset: number; - sortingAscending: boolean; - sort(): boolean; - private _allEntries; - private _freeEntries; - private _stride; - private _lastUsed; - private _firstFree; - private _sortTable; - private _sortedTable; - } -} - -declare module Earcut { - /** - * The fastest and smallest JavaScript polygon triangulation library for your WebGL apps - * @param data is a flat array of vertice coordinates like [x0, y0, x1, y1, x2, y2, ...]. - * @param holeIndices is an array of hole indices if any (e.g. [5, 8] for a 12- vertice input would mean one hole with vertices 5–7 and another with 8–11). - * @param dim is the number of coordinates per vertice in the input array (2 by default). - */ - function earcut(data: number[], holeIndices: number[], dim: number): any[]; - /** - * return a percentage difference between the polygon area and its triangulation area; - * used to verify correctness of triangulation - */ - function deviation(data: number[], holeIndices: number[], dim: number, triangles: number[]): number; - /** - * turn a polygon in a multi-dimensional array form (e.g. as in GeoJSON) into a form Earcut accepts - */ - function flatten(data: number[][][]): { - vertices: any[]; - holes: any[]; - dimensions: number; - }; -} - -declare module BABYLON { - enum PoseEnabledControllerType { - VIVE = 0, - OCULUS = 1, - WINDOWS = 2, - GENERIC = 3, - } - interface MutableGamepadButton { - value: number; - touched: boolean; - pressed: boolean; - } - class PoseEnabledControllerHelper { - static InitiateController(vrGamepad: any): OculusTouchController | ViveController | GenericController; - } - class PoseEnabledController extends Gamepad implements PoseControlled { - vrGamepad: any; - devicePosition: Vector3; - deviceRotationQuaternion: Quaternion; - deviceScaleFactor: number; - position: Vector3; - rotationQuaternion: Quaternion; - controllerType: PoseEnabledControllerType; - private _calculatedPosition; - private _calculatedRotation; - rawPose: DevicePose; - _mesh: AbstractMesh; - private _poseControlledCamera; - private _leftHandSystemQuaternion; - constructor(vrGamepad: any); - update(): void; - updateFromDevice(poseData: DevicePose): void; - attachToMesh(mesh: AbstractMesh): void; - attachToPoseControlledCamera(camera: TargetCamera): void; - detachMesh(): void; - readonly mesh: AbstractMesh; - getForwardRay(length?: number): Ray; - } - interface GamepadButtonChanges { - changed: boolean; - pressChanged: boolean; - touchChanged: boolean; - valueChanged: boolean; - } - abstract class WebVRController extends PoseEnabledController { - onTriggerStateChangedObservable: Observable; - onMainButtonStateChangedObservable: Observable; - onSecondaryButtonStateChangedObservable: Observable; - onPadStateChangedObservable: Observable; - onPadValuesChangedObservable: Observable; - protected _buttons: Array; - private _onButtonStateChange; - onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void; - pad: StickValues; - hand: string; - constructor(vrGamepad: any); - update(): void; - protected abstract handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): any; - abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): any; - private _setButtonValue(newState, currentState, buttonIndex); - private _changes; - private _checkChanges(newState, currentState); - } - class OculusTouchController extends WebVRController { - private _defaultModel; - onSecondaryTriggerStateChangedObservable: Observable; - onThumbRestChangedObservable: Observable; - constructor(vrGamepad: any); - initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void; - readonly onAButtonStateChangedObservable: Observable; - readonly onBButtonStateChangedObservable: Observable; - readonly onXButtonStateChangedObservable: Observable; - readonly onYButtonStateChangedObservable: Observable; - protected handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void; - } - class ViveController extends WebVRController { - private _defaultModel; - constructor(vrGamepad: any); - initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void; - readonly onLeftButtonStateChangedObservable: Observable; - readonly onRightButtonStateChangedObservable: Observable; - readonly onMenuButtonStateChangedObservable: Observable; + setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: (a: SubMesh, b: SubMesh) => number, alphaTestSortCompareFn?: (a: SubMesh, b: SubMesh) => number, transparentSortCompareFn?: (a: SubMesh, b: SubMesh) => number): void; /** - * Vive mapping: - * 0: touchpad - * 1: trigger - * 2: left AND right buttons - * 3: menu button + * 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. */ - protected handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void; - } - class GenericController extends WebVRController { - private _defaultModel; - constructor(vrGamepad: any); - initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void; - protected handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void; + setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void; } } -interface ExtendedGamepadButton extends GamepadButton { - readonly pressed: boolean; - readonly touched: boolean; - readonly value: number; -} declare module BABYLON { - class FilesInput { - private _engine; - private _currentScene; - private _canvas; - private _sceneLoadedCallback; - private _progressCallback; - private _additionnalRenderLoopLogicCallback; - private _textureLoadingCallback; - private _startingProcessingFilesCallback; - private _elementToMonitor; - static FilesToLoad: File[]; - private _sceneFileToLoad; - private _filesToLoad; - constructor(p_engine: Engine, p_scene: Scene, p_canvas: HTMLCanvasElement, p_sceneLoadedCallback: any, p_progressCallback: any, p_additionnalRenderLoopLogicCallback: any, p_textureLoadingCallback: any, p_startingProcessingFilesCallback: any); - monitorElementForDragNDrop(p_elementToMonitor: HTMLElement): void; - private renderFunction(); - private drag(e); - private drop(eventDrop); - private _handleFolderDrop(entry, files, callback); - private _processFiles(files); - loadFiles(event: any): void; - reload(): void; + class Sprite { + name: string; + position: Vector3; + color: Color4; + width: number; + height: number; + angle: number; + cellIndex: number; + invertU: number; + invertV: number; + disposeWhenFinishedAnimating: boolean; + animations: Animation[]; + isPickable: boolean; + actionManager: ActionManager; + private _animationStarted; + private _loopAnimation; + private _fromIndex; + private _toIndex; + private _delay; + private _direction; + private _frameCount; + private _manager; + private _time; + private _onAnimationEnd; + size: number; + constructor(name: string, manager: SpriteManager); + playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void; + stopAnimation(): void; + _animate(deltaTime: number): void; + dispose(): void; } } declare module BABYLON { - class Gamepads { - private babylonGamepads; - private oneGamepadConnected; - private isMonitoring; - private gamepadEventSupported; - private gamepadSupport; - private _callbackGamepadConnected; - private _callbackGamepadDisconnected; - private _onGamepadConnectedEvent; - private _onGamepadDisonnectedEvent; - constructor(ongamedpadconnected: (gamepad: T) => void, ongamedpaddisconnected?: (gamepad: T) => void); + class SpriteManager { + name: string; + sprites: Sprite[]; + renderingGroupId: number; + layerMask: number; + fogEnabled: boolean; + isPickable: boolean; + cellWidth: number; + cellHeight: number; + /** + * An event triggered when the manager is disposed. + * @type {BABYLON.Observable} + */ + onDisposeObservable: Observable; + private _onDisposeObserver; + onDispose: () => void; + private _capacity; + private _spriteTexture; + private _epsilon; + private _scene; + private _vertexData; + private _buffer; + private _vertexBuffers; + private _indexBuffer; + private _effectBase; + private _effectFog; + texture: Texture; + constructor(name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number); + private _appendSpriteVertex(index, sprite, offsetX, offsetY, rowSize); + intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): PickingInfo; + render(): void; dispose(): void; - private _onGamepadConnected(gamepad); - private _addNewGamepad(gamepad); - private _onGamepadDisconnected(gamepad); - private _startMonitoringGamepads(); - private _stopMonitoringGamepads(); - private _checkGamepadsStatus(); - private _updateGamepadObjects(); - } - class StickValues { - x: any; - y: any; - constructor(x: any, y: any); - } - class Gamepad { - id: string; - index: number; - browserGamepad: any; - type: number; - private _leftStick; - private _rightStick; - private _leftStickAxisX; - private _leftStickAxisY; - private _rightStickAxisX; - private _rightStickAxisY; - private _onleftstickchanged; - private _onrightstickchanged; - static GAMEPAD: number; - static GENERIC: number; - static XBOX: number; - static POSE_ENABLED: number; - constructor(id: string, index: number, browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number); - onleftstickchanged(callback: (values: StickValues) => void): void; - onrightstickchanged(callback: (values: StickValues) => void): void; - leftStick: StickValues; - rightStick: StickValues; - update(): void; - } - class GenericPad extends Gamepad { - private _buttons; - private _onbuttondown; - private _onbuttonup; - onbuttondown(callback: (buttonPressed: number) => void): void; - onbuttonup(callback: (buttonReleased: number) => void): void; - constructor(id: string, index: number, browserGamepad: any); - private _setButtonValue(newValue, currentValue, buttonIndex); - update(): void; - } - enum Xbox360Button { - A = 0, - B = 1, - X = 2, - Y = 3, - Start = 4, - Back = 5, - LB = 6, - RB = 7, - LeftStick = 8, - RightStick = 9, } - enum Xbox360Dpad { - Up = 0, - Down = 1, - Left = 2, - Right = 3, +} + +declare module BABYLON.Internals { + class _AlphaState { + private _isAlphaBlendDirty; + private _isBlendFunctionParametersDirty; + private _isBlendEquationParametersDirty; + private _isBlendConstantsDirty; + private _alphaBlend; + private _blendFunctionParameters; + private _blendEquationParameters; + private _blendConstants; + /** + * Initializes the state. + */ + constructor(); + readonly isDirty: boolean; + alphaBlend: boolean; + setAlphaBlendConstants(r: number, g: number, b: number, a: number): void; + setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void; + setAlphaEquationParameters(rgb: number, alpha: any): void; + reset(): void; + apply(gl: WebGLRenderingContext): void; } - class Xbox360Pad extends Gamepad { - private _leftTrigger; - private _rightTrigger; - private _onlefttriggerchanged; - private _onrighttriggerchanged; - private _onbuttondown; - private _onbuttonup; - private _ondpaddown; - private _ondpadup; - 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; - constructor(id: string, index: number, gamepad: any, xboxOne?: boolean); - onlefttriggerchanged(callback: (value: number) => void): void; - onrighttriggerchanged(callback: (value: number) => void): void; - leftTrigger: number; - rightTrigger: number; - onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void; - onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void; - ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void; - ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void; - private _setButtonValue(newValue, currentValue, buttonType); - private _setDPadValue(newValue, currentValue, buttonType); - buttonA: number; - buttonB: number; - buttonX: number; - buttonY: number; - buttonStart: number; - buttonBack: number; - buttonLB: number; - buttonRB: number; - buttonLeftStick: number; - buttonRightStick: number; - dPadUp: number; - dPadDown: number; - dPadLeft: number; - dPadRight: number; - update(): void; +} + +declare module BABYLON.Internals { + class _DepthCullingState { + private _isDepthTestDirty; + private _isDepthMaskDirty; + private _isDepthFuncDirty; + private _isCullFaceDirty; + private _isCullDirty; + private _isZOffsetDirty; + private _depthTest; + private _depthMask; + private _depthFunc; + private _cull; + private _cullFace; + private _zOffset; + /** + * Initializes the state. + */ + constructor(); + readonly isDirty: boolean; + zOffset: number; + cullFace: number; + cull: boolean; + depthFunc: number; + depthMask: boolean; + depthTest: boolean; + reset(): void; + apply(gl: WebGLRenderingContext): void; } } -interface Navigator { - getGamepads(func?: any): any; - webkitGetGamepads(func?: any): any; - msGetGamepads(func?: any): any; - webkitGamepads(func?: any): any; + +declare module BABYLON.Internals { + class _StencilState { + private _isStencilTestDirty; + private _isStencilMaskDirty; + private _isStencilFuncDirty; + private _isStencilOpDirty; + private _stencilTest; + private _stencilMask; + private _stencilFunc; + private _stencilFuncRef; + private _stencilFuncMask; + private _stencilOpStencilFail; + private _stencilOpDepthFail; + private _stencilOpStencilDepthPass; + readonly isDirty: boolean; + stencilFunc: number; + stencilFuncRef: number; + stencilFuncMask: number; + stencilOpStencilFail: number; + stencilOpDepthFail: number; + stencilOpStencilDepthPass: number; + stencilMask: number; + stencilTest: boolean; + constructor(); + reset(): void; + apply(gl: WebGLRenderingContext): void; + } } declare module BABYLON.Internals { - /** - * 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/ - */ - class KhronosTextureContainer { - arrayBuffer: any; - static HEADER_LEN: number; - static COMPRESSED_2D: number; - static COMPRESSED_3D: number; - static TEX_2D: number; - static TEX_3D: number; - glType: number; - glTypeSize: number; - glFormat: number; - glInternalFormat: number; - glBaseInternalFormat: number; - pixelWidth: number; - pixelHeight: number; - pixelDepth: number; - numberOfArrayElements: number; - numberOfFaces: number; - numberOfMipmapLevels: number; - bytesOfKeyValueData: number; - loadType: number; - /** - * @param {ArrayBuffer} arrayBuffer- contents of the KTX container file - * @param {number} facesExpected- should be either 1 or 6, based whether a cube texture or or - * @param {boolean} threeDExpected- provision for indicating that data should be a 3D texture, not implemented - * @param {boolean} textureArrayExpected- provision for indicating that data should be a texture array, not implemented - */ - constructor(arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean); - switchEndainness(val: number): number; - /** - * It is assumed that the texture has already been created & is currently bound - */ - uploadLevels(gl: WebGLRenderingContext, loadMipmaps: boolean): void; - private _upload2DCompressedLevels(gl, loadMipmaps); + class AndOrNotEvaluator { + static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean; + private static _HandleParenthesisContent(parenthesisContent, evaluateCallback); + private static _SimplifyNegation(booleanString); } } declare module BABYLON { - /** - * A class serves as a medium between the observable and its observers - */ - class EventState { - /** - * If the callback of a given Observer set skipNextObservers to true the following observers will be ignored - */ - constructor(mask: number, skipNextObservers?: boolean); - initalize(mask: number, skipNextObservers?: boolean): EventState; - /** - * An Observer can set this property to true to prevent subsequent observers of being notified - */ - skipNextObservers: boolean; - /** - * Get the mask value that were used to trigger the event corresponding to this EventState object - */ - mask: number; + interface IAssetTask { + onSuccess: (task: IAssetTask) => void; + onError: (task: IAssetTask) => void; + isCompleted: boolean; + run(scene: Scene, onSuccess: () => void, onError: () => void): any; } - /** - * Represent an Observer registered to a given Observable object. - */ - class Observer { - callback: (eventData: T, eventState: EventState) => void; - mask: number; - constructor(callback: (eventData: T, eventState: EventState) => void, mask: number); + class MeshAssetTask implements IAssetTask { + name: string; + meshesNames: any; + rootUrl: string; + sceneFilename: string; + loadedMeshes: Array; + loadedParticleSystems: Array; + loadedSkeletons: Array; + onSuccess: (task: IAssetTask) => void; + onError: (task: IAssetTask) => void; + isCompleted: boolean; + constructor(name: string, meshesNames: any, rootUrl: string, sceneFilename: string); + run(scene: Scene, onSuccess: () => void, onError: () => void): void; } - /** - * The Observable class is a simple implementation of the Observable pattern. - * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified. - * This enable a more fine grained execution without having to rely on multiple different Observable objects. - * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08). - * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right. - */ - class Observable { - _observers: Observer[]; - private _eventState; - constructor(); - /** - * Create a new Observer with the specified callback - * @param callback the callback that will be executed for that Observer - * @param mask the mask used to filter observers - * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present. - */ - add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean): Observer; - /** - * Remove an Observer from the Observable object - * @param observer the instance of the Observer to remove. If it doesn't belong to this Observable, false will be returned. - */ - remove(observer: Observer): boolean; - /** - * Remove a callback from the Observable object - * @param callback the callback to remove. If it doesn't belong to this Observable, false will be returned. - */ - removeCallback(callback: (eventData: T, eventState: EventState) => void): boolean; - /** - * Notify all Observers by calling their respective callback with the given data - * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute - * @param eventData - * @param mask - */ - notifyObservers(eventData: T, mask?: number): boolean; - /** - * return true is the Observable has at least one Observer registered - */ - hasObservers(): boolean; - /** - * Clear the list of observers - */ - clear(): void; - /** - * Clone the current observable - */ - clone(): Observable; - /** - * Does this observable handles observer registered with a given mask - * @param {number} trigger - the mask to be tested - * @return {boolean} whether or not one observer registered with the given mask is handeled - **/ - hasSpecificMask(mask?: number): boolean; + class TextFileAssetTask implements IAssetTask { + name: string; + url: string; + onSuccess: (task: IAssetTask) => void; + onError: (task: IAssetTask) => void; + isCompleted: boolean; + text: string; + constructor(name: string, url: string); + run(scene: Scene, onSuccess: () => void, onError: () => void): void; + } + class BinaryFileAssetTask implements IAssetTask { + name: string; + url: string; + onSuccess: (task: IAssetTask) => void; + onError: (task: IAssetTask) => void; + isCompleted: boolean; + data: ArrayBuffer; + constructor(name: string, url: string); + run(scene: Scene, onSuccess: () => void, onError: () => void): void; + } + class ImageAssetTask implements IAssetTask { + name: string; + url: string; + onSuccess: (task: IAssetTask) => void; + onError: (task: IAssetTask) => void; + isCompleted: boolean; + image: HTMLImageElement; + constructor(name: string, url: string); + run(scene: Scene, onSuccess: () => void, onError: () => void): void; + } + interface ITextureAssetTask extends IAssetTask { + onSuccess: (task: ITextureAssetTask) => void; + onError: (task: ITextureAssetTask) => void; + texture: Texture; + } + class TextureAssetTask implements ITextureAssetTask { + name: string; + url: string; + noMipmap: boolean; + invertY: boolean; + samplingMode: number; + onSuccess: (task: ITextureAssetTask) => void; + onError: (task: ITextureAssetTask) => void; + isCompleted: boolean; + texture: Texture; + constructor(name: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number); + run(scene: Scene, onSuccess: () => void, onError: () => void): void; + } + class CubeTextureAssetTask implements IAssetTask { + name: string; + url: string; + extensions: string[]; + noMipmap: boolean; + files: string[]; + onSuccess: (task: IAssetTask) => void; + onError: (task: IAssetTask) => void; + isCompleted: boolean; + texture: CubeTexture; + constructor(name: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]); + run(scene: Scene, onSuccess: () => void, onError: () => void): void; + } + class HDRCubeTextureAssetTask implements IAssetTask { + name: string; + url: string; + size: number; + noMipmap: boolean; + generateHarmonics: boolean; + useInGammaSpace: boolean; + usePMREMGenerator: boolean; + onSuccess: (task: IAssetTask) => void; + onError: (task: IAssetTask) => void; + isCompleted: boolean; + texture: HDRCubeTexture; + constructor(name: string, url: string, size?: number, noMipmap?: boolean, generateHarmonics?: boolean, useInGammaSpace?: boolean, usePMREMGenerator?: boolean); + run(scene: Scene, onSuccess: () => void, onError: () => void): void; + } + class AssetsManager { + private _scene; + protected tasks: IAssetTask[]; + protected waitingTasksCount: number; + onFinish: (tasks: IAssetTask[]) => void; + onTaskSuccess: (task: IAssetTask) => void; + onTaskError: (task: IAssetTask) => void; + useDefaultLoadingScreen: boolean; + constructor(scene: Scene); + addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): IAssetTask; + addTextFileTask(taskName: string, url: string): IAssetTask; + addBinaryFileTask(taskName: string, url: string): IAssetTask; + addImageTask(taskName: string, url: string): IAssetTask; + addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): ITextureAssetTask; + addCubeTextureTask(name: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): IAssetTask; + addHDRCubeTextureTask(name: string, url: string, size?: number, noMipmap?: boolean, generateHarmonics?: boolean, useInGammaSpace?: boolean, usePMREMGenerator?: boolean): IAssetTask; + private _decreaseWaitingTasksCount(); + private _runTask(task); + reset(): AssetsManager; + load(): AssetsManager; + } +} + +declare module BABYLON { + class Database { + private callbackManifestChecked; + private currentSceneUrl; + private db; + private enableSceneOffline; + private enableTexturesOffline; + private manifestVersionFound; + private mustUpdateRessources; + private hasReachedQuota; + private isSupported; + private idbFactory; + static IsUASupportingBlobStorage: boolean; + static IDBStorageEnabled: boolean; + constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any); + static parseURL: (url: string) => string; + static ReturnFullUrlLocation: (url: string) => string; + checkManifestFile(): void; + openAsync(successCallback: any, errorCallback: any): void; + loadImageFromDB(url: string, image: HTMLImageElement): void; + private _loadImageFromDBAsync(url, image, notInDBCallback); + private _saveImageIntoDBAsync(url, image); + private _checkVersionFromDB(url, versionLoaded); + private _loadVersionFromDBAsync(url, callback, updateInDBCallback); + private _saveVersionIntoDBAsync(url, callback); + private loadFileFromDB(url, sceneLoaded, progressCallBack, errorCallback, useArrayBuffer?); + private _loadFileFromDBAsync(url, callback, notInDBCallback, useArrayBuffer?); + private _saveFileIntoDBAsync(url, callback, progressCallback, useArrayBuffer?); } } -declare namespace BABYLON { - /** - * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window - */ - class PerformanceMonitor { - private _enabled; - private _rollingFrameTime; - private _lastFrameTimeMs; - private _lastChangeTimeMs; - /** - * constructor - * @param frameSampleSize The number of samples required to saturate the sliding window - */ - constructor(frameSampleSize?: number); - /** - * Samples current frame - * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames - */ - sampleFrame(timeMs?: number): void; - /** - * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far) - * @return Average frame time in milliseconds - */ - readonly averageFrameTime: number; - /** - * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far) - * @return Frame time variance in milliseconds squared - */ - readonly averageFrameTimeVariance: number; - /** - * Returns the frame time of the most recent frame - * @return Frame time in milliseconds - */ - readonly instantaneousFrameTime: number; - /** - * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far) - * @return Framerate in frames per second - */ - readonly averageFPS: number; - /** - * Returns the average framerate in frames per second using the most recent frame time - * @return Framerate in frames per second - */ - readonly instantaneousFPS: number; - /** - * Returns true if enough samples have been taken to completely fill the sliding window - * @return true if saturated - */ - readonly isSaturated: boolean; - /** - * Enables contributions to the sliding window sample set - */ - enable(): void; - /** - * Disables contributions to the sliding window sample set - * Samples will not be interpolated over the disabled period - */ - disable(): void; - /** - * Returns true if sampling is enabled - * @return true if enabled - */ - readonly isEnabled: boolean; - /** - * Resets performance monitor - */ - reset(): void; +declare module BABYLON.Internals { + interface DDSInfo { + width: number; + height: number; + mipmapCount: number; + isFourCC: boolean; + isRGB: boolean; + isLuminance: boolean; + isCube: boolean; + isCompressed: boolean; + dxgiFormat: number; + textureType: number; } - /** - * RollingAverage - * - * Utility to efficiently compute the rolling average and variance over a sliding window of samples - */ - class RollingAverage { - /** - * Current average - */ - average: number; - /** - * Current variance - */ - variance: number; - protected _samples: Array; - protected _sampleCount: number; - protected _pos: number; - protected _m2: number; - /** - * constructor - * @param length The number of samples required to saturate the sliding window - */ - constructor(length: number); - /** - * Adds a sample to the sample set - * @param v The sample value - */ - add(v: number): void; - /** - * Returns previously added values or null if outside of history or outside the sliding window domain - * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that - * @return Value previously recorded with add() or null if outside of range - */ - history(i: number): number; - /** - * Returns true if enough samples have been taken to completely fill the sliding window - * @return true if sample-set saturated - */ - isSaturated(): boolean; - /** - * Resets the rolling average (equivalent to 0 samples taken so far) - */ - reset(): void; - /** - * Wraps a value around the sample range boundaries - * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned. - * @return Wrapped position in sample range - */ - protected _wrapPosition(i: number): number; + class DDSTools { + static StoreLODInAlphaChannel: boolean; + static GetDDSInfo(arrayBuffer: any): DDSInfo; + private static _FloatView; + private static _Int32View; + private static _ToHalfFloat(value); + private static _FromHalfFloat(value); + private static _GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod); + private static _GetHalfFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod); + private static _GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod); + private static _GetFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod); + private static _GetHalfFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod); + private static _GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer); + private static _GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer); + private static _GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer); + static UploadDDSLevels(engine: Engine, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number): void; + } +} + +declare module BABYLON { + function expandToProperty(callback: string, targetKey?: string): (target: any, propertyKey: string) => void; + function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void; + function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void; + function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void; + function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void; + function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void; + function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void; + function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void; + function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void; + function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void; + function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void; + class SerializationHelper { + static Serialize(entity: T, serializationObject?: any): any; + static Parse(creationFunction: () => T, source: any, scene: Scene, rootUrl?: string): T; + static Clone(creationFunction: () => T, source: T): T; + static Instanciate(creationFunction: () => T, source: T): T; } } declare module BABYLON { + class DynamicFloatArrayElementInfo { + offset: number; + } /** - * This class describe a rectangle that were added to the map. - * You have access to its coordinates either in pixel or normalized (UV) - */ - class PackedRect { - constructor(root: RectPackingMap, parent: PackedRect, pos: Vector2, size: Size); - /** - * @returns the position of this node into the map - */ - readonly pos: Vector2; - /** - * @returns the size of the rectangle this node handles - */ - readonly contentSize: Size; - /** - * Retrieve the inner position (considering the margin) and stores it into the res object - * @param res must be a valid Vector2 that will contain the inner position after this call - */ - getInnerPosToRef(res: Vector2): void; - /** - * Retrieve the inner size (considering the margin) and stores it into the res object - * @param res must be a valid Size that will contain the inner size after this call - */ - getInnerSizeToRef(res: Size): void; + * The purpose of this class is to store float32 based elements of a given size (defined by the stride argument) in a dynamic fashion, that is, you can add/free elements. You can then access to a defragmented/packed version of the underlying Float32Array by calling the pack() method. + * The intent is to maintain through time data that will be bound to a WebGlBuffer with the ability to change add/remove elements. + * It was first built to efficiently maintain the WebGlBuffer that contain instancing based data. + * Allocating an Element will return a instance of DynamicFloatArrayElement which contains the offset into the Float32Array of where the element starts, you are then responsible to copy your data using this offset. + * Beware, calling pack() may change the offset of some Entries because this method will defragment the Float32Array to replace empty elements by moving allocated ones at their location. + * This method will return an ArrayBufferView on the existing Float32Array that describes the used elements. Use this View to update the WebGLBuffer and NOT the "buffer" field of the class. The pack() method won't shrink/reallocate the buffer to keep it GC friendly, all the empty space will be put at the end of the buffer, the method just ensure there are no "free holes". + */ + class DynamicFloatArray { /** - * Compute the UV of the top/left, top/right, bottom/right, bottom/left points of the rectangle this node handles into the map - * @returns And array of 4 Vector2, containing UV coordinates for the four corners of the Rectangle into the map + * Construct an instance of the dynamic float array + * @param stride size of one element in float (i.e. not bytes!) + * @param initialElementCount the number of available entries at construction */ - readonly UVs: Vector2[]; + constructor(stride: number, initialElementCount: number); /** - * You may have allocated the PackedRect using over-provisioning (you allocated more than you need in order to prevent frequent deallocations/reallocations) - * and then using only a part of the PackRect. - * This method will return the UVs for this part by given the custom size of what you really use - * @param customSize must be less/equal to the allocated size, UV will be compute from this + * Allocate an element in the array. + * @return the element info instance that contains the offset into the main buffer of the element's location. + * Beware, this offset may change when you call pack() */ - getUVsForCustomSize(customSize: Size): Vector2[]; + allocElement(): DynamicFloatArrayElementInfo; /** - * Free this rectangle from the map. - * Call this method when you no longer need the rectangle to be in the map. + * Free the element corresponding to the given element info + * @param elInfo the element that describe the allocated element */ - freeContent(): void; - protected readonly isUsed: boolean; - protected findAndSplitNode(contentSize: Size): PackedRect; - private findNode(size); - private static TpsSize; - private splitNode(contentSize); - private attemptDefrag(); - private clearNode(); - private readonly isRecursiveFree; - protected evalFreeSize(size: number): number; - protected _root: RectPackingMap; - protected _parent: PackedRect; - private _contentSize; - private _initialSize; - private _leftNode; - private _rightNode; - private _bottomNode; - private _pos; - protected _size: Size; - } - /** - * The purpose of this class is to pack several Rectangles into a big map, while trying to fit everything as optimally as possible. - * This class is typically used to build lightmaps, sprite map or to pack several little textures into a big one. - * Note that this class allows allocated Rectangles to be freed: that is the map is dynamically maintained so you can add/remove rectangle based on their life-cycle. - * In case you need a margin around the allocated rect, specify the amount in the margin argument during construction. - * In such case you will have to rely on innerPositionToRef and innerSizeToRef calls to get the proper size - */ - class RectPackingMap extends PackedRect { + freeElement(elInfo: DynamicFloatArrayElementInfo): void; /** - * Create an instance of the object with a dimension using the given size - * @param size The dimension of the rectangle that will contain all the sub ones. - * @param margin The margin (empty space) created (in pixels) around the allocated Rectangles + * This method will pack all the used elements into a linear sequence and put all the free space at the end. + * Instances of DynamicFloatArrayElement may have their 'offset' member changed as data could be copied from one location to another, so be sure to read/write your data based on the value inside this member after you called pack(). + * @return the subArray that is the view of the used elements area, you can use it as a source to update a WebGLBuffer */ - constructor(size: Size, margin?: number); + pack(): Float32Array; + private _moveElement(element, destOffset); + private _growBuffer(); /** - * Add a rectangle, finding the best location to store it into the map - * @param size the dimension of the rectangle to store - * @return the Node containing the rectangle information, or null if we couldn't find a free spot + * This is the main buffer, all elements are stored inside, you use the DynamicFloatArrayElement instance of a given element to know its location into this buffer, then you have the responsibility to perform write operations in this buffer at the right location! + * Don't use this buffer for a WebGL bufferSubData() operation, but use the one returned by the pack() method. */ - addRect(size: Size): PackedRect; + buffer: Float32Array; /** - * Return the current space free normalized between [0;1] - * @returns {} + * Get the total count of entries that can fit in the current buffer + * @returns the elements count */ - readonly freeSpace: number; - _margin: number; + readonly totalElementCount: number; + /** + * Get the count of free entries that can still be allocated without resizing the buffer + * @returns the free elements count + */ + readonly freeElementCount: number; + /** + * Get the count of allocated elements + * @returns the allocated elements count + */ + readonly usedElementCount: number; + /** + * Return the size of one element in float + * @returns the size in float + */ + readonly stride: number; + compareValueOffset: number; + sortingAscending: boolean; + sort(): boolean; + private _allEntries; + private _freeEntries; + private _stride; + private _lastUsed; + private _firstFree; + private _sortTable; + private _sortedTable; } } +declare module Earcut { + /** + * The fastest and smallest JavaScript polygon triangulation library for your WebGL apps + * @param data is a flat array of vertice coordinates like [x0, y0, x1, y1, x2, y2, ...]. + * @param holeIndices is an array of hole indices if any (e.g. [5, 8] for a 12- vertice input would mean one hole with vertices 5–7 and another with 8–11). + * @param dim is the number of coordinates per vertice in the input array (2 by default). + */ + function earcut(data: number[], holeIndices: number[], dim: number): any[]; + /** + * return a percentage difference between the polygon area and its triangulation area; + * used to verify correctness of triangulation + */ + function deviation(data: number[], holeIndices: number[], dim: number, triangles: number[]): number; + /** + * turn a polygon in a multi-dimensional array form (e.g. as in GeoJSON) into a form Earcut accepts + */ + function flatten(data: number[][][]): { + vertices: any[]; + holes: any[]; + dimensions: number; + }; +} + declare module BABYLON { - class SceneOptimization { - priority: number; - apply: (scene: Scene) => boolean; - constructor(priority?: number); + enum PoseEnabledControllerType { + VIVE = 0, + OCULUS = 1, + WINDOWS = 2, + GENERIC = 3, } - class TextureOptimization extends SceneOptimization { - priority: number; - maximumSize: number; - constructor(priority?: number, maximumSize?: number); - apply: (scene: Scene) => boolean; + interface MutableGamepadButton { + value: number; + touched: boolean; + pressed: boolean; } - class HardwareScalingOptimization extends SceneOptimization { - priority: number; - maximumScale: number; - private _currentScale; - constructor(priority?: number, maximumScale?: number); - apply: (scene: Scene) => boolean; + class PoseEnabledControllerHelper { + static InitiateController(vrGamepad: any): OculusTouchController | ViveController | GenericController; } - class ShadowsOptimization extends SceneOptimization { - apply: (scene: Scene) => boolean; + class PoseEnabledController extends Gamepad implements PoseControlled { + vrGamepad: any; + devicePosition: Vector3; + deviceRotationQuaternion: Quaternion; + deviceScaleFactor: number; + position: Vector3; + rotationQuaternion: Quaternion; + controllerType: PoseEnabledControllerType; + private _calculatedPosition; + private _calculatedRotation; + rawPose: DevicePose; + _mesh: AbstractMesh; + private _poseControlledCamera; + private _leftHandSystemQuaternion; + constructor(vrGamepad: any); + update(): void; + updateFromDevice(poseData: DevicePose): void; + attachToMesh(mesh: AbstractMesh): void; + attachToPoseControlledCamera(camera: TargetCamera): void; + detachMesh(): void; + readonly mesh: AbstractMesh; + getForwardRay(length?: number): Ray; } - class PostProcessesOptimization extends SceneOptimization { - apply: (scene: Scene) => boolean; + interface GamepadButtonChanges { + changed: boolean; + pressChanged: boolean; + touchChanged: boolean; + valueChanged: boolean; } - class LensFlaresOptimization extends SceneOptimization { - apply: (scene: Scene) => boolean; + abstract class WebVRController extends PoseEnabledController { + onTriggerStateChangedObservable: Observable; + onMainButtonStateChangedObservable: Observable; + onSecondaryButtonStateChangedObservable: Observable; + onPadStateChangedObservable: Observable; + onPadValuesChangedObservable: Observable; + protected _buttons: Array; + private _onButtonStateChange; + onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void; + pad: StickValues; + hand: string; + constructor(vrGamepad: any); + update(): void; + protected abstract handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): any; + abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): any; + private _setButtonValue(newState, currentState, buttonIndex); + private _changes; + private _checkChanges(newState, currentState); } - class ParticlesOptimization extends SceneOptimization { - apply: (scene: Scene) => boolean; + class OculusTouchController extends WebVRController { + private _defaultModel; + onSecondaryTriggerStateChangedObservable: Observable; + onThumbRestChangedObservable: Observable; + constructor(vrGamepad: any); + initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void; + readonly onAButtonStateChangedObservable: Observable; + readonly onBButtonStateChangedObservable: Observable; + readonly onXButtonStateChangedObservable: Observable; + readonly onYButtonStateChangedObservable: Observable; + protected handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void; } - class RenderTargetsOptimization extends SceneOptimization { - apply: (scene: Scene) => boolean; + class ViveController extends WebVRController { + private _defaultModel; + constructor(vrGamepad: any); + initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void; + readonly onLeftButtonStateChangedObservable: Observable; + readonly onRightButtonStateChangedObservable: Observable; + readonly onMenuButtonStateChangedObservable: Observable; + /** + * Vive mapping: + * 0: touchpad + * 1: trigger + * 2: left AND right buttons + * 3: menu button + */ + protected handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void; + } + class GenericController extends WebVRController { + private _defaultModel; + constructor(vrGamepad: any); + initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void; + protected handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void; + } +} +interface ExtendedGamepadButton extends GamepadButton { + readonly pressed: boolean; + readonly touched: boolean; + readonly value: number; +} + +declare module BABYLON { + class FilesInput { + private _engine; + private _currentScene; + private _canvas; + private _sceneLoadedCallback; + private _progressCallback; + private _additionnalRenderLoopLogicCallback; + private _textureLoadingCallback; + private _startingProcessingFilesCallback; + private _elementToMonitor; + static FilesToLoad: File[]; + private _sceneFileToLoad; + private _filesToLoad; + constructor(p_engine: Engine, p_scene: Scene, p_canvas: HTMLCanvasElement, p_sceneLoadedCallback: any, p_progressCallback: any, p_additionnalRenderLoopLogicCallback: any, p_textureLoadingCallback: any, p_startingProcessingFilesCallback: any); + monitorElementForDragNDrop(p_elementToMonitor: HTMLElement): void; + private renderFunction(); + private drag(e); + private drop(eventDrop); + private _handleFolderDrop(entry, files, callback); + private _processFiles(files); + loadFiles(event: any): void; + reload(): void; + } +} + +declare module BABYLON { + class Gamepads { + private babylonGamepads; + private oneGamepadConnected; + private isMonitoring; + private gamepadEventSupported; + private gamepadSupport; + private _callbackGamepadConnected; + private _callbackGamepadDisconnected; + private _onGamepadConnectedEvent; + private _onGamepadDisonnectedEvent; + constructor(ongamedpadconnected: (gamepad: T) => void, ongamedpaddisconnected?: (gamepad: T) => void); + dispose(): void; + private _onGamepadConnected(gamepad); + private _addNewGamepad(gamepad); + private _onGamepadDisconnected(gamepad); + private _startMonitoringGamepads(); + private _stopMonitoringGamepads(); + private _checkGamepadsStatus(); + private _updateGamepadObjects(); + } + class StickValues { + x: any; + y: any; + constructor(x: any, y: any); + } + class Gamepad { + id: string; + index: number; + browserGamepad: any; + type: number; + private _leftStick; + private _rightStick; + private _leftStickAxisX; + private _leftStickAxisY; + private _rightStickAxisX; + private _rightStickAxisY; + private _onleftstickchanged; + private _onrightstickchanged; + static GAMEPAD: number; + static GENERIC: number; + static XBOX: number; + static POSE_ENABLED: number; + constructor(id: string, index: number, browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number); + onleftstickchanged(callback: (values: StickValues) => void): void; + onrightstickchanged(callback: (values: StickValues) => void): void; + leftStick: StickValues; + rightStick: StickValues; + update(): void; } - class MergeMeshesOptimization extends SceneOptimization { - static _UpdateSelectionTree: boolean; - static UpdateSelectionTree: boolean; - private _canBeMerged; - apply: (scene: Scene, updateSelectionTree?: boolean) => boolean; + class GenericPad extends Gamepad { + private _buttons; + private _onbuttondown; + private _onbuttonup; + onbuttondown(callback: (buttonPressed: number) => void): void; + onbuttonup(callback: (buttonReleased: number) => void): void; + constructor(id: string, index: number, browserGamepad: any); + private _setButtonValue(newValue, currentValue, buttonIndex); + update(): void; } - class SceneOptimizerOptions { - targetFrameRate: number; - trackerDuration: number; - optimizations: SceneOptimization[]; - constructor(targetFrameRate?: number, trackerDuration?: number); - static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions; - static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions; - static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions; + enum Xbox360Button { + A = 0, + B = 1, + X = 2, + Y = 3, + Start = 4, + Back = 5, + LB = 6, + RB = 7, + LeftStick = 8, + RightStick = 9, } - class SceneOptimizer { - static _CheckCurrentState(scene: Scene, options: SceneOptimizerOptions, currentPriorityLevel: number, onSuccess?: () => void, onFailure?: () => void): void; - static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): void; + enum Xbox360Dpad { + Up = 0, + Down = 1, + Left = 2, + Right = 3, } -} - -declare module BABYLON { - class SceneSerializer { - static ClearCache(): void; - static Serialize(scene: Scene): any; - static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any; + class Xbox360Pad extends Gamepad { + private _leftTrigger; + private _rightTrigger; + private _onlefttriggerchanged; + private _onrighttriggerchanged; + private _onbuttondown; + private _onbuttonup; + private _ondpaddown; + private _ondpadup; + 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; + constructor(id: string, index: number, gamepad: any, xboxOne?: boolean); + onlefttriggerchanged(callback: (value: number) => void): void; + onrighttriggerchanged(callback: (value: number) => void): void; + leftTrigger: number; + rightTrigger: number; + onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void; + onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void; + ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void; + ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void; + private _setButtonValue(newValue, currentValue, buttonType); + private _setDPadValue(newValue, currentValue, buttonType); + buttonA: number; + buttonB: number; + buttonX: number; + buttonY: number; + buttonStart: number; + buttonBack: number; + buttonLB: number; + buttonRB: number; + buttonLeftStick: number; + buttonRightStick: number; + dPadUp: number; + dPadDown: number; + dPadLeft: number; + dPadRight: number; + update(): void; } } - -declare module BABYLON { - class SmartArray { - data: Array; - length: number; - private _id; - private _duplicateId; - constructor(capacity: number); - push(value: any): void; - forEach(func: (content: T) => void): void; - pushNoDuplicate(value: any): boolean; - sort(compareFn: any): void; - reset(): void; - dispose(): void; - concat(array: any): void; - concatWithNoDuplicate(array: any): void; - indexOf(value: T): number; - contains(value: T): boolean; - private static _GlobalId; - } +interface Navigator { + getGamepads(func?: any): any; + webkitGetGamepads(func?: any): any; + msGetGamepads(func?: any): any; + webkitGamepads(func?: any): any; } -declare module BABYLON { +declare module BABYLON.Internals { /** - * This class implement a typical dictionary using a string as key and the generic type T as value. - * The underlying implementation relies on an associative array to ensure the best performances. - * The value can be anything including 'null' but except 'undefined' + * 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/ */ - class StringDictionary { - /** - * This will clear this dictionary and copy the content from the 'source' one. - * If the T value is a custom object, it won't be copied/cloned, the same object will be used - * @param source the dictionary to take the content from and copy to this dictionary - */ - copyFrom(source: StringDictionary): void; - /** - * Get a value based from its key - * @param key the given key to get the matching value from - * @return the value if found, otherwise undefined is returned - */ - get(key: string): T; - /** - * Get a value from its key or add it if it doesn't exist. - * This method will ensure you that a given key/data will be present in the dictionary. - * @param key the given key to get the matching value from - * @param factory the factory that will create the value if the key is not present in the dictionary. - * The factory will only be invoked if there's no data for the given key. - * @return the value corresponding to the key. - */ - getOrAddWithFactory(key: string, factory: (key: string) => T): T; - /** - * Get a value from its key if present in the dictionary otherwise add it - * @param key the key to get the value from - * @param val if there's no such key/value pair in the dictionary add it with this value - * @return the value corresponding to the key - */ - getOrAdd(key: string, val: T): T; - /** - * Check if there's a given key in the dictionary - * @param key the key to check for - * @return true if the key is present, false otherwise - */ - contains(key: any): boolean; - /** - * Add a new key and its corresponding value - * @param key the key to add - * @param value the value corresponding to the key - * @return true if the operation completed successfully, false if we couldn't insert the key/value because there was already this key in the dictionary - */ - add(key: string, value: T): boolean; - set(key: string, value: T): boolean; - /** - * Get the element of the given key and remove it from the dictionary - * @param key - */ - getAndRemove(key: string): T; - /** - * Remove a key/value from the dictionary. - * @param key the key to remove - * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary - */ - remove(key: string): boolean; - /** - * Clear the whole content of the dictionary - */ - clear(): void; - readonly count: number; - /** - * Execute a callback on each key/val of the dictionary. - * Note that you can remove any element in this dictionary in the callback implementation - * @param callback the callback to execute on a given key/value pair - */ - forEach(callback: (key: string, val: T) => void): void; + class KhronosTextureContainer { + arrayBuffer: any; + static HEADER_LEN: number; + static COMPRESSED_2D: number; + static COMPRESSED_3D: number; + static TEX_2D: number; + static TEX_3D: number; + glType: number; + glTypeSize: number; + glFormat: number; + glInternalFormat: number; + glBaseInternalFormat: number; + pixelWidth: number; + pixelHeight: number; + pixelDepth: number; + numberOfArrayElements: number; + numberOfFaces: number; + numberOfMipmapLevels: number; + bytesOfKeyValueData: number; + loadType: number; /** - * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object. - * If the callback returns null or undefined the method will iterate to the next key/value pair - * Note that you can remove any element in this dictionary in the callback implementation - * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned - */ - first(callback: (key: string, val: T) => TRes): TRes; - private _count; - private _data; - } -} - -declare module BABYLON { - class Tags { - static EnableFor(obj: any): void; - static DisableFor(obj: any): void; - static HasTags(obj: any): boolean; - static GetTags(obj: any, asString?: boolean): any; - static AddTagsTo(obj: any, tagsString: string): void; - static _AddTagTo(obj: any, tag: string): void; - static RemoveTagsFrom(obj: any, tagsString: string): void; - static _RemoveTagFrom(obj: any, tag: string): void; - static MatchesQuery(obj: any, tagsQuery: string): boolean; - } -} - -declare module BABYLON { - class TextureTools { + * @param {ArrayBuffer} arrayBuffer- contents of the KTX container file + * @param {number} facesExpected- should be either 1 or 6, based whether a cube texture or or + * @param {boolean} threeDExpected- provision for indicating that data should be a 3D texture, not implemented + * @param {boolean} textureArrayExpected- provision for indicating that data should be a texture array, not implemented + */ + constructor(arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean); + switchEndainness(val: number): number; /** - * Uses the GPU to create a copy texture rescaled at a given size - * @param texture Texture to copy from - * @param width Desired width - * @param height Desired height - * @return Generated texture + * It is assumed that the texture has already been created & is currently bound */ - static CreateResizedCopy(texture: BABYLON.Texture, width: number, height: number, useBilinearMode?: boolean): BABYLON.Texture; - static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture; - private static _environmentBRDFBase64Texture; - } -} - -declare module BABYLON.Internals { - class TGATools { - private static _TYPE_NO_DATA; - private static _TYPE_INDEXED; - private static _TYPE_RGB; - private static _TYPE_GREY; - private static _TYPE_RLE_INDEXED; - private static _TYPE_RLE_RGB; - private static _TYPE_RLE_GREY; - private static _ORIGIN_MASK; - private static _ORIGIN_SHIFT; - private static _ORIGIN_BL; - private static _ORIGIN_BR; - private static _ORIGIN_UL; - private static _ORIGIN_UR; - static GetTGAHeader(data: Uint8Array): any; - static UploadContent(gl: WebGLRenderingContext, data: Uint8Array): void; - static _getImageData8bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array; - static _getImageData16bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array; - static _getImageData24bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array; - static _getImageData32bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array; - static _getImageDataGrey8bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array; - static _getImageDataGrey16bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array; + uploadLevels(gl: WebGLRenderingContext, loadMipmaps: boolean): void; + private _upload2DCompressedLevels(gl, loadMipmaps); } } declare module BABYLON { - interface IAnimatable { - animations: Array; - } - class Tools { - static BaseUrl: string; - static CorsBehavior: any; - static UseFallbackTexture: boolean; - private static fallbackTexture; + /** + * A class serves as a medium between the observable and its observers + */ + class EventState { /** - * Interpolates between a and b via alpha - * @param a The lower value (returned when alpha = 0) - * @param b The upper value (returned when alpha = 1) - * @param alpha The interpolation-factor - * @return The mixed value - */ - static Mix(a: number, b: number, alpha: number): number; - static Instantiate(className: string): any; - static SetImmediate(action: () => void): void; - static IsExponentOfTwo(value: number): boolean; + * If the callback of a given Observer set skipNextObservers to true the following observers will be ignored + */ + constructor(mask: number, skipNextObservers?: boolean); + initalize(mask: number, skipNextObservers?: boolean): EventState; /** - * Find the next highest power of two. - * @param x Number to start search from. - * @return Next highest power of two. + * An Observer can set this property to true to prevent subsequent observers of being notified */ - static CeilingPOT(x: number): number; + skipNextObservers: boolean; /** - * Find the next lowest power of two. - * @param x Number to start search from. - * @return Next lowest power of two. + * Get the mask value that were used to trigger the event corresponding to this EventState object */ - static FloorPOT(x: number): number; + mask: number; + } + /** + * Represent an Observer registered to a given Observable object. + */ + class Observer { + callback: (eventData: T, eventState: EventState) => void; + mask: number; + constructor(callback: (eventData: T, eventState: EventState) => void, mask: number); + } + /** + * The Observable class is a simple implementation of the Observable pattern. + * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified. + * This enable a more fine grained execution without having to rely on multiple different Observable objects. + * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08). + * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right. + */ + class Observable { + _observers: Observer[]; + private _eventState; + constructor(); /** - * Find the nearest power of two. - * @param x Number to start search from. - * @return Next nearest power of two. + * Create a new Observer with the specified callback + * @param callback the callback that will be executed for that Observer + * @param mask the mask used to filter observers + * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present. */ - static NearestPOT(x: number): number; - static GetExponentOfTwo(value: number, max: number, mode?: number): number; - static GetFilename(path: string): string; - static GetDOMTextContent(element: HTMLElement): string; - static ToDegrees(angle: number): number; - static ToRadians(angle: number): number; - static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string; - static ExtractMinAndMaxIndexed(positions: number[] | Float32Array, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Vector2): { - minimum: Vector3; - maximum: Vector3; - }; - static ExtractMinAndMax(positions: number[] | Float32Array, start: number, count: number, bias?: Vector2, stride?: number): { - minimum: Vector3; - maximum: Vector3; - }; - static Vector2ArrayFeeder(array: Array | Float32Array): (i: number) => Vector2; - static ExtractMinAndMaxVector2(feeder: (index: number) => Vector2, bias?: Vector2): { - minimum: Vector2; - maximum: Vector2; - }; - static MakeArray(obj: any, allowsNullUndefined?: boolean): Array; - static GetPointerPrefix(): string; + add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean): Observer; /** - * @param func - the function to be called - * @param requester - the object that will request the next frame. Falls back to window. + * Remove an Observer from the Observable object + * @param observer the instance of the Observer to remove. If it doesn't belong to this Observable, false will be returned. */ - static QueueNewFrame(func: any, requester?: any): void; - static RequestFullscreen(element: any): void; - static ExitFullscreen(): void; - static SetCorsBehavior(url: string, img: HTMLImageElement): void; - static CleanUrl(url: string): string; - static LoadImage(url: any, onload: any, onerror: any, database: any): HTMLImageElement; - static LoadFile(url: string, callback: (data: any) => void, progressCallBack?: (data: any) => void, database?: any, useArrayBuffer?: boolean, onError?: (request: XMLHttpRequest) => void): void; + remove(observer: Observer): boolean; /** - * Load a script (identified by an url). When the url returns, the - * content of this file is added into a new script element, attached to the DOM (body element) - */ - static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: () => void): void; - static ReadFileAsDataURL(fileToLoad: any, callback: any, progressCallback: any): void; - static ReadFile(fileToLoad: any, callback: any, progressCallBack: any, useArrayBuffer?: boolean): void; - static FileAsURL(content: string): string; - static Format(value: number, decimals?: number): string; - static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void; - static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void; - static IsEmpty(obj: any): boolean; - static RegisterTopRootEvents(events: { - name: string; - handler: EventListener; - }[]): void; - static UnregisterTopRootEvents(events: { - name: string; - handler: EventListener; - }[]): void; - static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string): void; - static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string): void; - static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void; - static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number): void; - static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean; + * Remove a callback from the Observable object + * @param callback the callback to remove. If it doesn't belong to this Observable, false will be returned. + */ + removeCallback(callback: (eventData: T, eventState: EventState) => void): boolean; /** - * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523 - * Be aware Math.random() could cause collisions, but: - * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide" + * Notify all Observers by calling their respective callback with the given data + * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute + * @param eventData + * @param mask */ - static RandomId(): string; - private static _NoneLogLevel; - private static _MessageLogLevel; - private static _WarningLogLevel; - private static _ErrorLogLevel; - private static _LogCache; - static errorsCount: number; - static OnNewCacheEntry: (entry: string) => void; - static readonly NoneLogLevel: number; - static readonly MessageLogLevel: number; - static readonly WarningLogLevel: number; - static readonly ErrorLogLevel: number; - static readonly AllLogLevel: number; - private static _AddLogEntry(entry); - private static _FormatMessage(message); - private static _LogDisabled(message); - private static _LogEnabled(message); - private static _WarnDisabled(message); - private static _WarnEnabled(message); - private static _ErrorDisabled(message); - private static _ErrorEnabled(message); - static Log: (message: string) => void; - static Warn: (message: string) => void; - static Error: (message: string) => void; - static readonly LogCache: string; - static ClearLogCache(): void; - static LogLevels: number; - private static _PerformanceNoneLogLevel; - private static _PerformanceUserMarkLogLevel; - private static _PerformanceConsoleLogLevel; - private static _performance; - static readonly PerformanceNoneLogLevel: number; - static readonly PerformanceUserMarkLogLevel: number; - static readonly PerformanceConsoleLogLevel: number; - static PerformanceLogLevel: number; - static _StartPerformanceCounterDisabled(counterName: string, condition?: boolean): void; - static _EndPerformanceCounterDisabled(counterName: string, condition?: boolean): void; - static _StartUserMark(counterName: string, condition?: boolean): void; - static _EndUserMark(counterName: string, condition?: boolean): void; - static _StartPerformanceConsole(counterName: string, condition?: boolean): void; - static _EndPerformanceConsole(counterName: string, condition?: boolean): void; - static StartPerformanceCounter: (counterName: string, condition?: boolean) => void; - static EndPerformanceCounter: (counterName: string, condition?: boolean) => void; - static readonly Now: number; + notifyObservers(eventData: T, mask?: number): boolean; /** - * This method will return the name of the class used to create the instance of the given object. - * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator. - * @param object the object to get the class name from - * @return the name of the class, will be "object" for a custom data type not using the @className decorator + * return true is the Observable has at least one Observer registered */ - static GetClassName(object: any, isType?: boolean): string; - static first(array: Array, predicate: (item: T) => boolean): T; + hasObservers(): boolean; + /** + * Clear the list of observers + */ + clear(): void; + /** + * Clone the current observable + */ + clone(): Observable; + /** + * Does this observable handles observer registered with a given mask + * @param {number} trigger - the mask to be tested + * @return {boolean} whether or not one observer registered with the given mask is handeled + **/ + hasSpecificMask(mask?: number): boolean; + } +} + +declare namespace BABYLON { + /** + * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window + */ + class PerformanceMonitor { + private _enabled; + private _rollingFrameTime; + private _lastFrameTimeMs; + private _lastChangeTimeMs; /** - * This method will return the name of the full name of the class, including its owning module (if any). - * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator or implementing a method getClassName():string (in which case the module won't be specified). - * @param object the object to get the class name from - * @return a string that can have two forms: "moduleName.className" if module was specified when the class' Name was registered or "className" if there was not module specified. + * constructor + * @param frameSampleSize The number of samples required to saturate the sliding window */ - static getFullClassName(object: any, isType?: boolean): string; + constructor(frameSampleSize?: number); /** - * This method can be used with hashCodeFromStream when your input is an array of values that are either: number, string, boolean or custom type implementing the getHashCode():number method. - * @param array + * Samples current frame + * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames */ - static arrayOrStringFeeder(array: any): (i: number) => number; + sampleFrame(timeMs?: number): void; /** - * Compute the hashCode of a stream of number - * To compute the HashCode on a string or an Array of data types implementing the getHashCode() method, use the arrayOrStringFeeder method. - * @param feeder a callback that will be called until it returns null, each valid returned values will be used to compute the hash code. - * @return the hash code computed + * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far) + * @return Average frame time in milliseconds */ - static hashCodeFromStream(feeder: (index: number) => number): number; - } - /** - * This class is used to track a performance counter which is number based. - * The user has access to many properties which give statistics of different nature - * - * The implementer can track two kinds of Performance Counter: time and count - * For time you can optionally call fetchNewFrame() to notify the start of a new frame to monitor, then call beginMonitoring() to start and endMonitoring() to record the lapsed time. endMonitoring takes a newFrame parameter for you to specify if the monitored time should be set for a new frame or accumulated to the current frame being monitored. - * For count you first have to call fetchNewFrame() to notify the start of a new frame to monitor, then call addCount() how many time required to increment the count value you monitor. - */ - class PerfCounter { - static Enabled: boolean; + readonly averageFrameTime: number; /** - * Returns the smallest value ever + * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far) + * @return Frame time variance in milliseconds squared */ - readonly min: number; + readonly averageFrameTimeVariance: number; /** - * Returns the biggest value ever + * Returns the frame time of the most recent frame + * @return Frame time in milliseconds */ - readonly max: number; + readonly instantaneousFrameTime: number; /** - * Returns the average value since the performance counter is running + * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far) + * @return Framerate in frames per second */ - readonly average: number; + readonly averageFPS: number; /** - * Returns the average value of the last second the counter was monitored + * Returns the average framerate in frames per second using the most recent frame time + * @return Framerate in frames per second */ - readonly lastSecAverage: number; + readonly instantaneousFPS: number; /** - * Returns the current value + * Returns true if enough samples have been taken to completely fill the sliding window + * @return true if saturated */ - readonly current: number; - readonly total: number; - constructor(); + readonly isSaturated: boolean; /** - * Call this method to start monitoring a new frame. - * This scenario is typically used when you accumulate monitoring time many times for a single frame, you call this method at the start of the frame, then beginMonitoring to start recording and endMonitoring(false) to accumulated the recorded time to the PerfCounter or addCount() to accumulate a monitored count. + * Enables contributions to the sliding window sample set */ - fetchNewFrame(): void; + enable(): void; /** - * Call this method to monitor a count of something (e.g. mesh drawn in viewport count) - * @param newCount the count value to add to the monitored count - * @param fetchResult true when it's the last time in the frame you add to the counter and you wish to update the statistics properties (min/max/average), false if you only want to update statistics. + * Disables contributions to the sliding window sample set + * Samples will not be interpolated over the disabled period */ - addCount(newCount: number, fetchResult: boolean): void; + disable(): void; /** - * Start monitoring this performance counter + * Returns true if sampling is enabled + * @return true if enabled */ - beginMonitoring(): void; + readonly isEnabled: boolean; /** - * Compute the time lapsed since the previous beginMonitoring() call. - * @param newFrame true by default to fetch the result and monitor a new frame, if false the time monitored will be added to the current frame counter + * Resets performance monitor */ - endMonitoring(newFrame?: boolean): void; - private _fetchResult(); - private _startMonitoringTime; - private _min; - private _max; - private _average; - private _current; - private _totalValueCount; - private _totalAccumulated; - private _lastSecAverage; - private _lastSecAccumulated; - private _lastSecTime; - private _lastSecValueCount; + reset(): void; } /** - * Use this className as a decorator on a given class definition to add it a name and optionally its module. - * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name. - * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified - * @param name The name of the class, case should be preserved - * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved. + * RollingAverage + * + * Utility to efficiently compute the rolling average and variance over a sliding window of samples */ - function className(name: string, module?: string): (target: Object) => void; - /** - * An implementation of a loop for asynchronous functions. - */ - class AsyncLoop { - iterations: number; - private _fn; - private _successCallback; - index: number; - private _done; + class RollingAverage { /** - * Constroctor. - * @param iterations the number of iterations. - * @param _fn the function to run each iteration - * @param _successCallback the callback that will be called upon succesful execution - * @param offset starting offset. + * Current average */ - constructor(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number); + average: number; /** - * Execute the next iteration. Must be called after the last iteration was finished. + * Current variance */ - executeNext(): void; + variance: number; + protected _samples: Array; + protected _sampleCount: number; + protected _pos: number; + protected _m2: number; /** - * Break the loop and run the success callback. + * constructor + * @param length The number of samples required to saturate the sliding window */ - breakLoop(): void; + constructor(length: number); /** - * Helper function + * Adds a sample to the sample set + * @param v The sample value */ - static Run(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number): AsyncLoop; + add(v: number): void; /** - * A for-loop that will run a given number of iterations synchronous and the rest async. - * @param iterations total number of iterations - * @param syncedIterations number of synchronous iterations in each async iteration. - * @param fn the function to call each iteration. - * @param callback a success call back that will be called when iterating stops. - * @param breakFunction a break condition (optional) - * @param timeout timeout settings for the setTimeout function. default - 0. - * @constructor + * Returns previously added values or null if outside of history or outside the sliding window domain + * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that + * @return Value previously recorded with add() or null if outside of range */ - static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): void; - } -} - -declare module BABYLON { - enum JoystickAxis { - X = 0, - Y = 1, - Z = 2, - } - class VirtualJoystick { - reverseLeftRight: boolean; - reverseUpDown: boolean; - deltaPosition: Vector3; - pressed: boolean; - private static _globalJoystickIndex; - private static vjCanvas; - private static vjCanvasContext; - private static vjCanvasWidth; - private static vjCanvasHeight; - private static halfWidth; - private static halfHeight; - private _action; - private _axisTargetedByLeftAndRight; - private _axisTargetedByUpAndDown; - private _joystickSensibility; - private _inversedSensibility; - private _rotationSpeed; - private _inverseRotationSpeed; - private _rotateOnAxisRelativeToMesh; - private _joystickPointerID; - private _joystickColor; - private _joystickPointerPos; - private _joystickPreviousPointerPos; - private _joystickPointerStartPos; - private _deltaJoystickVector; - private _leftJoystick; - private _joystickIndex; - private _touches; - private _onPointerDownHandlerRef; - private _onPointerMoveHandlerRef; - private _onPointerUpHandlerRef; - private _onPointerOutHandlerRef; - private _onResize; - constructor(leftJoystick?: boolean); - setJoystickSensibility(newJoystickSensibility: number): void; - private _onPointerDown(e); - private _onPointerMove(e); - private _onPointerUp(e); + history(i: number): number; /** - * Change the color of the virtual joystick - * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000") - */ - setJoystickColor(newColor: string): void; - setActionOnTouch(action: () => any): void; - setAxisForLeftRight(axis: JoystickAxis): void; - setAxisForUpDown(axis: JoystickAxis): void; - private _clearCanvas(); - private _drawVirtualJoystick(); - releaseCanvas(): void; - } -} - -declare module BABYLON { - class ArcRotateCameraGamepadInput implements ICameraInput { - camera: ArcRotateCamera; - gamepad: Gamepad; - private _gamepads; - gamepadRotationSensibility: number; - gamepadMoveSensibility: number; - attachControl(element: HTMLElement, noPreventDefault?: boolean): void; - detachControl(element: HTMLElement): void; - checkInputs(): void; - private _onNewGameConnected(gamepad); - getClassName(): string; - getSimpleName(): string; - } -} - -declare module BABYLON { - class ArcRotateCameraKeyboardMoveInput implements ICameraInput { - camera: ArcRotateCamera; - private _keys; - private _onKeyDown; - private _onKeyUp; - private _onLostFocus; - keysUp: number[]; - keysDown: number[]; - keysLeft: number[]; - keysRight: number[]; - attachControl(element: HTMLElement, noPreventDefault?: boolean): void; - detachControl(element: HTMLElement): void; - checkInputs(): void; - getClassName(): string; - getSimpleName(): string; + * Returns true if enough samples have been taken to completely fill the sliding window + * @return true if sample-set saturated + */ + isSaturated(): boolean; + /** + * Resets the rolling average (equivalent to 0 samples taken so far) + */ + reset(): void; + /** + * Wraps a value around the sample range boundaries + * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned. + * @return Wrapped position in sample range + */ + protected _wrapPosition(i: number): number; } } declare module BABYLON { - class ArcRotateCameraMouseWheelInput implements ICameraInput { - camera: ArcRotateCamera; - private _wheel; - private _observer; - wheelPrecision: number; - attachControl(element: HTMLElement, noPreventDefault?: boolean): void; - detachControl(element: HTMLElement): void; - getClassName(): string; - getSimpleName(): string; + /** + * This class describe a rectangle that were added to the map. + * You have access to its coordinates either in pixel or normalized (UV) + */ + class PackedRect { + constructor(root: RectPackingMap, parent: PackedRect, pos: Vector2, size: Size); + /** + * @returns the position of this node into the map + */ + readonly pos: Vector2; + /** + * @returns the size of the rectangle this node handles + */ + readonly contentSize: Size; + /** + * Retrieve the inner position (considering the margin) and stores it into the res object + * @param res must be a valid Vector2 that will contain the inner position after this call + */ + getInnerPosToRef(res: Vector2): void; + /** + * Retrieve the inner size (considering the margin) and stores it into the res object + * @param res must be a valid Size that will contain the inner size after this call + */ + getInnerSizeToRef(res: Size): void; + /** + * Compute the UV of the top/left, top/right, bottom/right, bottom/left points of the rectangle this node handles into the map + * @returns And array of 4 Vector2, containing UV coordinates for the four corners of the Rectangle into the map + */ + readonly UVs: Vector2[]; + /** + * You may have allocated the PackedRect using over-provisioning (you allocated more than you need in order to prevent frequent deallocations/reallocations) + * and then using only a part of the PackRect. + * This method will return the UVs for this part by given the custom size of what you really use + * @param customSize must be less/equal to the allocated size, UV will be compute from this + */ + getUVsForCustomSize(customSize: Size): Vector2[]; + /** + * Free this rectangle from the map. + * Call this method when you no longer need the rectangle to be in the map. + */ + freeContent(): void; + protected readonly isUsed: boolean; + protected findAndSplitNode(contentSize: Size): PackedRect; + private findNode(size); + private static TpsSize; + private splitNode(contentSize); + private attemptDefrag(); + private clearNode(); + private readonly isRecursiveFree; + protected evalFreeSize(size: number): number; + protected _root: RectPackingMap; + protected _parent: PackedRect; + private _contentSize; + private _initialSize; + private _leftNode; + private _rightNode; + private _bottomNode; + private _pos; + protected _size: Size; } -} - -declare module BABYLON { - class ArcRotateCameraPointersInput implements ICameraInput { - camera: ArcRotateCamera; - buttons: number[]; - angularSensibilityX: number; - angularSensibilityY: number; - pinchPrecision: number; - panningSensibility: number; - private _isPanClick; - pinchInwards: boolean; - private _pointerInput; - private _observer; - private _onMouseMove; - private _onGestureStart; - private _onGesture; - private _MSGestureHandler; - private _onLostFocus; - private _onContextMenu; - attachControl(element: HTMLElement, noPreventDefault?: boolean): void; - detachControl(element: HTMLElement): void; - getClassName(): string; - getSimpleName(): string; + /** + * The purpose of this class is to pack several Rectangles into a big map, while trying to fit everything as optimally as possible. + * This class is typically used to build lightmaps, sprite map or to pack several little textures into a big one. + * Note that this class allows allocated Rectangles to be freed: that is the map is dynamically maintained so you can add/remove rectangle based on their life-cycle. + * In case you need a margin around the allocated rect, specify the amount in the margin argument during construction. + * In such case you will have to rely on innerPositionToRef and innerSizeToRef calls to get the proper size + */ + class RectPackingMap extends PackedRect { + /** + * Create an instance of the object with a dimension using the given size + * @param size The dimension of the rectangle that will contain all the sub ones. + * @param margin The margin (empty space) created (in pixels) around the allocated Rectangles + */ + constructor(size: Size, margin?: number); + /** + * Add a rectangle, finding the best location to store it into the map + * @param size the dimension of the rectangle to store + * @return the Node containing the rectangle information, or null if we couldn't find a free spot + */ + addRect(size: Size): PackedRect; + /** + * Return the current space free normalized between [0;1] + * @returns {} + */ + readonly freeSpace: number; + _margin: number; } } declare module BABYLON { - class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput { - camera: ArcRotateCamera; - alphaCorrection: number; - betaCorrection: number; - gammaCorrection: number; - private _alpha; - private _beta; - private _gamma; - private _dirty; - private _offsetOrientation; - private _deviceOrientationHandler; - constructor(); - attachControl(element: HTMLElement, noPreventDefault?: boolean): void; - _onOrientationEvent(evt: DeviceOrientationEvent): void; - checkInputs(): void; - detachControl(element: HTMLElement): void; - getClassName(): string; - getSimpleName(): string; + class SceneOptimization { + priority: number; + apply: (scene: Scene) => boolean; + constructor(priority?: number); } -} - -declare module BABYLON { - class FreeCameraDeviceOrientationInput implements ICameraInput { - private _camera; - private _screenOrientationAngle; - private _constantTranform; - private _screenQuaternion; - private _alpha; - private _beta; - private _gamma; - constructor(); - camera: FreeCamera; - attachControl(element: HTMLElement, noPreventDefault?: boolean): void; - private _orientationChanged; - private _deviceOrientation; - detachControl(element: HTMLElement): void; - checkInputs(): void; - getClassName(): string; - getSimpleName(): string; + class TextureOptimization extends SceneOptimization { + priority: number; + maximumSize: number; + constructor(priority?: number, maximumSize?: number); + apply: (scene: Scene) => boolean; } -} - -declare module BABYLON { - class FreeCameraGamepadInput implements ICameraInput { - camera: FreeCamera; - gamepad: Gamepad; - private _gamepads; - gamepadAngularSensibility: number; - gamepadMoveSensibility: number; - private _cameraTransform; - private _deltaTransform; - private _vector3; - private _vector2; - attachControl(element: HTMLElement, noPreventDefault?: boolean): void; - detachControl(element: HTMLElement): void; - checkInputs(): void; - private _onNewGameConnected(gamepad); - getClassName(): string; - getSimpleName(): string; + class HardwareScalingOptimization extends SceneOptimization { + priority: number; + maximumScale: number; + private _currentScale; + constructor(priority?: number, maximumScale?: number); + apply: (scene: Scene) => boolean; } -} - -declare module BABYLON { - class FreeCameraKeyboardMoveInput implements ICameraInput { - camera: FreeCamera; - private _keys; - private _onKeyDown; - private _onKeyUp; - keysUp: number[]; - keysDown: number[]; - keysLeft: number[]; - keysRight: number[]; - attachControl(element: HTMLElement, noPreventDefault?: boolean): void; - detachControl(element: HTMLElement): void; - checkInputs(): void; - getClassName(): string; - _onLostFocus(e: FocusEvent): void; - getSimpleName(): string; + class ShadowsOptimization extends SceneOptimization { + apply: (scene: Scene) => boolean; } -} - -declare module BABYLON { - class FreeCameraMouseInput implements ICameraInput { - touchEnabled: boolean; - camera: FreeCamera; - buttons: number[]; - angularSensibility: number; - private _pointerInput; - private _onMouseMove; - private _observer; - private previousPosition; - constructor(touchEnabled?: boolean); - attachControl(element: HTMLElement, noPreventDefault?: boolean): void; - detachControl(element: HTMLElement): void; - getClassName(): string; - getSimpleName(): string; + class PostProcessesOptimization extends SceneOptimization { + apply: (scene: Scene) => boolean; } -} - -declare module BABYLON { - class FreeCameraTouchInput implements ICameraInput { - camera: FreeCamera; - private _offsetX; - private _offsetY; - private _pointerCount; - private _pointerPressed; - private _pointerInput; - private _observer; - private _onLostFocus; - touchAngularSensibility: number; - touchMoveSensibility: number; - attachControl(element: HTMLElement, noPreventDefault?: boolean): void; - detachControl(element: HTMLElement): void; - checkInputs(): void; - getClassName(): string; - getSimpleName(): string; + class LensFlaresOptimization extends SceneOptimization { + apply: (scene: Scene) => boolean; + } + class ParticlesOptimization extends SceneOptimization { + apply: (scene: Scene) => boolean; } -} - -declare module BABYLON { - class FreeCameraVirtualJoystickInput implements ICameraInput { - camera: FreeCamera; - private _leftjoystick; - private _rightjoystick; - getLeftJoystick(): VirtualJoystick; - getRightJoystick(): VirtualJoystick; - checkInputs(): void; - attachControl(element: HTMLElement, noPreventDefault?: boolean): void; - detachControl(element: HTMLElement): void; - getClassName(): string; - getSimpleName(): string; + class RenderTargetsOptimization extends SceneOptimization { + apply: (scene: Scene) => boolean; + } + class MergeMeshesOptimization extends SceneOptimization { + static _UpdateSelectionTree: boolean; + static UpdateSelectionTree: boolean; + private _canBeMerged; + apply: (scene: Scene, updateSelectionTree?: boolean) => boolean; + } + class SceneOptimizerOptions { + targetFrameRate: number; + trackerDuration: number; + optimizations: SceneOptimization[]; + constructor(targetFrameRate?: number, trackerDuration?: number); + static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions; + static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions; + static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions; + } + class SceneOptimizer { + static _CheckCurrentState(scene: Scene, options: SceneOptimizerOptions, currentPriorityLevel: number, onSuccess?: () => void, onFailure?: () => void): void; + static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): void; } } declare module BABYLON { - class VRCameraMetrics { - hResolution: number; - vResolution: number; - hScreenSize: number; - vScreenSize: number; - vScreenCenter: number; - eyeToScreenDistance: number; - lensSeparationDistance: number; - interpupillaryDistance: number; - distortionK: number[]; - chromaAbCorrection: number[]; - postProcessScaleFactor: number; - lensCenterOffset: number; - compensateDistortion: boolean; - readonly aspectRatio: number; - readonly aspectRatioFov: number; - readonly leftHMatrix: Matrix; - readonly rightHMatrix: Matrix; - readonly leftPreViewMatrix: Matrix; - readonly rightPreViewMatrix: Matrix; - static GetDefault(): VRCameraMetrics; + class SceneSerializer { + static ClearCache(): void; + static Serialize(scene: Scene): any; + static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any; } } declare module BABYLON { - class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera { - constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics); - getClassName(): string; - } - class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera { - constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics); - getClassName(): string; - } - class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera { - constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics); - getClassName(): string; + class SmartArray { + data: Array; + length: number; + private _id; + private _duplicateId; + constructor(capacity: number); + push(value: any): void; + forEach(func: (content: T) => void): void; + pushNoDuplicate(value: any): boolean; + sort(compareFn: any): void; + reset(): void; + dispose(): void; + concat(array: any): void; + concatWithNoDuplicate(array: any): void; + indexOf(value: T): number; + contains(value: T): boolean; + private static _GlobalId; } } -declare var HMDVRDevice: any; -declare var VRDisplay: any; -declare var VRFrameData: any; declare module BABYLON { /** - * This is a copy of VRPose. - * IMPORTANT!! The data is right-hand data. - * @export - * @interface DevicePose + * This class implement a typical dictionary using a string as key and the generic type T as value. + * The underlying implementation relies on an associative array to ensure the best performances. + * The value can be anything including 'null' but except 'undefined' */ - interface DevicePose { - readonly position?: Float32Array; - readonly linearVelocity?: Float32Array; - readonly linearAcceleration?: Float32Array; - readonly orientation?: Float32Array; - readonly angularVelocity?: Float32Array; - readonly angularAcceleration?: Float32Array; - } - interface PoseControlled { - position: Vector3; - rotationQuaternion: Quaternion; - devicePosition?: Vector3; - deviceRotationQuaternion: Quaternion; - rawPose: DevicePose; - deviceScaleFactor: number; - updateFromDevice(poseData: DevicePose): any; - } - interface WebVROptions { - trackPosition?: boolean; - positionScale?: number; - displayName?: string; - controllerMeshes?: boolean; - defaultLightningOnControllers?: boolean; - } - class WebVRFreeCamera extends FreeCamera implements PoseControlled { - private webVROptions; - _vrDevice: any; - rawPose: DevicePose; - private _vrEnabled; - private _specsVersion; - private _attached; - private _oldSize; - private _oldHardwareScaleFactor; - private _frameData; - private _quaternionCache; - private _positionOffset; - protected _descendants: Array; - devicePosition: Vector3; - deviceRotationQuaternion: any; - deviceScaleFactor: number; - controllers: Array; - nonVRControllers: Array; - private _onControllersAttached; - private _onNonVRControllerAttached; - rigParenting: boolean; - private _lightOnControllers; - constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions); - onControllersAttached: (controllers: Array) => void; - onNonVRControllerAttached: (controller: Gamepad) => void; - getControllerByName(name: string): WebVRController; - private _leftController; - readonly leftController: WebVRController; - private _rightController; - readonly rightController: WebVRController; - getForwardRay(length?: number): Ray; - _checkInputs(): void; - updateFromDevice(poseData: DevicePose): void; + class StringDictionary { /** - * WebVR's attach control will start broadcasting frames to the device. - * Note that in certain browsers (chrome for example) this function must be called - * within a user-interaction callback. Example: - *
 scene.onPointerDown = function() { camera.attachControl(canvas); }
- * - * @param {HTMLElement} element - * @param {boolean} [noPreventDefault] - * - * @memberOf WebVRFreeCamera + * This will clear this dictionary and copy the content from the 'source' one. + * If the T value is a custom object, it won't be copied/cloned, the same object will be used + * @param source the dictionary to take the content from and copy to this dictionary */ - attachControl(element: HTMLElement, noPreventDefault?: boolean): void; - detachControl(element: HTMLElement): void; - getClassName(): string; - resetToCurrentRotation(): void; - _updateRigCameras(): void; + copyFrom(source: StringDictionary): void; /** - * This function is called by the two RIG cameras. - * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance) + * Get a value based from its key + * @param key the given key to get the matching value from + * @return the value if found, otherwise undefined is returned */ - protected _getWebVRViewMatrix(): Matrix; - protected _getWebVRProjectionMatrix(): Matrix; - initControllers(): void; - } -} - -declare module BABYLON { - interface IOctreeContainer { - blocks: Array>; - } - class Octree { - maxDepth: number; - blocks: Array>; - dynamicContent: T[]; - private _maxBlockCapacity; - private _selectionContent; - private _creationFunc; - constructor(creationFunc: (entry: T, block: OctreeBlock) => void, maxBlockCapacity?: number, maxDepth?: number); - update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void; - addMesh(entry: T): void; - select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray; - intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray; - intersectsRay(ray: Ray): SmartArray; - static _CreateBlocks(worldMin: Vector3, worldMax: Vector3, entries: T[], maxBlockCapacity: number, currentDepth: number, maxDepth: number, target: IOctreeContainer, creationFunc: (entry: T, block: OctreeBlock) => void): void; - static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock) => void; - static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock) => void; + get(key: string): T; + /** + * Get a value from its key or add it if it doesn't exist. + * This method will ensure you that a given key/data will be present in the dictionary. + * @param key the given key to get the matching value from + * @param factory the factory that will create the value if the key is not present in the dictionary. + * The factory will only be invoked if there's no data for the given key. + * @return the value corresponding to the key. + */ + getOrAddWithFactory(key: string, factory: (key: string) => T): T; + /** + * Get a value from its key if present in the dictionary otherwise add it + * @param key the key to get the value from + * @param val if there's no such key/value pair in the dictionary add it with this value + * @return the value corresponding to the key + */ + getOrAdd(key: string, val: T): T; + /** + * Check if there's a given key in the dictionary + * @param key the key to check for + * @return true if the key is present, false otherwise + */ + contains(key: any): boolean; + /** + * Add a new key and its corresponding value + * @param key the key to add + * @param value the value corresponding to the key + * @return true if the operation completed successfully, false if we couldn't insert the key/value because there was already this key in the dictionary + */ + add(key: string, value: T): boolean; + set(key: string, value: T): boolean; + /** + * Get the element of the given key and remove it from the dictionary + * @param key + */ + getAndRemove(key: string): T; + /** + * Remove a key/value from the dictionary. + * @param key the key to remove + * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary + */ + remove(key: string): boolean; + /** + * Clear the whole content of the dictionary + */ + clear(): void; + readonly count: number; + /** + * Execute a callback on each key/val of the dictionary. + * Note that you can remove any element in this dictionary in the callback implementation + * @param callback the callback to execute on a given key/value pair + */ + forEach(callback: (key: string, val: T) => void): void; + /** + * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object. + * If the callback returns null or undefined the method will iterate to the next key/value pair + * Note that you can remove any element in this dictionary in the callback implementation + * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned + */ + first(callback: (key: string, val: T) => TRes): TRes; + private _count; + private _data; } } declare module BABYLON { - class OctreeBlock { - entries: T[]; - blocks: Array>; - private _depth; - private _maxDepth; - private _capacity; - private _minPoint; - private _maxPoint; - private _boundingVectors; - private _creationFunc; - constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock) => void); - readonly capacity: number; - readonly minPoint: Vector3; - readonly maxPoint: Vector3; - addEntry(entry: T): void; - addEntries(entries: T[]): void; - select(frustumPlanes: Plane[], selection: SmartArray, allowDuplicate?: boolean): void; - intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArray, allowDuplicate?: boolean): void; - intersectsRay(ray: Ray, selection: SmartArray): void; - createInnerBlocks(): void; + class Tags { + static EnableFor(obj: any): void; + static DisableFor(obj: any): void; + static HasTags(obj: any): boolean; + static GetTags(obj: any, asString?: boolean): any; + static AddTagsTo(obj: any, tagsString: string): void; + static _AddTagTo(obj: any, tag: string): void; + static RemoveTagsFrom(obj: any, tagsString: string): void; + static _RemoveTagFrom(obj: any, tag: string): void; + static MatchesQuery(obj: any, tagsQuery: string): boolean; + } +} + +declare module BABYLON { + class TextureTools { + /** + * Uses the GPU to create a copy texture rescaled at a given size + * @param texture Texture to copy from + * @param width Desired width + * @param height Desired height + * @return Generated texture + */ + static CreateResizedCopy(texture: BABYLON.Texture, width: number, height: number, useBilinearMode?: boolean): BABYLON.Texture; + static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture; + private static _environmentBRDFBase64Texture; } } declare module BABYLON.Internals { + class TGATools { + private static _TYPE_NO_DATA; + private static _TYPE_INDEXED; + private static _TYPE_RGB; + private static _TYPE_GREY; + private static _TYPE_RLE_INDEXED; + private static _TYPE_RLE_RGB; + private static _TYPE_RLE_GREY; + private static _ORIGIN_MASK; + private static _ORIGIN_SHIFT; + private static _ORIGIN_BL; + private static _ORIGIN_BR; + private static _ORIGIN_UL; + private static _ORIGIN_UR; + static GetTGAHeader(data: Uint8Array): any; + static UploadContent(gl: WebGLRenderingContext, data: Uint8Array): void; + static _getImageData8bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array; + static _getImageData16bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array; + static _getImageData24bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array; + static _getImageData32bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array; + static _getImageDataGrey8bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array; + static _getImageDataGrey16bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array; + } } declare module BABYLON { - /** - * Interface to implement to create a shadow generator compatible with BJS. - */ - interface IShadowGenerator { - getShadowMap(): RenderTargetTexture; - getShadowMapForRendering(): RenderTargetTexture; - isReady(subMesh: SubMesh, useInstances: boolean): boolean; - prepareDefines(defines: MaterialDefines, lightIndex: number): void; - bindShadowLight(lightIndex: string, effect: Effect): void; - getTransformMatrix(): Matrix; - recreateShadowMap(): void; - forceCompilation(onCompiled: (generator: ShadowGenerator) => void, options?: { - useInstances: boolean; - }): void; - serialize(): any; - dispose(): void; + interface IAnimatable { + animations: Array; } - class ShadowGenerator implements IShadowGenerator { - private static _FILTER_NONE; - private static _FILTER_EXPONENTIALSHADOWMAP; - private static _FILTER_POISSONSAMPLING; - private static _FILTER_BLUREXPONENTIALSHADOWMAP; - private static _FILTER_CLOSEEXPONENTIALSHADOWMAP; - private static _FILTER_BLURCLOSEEXPONENTIALSHADOWMAP; - static readonly FILTER_NONE: number; - static readonly FILTER_POISSONSAMPLING: number; - static readonly FILTER_EXPONENTIALSHADOWMAP: number; - static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number; - static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number; - static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number; - private _bias; - bias: number; - private _blurBoxOffset; - blurBoxOffset: number; - private _blurScale; - blurScale: number; - private _blurKernel; - blurKernel: number; - private _useKernelBlur; - useKernelBlur: boolean; - private _depthScale; - depthScale: number; - private _filter; - filter: number; - usePoissonSampling: boolean; - useVarianceShadowMap: boolean; - useBlurVarianceShadowMap: boolean; - useExponentialShadowMap: boolean; - useBlurExponentialShadowMap: boolean; - useCloseExponentialShadowMap: boolean; - useBlurCloseExponentialShadowMap: boolean; - private _darkness; - /** - * Returns the darkness value (float). - */ - getDarkness(): number; - /** - * Sets the ShadowGenerator darkness value (float <= 1.0). - * Returns the ShadowGenerator. - */ - setDarkness(darkness: number): ShadowGenerator; - private _transparencyShadow; - /** - * Sets the ability to have transparent shadow (boolean). - * Returns the ShadowGenerator. - */ - setTransparencyShadow(hasShadow: boolean): ShadowGenerator; - private _shadowMap; - private _shadowMap2; - /** - * Returns a RenderTargetTexture object : the shadow map texture. - */ - getShadowMap(): RenderTargetTexture; - /** - * Returns the most ready computed shadow map as a RenderTargetTexture object. - */ - getShadowMapForRendering(): RenderTargetTexture; + class Tools { + static BaseUrl: string; + static CorsBehavior: any; + static UseFallbackTexture: boolean; + private static fallbackTexture; /** - * Controls the extent to which the shadows fade out at the edge of the frustum - * Used only by directionals and spots + * Interpolates between a and b via alpha + * @param a The lower value (returned when alpha = 0) + * @param b The upper value (returned when alpha = 1) + * @param alpha The interpolation-factor + * @return The mixed value */ - frustumEdgeFalloff: number; - private _light; + static Mix(a: number, b: number, alpha: number): number; + static Instantiate(className: string): any; + static SetImmediate(action: () => void): void; + static IsExponentOfTwo(value: number): boolean; /** - * Returns the associated light object. + * Find the next highest power of two. + * @param x Number to start search from. + * @return Next highest power of two. */ - getLight(): IShadowLight; - forceBackFacesOnly: boolean; - private _scene; - private _lightDirection; - private _effect; - private _viewMatrix; - private _projectionMatrix; - private _transformMatrix; - private _worldViewProjection; - private _cachedPosition; - private _cachedDirection; - private _cachedDefines; - private _currentRenderID; - private _downSamplePostprocess; - private _boxBlurPostprocess; - private _kernelBlurXPostprocess; - private _kernelBlurYPostprocess; - private _blurPostProcesses; - private _mapSize; - private _currentFaceIndex; - private _currentFaceIndexCache; - private _textureType; - private _isCube; - private _defaultTextureMatrix; + static CeilingPOT(x: number): number; /** - * Creates a ShadowGenerator object. - * A ShadowGenerator is the required tool to use the shadows. - * Each light casting shadows needs to use its own ShadowGenerator. - * Required parameters : - * - `mapSize` (integer): the size of the texture what stores the shadows. Example : 1024. - * - `light`: the light object generating the shadows. - * - `useFullFloatFirst`: by default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture. - * Documentation : http://doc.babylonjs.com/tutorials/shadows + * Find the next lowest power of two. + * @param x Number to start search from. + * @return Next lowest power of two. */ - constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean); - private _initializeGenerator(); - private _initializeShadowMap(); - private _initializeBlurRTTAndPostProcesses(); - private _renderForShadowMap(opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes); - private _renderSubMeshForShadowMap(subMesh); - private _applyFilterValues(); + static FloorPOT(x: number): number; /** - * Force shader compilation including textures ready check + * Find the nearest power of two. + * @param x Number to start search from. + * @return Next nearest power of two. */ - forceCompilation(onCompiled: (generator: ShadowGenerator) => void, options?: { - useInstances: boolean; - }): void; + static NearestPOT(x: number): number; + static GetExponentOfTwo(value: number, max: number, mode?: number): number; + static GetFilename(path: string): string; + static GetDOMTextContent(element: HTMLElement): string; + static ToDegrees(angle: number): number; + static ToRadians(angle: number): number; + static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string; + static ExtractMinAndMaxIndexed(positions: number[] | Float32Array, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Vector2): { + minimum: Vector3; + maximum: Vector3; + }; + static ExtractMinAndMax(positions: number[] | Float32Array, start: number, count: number, bias?: Vector2, stride?: number): { + minimum: Vector3; + maximum: Vector3; + }; + static Vector2ArrayFeeder(array: Array | Float32Array): (i: number) => Vector2; + static ExtractMinAndMaxVector2(feeder: (index: number) => Vector2, bias?: Vector2): { + minimum: Vector2; + maximum: Vector2; + }; + static MakeArray(obj: any, allowsNullUndefined?: boolean): Array; + static GetPointerPrefix(): string; /** - * Boolean : true when the ShadowGenerator is finally computed. + * @param func - the function to be called + * @param requester - the object that will request the next frame. Falls back to window. */ - isReady(subMesh: SubMesh, useInstances: boolean): boolean; + static QueueNewFrame(func: any, requester?: any): void; + static RequestFullscreen(element: any): void; + static ExitFullscreen(): void; + static SetCorsBehavior(url: string, img: HTMLImageElement): void; + static CleanUrl(url: string): string; + static LoadImage(url: any, onload: any, onerror: any, database: any): HTMLImageElement; + static LoadFile(url: string, callback: (data: any) => void, progressCallBack?: (data: any) => void, database?: any, useArrayBuffer?: boolean, onError?: (request: XMLHttpRequest) => void): void; /** - * This creates the defines related to the standard BJS materials. + * Load a script (identified by an url). When the url returns, the + * content of this file is added into a new script element, attached to the DOM (body element) */ - prepareDefines(defines: MaterialDefines, lightIndex: number): void; + static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: () => void): void; + static ReadFileAsDataURL(fileToLoad: any, callback: any, progressCallback: any): void; + static ReadFile(fileToLoad: any, callback: any, progressCallBack: any, useArrayBuffer?: boolean): void; + static FileAsURL(content: string): string; + static Format(value: number, decimals?: number): string; + static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void; + static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void; + static IsEmpty(obj: any): boolean; + static RegisterTopRootEvents(events: { + name: string; + handler: EventListener; + }[]): void; + static UnregisterTopRootEvents(events: { + name: string; + handler: EventListener; + }[]): void; + static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string): void; + static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string): void; + static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void; + static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number): void; + static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean; /** - * This binds shadow lights related to the standard BJS materials. - * It implies the unifroms available on the materials are the standard BJS ones. + * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523 + * Be aware Math.random() could cause collisions, but: + * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide" */ - bindShadowLight(lightIndex: string, effect: Effect): void; + static RandomId(): string; + private static _NoneLogLevel; + private static _MessageLogLevel; + private static _WarningLogLevel; + private static _ErrorLogLevel; + private static _LogCache; + static errorsCount: number; + static OnNewCacheEntry: (entry: string) => void; + static readonly NoneLogLevel: number; + static readonly MessageLogLevel: number; + static readonly WarningLogLevel: number; + static readonly ErrorLogLevel: number; + static readonly AllLogLevel: number; + private static _AddLogEntry(entry); + private static _FormatMessage(message); + private static _LogDisabled(message); + private static _LogEnabled(message); + private static _WarnDisabled(message); + private static _WarnEnabled(message); + private static _ErrorDisabled(message); + private static _ErrorEnabled(message); + static Log: (message: string) => void; + static Warn: (message: string) => void; + static Error: (message: string) => void; + static readonly LogCache: string; + static ClearLogCache(): void; + static LogLevels: number; + private static _PerformanceNoneLogLevel; + private static _PerformanceUserMarkLogLevel; + private static _PerformanceConsoleLogLevel; + private static _performance; + static readonly PerformanceNoneLogLevel: number; + static readonly PerformanceUserMarkLogLevel: number; + static readonly PerformanceConsoleLogLevel: number; + static PerformanceLogLevel: number; + static _StartPerformanceCounterDisabled(counterName: string, condition?: boolean): void; + static _EndPerformanceCounterDisabled(counterName: string, condition?: boolean): void; + static _StartUserMark(counterName: string, condition?: boolean): void; + static _EndUserMark(counterName: string, condition?: boolean): void; + static _StartPerformanceConsole(counterName: string, condition?: boolean): void; + static _EndPerformanceConsole(counterName: string, condition?: boolean): void; + static StartPerformanceCounter: (counterName: string, condition?: boolean) => void; + static EndPerformanceCounter: (counterName: string, condition?: boolean) => void; + static readonly Now: number; /** - * Returns a Matrix object : the updated transformation matrix. + * This method will return the name of the class used to create the instance of the given object. + * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator. + * @param object the object to get the class name from + * @return the name of the class, will be "object" for a custom data type not using the @className decorator */ - getTransformMatrix(): Matrix; - recreateShadowMap(): void; - private _disposeBlurPostProcesses(); - private _disposeRTTandPostProcesses(); + static GetClassName(object: any, isType?: boolean): string; + static first(array: Array, predicate: (item: T) => boolean): T; /** - * Disposes the ShadowGenerator. - * Returns nothing. + * This method will return the name of the full name of the class, including its owning module (if any). + * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator or implementing a method getClassName():string (in which case the module won't be specified). + * @param object the object to get the class name from + * @return a string that can have two forms: "moduleName.className" if module was specified when the class' Name was registered or "className" if there was not module specified. */ - dispose(): void; + static getFullClassName(object: any, isType?: boolean): string; /** - * Serializes the ShadowGenerator and returns a serializationObject. + * This method can be used with hashCodeFromStream when your input is an array of values that are either: number, string, boolean or custom type implementing the getHashCode():number method. + * @param array */ - serialize(): any; + static arrayOrStringFeeder(array: any): (i: number) => number; /** - * Parses a serialized ShadowGenerator and returns a new ShadowGenerator. + * Compute the hashCode of a stream of number + * To compute the HashCode on a string or an Array of data types implementing the getHashCode() method, use the arrayOrStringFeeder method. + * @param feeder a callback that will be called until it returns null, each valid returned values will be used to compute the hash code. + * @return the hash code computed */ - static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator; - } -} - -declare module BABYLON { - class BaseTexture { - static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number; - name: string; - private _hasAlpha; - hasAlpha: boolean; - getAlphaFromRGB: boolean; - level: number; - coordinatesIndex: number; - private _coordinatesMode; - coordinatesMode: number; - wrapU: number; - wrapV: number; - anisotropicFilteringLevel: number; - isCube: boolean; - gammaSpace: boolean; - invertZ: boolean; - lodLevelInAlpha: boolean; - lodGenerationOffset: number; - lodGenerationScale: number; - isRenderTarget: boolean; - readonly uid: string; - toString(): string; - getClassName(): string; - animations: Animation[]; - /** - * An event triggered when the texture is disposed. - * @type {BABYLON.Observable} - */ - onDisposeObservable: Observable; - private _onDisposeObserver; - onDispose: () => void; - delayLoadState: number; - _cachedAnisotropicFilteringLevel: number; - private _scene; - _texture: WebGLTexture; - private _uid; - readonly isBlocking: boolean; - constructor(scene: Scene); - getScene(): Scene; - getTextureMatrix(): Matrix; - getReflectionTextureMatrix(): Matrix; - getInternalTexture(): WebGLTexture; - isReadyOrNotBlocking(): boolean; - isReady(): boolean; - getSize(): ISize; - getBaseSize(): ISize; - scale(ratio: number): void; - readonly canRescale: boolean; - _removeFromCache(url: string, noMipmap: boolean): void; - _getFromCache(url: string, noMipmap: boolean, sampling?: number): WebGLTexture; - delayLoad(): void; - clone(): BaseTexture; - readonly textureType: number; - readonly textureFormat: number; - readPixels(faceIndex?: number): ArrayBufferView; - releaseInternalTexture(): void; - sphericalPolynomial: SphericalPolynomial; - readonly _lodTextureHigh: BaseTexture; - readonly _lodTextureMid: BaseTexture; - readonly _lodTextureLow: BaseTexture; - dispose(): void; - serialize(): any; - static WhenAllReady(textures: BaseTexture[], callback: () => void): void; + static hashCodeFromStream(feeder: (index: number) => number): number; } -} - -declare module BABYLON { /** - * This represents a color grading texture. This acts as a lookup table LUT, useful during post process - * It can help converting any input color in a desired output one. This can then be used to create effects - * from sepia, black and white to sixties or futuristic rendering... + * This class is used to track a performance counter which is number based. + * The user has access to many properties which give statistics of different nature * - * The only supported format is currently 3dl. - * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table/ + * The implementer can track two kinds of Performance Counter: time and count + * For time you can optionally call fetchNewFrame() to notify the start of a new frame to monitor, then call beginMonitoring() to start and endMonitoring() to record the lapsed time. endMonitoring takes a newFrame parameter for you to specify if the monitored time should be set for a new frame or accumulated to the current frame being monitored. + * For count you first have to call fetchNewFrame() to notify the start of a new frame to monitor, then call addCount() how many time required to increment the count value you monitor. */ - class ColorGradingTexture extends BaseTexture { + class PerfCounter { + static Enabled: boolean; /** - * The current internal texture size. + * Returns the smallest value ever */ - private _size; + readonly min: number; /** - * The current texture matrix. (will always be identity in color grading texture) + * Returns the biggest value ever */ - private _textureMatrix; + readonly max: number; /** - * The texture URL. + * Returns the average value since the performance counter is running */ - url: string; + readonly average: number; /** - * Empty line regex stored for GC. + * Returns the average value of the last second the counter was monitored */ - private static _noneEmptyLineRegex; + readonly lastSecAverage: number; /** - * Instantiates a ColorGradingTexture from the following parameters. - * - * @param url The location of the color gradind data (currently only supporting 3dl) - * @param scene The scene the texture will be used in + * Returns the current value */ - constructor(url: string, scene: Scene); + readonly current: number; + readonly total: number; + constructor(); /** - * Returns the texture matrix used in most of the material. - * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in). + * Call this method to start monitoring a new frame. + * This scenario is typically used when you accumulate monitoring time many times for a single frame, you call this method at the start of the frame, then beginMonitoring to start recording and endMonitoring(false) to accumulated the recorded time to the PerfCounter or addCount() to accumulate a monitored count. */ - getTextureMatrix(): Matrix; + fetchNewFrame(): void; + /** + * Call this method to monitor a count of something (e.g. mesh drawn in viewport count) + * @param newCount the count value to add to the monitored count + * @param fetchResult true when it's the last time in the frame you add to the counter and you wish to update the statistics properties (min/max/average), false if you only want to update statistics. + */ + addCount(newCount: number, fetchResult: boolean): void; + /** + * Start monitoring this performance counter + */ + beginMonitoring(): void; + /** + * Compute the time lapsed since the previous beginMonitoring() call. + * @param newFrame true by default to fetch the result and monitor a new frame, if false the time monitored will be added to the current frame counter + */ + endMonitoring(newFrame?: boolean): void; + private _fetchResult(); + private _startMonitoringTime; + private _min; + private _max; + private _average; + private _current; + private _totalValueCount; + private _totalAccumulated; + private _lastSecAverage; + private _lastSecAccumulated; + private _lastSecTime; + private _lastSecValueCount; + } + /** + * Use this className as a decorator on a given class definition to add it a name and optionally its module. + * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name. + * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified + * @param name The name of the class, case should be preserved + * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved. + */ + function className(name: string, module?: string): (target: Object) => void; + /** + * An implementation of a loop for asynchronous functions. + */ + class AsyncLoop { + iterations: number; + private _fn; + private _successCallback; + index: number; + private _done; /** - * Occurs when the file being loaded is a .3dl LUT file. + * Constroctor. + * @param iterations the number of iterations. + * @param _fn the function to run each iteration + * @param _successCallback the callback that will be called upon succesful execution + * @param offset starting offset. */ - private load3dlTexture(); + constructor(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number); /** - * Starts the loading process of the texture. + * Execute the next iteration. Must be called after the last iteration was finished. */ - private loadTexture(); + executeNext(): void; /** - * Clones the color gradind texture. + * Break the loop and run the success callback. */ - clone(): ColorGradingTexture; + breakLoop(): void; /** - * Called during delayed load for textures. + * Helper function */ - delayLoad(): void; + static Run(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number): AsyncLoop; /** - * Parses a color grading texture serialized by Babylon. - * @param parsedTexture The texture information being parsedTexture - * @param scene The scene to load the texture in - * @param rootUrl The root url of the data assets to load - * @return A color gradind texture + * A for-loop that will run a given number of iterations synchronous and the rest async. + * @param iterations total number of iterations + * @param syncedIterations number of synchronous iterations in each async iteration. + * @param fn the function to call each iteration. + * @param callback a success call back that will be called when iterating stops. + * @param breakFunction a break condition (optional) + * @param timeout timeout settings for the setTimeout function. default - 0. + * @constructor */ - static Parse(parsedTexture: any, scene: Scene, rootUrl: string): ColorGradingTexture; + static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): void; + } +} + +declare module BABYLON { + enum JoystickAxis { + X = 0, + Y = 1, + Z = 2, + } + class VirtualJoystick { + reverseLeftRight: boolean; + reverseUpDown: boolean; + deltaPosition: Vector3; + pressed: boolean; + private static _globalJoystickIndex; + private static vjCanvas; + private static vjCanvasContext; + private static vjCanvasWidth; + private static vjCanvasHeight; + private static halfWidth; + private static halfHeight; + private _action; + private _axisTargetedByLeftAndRight; + private _axisTargetedByUpAndDown; + private _joystickSensibility; + private _inversedSensibility; + private _rotationSpeed; + private _inverseRotationSpeed; + private _rotateOnAxisRelativeToMesh; + private _joystickPointerID; + private _joystickColor; + private _joystickPointerPos; + private _joystickPreviousPointerPos; + private _joystickPointerStartPos; + private _deltaJoystickVector; + private _leftJoystick; + private _joystickIndex; + private _touches; + private _onPointerDownHandlerRef; + private _onPointerMoveHandlerRef; + private _onPointerUpHandlerRef; + private _onPointerOutHandlerRef; + private _onResize; + constructor(leftJoystick?: boolean); + setJoystickSensibility(newJoystickSensibility: number): void; + private _onPointerDown(e); + private _onPointerMove(e); + private _onPointerUp(e); /** - * Serializes the LUT texture to json format. - */ - serialize(): any; + * Change the color of the virtual joystick + * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000") + */ + setJoystickColor(newColor: string): void; + setActionOnTouch(action: () => any): void; + setAxisForLeftRight(axis: JoystickAxis): void; + setAxisForUpDown(axis: JoystickAxis): void; + private _clearCanvas(); + private _drawVirtualJoystick(); + releaseCanvas(): void; + } +} + +declare module BABYLON { + class ArcRotateCameraGamepadInput implements ICameraInput { + camera: ArcRotateCamera; + gamepad: Gamepad; + private _gamepads; + gamepadRotationSensibility: number; + gamepadMoveSensibility: number; + attachControl(element: HTMLElement, noPreventDefault?: boolean): void; + detachControl(element: HTMLElement): void; + checkInputs(): void; + private _onNewGameConnected(gamepad); + getClassName(): string; + getSimpleName(): string; + } +} + +declare module BABYLON { + class ArcRotateCameraKeyboardMoveInput implements ICameraInput { + camera: ArcRotateCamera; + private _keys; + private _onKeyDown; + private _onKeyUp; + private _onLostFocus; + keysUp: number[]; + keysDown: number[]; + keysLeft: number[]; + keysRight: number[]; + attachControl(element: HTMLElement, noPreventDefault?: boolean): void; + detachControl(element: HTMLElement): void; + checkInputs(): void; + getClassName(): string; + getSimpleName(): string; + } +} + +declare module BABYLON { + class ArcRotateCameraMouseWheelInput implements ICameraInput { + camera: ArcRotateCamera; + private _wheel; + private _observer; + wheelPrecision: number; + attachControl(element: HTMLElement, noPreventDefault?: boolean): void; + detachControl(element: HTMLElement): void; + getClassName(): string; + getSimpleName(): string; + } +} + +declare module BABYLON { + class ArcRotateCameraPointersInput implements ICameraInput { + camera: ArcRotateCamera; + buttons: number[]; + angularSensibilityX: number; + angularSensibilityY: number; + pinchPrecision: number; + panningSensibility: number; + private _isPanClick; + pinchInwards: boolean; + private _pointerInput; + private _observer; + private _onMouseMove; + private _onGestureStart; + private _onGesture; + private _MSGestureHandler; + private _onLostFocus; + private _onContextMenu; + attachControl(element: HTMLElement, noPreventDefault?: boolean): void; + detachControl(element: HTMLElement): void; + getClassName(): string; + getSimpleName(): string; + } +} + +declare module BABYLON { + class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput { + camera: ArcRotateCamera; + alphaCorrection: number; + betaCorrection: number; + gammaCorrection: number; + private _alpha; + private _beta; + private _gamma; + private _dirty; + private _offsetOrientation; + private _deviceOrientationHandler; + constructor(); + attachControl(element: HTMLElement, noPreventDefault?: boolean): void; + _onOrientationEvent(evt: DeviceOrientationEvent): void; + checkInputs(): void; + detachControl(element: HTMLElement): void; + getClassName(): string; + getSimpleName(): string; + } +} + +declare module BABYLON { + class FreeCameraDeviceOrientationInput implements ICameraInput { + private _camera; + private _screenOrientationAngle; + private _constantTranform; + private _screenQuaternion; + private _alpha; + private _beta; + private _gamma; + constructor(); + camera: FreeCamera; + attachControl(element: HTMLElement, noPreventDefault?: boolean): void; + private _orientationChanged; + private _deviceOrientation; + detachControl(element: HTMLElement): void; + checkInputs(): void; + getClassName(): string; + getSimpleName(): string; + } +} + +declare module BABYLON { + class FreeCameraGamepadInput implements ICameraInput { + camera: FreeCamera; + gamepad: Gamepad; + private _gamepads; + gamepadAngularSensibility: number; + gamepadMoveSensibility: number; + private _cameraTransform; + private _deltaTransform; + private _vector3; + private _vector2; + attachControl(element: HTMLElement, noPreventDefault?: boolean): void; + detachControl(element: HTMLElement): void; + checkInputs(): void; + private _onNewGameConnected(gamepad); + getClassName(): string; + getSimpleName(): string; + } +} + +declare module BABYLON { + class FreeCameraKeyboardMoveInput implements ICameraInput { + camera: FreeCamera; + private _keys; + private _onKeyDown; + private _onKeyUp; + keysUp: number[]; + keysDown: number[]; + keysLeft: number[]; + keysRight: number[]; + attachControl(element: HTMLElement, noPreventDefault?: boolean): void; + detachControl(element: HTMLElement): void; + checkInputs(): void; + getClassName(): string; + _onLostFocus(e: FocusEvent): void; + getSimpleName(): string; } } declare module BABYLON { - class CubeTexture extends BaseTexture { - url: string; - coordinatesMode: number; - private _noMipmap; - private _files; - private _extensions; - private _textureMatrix; - private _format; - private _prefiltered; - static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture; - static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any): CubeTexture; - constructor(rootUrl: string, scene: Scene, extensions?: string[], noMipmap?: boolean, files?: string[], onLoad?: () => void, onError?: () => void, format?: number, prefiltered?: boolean, forcedExtension?: any); - delayLoad(): void; - getReflectionTextureMatrix(): Matrix; - setReflectionTextureMatrix(value: Matrix): void; - static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture; - clone(): CubeTexture; + class FreeCameraMouseInput implements ICameraInput { + touchEnabled: boolean; + camera: FreeCamera; + buttons: number[]; + angularSensibility: number; + private _pointerInput; + private _onMouseMove; + private _observer; + private previousPosition; + constructor(touchEnabled?: boolean); + attachControl(element: HTMLElement, noPreventDefault?: boolean): void; + detachControl(element: HTMLElement): void; + getClassName(): string; + getSimpleName(): string; } } declare module BABYLON { - class DynamicTexture extends Texture { - private _generateMipMaps; - private _canvas; - private _context; - constructor(name: string, options: any, scene: Scene, generateMipMaps: boolean, samplingMode?: number, format?: number); - readonly canRescale: boolean; - private _recreate(textureSize); - scale(ratio: number): void; - scaleTo(width: number, height: number): void; - getContext(): CanvasRenderingContext2D; - clear(): void; - update(invertY?: boolean): void; - drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void; - clone(): DynamicTexture; + class FreeCameraTouchInput implements ICameraInput { + camera: FreeCamera; + private _offsetX; + private _offsetY; + private _pointerCount; + private _pointerPressed; + private _pointerInput; + private _observer; + private _onLostFocus; + touchAngularSensibility: number; + touchMoveSensibility: number; + attachControl(element: HTMLElement, noPreventDefault?: boolean): void; + detachControl(element: HTMLElement): void; + checkInputs(): void; + getClassName(): string; + getSimpleName(): string; } } declare module BABYLON { - /** - * This represents a texture coming from an HDR input. - * - * The only supported format is currently panorama picture stored in RGBE format. - * Example of such files can be found on HDRLib: http://hdrlib.com/ - */ - class HDRCubeTexture extends BaseTexture { - private static _facesMapping; - private _useInGammaSpace; - private _generateHarmonics; - private _noMipmap; - private _extensions; - private _textureMatrix; - private _size; - private _usePMREMGenerator; - private _isBABYLONPreprocessed; - private _onLoad; - private _onError; - /** - * The texture URL. - */ - url: string; - /** - * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. - */ - coordinatesMode: number; - /** - * Specifies wether the texture has been generated through the PMREMGenerator tool. - * This is usefull at run time to apply the good shader. - */ - isPMREM: boolean; - protected _isBlocking: boolean; - /** - * Gets wether or not the texture is blocking during loading. - */ - /** - * Sets wether or not the texture is blocking during loading. - */ - isBlocking: boolean; - /** - * Instantiates an HDRTexture from the following parameters. - * - * @param url The location of the HDR raw data (Panorama stored in RGBE format) - * @param scene The scene the texture will be used in - * @param size The cubemap desired size (the more it increases the longer the generation will be) If the size is omitted this implies you are using a preprocessed cubemap. - * @param noMipmap Forces to not generate the mipmap if true - * @param generateHarmonics Specifies wether you want to extract the polynomial harmonics during the generation process - * @param useInGammaSpace Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) - * @param usePMREMGenerator Specifies wether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time. - */ - constructor(url: string, scene: Scene, size?: number, noMipmap?: boolean, generateHarmonics?: boolean, useInGammaSpace?: boolean, usePMREMGenerator?: boolean, onLoad?: () => void, onError?: () => void); - /** - * Occurs when the file is a preprocessed .babylon.hdr file. - */ - private loadBabylonTexture(); - /** - * Occurs when the file is raw .hdr file. - */ - private loadHDRTexture(); - /** - * Starts the loading process of the texture. - */ - private loadTexture(); - clone(): HDRCubeTexture; - delayLoad(): void; - getReflectionTextureMatrix(): Matrix; - setReflectionTextureMatrix(value: Matrix): void; - static Parse(parsedTexture: any, scene: Scene, rootUrl: string): HDRCubeTexture; - serialize(): any; - /** - * Saves as a file the data contained in the texture in a binary format. - * This can be used to prevent the long loading tie associated with creating the seamless texture as well - * as the spherical used in the lighting. - * @param url The HDR file url. - * @param size The size of the texture data to generate (one of the cubemap face desired width). - * @param onError Method called if any error happens during download. - * @return The packed binary data. - */ - static generateBabylonHDROnDisk(url: string, size: number, onError?: (() => void)): void; - /** - * Serializes the data contained in the texture in a binary format. - * This can be used to prevent the long loading tie associated with creating the seamless texture as well - * as the spherical used in the lighting. - * @param url The HDR file url. - * @param size The size of the texture data to generate (one of the cubemap face desired width). - * @param onError Method called if any error happens during download. - * @return The packed binary data. - */ - static generateBabylonHDR(url: string, size: number, callback: ((ArrayBuffer: ArrayBuffer) => void), onError?: (() => void)): void; + class FreeCameraVirtualJoystickInput implements ICameraInput { + camera: FreeCamera; + private _leftjoystick; + private _rightjoystick; + getLeftJoystick(): VirtualJoystick; + getRightJoystick(): VirtualJoystick; + checkInputs(): void; + attachControl(element: HTMLElement, noPreventDefault?: boolean): void; + detachControl(element: HTMLElement): void; + getClassName(): string; + getSimpleName(): string; } } declare module BABYLON { - class MapTexture extends Texture { - private _rectPackingMap; - private _size; - private _replacedViewport; - constructor(name: string, scene: Scene, size: ISize, samplingMode?: number, useMipMap?: boolean, margin?: number); - /** - * Allocate a rectangle of a given size in the texture map - * @param size the size of the rectangle to allocation - * @return the PackedRect instance corresponding to the allocated rect or null is there was not enough space to allocate it. - */ - allocateRect(size: Size): PackedRect; - /** - * Free a given rectangle from the texture map - * @param rectInfo the instance corresponding to the rect to free. - */ - freeRect(rectInfo: PackedRect): void; - /** - * Return the available space in the range of [O;1]. 0 being not space left at all, 1 being an empty texture map. - * This is the cumulated space, not the biggest available surface. Due to fragmentation you may not allocate a rect corresponding to this surface. - * @returns {} - */ - readonly freeSpace: number; - /** - * Bind the texture to the rendering engine to render in the zone of a given rectangle. - * Use this method when you want to render into the texture map with a clipspace set to the location and size of the given rect. - * Don't forget to call unbindTexture when you're done rendering - * @param rect the zone to render to - * @param clear true to clear the portion's color/depth data - */ - bindTextureForRect(rect: PackedRect, clear: boolean): void; - /** - * Bind the texture to the rendering engine to render in the zone of the given size at the given position. - * Use this method when you want to render into the texture map with a clipspace set to the location and size of the given rect. - * Don't forget to call unbindTexture when you're done rendering - * @param pos the position into the texture - * @param size the portion to fit the clip space to - * @param clear true to clear the portion's color/depth data - */ - bindTextureForPosSize(pos: Vector2, size: Size, clear: boolean): void; - /** - * Unbind the texture map from the rendering engine. - * Call this method when you're done rendering. A previous call to bindTextureForRect has to be made. - * @param dumpForDebug if set to true the content of the texture map will be dumped to a picture file that will be sent to the internet browser. - */ - unbindTexture(dumpForDebug?: boolean): void; - readonly canRescale: boolean; - clone(): MapTexture; + class VRCameraMetrics { + hResolution: number; + vResolution: number; + hScreenSize: number; + vScreenSize: number; + vScreenCenter: number; + eyeToScreenDistance: number; + lensSeparationDistance: number; + interpupillaryDistance: number; + distortionK: number[]; + chromaAbCorrection: number[]; + postProcessScaleFactor: number; + lensCenterOffset: number; + compensateDistortion: boolean; + readonly aspectRatio: number; + readonly aspectRatioFov: number; + readonly leftHMatrix: Matrix; + readonly rightHMatrix: Matrix; + readonly leftPreViewMatrix: Matrix; + readonly rightPreViewMatrix: Matrix; + static GetDefault(): VRCameraMetrics; + } +} + +declare module BABYLON { + class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera { + constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics); + getClassName(): string; + } + class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera { + constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics); + getClassName(): string; + } + class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera { + constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics); + getClassName(): string; } } +declare var HMDVRDevice: any; +declare var VRDisplay: any; +declare var VRFrameData: any; declare module BABYLON { - class MirrorTexture extends RenderTargetTexture { - mirrorPlane: Plane; - private _transformMatrix; - private _mirrorMatrix; - private _savedViewMatrix; - private _blurX; - private _blurY; - private _blurKernelX; - private _blurKernelY; - private _blurRatio; - blurRatio: number; - blurKernel: number; - blurKernelX: number; - blurKernelY: number; - constructor(name: string, size: any, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean); - private _preparePostProcesses(); - clone(): MirrorTexture; - serialize(): any; + /** + * This is a copy of VRPose. + * IMPORTANT!! The data is right-hand data. + * @export + * @interface DevicePose + */ + interface DevicePose { + readonly position?: Float32Array; + readonly linearVelocity?: Float32Array; + readonly linearAcceleration?: Float32Array; + readonly orientation?: Float32Array; + readonly angularVelocity?: Float32Array; + readonly angularAcceleration?: Float32Array; + } + interface PoseControlled { + position: Vector3; + rotationQuaternion: Quaternion; + devicePosition?: Vector3; + deviceRotationQuaternion: Quaternion; + rawPose: DevicePose; + deviceScaleFactor: number; + updateFromDevice(poseData: DevicePose): any; + } + interface WebVROptions { + trackPosition?: boolean; + positionScale?: number; + displayName?: string; + controllerMeshes?: boolean; + defaultLightningOnControllers?: boolean; + } + class WebVRFreeCamera extends FreeCamera implements PoseControlled { + private webVROptions; + _vrDevice: any; + rawPose: DevicePose; + private _vrEnabled; + private _specsVersion; + private _attached; + private _oldSize; + private _oldHardwareScaleFactor; + private _frameData; + private _quaternionCache; + private _positionOffset; + protected _descendants: Array; + devicePosition: Vector3; + deviceRotationQuaternion: any; + deviceScaleFactor: number; + controllers: Array; + nonVRControllers: Array; + private _onControllersAttached; + private _onNonVRControllerAttached; + rigParenting: boolean; + private _lightOnControllers; + constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions); + onControllersAttached: (controllers: Array) => void; + onNonVRControllerAttached: (controller: Gamepad) => void; + getControllerByName(name: string): WebVRController; + private _leftController; + readonly leftController: WebVRController; + private _rightController; + readonly rightController: WebVRController; + getForwardRay(length?: number): Ray; + _checkInputs(): void; + updateFromDevice(poseData: DevicePose): void; + /** + * WebVR's attach control will start broadcasting frames to the device. + * Note that in certain browsers (chrome for example) this function must be called + * within a user-interaction callback. Example: + *
 scene.onPointerDown = function() { camera.attachControl(canvas); }
+ * + * @param {HTMLElement} element + * @param {boolean} [noPreventDefault] + * + * @memberOf WebVRFreeCamera + */ + attachControl(element: HTMLElement, noPreventDefault?: boolean): void; + detachControl(element: HTMLElement): void; + getClassName(): string; + resetToCurrentRotation(): void; + _updateRigCameras(): void; + /** + * This function is called by the two RIG cameras. + * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance) + */ + protected _getWebVRViewMatrix(): Matrix; + protected _getWebVRProjectionMatrix(): Matrix; + initControllers(): void; } } declare module BABYLON { - interface IMultiRenderTargetOptions { - generateMipMaps: boolean; - types: number[]; - samplingModes: number[]; - generateDepthBuffer: boolean; - generateStencilBuffer: boolean; - generateDepthTexture: boolean; - textureCount: number; + interface IOctreeContainer { + blocks: Array>; } - class MultiRenderTarget extends RenderTargetTexture { - private _webGLTextures; - private _textures; - private _count; - readonly isSupported: boolean; - private _multiRenderTargetOptions; - readonly textures: Texture[]; - readonly depthTexture: Texture; - constructor(name: string, size: any, count: number, scene: Scene, options?: any); - private _createInternalTextures(); - samples: number; - resize(size: any): void; - dispose(): void; - releaseInternalTextures(): void; + class Octree { + maxDepth: number; + blocks: Array>; + dynamicContent: T[]; + private _maxBlockCapacity; + private _selectionContent; + private _creationFunc; + constructor(creationFunc: (entry: T, block: OctreeBlock) => void, maxBlockCapacity?: number, maxDepth?: number); + update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void; + addMesh(entry: T): void; + select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray; + intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray; + intersectsRay(ray: Ray): SmartArray; + static _CreateBlocks(worldMin: Vector3, worldMax: Vector3, entries: T[], maxBlockCapacity: number, currentDepth: number, maxDepth: number, target: IOctreeContainer, creationFunc: (entry: T, block: OctreeBlock) => void): void; + static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock) => void; + static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock) => void; } } declare module BABYLON { - class RawTexture extends Texture { - format: number; - constructor(data: ArrayBufferView, width: number, height: number, format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number); - update(data: ArrayBufferView): void; - static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture; - static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture; - static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture; - static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture; - static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture; + class OctreeBlock { + entries: T[]; + blocks: Array>; + private _depth; + private _maxDepth; + private _capacity; + private _minPoint; + private _maxPoint; + private _boundingVectors; + private _creationFunc; + constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock) => void); + readonly capacity: number; + readonly minPoint: Vector3; + readonly maxPoint: Vector3; + addEntry(entry: T): void; + addEntries(entries: T[]): void; + select(frustumPlanes: Plane[], selection: SmartArray, allowDuplicate?: boolean): void; + intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArray, allowDuplicate?: boolean): void; + intersectsRay(ray: Ray, selection: SmartArray): void; + createInnerBlocks(): void; } } declare module BABYLON { /** - * Creates a refraction texture used by refraction channel of the standard material. - * @param name the texture name - * @param size size of the underlying texture - * @param scene root scene - */ - class RefractionTexture extends RenderTargetTexture { - refractionPlane: Plane; - depth: number; - constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean); - clone(): RefractionTexture; + * Interface to implement to create a shadow generator compatible with BJS. + */ + interface IShadowGenerator { + getShadowMap(): RenderTargetTexture; + getShadowMapForRendering(): RenderTargetTexture; + isReady(subMesh: SubMesh, useInstances: boolean): boolean; + prepareDefines(defines: MaterialDefines, lightIndex: number): void; + bindShadowLight(lightIndex: string, effect: Effect): void; + getTransformMatrix(): Matrix; + recreateShadowMap(): void; + forceCompilation(onCompiled: (generator: ShadowGenerator) => void, options?: { + useInstances: boolean; + }): void; serialize(): any; + dispose(): void; } -} - -declare module BABYLON { - interface IRenderTargetOptions { - generateMipMaps: boolean; - type: number; - samplingMode: number; - generateDepthBuffer: boolean; - generateStencilBuffer: boolean; - } - class RenderTargetTexture extends Texture { - isCube: boolean; - static _REFRESHRATE_RENDER_ONCE: number; - static _REFRESHRATE_RENDER_ONEVERYFRAME: number; - static _REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number; - static readonly REFRESHRATE_RENDER_ONCE: number; - static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number; - static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number; + class ShadowGenerator implements IShadowGenerator { + private static _FILTER_NONE; + private static _FILTER_EXPONENTIALSHADOWMAP; + private static _FILTER_POISSONSAMPLING; + private static _FILTER_BLUREXPONENTIALSHADOWMAP; + private static _FILTER_CLOSEEXPONENTIALSHADOWMAP; + private static _FILTER_BLURCLOSEEXPONENTIALSHADOWMAP; + static readonly FILTER_NONE: number; + static readonly FILTER_POISSONSAMPLING: number; + static readonly FILTER_EXPONENTIALSHADOWMAP: number; + static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number; + static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number; + static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number; + private _bias; + bias: number; + private _blurBoxOffset; + blurBoxOffset: number; + private _blurScale; + blurScale: number; + private _blurKernel; + blurKernel: number; + private _useKernelBlur; + useKernelBlur: boolean; + private _depthScale; + depthScale: number; + private _filter; + filter: number; + usePoissonSampling: boolean; + useVarianceShadowMap: boolean; + useBlurVarianceShadowMap: boolean; + useExponentialShadowMap: boolean; + useBlurExponentialShadowMap: boolean; + useCloseExponentialShadowMap: boolean; + useBlurCloseExponentialShadowMap: boolean; + private _darkness; + /** + * Returns the darkness value (float). + */ + getDarkness(): number; /** - * Use this predicate to dynamically define the list of mesh you want to render. - * If set, the renderList property will be overwritten. - */ - renderListPredicate: (AbstractMesh: AbstractMesh) => boolean; + * Sets the ShadowGenerator darkness value (float <= 1.0). + * Returns the ShadowGenerator. + */ + setDarkness(darkness: number): ShadowGenerator; + private _transparencyShadow; /** - * Use this list to define the list of mesh you want to render. - */ - renderList: AbstractMesh[]; - renderParticles: boolean; - renderSprites: boolean; - coordinatesMode: number; - activeCamera: Camera; - customRenderFunction: (opaqueSubMeshes: SmartArray, transparentSubMeshes: SmartArray, alphaTestSubMeshes: SmartArray, beforeTransparents?: () => void) => void; - useCameraPostProcesses: boolean; - private _postProcessManager; - private _postProcesses; + * Sets the ability to have transparent shadow (boolean). + * Returns the ShadowGenerator. + */ + setTransparencyShadow(hasShadow: boolean): ShadowGenerator; + private _shadowMap; + private _shadowMap2; /** - * An event triggered when the texture is unbind. - * @type {BABYLON.Observable} - */ - onBeforeBindObservable: Observable; + * Returns a RenderTargetTexture object : the shadow map texture. + */ + getShadowMap(): RenderTargetTexture; /** - * An event triggered when the texture is unbind. - * @type {BABYLON.Observable} - */ - onAfterUnbindObservable: Observable; - private _onAfterUnbindObserver; - onAfterUnbind: () => void; + * Returns the most ready computed shadow map as a RenderTargetTexture object. + */ + getShadowMapForRendering(): RenderTargetTexture; /** - * An event triggered before rendering the texture - * @type {BABYLON.Observable} - */ - onBeforeRenderObservable: Observable; - private _onBeforeRenderObserver; - onBeforeRender: (faceIndex: number) => void; + * Controls the extent to which the shadows fade out at the edge of the frustum + * Used only by directionals and spots + */ + frustumEdgeFalloff: number; + private _light; /** - * An event triggered after rendering the texture - * @type {BABYLON.Observable} - */ - onAfterRenderObservable: Observable; - private _onAfterRenderObserver; - onAfterRender: (faceIndex: number) => void; + * Returns the associated light object. + */ + getLight(): IShadowLight; + forceBackFacesOnly: boolean; + private _scene; + private _lightDirection; + private _effect; + private _viewMatrix; + private _projectionMatrix; + private _transformMatrix; + private _worldViewProjection; + private _cachedPosition; + private _cachedDirection; + private _cachedDefines; + private _currentRenderID; + private _downSamplePostprocess; + private _boxBlurPostprocess; + private _kernelBlurXPostprocess; + private _kernelBlurYPostprocess; + private _blurPostProcesses; + private _mapSize; + private _currentFaceIndex; + private _currentFaceIndexCache; + private _textureType; + private _isCube; + private _defaultTextureMatrix; /** - * An event triggered after the texture clear - * @type {BABYLON.Observable} - */ - onClearObservable: Observable; - private _onClearObserver; - onClear: (Engine: Engine) => void; - protected _size: number; - _generateMipMaps: boolean; - protected _renderingManager: RenderingManager; - _waitingRenderList: string[]; - protected _doNotChangeAspectRatio: boolean; - protected _currentRefreshId: number; - protected _refreshRate: number; - protected _textureMatrix: Matrix; - protected _samples: number; - protected _renderTargetOptions: IRenderTargetOptions; - readonly renderTargetOptions: IRenderTargetOptions; - constructor(name: string, size: any, scene: Scene, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean); - samples: number; - resetRefreshCounter(): void; - refreshRate: number; - addPostProcess(postProcess: PostProcess): void; - clearPostProcesses(dispose?: boolean): void; - removePostProcess(postProcess: PostProcess): void; - _shouldRender(): boolean; - isReady(): boolean; - getRenderSize(): number; - readonly canRescale: boolean; - scale(ratio: number): void; - getReflectionTextureMatrix(): Matrix; - resize(size: any): void; - render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void; - private renderToTarget(faceIndex, currentRenderList, currentRenderListLength, useCameraPostProcess, dumpForDebug); + * Creates a ShadowGenerator object. + * A ShadowGenerator is the required tool to use the shadows. + * Each light casting shadows needs to use its own ShadowGenerator. + * Required parameters : + * - `mapSize` (integer): the size of the texture what stores the shadows. Example : 1024. + * - `light`: the light object generating the shadows. + * - `useFullFloatFirst`: by default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture. + * Documentation : http://doc.babylonjs.com/tutorials/shadows + */ + constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean); + private _initializeGenerator(); + private _initializeShadowMap(); + private _initializeBlurRTTAndPostProcesses(); + private _renderForShadowMap(opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes); + private _renderSubMeshForShadowMap(subMesh); + private _applyFilterValues(); /** - * 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. + * Force shader compilation including textures ready check */ - setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: (a: SubMesh, b: SubMesh) => number, alphaTestSortCompareFn?: (a: SubMesh, b: SubMesh) => number, transparentSortCompareFn?: (a: SubMesh, b: SubMesh) => number): void; + forceCompilation(onCompiled: (generator: ShadowGenerator) => void, options?: { + useInstances: boolean; + }): 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. + * Boolean : true when the ShadowGenerator is finally computed. */ - setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void; - clone(): RenderTargetTexture; - serialize(): any; - disposeFramebufferObjects(): void; - dispose(): void; - } -} - -declare module BABYLON { - class Texture extends BaseTexture { - static NEAREST_SAMPLINGMODE: number; - static NEAREST_NEAREST_MIPLINEAR: number; - static BILINEAR_SAMPLINGMODE: number; - static LINEAR_LINEAR_MIPNEAREST: number; - static TRILINEAR_SAMPLINGMODE: number; - static LINEAR_LINEAR_MIPLINEAR: number; - static NEAREST_NEAREST_MIPNEAREST: number; - static NEAREST_LINEAR_MIPNEAREST: number; - static NEAREST_LINEAR_MIPLINEAR: number; - static NEAREST_LINEAR: number; - static NEAREST_NEAREST: number; - static LINEAR_NEAREST_MIPNEAREST: number; - static LINEAR_NEAREST_MIPLINEAR: number; - static LINEAR_LINEAR: number; - static LINEAR_NEAREST: number; - static EXPLICIT_MODE: number; - static SPHERICAL_MODE: number; - static PLANAR_MODE: number; - static CUBIC_MODE: number; - static PROJECTION_MODE: number; - static SKYBOX_MODE: number; - static INVCUBIC_MODE: number; - static EQUIRECTANGULAR_MODE: number; - static FIXED_EQUIRECTANGULAR_MODE: number; - static FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number; - static CLAMP_ADDRESSMODE: number; - static WRAP_ADDRESSMODE: number; - static MIRROR_ADDRESSMODE: number; - url: string; - uOffset: number; - vOffset: number; - uScale: number; - vScale: number; - uAng: number; - vAng: number; - wAng: number; - readonly noMipmap: boolean; - private _noMipmap; - _invertY: boolean; - private _rowGenerationMatrix; - private _cachedTextureMatrix; - private _projectionModeMatrix; - private _t0; - private _t1; - private _t2; - private _cachedUOffset; - private _cachedVOffset; - private _cachedUScale; - private _cachedVScale; - private _cachedUAng; - private _cachedVAng; - private _cachedWAng; - private _cachedProjectionMatrixId; - private _cachedCoordinatesMode; - _samplingMode: number; - private _buffer; - private _deleteBuffer; - protected _format: number; - private _delayedOnLoad; - private _delayedOnError; - private _onLoadObservable; - protected _isBlocking: boolean; - isBlocking: boolean; - readonly samplingMode: number; - constructor(url: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: () => void, onError?: () => void, buffer?: any, deleteBuffer?: boolean, format?: number); - updateURL(url: string): void; - delayLoad(): void; - updateSamplingMode(samplingMode: number): void; - private _prepareRowForTextureGeneration(x, y, z, t); - getTextureMatrix(): Matrix; - getReflectionTextureMatrix(): Matrix; - clone(): Texture; - readonly onLoadObservable: Observable; - serialize(): any; - getClassName(): string; - dispose(): void; - static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: () => void, onError?: () => void, format?: number): Texture; - static Parse(parsedTexture: any, scene: Scene, rootUrl: string): BaseTexture; - static LoadFromDataString(name: string, buffer: any, scene: Scene, deleteBuffer?: boolean, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: () => void, onError?: () => void, format?: number): Texture; - } -} - -declare module BABYLON { - class VideoTexture extends Texture { - video: HTMLVideoElement; - private _autoLaunch; - private _lastUpdate; - private _generateMipMaps; - private _setTextureReady; + isReady(subMesh: SubMesh, useInstances: boolean): boolean; + /** + * This creates the defines related to the standard BJS materials. + */ + prepareDefines(defines: MaterialDefines, lightIndex: number): void; /** - * Creates a video texture. - * Sample : https://doc.babylonjs.com/tutorials/01._Advanced_Texturing - * @param {Array} urlsOrVideo can be used to provide an array of urls or an already setup HTML video element. - * @param {BABYLON.Scene} scene is obviously the current scene. - * @param {boolean} generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated). - * @param {boolean} invertY is false by default but can be used to invert video on Y axis - * @param {number} samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default + * This binds shadow lights related to the standard BJS materials. + * It implies the unifroms available on the materials are the standard BJS ones. + */ + bindShadowLight(lightIndex: string, effect: Effect): void; + /** + * Returns a Matrix object : the updated transformation matrix. + */ + getTransformMatrix(): Matrix; + recreateShadowMap(): void; + private _disposeBlurPostProcesses(); + private _disposeRTTandPostProcesses(); + /** + * Disposes the ShadowGenerator. + * Returns nothing. */ - constructor(name: string, urlsOrVideo: string[] | HTMLVideoElement, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number); - private __setTextureReady(); - private _createTexture(); - update(): boolean; dispose(): void; - static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: { - minWidth: number; - maxWidth: number; - minHeight: number; - maxHeight: number; - deviceId: string; - }): void; + /** + * Serializes the ShadowGenerator and returns a serializationObject. + */ + serialize(): any; + /** + * Parses a serialized ShadowGenerator and returns a new ShadowGenerator. + */ + static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator; } } @@ -17287,289 +16655,921 @@ declare module BABYLON { */ useMetallnessFromMetallicTextureBlue: boolean; /** - * Specifies if the metallic texture contains the ambient occlusion information in its red channel. + * Specifies if the metallic texture contains the ambient occlusion information in its red channel. + */ + useAmbientOcclusionFromMetallicTextureRed: boolean; + /** + * Specifies if the ambient texture contains the ambient occlusion information in its red channel only. + */ + useAmbientInGrayScale: boolean; + /** + * In case the reflectivity map does not contain the microsurface information in its alpha channel, + * The material will try to infer what glossiness each pixel should be. + */ + useAutoMicroSurfaceFromReflectivityMap: boolean; + /** + * BJS is using an harcoded light falloff based on a manually sets up range. + * In PBR, one way to represents the fallof is to use the inverse squared root algorythm. + * This parameter can help you switch back to the BJS mode in order to create scenes using both materials. + */ + usePhysicalLightFalloff: boolean; + /** + * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones). + * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind. + */ + useRadianceOverAlpha: boolean; + /** + * Allows using the bump map in parallax mode. + */ + useParallax: boolean; + /** + * Allows using the bump map in parallax occlusion mode. + */ + useParallaxOcclusion: boolean; + /** + * Controls the scale bias of the parallax mode. + */ + parallaxScaleBias: number; + /** + * If sets to true, disables all the lights affecting the material. + */ + disableLighting: boolean; + /** + * Force the shader to compute irradiance in the fragment shader in order to take bump in account. + */ + forceIrradianceInFragment: boolean; + /** + * Number of Simultaneous lights allowed on the material. + */ + maxSimultaneousLights: number; + /** + * If sets to true, x component of normal map value will invert (x = 1.0 - x). + */ + invertNormalMapX: boolean; + /** + * If sets to true, y component of normal map value will invert (y = 1.0 - y). + */ + invertNormalMapY: boolean; + /** + * If sets to true and backfaceCulling is false, normals will be flipped on the backside. + */ + twoSidedLighting: boolean; + /** + * Specifies that the alpha is premultiplied before output (this enables alpha premultiplied blending). + * in your scene composition. + */ + preMultiplyAlpha: boolean; + /** + * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested. + * And/Or occlude the blended part. + */ + useAlphaFresnel: boolean; + /** + * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested. + * And/Or occlude the blended part. + */ + environmentBRDFTexture: BaseTexture; + /** + * Force normal to face away from face. + * (Temporary internal fix to remove before 3.1) + */ + forceNormalForward: boolean; + /** + * Gets the image processing configuration used either in this material. + */ + /** + * Sets the Default image processing configuration used either in the this material. + * + * If sets to null, the scene one is in use. + */ + imageProcessingConfiguration: ImageProcessingConfiguration; + /** + * Gets wether the color curves effect is enabled. + */ + /** + * Sets wether the color curves effect is enabled. + */ + cameraColorCurvesEnabled: boolean; + /** + * Gets wether the color grading effect is enabled. + */ + /** + * Gets wether the color grading effect is enabled. + */ + cameraColorGradingEnabled: boolean; + /** + * Gets wether tonemapping is enabled or not. + */ + /** + * Sets wether tonemapping is enabled or not + */ + cameraToneMappingEnabled: boolean; + /** + * The camera exposure used on this material. + * This property is here and not in the camera to allow controlling exposure without full screen post process. + * This corresponds to a photographic exposure. + */ + /** + * The camera exposure used on this material. + * This property is here and not in the camera to allow controlling exposure without full screen post process. + * This corresponds to a photographic exposure. + */ + cameraExposure: number; + /** + * Gets The camera contrast used on this material. + */ + /** + * Sets The camera contrast used on this material. + */ + cameraContrast: number; + /** + * Gets the Color Grading 2D Lookup Texture. + */ + /** + * Sets the Color Grading 2D Lookup Texture. + */ + cameraColorGradingTexture: BaseTexture; + /** + * 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. + */ + /** + * 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. + */ + cameraColorCurves: ColorCurves; + /** + * Instantiates a new PBRMaterial instance. + * + * @param name The material name + * @param scene The scene the material will be use in. + */ + constructor(name: string, scene: Scene); + getClassName(): string; + getActiveTextures(): BaseTexture[]; + hasTexture(texture: BaseTexture): boolean; + clone(name: string): PBRMaterial; + serialize(): any; + static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial; + } +} + +declare module BABYLON { + /** + * The PBR material of BJS following the metal roughness convention. + * + * This fits to the PBR convention in the GLTF definition: + * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0 + */ + class PBRMetallicRoughnessMaterial extends Internals.PBRBaseSimpleMaterial { + /** + * The base color has two different interpretations depending on the value of metalness. + * When the material is a metal, the base color is the specific measured reflectance value + * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color + * of the material. + */ + baseColor: Color3; + /** + * Base texture of the metallic workflow. It contains both the baseColor information in RGB as + * well as opacity information in the alpha channel. + */ + baseTexture: BaseTexture; + /** + * Specifies the metallic scalar value of the material. + * Can also be used to scale the metalness values of the metallic texture. + */ + metallic: number; + /** + * Specifies the roughness scalar value of the material. + * Can also be used to scale the roughness values of the metallic texture. + */ + roughness: number; + /** + * Texture containing both the metallic value in the B channel and the + * roughness value in the G channel to keep better precision. + */ + metallicRoughnessTexture: BaseTexture; + /** + * Instantiates a new PBRMetalRoughnessMaterial instance. + * + * @param name The material name + * @param scene The scene the material will be use in. + */ + constructor(name: string, scene: Scene); + /** + * Return the currrent class name of the material. + */ + getClassName(): string; + /** + * Return the active textures of the material. + */ + getActiveTextures(): BaseTexture[]; + hasTexture(texture: BaseTexture): boolean; + clone(name: string): PBRMetallicRoughnessMaterial; + /** + * Serialize the material to a parsable JSON object. */ - useAmbientOcclusionFromMetallicTextureRed: boolean; + serialize(): any; /** - * Specifies if the ambient texture contains the ambient occlusion information in its red channel only. + * Parses a JSON object correponding to the serialize function. */ - useAmbientInGrayScale: boolean; + static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial; + } +} + +declare module BABYLON { + /** + * The PBR material of BJS following the specular glossiness convention. + * + * This fits to the PBR convention in the GLTF definition: + * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness + */ + class PBRSpecularGlossinessMaterial extends Internals.PBRBaseSimpleMaterial { /** - * In case the reflectivity map does not contain the microsurface information in its alpha channel, - * The material will try to infer what glossiness each pixel should be. + * Specifies the diffuse color of the material. */ - useAutoMicroSurfaceFromReflectivityMap: boolean; + diffuseColor: Color3; /** - * BJS is using an harcoded light falloff based on a manually sets up range. - * In PBR, one way to represents the fallof is to use the inverse squared root algorythm. - * This parameter can help you switch back to the BJS mode in order to create scenes using both materials. + * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha + * channel. */ - usePhysicalLightFalloff: boolean; + diffuseTexture: BaseTexture; /** - * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones). - * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind. + * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror). */ - useRadianceOverAlpha: boolean; + specularColor: Color3; /** - * Allows using the bump map in parallax mode. + * Specifies the glossiness of the material. This indicates "how sharp is the reflection". */ - useParallax: boolean; + glossiness: number; /** - * Allows using the bump map in parallax occlusion mode. + * Specifies both the specular color RGB and the glossiness A of the material per pixels. */ - useParallaxOcclusion: boolean; + specularGlossinessTexture: BaseTexture; /** - * Controls the scale bias of the parallax mode. + * Instantiates a new PBRSpecularGlossinessMaterial instance. + * + * @param name The material name + * @param scene The scene the material will be use in. */ - parallaxScaleBias: number; + constructor(name: string, scene: Scene); /** - * If sets to true, disables all the lights affecting the material. + * Return the currrent class name of the material. */ - disableLighting: boolean; + getClassName(): string; /** - * Force the shader to compute irradiance in the fragment shader in order to take bump in account. + * Return the active textures of the material. */ - forceIrradianceInFragment: boolean; + getActiveTextures(): BaseTexture[]; + hasTexture(texture: BaseTexture): boolean; + clone(name: string): PBRSpecularGlossinessMaterial; /** - * Number of Simultaneous lights allowed on the material. + * Serialize the material to a parsable JSON object. */ - maxSimultaneousLights: number; + serialize(): any; /** - * If sets to true, x component of normal map value will invert (x = 1.0 - x). + * Parses a JSON object correponding to the serialize function. */ - invertNormalMapX: boolean; + static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial; + } +} + +declare module BABYLON { + class BaseTexture { + static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number; + name: string; + private _hasAlpha; + hasAlpha: boolean; + getAlphaFromRGB: boolean; + level: number; + coordinatesIndex: number; + private _coordinatesMode; + coordinatesMode: number; + wrapU: number; + wrapV: number; + anisotropicFilteringLevel: number; + isCube: boolean; + gammaSpace: boolean; + invertZ: boolean; + lodLevelInAlpha: boolean; + lodGenerationOffset: number; + lodGenerationScale: number; + isRenderTarget: boolean; + readonly uid: string; + toString(): string; + getClassName(): string; + animations: Animation[]; /** - * If sets to true, y component of normal map value will invert (y = 1.0 - y). + * An event triggered when the texture is disposed. + * @type {BABYLON.Observable} + */ + onDisposeObservable: Observable; + private _onDisposeObserver; + onDispose: () => void; + delayLoadState: number; + _cachedAnisotropicFilteringLevel: number; + private _scene; + _texture: WebGLTexture; + private _uid; + readonly isBlocking: boolean; + constructor(scene: Scene); + getScene(): Scene; + getTextureMatrix(): Matrix; + getReflectionTextureMatrix(): Matrix; + getInternalTexture(): WebGLTexture; + isReadyOrNotBlocking(): boolean; + isReady(): boolean; + getSize(): ISize; + getBaseSize(): ISize; + scale(ratio: number): void; + readonly canRescale: boolean; + _removeFromCache(url: string, noMipmap: boolean): void; + _getFromCache(url: string, noMipmap: boolean, sampling?: number): WebGLTexture; + delayLoad(): void; + clone(): BaseTexture; + readonly textureType: number; + readonly textureFormat: number; + readPixels(faceIndex?: number): ArrayBufferView; + releaseInternalTexture(): void; + sphericalPolynomial: SphericalPolynomial; + readonly _lodTextureHigh: BaseTexture; + readonly _lodTextureMid: BaseTexture; + readonly _lodTextureLow: BaseTexture; + dispose(): void; + serialize(): any; + static WhenAllReady(textures: BaseTexture[], callback: () => void): void; + } +} + +declare module BABYLON { + /** + * This represents a color grading texture. This acts as a lookup table LUT, useful during post process + * It can help converting any input color in a desired output one. This can then be used to create effects + * from sepia, black and white to sixties or futuristic rendering... + * + * The only supported format is currently 3dl. + * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table/ + */ + class ColorGradingTexture extends BaseTexture { + /** + * The current internal texture size. */ - invertNormalMapY: boolean; + private _size; /** - * If sets to true and backfaceCulling is false, normals will be flipped on the backside. + * The current texture matrix. (will always be identity in color grading texture) */ - twoSidedLighting: boolean; + private _textureMatrix; /** - * Specifies that the alpha is premultiplied before output (this enables alpha premultiplied blending). - * in your scene composition. + * The texture URL. */ - preMultiplyAlpha: boolean; + url: string; /** - * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested. - * And/Or occlude the blended part. + * Empty line regex stored for GC. */ - useAlphaFresnel: boolean; + private static _noneEmptyLineRegex; /** - * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested. - * And/Or occlude the blended part. + * Instantiates a ColorGradingTexture from the following parameters. + * + * @param url The location of the color gradind data (currently only supporting 3dl) + * @param scene The scene the texture will be used in */ - environmentBRDFTexture: BaseTexture; + constructor(url: string, scene: Scene); /** - * Force normal to face away from face. - * (Temporary internal fix to remove before 3.1) + * Returns the texture matrix used in most of the material. + * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in). */ - forceNormalForward: boolean; + getTextureMatrix(): Matrix; /** - * Gets the image processing configuration used either in this material. + * Occurs when the file being loaded is a .3dl LUT file. */ + private load3dlTexture(); /** - * Sets the Default image processing configuration used either in the this material. - * - * If sets to null, the scene one is in use. + * Starts the loading process of the texture. */ - imageProcessingConfiguration: ImageProcessingConfiguration; + private loadTexture(); /** - * Gets wether the color curves effect is enabled. + * Clones the color gradind texture. */ + clone(): ColorGradingTexture; /** - * Sets wether the color curves effect is enabled. + * Called during delayed load for textures. */ - cameraColorCurvesEnabled: boolean; + delayLoad(): void; /** - * Gets wether the color grading effect is enabled. + * Parses a color grading texture serialized by Babylon. + * @param parsedTexture The texture information being parsedTexture + * @param scene The scene to load the texture in + * @param rootUrl The root url of the data assets to load + * @return A color gradind texture */ + static Parse(parsedTexture: any, scene: Scene, rootUrl: string): ColorGradingTexture; /** - * Gets wether the color grading effect is enabled. + * Serializes the LUT texture to json format. */ - cameraColorGradingEnabled: boolean; + serialize(): any; + } +} + +declare module BABYLON { + class CubeTexture extends BaseTexture { + url: string; + coordinatesMode: number; + private _noMipmap; + private _files; + private _extensions; + private _textureMatrix; + private _format; + private _prefiltered; + static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture; + static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any): CubeTexture; + constructor(rootUrl: string, scene: Scene, extensions?: string[], noMipmap?: boolean, files?: string[], onLoad?: () => void, onError?: () => void, format?: number, prefiltered?: boolean, forcedExtension?: any); + delayLoad(): void; + getReflectionTextureMatrix(): Matrix; + setReflectionTextureMatrix(value: Matrix): void; + static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture; + clone(): CubeTexture; + } +} + +declare module BABYLON { + class DynamicTexture extends Texture { + private _generateMipMaps; + private _canvas; + private _context; + constructor(name: string, options: any, scene: Scene, generateMipMaps: boolean, samplingMode?: number, format?: number); + readonly canRescale: boolean; + private _recreate(textureSize); + scale(ratio: number): void; + scaleTo(width: number, height: number): void; + getContext(): CanvasRenderingContext2D; + clear(): void; + update(invertY?: boolean): void; + drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void; + clone(): DynamicTexture; + } +} + +declare module BABYLON { + /** + * This represents a texture coming from an HDR input. + * + * The only supported format is currently panorama picture stored in RGBE format. + * Example of such files can be found on HDRLib: http://hdrlib.com/ + */ + class HDRCubeTexture extends BaseTexture { + private static _facesMapping; + private _useInGammaSpace; + private _generateHarmonics; + private _noMipmap; + private _extensions; + private _textureMatrix; + private _size; + private _usePMREMGenerator; + private _isBABYLONPreprocessed; + private _onLoad; + private _onError; /** - * Gets wether tonemapping is enabled or not. + * The texture URL. */ + url: string; /** - * Sets wether tonemapping is enabled or not + * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */ - cameraToneMappingEnabled: boolean; + coordinatesMode: number; /** - * The camera exposure used on this material. - * This property is here and not in the camera to allow controlling exposure without full screen post process. - * This corresponds to a photographic exposure. + * Specifies wether the texture has been generated through the PMREMGenerator tool. + * This is usefull at run time to apply the good shader. */ + isPMREM: boolean; + protected _isBlocking: boolean; /** - * The camera exposure used on this material. - * This property is here and not in the camera to allow controlling exposure without full screen post process. - * This corresponds to a photographic exposure. + * Gets wether or not the texture is blocking during loading. */ - cameraExposure: number; /** - * Gets The camera contrast used on this material. + * Sets wether or not the texture is blocking during loading. */ + isBlocking: boolean; /** - * Sets The camera contrast used on this material. + * Instantiates an HDRTexture from the following parameters. + * + * @param url The location of the HDR raw data (Panorama stored in RGBE format) + * @param scene The scene the texture will be used in + * @param size The cubemap desired size (the more it increases the longer the generation will be) If the size is omitted this implies you are using a preprocessed cubemap. + * @param noMipmap Forces to not generate the mipmap if true + * @param generateHarmonics Specifies wether you want to extract the polynomial harmonics during the generation process + * @param useInGammaSpace Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) + * @param usePMREMGenerator Specifies wether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time. */ - cameraContrast: number; + constructor(url: string, scene: Scene, size?: number, noMipmap?: boolean, generateHarmonics?: boolean, useInGammaSpace?: boolean, usePMREMGenerator?: boolean, onLoad?: () => void, onError?: () => void); /** - * Gets the Color Grading 2D Lookup Texture. + * Occurs when the file is a preprocessed .babylon.hdr file. */ + private loadBabylonTexture(); /** - * Sets the Color Grading 2D Lookup Texture. + * Occurs when the file is raw .hdr file. */ - cameraColorGradingTexture: BaseTexture; + private loadHDRTexture(); /** - * 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. + * Starts the loading process of the texture. */ + private loadTexture(); + clone(): HDRCubeTexture; + delayLoad(): void; + getReflectionTextureMatrix(): Matrix; + setReflectionTextureMatrix(value: Matrix): void; + static Parse(parsedTexture: any, scene: Scene, rootUrl: string): HDRCubeTexture; + serialize(): any; /** - * 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. + * Saves as a file the data contained in the texture in a binary format. + * This can be used to prevent the long loading tie associated with creating the seamless texture as well + * as the spherical used in the lighting. + * @param url The HDR file url. + * @param size The size of the texture data to generate (one of the cubemap face desired width). + * @param onError Method called if any error happens during download. + * @return The packed binary data. */ - cameraColorCurves: ColorCurves; + static generateBabylonHDROnDisk(url: string, size: number, onError?: (() => void)): void; /** - * Instantiates a new PBRMaterial instance. - * - * @param name The material name - * @param scene The scene the material will be use in. + * Serializes the data contained in the texture in a binary format. + * This can be used to prevent the long loading tie associated with creating the seamless texture as well + * as the spherical used in the lighting. + * @param url The HDR file url. + * @param size The size of the texture data to generate (one of the cubemap face desired width). + * @param onError Method called if any error happens during download. + * @return The packed binary data. */ - constructor(name: string, scene: Scene); - getClassName(): string; - getActiveTextures(): BaseTexture[]; - hasTexture(texture: BaseTexture): boolean; - clone(name: string): PBRMaterial; - serialize(): any; - static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial; + static generateBabylonHDR(url: string, size: number, callback: ((ArrayBuffer: ArrayBuffer) => void), onError?: (() => void)): void; } } declare module BABYLON { - /** - * The PBR material of BJS following the metal roughness convention. - * - * This fits to the PBR convention in the GLTF definition: - * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0 - */ - class PBRMetallicRoughnessMaterial extends Internals.PBRBaseSimpleMaterial { - /** - * The base color has two different interpretations depending on the value of metalness. - * When the material is a metal, the base color is the specific measured reflectance value - * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color - * of the material. - */ - baseColor: Color3; - /** - * Base texture of the metallic workflow. It contains both the baseColor information in RGB as - * well as opacity information in the alpha channel. - */ - baseTexture: BaseTexture; - /** - * Specifies the metallic scalar value of the material. - * Can also be used to scale the metalness values of the metallic texture. - */ - metallic: number; + class MapTexture extends Texture { + private _rectPackingMap; + private _size; + private _replacedViewport; + constructor(name: string, scene: Scene, size: ISize, samplingMode?: number, useMipMap?: boolean, margin?: number); /** - * Specifies the roughness scalar value of the material. - * Can also be used to scale the roughness values of the metallic texture. + * Allocate a rectangle of a given size in the texture map + * @param size the size of the rectangle to allocation + * @return the PackedRect instance corresponding to the allocated rect or null is there was not enough space to allocate it. */ - roughness: number; + allocateRect(size: Size): PackedRect; /** - * Texture containing both the metallic value in the B channel and the - * roughness value in the G channel to keep better precision. + * Free a given rectangle from the texture map + * @param rectInfo the instance corresponding to the rect to free. */ - metallicRoughnessTexture: BaseTexture; + freeRect(rectInfo: PackedRect): void; /** - * Instantiates a new PBRMetalRoughnessMaterial instance. - * - * @param name The material name - * @param scene The scene the material will be use in. + * Return the available space in the range of [O;1]. 0 being not space left at all, 1 being an empty texture map. + * This is the cumulated space, not the biggest available surface. Due to fragmentation you may not allocate a rect corresponding to this surface. + * @returns {} */ - constructor(name: string, scene: Scene); + readonly freeSpace: number; /** - * Return the currrent class name of the material. + * Bind the texture to the rendering engine to render in the zone of a given rectangle. + * Use this method when you want to render into the texture map with a clipspace set to the location and size of the given rect. + * Don't forget to call unbindTexture when you're done rendering + * @param rect the zone to render to + * @param clear true to clear the portion's color/depth data */ - getClassName(): string; + bindTextureForRect(rect: PackedRect, clear: boolean): void; /** - * Return the active textures of the material. + * Bind the texture to the rendering engine to render in the zone of the given size at the given position. + * Use this method when you want to render into the texture map with a clipspace set to the location and size of the given rect. + * Don't forget to call unbindTexture when you're done rendering + * @param pos the position into the texture + * @param size the portion to fit the clip space to + * @param clear true to clear the portion's color/depth data */ - getActiveTextures(): BaseTexture[]; - hasTexture(texture: BaseTexture): boolean; - clone(name: string): PBRMetallicRoughnessMaterial; + bindTextureForPosSize(pos: Vector2, size: Size, clear: boolean): void; /** - * Serialize the material to a parsable JSON object. + * Unbind the texture map from the rendering engine. + * Call this method when you're done rendering. A previous call to bindTextureForRect has to be made. + * @param dumpForDebug if set to true the content of the texture map will be dumped to a picture file that will be sent to the internet browser. */ + unbindTexture(dumpForDebug?: boolean): void; + readonly canRescale: boolean; + clone(): MapTexture; + } +} + +declare module BABYLON { + class MirrorTexture extends RenderTargetTexture { + mirrorPlane: Plane; + private _transformMatrix; + private _mirrorMatrix; + private _savedViewMatrix; + private _blurX; + private _blurY; + private _blurKernelX; + private _blurKernelY; + private _blurRatio; + blurRatio: number; + blurKernel: number; + blurKernelX: number; + blurKernelY: number; + constructor(name: string, size: any, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean); + private _preparePostProcesses(); + clone(): MirrorTexture; + serialize(): any; + } +} + +declare module BABYLON { + interface IMultiRenderTargetOptions { + generateMipMaps: boolean; + types: number[]; + samplingModes: number[]; + generateDepthBuffer: boolean; + generateStencilBuffer: boolean; + generateDepthTexture: boolean; + textureCount: number; + } + class MultiRenderTarget extends RenderTargetTexture { + private _webGLTextures; + private _textures; + private _count; + readonly isSupported: boolean; + private _multiRenderTargetOptions; + readonly textures: Texture[]; + readonly depthTexture: Texture; + constructor(name: string, size: any, count: number, scene: Scene, options?: any); + private _createInternalTextures(); + samples: number; + resize(size: any): void; + dispose(): void; + releaseInternalTextures(): void; + } +} + +declare module BABYLON { + class RawTexture extends Texture { + format: number; + constructor(data: ArrayBufferView, width: number, height: number, format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number); + update(data: ArrayBufferView): void; + static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture; + static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture; + static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture; + static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture; + static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture; + } +} + +declare module BABYLON { + /** + * Creates a refraction texture used by refraction channel of the standard material. + * @param name the texture name + * @param size size of the underlying texture + * @param scene root scene + */ + class RefractionTexture extends RenderTargetTexture { + refractionPlane: Plane; + depth: number; + constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean); + clone(): RefractionTexture; serialize(): any; - /** - * Parses a JSON object correponding to the serialize function. - */ - static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial; } } declare module BABYLON { - /** - * The PBR material of BJS following the specular glossiness convention. - * - * This fits to the PBR convention in the GLTF definition: - * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness - */ - class PBRSpecularGlossinessMaterial extends Internals.PBRBaseSimpleMaterial { + interface IRenderTargetOptions { + generateMipMaps: boolean; + type: number; + samplingMode: number; + generateDepthBuffer: boolean; + generateStencilBuffer: boolean; + } + class RenderTargetTexture extends Texture { + isCube: boolean; + static _REFRESHRATE_RENDER_ONCE: number; + static _REFRESHRATE_RENDER_ONEVERYFRAME: number; + static _REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number; + static readonly REFRESHRATE_RENDER_ONCE: number; + static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number; + static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number; /** - * Specifies the diffuse color of the material. - */ - diffuseColor: Color3; + * Use this predicate to dynamically define the list of mesh you want to render. + * If set, the renderList property will be overwritten. + */ + renderListPredicate: (AbstractMesh: AbstractMesh) => boolean; /** - * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha - * channel. - */ - diffuseTexture: BaseTexture; + * Use this list to define the list of mesh you want to render. + */ + renderList: AbstractMesh[]; + renderParticles: boolean; + renderSprites: boolean; + coordinatesMode: number; + activeCamera: Camera; + customRenderFunction: (opaqueSubMeshes: SmartArray, transparentSubMeshes: SmartArray, alphaTestSubMeshes: SmartArray, beforeTransparents?: () => void) => void; + useCameraPostProcesses: boolean; + private _postProcessManager; + private _postProcesses; /** - * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror). - */ - specularColor: Color3; + * An event triggered when the texture is unbind. + * @type {BABYLON.Observable} + */ + onBeforeBindObservable: Observable; /** - * Specifies the glossiness of the material. This indicates "how sharp is the reflection". - */ - glossiness: number; + * An event triggered when the texture is unbind. + * @type {BABYLON.Observable} + */ + onAfterUnbindObservable: Observable; + private _onAfterUnbindObserver; + onAfterUnbind: () => void; /** - * Specifies both the specular color RGB and the glossiness A of the material per pixels. - */ - specularGlossinessTexture: BaseTexture; + * An event triggered before rendering the texture + * @type {BABYLON.Observable} + */ + onBeforeRenderObservable: Observable; + private _onBeforeRenderObserver; + onBeforeRender: (faceIndex: number) => void; /** - * Instantiates a new PBRSpecularGlossinessMaterial instance. - * - * @param name The material name - * @param scene The scene the material will be use in. - */ - constructor(name: string, scene: Scene); + * An event triggered after rendering the texture + * @type {BABYLON.Observable} + */ + onAfterRenderObservable: Observable; + private _onAfterRenderObserver; + onAfterRender: (faceIndex: number) => void; /** - * Return the currrent class name of the material. - */ - getClassName(): string; + * An event triggered after the texture clear + * @type {BABYLON.Observable} + */ + onClearObservable: Observable; + private _onClearObserver; + onClear: (Engine: Engine) => void; + protected _size: number; + _generateMipMaps: boolean; + protected _renderingManager: RenderingManager; + _waitingRenderList: string[]; + protected _doNotChangeAspectRatio: boolean; + protected _currentRefreshId: number; + protected _refreshRate: number; + protected _textureMatrix: Matrix; + protected _samples: number; + protected _renderTargetOptions: IRenderTargetOptions; + readonly renderTargetOptions: IRenderTargetOptions; + constructor(name: string, size: any, scene: Scene, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean); + samples: number; + resetRefreshCounter(): void; + refreshRate: number; + addPostProcess(postProcess: PostProcess): void; + clearPostProcesses(dispose?: boolean): void; + removePostProcess(postProcess: PostProcess): void; + _shouldRender(): boolean; + isReady(): boolean; + getRenderSize(): number; + readonly canRescale: boolean; + scale(ratio: number): void; + getReflectionTextureMatrix(): Matrix; + resize(size: any): void; + render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void; + private renderToTarget(faceIndex, currentRenderList, currentRenderListLength, useCameraPostProcess, dumpForDebug); /** - * Return the active textures of the 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. */ - getActiveTextures(): BaseTexture[]; - hasTexture(texture: BaseTexture): boolean; - clone(name: string): PBRSpecularGlossinessMaterial; + setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: (a: SubMesh, b: SubMesh) => number, alphaTestSortCompareFn?: (a: SubMesh, b: SubMesh) => number, transparentSortCompareFn?: (a: SubMesh, b: SubMesh) => number): void; /** - * Serialize the material to a parsable JSON object. + * 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. */ + setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void; + clone(): RenderTargetTexture; + serialize(): any; + disposeFramebufferObjects(): void; + dispose(): void; + } +} + +declare module BABYLON { + class Texture extends BaseTexture { + static NEAREST_SAMPLINGMODE: number; + static NEAREST_NEAREST_MIPLINEAR: number; + static BILINEAR_SAMPLINGMODE: number; + static LINEAR_LINEAR_MIPNEAREST: number; + static TRILINEAR_SAMPLINGMODE: number; + static LINEAR_LINEAR_MIPLINEAR: number; + static NEAREST_NEAREST_MIPNEAREST: number; + static NEAREST_LINEAR_MIPNEAREST: number; + static NEAREST_LINEAR_MIPLINEAR: number; + static NEAREST_LINEAR: number; + static NEAREST_NEAREST: number; + static LINEAR_NEAREST_MIPNEAREST: number; + static LINEAR_NEAREST_MIPLINEAR: number; + static LINEAR_LINEAR: number; + static LINEAR_NEAREST: number; + static EXPLICIT_MODE: number; + static SPHERICAL_MODE: number; + static PLANAR_MODE: number; + static CUBIC_MODE: number; + static PROJECTION_MODE: number; + static SKYBOX_MODE: number; + static INVCUBIC_MODE: number; + static EQUIRECTANGULAR_MODE: number; + static FIXED_EQUIRECTANGULAR_MODE: number; + static FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number; + static CLAMP_ADDRESSMODE: number; + static WRAP_ADDRESSMODE: number; + static MIRROR_ADDRESSMODE: number; + url: string; + uOffset: number; + vOffset: number; + uScale: number; + vScale: number; + uAng: number; + vAng: number; + wAng: number; + readonly noMipmap: boolean; + private _noMipmap; + _invertY: boolean; + private _rowGenerationMatrix; + private _cachedTextureMatrix; + private _projectionModeMatrix; + private _t0; + private _t1; + private _t2; + private _cachedUOffset; + private _cachedVOffset; + private _cachedUScale; + private _cachedVScale; + private _cachedUAng; + private _cachedVAng; + private _cachedWAng; + private _cachedProjectionMatrixId; + private _cachedCoordinatesMode; + _samplingMode: number; + private _buffer; + private _deleteBuffer; + protected _format: number; + private _delayedOnLoad; + private _delayedOnError; + private _onLoadObservable; + protected _isBlocking: boolean; + isBlocking: boolean; + readonly samplingMode: number; + constructor(url: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: () => void, onError?: () => void, buffer?: any, deleteBuffer?: boolean, format?: number); + updateURL(url: string): void; + delayLoad(): void; + updateSamplingMode(samplingMode: number): void; + private _prepareRowForTextureGeneration(x, y, z, t); + getTextureMatrix(): Matrix; + getReflectionTextureMatrix(): Matrix; + clone(): Texture; + readonly onLoadObservable: Observable; serialize(): any; + getClassName(): string; + dispose(): void; + static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: () => void, onError?: () => void, format?: number): Texture; + static Parse(parsedTexture: any, scene: Scene, rootUrl: string): BaseTexture; + static LoadFromDataString(name: string, buffer: any, scene: Scene, deleteBuffer?: boolean, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: () => void, onError?: () => void, format?: number): Texture; + } +} + +declare module BABYLON { + class VideoTexture extends Texture { + video: HTMLVideoElement; + private _autoLaunch; + private _lastUpdate; + private _generateMipMaps; + private _setTextureReady; /** - * Parses a JSON object correponding to the serialize function. + * Creates a video texture. + * Sample : https://doc.babylonjs.com/tutorials/01._Advanced_Texturing + * @param {Array} urlsOrVideo can be used to provide an array of urls or an already setup HTML video element. + * @param {BABYLON.Scene} scene is obviously the current scene. + * @param {boolean} generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated). + * @param {boolean} invertY is false by default but can be used to invert video on Y axis + * @param {number} samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default */ - static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial; + constructor(name: string, urlsOrVideo: string[] | HTMLVideoElement, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number); + private __setTextureReady(); + private _createTexture(); + update(): boolean; + dispose(): void; + static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: { + minWidth: number; + maxWidth: number; + minHeight: number; + maxHeight: number; + deviceId: string; + }): void; } } +declare module BABYLON.Internals { +} + declare module BABYLON { class CannonJSPlugin implements IPhysicsEnginePlugin { private _useDeltaForWorldStep; diff --git a/dist/preview release/babylon.worker.js b/dist/preview release/babylon.worker.js index 2462d97379f..c123b3889e0 100644 --- a/dist/preview release/babylon.worker.js +++ b/dist/preview release/babylon.worker.js @@ -9,36 +9,36 @@ o._diffPositionForCollisions=new e.Vector3(0,0,0),o._newPositionForCollisions=ne return function(){return new e.StereoscopicArcRotateCamera(i,0,0,1,e.Vector3.Zero(),n,o,r)};case"StereoscopicFreeCamera":return function(){return new e.StereoscopicFreeCamera(i,e.Vector3.Zero(),n,o,r)};case"StereoscopicGamepadCamera":return function(){return new e.StereoscopicGamepadCamera(i,e.Vector3.Zero(),n,o,r)};case"StereoscopicUniversalCamera":return function(){return new e.StereoscopicUniversalCamera(i,e.Vector3.Zero(),n,o,r)};case"FreeCamera":default:return function(){return new e.UniversalCamera(i,e.Vector3.Zero(),r)}}},i.Parse=function(t,r){var n=t.type,o=i.GetConstructorFromName(n,t.name,r,t.interaxial_distance,t.isStereoscopicSideBySide),s=e.SerializationHelper.Parse(o,t,r);if(t.parentId&&(s._waitingParentId=t.parentId),s.inputs&&(s.inputs.parse(t),s._setupInputs()),s.setPosition&&(s.position.copyFromFloats(0,0,0),s.setPosition(e.Vector3.FromArray(t.position))),t.target&&s.setTarget&&s.setTarget(e.Vector3.FromArray(t.target)),t.cameraRigMode){var a=t.interaxial_distance?{interaxialDistance:t.interaxial_distance}:{};s.setCameraRigMode(t.cameraRigMode,a)}if(t.animations){for(var h=0;hi._alphaIndex?1:e._alphaIndext._distanceToCamera?-1:0},t.frontToBackSortCompare=function(e,t){return e._distanceToCamerat._distanceToCamera?1:0},t.prototype.prepare=function(){this._opaqueSubMeshes.reset(),this._transparentSubMeshes.reset(),this._alphaTestSubMeshes.reset(),this._particleSystems.reset(),this._spriteManagers.reset(),this._edgesRenderers.reset()},t.prototype.dispose=function(){this._opaqueSubMeshes.dispose(),this._transparentSubMeshes.dispose(),this._alphaTestSubMeshes.dispose(),this._particleSystems.dispose(),this._spriteManagers.dispose(),this._edgesRenderers.dispose()},t.prototype.dispatch=function(e){var t=e.getMaterial(),i=e.getMesh();t.needAlphaBlending()||i.visibility<1||i.hasVertexAlpha?this._transparentSubMeshes.push(e):t.needAlphaTesting()?this._alphaTestSubMeshes.push(e):this._opaqueSubMeshes.push(e),i._edgesRenderer&&this._edgesRenderers.push(i._edgesRenderer)},t.prototype.dispatchSprites=function(e){this._spriteManagers.push(e)},t.prototype.dispatchParticles=function(e){this._particleSystems.push(e)},t.prototype._renderParticles=function(e){if(0!==this._particleSystems.length){var t=this._scene.activeCamera;this._scene._particlesDuration.beginMonitoring();for(var i=0;ir.DoubleClickDelay&&!l._doubleClickOccured||e!==l._previousButtonPressed)&&(l._doubleClickOccured=!1,t.singleClick=!0,t.ignore=!1,i(t,l._currentPickResult))},this._initClickEvent=function(n,o,s,a){var h=new t;l._currentPickResult=null;var c,u=n.hasSpecificMask(i.POINTERPICK)||o.hasSpecificMask(i.POINTERPICK)||n.hasSpecificMask(i.POINTERTAP)||o.hasSpecificMask(i.POINTERTAP)||n.hasSpecificMask(i.POINTERDOUBLETAP)||o.hasSpecificMask(i.POINTERDOUBLETAP);if(!u&&e.ActionManager&&e.ActionManager.HasPickTriggers&&(c=l._initActionManager(c,h))&&(u=c.hasPickTriggers),u){var f=s.button;if(h.hasSwiped=Math.abs(l._startingPointerPosition.x-l._pointerX)>r.DragMovementThreshold||Math.abs(l._startingPointerPosition.y-l._pointerY)>r.DragMovementThreshold,!h.hasSwiped){var d=!r.ExclusiveDoubleClickMode;d||(d=!n.hasSpecificMask(i.POINTERDOUBLETAP)&&!o.hasSpecificMask(i.POINTERDOUBLETAP))&&!e.ActionManager.HasSpecificTrigger(e.ActionManager.OnDoublePickTrigger)&&(c=l._initActionManager(c,h))&&(d=!c.hasSpecificTrigger(e.ActionManager.OnDoublePickTrigger)),d?((new Date).getTime()-l._previousStartingPointerTime>r.DoubleClickDelay||f!==l._previousButtonPressed)&&(h.singleClick=!0,a(h,l._currentPickResult)):(l._previousDelayedSimpleClickTimeout=l._delayedSimpleClickTimeout,l._delayedSimpleClickTimeout=window.setTimeout(l._delayedSimpleClick.bind(l,f,h,a),r.DoubleClickDelay));var p=n.hasSpecificMask(i.POINTERDOUBLETAP)||o.hasSpecificMask(i.POINTERDOUBLETAP);!p&&e.ActionManager.HasSpecificTrigger(e.ActionManager.OnDoublePickTrigger)&&(c=l._initActionManager(c,h))&&(p=c.hasSpecificTrigger(e.ActionManager.OnDoublePickTrigger)),p&&(f===l._previousButtonPressed&&(new Date).getTime()-l._previousStartingPointerTimer.LongPressDelay&&Math.abs(this._startingPointerPosition.x-this._pointerX)0&&(h=l.pickSprite(l._unTranslatedPointerX,l._unTranslatedPointerY,c,!1,l.cameraToUseForPointers))&&h.hit&&h.pickedSprite&&h.pickedSprite.actionManager){switch(l._pickedDownSprite=h.pickedSprite,t.button){case 0:h.pickedSprite.actionManager.processTrigger(e.ActionManager.OnLeftPickTrigger,e.ActionEvent.CreateNewFromSprite(h.pickedSprite,l,t));break;case 1:h.pickedSprite.actionManager.processTrigger(e.ActionManager.OnCenterPickTrigger,e.ActionEvent.CreateNewFromSprite(h.pickedSprite,l,t));break;case 2:h.pickedSprite.actionManager.processTrigger(e.ActionManager.OnRightPickTrigger,e.ActionEvent.CreateNewFromSprite(h.pickedSprite,l,t))}h.pickedSprite.actionManager&&h.pickedSprite.actionManager.processTrigger(e.ActionManager.OnPickDownTrigger,e.ActionEvent.CreateNewFromSprite(h.pickedSprite,l,t))}}},this._onPointerUp=function(t){l._isButtonPressed=!1,l._pickedUpMesh=null,l._meshPickProceed=!1,l._updatePointerPosition(t),l._initClickEvent(l.onPrePointerObservable,l.onPointerObservable,t,function(s,a){if(this.onPrePointerObservable.hasObservers())if(s.ignore){var h=i.POINTERUP,l=new n(h,t,this._unTranslatedPointerX,this._unTranslatedPointerY);if(this.onPrePointerObservable.notifyObservers(l,h),l.skipOnPointerObservable)return}else if(!s.hasSwiped){if(s.singleClick&&this.onPrePointerObservable.hasSpecificMask(i.POINTERTAP)){var h=i.POINTERTAP,l=new n(h,t,this._unTranslatedPointerX,this._unTranslatedPointerY);if(this.onPrePointerObservable.notifyObservers(l,h),l.skipOnPointerObservable)return}if(s.doubleClick&&this.onPrePointerObservable.hasSpecificMask(i.POINTERDOUBLETAP)){var h=i.POINTERDOUBLETAP,l=new n(h,t,this._unTranslatedPointerX,this._unTranslatedPointerY);if(this.onPrePointerObservable.notifyObservers(l,h),l.skipOnPointerObservable)return}}if(this.cameraToUseForPointers||this.activeCamera){if(this.pointerUpPredicate||(this.pointerUpPredicate=function(e){return e.isPickable&&e.isVisible&&e.isReady()&&e.isEnabled()}),!this._meshPickProceed&&(e.ActionManager&&e.ActionManager.HasTriggers||this.onPointerObservable.hasObservers())&&this._initActionManager(null,s),a||(a=this._currentPickResult),a&&a&&a.pickedMesh){if(this._pickedUpMesh=a.pickedMesh,this._pickedDownMesh===this._pickedUpMesh&&(this.onPointerPick&&this.onPointerPick(t,a),s.singleClick&&!s.ignore&&this.onPointerObservable.hasObservers())){var h=i.POINTERPICK,l=new o(h,t,a);this.onPointerObservable.notifyObservers(l,h)}a.pickedMesh.actionManager&&(s.ignore&&a.pickedMesh.actionManager.processTrigger(e.ActionManager.OnPickUpTrigger,e.ActionEvent.CreateNew(a.pickedMesh,t)),s.hasSwiped||s.ignore||!s.singleClick||a.pickedMesh.actionManager.processTrigger(e.ActionManager.OnPickTrigger,e.ActionEvent.CreateNew(a.pickedMesh,t)),s.doubleClick&&!s.ignore&&a.pickedMesh.actionManager.hasSpecificTrigger(e.ActionManager.OnDoublePickTrigger)&&a.pickedMesh.actionManager.processTrigger(e.ActionManager.OnDoublePickTrigger,e.ActionEvent.CreateNew(a.pickedMesh,t)))}if(this._pickedDownMesh&&this._pickedDownMesh.actionManager&&this._pickedDownMesh.actionManager.hasSpecificTrigger(e.ActionManager.OnPickOutTrigger)&&this._pickedDownMesh!==this._pickedUpMesh&&this._pickedDownMesh.actionManager.processTrigger(e.ActionManager.OnPickOutTrigger,e.ActionEvent.CreateNew(this._pickedDownMesh,t)),this.onPointerUp&&this.onPointerUp(t,a),this.onPointerObservable.hasObservers())if(s.ignore){var h=i.POINTERUP,l=new o(h,t,a);this.onPointerObservable.notifyObservers(l,h)}else if(!s.hasSwiped){if(s.singleClick&&this.onPointerObservable.hasSpecificMask(i.POINTERTAP)){var h=i.POINTERTAP,l=new o(h,t,a);this.onPointerObservable.notifyObservers(l,h)}if(s.doubleClick&&this.onPointerObservable.hasSpecificMask(i.POINTERDOUBLETAP)){var h=i.POINTERDOUBLETAP,l=new o(h,t,a);this.onPointerObservable.notifyObservers(l,h)}}this.spriteManagers.length>0&&(a=this.pickSprite(this._unTranslatedPointerX,this._unTranslatedPointerY,c,!1,this.cameraToUseForPointers),a.hit&&a.pickedSprite&&a.pickedSprite.actionManager&&(a.pickedSprite.actionManager.processTrigger(e.ActionManager.OnPickUpTrigger,e.ActionEvent.CreateNewFromSprite(a.pickedSprite,this,t)),a.pickedSprite.actionManager&&Math.abs(this._startingPointerPosition.x-this._pointerX)0)return!1;var t;for(t=0;tr&&o>0&&(o*=-1),this.stopAnimation(t),a||(a=new e.Animatable(this,t,i,r,n,o,s)),t.animations&&a.appendAnimations(t,t.animations),t.getAnimatables)for(var h=t.getAnimatables(),l=0;l0)return;this._animationTimeLast=t}var i=(t-this._animationTimeLast)*this.animationTimeScale;this._animationTime+=i,this._animationTimeLast=t;for(var r=0;r0?this.activeCamera=this.cameras[0]:this.activeCamera=null),this.onCameraRemovedObservable.notifyObservers(e),t},r.prototype.addLight=function(e){e.uniqueId=this.getUniqueId(),this.lights.push(e),this.sortLightsByPriority(),this.onNewLightAddedObservable.notifyObservers(e)},r.prototype.sortLightsByPriority=function(){this.requireLightSorting&&this.lights.sort(e.Light.compareLightsPriority)},r.prototype.addCamera=function(e){e.uniqueId=this.getUniqueId();this.cameras.push(e);this.onNewCameraAddedObservable.notifyObservers(e)},r.prototype.switchActiveCamera=function(e,t){void 0===t&&(t=!0);var i=this._engine.getRenderingCanvas();this.activeCamera.detachControl(i),this.activeCamera=e,t&&e.attachControl(i)},r.prototype.setActiveCameraByID=function(e){var t=this.getCameraByID(e);return t?(this.activeCamera=t,t):null},r.prototype.setActiveCameraByName=function(e){var t=this.getCameraByName(e);return t?(this.activeCamera=t,t):null},r.prototype.getMaterialByID=function(e){for(var t=0;t-1&&(this._geometries.splice(t,1),this.collisionCoordinator&&this.collisionCoordinator.onGeometryDeleted(e),this.onGeometryRemovedObservable.notifyObservers(e),!0)},r.prototype.getGeometries=function(){return this._geometries},r.prototype.getMeshByID=function(e){for(var t=0;t=0;t--)if(this.meshes[t].id===e)return this.meshes[t];return null},r.prototype.getLastEntryByID=function(e){var t;for(t=this.meshes.length-1;t>=0;t--)if(this.meshes[t].id===e)return this.meshes[t];for(t=this.cameras.length-1;t>=0;t--)if(this.cameras[t].id===e)return this.cameras[t];for(t=this.lights.length-1;t>=0;t--)if(this.lights[t].id===e)return this.lights[t];return null},r.prototype.getNodeByID=function(e){var t=this.getMeshByID(e);if(t)return t;var i=this.getLightByID(e);if(i)return i;var r=this.getCameraByID(e);return r||this.getBoneByID(e)},r.prototype.getNodeByName=function(e){var t=this.getMeshByName(e);if(t)return t;var i=this.getLightByName(e);if(i)return i;var r=this.getCameraByName(e);return r||this.getBoneByName(e)},r.prototype.getMeshByName=function(e){for(var t=0;t=0;t--)if(this.skeletons[t].id===e)return this.skeletons[t];return null},r.prototype.getSkeletonById=function(e){for(var t=0;t0&&0!=(o.layerMask&this.activeCamera.layerMask)&&o.isInFrustum(this._frustumPlanes))&&(this._activeMeshes.push(o),this.activeCamera._activeMeshes.push(o),o._activate(this._renderId),this._activeMesh(o,s)))}}this._particlesDuration.beginMonitoring();e.Tools.Now;if(this.particlesEnabled){e.Tools.StartPerformanceCounter("Particles",this.particleSystems.length>0);for(var a=0;a0)}this._particlesDuration.endMonitoring(!1)},r.prototype._activeMesh=function(e,t){if(t.skeleton&&this.skeletonsEnabled&&(this._activeSkeletons.pushNoDuplicate(t.skeleton)&&t.skeleton.prepare(),t.computeBonesUsingShaders||this._softwareSkinnedMeshes.pushNoDuplicate(t)),(e.showBoundingBox||this.forceShowBoundingBoxes)&&this.getBoundingBoxRenderer().renderList.push(e.getBoundingInfo().boundingBox),t&&t.subMeshes){var i,r;if(t._submeshesOctree&&t.useOctreeForRenderingSelection){var n=t._submeshesOctree.select(this._frustumPlanes);i=n.length,r=n.data}else r=t.subMeshes,i=r.length;for(var o=0;o0&&this._renderTargets.concatWithNoDuplicate(t.customRenderTargets),this.renderTargetsEnabled&&this._renderTargets.length>0){this._intermediateRendering=!0,e.Tools.StartPerformanceCounter("Render targets",this._renderTargets.length>0);for(var s=0;s0),this._intermediateRendering=!1,this._renderId++,o=!0}var l=this._engine.getStencilBuffer(),c=!1;if(this.renderTargetsEnabled&&this.highlightLayers&&this.highlightLayers.length>0){this._intermediateRendering=!0;for(var u=0;u-1)){c=!0;var a=f._mainTexture;a._shouldRender()&&(this._renderId++,a.render(!1,!1),o=!0)}}this._intermediateRendering=!1,this._renderId++}o&&i.restoreDefaultFramebuffer(),this._renderTargetsDuration.endMonitoring(!1),this.postProcessManager._prepareFrame(),this._renderDuration.beginMonitoring();var d,p;if(this.layers.length){for(i.setDepthBuffer(!1),d=0;d0);for(var m=0;m0)}if(this.layers.length){for(i.setDepthBuffer(!1),d=0;d-1&&(n.trigger===e.ActionManager.OnIntersectionExitTrigger&&n._executeCurrent(e.ActionEvent.CreateNew(i,null,s)),i.actionManager.hasSpecificTrigger(e.ActionManager.OnIntersectionExitTrigger)&&n.trigger!==e.ActionManager.OnIntersectionExitTrigger||i._intersectionsInProgress.splice(h,1))}}},r.prototype.render=function(){if(!this.isDisposed){this._lastFrameDuration.beginMonitoring(),this._particlesDuration.fetchNewFrame(),this._spritesDuration.fetchNewFrame(),this._activeParticles.fetchNewFrame(),this._renderDuration.fetchNewFrame(),this._renderTargetsDuration.fetchNewFrame(),this._evaluateActiveMeshesDuration.fetchNewFrame(),this._totalVertices.fetchNewFrame(),this._activeIndices.fetchNewFrame(),this._activeBones.fetchNewFrame(),this.getEngine().drawCallsPerfCounter.fetchNewFrame(),this._meshesForIntersections.reset(),this.resetCachedMaterial(),e.Tools.StartPerformanceCounter("Scene rendering"),this.actionManager&&this.actionManager.processTrigger(e.ActionManager.OnEveryFrameTrigger,null),this.simplificationQueue&&!this.simplificationQueue.running&&this.simplificationQueue.executeNext();var t=Math.max(r.MinDeltaTime,Math.min(this._engine.getDeltaTime(),r.MaxDeltaTime));this._animationRatio=.06*t,this._animate(),this._physicsEngine&&(e.Tools.StartPerformanceCounter("Physics"),this._physicsEngine._step(t/1e3),e.Tools.EndPerformanceCounter("Physics")),this.onBeforeRenderObservable.notifyObservers(this),this._renderTargetsDuration.beginMonitoring();var i=(e.Tools.Now,this.getEngine()),n=this.activeCamera;if(this.renderTargetsEnabled){e.Tools.StartPerformanceCounter("Custom render targets",this.customRenderTargets.length>0);for(var o=0;o0),this._renderId++}if(this.customRenderTargets.length>0&&i.restoreDefaultFramebuffer(),this._renderTargetsDuration.endMonitoring(),this.activeCamera=n,this.proceduralTexturesEnabled){e.Tools.StartPerformanceCounter("Procedural textures",this._proceduralTextures.length>0);for(var a=0;a0)} if((this.autoClearDepthAndStencil||this.autoClear)&&this._engine.clear(this.clearColor,this.autoClear||this.forceWireframe||this.forcePointsCloud,this.autoClearDepthAndStencil,this.autoClearDepthAndStencil),this.shadowsEnabled)for(var l=0;l0)for(var d=0;d0&&this._engine.clear(null,!1,!0,!0),this._processSubCameras(this.activeCameras[d]);else{if(!this.activeCamera)throw new Error("No camera defined");this._processSubCameras(this.activeCamera)}this._checkIntersections(),e.AudioEngine&&this._updateAudioParameters(),this.afterRender&&this.afterRender(),this.onAfterRenderObservable.notifyObservers(this);for(var p=0;p0?this.activeCameras[0]:this.activeCamera)&&i.canUseWebAudio){i.audioContext.listener.setPosition(t.position.x,t.position.y,t.position.z),t.rigCameras&&t.rigCameras.length>0&&(t=t.rigCameras[0]);var r=e.Matrix.Invert(t.getViewMatrix()),n=e.Vector3.TransformNormal(new e.Vector3(0,0,-1),r);n.normalize(),isNaN(n.x)||isNaN(n.y)||isNaN(n.z)||i.audioContext.listener.setOrientation(n.x,n.y,n.z,0,1,0);var o;for(o=0;o-1&&this._engine.scenes.splice(t,1),this._engine.wipeCaches(),this._engine=null,this.defaultMaterial=null,this.multiMaterials=null,this.materials=null},Object.defineProperty(r.prototype,"isDisposed",{get:function(){return!this._engine},enumerable:!0,configurable:!0}),r.prototype.disposeSounds=function(){this.mainSoundTrack.dispose();for(var e=0;e=n.distance))&&(n=l,r)))break}return n||new e.PickingInfo},r.prototype._internalMultiPick=function(t,i){if(!e.PickingInfo)return null;for(var r=new Array,n=0;n0)for(var s=0;s=o.distance))&&(o=h,r))break}}return o||new e.PickingInfo},r.prototype.pick=function(e,t,i,r,n){var o=this;return this._internalPick((function(i){return o.createPickingRay(e,t,i,n)}),i,r)},r.prototype.pickSprite=function(e,t,i,r,n){return this._internalPickSprites(this.createPickingRayInCameraSpace(e,t,n),i,r,n)},r.prototype.pickWithRay=function(t,i,r){var n=this;return this._internalPick((function(i){return n._pickWithRayInverseMatrix||(n._pickWithRayInverseMatrix=e.Matrix.Identity()),i.invertToRef(n._pickWithRayInverseMatrix),e.Ray.Transform(t,n._pickWithRayInverseMatrix)}),i,r)},r.prototype.multiPick=function(e,t,i,r){var n=this;return this._internalMultiPick((function(i){return n.createPickingRay(e,t,i,r)}),i)},r.prototype.multiPickWithRay=function(t,i){var r=this;return this._internalMultiPick((function(i){return r._pickWithRayInverseMatrix||(r._pickWithRayInverseMatrix=e.Matrix.Identity()),i.invertToRef(r._pickWithRayInverseMatrix),e.Ray.Transform(t,r._pickWithRayInverseMatrix)}),i)},r.prototype.setPointerOverMesh=function(t){this._pointerOverMesh!==t&&(this._pointerOverMesh&&this._pointerOverMesh.actionManager&&this._pointerOverMesh.actionManager.processTrigger(e.ActionManager.OnPointerOutTrigger,e.ActionEvent.CreateNew(this._pointerOverMesh)),this._pointerOverMesh=t,this._pointerOverMesh&&this._pointerOverMesh.actionManager&&this._pointerOverMesh.actionManager.processTrigger(e.ActionManager.OnPointerOverTrigger,e.ActionEvent.CreateNew(this._pointerOverMesh)))},r.prototype.getPointerOverMesh=function(){return this._pointerOverMesh},r.prototype.setPointerOverSprite=function(t){this._pointerOverSprite!==t&&(this._pointerOverSprite&&this._pointerOverSprite.actionManager&&this._pointerOverSprite.actionManager.processTrigger(e.ActionManager.OnPointerOutTrigger,e.ActionEvent.CreateNewFromSprite(this._pointerOverSprite,this)),this._pointerOverSprite=t,this._pointerOverSprite&&this._pointerOverSprite.actionManager&&this._pointerOverSprite.actionManager.processTrigger(e.ActionManager.OnPointerOverTrigger,e.ActionEvent.CreateNewFromSprite(this._pointerOverSprite,this)))},r.prototype.getPointerOverSprite=function(){return this._pointerOverSprite},r.prototype.getPhysicsEngine=function(){return this._physicsEngine},r.prototype.enablePhysics=function(t,i){if(this._physicsEngine)return!0;try{return this._physicsEngine=new e.PhysicsEngine(t,i),!0}catch(t){return e.Tools.Error(t.message),!1}},r.prototype.disablePhysicsEngine=function(){this._physicsEngine&&(this._physicsEngine.dispose(),this._physicsEngine=void 0)},r.prototype.isPhysicsEnabled=function(){return void 0!==this._physicsEngine},r.prototype.deleteCompoundImpostor=function(e){var t=e.parts[0].mesh;t.physicsImpostor.dispose(),t.physicsImpostor=null},r.prototype.createDefaultCameraOrLight=function(t,i,r){if(void 0===t&&(t=!1),void 0===i&&(i=!1),void 0===r&&(r=!1),i&&(this.activeCamera&&(this.activeCamera.dispose(),this.activeCamera=null),this.lights))for(var n=0;n=0&&this._scene.textures.splice(e,1),void 0!==this._texture&&(this.releaseInternalTexture(),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear())},t.prototype.serialize=function(){if(!this.name)return null;var t=e.SerializationHelper.Serialize(this);return e.Animation.AppendSerializedAnimations(this,t),t},t.WhenAllReady=function(e,t){var i=e.length;if(0===i)return void t();for(var r,n,o=0;o0},enumerable:!0,configurable:!0}),r.prototype._sortLODLevels=function(){this._LODLevels.sort((function(e,t){return e.distancet.distance?-1:0}))},r.prototype.addLODLevel=function(t,i){if(i&&i._masterMesh)return e.Tools.Warn("You cannot use a mesh as LOD level twice"),this;var r=new e.Internals.MeshLODLevel(t,i);return this._LODLevels.push(r),i&&(i._masterMesh=this),this._sortLODLevels(),this},r.prototype.getLODLevelAtDistance=function(e){for(var t=0;ti)return this.onLODLevelSelection&&this.onLODLevelSelection(i,this,this._LODLevels[this._LODLevels.length-1].mesh),this;for(var r=0;r0){var r=this.getIndices().length,n=!1;if(t)n=!0;else for(var o=0,s=this.subMeshes;o=r){n=!0;break}if(a.verticesStart+a.verticesCount>=i){n=!0;break}}if(!n)return}return this.releaseSubMeshes(),new e.SubMesh(0,0,i,0,this.getTotalIndices(),this)},r.prototype.subdivide=function(t){if(!(t<1)){for(var i=this.getTotalIndices(),r=i/t|0,n=0;r%3!=0;)r++;this.releaseSubMeshes();for(var o=0;o=i);o++)e.SubMesh.CreateFromIndices(0,n,Math.min(r,i-n),this),n+=r;this.synchronizeInstances()}},r.prototype.setVerticesData=function(t,i,r,n){if(this._geometry)this._geometry.setVerticesData(t,i,r,n);else{var o=new e.VertexData;o.set(i,t);var s=this.getScene();new e.Geometry(e.Geometry.RandomId(),s,o,r,this)}return this},r.prototype.markVerticesDataAsUpdatable=function(e,t){void 0===t&&(t=!0),this.getVertexBuffer(e).isUpdatable()!==t&&this.setVerticesData(e,this.getVerticesData(e),t)},r.prototype.setVerticesBuffer=function(t){if(!this._geometry){var i=this.getScene();new e.Geometry(e.Geometry.RandomId(),i).applyToMesh(this)}return this._geometry.setVerticesBuffer(t),this},r.prototype.updateVerticesData=function(e,t,i,r){if(this._geometry)return r?(this.makeGeometryUnique(),this.updateVerticesData(e,t,i,!1)):this._geometry.updateVerticesData(e,t,i),this},r.prototype.updateMeshPositions=function(t,i){void 0===i&&(i=!0);var r=this.getVerticesData(e.VertexBuffer.PositionKind);if(t(r),this.updateVerticesData(e.VertexBuffer.PositionKind,r,!1,!1),i){var n=this.getIndices(),o=this.getVerticesData(e.VertexBuffer.NormalKind);e.VertexData.ComputeNormals(r,n,o),this.updateVerticesData(e.VertexBuffer.NormalKind,o,!1,!1)}return this},r.prototype.makeGeometryUnique=function(){if(this._geometry){var t=this._geometry,i=this._geometry.copy(e.Geometry.RandomId());return t.releaseForMesh(this,!0),i.applyToMesh(this),this}},r.prototype.setIndices=function(t,i){if(this._geometry)this._geometry.setIndices(t,i);else{var r=new e.VertexData;r.indices=t;var n=this.getScene();new e.Geometry(e.Geometry.RandomId(),n,r,!1,this)}return this},r.prototype.toLeftHanded=function(){if(this._geometry)return this._geometry.toLeftHanded(),this},r.prototype._bind=function(t,i,r){var n,o=this.getScene().getEngine();if(this._unIndexed)n=null;else switch(r){case e.Material.PointFillMode:n=null;break;case e.Material.WireFrameFillMode:n=t.getLinesIndexBuffer(this.getIndices(),o);break;default:case e.Material.TriangleFillMode:n=this._unIndexed?null:this._geometry.getIndexBuffer()}return this._geometry._bind(i,n),this},r.prototype._draw=function(t,i,r){if(!this._geometry||!this._geometry.getVertexBuffers()||!this._geometry.getIndexBuffer())return this;this.onBeforeDrawObservable.notifyObservers(this);var n=this.getScene().getEngine();switch(i){case e.Material.PointFillMode:n.drawPointClouds(t.verticesStart,t.verticesCount,r);break;case e.Material.WireFrameFillMode:this._unIndexed?n.drawUnIndexed(!1,t.verticesStart,t.verticesCount,r):n.draw(!1,0,r>0?t.linesIndexCount/2:t.linesIndexCount,r);break;default:this._unIndexed?n.drawUnIndexed(!0,t.verticesStart,t.verticesCount,r):n.draw(!0,t.indexStart,t.indexCount,r)}return this},r.prototype.registerBeforeRender=function(e){return this.onBeforeRenderObservable.add(e),this},r.prototype.unregisterBeforeRender=function(e){return this.onBeforeRenderObservable.removeCallback(e),this},r.prototype.registerAfterRender=function(e){return this.onAfterRenderObservable.add(e),this},r.prototype.unregisterAfterRender=function(e){return this.onAfterRenderObservable.removeCallback(e),this},r.prototype._getInstancesRenderList=function(e){var t=this.getScene();if(this._batchCache.mustReturn=!1,this._batchCache.renderSelf[e]=this.isEnabled()&&this.isVisible,this._batchCache.visibleInstances[e]=null,this._visibleInstances){var i=t.getRenderId(),r=t._isInIntermediateRendering()?this._visibleInstances.intermediateDefaultRenderId:this._visibleInstances.defaultRenderId;this._batchCache.visibleInstances[e]=this._visibleInstances[i];var n=this._renderId;if(!this._batchCache.visibleInstances[e]&&r&&(this._batchCache.visibleInstances[e]=this._visibleInstances[r],i=Math.max(r,i),n=Math.max(this._visibleInstances.selfDefaultRenderId,i)),this._batchCache.visibleInstances[e]&&this._batchCache.visibleInstances[e].length){if(this._renderIdForInstances[e]===i)return this._batchCache.mustReturn=!0,this._batchCache;i!==n&&(this._batchCache.renderSelf[e]=!1)}this._renderIdForInstances[e]=i}return this._batchCache},r.prototype._renderWithInstances=function(t,i,r,n,o){for(var s=r.visibleInstances[t._id],a=s.length+1,h=16*a*4,l=this._instancesBufferSize,c=this._instancesBuffer;this._instancesBufferSize-1;t--)if(i[t].id===e)return this.material=i[t],this;var r=this.getScene().multiMaterials;for(t=r.length-1;t>-1;t--)if(r[t].id===e)return this.material=r[t],this;return this},r.prototype.getAnimatables=function(){var e=[];return this.material&&e.push(this.material),this.skeleton&&e.push(this.skeleton),e},r.prototype.bakeTransformIntoVertices=function(t){if(!this.isVerticesDataPresent(e.VertexBuffer.PositionKind))return this;var i=this.subMeshes.splice(0);this._resetPointsArrayCache();var r,n=this.getVerticesData(e.VertexBuffer.PositionKind),o=[];for(r=0;r-1&&(o.morphTargetManager=i.getMorphTargetManagerById(t.morphTargetManagerId)),t.skeletonId>-1&&(o.skeleton=i.getLastSkeletonByID(t.skeletonId),t.numBoneInfluencers&&(o.numBoneInfluencers=t.numBoneInfluencers)),t.animations){for(var s=0;s4,l=h?this.getVerticesData(e.VertexBuffer.MatricesIndicesExtraKind):null,c=h?this.getVerticesData(e.VertexBuffer.MatricesWeightsExtraKind):null,u=t.getTransformMatrices(this),f=e.Vector3.Zero(),d=new e.Matrix,p=new e.Matrix,m=0,_=0;_0;o++)e.Matrix.FromFloat32ArrayToRefScaled(u,16*s[m+o],g,p),d.addToSelf(p);if(h)for(o=0;o<4&&(g=c[m+o])>0;o++)e.Matrix.FromFloat32ArrayToRefScaled(u,16*l[m+o],g,p),d.addToSelf(p);e.Vector3.TransformCoordinatesFromFloatsToRef(this._sourcePositions[_],this._sourcePositions[_+1],this._sourcePositions[_+2],d,f),f.toArray(r,_),e.Vector3.TransformNormalFromFloatsToRef(this._sourceNormals[_],this._sourceNormals[_+1],this._sourceNormals[_+2],d,f),f.toArray(n,_),d.reset()}return this.updateVerticesData(e.VertexBuffer.PositionKind,r),this.updateVerticesData(e.VertexBuffer.NormalKind,n),this},r.MinMax=function(e){var t=null,i=null;return e.forEach((function(e,r,n){var o=e.getBoundingInfo().boundingBox;t?(t.MinimizeInPlace(o.minimumWorld),i.MaximizeInPlace(o.maximumWorld)):(t=o.minimumWorld,i=o.maximumWorld)})),{min:t,max:i}},r.Center=function(t){var i=t instanceof Array?e.Mesh.MinMax(t):t;return e.Vector3.Center(i.min,i.max)},r.MergeMeshes=function(t,i,n,o,s){void 0===i&&(i=!0);var a;if(!n){var h=0;for(a=0;a65536)return e.Tools.Warn("Cannot merge meshes because resulting mesh will have more than 65536 vertices. Please use allow32BitsIndices = true to use 32 bits indices"),null}var l,c,u,f=new Array;for(a=0;aa&&(a=c)}return new i(e,s,a-s+1,t,r,n,o)},i})(t);e.SubMesh=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(BABYLON){var EffectFallbacks=(function(){function e(){this._defines={},this._currentRank=32,this._maxRank=-1}return e.prototype.addFallback=function(e,t){this._defines[e]||(ethis._maxRank&&(this._maxRank=e),this._defines[e]=new Array),this._defines[e].push(t)},e.prototype.addCPUSkinningFallback=function(e,t){this._meshRank=e,this._mesh=t,ethis._maxRank&&(this._maxRank=e)},Object.defineProperty(e.prototype,"isMoreFallbacks",{get:function(){return this._currentRank<=this._maxRank},enumerable:!0,configurable:!0}),e.prototype.reduce=function(e){if(this._mesh&&this._mesh.computeBonesUsingShaders&&this._mesh.numBoneInfluencers>0){this._mesh.computeBonesUsingShaders=!1,e=e.replace("#define NUM_BONE_INFLUENCERS "+this._mesh.numBoneInfluencers,"#define NUM_BONE_INFLUENCERS 0"),BABYLON.Tools.Log("Falling back to CPU skinning for "+this._mesh.name);for(var t=this._mesh.getScene(),i=0;i0&&(r.computeBonesUsingShaders=!1)}}else{var n=this._defines[this._currentRank];if(n)for(var i=0;i-1?e:BABYLON.Engine.ShadersRepository+e,BABYLON.Tools.LoadFile(i+".vertex.fx",t)},Effect.prototype._loadFragmentShader=function(e,t){if(e instanceof HTMLElement){return void t(BABYLON.Tools.GetDOMTextContent(e))}if("base64:"===e.substr(0,7)){return void t(window.atob(e.substr(7)))}if(Effect.ShadersStore[e+"PixelShader"])return void t(Effect.ShadersStore[e+"PixelShader"]);if(Effect.ShadersStore[e+"FragmentShader"])return void t(Effect.ShadersStore[e+"FragmentShader"]);var i;i="."===e[0]||"/"===e[0]||e.indexOf("http")>-1?e:BABYLON.Engine.ShadersRepository+e,BABYLON.Tools.LoadFile(i+".fragment.fx",t)},Effect.prototype._dumpShadersSource=function(e,t,i){var r=this._engine.webGLVersion>1?"#version 300 es\n":"",n=r+(i?i+"\n":"");e=n+e,t=n+t;var o=2,s="\n1\t"+e.replace(/\n/gm,(function(){return"\n"+o+++"\t"}));o=2;var a="\n1\t"+t.replace(/\n/gm,(function(){return"\n"+o+++"\t"}));this.name.vertexElement?(BABYLON.Tools.Error("Vertex shader: "+this.name.vertexElement+s),BABYLON.Tools.Error("Fragment shader: "+this.name.fragmentElement+a)):this.name.vertex?(BABYLON.Tools.Error("Vertex shader: "+this.name.vertex+s),BABYLON.Tools.Error("Fragment shader: "+this.name.fragment+a)):(BABYLON.Tools.Error("Vertex shader: "+this.name+s),BABYLON.Tools.Error("Fragment shader: "+this.name+a))},Effect.prototype._processShaderConversion=function(e,t,i){var r=this._processPrecision(e);if(1==this._engine.webGLVersion)return void i(r);if(-1!==r.indexOf("#version 3"))return void i(r.replace("#version 300 es",""));var n=r.replace(/#extension.+(GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth).+enable/g,"");n=n.replace(/varying(?![\n\r])\s/g,t?"in ":"out "),n=n.replace(/attribute[ \t]/g,"in "),n=n.replace(/[ \t]attribute/g," in"),t&&(n=n.replace(/texture2DLodEXT\(/g,"textureLod("),n=n.replace(/textureCubeLodEXT\(/g,"textureLod("),n=n.replace(/texture2D\(/g,"texture("),n=n.replace(/textureCube\(/g,"texture("),n=n.replace(/gl_FragDepthEXT/g,"gl_FragDepth"),n=n.replace(/gl_FragColor/g,"glFragColor"),n=n.replace(/void\s+?main\(/g,"out vec4 glFragColor;\nvoid main(")),i(n)},Effect.prototype._processIncludes=function(e,t){for(var i=this,r=/#include<(.+)>(\((.*)\))*(\[(.*)\])*/g,n=r.exec(e),o=new String(e);null!=n;){var s=n[1];if(-1!==s.indexOf("__decl__")&&(s=s.replace(/__decl__/,""),1!=this._engine.webGLVersion&&(s=s.replace(/Vertex/,"Ubo"),s=s.replace(/Fragment/,"Ubo")),s+="Declaration"),!Effect.IncludesShadersStore[s]){var a=BABYLON.Engine.ShadersRepository+"ShadersInclude/"+s+".fx";return void BABYLON.Tools.LoadFile(a,(function(e){Effect.IncludesShadersStore[s]=e,i._processIncludes(o,t)}))}var h=Effect.IncludesShadersStore[s];if(n[2])for(var l=n[3].split(","),c=0;c1)for(var s in this._uniformBuffersNames)this.bindUniformBlock(s,this._uniformBuffersNames[s]);this._uniforms=o.getUniforms(this._program,this._uniformsNames),this._attributes=o.getAttributes(this._program,i);var a;for(a=0;a0&&(result+=line+"\r\n")}return result},Effect.prototype._evaluateDefinesOnString=function(e){for(var t={children:[]},i=t,r=e.split("\n"),n=0;n0,i.NUM_MORPH_INFLUENCERS=s.numInfluencers}else i.MORPHTARGETS_TANGENT=!1,i.MORPHTARGETS_NORMAL=!1,i.MORPHTARGETS=!1,i.NUM_MORPH_INFLUENCERS=0;return!0},t.PrepareDefinesForLights=function(t,i,r,n,o,s){if(void 0===o&&(o=4),void 0===s&&(s=!1),!r._areLightsDirty)return r._needNormals;var a=0,h=!1,l=!1,c=!1,u=!1,f=!1;if(t.lightsEnabled&&!s)for(var d=0,p=i._lightSources;d0&&t.addFallback(r,"LIGHT"+r),e["SHADOW"+r]&&t.addFallback(0,"SHADOW"+r),e["SHADOWPCF"+r]&&t.addFallback(0,"SHADOWPCF"+r),e["SHADOWESM"+r]&&t.addFallback(0,"SHADOWESM"+r)},t.PrepareAttributesForMorphTargets=function(t,i,r){var n=r.NUM_MORPH_INFLUENCERS;if(n>0)for(var o=e.Engine.LastCreatedEngine.getCaps().maxVertexAttribs,s=i.morphTargetManager,a=s.supportsNormals&&r.NORMAL,h=s.supportsTangents&&r.TANGENT,l=0;lo&&e.Tools.Error("Cannot add more vertex attributes for mesh "+i.name)},t.PrepareAttributesForBones=function(t,i,r,n){r.NUM_BONE_INFLUENCERS>0&&(n.addCPUSkinningFallback(0,i),t.push(e.VertexBuffer.MatricesIndicesKind),t.push(e.VertexBuffer.MatricesWeightsKind),r.NUM_BONE_INFLUENCERS>4&&(t.push(e.VertexBuffer.MatricesIndicesExtraKind),t.push(e.VertexBuffer.MatricesWeightsExtraKind)))},t.PrepareAttributesForInstances=function(e,t){t.INSTANCES&&(e.push("world0"),e.push("world1"),e.push("world2"),e.push("world3"))},t.BindLightShadow=function(e,t,i,r,n){if(e.shadowEnabled&&i.receiveShadows){var o=e.getShadowGenerator();o&&o.bindShadowLight(r,n)}},t.BindLightProperties=function(e,t,i){e.transferToEffect(t,i+"")},t.BindLights=function(i,r,n,o,s,a){void 0===s&&(s=4),void 0===a&&(a=!1);for(var h=0,l=0,c=r._lightSources;l1,n||this._scene.materials.push(this)}return Object.defineProperty(t,"TriangleFillMode",{get:function(){return t._TriangleFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(t,"WireFrameFillMode",{get:function(){return t._WireFrameFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(t,"PointFillMode",{get:function(){return t._PointFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(t,"ClockWiseSideOrientation",{get:function(){return t._ClockWiseSideOrientation},enumerable:!0,configurable:!0}),Object.defineProperty(t,"CounterClockWiseSideOrientation",{get:function(){return t._CounterClockWiseSideOrientation},enumerable:!0,configurable:!0}),Object.defineProperty(t,"TextureDirtyFlag",{get:function(){return t._TextureDirtyFlag},enumerable:!0,configurable:!0}),Object.defineProperty(t,"LightDirtyFlag",{get:function(){return t._LightDirtyFlag},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FresnelDirtyFlag",{get:function(){return t._FresnelDirtyFlag},enumerable:!0,configurable:!0}),Object.defineProperty(t,"AttributesDirtyFlag",{get:function(){return t._AttributesDirtyFlag},enumerable:!0,configurable:!0}),Object.defineProperty(t,"MiscDirtyFlag",{get:function(){return t._MiscDirtyFlag},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"backFaceCulling",{get:function(){return this._backFaceCulling},set:function(e){this._backFaceCulling!==e&&(this._backFaceCulling=e,this.markAsDirty(t.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onBind",{set:function(e){this._onBindObserver&&this.onBindObservable.remove(this._onBindObserver),this._onBindObserver=this.onBindObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"fogEnabled",{get:function(){return this._fogEnabled},set:function(e){this._fogEnabled!==e&&(this._fogEnabled=e,this.markAsDirty(t.MiscDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"wireframe",{get:function(){return this._fillMode===t.WireFrameFillMode},set:function(e){this._fillMode=e?t.WireFrameFillMode:t.TriangleFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"pointsCloud",{get:function(){return this._fillMode===t.PointFillMode},set:function(e){this._fillMode=e?t.PointFillMode:t.TriangleFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"fillMode",{get:function(){return this._fillMode},set:function(e){this._fillMode!==e&&(this._fillMode=e,this.markAsDirty(t.MiscDirtyFlag))},enumerable:!0,configurable:!0}),t.prototype.toString=function(e){return"Name: "+this.name},t.prototype.getClassName=function(){return"Material"},Object.defineProperty(t.prototype,"isFrozen",{get:function(){return this.checkReadyOnlyOnce},enumerable:!0,configurable:!0}),t.prototype.freeze=function(){this.checkReadyOnlyOnce=!0},t.prototype.unfreeze=function(){this.checkReadyOnlyOnce=!1},t.prototype.isReady=function(e,t){return!0},t.prototype.isReadyForSubMesh=function(e,t,i){return!1},t.prototype.getEffect=function(){return this._effect},t.prototype.getScene=function(){return this._scene},t.prototype.needAlphaBlending=function(){return this.alpha<1},t.prototype.needAlphaTesting=function(){return!1},t.prototype.getAlphaTestTexture=function(){return null},t.prototype.markDirty=function(){this._wasPreviouslyReady=!1},t.prototype._preBind=function(e){var i=this._scene.getEngine(),r=this.sideOrientation===t.ClockWiseSideOrientation;i.enableEffect(e||this._effect),i.setState(this.backFaceCulling,this.zOffset,!1,r)},t.prototype.bind=function(e,t){},t.prototype.bindForSubMesh=function(e,t,i){},t.prototype.bindOnlyWorldMatrix=function(e){},t.prototype.bindSceneUniformBuffer=function(e,t){t.bindToEffect(e,"Scene")},t.prototype.bindView=function(e){this._useUBO?this.bindSceneUniformBuffer(e,this.getScene().getSceneUniformBuffer()):e.setMatrix("view",this.getScene().getViewMatrix())},t.prototype.bindViewProjection=function(e){this._useUBO?this.bindSceneUniformBuffer(e,this.getScene().getSceneUniformBuffer()):e.setMatrix("viewProjection",this.getScene().getTransformMatrix())},t.prototype._afterBind=function(e){if(this._scene._cachedMaterial=this,this.onBindObservable.notifyObservers(e),this.disableDepthWrite){var t=this._scene.getEngine();this._cachedDepthWriteState=t.getDepthWrite(),t.setDepthWrite(!1)}},t.prototype.unbind=function(){if(this.onUnBindObservable.notifyObservers(this),this.disableDepthWrite){this._scene.getEngine().setDepthWrite(this._cachedDepthWriteState)}},t.prototype.getActiveTextures=function(){return[]},t.prototype.hasTexture=function(e){return!1},t.prototype.clone=function(e){return null},t.prototype.getBindedMeshes=function(){for(var e=new Array,t=0;t=0&&this._scene.materials.splice(i,1),i=0;ia?a:Math.floor(h);var l,c,u,f,d=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,p=i.uvs,m=i.colors,_=[],g=[],v=[],y=[],x=[],b=[],A=[],T=[],E=[],P=[];if(r.length<2){var M=[],S=[];for(u=0;u0&&(D=C[f].subtract(C[f-1]).length(),B=D+A[c],x[c].push(B),A[c]=B),f++;o&&(f--,_.push(C[0].x,C[0].y,C[0].z),D=C[f].subtract(C[0]).length(),B=D+A[c],x[c].push(B),A[c]=B),E[c]=R+I,P[c]=O,O+=R+I}var L,w,F,N;for(u=0;u1?1:i.arc||1,h=i.slice<=0?1:i.slice||1,l=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,c=new e.Vector3(n/2,o/2,s/2),u=2+r,f=2*u,d=[],p=[],m=[],_=[],g=0;g<=u;g++){for(var v=g/u,y=v*Math.PI*h,x=0;x<=f;x++){var b=x/f,A=b*Math.PI*2*a,T=e.Matrix.RotationZ(-y),E=e.Matrix.RotationY(A),P=e.Vector3.TransformCoordinates(e.Vector3.Up(),T),M=e.Vector3.TransformCoordinates(P,E),S=M.multiply(c),C=M.divide(c).normalize();p.push(S.x,S.y,S.z),m.push(C.x,C.y,C.z),_.push(b,v)}if(g>0)for(var R=p.length/3,O=R-2*(f+1);O+f+21?1:i.arc||1,f=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,d=i.faceUV||new Array(3),p=i.faceColors,m=1!==u&&c?2:0,_=l?h:1,g=2+(1+m)*_;for(r=0;r0&&(i.push(o-1),i.push(o)),o++;var l=new t;return l.indices=i,l.positions=r,l},t.CreateDashedLines=function(i){var r=i.dashSize||3,n=i.gapSize||1,o=i.dashNb||200,s=i.points,a=new Array,h=new Array,l=e.Vector3.Zero(),c=0,u=0,f=0,d=0,p=0,m=0,_=0;for(_=0;_1?1:i.arc||1,c=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE;r.push(0,0,0),s.push(.5,.5);for(var u=2*Math.PI*l,f=u/h,d=0;d=r.length?0:i.type||0,u=i.size,f=i.sizeX||u||1,d=i.sizeY||u||1,p=i.sizeZ||u||1,m=i.custom||r[c],_=m.face.length,g=i.faceUV||new Array(_),v=i.faceColors,y=void 0===i.flat||i.flat,x=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,b=[],A=[],T=[],E=[],P=[],M=0,S=0,C=[],R=0,O=0;if(y)for(O=0;O<_;O++)v&&void 0===v[O]&&(v[O]=new e.Color4(1,1,1,1)),g&&void 0===g[O]&&(g[O]=new e.Vector4(0,0,1,1));if(y)for(O=0;O<_;O++){var I=m.face[O].length;for(s=2*Math.PI/I,a=.5*Math.tan(s/2),h=.5,R=0;Rr.bbSize.y?r.bbSize.x:r.bbSize.y;W=W>r.bbSize.z?W:r.bbSize.z;var H=r.subDiv.X*r.ratio/r.bbSize.x,j=r.subDiv.Y*r.ratio/r.bbSize.y,X=r.subDiv.Z*r.ratio/r.bbSize.z,K=r.subDiv.max*r.subDiv.max;r.facetPartitioning.length=0}for(n=0;n0&&(this._indexBuffer=this._engine.createIndexBuffer(this._indices)),this._indexBuffer&&(this._indexBuffer.references=i)},t.prototype.notifyUpdate=function(e){this.onGeometryUpdated&&this.onGeometryUpdated(this,e);for(var t=0,i=this._meshes;t0){for(var i=0;i0){for(var i=0;i0){for(var i=0;i0){var h=new Float32Array(i,a.positionsAttrDesc.offset,a.positionsAttrDesc.count);r.setVerticesData(e.VertexBuffer.PositionKind,h,!1)}if(a.normalsAttrDesc&&a.normalsAttrDesc.count>0){var l=new Float32Array(i,a.normalsAttrDesc.offset,a.normalsAttrDesc.count);r.setVerticesData(e.VertexBuffer.NormalKind,l,!1)}if(a.uvsAttrDesc&&a.uvsAttrDesc.count>0){var c=new Float32Array(i,a.uvsAttrDesc.offset,a.uvsAttrDesc.count);r.setVerticesData(e.VertexBuffer.UVKind,c,!1)}if(a.uvs2AttrDesc&&a.uvs2AttrDesc.count>0){var u=new Float32Array(i,a.uvs2AttrDesc.offset,a.uvs2AttrDesc.count);r.setVerticesData(e.VertexBuffer.UV2Kind,u,!1)}if(a.uvs3AttrDesc&&a.uvs3AttrDesc.count>0){var f=new Float32Array(i,a.uvs3AttrDesc.offset,a.uvs3AttrDesc.count);r.setVerticesData(e.VertexBuffer.UV3Kind,f,!1)}if(a.uvs4AttrDesc&&a.uvs4AttrDesc.count>0){var d=new Float32Array(i,a.uvs4AttrDesc.offset,a.uvs4AttrDesc.count);r.setVerticesData(e.VertexBuffer.UV4Kind,d,!1)}if(a.uvs5AttrDesc&&a.uvs5AttrDesc.count>0){var p=new Float32Array(i,a.uvs5AttrDesc.offset,a.uvs5AttrDesc.count);r.setVerticesData(e.VertexBuffer.UV5Kind,p,!1)}if(a.uvs6AttrDesc&&a.uvs6AttrDesc.count>0){var m=new Float32Array(i,a.uvs6AttrDesc.offset,a.uvs6AttrDesc.count);r.setVerticesData(e.VertexBuffer.UV6Kind,m,!1)}if(a.colorsAttrDesc&&a.colorsAttrDesc.count>0){var _=new Float32Array(i,a.colorsAttrDesc.offset,a.colorsAttrDesc.count);r.setVerticesData(e.VertexBuffer.ColorKind,_,!1,a.colorsAttrDesc.stride)}if(a.matricesIndicesAttrDesc&&a.matricesIndicesAttrDesc.count>0){var g=new Int32Array(i,a.matricesIndicesAttrDesc.offset,a.matricesIndicesAttrDesc.count);r.setVerticesData(e.VertexBuffer.MatricesIndicesKind,g,!1)}if(a.matricesWeightsAttrDesc&&a.matricesWeightsAttrDesc.count>0){var v=new Float32Array(i,a.matricesWeightsAttrDesc.offset,a.matricesWeightsAttrDesc.count);r.setVerticesData(e.VertexBuffer.MatricesWeightsKind,v,!1)}if(a.indicesAttrDesc&&a.indicesAttrDesc.count>0){var y=new Int32Array(i,a.indicesAttrDesc.offset,a.indicesAttrDesc.count);r.setIndices(y)}if(a.subMeshesAttrDesc&&a.subMeshesAttrDesc.count>0){var x=new Int32Array(i,a.subMeshesAttrDesc.offset,5*a.subMeshesAttrDesc.count);r.subMeshes=[];for(var b=0;b>8),S.push((16711680&C)>>16),S.push(C>>24)}r.setVerticesData(e.VertexBuffer.MatricesIndicesKind,S,i.matricesIndices._updatable)}if(i.matricesIndicesExtra)if(i.matricesIndicesExtra._isExpanded)delete i.matricesIndices._isExpanded,r.setVerticesData(e.VertexBuffer.MatricesIndicesExtraKind,i.matricesIndicesExtra,i.matricesIndicesExtra._updatable);else{for(var S=[],b=0;b>8),S.push((16711680&C)>>16),S.push(C>>24)}r.setVerticesData(e.VertexBuffer.MatricesIndicesExtraKind,S,i.matricesIndicesExtra._updatable)}i.matricesWeights&&(t._CleanMatricesWeights(i.matricesWeights,i.numBoneInfluencers),r.setVerticesData(e.VertexBuffer.MatricesWeightsKind,i.matricesWeights,i.matricesWeights._updatable)),i.matricesWeightsExtra&&(t._CleanMatricesWeights(i.matricesWeightsExtra,i.numBoneInfluencers),r.setVerticesData(e.VertexBuffer.MatricesWeightsExtraKind,i.matricesWeightsExtra,i.matricesWeights._updatable)),r.setIndices(i.indices)}if(i.subMeshes){r.subMeshes=[];for(var R=0;Ra&&(a=t[n+h],s=n+h);t[s]+=Math.max(0,1-o)}},t.Parse=function(i,r,n){if(r.getGeometryByID(i.id))return null;var o=new t(i.id,r,null,i.updatable);return e.Tags&&e.Tags.AddTagsTo(o,i.tags),i.delayLoadingFile?(o.delayLoadState=e.Engine.DELAYLOADSTATE_NOTLOADED,o.delayLoadingFile=n+i.delayLoadingFile,o._boundingInfo=new e.BoundingInfo(e.Vector3.FromArray(i.boundingBoxMinimum),e.Vector3.FromArray(i.boundingBoxMaximum)),o._delayInfo=[],i.hasUVs&&o._delayInfo.push(e.VertexBuffer.UVKind),i.hasUVs2&&o._delayInfo.push(e.VertexBuffer.UV2Kind),i.hasUVs3&&o._delayInfo.push(e.VertexBuffer.UV3Kind),i.hasUVs4&&o._delayInfo.push(e.VertexBuffer.UV4Kind),i.hasUVs5&&o._delayInfo.push(e.VertexBuffer.UV5Kind),i.hasUVs6&&o._delayInfo.push(e.VertexBuffer.UV6Kind),i.hasColors&&o._delayInfo.push(e.VertexBuffer.ColorKind),i.hasMatricesIndices&&o._delayInfo.push(e.VertexBuffer.MatricesIndicesKind),i.hasMatricesWeights&&o._delayInfo.push(e.VertexBuffer.MatricesWeightsKind),o._delayLoadingFunction=e.VertexData.ImportVertexData):e.VertexData.ImportVertexData(i,o),r.pushGeometry(o,!0),o},t})();e.Geometry=t,(function(t){!(function(i){var r=(function(e){function t(t,i,r,n){var o=e.call(this,t,i,null,!1,n)||this;return o._canBeRegenerated=r,o._beingRegenerated=!0,o.regenerate(),o._beingRegenerated=!1,o}return __extends(t,e),t.prototype.canBeRegenerated=function(){return this._canBeRegenerated},t.prototype.regenerate=function(){this._canBeRegenerated&&(this._beingRegenerated=!0,this.setAllVerticesData(this._regenerateVertexData(),!1),this._beingRegenerated=!1)},t.prototype.asNewGeometry=function(t){return e.prototype.copy.call(this,t)},t.prototype.setAllVerticesData=function(t,i){this._beingRegenerated&&e.prototype.setAllVerticesData.call(this,t,!1)},t.prototype.setVerticesData=function(t,i,r){this._beingRegenerated&&e.prototype.setVerticesData.call(this,t,i,!1)},t.prototype._regenerateVertexData=function(){throw new Error("Abstract method")},t.prototype.copy=function(e){throw new Error("Must be overriden in sub-classes.")},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.canBeRegenerated=this.canBeRegenerated(),t},t})(t);i._Primitive=r;var n=(function(t){function i(i,r,n,o,s,a,h,l,c){void 0===c&&(c=e.Mesh.DEFAULTSIDE);var u=t.call(this,i,r,h,l)||this;return u.pathArray=n,u.closeArray=o,u.closePath=s,u.offset=a,u.side=c,u}return __extends(i,t),i.prototype._regenerateVertexData=function(){return e.VertexData.CreateRibbon({pathArray:this.pathArray,closeArray:this.closeArray,closePath:this.closePath,offset:this.offset,sideOrientation:this.side})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.pathArray,this.closeArray,this.closePath,this.offset,this.canBeRegenerated(),null,this.side)},i})(r);i.Ribbon=n;var o=(function(i){function r(t,r,n,o,s,a){void 0===a&&(a=e.Mesh.DEFAULTSIDE);var h=i.call(this,t,r,o,s)||this;return h.size=n,h.side=a,h}return __extends(r,i),r.prototype._regenerateVertexData=function(){return e.VertexData.CreateBox({size:this.size,sideOrientation:this.side})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.size,this.canBeRegenerated(),null,this.side)},r.prototype.serialize=function(){var e=i.prototype.serialize.call(this);return e.size=this.size,e},r.Parse=function(i,r){if(r.getGeometryByID(i.id))return null;var n=new t.Primitives.Box(i.id,r,i.size,i.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,i.tags),r.pushGeometry(n,!0),n},r})(r);i.Box=o;var s=(function(i){function r(t,r,n,o,s,a,h){void 0===h&&(h=e.Mesh.DEFAULTSIDE);var l=i.call(this,t,r,s,a)||this;return l.segments=n,l.diameter=o,l.side=h,l}return __extends(r,i),r.prototype._regenerateVertexData=function(){return e.VertexData.CreateSphere({segments:this.segments,diameter:this.diameter,sideOrientation:this.side})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.segments,this.diameter,this.canBeRegenerated(),null,this.side)},r.prototype.serialize=function(){var e=i.prototype.serialize.call(this);return e.segments=this.segments,e.diameter=this.diameter,e},r.Parse=function(i,r){if(r.getGeometryByID(i.id))return null;var n=new t.Primitives.Sphere(i.id,r,i.segments,i.diameter,i.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,i.tags),r.pushGeometry(n,!0),n},r})(r);i.Sphere=s;var a=(function(t){function i(i,r,n,o,s,a,h){void 0===h&&(h=e.Mesh.DEFAULTSIDE);var l=t.call(this,i,r,s,a)||this;return l.radius=n,l.tessellation=o,l.side=h,l}return __extends(i,t),i.prototype._regenerateVertexData=function(){return e.VertexData.CreateDisc({radius:this.radius,tessellation:this.tessellation,sideOrientation:this.side})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.radius,this.tessellation,this.canBeRegenerated(),null,this.side)},i})(r);i.Disc=a;var h=(function(i){function r(t,r,n,o,s,a,h,l,c,u){void 0===h&&(h=1),void 0===u&&(u=e.Mesh.DEFAULTSIDE);var f=i.call(this,t,r,l,c)||this;return f.height=n,f.diameterTop=o,f.diameterBottom=s,f.tessellation=a,f.subdivisions=h,f.side=u,f}return __extends(r,i),r.prototype._regenerateVertexData=function(){return e.VertexData.CreateCylinder({height:this.height,diameterTop:this.diameterTop,diameterBottom:this.diameterBottom,tessellation:this.tessellation,subdivisions:this.subdivisions,sideOrientation:this.side})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.height,this.diameterTop,this.diameterBottom,this.tessellation,this.subdivisions,this.canBeRegenerated(),null,this.side)},r.prototype.serialize=function(){var e=i.prototype.serialize.call(this);return e.height=this.height,e.diameterTop=this.diameterTop,e.diameterBottom=this.diameterBottom,e.tessellation=this.tessellation,e},r.Parse=function(i,r){if(r.getGeometryByID(i.id))return null;var n=new t.Primitives.Cylinder(i.id,r,i.height,i.diameterTop,i.diameterBottom,i.tessellation,i.subdivisions,i.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,i.tags),r.pushGeometry(n,!0),n},r})(r);i.Cylinder=h;var l=(function(i){function r(t,r,n,o,s,a,h,l){void 0===l&&(l=e.Mesh.DEFAULTSIDE);var c=i.call(this,t,r,a,h)||this;return c.diameter=n,c.thickness=o,c.tessellation=s,c.side=l,c}return __extends(r,i),r.prototype._regenerateVertexData=function(){return e.VertexData.CreateTorus({diameter:this.diameter,thickness:this.thickness,tessellation:this.tessellation,sideOrientation:this.side})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.diameter,this.thickness,this.tessellation,this.canBeRegenerated(),null,this.side)},r.prototype.serialize=function(){var e=i.prototype.serialize.call(this);return e.diameter=this.diameter,e.thickness=this.thickness,e.tessellation=this.tessellation,e},r.Parse=function(i,r){if(r.getGeometryByID(i.id))return null;var n=new t.Primitives.Torus(i.id,r,i.diameter,i.thickness,i.tessellation,i.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,i.tags),r.pushGeometry(n,!0),n},r})(r);i.Torus=l;var c=(function(i){function r(e,t,r,n,o,s,a){var h=i.call(this,e,t,s,a)||this;return h.width=r,h.height=n,h.subdivisions=o,h}return __extends(r,i),r.prototype._regenerateVertexData=function(){return e.VertexData.CreateGround({width:this.width,height:this.height,subdivisions:this.subdivisions})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.width,this.height,this.subdivisions,this.canBeRegenerated(),null)},r.prototype.serialize=function(){var e=i.prototype.serialize.call(this);return e.width=this.width,e.height=this.height,e.subdivisions=this.subdivisions,e},r.Parse=function(i,r){if(r.getGeometryByID(i.id))return null;var n=new t.Primitives.Ground(i.id,r,i.width,i.height,i.subdivisions,i.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,i.tags),r.pushGeometry(n,!0),n},r})(r);i.Ground=c;var u=(function(t){function i(e,i,r,n,o,s,a,h,l,c){var u=t.call(this,e,i,l,c)||this;return u.xmin=r,u.zmin=n,u.xmax=o,u.zmax=s,u.subdivisions=a,u.precision=h,u}return __extends(i,t),i.prototype._regenerateVertexData=function(){return e.VertexData.CreateTiledGround({xmin:this.xmin,zmin:this.zmin,xmax:this.xmax,zmax:this.zmax,subdivisions:this.subdivisions,precision:this.precision})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.xmin,this.zmin,this.xmax,this.zmax,this.subdivisions,this.precision,this.canBeRegenerated(),null)},i})(r);i.TiledGround=u;var f=(function(i){function r(t,r,n,o,s,a){void 0===a&&(a=e.Mesh.DEFAULTSIDE);var h=i.call(this,t,r,o,s)||this;return h.size=n,h.side=a,h}return __extends(r,i),r.prototype._regenerateVertexData=function(){return e.VertexData.CreatePlane({size:this.size,sideOrientation:this.side})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.size,this.canBeRegenerated(),null,this.side)},r.prototype.serialize=function(){var e=i.prototype.serialize.call(this);return e.size=this.size,e},r.Parse=function(i,r){if(r.getGeometryByID(i.id))return null;var n=new t.Primitives.Plane(i.id,r,i.size,i.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,i.tags),r.pushGeometry(n,!0),n},r})(r);i.Plane=f;var d=(function(i){function r(t,r,n,o,s,a,h,l,c,u,f){void 0===f&&(f=e.Mesh.DEFAULTSIDE);var d=i.call(this,t,r,c,u)||this;return d.radius=n,d.tube=o,d.radialSegments=s,d.tubularSegments=a,d.p=h,d.q=l,d.side=f,d}return __extends(r,i),r.prototype._regenerateVertexData=function(){return e.VertexData.CreateTorusKnot({radius:this.radius,tube:this.tube,radialSegments:this.radialSegments,tubularSegments:this.tubularSegments,p:this.p,q:this.q,sideOrientation:this.side})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.radius,this.tube,this.radialSegments,this.tubularSegments,this.p,this.q,this.canBeRegenerated(),null,this.side)},r.prototype.serialize=function(){var e=i.prototype.serialize.call(this);return e.radius=this.radius,e.tube=this.tube,e.radialSegments=this.radialSegments,e.tubularSegments=this.tubularSegments,e.p=this.p,e.q=this.q,e},r.Parse=function(i,r){if(r.getGeometryByID(i.id))return null;var n=new t.Primitives.TorusKnot(i.id,r,i.radius,i.tube,i.radialSegments,i.tubularSegments,i.p,i.q,i.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,i.tags),r.pushGeometry(n,!0),n},r})(r);i.TorusKnot=d})(t.Primitives||(t.Primitives={}))})(t=e.Geometry||(e.Geometry={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e){this._vertexBuffers={},this._scene=e}return t.prototype._prepareBuffers=function(){if(!this._vertexBuffers[e.VertexBuffer.PositionKind]){var t=[];t.push(1,1),t.push(-1,1),t.push(-1,-1),t.push(1,-1),this._vertexBuffers[e.VertexBuffer.PositionKind]=new e.VertexBuffer(this._scene.getEngine(),t,e.VertexBuffer.PositionKind,!1,!1,2);var i=[];i.push(0),i.push(1),i.push(2),i.push(0),i.push(2),i.push(3),this._indexBuffer=this._scene.getEngine().createIndexBuffer(i)}},t.prototype._prepareFrame=function(e,t){var t=t||this._scene.activeCamera._postProcesses;return!(0===t.length||!this._scene.postProcessesEnabled)&&(t[0].activate(this._scene.activeCamera,e,null!==t&&void 0!==t),!0)},t.prototype.directRender=function(e,t){for(var i=this._scene.getEngine(),r=0;r=this._sampleCount||e>=this._samples.length)return null;var t=this._wrapPosition(this._pos-1);return this._samples[this._wrapPosition(t-e)]},e.prototype.isSaturated=function(){return this._sampleCount>=this._samples.length},e.prototype.reset=function(){this.average=0,this.variance=0,this._sampleCount=0,this._pos=0,this._m2=0},e.prototype._wrapPosition=function(e){var t=this._samples.length;return(e%t+t)%t},e})();e.RollingAverage=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(e){function t(){var t=e.call(this)||this;return t.MAINUV1=!1,t.MAINUV2=!1,t.DIFFUSE=!1,t.DIFFUSEDIRECTUV=0,t.AMBIENT=!1,t.AMBIENTDIRECTUV=0,t.OPACITY=!1,t.OPACITYDIRECTUV=0,t.OPACITYRGB=!1,t.REFLECTION=!1,t.EMISSIVE=!1,t.EMISSIVEDIRECTUV=0,t.SPECULAR=!1,t.SPECULARDIRECTUV=0,t.BUMP=!1,t.BUMPDIRECTUV=0,t.PARALLAX=!1,t.PARALLAXOCCLUSION=!1,t.SPECULAROVERALPHA=!1,t.CLIPPLANE=!1,t.ALPHATEST=!1,t.ALPHAFROMDIFFUSE=!1,t.POINTSIZE=!1,t.FOG=!1,t.SPECULARTERM=!1,t.DIFFUSEFRESNEL=!1,t.OPACITYFRESNEL=!1,t.REFLECTIONFRESNEL=!1,t.REFRACTIONFRESNEL=!1,t.EMISSIVEFRESNEL=!1,t.FRESNEL=!1,t.NORMAL=!1,t.UV1=!1,t.UV2=!1,t.VERTEXCOLOR=!1,t.VERTEXALPHA=!1,t.NUM_BONE_INFLUENCERS=0,t.BonesPerMesh=0,t.INSTANCES=!1,t.GLOSSINESS=!1,t.ROUGHNESS=!1,t.EMISSIVEASILLUMINATION=!1,t.LINKEMISSIVEWITHDIFFUSE=!1,t.REFLECTIONFRESNELFROMSPECULAR=!1,t.LIGHTMAP=!1,t.LIGHTMAPDIRECTUV=0,t.USELIGHTMAPASSHADOWMAP=!1,t.REFLECTIONMAP_3D=!1,t.REFLECTIONMAP_SPHERICAL=!1,t.REFLECTIONMAP_PLANAR=!1,t.REFLECTIONMAP_CUBIC=!1,t.REFLECTIONMAP_PROJECTION=!1,t.REFLECTIONMAP_SKYBOX=!1,t.REFLECTIONMAP_EXPLICIT=!1,t.REFLECTIONMAP_EQUIRECTANGULAR=!1,t.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,t.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,t.INVERTCUBICMAP=!1,t.LOGARITHMICDEPTH=!1,t.REFRACTION=!1,t.REFRACTIONMAP_3D=!1,t.REFLECTIONOVERALPHA=!1,t.TWOSIDEDLIGHTING=!1,t.SHADOWFLOAT=!1,t.MORPHTARGETS=!1,t.MORPHTARGETS_NORMAL=!1,t.MORPHTARGETS_TANGENT=!1,t.NUM_MORPH_INFLUENCERS=0,t.USERIGHTHANDEDSYSTEM=!1,t.IMAGEPROCESSING=!1,t.VIGNETTE=!1,t.VIGNETTEBLENDMODEMULTIPLY=!1,t.VIGNETTEBLENDMODEOPAQUE=!1,t.TONEMAPPING=!1,t.CONTRAST=!1,t.COLORCURVES=!1,t.COLORGRADING=!1,t.SAMPLER3DGREENDEPTH=!1,t.SAMPLER3DBGRMAP=!1,t.IMAGEPROCESSINGPOSTPROCESS=!1,t.EXPOSURE=!1,t.rebuild(),t}return __extends(t,e),t.prototype.setReflectionMode=function(e){for(var t=["REFLECTIONMAP_CUBIC","REFLECTIONMAP_EXPLICIT","REFLECTIONMAP_PLANAR","REFLECTIONMAP_PROJECTION","REFLECTIONMAP_PROJECTION","REFLECTIONMAP_SKYBOX","REFLECTIONMAP_SPHERICAL","REFLECTIONMAP_EQUIRECTANGULAR","REFLECTIONMAP_EQUIRECTANGULAR_FIXED","REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED"],i=0,r=t;i0,a.REFLECTIONOVERALPHA=this._useReflectionOverAlpha,a.INVERTCUBICMAP=this._reflectionTexture.coordinatesMode===e.Texture.INVCUBIC_MODE,a.REFLECTIONMAP_3D=this._reflectionTexture.isCube,this._reflectionTexture.coordinatesMode){case e.Texture.CUBIC_MODE:case e.Texture.INVCUBIC_MODE:a.setReflectionMode("REFLECTIONMAP_CUBIC");break;case e.Texture.EXPLICIT_MODE:a.setReflectionMode("REFLECTIONMAP_EXPLICIT");break;case e.Texture.PLANAR_MODE:a.setReflectionMode("REFLECTIONMAP_PLANAR");break;case e.Texture.PROJECTION_MODE:a.setReflectionMode("REFLECTIONMAP_PROJECTION");break;case e.Texture.SKYBOX_MODE:a.setReflectionMode("REFLECTIONMAP_SKYBOX");break;case e.Texture.SPHERICAL_MODE:a.setReflectionMode("REFLECTIONMAP_SPHERICAL");break;case e.Texture.EQUIRECTANGULAR_MODE:a.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR");break;case e.Texture.FIXED_EQUIRECTANGULAR_MODE:a.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR_FIXED");break;case e.Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:a.setReflectionMode("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED")}}else a.REFLECTION=!1;if(this._emissiveTexture&&r.EmissiveTextureEnabled){if(!this._emissiveTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._emissiveTexture,a,"EMISSIVE")}else a.EMISSIVE=!1;if(this._lightmapTexture&&r.LightmapTextureEnabled){if(!this._lightmapTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._lightmapTexture,a,"LIGHTMAP"),a.USELIGHTMAPASSHADOWMAP=this._useLightmapAsShadowmap}else a.LIGHTMAP=!1;if(this._specularTexture&&r.SpecularTextureEnabled){if(!this._specularTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._specularTexture,a,"SPECULAR"),a.GLOSSINESS=this._useGlossinessFromSpecularMapAlpha}else a.SPECULAR=!1;if(s.getEngine().getCaps().standardDerivatives&&this._bumpTexture&&r.BumpTextureEnabled){if(!this._bumpTexture.isReady())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._bumpTexture,a,"BUMP"),a.PARALLAX=this._useParallax,a.PARALLAXOCCLUSION=this._useParallaxOcclusion}else a.BUMP=!1;if(this._refractionTexture&&r.RefractionTextureEnabled){if(!this._refractionTexture.isReadyOrNotBlocking())return!1;a._needUVs=!0,a.REFRACTION=!0,a.REFRACTIONMAP_3D=this._refractionTexture.isCube}else a.REFRACTION=!1;a.TWOSIDEDLIGHTING=!this._backFaceCulling&&this._twoSidedLighting}else a.DIFFUSE=!1,a.AMBIENT=!1,a.OPACITY=!1,a.REFLECTION=!1,a.EMISSIVE=!1,a.LIGHTMAP=!1,a.BUMP=!1,a.REFRACTION=!1;a.ALPHAFROMDIFFUSE=this._shouldUseAlphaFromDiffuseTexture(),a.EMISSIVEASILLUMINATION=this._useEmissiveAsIllumination,a.LINKEMISSIVEWITHDIFFUSE=this._linkEmissiveWithDiffuse,a.SPECULAROVERALPHA=this._useSpecularOverAlpha}if(a._areImageProcessingDirty){if(!this._imageProcessingConfiguration.isReady())return!1;this._imageProcessingConfiguration.prepareDefines(a)}if(a._areFresnelDirty&&(r.FresnelEnabled?(this._diffuseFresnelParameters||this._opacityFresnelParameters||this._emissiveFresnelParameters||this._refractionFresnelParameters||this._reflectionFresnelParameters)&&(a.DIFFUSEFRESNEL=this._diffuseFresnelParameters&&this._diffuseFresnelParameters.isEnabled,a.OPACITYFRESNEL=this._opacityFresnelParameters&&this._opacityFresnelParameters.isEnabled,a.REFLECTIONFRESNEL=this._reflectionFresnelParameters&&this._reflectionFresnelParameters.isEnabled,a.REFLECTIONFRESNELFROMSPECULAR=this._useReflectionFresnelFromSpecular,a.REFRACTIONFRESNEL=this._refractionFresnelParameters&&this._refractionFresnelParameters.isEnabled,a.EMISSIVEFRESNEL=this._emissiveFresnelParameters&&this._emissiveFresnelParameters.isEnabled,a._needNormals=!0,a.FRESNEL=!0):a.FRESNEL=!1),e.MaterialHelper.PrepareDefinesForMisc(i,s,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,a),e.MaterialHelper.PrepareDefinesForAttributes(i,a,!0,!0,!0),e.MaterialHelper.PrepareDefinesForFrameBoundValues(s,h,a,o),a.isDirty){a.markAsProcessed(),s.resetCachedMaterial();var l=new e.EffectFallbacks;a.REFLECTION&&l.addFallback(0,"REFLECTION"),a.SPECULAR&&l.addFallback(0,"SPECULAR"),a.BUMP&&l.addFallback(0,"BUMP"),a.PARALLAX&&l.addFallback(1,"PARALLAX"),a.PARALLAXOCCLUSION&&l.addFallback(0,"PARALLAXOCCLUSION"),a.SPECULAROVERALPHA&&l.addFallback(0,"SPECULAROVERALPHA"),a.FOG&&l.addFallback(1,"FOG"),a.POINTSIZE&&l.addFallback(0,"POINTSIZE"),a.LOGARITHMICDEPTH&&l.addFallback(0,"LOGARITHMICDEPTH"),e.MaterialHelper.HandleFallbacksForShadows(a,l,this._maxSimultaneousLights),a.SPECULARTERM&&l.addFallback(0,"SPECULARTERM"),a.DIFFUSEFRESNEL&&l.addFallback(1,"DIFFUSEFRESNEL"),a.OPACITYFRESNEL&&l.addFallback(2,"OPACITYFRESNEL"),a.REFLECTIONFRESNEL&&l.addFallback(3,"REFLECTIONFRESNEL"),a.EMISSIVEFRESNEL&&l.addFallback(4,"EMISSIVEFRESNEL"),a.FRESNEL&&l.addFallback(4,"FRESNEL");var c=[e.VertexBuffer.PositionKind];a.NORMAL&&c.push(e.VertexBuffer.NormalKind),a.UV1&&c.push(e.VertexBuffer.UVKind),a.UV2&&c.push(e.VertexBuffer.UV2Kind),a.VERTEXCOLOR&&c.push(e.VertexBuffer.ColorKind),e.MaterialHelper.PrepareAttributesForBones(c,i,a,l),e.MaterialHelper.PrepareAttributesForInstances(c,a),e.MaterialHelper.PrepareAttributesForMorphTargets(c,i,a);var u="default",f=["world","view","viewProjection","vEyePosition","vLightsType","vAmbientColor","vDiffuseColor","vSpecularColor","vEmissiveColor","vFogInfos","vFogColor","pointSize","vDiffuseInfos","vAmbientInfos","vOpacityInfos","vReflectionInfos","vEmissiveInfos","vSpecularInfos","vBumpInfos","vLightmapInfos","vRefractionInfos","mBones","vClipPlane","diffuseMatrix","ambientMatrix","opacityMatrix","reflectionMatrix","emissiveMatrix","specularMatrix","bumpMatrix","lightmapMatrix","refractionMatrix","diffuseLeftColor","diffuseRightColor","opacityParts","reflectionLeftColor","reflectionRightColor","emissiveLeftColor","emissiveRightColor","refractionLeftColor","refractionRightColor","logarithmicDepthConstant","vNormalReoderParams"],d=["diffuseSampler","ambientSampler","opacitySampler","reflectionCubeSampler","reflection2DSampler","emissiveSampler","specularSampler","bumpSampler","lightmapSampler","refractionCubeSampler","refraction2DSampler"],p=["Material","Scene"];e.ImageProcessingConfiguration.PrepareUniforms(f,a),e.ImageProcessingConfiguration.PrepareSamplers(d,a),e.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:f,uniformBuffersNames:p,samplers:d,defines:a,maxSimultaneousLights:this._maxSimultaneousLights}),this.customShaderNameResolve&&(u=this.customShaderNameResolve(u,f,p,d,a));var m=a.toString();n.setEffect(s.getEngine().createEffect(u,{attributes:c,uniformsNames:f,uniformBuffersNames:p,samplers:d,defines:m,fallbacks:l,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights,maxSimultaneousMorphTargets:a.NUM_MORPH_INFLUENCERS}},h),a),this.buildUniformLayout()}return!!n.effect.isReady()&&(a._renderId=s.getRenderId(),this._wasPreviouslyReady=!0,!0)},r.prototype.buildUniformLayout=function(){this._uniformBuffer.addUniform("diffuseLeftColor",4),this._uniformBuffer.addUniform("diffuseRightColor",4),this._uniformBuffer.addUniform("opacityParts",4),this._uniformBuffer.addUniform("reflectionLeftColor",4),this._uniformBuffer.addUniform("reflectionRightColor",4),this._uniformBuffer.addUniform("refractionLeftColor",4),this._uniformBuffer.addUniform("refractionRightColor",4),this._uniformBuffer.addUniform("emissiveLeftColor",4),this._uniformBuffer.addUniform("emissiveRightColor",4),this._uniformBuffer.addUniform("vDiffuseInfos",2),this._uniformBuffer.addUniform("vAmbientInfos",2),this._uniformBuffer.addUniform("vOpacityInfos",2),this._uniformBuffer.addUniform("vReflectionInfos",2),this._uniformBuffer.addUniform("vEmissiveInfos",2),this._uniformBuffer.addUniform("vLightmapInfos",2),this._uniformBuffer.addUniform("vSpecularInfos",2),this._uniformBuffer.addUniform("vBumpInfos",3),this._uniformBuffer.addUniform("diffuseMatrix",16),this._uniformBuffer.addUniform("ambientMatrix",16),this._uniformBuffer.addUniform("opacityMatrix",16),this._uniformBuffer.addUniform("reflectionMatrix",16),this._uniformBuffer.addUniform("emissiveMatrix",16),this._uniformBuffer.addUniform("lightmapMatrix",16),this._uniformBuffer.addUniform("specularMatrix",16),this._uniformBuffer.addUniform("bumpMatrix",16),this._uniformBuffer.addUniform("vNormalReoderParams",4),this._uniformBuffer.addUniform("refractionMatrix",16),this._uniformBuffer.addUniform("vRefractionInfos",4),this._uniformBuffer.addUniform("vSpecularColor",4),this._uniformBuffer.addUniform("vEmissiveColor",3),this._uniformBuffer.addUniform("vDiffuseColor",4),this._uniformBuffer.addUniform("pointSize",1),this._uniformBuffer.create()},r.prototype.unbind=function(){this._activeEffect&&(this._reflectionTexture&&this._reflectionTexture.isRenderTarget&&this._activeEffect.setTexture("reflection2DSampler",null),this._refractionTexture&&this._refractionTexture.isRenderTarget&&this._activeEffect.setTexture("refraction2DSampler",null)),i.prototype.unbind.call(this)},r.prototype.bindForSubMesh=function(t,i,n){var o=this.getScene(),s=n._materialDefines;if(s){var a=n.effect;if(this._activeEffect=a,this.bindOnlyWorldMatrix(t),e.MaterialHelper.BindBonesParameters(i,a),this._mustRebind(o,a,i.visibility)){if(this._uniformBuffer.bindToEffect(a,"Material"),this.bindViewProjection(a),!this._uniformBuffer.useUbo||!this.isFrozen||!this._uniformBuffer.isSync){if(r.FresnelEnabled&&s.FRESNEL&&(this.diffuseFresnelParameters&&this.diffuseFresnelParameters.isEnabled&&(this._uniformBuffer.updateColor4("diffuseLeftColor",this.diffuseFresnelParameters.leftColor,this.diffuseFresnelParameters.power),this._uniformBuffer.updateColor4("diffuseRightColor",this.diffuseFresnelParameters.rightColor,this.diffuseFresnelParameters.bias)),this.opacityFresnelParameters&&this.opacityFresnelParameters.isEnabled&&this._uniformBuffer.updateColor4("opacityParts",new e.Color3(this.opacityFresnelParameters.leftColor.toLuminance(),this.opacityFresnelParameters.rightColor.toLuminance(),this.opacityFresnelParameters.bias),this.opacityFresnelParameters.power),this.reflectionFresnelParameters&&this.reflectionFresnelParameters.isEnabled&&(this._uniformBuffer.updateColor4("reflectionLeftColor",this.reflectionFresnelParameters.leftColor,this.reflectionFresnelParameters.power),this._uniformBuffer.updateColor4("reflectionRightColor",this.reflectionFresnelParameters.rightColor,this.reflectionFresnelParameters.bias)),this.refractionFresnelParameters&&this.refractionFresnelParameters.isEnabled&&(this._uniformBuffer.updateColor4("refractionLeftColor",this.refractionFresnelParameters.leftColor,this.refractionFresnelParameters.power),this._uniformBuffer.updateColor4("refractionRightColor",this.refractionFresnelParameters.rightColor,this.refractionFresnelParameters.bias)),this.emissiveFresnelParameters&&this.emissiveFresnelParameters.isEnabled&&(this._uniformBuffer.updateColor4("emissiveLeftColor",this.emissiveFresnelParameters.leftColor,this.emissiveFresnelParameters.power),this._uniformBuffer.updateColor4("emissiveRightColor",this.emissiveFresnelParameters.rightColor,this.emissiveFresnelParameters.bias))),o.texturesEnabled&&(this._diffuseTexture&&r.DiffuseTextureEnabled&&(this._uniformBuffer.updateFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),e.MaterialHelper.BindTextureMatrix(this._diffuseTexture,this._uniformBuffer,"diffuse")),this._ambientTexture&&r.AmbientTextureEnabled&&(this._uniformBuffer.updateFloat2("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level),e.MaterialHelper.BindTextureMatrix(this._ambientTexture,this._uniformBuffer,"ambient")),this._opacityTexture&&r.OpacityTextureEnabled&&(this._uniformBuffer.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),e.MaterialHelper.BindTextureMatrix(this._opacityTexture,this._uniformBuffer,"opacity")),this._reflectionTexture&&r.ReflectionTextureEnabled&&(this._uniformBuffer.updateFloat2("vReflectionInfos",this._reflectionTexture.level,this.roughness),this._uniformBuffer.updateMatrix("reflectionMatrix",this._reflectionTexture.getReflectionTextureMatrix())),this._emissiveTexture&&r.EmissiveTextureEnabled&&(this._uniformBuffer.updateFloat2("vEmissiveInfos",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),e.MaterialHelper.BindTextureMatrix(this._emissiveTexture,this._uniformBuffer,"emissive")),this._lightmapTexture&&r.LightmapTextureEnabled&&(this._uniformBuffer.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),e.MaterialHelper.BindTextureMatrix(this._lightmapTexture,this._uniformBuffer,"lightmap")),this._specularTexture&&r.SpecularTextureEnabled&&(this._uniformBuffer.updateFloat2("vSpecularInfos",this._specularTexture.coordinatesIndex,this._specularTexture.level),e.MaterialHelper.BindTextureMatrix(this._specularTexture,this._uniformBuffer,"specular")),this._bumpTexture&&o.getEngine().getCaps().standardDerivatives&&r.BumpTextureEnabled&&(this._uniformBuffer.updateFloat3("vBumpInfos",this._bumpTexture.coordinatesIndex,1/this._bumpTexture.level,this.parallaxScaleBias),e.MaterialHelper.BindTextureMatrix(this._bumpTexture,this._uniformBuffer,"bump"),o._mirroredCameraPosition?this._uniformBuffer.updateFloat4("vNormalReoderParams",this.invertNormalMapX?0:1,this.invertNormalMapX?1:-1,this.invertNormalMapY?0:1,this.invertNormalMapY?1:-1):this._uniformBuffer.updateFloat4("vNormalReoderParams",this.invertNormalMapX?1:0,this.invertNormalMapX?-1:1,this.invertNormalMapY?1:0,this.invertNormalMapY?-1:1)),this._refractionTexture&&r.RefractionTextureEnabled)){var h=1;this._refractionTexture.isCube||(this._uniformBuffer.updateMatrix("refractionMatrix",this._refractionTexture.getReflectionTextureMatrix()),this._refractionTexture.depth&&(h=this._refractionTexture.depth)),this._uniformBuffer.updateFloat4("vRefractionInfos",this._refractionTexture.level,this.indexOfRefraction,h,this.invertRefractionY?-1:1)}this.pointsCloud&&this._uniformBuffer.updateFloat("pointSize",this.pointSize),s.SPECULARTERM&&this._uniformBuffer.updateColor4("vSpecularColor",this.specularColor,this.specularPower),this._uniformBuffer.updateColor3("vEmissiveColor",this.emissiveColor),this._uniformBuffer.updateColor4("vDiffuseColor",this.diffuseColor,this.alpha*i.visibility)}if(o.texturesEnabled&&(this._diffuseTexture&&r.DiffuseTextureEnabled&&a.setTexture("diffuseSampler",this._diffuseTexture),this._ambientTexture&&r.AmbientTextureEnabled&&a.setTexture("ambientSampler",this._ambientTexture),this._opacityTexture&&r.OpacityTextureEnabled&&a.setTexture("opacitySampler",this._opacityTexture),this._reflectionTexture&&r.ReflectionTextureEnabled&&(this._reflectionTexture.isCube?a.setTexture("reflectionCubeSampler",this._reflectionTexture):a.setTexture("reflection2DSampler",this._reflectionTexture)),this._emissiveTexture&&r.EmissiveTextureEnabled&&a.setTexture("emissiveSampler",this._emissiveTexture),this._lightmapTexture&&r.LightmapTextureEnabled&&a.setTexture("lightmapSampler",this._lightmapTexture),this._specularTexture&&r.SpecularTextureEnabled&&a.setTexture("specularSampler",this._specularTexture),this._bumpTexture&&o.getEngine().getCaps().standardDerivatives&&r.BumpTextureEnabled&&a.setTexture("bumpSampler",this._bumpTexture),this._refractionTexture&&r.RefractionTextureEnabled)){var h=1;this._refractionTexture.isCube?a.setTexture("refractionCubeSampler",this._refractionTexture):a.setTexture("refraction2DSampler",this._refractionTexture)}e.MaterialHelper.BindClipPlane(a,o),o.ambientColor.multiplyToRef(this.ambientColor,this._globalAmbientColor),a.setVector3("vEyePosition",o._mirroredCameraPosition?o._mirroredCameraPosition:o.activeCamera.globalPosition),a.setColor3("vAmbientColor",this._globalAmbientColor)}!this._mustRebind(o,a)&&this.isFrozen||(o.lightsEnabled&&!this._disableLighting&&e.MaterialHelper.BindLights(o,i,a,s,this._maxSimultaneousLights),(o.fogEnabled&&i.applyFog&&o.fogMode!==e.Scene.FOGMODE_NONE||this._reflectionTexture||this._refractionTexture)&&this.bindView(a),e.MaterialHelper.BindFogParameters(o,i,a),s.NUM_MORPH_INFLUENCERS&&e.MaterialHelper.BindMorphTargetParameters(i,a),e.MaterialHelper.BindLogDepth(s,a,o),this._imageProcessingConfiguration.bind(this._activeEffect)),this._uniformBuffer.update(),this._afterBind(i,this._activeEffect)}},r.prototype.getAnimatables=function(){var e=[];return this._diffuseTexture&&this._diffuseTexture.animations&&this._diffuseTexture.animations.length>0&&e.push(this._diffuseTexture),this._ambientTexture&&this._ambientTexture.animations&&this._ambientTexture.animations.length>0&&e.push(this._ambientTexture),this._opacityTexture&&this._opacityTexture.animations&&this._opacityTexture.animations.length>0&&e.push(this._opacityTexture),this._reflectionTexture&&this._reflectionTexture.animations&&this._reflectionTexture.animations.length>0&&e.push(this._reflectionTexture),this._emissiveTexture&&this._emissiveTexture.animations&&this._emissiveTexture.animations.length>0&&e.push(this._emissiveTexture),this._specularTexture&&this._specularTexture.animations&&this._specularTexture.animations.length>0&&e.push(this._specularTexture),this._bumpTexture&&this._bumpTexture.animations&&this._bumpTexture.animations.length>0&&e.push(this._bumpTexture),this._lightmapTexture&&this._lightmapTexture.animations&&this._lightmapTexture.animations.length>0&&e.push(this._lightmapTexture),this._refractionTexture&&this._refractionTexture.animations&&this._refractionTexture.animations.length>0&&e.push(this._refractionTexture),e},r.prototype.getActiveTextures=function(){var e=i.prototype.getActiveTextures.call(this);return this._diffuseTexture&&e.push(this._diffuseTexture),this._ambientTexture&&e.push(this._ambientTexture),this._opacityTexture&&e.push(this._opacityTexture),this._reflectionTexture&&e.push(this._reflectionTexture),this._emissiveTexture&&e.push(this._emissiveTexture),this._specularTexture&&e.push(this._specularTexture),this._bumpTexture&&e.push(this._bumpTexture),this._lightmapTexture&&e.push(this._lightmapTexture),this._refractionTexture&&e.push(this._refractionTexture),e},r.prototype.hasTexture=function(e){return!!i.prototype.hasTexture.call(this,e)||(this._diffuseTexture===e||(this._ambientTexture===e||(this._opacityTexture===e||(this._reflectionTexture===e||(this._emissiveTexture===e||(this._specularTexture===e||(this._bumpTexture===e||(this._lightmapTexture===e||this._refractionTexture===e))))))))},r.prototype.dispose=function(e,t){t&&(this._diffuseTexture&&this._diffuseTexture.dispose(),this._ambientTexture&&this._ambientTexture.dispose(),this._opacityTexture&&this._opacityTexture.dispose(),this._reflectionTexture&&this._reflectionTexture.dispose(),this._emissiveTexture&&this._emissiveTexture.dispose(),this._specularTexture&&this._specularTexture.dispose(),this._bumpTexture&&this._bumpTexture.dispose(),this._lightmapTexture&&this._lightmapTexture.dispose(),this._refractionTexture&&this._refractionTexture.dispose()),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),i.prototype.dispose.call(this,e,t)},r.prototype.clone=function(t){var i=this,n=e.SerializationHelper.Clone((function(){return new r(t,i.getScene())}),this);return n.name=t,n.id=t,n},r.prototype.serialize=function(){return e.SerializationHelper.Serialize(this)},r.Parse=function(t,i,n){return e.SerializationHelper.Parse((function(){return new r(t.name,i)}),t,i,n)},Object.defineProperty(r,"DiffuseTextureEnabled",{get:function(){return r._DiffuseTextureEnabled},set:function(t){r._DiffuseTextureEnabled!==t&&(r._DiffuseTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"AmbientTextureEnabled",{get:function(){return r._AmbientTextureEnabled},set:function(t){r._AmbientTextureEnabled!==t&&(r._AmbientTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"OpacityTextureEnabled",{get:function(){return r._OpacityTextureEnabled},set:function(t){r._OpacityTextureEnabled!==t&&(r._OpacityTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"ReflectionTextureEnabled",{get:function(){return r._ReflectionTextureEnabled},set:function(t){r._ReflectionTextureEnabled!==t&&(r._ReflectionTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"EmissiveTextureEnabled",{get:function(){return r._EmissiveTextureEnabled},set:function(t){r._EmissiveTextureEnabled!==t&&(r._EmissiveTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"SpecularTextureEnabled",{get:function(){return r._SpecularTextureEnabled},set:function(t){r._SpecularTextureEnabled!==t&&(r._SpecularTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"BumpTextureEnabled",{get:function(){return r._BumpTextureEnabled},set:function(t){r._BumpTextureEnabled!==t&&(r._BumpTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"LightmapTextureEnabled",{get:function(){return r._LightmapTextureEnabled},set:function(t){r._LightmapTextureEnabled!==t&&(r._LightmapTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"RefractionTextureEnabled",{get:function(){return r._RefractionTextureEnabled},set:function(t){r._RefractionTextureEnabled!==t&&(r._RefractionTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"ColorGradingTextureEnabled",{get:function(){return r._ColorGradingTextureEnabled},set:function(t){r._ColorGradingTextureEnabled!==t&&(r._ColorGradingTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"FresnelEnabled",{get:function(){return r._FresnelEnabled},set:function(t){r._FresnelEnabled!==t&&(r._FresnelEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.FresnelDirtyFlag))},enumerable:!0,configurable:!0}),r})(e.PushMaterial);i._DiffuseTextureEnabled=!0,i._AmbientTextureEnabled=!0,i._OpacityTextureEnabled=!0,i._ReflectionTextureEnabled=!0,i._EmissiveTextureEnabled=!0,i._SpecularTextureEnabled=!0,i._BumpTextureEnabled=!0,i._LightmapTextureEnabled=!0,i._RefractionTextureEnabled=!0,i._ColorGradingTextureEnabled=!0,i._FresnelEnabled=!0,__decorate([e.serializeAsTexture("diffuseTexture")],i.prototype,"_diffuseTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"diffuseTexture",void 0),__decorate([e.serializeAsTexture("ambientTexture")],i.prototype,"_ambientTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"ambientTexture",void 0),__decorate([e.serializeAsTexture("opacityTexture")],i.prototype,"_opacityTexture",void 0), -__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"opacityTexture",void 0),__decorate([e.serializeAsTexture("reflectionTexture")],i.prototype,"_reflectionTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"reflectionTexture",void 0),__decorate([e.serializeAsTexture("emissiveTexture")],i.prototype,"_emissiveTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"emissiveTexture",void 0),__decorate([e.serializeAsTexture("specularTexture")],i.prototype,"_specularTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"specularTexture",void 0),__decorate([e.serializeAsTexture("bumpTexture")],i.prototype,"_bumpTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"bumpTexture",void 0),__decorate([e.serializeAsTexture("lightmapTexture")],i.prototype,"_lightmapTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"lightmapTexture",void 0),__decorate([e.serializeAsTexture("refractionTexture")],i.prototype,"_refractionTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"refractionTexture",void 0),__decorate([e.serializeAsColor3("ambient")],i.prototype,"ambientColor",void 0),__decorate([e.serializeAsColor3("diffuse")],i.prototype,"diffuseColor",void 0),__decorate([e.serializeAsColor3("specular")],i.prototype,"specularColor",void 0),__decorate([e.serializeAsColor3("emissive")],i.prototype,"emissiveColor",void 0),__decorate([e.serialize()],i.prototype,"specularPower",void 0),__decorate([e.serialize("useAlphaFromDiffuseTexture")],i.prototype,"_useAlphaFromDiffuseTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useAlphaFromDiffuseTexture",void 0),__decorate([e.serialize("useEmissiveAsIllumination")],i.prototype,"_useEmissiveAsIllumination",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useEmissiveAsIllumination",void 0),__decorate([e.serialize("linkEmissiveWithDiffuse")],i.prototype,"_linkEmissiveWithDiffuse",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"linkEmissiveWithDiffuse",void 0),__decorate([e.serialize("useSpecularOverAlpha")],i.prototype,"_useSpecularOverAlpha",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useSpecularOverAlpha",void 0),__decorate([e.serialize("useReflectionOverAlpha")],i.prototype,"_useReflectionOverAlpha",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useReflectionOverAlpha",void 0),__decorate([e.serialize("disableLighting")],i.prototype,"_disableLighting",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsLightsDirty")],i.prototype,"disableLighting",void 0),__decorate([e.serialize("useParallax")],i.prototype,"_useParallax",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useParallax",void 0),__decorate([e.serialize("useParallaxOcclusion")],i.prototype,"_useParallaxOcclusion",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useParallaxOcclusion",void 0),__decorate([e.serialize()],i.prototype,"parallaxScaleBias",void 0),__decorate([e.serialize("roughness")],i.prototype,"_roughness",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"roughness",void 0),__decorate([e.serialize()],i.prototype,"indexOfRefraction",void 0),__decorate([e.serialize()],i.prototype,"invertRefractionY",void 0),__decorate([e.serialize("useLightmapAsShadowmap")],i.prototype,"_useLightmapAsShadowmap",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useLightmapAsShadowmap",void 0),__decorate([e.serializeAsFresnelParameters("diffuseFresnelParameters")],i.prototype,"_diffuseFresnelParameters",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],i.prototype,"diffuseFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters("opacityFresnelParameters")],i.prototype,"_opacityFresnelParameters",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],i.prototype,"opacityFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters("reflectionFresnelParameters")],i.prototype,"_reflectionFresnelParameters",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],i.prototype,"reflectionFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters("refractionFresnelParameters")],i.prototype,"_refractionFresnelParameters",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],i.prototype,"refractionFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters("emissiveFresnelParameters")],i.prototype,"_emissiveFresnelParameters",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],i.prototype,"emissiveFresnelParameters",void 0),__decorate([e.serialize("useReflectionFresnelFromSpecular")],i.prototype,"_useReflectionFresnelFromSpecular",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],i.prototype,"useReflectionFresnelFromSpecular",void 0),__decorate([e.serialize("useGlossinessFromSpecularMapAlpha")],i.prototype,"_useGlossinessFromSpecularMapAlpha",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useGlossinessFromSpecularMapAlpha",void 0),__decorate([e.serialize("maxSimultaneousLights")],i.prototype,"_maxSimultaneousLights",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsLightsDirty")],i.prototype,"maxSimultaneousLights",void 0),__decorate([e.serialize("invertNormalMapX")],i.prototype,"_invertNormalMapX",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"invertNormalMapX",void 0),__decorate([e.serialize("invertNormalMapY")],i.prototype,"_invertNormalMapY",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"invertNormalMapY",void 0),__decorate([e.serialize("twoSidedLighting")],i.prototype,"_twoSidedLighting",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"twoSidedLighting",void 0),__decorate([e.serialize()],i.prototype,"useLogarithmicDepth",null),e.StandardMaterial=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(e){function t(){var t=e.call(this)||this;return t.PBR=!0,t.MAINUV1=!1,t.MAINUV2=!1,t.UV1=!1,t.UV2=!1,t.ALBEDO=!1,t.ALBEDODIRECTUV=0,t.VERTEXCOLOR=!1,t.AMBIENT=!1,t.AMBIENTDIRECTUV=0,t.AMBIENTINGRAYSCALE=!1,t.OPACITY=!1,t.VERTEXALPHA=!1,t.OPACITYDIRECTUV=0,t.OPACITYRGB=!1,t.ALPHATEST=!1,t.ALPHABLEND=!1,t.ALPHAFROMALBEDO=!1,t.ALPHATESTVALUE=.5,t.SPECULAROVERALPHA=!1,t.RADIANCEOVERALPHA=!1,t.ALPHAFRESNEL=!1,t.PREMULTIPLYALPHA=!1,t.EMISSIVE=!1,t.EMISSIVEDIRECTUV=0,t.REFLECTIVITY=!1,t.REFLECTIVITYDIRECTUV=0,t.SPECULARTERM=!1,t.MICROSURFACEFROMREFLECTIVITYMAP=!1,t.MICROSURFACEAUTOMATIC=!1,t.LODBASEDMICROSFURACE=!1,t.MICROSURFACEMAP=!1,t.MICROSURFACEMAPDIRECTUV=0,t.METALLICWORKFLOW=!1,t.ROUGHNESSSTOREINMETALMAPALPHA=!1,t.ROUGHNESSSTOREINMETALMAPGREEN=!1,t.METALLNESSSTOREINMETALMAPBLUE=!1,t.AOSTOREINMETALMAPRED=!1,t.ENVIRONMENTBRDF=!1,t.NORMAL=!1,t.TANGENT=!1,t.BUMP=!1,t.BUMPDIRECTUV=0,t.PARALLAX=!1,t.PARALLAXOCCLUSION=!1,t.NORMALXYSCALE=!0,t.LIGHTMAP=!1,t.LIGHTMAPDIRECTUV=0,t.USELIGHTMAPASSHADOWMAP=!1,t.REFLECTION=!1,t.REFLECTIONMAP_3D=!1,t.REFLECTIONMAP_SPHERICAL=!1,t.REFLECTIONMAP_PLANAR=!1,t.REFLECTIONMAP_CUBIC=!1,t.REFLECTIONMAP_PROJECTION=!1,t.REFLECTIONMAP_SKYBOX=!1,t.REFLECTIONMAP_EXPLICIT=!1,t.REFLECTIONMAP_EQUIRECTANGULAR=!1,t.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,t.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,t.INVERTCUBICMAP=!1,t.USESPHERICALFROMREFLECTIONMAP=!1,t.USESPHERICALINFRAGMENT=!1,t.REFLECTIONMAP_OPPOSITEZ=!1,t.LODINREFLECTIONALPHA=!1,t.GAMMAREFLECTION=!1,t.REFRACTION=!1,t.REFRACTIONMAP_3D=!1,t.REFRACTIONMAP_OPPOSITEZ=!1,t.LODINREFRACTIONALPHA=!1,t.GAMMAREFRACTION=!1,t.LINKREFRACTIONTOTRANSPARENCY=!1,t.INSTANCES=!1,t.NUM_BONE_INFLUENCERS=0,t.BonesPerMesh=0,t.MORPHTARGETS=!1,t.MORPHTARGETS_NORMAL=!1,t.MORPHTARGETS_TANGENT=!1,t.NUM_MORPH_INFLUENCERS=0,t.IMAGEPROCESSING=!1,t.VIGNETTE=!1,t.VIGNETTEBLENDMODEMULTIPLY=!1,t.VIGNETTEBLENDMODEOPAQUE=!1,t.TONEMAPPING=!1,t.CONTRAST=!1,t.COLORCURVES=!1,t.COLORGRADING=!1,t.SAMPLER3DGREENDEPTH=!1,t.SAMPLER3DBGRMAP=!1,t.IMAGEPROCESSINGPOSTPROCESS=!1,t.EXPOSURE=!1,t.USEPHYSICALLIGHTFALLOFF=!1,t.TWOSIDEDLIGHTING=!1,t.SHADOWFLOAT=!1,t.USERIGHTHANDEDSYSTEM=!1,t.CLIPPLANE=!1,t.POINTSIZE=!1,t.FOG=!1,t.LOGARITHMICDEPTH=!1,t.FORCENORMALFORWARD=!1,t.rebuild(),t}return __extends(t,e),t.prototype.reset=function(){e.prototype.reset.call(this),this.ALPHATESTVALUE=.5,this.PBR=!0},t})(e.MaterialDefines),i=(function(i){function r(t,r){var n=i.call(this,t,r)||this;return n._directIntensity=1,n._emissiveIntensity=1,n._environmentIntensity=1,n._specularIntensity=1,n._lightingInfos=new e.Vector4(n._directIntensity,n._emissiveIntensity,n._environmentIntensity,n._specularIntensity),n._disableBumpMap=!1,n._ambientTextureStrength=1,n._ambientColor=new e.Color3(0,0,0),n._albedoColor=new e.Color3(1,1,1),n._reflectivityColor=new e.Color3(1,1,1),n._reflectionColor=new e.Color3(1,1,1),n._emissiveColor=new e.Color3(0,0,0),n._microSurface=.9,n._indexOfRefraction=.66,n._invertRefractionY=!1,n._linkRefractionWithTransparency=!1,n._useLightmapAsShadowmap=!1,n._useAlphaFromAlbedoTexture=!1,n._useSpecularOverAlpha=!0,n._useMicroSurfaceFromReflectivityMapAlpha=!1,n._useRoughnessFromMetallicTextureAlpha=!0,n._useRoughnessFromMetallicTextureGreen=!1,n._useMetallnessFromMetallicTextureBlue=!1,n._useAmbientOcclusionFromMetallicTextureRed=!1,n._useAmbientInGrayScale=!1,n._useAutoMicroSurfaceFromReflectivityMap=!1,n._usePhysicalLightFalloff=!0,n._useRadianceOverAlpha=!0,n._useParallax=!1,n._useParallaxOcclusion=!1,n._parallaxScaleBias=.05,n._disableLighting=!1,n._maxSimultaneousLights=4,n._invertNormalMapX=!1,n._invertNormalMapY=!1,n._twoSidedLighting=!1,n._alphaCutOff=.4,n._forceAlphaTest=!1,n._preMultiplyAlpha=!1,n._useAlphaFresnel=!1,n._environmentBRDFTexture=null,n._forceIrradianceInFragment=!1,n._forceNormalForward=!1,n._renderTargets=new e.SmartArray(16),n._worldViewProjectionMatrix=e.Matrix.Zero(),n._globalAmbientColor=new e.Color3(0,0,0),n._tempColor=new e.Color3,n._attachImageProcessingConfiguration(null),n.getRenderTargetTextures=function(){return n._renderTargets.reset(),e.StandardMaterial.ReflectionTextureEnabled&&n._reflectionTexture&&n._reflectionTexture.isRenderTarget&&n._renderTargets.push(n._reflectionTexture),e.StandardMaterial.RefractionTextureEnabled&&n._refractionTexture&&n._refractionTexture.isRenderTarget&&n._renderTargets.push(n._refractionTexture),n._renderTargets},n._environmentBRDFTexture=e.TextureTools.GetEnvironmentBRDFTexture(r),n}return __extends(r,i),r.prototype._attachImageProcessingConfiguration=function(e){var t=this;e!==this._imageProcessingConfiguration&&(this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),this._imageProcessingConfiguration=e||this.getScene().imageProcessingConfiguration,this._imageProcessingObserver=this._imageProcessingConfiguration.onUpdateParameters.add((function(e){t._markAllSubMeshesAsImageProcessingDirty()})))},r.prototype.getClassName=function(){return"PBRBaseMaterial"},Object.defineProperty(r.prototype,"useLogarithmicDepth",{get:function(){return this._useLogarithmicDepth},set:function(e){this._useLogarithmicDepth=e&&this.getScene().getEngine().getCaps().fragmentDepthSupported},enumerable:!0,configurable:!0}),r.prototype.needAlphaBlending=function(){return!this._linkRefractionWithTransparency&&(this.alpha<1||null!=this._opacityTexture||this._shouldUseAlphaFromAlbedoTexture())},r.prototype.needAlphaTesting=function(){return!!this._forceAlphaTest||!this._linkRefractionWithTransparency&&(null!=this._albedoTexture&&this._albedoTexture.hasAlpha)},r.prototype._shouldUseAlphaFromAlbedoTexture=function(){return null!=this._albedoTexture&&this._albedoTexture.hasAlpha&&this._useAlphaFromAlbedoTexture},r.prototype.getAlphaTestTexture=function(){return this._albedoTexture},r.prototype.isReadyForSubMesh=function(i,r,n){if(this.isFrozen&&this._wasPreviouslyReady)return!0;r._materialDefines||(r._materialDefines=new t);var o=this.getScene(),s=r._materialDefines;if(!this.checkReadyOnEveryCall&&r.effect&&s._renderId===o.getRenderId())return!0;var a=o.getEngine();if(e.MaterialHelper.PrepareDefinesForLights(o,i,s,!0,this._maxSimultaneousLights,this._disableLighting),s._needNormals=!0,s._areTexturesDirty){if(s._needUVs=!1,o.texturesEnabled){if(o.getEngine().getCaps().textureLOD&&(s.LODBASEDMICROSFURACE=!0),this._albedoTexture&&e.StandardMaterial.DiffuseTextureEnabled){if(!this._albedoTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._albedoTexture,s,"ALBEDO")}else s.ALBEDO=!1;if(this._ambientTexture&&e.StandardMaterial.AmbientTextureEnabled){if(!this._ambientTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._ambientTexture,s,"AMBIENT"),s.AMBIENTINGRAYSCALE=this._useAmbientInGrayScale}else s.AMBIENT=!1;if(this._opacityTexture&&e.StandardMaterial.OpacityTextureEnabled){if(!this._opacityTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._opacityTexture,s,"OPACITY"),s.OPACITYRGB=this._opacityTexture.getAlphaFromRGB}else s.OPACITY=!1;var h=this._getReflectionTexture();if(h&&e.StandardMaterial.ReflectionTextureEnabled){if(!h.isReadyOrNotBlocking())return!1;switch(s.REFLECTION=!0,s.GAMMAREFLECTION=h.gammaSpace,s.REFLECTIONMAP_OPPOSITEZ=this.getScene().useRightHandedSystem?!h.invertZ:h.invertZ,s.LODINREFLECTIONALPHA=h.lodLevelInAlpha,h.coordinatesMode===e.Texture.INVCUBIC_MODE&&(s.INVERTCUBICMAP=!0),s.REFLECTIONMAP_3D=h.isCube,h.coordinatesMode){case e.Texture.CUBIC_MODE:case e.Texture.INVCUBIC_MODE:s.REFLECTIONMAP_CUBIC=!0;break;case e.Texture.EXPLICIT_MODE:s.REFLECTIONMAP_EXPLICIT=!0;break;case e.Texture.PLANAR_MODE:s.REFLECTIONMAP_PLANAR=!0;break;case e.Texture.PROJECTION_MODE:s.REFLECTIONMAP_PROJECTION=!0;break;case e.Texture.SKYBOX_MODE:s.REFLECTIONMAP_SKYBOX=!0;break;case e.Texture.SPHERICAL_MODE:s.REFLECTIONMAP_SPHERICAL=!0;break;case e.Texture.EQUIRECTANGULAR_MODE:s.REFLECTIONMAP_EQUIRECTANGULAR=!0;break;case e.Texture.FIXED_EQUIRECTANGULAR_MODE:s.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!0;break;case e.Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:s.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!0}h.coordinatesMode!==e.Texture.SKYBOX_MODE&&h.sphericalPolynomial&&(s.USESPHERICALFROMREFLECTIONMAP=!0,(this._forceIrradianceInFragment||o.getEngine().getCaps().maxVaryingVectors<=8)&&(s.USESPHERICALINFRAGMENT=!0))}else s.REFLECTION=!1,s.REFLECTIONMAP_3D=!1,s.REFLECTIONMAP_SPHERICAL=!1,s.REFLECTIONMAP_PLANAR=!1,s.REFLECTIONMAP_CUBIC=!1,s.REFLECTIONMAP_PROJECTION=!1,s.REFLECTIONMAP_SKYBOX=!1,s.REFLECTIONMAP_EXPLICIT=!1,s.REFLECTIONMAP_EQUIRECTANGULAR=!1,s.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,s.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,s.INVERTCUBICMAP=!1,s.USESPHERICALFROMREFLECTIONMAP=!1,s.USESPHERICALINFRAGMENT=!1,s.REFLECTIONMAP_OPPOSITEZ=!1,s.LODINREFLECTIONALPHA=!1,s.GAMMAREFLECTION=!1;if(this._lightmapTexture&&e.StandardMaterial.LightmapTextureEnabled){if(!this._lightmapTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._lightmapTexture,s,"LIGHTMAP"),s.USELIGHTMAPASSHADOWMAP=this._useLightmapAsShadowmap}else s.LIGHTMAP=!1;if(this._emissiveTexture&&e.StandardMaterial.EmissiveTextureEnabled){if(!this._emissiveTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._emissiveTexture,s,"EMISSIVE")}else s.EMISSIVE=!1;if(e.StandardMaterial.SpecularTextureEnabled){if(this._metallicTexture){if(!this._metallicTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._metallicTexture,s,"REFLECTIVITY"),s.METALLICWORKFLOW=!0,s.ROUGHNESSSTOREINMETALMAPALPHA=this._useRoughnessFromMetallicTextureAlpha,s.ROUGHNESSSTOREINMETALMAPGREEN=!this._useRoughnessFromMetallicTextureAlpha&&this._useRoughnessFromMetallicTextureGreen,s.METALLNESSSTOREINMETALMAPBLUE=this._useMetallnessFromMetallicTextureBlue,s.AOSTOREINMETALMAPRED=this._useAmbientOcclusionFromMetallicTextureRed}else if(this._reflectivityTexture){if(!this._reflectivityTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._reflectivityTexture,s,"REFLECTIVITY"),s.MICROSURFACEFROMREFLECTIVITYMAP=this._useMicroSurfaceFromReflectivityMapAlpha,s.MICROSURFACEAUTOMATIC=this._useAutoMicroSurfaceFromReflectivityMap}else s.REFLECTIVITY=!1;if(this._microSurfaceTexture){if(!this._microSurfaceTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._microSurfaceTexture,s,"MICROSURFACEMAP")}else s.MICROSURFACEMAP=!1}else s.REFLECTIVITY=!1,s.MICROSURFACEMAP=!1;if(o.getEngine().getCaps().standardDerivatives&&this._bumpTexture&&e.StandardMaterial.BumpTextureEnabled&&!this._disableBumpMap){if(!this._bumpTexture.isReady())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._bumpTexture,s,"BUMP"),this._useParallax&&this._albedoTexture&&e.StandardMaterial.DiffuseTextureEnabled?(s.PARALLAX=!0,s.PARALLAXOCCLUSION=!!this._useParallaxOcclusion):s.PARALLAX=!1,s.USERIGHTHANDEDSYSTEM=o.useRightHandedSystem}else s.BUMP=!1;var l=this._getRefractionTexture();if(l&&e.StandardMaterial.RefractionTextureEnabled){if(!l.isReadyOrNotBlocking())return!1;s.REFRACTION=!0,s.REFRACTIONMAP_3D=l.isCube,s.GAMMAREFRACTION=l.gammaSpace,s.REFRACTIONMAP_OPPOSITEZ=h.invertZ,s.LODINREFRACTIONALPHA=h.lodLevelInAlpha,this._linkRefractionWithTransparency&&(s.LINKREFRACTIONTOTRANSPARENCY=!0)}else s.REFRACTION=!1;if(this._environmentBRDFTexture&&e.StandardMaterial.ReflectionTextureEnabled){if(!this._environmentBRDFTexture.isReady())return!1;s.ENVIRONMENTBRDF=!0}this._shouldUseAlphaFromAlbedoTexture()&&(s.ALPHAFROMALBEDO=!0)}this._useSpecularOverAlpha&&(s.SPECULAROVERALPHA=!0),this._usePhysicalLightFalloff&&(s.USEPHYSICALLIGHTFALLOFF=!0),this._useRadianceOverAlpha&&(s.RADIANCEOVERALPHA=!0),(void 0!==this._metallic&&null!==this._metallic||void 0!==this._roughness&&null!==this._roughness)&&(s.METALLICWORKFLOW=!0),!this.backFaceCulling&&this._twoSidedLighting&&(s.TWOSIDEDLIGHTING=!0),s.ALPHATESTVALUE=this._alphaCutOff,s.PREMULTIPLYALPHA=this._preMultiplyAlpha,s.ALPHABLEND=this.needAlphaBlending(),s.ALPHAFRESNEL=this._useAlphaFresnel}if(s._areImageProcessingDirty){if(!this._imageProcessingConfiguration.isReady())return!1;this._imageProcessingConfiguration.prepareDefines(s)}if(s.FORCENORMALFORWARD=this._forceNormalForward,e.MaterialHelper.PrepareDefinesForMisc(i,o,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,s),e.MaterialHelper.PrepareDefinesForFrameBoundValues(o,a,s,n,this._forceAlphaTest),e.MaterialHelper.PrepareDefinesForAttributes(i,s,!0,!0,!0)&&i&&(o.getEngine().getCaps().standardDerivatives||i.isVerticesDataPresent(e.VertexBuffer.NormalKind)||(i.createNormals(!0),e.Tools.Warn("PBRMaterial: Normals have been created for the mesh: "+i.name))),s.isDirty){s.markAsProcessed(),o.resetCachedMaterial();var c=new e.EffectFallbacks;s.ENVIRONMENTBRDF&&c.addFallback(0,"ENVIRONMENTBRDF"),s.REFLECTION&&c.addFallback(0,"REFLECTION"),s.REFRACTION&&c.addFallback(0,"REFRACTION"),s.REFLECTIVITY&&c.addFallback(0,"REFLECTIVITY"),s.BUMP&&c.addFallback(0,"BUMP"),s.PARALLAX&&c.addFallback(1,"PARALLAX"),s.PARALLAXOCCLUSION&&c.addFallback(0,"PARALLAXOCCLUSION"),s.SPECULAROVERALPHA&&c.addFallback(0,"SPECULAROVERALPHA"),s.FOG&&c.addFallback(1,"FOG"),s.POINTSIZE&&c.addFallback(0,"POINTSIZE"),s.LOGARITHMICDEPTH&&c.addFallback(0,"LOGARITHMICDEPTH"),e.MaterialHelper.HandleFallbacksForShadows(s,c,this._maxSimultaneousLights),s.SPECULARTERM&&c.addFallback(0,"SPECULARTERM"),s.NUM_BONE_INFLUENCERS>0&&c.addCPUSkinningFallback(0,i);var u=[e.VertexBuffer.PositionKind];s.NORMAL&&u.push(e.VertexBuffer.NormalKind),s.TANGENT&&u.push(e.VertexBuffer.TangentKind),s.UV1&&u.push(e.VertexBuffer.UVKind),s.UV2&&u.push(e.VertexBuffer.UV2Kind),s.VERTEXCOLOR&&u.push(e.VertexBuffer.ColorKind),e.MaterialHelper.PrepareAttributesForBones(u,i,s,c),e.MaterialHelper.PrepareAttributesForInstances(u,s),e.MaterialHelper.PrepareAttributesForMorphTargets(u,i,s);var f=["world","view","viewProjection","vEyePosition","vLightsType","vAmbientColor","vAlbedoColor","vReflectivityColor","vEmissiveColor","vReflectionColor","vFogInfos","vFogColor","pointSize","vAlbedoInfos","vAmbientInfos","vOpacityInfos","vReflectionInfos","vEmissiveInfos","vReflectivityInfos","vMicroSurfaceSamplerInfos","vBumpInfos","vLightmapInfos","vRefractionInfos","mBones","vClipPlane","albedoMatrix","ambientMatrix","opacityMatrix","reflectionMatrix","emissiveMatrix","reflectivityMatrix","microSurfaceSamplerMatrix","bumpMatrix","lightmapMatrix","refractionMatrix","vLightingIntensity","logarithmicDepthConstant","vSphericalX","vSphericalY","vSphericalZ","vSphericalXX","vSphericalYY","vSphericalZZ","vSphericalXY","vSphericalYZ","vSphericalZX","vReflectionMicrosurfaceInfos","vRefractionMicrosurfaceInfos","vNormalReoderParams"],d=["albedoSampler","reflectivitySampler","ambientSampler","emissiveSampler","bumpSampler","lightmapSampler","opacitySampler","refractionSampler","refractionSamplerLow","refractionSamplerHigh","reflectionSampler","reflectionSamplerLow","reflectionSamplerHigh","microSurfaceSampler","environmentBrdfSampler"],p=["Material","Scene"];e.ImageProcessingConfiguration.PrepareUniforms(f,s),e.ImageProcessingConfiguration.PrepareSamplers(d,s),e.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:f,uniformBuffersNames:p,samplers:d,defines:s,maxSimultaneousLights:this._maxSimultaneousLights});var m=function(e){this.onCompiled&&this.onCompiled(e),this.bindSceneUniformBuffer(e,o.getSceneUniformBuffer())}.bind(this),_=s.toString();r.setEffect(o.getEngine().createEffect("pbr",{attributes:u,uniformsNames:f,uniformBuffersNames:p,samplers:d,defines:_,fallbacks:c,onCompiled:m,onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights,maxSimultaneousMorphTargets:s.NUM_MORPH_INFLUENCERS}},a),s),this.buildUniformLayout()}return!!r.effect.isReady()&&(s._renderId=o.getRenderId(),this._wasPreviouslyReady=!0,!0)},r.prototype.buildUniformLayout=function(){this._uniformBuffer.addUniform("vAlbedoInfos",2),this._uniformBuffer.addUniform("vAmbientInfos",3),this._uniformBuffer.addUniform("vOpacityInfos",2),this._uniformBuffer.addUniform("vEmissiveInfos",2),this._uniformBuffer.addUniform("vLightmapInfos",2),this._uniformBuffer.addUniform("vReflectivityInfos",3),this._uniformBuffer.addUniform("vMicroSurfaceSamplerInfos",2),this._uniformBuffer.addUniform("vRefractionInfos",4),this._uniformBuffer.addUniform("vReflectionInfos",2),this._uniformBuffer.addUniform("vBumpInfos",3),this._uniformBuffer.addUniform("albedoMatrix",16),this._uniformBuffer.addUniform("ambientMatrix",16),this._uniformBuffer.addUniform("opacityMatrix",16),this._uniformBuffer.addUniform("emissiveMatrix",16),this._uniformBuffer.addUniform("lightmapMatrix",16),this._uniformBuffer.addUniform("reflectivityMatrix",16),this._uniformBuffer.addUniform("microSurfaceSamplerMatrix",16),this._uniformBuffer.addUniform("bumpMatrix",16),this._uniformBuffer.addUniform("vNormalReoderParams",4),this._uniformBuffer.addUniform("refractionMatrix",16),this._uniformBuffer.addUniform("reflectionMatrix",16),this._uniformBuffer.addUniform("vReflectionColor",3),this._uniformBuffer.addUniform("vAlbedoColor",4),this._uniformBuffer.addUniform("vLightingIntensity",4),this._uniformBuffer.addUniform("vRefractionMicrosurfaceInfos",3),this._uniformBuffer.addUniform("vReflectionMicrosurfaceInfos",3),this._uniformBuffer.addUniform("vReflectivityColor",4),this._uniformBuffer.addUniform("vEmissiveColor",3),this._uniformBuffer.addUniform("pointSize",1),this._uniformBuffer.create()},r.prototype.unbind=function(){this._reflectionTexture&&this._reflectionTexture.isRenderTarget&&this._uniformBuffer.setTexture("reflectionSampler",null),this._refractionTexture&&this._refractionTexture.isRenderTarget&&this._uniformBuffer.setTexture("refractionSampler",null),i.prototype.unbind.call(this)},r.prototype.bindOnlyWorldMatrix=function(e){this._activeEffect.setMatrix("world",e)},r.prototype.bindForSubMesh=function(t,i,r){var n=this.getScene(),o=r._materialDefines;if(o){var s=r.effect;if(this._activeEffect=s,this.bindOnlyWorldMatrix(t),e.MaterialHelper.BindBonesParameters(i,this._activeEffect),this._mustRebind(n,s,i.visibility)){if(this._uniformBuffer.bindToEffect(s,"Material"),this.bindViewProjection(s),!this._uniformBuffer.useUbo||!this.isFrozen||!this._uniformBuffer.isSync){if(n.texturesEnabled){this._albedoTexture&&e.StandardMaterial.DiffuseTextureEnabled&&(this._uniformBuffer.updateFloat2("vAlbedoInfos",this._albedoTexture.coordinatesIndex,this._albedoTexture.level),e.MaterialHelper.BindTextureMatrix(this._albedoTexture,this._uniformBuffer,"albedo")),this._ambientTexture&&e.StandardMaterial.AmbientTextureEnabled&&(this._uniformBuffer.updateFloat3("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level,this._ambientTextureStrength),e.MaterialHelper.BindTextureMatrix(this._ambientTexture,this._uniformBuffer,"ambient")),this._opacityTexture&&e.StandardMaterial.OpacityTextureEnabled&&(this._uniformBuffer.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),e.MaterialHelper.BindTextureMatrix(this._opacityTexture,this._uniformBuffer,"opacity"));var a=this._getReflectionTexture();if(a&&e.StandardMaterial.ReflectionTextureEnabled){if(this._uniformBuffer.updateMatrix("reflectionMatrix",a.getReflectionTextureMatrix()),this._uniformBuffer.updateFloat2("vReflectionInfos",a.level,0),o.USESPHERICALFROMREFLECTIONMAP){var h=a.sphericalPolynomial;this._activeEffect.setFloat3("vSphericalX",h.x.x,h.x.y,h.x.z),this._activeEffect.setFloat3("vSphericalY",h.y.x,h.y.y,h.y.z),this._activeEffect.setFloat3("vSphericalZ",h.z.x,h.z.y,h.z.z),this._activeEffect.setFloat3("vSphericalXX_ZZ",h.xx.x-h.zz.x,h.xx.y-h.zz.y,h.xx.z-h.zz.z),this._activeEffect.setFloat3("vSphericalYY_ZZ",h.yy.x-h.zz.x,h.yy.y-h.zz.y,h.yy.z-h.zz.z),this._activeEffect.setFloat3("vSphericalZZ",h.zz.x,h.zz.y,h.zz.z),this._activeEffect.setFloat3("vSphericalXY",h.xy.x,h.xy.y,h.xy.z),this._activeEffect.setFloat3("vSphericalYZ",h.yz.x,h.yz.y,h.yz.z),this._activeEffect.setFloat3("vSphericalZX",h.zx.x,h.zx.y,h.zx.z)}this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos",a.getSize().width,a.lodGenerationScale,a.lodGenerationOffset)}this._emissiveTexture&&e.StandardMaterial.EmissiveTextureEnabled&&(this._uniformBuffer.updateFloat2("vEmissiveInfos",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),e.MaterialHelper.BindTextureMatrix(this._emissiveTexture,this._uniformBuffer,"emissive")),this._lightmapTexture&&e.StandardMaterial.LightmapTextureEnabled&&(this._uniformBuffer.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),e.MaterialHelper.BindTextureMatrix(this._lightmapTexture,this._uniformBuffer,"lightmap")),e.StandardMaterial.SpecularTextureEnabled&&(this._metallicTexture?(this._uniformBuffer.updateFloat3("vReflectivityInfos",this._metallicTexture.coordinatesIndex,this._metallicTexture.level,this._ambientTextureStrength),e.MaterialHelper.BindTextureMatrix(this._metallicTexture,this._uniformBuffer,"reflectivity")):this._reflectivityTexture&&(this._uniformBuffer.updateFloat3("vReflectivityInfos",this._reflectivityTexture.coordinatesIndex,this._reflectivityTexture.level,1),e.MaterialHelper.BindTextureMatrix(this._reflectivityTexture,this._uniformBuffer,"reflectivity")),this._microSurfaceTexture&&(this._uniformBuffer.updateFloat2("vMicroSurfaceSamplerInfos",this._microSurfaceTexture.coordinatesIndex,this._microSurfaceTexture.level),e.MaterialHelper.BindTextureMatrix(this._microSurfaceTexture,this._uniformBuffer,"microSurfaceSampler"))),this._bumpTexture&&n.getEngine().getCaps().standardDerivatives&&e.StandardMaterial.BumpTextureEnabled&&!this._disableBumpMap&&(this._uniformBuffer.updateFloat3("vBumpInfos",this._bumpTexture.coordinatesIndex,this._bumpTexture.level,this._parallaxScaleBias),e.MaterialHelper.BindTextureMatrix(this._bumpTexture,this._uniformBuffer,"bump"),n._mirroredCameraPosition?this._uniformBuffer.updateFloat4("vNormalReoderParams",this._invertNormalMapX?0:1,this._invertNormalMapX?1:-1,this._invertNormalMapY?0:1,this._invertNormalMapY?1:-1):this._uniformBuffer.updateFloat4("vNormalReoderParams",this._invertNormalMapX?1:0,this._invertNormalMapX?-1:1,this._invertNormalMapY?1:0,this._invertNormalMapY?-1:1));var l=this._getRefractionTexture();if(l&&e.StandardMaterial.RefractionTextureEnabled){this._uniformBuffer.updateMatrix("refractionMatrix",l.getReflectionTextureMatrix());var c=1;l.isCube||l.depth&&(c=l.depth),this._uniformBuffer.updateFloat4("vRefractionInfos",l.level,this._indexOfRefraction,c,this._invertRefractionY?-1:1),this._uniformBuffer.updateFloat3("vRefractionMicrosurfaceInfos",l.getSize().width,l.lodGenerationScale,l.lodGenerationOffset)}}this.pointsCloud&&this._uniformBuffer.updateFloat("pointSize",this.pointSize),o.METALLICWORKFLOW?(e.PBRMaterial._scaledReflectivity.r=void 0===this._metallic||null===this._metallic?1:this._metallic,e.PBRMaterial._scaledReflectivity.g=void 0===this._roughness||null===this._roughness?1:this._roughness,this._uniformBuffer.updateColor4("vReflectivityColor",e.PBRMaterial._scaledReflectivity,0)):this._uniformBuffer.updateColor4("vReflectivityColor",this._reflectivityColor,this._microSurface),this._uniformBuffer.updateColor3("vEmissiveColor",this._emissiveColor),this._uniformBuffer.updateColor3("vReflectionColor",this._reflectionColor),this._uniformBuffer.updateColor4("vAlbedoColor",this._albedoColor,this.alpha*i.visibility),this._lightingInfos.x=this._directIntensity,this._lightingInfos.y=this._emissiveIntensity,this._lightingInfos.z=this._environmentIntensity,this._lightingInfos.w=this._specularIntensity,this._uniformBuffer.updateVector4("vLightingIntensity",this._lightingInfos)}n.texturesEnabled&&(this._albedoTexture&&e.StandardMaterial.DiffuseTextureEnabled&&this._uniformBuffer.setTexture("albedoSampler",this._albedoTexture),this._ambientTexture&&e.StandardMaterial.AmbientTextureEnabled&&this._uniformBuffer.setTexture("ambientSampler",this._ambientTexture),this._opacityTexture&&e.StandardMaterial.OpacityTextureEnabled&&this._uniformBuffer.setTexture("opacitySampler",this._opacityTexture),a&&e.StandardMaterial.ReflectionTextureEnabled&&(o.LODBASEDMICROSFURACE?this._uniformBuffer.setTexture("reflectionSampler",a):(this._uniformBuffer.setTexture("reflectionSampler",a._lodTextureMid||a),this._uniformBuffer.setTexture("reflectionSamplerLow",a._lodTextureLow||a),this._uniformBuffer.setTexture("reflectionSamplerHigh",a._lodTextureHigh||a))),o.ENVIRONMENTBRDF&&this._uniformBuffer.setTexture("environmentBrdfSampler",this._environmentBRDFTexture),l&&e.StandardMaterial.RefractionTextureEnabled&&(o.LODBASEDMICROSFURACE?this._uniformBuffer.setTexture("refractionSampler",l):(this._uniformBuffer.setTexture("refractionSampler",l._lodTextureMid||l),this._uniformBuffer.setTexture("refractionSamplerLow",l._lodTextureLow||l),this._uniformBuffer.setTexture("refractionSamplerHigh",l._lodTextureHigh||l))),this._emissiveTexture&&e.StandardMaterial.EmissiveTextureEnabled&&this._uniformBuffer.setTexture("emissiveSampler",this._emissiveTexture),this._lightmapTexture&&e.StandardMaterial.LightmapTextureEnabled&&this._uniformBuffer.setTexture("lightmapSampler",this._lightmapTexture), -e.StandardMaterial.SpecularTextureEnabled&&(this._metallicTexture?this._uniformBuffer.setTexture("reflectivitySampler",this._metallicTexture):this._reflectivityTexture&&this._uniformBuffer.setTexture("reflectivitySampler",this._reflectivityTexture),this._microSurfaceTexture&&this._uniformBuffer.setTexture("microSurfaceSampler",this._microSurfaceTexture)),this._bumpTexture&&n.getEngine().getCaps().standardDerivatives&&e.StandardMaterial.BumpTextureEnabled&&!this._disableBumpMap&&this._uniformBuffer.setTexture("bumpSampler",this._bumpTexture)),e.MaterialHelper.BindClipPlane(this._activeEffect,n),n.ambientColor.multiplyToRef(this._ambientColor,this._globalAmbientColor);var u=n._mirroredCameraPosition?n._mirroredCameraPosition:n.activeCamera.globalPosition;s.setFloat4("vEyePosition",u.x,u.y,u.z,n._mirroredCameraPosition?-1:1),s.setColor3("vAmbientColor",this._globalAmbientColor)}!this._mustRebind(n,s)&&this.isFrozen||(n.lightsEnabled&&!this._disableLighting&&e.MaterialHelper.BindLights(n,i,this._activeEffect,o,this._maxSimultaneousLights,this._usePhysicalLightFalloff),(n.fogEnabled&&i.applyFog&&n.fogMode!==e.Scene.FOGMODE_NONE||a)&&this.bindView(s),e.MaterialHelper.BindFogParameters(n,i,this._activeEffect),o.NUM_MORPH_INFLUENCERS&&e.MaterialHelper.BindMorphTargetParameters(i,this._activeEffect),this._imageProcessingConfiguration.bind(this._activeEffect),e.MaterialHelper.BindLogDepth(o,this._activeEffect,n)),this._uniformBuffer.update(),this._afterBind(i),n=null}},r.prototype.getAnimatables=function(){var e=[];return this._albedoTexture&&this._albedoTexture.animations&&this._albedoTexture.animations.length>0&&e.push(this._albedoTexture),this._ambientTexture&&this._ambientTexture.animations&&this._ambientTexture.animations.length>0&&e.push(this._ambientTexture),this._opacityTexture&&this._opacityTexture.animations&&this._opacityTexture.animations.length>0&&e.push(this._opacityTexture),this._reflectionTexture&&this._reflectionTexture.animations&&this._reflectionTexture.animations.length>0&&e.push(this._reflectionTexture),this._emissiveTexture&&this._emissiveTexture.animations&&this._emissiveTexture.animations.length>0&&e.push(this._emissiveTexture),this._metallicTexture&&this._metallicTexture.animations&&this._metallicTexture.animations.length>0?e.push(this._metallicTexture):this._reflectivityTexture&&this._reflectivityTexture.animations&&this._reflectivityTexture.animations.length>0&&e.push(this._reflectivityTexture),this._bumpTexture&&this._bumpTexture.animations&&this._bumpTexture.animations.length>0&&e.push(this._bumpTexture),this._lightmapTexture&&this._lightmapTexture.animations&&this._lightmapTexture.animations.length>0&&e.push(this._lightmapTexture),this._refractionTexture&&this._refractionTexture.animations&&this._refractionTexture.animations.length>0&&e.push(this._refractionTexture),e},r.prototype._getReflectionTexture=function(){return this._reflectionTexture?this._reflectionTexture:this.getScene().environmentTexture},r.prototype._getRefractionTexture=function(){return this._refractionTexture?this._refractionTexture:this._linkRefractionWithTransparency?this.getScene().environmentTexture:null},r.prototype.dispose=function(e,t){t&&(this._albedoTexture&&this._albedoTexture.dispose(),this._ambientTexture&&this._ambientTexture.dispose(),this._opacityTexture&&this._opacityTexture.dispose(),this._reflectionTexture&&this._reflectionTexture.dispose(),this._environmentBRDFTexture&&this._environmentBRDFTexture.dispose(),this._emissiveTexture&&this._emissiveTexture.dispose(),this._metallicTexture&&this._metallicTexture.dispose(),this._reflectivityTexture&&this._reflectivityTexture.dispose(),this._bumpTexture&&this._bumpTexture.dispose(),this._lightmapTexture&&this._lightmapTexture.dispose(),this._refractionTexture&&this._refractionTexture.dispose()),this._renderTargets.dispose(),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),i.prototype.dispose.call(this,e,t)},r})(e.PushMaterial);i._scaledReflectivity=new e.Color3,__decorate([e.serializeAsImageProcessingConfiguration()],i.prototype,"_imageProcessingConfiguration",void 0),__decorate([e.serialize()],i.prototype,"useLogarithmicDepth",null),e.PBRBaseMaterial=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){var i=(function(t){function i(i,r){var n=t.call(this,i,r)||this;return n.maxSimultaneousLights=4,n.disableLighting=!1,n.invertNormalMapX=!1,n.invertNormalMapY=!1,n.emissiveColor=new e.Color3(0,0,0),n.occlusionStrength=1,n._transparencyMode=e.PBRMaterial.PBRMATERIAL_OPAQUE,n._useAmbientInGrayScale=!0,n}return __extends(i,t),Object.defineProperty(i.prototype,"transparencyMode",{get:function(){return this._transparencyMode},set:function(t){this._transparencyMode!==t&&(this._transparencyMode=t,t===e.PBRMaterial.PBRMATERIAL_ALPHATESTANDBLEND?this._forceAlphaTest=!0:this._forceAlphaTest=!1,this._markAllSubMeshesAsTexturesDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"doubleSided",{get:function(){return this._twoSidedLighting},set:function(e){this._twoSidedLighting!==e&&(this._twoSidedLighting=e,this.backFaceCulling=!e,this._markAllSubMeshesAsTexturesDirty())},enumerable:!0,configurable:!0}),i.prototype._shouldUseAlphaFromAlbedoTexture=function(){return this._albedoTexture&&this._albedoTexture.hasAlpha&&this._transparencyMode!==e.PBRMaterial.PBRMATERIAL_OPAQUE},i.prototype.needAlphaBlending=function(){return!this._linkRefractionWithTransparency&&(this.alpha<1||this._shouldUseAlphaFromAlbedoTexture()&&(this._transparencyMode===e.PBRMaterial.PBRMATERIAL_ALPHABLEND||this._transparencyMode===e.PBRMaterial.PBRMATERIAL_ALPHATESTANDBLEND))},i.prototype.needAlphaTesting=function(){return!this._linkRefractionWithTransparency&&(this._shouldUseAlphaFromAlbedoTexture()&&this._transparencyMode===e.PBRMaterial.PBRMATERIAL_ALPHATEST)},i.prototype.getActiveTextures=function(){var e=t.prototype.getActiveTextures.call(this);return this.environmentTexture&&e.push(this.environmentTexture),this.normalTexture&&e.push(this.normalTexture),this.emissiveTexture&&e.push(this.emissiveTexture),this.occlusionTexture&&e.push(this.occlusionTexture),e},i.prototype.getClassName=function(){return"PBRBaseSimpleMaterial"},i})(e.PBRBaseMaterial);__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsLightsDirty")],i.prototype,"maxSimultaneousLights",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsLightsDirty")],i.prototype,"disableLighting",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_reflectionTexture")],i.prototype,"environmentTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"invertNormalMapX",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"invertNormalMapY",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_bumpTexture")],i.prototype,"normalTexture",void 0),__decorate([e.serializeAsColor3("emissive"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"emissiveColor",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"emissiveTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_ambientTextureStrength")],i.prototype,"occlusionStrength",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_ambientTexture")],i.prototype,"occlusionTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_alphaCutOff")],i.prototype,"alphaCutOff",void 0),__decorate([e.serialize()],i.prototype,"transparencyMode",null),__decorate([e.serialize()],i.prototype,"doubleSided",null),t.PBRBaseSimpleMaterial=i})(e.Internals||(e.Internals={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r){var n=t.call(this,i,r)||this;return n.directIntensity=1,n.emissiveIntensity=1,n.environmentIntensity=1,n.specularIntensity=1,n.disableBumpMap=!1,n.ambientTextureStrength=1,n.ambientColor=new e.Color3(0,0,0),n.albedoColor=new e.Color3(1,1,1),n.reflectivityColor=new e.Color3(1,1,1),n.reflectionColor=new e.Color3(1,1,1),n.emissiveColor=new e.Color3(0,0,0),n.microSurface=1,n.indexOfRefraction=.66,n.invertRefractionY=!1,n.linkRefractionWithTransparency=!1,n.useLightmapAsShadowmap=!1,n.useAlphaFromAlbedoTexture=!1,n.forceAlphaTest=!1,n.alphaCutOff=.4,n.useSpecularOverAlpha=!0,n.useMicroSurfaceFromReflectivityMapAlpha=!1,n.useRoughnessFromMetallicTextureAlpha=!0,n.useRoughnessFromMetallicTextureGreen=!1,n.useMetallnessFromMetallicTextureBlue=!1,n.useAmbientOcclusionFromMetallicTextureRed=!1,n.useAmbientInGrayScale=!1,n.useAutoMicroSurfaceFromReflectivityMap=!1,n.usePhysicalLightFalloff=!0,n.useRadianceOverAlpha=!0,n.useParallax=!1,n.useParallaxOcclusion=!1,n.parallaxScaleBias=.05,n.disableLighting=!1,n.forceIrradianceInFragment=!1,n.maxSimultaneousLights=4,n.invertNormalMapX=!1,n.invertNormalMapY=!1,n.twoSidedLighting=!1,n.preMultiplyAlpha=!1,n.useAlphaFresnel=!1,n.environmentBRDFTexture=null,n.forceNormalForward=!1,n._environmentBRDFTexture=e.TextureTools.GetEnvironmentBRDFTexture(r),n}return __extends(i,t),Object.defineProperty(i,"PBRMATERIAL_OPAQUE",{get:function(){return this._PBRMATERIAL_OPAQUE},enumerable:!0,configurable:!0}),Object.defineProperty(i,"PBRMATERIAL_ALPHATEST",{get:function(){return this._PBRMATERIAL_ALPHATEST},enumerable:!0,configurable:!0}),Object.defineProperty(i,"PBRMATERIAL_ALPHABLEND",{get:function(){return this._PBRMATERIAL_ALPHABLEND},enumerable:!0,configurable:!0}),Object.defineProperty(i,"PBRMATERIAL_ALPHATESTANDBLEND",{get:function(){return this._PBRMATERIAL_ALPHATESTANDBLEND},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(e){this._attachImageProcessingConfiguration(e),this._markAllSubMeshesAsTexturesDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"cameraColorCurvesEnabled",{get:function(){return this.imageProcessingConfiguration.colorCurvesEnabled},set:function(e){this.imageProcessingConfiguration.colorCurvesEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"cameraColorGradingEnabled",{get:function(){return this.imageProcessingConfiguration.colorGradingEnabled},set:function(e){this.imageProcessingConfiguration.colorGradingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"cameraToneMappingEnabled",{get:function(){return this._imageProcessingConfiguration.toneMappingEnabled},set:function(e){this._imageProcessingConfiguration.toneMappingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"cameraExposure",{get:function(){return this._imageProcessingConfiguration.exposure},set:function(e){this._imageProcessingConfiguration.exposure=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"cameraContrast",{get:function(){return this._imageProcessingConfiguration.contrast},set:function(e){this._imageProcessingConfiguration.contrast=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"cameraColorGradingTexture",{get:function(){return this._imageProcessingConfiguration.colorGradingTexture},set:function(e){this._imageProcessingConfiguration.colorGradingTexture=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"cameraColorCurves",{get:function(){return this._imageProcessingConfiguration.colorCurves},set:function(e){this._imageProcessingConfiguration.colorCurves=e},enumerable:!0,configurable:!0}),i.prototype.getClassName=function(){return"PBRMaterial"},i.prototype.getActiveTextures=function(){var e=t.prototype.getActiveTextures.call(this);return this._albedoTexture&&e.push(this._albedoTexture),this._ambientTexture&&e.push(this._ambientTexture),this._opacityTexture&&e.push(this._opacityTexture),this._reflectionTexture&&e.push(this._reflectionTexture),this._emissiveTexture&&e.push(this._emissiveTexture),this._reflectivityTexture&&e.push(this._reflectivityTexture),this._metallicTexture&&e.push(this._metallicTexture),this._microSurfaceTexture&&e.push(this._microSurfaceTexture),this._bumpTexture&&e.push(this._bumpTexture),this._lightmapTexture&&e.push(this._lightmapTexture),this._refractionTexture&&e.push(this._refractionTexture),e},i.prototype.hasTexture=function(e){return!!t.prototype.hasTexture.call(this,e)||(this._albedoTexture===e||(this._ambientTexture===e||(this._opacityTexture===e||(this._reflectionTexture===e||(this._reflectivityTexture===e||(this._metallicTexture===e||(this._microSurfaceTexture===e||(this._bumpTexture===e||(this._lightmapTexture===e||this._refractionTexture===e)))))))))},i.prototype.clone=function(t){var r=this;return e.SerializationHelper.Clone((function(){return new i(t,r.getScene())}),this)},i.prototype.serialize=function(){var t=e.SerializationHelper.Serialize(this);return t.customType="BABYLON.PBRMaterial",t},i.Parse=function(t,r,n){return e.SerializationHelper.Parse((function(){return new i(t.name,r)}),t,r,n)},i})(e.PBRBaseMaterial);t._PBRMATERIAL_OPAQUE=0,t._PBRMATERIAL_ALPHATEST=1,t._PBRMATERIAL_ALPHABLEND=2,t._PBRMATERIAL_ALPHATESTANDBLEND=3,__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"directIntensity",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveIntensity",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"environmentIntensity",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"specularIntensity",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"disableBumpMap",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"albedoTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientTextureStrength",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"opacityTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectivityTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallicTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallic",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"roughness",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"microSurfaceTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"bumpTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty",null)],t.prototype,"lightmapTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"refractionTexture",void 0),__decorate([e.serializeAsColor3("ambient"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientColor",void 0),__decorate([e.serializeAsColor3("albedo"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"albedoColor",void 0),__decorate([e.serializeAsColor3("reflectivity"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectivityColor",void 0),__decorate([e.serializeAsColor3("reflection"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionColor",void 0),__decorate([e.serializeAsColor3("emissive"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveColor",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"microSurface",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"indexOfRefraction",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertRefractionY",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"linkRefractionWithTransparency",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useLightmapAsShadowmap",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAlphaFromAlbedoTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"forceAlphaTest",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"alphaCutOff",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useSpecularOverAlpha",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useMicroSurfaceFromReflectivityMapAlpha",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRoughnessFromMetallicTextureAlpha",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRoughnessFromMetallicTextureGreen",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useMetallnessFromMetallicTextureBlue",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAmbientOcclusionFromMetallicTextureRed",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAmbientInGrayScale",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAutoMicroSurfaceFromReflectivityMap",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"usePhysicalLightFalloff",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRadianceOverAlpha",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useParallax",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useParallaxOcclusion",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"parallaxScaleBias",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsLightsDirty")],t.prototype,"disableLighting",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"forceIrradianceInFragment",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsLightsDirty")],t.prototype,"maxSimultaneousLights",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapX",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapY",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"twoSidedLighting",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"preMultiplyAlpha",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAlphaFresnel",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"environmentBRDFTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"forceNormalForward",void 0),e.PBRMaterial=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e,i){var r=t.call(this,e,i)||this;return r._useRoughnessFromMetallicTextureAlpha=!1,r._useRoughnessFromMetallicTextureGreen=!0,r._useMetallnessFromMetallicTextureBlue=!0,r}return __extends(i,t),i.prototype.getClassName=function(){return"PBRMetallicRoughnessMaterial"},i.prototype.getActiveTextures=function(){var e=t.prototype.getActiveTextures.call(this);return this.baseTexture&&e.push(this.baseTexture),this.metallicRoughnessTexture&&e.push(this.metallicRoughnessTexture),e},i.prototype.hasTexture=function(e){return!!t.prototype.hasTexture.call(this,e)||(this.baseTexture===e||this.metallicRoughnessTexture===e)},i.prototype.clone=function(t){var r=this;return e.SerializationHelper.Clone((function(){return new i(t,r.getScene())}),this)},i.prototype.serialize=function(){var t=e.SerializationHelper.Serialize(this);return t.customType="BABYLON.PBRMetallicRoughnessMaterial",t},i.Parse=function(t,r,n){return e.SerializationHelper.Parse((function(){return new i(t.name,r)}),t,r,n)},i})(e.Internals.PBRBaseSimpleMaterial);__decorate([e.serializeAsColor3(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_albedoColor")],t.prototype,"baseColor",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_albedoTexture")],t.prototype,"baseTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallic",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"roughness",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_metallicTexture")],t.prototype,"metallicRoughnessTexture",void 0),e.PBRMetallicRoughnessMaterial=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e,i){var r=t.call(this,e,i)||this;return r._useMicroSurfaceFromReflectivityMapAlpha=!0,r}return __extends(i,t),i.prototype.getClassName=function(){return"PBRSpecularGlossinessMaterial"},i.prototype.getActiveTextures=function(){var e=t.prototype.getActiveTextures.call(this);return this.diffuseTexture&&e.push(this.diffuseTexture),this.specularGlossinessTexture&&e.push(this.specularGlossinessTexture),e},i.prototype.hasTexture=function(e){return!!t.prototype.hasTexture.call(this,e)||(this.diffuseTexture===e||this.specularGlossinessTexture===e)},i.prototype.clone=function(t){var r=this;return e.SerializationHelper.Clone((function(){return new i(t,r.getScene())}),this)},i.prototype.serialize=function(){var t=e.SerializationHelper.Serialize(this);return t.customType="BABYLON.PBRSpecularGlossinessMaterial",t},i.Parse=function(t,r,n){return e.SerializationHelper.Parse((function(){return new i(t.name,r)}),t,r,n)},i})(e.Internals.PBRBaseSimpleMaterial);__decorate([e.serializeAsColor3("diffuse"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_albedoColor")],t.prototype,"diffuseColor",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_albedoTexture")],t.prototype,"diffuseTexture",void 0),__decorate([e.serializeAsColor3("specular"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_reflectivityColor")],t.prototype,"specularColor",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_microSurface")],t.prototype,"glossiness",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_reflectivityTexture")],t.prototype,"specularGlossinessTexture",void 0),e.PBRSpecularGlossinessMaterial=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){e.CameraInputTypes={};var t=(function(){function t(e){this.attached={},this.camera=e,this.checkInputs=function(){}}return t.prototype.add=function(t){var i=t.getSimpleName();if(this.attached[i])return void e.Tools.Warn("camera input of type "+i+" already exists on camera");this.attached[i]=t,t.camera=this.camera,t.checkInputs&&(this.checkInputs=this._addCheckInputs(t.checkInputs.bind(t))),this.attachedElement&&t.attachControl(this.attachedElement)},t.prototype.remove=function(e){for(var t in this.attached){var i=this.attached[t];i===e&&(i.detachControl(this.attachedElement),delete this.attached[t],this.rebuildInputCheck())}},t.prototype.removeByType=function(e){for(var t in this.attached){var i=this.attached[t];i.getClassName()===e&&(i.detachControl(this.attachedElement),delete this.attached[t],this.rebuildInputCheck())}},t.prototype._addCheckInputs=function(e){var t=this.checkInputs;return function(){t(),e()}},t.prototype.attachInput=function(e){e.attachControl(this.attachedElement,this.noPreventDefault)},t.prototype.attachElement=function(t,i){if(!this.attachedElement){i=!e.Camera.ForceAttachControlToAlwaysPreventDefault&&i,this.attachedElement=t,this.noPreventDefault=i;for(var r in this.attached){this.attached[r];this.attached[r].attachControl(t,i)}}},t.prototype.detachElement=function(e){if(this.attachedElement===e){for(var t in this.attached){this.attached[t];this.attached[t].detachControl(e)}this.attachedElement=null}},t.prototype.rebuildInputCheck=function(){this.checkInputs=function(){};for(var e in this.attached){var t=this.attached[e];t.checkInputs&&(this.checkInputs=this._addCheckInputs(t.checkInputs.bind(t)))}},t.prototype.clear=function(){this.attachedElement&&this.detachElement(this.attachedElement),this.attached={},this.attachedElement=null,this.checkInputs=function(){}},t.prototype.serialize=function(t){var i={};for(var r in this.attached){var n=this.attached[r],o=e.SerializationHelper.Serialize(n);i[n.getClassName()]=o}t.inputsmgr=i},t.prototype.parse=function(t){var i=t.inputsmgr;if(i){this.clear();for(var r in i){var n=e.CameraInputTypes[r];if(n){var o=i[r],s=e.SerializationHelper.Parse((function(){return new n}),o,null);this.add(s)}}}else for(var r in this.attached){var n=e.CameraInputTypes[this.attached[r].getClassName()];if(n){var s=e.SerializationHelper.Parse((function(){return new n}),t,null);this.remove(this.attached[r]),this.add(s)}}},t})();e.CameraInputsManager=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e){void 0===e&&(e=!0),this.touchEnabled=e,this.buttons=[0,1,2],this.angularSensibility=2e3}return t.prototype.attachControl=function(t,i){var r=this,n=this.camera.getEngine();this._pointerInput||(this._pointerInput=function(o,s){var a=o.event;if((r.touchEnabled||"touch"!==a.pointerType)&&(o.type===e.PointerEventTypes.POINTERMOVE||-1!==r.buttons.indexOf(a.button)))if(o.type===e.PointerEventTypes.POINTERDOWN){try{a.srcElement.setPointerCapture(a.pointerId)}catch(e){}r.previousPosition={x:a.clientX,y:a.clientY},i||(a.preventDefault(),t.focus())}else if(o.type===e.PointerEventTypes.POINTERUP){try{a.srcElement.releasePointerCapture(a.pointerId)}catch(e){}r.previousPosition=null,i||a.preventDefault()}else if(o.type===e.PointerEventTypes.POINTERMOVE){if(!r.previousPosition||n.isPointerLock)return;var h=a.clientX-r.previousPosition.x,l=a.clientY-r.previousPosition.y;r.camera.getScene().useRightHandedSystem?r.camera.cameraRotation.y-=h/r.angularSensibility:r.camera.cameraRotation.y+=h/r.angularSensibility,r.camera.cameraRotation.x+=l/r.angularSensibility,r.previousPosition={x:a.clientX,y:a.clientY},i||a.preventDefault()}}),this._onMouseMove=function(e){if(n.isPointerLock){var t=e.movementX||e.mozMovementX||e.webkitMovementX||e.msMovementX||0,o=e.movementY||e.mozMovementY||e.webkitMovementY||e.msMovementY||0;r.camera.getScene().useRightHandedSystem?r.camera.cameraRotation.y-=t/r.angularSensibility:r.camera.cameraRotation.y+=t/r.angularSensibility,r.camera.cameraRotation.x+=o/r.angularSensibility,r.previousPosition=null,i||e.preventDefault()}},this._observer=this.camera.getScene().onPointerObservable.add(this._pointerInput,e.PointerEventTypes.POINTERDOWN|e.PointerEventTypes.POINTERUP|e.PointerEventTypes.POINTERMOVE),t.addEventListener("mousemove",this._onMouseMove,!1)},t.prototype.detachControl=function(e){this._observer&&e&&(this.camera.getScene().onPointerObservable.remove(this._observer),e.removeEventListener("mousemove",this._onMouseMove),this._observer=null,this._onMouseMove=null,this.previousPosition=null)},t.prototype.getClassName=function(){return"FreeCameraMouseInput"},t.prototype.getSimpleName=function(){return"mouse"},t})();__decorate([e.serialize()],t.prototype,"buttons",void 0),__decorate([e.serialize()],t.prototype,"angularSensibility",void 0),e.FreeCameraMouseInput=t,e.CameraInputTypes.FreeCameraMouseInput=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this._keys=[],this.keysUp=[38],this.keysDown=[40],this.keysLeft=[37],this.keysRight=[39]}return t.prototype.attachControl=function(t,i){var r=this;this._onKeyDown||(t.tabIndex=1,this._onKeyDown=function(e){if(-1!==r.keysUp.indexOf(e.keyCode)||-1!==r.keysDown.indexOf(e.keyCode)||-1!==r.keysLeft.indexOf(e.keyCode)||-1!==r.keysRight.indexOf(e.keyCode)){-1===r._keys.indexOf(e.keyCode)&&r._keys.push(e.keyCode),i||e.preventDefault()}},this._onKeyUp=function(e){if(-1!==r.keysUp.indexOf(e.keyCode)||-1!==r.keysDown.indexOf(e.keyCode)||-1!==r.keysLeft.indexOf(e.keyCode)||-1!==r.keysRight.indexOf(e.keyCode)){var t=r._keys.indexOf(e.keyCode);t>=0&&r._keys.splice(t,1),i||e.preventDefault()}},t.addEventListener("keydown",this._onKeyDown,!1),t.addEventListener("keyup",this._onKeyUp,!1),e.Tools.RegisterTopRootEvents([{name:"blur",handler:this._onLostFocus}]))},t.prototype.detachControl=function(t){this._onKeyDown&&(t.removeEventListener("keydown",this._onKeyDown),t.removeEventListener("keyup",this._onKeyUp),e.Tools.UnregisterTopRootEvents([{name:"blur",handler:this._onLostFocus}]),this._keys=[],this._onKeyDown=null,this._onKeyUp=null)},t.prototype.checkInputs=function(){if(this._onKeyDown)for(var t=this.camera,i=0;i=0?this.rotation.y=-Math.atan(i.z/i.x)+Math.PI/2:this.rotation.y=-Math.atan(i.z/i.x)-Math.PI/2,this.rotation.z=0,isNaN(this.rotation.x)&&(this.rotation.x=0),isNaN(this.rotation.y)&&(this.rotation.y=0),isNaN(this.rotation.z)&&(this.rotation.z=0),this.rotationQuaternion&&e.Quaternion.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this.rotationQuaternion)},i.prototype.getTarget=function(){return this._currentTarget},i.prototype._decideIfNeedsToMove=function(){return Math.abs(this.cameraDirection.x)>0||Math.abs(this.cameraDirection.y)>0||Math.abs(this.cameraDirection.z)>0},i.prototype._updatePosition=function(){if(this.parent)return this.parent.getWorldMatrix().invertToRef(e.Tmp.Matrix[0]),e.Vector3.TransformNormalToRef(this.cameraDirection,e.Tmp.Matrix[0],e.Tmp.Vector3[0]),void this.position.addInPlace(e.Tmp.Vector3[0]);this.position.addInPlace(this.cameraDirection)},i.prototype._checkInputs=function(){var i=this._decideIfNeedsToMove(),r=Math.abs(this.cameraRotation.x)>0||Math.abs(this.cameraRotation.y)>0;if(i&&this._updatePosition(),r){if(this.rotation.x+=this.cameraRotation.x,this.rotation.y+=this.cameraRotation.y,this.rotationQuaternion){this.rotation.lengthSquared()&&e.Quaternion.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this.rotationQuaternion)}if(!this.noRotationConstraint){var n=Math.PI/2*.95;this.rotation.x>n&&(this.rotation.x=n),this.rotation.x<-n&&(this.rotation.x=-n)}}i&&(Math.abs(this.cameraDirection.x)e.Engine.CollisionsEpsilon&&(o.position.addInPlace(o._diffPosition),o.onCollide&&r&&o.onCollide(r))})(i)},o.inputs=new e.FreeCameraInputsManager(o),o.inputs.addKeyboard().addMouse(),o}return __extends(i,t),Object.defineProperty(i.prototype,"angularSensibility",{get:function(){var e=this.inputs.attached.mouse;if(e)return e.angularSensibility},set:function(e){var t=this.inputs.attached.mouse;t&&(t.angularSensibility=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"keysUp",{get:function(){var e=this.inputs.attached.keyboard;if(e)return e.keysUp},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysUp=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"keysDown",{get:function(){var e=this.inputs.attached.keyboard;if(e)return e.keysDown},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysDown=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"keysLeft",{get:function(){var e=this.inputs.attached.keyboard;if(e)return e.keysLeft},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysLeft=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"keysRight",{get:function(){var e=this.inputs.attached.keyboard;if(e)return e.keysRight},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysRight=e)},enumerable:!0,configurable:!0}),i.prototype.attachControl=function(e,t){this.inputs.attachElement(e,t)},i.prototype.detachControl=function(t){this.inputs.detachElement(t),this.cameraDirection=new e.Vector3(0,0,0),this.cameraRotation=new e.Vector2(0,0)},Object.defineProperty(i.prototype,"collisionMask",{get:function(){return this._collisionMask},set:function(e){this._collisionMask=isNaN(e)?-1:e},enumerable:!0,configurable:!0}),i.prototype._collideWithWorld=function(t){var i;i=this.parent?e.Vector3.TransformCoordinates(this.position,this.parent.getWorldMatrix()):this.position,i.subtractFromFloatsToRef(0,this.ellipsoid.y,0,this._oldPosition),this._collider||(this._collider=new e.Collider),this._collider.radius=this.ellipsoid,this._collider.collisionMask=this._collisionMask;var r=t;this.applyGravity&&(r=t.add(this.getScene().gravity)),this.getScene().collisionCoordinator.getNewPosition(this._oldPosition,r,this._collider,3,null,this._onCollisionPositionChange,this.uniqueId)},i.prototype._checkInputs=function(){this._localDirection||(this._localDirection=e.Vector3.Zero(),this._transformedDirection=e.Vector3.Zero()),this.inputs.checkInputs(),t.prototype._checkInputs.call(this)},i.prototype._decideIfNeedsToMove=function(){return this._needMoveForGravity||Math.abs(this.cameraDirection.x)>0||Math.abs(this.cameraDirection.y)>0||Math.abs(this.cameraDirection.z)>0},i.prototype._updatePosition=function(){this.checkCollisions&&this.getScene().collisionsEnabled?this._collideWithWorld(this.cameraDirection):t.prototype._updatePosition.call(this)},i.prototype.dispose=function(){this.inputs.clear(),t.prototype.dispose.call(this)},i.prototype.getClassName=function(){return"FreeCamera"},i})(e.TargetCamera);__decorate([e.serializeAsVector3()],t.prototype,"ellipsoid",void 0),__decorate([e.serialize()],t.prototype,"checkCollisions",void 0),__decorate([e.serialize()],t.prototype,"applyGravity",void 0),e.FreeCamera=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this._keys=[],this.keysUp=[38],this.keysDown=[40],this.keysLeft=[37],this.keysRight=[39]}return t.prototype.attachControl=function(t,i){var r=this;t.tabIndex=1,this._onKeyDown=function(e){if(-1!==r.keysUp.indexOf(e.keyCode)||-1!==r.keysDown.indexOf(e.keyCode)||-1!==r.keysLeft.indexOf(e.keyCode)||-1!==r.keysRight.indexOf(e.keyCode)){-1===r._keys.indexOf(e.keyCode)&&r._keys.push(e.keyCode),e.preventDefault&&(i||e.preventDefault())}},this._onKeyUp=function(e){if(-1!==r.keysUp.indexOf(e.keyCode)||-1!==r.keysDown.indexOf(e.keyCode)||-1!==r.keysLeft.indexOf(e.keyCode)||-1!==r.keysRight.indexOf(e.keyCode)){var t=r._keys.indexOf(e.keyCode);t>=0&&r._keys.splice(t,1),e.preventDefault&&(i||e.preventDefault())}},this._onLostFocus=function(){r._keys=[]},t.addEventListener("keydown",this._onKeyDown,!1),t.addEventListener("keyup",this._onKeyUp,!1),e.Tools.RegisterTopRootEvents([{name:"blur",handler:this._onLostFocus}])},t.prototype.detachControl=function(t){t&&(t.removeEventListener("keydown",this._onKeyDown),t.removeEventListener("keyup",this._onKeyUp)),e.Tools.UnregisterTopRootEvents([{name:"blur",handler:this._onLostFocus}]),this._keys=[],this._onKeyDown=null,this._onKeyUp=null,this._onLostFocus=null},t.prototype.checkInputs=function(){if(this._onKeyDown)for(var e=this.camera,t=0;tMath.PI&&(this.beta=this.beta-2*Math.PI):this.betathis.upperBetaLimit&&(this.beta=this.upperBetaLimit),this.lowerAlphaLimit&&this.alphathis.upperAlphaLimit&&(this.alpha=this.upperAlphaLimit),this.lowerRadiusLimit&&this.radiusthis.upperRadiusLimit&&(this.radius=this.upperRadiusLimit)},i.prototype.rebuildAnglesAndRadius=function(){var e=this.position.subtract(this._getTargetPosition());this.radius=e.length(),this.alpha=Math.acos(e.x/Math.sqrt(Math.pow(e.x,2)+Math.pow(e.z,2))),e.z<0&&(this.alpha=2*Math.PI-this.alpha),this.beta=Math.acos(e.y/this.radius),this._checkLimits()},i.prototype.setPosition=function(e){this.position.equals(e)||(this.position.copyFrom(e),this.rebuildAnglesAndRadius())},i.prototype.setTarget=function(e,t,i){if(void 0===t&&(t=!1),void 0===i&&(i=!1),e.getBoundingInfo)this._targetBoundingCenter=t?e.getBoundingInfo().boundingBox.centerWorld.clone():null,this._targetHost=e,this._target=this._getTargetPosition();else{var r=e,n=this._getTargetPosition();if(n&&!i&&n.equals(r))return;this._target=r,this._targetBoundingCenter=null}this.rebuildAnglesAndRadius()},i.prototype._getViewMatrix=function(){var t=Math.cos(this.alpha),i=Math.sin(this.alpha),r=Math.cos(this.beta),n=Math.sin(this.beta);0===n&&(n=1e-4);var o=this._getTargetPosition();if(o.addToRef(new e.Vector3(this.radius*t*n,this.radius*r,this.radius*i*n),this._newPosition),this.getScene().collisionsEnabled&&this.checkCollisions)this._collider||(this._collider=new e.Collider),this._collider.radius=this.collisionRadius,this._newPosition.subtractToRef(this.position,this._collisionVelocity),this._collisionTriggered=!0,this.getScene().collisionCoordinator.getNewPosition(this.position,this._collisionVelocity,this._collider,3,null,this._onCollisionPositionChange,this.uniqueId);else{this.position.copyFrom(this._newPosition);var s=this.upVector;this.allowUpsideDown&&n<0&&(s=s.clone(),s=s.negate()),this.getScene().useRightHandedSystem?e.Matrix.LookAtRHToRef(this.position,o,s,this._viewMatrix):e.Matrix.LookAtLHToRef(this.position,o,s,this._viewMatrix),this._viewMatrix.m[12]+=this.targetScreenOffset.x,this._viewMatrix.m[13]+=this.targetScreenOffset.y}return this._currentTarget=o,this._viewMatrix},i.prototype.zoomOn=function(t,i){void 0===i&&(i=!1),t=t||this.getScene().meshes;var r=e.Mesh.MinMax(t),n=e.Vector3.Distance(r.min,r.max);this.radius=n*this.zoomOnFactor,this.focusOn({min:r.min,max:r.max,distance:n},i)},i.prototype.focusOn=function(t,i){void 0===i&&(i=!1);var r,n;void 0===t.min?(r=t||this.getScene().meshes,r=e.Mesh.MinMax(r),n=e.Vector3.Distance(r.min,r.max)):(r=t,n=t.distance),this._target=e.Mesh.Center(r),i||(this.maxZ=2*n)},i.prototype.createRigCamera=function(t,r){var n;switch(this.cameraRigMode){case e.Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case e.Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER:case e.Camera.RIG_MODE_VR:n=this._cameraRigParams.stereoHalfAngle*(0===r?1:-1);break;case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:n=this._cameraRigParams.stereoHalfAngle*(0===r?-1:1)}var o=new i(t,this.alpha+n,this.beta,this.radius,this._target,this.getScene());return o._cameraRigParams={},o},i.prototype._updateRigCameras=function(){var i=this._rigCameras[0],r=this._rigCameras[1];switch(i.beta=r.beta=this.beta,i.radius=r.radius=this.radius,this.cameraRigMode){case e.Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case e.Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER:case e.Camera.RIG_MODE_VR:i.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle,r.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle;break;case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:i.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle,r.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle}t.prototype._updateRigCameras.call(this)},i.prototype.dispose=function(){this.inputs.clear(),t.prototype.dispose.call(this)},i.prototype.getClassName=function(){return"ArcRotateCamera"},i})(e.TargetCamera);__decorate([e.serialize()],t.prototype,"alpha",void 0),__decorate([e.serialize()],t.prototype,"beta",void 0),__decorate([e.serialize()],t.prototype,"radius",void 0),__decorate([e.serializeAsVector3("target")],t.prototype,"_target",void 0),__decorate([e.serialize()],t.prototype,"inertialAlphaOffset",void 0),__decorate([e.serialize()],t.prototype,"inertialBetaOffset",void 0),__decorate([e.serialize()],t.prototype,"inertialRadiusOffset",void 0),__decorate([e.serialize()],t.prototype,"lowerAlphaLimit",void 0),__decorate([e.serialize()],t.prototype,"upperAlphaLimit",void 0),__decorate([e.serialize()],t.prototype,"lowerBetaLimit",void 0),__decorate([e.serialize()],t.prototype,"upperBetaLimit",void 0),__decorate([e.serialize()],t.prototype,"lowerRadiusLimit",void 0),__decorate([e.serialize()],t.prototype,"upperRadiusLimit",void 0),__decorate([e.serialize()],t.prototype,"inertialPanningX",void 0),__decorate([e.serialize()],t.prototype,"inertialPanningY",void 0),__decorate([e.serialize()],t.prototype,"panningInertia",void 0),__decorate([e.serialize()],t.prototype,"zoomOnFactor",void 0),__decorate([e.serialize()],t.prototype,"allowUpsideDown",void 0),e.ArcRotateCamera=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e){return t.call(this,e)||this}return __extends(i,t), -i.prototype.addMouseWheel=function(){return this.add(new e.ArcRotateCameraMouseWheelInput),this},i.prototype.addPointers=function(){return this.add(new e.ArcRotateCameraPointersInput),this},i.prototype.addKeyboard=function(){return this.add(new e.ArcRotateCameraKeyboardMoveInput),this},i.prototype.addGamepad=function(){return this.add(new e.ArcRotateCameraGamepadInput),this},i.prototype.addVRDeviceOrientation=function(){return this.add(new e.ArcRotateCameraVRDeviceOrientationInput),this},i})(e.CameraInputsManager);e.ArcRotateCameraInputsManager=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n){var o=t.call(this,i,n)||this;return o.groundColor=new e.Color3(0,0,0),o.direction=r||e.Vector3.Up(),o}return __extends(i,t),i.prototype._buildUniformLayout=function(){this._uniformBuffer.addUniform("vLightData",4),this._uniformBuffer.addUniform("vLightDiffuse",4),this._uniformBuffer.addUniform("vLightSpecular",3),this._uniformBuffer.addUniform("vLightGround",3),this._uniformBuffer.addUniform("shadowsInfo",3),this._uniformBuffer.addUniform("depthValues",2),this._uniformBuffer.create()},i.prototype.getClassName=function(){return"HemisphericLight"},i.prototype.setDirectionToTarget=function(t){return this.direction=e.Vector3.Normalize(t.subtract(e.Vector3.Zero())),this.direction},i.prototype.getShadowGenerator=function(){return null},i.prototype.transferToEffect=function(t,i){var r=e.Vector3.Normalize(this.direction);return this._uniformBuffer.updateFloat4("vLightData",r.x,r.y,r.z,0,i),this._uniformBuffer.updateColor3("vLightGround",this.groundColor.scale(this.intensity),i),this},i.prototype._getWorldMatrix=function(){return this._worldMatrix||(this._worldMatrix=e.Matrix.Identity()),this._worldMatrix},i.prototype.getTypeID=function(){return e.Light.LIGHTTYPEID_HEMISPHERICLIGHT},i})(e.Light);__decorate([e.serializeAsColor3()],t.prototype,"groundColor",void 0),__decorate([e.serializeAsVector3()],t.prototype,"direction",void 0),e.HemisphericLight=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(){var e=null!==t&&t.apply(this,arguments)||this;return e._needProjectionMatrixCompute=!0,e}return __extends(i,t),Object.defineProperty(i.prototype,"direction",{get:function(){return this._direction},set:function(e){this._direction=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"shadowMinZ",{get:function(){return this._shadowMinZ},set:function(e){this._shadowMinZ=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"shadowMaxZ",{get:function(){return this._shadowMaxZ},set:function(e){this._shadowMaxZ=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),i.prototype.computeTransformedInformation=function(){return!(!this.parent||!this.parent.getWorldMatrix)&&(this.transformedPosition||(this.transformedPosition=e.Vector3.Zero()),e.Vector3.TransformCoordinatesToRef(this.position,this.parent.getWorldMatrix(),this.transformedPosition),this.direction&&(this.transformedDirection||(this.transformedDirection=e.Vector3.Zero()),e.Vector3.TransformNormalToRef(this.direction,this.parent.getWorldMatrix(),this.transformedDirection)),!0)},i.prototype.getDepthScale=function(){return 50},i.prototype.getShadowDirection=function(e){return this.transformedDirection?this.transformedDirection:this.direction},i.prototype.getAbsolutePosition=function(){return this.transformedPosition?this.transformedPosition:this.position},i.prototype.setDirectionToTarget=function(t){return this.direction=e.Vector3.Normalize(t.subtract(this.position)),this.direction},i.prototype.getRotation=function(){this.direction.normalize();var t=e.Vector3.Cross(this.direction,e.Axis.Y),i=e.Vector3.Cross(t,this.direction);return e.Vector3.RotationFromAxis(t,i,this.direction)},i.prototype.needCube=function(){return!1},i.prototype.needProjectionMatrixCompute=function(){return this._needProjectionMatrixCompute},i.prototype.forceProjectionMatrixCompute=function(){this._needProjectionMatrixCompute=!0},i.prototype._getWorldMatrix=function(){return this._worldMatrix||(this._worldMatrix=e.Matrix.Identity()),e.Matrix.TranslationToRef(this.position.x,this.position.y,this.position.z,this._worldMatrix),this._worldMatrix},i.prototype.getDepthMinZ=function(e){return void 0!==this.shadowMinZ?this.shadowMinZ:e.minZ},i.prototype.getDepthMaxZ=function(e){return void 0!==this.shadowMaxZ?this.shadowMaxZ:e.maxZ},i.prototype.setShadowProjectionMatrix=function(e,t,i){return this.customProjectionMatrixBuilder?this.customProjectionMatrixBuilder(t,i,e):this._setDefaultShadowProjectionMatrix(e,t,i),this},i})(e.Light);__decorate([e.serializeAsVector3()],t.prototype,"position",void 0),__decorate([e.serializeAsVector3()],t.prototype,"direction",null),__decorate([e.serialize()],t.prototype,"shadowMinZ",null),__decorate([e.serialize()],t.prototype,"shadowMaxZ",null),e.ShadowLight=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e,i,r){var n=t.call(this,e,r)||this;return n._shadowAngle=Math.PI/2,n.position=i,n}return __extends(i,t),Object.defineProperty(i.prototype,"shadowAngle",{get:function(){return this._shadowAngle},set:function(e){this._shadowAngle=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"direction",{get:function(){return this._direction},set:function(e){var t=this.needCube();this._direction=e,this.needCube()!==t&&this._shadowGenerator&&this._shadowGenerator.recreateShadowMap()},enumerable:!0,configurable:!0}),i.prototype.getClassName=function(){return"PointLight"},i.prototype.getTypeID=function(){return e.Light.LIGHTTYPEID_POINTLIGHT},i.prototype.needCube=function(){return!this.direction},i.prototype.getShadowDirection=function(i){if(this.direction)return t.prototype.getShadowDirection.call(this,i);switch(i){case 0:return new e.Vector3(1,0,0);case 1:return new e.Vector3(-1,0,0);case 2:return new e.Vector3(0,-1,0);case 3:return new e.Vector3(0,1,0);case 4:return new e.Vector3(0,0,1);case 5:return new e.Vector3(0,0,-1)}return e.Vector3.Zero()},i.prototype._setDefaultShadowProjectionMatrix=function(t,i,r){var n=this.getScene().activeCamera;e.Matrix.PerspectiveFovLHToRef(this.shadowAngle,1,this.getDepthMinZ(n),this.getDepthMaxZ(n),t)},i.prototype._buildUniformLayout=function(){this._uniformBuffer.addUniform("vLightData",4),this._uniformBuffer.addUniform("vLightDiffuse",4),this._uniformBuffer.addUniform("vLightSpecular",3),this._uniformBuffer.addUniform("shadowsInfo",3),this._uniformBuffer.addUniform("depthValues",2),this._uniformBuffer.create()},i.prototype.transferToEffect=function(e,t){return this.computeTransformedInformation()?(this._uniformBuffer.updateFloat4("vLightData",this.transformedPosition.x,this.transformedPosition.y,this.transformedPosition.z,0,t),this):(this._uniformBuffer.updateFloat4("vLightData",this.position.x,this.position.y,this.position.z,0,t),this)},i})(e.ShadowLight);__decorate([e.serialize()],t.prototype,"shadowAngle",null),e.PointLight=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e,i,r){var n=t.call(this,e,r)||this;return n._shadowFrustumSize=0,n._shadowOrthoScale=.5,n.autoUpdateExtends=!0,n._orthoLeft=Number.MAX_VALUE,n._orthoRight=Number.MIN_VALUE,n._orthoTop=Number.MIN_VALUE,n._orthoBottom=Number.MAX_VALUE,n.position=i.scale(-1),n.direction=i,n}return __extends(i,t),Object.defineProperty(i.prototype,"shadowFrustumSize",{get:function(){return this._shadowFrustumSize},set:function(e){this._shadowFrustumSize=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"shadowOrthoScale",{get:function(){return this._shadowOrthoScale},set:function(e){this._shadowOrthoScale=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),i.prototype.getClassName=function(){return"DirectionalLight"},i.prototype.getTypeID=function(){return e.Light.LIGHTTYPEID_DIRECTIONALLIGHT},i.prototype._setDefaultShadowProjectionMatrix=function(e,t,i){this.shadowFrustumSize>0?this._setDefaultFixedFrustumShadowProjectionMatrix(e,t):this._setDefaultAutoExtendShadowProjectionMatrix(e,t,i)},i.prototype._setDefaultFixedFrustumShadowProjectionMatrix=function(t,i){var r=this.getScene().activeCamera;e.Matrix.OrthoLHToRef(this.shadowFrustumSize,this.shadowFrustumSize,void 0!==this.shadowMinZ?this.shadowMinZ:r.minZ,void 0!==this.shadowMaxZ?this.shadowMaxZ:r.maxZ,t)},i.prototype._setDefaultAutoExtendShadowProjectionMatrix=function(t,i,r){var n=this.getScene().activeCamera;if(this.autoUpdateExtends||this._orthoLeft===Number.MAX_VALUE){var o=e.Vector3.Zero();this._orthoLeft=Number.MAX_VALUE,this._orthoRight=Number.MIN_VALUE,this._orthoTop=Number.MIN_VALUE,this._orthoBottom=Number.MAX_VALUE;for(var s=0;sthis._orthoRight&&(this._orthoRight=o.x),o.y>this._orthoTop&&(this._orthoTop=o.y)}}}var u=this._orthoRight-this._orthoLeft,f=this._orthoTop-this._orthoBottom;e.Matrix.OrthoOffCenterLHToRef(this._orthoLeft-u*this.shadowOrthoScale,this._orthoRight+u*this.shadowOrthoScale,this._orthoBottom-f*this.shadowOrthoScale,this._orthoTop+f*this.shadowOrthoScale,void 0!==this.shadowMinZ?this.shadowMinZ:n.minZ,void 0!==this.shadowMaxZ?this.shadowMaxZ:n.maxZ,t)},i.prototype._buildUniformLayout=function(){this._uniformBuffer.addUniform("vLightData",4),this._uniformBuffer.addUniform("vLightDiffuse",4),this._uniformBuffer.addUniform("vLightSpecular",3),this._uniformBuffer.addUniform("shadowsInfo",3),this._uniformBuffer.addUniform("depthValues",2),this._uniformBuffer.create()},i.prototype.transferToEffect=function(e,t){return this.computeTransformedInformation()?(this._uniformBuffer.updateFloat4("vLightData",this.transformedDirection.x,this.transformedDirection.y,this.transformedDirection.z,1,t),this):(this._uniformBuffer.updateFloat4("vLightData",this.direction.x,this.direction.y,this.direction.z,1,t),this)},i.prototype.getDepthMinZ=function(e){return 1},i.prototype.getDepthMaxZ=function(e){return 1},i})(e.ShadowLight);__decorate([e.serialize()],t.prototype,"shadowFrustumSize",null),__decorate([e.serialize()],t.prototype,"shadowOrthoScale",null),__decorate([e.serialize()],t.prototype,"autoUpdateExtends",void 0),e.DirectionalLight=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e,i,r,n,o,s){var a=t.call(this,e,s)||this;return a.position=i,a.direction=r,a.angle=n,a.exponent=o,a}return __extends(i,t),Object.defineProperty(i.prototype,"angle",{get:function(){return this._angle},set:function(e){this._angle=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"shadowAngleScale",{get:function(){return this._shadowAngleScale},set:function(e){this._shadowAngleScale=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),i.prototype.getClassName=function(){return"SpotLight"},i.prototype.getTypeID=function(){return e.Light.LIGHTTYPEID_SPOTLIGHT},i.prototype._setDefaultShadowProjectionMatrix=function(t,i,r){var n=this.getScene().activeCamera;this._shadowAngleScale=this._shadowAngleScale||1;var o=this._shadowAngleScale*this._angle;e.Matrix.PerspectiveFovLHToRef(o,1,this.getDepthMinZ(n),this.getDepthMaxZ(n),t)},i.prototype._buildUniformLayout=function(){this._uniformBuffer.addUniform("vLightData",4),this._uniformBuffer.addUniform("vLightDiffuse",4),this._uniformBuffer.addUniform("vLightSpecular",3),this._uniformBuffer.addUniform("vLightDirection",3),this._uniformBuffer.addUniform("shadowsInfo",3),this._uniformBuffer.addUniform("depthValues",2),this._uniformBuffer.create()},i.prototype.transferToEffect=function(t,i){var r;return this.computeTransformedInformation()?(this._uniformBuffer.updateFloat4("vLightData",this.transformedPosition.x,this.transformedPosition.y,this.transformedPosition.z,this.exponent,i),r=e.Vector3.Normalize(this.transformedDirection)):(this._uniformBuffer.updateFloat4("vLightData",this.position.x,this.position.y,this.position.z,this.exponent,i),r=e.Vector3.Normalize(this.direction)),this._uniformBuffer.updateFloat4("vLightDirection",r.x,r.y,r.z,Math.cos(.5*this.angle),i),this},i})(e.ShadowLight);__decorate([e.serialize()],t.prototype,"angle",null),__decorate([e.serialize()],t.prototype,"shadowAngleScale",null),__decorate([e.serialize()],t.prototype,"exponent",void 0),e.SpotLight=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(e,t,i){this.name=e,this.from=t,this.to=i}return e.prototype.clone=function(){return new e(this.name,this.from,this.to)},e})();e.AnimationRange=t;var i=(function(){function e(e,t,i){this.frame=e,this.action=t,this.onlyOnce=i,this.isDone=!1}return e})();e.AnimationEvent=i;var r=(function(){function t(e){this.path=e,this._onchange=new Array,this.value=0,this.animations=new Array}return t.prototype.getPoint=function(){var t=this.path.getPointAtLengthPosition(this.value);return new e.Vector3(t.x,0,t.y)},t.prototype.moveAhead=function(e){return void 0===e&&(e=.002),this.move(e),this},t.prototype.moveBack=function(e){return void 0===e&&(e=.002),this.move(-e),this},t.prototype.move=function(e){if(Math.abs(e)>1)throw"step size should be less than 1.";return this.value+=e,this.ensureLimits(),this.raiseOnChange(),this},t.prototype.ensureLimits=function(){for(;this.value>1;)this.value-=1;for(;this.value<0;)this.value+=1;return this},t.prototype.markAsDirty=function(e){return this.ensureLimits(),this.raiseOnChange(),this},t.prototype.raiseOnChange=function(){var e=this;return this._onchange.forEach((function(t){return t(e)})),this},t.prototype.onchange=function(e){return this._onchange.push(e),this},t})();e.PathCursor=r;var n=(function(){function i(e,t,r,n,o,s){this.name=e,this.targetProperty=t,this.framePerSecond=r,this.dataType=n,this.loopMode=o,this.enableBlending=s,this._offsetsCache={},this._highLimitsCache={},this._stopped=!1,this._blendingFactor=0,this._events=new Array,this.allowMatricesInterpolation=!1,this.blendingSpeed=.01,this._ranges={},this.targetPropertyPath=t.split("."),this.dataType=n,this.loopMode=void 0===o?i.ANIMATIONLOOPMODE_CYCLE:o}return i._PrepareAnimation=function(t,r,n,o,s,a,h,l){var c=void 0;if(!isNaN(parseFloat(s))&&isFinite(s)?c=i.ANIMATIONTYPE_FLOAT:s instanceof e.Quaternion?c=i.ANIMATIONTYPE_QUATERNION:s instanceof e.Vector3?c=i.ANIMATIONTYPE_VECTOR3:s instanceof e.Vector2?c=i.ANIMATIONTYPE_VECTOR2:s instanceof e.Color3?c=i.ANIMATIONTYPE_COLOR3:s instanceof e.Size&&(c=i.ANIMATIONTYPE_SIZE),void 0==c)return null;var u=new i(t,r,n,c,h),f=[{frame:0,value:s},{frame:o,value:a}];return u.setKeys(f),void 0!==l&&u.setEasingFunction(l),u},i.CreateAndStartAnimation=function(e,t,r,n,o,s,a,h,l,c){var u=i._PrepareAnimation(e,r,n,o,s,a,h,l);return t.getScene().beginDirectAnimation(t,[u],0,o,1===u.loopMode,1,c)},i.CreateMergeAndStartAnimation=function(e,t,r,n,o,s,a,h,l,c){var u=i._PrepareAnimation(e,r,n,o,s,a,h,l);return t.animations.push(u),t.getScene().beginAnimation(t,0,o,1===u.loopMode,1,c)},i.prototype.toString=function(e){var t="Name: "+this.name+", property: "+this.targetProperty;if(t+=", datatype: "+["Float","Vector3","Quaternion","Matrix","Color3","Vector2"][this.dataType],t+=", nKeys: "+(this._keys?this._keys.length:"none"),t+=", nRanges: "+(this._ranges?Object.keys(this._ranges).length:"none"),e){t+=", Ranges: {";var i=!0;for(var r in this._ranges)i&&(t+=", ",i=!1),t+=r;t+="}"}return t},i.prototype.addEvent=function(e){this._events.push(e)},i.prototype.removeEvents=function(e){for(var t=0;t=0;n--)this._keys[n].frame>=i&&this._keys[n].frame<=r&&this._keys.splice(n,1);this._ranges[e]=void 0}},i.prototype.getRange=function(e){return this._ranges[e]},i.prototype.reset=function(){this._offsetsCache={},this._highLimitsCache={},this.currentFrame=0,this._blendingFactor=0,this._originalBlendValue=null},i.prototype.isStopped=function(){return this._stopped},i.prototype.getKeys=function(){return this._keys},i.prototype.getHighestFrame=function(){for(var e=0,t=0,i=this._keys.length;t0)return o.clone?o.clone():o;this.currentFrame=e;var s=Math.max(0,Math.min(this._keys.length-1,Math.floor(this._keys.length*(e-this._keys[0].frame)/(this._keys[this._keys.length-1].frame-this._keys[0].frame))-1));if(this._keys[s].frame>=e)for(;s-1>=0&&this._keys[s].frame>=e;)s--;for(var a=s;a=e){var l=this._keys[a],c=this._getKeyValue(l.value),u=this._getKeyValue(h.value),f=void 0!==l.outTangent&&void 0!==h.inTangent,d=h.frame-l.frame,p=(e-l.frame)/d;switch(null!=this._easingFunction&&(p=this._easingFunction.ease(p)),this.dataType){case i.ANIMATIONTYPE_FLOAT:var m=f?this.floatInterpolateFunctionWithTangents(c,l.outTangent*d,u,h.inTangent*d,p):this.floatInterpolateFunction(c,u,p);switch(r){case i.ANIMATIONLOOPMODE_CYCLE:case i.ANIMATIONLOOPMODE_CONSTANT:return m;case i.ANIMATIONLOOPMODE_RELATIVE:return n*t+m}break;case i.ANIMATIONTYPE_QUATERNION:var _=f?this.quaternionInterpolateFunctionWithTangents(c,l.outTangent.scale(d),u,h.inTangent.scale(d),p):this.quaternionInterpolateFunction(c,u,p);switch(r){case i.ANIMATIONLOOPMODE_CYCLE:case i.ANIMATIONLOOPMODE_CONSTANT:return _;case i.ANIMATIONLOOPMODE_RELATIVE:return _.add(n.scale(t))}return _;case i.ANIMATIONTYPE_VECTOR3:var g=f?this.vector3InterpolateFunctionWithTangents(c,l.outTangent.scale(d),u,h.inTangent.scale(d),p):this.vector3InterpolateFunction(c,u,p);switch(r){case i.ANIMATIONLOOPMODE_CYCLE:case i.ANIMATIONLOOPMODE_CONSTANT:return g;case i.ANIMATIONLOOPMODE_RELATIVE:return g.add(n.scale(t))}case i.ANIMATIONTYPE_VECTOR2:var v=f?this.vector2InterpolateFunctionWithTangents(c,l.outTangent.scale(d),u,h.inTangent.scale(d),p):this.vector2InterpolateFunction(c,u,p);switch(r){case i.ANIMATIONLOOPMODE_CYCLE:case i.ANIMATIONLOOPMODE_CONSTANT:return v;case i.ANIMATIONLOOPMODE_RELATIVE:return v.add(n.scale(t))}case i.ANIMATIONTYPE_SIZE:switch(r){case i.ANIMATIONLOOPMODE_CYCLE:case i.ANIMATIONLOOPMODE_CONSTANT:return this.sizeInterpolateFunction(c,u,p);case i.ANIMATIONLOOPMODE_RELATIVE:return this.sizeInterpolateFunction(c,u,p).add(n.scale(t))}case i.ANIMATIONTYPE_COLOR3:switch(r){case i.ANIMATIONLOOPMODE_CYCLE:case i.ANIMATIONLOOPMODE_CONSTANT:return this.color3InterpolateFunction(c,u,p);case i.ANIMATIONLOOPMODE_RELATIVE:return this.color3InterpolateFunction(c,u,p).add(n.scale(t))}case i.ANIMATIONTYPE_MATRIX:switch(r){case i.ANIMATIONLOOPMODE_CYCLE:case i.ANIMATIONLOOPMODE_CONSTANT:if(this.allowMatricesInterpolation)return this.matrixInterpolateFunction(c,u,p);case i.ANIMATIONLOOPMODE_RELATIVE:return c}}break}}return this._getKeyValue(this._keys[this._keys.length-1].value)},i.prototype.setValue=function(t,i){void 0===i&&(i=!1);var r,n;if(this.targetPropertyPath.length>1){for(var o=this._target[this.targetPropertyPath[0]],s=1;sthis._keys[this._keys.length-1].frame&&(e=this._keys[this._keys.length-1].frame);var t=this._interpolate(e,0,this.loopMode);this.setValue(t)},i.prototype.animate=function(t,r,n,o,s,a){if(void 0===a&&(a=!1),!this.targetPropertyPath||this.targetPropertyPath.length<1)return this._stopped=!0,!1;var h=!0;if(0!==this._keys[0].frame){var l={frame:0,value:this._keys[0].value};this._keys.splice(0,0,l)}(rthis._keys[this._keys.length-1].frame)&&(r=this._keys[0].frame),(nthis._keys[this._keys.length-1].frame)&&(n=this._keys[this._keys.length-1].frame),r===n&&r++;var c,u=n-r,f=t*(this.framePerSecond*s)/1e3,d=0;if((n>r&&f>u||r>n&&f>0,v=h?r+f%u:n,y=this._interpolate(v,g,this.loopMode,c,d);this.setValue(y);for(var x=0;x0&&v>=this._events[x].frame&&this._events[x].frame>=r||u<0&&v<=this._events[x].frame&&this._events[x].frame<=r){var b=this._events[x];b.isDone||(b.onlyOnce&&(this._events.splice(x,1),x--),b.isDone=!0,b.action())}else this._events[x].isDone&&!this._events[x].onlyOnce&&(this._events[x].isDone=!1);return h||(this._stopped=!0),h},i.prototype.serialize=function(){var e={};e.name=this.name,e.property=this.targetProperty,e.framePerSecond=this.framePerSecond,e.dataType=this.dataType,e.loopBehavior=this.loopMode,e.enableBlending=this.enableBlending,e.blendingSpeed=this.blendingSpeed;var t=this.dataType;e.keys=[];for(var r=this.getKeys(),n=0;n-1){for(var i=this._animations,r=i.length-1;r>=0;r--)"string"==typeof e&&i[r].name!=e||(i[r].reset(),i.splice(r,1));0==i.length&&(this._scene._activeAnimatables.splice(t,1),this.onAnimationEnd&&this.onAnimationEnd())}}else{var r=this._scene._activeAnimatables.indexOf(this);if(r>-1){this._scene._activeAnimatables.splice(r,1);for(var i=this._animations,r=0;r=.5?.5*(1-this.easeInCore(2*(1-t)))+.5:.5*this.easeInCore(2*t)},e})();t._EASINGMODE_EASEIN=0,t._EASINGMODE_EASEOUT=1,t._EASINGMODE_EASEINOUT=2,e.EasingFunction=t;var i=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.easeInCore=function(e){return e=Math.max(0,Math.min(1,e)),1-Math.sqrt(1-e*e)},t})(t);e.CircleEase=i;var r=(function(e){function t(t){void 0===t&&(t=1);var i=e.call(this)||this;return i.amplitude=t,i}return __extends(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.amplitude);return Math.pow(e,3)-e*t*Math.sin(3.141592653589793*e)},t})(t);e.BackEase=r;var n=(function(e){function t(t,i){void 0===t&&(t=3),void 0===i&&(i=2);var r=e.call(this)||this;return r.bounces=t,r.bounciness=i,r}return __extends(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.bounces),i=this.bounciness -;i<=1&&(i=1.001);var r=Math.pow(i,t),n=1-i,o=(1-r)/n+.5*r,s=e*o,a=Math.log(-s*(1-i)+1)/Math.log(i),h=Math.floor(a),l=h+1,c=(1-Math.pow(i,h))/(n*o),u=(1-Math.pow(i,l))/(n*o),f=.5*(c+u),d=e-f,p=f-c;return-Math.pow(1/i,t-h)/(p*p)*(d-p)*(d+p)},t})(t);e.BounceEase=n;var o=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.easeInCore=function(e){return e*e*e},t})(t);e.CubicEase=o;var s=(function(e){function t(t,i){void 0===t&&(t=3),void 0===i&&(i=3);var r=e.call(this)||this;return r.oscillations=t,r.springiness=i,r}return __extends(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.oscillations),i=Math.max(0,this.springiness);return(0==i?e:(Math.exp(i*e)-1)/(Math.exp(i)-1))*Math.sin((6.283185307179586*t+1.5707963267948966)*e)},t})(t);e.ElasticEase=s;var a=(function(e){function t(t){void 0===t&&(t=2);var i=e.call(this)||this;return i.exponent=t,i}return __extends(t,e),t.prototype.easeInCore=function(e){return this.exponent<=0?e:(Math.exp(this.exponent*e)-1)/(Math.exp(this.exponent)-1)},t})(t);e.ExponentialEase=a;var h=(function(e){function t(t){void 0===t&&(t=2);var i=e.call(this)||this;return i.power=t,i}return __extends(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.power);return Math.pow(e,t)},t})(t);e.PowerEase=h;var l=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.easeInCore=function(e){return e*e},t})(t);e.QuadraticEase=l;var c=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.easeInCore=function(e){return e*e*e*e},t})(t);e.QuarticEase=c;var u=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.easeInCore=function(e){return e*e*e*e*e},t})(t);e.QuinticEase=u;var f=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.easeInCore=function(e){return 1-Math.sin(1.5707963267948966*(1-e))},t})(t);e.SineEase=f;var d=(function(t){function i(e,i,r,n){void 0===e&&(e=0),void 0===i&&(i=0),void 0===r&&(r=1),void 0===n&&(n=1);var o=t.call(this)||this;return o.x1=e,o.y1=i,o.x2=r,o.y2=n,o}return __extends(i,t),i.prototype.easeInCore=function(t){return e.BezierCurve.interpolate(t,this.x1,this.y1,this.x2,this.y2)},i})(t);e.BezierCurveEase=d})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(e){this._actionManager=e}return e.prototype.isValid=function(){return!0},e.prototype._getProperty=function(e){return this._actionManager._getProperty(e)},e.prototype._getEffectiveTarget=function(e,t){return this._actionManager._getEffectiveTarget(e,t)},e.prototype.serialize=function(){},e.prototype._serialize=function(e){return{type:2,children:[],name:e.name,properties:e.properties}},e})();e.Condition=t;var i=(function(t){function i(e,r,n,o,s){void 0===s&&(s=i.IsEqual);var a=t.call(this,e)||this;return a.propertyPath=n,a.value=o,a.operator=s,a._target=r,a._effectiveTarget=a._getEffectiveTarget(r,a.propertyPath),a._property=a._getProperty(a.propertyPath),a}return __extends(i,t),Object.defineProperty(i,"IsEqual",{get:function(){return i._IsEqual},enumerable:!0,configurable:!0}),Object.defineProperty(i,"IsDifferent",{get:function(){return i._IsDifferent},enumerable:!0,configurable:!0}),Object.defineProperty(i,"IsGreater",{get:function(){return i._IsGreater},enumerable:!0,configurable:!0}),Object.defineProperty(i,"IsLesser",{get:function(){return i._IsLesser},enumerable:!0,configurable:!0}),i.prototype.isValid=function(){switch(this.operator){case i.IsGreater:return this._effectiveTarget[this._property]>this.value;case i.IsLesser:return this._effectiveTarget[this._property]-1&&this._scene._actionManagers.splice(e,1)},t.prototype.getScene=function(){return this._scene},t.prototype.hasSpecificTriggers=function(e){for(var t=0;t-1)return!0}return!1},t.prototype.hasSpecificTrigger=function(e){for(var t=0;t=t._OnPickTrigger&&i.trigger<=t._OnPointerOutTrigger)return!0}return!1},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"hasPickTriggers",{get:function(){for(var e=0;e=t._OnPickTrigger&&i.trigger<=t._OnPickUpTrigger)return!0}return!1},enumerable:!0,configurable:!0}),Object.defineProperty(t,"HasTriggers",{get:function(){for(var e in t.Triggers)if(t.Triggers.hasOwnProperty(e))return!0;return!1},enumerable:!0,configurable:!0}),Object.defineProperty(t,"HasPickTriggers",{get:function(){for(var e in t.Triggers)if(t.Triggers.hasOwnProperty(e)){var i=parseInt(e);if(i>=t._OnPickTrigger&&i<=t._OnPickUpTrigger)return!0}return!1},enumerable:!0,configurable:!0}),t.HasSpecificTrigger=function(e){for(var i in t.Triggers)if(t.Triggers.hasOwnProperty(i)){var r=parseInt(i);if(r===e)return!0}return!1},t.prototype.registerAction=function(i){return i.trigger===t.OnEveryFrameTrigger&&this.getScene().actionManager!==this?(e.Tools.Warn("OnEveryFrameTrigger can only be used with scene.actionManager"),null):(this.actions.push(i),t.Triggers[i.trigger]?t.Triggers[i.trigger]++:t.Triggers[i.trigger]=1,i._actionManager=this,i._prepare(),i)},t.prototype.processTrigger=function(e,i){for(var r=0;r0;if(2===i.type?f.push(o):f.push(r),m){for(var _=new Array,g=0;g0){var f=u.properties[0].value,d=null===u.properties[0].targetType?f:n.getMeshByName(f);d._meshId&&(d.mesh=n.getMeshByID(d._meshId)),c={trigger:e.ActionManager[u.name],parameter:d}}else c=e.ActionManager[u.name];for(var p=0;p>0;this._vertexData[o+10]=t.cellIndex-s*n,this._vertexData[o+11]=s,this._vertexData[o+12]=t.color.r,this._vertexData[o+13]=t.color.g,this._vertexData[o+14]=t.color.b,this._vertexData[o+15]=t.color.a},t.prototype.intersects=function(t,i,r,n){for(var o,s=Math.min(this._capacity,this.sprites.length),a=e.Vector3.Zero(),h=e.Vector3.Zero(),l=Number.MAX_VALUE,c=e.Vector3.Zero(),u=i.getViewMatrix(),f=0;fp&&(l=p,o=d,n))break}}}if(o){var m=new e.PickingInfo;return m.hit=!0,m.pickedSprite=o,m.distance=l,m}return null},t.prototype.render=function(){if(this._effectBase.isReady()&&this._effectFog.isReady()&&this._spriteTexture&&this._spriteTexture.isReady()){for(var t=this._scene.getEngine(),i=this._spriteTexture.getBaseSize(),r=t.getDeltaTime(),n=Math.min(this._capacity,this.sprites.length),o=i.width/this.cellWidth,s=0,a=0;athis._delay&&(this._time=this._time%this._delay,this.cellIndex+=this._direction,this.cellIndex===this._toIndex&&(this._loopAnimation?this.cellIndex=this._fromIndex:(this._animationStarted=!1,this._onAnimationEnd&&this._onAnimationEnd(),this.disposeWhenFinishedAnimating&&this.dispose()))))},t.prototype.dispose=function(){for(var e=0;et.x)return!1}else if(i=1/this.direction.x,r=(e.x-this.origin.x)*i,n=(t.x-this.origin.x)*i,n===-1/0&&(n=1/0),r>n&&(o=r,r=n,n=o),s=Math.max(r,s),a=Math.min(n,a),s>a)return!1;if(Math.abs(this.direction.y)<1e-7){if(this.origin.yt.y)return!1}else if(i=1/this.direction.y,r=(e.y-this.origin.y)*i,n=(t.y-this.origin.y)*i,n===-1/0&&(n=1/0),r>n&&(o=r,r=n,n=o),s=Math.max(r,s),a=Math.min(n,a),s>a)return!1;if(Math.abs(this.direction.z)<1e-7){if(this.origin.zt.z)return!1}else if(i=1/this.direction.z,r=(e.z-this.origin.z)*i,n=(t.z-this.origin.z)*i,n===-1/0&&(n=1/0),r>n&&(o=r,r=n,n=o),s=Math.max(r,s),a=Math.min(n,a),s>a)return!1;return!0},t.prototype.intersectsBox=function(e){return this.intersectsBoxMinMax(e.minimum,e.maximum)},t.prototype.intersectsSphere=function(e){var t=e.center.x-this.origin.x,i=e.center.y-this.origin.y,r=e.center.z-this.origin.z,n=t*t+i*i+r*r,o=e.radius*e.radius;if(n<=o)return!0;var s=t*this.direction.x+i*this.direction.y+r*this.direction.z;return!(s<0)&&n-s*s<=o},t.prototype.intersectsTriangle=function(t,i,r){this._edge1||(this._edge1=e.Vector3.Zero(),this._edge2=e.Vector3.Zero(),this._pvec=e.Vector3.Zero(),this._tvec=e.Vector3.Zero(),this._qvec=e.Vector3.Zero()),i.subtractToRef(t,this._edge1),r.subtractToRef(t,this._edge2),e.Vector3.CrossToRef(this.direction,this._edge2,this._pvec);var n=e.Vector3.Dot(this._edge1,this._pvec);if(0===n)return null;var o=1/n;this.origin.subtractToRef(t,this._tvec);var s=e.Vector3.Dot(this._tvec,this._pvec)*o;if(s<0||s>1)return null;e.Vector3.CrossToRef(this._tvec,this._edge1,this._qvec);var a=e.Vector3.Dot(this.direction,this._qvec)*o;if(a<0||s+a>1)return null;var h=e.Vector3.Dot(this._edge2,this._qvec)*o;return h>this.length?null:new e.IntersectionInfo(s,a,h)},t.prototype.intersectsPlane=function(t){var i,r=e.Vector3.Dot(t.normal,this.direction);if(Math.abs(r)<9.99999997475243e-7)return null;var n=e.Vector3.Dot(t.normal,this.origin);return i=(-t.d-n)/r,i<0?i<-9.99999997475243e-7?null:0:i},t.prototype.intersectsMesh=function(i,r){var n=e.Tmp.Matrix[0];return i.getWorldMatrix().invertToRef(n),this._tmpRay?t.TransformToRef(this,n,this._tmpRay):this._tmpRay=t.Transform(this,n),i.intersects(this._tmpRay,r)},t.prototype.intersectsMeshes=function(e,t,i){i?i.length=0:i=[];for(var r=0;rt.distance?1:0},t.prototype.intersectionSegment=function(i,r,n){var o,s,a,h,l=this.origin.add(this.direction.multiplyByFloats(t.rayl,t.rayl,t.rayl)),c=r.subtract(i),u=l.subtract(this.origin),f=i.subtract(this.origin),d=e.Vector3.Dot(c,c),p=e.Vector3.Dot(c,u),m=e.Vector3.Dot(u,u),_=e.Vector3.Dot(c,f),g=e.Vector3.Dot(u,f),v=d*m-p*p,y=v,x=v;vy&&(s=y,h=g+p,x=m)),h<0?(h=0,-_<0?s=0:-_>d?s=y:(s=-_,y=d)):h>x&&(h=x,-_+p<0?s=0:-_+p>d?s=y:(s=-_+p,y=d)),o=Math.abs(s)0&&a<=this.length&&A.lengthSquared()i.x+r)&&(!(i.x-r>t.x)&&(!(e.y>i.y+r)&&(!(i.y-r>t.y)&&(!(e.z>i.z+r)&&!(i.z-r>t.z)))))},i=(function(){var e={root:0,found:!1};return function(t,i,r,n){e.root=0,e.found=!1;var o=i*i-4*t*r;if(o<0)return e;var s=Math.sqrt(o),a=(-i-s)/(2*t),h=(-i+s)/(2*t);if(a>h){var l=h;h=a,a=l}return a>0&&a0&&h=0))},r.prototype._canDoCollision=function(i,r,n,o){var s=e.Vector3.Distance(this.basePointWorld,i),a=Math.max(this.radius.x,this.radius.y,this.radius.z);return!(s>this.velocityWorldLength+a+r)&&!!t(n,o,this.basePointWorld,this.velocityWorldLength+a)},r.prototype._testTriangle=function(t,r,n,o,s,a){var h,l=!1;r||(r=[]),r[t]||(r[t]=new e.Plane(0,0,0,0),r[t].copyFromPoints(n,o,s));var c=r[t];if(a||c.isFrontFacingTo(this.normalizedVelocity,0)){var u=c.signedDistanceTo(this.basePoint),f=e.Vector3.Dot(c.normal,this.velocity);if(0==f){if(Math.abs(u)>=1)return;l=!0,h=0}else{h=(-1-u)/f;var d=(1-u)/f;if(h>d){var p=d;d=h,h=p}if(h>1||d<0)return;h<0&&(h=0),h>1&&(h=1)}this._collisionPoint.copyFromFloats(0,0,0);var m=!1,_=1;if(l||(this.basePoint.subtractToRef(c.normal,this._planeIntersectionPoint),this.velocity.scaleToRef(h,this._tempVector),this._planeIntersectionPoint.addInPlace(this._tempVector),this._checkPointInTriangle(this._planeIntersectionPoint,n,o,s,c.normal)&&(m=!0,_=h,this._collisionPoint.copyFrom(this._planeIntersectionPoint))),!m){var g=this.velocity.lengthSquared(),v=g;this.basePoint.subtractToRef(n,this._tempVector);var y=2*e.Vector3.Dot(this.velocity,this._tempVector),x=this._tempVector.lengthSquared()-1,b=i(v,y,x,_);b.found&&(_=b.root,m=!0,this._collisionPoint.copyFrom(n)),this.basePoint.subtractToRef(o,this._tempVector),y=2*e.Vector3.Dot(this.velocity,this._tempVector),x=this._tempVector.lengthSquared()-1,b=i(v,y,x,_),b.found&&(_=b.root,m=!0,this._collisionPoint.copyFrom(o)),this.basePoint.subtractToRef(s,this._tempVector),y=2*e.Vector3.Dot(this.velocity,this._tempVector),x=this._tempVector.lengthSquared()-1,b=i(v,y,x,_),b.found&&(_=b.root,m=!0,this._collisionPoint.copyFrom(s)),o.subtractToRef(n,this._edge),n.subtractToRef(this.basePoint,this._baseToVertex);var A=this._edge.lengthSquared(),T=e.Vector3.Dot(this._edge,this.velocity),E=e.Vector3.Dot(this._edge,this._baseToVertex);if(v=A*-g+T*T,y=A*(2*e.Vector3.Dot(this.velocity,this._baseToVertex))-2*T*E,x=A*(1-this._baseToVertex.lengthSquared())+E*E,b=i(v,y,x,_),b.found){var P=(T*b.root-E)/A;P>=0&&P<=1&&(_=b.root,m=!0,this._edge.scaleInPlace(P),n.addToRef(this._edge,this._collisionPoint))}s.subtractToRef(o,this._edge),o.subtractToRef(this.basePoint,this._baseToVertex),A=this._edge.lengthSquared(),T=e.Vector3.Dot(this._edge,this.velocity),E=e.Vector3.Dot(this._edge,this._baseToVertex),v=A*-g+T*T,y=A*(2*e.Vector3.Dot(this.velocity,this._baseToVertex))-2*T*E,x=A*(1-this._baseToVertex.lengthSquared())+E*E,b=i(v,y,x,_),b.found&&(P=(T*b.root-E)/A)>=0&&P<=1&&(_=b.root,m=!0,this._edge.scaleInPlace(P),o.addToRef(this._edge,this._collisionPoint)),n.subtractToRef(s,this._edge),s.subtractToRef(this.basePoint,this._baseToVertex),A=this._edge.lengthSquared(),T=e.Vector3.Dot(this._edge,this.velocity),E=e.Vector3.Dot(this._edge,this._baseToVertex),v=A*-g+T*T,y=A*(2*e.Vector3.Dot(this.velocity,this._baseToVertex))-2*T*E,x=A*(1-this._baseToVertex.lengthSquared())+E*E,b=i(v,y,x,_),b.found&&(P=(T*b.root-E)/A)>=0&&P<=1&&(_=b.root,m=!0,this._edge.scaleInPlace(P),s.addToRef(this._edge,this._collisionPoint))}if(m){var M=_*this.velocity.length();(!this.collisionFound||M4)){++n._runningUpdated;var e={updatedMeshes:n._addUpdateMeshesList,updatedGeometries:n._addUpdateGeometriesList,removedGeometries:n._toRemoveGeometryArray,removedMeshes:n._toRemoveMeshesArray},i={payload:e,taskType:t.UPDATE},r=[];for(var o in e.updatedGeometries)e.updatedGeometries.hasOwnProperty(o)&&(r.push(i.payload.updatedGeometries[o].indices.buffer),r.push(i.payload.updatedGeometries[o].normals.buffer),r.push(i.payload.updatedGeometries[o].positions.buffer));n._worker.postMessage(i,r),n._addUpdateMeshesList={},n._addUpdateGeometriesList={},n._toRemoveGeometryArray=[],n._toRemoveMeshesArray=[]}},this._onMessageFromWorker=function(r){var o=r.data;if(o.error!=i.SUCCESS)return void e.Tools.Warn("error returned from worker!");switch(o.taskType){case t.INIT:n._init=!0,n._scene.meshes.forEach((function(e){n.onMeshAdded(e)})),n._scene.getGeometries().forEach((function(e){n.onGeometryAdded(e)}));break;case t.UPDATE:n._runningUpdated--;break;case t.COLLIDE:n._runningCollisionTask=!1;var s=o.payload;if(!n._collisionsCallbackArray[s.collisionId])return;n._collisionsCallbackArray[s.collisionId](s.collisionId,e.Vector3.FromArray(s.newPosition),n._scene.getMeshByUniqueID(s.collidedMeshUniqueId)),n._collisionsCallbackArray[s.collisionId]=void 0}},this._collisionsCallbackArray=[],this._init=!1,this._runningUpdated=0,this._runningCollisionTask=!1,this._addUpdateMeshesList={},this._addUpdateGeometriesList={},this._toRemoveGeometryArray=[],this._toRemoveMeshesArray=[]}return r.prototype.getNewPosition=function(e,i,r,n,o,s,a){if(this._init&&!this._collisionsCallbackArray[a]&&!this._collisionsCallbackArray[a+1e5]){e.divideToRef(r.radius,this._scaledPosition),i.divideToRef(r.radius,this._scaledVelocity),this._collisionsCallbackArray[a]=s;var h={collider:{position:this._scaledPosition.asArray(),velocity:this._scaledVelocity.asArray(),radius:r.radius.asArray()},collisionId:a,excludedMeshUniqueId:o?o.uniqueId:null,maximumRetry:n},l={payload:h,taskType:t.COLLIDE};this._worker.postMessage(l)}},r.prototype.init=function(i){this._scene=i,this._scene.registerAfterRender(this._afterRender);var r=e.WorkerIncluded?e.Engine.CodeRepository+"Collisions/babylon.collisionWorker.js":URL.createObjectURL(new Blob([e.CollisionWorker],{type:"application/javascript"}));this._worker=new Worker(r),this._worker.onmessage=this._onMessageFromWorker;var n={payload:{},taskType:t.INIT};this._worker.postMessage(n)},r.prototype.destroy=function(){this._scene.unregisterAfterRender(this._afterRender),this._worker.terminate()},r.prototype.onMeshAdded=function(e){e.registerAfterWorldMatrixUpdate(this.onMeshUpdated),this.onMeshUpdated(e)},r.prototype.onMeshRemoved=function(e){this._toRemoveMeshesArray.push(e.uniqueId)},r.prototype.onGeometryAdded=function(e){e.onGeometryUpdated=this.onGeometryUpdated,this.onGeometryUpdated(e)},r.prototype.onGeometryDeleted=function(e){this._toRemoveGeometryArray.push(e.id)},r})();r.SerializeMesh=function(t){var i=[];t.subMeshes&&(i=t.subMeshes.map((function(e,t){return{position:t,verticesStart:e.verticesStart,verticesCount:e.verticesCount,indexStart:e.indexStart,indexCount:e.indexCount,hasMaterial:!!e.getMaterial(),sphereCenter:e.getBoundingInfo().boundingSphere.centerWorld.asArray(),sphereRadius:e.getBoundingInfo().boundingSphere.radiusWorld,boxMinimum:e.getBoundingInfo().boundingBox.minimumWorld.asArray(),boxMaximum:e.getBoundingInfo().boundingBox.maximumWorld.asArray()}})));var r=null;return t instanceof e.Mesh?r=t.geometry?t.geometry.id:null:t instanceof e.InstancedMesh&&(r=t.sourceMesh&&t.sourceMesh.geometry?t.sourceMesh.geometry.id:null),{uniqueId:t.uniqueId,id:t.id,name:t.name,geometryId:r,sphereCenter:t.getBoundingInfo().boundingSphere.centerWorld.asArray(),sphereRadius:t.getBoundingInfo().boundingSphere.radiusWorld,boxMinimum:t.getBoundingInfo().boundingBox.minimumWorld.asArray(),boxMaximum:t.getBoundingInfo().boundingBox.maximumWorld.asArray(),worldMatrixFromCache:t.worldMatrixFromCache.asArray(),subMeshes:i,checkCollisions:t.checkCollisions}},r.SerializeGeometry=function(t){return{id:t.id,positions:new Float32Array(t.getVerticesData(e.VertexBuffer.PositionKind)||[]),normals:new Float32Array(t.getVerticesData(e.VertexBuffer.NormalKind)||[]),indices:new Uint32Array(t.getIndices()||[])}},e.CollisionCoordinatorWorker=r;var n=(function(){function t(){this._scaledPosition=e.Vector3.Zero(),this._scaledVelocity=e.Vector3.Zero(),this._finalPosition=e.Vector3.Zero()}return t.prototype.getNewPosition=function(e,t,i,r,n,o,s){e.divideToRef(i.radius,this._scaledPosition),t.divideToRef(i.radius,this._scaledVelocity),i.collidedMesh=null,i.retry=0,i.initialVelocity=this._scaledVelocity,i.initialPosition=this._scaledPosition,this._collideWithWorld(this._scaledPosition,this._scaledVelocity,i,r,this._finalPosition,n),this._finalPosition.multiplyInPlace(i.radius),o(s,this._finalPosition,i.collidedMesh)},t.prototype.init=function(e){this._scene=e},t.prototype.destroy=function(){},t.prototype.onMeshAdded=function(e){},t.prototype.onMeshUpdated=function(e){},t.prototype.onMeshRemoved=function(e){},t.prototype.onGeometryAdded=function(e){},t.prototype.onGeometryUpdated=function(e){},t.prototype.onGeometryDeleted=function(e){},t.prototype._collideWithWorld=function(t,i,r,n,o,s){void 0===s&&(s=null);var a=10*e.Engine.CollisionsEpsilon;if(r.retry>=n)return void o.copyFrom(t);var h=s?s.collisionMask:r.collisionMask;r._initialize(t,i,a);for(var l=0;l=i.lifeTime?(a.recycleParticle(i),t--):(i.colorStep.scaleToRef(a._scaledUpdateSpeed,a._scaledColorStep),i.color.addInPlace(a._scaledColorStep),i.color.a<0&&(i.color.a=0),i.angle+=i.angularSpeed*a._scaledUpdateSpeed,i.direction.scaleToRef(a._scaledUpdateSpeed,a._scaledDirection),i.position.addInPlace(a._scaledDirection),a.gravity.scaleToRef(a._scaledUpdateSpeed,a._scaledGravity),i.direction.addInPlace(a._scaledGravity))}}}return Object.defineProperty(i.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!0,configurable:!0}),i.prototype.recycleParticle=function(e){var t=this.particles.pop();t!==e&&(t.copyTo(e),this._stockParticles.push(t))},i.prototype.getCapacity=function(){return this._capacity},i.prototype.isAlive=function(){return this._alive},i.prototype.isStarted=function(){return this._started},i.prototype.start=function(){this._started=!0,this._stopped=!1,this._actualFrame=0},i.prototype.stop=function(){this._stopped=!0},i.prototype._appendParticleVertex=function(e,t,i,r){var n=11*e;this._vertexData[n]=t.position.x,this._vertexData[n+1]=t.position.y,this._vertexData[n+2]=t.position.z,this._vertexData[n+3]=t.color.r,this._vertexData[n+4]=t.color.g,this._vertexData[n+5]=t.color.b,this._vertexData[n+6]=t.color.a,this._vertexData[n+7]=t.angle,this._vertexData[n+8]=t.size,this._vertexData[n+9]=i,this._vertexData[n+10]=r},i.prototype._update=function(i){this._alive=this.particles.length>0,this.updateFunction(this.particles);var r;if(this.emitter.position){r=this.emitter.getWorldMatrix()}else{var n=this.emitter;r=e.Matrix.Translation(n.x,n.y,n.z)}for(var o,s=0;s-1?(t=this.manualEmitCount,this._newPartsExcess=0,this.manualEmitCount=0):(t=this.emitRate*this._scaledUpdateSpeed>>0,this._newPartsExcess+=this.emitRate*this._scaledUpdateSpeed-t),this._newPartsExcess>1&&(t+=this._newPartsExcess>>0,this._newPartsExcess-=this._newPartsExcess>>0),this._alive=!1,this._stopped?t=0:(this._actualFrame+=this._scaledUpdateSpeed,this.targetStopDuration&&this._actualFrame>=this.targetStopDuration&&this.stop()),this._update(t),this._stopped&&(this._alive||(this._started=!1,this.onAnimationEnd&&this.onAnimationEnd(),this.disposeOnStop&&this._scene._toBeDisposed.push(this)));for(var i=0,r=0;r-1&&this._scene.particleSystems.splice(e,1),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear()},i.prototype.clone=function(t,r){var n=null,o=null;if(null!=this.customShader){o=this.customShader;var s=o.shaderOptions.defines.length>0?o.shaderOptions.defines.join("\n"):"";n=this._scene.getEngine().createEffectForParticles(o.shaderPath.fragmentElement,o.shaderOptions.uniforms,o.shaderOptions.samplers,s)}var a=new i(t,this._capacity,this._scene,n);return a.customShader=o,e.Tools.DeepCopy(this,a,["particles","customShader"]),void 0===r&&(r=this.emitter),a.emitter=r,this.particleTexture&&(a.particleTexture=new e.Texture(this.particleTexture.url,this._scene)),this.preventAutoStart||a.start(),a},i.prototype.serialize=function(){var t={};if(t.name=this.name,t.id=this.id,this.emitter.position){var i=this.emitter;t.emitterId=i.id}else{var r=this.emitter;t.emitter=r.asArray()}return t.capacity=this.getCapacity(),this.particleTexture&&(t.textureName=this.particleTexture.name),e.Animation.AppendSerializedAnimations(this,t),t.minAngularSpeed=this.minAngularSpeed,t.maxAngularSpeed=this.maxAngularSpeed,t.minSize=this.minSize,t.maxSize=this.maxSize,t.minEmitPower=this.minEmitPower,t.maxEmitPower=this.maxEmitPower,t.minLifeTime=this.minLifeTime,t.maxLifeTime=this.maxLifeTime,t.emitRate=this.emitRate,t.minEmitBox=this.minEmitBox.asArray(),t.maxEmitBox=this.maxEmitBox.asArray(),t.gravity=this.gravity.asArray(),t.direction1=this.direction1.asArray(),t.direction2=this.direction2.asArray(),t.color1=this.color1.asArray(),t.color2=this.color2.asArray(),t.colorDead=this.colorDead.asArray(),t.updateSpeed=this.updateSpeed,t.targetStopDuration=this.targetStopDuration,t.textureMask=this.textureMask.asArray(),t.blendMode=this.blendMode,t.customShader=this.customShader,t.preventAutoStart=this.preventAutoStart,t},i.Parse=function(t,r,n){var o=t.name,s=null,a=null;if(t.customShader){a=t.customShader;var h=a.shaderOptions.defines.length>0?a.shaderOptions.defines.join("\n"):"";s=r.getEngine().createEffectForParticles(a.shaderPath.fragmentElement,a.shaderOptions.uniforms,a.shaderOptions.samplers,h)}var l=new i(o,t.capacity,r,s);if(l.customShader=a,t.id&&(l.id=t.id),t.preventAutoStart&&(l.preventAutoStart=t.preventAutoStart),t.textureName&&(l.particleTexture=new e.Texture(n+t.textureName,r),l.particleTexture.name=t.textureName),t.emitterId?l.emitter=r.getLastMeshByID(t.emitterId):l.emitter=e.Vector3.FromArray(t.emitter),t.animations)for(var c=0;cf?f:n,r=Math.round(f/n),o=0):r=r>f?f:r;for(var d=[],p=[],m=[],_=[],g=e.Tmp.Vector3[0],v=r;uf-r&&(r=f-u),d.length=0,p.length=0,m.length=0,_.length=0;for(var y=0,x=3*u;x<3*(u+r);x++){p.push(y);var b=a[x];d.push(s[3*b],s[3*b+1],s[3*b+2]),h&&m.push(h[2*b],h[2*b+1]),l&&_.push(l[4*b],l[4*b+1],l[4*b+2],l[4*b+3]),y++}var A,T=this.nbParticles,E=this._posToShape(d),P=this._uvsToShapeUV(m);for(A=0;A=this.nbParticles?this.nbParticles-1:i,this._computeBoundingBox&&(0==t&&i==this.nbParticles-1?(e.Vector3.FromFloatsToRef(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,this._minimum),e.Vector3.FromFloatsToRef(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE,this._maximum)):(this._minimum.copyFrom(this.mesh._boundingInfo.boundingBox.minimum),this._maximum.copyFrom(this.mesh._boundingInfo.boundingBox.maximum))),s=this.particles[t]._pos;var f=s/3|0;h=4*f,c=2*f;for(var d=t;d<=i;d++){if(this._particle=this.particles[d],this._shape=this._particle._model._shape,this._shapeUV=this._particle._model._shapeUV,this.updateParticle(this._particle),this._particle.isVisible)for(this.billboard&&(this._particle.rotation.x=0,this._particle.rotation.y=0),(this._computeParticleRotation||this.billboard)&&(this._particle.rotationQuaternion?this._quaternion.copyFrom(this._particle.rotationQuaternion):(this._yaw=this._particle.rotation.y,this._pitch=this._particle.rotation.x,this._roll=this._particle.rotation.z,this._quaternionRotationYPR()),this._quaternionToRotationMatrix()),u=0;uthis._maximum.x&&(this._maximum.x=this._positions32[o]),this._positions32[o+1]this._maximum.y&&(this._maximum.y=this._positions32[o+1]),this._positions32[o+2]this._maximum.z&&(this._maximum.z=this._positions32[o+2])),this._computeParticleVertex||(this._normal.x=this._fixedNormal32[o],this._normal.y=this._fixedNormal32[o+1],this._normal.z=this._fixedNormal32[o+2],this._rotated.x=this._normal.x*this._rotMatrix.m[0]+this._normal.y*this._rotMatrix.m[4]+this._normal.z*this._rotMatrix.m[8]+this._rotMatrix.m[12],this._rotated.y=this._normal.x*this._rotMatrix.m[1]+this._normal.y*this._rotMatrix.m[5]+this._normal.z*this._rotMatrix.m[9]+this._rotMatrix.m[13],this._rotated.z=this._normal.x*this._rotMatrix.m[2]+this._normal.y*this._rotMatrix.m[6]+this._normal.z*this._rotMatrix.m[10]+this._rotMatrix.m[14],this._normals32[o]=this._cam_axisX.x*this._rotated.x+this._cam_axisY.x*this._rotated.y+this._cam_axisZ.x*this._rotated.z,this._normals32[o+1]=this._cam_axisX.y*this._rotated.x+this._cam_axisY.y*this._rotated.y+this._cam_axisZ.y*this._rotated.z,this._normals32[o+2]=this._cam_axisX.z*this._rotated.x+this._cam_axisY.z*this._rotated.y+this._cam_axisZ.z*this._rotated.z),this._computeParticleColor&&(this._colors32[a]=this._particle.color.r,this._colors32[a+1]=this._particle.color.g,this._colors32[a+2]=this._particle.color.b,this._colors32[a+3]=this._particle.color.a),this._computeParticleTexture&&(this._uvs32[l]=this._shapeUV[2*u]*(this._particle.uvs.z-this._particle.uvs.x)+this._particle.uvs.x,this._uvs32[l+1]=this._shapeUV[2*u+1]*(this._particle.uvs.w-this._particle.uvs.y)+this._particle.uvs.y);else for(u=0;uthis._maxX||ithis._maxZ)return this.position.y;this._heightQuads&&0!=this._heightQuads.length||(this._initHeightQuads(),this._computeHeightQuads());var s=this._getFacetAt(t,i),a=-(s.x*t+s.z*i+s.w)/s.y;return e.Vector3.TransformCoordinatesFromFloatsToRef(0,a,0,r,o),o.y},i.prototype.getNormalAtCoordinates=function(t,i){var r=new e.Vector3(0,1,0);return this.getNormalAtCoordinatesToRef(t,i,r),r},i.prototype.getNormalAtCoordinatesToRef=function(t,i,r){var n=this.getWorldMatrix(),o=e.Tmp.Matrix[5];n.invertToRef(o);var s=e.Tmp.Vector3[8];if(e.Vector3.TransformCoordinatesFromFloatsToRef(t,0,i,o,s),t=s.x,i=s.z,tthis._maxX||ithis._maxZ)return this;this._heightQuads&&0!=this._heightQuads.length||(this._initHeightQuads(),this._computeHeightQuads());var a=this._getFacetAt(t,i);return e.Vector3.TransformNormalFromFloatsToRef(a.x,a.y,a.z,n,r),this},i.prototype.updateCoordinateHeights=function(){return this._heightQuads&&0!=this._heightQuads.length||this._initHeightQuads(),this._computeHeightQuads(),this},i.prototype._getFacetAt=function(e,t){var i=(this._subdivisionsX,this._subdivisionsY,Math.floor((e+this._maxX)*this._subdivisionsX/this._width)),r=Math.floor(-(t+this._maxZ)*this._subdivisionsY/this._height+this._subdivisionsY),n=this._heightQuads[r*this._subdivisionsX+i];return t4&&(s.push(e.VertexBuffer.MatricesIndicesExtraKind),s.push(e.VertexBuffer.MatricesWeightsExtraKind)),o.push("#define NUM_BONE_INFLUENCERS "+t.numBoneInfluencers),o.push("#define BonesPerMesh "+(t.skeleton.bones.length+1)),a.addCPUSkinningFallback(0,t),-1===this._options.uniforms.indexOf("mBones")&&this._options.uniforms.push("mBones")):o.push("#define NUM_BONE_INFLUENCERS 0");for(var l in this._textures)if(!this._textures[l].isReady())return!1;n.getAlphaTesting()&&o.push("#define ALPHATEST");var c=this._effect,u=o.join("\n");return this._effect=n.createEffect(this._shaderPath,{attributes:s,uniformsNames:this._options.uniforms,uniformBuffersNames:this._options.uniformBuffers,samplers:this._options.samplers,defines:u,fallbacks:a,onCompiled:this.onCompiled,onError:this.onError},n),!!this._effect.isReady()&&(c!==this._effect&&r.resetCachedMaterial(),this._renderId=r.getRenderId(),!0)},i.prototype.bindOnlyWorldMatrix=function(e){var t=this.getScene();-1!==this._options.uniforms.indexOf("world")&&this._effect.setMatrix("world",e),-1!==this._options.uniforms.indexOf("worldView")&&(e.multiplyToRef(t.getViewMatrix(),this._cachedWorldViewMatrix),this._effect.setMatrix("worldView",this._cachedWorldViewMatrix)),-1!==this._options.uniforms.indexOf("worldViewProjection")&&this._effect.setMatrix("worldViewProjection",e.multiply(t.getTransformMatrix()))},i.prototype.bind=function(t,i){if(this.bindOnlyWorldMatrix(t),this.getScene().getCachedMaterial()!==this){-1!==this._options.uniforms.indexOf("view")&&this._effect.setMatrix("view",this.getScene().getViewMatrix()),-1!==this._options.uniforms.indexOf("projection")&&this._effect.setMatrix("projection",this.getScene().getProjectionMatrix()),-1!==this._options.uniforms.indexOf("viewProjection")&&this._effect.setMatrix("viewProjection",this.getScene().getTransformMatrix()),e.MaterialHelper.BindBonesParameters(i,this._effect);var r;for(r in this._textures)this._effect.setTexture(r,this._textures[r]);for(r in this._textureArrays)this._effect.setTextureArray(r,this._textureArrays[r]);for(r in this._floats)this._effect.setFloat(r,this._floats[r]);for(r in this._floatsArrays)this._effect.setArray(r,this._floatsArrays[r]);for(r in this._colors3)this._effect.setColor3(r,this._colors3[r]);for(r in this._colors3Arrays)this._effect.setArray3(r,this._colors3Arrays[r]);for(r in this._colors4){var n=this._colors4[r];this._effect.setFloat4(r,n.r,n.g,n.b,n.a)}for(r in this._vectors2)this._effect.setVector2(r,this._vectors2[r]);for(r in this._vectors3)this._effect.setVector3(r,this._vectors3[r]);for(r in this._vectors4)this._effect.setVector4(r,this._vectors4[r]);for(r in this._matrices)this._effect.setMatrix(r,this._matrices[r]);for(r in this._matrices3x3)this._effect.setMatrix3x3(r,this._matrices3x3[r]);for(r in this._matrices2x2)this._effect.setMatrix2x2(r,this._matrices2x2[r]);for(r in this._vectors3Arrays)this._effect.setArray3(r,this._vectors3Arrays[r])}this._afterBind(i)},i.prototype.getActiveTextures=function(){var e=t.prototype.getActiveTextures.call(this);for(var i in this._textures)e.push(this._textures[i]);for(var i in this._textureArrays)for(var r=this._textureArrays[i],n=0;ne.Tmp.Vector3[1].x&&(e.Tmp.Vector3[1].x=h[u].x),h[u].ye.Tmp.Vector3[1].y&&(e.Tmp.Vector3[1].y=h[u].y),h[u].ze.Tmp.Vector3[1].z&&(e.Tmp.Vector3[1].z=h[u].z),u++,r+=3;l._closePath&&(t[r]=h[0].x,t[r+1]=h[0].y,t[r+2]=h[0].z,r+=3)}}(u),l._boundingInfo=new e.BoundingInfo(e.Tmp.Vector3[0],e.Tmp.Vector3[1]),l._boundingInfo.update(l._worldMatrix),l.updateVerticesData(e.VertexBuffer.PositionKind,u,!1,!1),r.colors){for(var f=l.getVerticesData(e.VertexBuffer.ColorKind),d=0;d1?1:r.arc:1,a=void 0===r.closed||r.closed,h=r.shape,l=r.radius||1,c=r.tessellation||64,u=r.updatable,f=t.updateSideOrientation(r.sideOrientation,n),d=r.cap||e.Mesh.NO_CAP,p=2*Math.PI,m=new Array,_=r.invertUV||!1,g=0,v=0,y=p/c*s,x=new Array;for(g=0;g<=c;g++){var x=[];for(d!=e.Mesh.CAP_START&&d!=e.Mesh.CAP_ALL||(x.push(new e.Vector3(0,h[0].y,0)),x.push(new e.Vector3(Math.cos(g*y)*h[0].x*l,h[0].y,Math.sin(g*y)*h[0].x*l))),v=0;v1?1:r.arc||1;var p,m,_=function(t,i,r,n,o,s,a,h){for(var l,c,u,f,d=i.getTangents(),p=i.getNormals(),m=i.getDistances(),_=2*Math.PI,g=_/o*h,v=function(){return n},y=s||v,x=e.Tmp.Matrix[0],b=a===e.Mesh._NO_CAP||a===e.Mesh.CAP_END?0:2,A=0;A3?0:l,m=_(o,p,v,s,a,h,l,r.arc);var y=t.CreateRibbon(i,{pathArray:m,closePath:!0,closeArray:!1,updatable:u,sideOrientation:f,invertUV:c,frontUVs:r.frontUVs,backUVs:r.backUVs},n);return y.pathArray=m,y.path3D=p,y.tessellation=a,y.cap=l,y.arc=r.arc,y},t.CreatePolyhedron=function(i,r,n){var o=new e.Mesh(i,n);return r.sideOrientation=t.updateSideOrientation(r.sideOrientation,n),o.sideOrientation=r.sideOrientation,e.VertexData.CreatePolyhedron(r).applyToMesh(o,r.updatable),o},t.CreateDecal=function(t,i,r){var n=i.getIndices(),o=i.getVerticesData(e.VertexBuffer.PositionKind),s=i.getVerticesData(e.VertexBuffer.NormalKind),a=r.position||e.Vector3.Zero(),h=r.normal||e.Vector3.Up(),l=r.size||e.Vector3.One(),c=r.angle||0;if(!h){var u=new e.Vector3(0,0,1),f=i.getScene().activeCamera,d=e.Vector3.TransformCoordinates(u,f.getWorldMatrix());h=f.globalPosition.subtract(d)}var p=-Math.atan2(h.z,h.x)-Math.PI/2,m=Math.sqrt(h.x*h.x+h.z*h.z),_=Math.atan2(h.y,m),g=e.Matrix.RotationYawPitchRoll(p,_,c).multiply(e.Matrix.Translation(a.x,a.y,a.z)),v=e.Matrix.Invert(g),y=i.getWorldMatrix(),x=y.multiply(v),b=new e.VertexData;b.indices=[],b.positions=[],b.normals=[],b.uvs=[];for(var A=0,T=function(t){var i=n[t],r=new e.PositionNormalVertex;return r.position=new e.Vector3(o[3*i],o[3*i+1],o[3*i+2]),r.position=e.Vector3.TransformCoordinates(r.position,x),r.normal=new e.Vector3(s[3*i],s[3*i+1],s[3*i+2]),r.normal=e.Vector3.TransformNormal(r.normal,x),r},E=function(t,i){if(0===t.length)return t;for(var r=.5*Math.abs(e.Vector3.Dot(l,i)),n=function(t,n){var o=e.Vector3.GetClipFactor(t.position,n.position,i,r);return new e.PositionNormalVertex(e.Vector3.Lerp(t.position,n.position,o),e.Vector3.Lerp(t.normal,n.normal,o))},o=new Array,s=0;s0,h=_>0,c=g>0,(a?1:0)+(h?1:0)+(c?1:0)){case 0:o.push(t[s]),o.push(t[s+1]),o.push(t[s+2]);break;case 1:if(a&&(u=t[s+1],f=t[s+2],d=n(t[s],u),p=n(t[s],f)),h){u=t[s],f=t[s+2],d=n(t[s+1],u),p=n(t[s+1],f),o.push(d),o.push(f.clone()),o.push(u.clone()),o.push(f.clone()),o.push(d.clone()),o.push(p);break}c&&(u=t[s],f=t[s+1],d=n(t[s+2],u),p=n(t[s+2],f)),o.push(u.clone()),o.push(f.clone()),o.push(d),o.push(p),o.push(d.clone()),o.push(f.clone());break;case 2:a||(u=t[s].clone(),f=n(u,t[s+1]),d=n(u,t[s+2]),o.push(u),o.push(f),o.push(d)),h||(u=t[s+1].clone(),f=n(u,t[s+2]),d=n(u,t[s]),o.push(u),o.push(f),o.push(d)),c||(u=t[s+2].clone(),f=n(u,t[s]),d=n(u,t[s+1]),o.push(u),o.push(f),o.push(d))}}return o},P=0;P3?0:u,b=A(r,n,x,T,o,s,a,h,u,f);var E=t.CreateRibbon(i,{pathArray:b,closeArray:l,closePath:c,updatable:p,sideOrientation:m,invertUV:g,frontUVs:v,backUVs:y},d);return E.pathArray=b,E.path3D=x,E.cap=u,E},t})();e.MeshBuilder=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this._audioContext=null,this._audioContextInitialized=!1,this.canUseWebAudio=!1,this.WarnedWebAudioUnsupported=!1,this.unlocked=!1,this.isMP3supported=!1,this.isOGGsupported=!1,void 0===window.AudioContext&&void 0===window.webkitAudioContext||(window.AudioContext=window.AudioContext||window.webkitAudioContext,this.canUseWebAudio=!0);var e=document.createElement("audio");try{e&&e.canPlayType&&e.canPlayType('audio/mpeg; codecs="mp3"').replace(/^no$/,"")&&(this.isMP3supported=!0)}catch(e){}try{e&&e.canPlayType&&e.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,"")&&(this.isOGGsupported=!0)}catch(e){}/iPad|iPhone|iPod/.test(navigator.platform)?this._unlockiOSaudio():this.unlocked=!0}return Object.defineProperty(t.prototype,"audioContext",{get:function(){return this._audioContextInitialized||this._initializeAudioContext(),this._audioContext},enumerable:!0,configurable:!0}),t.prototype._unlockiOSaudio=function(){var e=this,t=function(){var i=e.audioContext.createBuffer(1,1,22050),r=e.audioContext.createBufferSource();r.buffer=i,r.connect(e.audioContext.destination),r.start(0),setTimeout((function(){r.playbackState!==r.PLAYING_STATE&&r.playbackState!==r.FINISHED_STATE||(e.unlocked=!0,window.removeEventListener("touchend",t,!1),e.onAudioUnlocked&&e.onAudioUnlocked())}),0)};window.addEventListener("touchend",t,!1)},t.prototype._initializeAudioContext=function(){try{this.canUseWebAudio&&(this._audioContext=new AudioContext,this.masterGain=this._audioContext.createGain(),this.masterGain.gain.value=1,this.masterGain.connect(this._audioContext.destination),this._audioContextInitialized=!0)}catch(t){this.canUseWebAudio=!1,e.Tools.Error("Web Audio: "+t.message)}},t.prototype.dispose=function(){this.canUseWebAudio&&this._audioContextInitialized&&(this._connectedAnalyser&&(this._connectedAnalyser.stopDebugCanvas(),this._connectedAnalyser.dispose(),this.masterGain.disconnect(),this.masterGain.connect(this._audioContext.destination),this._connectedAnalyser=null),this.masterGain.gain.value=1),this.WarnedWebAudioUnsupported=!1},t.prototype.getGlobalVolume=function(){return this.canUseWebAudio&&this._audioContextInitialized?this.masterGain.gain.value:-1},t.prototype.setGlobalVolume=function(e){this.canUseWebAudio&&this._audioContextInitialized&&(this.masterGain.gain.value=e)},t.prototype.connectToAnalyser=function(e){this._connectedAnalyser&&this._connectedAnalyser.stopDebugCanvas(),this.canUseWebAudio&&this._audioContextInitialized&&(this._connectedAnalyser=e,this.masterGain.disconnect(),this._connectedAnalyser.connectAudioNodes(this.masterGain,this._audioContext.destination))},t})();e.AudioEngine=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t,i,r,n,o){var s=this;if(this.autoplay=!1,this.loop=!1,this.useCustomAttenuation=!1,this.spatialSound=!1,this.refDistance=1,this.rolloffFactor=1,this.maxDistance=100,this.distanceModel="linear",this._panningModel="equalpower",this._playbackRate=1,this._streaming=!1,this._startTime=0,this._startOffset=0,this._position=e.Vector3.Zero(),this._localDirection=new e.Vector3(1,0,0),this._volume=1,this._isLoaded=!1,this._isReadyToPlay=!1,this.isPlaying=!1,this.isPaused=!1,this._isDirectional=!1,this._coneInnerAngle=360,this._coneOuterAngle=360,this._coneOuterGain=0,this._isOutputConnected=!1,this._urlType="Unknown",this.name=t,this._scene=r,this._readyToPlayCallback=n,this._customAttenuationFunction=function(e,t,i,r,n){return t0&&(l=!0,this._soundLoaded(i));break;case"String":h.push(i);case"Array":0===h.length&&(h=i);for(var c=0;c0&&(this._htmlAudioElement.currentTime=0);else{var i=t?e.Engine.audioEngine.audioContext.currentTime+t:e.Engine.audioEngine.audioContext.currentTime;this._soundSource.stop(i),this._soundSource.onended=null,this.isPaused||(this._startOffset=0)}this.isPlaying=!1}},t.prototype.pause=function(){this.isPlaying&&(this.isPaused=!0,this._streaming?this._htmlAudioElement.pause():(this.stop(0),this._startOffset+=e.Engine.audioEngine.audioContext.currentTime-this._startTime))},t.prototype.setVolume=function(t,i){e.Engine.audioEngine.canUseWebAudio&&(i?(this._soundGain.gain.cancelScheduledValues(e.Engine.audioEngine.audioContext.currentTime),this._soundGain.gain.setValueAtTime(this._soundGain.gain.value,e.Engine.audioEngine.audioContext.currentTime),this._soundGain.gain.linearRampToValueAtTime(t,e.Engine.audioEngine.audioContext.currentTime+i)):this._soundGain.gain.value=t),this._volume=t},t.prototype.setPlaybackRate=function(e){this._playbackRate=e,this.isPlaying&&(this._streaming?this._htmlAudioElement.playbackRate=this._playbackRate:this._soundSource.playbackRate.value=this._playbackRate)},t.prototype.getVolume=function(){return this._volume},t.prototype.attachToMesh=function(e){var t=this;this._connectedMesh&&(this._connectedMesh.unregisterAfterWorldMatrixUpdate(this._registerFunc),this._registerFunc=null),this._connectedMesh=e,this.spatialSound||(this.spatialSound=!0,this._createSpatialParameters(),this.isPlaying&&this.loop&&(this.stop(),this.play())),this._onRegisterAfterWorldMatrixUpdate(this._connectedMesh),this._registerFunc=function(e){return t._onRegisterAfterWorldMatrixUpdate(e)},e.registerAfterWorldMatrixUpdate(this._registerFunc)},t.prototype.detachFromMesh=function(){this._connectedMesh&&(this._connectedMesh.unregisterAfterWorldMatrixUpdate(this._registerFunc),this._registerFunc=null,this._connectedMesh=null)},t.prototype._onRegisterAfterWorldMatrixUpdate=function(t){this.setPosition(t.getBoundingInfo().boundingSphere.centerWorld),e.Engine.audioEngine.canUseWebAudio&&this._isDirectional&&this.isPlaying&&this._updateDirection()},t.prototype.clone=function(){var e=this;if(this._streaming)return null;var i=function(){e._isReadyToPlay?(n._audioBuffer=e.getAudioBuffer(),n._isReadyToPlay=!0,n.autoplay&&n.play()):window.setTimeout(i,300)},r={autoplay:this.autoplay,loop:this.loop,volume:this._volume,spatialSound:this.spatialSound,maxDistance:this.maxDistance,useCustomAttenuation:this.useCustomAttenuation,rolloffFactor:this.rolloffFactor,refDistance:this.refDistance,distanceModel:this.distanceModel},n=new t(this.name+"_cloned",new ArrayBuffer(0),this._scene,null,r);return this.useCustomAttenuation&&n.setAttenuationFunction(this._customAttenuationFunction),n.setPosition(this._position),n.setPlaybackRate(this._playbackRate),i(),n},t.prototype.getAudioBuffer=function(){return this._audioBuffer},t.prototype.serialize=function(){var e={name:this.name,url:this.name,autoplay:this.autoplay,loop:this.loop,volume:this._volume,spatialSound:this.spatialSound,maxDistance:this.maxDistance,rolloffFactor:this.rolloffFactor,refDistance:this.refDistance,distanceModel:this.distanceModel,playbackRate:this._playbackRate,panningModel:this._panningModel,soundTrackId:this.soundTrackId};return this.spatialSound&&(this._connectedMesh&&(e.connectedMeshId=this._connectedMesh.id),e.position=this._position.asArray(),e.refDistance=this.refDistance,e.distanceModel=this.distanceModel,e.isDirectional=this._isDirectional,e.localDirectionToMesh=this._localDirection.asArray(),e.coneInnerAngle=this._coneInnerAngle,e.coneOuterAngle=this._coneOuterAngle,e.coneOuterGain=this._coneOuterGain),e},t.Parse=function(i,r,n,o){var s,a=i.name;s=i.url?n+i.url:n+a;var h,l={autoplay:i.autoplay,loop:i.loop,volume:i.volume,spatialSound:i.spatialSound,maxDistance:i.maxDistance,rolloffFactor:i.rolloffFactor,refDistance:i.refDistance,distanceModel:i.distanceModel,playbackRate:i.playbackRate};if(o){var c=function(){o._isReadyToPlay?(h._audioBuffer=o.getAudioBuffer(),h._isReadyToPlay=!0,h.autoplay&&h.play()):window.setTimeout(c,300)};h=new t(a,new ArrayBuffer(0),r,null,l),c()}else h=new t(a,s,r,function(){r._removePendingData(h)},l),r._addPendingData(h);if(i.position){var u=e.Vector3.FromArray(i.position);h.setPosition(u)}if(i.isDirectional&&(h.setDirectionalCone(i.coneInnerAngle||360,i.coneOuterAngle||360,i.coneOuterGain||0),i.localDirectionToMesh)){var f=e.Vector3.FromArray(i.localDirectionToMesh);h.setLocalDirectionToMesh(f)}if(i.connectedMeshId){var d=r.getMeshByID(i.connectedMeshId);d&&h.attachToMesh(d)}return h},t})();e.Sound=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e,t){this.id=-1,this._isMainTrack=!1,this._isInitialized=!1,this._scene=e,this.soundCollection=new Array,this._options=t,this._isMainTrack||(this._scene.soundTracks.push(this),this.id=this._scene.soundTracks.length-1)}return t.prototype._initializeSoundTrackAudioGraph=function(){e.Engine.audioEngine.canUseWebAudio&&(this._outputAudioNode=e.Engine.audioEngine.audioContext.createGain(),this._outputAudioNode.connect(e.Engine.audioEngine.masterGain),this._options&&(this._options.volume&&(this._outputAudioNode.gain.value=this._options.volume),this._options.mainTrack&&(this._isMainTrack=this._options.mainTrack)),this._isInitialized=!0)},t.prototype.dispose=function(){if(e.Engine.audioEngine.canUseWebAudio){for(this._connectedAnalyser&&this._connectedAnalyser.stopDebugCanvas();this.soundCollection.length;)this.soundCollection[0].dispose();this._outputAudioNode&&this._outputAudioNode.disconnect(),this._outputAudioNode=null}},t.prototype.AddSound=function(t){this._isInitialized||this._initializeSoundTrackAudioGraph(),e.Engine.audioEngine.canUseWebAudio&&t.connectToSoundTrackAudioNode(this._outputAudioNode),t.soundTrackId&&(-1===t.soundTrackId?this._scene.mainSoundTrack.RemoveSound(t):this._scene.soundTracks[t.soundTrackId].RemoveSound(t)),this.soundCollection.push(t),t.soundTrackId=this.id},t.prototype.RemoveSound=function(e){var t=this.soundCollection.indexOf(e);-1!==t&&this.soundCollection.splice(t,1)},t.prototype.setVolume=function(t){e.Engine.audioEngine.canUseWebAudio&&(this._outputAudioNode.gain.value=t)},t.prototype.switchPanningModelToHRTF=function(){if(e.Engine.audioEngine.canUseWebAudio)for(var t=0;t0&&(this._postProcesses[0].autoClear=!1))}},i.prototype._shouldRender=function(){return-1===this._currentRefreshId?(this._currentRefreshId=1,!0):this.refreshRate===this._currentRefreshId?(this._currentRefreshId=1,!0):(this._currentRefreshId++,!1)},i.prototype.isReady=function(){return!!this.getScene().renderTargetsEnabled&&t.prototype.isReady.call(this)},i.prototype.getRenderSize=function(){return this._size},Object.defineProperty(i.prototype,"canRescale",{get:function(){return!0},enumerable:!0,configurable:!0}),i.prototype.scale=function(e){var t=this._size*e;this.resize(t)},i.prototype.getReflectionTextureMatrix=function(){return this.isCube?this._textureMatrix:t.prototype.getReflectionTextureMatrix.call(this)},i.prototype.resize=function(e){this.releaseInternalTexture(),this.isCube?this._texture=this.getScene().getEngine().createRenderTargetCubeTexture(e,this._renderTargetOptions):this._texture=this.getScene().getEngine().createRenderTargetTexture(e,this._renderTargetOptions)},i.prototype.render=function(e,t){var i=this.getScene(),r=i.getEngine();if(void 0!==this.useCameraPostProcesses&&(e=this.useCameraPostProcesses),this._waitingRenderList){this.renderList=[];for(var n=0;n=0&&this._renderingManager.dispatchParticles(g))}if(this.isCube)for(var y=0;y<6;y++)this.renderToTarget(y,l,c,e,t),i.incrementRenderId(),i.resetCachedMaterial();else this.renderToTarget(0,l,c,e,t);this.onAfterUnbindObservable.notifyObservers(this),this.activeCamera&&this.activeCamera!==i.activeCamera&&i.setTransformMatrix(i.activeCamera.getViewMatrix(),i.activeCamera.getProjectionMatrix(!0)),r.setViewport(i.activeCamera.viewport),i.resetCachedMaterial()}},i.prototype.renderToTarget=function(t,i,r,n,o){var s=this,a=this.getScene(),h=a.getEngine();this._postProcessManager?this._postProcessManager._prepareFrame(this._texture,this._postProcesses):n&&a.postProcessManager._prepareFrame(this._texture)||(this.isCube?h.bindFramebuffer(this._texture,t):h.bindFramebuffer(this._texture)),this.onBeforeRenderObservable.notifyObservers(t),this.onClearObservable.hasObservers()?this.onClearObservable.notifyObservers(h):h.clear(a.clearColor,!0,!0,!0),this._doNotChangeAspectRatio||a.updateTransformMatrix(!0),this._renderingManager.render(this.customRenderFunction,i,this.renderParticles,this.renderSprites),this._postProcessManager?this._postProcessManager._finalizeFrame(!1,this._texture,t,this._postProcesses):n&&a.postProcessManager._finalizeFrame(!1,this._texture,t),this._doNotChangeAspectRatio||a.updateTransformMatrix(!0),o&&e.Tools.DumpFramebuffer(this._size,this._size,h),this.isCube&&5!==t?this.onAfterRenderObservable.notifyObservers(t):(this.isCube&&5===t&&h.generateMipMapsForCubemap(this._texture),h.unBindFramebuffer(this._texture,this.isCube,(function(){s.onAfterRenderObservable.notifyObservers(t)})))},i.prototype.setRenderingOrder=function(e,t,i,r){void 0===t&&(t=null),void 0===i&&(i=null),void 0===r&&(r=null),this._renderingManager.setRenderingOrder(e,t,i,r)},i.prototype.setRenderingAutoClearDepthStencil=function(e,t){this._renderingManager.setRenderingAutoClearDepthStencil(e,t)},i.prototype.clone=function(){var e=this.getSize(),t=new i(this.name,e.width,this.getScene(),this._renderTargetOptions.generateMipMaps,this._doNotChangeAspectRatio,this._renderTargetOptions.type,this.isCube,this._renderTargetOptions.samplingMode,this._renderTargetOptions.generateDepthBuffer,this._renderTargetOptions.generateStencilBuffer);return t.hasAlpha=this.hasAlpha,t.level=this.level,t.coordinatesMode=this.coordinatesMode,t.renderList=this.renderList.slice(0),t},i.prototype.serialize=function(){if(!this.name)return null;var e=t.prototype.serialize.call(this);e.renderTargetSize=this.getRenderSize(),e.renderList=[];for(var i=0;i=0&&e.customRenderTargets.splice(i,1);for(var r=0,n=e.cameras;r=0&&o.customRenderTargets.splice(i,1)}t.prototype.dispose.call(this)},i})(e.Texture);t._REFRESHRATE_RENDER_ONCE=0,t._REFRESHRATE_RENDER_ONEVERYFRAME=1,t._REFRESHRATE_RENDER_ONEVERYTWOFRAMES=2,e.RenderTargetTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o,s){var a=this;s=s||{};var h=!!s.generateMipMaps&&s.generateMipMaps,l=!!s.generateDepthTexture&&s.generateDepthTexture,c=void 0===s.doNotChangeAspectRatio||s.doNotChangeAspectRatio;if(a=t.call(this,i,r,o,h,c)||this,!a.isSupported)return void a.dispose();for(var u=[],f=[],d=0;d1||e.getCaps().drawBuffersExtension},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"textures",{get:function(){return this._textures},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"depthTexture",{get:function(){return this._textures[this._textures.length-1]},enumerable:!0,configurable:!0}),i.prototype._createInternalTextures=function(){this._textures=[];for(var t=0;t=0;e--)void 0!==this._webGLTextures[e]&&(this.getScene().getEngine().releaseInternalTexture(this._webGLTextures[e]),this._webGLTextures.splice(e,1))},i})(e.RenderTargetTexture);e.MultiRenderTarget=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o,s,a,h){void 0===s&&(s=e.Engine.TEXTURETYPE_UNSIGNED_INT),void 0===a&&(a=e.Texture.BILINEAR_SAMPLINGMODE),void 0===h&&(h=!0);var l=t.call(this,i,r,n,o,!0,s,!1,a,h)||this;return l.mirrorPlane=new e.Plane(0,1,0,1),l._transformMatrix=e.Matrix.Zero(),l._mirrorMatrix=e.Matrix.Zero(),l._blurKernelX=0,l._blurKernelY=0,l._blurRatio=1,l.onBeforeRenderObservable.add((function(){e.Matrix.ReflectionToRef(l.mirrorPlane,l._mirrorMatrix),l._savedViewMatrix=n.getViewMatrix(),l._mirrorMatrix.multiplyToRef(l._savedViewMatrix,l._transformMatrix),n.setTransformMatrix(l._transformMatrix,n.getProjectionMatrix()),n.clipPlane=l.mirrorPlane,n.getEngine().cullBackFaces=!1,n._mirroredCameraPosition=e.Vector3.TransformCoordinates(n.activeCamera.globalPosition,l._mirrorMatrix)})),l.onAfterRenderObservable.add((function(){n.setTransformMatrix(l._savedViewMatrix,n.getProjectionMatrix()),n.getEngine().cullBackFaces=!0,n._mirroredCameraPosition=null,delete n.clipPlane})),l}return __extends(i,t),Object.defineProperty(i.prototype,"blurRatio",{get:function(){return this._blurRatio},set:function(e){this._blurRatio!==e&&(this._blurRatio=e,this._preparePostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"blurKernel",{set:function(e){this.blurKernelX=e,this.blurKernelY=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"blurKernelX",{get:function(){return this._blurKernelX},set:function(e){this._blurKernelX!==e&&(this._blurKernelX=e,this._preparePostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"blurKernelY",{get:function(){return this._blurKernelY},set:function(e){this._blurKernelY!==e&&(this._blurKernelY=e,this._preparePostProcesses())},enumerable:!0,configurable:!0}),i.prototype._preparePostProcesses=function(){if(this.clearPostProcesses(!0),this._blurKernelX&&this._blurKernelY){var t=this.getScene().getEngine(),i=t.getCaps().textureFloatRender?e.Engine.TEXTURETYPE_FLOAT:e.Engine.TEXTURETYPE_HALF_FLOAT;this._blurX=new e.BlurPostProcess("horizontal blur",new e.Vector2(1,0),this._blurKernelX,this._blurRatio,null,e.Texture.BILINEAR_SAMPLINGMODE,t,!1,i),this._blurX.autoClear=!1,1===this._blurRatio&&this.samples<2?this._blurX.outputTexture=this._texture:this._blurX.alwaysForcePOT=!0,this._blurY=new e.BlurPostProcess("vertical blur",new e.Vector2(0,1),this._blurKernelY,this._blurRatio,null,e.Texture.BILINEAR_SAMPLINGMODE,t,!1,i),this._blurY.autoClear=!1,this._blurY.alwaysForcePOT=1!==this._blurRatio,this.addPostProcess(this._blurX),this.addPostProcess(this._blurY)}},i.prototype.clone=function(){var e=this.getSize(),t=new i(this.name,e.width,this.getScene(),this._renderTargetOptions.generateMipMaps,this._renderTargetOptions.type,this._renderTargetOptions.samplingMode,this._renderTargetOptions.generateDepthBuffer);return t.hasAlpha=this.hasAlpha,t.level=this.level,t.mirrorPlane=this.mirrorPlane.clone(),t.renderList=this.renderList.slice(0),t},i.prototype.serialize=function(){if(!this.name)return null;var e=t.prototype.serialize.call(this);return e.mirrorPlane=this.mirrorPlane.asArray(),e},i})(e.RenderTargetTexture);e.MirrorTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o){var s=t.call(this,i,r,n,o,!0)||this;return s.refractionPlane=new e.Plane(0,1,0,1),s.depth=2,s.onBeforeRenderObservable.add((function(){n.clipPlane=s.refractionPlane})),s.onAfterRenderObservable.add((function(){delete n.clipPlane})),s}return __extends(i,t),i.prototype.clone=function(){var e=this.getSize(),t=new i(this.name,e.width,this.getScene(),this._generateMipMaps);return t.hasAlpha=this.hasAlpha,t.level=this.level,t.refractionPlane=this.refractionPlane.clone(),t.renderList=this.renderList.slice(0),t.depth=this.depth,t},i.prototype.serialize=function(){if(!this.name)return null;var e=t.prototype.serialize.call(this);return e.mirrorPlane=this.refractionPlane.asArray(),e.depth=this.depth,e},i})(e.RenderTargetTexture);e.RefractionTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o,s,a){void 0===s&&(s=e.Texture.TRILINEAR_SAMPLINGMODE),void 0===a&&(a=e.Engine.TEXTUREFORMAT_RGBA);var h=t.call(this,null,n,!o,void 0,s,void 0,void 0,void 0,void 0,a)||this;h.name=i;var l=h.getScene().getEngine();h.wrapU=e.Texture.CLAMP_ADDRESSMODE,h.wrapV=e.Texture.CLAMP_ADDRESSMODE,h._generateMipMaps=o,r.getContext?(h._canvas=r,h._texture=l.createDynamicTexture(r.width,r.height,o,s)):(h._canvas=document.createElement("canvas"),r.width?h._texture=l.createDynamicTexture(r.width,r.height,o,s):h._texture=l.createDynamicTexture(r,r,o,s));var c=h.getSize();return h._canvas.width=c.width,h._canvas.height=c.height,h._context=h._canvas.getContext("2d"),h}return __extends(i,t),Object.defineProperty(i.prototype,"canRescale",{get:function(){return!0},enumerable:!0,configurable:!0}),i.prototype._recreate=function(e){this._canvas.width=e.width,this._canvas.height=e.height,this.releaseInternalTexture(),this._texture=this.getScene().getEngine().createDynamicTexture(e.width,e.height,this._generateMipMaps,this._samplingMode)},i.prototype.scale=function(e){var t=this.getSize();t.width*=e,t.height*=e,this._recreate(t)},i.prototype.scaleTo=function(e,t){var i=this.getSize();i.width=e,i.height=t,this._recreate(i)},i.prototype.getContext=function(){return this._context},i.prototype.clear=function(){var e=this.getSize();this._context.fillRect(0,0,e.width,e.height)},i.prototype.update=function(e){this.getScene().getEngine().updateDynamicTexture(this._texture,this._canvas,void 0===e||e,void 0,this._format)},i.prototype.drawText=function(e,t,i,r,n,o,s,a){void 0===a&&(a=!0);var h=this.getSize();if(o&&(this._context.fillStyle=o,this._context.fillRect(0,0,h.width,h.height)),this._context.font=r,null===t||void 0===t){var l=this._context.measureText(e);t=(h.width-l.width)/2}if(null===i||void 0===i){var c=parseInt(r.replace(/\D/g,""));i=h.height/2+c/3.65}this._context.fillStyle=n,this._context.fillText(e,t,i),a&&this.update(s)},i.prototype.clone=function(){var e=this.getSize(),t=new i(this.name,e,this.getScene(),this._generateMipMaps);return t.hasAlpha=this.hasAlpha,t.level=this.level,t.wrapU=this.wrapU,t.wrapV=this.wrapV,t},i})(e.Texture);e.DynamicTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o,s,a){void 0===o&&(o=!1),void 0===s&&(s=!1),void 0===a&&(a=e.Texture.TRILINEAR_SAMPLINGMODE);var h=t.call(this,null,n,!o,s)||this;h._autoLaunch=!0;var l;return h.name=i,r instanceof HTMLVideoElement?h.video=r:(l=r,h.video=document.createElement("video"),h.video.autoplay=!1,h.video.loop=!0),h._generateMipMaps=o,h._samplingMode=a,!h.getScene().getEngine().needPOTTextures||e.Tools.IsExponentOfTwo(h.video.videoWidth)&&e.Tools.IsExponentOfTwo(h.video.videoHeight)?(h.wrapU=e.Texture.WRAP_ADDRESSMODE,h.wrapV=e.Texture.WRAP_ADDRESSMODE):(h.wrapU=e.Texture.CLAMP_ADDRESSMODE,h.wrapV=e.Texture.CLAMP_ADDRESSMODE,h._generateMipMaps=!1),l?(h.video.addEventListener("canplay",(function(){h._createTexture()})),l.forEach((function(e){var t=document.createElement("source");t.src=e,h.video.appendChild(t)}))):h._createTexture(),h._lastUpdate=e.Tools.Now,h}return __extends(i,t),i.prototype.__setTextureReady=function(){this._texture.isReady=!0},i.prototype._createTexture=function(){this._texture=this.getScene().getEngine().createDynamicTexture(this.video.videoWidth,this.video.videoHeight,this._generateMipMaps,this._samplingMode),this._autoLaunch&&(this._autoLaunch=!1,this.video.play()),this._setTextureReady=this.__setTextureReady.bind(this),this.video.addEventListener("playing",this._setTextureReady)},i.prototype.update=function(){var t=e.Tools.Now;return!(t-this._lastUpdate<15||this.video.readyState!==this.video.HAVE_ENOUGH_DATA)&&(this._lastUpdate=t,this.getScene().getEngine().updateVideoTexture(this._texture,this.video,this._invertY),!0)},i.prototype.dispose=function(){t.prototype.dispose.call(this),this.video.removeEventListener("playing",this._setTextureReady)},i.CreateFromWebCam=function(t,i,r){var n,o=document.createElement("video");r&&r.deviceId&&(n={exact:r.deviceId}),navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia,window.URL=window.URL||window.webkitURL||window.mozURL||window.msURL,navigator.getUserMedia&&navigator.getUserMedia({video:{deviceId:n,width:{min:r&&r.minWidth||256,max:r&&r.maxWidth||640},height:{min:r&&r.minHeight||256,max:r&&r.maxHeight||480}}},(function(r){void 0!==o.mozSrcObject?o.mozSrcObject=r:o.src=window.URL&&window.URL.createObjectURL(r)||r,o.play(),i&&i(new e.VideoTexture("video",o,t,!0,!0))}),(function(t){e.Tools.Error(t.name)}))},i})(e.Texture);e.VideoTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o,s,a,h,l){void 0===a&&(a=!0),void 0===h&&(h=!1),void 0===l&&(l=e.Texture.TRILINEAR_SAMPLINGMODE);var c=t.call(this,null,s,!a,h)||this;return c.format=o,c._texture=s.getEngine().createRawTexture(i,r,n,o,a,h,l),c.wrapU=e.Texture.CLAMP_ADDRESSMODE,c.wrapV=e.Texture.CLAMP_ADDRESSMODE,c}return __extends(i,t),i.prototype.update=function(e){this.getScene().getEngine().updateRawTexture(this._texture,e,this.format,this._invertY)},i.CreateLuminanceTexture=function(t,r,n,o,s,a,h){return void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===h&&(h=e.Texture.TRILINEAR_SAMPLINGMODE),new i(t,r,n,e.Engine.TEXTUREFORMAT_LUMINANCE,o,s,a,h)},i.CreateLuminanceAlphaTexture=function(t,r,n,o,s,a,h){return void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===h&&(h=e.Texture.TRILINEAR_SAMPLINGMODE),new i(t,r,n,e.Engine.TEXTUREFORMAT_LUMINANCE_ALPHA,o,s,a,h)},i.CreateAlphaTexture=function(t,r,n,o,s,a,h){return void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===h&&(h=e.Texture.TRILINEAR_SAMPLINGMODE),new i(t,r,n,e.Engine.TEXTUREFORMAT_ALPHA,o,s,a,h)},i.CreateRGBTexture=function(t,r,n,o,s,a,h){return void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===h&&(h=e.Texture.TRILINEAR_SAMPLINGMODE),new i(t,r,n,e.Engine.TEXTUREFORMAT_RGB,o,s,a,h)},i.CreateRGBATexture=function(t,r,n,o,s,a,h){return void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===h&&(h=e.Texture.TRILINEAR_SAMPLINGMODE),new i(t,r,n,e.Engine.TEXTUREFORMAT_RGBA,o,s,a,h)},i})(e.Texture);e.RawTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t,i,r,n,o,s,a,h,l,c,u,f,d,p){void 0===a&&(a=e.Texture.NEAREST_SAMPLINGMODE),void 0===u&&(u=e.Engine.TEXTURETYPE_UNSIGNED_INT),void 0===f&&(f="postprocess"),void 0===p&&(p=!1),this.name=t,this.width=-1,this.height=-1,this.autoClear=!0,this.alphaMode=e.Engine.ALPHA_DISABLE,this.enablePixelPerfectMode=!1,this.scaleMode=e.Engine.SCALEMODE_FLOOR,this.alwaysForcePOT=!1,this.samples=1,this._reusable=!1,this._textures=new e.SmartArray(2),this._currentRenderTextureInd=0,this._scaleRatio=new e.Vector2(1,1),this._texelSize=e.Vector2.Zero(),this.onActivateObservable=new e.Observable,this.onSizeChangedObservable=new e.Observable,this.onApplyObservable=new e.Observable,this.onBeforeRenderObservable=new e.Observable,this.onAfterRenderObservable=new e.Observable,null!=s?(this._camera=s,this._scene=s.getScene(),s.attachPostProcess(this),this._engine=this._scene.getEngine()):this._engine=h,this._options=o,this.renderTargetSamplingMode=a||e.Texture.NEAREST_SAMPLINGMODE,this._reusable=l||!1,this._textureType=u,this._samplers=n||[],this._samplers.push("textureSampler"),this._fragmentUrl=i,this._vertexUrl=f,this._parameters=r||[],this._parameters.push("scale"),this._indexParameters=d,p||this.updateEffect(c)}return Object.defineProperty(t.prototype,"onActivate",{set:function(e){this._onActivateObserver&&this.onActivateObservable.remove(this._onActivateObserver),this._onActivateObserver=this.onActivateObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onSizeChanged",{set:function(e){this._onSizeChangedObserver&&this.onSizeChangedObservable.remove(this._onSizeChangedObserver),this._onSizeChangedObserver=this.onSizeChangedObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onApply",{set:function(e){this._onApplyObserver&&this.onApplyObservable.remove(this._onApplyObserver),this._onApplyObserver=this.onApplyObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onBeforeRender",{set:function(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onAfterRender",{set:function(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=this.onAfterRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"outputTexture",{get:function(){return this._textures.data[this._currentRenderTextureInd]},set:function(e){this._forcedOutputTexture=e},enumerable:!0,configurable:!0}),t.prototype.getCamera=function(){return this._camera},Object.defineProperty(t.prototype,"texelSize",{get:function(){return this._shareOutputWithPostProcess?this._shareOutputWithPostProcess.texelSize:(this._forcedOutputTexture&&this._texelSize.copyFromFloats(1/this._forcedOutputTexture._width,1/this._forcedOutputTexture._height),this._texelSize)},enumerable:!0,configurable:!0}),t.prototype.getEngine=function(){return this._engine},t.prototype.getEffect=function(){return this._effect},t.prototype.shareOutputWith=function(e){return this._disposeTextures(),this._shareOutputWithPostProcess=e,this},t.prototype.updateEffect=function(e,t,i,r,n,o){this._effect=this._engine.createEffect({vertex:this._vertexUrl,fragment:this._fragmentUrl},["position"],t||this._parameters,i||this._samplers,void 0!==e?e:"",null,n,o,r||this._indexParameters)},t.prototype.isReusable=function(){return this._reusable},t.prototype.markTextureDirty=function(){this.width=-1},t.prototype.activate=function(t,i,r){var n=this;if(!this._shareOutputWithPostProcess&&!this._forcedOutputTexture){t=t||this._camera;var o=t.getScene(),s=o.getEngine(),a=s.getCaps().maxTextureSize,h=(i?i._width:this._engine.getRenderingCanvas().width)*this._options|0,l=(i?i._height:this._engine.getRenderingCanvas().height)*this._options|0,c=this._options.width||h,u=this._options.height||l;if((this.renderTargetSamplingMode===e.Texture.TRILINEAR_SAMPLINGMODE||this.alwaysForcePOT)&&(this._options.width||(c=s.needPOTTextures?e.Tools.GetExponentOfTwo(c,a,this.scaleMode):c),this._options.height||(u=s.needPOTTextures?e.Tools.GetExponentOfTwo(u,a,this.scaleMode):u)),this.width!==c||this.height!==u){if(this._textures.length>0){for(var f=0;f0)for(var e=0;e0&&this._camera._postProcesses[0].markTextureDirty(),this.onActivateObservable.clear(),this.onAfterRenderObservable.clear(),this.onApplyObservable.clear(),this.onBeforeRenderObservable.clear(),this.onSizeChangedObservable.clear()}},t})();e.PostProcess=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o,s,a,h){return void 0===h&&(h=e.Engine.TEXTURETYPE_UNSIGNED_INT),t.call(this,i,"pass",null,null,r,n,o,s,a,null,h)||this}return __extends(i,t),i})(e.PostProcess);e.PassPostProcess=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(i,r,n){this._bias=5e-5,this._blurBoxOffset=1,this._blurScale=2,this._blurKernel=1,this._useKernelBlur=!1,this._filter=t.FILTER_NONE,this._darkness=0,this._transparencyShadow=!1,this.frustumEdgeFalloff=0,this.forceBackFacesOnly=!1,this._lightDirection=e.Vector3.Zero(),this._viewMatrix=e.Matrix.Zero(),this._projectionMatrix=e.Matrix.Zero(),this._transformMatrix=e.Matrix.Zero(),this._worldViewProjection=e.Matrix.Zero(),this._currentFaceIndex=0,this._currentFaceIndexCache=0,this._isCube=!1,this._defaultTextureMatrix=e.Matrix.Identity(),this._mapSize=i,this._light=r,this._scene=r.getScene(),r._shadowGenerator=this;var o=this._scene.getEngine().getCaps();n?o.textureFloatRender&&o.textureFloatLinearFiltering?this._textureType=e.Engine.TEXTURETYPE_FLOAT:o.textureHalfFloatRender&&o.textureHalfFloatLinearFiltering?this._textureType=e.Engine.TEXTURETYPE_HALF_FLOAT:this._textureType=e.Engine.TEXTURETYPE_UNSIGNED_INT:o.textureHalfFloatRender&&o.textureHalfFloatLinearFiltering?this._textureType=e.Engine.TEXTURETYPE_HALF_FLOAT:o.textureFloatRender&&o.textureFloatLinearFiltering?this._textureType=e.Engine.TEXTURETYPE_FLOAT:this._textureType=e.Engine.TEXTURETYPE_UNSIGNED_INT,this._initializeGenerator()}return Object.defineProperty(t,"FILTER_NONE",{get:function(){return t._FILTER_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FILTER_POISSONSAMPLING",{get:function(){return t._FILTER_POISSONSAMPLING},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FILTER_EXPONENTIALSHADOWMAP",{get:function(){return t._FILTER_EXPONENTIALSHADOWMAP},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FILTER_BLUREXPONENTIALSHADOWMAP",{get:function(){return t._FILTER_BLUREXPONENTIALSHADOWMAP},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FILTER_CLOSEEXPONENTIALSHADOWMAP",{get:function(){return t._FILTER_CLOSEEXPONENTIALSHADOWMAP},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FILTER_BLURCLOSEEXPONENTIALSHADOWMAP",{get:function(){return t._FILTER_BLURCLOSEEXPONENTIALSHADOWMAP},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"bias",{get:function(){return this._bias},set:function(e){this._bias=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"blurBoxOffset",{get:function(){return this._blurBoxOffset},set:function(e){this._blurBoxOffset!==e&&(this._blurBoxOffset=e,this._disposeBlurPostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"blurScale",{get:function(){return this._blurScale},set:function(e){this._blurScale!==e&&(this._blurScale=e,this._disposeBlurPostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"blurKernel",{get:function(){return this._blurKernel},set:function(e){this._blurKernel!==e&&(this._blurKernel=e,this._disposeBlurPostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useKernelBlur",{get:function(){return this._useKernelBlur},set:function(e){this._useKernelBlur!==e&&(this._useKernelBlur=e,this._disposeBlurPostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"depthScale",{get:function(){return void 0!==this._depthScale?this._depthScale:this._light.getDepthScale()},set:function(e){this._depthScale=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"filter",{get:function(){return this._filter},set:function(e){if(this._light.needCube()){if(e===t.FILTER_BLUREXPONENTIALSHADOWMAP)return void(this.useExponentialShadowMap=!0);if(e===t.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP)return void(this.useCloseExponentialShadowMap=!0)}this._filter!==e&&(this._filter=e,this._disposeBlurPostProcesses(),this._applyFilterValues(),this._light._markMeshesAsLightDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"usePoissonSampling",{get:function(){return this.filter===t.FILTER_POISSONSAMPLING},set:function(e){this.filter=e?t.FILTER_POISSONSAMPLING:t.FILTER_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useVarianceShadowMap",{get:function(){return e.Tools.Warn("VSM are now replaced by ESM. Please use useExponentialShadowMap instead."),this.useExponentialShadowMap},set:function(t){e.Tools.Warn("VSM are now replaced by ESM. Please use useExponentialShadowMap instead."),this.useExponentialShadowMap=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useBlurVarianceShadowMap",{get:function(){return e.Tools.Warn("VSM are now replaced by ESM. Please use useBlurExponentialShadowMap instead."),this.useBlurExponentialShadowMap},set:function(t){e.Tools.Warn("VSM are now replaced by ESM. Please use useBlurExponentialShadowMap instead."),this.useBlurExponentialShadowMap=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useExponentialShadowMap",{get:function(){return this.filter===t.FILTER_EXPONENTIALSHADOWMAP},set:function(e){this.filter=e?t.FILTER_EXPONENTIALSHADOWMAP:t.FILTER_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useBlurExponentialShadowMap",{get:function(){return this.filter===t.FILTER_BLUREXPONENTIALSHADOWMAP},set:function(e){this.filter=e?t.FILTER_BLUREXPONENTIALSHADOWMAP:t.FILTER_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useCloseExponentialShadowMap",{get:function(){return this.filter===t.FILTER_CLOSEEXPONENTIALSHADOWMAP},set:function(e){this.filter=e?t.FILTER_CLOSEEXPONENTIALSHADOWMAP:t.FILTER_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useBlurCloseExponentialShadowMap",{get:function(){return this.filter===t.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP},set:function(e){this.filter=e?t.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP:t.FILTER_NONE},enumerable:!0,configurable:!0}),t.prototype.getDarkness=function(){return this._darkness},t.prototype.setDarkness=function(e){return this._darkness=e>=1?1:e<=0?0:e,this},t.prototype.setTransparencyShadow=function(e){return this._transparencyShadow=e,this},t.prototype.getShadowMap=function(){return this._shadowMap},t.prototype.getShadowMapForRendering=function(){return this._shadowMap2?this._shadowMap2:this._shadowMap},t.prototype.getLight=function(){return this._light},t.prototype._initializeGenerator=function(){this._light._markMeshesAsLightDirty(),this._initializeShadowMap()},t.prototype._initializeShadowMap=function(){var t=this;this._shadowMap=new e.RenderTargetTexture(this._light.name+"_shadowMap",this._mapSize,this._scene,!1,!0,this._textureType,this._light.needCube()),this._shadowMap.wrapU=e.Texture.CLAMP_ADDRESSMODE,this._shadowMap.wrapV=e.Texture.CLAMP_ADDRESSMODE,this._shadowMap.anisotropicFilteringLevel=1,this._shadowMap.updateSamplingMode(e.Texture.BILINEAR_SAMPLINGMODE),this._shadowMap.renderParticles=!1,this._shadowMap.onBeforeRenderObservable.add((function(e){t._currentFaceIndex=e})),this._shadowMap.customRenderFunction=this._renderForShadowMap.bind(this),this._shadowMap.onAfterUnbindObservable.add((function(){(t.useBlurExponentialShadowMap||t.useBlurCloseExponentialShadowMap)&&(t._blurPostProcesses||t._initializeBlurRTTAndPostProcesses(),t._scene.postProcessManager.directRender(t._blurPostProcesses,t.getShadowMapForRendering().getInternalTexture()))})),this._shadowMap.onClearObservable.add((function(i){t.useExponentialShadowMap||t.useBlurExponentialShadowMap?i.clear(new e.Color4(0,0,0,0),!0,!0,!0):i.clear(new e.Color4(1,1,1,1),!0,!0,!0)}))},t.prototype._initializeBlurRTTAndPostProcesses=function(){var t=this,i=this._scene.getEngine(),r=this._mapSize/this.blurScale;this.useKernelBlur&&1===this.blurScale||(this._shadowMap2=new e.RenderTargetTexture(this._light.name+"_shadowMap2",r,this._scene,!1,!0,this._textureType),this._shadowMap2.wrapU=e.Texture.CLAMP_ADDRESSMODE,this._shadowMap2.wrapV=e.Texture.CLAMP_ADDRESSMODE,this._shadowMap2.updateSamplingMode(e.Texture.BILINEAR_SAMPLINGMODE)),this.useKernelBlur?(this._kernelBlurXPostprocess=new e.BlurPostProcess(this._light.name+"KernelBlurX",new e.Vector2(1,0),this.blurKernel,1,null,e.Texture.BILINEAR_SAMPLINGMODE,i,!1,this._textureType),this._kernelBlurXPostprocess.width=r,this._kernelBlurXPostprocess.height=r,this._kernelBlurXPostprocess.onApplyObservable.add((function(e){e.setTexture("textureSampler",t._shadowMap)})),this._kernelBlurYPostprocess=new e.BlurPostProcess(this._light.name+"KernelBlurY",new e.Vector2(0,1),this.blurKernel,1,null,e.Texture.BILINEAR_SAMPLINGMODE,i,!1,this._textureType),this._kernelBlurXPostprocess.autoClear=!1,this._kernelBlurYPostprocess.autoClear=!1,this._textureType===e.Engine.TEXTURETYPE_UNSIGNED_INT&&(this._kernelBlurXPostprocess.packedFloat=!0,this._kernelBlurYPostprocess.packedFloat=!0),this._blurPostProcesses=[this._kernelBlurXPostprocess,this._kernelBlurYPostprocess]):(this._boxBlurPostprocess=new e.PostProcess(this._light.name+"DepthBoxBlur","depthBoxBlur",["screenSize","boxOffset"],[],1,null,e.Texture.BILINEAR_SAMPLINGMODE,i,!1,"#define OFFSET "+this._blurBoxOffset,this._textureType),this._boxBlurPostprocess.onApplyObservable.add((function(e){e.setFloat2("screenSize",r,r),e.setTexture("textureSampler",t._shadowMap)})),this._boxBlurPostprocess.autoClear=!1,this._blurPostProcesses=[this._boxBlurPostprocess])},t.prototype._renderForShadowMap=function(e,t,i){var r;for(r=0;r=n.length)return void(e&&e(i));setTimeout(l,16)}};n.length>0&&l()},t.prototype.isReady=function(t,i){var r=[];this._textureType!==e.Engine.TEXTURETYPE_UNSIGNED_INT&&r.push("#define FLOAT"),(this.useExponentialShadowMap||this.useBlurExponentialShadowMap)&&r.push("#define ESM");var n=[e.VertexBuffer.PositionKind],o=t.getMesh(),s=t.getMaterial();if(s&&s.needAlphaTesting()){var a=s.getAlphaTestTexture();a&&(r.push("#define ALPHATEST"),o.isVerticesDataPresent(e.VertexBuffer.UVKind)&&(n.push(e.VertexBuffer.UVKind),r.push("#define UV1")),o.isVerticesDataPresent(e.VertexBuffer.UV2Kind)&&1===a.coordinatesIndex&&(n.push(e.VertexBuffer.UV2Kind),r.push("#define UV2")))}o.useBones&&o.computeBonesUsingShaders?(n.push(e.VertexBuffer.MatricesIndicesKind),n.push(e.VertexBuffer.MatricesWeightsKind),o.numBoneInfluencers>4&&(n.push(e.VertexBuffer.MatricesIndicesExtraKind),n.push(e.VertexBuffer.MatricesWeightsExtraKind)),r.push("#define NUM_BONE_INFLUENCERS "+o.numBoneInfluencers),r.push("#define BonesPerMesh "+(o.skeleton.bones.length+1))):r.push("#define NUM_BONE_INFLUENCERS 0"),i&&(r.push("#define INSTANCES"),n.push("world0"),n.push("world1"),n.push("world2"),n.push("world3"));var h=r.join("\n");return this._cachedDefines!==h&&(this._cachedDefines=h,this._effect=this._scene.getEngine().createEffect("shadowMap",n,["world","mBones","viewProjection","diffuseMatrix","lightPosition","depthValues","biasAndScale"],["diffuseSampler"],h)),this._effect.isReady()},t.prototype.prepareDefines=function(e,t){var i=this._scene,r=this._light;i.shadowsEnabled&&r.shadowEnabled&&(e["SHADOW"+t]=!0,this.usePoissonSampling?e["SHADOWPCF"+t]=!0:this.useExponentialShadowMap||this.useBlurExponentialShadowMap?e["SHADOWESM"+t]=!0:(this.useCloseExponentialShadowMap||this.useBlurCloseExponentialShadowMap)&&(e["SHADOWCLOSEESM"+t]=!0),r.needCube()&&(e["SHADOWCUBE"+t]=!0))},t.prototype.bindShadowLight=function(e,t){var i=this._light,r=this._scene;r.shadowsEnabled&&i.shadowEnabled&&(i.needCube()||t.setMatrix("lightMatrix"+e,this.getTransformMatrix()), -t.setTexture("shadowSampler"+e,this.getShadowMapForRendering()),i._uniformBuffer.updateFloat4("shadowsInfo",this.getDarkness(),this.blurScale/this.getShadowMap().getSize().width,this.depthScale,this.frustumEdgeFalloff,e),i._uniformBuffer.updateFloat2("depthValues",this.getLight().getDepthMinZ(r.activeCamera),this.getLight().getDepthMinZ(r.activeCamera)+this.getLight().getDepthMaxZ(r.activeCamera),e))},t.prototype.getTransformMatrix=function(){var t=this._scene;if(this._currentRenderID===t.getRenderId()&&this._currentFaceIndexCache===this._currentFaceIndex)return this._transformMatrix;this._currentRenderID=t.getRenderId(),this._currentFaceIndexCache=this._currentFaceIndex;var i=this._light.position;return this._light.computeTransformedInformation()&&(i=this._light.transformedPosition),e.Vector3.NormalizeToRef(this._light.getShadowDirection(this._currentFaceIndex),this._lightDirection),1===Math.abs(e.Vector3.Dot(this._lightDirection,e.Vector3.Up()))&&(this._lightDirection.z=1e-13),!this._light.needProjectionMatrixCompute()&&this._cachedPosition&&this._cachedDirection&&i.equals(this._cachedPosition)&&this._lightDirection.equals(this._cachedDirection)||(this._cachedPosition=i.clone(),this._cachedDirection=this._lightDirection.clone(),e.Matrix.LookAtLHToRef(i,i.add(this._lightDirection),e.Vector3.Up(),this._viewMatrix),this._light.setShadowProjectionMatrix(this._projectionMatrix,this._viewMatrix,this.getShadowMap().renderList),this._viewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix)),this._transformMatrix},t.prototype.recreateShadowMap=function(){var e=this._shadowMap.renderList;this._disposeRTTandPostProcesses(),this._initializeGenerator(),this.filter=this.filter,this._applyFilterValues(),this._shadowMap.renderList=e},t.prototype._disposeBlurPostProcesses=function(){this._shadowMap2&&(this._shadowMap2.dispose(),this._shadowMap2=null),this._downSamplePostprocess&&(this._downSamplePostprocess.dispose(),this._downSamplePostprocess=null),this._boxBlurPostprocess&&(this._boxBlurPostprocess.dispose(),this._boxBlurPostprocess=null),this._kernelBlurXPostprocess&&(this._kernelBlurXPostprocess.dispose(),this._kernelBlurXPostprocess=null),this._kernelBlurYPostprocess&&(this._kernelBlurYPostprocess.dispose(),this._kernelBlurYPostprocess=null),this._blurPostProcesses=null},t.prototype._disposeRTTandPostProcesses=function(){this._shadowMap&&(this._shadowMap.dispose(),this._shadowMap=null),this._disposeBlurPostProcesses()},t.prototype.dispose=function(){this._disposeRTTandPostProcesses(),this._light._shadowGenerator=null,this._light._markMeshesAsLightDirty()},t.prototype.serialize=function(){var e={},t=this.getShadowMap();e.lightId=this._light.id,e.mapSize=t.getRenderSize(),e.useExponentialShadowMap=this.useExponentialShadowMap,e.useBlurExponentialShadowMap=this.useBlurExponentialShadowMap,e.useCloseExponentialShadowMap=this.useBlurExponentialShadowMap,e.useBlurCloseExponentialShadowMap=this.useBlurExponentialShadowMap,e.usePoissonSampling=this.usePoissonSampling,e.forceBackFacesOnly=this.forceBackFacesOnly,e.depthScale=this.depthScale,e.darkness=this.getDarkness(),e.blurBoxOffset=this.blurBoxOffset,e.blurKernel=this.blurKernel,e.blurScale=this.blurScale,e.useKernelBlur=this.useKernelBlur,e.transparencyShadow=this._transparencyShadow,e.renderList=[];for(var i=0;i-1&&void 0!==f.skeletons&&null!==f.skeletons){if(!1===_.indexOf(y.skeletonId)>-1)for(var O=0,I=f.skeletons.length;O0){for(var $=0;$0){for(var te=0;te0&&this._textureLoadingCallback(e)}this._currentScene.render()}},t.prototype.drag=function(e){e.stopPropagation(),e.preventDefault()},t.prototype.drop=function(e){e.stopPropagation(),e.preventDefault(),this.loadFiles(e)},t.prototype._handleFolderDrop=function(e,t,i){ -var r=e.createReader(),n=e.fullPath.replace(/^\//,"").replace(/(.+?)\/?$/,"$1/");r.readEntries((function(e){for(var r=e.length,o=0,s=e;o0){for(var i=[],r=[],n=0;n0&&(e.Tools.ClearLogCache(),e.Tools.Log("Babylon.js engine (v"+e.Engine.Version+") launched")),this._engine.stopRenderLoop(),this._currentScene.dispose()),e.SceneLoader.Load("file:",this._sceneFileToLoad,this._engine,(function(e){i._currentScene=e,i._currentScene.executeWhenReady((function(){i._sceneLoadedCallback&&i._sceneLoadedCallback(t._sceneFileToLoad,i._currentScene),i._engine.runRenderLoop((function(){i.renderFunction()}))}))}),(function(e){t._progressCallback&&t._progressCallback(e)}))):e.Tools.Error("Please provide a valid .babylon file.")},t})();t.FilesToLoad=new Array,e.FilesInput=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(){this._count=0,this._data={}}return e.prototype.copyFrom=function(e){var t=this;this.clear(),e.forEach((function(e,i){return t.add(e,i)}))},e.prototype.get=function(e){var t=this._data[e];if(void 0!==t)return t},e.prototype.getOrAddWithFactory=function(e,t){var i=this.get(e);return void 0!==i?i:(i=t(e),i&&this.add(e,i),i)},e.prototype.getOrAdd=function(e,t){var i=this.get(e);return void 0!==i?i:(this.add(e,t),t)},e.prototype.contains=function(e){return void 0!==this._data[e]},e.prototype.add=function(e,t){return void 0===this._data[e]&&(this._data[e]=t,++this._count,!0)},e.prototype.set=function(e,t){return void 0!==this._data[e]&&(this._data[e]=t,!0)},e.prototype.getAndRemove=function(e){var t=this.get(e);return void 0!==t?(delete this._data[e],--this._count,t):null},e.prototype.remove=function(e){return!!this.contains(e)&&(delete this._data[e],--this._count,!0)},e.prototype.clear=function(){this._data={},this._count=0},Object.defineProperty(e.prototype,"count",{get:function(){return this._count},enumerable:!0,configurable:!0}),e.prototype.forEach=function(e){for(var t in this._data){e(t,this._data[t])}},e.prototype.first=function(e){for(var t in this._data){var i=this._data[t],r=e(t,i);if(r)return r}return null},e})();e.StringDictionary=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){}return t.EnableFor=function(e){e._tags=e._tags||{},e.hasTags=function(){return t.HasTags(e)},e.addTags=function(i){return t.AddTagsTo(e,i)},e.removeTags=function(i){return t.RemoveTagsFrom(e,i)},e.matchesTagsQuery=function(i){return t.MatchesQuery(e,i)}},t.DisableFor=function(e){delete e._tags,delete e.hasTags,delete e.addTags,delete e.removeTags,delete e.matchesTagsQuery},t.HasTags=function(t){return!!t._tags&&!e.Tools.IsEmpty(t._tags)},t.GetTags=function(e,t){if(void 0===t&&(t=!0),!e._tags)return null;if(t){var i=[];for(var r in e._tags)e._tags.hasOwnProperty(r)&&!0===e._tags[r]&&i.push(r);return i.join(" ")}return e._tags},t.AddTagsTo=function(e,i){if(i&&"string"==typeof i){i.split(" ").forEach((function(i,r,n){t._AddTagTo(e,i)}))}},t._AddTagTo=function(e,i){""!==(i=i.trim())&&"true"!==i&&"false"!==i&&(i.match(/[\s]/)||i.match(/^([!]|([|]|[&]){2})/)||(t.EnableFor(e),e._tags[i]=!0))},t.RemoveTagsFrom=function(e,i){if(t.HasTags(e)){var r=i.split(" ");for(var n in r)t._RemoveTagFrom(e,r[n])}},t._RemoveTagFrom=function(e,t){delete e._tags[t]},t.MatchesQuery=function(i,r){return void 0===r||(""===r?t.HasTags(i):e.Internals.AndOrNotEvaluator.Eval(r,(function(e){return t.HasTags(i)&&i._tags[e]})))},t})();e.Tags=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(e){var t=(function(){function e(){}return e.Eval=function(t,i){return"true"===(t=t.match(/\([^\(\)]*\)/g)?t.replace(/\([^\(\)]*\)/g,(function(t){return t=t.slice(1,t.length-1),e._HandleParenthesisContent(t,i)})):e._HandleParenthesisContent(t,i))||"false"!==t&&e.Eval(t,i)},e._HandleParenthesisContent=function(t,i){i=i||function(e){return"true"===e};var r,n=t.split("||");for(var o in n)if(n.hasOwnProperty(o)){var s=e._SimplifyNegation(n[o].trim()),a=s.split("&&");if(a.length>1)for(var h=0;ho.data?(n.mustUpdateRessources=!0,r()):i(o.data):(n.mustUpdateRessources=!0,r())},s.onabort=function(e){i(-1)};var a=s.objectStore("versions").get(t);a.onsuccess=function(e){o=e.target.result},a.onerror=function(r){e.Tools.Error("Error loading version for scene "+t+" from DB."),i(-1)}}catch(t){e.Tools.Error("Error while accessing 'versions' object store (READ OP). Exception: "+t.message),i(-1)}}else e.Tools.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."),i(-1)},t.prototype._saveVersionIntoDBAsync=function(t,i){var r=this;if(this.isSupported&&!this.hasReachedQuota)try{var n=this.db.transaction(["versions"],"readwrite");n.onabort=function(e){try{e.srcElement.error&&"QuotaExceededError"===e.srcElement.error.name&&(r.hasReachedQuota=!0)}catch(e){}i(-1)},n.oncomplete=function(e){i(r.manifestVersionFound)};var o={sceneUrl:t,data:this.manifestVersionFound},s=n.objectStore("versions").put(o);s.onsuccess=function(e){},s.onerror=function(t){e.Tools.Error("Error in DB add version request in BABYLON.Database.")}}catch(t){e.Tools.Error("Error while accessing 'versions' object store (WRITE OP). Exception: "+t.message),i(-1)}else i(-1)},t.prototype.loadFileFromDB=function(e,i,r,n,o){var s=this,a=t.ReturnFullUrlLocation(e),h=function(e){s._saveFileIntoDBAsync(a,i,r)};this._checkVersionFromDB(a,(function(e){-1!==e?s.mustUpdateRessources?s._saveFileIntoDBAsync(a,i,r,o):s._loadFileFromDBAsync(a,i,h,o):n()}))},t.prototype._loadFileFromDBAsync=function(t,i,r,n){if(this.isSupported){var o;o=-1!==t.indexOf(".babylon")?"scenes":"textures";var s,a=this.db.transaction([o]);a.oncomplete=function(e){s?i(s.data):r()},a.onabort=function(e){r()};var h=a.objectStore(o).get(t);h.onsuccess=function(e){s=e.target.result},h.onerror=function(i){e.Tools.Error("Error loading file "+t+" from DB."),r()}}else e.Tools.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."),i()},t.prototype._saveFileIntoDBAsync=function(t,i,r,n){var o=this;if(this.isSupported){var s;s=-1!==t.indexOf(".babylon")?"scenes":"textures";var a,h=new XMLHttpRequest;h.open("GET",t,!0),n&&(h.responseType="arraybuffer"),h.onprogress=r,h.addEventListener("load",(function(){if(200===h.status||e.Tools.ValidateXHRData(h,n?6:1))if(a=n?h.response:h.responseText,o.hasReachedQuota)i(a);else{var r=o.db.transaction([s],"readwrite");r.onabort=function(e){try{e.srcElement.error&&"QuotaExceededError"===e.srcElement.error.name&&(o.hasReachedQuota=!0)}catch(e){}i(a)},r.oncomplete=function(e){i(a)};var l;l="scenes"===s?{sceneUrl:t,data:a,version:o.manifestVersionFound}:{textureUrl:t,data:a};try{var c=r.objectStore(s).put(l);c.onsuccess=function(e){},c.onerror=function(t){e.Tools.Error("Error in DB add file request in BABYLON.Database.")}}catch(e){i(a)}}else i()}),!1),h.addEventListener("error",(function(t){e.Tools.Error("error on XHR request."),i()}),!1),h.send()}else e.Tools.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."),i()},t})();t.IsUASupportingBlobStorage=!0,t.IDBStorageEnabled=!0,t.parseURL=function(e){document.createElement("a").href=e;var t=e.substring(0,e.lastIndexOf("#")),i=e.substring(t.lastIndexOf("/")+1,e.length);return e.substring(0,e.indexOf(i,0))},t.ReturnFullUrlLocation=function(e){return-1===e.indexOf("http:/")&&-1===e.indexOf("https:/")?t.parseURL(window.location.href)+e:e},e.Database=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this._isEnabled=!0,this.leftColor=e.Color3.White(),this.rightColor=e.Color3.Black(),this.bias=0,this.power=1}return Object.defineProperty(t.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(t){this._isEnabled!==t&&(this._isEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.FresnelDirtyFlag))},enumerable:!0,configurable:!0}),t.prototype.clone=function(){var i=new t;return e.Tools.DeepCopy(this,i),i},t.prototype.serialize=function(){var e={};return e.isEnabled=this.isEnabled,e.leftColor=this.leftColor,e.rightColor=this.rightColor,e.bias=this.bias,e.power=this.power,e},t.Parse=function(i){var r=new t;return r.isEnabled=i.isEnabled,r.leftColor=e.Color3.FromArray(i.leftColor),r.rightColor=e.Color3.FromArray(i.rightColor),r.bias=i.bias,r.power=i.power||1,r},t})();e.FresnelParameters=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e,i){var r=t.call(this,e,i,!0)||this;return i.multiMaterials.push(r),r.subMaterials=new Array,r.storeEffectOnSubMeshes=!0,r}return __extends(i,t),Object.defineProperty(i.prototype,"subMaterials",{get:function(){return this._subMaterials},set:function(e){this._subMaterials=e,this._hookArray(e)},enumerable:!0,configurable:!0}),i.prototype._hookArray=function(e){var t=this,i=e.push;e.push=function(){for(var r=[],n=0;n=this.subMaterials.length?this.getScene().defaultMaterial:this.subMaterials[e]},i.prototype.getActiveTextures=function(){return(e=t.prototype.getActiveTextures.call(this)).concat.apply(e,this.subMaterials.map((function(e){return e.getActiveTextures()})));var e},i.prototype.getClassName=function(){return"MultiMaterial"},i.prototype.isReadyForSubMesh=function(e,t,i){for(var r=0;r=0&&r.multiMaterials.splice(n,1),t.prototype.dispose.call(this,e,i)}},i})(e.Material);e.MultiMaterial=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this._offsetX=null,this._offsetY=null,this._pointerCount=0,this._pointerPressed=[],this.touchAngularSensibility=2e5,this.touchMoveSensibility=250}return t.prototype.attachControl=function(t,i){var r,n=this;void 0===this._pointerInput&&(this._onLostFocus=function(e){n._offsetX=null,n._offsetY=null},this._pointerInput=function(t,o){var s=t.event;if("mouse"!==s.pointerType)if(t.type===e.PointerEventTypes.POINTERDOWN){if(i||s.preventDefault(),n._pointerPressed.push(s.pointerId),1!==n._pointerPressed.length)return;r={x:s.clientX,y:s.clientY}}else if(t.type===e.PointerEventTypes.POINTERUP){i||s.preventDefault();var a=n._pointerPressed.indexOf(s.pointerId);if(-1===a)return;if(n._pointerPressed.splice(a,1),0!=a)return;r=null,n._offsetX=null,n._offsetY=null}else if(t.type===e.PointerEventTypes.POINTERMOVE){if(i||s.preventDefault(),!r)return;var a=n._pointerPressed.indexOf(s.pointerId);if(0!=a)return;n._offsetX=s.clientX-r.x,n._offsetY=-(s.clientY-r.y)}}),this._observer=this.camera.getScene().onPointerObservable.add(this._pointerInput,e.PointerEventTypes.POINTERDOWN|e.PointerEventTypes.POINTERUP|e.PointerEventTypes.POINTERMOVE),t.addEventListener("blur",this._onLostFocus)},t.prototype.detachControl=function(e){this._pointerInput&&e&&(this.camera.getScene().onPointerObservable.remove(this._observer),this._observer=null,e.removeEventListener("blur",this._onLostFocus),this._onLostFocus=null,this._pointerPressed=[],this._offsetX=null,this._offsetY=null,this._pointerCount=0)},t.prototype.checkInputs=function(){if(this._offsetX){var t=this.camera;if(t.cameraRotation.y+=this._offsetX/this.touchAngularSensibility,this._pointerPressed.length>1)t.cameraRotation.x+=-this._offsetY/this.touchAngularSensibility;else{var i=t._computeLocalCameraSpeed(),r=new e.Vector3(0,0,i*this._offsetY/this.touchMoveSensibility);e.Matrix.RotationYawPitchRollToRef(t.rotation.y,t.rotation.x,0,t._cameraRotationMatrix),t.cameraDirection.addInPlace(e.Vector3.TransformCoordinates(r,t._cameraRotationMatrix))}}},t.prototype.getClassName=function(){return"FreeCameraTouchInput"},t.prototype.getSimpleName=function(){return"touch"},t})();__decorate([e.serialize()],t.prototype,"touchAngularSensibility",void 0),__decorate([e.serialize()],t.prototype,"touchMoveSensibility",void 0),e.FreeCameraTouchInput=t,e.CameraInputTypes.FreeCameraTouchInput=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(e){function t(t,i,r){var n=e.call(this,t,i,r)||this;return n.inputs.addTouch(),n._setupInputs(),n}return __extends(t,e),Object.defineProperty(t.prototype,"touchAngularSensibility",{get:function(){var e=this.inputs.attached.touch;if(e)return e.touchAngularSensibility},set:function(e){var t=this.inputs.attached.touch;t&&(t.touchAngularSensibility=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"touchMoveSensibility",{get:function(){var e=this.inputs.attached.touch;if(e)return e.touchMoveSensibility},set:function(e){var t=this.inputs.attached.touch;t&&(t.touchMoveSensibility=e)},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return"TouchCamera"},t.prototype._setupInputs=function(){var e=this.inputs.attached.mouse;e&&(e.touchEnabled=!1)},t})(e.FreeCamera);e.TouchCamera=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o,s,a,h){void 0===a&&(a=!0),void 0===h&&(h=!1);var l=t.call(this,null,o,!a)||this;l.isCube=h,l.isEnabled=!0,l._currentRefreshId=-1,l._refreshRate=1,l._vertexBuffers={},l._uniforms=new Array,l._samplers=new Array,l._textures=new Array,l._floats=new Array,l._floatsArrays={},l._colors3=new Array,l._colors4=new Array,l._vectors2=new Array,l._vectors3=new Array,l._matrices=new Array,l._fallbackTextureUsed=!1,o._proceduralTextures.push(l),l.name=i,l.isRenderTarget=!0,l._size=r,l._generateMipMaps=a,l.setFragment(n),l._fallbackTexture=s;var c=o.getEngine();h?(l._texture=c.createRenderTargetCubeTexture(r,{generateMipMaps:a}),l.setFloat("face",0)):l._texture=c.createRenderTargetTexture(r,a);var u=[];u.push(1,1),u.push(-1,1),u.push(-1,-1),u.push(1,-1),l._vertexBuffers[e.VertexBuffer.PositionKind]=new e.VertexBuffer(c,u,e.VertexBuffer.PositionKind,!1,!1,2);var f=[];return f.push(0),f.push(1),f.push(2),f.push(0),f.push(2),f.push(3),l._indexBuffer=c.createIndexBuffer(f),l}return __extends(i,t),i.prototype.reset=function(){if(void 0!==this._effect){this.getScene().getEngine()._releaseEffect(this._effect)}},i.prototype.isReady=function(){var t,i=this,r=this.getScene().getEngine();return!!this._fragment&&(!!this._fallbackTextureUsed||(t=void 0!==this._fragment.fragmentElement?{vertex:"procedural",fragmentElement:this._fragment.fragmentElement}:{vertex:"procedural",fragment:this._fragment},this._effect=r.createEffect(t,[e.VertexBuffer.PositionKind],this._uniforms,this._samplers,"",null,null,(function(){i.releaseInternalTexture(),i._fallbackTexture&&(i._texture=i._fallbackTexture._texture,i._texture.references++),i._fallbackTextureUsed=!0})),this._effect.isReady()))},i.prototype.resetRefreshCounter=function(){this._currentRefreshId=-1},i.prototype.setFragment=function(e){this._fragment=e},Object.defineProperty(i.prototype,"refreshRate",{get:function(){return this._refreshRate},set:function(e){this._refreshRate=e,this.resetRefreshCounter()},enumerable:!0,configurable:!0}),i.prototype._shouldRender=function(){return!!(this.isEnabled&&this.isReady()&&this._texture)&&(!this._fallbackTextureUsed&&(-1===this._currentRefreshId?(this._currentRefreshId=1,!0):this.refreshRate===this._currentRefreshId?(this._currentRefreshId=1,!0):(this._currentRefreshId++,!1)))},i.prototype.getRenderSize=function(){return this._size},i.prototype.resize=function(e,t){this._fallbackTextureUsed||(this.releaseInternalTexture(),this._texture=this.getScene().getEngine().createRenderTargetTexture(e,t))},i.prototype._checkUniform=function(e){-1===this._uniforms.indexOf(e)&&this._uniforms.push(e)},i.prototype.setTexture=function(e,t){return-1===this._samplers.indexOf(e)&&this._samplers.push(e),this._textures[e]=t,this},i.prototype.setFloat=function(e,t){return this._checkUniform(e),this._floats[e]=t,this},i.prototype.setFloats=function(e,t){return this._checkUniform(e),this._floatsArrays[e]=t,this},i.prototype.setColor3=function(e,t){return this._checkUniform(e),this._colors3[e]=t,this},i.prototype.setColor4=function(e,t){return this._checkUniform(e),this._colors4[e]=t,this},i.prototype.setVector2=function(e,t){return this._checkUniform(e),this._vectors2[e]=t,this},i.prototype.setVector3=function(e,t){return this._checkUniform(e),this._vectors3[e]=t,this},i.prototype.setMatrix=function(e,t){return this._checkUniform(e),this._matrices[e]=t,this},i.prototype.render=function(e){var t=this.getScene(),i=t.getEngine();i.enableEffect(this._effect),i.setState(!1);for(var r in this._textures)this._effect.setTexture(r,this._textures[r]);for(r in this._floats)this._effect.setFloat(r,this._floats[r]);for(r in this._floatsArrays)this._effect.setArray(r,this._floatsArrays[r]);for(r in this._colors3)this._effect.setColor3(r,this._colors3[r]);for(r in this._colors4){var n=this._colors4[r];this._effect.setFloat4(r,n.r,n.g,n.b,n.a)}for(r in this._vectors2)this._effect.setVector2(r,this._vectors2[r]);for(r in this._vectors3)this._effect.setVector3(r,this._vectors3[r]);for(r in this._matrices)this._effect.setMatrix(r,this._matrices[r]);if(this.isCube)for(var o=0;o<6;o++)i.bindFramebuffer(this._texture,o),i.bindBuffers(this._vertexBuffers,this._indexBuffer,this._effect),this._effect.setFloat("face",o),i.clear(t.clearColor,!0,!0,!0),i.draw(!0,0,6),5===o&&i.generateMipMapsForCubemap(this._texture);else i.bindFramebuffer(this._texture),i.bindBuffers(this._vertexBuffers,this._indexBuffer,this._effect),i.clear(t.clearColor,!0,!0,!0),i.draw(!0,0,6);i.unBindFramebuffer(this._texture,this.isCube),this.onGenerated&&this.onGenerated()},i.prototype.clone=function(){var e=this.getSize(),t=new i(this.name,e.width,this._fragment,this.getScene(),this._fallbackTexture,this._generateMipMaps);return t.hasAlpha=this.hasAlpha,t.level=this.level,t.coordinatesMode=this.coordinatesMode,t},i.prototype.dispose=function(){var i=this.getScene()._proceduralTextures.indexOf(this);i>=0&&this.getScene()._proceduralTextures.splice(i,1);var r=this._vertexBuffers[e.VertexBuffer.PositionKind];r&&(r.dispose(),this._vertexBuffers[e.VertexBuffer.PositionKind]=null),this._indexBuffer&&this.getScene().getEngine()._releaseBuffer(this._indexBuffer)&&(this._indexBuffer=null),t.prototype.dispose.call(this)},i})(e.Texture);e.ProceduralTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e,i,r,n,o,s){var a=t.call(this,e,r,null,n,o,s)||this;return a._animate=!0,a._time=0,a._texturePath=i,a.loadJson(i),a.refreshRate=1,a}return __extends(i,t),i.prototype.loadJson=function(t){function i(){e.Tools.Log("No config file found in "+t+" trying to use ShadersStore or DOM element");try{n.setFragment(n._texturePath)}catch(t){e.Tools.Error("No json or ShaderStore or DOM element found for CustomProceduralTexture")}}var r=this,n=this,o=t+"/config.json",s=new XMLHttpRequest;s.open("GET",o,!0),s.addEventListener("load",(function(){if(200===s.status||e.Tools.ValidateXHRData(s,1))try{r._config=JSON.parse(s.response),r.updateShaderUniforms(),r.updateTextures(),r.setFragment(r._texturePath+"/custom"),r._animate=r._config.animate,r.refreshRate=r._config.refreshrate}catch(e){i()}else i()}),!1),s.addEventListener("error",(function(){i()}),!1);try{s.send()}catch(t){e.Tools.Error("CustomProceduralTexture: Error on XHR send request.")}},i.prototype.isReady=function(){if(!t.prototype.isReady.call(this))return!1;for(var e in this._textures){if(!this._textures[e].isReady())return!1}return!0},i.prototype.render=function(e){this._animate&&(this._time+=.03*this.getScene().getAnimationRatio(),this.updateShaderUniforms()),t.prototype.render.call(this,e)},i.prototype.updateTextures=function(){for(var t=0;t.005?0+r:0,i.y=Math.abs(n)>.005?0+n:0;var o=this.gamepad.rightStick;if(o){var s=o.x/this.gamepadAngularSensibility,a=o.y/this.gamepadAngularSensibility;o.x=Math.abs(s)>.001?0+s:0,o.y=Math.abs(a)>.001?0+a:0}else o={x:0,y:0};t.rotationQuaternion?t.rotationQuaternion.toRotationMatrix(this._cameraTransform):e.Matrix.RotationYawPitchRollToRef(t.rotation.y,t.rotation.x,0,this._cameraTransform);var h=50*t._computeLocalCameraSpeed();this._vector3.copyFromFloats(i.x*h,0,-i.y*h),e.Vector3.TransformCoordinatesToRef(this._vector3,this._cameraTransform,this._deltaTransform),t.cameraDirection.addInPlace(this._deltaTransform),this._vector2.copyFromFloats(o.y,o.x),t.cameraRotation.addInPlace(this._vector2)}},t.prototype._onNewGameConnected=function(t){t.type!==e.Gamepad.POSE_ENABLED&&(this.gamepad&&t.type!==e.Gamepad.XBOX||(this.gamepad=t))},t.prototype.getClassName=function(){return"FreeCameraGamepadInput"},t.prototype.getSimpleName=function(){return"gamepad"},t})();__decorate([e.serialize()],t.prototype,"gamepadAngularSensibility",void 0),__decorate([e.serialize()],t.prototype,"gamepadMoveSensibility",void 0),e.FreeCameraGamepadInput=t,e.CameraInputTypes.FreeCameraGamepadInput=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this.gamepadRotationSensibility=80,this.gamepadMoveSensibility=40}return t.prototype.attachControl=function(t,i){var r=this;this._gamepads=new e.Gamepads(function(e){r._onNewGameConnected(e)})},t.prototype.detachControl=function(e){this._gamepads&&this._gamepads.dispose(),this.gamepad=null},t.prototype.checkInputs=function(){if(this.gamepad){var e=this.camera,t=this.gamepad.rightStick;if(t){if(0!=t.x){var i=t.x/this.gamepadRotationSensibility;0!=i&&Math.abs(i)>.005&&(e.inertialAlphaOffset+=i)}if(0!=t.y){var r=t.y/this.gamepadRotationSensibility;0!=r&&Math.abs(r)>.005&&(e.inertialBetaOffset+=r)}}var n=this.gamepad.leftStick;if(n&&0!=n.y){var o=n.y/this.gamepadMoveSensibility;0!=o&&Math.abs(o)>.005&&(this.camera.inertialRadiusOffset-=o)}}},t.prototype._onNewGameConnected=function(t){t.type!==e.Gamepad.POSE_ENABLED&&(this.gamepad&&t.type!==e.Gamepad.XBOX||(this.gamepad=t))},t.prototype.getClassName=function(){return"ArcRotateCameraGamepadInput"},t.prototype.getSimpleName=function(){return"gamepad"},t})();__decorate([e.serialize()],t.prototype,"gamepadRotationSensibility",void 0),__decorate([e.serialize()],t.prototype,"gamepadMoveSensibility",void 0),e.ArcRotateCameraGamepadInput=t,e.CameraInputTypes.ArcRotateCameraGamepadInput=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e,t){var i=this;this.babylonGamepads=[],this.oneGamepadConnected=!1,this.isMonitoring=!1,this.gamepadEventSupported="GamepadEvent"in window,this.gamepadSupport=navigator.getGamepads||navigator.webkitGetGamepads||navigator.msGetGamepads||navigator.webkitGamepads,this._callbackGamepadConnected=e,this._callbackGamepadDisconnected=t,this.gamepadSupport&&(this._updateGamepadObjects(),this.babylonGamepads.length&&this._startMonitoringGamepads(),this.gamepadEventSupported?(this._onGamepadConnectedEvent=function(e){i._onGamepadConnected(e.gamepad)},this._onGamepadDisonnectedEvent=function(e){i._onGamepadDisconnected(e.gamepad)},window.addEventListener("gamepadconnected",this._onGamepadConnectedEvent,!1),window.addEventListener("gamepaddisconnected",this._onGamepadDisonnectedEvent,!1)):this._startMonitoringGamepads())}return t.prototype.dispose=function(){this._onGamepadConnectedEvent&&(window.removeEventListener("gamepadconnected",this._onGamepadConnectedEvent,!1),window.removeEventListener("gamepaddisconnected",this._onGamepadDisonnectedEvent,!1),this._onGamepadConnectedEvent=null,this._onGamepadDisonnectedEvent=null),this.oneGamepadConnected=!1, -this._stopMonitoringGamepads(),this.babylonGamepads=[]},t.prototype._onGamepadConnected=function(e){if(!(e.index in this.babylonGamepads)){var t=this._addNewGamepad(e);this._callbackGamepadConnected&&this._callbackGamepadConnected(t),this._startMonitoringGamepads()}},t.prototype._addNewGamepad=function(t){this.oneGamepadConnected||(this.oneGamepadConnected=!0);var i,r=-1!==t.id.search("Xbox One");return i=r||-1!==t.id.search("Xbox 360")||-1!==t.id.search("xinput")?new a(t.id,t.index,t,r):t.pose?e.PoseEnabledControllerHelper.InitiateController(t):new n(t.id,t.index,t),this.babylonGamepads.push(i),i},t.prototype._onGamepadDisconnected=function(e){for(var t in this.babylonGamepads)if(this.babylonGamepads[t].index==e.index){this.babylonGamepads.splice(+t,1);break}0==this.babylonGamepads.length&&(this._stopMonitoringGamepads(),this.oneGamepadConnected=!1),this._callbackGamepadDisconnected&&this._callbackGamepadDisconnected(e)},t.prototype._startMonitoringGamepads=function(){this.isMonitoring||(this.isMonitoring=!0,this._checkGamepadsStatus())},t.prototype._stopMonitoringGamepads=function(){this.isMonitoring=!1},t.prototype._checkGamepadsStatus=function(){var e=this;this._updateGamepadObjects();for(var t in this.babylonGamepads)this.babylonGamepads[t].update();this.isMonitoring&&(window.requestAnimationFrame?window.requestAnimationFrame((function(){e._checkGamepadsStatus()})):window.mozRequestAnimationFrame?window.mozRequestAnimationFrame((function(){e._checkGamepadsStatus()})):window.webkitRequestAnimationFrame&&window.webkitRequestAnimationFrame((function(){e._checkGamepadsStatus()})))},t.prototype._updateGamepadObjects=function(){for(var e=navigator.getGamepads?navigator.getGamepads():navigator.webkitGetGamepads?navigator.webkitGetGamepads():[],t=0;t=2&&(this._leftStick={x:this.browserGamepad.axes[this._leftStickAxisX],y:this.browserGamepad.axes[this._leftStickAxisY]}),this.browserGamepad.axes.length>=4&&(this._rightStick={x:this.browserGamepad.axes[this._rightStickAxisX],y:this.browserGamepad.axes[this._rightStickAxisY]})}return e.prototype.onleftstickchanged=function(e){this._onleftstickchanged=e},e.prototype.onrightstickchanged=function(e){this._onrightstickchanged=e},Object.defineProperty(e.prototype,"leftStick",{get:function(){return this._leftStick},set:function(e){!this._onleftstickchanged||this._leftStick.x===e.x&&this._leftStick.y===e.y||this._onleftstickchanged(e),this._leftStick=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rightStick",{get:function(){return this._rightStick},set:function(e){!this._onrightstickchanged||this._rightStick.x===e.x&&this._rightStick.y===e.y||this._onrightstickchanged(e),this._rightStick=e},enumerable:!0,configurable:!0}),e.prototype.update=function(){this._leftStick&&(this.leftStick={x:this.browserGamepad.axes[this._leftStickAxisX],y:this.browserGamepad.axes[this._leftStickAxisY]}),this._rightStick&&(this.rightStick={x:this.browserGamepad.axes[this._rightStickAxisX],y:this.browserGamepad.axes[this._rightStickAxisY]})},e})();r.GAMEPAD=0,r.GENERIC=1,r.XBOX=2,r.POSE_ENABLED=3,e.Gamepad=r;var n=(function(e){function t(t,i,n){var o=e.call(this,t,i,n)||this;return o.type=r.GENERIC,o._buttons=new Array(n.buttons.length),o}return __extends(t,e),t.prototype.onbuttondown=function(e){this._onbuttondown=e},t.prototype.onbuttonup=function(e){this._onbuttonup=e},t.prototype._setButtonValue=function(e,t,i){return e!==t&&(this._onbuttondown&&1===e&&this._onbuttondown(i),this._onbuttonup&&0===e&&this._onbuttonup(i)),e},t.prototype.update=function(){e.prototype.update.call(this);for(var t=0;tthis.maxCameraSpeed||u<-this.maxCameraSpeed)&&(u=u<1?-this.maxCameraSpeed:this.maxCameraSpeed),(f>this.maxCameraSpeed||f<-this.maxCameraSpeed)&&(f=f<1?-this.maxCameraSpeed:this.maxCameraSpeed),(d>this.maxCameraSpeed||d<-this.maxCameraSpeed)&&(d=d<1?-this.maxCameraSpeed:this.maxCameraSpeed),this.position=new e.Vector3(this.position.x+u,this.position.y+f,this.position.z+d),this.setTarget(o)}},i.prototype._checkInputs=function(){t.prototype._checkInputs.call(this),this.follow(this.lockedTarget)},i.prototype.getClassName=function(){return"FollowCamera"},i})(e.TargetCamera);__decorate([e.serialize()],t.prototype,"radius",void 0),__decorate([e.serialize()],t.prototype,"rotationOffset",void 0),__decorate([e.serialize()],t.prototype,"heightOffset",void 0),__decorate([e.serialize()],t.prototype,"cameraAcceleration",void 0),__decorate([e.serialize()],t.prototype,"maxCameraSpeed",void 0),__decorate([e.serializeAsMeshReference("lockedTargetId")],t.prototype,"lockedTarget",void 0),e.FollowCamera=t;var i=(function(t){function i(i,r,n,o,s,a){var h=t.call(this,i,e.Vector3.Zero(),a)||this;return h.alpha=r,h.beta=n,h.radius=o,h.target=s,h._cartesianCoordinates=e.Vector3.Zero(),h.follow(),h}return __extends(i,t),i.prototype.follow=function(){this._cartesianCoordinates.x=this.radius*Math.cos(this.alpha)*Math.cos(this.beta),this._cartesianCoordinates.y=this.radius*Math.sin(this.beta),this._cartesianCoordinates.z=this.radius*Math.sin(this.alpha)*Math.cos(this.beta);var e=this.target.getAbsolutePosition();this.position=e.add(this._cartesianCoordinates),this.setTarget(e)},i.prototype._checkInputs=function(){t.prototype._checkInputs.call(this),this.follow()},i.prototype.getClassName=function(){return"ArcFollowCamera"},i})(e.TargetCamera);e.ArcFollowCamera=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(e){function t(t,i,r){var n=e.call(this,t,i,r)||this;return n.inputs.addGamepad(),n}return __extends(t,e),Object.defineProperty(t.prototype,"gamepadAngularSensibility",{get:function(){var e=this.inputs.attached.gamepad;if(e)return e.gamepadAngularSensibility},set:function(e){var t=this.inputs.attached.gamepad;t&&(t.gamepadAngularSensibility=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"gamepadMoveSensibility",{get:function(){var e=this.inputs.attached.gamepad;if(e)return e.gamepadMoveSensibility},set:function(e){var t=this.inputs.attached.gamepad;t&&(t.gamepadMoveSensibility=e)},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return"UniversalCamera"},t})(e.TouchCamera);e.UniversalCamera=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(e){function t(t,i,r){return e.call(this,t,i,r)||this}return __extends(t,e),Object.defineProperty(t.prototype,"gamepadAngularSensibility",{get:function(){var e=this.inputs.attached.gamepad;if(e)return e.gamepadAngularSensibility},set:function(e){var t=this.inputs.attached.gamepad;t&&(t.gamepadAngularSensibility=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"gamepadMoveSensibility",{get:function(){var e=this.inputs.attached.gamepad;if(e)return e.gamepadMoveSensibility},set:function(e){var t=this.inputs.attached.gamepad;t&&(t.gamepadMoveSensibility=e)},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return"GamepadCamera"},t})(e.UniversalCamera);e.GamepadCamera=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(){this._renderPipelines={}}return e.prototype.addPipeline=function(e){this._renderPipelines[e._name]=e},e.prototype.attachCamerasToRenderPipeline=function(e,t,i){var r=this._renderPipelines[e];r&&r._attachCameras(t,i)},e.prototype.detachCamerasFromRenderPipeline=function(e,t){var i=this._renderPipelines[e];i&&i._detachCameras(t)},e.prototype.enableEffectInPipeline=function(e,t,i){var r=this._renderPipelines[e];r&&r._enableEffect(t,i)},e.prototype.disableEffectInPipeline=function(e,t,i){var r=this._renderPipelines[e];r&&r._disableEffect(t,i)},e.prototype.enableDisplayOnlyPassInPipeline=function(e,t,i){var r=this._renderPipelines[e];r&&r._enableDisplayOnlyPass(t,i)},e.prototype.disableDisplayOnlyPassInPipeline=function(e,t){var i=this._renderPipelines[e];i&&i._disableDisplayOnlyPass(t)},e.prototype.update=function(){for(var e in this._renderPipelines){var t=this._renderPipelines[e];t.isSupported?t._update():(t.dispose(),delete this._renderPipelines[e])}},e})();e.PostProcessRenderPipelineManager=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t,i,r,n,o,s){this._enabled=!0,this._refCount=0,this._name=i,this._renderTexture=new e.RenderTargetTexture(i,r,t),this.setRenderList(n),this._renderTexture.onBeforeRenderObservable.add(o),this._renderTexture.onAfterRenderObservable.add(s),this._scene=t,this._renderList=n}return t.prototype._incRefCount=function(){return 0===this._refCount&&this._scene.customRenderTargets.push(this._renderTexture),++this._refCount},t.prototype._decRefCount=function(){return this._refCount--,this._refCount<=0&&this._scene.customRenderTargets.splice(this._scene.customRenderTargets.indexOf(this._renderTexture),1),this._refCount},t.prototype._update=function(){this.setRenderList(this._renderList)},t.prototype.setRenderList=function(e){this._renderTexture.renderList=e},t.prototype.getRenderTexture=function(){return this._renderTexture},t})();e.PostProcessRenderPass=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e,t,i,r){this._engine=e,this._name=t,this._singleInstance=r||!0,this._getPostProcess=i,this._cameras=[],this._indicesForCamera=[],this._postProcesses={},this._renderPasses={},this._renderEffectAsPasses={}}return Object.defineProperty(t.prototype,"isSupported",{get:function(){for(var e in this._postProcesses)if(!this._postProcesses[e].isSupported)return!1;return!0},enumerable:!0,configurable:!0}),t.prototype._update=function(){for(var e in this._renderPasses)this._renderPasses[e]._update()},t.prototype.addPass=function(e){this._renderPasses[e._name]=e,this._linkParameters()},t.prototype.removePass=function(e){delete this._renderPasses[e._name],this._linkParameters()},t.prototype.addRenderEffectAsPass=function(e){this._renderEffectAsPasses[e._name]=e,this._linkParameters()},t.prototype.getPass=function(e){for(var t in this._renderPasses)if(t===e)return this._renderPasses[e]},t.prototype.emptyPasses=function(){this._renderPasses={},this._linkParameters()},t.prototype._attachCameras=function(t){for(var i,r=e.Tools.MakeArray(t||this._cameras),n=0;n4&&(o.push(e.VertexBuffer.MatricesIndicesExtraKind),o.push(e.VertexBuffer.MatricesWeightsExtraKind)),n.push("#define NUM_BONE_INFLUENCERS "+s.numBoneInfluencers),n.push("#define BonesPerMesh "+(s.skeleton.bones.length+1))):n.push("#define NUM_BONE_INFLUENCERS 0"),i&&(n.push("#define INSTANCES"),o.push("world0"),o.push("world1"),o.push("world2"),o.push("world3"));var a=n.join("\n");return this._cachedDefines!==a&&(this._cachedDefines=a,this._effect=this._scene.getEngine().createEffect("depth",o,["world","mBones","viewProjection","diffuseMatrix","depthValues"],["diffuseSampler"],a)),this._effect.isReady()},t.prototype.getDepthMap=function(){return this._depthMap},t.prototype.dispose=function(){this._depthMap.dispose()},t})();e.DepthRenderer=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o){var s=t.call(this,r.getEngine(),i)||this;s.SSAOOriginalSceneColorEffect="SSAOOriginalSceneColorEffect",s.SSAORenderEffect="SSAORenderEffect",s.SSAOBlurHRenderEffect="SSAOBlurHRenderEffect",s.SSAOBlurVRenderEffect="SSAOBlurVRenderEffect",s.SSAOCombineRenderEffect="SSAOCombineRenderEffect",s.totalStrength=1,s.radius=1e-4,s.area=.0075,s.fallOff=1e-6,s.base=.5,s._firstUpdate=!0,s._scene=r,s._createRandomTexture(),s._depthTexture=r.enableDepthRenderer().getDepthMap();var a=n.ssaoRatio||n,h=n.combineRatio||n;return s._ratio={ssaoRatio:a,combineRatio:h},s._originalColorPostProcess=new e.PassPostProcess("SSAOOriginalSceneColor",h,null,e.Texture.BILINEAR_SAMPLINGMODE,r.getEngine(),!1),s._createSSAOPostProcess(a),s._createBlurPostProcess(a),s._createSSAOCombinePostProcess(h),s.addEffect(new e.PostProcessRenderEffect(r.getEngine(),s.SSAOOriginalSceneColorEffect,function(){return s._originalColorPostProcess},!0)),s.addEffect(new e.PostProcessRenderEffect(r.getEngine(),s.SSAORenderEffect,function(){return s._ssaoPostProcess},!0)),s.addEffect(new e.PostProcessRenderEffect(r.getEngine(),s.SSAOBlurHRenderEffect,function(){return s._blurHPostProcess},!0)),s.addEffect(new e.PostProcessRenderEffect(r.getEngine(),s.SSAOBlurVRenderEffect,function(){return s._blurVPostProcess},!0)),s.addEffect(new e.PostProcessRenderEffect(r.getEngine(),s.SSAOCombineRenderEffect,function(){return s._ssaoCombinePostProcess},!0)),r.postProcessRenderPipelineManager.addPipeline(s),o&&r.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(i,o),s}return __extends(i,t),i.prototype.dispose=function(e){void 0===e&&(e=!1);for(var i=0;i1},enumerable:!0,configurable:!0}),i.prototype.dispose=function(e){void 0===e&&(e=!1);for(var i=0;i=0;a--){var o=Math.pow(3,a),h="#define LUMINANCE_DOWN_SAMPLE\n";0===a&&(h+="#define FINAL_DOWN_SAMPLER");var l=new e.PostProcess("HDRLuminanceDownSample"+a,"standard",["dsOffsets","halfDestPixelSize"],[],{width:o,height:o},null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,h,r);this.luminanceDownSamplePostProcesses.push(l)}var c=this.luminancePostProcess;this.luminanceDownSamplePostProcesses.forEach((function(i,r){var o=new Array(18);i.onApply=function(e){for(var t=0,s=-1;s<2;s++)for(var a=-1;a<2;a++)o[t]=s/c.width,o[t+1]=a/c.height,t+=2;e.setArray2("dsOffsets",o),e.setFloat("halfDestPixelSize",.5/c.width),c=r===n.luminanceDownSamplePostProcesses.length-1?n.luminancePostProcess:i},r===n.luminanceDownSamplePostProcesses.length-1&&(i.onAfterRender=function(i){var r=t.getEngine().readPixels(0,0,1,1),o=new e.Vector4(1/16581375,1/65025,1/255,1);n._hdrCurrentLuminance=(r[0]*o.x+r[1]*o.y+r[2]*o.z+r[3]*o.w)/100}),n.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRLuminanceDownSample"+r,function(){return i},!0))}))},i.prototype._createHdrPostProcess=function(t,i){var r=this;this.hdrPostProcess=new e.PostProcess("HDR","standard",["averageLuminance"],["textureAdderSampler"],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,"#define HDR",e.Engine.TEXTURETYPE_UNSIGNED_INT);var n=1,o=0,s=0;this.hdrPostProcess.onApply=function(i){if(i.setTextureFromPostProcess("textureAdderSampler",r._currentDepthOfFieldSource),o+=t.getEngine().getDeltaTime(),n<0)n=r._hdrCurrentLuminance;else{var a=(s-o)/1e3;r._hdrCurrentLuminancen-r.hdrIncreaseRate*a?n-=r.hdrIncreaseRate*a:n=r._hdrCurrentLuminance}n=e.Scalar.Clamp(n,r.hdrMinimumLuminance,1e20),i.setFloat("averageLuminance",n),s=o,r._currentDepthOfFieldSource=r.hdrFinalPostProcess},this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDR",function(){return r.hdrPostProcess},!0))},i.prototype._createLensFlarePostProcess=function(t,i){var r=this;this.lensFlarePostProcess=new e.PostProcess("HDRLensFlare","standard",["strength","ghostDispersal","haloWidth","resolution","distortionStrength"],["lensColorSampler"],i/2,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,"#define LENS_FLARE",e.Engine.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRLensFlare",function(){return r.lensFlarePostProcess},!0)),this._createBlurPostProcesses(t,i/4,2),this.lensFlareComposePostProcess=new e.PostProcess("HDRLensFlareCompose","standard",["lensStarMatrix"],["otherSampler","lensDirtSampler","lensStarSampler"],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,"#define LENS_FLARE_COMPOSE",e.Engine.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRLensFlareCompose",function(){return r.lensFlareComposePostProcess},!0));var n=new e.Vector2(0,0);this.lensFlarePostProcess.onApply=function(e){e.setTextureFromPostProcess("textureSampler",r._bloomEnabled?r.blurHPostProcesses[0]:r.originalPostProcess),e.setTexture("lensColorSampler",r.lensColorTexture),e.setFloat("strength",r.lensFlareStrength),e.setFloat("ghostDispersal",r.lensFlareGhostDispersal),e.setFloat("haloWidth",r.lensFlareHaloWidth),n.x=r.lensFlarePostProcess.width,n.y=r.lensFlarePostProcess.height,e.setVector2("resolution",n),e.setFloat("distortionStrength",r.lensFlareDistortionStrength)};var o=e.Matrix.FromValues(2,0,-1,0,0,2,-1,0,0,0,1,0,0,0,0,1),s=e.Matrix.FromValues(.5,0,.5,0,0,.5,.5,0,0,0,1,0,0,0,0,1);this.lensFlareComposePostProcess.onApply=function(t){t.setTextureFromPostProcess("otherSampler",r._currentDepthOfFieldSource),t.setTexture("lensDirtSampler",r.lensFlareDirtTexture),t.setTexture("lensStarSampler",r.lensStarTexture);var i=r._scene.activeCamera.getViewMatrix().getRow(0),n=r._scene.activeCamera.getViewMatrix().getRow(2),a=e.Vector3.Dot(i.toVector3(),new e.Vector3(1,0,0))+e.Vector3.Dot(n.toVector3(),new e.Vector3(0,0,1));a*=4;var h=e.Matrix.FromValues(.5*Math.cos(a),-Math.sin(a),0,0,Math.sin(a),.5*Math.cos(a),0,0,0,0,1,0,0,0,0,1),l=s.multiply(h).multiply(o);t.setMatrix("lensStarMatrix",l),r._currentDepthOfFieldSource=r.lensFlareFinalPostProcess}},i.prototype._createDepthOfFieldPostProcess=function(t,i){var r=this;this.depthOfFieldPostProcess=new e.PostProcess("HDRDepthOfField","standard",["distance"],["otherSampler","depthSampler"],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,"#define DEPTH_OF_FIELD",e.Engine.TEXTURETYPE_UNSIGNED_INT),this.depthOfFieldPostProcess.onApply=function(e){e.setTextureFromPostProcess("otherSampler",r._currentDepthOfFieldSource),e.setTexture("depthSampler",r._getDepthTexture()),e.setFloat("distance",r.depthOfFieldDistance)},this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRDepthOfField",function(){return r.depthOfFieldPostProcess},!0))},i.prototype._createMotionBlurPostProcess=function(t,i){var r=this;this.motionBlurPostProcess=new e.PostProcess("HDRMotionBlur","standard",["inverseViewProjection","prevViewProjection","screenSize","motionScale","motionStrength"],["depthSampler"],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,"#define MOTION_BLUR\n#define MAX_MOTION_SAMPLES "+this.motionBlurSamples.toFixed(1),e.Engine.TEXTURETYPE_UNSIGNED_INT);var n=0,o=e.Matrix.Identity(),s=e.Matrix.Identity(),a=e.Matrix.Identity(),h=e.Vector2.Zero();this.motionBlurPostProcess.onApply=function(e){a=t.getProjectionMatrix().multiply(t.getViewMatrix()),a.invertToRef(s),e.setMatrix("inverseViewProjection",s),e.setMatrix("prevViewProjection",o),o=a,h.x=r.motionBlurPostProcess.width,h.y=r.motionBlurPostProcess.height,e.setVector2("screenSize",h),n=t.getEngine().getFps()/60,e.setFloat("motionScale",n),e.setFloat("motionStrength",r.motionStrength),e.setTexture("depthSampler",r._getDepthTexture())},this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRMotionBlur",function(){return r.motionBlurPostProcess},!0))},i.prototype._getDepthTexture=function(){var e=this._scene.enableGeometryBufferRenderer();return e?e.getGBuffer().textures[0]:this._scene.enableDepthRenderer().getDepthMap()},i.prototype._disposePostProcesses=function(){for(var e=0;e4&&(o.push(e.VertexBuffer.MatricesIndicesExtraKind),o.push(e.VertexBuffer.MatricesWeightsExtraKind)),n.push("#define NUM_BONE_INFLUENCERS "+s.numBoneInfluencers),n.push("#define BonesPerMesh "+(s.skeleton.bones.length+1))):n.push("#define NUM_BONE_INFLUENCERS 0"),i&&(n.push("#define INSTANCES"),o.push("world0"),o.push("world1"),o.push("world2"),o.push("world3"));var a=n.join("\n");return this._cachedDefines!==a&&(this._cachedDefines=a,this._effect=this._scene.getEngine().createEffect("geometry",o,["world","mBones","viewProjection","diffuseMatrix","view"],["diffuseSampler"],a)),this._effect.isReady()},t.prototype.getGBuffer=function(){return this._multiRenderTarget},t.prototype.dispose=function(){this.getGBuffer().dispose()},t.prototype._createRenderTargets=function(){var t=this,i=this._scene.getEngine(),r=this._enablePosition?3:2;if(this._multiRenderTarget=new e.MultiRenderTarget("gBuffer",{width:i.getRenderWidth()*this._ratio,height:i.getRenderHeight()*this._ratio},r,this._scene,{generateMipMaps:!1,generateDepthTexture:!0}),!this.isSupported)return null;this._multiRenderTarget.wrapU=e.Texture.CLAMP_ADDRESSMODE,this._multiRenderTarget.wrapV=e.Texture.CLAMP_ADDRESSMODE,this._multiRenderTarget.refreshRate=1,this._multiRenderTarget.renderParticles=!1,this._multiRenderTarget.renderList=null,this._multiRenderTarget.onClearObservable.add((function(t){t.clear(new e.Color4(0,0,0,1),!0,!0,!0)}));var n=function(i){var r=i.getRenderingMesh(),n=t._scene,o=n.getEngine();o.setState(i.getMaterial().backFaceCulling);var s=r._getInstancesRenderList(i._id);if(!s.mustReturn){var a=o.getCaps().instancedArrays&&null!==s.visibleInstances[i._id];if(t.isReady(i,a)){o.enableEffect(t._effect),r._bind(i,t._effect,e.Material.TriangleFillMode);var h=i.getMaterial();if(t._effect.setMatrix("viewProjection",n.getTransformMatrix()),t._effect.setMatrix("view",n.getViewMatrix()),h&&h.needAlphaTesting()){var l=h.getAlphaTestTexture();t._effect.setTexture("diffuseSampler",l),t._effect.setMatrix("diffuseMatrix",l.getTextureMatrix())}r.useBones&&r.computeBonesUsingShaders&&t._effect.setMatrices("mBones",r.skeleton.getTransformMatrices(r)),r._processRendering(i,t._effect,e.Material.TriangleFillMode,s,a,(function(e,i){return t._effect.setMatrix("world",i)}))}}};this._multiRenderTarget.customRenderFunction=function(e,t){var i;for(i=0;i0&&-1!==this.excludedMeshes.indexOf(e)},i.prototype._createPass=function(t,i){var r=this,n=t.getEngine();this._volumetricLightScatteringRTT=new e.RenderTargetTexture("volumetricLightScatteringMap",{width:n.getRenderWidth()*i,height:n.getRenderHeight()*i},t,!1,!0,e.Engine.TEXTURETYPE_UNSIGNED_INT),this._volumetricLightScatteringRTT.wrapU=e.Texture.CLAMP_ADDRESSMODE,this._volumetricLightScatteringRTT.wrapV=e.Texture.CLAMP_ADDRESSMODE,this._volumetricLightScatteringRTT.renderList=null,this._volumetricLightScatteringRTT.renderParticles=!1,t.customRenderTargets.push(this._volumetricLightScatteringRTT);var o,s=function(t){var i=t.getRenderingMesh();if(!r._meshExcluded(i)){var n=i.getScene(),o=n.getEngine();o.setState(t.getMaterial().backFaceCulling);var s=i._getInstancesRenderList(t._id);if(!s.mustReturn){var a=o.getCaps().instancedArrays&&null!==s.visibleInstances[t._id];if(r.isReady(t,a)){var h=r._volumetricLightScatteringPass;if(i===r.mesh&&(h=t.effect?t.effect:t.getMaterial().getEffect()),o.enableEffect(h),i._bind(t,h,e.Material.TriangleFillMode),i===r.mesh)t.getMaterial().bind(i.getWorldMatrix(),i);else{var l=t.getMaterial();if(r._volumetricLightScatteringPass.setMatrix("viewProjection",n.getTransformMatrix()),l&&l.needAlphaTesting()){var c=l.getAlphaTestTexture();r._volumetricLightScatteringPass.setTexture("diffuseSampler",c),c&&r._volumetricLightScatteringPass.setMatrix("diffuseMatrix",c.getTextureMatrix())}i.useBones&&i.computeBonesUsingShaders&&r._volumetricLightScatteringPass.setMatrices("mBones",i.skeleton.getTransformMatrices(i))}i._processRendering(t,r._volumetricLightScatteringPass,e.Material.TriangleFillMode,s,a,(function(e,t){return h.setMatrix("world",t)}))}}}},a=new e.Color4(0,0,0,1);this._volumetricLightScatteringRTT.onBeforeRenderObservable.add((function(){o=t.clearColor,t.clearColor=a})),this._volumetricLightScatteringRTT.onAfterRenderObservable.add((function(){t.clearColor=o})),this._volumetricLightScatteringRTT.customRenderFunction=function(i,r,n){var o,a=t.getEngine();for(o=0;ot._alphaIndex?1:e._alphaIndext._distanceToCamera?-1:0})),a.setAlphaMode(e.Engine.ALPHA_COMBINE),o=0;o0)return Math.max(n,3)}return Math.max(t,3)},i.prototype._gaussianWeight=function(e){var t=Math.sqrt(2*Math.PI)*(1/3),i=-e*e/(1/3*2*(1/3));return 1/t*Math.exp(i)},i.prototype._glslFloat=function(e,t){return void 0===t&&(t=8),e.toFixed(t).replace(/0+$/,"")},i})(e.PostProcess);e.BlurPostProcess=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o,s){void 0===n&&(n=null);var a=t.call(this,i,r.getScene())||this;return a.name=i,a.children=new Array,a.animations=new Array,a._worldTransform=new e.Matrix,a._absoluteTransform=new e.Matrix,a._invertedAbsoluteTransform=new e.Matrix,a._scaleMatrix=e.Matrix.Identity(),a._scaleVector=e.Vector3.One(),a._negateScaleChildren=e.Vector3.One(),a._scalingDeterminant=1,a._skeleton=r,a._localMatrix=o||e.Matrix.Identity(),a._baseMatrix=a._localMatrix.clone(),a._restPose=s||a._localMatrix.clone(),r.bones.push(a),a.setParent(n,!1),a._updateDifferenceMatrix(),a}return __extends(i,t),Object.defineProperty(i.prototype,"_matrix",{get:function(){return this._localMatrix},set:function(e){this._localMatrix?this._localMatrix.copyFrom(e):this._localMatrix=e},enumerable:!0,configurable:!0}),i.prototype.getSkeleton=function(){return this._skeleton},i.prototype.getParent=function(){return this._parent},i.prototype.setParent=function(e,t){if(void 0===t&&(t=!0),this._parent!==e){if(this._parent){var i=this._parent.children.indexOf(this);-1!==i&&this._parent.children.splice(i)}this._parent=e,this._parent&&this._parent.children.push(this),t&&this._updateDifferenceMatrix()}},i.prototype.getLocalMatrix=function(){return this._localMatrix},i.prototype.getBaseMatrix=function(){return this._baseMatrix},i.prototype.getRestPose=function(){return this._restPose},i.prototype.returnToRest=function(){this.updateMatrix(this._restPose.clone())},i.prototype.getWorldMatrix=function(){return this._worldTransform},i.prototype.getInvertedAbsoluteTransform=function(){return this._invertedAbsoluteTransform},i.prototype.getAbsoluteTransform=function(){return this._absoluteTransform},Object.defineProperty(i.prototype,"position",{get:function(){return this.getPosition()},set:function(e){this.setPosition(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"rotation",{get:function(){return this.getRotation()},set:function(e){this.setRotation(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"rotationQuaternion",{get:function(){return this.getRotationQuaternion()},set:function(e){this.setRotationQuaternion(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"scaling",{get:function(){return this.getScale()},set:function(e){this.setScale(e.x,e.y,e.z)},enumerable:!0,configurable:!0}),i.prototype.updateMatrix=function(e,t){void 0===t&&(t=!0),this._baseMatrix=e.clone(),this._localMatrix=e.clone(),this._skeleton._markAsDirty(),t&&this._updateDifferenceMatrix()},i.prototype._updateDifferenceMatrix=function(e){e||(e=this._baseMatrix),this._parent?e.multiplyToRef(this._parent._absoluteTransform,this._absoluteTransform):this._absoluteTransform.copyFrom(e),this._absoluteTransform.invertToRef(this._invertedAbsoluteTransform);for(var t=0;t=c&&a.frame<=u&&(n?(l=a.value.clone(),_?(h=l.getTranslation(),l.setTranslation(h.scaleInPlace(g))):v?(h=l.getTranslation(),l.setTranslation(h.multiplyInPlace(o))):l=a.value):l=a.value,y.push({frame:a.frame+r,value:l}));return this.animations[0].createRange(i,c+r,u+r),!0},i.prototype.translate=function(t,r,n){void 0===r&&(r=e.Space.LOCAL);var o=this.getLocalMatrix();if(r==e.Space.LOCAL)o.m[12]+=t.x,o.m[13]+=t.y,o.m[14]+=t.z;else{var s;n&&(s=n.getWorldMatrix()),this._skeleton.computeAbsoluteTransforms();var a=i._tmpMats[0],h=i._tmpVecs[0];n?(a.copyFrom(this._parent.getAbsoluteTransform()),a.multiplyToRef(s,a)):a.copyFrom(this._parent.getAbsoluteTransform()),a.m[12]=0,a.m[13]=0,a.m[14]=0,a.invert(),e.Vector3.TransformCoordinatesToRef(t,a,h),o.m[12]+=h.x,o.m[13]+=h.y,o.m[14]+=h.z}this.markAsDirty()},i.prototype.setPosition=function(t,r,n){void 0===r&&(r=e.Space.LOCAL);var o=this.getLocalMatrix();if(r==e.Space.LOCAL)o.m[12]=t.x,o.m[13]=t.y,o.m[14]=t.z;else{var s;n&&(s=n.getWorldMatrix()),this._skeleton.computeAbsoluteTransforms();var a=i._tmpMats[0],h=i._tmpVecs[0];n?(a.copyFrom(this._parent.getAbsoluteTransform()),a.multiplyToRef(s,a)):a.copyFrom(this._parent.getAbsoluteTransform()),a.invert(),e.Vector3.TransformCoordinatesToRef(t,a,h),o.m[12]=h.x,o.m[13]=h.y,o.m[14]=h.z}this.markAsDirty()},i.prototype.setAbsolutePosition=function(t,i){this.setPosition(t,e.Space.WORLD,i)},i.prototype.setScale=function(e,t,i,r){void 0===r&&(r=!1),this.animations[0]&&!this.animations[0].isStopped()&&(r||(this._negateScaleChildren.x=1/e,this._negateScaleChildren.y=1/t,this._negateScaleChildren.z=1/i),this._syncScaleVector()),this.scale(e/this._scaleVector.x,t/this._scaleVector.y,i/this._scaleVector.z,r)},i.prototype.scale=function(t,r,n,o){void 0===o&&(o=!1);var s=this.getLocalMatrix(),a=i._tmpMats[0];a.copyFrom(s);var h=i._tmpMats[1];h.copyFrom(a),h.invert();var l=i._tmpMats[2];e.Matrix.FromValuesToRef(t,0,0,0,0,r,0,0,0,0,n,0,0,0,0,1,l),this._scaleMatrix.multiplyToRef(l,this._scaleMatrix),this._scaleVector.x*=t,this._scaleVector.y*=r,this._scaleVector.z*=n,s.multiplyToRef(h,s),s.multiplyToRef(l,s),s.multiplyToRef(a,s);var c=this.getParent();c?s.multiplyToRef(c.getAbsoluteTransform(),this.getAbsoluteTransform()):this.getAbsoluteTransform().copyFrom(s);var u=this.children.length;l.invert();for(var f=0;f0&&(this._rightHandedSystem=!0,this._bendAxis.x=0,this._bendAxis.y=0,this._bendAxis.z=-1,n.x>n.y&&n.x>n.z&&(this._adjustRoll=.5*Math.PI,this._bendAxis.z=1)),this._bone1.length){var o=this._bone1.getScale(),s=this._bone2.getScale();this._bone1Length=this._bone1.length*o.y*this.mesh.scaling.y,this._bone2Length=this._bone2.length*s.y*this.mesh.scaling.y}else if(this._bone1.children[0]){t.computeWorldMatrix(!0);var a=this._bone2.children[0].getAbsolutePosition(t),h=this._bone2.getAbsolutePosition(t),l=this._bone1.getAbsolutePosition(t);this._bone1Length=e.Vector3.Distance(a,h),this._bone2Length=e.Vector3.Distance(h,l)}this._bone1.getRotationMatrixToRef(e.Space.WORLD,t,this._bone1Mat),this.maxAngle=Math.PI,r&&(r.targetMesh&&(this.targetMesh=r.targetMesh,this.targetMesh.computeWorldMatrix(!0)),r.poleTargetMesh?(this.poleTargetMesh=r.poleTargetMesh,this.poleTargetMesh.computeWorldMatrix(!0)):r.poleTargetBone?this.poleTargetBone=r.poleTargetBone:this._bone1.getParent()&&(this.poleTargetBone=this._bone1.getParent()),r.poleTargetLocalOffset&&this.poleTargetLocalOffset.copyFrom(r.poleTargetLocalOffset),r.poleAngle&&(this.poleAngle=r.poleAngle),r.bendAxis&&this._bendAxis.copyFrom(r.bendAxis),r.maxAngle&&(this.maxAngle=r.maxAngle),r.slerpAmount&&(this.slerpAmount=r.slerpAmount))}return Object.defineProperty(t.prototype,"maxAngle",{get:function(){return this._maxAngle},set:function(e){this._setMaxAngle(e)},enumerable:!0,configurable:!0}),t.prototype._setMaxAngle=function(e){e<0&&(e=0),(e>Math.PI||void 0==e)&&(e=Math.PI),this._maxAngle=e;var t=this._bone1Length,i=this._bone2Length;this._maxReach=Math.sqrt(t*t+i*i-2*t*i*Math.cos(e))},t.prototype.update=function(){var i=this._bone1,r=this.targetPosition,n=this.poleTargetPosition,o=t._tmpMats[0],s=t._tmpMats[1];this.targetMesh&&r.copyFrom(this.targetMesh.getAbsolutePosition()),this.poleTargetBone?this.poleTargetBone.getAbsolutePositionFromLocalToRef(this.poleTargetLocalOffset,this.mesh,n):this.poleTargetMesh&&e.Vector3.TransformCoordinatesToRef(this.poleTargetLocalOffset,this.poleTargetMesh.getWorldMatrix(),n);var a=t._tmpVecs[0],h=t._tmpVecs[1],l=t._tmpVecs[2],c=t._tmpVecs[3],u=t._tmpVecs[4],f=t._tmpQuat;i.getAbsolutePositionToRef(this.mesh,a),n.subtractToRef(a,u),0==u.x&&0==u.y&&0==u.z?u.y=1:u.normalize(),r.subtractToRef(a,c),c.normalize(),e.Vector3.CrossToRef(c,u,h),h.normalize(),e.Vector3.CrossToRef(c,h,l),l.normalize(),e.Matrix.FromXYZAxesToRef(l,c,h,o);var d=this._bone1Length,p=this._bone2Length,m=e.Vector3.Distance(a,r);this._maxReach>0&&(m=Math.min(this._maxReach,m));var _=(p*p+m*m-d*d)/(2*p*m),g=(m*m+d*d-p*p)/(2*m*d);_>1&&(_=1),g>1&&(g=1),_<-1&&(_=-1),g<-1&&(g=-1);var v=Math.acos(_),y=Math.acos(g),x=-v-y;if(this._rightHandedSystem)e.Matrix.RotationYawPitchRollToRef(0,0,this._adjustRoll,s),s.multiplyToRef(o,o),e.Matrix.RotationAxisToRef(this._bendAxis,y,s),s.multiplyToRef(o,o);else{ -var b=t._tmpVecs[5];b.copyFrom(this._bendAxis),b.x*=-1,e.Matrix.RotationAxisToRef(b,-y,s),s.multiplyToRef(o,o)}this.poleAngle&&(e.Matrix.RotationAxisToRef(c,this.poleAngle,s),o.multiplyToRef(s,o)),this.slerpAmount<1?(this._slerping||e.Quaternion.FromRotationMatrixToRef(this._bone1Mat,this._bone1Quat),e.Quaternion.FromRotationMatrixToRef(o,f),e.Quaternion.SlerpToRef(this._bone1Quat,f,this.slerpAmount,this._bone1Quat),x=this._bone2Ang*(1-this.slerpAmount)+x*this.slerpAmount,this._bone1.setRotationQuaternion(this._bone1Quat,e.Space.WORLD,this.mesh),this._slerping=!0):(this._bone1.setRotationMatrix(o,e.Space.WORLD,this.mesh),this._bone1Mat.copyFrom(o),this._slerping=!1),this._bone2.setAxisAngle(this._bendAxis,x,e.Space.LOCAL),this._bone2Ang=x},t})();t._tmpVecs=[e.Vector3.Zero(),e.Vector3.Zero(),e.Vector3.Zero(),e.Vector3.Zero(),e.Vector3.Zero(),e.Vector3.Zero()],t._tmpQuat=e.Quaternion.Identity(),t._tmpMats=[e.Matrix.Identity(),e.Matrix.Identity()],e.BoneIKController=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t,i,r,n){if(this.upAxis=e.Vector3.Up(),this.upAxisSpace=e.Space.LOCAL,this.adjustYaw=0,this.adjustPitch=0,this.adjustRoll=0,this.slerpAmount=1,this._boneQuat=e.Quaternion.Identity(),this._slerping=!1,this._firstFrameSkipped=!1,this._fowardAxis=e.Vector3.Forward(),this.mesh=t,this.bone=i,this.target=r,n&&(n.adjustYaw&&(this.adjustYaw=n.adjustYaw),n.adjustPitch&&(this.adjustPitch=n.adjustPitch),n.adjustRoll&&(this.adjustRoll=n.adjustRoll),null!=n.maxYaw?this.maxYaw=n.maxYaw:this.maxYaw=Math.PI,null!=n.minYaw?this.minYaw=n.minYaw:this.minYaw=-Math.PI,null!=n.maxPitch?this.maxPitch=n.maxPitch:this.maxPitch=Math.PI,null!=n.minPitch?this.minPitch=n.minPitch:this.minPitch=-Math.PI,null!=n.slerpAmount&&(this.slerpAmount=n.slerpAmount),null!=n.upAxis&&(this.upAxis=n.upAxis),null!=n.upAxisSpace&&(this.upAxisSpace=n.upAxisSpace),null!=n.yawAxis||null!=n.pitchAxis)){var o=e.Axis.Y,s=e.Axis.X;null!=n.yawAxis&&(o=n.yawAxis.clone(),o.normalize()),null!=n.pitchAxis&&(s=n.pitchAxis.clone(),s.normalize());var a=e.Vector3.Cross(s,o);this._transformYawPitch=e.Matrix.Identity(),e.Matrix.FromXYZAxesToRef(s,o,a,this._transformYawPitch),this._transformYawPitchInv=this._transformYawPitch.clone(),this._transformYawPitch.invert()}i.getParent()||this.upAxisSpace!=e.Space.BONE||(this.upAxisSpace=e.Space.LOCAL)}return Object.defineProperty(t.prototype,"minYaw",{get:function(){return this._minYaw},set:function(e){this._minYaw=e,this._minYawSin=Math.sin(e),this._minYawCos=Math.cos(e),null!=this._maxYaw&&(this._midYawConstraint=.5*this._getAngleDiff(this._minYaw,this._maxYaw)+this._minYaw,this._yawRange=this._maxYaw-this._minYaw)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"maxYaw",{get:function(){return this._maxYaw},set:function(e){this._maxYaw=e,this._maxYawSin=Math.sin(e),this._maxYawCos=Math.cos(e),null!=this._minYaw&&(this._midYawConstraint=.5*this._getAngleDiff(this._minYaw,this._maxYaw)+this._minYaw,this._yawRange=this._maxYaw-this._minYaw)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"minPitch",{get:function(){return this._minPitch},set:function(e){this._minPitch=e,this._minPitchTan=Math.tan(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"maxPitch",{get:function(){return this._maxPitch},set:function(e){this._maxPitch=e,this._maxPitchTan=Math.tan(e)},enumerable:!0,configurable:!0}),t.prototype.update=function(){if(this.slerpAmount<1&&!this._firstFrameSkipped)return void(this._firstFrameSkipped=!0);var i=this.bone,r=t._tmpVecs[0];i.getAbsolutePositionToRef(this.mesh,r);var n=this.target,o=t._tmpMats[0],s=t._tmpMats[1],a=this.mesh,h=i.getParent(),l=t._tmpVecs[1];l.copyFrom(this.upAxis),this.upAxisSpace==e.Space.BONE?(this._transformYawPitch&&e.Vector3.TransformCoordinatesToRef(l,this._transformYawPitchInv,l),h.getDirectionToRef(l,this.mesh,l)):this.upAxisSpace==e.Space.LOCAL&&(a.getDirectionToRef(l,l),1==a.scaling.x&&1==a.scaling.y&&1==a.scaling.z||l.normalize());var c=!1,u=!1;if(this._maxYaw==Math.PI&&this._minYaw==-Math.PI||(c=!0),this._maxPitch==Math.PI&&this._minPitch==-Math.PI||(u=!0),c||u){var f=t._tmpMats[2],d=t._tmpMats[3];if(this.upAxisSpace==e.Space.BONE&&1==l.y)h.getRotationMatrixToRef(e.Space.WORLD,this.mesh,f);else if(this.upAxisSpace!=e.Space.LOCAL||1!=l.y||h){var p=t._tmpVecs[2];p.copyFrom(this._fowardAxis),this._transformYawPitch&&e.Vector3.TransformCoordinatesToRef(p,this._transformYawPitchInv,p),h?h.getDirectionToRef(p,this.mesh,p):a.getDirectionToRef(p,p);var m=e.Vector3.Cross(l,p);m.normalize();var p=e.Vector3.Cross(m,l);e.Matrix.FromXYZAxesToRef(m,l,p,f)}else f.copyFrom(a.getWorldMatrix());f.invertToRef(d);var _;if(u){var g=t._tmpVecs[3];n.subtractToRef(r,g),e.Vector3.TransformCoordinatesToRef(g,d,g);var _=Math.sqrt(g.x*g.x+g.z*g.z),v=Math.atan2(g.y,_),y=v;v>this._maxPitch?(g.y=this._maxPitchTan*_,y=this._maxPitch):vthis._maxYaw||xMath.PI?this._isAngleBetween(x,this._maxYaw,this._midYawConstraint)?(g.z=this._maxYawCos*_,g.x=this._maxYawSin*_,b=this._maxYaw):this._isAngleBetween(x,this._midYawConstraint,this._minYaw)&&(g.z=this._minYawCos*_,g.x=this._minYawSin*_,b=this._minYaw):x>this._maxYaw?(g.z=this._maxYawCos*_,g.x=this._maxYawSin*_,b=this._maxYaw):xMath.PI){var A=t._tmpVecs[8];A.copyFrom(e.Axis.Z),this._transformYawPitch&&e.Vector3.TransformCoordinatesToRef(A,this._transformYawPitchInv,A);var T=e.BoneLookController._tmpMats[4];this._boneQuat.toRotationMatrix(T),this.mesh.getWorldMatrix().multiplyToRef(T,T),e.Vector3.TransformCoordinatesToRef(A,T,A),e.Vector3.TransformCoordinatesToRef(A,d,A);var E=Math.atan2(A.x,A.z);if(this._getAngleBetween(E,x)>this._getAngleBetween(E,this._midYawConstraint)){null==_&&(_=Math.sqrt(g.x*g.x+g.z*g.z));var P=this._getAngleBetween(E,this._maxYaw);this._getAngleBetween(E,this._minYaw)Math.PI?i-=2*Math.PI:i<-Math.PI&&(i+=2*Math.PI),i},t.prototype._getAngleBetween=function(e,t){e%=2*Math.PI,e=e<0?e+2*Math.PI:e,t%=2*Math.PI,t=t<0?t+2*Math.PI:t;var i=0;return i=eMath.PI&&(i=2*Math.PI-i),i},t.prototype._isAngleBetween=function(e,t,i){if(e%=2*Math.PI,e=e<0?e+2*Math.PI:e,t%=2*Math.PI,t=t<0?t+2*Math.PI:t,i%=2*Math.PI,i=i<0?i+2*Math.PI:i,tt&&ei&&e-1&&this._meshesWithPoseMatrix.splice(t,1)},t.prototype._computeTransformMatrices=function(e,t){this.onBeforeComputeObservable.notifyObservers(this);for(var i=0;i0&&(r.animation=i.animations[0].serialize()),e.ranges=[];for(var n in this._ranges){var o={};o.name=n,o.from=this._ranges[n].from,o.to=this._ranges[n].to,e.ranges.push(o)}}return e},t.Parse=function(i,r){var n=new t(i.name,i.id,r);i.dimensionsAtRest&&(n.dimensionsAtRest=e.Vector3.FromArray(i.dimensionsAtRest)),n.needInitialSkinMatrix=i.needInitialSkinMatrix;var o;for(o=0;o-1&&(a=n.bones[s.parentBoneIndex]);var h=s.rest?e.Matrix.FromArray(s.rest):null,l=new e.Bone(s.name,n,a,e.Matrix.FromArray(s.matrix),h);s.length&&(l.length=s.length),s.animation&&l.animations.push(e.Animation.Parse(s.animation))}if(i.ranges)for(o=0;o0&&(e=this._meshesWithPoseMatrix[0].getPoseMatrix()),e},t})();e.Skeleton=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this.x=e.Vector3.Zero(),this.y=e.Vector3.Zero(),this.z=e.Vector3.Zero(),this.xx=e.Vector3.Zero(),this.yy=e.Vector3.Zero(),this.zz=e.Vector3.Zero(),this.xy=e.Vector3.Zero(),this.yz=e.Vector3.Zero(),this.zx=e.Vector3.Zero()}return t.prototype.addAmbient=function(t){var i=new e.Vector3(t.r,t.g,t.b);this.xx=this.xx.add(i),this.yy=this.yy.add(i),this.zz=this.zz.add(i)},t.getSphericalPolynomialFromHarmonics=function(e){var i=new t;return i.x=e.L11.scale(1.02333),i.y=e.L1_1.scale(1.02333),i.z=e.L10.scale(1.02333),i.xx=e.L00.scale(.886277).subtract(e.L20.scale(.247708)).add(e.L22.scale(.429043)),i.yy=e.L00.scale(.886277).subtract(e.L20.scale(.247708)).subtract(e.L22.scale(.429043)),i.zz=e.L00.scale(.886277).add(e.L20.scale(.495417)),i.yz=e.L2_1.scale(.858086),i.zx=e.L21.scale(.858086),i.xy=e.L2_2.scale(.858086),i.scale(1/Math.PI),i},t.prototype.scale=function(e){this.x=this.x.scale(e),this.y=this.y.scale(e),this.z=this.z.scale(e),this.xx=this.xx.scale(e),this.yy=this.yy.scale(e),this.zz=this.zz.scale(e),this.yz=this.yz.scale(e),this.zx=this.zx.scale(e),this.xy=this.xy.scale(e)},t})();e.SphericalPolynomial=t;var i=(function(){function t(){this.L00=e.Vector3.Zero(),this.L1_1=e.Vector3.Zero(),this.L10=e.Vector3.Zero(),this.L11=e.Vector3.Zero(),this.L2_2=e.Vector3.Zero(),this.L2_1=e.Vector3.Zero(),this.L20=e.Vector3.Zero(),this.L21=e.Vector3.Zero(),this.L22=e.Vector3.Zero()}return t.prototype.addLight=function(t,i,r){var n=new e.Vector3(i.r,i.g,i.b),o=n.scale(r);this.L00=this.L00.add(o.scale(.282095)),this.L1_1=this.L1_1.add(o.scale(.488603*t.y)),this.L10=this.L10.add(o.scale(.488603*t.z)),this.L11=this.L11.add(o.scale(.488603*t.x)),this.L2_2=this.L2_2.add(o.scale(1.092548*t.x*t.y)),this.L2_1=this.L2_1.add(o.scale(1.092548*t.y*t.z)),this.L21=this.L21.add(o.scale(1.092548*t.x*t.z)),this.L20=this.L20.add(o.scale(.315392*(3*t.z*t.z-1))),this.L22=this.L22.add(o.scale(.546274*(t.x*t.x-t.y*t.y)))},t.prototype.scale=function(e){this.L00=this.L00.scale(e),this.L1_1=this.L1_1.scale(e),this.L10=this.L10.scale(e),this.L11=this.L11.scale(e),this.L2_2=this.L2_2.scale(e),this.L2_1=this.L2_1.scale(e),this.L20=this.L20.scale(e),this.L21=this.L21.scale(e),this.L22=this.L22.scale(e)},t.prototype.convertIncidentRadianceToIrradiance=function(){this.L00=this.L00.scale(3.141593),this.L1_1=this.L1_1.scale(2.094395),this.L10=this.L10.scale(2.094395),this.L11=this.L11.scale(2.094395),this.L2_2=this.L2_2.scale(.785398),this.L2_1=this.L2_1.scale(.785398),this.L20=this.L20.scale(.785398),this.L21=this.L21.scale(.785398),this.L22=this.L22.scale(.785398)},t.prototype.convertIrradianceToLambertianRadiance=function(){this.scale(1/Math.PI)},t.getsphericalHarmonicsFromPolynomial=function(e){var i=new t;return i.L00=e.xx.scale(.376127).add(e.yy.scale(.376127)).add(e.zz.scale(.376126)),i.L1_1=e.y.scale(.977204),i.L10=e.z.scale(.977204),i.L11=e.x.scale(.977204),i.L2_2=e.xy.scale(1.16538),i.L2_1=e.yz.scale(1.16538),i.L20=e.zz.scale(1.34567).subtract(e.xx.scale(.672834)).subtract(e.yy.scale(.672834)),i.L21=e.zx.scale(1.16538),i.L22=e.xx.scale(1.16538).subtract(e.yy.scale(1.16538)),i.scale(Math.PI),i},t})();e.SphericalHarmonics=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){var i=(function(){function e(e,t,i,r){this.name=e,this.worldAxisForNormal=t,this.worldAxisForFileX=i,this.worldAxisForFileY=r}return e})(),r=(function(){function t(){}return t.ConvertCubeMapTextureToSphericalPolynomial=function(t){if(!t.isCube)return null;var i,r,n=t.getSize().width,o=t.readPixels(0),s=t.readPixels(1);t.isRenderTarget?(i=t.readPixels(3),r=t.readPixels(2)):(i=t.readPixels(2),r=t.readPixels(3));var a=t.readPixels(4),h=t.readPixels(5),l=t.gammaSpace,c=e.Engine.TEXTUREFORMAT_RGBA,u=e.Engine.TEXTURETYPE_UNSIGNED_INT;t.textureType&&t.textureType!==e.Engine.TEXTURETYPE_UNSIGNED_INT&&(u=e.Engine.TEXTURETYPE_FLOAT);var f={size:n,right:o,left:s,up:i,down:r,front:a,back:h,format:c,type:u,gammaSpace:l};return this.ConvertCubeMapToSphericalPolynomial(f)},t.ConvertCubeMapToSphericalPolynomial=function(t){for(var i=new e.SphericalHarmonics,r=0,n=2/t.size,o=n,s=.5*n-1,a=0;a<6;a++)for(var h=this.FileFaces[a],l=t[h.name],c=s,u=t.format===e.Engine.TEXTUREFORMAT_RGBA?4:3,f=0;fMath.PI;)n-=2*Math.PI;var s=n/Math.PI,a=o/Math.PI;s=.5*s+.5;var h=Math.round(s*i);h<0?h=0:h>=i&&(h=i-1);var l=Math.round(a*r);l<0?l=0:l>=r&&(l=r-1);var c=r-l-1;return{r:t[c*i*3+3*h+0],g:t[c*i*3+3*h+1],b:t[c*i*3+3*h+2]}},t})();i.FACE_FRONT=[new e.Vector3(-1,-1,-1),new e.Vector3(1,-1,-1),new e.Vector3(-1,1,-1),new e.Vector3(1,1,-1)],i.FACE_BACK=[new e.Vector3(1,-1,1),new e.Vector3(-1,-1,1),new e.Vector3(1,1,1),new e.Vector3(-1,1,1)],i.FACE_RIGHT=[new e.Vector3(1,-1,-1),new e.Vector3(1,-1,1),new e.Vector3(1,1,-1),new e.Vector3(1,1,1)],i.FACE_LEFT=[new e.Vector3(-1,-1,1),new e.Vector3(-1,-1,-1),new e.Vector3(-1,1,1),new e.Vector3(-1,1,-1)],i.FACE_DOWN=[new e.Vector3(-1,1,-1),new e.Vector3(1,1,-1),new e.Vector3(-1,1,1),new e.Vector3(1,1,1)],i.FACE_UP=[new e.Vector3(-1,-1,1),new e.Vector3(1,-1,1),new e.Vector3(-1,-1,-1),new e.Vector3(1,-1,-1)],t.PanoramaToCubeMapTools=i})(e.Internals||(e.Internals={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(e){var t=(function(){function t(){}return t.Ldexp=function(e,t){return t>1023?e*Math.pow(2,1023)*Math.pow(2,t-1023):t<-1074?e*Math.pow(2,-1074)*Math.pow(2,t+1074):e*Math.pow(2,t)},t.Rgbe2float=function(e,t,i,r,n,o){n>0?(n=this.Ldexp(1,n-136),e[o+0]=t*n,e[o+1]=i*n,e[o+2]=r*n):(e[o+0]=0,e[o+1]=0,e[o+2]=0)},t.readStringLine=function(e,t){for(var i="",r="",n=t;n32767)throw"HDR Bad header format, unsupported size";return s+=r.length+1,{height:t,width:i,dataPosition:s}},t.GetCubeMapTextureData=function(t,i){var r=new Uint8Array(t),n=this.RGBE_ReadHeader(r),o=this.RGBE_ReadPixels_RLE(r,n);return e.PanoramaToCubeMapTools.ConvertPanoramaToCubemap(o,n.width,n.height,i)},t.RGBE_ReadPixels=function(e,t){return this.RGBE_ReadPixels_RLE(e,t)},t.RGBE_ReadPixels_RLE=function(e,t){for(var i,r,n,o,s,a=t.height,h=t.width,l=t.dataPosition,c=0,u=0,f=0,d=new ArrayBuffer(4*h),p=new Uint8Array(d),m=new ArrayBuffer(t.width*t.height*4*3),_=new Float32Array(m);a>0;){if(i=e[l++],r=e[l++],n=e[l++],o=e[l++],2!=i||2!=r||128&n)throw"HDR Bad header format, not RLE";if((n<<8|o)!=h)throw"HDR Bad header format, wrong scan line width";for(c=0,f=0;f<4;f++)for(u=(f+1)*h;c128){if(0==(s=i-128)||s>u-c)throw"HDR Bad Format, bad scanline data (run)";for(;s-- >0;)p[c++]=r}else{if(0==(s=i)||s>u-c)throw"HDR Bad Format, bad scanline data (non-run)";if(p[c++]=r,--s>0)for(var g=0;g>s,2),h=0;h<6;h++){var l=r.subarray(o,o+a);n[s].push(l),o+=a}}return n}:null,o=function(o){var s=new Int32Array(o);r=new Float32Array(o);var a=s[0];t._size=s[1],t.getScene().getEngine().updateTextureSize(t._texture,t._size,t._size);var h=new e.SphericalPolynomial;h.x.copyFromFloats(r[2],r[3],r[4]),h.y.copyFromFloats(r[5],r[6],r[7]),h.z.copyFromFloats(r[8],r[9],r[10]),h.xx.copyFromFloats(r[11],r[12],r[13]),h.yy.copyFromFloats(r[14],r[15],r[16]),h.zz.copyFromFloats(r[17],r[18],r[19]),h.xy.copyFromFloats(r[20],r[21],r[22]),h.yz.copyFromFloats(r[23],r[24],r[25]),h.zx.copyFromFloats(r[26],r[27],r[28]),t.sphericalPolynomial=h,i=s[29];for(var l=30,c=[],u=3*Math.pow(t._size,2),f=0;f<6;f++)c.push(r.subarray(l,l+u)),l+=u;for(var d=[],p=null,m=0;m<6;m++){var _=null;if(1===a){_=c[[0,2,4,1,3,5][m]]}if(!n){if(!t.getScene().getEngine().getCaps().textureFloat){var g=new ArrayBuffer(u);p=new Uint8Array(g)}for(var v=0;v255){var T=255/A;y*=T,x*=T,b*=T}p[3*v+0]=y,p[3*v+1]=x,p[3*v+2]=b}}p?d.push(p):d.push(_)}return d};this._texture=this.getScene().getEngine().createRawCubeTextureFromUrl(this.url,this.getScene(),this._size,e.Engine.TEXTUREFORMAT_RGB,this.getScene().getEngine().getCaps().textureFloat?e.Engine.TEXTURETYPE_FLOAT:e.Engine.TEXTURETYPE_UNSIGNED_INT,this._noMipmap,o,n,this._onLoad,this._onError)},i.prototype.loadHDRTexture=function(){var t=this,r=function(r){var n=e.Internals.HDRTools.GetCubeMapTextureData(r,t._size);if(t._generateHarmonics){var o=e.Internals.CubeMapToSphericalPolynomialTools.ConvertCubeMapToSphericalPolynomial(n);t.sphericalPolynomial=o}for(var s=[],a=null,h=0;h<6;h++){if(!t.getScene().getEngine().getCaps().textureFloat){var l=new ArrayBuffer(t._size*t._size*3);a=new Uint8Array(l)}var c=n[i._facesMapping[h]];if(t._useInGammaSpace||a)for(var u=0;u255){var _=255/m;f*=_,d*=_,p*=_}a[3*u+0]=f,a[3*u+1]=d,a[3*u+2]=p}a?s.push(a):s.push(c)}return s};this._texture=this.getScene().getEngine().createRawCubeTextureFromUrl(this.url,this.getScene(),this._size,e.Engine.TEXTUREFORMAT_RGB,this.getScene().getEngine().getCaps().textureFloat?e.Engine.TEXTURETYPE_FLOAT:e.Engine.TEXTURETYPE_UNSIGNED_INT,this._noMipmap,r,null,this._onLoad,this._onError)},i.prototype.loadTexture=function(){this._isBABYLONPreprocessed?this.loadBabylonTexture():this.loadHDRTexture()},i.prototype.clone=function(){var e=this._isBABYLONPreprocessed?null:this._size,t=new i(this.url,this.getScene(),e,this._noMipmap,this._generateHarmonics,this._useInGammaSpace,this._usePMREMGenerator);return t.level=this.level,t.wrapU=this.wrapU,t.wrapV=this.wrapV,t.coordinatesIndex=this.coordinatesIndex,t.coordinatesMode=this.coordinatesMode,t},i.prototype.delayLoad=function(){this.delayLoadState===e.Engine.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=e.Engine.DELAYLOADSTATE_LOADED,this._texture=this._getFromCache(this.url,this._noMipmap),this._texture||this.loadTexture())},i.prototype.getReflectionTextureMatrix=function(){return this._textureMatrix},i.prototype.setReflectionTextureMatrix=function(e){this._textureMatrix=e},i.Parse=function(t,i,r){var n=null;if(t.name&&!t.isRenderTarget){var o=t.isBABYLONPreprocessed?null:t.size;n=new e.HDRCubeTexture(r+t.name,i,o,t.noMipmap,t.generateHarmonics,t.useInGammaSpace,t.usePMREMGenerator),n.name=t.name,n.hasAlpha=t.hasAlpha,n.level=t.level,n.coordinatesMode=t.coordinatesMode,n.isBlocking=t.isBlocking}return n},i.prototype.serialize=function(){if(!this.name)return null;var e={};return e.name=this.name,e.hasAlpha=this.hasAlpha,e.isCube=!0,e.level=this.level,e.size=this._size,e.coordinatesMode=this.coordinatesMode,e.useInGammaSpace=this._useInGammaSpace,e.generateHarmonics=this._generateHarmonics,e.usePMREMGenerator=this._usePMREMGenerator,e.isBABYLONPreprocessed=this._isBABYLONPreprocessed,e.customType="BABYLON.HDRCubeTexture",e.noMipmap=this._noMipmap,e.isBlocking=this._isBlocking,e},i.generateBabylonHDROnDisk=function(e,t,r){void 0===r&&(r=null);var n=function(e){var t=new Blob([e],{type:"application/octet-stream"}),i=window.URL.createObjectURL(t),r=document.createElement("a");document.body.appendChild(r),r.style.display="none",r.href=i,r.download="envmap.babylon.hdr",r.click()};i.generateBabylonHDR(e,t,n,r)},i.generateBabylonHDR=function(t,i,r,n){return void 0===n&&(n=null),t&&e.Tools.IsExponentOfTwo(i)?(e.Tools.Error("Generation of Babylon HDR is coming back in 3.1."),null):null},i})(e.BaseTexture) -;t._facesMapping=["right","left","up","down","front","back"],e.HDRCubeTexture=t})(BABYLON||(BABYLON={}));var Earcut;!(function(e){function t(e,t,r){r=r||2;var o=t&&t.length,s=o?t[0]*r:e.length,a=i(e,0,s,r,!0),h=[];if(!a)return h;var c,u,f,d,p,m,_;if(o&&(a=l(e,t,a,r)),e.length>80*r){c=f=e[0],u=d=e[1];for(var g=r;gf&&(f=p),m>d&&(d=m);_=Math.max(f-c,d-u)}return n(a,h,r,c,u,_,void 0),h}function i(e,t,i,r,n){var o,s;if(n===O(e,t,i,r)>0)for(o=t;o=t;o-=r)s=M(o,e[o],e[o+1],s);return s&&x(s,s.next)&&(S(s),s=s.next),s}function r(e,t){if(!e)return e;t||(t=e);var i,r=e;do{if(i=!1,r.steiner||!x(r,r.next)&&0!==y(r.prev,r,r.next))r=r.next;else{if(S(r),(r=t=r.prev)===r.next)return null;i=!0}}while(i||r!==t);return t}function n(e,t,i,l,c,u,f){if(e){!f&&u&&d(e,l,c,u);for(var p,m,_=e;e.prev!==e.next;)if(p=e.prev,m=e.next,u?s(e,l,c,u):o(e))t.push(p.i/i),t.push(e.i/i),t.push(m.i/i),S(e),e=m.next,_=m.next;else if((e=m)===_){f?1===f?(e=a(e,t,i),n(e,t,i,l,c,u,2)):2===f&&h(e,t,i,l,c,u):n(r(e,void 0),t,i,l,c,u,1);break}}}function o(e){var t=e.prev,i=e,r=e.next;if(y(t,i,r)>=0)return!1;for(var n=e.next.next;n!==e.prev;){if(g(t.x,t.y,i.x,i.y,r.x,r.y,n.x,n.y)&&y(n.prev,n,n.next)>=0)return!1;n=n.next}return!0}function s(e,t,i,r){var n=e.prev,o=e,s=e.next;if(y(n,o,s)>=0)return!1;for(var a=n.xo.x?n.x>s.x?n.x:s.x:o.x>s.x?o.x:s.x,c=n.y>o.y?n.y>s.y?n.y:s.y:o.y>s.y?o.y:s.y,u=m(a,h,t,i,r),f=m(l,c,t,i,r),d=e.nextZ;d&&d.z<=f;){if(d!==e.prev&&d!==e.next&&g(n.x,n.y,o.x,o.y,s.x,s.y,d.x,d.y)&&y(d.prev,d,d.next)>=0)return!1;d=d.nextZ}for(d=e.prevZ;d&&d.z>=u;){if(d!==e.prev&&d!==e.next&&g(n.x,n.y,o.x,o.y,s.x,s.y,d.x,d.y)&&y(d.prev,d,d.next)>=0)return!1;d=d.prevZ}return!0}function a(e,t,i){var r=e;do{var n=r.prev,o=r.next.next;!x(n,o)&&b(n,r,r.next,o)&&T(n,o)&&T(o,n)&&(t.push(n.i/i),t.push(r.i/i),t.push(o.i/i),S(r),S(r.next),r=e=o),r=r.next}while(r!==e);return r}function h(e,t,i,o,s,a){var h=e;do{for(var l=h.next.next;l!==h.prev;){if(h.i!==l.i&&v(h,l)){var c=P(h,l);return h=r(h,h.next),c=r(c,c.next),n(h,t,i,o,s,a,void 0),void n(c,t,i,o,s,a,void 0)}l=l.next}h=h.next}while(h!==e)}function l(e,t,n,o){var s,a,h,l,f,d=[];for(s=0,a=t.length;s=r.next.y){var a=r.x+(o-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(a<=n&&a>s){if(s=a,a===n){if(o===r.y)return r;if(o===r.next.y)return r.next}i=r.x=r.x&&r.x>=c&&g(oi.x)&&T(r,e)&&(i=r,f=h),r=r.next;return i}function d(e,t,i,r){var n=e;do{null===n.z&&(n.z=m(n.x,n.y,t,i,r)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next}while(n!==e);n.prevZ.nextZ=null,n.prevZ=null,p(n)}function p(e){var t,i,r,n,o,s,a,h,l=1;do{for(i=e,e=null,o=null,s=0;i;){for(s++,r=i,a=0,t=0;t0||h>0&&r;)0===a?(n=r,r=r.nextZ,h--):0!==h&&r?i.z<=r.z?(n=i,i=i.nextZ,a--):(n=r,r=r.nextZ,h--):(n=i,i=i.nextZ,a--),o?o.nextZ=n:e=n,n.prevZ=o,o=n;i=r}o.nextZ=null,l*=2}while(s>1);return e}function m(e,t,i,r,n){return e=32767*(e-i)/n,t=32767*(t-r)/n,e=16711935&(e|e<<8),e=252645135&(e|e<<4),e=858993459&(e|e<<2),e=1431655765&(e|e<<1),t=16711935&(t|t<<8),t=252645135&(t|t<<4),t=858993459&(t|t<<2),t=1431655765&(t|t<<1),e|t<<1}function _(e){var t=e,i=e;do{t.x=0&&(e-s)*(r-a)-(i-s)*(t-a)>=0&&(i-s)*(o-a)-(n-s)*(r-a)>=0}function v(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!A(e,t)&&T(e,t)&&T(t,e)&&E(e,t)}function y(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function x(e,t){return e.x===t.x&&e.y===t.y}function b(e,t,i,r){return!!(x(e,t)&&x(i,r)||x(e,r)&&x(i,t))||y(e,t,i)>0!=y(e,t,r)>0&&y(i,r,e)>0!=y(i,r,t)>0}function A(e,t){var i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&b(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}function T(e,t){return y(e.prev,e,e.next)<0?y(e,t,e.next)>=0&&y(e,e.prev,t)>=0:y(e,t,e.prev)<0||y(e,e.next,t)<0}function E(e,t){var i=e,r=!1,n=(e.x+t.x)/2,o=(e.y+t.y)/2;do{i.y>o!=i.next.y>o&&n<(i.next.x-i.x)*(o-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next}while(i!==e);return r}function P(e,t){var i=new C(e.i,e.x,e.y),r=new C(t.i,t.x,t.y),n=e.next,o=t.prev;return e.next=t,t.prev=e,i.next=n,n.prev=i,r.next=i,i.prev=r,o.next=r,r.prev=o,r}function M(e,t,i,r){var n=new C(e,t,i);return r?(n.next=r.next,n.prev=r,r.next.prev=n,r.next=n):(n.prev=n,n.next=n),n}function S(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function C(e,t,i){this.i=e,this.x=t,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function R(e,t,i,r){var n=t&&t.length,o=n?t[0]*i:e.length,s=Math.abs(O(e,0,o,i));if(n)for(var a=0,h=t.length;a0&&(r+=e[n-1].length,i.holes.push(r))}return i}e.earcut=t,e.deviation=R,e.flatten=I})(Earcut||(Earcut={}));var BABYLON;!(function(e){var t=(function(e){function t(t,i){var r=e.call(this,t.x,t.y)||this;return r.index=i,r}return __extends(t,e),t})(e.Vector2),i=(function(){function i(){this.elements=new Array}return i.prototype.add=function(e){var i=this,r=new Array;return e.forEach((function(e){if(0===r.length||!e.equalsWithEpsilon(r[0])){var n=new t(e,i.elements.length);r.push(n),i.elements.push(n)}})),r},i.prototype.computeBounds=function(){var t=new e.Vector2(this.elements[0].x,this.elements[0].y),i=new e.Vector2(this.elements[0].x,this.elements[0].y);return this.elements.forEach((function(e){e.xi.x&&(i.x=e.x),e.yi.y&&(i.y=e.y)})),{min:t,max:i,width:i.x-t.x,height:i.y-t.y}},i})(),r=(function(){function t(){}return t.Rectangle=function(t,i,r,n){return[new e.Vector2(t,i),new e.Vector2(r,i),new e.Vector2(r,n),new e.Vector2(t,n)]},t.Circle=function(t,i,r,n){void 0===i&&(i=0),void 0===r&&(r=0),void 0===n&&(n=32);for(var o=new Array,s=0,a=2*Math.PI/n,h=0;h0){var f=s.length/3;this._points.elements.forEach((function(e){o.push(0,-1,0),s.push(e.x,-i,e.y),a.push(1-(e.x-h.min.x)/h.width,1-(e.y-h.min.y)/h.height)}));for(var d=l.length,u=0;us.elements.length-1?s.elements[0]:s.elements[u+1],t.push(d.x,0,d.y),t.push(d.x,-a,d.y),t.push(f.x,0,f.y),t.push(f.x,-a,f.y);var p=new e.Vector3(d.x,0,d.y),m=new e.Vector3(f.x,0,f.y),_=m.subtract(p),g=new e.Vector3(0,1,0),v=e.Vector3.Cross(_,g);v=v.normalize(),r.push(c/o.width,0),r.push(c/o.width,1),c+=_.length(),r.push(c/o.width,0),r.push(c/o.width,1),h?(i.push(v.x,v.y,v.z),i.push(v.x,v.y,v.z),i.push(v.x,v.y,v.z),i.push(v.x,v.y,v.z),n.push(l),n.push(l+2),n.push(l+1),n.push(l+1),n.push(l+2),n.push(l+3)):(i.push(-v.x,-v.y,-v.z),i.push(-v.x,-v.y,-v.z),i.push(-v.x,-v.y,-v.z),i.push(-v.x,-v.y,-v.z),n.push(l),n.push(l+1),n.push(l+2),n.push(l+1),n.push(l+3),n.push(l+2)),l+=4}},t})();e.PolygonMeshBuilder=n})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=0,i=(function(){function t(e,t,i){this.pos=e,this.normal=t,this.uv=i}return t.prototype.clone=function(){return new t(this.pos.clone(),this.normal.clone(),this.uv.clone())},t.prototype.flip=function(){this.normal=this.normal.scale(-1)},t.prototype.interpolate=function(i,r){return new t(e.Vector3.Lerp(this.pos,i.pos,r),e.Vector3.Lerp(this.normal,i.normal,r),e.Vector2.Lerp(this.uv,i.uv,r))},t})(),r=(function(){function t(e,t){this.normal=e,this.w=t}return t.FromPoints=function(i,r,n){var o=n.subtract(i),s=r.subtract(i);if(0===o.lengthSquared()||0===s.lengthSquared())return null;var a=e.Vector3.Normalize(e.Vector3.Cross(o,s));return new t(a,e.Vector3.Dot(a,i))},t.prototype.clone=function(){return new t(this.normal.clone(),this.w)},t.prototype.flip=function(){this.normal.scaleInPlace(-1),this.w=-this.w},t.prototype.splitPolygon=function(i,r,o,s,a){var h,l,c=0,u=[];for(h=0;ht.EPSILON?1:0;c|=f,u.push(f)}switch(c){case 0:(e.Vector3.Dot(this.normal,i.plane.normal)>0?r:o).push(i);break;case 1:s.push(i);break;case 2:a.push(i);break;case 3:var d=[],p=[];for(h=0;h=3&&(b=new n(d,i.shared),b.plane&&s.push(b)),p.length>=3&&(b=new n(p,i.shared),b.plane&&a.push(b))}},t})();r.EPSILON=1e-5;var n=(function(){function e(e,t){this.vertices=e,this.shared=t,this.plane=r.FromPoints(e[0].pos,e[1].pos,e[2].pos)}return e.prototype.clone=function(){return new e(this.vertices.map((function(e){return e.clone()})),this.shared)},e.prototype.flip=function(){this.vertices.reverse().map((function(e){e.flip()})),this.plane.flip()},e})(),o=(function(){function e(e){this.plane=null,this.front=null,this.back=null,this.polygons=[],e&&this.build(e)}return e.prototype.clone=function(){var t=new e;return t.plane=this.plane&&this.plane.clone(),t.front=this.front&&this.front.clone(),t.back=this.back&&this.back.clone(),t.polygons=this.polygons.map((function(e){return e.clone()})),t},e.prototype.invert=function(){for(var e=0;e0&&(t.x-=this.viewportBorder,t.y-=this.viewportBorder,t.width+=2*this.viewportBorder,t.height+=2*this.viewportBorder,i.x+=this.viewportBorder,i.y+=this.viewportBorder,this._positionX+=this.viewportBorder,this._positionY+=this.viewportBorder),i.z>0&&(this._positionX>t.x&&this._positionXt.y&&(this._positionY,t.y,t.height),!0)},t.prototype._isVisible=function(){if(!this._isEnabled)return!1;var t=this.getEmitterPosition(),i=t.subtract(this._scene.activeCamera.globalPosition),r=i.length();i.normalize();var n=new e.Ray(this._scene.activeCamera.globalPosition,i),o=this._scene.pickWithRay(n,this.meshesSelectionPredicate,!0);return!o.hit||o.distance>r},t.prototype.render=function(){if(!this._effect.isReady())return!1;var t=this._scene.getEngine(),i=this._scene.activeCamera.viewport,r=i.toGlobal(t.getRenderWidth(!0),t.getRenderHeight(!0));if(!this.computeEffectivePosition(r))return!1;if(!this._isVisible())return!1;var n,o;n=this._positionXr.x+r.width-this.borderLimit?this._positionX-r.x-r.width+this.borderLimit:0,o=this._positionYr.y+r.height-this.borderLimit?this._positionY-r.y-r.height+this.borderLimit:0;var s=n>o?n:o;(s-=this.viewportBorder)>this.borderLimit&&(s=this.borderLimit);var a=1-s/this.borderLimit;if(a<0)return!1;a>1&&(a=1),this.viewportBorder>0&&(r.x+=this.viewportBorder,r.y+=this.viewportBorder,r.width-=2*this.viewportBorder,r.height-=2*this.viewportBorder,this._positionX-=this.viewportBorder,this._positionY-=this.viewportBorder);var h=r.x+r.width/2,l=r.y+r.height/2,c=h-this._positionX,u=l-this._positionY;t.enableEffect(this._effect),t.setState(!1),t.setDepthBuffer(!1),t.bindBuffers(this._vertexBuffers,this._indexBuffer,this._effect);for(var f=0;f-1?this._onBeforePhysicsStepCallbacks.splice(i,1):e.Tools.Warn("Function to remove was not found")},t.prototype.registerAfterPhysicsStep=function(e){this._onAfterPhysicsStepCallbacks.push(e)},t.prototype.unregisterAfterPhysicsStep=function(t){var i=this._onAfterPhysicsStepCallbacks.indexOf(t);i>-1?this._onAfterPhysicsStepCallbacks.splice(i,1):e.Tools.Warn("Function to remove was not found")},t.prototype.registerOnPhysicsCollide=function(e,t){var i=e instanceof Array?e:[e] -;this._onPhysicsCollideCallbacks.push({callback:t,otherImpostors:i})},t.prototype.unregisterOnPhysicsCollide=function(t,i){var r=t instanceof Array?t:[t],n=this._onPhysicsCollideCallbacks.indexOf({callback:i,otherImpostors:r});n>-1?this._onPhysicsCollideCallbacks.splice(n,1):e.Tools.Warn("Function to remove was not found")},t.prototype.applyForce=function(e,t){this._physicsEngine.getPhysicsPlugin().applyForce(this,e,t)},t.prototype.applyImpulse=function(e,t){this._physicsEngine.getPhysicsPlugin().applyImpulse(this,e,t)},t.prototype.createJoint=function(t,i,r){var n=new e.PhysicsJoint(i,r);this.addJoint(t,n)},t.prototype.addJoint=function(e,t){this._joints.push({otherImpostor:e,joint:t}),this._physicsEngine.addJoint(this,e,t)},t.prototype.sleep=function(){this._physicsEngine.getPhysicsPlugin().sleepBody(this)},t.prototype.wakeUp=function(){this._physicsEngine.getPhysicsPlugin().wakeUpBody(this)},t.prototype.clone=function(e){return e?new t(e,this.type,this._options,this._scene):null},t.prototype.dispose=function(){var e=this;this._physicsEngine&&(this._joints.forEach((function(t){e._physicsEngine.removeJoint(e,t.otherImpostor,t.joint)})),this._physicsEngine.removeImpostor(this),this.parent&&this.parent.forceUpdate(),this._isDisposed=!0)},t.prototype.setDeltaPosition=function(e){this._deltaPosition.copyFrom(e)},t.prototype.setDeltaRotation=function(t){this._deltaRotation||(this._deltaRotation=new e.Quaternion),this._deltaRotation.copyFrom(t),this._deltaRotationConjugated=this._deltaRotation.conjugate()},t.prototype.getBoxSizeToRef=function(e){this._physicsEngine.getPhysicsPlugin().getBoxSizeToRef(this,e)},t.prototype.getRadius=function(){return this._physicsEngine.getPhysicsPlugin().getRadius(this)},t.prototype.syncBoneWithImpostor=function(i,r,n,o,s){var a=t._tmpVecs[0],h=this.object;if(s){var l=t._tmpQuat;h.rotationQuaternion.multiplyToRef(s,l),i.setRotationQuaternion(l,e.Space.WORLD,r)}else i.setRotationQuaternion(h.rotationQuaternion,e.Space.WORLD,r);a.x=0,a.y=0,a.z=0,n&&(a.x=n.x,a.y=n.y,a.z=n.z,i.getDirectionToRef(a,r,a),void 0!==o&&null!==o||(o=n.length()),a.x*=o,a.y*=o,a.z*=o),i.getParent()?(a.addInPlace(h.getAbsolutePosition()),i.setAbsolutePosition(a,r)):(r.setAbsolutePosition(h.getAbsolutePosition()),r.position.x-=a.x,r.position.y-=a.y,r.position.z-=a.z)},t.prototype.syncImpostorWithBone=function(i,r,n,o,s,a){var h=this.object;if(s){var l=t._tmpQuat;i.getRotationQuaternionToRef(e.Space.WORLD,r,l),l.multiplyToRef(s,h.rotationQuaternion)}else i.getRotationQuaternionToRef(e.Space.WORLD,r,h.rotationQuaternion);var c=t._tmpVecs[0],u=t._tmpVecs[1];a||(a=t._tmpVecs[2],a.x=0,a.y=1,a.z=0),i.getDirectionToRef(a,r,u),i.getAbsolutePositionToRef(r,c),void 0!==o&&null!==o||!n||(o=n.length()),void 0!==o&&null!==o&&(c.x+=u.x*o,c.y+=u.y*o,c.z+=u.z*o),h.setAbsolutePosition(c)},t})();t.DEFAULT_OBJECT_SIZE=new e.Vector3(1,1,1),t.IDENTITY_QUATERNION=e.Quaternion.Identity(),t._tmpVecs=[e.Vector3.Zero(),e.Vector3.Zero(),e.Vector3.Zero()],t._tmpQuat=e.Quaternion.Identity(),t.NoImpostor=0,t.SphereImpostor=1,t.BoxImpostor=2,t.PlaneImpostor=3,t.MeshImpostor=4,t.CylinderImpostor=7,t.ParticleImpostor=8,t.HeightmapImpostor=9,e.PhysicsImpostor=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t,i){if(void 0===i&&(i=new e.CannonJSPlugin),this._physicsPlugin=i,this._impostors=[],this._joints=[],!this._physicsPlugin.isSupported())throw new Error("Physics Engine "+this._physicsPlugin.name+" cannot be found. Please make sure it is included.");t=t||new e.Vector3(0,-9.807,0),this.setGravity(t),this.setTimeStep()}return t.prototype.setGravity=function(e){this.gravity=e,this._physicsPlugin.setGravity(this.gravity)},t.prototype.setTimeStep=function(e){void 0===e&&(e=1/60),this._physicsPlugin.setTimeStep(e)},t.prototype.dispose=function(){this._impostors.forEach((function(e){e.dispose()})),this._physicsPlugin.dispose()},t.prototype.getPhysicsPluginName=function(){return this._physicsPlugin.name},t.prototype.addImpostor=function(e){e.uniqueId=this._impostors.push(e),e.parent||this._physicsPlugin.generatePhysicsBody(e)},t.prototype.removeImpostor=function(e){var t=this._impostors.indexOf(e);if(t>-1){var i=this._impostors.splice(t,1);i.length&&(i[0].physicsBody=null)}},t.prototype.addJoint=function(e,t,i){var r={mainImpostor:e,connectedImpostor:t,joint:i};i.physicsPlugin=this._physicsPlugin,this._joints.push(r),this._physicsPlugin.generateJoint(r)},t.prototype.removeJoint=function(e,t,i){var r=this._joints.filter((function(r){return r.connectedImpostor===t&&r.joint===i&&r.mainImpostor===e}));r.length&&this._physicsPlugin.removeJoint(r[0])},t.prototype._step=function(e){var t=this;this._impostors.forEach((function(e){e.isBodyInitRequired()&&t._physicsPlugin.generatePhysicsBody(e)})),e>.1?e=.1:e<=0&&(e=1/60),this._physicsPlugin.executeStep(e,this._impostors)},t.prototype.getPhysicsPlugin=function(){return this._physicsPlugin},t.prototype.getImpostorForPhysicsObject=function(e){for(var t=0;tr.length)return void e.Tools.Error("Unable to load TGA file - Not enough data");n+=o.id_length;var s=!1,a=!1,h=!1;switch(o.image_type){case t._TYPE_RLE_INDEXED:s=!0;case t._TYPE_INDEXED:a=!0;break;case t._TYPE_RLE_RGB:s=!0;case t._TYPE_RGB:!0;break;case t._TYPE_RLE_GREY:s=!0;case t._TYPE_GREY:h=!0}var l,c,u=(o.flags,o.pixel_size>>3),f=o.width*o.height*u;if(a&&(c=r.subarray(n,n+=o.colormap_length*(o.colormap_size>>3))),s){l=new Uint8Array(f);for(var d,p,m,_=0,g=new Uint8Array(u);n>t._ORIGIN_SHIFT){default:case t._ORIGIN_UL:v=0,x=1,T=o.width,y=0,b=1,A=o.height;break;case t._ORIGIN_BL:v=0,x=1,T=o.width,y=o.height-1,b=-1,A=-1;break;case t._ORIGIN_UR:v=o.width-1,x=-1,T=-1,y=0,b=1,A=o.height;break;case t._ORIGIN_BR:v=o.width-1,x=-1,T=-1,y=o.height-1,b=-1,A=-1}var E="_getImageData"+(h?"Grey":"")+o.pixel_size+"bits",P=t[E](o,c,l,y,b,A,v,x,T);i.texImage2D(i.TEXTURE_2D,0,i.RGBA,o.width,o.height,0,i.RGBA,i.UNSIGNED_BYTE,P)},t._getImageData8bits=function(e,t,i,r,n,o,s,a,h){var l,c,u,f=i,d=t,p=e.width,m=e.height,_=0,g=new Uint8Array(p*m*4);for(u=r;u!==o;u+=n)for(c=s;c!==h;c+=a,_++)l=f[_],g[4*(c+p*u)+3]=255,g[4*(c+p*u)+2]=d[3*l+0],g[4*(c+p*u)+1]=d[3*l+1],g[4*(c+p*u)+0]=d[3*l+2];return g},t._getImageData16bits=function(e,t,i,r,n,o,s,a,h){var l,c,u,f=i,d=e.width,p=e.height,m=0,_=new Uint8Array(d*p*4);for(u=r;u!==o;u+=n)for(c=s;c!==h;c+=a,m+=2)l=f[m+0]+(f[m+1]<<8),_[4*(c+d*u)+0]=(31744&l)>>7,_[4*(c+d*u)+1]=(992&l)>>2,_[4*(c+d*u)+2]=(31&l)>>3,_[4*(c+d*u)+3]=32768&l?0:255;return _},t._getImageData24bits=function(e,t,i,r,n,o,s,a,h){var l,c,u=i,f=e.width,d=e.height,p=0,m=new Uint8Array(f*d*4);for(c=r;c!==o;c+=n)for(l=s;l!==h;l+=a,p+=3)m[4*(l+f*c)+3]=255,m[4*(l+f*c)+2]=u[p+0],m[4*(l+f*c)+1]=u[p+1],m[4*(l+f*c)+0]=u[p+2];return m},t._getImageData32bits=function(e,t,i,r,n,o,s,a,h){var l,c,u=i,f=e.width,d=e.height,p=0,m=new Uint8Array(f*d*4);for(c=r;c!==o;c+=n)for(l=s;l!==h;l+=a,p+=4)m[4*(l+f*c)+2]=u[p+0],m[4*(l+f*c)+1]=u[p+1],m[4*(l+f*c)+0]=u[p+2],m[4*(l+f*c)+3]=u[p+3];return m},t._getImageDataGrey8bits=function(e,t,i,r,n,o,s,a,h){var l,c,u,f=i,d=e.width,p=e.height,m=0,_=new Uint8Array(d*p*4);for(u=r;u!==o;u+=n)for(c=s;c!==h;c+=a,m++)l=f[m],_[4*(c+d*u)+0]=l,_[4*(c+d*u)+1]=l,_[4*(c+d*u)+2]=l,_[4*(c+d*u)+3]=255;return _},t._getImageDataGrey16bits=function(e,t,i,r,n,o,s,a,h){var l,c,u=i,f=e.width,d=e.height,p=0,m=new Uint8Array(f*d*4);for(c=r;c!==o;c+=n)for(l=s;l!==h;l+=a,p+=2)m[4*(l+f*c)+0]=u[p+0],m[4*(l+f*c)+1]=u[p+0],m[4*(l+f*c)+2]=u[p+0],m[4*(l+f*c)+3]=u[p+1];return m},t})();i._TYPE_NO_DATA=0,i._TYPE_INDEXED=1,i._TYPE_RGB=2,i._TYPE_GREY=3,i._TYPE_RLE_INDEXED=9,i._TYPE_RLE_RGB=10,i._TYPE_RLE_GREY=11,i._ORIGIN_MASK=48,i._ORIGIN_SHIFT=4,i._ORIGIN_BL=0,i._ORIGIN_BR=1,i._ORIGIN_UL=2,i._ORIGIN_UR=3,t.TGATools=i})(e.Internals||(e.Internals={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){function i(e){return e.charCodeAt(0)+(e.charCodeAt(1)<<8)+(e.charCodeAt(2)<<16)+(e.charCodeAt(3)<<24)}function r(e){return String.fromCharCode(255&e,e>>8&255,e>>16&255,e>>24&255)}var n=i("DXT1"),o=i("DXT3"),s=i("DXT5"),a=i("DX10"),h=(function(){function t(){}return t.GetDDSInfo=function(t){var i=new Int32Array(t,0,31),r=new Int32Array(t,0,35),h=1;131072&i[2]&&(h=Math.max(1,i[7]));var l=i[21],c=l===a?r[32]:0,u=e.Engine.TEXTURETYPE_UNSIGNED_INT;switch(l){case 113:u=e.Engine.TEXTURETYPE_HALF_FLOAT;break;case 116:u=e.Engine.TEXTURETYPE_FLOAT;break;case a:if(10===c){u=e.Engine.TEXTURETYPE_HALF_FLOAT;break}}return{width:i[4],height:i[3],mipmapCount:h,isFourCC:4==(4&i[20]),isRGB:64==(64&i[20]),isLuminance:131072==(131072&i[20]),isCube:512==(512&i[28]),isCompressed:l===n||l===o||n===s,dxgiFormat:c,textureType:u}},t._ToHalfFloat=function(e){t._FloatView||(t._FloatView=new Float32Array(1),t._Int32View=new Int32Array(t._FloatView.buffer)),t._FloatView[0]=e;var i=t._Int32View[0],r=i>>16&32768,n=i>>12&2047,o=i>>23&255;return o<103?r:o>142?(r|=31744,r|=(255==o?0:1)&&8388607&i):o<113?(n|=2048,r|=(n>>114-o)+(n>>113-o&1)):(r|=o-112<<10|n>>1,r+=1&n)},t._FromHalfFloat=function(e){var t=(32768&e)>>15,i=(31744&e)>>10,r=1023&e;return 0===i?(t?-1:1)*Math.pow(2,-14)*(r/Math.pow(2,10)):31==i?r?NaN:1/0*(t?-1:1):(t?-1:1)*Math.pow(2,i-15)*(1+r/Math.pow(2,10))},t._GetHalfFloatAsFloatRGBAArrayBuffer=function(e,i,r,n,o,s){for(var a=new Float32Array(n),h=new Uint16Array(o,r),l=0,c=0;c>8&65280|e>>24&255},t.prototype.uploadLevels=function(e,i){switch(this.loadType){case t.COMPRESSED_2D:this._upload2DCompressedLevels(e,i);break;case t.TEX_2D:case t.COMPRESSED_3D:case t.TEX_3D:}},t.prototype._upload2DCompressedLevels=function(e,i){for(var r=t.HEADER_LEN+this.bytesOfKeyValueData,n=this.pixelWidth,o=this.pixelHeight,s=i?this.numberOfMipmapLevels:1,a=0;a0?this._firstFree=this._freeEntries[this._freeEntries.length-1].offset:this._firstFree+=this._stride),e},e.prototype.freeElement=function(e){this._firstFree=Math.min(e.offset,this._firstFree),this._freeEntries.push(e)},e.prototype.pack=function(){if(0===this._freeEntries.length)return this.buffer;if(this._lastUsed=a);l++){var c=r[l],u=c.offset,f=u-h;if(f!==e){for(var d=f/e-1,p=u-e,m=Math.min(s,d),_=0;_=0;s--){var a=t[s],h=a.getParent();if(h){var l=this._debugLines[n];l||(l=[e.Vector3.Zero(),e.Vector3.Zero()],this._debugLines[n]=l),a.getAbsolutePositionToRef(this.mesh,l[0]),h.getAbsolutePositionToRef(this.mesh,l[1]),l[0].subtractInPlace(o),l[1].subtractInPlace(o),n++}}},t.prototype.update=function(){this.autoUpdateBonesMatrices&&this.skeleton.computeAbsoluteTransforms(),void 0===this.skeleton.bones[0].length?this._getLinesForBonesNoLength(this.skeleton.bones,this.mesh.getWorldMatrix()):this._getLinesForBonesWithLength(this.skeleton.bones,this.mesh.getWorldMatrix()),this._debugMesh?e.MeshBuilder.CreateLineSystem(null,{lines:this._debugLines,updatable:!0,instance:this._debugMesh},this._scene):(this._debugMesh=e.MeshBuilder.CreateLineSystem(null,{lines:this._debugLines,updatable:!0},this._scene),this._debugMesh.renderingGroupId=this.renderingGroupId),this._debugMesh.position.copyFrom(this.mesh.position),this._debugMesh.color=this.color},t.prototype.dispose=function(){this._debugMesh&&(this.isEnabled=!1,this._debugMesh.dispose(),this._debugMesh=null)},t})();t.SkeletonViewer=i})(e.Debug||(e.Debug={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){var i=(function(){function t(t,i){void 0===i&&(i=1),this._xline=[e.Vector3.Zero(),e.Vector3.Zero()],this._yline=[e.Vector3.Zero(),e.Vector3.Zero()],this._zline=[e.Vector3.Zero(),e.Vector3.Zero()],this.scaleLines=1,this.scaleLines=i,this._xmesh=e.Mesh.CreateLines("xline",this._xline,t,!0),this._ymesh=e.Mesh.CreateLines("yline",this._yline,t,!0),this._zmesh=e.Mesh.CreateLines("zline",this._zline,t,!0),this._xmesh.renderingGroupId=2,this._ymesh.renderingGroupId=2,this._zmesh.renderingGroupId=2,this._xmesh.material.checkReadyOnlyOnce=!0,this._xmesh.color=new e.Color3(1,0,0),this._ymesh.material.checkReadyOnlyOnce=!0,this._ymesh.color=new e.Color3(0,1,0),this._zmesh.material.checkReadyOnlyOnce=!0,this._zmesh.color=new e.Color3(0,0,1),this.scene=t}return t.prototype.update=function(t,i,r,n){var o=this.scaleLines;this._xmesh.position.copyFrom(t),this._ymesh.position.copyFrom(t),this._zmesh.position.copyFrom(t);var s=this._xline[1];s.x=i.x*o,s.y=i.y*o,s.z=i.z*o,e.Mesh.CreateLines(null,this._xline,null,null,this._xmesh),s=this._yline[1],s.x=r.x*o,s.y=r.y*o,s.z=r.z*o,e.Mesh.CreateLines(null,this._yline,null,null,this._ymesh),s=this._zline[1],s.x=n.x*o,s.y=n.y*o,s.z=n.z*o,e.Mesh.CreateLines(null,this._zline,null,null,this._zmesh)},t.prototype.dispose=function(){this._xmesh&&(this._xmesh.dispose(),this._ymesh.dispose(),this._zmesh.dispose(),this._xmesh=null,this._ymesh=null,this._zmesh=null,this._xline=null,this._yline=null,this._zline=null,this.scene=null)},t})();t.AxesViewer=i})(e.Debug||(e.Debug={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){var i=(function(t){function i(i,r,n,o){void 0===o&&(o=1);var s=t.call(this,i,o)||this;return s.pos=e.Vector3.Zero(),s.xaxis=e.Vector3.Zero(),s.yaxis=e.Vector3.Zero(),s.zaxis=e.Vector3.Zero(),s.mesh=n,s.bone=r,s}return __extends(i,t),i.prototype.update=function(){var i=this.bone;i.getAbsolutePositionToRef(this.mesh,this.pos),i.getDirectionToRef(e.Axis.X,this.mesh,this.xaxis),i.getDirectionToRef(e.Axis.Y,this.mesh,this.yaxis),i.getDirectionToRef(e.Axis.Z,this.mesh,this.zaxis),t.prototype.update.call(this,this.pos,this.xaxis,this.yaxis,this.zaxis)},i.prototype.dispose=function(){this.pos&&(this.pos=null,this.xaxis=null,this.yaxis=null,this.zaxis=null,this.mesh=null,this.bone=null,t.prototype.dispose.call(this))},i})(t.AxesViewer);t.BoneAxesViewer=i})(e.Debug||(e.Debug={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e){this.ray=e}return t.CreateAndShow=function(e,i,r){var n=new t(e);return n.show(i,r),n},t.prototype.show=function(t,i){if(!this._renderFunction){var r=this.ray;this._renderFunction=this._render.bind(this),this._scene=t,this._renderPoints=[r.origin,r.origin.add(r.direction.scale(r.length))],this._renderLine=e.Mesh.CreateLines("ray",this._renderPoints,t,!0),this._scene.registerBeforeRender(this._renderFunction)}i&&this._renderLine.color.copyFrom(i)},t.prototype.hide=function(){this._renderFunction&&(this._scene.unregisterBeforeRender(this._renderFunction),this._scene=null,this._renderFunction=null,this._renderLine.dispose(),this._renderLine=null,this._renderPoints=null)},t.prototype._render=function(){var t=this.ray,i=this._renderPoints[1],r=Math.min(t.length,1e6);i.copyFrom(t.direction),i.scaleInPlace(r),i.addInPlace(t.origin),e.Mesh.CreateLines("ray",this._renderPoints,this._scene,!0,this._renderLine)},t.prototype.attachToMesh=function(t,i,r,n){this._attachedToMesh=t;var o=this.ray;o.direction||(o.direction=e.Vector3.Zero()),o.origin||(o.origin=e.Vector3.Zero()),n&&(o.length=n),r||(r=e.Vector3.Zero()),i||(i=new e.Vector3(0,0,-1)),this._meshSpaceDirection?(this._meshSpaceDirection.copyFrom(i),this._meshSpaceOrigin.copyFrom(r)):(this._meshSpaceDirection=i.clone(),this._meshSpaceOrigin=r.clone()),this._updateToMeshFunction||(this._updateToMeshFunction=this._updateToMesh.bind(this),this._attachedToMesh.getScene().registerBeforeRender(this._updateToMeshFunction)),this._updateToMesh()},t.prototype.detachFromMesh=function(){this._attachedToMesh&&(this._attachedToMesh.getScene().unregisterBeforeRender(this._updateToMeshFunction),this._attachedToMesh=null,this._updateToMeshFunction=null)},t.prototype._updateToMesh=function(){var t=this.ray;if(this._attachedToMesh._isDisposed)return void this.detachFromMesh();this._attachedToMesh.getDirectionToRef(this._meshSpaceDirection,t.direction),e.Vector3.TransformCoordinatesToRef(this._meshSpaceOrigin,this._attachedToMesh.getWorldMatrix(),t.origin)},t.prototype.dispose=function(){this.hide(),this.detachFromMesh(),this.ray=null},t})();e.RayHelper=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e){this._scene=e}return t.prototype._createInspector=function(e){void 0===e&&(e={});var t=e.popup||!1,i=e.initialTab||0,r=e.parentElement||null;this._inspector||(this._inspector=new INSPECTOR.Inspector(this._scene,t,i,r,e.newColors))},t.prototype.isVisible=function(){return!!this._inspector},t.prototype.hide=function(){if(this._inspector){try{this._inspector.dispose()}catch(e){}this._inspector=null}},t.prototype.show=function(i){void 0===i&&(i={}),"undefined"==typeof INSPECTOR?e.Tools.LoadScript(t.InspectorURL,this._createInspector.bind(this,i)):this._createInspector(i)},t})();t.InspectorURL=window.location.href.split("/")[0]+"//preview.babylonjs.com/inspector/babylon.inspector.bundle.js",e.DebugLayer=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){var i=(function(){function t(t){this._impostors=[],this._meshes=[],this._numMeshes=0,this._scene=t||e.Engine.LastCreatedScene,this._physicsEnginePlugin=this._scene.getPhysicsEngine().getPhysicsPlugin()}return t.prototype._updateDebugMeshes=function(){for(var e=this._physicsEnginePlugin,t=0;t0?(this._meshes[i]=this._meshes[this._numMeshes],this._impostors[i]=this._impostors[this._numMeshes],this._meshes[this._numMeshes]=null,this._impostors[this._numMeshes]=null):(this._meshes[0]=null,this._impostors[0]=null),t=!0;break}t&&0===this._numMeshes&&this._scene.unregisterBeforeRender(this._renderFunction)},t.prototype._getDebugMaterial=function(t){return this._debugMaterial||(this._debugMaterial=new e.StandardMaterial("",t),this._debugMaterial.wireframe=!0),this._debugMaterial},t.prototype._getDebugBoxMesh=function(t){return this._debugBoxMesh||(this._debugBoxMesh=e.MeshBuilder.CreateBox("physicsBodyBoxViewMesh",{size:1},t),this._debugBoxMesh.renderingGroupId=1,this._debugBoxMesh.rotationQuaternion=e.Quaternion.Identity(),this._debugBoxMesh.material=this._getDebugMaterial(t),t.removeMesh(this._debugBoxMesh)),this._debugBoxMesh.createInstance("physicsBodyBoxViewInstance")},t.prototype._getDebugSphereMesh=function(t){return this._debugSphereMesh||(this._debugSphereMesh=e.MeshBuilder.CreateSphere("physicsBodySphereViewMesh",{diameter:1},t),this._debugSphereMesh.renderingGroupId=1,this._debugSphereMesh.rotationQuaternion=e.Quaternion.Identity(),this._debugSphereMesh.material=this._getDebugMaterial(t),t.removeMesh(this._debugSphereMesh)),this._debugSphereMesh.createInstance("physicsBodyBoxViewInstance")},t.prototype._getDebugMesh=function(t,i){var r,n=t.physicsBody;n.shapes[0];if(t.type==e.PhysicsImpostor.BoxImpostor)r=this._getDebugBoxMesh(i),t.getBoxSizeToRef(r.scaling);else if(t.type==e.PhysicsImpostor.SphereImpostor){r=this._getDebugSphereMesh(i);var o=t.getRadius();r.scaling.x=2*o,r.scaling.y=2*o,r.scaling.z=2*o}return r},t.prototype.dispose=function(){for(var e=0;e=0&&(this._targets.splice(t,1),e.onInfluenceChanged.remove(this._targetObservable.splice(t,1)[0]),this._vertexCount=0,this._syncActiveTargets(!0))},t.prototype.serialize=function(){var e={};e.id=this.uniqueId,e.targets=[];for(var t=0,i=this._targets;t0&&(this._activeTargets.push(n),this._tempInfluences[t++]=n.influence,this._supportsNormals=this._supportsNormals&&n.hasNormals,this._supportsTangents=this._supportsTangents&&n.hasTangents,0===this._vertexCount&&(this._vertexCount=n.getPositions().length/3))}this._influences&&this._influences.length===t||(this._influences=new Float32Array(t));for(var o=0;o0&&(p+1)%4==0)o[p]=255;else{var x=s[p];o[p]=x/d*255}t.getScene().getEngine().updateTextureSize(r,l*l,l),t.getScene().getEngine().updateRawTexture(r,o,e.Engine.TEXTUREFORMAT_RGBA,!1)};return e.Tools.LoadFile(this.url,n),this._texture},i.prototype.loadTexture=function(){this.url&&this.url.toLocaleLowerCase().indexOf(".3dl")==this.url.length-4&&this.load3dlTexture()},i.prototype.clone=function(){var e=new i(this.url,this.getScene());return e.level=this.level,e},i.prototype.delayLoad=function(){this.delayLoadState===e.Engine.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=e.Engine.DELAYLOADSTATE_LOADED,this._texture=this._getFromCache(this.url,!0),this._texture||this.loadTexture())},i.Parse=function(t,i,r){var n=null;return t.name&&!t.isRenderTarget&&(n=new e.ColorGradingTexture(t.name,i),n.name=t.name,n.level=t.level),n},i.prototype.serialize=function(){if(!this.name)return null;var e={};return e.name=this.name,e.level=this.level,e.customType="BABYLON.ColorGradingTexture",e},i})(e.BaseTexture);t._noneEmptyLineRegex=/\S+/,e.ColorGradingTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this._dirty=!0,this._tempColor=new e.Color4(0,0,0,0),this._globalCurve=new e.Color4(0,0,0,0),this._highlightsCurve=new e.Color4(0,0,0,0),this._midtonesCurve=new e.Color4(0,0,0,0),this._shadowsCurve=new e.Color4(0,0,0,0),this._positiveCurve=new e.Color4(0,0,0,0),this._negativeCurve=new e.Color4(0,0,0,0),this._globalHue=30,this._globalDensity=0,this._globalSaturation=0,this._globalExposure=0,this._highlightsHue=30,this._highlightsDensity=0,this._highlightsSaturation=0,this._highlightsExposure=0,this._midtonesHue=30,this._midtonesDensity=0,this._midtonesSaturation=0,this._midtonesExposure=0,this._shadowsHue=30,this._shadowsDensity=0,this._shadowsSaturation=0,this._shadowsExposure=0}return Object.defineProperty(t.prototype,"globalHue",{get:function(){return this._globalHue},set:function(e){this._globalHue=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"globalDensity",{get:function(){return this._globalDensity},set:function(e){this._globalDensity=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"globalSaturation",{get:function(){return this._globalSaturation},set:function(e){this._globalSaturation=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"highlightsHue",{get:function(){return this._highlightsHue},set:function(e){this._highlightsHue=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"highlightsDensity",{get:function(){return this._highlightsDensity},set:function(e){this._highlightsDensity=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"highlightsSaturation",{get:function(){return this._highlightsSaturation},set:function(e){this._highlightsSaturation=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"highlightsExposure",{get:function(){return this._highlightsExposure},set:function(e){this._highlightsExposure=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"midtonesHue",{get:function(){return this._midtonesHue},set:function(e){this._midtonesHue=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"midtonesDensity",{get:function(){return this._midtonesDensity},set:function(e){this._midtonesDensity=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"midtonesSaturation",{get:function(){return this._midtonesSaturation},set:function(e){this._midtonesSaturation=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"midtonesExposure",{get:function(){return this._midtonesExposure},set:function(e){this._midtonesExposure=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"shadowsHue",{get:function(){return this._shadowsHue},set:function(e){this._shadowsHue=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"shadowsDensity",{get:function(){return this._shadowsDensity},set:function(e){this._shadowsDensity=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"shadowsSaturation",{get:function(){return this._shadowsSaturation},set:function(e){this._shadowsSaturation=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"shadowsExposure",{get:function(){return this._shadowsExposure},set:function(e){this._shadowsExposure=e,this._dirty=!0},enumerable:!0, -configurable:!0}),t.prototype.getClassName=function(){return"ColorCurves"},t.Bind=function(e,t,i,r,n){void 0===i&&(i="vCameraColorCurvePositive"),void 0===r&&(r="vCameraColorCurveNeutral"),void 0===n&&(n="vCameraColorCurveNegative"),e._dirty&&(e._dirty=!1,e.getColorGradingDataToRef(e._globalHue,e._globalDensity,e._globalSaturation,e._globalExposure,e._globalCurve),e.getColorGradingDataToRef(e._highlightsHue,e._highlightsDensity,e._highlightsSaturation,e._highlightsExposure,e._tempColor),e._tempColor.multiplyToRef(e._globalCurve,e._highlightsCurve),e.getColorGradingDataToRef(e._midtonesHue,e._midtonesDensity,e._midtonesSaturation,e._midtonesExposure,e._tempColor),e._tempColor.multiplyToRef(e._globalCurve,e._midtonesCurve),e.getColorGradingDataToRef(e._shadowsHue,e._shadowsDensity,e._shadowsSaturation,e._shadowsExposure,e._tempColor),e._tempColor.multiplyToRef(e._globalCurve,e._shadowsCurve),e._highlightsCurve.subtractToRef(e._midtonesCurve,e._positiveCurve),e._midtonesCurve.subtractToRef(e._shadowsCurve,e._negativeCurve)),t&&(t.setFloat4(i,e._positiveCurve.r,e._positiveCurve.g,e._positiveCurve.b,e._positiveCurve.a),t.setFloat4(r,e._midtonesCurve.r,e._midtonesCurve.g,e._midtonesCurve.b,e._midtonesCurve.a),t.setFloat4(n,e._negativeCurve.r,e._negativeCurve.g,e._negativeCurve.b,e._negativeCurve.a))},t.PrepareUniforms=function(e){e.push("vCameraColorCurveNeutral","vCameraColorCurvePositive","vCameraColorCurveNegative")},t.prototype.getColorGradingDataToRef=function(e,i,r,n,o){null!=e&&(e=t.clamp(e,0,360),i=t.clamp(i,-100,100),r=t.clamp(r,-100,100),n=t.clamp(n,-100,100),i=t.applyColorGradingSliderNonlinear(i),i*=.5,n=t.applyColorGradingSliderNonlinear(n),i<0&&(i*=-1,e=(e+180)%360),t.fromHSBToRef(e,i,50+.25*n,o),o.scaleToRef(2,o),o.a=1+.01*r)},t.applyColorGradingSliderNonlinear=function(e){e/=100;var t=Math.abs(e);return t=Math.pow(t,2),e<0&&(t*=-1),t*=100},t.fromHSBToRef=function(e,i,r,n){var o=t.clamp(e,0,360),s=t.clamp(i/100,0,1),a=t.clamp(r/100,0,1);if(0===s)n.r=a,n.g=a,n.b=a;else{o/=60;var h=Math.floor(o),l=o-h,c=a*(1-s),u=a*(1-s*l),f=a*(1-s*(1-l));switch(h){case 0:n.r=a,n.g=f,n.b=c;break;case 1:n.r=u,n.g=a,n.b=c;break;case 2:n.r=c,n.g=a,n.b=f;break;case 3:n.r=c,n.g=u,n.b=a;break;case 4:n.r=f,n.g=c,n.b=a;break;default:n.r=a,n.g=c,n.b=u}}n.a=1},t.clamp=function(e,t,i){return Math.min(Math.max(e,t),i)},t.prototype.clone=function(){return e.SerializationHelper.Clone((function(){return new t}),this)},t.prototype.serialize=function(){return e.SerializationHelper.Serialize(this)},t.Parse=function(i){return e.SerializationHelper.Parse((function(){return new t}),i,null,null)},t})();__decorate([e.serialize()],t.prototype,"_globalHue",void 0),__decorate([e.serialize()],t.prototype,"_globalDensity",void 0),__decorate([e.serialize()],t.prototype,"_globalSaturation",void 0),__decorate([e.serialize()],t.prototype,"_globalExposure",void 0),__decorate([e.serialize()],t.prototype,"_highlightsHue",void 0),__decorate([e.serialize()],t.prototype,"_highlightsDensity",void 0),__decorate([e.serialize()],t.prototype,"_highlightsSaturation",void 0),__decorate([e.serialize()],t.prototype,"_highlightsExposure",void 0),__decorate([e.serialize()],t.prototype,"_midtonesHue",void 0),__decorate([e.serialize()],t.prototype,"_midtonesDensity",void 0),__decorate([e.serialize()],t.prototype,"_midtonesSaturation",void 0),__decorate([e.serialize()],t.prototype,"_midtonesExposure",void 0),e.ColorCurves=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t,i,r){void 0===r&&(r=2),this.maxDepth=r,this.dynamicContent=new Array,this._maxBlockCapacity=i||64,this._selectionContent=new e.SmartArray(1024),this._creationFunc=t}return t.prototype.update=function(e,i,r){t._CreateBlocks(e,i,r,this._maxBlockCapacity,0,this.maxDepth,this,this._creationFunc)},t.prototype.addMesh=function(e){for(var t=0;tthis.capacity&&this._depth>>16&65535,r=65535&e,n=t>>>16&65535,o=65535&t;return r*o+(i*o+r*n<<16>>>0)|0}),e.Matrix.prototype.multiplyToArray=i.prototype.multiplyToArraySIMD,e.Matrix.prototype.invertToRef=i.prototype.invertToRefSIMD,e.Matrix.LookAtLHToRef=i.LookAtLHToRefSIMD,e.Vector3.TransformCoordinatesToRef=t.TransformCoordinatesToRefSIMD,e.Vector3.TransformCoordinatesFromFloatsToRef=t.TransformCoordinatesFromFloatsToRefSIMD,h._isEnabled=!0)},h})();h._isEnabled=!1,e.SIMDHelper=h})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o){var s=t.call(this,i,"vrDistortionCorrection",["LensCenter","Scale","ScaleIn","HmdWarpParam"],null,o.postProcessScaleFactor,r,e.Texture.BILINEAR_SAMPLINGMODE,null,null)||this;return s._isRightEye=n,s._distortionFactors=o.distortionK,s._postProcessScaleFactor=o.postProcessScaleFactor,s._lensCenterOffset=o.lensCenterOffset,s.onSizeChangedObservable.add((function(){s.aspectRatio=.5*s.width/s.height,s._scaleIn=new e.Vector2(2,2/s.aspectRatio),s._scaleFactor=new e.Vector2(1/s._postProcessScaleFactor*.5,1/s._postProcessScaleFactor*.5*s.aspectRatio),s._lensCenter=new e.Vector2(s._isRightEye?.5-.5*s._lensCenterOffset:.5+.5*s._lensCenterOffset,.5)})),s.onApplyObservable.add((function(e){e.setFloat2("LensCenter",s._lensCenter.x,s._lensCenter.y),e.setFloat2("Scale",s._scaleFactor.x,s._scaleFactor.y),e.setFloat2("ScaleIn",s._scaleIn.x,s._scaleIn.y),e.setFloat4("HmdWarpParam",s._distortionFactors[0],s._distortionFactors[1],s._distortionFactors[2],s._distortionFactors[3])})),s}return __extends(i,t),i})(e.PostProcess);e.VRDistortionCorrectionPostProcess=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(e){function t(t,i,r,n,o,s){var a=e.call(this,t,"anaglyph",null,["leftSampler"],i,r[1],n,o,s)||this;return a._passedProcess=r[0]._rigPostProcess,a.onApplyObservable.add((function(e){e.setTextureFromPostProcess("leftSampler",a._passedProcess)})),a}return __extends(t,e),t})(e.PostProcess);e.AnaglyphPostProcess=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o,s,a){var h=t.call(this,i,"stereoscopicInterlace",["stepSize"],["camASampler"],1,r[1],o,s,a,n?"#define IS_STEREOSCOPIC_HORIZ 1":void 0)||this;return h._passedProcess=r[0]._rigPostProcess,h._stepSize=new e.Vector2(1/h.width,1/h.height),h.onSizeChangedObservable.add((function(){h._stepSize=new e.Vector2(1/h.width,1/h.height)})),h.onApplyObservable.add((function(e){e.setTextureFromPostProcess("camASampler",h._passedProcess),e.setFloat2("stepSize",h._stepSize.x,h._stepSize.y)})),h}return __extends(i,t),i})(e.PostProcess);e.StereoscopicInterlacePostProcess=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){var t=this;this._screenOrientationAngle=0,this._screenQuaternion=new e.Quaternion,this._alpha=0,this._beta=0,this._gamma=0,this._orientationChanged=function(){t._screenOrientationAngle=void 0!==window.orientation?+window.orientation:window.screen.orientation&&window.screen.orientation.angle?window.screen.orientation.angle:0,t._screenOrientationAngle=-e.Tools.ToRadians(t._screenOrientationAngle/2),t._screenQuaternion.copyFromFloats(0,Math.sin(t._screenOrientationAngle),0,Math.cos(t._screenOrientationAngle))},this._deviceOrientation=function(e){t._alpha=e.alpha,t._beta=e.beta,t._gamma=e.gamma},this._constantTranform=new e.Quaternion(-Math.sqrt(.5),0,0,Math.sqrt(.5)),this._orientationChanged()}return Object.defineProperty(t.prototype,"camera",{get:function(){return this._camera},set:function(t){this._camera=t,this._camera.rotationQuaternion||(this._camera.rotationQuaternion=new e.Quaternion)},enumerable:!0,configurable:!0}),t.prototype.attachControl=function(e,t){window.addEventListener("orientationchange",this._orientationChanged),window.addEventListener("deviceorientation",this._deviceOrientation),this._orientationChanged()},t.prototype.detachControl=function(e){window.removeEventListener("orientationchange",this._orientationChanged),window.removeEventListener("deviceorientation",this._deviceOrientation)},t.prototype.checkInputs=function(){this._alpha&&(e.Quaternion.RotationYawPitchRollToRef(e.Tools.ToRadians(this._alpha),e.Tools.ToRadians(this._beta),-e.Tools.ToRadians(this._gamma),this.camera.rotationQuaternion),this._camera.rotationQuaternion.multiplyInPlace(this._screenQuaternion),this._camera.rotationQuaternion.multiplyInPlace(this._constantTranform),this._camera.rotationQuaternion.z*=-1,this._camera.rotationQuaternion.w*=-1)},t.prototype.getClassName=function(){return"FreeCameraDeviceOrientationInput"},t.prototype.getSimpleName=function(){return"deviceOrientation"},t})();e.FreeCameraDeviceOrientationInput=t,e.CameraInputTypes.FreeCameraDeviceOrientationInput=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(){this.alphaCorrection=1,this.betaCorrection=1,this.gammaCorrection=1,this._alpha=0,this._beta=0,this._gamma=0,this._dirty=!1,this._deviceOrientationHandler=this._onOrientationEvent.bind(this)}return e.prototype.attachControl=function(e,t){this.camera.attachControl(e,t),window.addEventListener("deviceorientation",this._deviceOrientationHandler)},e.prototype._onOrientationEvent=function(e){this.camera;this._alpha=0|+e.alpha,this._beta=0|+e.beta,this._gamma=0|+e.gamma,this._dirty=!0},e.prototype.checkInputs=function(){this._dirty&&(this._dirty=!1,this._gamma<0&&(this._gamma=180+this._gamma),this.camera.alpha=-this._alpha/180*Math.PI%Math.PI*2,this.camera.beta=this._gamma/180*Math.PI)},e.prototype.detachControl=function(e){window.removeEventListener("deviceorientation",this._deviceOrientationHandler)},e.prototype.getClassName=function(){return"ArcRotateCameraVRDeviceOrientationInput"},e.prototype.getSimpleName=function(){return"VRDeviceOrientation"},e})();e.ArcRotateCameraVRDeviceOrientationInput=t,e.CameraInputTypes.ArcRotateCameraVRDeviceOrientationInput=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this.compensateDistortion=!0}return Object.defineProperty(t.prototype,"aspectRatio",{get:function(){return this.hResolution/(2*this.vResolution)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"aspectRatioFov",{get:function(){return 2*Math.atan(this.postProcessScaleFactor*this.vScreenSize/(2*this.eyeToScreenDistance))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"leftHMatrix",{get:function(){var t=this.hScreenSize/4-this.lensSeparationDistance/2,i=4*t/this.hScreenSize;return e.Matrix.Translation(i,0,0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rightHMatrix",{get:function(){var t=this.hScreenSize/4-this.lensSeparationDistance/2,i=4*t/this.hScreenSize;return e.Matrix.Translation(-i,0,0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"leftPreViewMatrix",{get:function(){return e.Matrix.Translation(.5*this.interpupillaryDistance,0,0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rightPreViewMatrix",{get:function(){return e.Matrix.Translation(-.5*this.interpupillaryDistance,0,0)},enumerable:!0,configurable:!0}),t.GetDefault=function(){var e=new t;return e.hResolution=1280,e.vResolution=800,e.hScreenSize=.149759993,e.vScreenSize=.0935999975,e.vScreenCenter=.0467999987,e.eyeToScreenDistance=.0410000011,e.lensSeparationDistance=.063500002,e.interpupillaryDistance=.064000003,e.distortionK=[1,.219999999,.239999995,0],e.chromaAbCorrection=[.995999992,-.00400000019,1.01400006,0],e.postProcessScaleFactor=1.714605507808412,e.lensCenterOffset=.151976421,e},t})();e.VRCameraMetrics=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o){void 0===o&&(o={});var s=t.call(this,i,r,n)||this;return s.webVROptions=o,s._vrDevice=null,s.rawPose=null,s._vrEnabled=!1,s._specsVersion=1.1,s._attached=!1,s._positionOffset=e.Vector3.Zero(),s._descendants=[],s.devicePosition=e.Vector3.Zero(),s.deviceScaleFactor=1,s.controllers=[],s.nonVRControllers=[],s.rigParenting=!0,5===arguments.length&&(s.webVROptions=arguments[4]),void 0==s.webVROptions.trackPosition&&(s.webVROptions.trackPosition=!0),void 0==s.webVROptions.controllerMeshes&&(s.webVROptions.controllerMeshes=!0),void 0==s.webVROptions.defaultLightningOnControllers&&(s.webVROptions.defaultLightningOnControllers=!0),s.rotationQuaternion=new e.Quaternion,s.deviceRotationQuaternion=new e.Quaternion,s.webVROptions&&s.webVROptions.positionScale&&(s.deviceScaleFactor=s.webVROptions.positionScale),s.getEngine().initWebVR(),window.VRFrameData?s._frameData=new VRFrameData:(s._specsVersion=1,s._frameData={}),s.getEngine().getVRDevice(s.webVROptions.displayName,(function(t){t&&(s._vrEnabled=!0,s._vrDevice=t,s.setCameraRigMode(e.Camera.RIG_MODE_WEBVR,{parentCamera:s,vrDisplay:s._vrDevice,frameData:s._frameData,specs:s._specsVersion}),s._attached&&s.getEngine().enableVR(s._vrDevice))})),s.initControllers(),n.onBeforeCameraRenderObservable.add((function(e){e.parent===s&&s.rigParenting&&(s._descendants=s.getDescendants(!0,(function(e){var t=s.controllers.some((function(t){return t._mesh===e})),i=-1!==s._rigCameras.indexOf(e);return!t&&!i})),s._descendants.forEach((function(t){t.parent=e})))})),n.onAfterCameraRenderObservable.add((function(e){e.parent===s&&s.rigParenting&&s._descendants.forEach((function(e){e.parent=s}))})),s}return __extends(i,t),Object.defineProperty(i.prototype,"onControllersAttached",{set:function(e){this._onControllersAttached=e,this.controllers.length>=2&&e(this.controllers)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"onNonVRControllerAttached",{set:function(e){this._onNonVRControllerAttached=e,this.nonVRControllers.forEach((function(t){e(t)}))},enumerable:!0,configurable:!0}),i.prototype.getControllerByName=function(e){for(var t=0,i=this.controllers;t=2)){for(var n=!1,o=0;oi.halfWidth,t&&this._joystickPointerID<0?(this._joystickPointerID=e.pointerId,this._joystickPointerStartPos.x=e.clientX,this._joystickPointerStartPos.y=e.clientY,this._joystickPointerPos=this._joystickPointerStartPos.clone(),this._joystickPreviousPointerPos=this._joystickPointerStartPos.clone(),this._deltaJoystickVector.x=0,this._deltaJoystickVector.y=0,this.pressed=!0,this._touches.add(e.pointerId.toString(),e)):i._globalJoystickIndex<2&&this._action&&(this._action(),this._touches.add(e.pointerId.toString(),{x:e.clientX,y:e.clientY,prevX:e.clientX,prevY:e.clientY}))},i.prototype._onPointerMove=function(e){if(this._joystickPointerID==e.pointerId){this._joystickPointerPos.x=e.clientX,this._joystickPointerPos.y=e.clientY,this._deltaJoystickVector=this._joystickPointerPos.clone(),this._deltaJoystickVector=this._deltaJoystickVector.subtract(this._joystickPointerStartPos);var i=this.reverseLeftRight?-1:1,r=i*this._deltaJoystickVector.x/this._inversedSensibility;switch(this._axisTargetedByLeftAndRight){case t.X:this.deltaPosition.x=Math.min(1,Math.max(-1,r));break;case t.Y:this.deltaPosition.y=Math.min(1,Math.max(-1,r));break;case t.Z:this.deltaPosition.z=Math.min(1,Math.max(-1,r))}var n=this.reverseUpDown?1:-1,o=n*this._deltaJoystickVector.y/this._inversedSensibility;switch(this._axisTargetedByUpAndDown){case t.X:this.deltaPosition.x=Math.min(1,Math.max(-1,o));break;case t.Y:this.deltaPosition.y=Math.min(1,Math.max(-1,o));break;case t.Z:this.deltaPosition.z=Math.min(1,Math.max(-1,o))}}else{var s=this._touches.get(e.pointerId.toString());s&&(s.x=e.clientX,s.y=e.clientY)}},i.prototype._onPointerUp=function(e){if(this._joystickPointerID==e.pointerId)i.vjCanvasContext.clearRect(this._joystickPointerStartPos.x-64,this._joystickPointerStartPos.y-64,128,128),i.vjCanvasContext.clearRect(this._joystickPreviousPointerPos.x-42,this._joystickPreviousPointerPos.y-42,84,84),this._joystickPointerID=-1,this.pressed=!1;else{var t=this._touches.get(e.pointerId.toString());t&&i.vjCanvasContext.clearRect(t.prevX-44,t.prevY-44,88,88)}this._deltaJoystickVector.x=0,this._deltaJoystickVector.y=0,this._touches.remove(e.pointerId.toString())},i.prototype.setJoystickColor=function(e){this._joystickColor=e},i.prototype.setActionOnTouch=function(e){this._action=e},i.prototype.setAxisForLeftRight=function(e){switch(e){case t.X:case t.Y:case t.Z:this._axisTargetedByLeftAndRight=e;break;default:this._axisTargetedByLeftAndRight=t.X}},i.prototype.setAxisForUpDown=function(e){switch(e){case t.X:case t.Y:case t.Z:this._axisTargetedByUpAndDown=e;break;default:this._axisTargetedByUpAndDown=t.Y}},i.prototype._clearCanvas=function(){this._leftJoystick?i.vjCanvasContext.clearRect(0,0,i.vjCanvasWidth/2,i.vjCanvasHeight):i.vjCanvasContext.clearRect(i.vjCanvasWidth/2,0,i.vjCanvasWidth,i.vjCanvasHeight)},i.prototype._drawVirtualJoystick=function(){var e=this;this.pressed&&this._touches.forEach((function(t,r){r.pointerId===e._joystickPointerID?(i.vjCanvasContext.clearRect(e._joystickPointerStartPos.x-64,e._joystickPointerStartPos.y-64,128,128),i.vjCanvasContext.clearRect(e._joystickPreviousPointerPos.x-42,e._joystickPreviousPointerPos.y-42,84,84),i.vjCanvasContext.beginPath(),i.vjCanvasContext.lineWidth=6,i.vjCanvasContext.strokeStyle=e._joystickColor,i.vjCanvasContext.arc(e._joystickPointerStartPos.x,e._joystickPointerStartPos.y,40,0,2*Math.PI,!0),i.vjCanvasContext.stroke(),i.vjCanvasContext.closePath(),i.vjCanvasContext.beginPath(),i.vjCanvasContext.strokeStyle=e._joystickColor,i.vjCanvasContext.lineWidth=2,i.vjCanvasContext.arc(e._joystickPointerStartPos.x,e._joystickPointerStartPos.y,60,0,2*Math.PI,!0),i.vjCanvasContext.stroke(),i.vjCanvasContext.closePath(),i.vjCanvasContext.beginPath(),i.vjCanvasContext.strokeStyle=e._joystickColor,i.vjCanvasContext.arc(e._joystickPointerPos.x,e._joystickPointerPos.y,40,0,2*Math.PI,!0),i.vjCanvasContext.stroke(),i.vjCanvasContext.closePath(),e._joystickPreviousPointerPos=e._joystickPointerPos.clone()):(i.vjCanvasContext.clearRect(r.prevX-44,r.prevY-44,88,88),i.vjCanvasContext.beginPath(),i.vjCanvasContext.fillStyle="white",i.vjCanvasContext.beginPath(),i.vjCanvasContext.strokeStyle="red",i.vjCanvasContext.lineWidth=6,i.vjCanvasContext.arc(r.x,r.y,40,0,2*Math.PI,!0),i.vjCanvasContext.stroke(),i.vjCanvasContext.closePath(),r.prevX=r.x,r.prevY=r.y)})),requestAnimationFrame((function(){e._drawVirtualJoystick()}))},i.prototype.releaseCanvas=function(){i.vjCanvas&&(i.vjCanvas.removeEventListener("pointerdown",this._onPointerDownHandlerRef),i.vjCanvas.removeEventListener("pointermove",this._onPointerMoveHandlerRef),i.vjCanvas.removeEventListener("pointerup",this._onPointerUpHandlerRef),i.vjCanvas.removeEventListener("pointerout",this._onPointerUpHandlerRef),window.removeEventListener("resize",this._onResize),document.body.removeChild(i.vjCanvas),i.vjCanvas=null)},i})();i._globalJoystickIndex=0,e.VirtualJoystick=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(e){function t(t,i,r){var n=e.call(this,t,i,r)||this;return n.inputs.addVirtualJoystick(),n}return __extends(t,e),t.prototype.getClassName=function(){return"VirtualJoysticksCamera"},t})(e.FreeCamera);e.VirtualJoysticksCamera=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){}return t.prototype.getLeftJoystick=function(){return this._leftjoystick},t.prototype.getRightJoystick=function(){return this._rightjoystick},t.prototype.checkInputs=function(){if(this._leftjoystick){var t=this.camera,i=50*t._computeLocalCameraSpeed(),r=e.Matrix.RotationYawPitchRoll(t.rotation.y,t.rotation.x,0),n=e.Vector3.TransformCoordinates(new e.Vector3(this._leftjoystick.deltaPosition.x*i,this._leftjoystick.deltaPosition.y*i,this._leftjoystick.deltaPosition.z*i),r);t.cameraDirection=t.cameraDirection.add(n),t.cameraRotation=t.cameraRotation.addVector3(this._rightjoystick.deltaPosition),this._leftjoystick.pressed||(this._leftjoystick.deltaPosition=this._leftjoystick.deltaPosition.scale(.9)),this._rightjoystick.pressed||(this._rightjoystick.deltaPosition=this._rightjoystick.deltaPosition.scale(.9))}},t.prototype.attachControl=function(t,i){this._leftjoystick=new e.VirtualJoystick(!0),this._leftjoystick.setAxisForUpDown(e.JoystickAxis.Z),this._leftjoystick.setAxisForLeftRight(e.JoystickAxis.X),this._leftjoystick.setJoystickSensibility(.15),this._rightjoystick=new e.VirtualJoystick(!1),this._rightjoystick.setAxisForUpDown(e.JoystickAxis.X),this._rightjoystick.setAxisForLeftRight(e.JoystickAxis.Y),this._rightjoystick.reverseUpDown=!0,this._rightjoystick.setJoystickSensibility(.05),this._rightjoystick.setJoystickColor("yellow")},t.prototype.detachControl=function(e){this._leftjoystick.releaseCanvas(),this._rightjoystick.releaseCanvas()},t.prototype.getClassName=function(){return"FreeCameraVirtualJoystickInput"},t.prototype.getSimpleName=function(){return"virtualJoystick"},t})();e.FreeCameraVirtualJoystickInput=t,e.CameraInputTypes.FreeCameraVirtualJoystickInput=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(e,t,i){this.quality=e,this.distance=t,this.optimizeMesh=i}return e})();e.SimplificationSettings=t;var i=(function(){function t(){this.running=!1,this._simplificationArray=[]}return t.prototype.addTask=function(e){this._simplificationArray.push(e)},t.prototype.executeNext=function(){var e=this._simplificationArray.pop();e?(this.running=!0,this.runSimplification(e)):this.running=!1},t.prototype.runSimplification=function(t){var i=this;if(t.parallelProcessing)t.settings.forEach((function(e){i.getSimplifier(t).simplify(e,(function(r){t.mesh.addLODLevel(e.distance,r),r.isVisible=!0,e.quality===t.settings[t.settings.length-1].quality&&t.successCallback&&t.successCallback(),i.executeNext()}))}));else{var r=this.getSimplifier(t),n=function(e,i){r.simplify(e,(function(r){t.mesh.addLODLevel(e.distance,r),r.isVisible=!0,i()}))};e.AsyncLoop.Run(t.settings.length,(function(e){n(t.settings[e.index],(function(){e.executeNext()}))}),(function(){t.successCallback&&t.successCallback(),i.executeNext()}))}},t.prototype.getSimplifier=function(e){switch(e.simplificationType){case r.QUADRATIC:default:return new h(e.mesh)}},t})();e.SimplificationQueue=i;var r;!(function(e){e[e.QUADRATIC=0]="QUADRATIC"})(r=e.SimplificationType||(e.SimplificationType={}));var n=(function(){function e(e){this.vertices=e,this.error=new Array(4),this.deleted=!1,this.isDirty=!1,this.deletePending=!1,this.borderFactor=0}return e})();e.DecimationTriangle=n;var o=(function(){function e(e,t){this.position=e,this.id=t,this.isBorder=!0,this.q=new s,this.triangleCount=0,this.triangleStart=0,this.originalOffsets=[]}return e.prototype.updatePosition=function(e){this.position.copyFrom(e)},e})();e.DecimationVertex=o;var s=(function(){function e(e){this.data=new Array(10);for(var t=0;t<10;++t)e&&e[t]?this.data[t]=e[t]:this.data[t]=0}return e.prototype.det=function(e,t,i,r,n,o,s,a,h){return this.data[e]*this.data[n]*this.data[h]+this.data[i]*this.data[r]*this.data[a]+this.data[t]*this.data[o]*this.data[s]-this.data[i]*this.data[n]*this.data[s]-this.data[e]*this.data[o]*this.data[a]-this.data[t]*this.data[r]*this.data[h]},e.prototype.addInPlace=function(e){for(var t=0;t<10;++t)this.data[t]+=e.data[t]},e.prototype.addArrayInPlace=function(e){for(var t=0;t<10;++t)this.data[t]+=e[t]},e.prototype.add=function(t){for(var i=new e,r=0;r<10;++r)i.data[r]=this.data[r]+t.data[r];return i},e.FromData=function(t,i,r,n){return new e(e.DataFromNumbers(t,i,r,n))},e.DataFromNumbers=function(e,t,i,r){return[e*e,e*t,e*i,e*r,t*t,t*i,t*r,i*i,i*r,r*r]},e})();e.QuadraticMatrix=s;var a=(function(){function e(e,t){this.vertexId=e,this.triangleId=t}return e})();e.Reference=a;var h=(function(){function t(t){this._mesh=t,this.initialized=!1,this.syncIterations=5e3,this.aggressiveness=7,this.decimationIterations=100,this.boundingBoxEpsilon=e.Epsilon}return t.prototype.simplify=function(t,i){var r=this;this.initDecimatedMesh(),e.AsyncLoop.Run(this._mesh.subMeshes.length,(function(e){r.initWithMesh(e.index,(function(){r.runDecimation(t,e.index,(function(){e.executeNext()}))}),t.optimizeMesh)}),(function(){setTimeout((function(){i(r._reconstructedMesh)}),0)}))},t.prototype.isTriangleOnBoundingBox=function(e){var t=this,i=0;return e.vertices.forEach((function(e){var r=0,n=e.position,o=t._mesh.getBoundingInfo().boundingBox;(o.maximum.x-n.xt.boundingBoxEpsilon)&&++r,o.maximum.y!==n.y&&n.y!==o.minimum.y||++r,o.maximum.z!==n.z&&n.z!==o.minimum.z||++r,r>1&&++i})),i>1&&console.log(e,i),i>1},t.prototype.runDecimation=function(t,i,r){var n=this,o=~~(this.triangles.length*t.quality),s=0,a=this.triangles.length,h=function(t,i){setTimeout((function(){t%5==0&&n.updateMesh(0===t);for(var r=0;rh||r.deleted||r.isDirty))for(var o=0;o<3;++o)if(r.error[o]>0,f,(function(){var t=function(e){var t=l.indexStart/3+e,i=3*t,r=h[i+0],o=h[i+1],a=h[i+2],c=s.vertices[u[r-l.verticesStart]],f=s.vertices[u[o-l.verticesStart]],d=s.vertices[u[a-l.verticesStart]],p=new n([c,f,d]);p.originalOffset=i,s.triangles.push(p)};e.AsyncLoop.SyncAsyncForLoop(l.indexCount/3,s.syncIterations,t,(function(){s.init(i)}))}))},t.prototype.init=function(t){var i=this,r=function(t){var r=i.triangles[t];r.normal=e.Vector3.Cross(r.vertices[1].position.subtract(r.vertices[0].position),r.vertices[2].position.subtract(r.vertices[0].position)).normalize();for(var n=0;n<3;n++)r.vertices[n].q.addArrayInPlace(s.DataFromNumbers(r.normal.x,r.normal.y,r.normal.z,-e.Vector3.Dot(r.normal,r.vertices[0].position)))};e.AsyncLoop.SyncAsyncForLoop(this.triangles.length,this.syncIterations,r,(function(){var r=function(e){for(var t=i.triangles[e],r=0;r<3;++r)t.error[r]=i.calculateError(t.vertices[r],t.vertices[(r+1)%3]);t.error[3]=Math.min(t.error[0],t.error[1],t.error[2])};e.AsyncLoop.SyncAsyncForLoop(i.triangles.length,i.syncIterations,r,(function(){i.initialized=!0,t()}))}))},t.prototype.reconstructMesh=function(t){var i,r=[];for(i=0;i0&&this._reconstructedMesh.setVerticesData(e.VertexBuffer.UVKind,h),l.length>0&&this._reconstructedMesh.setVerticesData(e.VertexBuffer.ColorKind,l);var x=this._mesh.subMeshes[t];if(t>0){this._reconstructedMesh.subMeshes=[],g.forEach((function(t){new e.SubMesh(t.materialIndex,t.verticesStart,t.verticesCount,t.indexStart,t.indexCount,t.getMesh())}));new e.SubMesh(x.materialIndex,_,d,m,3*r.length,this._reconstructedMesh)}},t.prototype.initDecimatedMesh=function(){this._reconstructedMesh=new e.Mesh(this._mesh.name+"Decimated",this._mesh.getScene()),this._reconstructedMesh.material=this._mesh.material,this._reconstructedMesh.parent=this._mesh.parent,this._reconstructedMesh.isVisible=!1,this._reconstructedMesh.renderingGroupId=this._mesh.renderingGroupId},t.prototype.isFlipped=function(t,i,r,n,o,s){for(var a=0;a.999)return!0;var p=e.Vector3.Cross(f,d).normalize();if(n[a]=!1,e.Vector3.Dot(p,h.normal)<.2)return!0}else n[a]=!0,s.push(h)}}return!1},t.prototype.updateTriangles=function(e,t,i,r){for(var n=r,o=0;or.maximumSize&&(n.scale(.5),t=!1)}}return t},r}return __extends(t,e),t})(t);e.TextureOptimization=i;var r=(function(e){function t(t,i){void 0===t&&(t=0),void 0===i&&(i=2);var r=e.call(this,t)||this;return r.priority=t,r.maximumScale=i,r._currentScale=1,r.apply=function(e){return r._currentScale++,e.getEngine().setHardwareScalingLevel(r._currentScale),r._currentScale>=r.maximumScale},r}return __extends(t,e),t})(t);e.HardwareScalingOptimization=r;var n=(function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.apply=function(e){return e.shadowsEnabled=!1,!0},t}return __extends(t,e),t})(t);e.ShadowsOptimization=n;var o=(function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.apply=function(e){return e.postProcessesEnabled=!1,!0},t}return __extends(t,e),t})(t);e.PostProcessesOptimization=o;var s=(function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.apply=function(e){return e.lensFlaresEnabled=!1,!0},t}return __extends(t,e),t})(t);e.LensFlaresOptimization=s;var a=(function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.apply=function(e){return e.particlesEnabled=!1,!0},t}return __extends(t,e),t})(t);e.ParticlesOptimization=a;var h=(function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.apply=function(e){return e.renderTargetsEnabled=!1,!0},t}return __extends(t,e),t})(t);e.RenderTargetsOptimization=h;var l=(function(t){function i(){var r=null!==t&&t.apply(this,arguments)||this;return r._canBeMerged=function(t){if(!(t instanceof e.Mesh))return!1;var i=t;return!(!i.isVisible||!i.isEnabled())&&(!(i.instances.length>0)&&(!i.skeleton&&!i.hasLODLevels&&!i.parent))},r.apply=function(t,n){for(var o=t.meshes.slice(0),s=o.length,a=0;a=i.targetFrameRate)return void(n&&n());for(var s=!0,a=!0,h=0;h4&&(n.push(e.VertexBuffer.MatricesIndicesExtraKind),n.push(e.VertexBuffer.MatricesWeightsExtraKind)),r.push("#define NUM_BONE_INFLUENCERS "+o.numBoneInfluencers),r.push("#define BonesPerMesh "+(o.skeleton.bones.length+1))):r.push("#define NUM_BONE_INFLUENCERS 0"),i&&(r.push("#define INSTANCES"),n.push("world0"),n.push("world1"),n.push("world2"),n.push("world3"));var a=r.join("\n");return this._cachedDefines!==a&&(this._cachedDefines=a,this._effect=this._scene.getEngine().createEffect("outline",n,["world","mBones","viewProjection","diffuseMatrix","offset","color"],["diffuseSampler"],a)),this._effect.isReady()},t})();e.OutlineRenderer=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(){this.edges=new Array,this.edgesConnectedCount=0}return e})(),i=(function(){function i(e,t,i){void 0===t&&(t=.95),void 0===i&&(i=!1),this.edgesWidthScalerForOrthographic=1e3,this.edgesWidthScalerForPerspective=50,this._linesPositions=new Array,this._linesNormals=new Array,this._linesIndices=new Array,this._buffers={},this._checkVerticesInsteadOfIndices=!1,this._source=e,this._checkVerticesInsteadOfIndices=i,this._epsilon=t,this._prepareRessources(),this._generateEdgesLines()}return i.prototype._prepareRessources=function(){this._lineShader||(this._lineShader=new e.ShaderMaterial("lineShader",this._source.getScene(),"line",{attributes:["position","normal"],uniforms:["worldViewProjection","color","width","aspectRatio"]}),this._lineShader.disableDepthWrite=!0,this._lineShader.backFaceCulling=!1)},i.prototype.dispose=function(){var t=this._buffers[e.VertexBuffer.PositionKind];t&&(t.dispose(),this._buffers[e.VertexBuffer.PositionKind]=null),t=this._buffers[e.VertexBuffer.NormalKind],t&&(t.dispose(),this._buffers[e.VertexBuffer.NormalKind]=null),this._source.getScene().getEngine()._releaseBuffer(this._ib),this._lineShader.dispose()},i.prototype._processEdgeForAdjacencies=function(e,t,i,r,n){return e===i&&t===r||e===r&&t===i?0:e===r&&t===n||e===n&&t===r?1:e===n&&t===i||e===i&&t===n?2:-1},i.prototype._processEdgeForAdjacenciesWithVertices=function(e,t,i,r,n){return e.equalsWithEpsilon(i)&&t.equalsWithEpsilon(r)||e.equalsWithEpsilon(r)&&t.equalsWithEpsilon(i)?0:e.equalsWithEpsilon(r)&&t.equalsWithEpsilon(n)||e.equalsWithEpsilon(n)&&t.equalsWithEpsilon(r)?1:e.equalsWithEpsilon(n)&&t.equalsWithEpsilon(i)||e.equalsWithEpsilon(i)&&t.equalsWithEpsilon(n)?2:-1},i.prototype._checkEdge=function(t,i,r,n,o){var s;if(void 0===i)s=!0;else{s=e.Vector3.Dot(r[t],r[i])4&&(o.push(e.VertexBuffer.MatricesIndicesExtraKind),o.push(e.VertexBuffer.MatricesWeightsExtraKind)),n.push("#define NUM_BONE_INFLUENCERS "+s.numBoneInfluencers),n.push("#define BonesPerMesh "+(s.skeleton.bones.length+1))):n.push("#define NUM_BONE_INFLUENCERS 0"),i&&(n.push("#define INSTANCES"),o.push("world0"),o.push("world1"),o.push("world2"),o.push("world3"));var u=n.join("\n");return this._cachedDefines!==u&&(this._cachedDefines=u,this._glowMapGenerationEffect=this._scene.getEngine().createEffect("glowMapGeneration",o,["world","mBones","viewProjection","diffuseMatrix","color","emissiveMatrix"],["diffuseSampler","emissiveSampler"],u)),this._glowMapGenerationEffect.isReady()},i.prototype.render=function(){var t=this._glowMapMergeEffect;if(t.isReady()&&this._blurTexture.isReady()){var i=this._scene.getEngine();this.onBeforeComposeObservable.notifyObservers(this),i.enableEffect(t),i.setState(!1);var r=i.getStencilBuffer(),n=i.getStencilFunction(),o=i.getStencilMask(),s=i.getStencilOperationPass(),a=i.getStencilOperationFail(),h=i.getStencilOperationDepthFail(),l=i.getAlphaMode();t.setTexture("textureSampler",this._blurTexture),i.bindBuffers(this._vertexBuffers,this._indexBuffer,t),i.setStencilOperationPass(e.Engine.REPLACE),i.setStencilOperationFail(e.Engine.KEEP),i.setStencilOperationDepthFail(e.Engine.KEEP),i.setAlphaMode(this._options.alphaBlendingMode),i.setStencilMask(0),i.setStencilBuffer(!0),i.setStencilFunctionReference(this._instanceGlowingMeshStencilReference),this.outerGlow&&(t.setFloat("offset",0),i.setStencilFunction(e.Engine.NOTEQUAL),i.draw(!0,0,6)),this.innerGlow&&(t.setFloat("offset",1),i.setStencilFunction(e.Engine.EQUAL),i.draw(!0,0,6)),i.setStencilFunction(n),i.setStencilMask(o),i.setAlphaMode(l),i.setStencilBuffer(r),i.setStencilOperationPass(s),i.setStencilOperationFail(a),i.setStencilOperationDepthFail(h),i._stencilState.reset(),this.onAfterComposeObservable.notifyObservers(this);var c=this._mainTexture.getSize();this.setMainTextureSize(),c.width===this._mainTextureDesiredSize.width&&c.height===this._mainTextureDesiredSize.height||(this.onSizeChangedObservable.notifyObservers(this),this.disposeTextureAndPostProcesses(),this.createTextureAndPostProcesses())}},i.prototype.addExcludedMesh=function(e){this._excludedMeshes[e.uniqueId]||(this._excludedMeshes[e.uniqueId]={mesh:e,beforeRender:e.onBeforeRenderObservable.add((function(e){e.getEngine().setStencilBuffer(!1)})),afterRender:e.onAfterRenderObservable.add((function(e){e.getEngine().setStencilBuffer(!0)}))})},i.prototype.removeExcludedMesh=function(e){var t=this._excludedMeshes[e.uniqueId];t&&(e.onBeforeRenderObservable.remove(t.beforeRender),e.onAfterRenderObservable.remove(t.afterRender)),this._excludedMeshes[e.uniqueId]=void 0},i.prototype.addMesh=function(e,t,i){var r=this;void 0===i&&(i=!1);var n=this._meshes[e.uniqueId];n?n.color=t:this._meshes[e.uniqueId]={mesh:e,color:t,observerHighlight:e.onBeforeRenderObservable.add((function(e){r._excludedMeshes[e.uniqueId]?r.defaultStencilReference(e):e.getScene().getEngine().setStencilFunctionReference(r._instanceGlowingMeshStencilReference)})),observerDefault:e.onAfterRenderObservable.add(this.defaultStencilReference),glowEmissiveOnly:i},this._shouldRender=!0},i.prototype.removeMesh=function(e){var t=this._meshes[e.uniqueId];t&&(e.onBeforeRenderObservable.remove(t.observerHighlight),e.onAfterRenderObservable.remove(t.observerDefault)),this._meshes[e.uniqueId]=void 0,this._shouldRender=!1;for(var i in this._meshes)if(i){this._shouldRender=!0;break}},i.prototype.shouldRender=function(){return this.isEnabled&&this._shouldRender},i.prototype.setMainTextureSize=function(){this._options.mainTextureFixedSize?(this._mainTextureDesiredSize.width=this._options.mainTextureFixedSize,this._mainTextureDesiredSize.height=this._options.mainTextureFixedSize):(this._mainTextureDesiredSize.width=this._engine.getRenderingCanvas().width*this._options.mainTextureRatio,this._mainTextureDesiredSize.height=this._engine.getRenderingCanvas().height*this._options.mainTextureRatio,this._mainTextureDesiredSize.width=this._engine.needPOTTextures?e.Tools.GetExponentOfTwo(this._mainTextureDesiredSize.width,this._maxSize):this._mainTextureDesiredSize.width,this._mainTextureDesiredSize.height=this._engine.needPOTTextures?e.Tools.GetExponentOfTwo(this._mainTextureDesiredSize.height,this._maxSize):this._mainTextureDesiredSize.height)},i.prototype.defaultStencilReference=function(e){e.getScene().getEngine().setStencilFunctionReference(i.normalMeshStencilReference)},i.prototype.disposeTextureAndPostProcesses=function(){this._blurTexture.dispose(),this._mainTexture.dispose(),this._downSamplePostprocess.dispose(),this._horizontalBlurPostprocess.dispose(),this._verticalBlurPostprocess.dispose()},i.prototype.dispose=function(){var t=this._vertexBuffers[e.VertexBuffer.PositionKind];t&&(t.dispose(),this._vertexBuffers[e.VertexBuffer.PositionKind]=null),this._indexBuffer&&(this._scene.getEngine()._releaseBuffer(this._indexBuffer),this._indexBuffer=null),this.disposeTextureAndPostProcesses();for(var i in this._meshes){var r=this._meshes[i];r&&r.mesh&&(r.mesh.onBeforeRenderObservable.remove(r.observerHighlight),r.mesh.onAfterRenderObservable.remove(r.observerDefault))}this._meshes=null;for(var i in this._excludedMeshes){var r=this._excludedMeshes[i];r&&(r.mesh.onBeforeRenderObservable.remove(r.beforeRender),r.mesh.onAfterRenderObservable.remove(r.afterRender))}this._excludedMeshes=null;var n=this._scene.highlightLayers.indexOf(this,0);n>-1&&this._scene.highlightLayers.splice(n,1),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onBeforeRenderMainTextureObservable.clear(),this.onBeforeBlurObservable.clear(),this.onBeforeComposeObservable.clear(),this.onAfterComposeObservable.clear(),this.onSizeChangedObservable.clear()},i})();i.neutralColor=new e.Color4(0,0,0,0),i.glowingMeshStencilReference=2,i.normalMeshStencilReference=1,e.HighlightLayer=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e,t,i,r){this.name=e,this.meshesNames=t,this.rootUrl=i,this.sceneFilename=r,this.isCompleted=!1}return t.prototype.run=function(t,i,r){var n=this;e.SceneLoader.ImportMesh(this.meshesNames,this.rootUrl,this.sceneFilename,t,(function(e,t,r){n.loadedMeshes=e,n.loadedParticleSystems=t,n.loadedSkeletons=r,n.isCompleted=!0,n.onSuccess&&n.onSuccess(n),i()}),null,(function(){n.onError&&n.onError(n),r()}))},t})();e.MeshAssetTask=t;var i=(function(){function t(e,t){this.name=e,this.url=t,this.isCompleted=!1}return t.prototype.run=function(t,i,r){var n=this;e.Tools.LoadFile(this.url,(function(e){n.text=e,n.isCompleted=!0,n.onSuccess&&n.onSuccess(n),i()}),null,t.database,!1,(function(){n.onError&&n.onError(n),r()}))},t})();e.TextFileAssetTask=i;var r=(function(){function t(e,t){this.name=e,this.url=t,this.isCompleted=!1}return t.prototype.run=function(t,i,r){var n=this;e.Tools.LoadFile(this.url,(function(e){n.data=e,n.isCompleted=!0,n.onSuccess&&n.onSuccess(n),i()}),null,t.database,!0,(function(){n.onError&&n.onError(n),r()}))},t})();e.BinaryFileAssetTask=r;var n=(function(){function t(e,t){this.name=e,this.url=t,this.isCompleted=!1}return t.prototype.run=function(t,i,r){var n=this,o=new Image;e.Tools.SetCorsBehavior(this.url,o),o.onload=function(){n.image=o,n.isCompleted=!0,n.onSuccess&&n.onSuccess(n),i()},o.onerror=function(){n.onError&&n.onError(n),r()},o.src=this.url},t})();e.ImageAssetTask=n;var o=(function(){function t(t,i,r,n,o){void 0===o&&(o=e.Texture.TRILINEAR_SAMPLINGMODE),this.name=t,this.url=i,this.noMipmap=r,this.invertY=n,this.samplingMode=o,this.isCompleted=!1}return t.prototype.run=function(t,i,r){var n=this,o=function(){n.isCompleted=!0,n.onSuccess&&n.onSuccess(n),i()},s=function(){n.onError&&n.onError(n),r()};this.texture=new e.Texture(this.url,t,this.noMipmap,this.invertY,this.samplingMode,o,s)},t})();e.TextureAssetTask=o;var s=(function(){function t(e,t,i,r,n){this.name=e,this.url=t,this.extensions=i,this.noMipmap=r,this.files=n,this.isCompleted=!1}return t.prototype.run=function(t,i,r){var n=this,o=function(){n.isCompleted=!0,n.onSuccess&&n.onSuccess(n),i()},s=function(){n.onError&&n.onError(n),r()};this.texture=new e.CubeTexture(this.url,t,this.extensions,this.noMipmap,this.files,o,s)},t})();e.CubeTextureAssetTask=s;var a=(function(){function t(e,t,i,r,n,o,s){void 0===r&&(r=!1),void 0===n&&(n=!0),void 0===o&&(o=!1),void 0===s&&(s=!1),this.name=e,this.url=t,this.size=i,this.noMipmap=r,this.generateHarmonics=n,this.useInGammaSpace=o,this.usePMREMGenerator=s,this.isCompleted=!1}return t.prototype.run=function(t,i,r){var n=this,o=function(){n.isCompleted=!0,n.onSuccess&&n.onSuccess(n),i()},s=function(){n.onError&&n.onError(n),r()};this.texture=new e.HDRCubeTexture(this.url,t,this.size,this.noMipmap,this.generateHarmonics,this.useInGammaSpace,this.usePMREMGenerator,o,s)},t})();e.HDRCubeTextureAssetTask=a;var h=(function(){function h(e){this.tasks=new Array,this.waitingTasksCount=0,this.useDefaultLoadingScreen=!0,this._scene=e}return h.prototype.addMeshTask=function(e,i,r,n){var o=new t(e,i,r,n);return this.tasks.push(o),o},h.prototype.addTextFileTask=function(e,t){var r=new i(e,t);return this.tasks.push(r),r},h.prototype.addBinaryFileTask=function(e,t){var i=new r(e,t);return this.tasks.push(i),i},h.prototype.addImageTask=function(e,t){var i=new n(e,t);return this.tasks.push(i),i},h.prototype.addTextureTask=function(t,i,r,n,s){void 0===s&&(s=e.Texture.TRILINEAR_SAMPLINGMODE);var a=new o(t,i,r,n,s);return this.tasks.push(a),a},h.prototype.addCubeTextureTask=function(e,t,i,r,n){var o=new s(e,t,i,r,n);return this.tasks.push(o),o},h.prototype.addHDRCubeTextureTask=function(e,t,i,r,n,o,s){void 0===r&&(r=!1),void 0===n&&(n=!0),void 0===o&&(o=!1),void 0===s&&(s=!1);var h=new a(e,t,i,r,n,o,s);return this.tasks.push(h),h},h.prototype._decreaseWaitingTasksCount=function(){0===--this.waitingTasksCount&&(this.onFinish&&this.onFinish(this.tasks),this._scene.getEngine().hideLoadingUI())},h.prototype._runTask=function(e){var t=this;e.run(this._scene,(function(){t.onTaskSuccess&&t.onTaskSuccess(e),t._decreaseWaitingTasksCount()}),(function(){t.onTaskError&&t.onTaskError(e),t._decreaseWaitingTasksCount()}))},h.prototype.reset=function(){return this.tasks=new Array,this},h.prototype.load=function(){if(this.waitingTasksCount=this.tasks.length,0===this.waitingTasksCount)return this.onFinish&&this.onFinish(this.tasks),this;this.useDefaultLoadingScreen&&this._scene.getEngine().displayLoadingUI();for(var e=0;e0},enumerable:!0,configurable:!0}),r.prototype._sortLODLevels=function(){this._LODLevels.sort((function(e,t){return e.distancet.distance?-1:0}))},r.prototype.addLODLevel=function(t,i){if(i&&i._masterMesh)return e.Tools.Warn("You cannot use a mesh as LOD level twice"),this;var r=new e.Internals.MeshLODLevel(t,i);return this._LODLevels.push(r),i&&(i._masterMesh=this),this._sortLODLevels(),this},r.prototype.getLODLevelAtDistance=function(e){for(var t=0;ti)return this.onLODLevelSelection&&this.onLODLevelSelection(i,this,this._LODLevels[this._LODLevels.length-1].mesh),this;for(var r=0;r0){var r=this.getIndices().length,n=!1;if(t)n=!0;else for(var o=0,s=this.subMeshes;o=r){n=!0;break}if(a.verticesStart+a.verticesCount>=i){n=!0;break}}if(!n)return}return this.releaseSubMeshes(),new e.SubMesh(0,0,i,0,this.getTotalIndices(),this)},r.prototype.subdivide=function(t){if(!(t<1)){for(var i=this.getTotalIndices(),r=i/t|0,n=0;r%3!=0;)r++;this.releaseSubMeshes();for(var o=0;o=i);o++)e.SubMesh.CreateFromIndices(0,n,Math.min(r,i-n),this),n+=r;this.synchronizeInstances()}},r.prototype.setVerticesData=function(t,i,r,n){if(this._geometry)this._geometry.setVerticesData(t,i,r,n);else{var o=new e.VertexData;o.set(i,t);var s=this.getScene();new e.Geometry(e.Geometry.RandomId(),s,o,r,this)}return this},r.prototype.markVerticesDataAsUpdatable=function(e,t){void 0===t&&(t=!0),this.getVertexBuffer(e).isUpdatable()!==t&&this.setVerticesData(e,this.getVerticesData(e),t)},r.prototype.setVerticesBuffer=function(t){if(!this._geometry){var i=this.getScene();new e.Geometry(e.Geometry.RandomId(),i).applyToMesh(this)}return this._geometry.setVerticesBuffer(t),this},r.prototype.updateVerticesData=function(e,t,i,r){if(this._geometry)return r?(this.makeGeometryUnique(),this.updateVerticesData(e,t,i,!1)):this._geometry.updateVerticesData(e,t,i),this},r.prototype.updateMeshPositions=function(t,i){void 0===i&&(i=!0);var r=this.getVerticesData(e.VertexBuffer.PositionKind);if(t(r),this.updateVerticesData(e.VertexBuffer.PositionKind,r,!1,!1),i){var n=this.getIndices(),o=this.getVerticesData(e.VertexBuffer.NormalKind);e.VertexData.ComputeNormals(r,n,o),this.updateVerticesData(e.VertexBuffer.NormalKind,o,!1,!1)}return this},r.prototype.makeGeometryUnique=function(){if(this._geometry){var t=this._geometry,i=this._geometry.copy(e.Geometry.RandomId());return t.releaseForMesh(this,!0),i.applyToMesh(this),this}},r.prototype.setIndices=function(t,i){if(this._geometry)this._geometry.setIndices(t,i);else{var r=new e.VertexData;r.indices=t;var n=this.getScene();new e.Geometry(e.Geometry.RandomId(),n,r,!1,this)}return this},r.prototype.toLeftHanded=function(){if(this._geometry)return this._geometry.toLeftHanded(),this},r.prototype._bind=function(t,i,r){var n,o=this.getScene().getEngine();if(this._unIndexed)n=null;else switch(r){case e.Material.PointFillMode:n=null;break;case e.Material.WireFrameFillMode:n=t.getLinesIndexBuffer(this.getIndices(),o);break;default:case e.Material.TriangleFillMode:n=this._unIndexed?null:this._geometry.getIndexBuffer()}return this._geometry._bind(i,n),this},r.prototype._draw=function(t,i,r){if(!this._geometry||!this._geometry.getVertexBuffers()||!this._geometry.getIndexBuffer())return this;this.onBeforeDrawObservable.notifyObservers(this);var n=this.getScene().getEngine();switch(i){case e.Material.PointFillMode:n.drawPointClouds(t.verticesStart,t.verticesCount,r);break;case e.Material.WireFrameFillMode:this._unIndexed?n.drawUnIndexed(!1,t.verticesStart,t.verticesCount,r):n.draw(!1,0,r>0?t.linesIndexCount/2:t.linesIndexCount,r);break;default:this._unIndexed?n.drawUnIndexed(!0,t.verticesStart,t.verticesCount,r):n.draw(!0,t.indexStart,t.indexCount,r)}return this},r.prototype.registerBeforeRender=function(e){return this.onBeforeRenderObservable.add(e),this},r.prototype.unregisterBeforeRender=function(e){return this.onBeforeRenderObservable.removeCallback(e),this},r.prototype.registerAfterRender=function(e){return this.onAfterRenderObservable.add(e),this},r.prototype.unregisterAfterRender=function(e){return this.onAfterRenderObservable.removeCallback(e),this},r.prototype._getInstancesRenderList=function(e){var t=this.getScene();if(this._batchCache.mustReturn=!1,this._batchCache.renderSelf[e]=this.isEnabled()&&this.isVisible,this._batchCache.visibleInstances[e]=null,this._visibleInstances){var i=t.getRenderId(),r=t._isInIntermediateRendering()?this._visibleInstances.intermediateDefaultRenderId:this._visibleInstances.defaultRenderId;this._batchCache.visibleInstances[e]=this._visibleInstances[i];var n=this._renderId;if(!this._batchCache.visibleInstances[e]&&r&&(this._batchCache.visibleInstances[e]=this._visibleInstances[r],i=Math.max(r,i),n=Math.max(this._visibleInstances.selfDefaultRenderId,i)),this._batchCache.visibleInstances[e]&&this._batchCache.visibleInstances[e].length){if(this._renderIdForInstances[e]===i)return this._batchCache.mustReturn=!0,this._batchCache;i!==n&&(this._batchCache.renderSelf[e]=!1)}this._renderIdForInstances[e]=i}return this._batchCache},r.prototype._renderWithInstances=function(t,i,r,n,o){for(var s=r.visibleInstances[t._id],a=s.length+1,h=16*a*4,l=this._instancesBufferSize,c=this._instancesBuffer;this._instancesBufferSize-1;t--)if(i[t].id===e)return this.material=i[t],this;var r=this.getScene().multiMaterials;for(t=r.length-1;t>-1;t--)if(r[t].id===e)return this.material=r[t],this;return this},r.prototype.getAnimatables=function(){var e=[];return this.material&&e.push(this.material),this.skeleton&&e.push(this.skeleton),e},r.prototype.bakeTransformIntoVertices=function(t){if(!this.isVerticesDataPresent(e.VertexBuffer.PositionKind))return this;var i=this.subMeshes.splice(0);this._resetPointsArrayCache();var r,n=this.getVerticesData(e.VertexBuffer.PositionKind),o=[];for(r=0;r-1&&(o.morphTargetManager=i.getMorphTargetManagerById(t.morphTargetManagerId)),t.skeletonId>-1&&(o.skeleton=i.getLastSkeletonByID(t.skeletonId),t.numBoneInfluencers&&(o.numBoneInfluencers=t.numBoneInfluencers)),t.animations){for(var s=0;s4,l=h?this.getVerticesData(e.VertexBuffer.MatricesIndicesExtraKind):null,c=h?this.getVerticesData(e.VertexBuffer.MatricesWeightsExtraKind):null,u=t.getTransformMatrices(this),f=e.Vector3.Zero(),d=new e.Matrix,p=new e.Matrix,m=0,_=0;_0;o++)e.Matrix.FromFloat32ArrayToRefScaled(u,16*s[m+o],g,p),d.addToSelf(p);if(h)for(o=0;o<4&&(g=c[m+o])>0;o++)e.Matrix.FromFloat32ArrayToRefScaled(u,16*l[m+o],g,p),d.addToSelf(p);e.Vector3.TransformCoordinatesFromFloatsToRef(this._sourcePositions[_],this._sourcePositions[_+1],this._sourcePositions[_+2],d,f),f.toArray(r,_),e.Vector3.TransformNormalFromFloatsToRef(this._sourceNormals[_],this._sourceNormals[_+1],this._sourceNormals[_+2],d,f),f.toArray(n,_),d.reset()}return this.updateVerticesData(e.VertexBuffer.PositionKind,r),this.updateVerticesData(e.VertexBuffer.NormalKind,n),this},r.MinMax=function(e){var t=null,i=null;return e.forEach((function(e,r,n){var o=e.getBoundingInfo().boundingBox;t?(t.MinimizeInPlace(o.minimumWorld),i.MaximizeInPlace(o.maximumWorld)):(t=o.minimumWorld,i=o.maximumWorld)})),{min:t,max:i}},r.Center=function(t){var i=t instanceof Array?e.Mesh.MinMax(t):t;return e.Vector3.Center(i.min,i.max)},r.MergeMeshes=function(t,i,n,o,s){void 0===i&&(i=!0);var a;if(!n){var h=0;for(a=0;a65536)return e.Tools.Warn("Cannot merge meshes because resulting mesh will have more than 65536 vertices. Please use allow32BitsIndices = true to use 32 bits indices"),null}var l,c,u,f=new Array;for(a=0;aa&&(a=c)}return new i(e,s,a-s+1,t,r,n,o)},i})(t);e.SubMesh=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(BABYLON){var EffectFallbacks=(function(){function e(){this._defines={},this._currentRank=32,this._maxRank=-1}return e.prototype.addFallback=function(e,t){this._defines[e]||(ethis._maxRank&&(this._maxRank=e),this._defines[e]=new Array),this._defines[e].push(t)},e.prototype.addCPUSkinningFallback=function(e,t){this._meshRank=e,this._mesh=t,ethis._maxRank&&(this._maxRank=e)},Object.defineProperty(e.prototype,"isMoreFallbacks",{get:function(){return this._currentRank<=this._maxRank},enumerable:!0,configurable:!0}),e.prototype.reduce=function(e){if(this._mesh&&this._mesh.computeBonesUsingShaders&&this._mesh.numBoneInfluencers>0){this._mesh.computeBonesUsingShaders=!1,e=e.replace("#define NUM_BONE_INFLUENCERS "+this._mesh.numBoneInfluencers,"#define NUM_BONE_INFLUENCERS 0"),BABYLON.Tools.Log("Falling back to CPU skinning for "+this._mesh.name);for(var t=this._mesh.getScene(),i=0;i0&&(r.computeBonesUsingShaders=!1)}}else{var n=this._defines[this._currentRank];if(n)for(var i=0;i-1?e:BABYLON.Engine.ShadersRepository+e,BABYLON.Tools.LoadFile(i+".vertex.fx",t)},Effect.prototype._loadFragmentShader=function(e,t){if(e instanceof HTMLElement){return void t(BABYLON.Tools.GetDOMTextContent(e))}if("base64:"===e.substr(0,7)){return void t(window.atob(e.substr(7)))}if(Effect.ShadersStore[e+"PixelShader"])return void t(Effect.ShadersStore[e+"PixelShader"]);if(Effect.ShadersStore[e+"FragmentShader"])return void t(Effect.ShadersStore[e+"FragmentShader"]);var i;i="."===e[0]||"/"===e[0]||e.indexOf("http")>-1?e:BABYLON.Engine.ShadersRepository+e,BABYLON.Tools.LoadFile(i+".fragment.fx",t)},Effect.prototype._dumpShadersSource=function(e,t,i){var r=this._engine.webGLVersion>1?"#version 300 es\n":"",n=r+(i?i+"\n":"");e=n+e,t=n+t;var o=2,s="\n1\t"+e.replace(/\n/gm,(function(){return"\n"+o+++"\t"}));o=2;var a="\n1\t"+t.replace(/\n/gm,(function(){return"\n"+o+++"\t"}));this.name.vertexElement?(BABYLON.Tools.Error("Vertex shader: "+this.name.vertexElement+s),BABYLON.Tools.Error("Fragment shader: "+this.name.fragmentElement+a)):this.name.vertex?(BABYLON.Tools.Error("Vertex shader: "+this.name.vertex+s),BABYLON.Tools.Error("Fragment shader: "+this.name.fragment+a)):(BABYLON.Tools.Error("Vertex shader: "+this.name+s),BABYLON.Tools.Error("Fragment shader: "+this.name+a))},Effect.prototype._processShaderConversion=function(e,t,i){var r=this._processPrecision(e);if(1==this._engine.webGLVersion)return void i(r);if(-1!==r.indexOf("#version 3"))return void i(r.replace("#version 300 es",""));var n=r.replace(/#extension.+(GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth).+enable/g,"");n=n.replace(/varying(?![\n\r])\s/g,t?"in ":"out "),n=n.replace(/attribute[ \t]/g,"in "),n=n.replace(/[ \t]attribute/g," in"),t&&(n=n.replace(/texture2DLodEXT\(/g,"textureLod("),n=n.replace(/textureCubeLodEXT\(/g,"textureLod("),n=n.replace(/texture2D\(/g,"texture("),n=n.replace(/textureCube\(/g,"texture("),n=n.replace(/gl_FragDepthEXT/g,"gl_FragDepth"),n=n.replace(/gl_FragColor/g,"glFragColor"),n=n.replace(/void\s+?main\(/g,"out vec4 glFragColor;\nvoid main(")),i(n)},Effect.prototype._processIncludes=function(e,t){for(var i=this,r=/#include<(.+)>(\((.*)\))*(\[(.*)\])*/g,n=r.exec(e),o=new String(e);null!=n;){var s=n[1];if(-1!==s.indexOf("__decl__")&&(s=s.replace(/__decl__/,""),1!=this._engine.webGLVersion&&(s=s.replace(/Vertex/,"Ubo"),s=s.replace(/Fragment/,"Ubo")),s+="Declaration"),!Effect.IncludesShadersStore[s]){var a=BABYLON.Engine.ShadersRepository+"ShadersInclude/"+s+".fx";return void BABYLON.Tools.LoadFile(a,(function(e){Effect.IncludesShadersStore[s]=e,i._processIncludes(o,t)}))}var h=Effect.IncludesShadersStore[s];if(n[2])for(var l=n[3].split(","),c=0;c1)for(var s in this._uniformBuffersNames)this.bindUniformBlock(s,this._uniformBuffersNames[s]);this._uniforms=o.getUniforms(this._program,this._uniformsNames),this._attributes=o.getAttributes(this._program,i);var a;for(a=0;a0&&(result+=line+"\r\n")}return result}, +Effect.prototype._evaluateDefinesOnString=function(e){for(var t={children:[]},i=t,r=e.split("\n"),n=0;n0,i.NUM_MORPH_INFLUENCERS=s.numInfluencers}else i.MORPHTARGETS_TANGENT=!1,i.MORPHTARGETS_NORMAL=!1,i.MORPHTARGETS=!1,i.NUM_MORPH_INFLUENCERS=0;return!0},t.PrepareDefinesForLights=function(t,i,r,n,o,s){if(void 0===o&&(o=4),void 0===s&&(s=!1),!r._areLightsDirty)return r._needNormals;var a=0,h=!1,l=!1,c=!1,u=!1,f=!1;if(t.lightsEnabled&&!s)for(var d=0,p=i._lightSources;d0&&t.addFallback(r,"LIGHT"+r),e["SHADOW"+r]&&t.addFallback(0,"SHADOW"+r),e["SHADOWPCF"+r]&&t.addFallback(0,"SHADOWPCF"+r),e["SHADOWESM"+r]&&t.addFallback(0,"SHADOWESM"+r)},t.PrepareAttributesForMorphTargets=function(t,i,r){var n=r.NUM_MORPH_INFLUENCERS;if(n>0)for(var o=e.Engine.LastCreatedEngine.getCaps().maxVertexAttribs,s=i.morphTargetManager,a=s.supportsNormals&&r.NORMAL,h=s.supportsTangents&&r.TANGENT,l=0;lo&&e.Tools.Error("Cannot add more vertex attributes for mesh "+i.name)},t.PrepareAttributesForBones=function(t,i,r,n){r.NUM_BONE_INFLUENCERS>0&&(n.addCPUSkinningFallback(0,i),t.push(e.VertexBuffer.MatricesIndicesKind),t.push(e.VertexBuffer.MatricesWeightsKind),r.NUM_BONE_INFLUENCERS>4&&(t.push(e.VertexBuffer.MatricesIndicesExtraKind),t.push(e.VertexBuffer.MatricesWeightsExtraKind)))},t.PrepareAttributesForInstances=function(e,t){t.INSTANCES&&(e.push("world0"),e.push("world1"),e.push("world2"),e.push("world3"))},t.BindLightShadow=function(e,t,i,r,n){if(e.shadowEnabled&&i.receiveShadows){var o=e.getShadowGenerator();o&&o.bindShadowLight(r,n)}},t.BindLightProperties=function(e,t,i){e.transferToEffect(t,i+"")},t.BindLights=function(i,r,n,o,s,a){void 0===s&&(s=4),void 0===a&&(a=!1);for(var h=0,l=0,c=r._lightSources;l1,n||this._scene.materials.push(this)}return Object.defineProperty(t,"TriangleFillMode",{get:function(){return t._TriangleFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(t,"WireFrameFillMode",{get:function(){return t._WireFrameFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(t,"PointFillMode",{get:function(){return t._PointFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(t,"ClockWiseSideOrientation",{get:function(){return t._ClockWiseSideOrientation},enumerable:!0,configurable:!0}),Object.defineProperty(t,"CounterClockWiseSideOrientation",{get:function(){return t._CounterClockWiseSideOrientation},enumerable:!0,configurable:!0}),Object.defineProperty(t,"TextureDirtyFlag",{get:function(){return t._TextureDirtyFlag},enumerable:!0,configurable:!0}),Object.defineProperty(t,"LightDirtyFlag",{get:function(){return t._LightDirtyFlag},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FresnelDirtyFlag",{get:function(){return t._FresnelDirtyFlag},enumerable:!0,configurable:!0}),Object.defineProperty(t,"AttributesDirtyFlag",{get:function(){return t._AttributesDirtyFlag},enumerable:!0,configurable:!0}),Object.defineProperty(t,"MiscDirtyFlag",{get:function(){return t._MiscDirtyFlag},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"backFaceCulling",{get:function(){return this._backFaceCulling},set:function(e){this._backFaceCulling!==e&&(this._backFaceCulling=e,this.markAsDirty(t.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onBind",{set:function(e){this._onBindObserver&&this.onBindObservable.remove(this._onBindObserver),this._onBindObserver=this.onBindObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"fogEnabled",{get:function(){return this._fogEnabled},set:function(e){this._fogEnabled!==e&&(this._fogEnabled=e,this.markAsDirty(t.MiscDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"wireframe",{get:function(){return this._fillMode===t.WireFrameFillMode},set:function(e){this._fillMode=e?t.WireFrameFillMode:t.TriangleFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"pointsCloud",{get:function(){return this._fillMode===t.PointFillMode},set:function(e){this._fillMode=e?t.PointFillMode:t.TriangleFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"fillMode",{get:function(){return this._fillMode},set:function(e){this._fillMode!==e&&(this._fillMode=e,this.markAsDirty(t.MiscDirtyFlag))},enumerable:!0,configurable:!0}),t.prototype.toString=function(e){return"Name: "+this.name},t.prototype.getClassName=function(){return"Material"},Object.defineProperty(t.prototype,"isFrozen",{get:function(){return this.checkReadyOnlyOnce},enumerable:!0,configurable:!0}),t.prototype.freeze=function(){this.checkReadyOnlyOnce=!0},t.prototype.unfreeze=function(){this.checkReadyOnlyOnce=!1},t.prototype.isReady=function(e,t){return!0},t.prototype.isReadyForSubMesh=function(e,t,i){return!1},t.prototype.getEffect=function(){return this._effect},t.prototype.getScene=function(){return this._scene},t.prototype.needAlphaBlending=function(){return this.alpha<1},t.prototype.needAlphaTesting=function(){return!1},t.prototype.getAlphaTestTexture=function(){return null},t.prototype.markDirty=function(){this._wasPreviouslyReady=!1},t.prototype._preBind=function(e){var i=this._scene.getEngine(),r=this.sideOrientation===t.ClockWiseSideOrientation;i.enableEffect(e||this._effect),i.setState(this.backFaceCulling,this.zOffset,!1,r)},t.prototype.bind=function(e,t){},t.prototype.bindForSubMesh=function(e,t,i){},t.prototype.bindOnlyWorldMatrix=function(e){},t.prototype.bindSceneUniformBuffer=function(e,t){t.bindToEffect(e,"Scene")},t.prototype.bindView=function(e){this._useUBO?this.bindSceneUniformBuffer(e,this.getScene().getSceneUniformBuffer()):e.setMatrix("view",this.getScene().getViewMatrix())},t.prototype.bindViewProjection=function(e){this._useUBO?this.bindSceneUniformBuffer(e,this.getScene().getSceneUniformBuffer()):e.setMatrix("viewProjection",this.getScene().getTransformMatrix())},t.prototype._afterBind=function(e){if(this._scene._cachedMaterial=this,this.onBindObservable.notifyObservers(e),this.disableDepthWrite){var t=this._scene.getEngine();this._cachedDepthWriteState=t.getDepthWrite(),t.setDepthWrite(!1)}},t.prototype.unbind=function(){if(this.onUnBindObservable.notifyObservers(this),this.disableDepthWrite){this._scene.getEngine().setDepthWrite(this._cachedDepthWriteState)}},t.prototype.getActiveTextures=function(){return[]},t.prototype.hasTexture=function(e){return!1},t.prototype.clone=function(e){return null},t.prototype.getBindedMeshes=function(){for(var e=new Array,t=0;t=0&&this._scene.materials.splice(i,1),i=0;ia?a:Math.floor(h);var l,c,u,f,d=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,p=i.uvs,m=i.colors,_=[],g=[],v=[],y=[],x=[],b=[],A=[],T=[],E=[],P=[];if(r.length<2){var M=[],S=[];for(u=0;u0&&(D=C[f].subtract(C[f-1]).length(),B=D+A[c],x[c].push(B),A[c]=B),f++;o&&(f--,_.push(C[0].x,C[0].y,C[0].z),D=C[f].subtract(C[0]).length(),B=D+A[c],x[c].push(B),A[c]=B),E[c]=R+I,P[c]=O,O+=R+I}var L,w,F,N;for(u=0;u1?1:i.arc||1,h=i.slice<=0?1:i.slice||1,l=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,c=new e.Vector3(n/2,o/2,s/2),u=2+r,f=2*u,d=[],p=[],m=[],_=[],g=0;g<=u;g++){for(var v=g/u,y=v*Math.PI*h,x=0;x<=f;x++){var b=x/f,A=b*Math.PI*2*a,T=e.Matrix.RotationZ(-y),E=e.Matrix.RotationY(A),P=e.Vector3.TransformCoordinates(e.Vector3.Up(),T),M=e.Vector3.TransformCoordinates(P,E),S=M.multiply(c),C=M.divide(c).normalize();p.push(S.x,S.y,S.z),m.push(C.x,C.y,C.z),_.push(b,v)}if(g>0)for(var R=p.length/3,O=R-2*(f+1);O+f+21?1:i.arc||1,f=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,d=i.faceUV||new Array(3),p=i.faceColors,m=1!==u&&c?2:0,_=l?h:1,g=2+(1+m)*_;for(r=0;r0&&(i.push(o-1),i.push(o)),o++;var l=new t;return l.indices=i,l.positions=r,l},t.CreateDashedLines=function(i){var r=i.dashSize||3,n=i.gapSize||1,o=i.dashNb||200,s=i.points,a=new Array,h=new Array,l=e.Vector3.Zero(),c=0,u=0,f=0,d=0,p=0,m=0,_=0;for(_=0;_1?1:i.arc||1,c=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE;r.push(0,0,0),s.push(.5,.5);for(var u=2*Math.PI*l,f=u/h,d=0;d=r.length?0:i.type||0,u=i.size,f=i.sizeX||u||1,d=i.sizeY||u||1,p=i.sizeZ||u||1,m=i.custom||r[c],_=m.face.length,g=i.faceUV||new Array(_),v=i.faceColors,y=void 0===i.flat||i.flat,x=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,b=[],A=[],T=[],E=[],P=[],M=0,S=0,C=[],R=0,O=0;if(y)for(O=0;O<_;O++)v&&void 0===v[O]&&(v[O]=new e.Color4(1,1,1,1)),g&&void 0===g[O]&&(g[O]=new e.Vector4(0,0,1,1));if(y)for(O=0;O<_;O++){var I=m.face[O].length;for(s=2*Math.PI/I,a=.5*Math.tan(s/2),h=.5,R=0;Rr.bbSize.y?r.bbSize.x:r.bbSize.y;W=W>r.bbSize.z?W:r.bbSize.z;var H=r.subDiv.X*r.ratio/r.bbSize.x,j=r.subDiv.Y*r.ratio/r.bbSize.y,X=r.subDiv.Z*r.ratio/r.bbSize.z,K=r.subDiv.max*r.subDiv.max;r.facetPartitioning.length=0}for(n=0;n0&&(this._indexBuffer=this._engine.createIndexBuffer(this._indices)),this._indexBuffer&&(this._indexBuffer.references=i)},t.prototype.notifyUpdate=function(e){this.onGeometryUpdated&&this.onGeometryUpdated(this,e);for(var t=0,i=this._meshes;t0){for(var i=0;i0){for(var i=0;i0){for(var i=0;i0){var h=new Float32Array(i,a.positionsAttrDesc.offset,a.positionsAttrDesc.count);r.setVerticesData(e.VertexBuffer.PositionKind,h,!1)}if(a.normalsAttrDesc&&a.normalsAttrDesc.count>0){var l=new Float32Array(i,a.normalsAttrDesc.offset,a.normalsAttrDesc.count);r.setVerticesData(e.VertexBuffer.NormalKind,l,!1)}if(a.uvsAttrDesc&&a.uvsAttrDesc.count>0){var c=new Float32Array(i,a.uvsAttrDesc.offset,a.uvsAttrDesc.count);r.setVerticesData(e.VertexBuffer.UVKind,c,!1)}if(a.uvs2AttrDesc&&a.uvs2AttrDesc.count>0){var u=new Float32Array(i,a.uvs2AttrDesc.offset,a.uvs2AttrDesc.count);r.setVerticesData(e.VertexBuffer.UV2Kind,u,!1)}if(a.uvs3AttrDesc&&a.uvs3AttrDesc.count>0){var f=new Float32Array(i,a.uvs3AttrDesc.offset,a.uvs3AttrDesc.count);r.setVerticesData(e.VertexBuffer.UV3Kind,f,!1)}if(a.uvs4AttrDesc&&a.uvs4AttrDesc.count>0){var d=new Float32Array(i,a.uvs4AttrDesc.offset,a.uvs4AttrDesc.count);r.setVerticesData(e.VertexBuffer.UV4Kind,d,!1)}if(a.uvs5AttrDesc&&a.uvs5AttrDesc.count>0){var p=new Float32Array(i,a.uvs5AttrDesc.offset,a.uvs5AttrDesc.count);r.setVerticesData(e.VertexBuffer.UV5Kind,p,!1)}if(a.uvs6AttrDesc&&a.uvs6AttrDesc.count>0){var m=new Float32Array(i,a.uvs6AttrDesc.offset,a.uvs6AttrDesc.count);r.setVerticesData(e.VertexBuffer.UV6Kind,m,!1)}if(a.colorsAttrDesc&&a.colorsAttrDesc.count>0){var _=new Float32Array(i,a.colorsAttrDesc.offset,a.colorsAttrDesc.count);r.setVerticesData(e.VertexBuffer.ColorKind,_,!1,a.colorsAttrDesc.stride)}if(a.matricesIndicesAttrDesc&&a.matricesIndicesAttrDesc.count>0){var g=new Int32Array(i,a.matricesIndicesAttrDesc.offset,a.matricesIndicesAttrDesc.count);r.setVerticesData(e.VertexBuffer.MatricesIndicesKind,g,!1)}if(a.matricesWeightsAttrDesc&&a.matricesWeightsAttrDesc.count>0){var v=new Float32Array(i,a.matricesWeightsAttrDesc.offset,a.matricesWeightsAttrDesc.count);r.setVerticesData(e.VertexBuffer.MatricesWeightsKind,v,!1)}if(a.indicesAttrDesc&&a.indicesAttrDesc.count>0){var y=new Int32Array(i,a.indicesAttrDesc.offset,a.indicesAttrDesc.count);r.setIndices(y)}if(a.subMeshesAttrDesc&&a.subMeshesAttrDesc.count>0){var x=new Int32Array(i,a.subMeshesAttrDesc.offset,5*a.subMeshesAttrDesc.count);r.subMeshes=[];for(var b=0;b>8),S.push((16711680&C)>>16),S.push(C>>24)}r.setVerticesData(e.VertexBuffer.MatricesIndicesKind,S,i.matricesIndices._updatable)}if(i.matricesIndicesExtra)if(i.matricesIndicesExtra._isExpanded)delete i.matricesIndices._isExpanded,r.setVerticesData(e.VertexBuffer.MatricesIndicesExtraKind,i.matricesIndicesExtra,i.matricesIndicesExtra._updatable);else{for(var S=[],b=0;b>8),S.push((16711680&C)>>16),S.push(C>>24)}r.setVerticesData(e.VertexBuffer.MatricesIndicesExtraKind,S,i.matricesIndicesExtra._updatable)}i.matricesWeights&&(t._CleanMatricesWeights(i.matricesWeights,i.numBoneInfluencers),r.setVerticesData(e.VertexBuffer.MatricesWeightsKind,i.matricesWeights,i.matricesWeights._updatable)),i.matricesWeightsExtra&&(t._CleanMatricesWeights(i.matricesWeightsExtra,i.numBoneInfluencers),r.setVerticesData(e.VertexBuffer.MatricesWeightsExtraKind,i.matricesWeightsExtra,i.matricesWeights._updatable)),r.setIndices(i.indices)}if(i.subMeshes){r.subMeshes=[];for(var R=0;Ra&&(a=t[n+h],s=n+h);t[s]+=Math.max(0,1-o)}},t.Parse=function(i,r,n){if(r.getGeometryByID(i.id))return null;var o=new t(i.id,r,null,i.updatable);return e.Tags&&e.Tags.AddTagsTo(o,i.tags),i.delayLoadingFile?(o.delayLoadState=e.Engine.DELAYLOADSTATE_NOTLOADED,o.delayLoadingFile=n+i.delayLoadingFile,o._boundingInfo=new e.BoundingInfo(e.Vector3.FromArray(i.boundingBoxMinimum),e.Vector3.FromArray(i.boundingBoxMaximum)),o._delayInfo=[],i.hasUVs&&o._delayInfo.push(e.VertexBuffer.UVKind),i.hasUVs2&&o._delayInfo.push(e.VertexBuffer.UV2Kind),i.hasUVs3&&o._delayInfo.push(e.VertexBuffer.UV3Kind),i.hasUVs4&&o._delayInfo.push(e.VertexBuffer.UV4Kind),i.hasUVs5&&o._delayInfo.push(e.VertexBuffer.UV5Kind),i.hasUVs6&&o._delayInfo.push(e.VertexBuffer.UV6Kind),i.hasColors&&o._delayInfo.push(e.VertexBuffer.ColorKind),i.hasMatricesIndices&&o._delayInfo.push(e.VertexBuffer.MatricesIndicesKind),i.hasMatricesWeights&&o._delayInfo.push(e.VertexBuffer.MatricesWeightsKind),o._delayLoadingFunction=e.VertexData.ImportVertexData):e.VertexData.ImportVertexData(i,o),r.pushGeometry(o,!0),o},t})();e.Geometry=t,(function(t){!(function(i){var r=(function(e){function t(t,i,r,n){var o=e.call(this,t,i,null,!1,n)||this;return o._canBeRegenerated=r,o._beingRegenerated=!0,o.regenerate(),o._beingRegenerated=!1,o}return __extends(t,e),t.prototype.canBeRegenerated=function(){return this._canBeRegenerated},t.prototype.regenerate=function(){this._canBeRegenerated&&(this._beingRegenerated=!0,this.setAllVerticesData(this._regenerateVertexData(),!1),this._beingRegenerated=!1)},t.prototype.asNewGeometry=function(t){return e.prototype.copy.call(this,t)},t.prototype.setAllVerticesData=function(t,i){this._beingRegenerated&&e.prototype.setAllVerticesData.call(this,t,!1)},t.prototype.setVerticesData=function(t,i,r){this._beingRegenerated&&e.prototype.setVerticesData.call(this,t,i,!1)},t.prototype._regenerateVertexData=function(){throw new Error("Abstract method")},t.prototype.copy=function(e){throw new Error("Must be overriden in sub-classes.")},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.canBeRegenerated=this.canBeRegenerated(),t},t})(t);i._Primitive=r;var n=(function(t){function i(i,r,n,o,s,a,h,l,c){void 0===c&&(c=e.Mesh.DEFAULTSIDE);var u=t.call(this,i,r,h,l)||this;return u.pathArray=n,u.closeArray=o,u.closePath=s,u.offset=a,u.side=c,u}return __extends(i,t),i.prototype._regenerateVertexData=function(){return e.VertexData.CreateRibbon({pathArray:this.pathArray,closeArray:this.closeArray,closePath:this.closePath,offset:this.offset,sideOrientation:this.side})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.pathArray,this.closeArray,this.closePath,this.offset,this.canBeRegenerated(),null,this.side)},i})(r);i.Ribbon=n;var o=(function(i){function r(t,r,n,o,s,a){void 0===a&&(a=e.Mesh.DEFAULTSIDE);var h=i.call(this,t,r,o,s)||this;return h.size=n,h.side=a,h}return __extends(r,i),r.prototype._regenerateVertexData=function(){return e.VertexData.CreateBox({size:this.size,sideOrientation:this.side})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.size,this.canBeRegenerated(),null,this.side)},r.prototype.serialize=function(){var e=i.prototype.serialize.call(this);return e.size=this.size,e},r.Parse=function(i,r){if(r.getGeometryByID(i.id))return null;var n=new t.Primitives.Box(i.id,r,i.size,i.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,i.tags),r.pushGeometry(n,!0),n},r})(r);i.Box=o;var s=(function(i){function r(t,r,n,o,s,a,h){void 0===h&&(h=e.Mesh.DEFAULTSIDE);var l=i.call(this,t,r,s,a)||this;return l.segments=n,l.diameter=o,l.side=h,l}return __extends(r,i),r.prototype._regenerateVertexData=function(){return e.VertexData.CreateSphere({segments:this.segments,diameter:this.diameter,sideOrientation:this.side})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.segments,this.diameter,this.canBeRegenerated(),null,this.side)},r.prototype.serialize=function(){var e=i.prototype.serialize.call(this);return e.segments=this.segments,e.diameter=this.diameter,e},r.Parse=function(i,r){if(r.getGeometryByID(i.id))return null;var n=new t.Primitives.Sphere(i.id,r,i.segments,i.diameter,i.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,i.tags),r.pushGeometry(n,!0),n},r})(r);i.Sphere=s;var a=(function(t){function i(i,r,n,o,s,a,h){void 0===h&&(h=e.Mesh.DEFAULTSIDE);var l=t.call(this,i,r,s,a)||this;return l.radius=n,l.tessellation=o,l.side=h,l}return __extends(i,t),i.prototype._regenerateVertexData=function(){return e.VertexData.CreateDisc({radius:this.radius,tessellation:this.tessellation,sideOrientation:this.side})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.radius,this.tessellation,this.canBeRegenerated(),null,this.side)},i})(r);i.Disc=a;var h=(function(i){function r(t,r,n,o,s,a,h,l,c,u){void 0===h&&(h=1),void 0===u&&(u=e.Mesh.DEFAULTSIDE);var f=i.call(this,t,r,l,c)||this;return f.height=n,f.diameterTop=o,f.diameterBottom=s,f.tessellation=a,f.subdivisions=h,f.side=u,f}return __extends(r,i),r.prototype._regenerateVertexData=function(){return e.VertexData.CreateCylinder({height:this.height,diameterTop:this.diameterTop,diameterBottom:this.diameterBottom,tessellation:this.tessellation,subdivisions:this.subdivisions,sideOrientation:this.side})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.height,this.diameterTop,this.diameterBottom,this.tessellation,this.subdivisions,this.canBeRegenerated(),null,this.side)},r.prototype.serialize=function(){var e=i.prototype.serialize.call(this);return e.height=this.height,e.diameterTop=this.diameterTop,e.diameterBottom=this.diameterBottom,e.tessellation=this.tessellation,e},r.Parse=function(i,r){if(r.getGeometryByID(i.id))return null;var n=new t.Primitives.Cylinder(i.id,r,i.height,i.diameterTop,i.diameterBottom,i.tessellation,i.subdivisions,i.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,i.tags),r.pushGeometry(n,!0),n},r})(r);i.Cylinder=h;var l=(function(i){function r(t,r,n,o,s,a,h,l){void 0===l&&(l=e.Mesh.DEFAULTSIDE);var c=i.call(this,t,r,a,h)||this;return c.diameter=n,c.thickness=o,c.tessellation=s,c.side=l,c}return __extends(r,i),r.prototype._regenerateVertexData=function(){return e.VertexData.CreateTorus({diameter:this.diameter,thickness:this.thickness,tessellation:this.tessellation,sideOrientation:this.side})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.diameter,this.thickness,this.tessellation,this.canBeRegenerated(),null,this.side)},r.prototype.serialize=function(){var e=i.prototype.serialize.call(this);return e.diameter=this.diameter,e.thickness=this.thickness,e.tessellation=this.tessellation,e},r.Parse=function(i,r){if(r.getGeometryByID(i.id))return null;var n=new t.Primitives.Torus(i.id,r,i.diameter,i.thickness,i.tessellation,i.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,i.tags),r.pushGeometry(n,!0),n},r})(r);i.Torus=l;var c=(function(i){function r(e,t,r,n,o,s,a){var h=i.call(this,e,t,s,a)||this;return h.width=r,h.height=n,h.subdivisions=o,h}return __extends(r,i),r.prototype._regenerateVertexData=function(){return e.VertexData.CreateGround({width:this.width,height:this.height,subdivisions:this.subdivisions})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.width,this.height,this.subdivisions,this.canBeRegenerated(),null)},r.prototype.serialize=function(){var e=i.prototype.serialize.call(this);return e.width=this.width,e.height=this.height,e.subdivisions=this.subdivisions,e},r.Parse=function(i,r){if(r.getGeometryByID(i.id))return null;var n=new t.Primitives.Ground(i.id,r,i.width,i.height,i.subdivisions,i.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,i.tags),r.pushGeometry(n,!0),n},r})(r);i.Ground=c;var u=(function(t){function i(e,i,r,n,o,s,a,h,l,c){var u=t.call(this,e,i,l,c)||this;return u.xmin=r,u.zmin=n,u.xmax=o,u.zmax=s,u.subdivisions=a,u.precision=h,u}return __extends(i,t),i.prototype._regenerateVertexData=function(){return e.VertexData.CreateTiledGround({xmin:this.xmin,zmin:this.zmin,xmax:this.xmax,zmax:this.zmax,subdivisions:this.subdivisions,precision:this.precision})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.xmin,this.zmin,this.xmax,this.zmax,this.subdivisions,this.precision,this.canBeRegenerated(),null)},i})(r);i.TiledGround=u;var f=(function(i){function r(t,r,n,o,s,a){void 0===a&&(a=e.Mesh.DEFAULTSIDE);var h=i.call(this,t,r,o,s)||this;return h.size=n,h.side=a,h}return __extends(r,i),r.prototype._regenerateVertexData=function(){return e.VertexData.CreatePlane({size:this.size,sideOrientation:this.side})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.size,this.canBeRegenerated(),null,this.side)},r.prototype.serialize=function(){var e=i.prototype.serialize.call(this);return e.size=this.size,e},r.Parse=function(i,r){if(r.getGeometryByID(i.id))return null;var n=new t.Primitives.Plane(i.id,r,i.size,i.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,i.tags),r.pushGeometry(n,!0),n},r})(r);i.Plane=f;var d=(function(i){function r(t,r,n,o,s,a,h,l,c,u,f){void 0===f&&(f=e.Mesh.DEFAULTSIDE);var d=i.call(this,t,r,c,u)||this;return d.radius=n,d.tube=o,d.radialSegments=s,d.tubularSegments=a,d.p=h,d.q=l,d.side=f,d}return __extends(r,i),r.prototype._regenerateVertexData=function(){return e.VertexData.CreateTorusKnot({radius:this.radius,tube:this.tube,radialSegments:this.radialSegments,tubularSegments:this.tubularSegments,p:this.p,q:this.q,sideOrientation:this.side})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.radius,this.tube,this.radialSegments,this.tubularSegments,this.p,this.q,this.canBeRegenerated(),null,this.side)},r.prototype.serialize=function(){var e=i.prototype.serialize.call(this);return e.radius=this.radius,e.tube=this.tube,e.radialSegments=this.radialSegments,e.tubularSegments=this.tubularSegments,e.p=this.p,e.q=this.q,e},r.Parse=function(i,r){if(r.getGeometryByID(i.id))return null;var n=new t.Primitives.TorusKnot(i.id,r,i.radius,i.tube,i.radialSegments,i.tubularSegments,i.p,i.q,i.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,i.tags),r.pushGeometry(n,!0),n},r})(r);i.TorusKnot=d})(t.Primitives||(t.Primitives={}))})(t=e.Geometry||(e.Geometry={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e){this._vertexBuffers={},this._scene=e}return t.prototype._prepareBuffers=function(){if(!this._vertexBuffers[e.VertexBuffer.PositionKind]){var t=[];t.push(1,1),t.push(-1,1),t.push(-1,-1),t.push(1,-1),this._vertexBuffers[e.VertexBuffer.PositionKind]=new e.VertexBuffer(this._scene.getEngine(),t,e.VertexBuffer.PositionKind,!1,!1,2);var i=[];i.push(0),i.push(1),i.push(2),i.push(0),i.push(2),i.push(3),this._indexBuffer=this._scene.getEngine().createIndexBuffer(i)}},t.prototype._prepareFrame=function(e,t){var t=t||this._scene.activeCamera._postProcesses;return!(0===t.length||!this._scene.postProcessesEnabled)&&(t[0].activate(this._scene.activeCamera,e,null!==t&&void 0!==t),!0)},t.prototype.directRender=function(e,t){for(var i=this._scene.getEngine(),r=0;r=this._sampleCount||e>=this._samples.length)return null;var t=this._wrapPosition(this._pos-1);return this._samples[this._wrapPosition(t-e)]},e.prototype.isSaturated=function(){return this._sampleCount>=this._samples.length},e.prototype.reset=function(){this.average=0,this.variance=0,this._sampleCount=0,this._pos=0,this._m2=0},e.prototype._wrapPosition=function(e){var t=this._samples.length;return(e%t+t)%t},e})();e.RollingAverage=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(e){function t(){var t=e.call(this)||this;return t.MAINUV1=!1,t.MAINUV2=!1,t.DIFFUSE=!1,t.DIFFUSEDIRECTUV=0,t.AMBIENT=!1,t.AMBIENTDIRECTUV=0,t.OPACITY=!1,t.OPACITYDIRECTUV=0,t.OPACITYRGB=!1,t.REFLECTION=!1,t.EMISSIVE=!1,t.EMISSIVEDIRECTUV=0,t.SPECULAR=!1,t.SPECULARDIRECTUV=0,t.BUMP=!1,t.BUMPDIRECTUV=0,t.PARALLAX=!1,t.PARALLAXOCCLUSION=!1,t.SPECULAROVERALPHA=!1,t.CLIPPLANE=!1,t.ALPHATEST=!1,t.ALPHAFROMDIFFUSE=!1,t.POINTSIZE=!1,t.FOG=!1,t.SPECULARTERM=!1,t.DIFFUSEFRESNEL=!1,t.OPACITYFRESNEL=!1,t.REFLECTIONFRESNEL=!1,t.REFRACTIONFRESNEL=!1,t.EMISSIVEFRESNEL=!1,t.FRESNEL=!1,t.NORMAL=!1,t.UV1=!1,t.UV2=!1,t.VERTEXCOLOR=!1,t.VERTEXALPHA=!1,t.NUM_BONE_INFLUENCERS=0,t.BonesPerMesh=0,t.INSTANCES=!1,t.GLOSSINESS=!1,t.ROUGHNESS=!1,t.EMISSIVEASILLUMINATION=!1,t.LINKEMISSIVEWITHDIFFUSE=!1,t.REFLECTIONFRESNELFROMSPECULAR=!1,t.LIGHTMAP=!1,t.LIGHTMAPDIRECTUV=0,t.USELIGHTMAPASSHADOWMAP=!1,t.REFLECTIONMAP_3D=!1,t.REFLECTIONMAP_SPHERICAL=!1,t.REFLECTIONMAP_PLANAR=!1,t.REFLECTIONMAP_CUBIC=!1,t.REFLECTIONMAP_PROJECTION=!1,t.REFLECTIONMAP_SKYBOX=!1,t.REFLECTIONMAP_EXPLICIT=!1,t.REFLECTIONMAP_EQUIRECTANGULAR=!1,t.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,t.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,t.INVERTCUBICMAP=!1,t.LOGARITHMICDEPTH=!1,t.REFRACTION=!1,t.REFRACTIONMAP_3D=!1,t.REFLECTIONOVERALPHA=!1,t.TWOSIDEDLIGHTING=!1,t.SHADOWFLOAT=!1,t.MORPHTARGETS=!1,t.MORPHTARGETS_NORMAL=!1,t.MORPHTARGETS_TANGENT=!1,t.NUM_MORPH_INFLUENCERS=0,t.USERIGHTHANDEDSYSTEM=!1,t.IMAGEPROCESSING=!1,t.VIGNETTE=!1,t.VIGNETTEBLENDMODEMULTIPLY=!1,t.VIGNETTEBLENDMODEOPAQUE=!1,t.TONEMAPPING=!1,t.CONTRAST=!1,t.COLORCURVES=!1,t.COLORGRADING=!1,t.SAMPLER3DGREENDEPTH=!1,t.SAMPLER3DBGRMAP=!1,t.IMAGEPROCESSINGPOSTPROCESS=!1,t.EXPOSURE=!1,t.rebuild(),t}return __extends(t,e),t.prototype.setReflectionMode=function(e){for(var t=["REFLECTIONMAP_CUBIC","REFLECTIONMAP_EXPLICIT","REFLECTIONMAP_PLANAR","REFLECTIONMAP_PROJECTION","REFLECTIONMAP_PROJECTION","REFLECTIONMAP_SKYBOX","REFLECTIONMAP_SPHERICAL","REFLECTIONMAP_EQUIRECTANGULAR","REFLECTIONMAP_EQUIRECTANGULAR_FIXED","REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED"],i=0,r=t;i0,a.REFLECTIONOVERALPHA=this._useReflectionOverAlpha,a.INVERTCUBICMAP=this._reflectionTexture.coordinatesMode===e.Texture.INVCUBIC_MODE,a.REFLECTIONMAP_3D=this._reflectionTexture.isCube,this._reflectionTexture.coordinatesMode){case e.Texture.CUBIC_MODE:case e.Texture.INVCUBIC_MODE:a.setReflectionMode("REFLECTIONMAP_CUBIC");break;case e.Texture.EXPLICIT_MODE:a.setReflectionMode("REFLECTIONMAP_EXPLICIT");break;case e.Texture.PLANAR_MODE:a.setReflectionMode("REFLECTIONMAP_PLANAR");break;case e.Texture.PROJECTION_MODE:a.setReflectionMode("REFLECTIONMAP_PROJECTION");break;case e.Texture.SKYBOX_MODE:a.setReflectionMode("REFLECTIONMAP_SKYBOX");break;case e.Texture.SPHERICAL_MODE:a.setReflectionMode("REFLECTIONMAP_SPHERICAL");break;case e.Texture.EQUIRECTANGULAR_MODE:a.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR");break;case e.Texture.FIXED_EQUIRECTANGULAR_MODE:a.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR_FIXED");break;case e.Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:a.setReflectionMode("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED")}}else a.REFLECTION=!1;if(this._emissiveTexture&&r.EmissiveTextureEnabled){if(!this._emissiveTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._emissiveTexture,a,"EMISSIVE")}else a.EMISSIVE=!1;if(this._lightmapTexture&&r.LightmapTextureEnabled){if(!this._lightmapTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._lightmapTexture,a,"LIGHTMAP"),a.USELIGHTMAPASSHADOWMAP=this._useLightmapAsShadowmap}else a.LIGHTMAP=!1;if(this._specularTexture&&r.SpecularTextureEnabled){if(!this._specularTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._specularTexture,a,"SPECULAR"),a.GLOSSINESS=this._useGlossinessFromSpecularMapAlpha}else a.SPECULAR=!1;if(s.getEngine().getCaps().standardDerivatives&&this._bumpTexture&&r.BumpTextureEnabled){if(!this._bumpTexture.isReady())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._bumpTexture,a,"BUMP"),a.PARALLAX=this._useParallax,a.PARALLAXOCCLUSION=this._useParallaxOcclusion}else a.BUMP=!1;if(this._refractionTexture&&r.RefractionTextureEnabled){if(!this._refractionTexture.isReadyOrNotBlocking())return!1;a._needUVs=!0,a.REFRACTION=!0,a.REFRACTIONMAP_3D=this._refractionTexture.isCube}else a.REFRACTION=!1;a.TWOSIDEDLIGHTING=!this._backFaceCulling&&this._twoSidedLighting}else a.DIFFUSE=!1,a.AMBIENT=!1,a.OPACITY=!1,a.REFLECTION=!1,a.EMISSIVE=!1,a.LIGHTMAP=!1,a.BUMP=!1,a.REFRACTION=!1;a.ALPHAFROMDIFFUSE=this._shouldUseAlphaFromDiffuseTexture(),a.EMISSIVEASILLUMINATION=this._useEmissiveAsIllumination,a.LINKEMISSIVEWITHDIFFUSE=this._linkEmissiveWithDiffuse,a.SPECULAROVERALPHA=this._useSpecularOverAlpha}if(a._areImageProcessingDirty){if(!this._imageProcessingConfiguration.isReady())return!1;this._imageProcessingConfiguration.prepareDefines(a)}if(a._areFresnelDirty&&(r.FresnelEnabled?(this._diffuseFresnelParameters||this._opacityFresnelParameters||this._emissiveFresnelParameters||this._refractionFresnelParameters||this._reflectionFresnelParameters)&&(a.DIFFUSEFRESNEL=this._diffuseFresnelParameters&&this._diffuseFresnelParameters.isEnabled,a.OPACITYFRESNEL=this._opacityFresnelParameters&&this._opacityFresnelParameters.isEnabled,a.REFLECTIONFRESNEL=this._reflectionFresnelParameters&&this._reflectionFresnelParameters.isEnabled,a.REFLECTIONFRESNELFROMSPECULAR=this._useReflectionFresnelFromSpecular,a.REFRACTIONFRESNEL=this._refractionFresnelParameters&&this._refractionFresnelParameters.isEnabled,a.EMISSIVEFRESNEL=this._emissiveFresnelParameters&&this._emissiveFresnelParameters.isEnabled,a._needNormals=!0,a.FRESNEL=!0):a.FRESNEL=!1),e.MaterialHelper.PrepareDefinesForMisc(i,s,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,a),e.MaterialHelper.PrepareDefinesForAttributes(i,a,!0,!0,!0),e.MaterialHelper.PrepareDefinesForFrameBoundValues(s,h,a,o),a.isDirty){a.markAsProcessed(),s.resetCachedMaterial();var l=new e.EffectFallbacks;a.REFLECTION&&l.addFallback(0,"REFLECTION"),a.SPECULAR&&l.addFallback(0,"SPECULAR"),a.BUMP&&l.addFallback(0,"BUMP"),a.PARALLAX&&l.addFallback(1,"PARALLAX"),a.PARALLAXOCCLUSION&&l.addFallback(0,"PARALLAXOCCLUSION"),a.SPECULAROVERALPHA&&l.addFallback(0,"SPECULAROVERALPHA"),a.FOG&&l.addFallback(1,"FOG"),a.POINTSIZE&&l.addFallback(0,"POINTSIZE"),a.LOGARITHMICDEPTH&&l.addFallback(0,"LOGARITHMICDEPTH"),e.MaterialHelper.HandleFallbacksForShadows(a,l,this._maxSimultaneousLights),a.SPECULARTERM&&l.addFallback(0,"SPECULARTERM"),a.DIFFUSEFRESNEL&&l.addFallback(1,"DIFFUSEFRESNEL"),a.OPACITYFRESNEL&&l.addFallback(2,"OPACITYFRESNEL"),a.REFLECTIONFRESNEL&&l.addFallback(3,"REFLECTIONFRESNEL"),a.EMISSIVEFRESNEL&&l.addFallback(4,"EMISSIVEFRESNEL"),a.FRESNEL&&l.addFallback(4,"FRESNEL");var c=[e.VertexBuffer.PositionKind];a.NORMAL&&c.push(e.VertexBuffer.NormalKind),a.UV1&&c.push(e.VertexBuffer.UVKind),a.UV2&&c.push(e.VertexBuffer.UV2Kind),a.VERTEXCOLOR&&c.push(e.VertexBuffer.ColorKind),e.MaterialHelper.PrepareAttributesForBones(c,i,a,l),e.MaterialHelper.PrepareAttributesForInstances(c,a),e.MaterialHelper.PrepareAttributesForMorphTargets(c,i,a);var u="default",f=["world","view","viewProjection","vEyePosition","vLightsType","vAmbientColor","vDiffuseColor","vSpecularColor","vEmissiveColor","vFogInfos","vFogColor","pointSize","vDiffuseInfos","vAmbientInfos","vOpacityInfos","vReflectionInfos","vEmissiveInfos","vSpecularInfos","vBumpInfos","vLightmapInfos","vRefractionInfos","mBones","vClipPlane","diffuseMatrix","ambientMatrix","opacityMatrix","reflectionMatrix","emissiveMatrix","specularMatrix","bumpMatrix","lightmapMatrix","refractionMatrix","diffuseLeftColor","diffuseRightColor","opacityParts","reflectionLeftColor","reflectionRightColor","emissiveLeftColor","emissiveRightColor","refractionLeftColor","refractionRightColor","logarithmicDepthConstant","vNormalReoderParams"],d=["diffuseSampler","ambientSampler","opacitySampler","reflectionCubeSampler","reflection2DSampler","emissiveSampler","specularSampler","bumpSampler","lightmapSampler","refractionCubeSampler","refraction2DSampler"],p=["Material","Scene"];e.ImageProcessingConfiguration.PrepareUniforms(f,a),e.ImageProcessingConfiguration.PrepareSamplers(d,a),e.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:f,uniformBuffersNames:p,samplers:d,defines:a,maxSimultaneousLights:this._maxSimultaneousLights}),this.customShaderNameResolve&&(u=this.customShaderNameResolve(u,f,p,d,a));var m=a.toString();n.setEffect(s.getEngine().createEffect(u,{attributes:c,uniformsNames:f,uniformBuffersNames:p,samplers:d,defines:m,fallbacks:l,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights,maxSimultaneousMorphTargets:a.NUM_MORPH_INFLUENCERS}},h),a),this.buildUniformLayout()}return!!n.effect.isReady()&&(a._renderId=s.getRenderId(),this._wasPreviouslyReady=!0,!0)},r.prototype.buildUniformLayout=function(){this._uniformBuffer.addUniform("diffuseLeftColor",4),this._uniformBuffer.addUniform("diffuseRightColor",4),this._uniformBuffer.addUniform("opacityParts",4),this._uniformBuffer.addUniform("reflectionLeftColor",4),this._uniformBuffer.addUniform("reflectionRightColor",4),this._uniformBuffer.addUniform("refractionLeftColor",4),this._uniformBuffer.addUniform("refractionRightColor",4),this._uniformBuffer.addUniform("emissiveLeftColor",4),this._uniformBuffer.addUniform("emissiveRightColor",4),this._uniformBuffer.addUniform("vDiffuseInfos",2),this._uniformBuffer.addUniform("vAmbientInfos",2),this._uniformBuffer.addUniform("vOpacityInfos",2),this._uniformBuffer.addUniform("vReflectionInfos",2),this._uniformBuffer.addUniform("vEmissiveInfos",2),this._uniformBuffer.addUniform("vLightmapInfos",2),this._uniformBuffer.addUniform("vSpecularInfos",2),this._uniformBuffer.addUniform("vBumpInfos",3),this._uniformBuffer.addUniform("diffuseMatrix",16),this._uniformBuffer.addUniform("ambientMatrix",16),this._uniformBuffer.addUniform("opacityMatrix",16),this._uniformBuffer.addUniform("reflectionMatrix",16),this._uniformBuffer.addUniform("emissiveMatrix",16),this._uniformBuffer.addUniform("lightmapMatrix",16),this._uniformBuffer.addUniform("specularMatrix",16),this._uniformBuffer.addUniform("bumpMatrix",16),this._uniformBuffer.addUniform("vNormalReoderParams",4),this._uniformBuffer.addUniform("refractionMatrix",16),this._uniformBuffer.addUniform("vRefractionInfos",4),this._uniformBuffer.addUniform("vSpecularColor",4),this._uniformBuffer.addUniform("vEmissiveColor",3),this._uniformBuffer.addUniform("vDiffuseColor",4),this._uniformBuffer.addUniform("pointSize",1),this._uniformBuffer.create()},r.prototype.unbind=function(){this._activeEffect&&(this._reflectionTexture&&this._reflectionTexture.isRenderTarget&&this._activeEffect.setTexture("reflection2DSampler",null),this._refractionTexture&&this._refractionTexture.isRenderTarget&&this._activeEffect.setTexture("refraction2DSampler",null)),i.prototype.unbind.call(this)},r.prototype.bindForSubMesh=function(t,i,n){var o=this.getScene(),s=n._materialDefines;if(s){var a=n.effect;if(this._activeEffect=a,this.bindOnlyWorldMatrix(t),e.MaterialHelper.BindBonesParameters(i,a),this._mustRebind(o,a,i.visibility)){if(this._uniformBuffer.bindToEffect(a,"Material"),this.bindViewProjection(a),!this._uniformBuffer.useUbo||!this.isFrozen||!this._uniformBuffer.isSync){if(r.FresnelEnabled&&s.FRESNEL&&(this.diffuseFresnelParameters&&this.diffuseFresnelParameters.isEnabled&&(this._uniformBuffer.updateColor4("diffuseLeftColor",this.diffuseFresnelParameters.leftColor,this.diffuseFresnelParameters.power),this._uniformBuffer.updateColor4("diffuseRightColor",this.diffuseFresnelParameters.rightColor,this.diffuseFresnelParameters.bias)),this.opacityFresnelParameters&&this.opacityFresnelParameters.isEnabled&&this._uniformBuffer.updateColor4("opacityParts",new e.Color3(this.opacityFresnelParameters.leftColor.toLuminance(),this.opacityFresnelParameters.rightColor.toLuminance(),this.opacityFresnelParameters.bias),this.opacityFresnelParameters.power),this.reflectionFresnelParameters&&this.reflectionFresnelParameters.isEnabled&&(this._uniformBuffer.updateColor4("reflectionLeftColor",this.reflectionFresnelParameters.leftColor,this.reflectionFresnelParameters.power),this._uniformBuffer.updateColor4("reflectionRightColor",this.reflectionFresnelParameters.rightColor,this.reflectionFresnelParameters.bias)),this.refractionFresnelParameters&&this.refractionFresnelParameters.isEnabled&&(this._uniformBuffer.updateColor4("refractionLeftColor",this.refractionFresnelParameters.leftColor,this.refractionFresnelParameters.power),this._uniformBuffer.updateColor4("refractionRightColor",this.refractionFresnelParameters.rightColor,this.refractionFresnelParameters.bias)),this.emissiveFresnelParameters&&this.emissiveFresnelParameters.isEnabled&&(this._uniformBuffer.updateColor4("emissiveLeftColor",this.emissiveFresnelParameters.leftColor,this.emissiveFresnelParameters.power),this._uniformBuffer.updateColor4("emissiveRightColor",this.emissiveFresnelParameters.rightColor,this.emissiveFresnelParameters.bias))),o.texturesEnabled&&(this._diffuseTexture&&r.DiffuseTextureEnabled&&(this._uniformBuffer.updateFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),e.MaterialHelper.BindTextureMatrix(this._diffuseTexture,this._uniformBuffer,"diffuse")),this._ambientTexture&&r.AmbientTextureEnabled&&(this._uniformBuffer.updateFloat2("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level),e.MaterialHelper.BindTextureMatrix(this._ambientTexture,this._uniformBuffer,"ambient")),this._opacityTexture&&r.OpacityTextureEnabled&&(this._uniformBuffer.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),e.MaterialHelper.BindTextureMatrix(this._opacityTexture,this._uniformBuffer,"opacity")),this._reflectionTexture&&r.ReflectionTextureEnabled&&(this._uniformBuffer.updateFloat2("vReflectionInfos",this._reflectionTexture.level,this.roughness),this._uniformBuffer.updateMatrix("reflectionMatrix",this._reflectionTexture.getReflectionTextureMatrix())),this._emissiveTexture&&r.EmissiveTextureEnabled&&(this._uniformBuffer.updateFloat2("vEmissiveInfos",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),e.MaterialHelper.BindTextureMatrix(this._emissiveTexture,this._uniformBuffer,"emissive")),this._lightmapTexture&&r.LightmapTextureEnabled&&(this._uniformBuffer.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),e.MaterialHelper.BindTextureMatrix(this._lightmapTexture,this._uniformBuffer,"lightmap")),this._specularTexture&&r.SpecularTextureEnabled&&(this._uniformBuffer.updateFloat2("vSpecularInfos",this._specularTexture.coordinatesIndex,this._specularTexture.level),e.MaterialHelper.BindTextureMatrix(this._specularTexture,this._uniformBuffer,"specular")),this._bumpTexture&&o.getEngine().getCaps().standardDerivatives&&r.BumpTextureEnabled&&(this._uniformBuffer.updateFloat3("vBumpInfos",this._bumpTexture.coordinatesIndex,1/this._bumpTexture.level,this.parallaxScaleBias),e.MaterialHelper.BindTextureMatrix(this._bumpTexture,this._uniformBuffer,"bump"),o._mirroredCameraPosition?this._uniformBuffer.updateFloat4("vNormalReoderParams",this.invertNormalMapX?0:1,this.invertNormalMapX?1:-1,this.invertNormalMapY?0:1,this.invertNormalMapY?1:-1):this._uniformBuffer.updateFloat4("vNormalReoderParams",this.invertNormalMapX?1:0,this.invertNormalMapX?-1:1,this.invertNormalMapY?1:0,this.invertNormalMapY?-1:1)),this._refractionTexture&&r.RefractionTextureEnabled)){var h=1;this._refractionTexture.isCube||(this._uniformBuffer.updateMatrix("refractionMatrix",this._refractionTexture.getReflectionTextureMatrix()),this._refractionTexture.depth&&(h=this._refractionTexture.depth)),this._uniformBuffer.updateFloat4("vRefractionInfos",this._refractionTexture.level,this.indexOfRefraction,h,this.invertRefractionY?-1:1)}this.pointsCloud&&this._uniformBuffer.updateFloat("pointSize",this.pointSize),s.SPECULARTERM&&this._uniformBuffer.updateColor4("vSpecularColor",this.specularColor,this.specularPower),this._uniformBuffer.updateColor3("vEmissiveColor",this.emissiveColor),this._uniformBuffer.updateColor4("vDiffuseColor",this.diffuseColor,this.alpha*i.visibility)}if(o.texturesEnabled&&(this._diffuseTexture&&r.DiffuseTextureEnabled&&a.setTexture("diffuseSampler",this._diffuseTexture),this._ambientTexture&&r.AmbientTextureEnabled&&a.setTexture("ambientSampler",this._ambientTexture),this._opacityTexture&&r.OpacityTextureEnabled&&a.setTexture("opacitySampler",this._opacityTexture),this._reflectionTexture&&r.ReflectionTextureEnabled&&(this._reflectionTexture.isCube?a.setTexture("reflectionCubeSampler",this._reflectionTexture):a.setTexture("reflection2DSampler",this._reflectionTexture)),this._emissiveTexture&&r.EmissiveTextureEnabled&&a.setTexture("emissiveSampler",this._emissiveTexture),this._lightmapTexture&&r.LightmapTextureEnabled&&a.setTexture("lightmapSampler",this._lightmapTexture),this._specularTexture&&r.SpecularTextureEnabled&&a.setTexture("specularSampler",this._specularTexture),this._bumpTexture&&o.getEngine().getCaps().standardDerivatives&&r.BumpTextureEnabled&&a.setTexture("bumpSampler",this._bumpTexture),this._refractionTexture&&r.RefractionTextureEnabled)){var h=1;this._refractionTexture.isCube?a.setTexture("refractionCubeSampler",this._refractionTexture):a.setTexture("refraction2DSampler",this._refractionTexture)}e.MaterialHelper.BindClipPlane(a,o),o.ambientColor.multiplyToRef(this.ambientColor,this._globalAmbientColor),a.setVector3("vEyePosition",o._mirroredCameraPosition?o._mirroredCameraPosition:o.activeCamera.globalPosition),a.setColor3("vAmbientColor",this._globalAmbientColor)}!this._mustRebind(o,a)&&this.isFrozen||(o.lightsEnabled&&!this._disableLighting&&e.MaterialHelper.BindLights(o,i,a,s,this._maxSimultaneousLights),(o.fogEnabled&&i.applyFog&&o.fogMode!==e.Scene.FOGMODE_NONE||this._reflectionTexture||this._refractionTexture)&&this.bindView(a),e.MaterialHelper.BindFogParameters(o,i,a),s.NUM_MORPH_INFLUENCERS&&e.MaterialHelper.BindMorphTargetParameters(i,a),e.MaterialHelper.BindLogDepth(s,a,o),this._imageProcessingConfiguration.bind(this._activeEffect)),this._uniformBuffer.update(),this._afterBind(i,this._activeEffect)}},r.prototype.getAnimatables=function(){var e=[];return this._diffuseTexture&&this._diffuseTexture.animations&&this._diffuseTexture.animations.length>0&&e.push(this._diffuseTexture),this._ambientTexture&&this._ambientTexture.animations&&this._ambientTexture.animations.length>0&&e.push(this._ambientTexture),this._opacityTexture&&this._opacityTexture.animations&&this._opacityTexture.animations.length>0&&e.push(this._opacityTexture),this._reflectionTexture&&this._reflectionTexture.animations&&this._reflectionTexture.animations.length>0&&e.push(this._reflectionTexture),this._emissiveTexture&&this._emissiveTexture.animations&&this._emissiveTexture.animations.length>0&&e.push(this._emissiveTexture),this._specularTexture&&this._specularTexture.animations&&this._specularTexture.animations.length>0&&e.push(this._specularTexture),this._bumpTexture&&this._bumpTexture.animations&&this._bumpTexture.animations.length>0&&e.push(this._bumpTexture),this._lightmapTexture&&this._lightmapTexture.animations&&this._lightmapTexture.animations.length>0&&e.push(this._lightmapTexture),this._refractionTexture&&this._refractionTexture.animations&&this._refractionTexture.animations.length>0&&e.push(this._refractionTexture),e},r.prototype.getActiveTextures=function(){var e=i.prototype.getActiveTextures.call(this);return this._diffuseTexture&&e.push(this._diffuseTexture),this._ambientTexture&&e.push(this._ambientTexture),this._opacityTexture&&e.push(this._opacityTexture),this._reflectionTexture&&e.push(this._reflectionTexture),this._emissiveTexture&&e.push(this._emissiveTexture),this._specularTexture&&e.push(this._specularTexture),this._bumpTexture&&e.push(this._bumpTexture),this._lightmapTexture&&e.push(this._lightmapTexture),this._refractionTexture&&e.push(this._refractionTexture),e},r.prototype.hasTexture=function(e){return!!i.prototype.hasTexture.call(this,e)||(this._diffuseTexture===e||(this._ambientTexture===e||(this._opacityTexture===e||(this._reflectionTexture===e||(this._emissiveTexture===e||(this._specularTexture===e||(this._bumpTexture===e||(this._lightmapTexture===e||this._refractionTexture===e))))))))},r.prototype.dispose=function(e,t){t&&(this._diffuseTexture&&this._diffuseTexture.dispose(),this._ambientTexture&&this._ambientTexture.dispose(),this._opacityTexture&&this._opacityTexture.dispose(),this._reflectionTexture&&this._reflectionTexture.dispose(),this._emissiveTexture&&this._emissiveTexture.dispose(),this._specularTexture&&this._specularTexture.dispose(),this._bumpTexture&&this._bumpTexture.dispose(),this._lightmapTexture&&this._lightmapTexture.dispose(),this._refractionTexture&&this._refractionTexture.dispose()),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),i.prototype.dispose.call(this,e,t)},r.prototype.clone=function(t){var i=this,n=e.SerializationHelper.Clone((function(){return new r(t,i.getScene())}),this);return n.name=t,n.id=t,n},r.prototype.serialize=function(){return e.SerializationHelper.Serialize(this)},r.Parse=function(t,i,n){return e.SerializationHelper.Parse((function(){return new r(t.name,i)}),t,i,n)},Object.defineProperty(r,"DiffuseTextureEnabled",{get:function(){return r._DiffuseTextureEnabled},set:function(t){r._DiffuseTextureEnabled!==t&&(r._DiffuseTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"AmbientTextureEnabled",{get:function(){return r._AmbientTextureEnabled},set:function(t){r._AmbientTextureEnabled!==t&&(r._AmbientTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"OpacityTextureEnabled",{get:function(){return r._OpacityTextureEnabled},set:function(t){r._OpacityTextureEnabled!==t&&(r._OpacityTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"ReflectionTextureEnabled",{get:function(){return r._ReflectionTextureEnabled},set:function(t){r._ReflectionTextureEnabled!==t&&(r._ReflectionTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"EmissiveTextureEnabled",{get:function(){return r._EmissiveTextureEnabled},set:function(t){r._EmissiveTextureEnabled!==t&&(r._EmissiveTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"SpecularTextureEnabled",{get:function(){return r._SpecularTextureEnabled},set:function(t){r._SpecularTextureEnabled!==t&&(r._SpecularTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"BumpTextureEnabled",{get:function(){return r._BumpTextureEnabled},set:function(t){r._BumpTextureEnabled!==t&&(r._BumpTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"LightmapTextureEnabled",{get:function(){return r._LightmapTextureEnabled},set:function(t){r._LightmapTextureEnabled!==t&&(r._LightmapTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"RefractionTextureEnabled",{get:function(){return r._RefractionTextureEnabled},set:function(t){r._RefractionTextureEnabled!==t&&(r._RefractionTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"ColorGradingTextureEnabled",{get:function(){return r._ColorGradingTextureEnabled},set:function(t){r._ColorGradingTextureEnabled!==t&&(r._ColorGradingTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"FresnelEnabled",{get:function(){return r._FresnelEnabled},set:function(t){r._FresnelEnabled!==t&&(r._FresnelEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.FresnelDirtyFlag))},enumerable:!0,configurable:!0}),r})(e.PushMaterial);i._DiffuseTextureEnabled=!0,i._AmbientTextureEnabled=!0,i._OpacityTextureEnabled=!0,i._ReflectionTextureEnabled=!0,i._EmissiveTextureEnabled=!0,i._SpecularTextureEnabled=!0,i._BumpTextureEnabled=!0,i._LightmapTextureEnabled=!0,i._RefractionTextureEnabled=!0,i._ColorGradingTextureEnabled=!0,i._FresnelEnabled=!0,__decorate([e.serializeAsTexture("diffuseTexture")],i.prototype,"_diffuseTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"diffuseTexture",void 0),__decorate([e.serializeAsTexture("ambientTexture")],i.prototype,"_ambientTexture",void 0), +__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"ambientTexture",void 0),__decorate([e.serializeAsTexture("opacityTexture")],i.prototype,"_opacityTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"opacityTexture",void 0),__decorate([e.serializeAsTexture("reflectionTexture")],i.prototype,"_reflectionTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"reflectionTexture",void 0),__decorate([e.serializeAsTexture("emissiveTexture")],i.prototype,"_emissiveTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"emissiveTexture",void 0),__decorate([e.serializeAsTexture("specularTexture")],i.prototype,"_specularTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"specularTexture",void 0),__decorate([e.serializeAsTexture("bumpTexture")],i.prototype,"_bumpTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"bumpTexture",void 0),__decorate([e.serializeAsTexture("lightmapTexture")],i.prototype,"_lightmapTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"lightmapTexture",void 0),__decorate([e.serializeAsTexture("refractionTexture")],i.prototype,"_refractionTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"refractionTexture",void 0),__decorate([e.serializeAsColor3("ambient")],i.prototype,"ambientColor",void 0),__decorate([e.serializeAsColor3("diffuse")],i.prototype,"diffuseColor",void 0),__decorate([e.serializeAsColor3("specular")],i.prototype,"specularColor",void 0),__decorate([e.serializeAsColor3("emissive")],i.prototype,"emissiveColor",void 0),__decorate([e.serialize()],i.prototype,"specularPower",void 0),__decorate([e.serialize("useAlphaFromDiffuseTexture")],i.prototype,"_useAlphaFromDiffuseTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useAlphaFromDiffuseTexture",void 0),__decorate([e.serialize("useEmissiveAsIllumination")],i.prototype,"_useEmissiveAsIllumination",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useEmissiveAsIllumination",void 0),__decorate([e.serialize("linkEmissiveWithDiffuse")],i.prototype,"_linkEmissiveWithDiffuse",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"linkEmissiveWithDiffuse",void 0),__decorate([e.serialize("useSpecularOverAlpha")],i.prototype,"_useSpecularOverAlpha",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useSpecularOverAlpha",void 0),__decorate([e.serialize("useReflectionOverAlpha")],i.prototype,"_useReflectionOverAlpha",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useReflectionOverAlpha",void 0),__decorate([e.serialize("disableLighting")],i.prototype,"_disableLighting",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsLightsDirty")],i.prototype,"disableLighting",void 0),__decorate([e.serialize("useParallax")],i.prototype,"_useParallax",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useParallax",void 0),__decorate([e.serialize("useParallaxOcclusion")],i.prototype,"_useParallaxOcclusion",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useParallaxOcclusion",void 0),__decorate([e.serialize()],i.prototype,"parallaxScaleBias",void 0),__decorate([e.serialize("roughness")],i.prototype,"_roughness",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"roughness",void 0),__decorate([e.serialize()],i.prototype,"indexOfRefraction",void 0),__decorate([e.serialize()],i.prototype,"invertRefractionY",void 0),__decorate([e.serialize("useLightmapAsShadowmap")],i.prototype,"_useLightmapAsShadowmap",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useLightmapAsShadowmap",void 0),__decorate([e.serializeAsFresnelParameters("diffuseFresnelParameters")],i.prototype,"_diffuseFresnelParameters",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],i.prototype,"diffuseFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters("opacityFresnelParameters")],i.prototype,"_opacityFresnelParameters",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],i.prototype,"opacityFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters("reflectionFresnelParameters")],i.prototype,"_reflectionFresnelParameters",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],i.prototype,"reflectionFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters("refractionFresnelParameters")],i.prototype,"_refractionFresnelParameters",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],i.prototype,"refractionFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters("emissiveFresnelParameters")],i.prototype,"_emissiveFresnelParameters",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],i.prototype,"emissiveFresnelParameters",void 0),__decorate([e.serialize("useReflectionFresnelFromSpecular")],i.prototype,"_useReflectionFresnelFromSpecular",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],i.prototype,"useReflectionFresnelFromSpecular",void 0),__decorate([e.serialize("useGlossinessFromSpecularMapAlpha")],i.prototype,"_useGlossinessFromSpecularMapAlpha",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useGlossinessFromSpecularMapAlpha",void 0),__decorate([e.serialize("maxSimultaneousLights")],i.prototype,"_maxSimultaneousLights",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsLightsDirty")],i.prototype,"maxSimultaneousLights",void 0),__decorate([e.serialize("invertNormalMapX")],i.prototype,"_invertNormalMapX",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"invertNormalMapX",void 0),__decorate([e.serialize("invertNormalMapY")],i.prototype,"_invertNormalMapY",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"invertNormalMapY",void 0),__decorate([e.serialize("twoSidedLighting")],i.prototype,"_twoSidedLighting",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"twoSidedLighting",void 0),__decorate([e.serialize()],i.prototype,"useLogarithmicDepth",null),e.StandardMaterial=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(e){function t(){var t=e.call(this)||this;return t.PBR=!0,t.MAINUV1=!1,t.MAINUV2=!1,t.UV1=!1,t.UV2=!1,t.ALBEDO=!1,t.ALBEDODIRECTUV=0,t.VERTEXCOLOR=!1,t.AMBIENT=!1,t.AMBIENTDIRECTUV=0,t.AMBIENTINGRAYSCALE=!1,t.OPACITY=!1,t.VERTEXALPHA=!1,t.OPACITYDIRECTUV=0,t.OPACITYRGB=!1,t.ALPHATEST=!1,t.ALPHABLEND=!1,t.ALPHAFROMALBEDO=!1,t.ALPHATESTVALUE=.5,t.SPECULAROVERALPHA=!1,t.RADIANCEOVERALPHA=!1,t.ALPHAFRESNEL=!1,t.PREMULTIPLYALPHA=!1,t.EMISSIVE=!1,t.EMISSIVEDIRECTUV=0,t.REFLECTIVITY=!1,t.REFLECTIVITYDIRECTUV=0,t.SPECULARTERM=!1,t.MICROSURFACEFROMREFLECTIVITYMAP=!1,t.MICROSURFACEAUTOMATIC=!1,t.LODBASEDMICROSFURACE=!1,t.MICROSURFACEMAP=!1,t.MICROSURFACEMAPDIRECTUV=0,t.METALLICWORKFLOW=!1,t.ROUGHNESSSTOREINMETALMAPALPHA=!1,t.ROUGHNESSSTOREINMETALMAPGREEN=!1,t.METALLNESSSTOREINMETALMAPBLUE=!1,t.AOSTOREINMETALMAPRED=!1,t.ENVIRONMENTBRDF=!1,t.NORMAL=!1,t.TANGENT=!1,t.BUMP=!1,t.BUMPDIRECTUV=0,t.PARALLAX=!1,t.PARALLAXOCCLUSION=!1,t.NORMALXYSCALE=!0,t.LIGHTMAP=!1,t.LIGHTMAPDIRECTUV=0,t.USELIGHTMAPASSHADOWMAP=!1,t.REFLECTION=!1,t.REFLECTIONMAP_3D=!1,t.REFLECTIONMAP_SPHERICAL=!1,t.REFLECTIONMAP_PLANAR=!1,t.REFLECTIONMAP_CUBIC=!1,t.REFLECTIONMAP_PROJECTION=!1,t.REFLECTIONMAP_SKYBOX=!1,t.REFLECTIONMAP_EXPLICIT=!1,t.REFLECTIONMAP_EQUIRECTANGULAR=!1,t.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,t.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,t.INVERTCUBICMAP=!1,t.USESPHERICALFROMREFLECTIONMAP=!1,t.USESPHERICALINFRAGMENT=!1,t.REFLECTIONMAP_OPPOSITEZ=!1,t.LODINREFLECTIONALPHA=!1,t.GAMMAREFLECTION=!1,t.REFRACTION=!1,t.REFRACTIONMAP_3D=!1,t.REFRACTIONMAP_OPPOSITEZ=!1,t.LODINREFRACTIONALPHA=!1,t.GAMMAREFRACTION=!1,t.LINKREFRACTIONTOTRANSPARENCY=!1,t.INSTANCES=!1,t.NUM_BONE_INFLUENCERS=0,t.BonesPerMesh=0,t.MORPHTARGETS=!1,t.MORPHTARGETS_NORMAL=!1,t.MORPHTARGETS_TANGENT=!1,t.NUM_MORPH_INFLUENCERS=0,t.IMAGEPROCESSING=!1,t.VIGNETTE=!1,t.VIGNETTEBLENDMODEMULTIPLY=!1,t.VIGNETTEBLENDMODEOPAQUE=!1,t.TONEMAPPING=!1,t.CONTRAST=!1,t.COLORCURVES=!1,t.COLORGRADING=!1,t.SAMPLER3DGREENDEPTH=!1,t.SAMPLER3DBGRMAP=!1,t.IMAGEPROCESSINGPOSTPROCESS=!1,t.EXPOSURE=!1,t.USEPHYSICALLIGHTFALLOFF=!1,t.TWOSIDEDLIGHTING=!1,t.SHADOWFLOAT=!1,t.USERIGHTHANDEDSYSTEM=!1,t.CLIPPLANE=!1,t.POINTSIZE=!1,t.FOG=!1,t.LOGARITHMICDEPTH=!1,t.FORCENORMALFORWARD=!1,t.rebuild(),t}return __extends(t,e),t.prototype.reset=function(){e.prototype.reset.call(this),this.ALPHATESTVALUE=.5,this.PBR=!0},t})(e.MaterialDefines),i=(function(i){function r(t,r){var n=i.call(this,t,r)||this;return n._directIntensity=1,n._emissiveIntensity=1,n._environmentIntensity=1,n._specularIntensity=1,n._lightingInfos=new e.Vector4(n._directIntensity,n._emissiveIntensity,n._environmentIntensity,n._specularIntensity),n._disableBumpMap=!1,n._ambientTextureStrength=1,n._ambientColor=new e.Color3(0,0,0),n._albedoColor=new e.Color3(1,1,1),n._reflectivityColor=new e.Color3(1,1,1),n._reflectionColor=new e.Color3(1,1,1),n._emissiveColor=new e.Color3(0,0,0),n._microSurface=.9,n._indexOfRefraction=.66,n._invertRefractionY=!1,n._linkRefractionWithTransparency=!1,n._useLightmapAsShadowmap=!1,n._useAlphaFromAlbedoTexture=!1,n._useSpecularOverAlpha=!0,n._useMicroSurfaceFromReflectivityMapAlpha=!1,n._useRoughnessFromMetallicTextureAlpha=!0,n._useRoughnessFromMetallicTextureGreen=!1,n._useMetallnessFromMetallicTextureBlue=!1,n._useAmbientOcclusionFromMetallicTextureRed=!1,n._useAmbientInGrayScale=!1,n._useAutoMicroSurfaceFromReflectivityMap=!1,n._usePhysicalLightFalloff=!0,n._useRadianceOverAlpha=!0,n._useParallax=!1,n._useParallaxOcclusion=!1,n._parallaxScaleBias=.05,n._disableLighting=!1,n._maxSimultaneousLights=4,n._invertNormalMapX=!1,n._invertNormalMapY=!1,n._twoSidedLighting=!1,n._alphaCutOff=.4,n._forceAlphaTest=!1,n._preMultiplyAlpha=!1,n._useAlphaFresnel=!1,n._environmentBRDFTexture=null,n._forceIrradianceInFragment=!1,n._forceNormalForward=!1,n._renderTargets=new e.SmartArray(16),n._worldViewProjectionMatrix=e.Matrix.Zero(),n._globalAmbientColor=new e.Color3(0,0,0),n._tempColor=new e.Color3,n._attachImageProcessingConfiguration(null),n.getRenderTargetTextures=function(){return n._renderTargets.reset(),e.StandardMaterial.ReflectionTextureEnabled&&n._reflectionTexture&&n._reflectionTexture.isRenderTarget&&n._renderTargets.push(n._reflectionTexture),e.StandardMaterial.RefractionTextureEnabled&&n._refractionTexture&&n._refractionTexture.isRenderTarget&&n._renderTargets.push(n._refractionTexture),n._renderTargets},n._environmentBRDFTexture=e.TextureTools.GetEnvironmentBRDFTexture(r),n}return __extends(r,i),r.prototype._attachImageProcessingConfiguration=function(e){var t=this;e!==this._imageProcessingConfiguration&&(this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),this._imageProcessingConfiguration=e||this.getScene().imageProcessingConfiguration,this._imageProcessingObserver=this._imageProcessingConfiguration.onUpdateParameters.add((function(e){t._markAllSubMeshesAsImageProcessingDirty()})))},r.prototype.getClassName=function(){return"PBRBaseMaterial"},Object.defineProperty(r.prototype,"useLogarithmicDepth",{get:function(){return this._useLogarithmicDepth},set:function(e){this._useLogarithmicDepth=e&&this.getScene().getEngine().getCaps().fragmentDepthSupported},enumerable:!0,configurable:!0}),r.prototype.needAlphaBlending=function(){return!this._linkRefractionWithTransparency&&(this.alpha<1||null!=this._opacityTexture||this._shouldUseAlphaFromAlbedoTexture())},r.prototype.needAlphaTesting=function(){return!!this._forceAlphaTest||!this._linkRefractionWithTransparency&&(null!=this._albedoTexture&&this._albedoTexture.hasAlpha)},r.prototype._shouldUseAlphaFromAlbedoTexture=function(){return null!=this._albedoTexture&&this._albedoTexture.hasAlpha&&this._useAlphaFromAlbedoTexture},r.prototype.getAlphaTestTexture=function(){return this._albedoTexture},r.prototype.isReadyForSubMesh=function(i,r,n){if(this.isFrozen&&this._wasPreviouslyReady)return!0;r._materialDefines||(r._materialDefines=new t);var o=this.getScene(),s=r._materialDefines;if(!this.checkReadyOnEveryCall&&r.effect&&s._renderId===o.getRenderId())return!0;var a=o.getEngine();if(e.MaterialHelper.PrepareDefinesForLights(o,i,s,!0,this._maxSimultaneousLights,this._disableLighting),s._needNormals=!0,s._areTexturesDirty){if(s._needUVs=!1,o.texturesEnabled){if(o.getEngine().getCaps().textureLOD&&(s.LODBASEDMICROSFURACE=!0),this._albedoTexture&&e.StandardMaterial.DiffuseTextureEnabled){if(!this._albedoTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._albedoTexture,s,"ALBEDO")}else s.ALBEDO=!1;if(this._ambientTexture&&e.StandardMaterial.AmbientTextureEnabled){if(!this._ambientTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._ambientTexture,s,"AMBIENT"),s.AMBIENTINGRAYSCALE=this._useAmbientInGrayScale}else s.AMBIENT=!1;if(this._opacityTexture&&e.StandardMaterial.OpacityTextureEnabled){if(!this._opacityTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._opacityTexture,s,"OPACITY"),s.OPACITYRGB=this._opacityTexture.getAlphaFromRGB}else s.OPACITY=!1;var h=this._getReflectionTexture();if(h&&e.StandardMaterial.ReflectionTextureEnabled){if(!h.isReadyOrNotBlocking())return!1;switch(s.REFLECTION=!0,s.GAMMAREFLECTION=h.gammaSpace,s.REFLECTIONMAP_OPPOSITEZ=this.getScene().useRightHandedSystem?!h.invertZ:h.invertZ,s.LODINREFLECTIONALPHA=h.lodLevelInAlpha,h.coordinatesMode===e.Texture.INVCUBIC_MODE&&(s.INVERTCUBICMAP=!0),s.REFLECTIONMAP_3D=h.isCube,h.coordinatesMode){case e.Texture.CUBIC_MODE:case e.Texture.INVCUBIC_MODE:s.REFLECTIONMAP_CUBIC=!0;break;case e.Texture.EXPLICIT_MODE:s.REFLECTIONMAP_EXPLICIT=!0;break;case e.Texture.PLANAR_MODE:s.REFLECTIONMAP_PLANAR=!0;break;case e.Texture.PROJECTION_MODE:s.REFLECTIONMAP_PROJECTION=!0;break;case e.Texture.SKYBOX_MODE:s.REFLECTIONMAP_SKYBOX=!0;break;case e.Texture.SPHERICAL_MODE:s.REFLECTIONMAP_SPHERICAL=!0;break;case e.Texture.EQUIRECTANGULAR_MODE:s.REFLECTIONMAP_EQUIRECTANGULAR=!0;break;case e.Texture.FIXED_EQUIRECTANGULAR_MODE:s.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!0;break;case e.Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:s.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!0}h.coordinatesMode!==e.Texture.SKYBOX_MODE&&h.sphericalPolynomial&&(s.USESPHERICALFROMREFLECTIONMAP=!0,(this._forceIrradianceInFragment||o.getEngine().getCaps().maxVaryingVectors<=8)&&(s.USESPHERICALINFRAGMENT=!0))}else s.REFLECTION=!1,s.REFLECTIONMAP_3D=!1,s.REFLECTIONMAP_SPHERICAL=!1,s.REFLECTIONMAP_PLANAR=!1,s.REFLECTIONMAP_CUBIC=!1,s.REFLECTIONMAP_PROJECTION=!1,s.REFLECTIONMAP_SKYBOX=!1,s.REFLECTIONMAP_EXPLICIT=!1,s.REFLECTIONMAP_EQUIRECTANGULAR=!1,s.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,s.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,s.INVERTCUBICMAP=!1,s.USESPHERICALFROMREFLECTIONMAP=!1,s.USESPHERICALINFRAGMENT=!1,s.REFLECTIONMAP_OPPOSITEZ=!1,s.LODINREFLECTIONALPHA=!1,s.GAMMAREFLECTION=!1;if(this._lightmapTexture&&e.StandardMaterial.LightmapTextureEnabled){if(!this._lightmapTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._lightmapTexture,s,"LIGHTMAP"),s.USELIGHTMAPASSHADOWMAP=this._useLightmapAsShadowmap}else s.LIGHTMAP=!1;if(this._emissiveTexture&&e.StandardMaterial.EmissiveTextureEnabled){if(!this._emissiveTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._emissiveTexture,s,"EMISSIVE")}else s.EMISSIVE=!1;if(e.StandardMaterial.SpecularTextureEnabled){if(this._metallicTexture){if(!this._metallicTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._metallicTexture,s,"REFLECTIVITY"),s.METALLICWORKFLOW=!0,s.ROUGHNESSSTOREINMETALMAPALPHA=this._useRoughnessFromMetallicTextureAlpha,s.ROUGHNESSSTOREINMETALMAPGREEN=!this._useRoughnessFromMetallicTextureAlpha&&this._useRoughnessFromMetallicTextureGreen,s.METALLNESSSTOREINMETALMAPBLUE=this._useMetallnessFromMetallicTextureBlue,s.AOSTOREINMETALMAPRED=this._useAmbientOcclusionFromMetallicTextureRed}else if(this._reflectivityTexture){if(!this._reflectivityTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._reflectivityTexture,s,"REFLECTIVITY"),s.MICROSURFACEFROMREFLECTIVITYMAP=this._useMicroSurfaceFromReflectivityMapAlpha,s.MICROSURFACEAUTOMATIC=this._useAutoMicroSurfaceFromReflectivityMap}else s.REFLECTIVITY=!1;if(this._microSurfaceTexture){if(!this._microSurfaceTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._microSurfaceTexture,s,"MICROSURFACEMAP")}else s.MICROSURFACEMAP=!1}else s.REFLECTIVITY=!1,s.MICROSURFACEMAP=!1;if(o.getEngine().getCaps().standardDerivatives&&this._bumpTexture&&e.StandardMaterial.BumpTextureEnabled&&!this._disableBumpMap){if(!this._bumpTexture.isReady())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._bumpTexture,s,"BUMP"),this._useParallax&&this._albedoTexture&&e.StandardMaterial.DiffuseTextureEnabled?(s.PARALLAX=!0,s.PARALLAXOCCLUSION=!!this._useParallaxOcclusion):s.PARALLAX=!1,s.USERIGHTHANDEDSYSTEM=o.useRightHandedSystem}else s.BUMP=!1;var l=this._getRefractionTexture();if(l&&e.StandardMaterial.RefractionTextureEnabled){if(!l.isReadyOrNotBlocking())return!1;s.REFRACTION=!0,s.REFRACTIONMAP_3D=l.isCube,s.GAMMAREFRACTION=l.gammaSpace,s.REFRACTIONMAP_OPPOSITEZ=h.invertZ,s.LODINREFRACTIONALPHA=h.lodLevelInAlpha,this._linkRefractionWithTransparency&&(s.LINKREFRACTIONTOTRANSPARENCY=!0)}else s.REFRACTION=!1;if(this._environmentBRDFTexture&&e.StandardMaterial.ReflectionTextureEnabled){if(!this._environmentBRDFTexture.isReady())return!1;s.ENVIRONMENTBRDF=!0}this._shouldUseAlphaFromAlbedoTexture()&&(s.ALPHAFROMALBEDO=!0)}this._useSpecularOverAlpha&&(s.SPECULAROVERALPHA=!0),this._usePhysicalLightFalloff&&(s.USEPHYSICALLIGHTFALLOFF=!0),this._useRadianceOverAlpha&&(s.RADIANCEOVERALPHA=!0),(void 0!==this._metallic&&null!==this._metallic||void 0!==this._roughness&&null!==this._roughness)&&(s.METALLICWORKFLOW=!0),!this.backFaceCulling&&this._twoSidedLighting&&(s.TWOSIDEDLIGHTING=!0),s.ALPHATESTVALUE=this._alphaCutOff,s.PREMULTIPLYALPHA=this._preMultiplyAlpha,s.ALPHABLEND=this.needAlphaBlending(),s.ALPHAFRESNEL=this._useAlphaFresnel}if(s._areImageProcessingDirty){if(!this._imageProcessingConfiguration.isReady())return!1;this._imageProcessingConfiguration.prepareDefines(s)}if(s.FORCENORMALFORWARD=this._forceNormalForward,e.MaterialHelper.PrepareDefinesForMisc(i,o,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,s),e.MaterialHelper.PrepareDefinesForFrameBoundValues(o,a,s,n,this._forceAlphaTest),e.MaterialHelper.PrepareDefinesForAttributes(i,s,!0,!0,!0)&&i&&(o.getEngine().getCaps().standardDerivatives||i.isVerticesDataPresent(e.VertexBuffer.NormalKind)||(i.createNormals(!0),e.Tools.Warn("PBRMaterial: Normals have been created for the mesh: "+i.name))),s.isDirty){s.markAsProcessed(),o.resetCachedMaterial();var c=new e.EffectFallbacks;s.ENVIRONMENTBRDF&&c.addFallback(0,"ENVIRONMENTBRDF"),s.REFLECTION&&c.addFallback(0,"REFLECTION"),s.REFRACTION&&c.addFallback(0,"REFRACTION"),s.REFLECTIVITY&&c.addFallback(0,"REFLECTIVITY"),s.BUMP&&c.addFallback(0,"BUMP"),s.PARALLAX&&c.addFallback(1,"PARALLAX"),s.PARALLAXOCCLUSION&&c.addFallback(0,"PARALLAXOCCLUSION"),s.SPECULAROVERALPHA&&c.addFallback(0,"SPECULAROVERALPHA"),s.FOG&&c.addFallback(1,"FOG"),s.POINTSIZE&&c.addFallback(0,"POINTSIZE"),s.LOGARITHMICDEPTH&&c.addFallback(0,"LOGARITHMICDEPTH"),e.MaterialHelper.HandleFallbacksForShadows(s,c,this._maxSimultaneousLights),s.SPECULARTERM&&c.addFallback(0,"SPECULARTERM"),s.NUM_BONE_INFLUENCERS>0&&c.addCPUSkinningFallback(0,i);var u=[e.VertexBuffer.PositionKind];s.NORMAL&&u.push(e.VertexBuffer.NormalKind),s.TANGENT&&u.push(e.VertexBuffer.TangentKind),s.UV1&&u.push(e.VertexBuffer.UVKind),s.UV2&&u.push(e.VertexBuffer.UV2Kind),s.VERTEXCOLOR&&u.push(e.VertexBuffer.ColorKind),e.MaterialHelper.PrepareAttributesForBones(u,i,s,c),e.MaterialHelper.PrepareAttributesForInstances(u,s),e.MaterialHelper.PrepareAttributesForMorphTargets(u,i,s);var f=["world","view","viewProjection","vEyePosition","vLightsType","vAmbientColor","vAlbedoColor","vReflectivityColor","vEmissiveColor","vReflectionColor","vFogInfos","vFogColor","pointSize","vAlbedoInfos","vAmbientInfos","vOpacityInfos","vReflectionInfos","vEmissiveInfos","vReflectivityInfos","vMicroSurfaceSamplerInfos","vBumpInfos","vLightmapInfos","vRefractionInfos","mBones","vClipPlane","albedoMatrix","ambientMatrix","opacityMatrix","reflectionMatrix","emissiveMatrix","reflectivityMatrix","microSurfaceSamplerMatrix","bumpMatrix","lightmapMatrix","refractionMatrix","vLightingIntensity","logarithmicDepthConstant","vSphericalX","vSphericalY","vSphericalZ","vSphericalXX","vSphericalYY","vSphericalZZ","vSphericalXY","vSphericalYZ","vSphericalZX","vReflectionMicrosurfaceInfos","vRefractionMicrosurfaceInfos","vNormalReoderParams"],d=["albedoSampler","reflectivitySampler","ambientSampler","emissiveSampler","bumpSampler","lightmapSampler","opacitySampler","refractionSampler","refractionSamplerLow","refractionSamplerHigh","reflectionSampler","reflectionSamplerLow","reflectionSamplerHigh","microSurfaceSampler","environmentBrdfSampler"],p=["Material","Scene"];e.ImageProcessingConfiguration.PrepareUniforms(f,s),e.ImageProcessingConfiguration.PrepareSamplers(d,s),e.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:f,uniformBuffersNames:p,samplers:d,defines:s,maxSimultaneousLights:this._maxSimultaneousLights});var m=function(e){this.onCompiled&&this.onCompiled(e),this.bindSceneUniformBuffer(e,o.getSceneUniformBuffer())}.bind(this),_=s.toString();r.setEffect(o.getEngine().createEffect("pbr",{attributes:u,uniformsNames:f,uniformBuffersNames:p,samplers:d,defines:_,fallbacks:c,onCompiled:m,onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights,maxSimultaneousMorphTargets:s.NUM_MORPH_INFLUENCERS}},a),s),this.buildUniformLayout()}return!!r.effect.isReady()&&(s._renderId=o.getRenderId(),this._wasPreviouslyReady=!0,!0)},r.prototype.buildUniformLayout=function(){this._uniformBuffer.addUniform("vAlbedoInfos",2),this._uniformBuffer.addUniform("vAmbientInfos",3),this._uniformBuffer.addUniform("vOpacityInfos",2),this._uniformBuffer.addUniform("vEmissiveInfos",2),this._uniformBuffer.addUniform("vLightmapInfos",2),this._uniformBuffer.addUniform("vReflectivityInfos",3),this._uniformBuffer.addUniform("vMicroSurfaceSamplerInfos",2),this._uniformBuffer.addUniform("vRefractionInfos",4),this._uniformBuffer.addUniform("vReflectionInfos",2),this._uniformBuffer.addUniform("vBumpInfos",3),this._uniformBuffer.addUniform("albedoMatrix",16),this._uniformBuffer.addUniform("ambientMatrix",16),this._uniformBuffer.addUniform("opacityMatrix",16),this._uniformBuffer.addUniform("emissiveMatrix",16),this._uniformBuffer.addUniform("lightmapMatrix",16),this._uniformBuffer.addUniform("reflectivityMatrix",16),this._uniformBuffer.addUniform("microSurfaceSamplerMatrix",16),this._uniformBuffer.addUniform("bumpMatrix",16),this._uniformBuffer.addUniform("vNormalReoderParams",4),this._uniformBuffer.addUniform("refractionMatrix",16),this._uniformBuffer.addUniform("reflectionMatrix",16),this._uniformBuffer.addUniform("vReflectionColor",3),this._uniformBuffer.addUniform("vAlbedoColor",4),this._uniformBuffer.addUniform("vLightingIntensity",4),this._uniformBuffer.addUniform("vRefractionMicrosurfaceInfos",3),this._uniformBuffer.addUniform("vReflectionMicrosurfaceInfos",3),this._uniformBuffer.addUniform("vReflectivityColor",4),this._uniformBuffer.addUniform("vEmissiveColor",3),this._uniformBuffer.addUniform("pointSize",1),this._uniformBuffer.create()},r.prototype.unbind=function(){this._reflectionTexture&&this._reflectionTexture.isRenderTarget&&this._uniformBuffer.setTexture("reflectionSampler",null),this._refractionTexture&&this._refractionTexture.isRenderTarget&&this._uniformBuffer.setTexture("refractionSampler",null),i.prototype.unbind.call(this)},r.prototype.bindOnlyWorldMatrix=function(e){this._activeEffect.setMatrix("world",e)},r.prototype.bindForSubMesh=function(t,i,r){var n=this.getScene(),o=r._materialDefines;if(o){var s=r.effect;if(this._activeEffect=s,this.bindOnlyWorldMatrix(t),e.MaterialHelper.BindBonesParameters(i,this._activeEffect),this._mustRebind(n,s,i.visibility)){if(this._uniformBuffer.bindToEffect(s,"Material"),this.bindViewProjection(s),!this._uniformBuffer.useUbo||!this.isFrozen||!this._uniformBuffer.isSync){if(n.texturesEnabled){this._albedoTexture&&e.StandardMaterial.DiffuseTextureEnabled&&(this._uniformBuffer.updateFloat2("vAlbedoInfos",this._albedoTexture.coordinatesIndex,this._albedoTexture.level),e.MaterialHelper.BindTextureMatrix(this._albedoTexture,this._uniformBuffer,"albedo")),this._ambientTexture&&e.StandardMaterial.AmbientTextureEnabled&&(this._uniformBuffer.updateFloat3("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level,this._ambientTextureStrength),e.MaterialHelper.BindTextureMatrix(this._ambientTexture,this._uniformBuffer,"ambient")),this._opacityTexture&&e.StandardMaterial.OpacityTextureEnabled&&(this._uniformBuffer.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),e.MaterialHelper.BindTextureMatrix(this._opacityTexture,this._uniformBuffer,"opacity"));var a=this._getReflectionTexture();if(a&&e.StandardMaterial.ReflectionTextureEnabled){if(this._uniformBuffer.updateMatrix("reflectionMatrix",a.getReflectionTextureMatrix()),this._uniformBuffer.updateFloat2("vReflectionInfos",a.level,0),o.USESPHERICALFROMREFLECTIONMAP){var h=a.sphericalPolynomial;this._activeEffect.setFloat3("vSphericalX",h.x.x,h.x.y,h.x.z),this._activeEffect.setFloat3("vSphericalY",h.y.x,h.y.y,h.y.z),this._activeEffect.setFloat3("vSphericalZ",h.z.x,h.z.y,h.z.z),this._activeEffect.setFloat3("vSphericalXX_ZZ",h.xx.x-h.zz.x,h.xx.y-h.zz.y,h.xx.z-h.zz.z),this._activeEffect.setFloat3("vSphericalYY_ZZ",h.yy.x-h.zz.x,h.yy.y-h.zz.y,h.yy.z-h.zz.z),this._activeEffect.setFloat3("vSphericalZZ",h.zz.x,h.zz.y,h.zz.z),this._activeEffect.setFloat3("vSphericalXY",h.xy.x,h.xy.y,h.xy.z),this._activeEffect.setFloat3("vSphericalYZ",h.yz.x,h.yz.y,h.yz.z),this._activeEffect.setFloat3("vSphericalZX",h.zx.x,h.zx.y,h.zx.z)}this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos",a.getSize().width,a.lodGenerationScale,a.lodGenerationOffset)}this._emissiveTexture&&e.StandardMaterial.EmissiveTextureEnabled&&(this._uniformBuffer.updateFloat2("vEmissiveInfos",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),e.MaterialHelper.BindTextureMatrix(this._emissiveTexture,this._uniformBuffer,"emissive")),this._lightmapTexture&&e.StandardMaterial.LightmapTextureEnabled&&(this._uniformBuffer.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),e.MaterialHelper.BindTextureMatrix(this._lightmapTexture,this._uniformBuffer,"lightmap")),e.StandardMaterial.SpecularTextureEnabled&&(this._metallicTexture?(this._uniformBuffer.updateFloat3("vReflectivityInfos",this._metallicTexture.coordinatesIndex,this._metallicTexture.level,this._ambientTextureStrength),e.MaterialHelper.BindTextureMatrix(this._metallicTexture,this._uniformBuffer,"reflectivity")):this._reflectivityTexture&&(this._uniformBuffer.updateFloat3("vReflectivityInfos",this._reflectivityTexture.coordinatesIndex,this._reflectivityTexture.level,1),e.MaterialHelper.BindTextureMatrix(this._reflectivityTexture,this._uniformBuffer,"reflectivity")),this._microSurfaceTexture&&(this._uniformBuffer.updateFloat2("vMicroSurfaceSamplerInfos",this._microSurfaceTexture.coordinatesIndex,this._microSurfaceTexture.level),e.MaterialHelper.BindTextureMatrix(this._microSurfaceTexture,this._uniformBuffer,"microSurfaceSampler"))),this._bumpTexture&&n.getEngine().getCaps().standardDerivatives&&e.StandardMaterial.BumpTextureEnabled&&!this._disableBumpMap&&(this._uniformBuffer.updateFloat3("vBumpInfos",this._bumpTexture.coordinatesIndex,this._bumpTexture.level,this._parallaxScaleBias),e.MaterialHelper.BindTextureMatrix(this._bumpTexture,this._uniformBuffer,"bump"),n._mirroredCameraPosition?this._uniformBuffer.updateFloat4("vNormalReoderParams",this._invertNormalMapX?0:1,this._invertNormalMapX?1:-1,this._invertNormalMapY?0:1,this._invertNormalMapY?1:-1):this._uniformBuffer.updateFloat4("vNormalReoderParams",this._invertNormalMapX?1:0,this._invertNormalMapX?-1:1,this._invertNormalMapY?1:0,this._invertNormalMapY?-1:1));var l=this._getRefractionTexture();if(l&&e.StandardMaterial.RefractionTextureEnabled){this._uniformBuffer.updateMatrix("refractionMatrix",l.getReflectionTextureMatrix());var c=1;l.isCube||l.depth&&(c=l.depth),this._uniformBuffer.updateFloat4("vRefractionInfos",l.level,this._indexOfRefraction,c,this._invertRefractionY?-1:1),this._uniformBuffer.updateFloat3("vRefractionMicrosurfaceInfos",l.getSize().width,l.lodGenerationScale,l.lodGenerationOffset)}}this.pointsCloud&&this._uniformBuffer.updateFloat("pointSize",this.pointSize),o.METALLICWORKFLOW?(e.PBRMaterial._scaledReflectivity.r=void 0===this._metallic||null===this._metallic?1:this._metallic,e.PBRMaterial._scaledReflectivity.g=void 0===this._roughness||null===this._roughness?1:this._roughness,this._uniformBuffer.updateColor4("vReflectivityColor",e.PBRMaterial._scaledReflectivity,0)):this._uniformBuffer.updateColor4("vReflectivityColor",this._reflectivityColor,this._microSurface),this._uniformBuffer.updateColor3("vEmissiveColor",this._emissiveColor),this._uniformBuffer.updateColor3("vReflectionColor",this._reflectionColor),this._uniformBuffer.updateColor4("vAlbedoColor",this._albedoColor,this.alpha*i.visibility),this._lightingInfos.x=this._directIntensity,this._lightingInfos.y=this._emissiveIntensity,this._lightingInfos.z=this._environmentIntensity,this._lightingInfos.w=this._specularIntensity,this._uniformBuffer.updateVector4("vLightingIntensity",this._lightingInfos)}n.texturesEnabled&&(this._albedoTexture&&e.StandardMaterial.DiffuseTextureEnabled&&this._uniformBuffer.setTexture("albedoSampler",this._albedoTexture),this._ambientTexture&&e.StandardMaterial.AmbientTextureEnabled&&this._uniformBuffer.setTexture("ambientSampler",this._ambientTexture),this._opacityTexture&&e.StandardMaterial.OpacityTextureEnabled&&this._uniformBuffer.setTexture("opacitySampler",this._opacityTexture),a&&e.StandardMaterial.ReflectionTextureEnabled&&(o.LODBASEDMICROSFURACE?this._uniformBuffer.setTexture("reflectionSampler",a):(this._uniformBuffer.setTexture("reflectionSampler",a._lodTextureMid||a),this._uniformBuffer.setTexture("reflectionSamplerLow",a._lodTextureLow||a),this._uniformBuffer.setTexture("reflectionSamplerHigh",a._lodTextureHigh||a))),o.ENVIRONMENTBRDF&&this._uniformBuffer.setTexture("environmentBrdfSampler",this._environmentBRDFTexture),l&&e.StandardMaterial.RefractionTextureEnabled&&(o.LODBASEDMICROSFURACE?this._uniformBuffer.setTexture("refractionSampler",l):(this._uniformBuffer.setTexture("refractionSampler",l._lodTextureMid||l),this._uniformBuffer.setTexture("refractionSamplerLow",l._lodTextureLow||l),this._uniformBuffer.setTexture("refractionSamplerHigh",l._lodTextureHigh||l))),this._emissiveTexture&&e.StandardMaterial.EmissiveTextureEnabled&&this._uniformBuffer.setTexture("emissiveSampler",this._emissiveTexture), +this._lightmapTexture&&e.StandardMaterial.LightmapTextureEnabled&&this._uniformBuffer.setTexture("lightmapSampler",this._lightmapTexture),e.StandardMaterial.SpecularTextureEnabled&&(this._metallicTexture?this._uniformBuffer.setTexture("reflectivitySampler",this._metallicTexture):this._reflectivityTexture&&this._uniformBuffer.setTexture("reflectivitySampler",this._reflectivityTexture),this._microSurfaceTexture&&this._uniformBuffer.setTexture("microSurfaceSampler",this._microSurfaceTexture)),this._bumpTexture&&n.getEngine().getCaps().standardDerivatives&&e.StandardMaterial.BumpTextureEnabled&&!this._disableBumpMap&&this._uniformBuffer.setTexture("bumpSampler",this._bumpTexture)),e.MaterialHelper.BindClipPlane(this._activeEffect,n),n.ambientColor.multiplyToRef(this._ambientColor,this._globalAmbientColor);var u=n._mirroredCameraPosition?n._mirroredCameraPosition:n.activeCamera.globalPosition;s.setFloat4("vEyePosition",u.x,u.y,u.z,n._mirroredCameraPosition?-1:1),s.setColor3("vAmbientColor",this._globalAmbientColor)}!this._mustRebind(n,s)&&this.isFrozen||(n.lightsEnabled&&!this._disableLighting&&e.MaterialHelper.BindLights(n,i,this._activeEffect,o,this._maxSimultaneousLights,this._usePhysicalLightFalloff),(n.fogEnabled&&i.applyFog&&n.fogMode!==e.Scene.FOGMODE_NONE||a)&&this.bindView(s),e.MaterialHelper.BindFogParameters(n,i,this._activeEffect),o.NUM_MORPH_INFLUENCERS&&e.MaterialHelper.BindMorphTargetParameters(i,this._activeEffect),this._imageProcessingConfiguration.bind(this._activeEffect),e.MaterialHelper.BindLogDepth(o,this._activeEffect,n)),this._uniformBuffer.update(),this._afterBind(i),n=null}},r.prototype.getAnimatables=function(){var e=[];return this._albedoTexture&&this._albedoTexture.animations&&this._albedoTexture.animations.length>0&&e.push(this._albedoTexture),this._ambientTexture&&this._ambientTexture.animations&&this._ambientTexture.animations.length>0&&e.push(this._ambientTexture),this._opacityTexture&&this._opacityTexture.animations&&this._opacityTexture.animations.length>0&&e.push(this._opacityTexture),this._reflectionTexture&&this._reflectionTexture.animations&&this._reflectionTexture.animations.length>0&&e.push(this._reflectionTexture),this._emissiveTexture&&this._emissiveTexture.animations&&this._emissiveTexture.animations.length>0&&e.push(this._emissiveTexture),this._metallicTexture&&this._metallicTexture.animations&&this._metallicTexture.animations.length>0?e.push(this._metallicTexture):this._reflectivityTexture&&this._reflectivityTexture.animations&&this._reflectivityTexture.animations.length>0&&e.push(this._reflectivityTexture),this._bumpTexture&&this._bumpTexture.animations&&this._bumpTexture.animations.length>0&&e.push(this._bumpTexture),this._lightmapTexture&&this._lightmapTexture.animations&&this._lightmapTexture.animations.length>0&&e.push(this._lightmapTexture),this._refractionTexture&&this._refractionTexture.animations&&this._refractionTexture.animations.length>0&&e.push(this._refractionTexture),e},r.prototype._getReflectionTexture=function(){return this._reflectionTexture?this._reflectionTexture:this.getScene().environmentTexture},r.prototype._getRefractionTexture=function(){return this._refractionTexture?this._refractionTexture:this._linkRefractionWithTransparency?this.getScene().environmentTexture:null},r.prototype.dispose=function(e,t){t&&(this._albedoTexture&&this._albedoTexture.dispose(),this._ambientTexture&&this._ambientTexture.dispose(),this._opacityTexture&&this._opacityTexture.dispose(),this._reflectionTexture&&this._reflectionTexture.dispose(),this._environmentBRDFTexture&&this._environmentBRDFTexture.dispose(),this._emissiveTexture&&this._emissiveTexture.dispose(),this._metallicTexture&&this._metallicTexture.dispose(),this._reflectivityTexture&&this._reflectivityTexture.dispose(),this._bumpTexture&&this._bumpTexture.dispose(),this._lightmapTexture&&this._lightmapTexture.dispose(),this._refractionTexture&&this._refractionTexture.dispose()),this._renderTargets.dispose(),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),i.prototype.dispose.call(this,e,t)},r})(e.PushMaterial);i._scaledReflectivity=new e.Color3,__decorate([e.serializeAsImageProcessingConfiguration()],i.prototype,"_imageProcessingConfiguration",void 0),__decorate([e.serialize()],i.prototype,"useLogarithmicDepth",null),e.PBRBaseMaterial=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){var i=(function(t){function i(i,r){var n=t.call(this,i,r)||this;return n.maxSimultaneousLights=4,n.disableLighting=!1,n.invertNormalMapX=!1,n.invertNormalMapY=!1,n.emissiveColor=new e.Color3(0,0,0),n.occlusionStrength=1,n._transparencyMode=e.PBRMaterial.PBRMATERIAL_OPAQUE,n._useAmbientInGrayScale=!0,n}return __extends(i,t),Object.defineProperty(i.prototype,"transparencyMode",{get:function(){return this._transparencyMode},set:function(t){this._transparencyMode!==t&&(this._transparencyMode=t,t===e.PBRMaterial.PBRMATERIAL_ALPHATESTANDBLEND?this._forceAlphaTest=!0:this._forceAlphaTest=!1,this._markAllSubMeshesAsTexturesDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"doubleSided",{get:function(){return this._twoSidedLighting},set:function(e){this._twoSidedLighting!==e&&(this._twoSidedLighting=e,this.backFaceCulling=!e,this._markAllSubMeshesAsTexturesDirty())},enumerable:!0,configurable:!0}),i.prototype._shouldUseAlphaFromAlbedoTexture=function(){return this._albedoTexture&&this._albedoTexture.hasAlpha&&this._transparencyMode!==e.PBRMaterial.PBRMATERIAL_OPAQUE},i.prototype.needAlphaBlending=function(){return!this._linkRefractionWithTransparency&&(this.alpha<1||this._shouldUseAlphaFromAlbedoTexture()&&(this._transparencyMode===e.PBRMaterial.PBRMATERIAL_ALPHABLEND||this._transparencyMode===e.PBRMaterial.PBRMATERIAL_ALPHATESTANDBLEND))},i.prototype.needAlphaTesting=function(){return!this._linkRefractionWithTransparency&&(this._shouldUseAlphaFromAlbedoTexture()&&this._transparencyMode===e.PBRMaterial.PBRMATERIAL_ALPHATEST)},i.prototype.getActiveTextures=function(){var e=t.prototype.getActiveTextures.call(this);return this.environmentTexture&&e.push(this.environmentTexture),this.normalTexture&&e.push(this.normalTexture),this.emissiveTexture&&e.push(this.emissiveTexture),this.occlusionTexture&&e.push(this.occlusionTexture),e},i.prototype.getClassName=function(){return"PBRBaseSimpleMaterial"},i})(e.PBRBaseMaterial);__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsLightsDirty")],i.prototype,"maxSimultaneousLights",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsLightsDirty")],i.prototype,"disableLighting",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_reflectionTexture")],i.prototype,"environmentTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"invertNormalMapX",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"invertNormalMapY",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_bumpTexture")],i.prototype,"normalTexture",void 0),__decorate([e.serializeAsColor3("emissive"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"emissiveColor",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"emissiveTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_ambientTextureStrength")],i.prototype,"occlusionStrength",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_ambientTexture")],i.prototype,"occlusionTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_alphaCutOff")],i.prototype,"alphaCutOff",void 0),__decorate([e.serialize()],i.prototype,"transparencyMode",null),__decorate([e.serialize()],i.prototype,"doubleSided",null),t.PBRBaseSimpleMaterial=i})(e.Internals||(e.Internals={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r){var n=t.call(this,i,r)||this;return n.directIntensity=1,n.emissiveIntensity=1,n.environmentIntensity=1,n.specularIntensity=1,n.disableBumpMap=!1,n.ambientTextureStrength=1,n.ambientColor=new e.Color3(0,0,0),n.albedoColor=new e.Color3(1,1,1),n.reflectivityColor=new e.Color3(1,1,1),n.reflectionColor=new e.Color3(1,1,1),n.emissiveColor=new e.Color3(0,0,0),n.microSurface=1,n.indexOfRefraction=.66,n.invertRefractionY=!1,n.linkRefractionWithTransparency=!1,n.useLightmapAsShadowmap=!1,n.useAlphaFromAlbedoTexture=!1,n.forceAlphaTest=!1,n.alphaCutOff=.4,n.useSpecularOverAlpha=!0,n.useMicroSurfaceFromReflectivityMapAlpha=!1,n.useRoughnessFromMetallicTextureAlpha=!0,n.useRoughnessFromMetallicTextureGreen=!1,n.useMetallnessFromMetallicTextureBlue=!1,n.useAmbientOcclusionFromMetallicTextureRed=!1,n.useAmbientInGrayScale=!1,n.useAutoMicroSurfaceFromReflectivityMap=!1,n.usePhysicalLightFalloff=!0,n.useRadianceOverAlpha=!0,n.useParallax=!1,n.useParallaxOcclusion=!1,n.parallaxScaleBias=.05,n.disableLighting=!1,n.forceIrradianceInFragment=!1,n.maxSimultaneousLights=4,n.invertNormalMapX=!1,n.invertNormalMapY=!1,n.twoSidedLighting=!1,n.preMultiplyAlpha=!1,n.useAlphaFresnel=!1,n.environmentBRDFTexture=null,n.forceNormalForward=!1,n._environmentBRDFTexture=e.TextureTools.GetEnvironmentBRDFTexture(r),n}return __extends(i,t),Object.defineProperty(i,"PBRMATERIAL_OPAQUE",{get:function(){return this._PBRMATERIAL_OPAQUE},enumerable:!0,configurable:!0}),Object.defineProperty(i,"PBRMATERIAL_ALPHATEST",{get:function(){return this._PBRMATERIAL_ALPHATEST},enumerable:!0,configurable:!0}),Object.defineProperty(i,"PBRMATERIAL_ALPHABLEND",{get:function(){return this._PBRMATERIAL_ALPHABLEND},enumerable:!0,configurable:!0}),Object.defineProperty(i,"PBRMATERIAL_ALPHATESTANDBLEND",{get:function(){return this._PBRMATERIAL_ALPHATESTANDBLEND},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(e){this._attachImageProcessingConfiguration(e),this._markAllSubMeshesAsTexturesDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"cameraColorCurvesEnabled",{get:function(){return this.imageProcessingConfiguration.colorCurvesEnabled},set:function(e){this.imageProcessingConfiguration.colorCurvesEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"cameraColorGradingEnabled",{get:function(){return this.imageProcessingConfiguration.colorGradingEnabled},set:function(e){this.imageProcessingConfiguration.colorGradingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"cameraToneMappingEnabled",{get:function(){return this._imageProcessingConfiguration.toneMappingEnabled},set:function(e){this._imageProcessingConfiguration.toneMappingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"cameraExposure",{get:function(){return this._imageProcessingConfiguration.exposure},set:function(e){this._imageProcessingConfiguration.exposure=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"cameraContrast",{get:function(){return this._imageProcessingConfiguration.contrast},set:function(e){this._imageProcessingConfiguration.contrast=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"cameraColorGradingTexture",{get:function(){return this._imageProcessingConfiguration.colorGradingTexture},set:function(e){this._imageProcessingConfiguration.colorGradingTexture=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"cameraColorCurves",{get:function(){return this._imageProcessingConfiguration.colorCurves},set:function(e){this._imageProcessingConfiguration.colorCurves=e},enumerable:!0,configurable:!0}),i.prototype.getClassName=function(){return"PBRMaterial"},i.prototype.getActiveTextures=function(){var e=t.prototype.getActiveTextures.call(this);return this._albedoTexture&&e.push(this._albedoTexture),this._ambientTexture&&e.push(this._ambientTexture),this._opacityTexture&&e.push(this._opacityTexture),this._reflectionTexture&&e.push(this._reflectionTexture),this._emissiveTexture&&e.push(this._emissiveTexture),this._reflectivityTexture&&e.push(this._reflectivityTexture),this._metallicTexture&&e.push(this._metallicTexture),this._microSurfaceTexture&&e.push(this._microSurfaceTexture),this._bumpTexture&&e.push(this._bumpTexture),this._lightmapTexture&&e.push(this._lightmapTexture),this._refractionTexture&&e.push(this._refractionTexture),e},i.prototype.hasTexture=function(e){return!!t.prototype.hasTexture.call(this,e)||(this._albedoTexture===e||(this._ambientTexture===e||(this._opacityTexture===e||(this._reflectionTexture===e||(this._reflectivityTexture===e||(this._metallicTexture===e||(this._microSurfaceTexture===e||(this._bumpTexture===e||(this._lightmapTexture===e||this._refractionTexture===e)))))))))},i.prototype.clone=function(t){var r=this;return e.SerializationHelper.Clone((function(){return new i(t,r.getScene())}),this)},i.prototype.serialize=function(){var t=e.SerializationHelper.Serialize(this);return t.customType="BABYLON.PBRMaterial",t},i.Parse=function(t,r,n){return e.SerializationHelper.Parse((function(){return new i(t.name,r)}),t,r,n)},i})(e.PBRBaseMaterial);t._PBRMATERIAL_OPAQUE=0,t._PBRMATERIAL_ALPHATEST=1,t._PBRMATERIAL_ALPHABLEND=2,t._PBRMATERIAL_ALPHATESTANDBLEND=3,__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"directIntensity",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveIntensity",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"environmentIntensity",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"specularIntensity",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"disableBumpMap",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"albedoTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientTextureStrength",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"opacityTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectivityTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallicTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallic",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"roughness",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"microSurfaceTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"bumpTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty",null)],t.prototype,"lightmapTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"refractionTexture",void 0),__decorate([e.serializeAsColor3("ambient"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientColor",void 0),__decorate([e.serializeAsColor3("albedo"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"albedoColor",void 0),__decorate([e.serializeAsColor3("reflectivity"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectivityColor",void 0),__decorate([e.serializeAsColor3("reflection"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionColor",void 0),__decorate([e.serializeAsColor3("emissive"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveColor",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"microSurface",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"indexOfRefraction",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertRefractionY",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"linkRefractionWithTransparency",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useLightmapAsShadowmap",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAlphaFromAlbedoTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"forceAlphaTest",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"alphaCutOff",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useSpecularOverAlpha",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useMicroSurfaceFromReflectivityMapAlpha",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRoughnessFromMetallicTextureAlpha",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRoughnessFromMetallicTextureGreen",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useMetallnessFromMetallicTextureBlue",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAmbientOcclusionFromMetallicTextureRed",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAmbientInGrayScale",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAutoMicroSurfaceFromReflectivityMap",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"usePhysicalLightFalloff",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRadianceOverAlpha",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useParallax",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useParallaxOcclusion",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"parallaxScaleBias",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsLightsDirty")],t.prototype,"disableLighting",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"forceIrradianceInFragment",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsLightsDirty")],t.prototype,"maxSimultaneousLights",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapX",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapY",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"twoSidedLighting",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"preMultiplyAlpha",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAlphaFresnel",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"environmentBRDFTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"forceNormalForward",void 0),e.PBRMaterial=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e,i){var r=t.call(this,e,i)||this;return r._useRoughnessFromMetallicTextureAlpha=!1,r._useRoughnessFromMetallicTextureGreen=!0,r._useMetallnessFromMetallicTextureBlue=!0,r}return __extends(i,t),i.prototype.getClassName=function(){return"PBRMetallicRoughnessMaterial"},i.prototype.getActiveTextures=function(){var e=t.prototype.getActiveTextures.call(this);return this.baseTexture&&e.push(this.baseTexture),this.metallicRoughnessTexture&&e.push(this.metallicRoughnessTexture),e},i.prototype.hasTexture=function(e){return!!t.prototype.hasTexture.call(this,e)||(this.baseTexture===e||this.metallicRoughnessTexture===e)},i.prototype.clone=function(t){var r=this;return e.SerializationHelper.Clone((function(){return new i(t,r.getScene())}),this)},i.prototype.serialize=function(){var t=e.SerializationHelper.Serialize(this);return t.customType="BABYLON.PBRMetallicRoughnessMaterial",t},i.Parse=function(t,r,n){return e.SerializationHelper.Parse((function(){return new i(t.name,r)}),t,r,n)},i})(e.Internals.PBRBaseSimpleMaterial);__decorate([e.serializeAsColor3(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_albedoColor")],t.prototype,"baseColor",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_albedoTexture")],t.prototype,"baseTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallic",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"roughness",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_metallicTexture")],t.prototype,"metallicRoughnessTexture",void 0),e.PBRMetallicRoughnessMaterial=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e,i){var r=t.call(this,e,i)||this;return r._useMicroSurfaceFromReflectivityMapAlpha=!0,r}return __extends(i,t),i.prototype.getClassName=function(){return"PBRSpecularGlossinessMaterial"},i.prototype.getActiveTextures=function(){var e=t.prototype.getActiveTextures.call(this);return this.diffuseTexture&&e.push(this.diffuseTexture),this.specularGlossinessTexture&&e.push(this.specularGlossinessTexture),e},i.prototype.hasTexture=function(e){return!!t.prototype.hasTexture.call(this,e)||(this.diffuseTexture===e||this.specularGlossinessTexture===e)},i.prototype.clone=function(t){var r=this;return e.SerializationHelper.Clone((function(){return new i(t,r.getScene())}),this)},i.prototype.serialize=function(){var t=e.SerializationHelper.Serialize(this);return t.customType="BABYLON.PBRSpecularGlossinessMaterial",t},i.Parse=function(t,r,n){return e.SerializationHelper.Parse((function(){return new i(t.name,r)}),t,r,n)},i})(e.Internals.PBRBaseSimpleMaterial);__decorate([e.serializeAsColor3("diffuse"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_albedoColor")],t.prototype,"diffuseColor",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_albedoTexture")],t.prototype,"diffuseTexture",void 0),__decorate([e.serializeAsColor3("specular"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_reflectivityColor")],t.prototype,"specularColor",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_microSurface")],t.prototype,"glossiness",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_reflectivityTexture")],t.prototype,"specularGlossinessTexture",void 0),e.PBRSpecularGlossinessMaterial=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){e.CameraInputTypes={};var t=(function(){function t(e){this.attached={},this.camera=e,this.checkInputs=function(){}}return t.prototype.add=function(t){var i=t.getSimpleName();if(this.attached[i])return void e.Tools.Warn("camera input of type "+i+" already exists on camera");this.attached[i]=t,t.camera=this.camera,t.checkInputs&&(this.checkInputs=this._addCheckInputs(t.checkInputs.bind(t))),this.attachedElement&&t.attachControl(this.attachedElement)},t.prototype.remove=function(e){for(var t in this.attached){var i=this.attached[t];i===e&&(i.detachControl(this.attachedElement),delete this.attached[t],this.rebuildInputCheck())}},t.prototype.removeByType=function(e){for(var t in this.attached){var i=this.attached[t];i.getClassName()===e&&(i.detachControl(this.attachedElement),delete this.attached[t],this.rebuildInputCheck())}},t.prototype._addCheckInputs=function(e){var t=this.checkInputs;return function(){t(),e()}},t.prototype.attachInput=function(e){e.attachControl(this.attachedElement,this.noPreventDefault)},t.prototype.attachElement=function(t,i){if(!this.attachedElement){i=!e.Camera.ForceAttachControlToAlwaysPreventDefault&&i,this.attachedElement=t,this.noPreventDefault=i;for(var r in this.attached){this.attached[r];this.attached[r].attachControl(t,i)}}},t.prototype.detachElement=function(e){if(this.attachedElement===e){for(var t in this.attached){this.attached[t];this.attached[t].detachControl(e)}this.attachedElement=null}},t.prototype.rebuildInputCheck=function(){this.checkInputs=function(){};for(var e in this.attached){var t=this.attached[e];t.checkInputs&&(this.checkInputs=this._addCheckInputs(t.checkInputs.bind(t)))}},t.prototype.clear=function(){this.attachedElement&&this.detachElement(this.attachedElement),this.attached={},this.attachedElement=null,this.checkInputs=function(){}},t.prototype.serialize=function(t){var i={};for(var r in this.attached){var n=this.attached[r],o=e.SerializationHelper.Serialize(n);i[n.getClassName()]=o}t.inputsmgr=i},t.prototype.parse=function(t){var i=t.inputsmgr;if(i){this.clear();for(var r in i){var n=e.CameraInputTypes[r];if(n){var o=i[r],s=e.SerializationHelper.Parse((function(){return new n}),o,null);this.add(s)}}}else for(var r in this.attached){var n=e.CameraInputTypes[this.attached[r].getClassName()];if(n){var s=e.SerializationHelper.Parse((function(){return new n}),t,null);this.remove(this.attached[r]),this.add(s)}}},t})();e.CameraInputsManager=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e){void 0===e&&(e=!0),this.touchEnabled=e,this.buttons=[0,1,2],this.angularSensibility=2e3}return t.prototype.attachControl=function(t,i){var r=this,n=this.camera.getEngine();this._pointerInput||(this._pointerInput=function(o,s){var a=o.event;if((r.touchEnabled||"touch"!==a.pointerType)&&(o.type===e.PointerEventTypes.POINTERMOVE||-1!==r.buttons.indexOf(a.button)))if(o.type===e.PointerEventTypes.POINTERDOWN){try{a.srcElement.setPointerCapture(a.pointerId)}catch(e){}r.previousPosition={x:a.clientX,y:a.clientY},i||(a.preventDefault(),t.focus())}else if(o.type===e.PointerEventTypes.POINTERUP){try{a.srcElement.releasePointerCapture(a.pointerId)}catch(e){}r.previousPosition=null,i||a.preventDefault()}else if(o.type===e.PointerEventTypes.POINTERMOVE){if(!r.previousPosition||n.isPointerLock)return;var h=a.clientX-r.previousPosition.x,l=a.clientY-r.previousPosition.y;r.camera.getScene().useRightHandedSystem?r.camera.cameraRotation.y-=h/r.angularSensibility:r.camera.cameraRotation.y+=h/r.angularSensibility,r.camera.cameraRotation.x+=l/r.angularSensibility,r.previousPosition={x:a.clientX,y:a.clientY},i||a.preventDefault()}}),this._onMouseMove=function(e){if(n.isPointerLock){var t=e.movementX||e.mozMovementX||e.webkitMovementX||e.msMovementX||0,o=e.movementY||e.mozMovementY||e.webkitMovementY||e.msMovementY||0;r.camera.getScene().useRightHandedSystem?r.camera.cameraRotation.y-=t/r.angularSensibility:r.camera.cameraRotation.y+=t/r.angularSensibility,r.camera.cameraRotation.x+=o/r.angularSensibility,r.previousPosition=null,i||e.preventDefault()}},this._observer=this.camera.getScene().onPointerObservable.add(this._pointerInput,e.PointerEventTypes.POINTERDOWN|e.PointerEventTypes.POINTERUP|e.PointerEventTypes.POINTERMOVE),t.addEventListener("mousemove",this._onMouseMove,!1)},t.prototype.detachControl=function(e){this._observer&&e&&(this.camera.getScene().onPointerObservable.remove(this._observer),e.removeEventListener("mousemove",this._onMouseMove),this._observer=null,this._onMouseMove=null,this.previousPosition=null)},t.prototype.getClassName=function(){return"FreeCameraMouseInput"},t.prototype.getSimpleName=function(){return"mouse"},t})();__decorate([e.serialize()],t.prototype,"buttons",void 0),__decorate([e.serialize()],t.prototype,"angularSensibility",void 0),e.FreeCameraMouseInput=t,e.CameraInputTypes.FreeCameraMouseInput=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this._keys=[],this.keysUp=[38],this.keysDown=[40],this.keysLeft=[37],this.keysRight=[39]}return t.prototype.attachControl=function(t,i){var r=this;this._onKeyDown||(t.tabIndex=1,this._onKeyDown=function(e){if(-1!==r.keysUp.indexOf(e.keyCode)||-1!==r.keysDown.indexOf(e.keyCode)||-1!==r.keysLeft.indexOf(e.keyCode)||-1!==r.keysRight.indexOf(e.keyCode)){-1===r._keys.indexOf(e.keyCode)&&r._keys.push(e.keyCode),i||e.preventDefault()}},this._onKeyUp=function(e){if(-1!==r.keysUp.indexOf(e.keyCode)||-1!==r.keysDown.indexOf(e.keyCode)||-1!==r.keysLeft.indexOf(e.keyCode)||-1!==r.keysRight.indexOf(e.keyCode)){var t=r._keys.indexOf(e.keyCode);t>=0&&r._keys.splice(t,1),i||e.preventDefault()}},t.addEventListener("keydown",this._onKeyDown,!1),t.addEventListener("keyup",this._onKeyUp,!1),e.Tools.RegisterTopRootEvents([{name:"blur",handler:this._onLostFocus}]))},t.prototype.detachControl=function(t){this._onKeyDown&&(t.removeEventListener("keydown",this._onKeyDown),t.removeEventListener("keyup",this._onKeyUp),e.Tools.UnregisterTopRootEvents([{name:"blur",handler:this._onLostFocus}]),this._keys=[],this._onKeyDown=null,this._onKeyUp=null)},t.prototype.checkInputs=function(){if(this._onKeyDown)for(var t=this.camera,i=0;i=0?this.rotation.y=-Math.atan(i.z/i.x)+Math.PI/2:this.rotation.y=-Math.atan(i.z/i.x)-Math.PI/2,this.rotation.z=0,isNaN(this.rotation.x)&&(this.rotation.x=0),isNaN(this.rotation.y)&&(this.rotation.y=0),isNaN(this.rotation.z)&&(this.rotation.z=0),this.rotationQuaternion&&e.Quaternion.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this.rotationQuaternion)},i.prototype.getTarget=function(){return this._currentTarget},i.prototype._decideIfNeedsToMove=function(){return Math.abs(this.cameraDirection.x)>0||Math.abs(this.cameraDirection.y)>0||Math.abs(this.cameraDirection.z)>0},i.prototype._updatePosition=function(){if(this.parent)return this.parent.getWorldMatrix().invertToRef(e.Tmp.Matrix[0]),e.Vector3.TransformNormalToRef(this.cameraDirection,e.Tmp.Matrix[0],e.Tmp.Vector3[0]),void this.position.addInPlace(e.Tmp.Vector3[0]);this.position.addInPlace(this.cameraDirection)},i.prototype._checkInputs=function(){var i=this._decideIfNeedsToMove(),r=Math.abs(this.cameraRotation.x)>0||Math.abs(this.cameraRotation.y)>0;if(i&&this._updatePosition(),r){if(this.rotation.x+=this.cameraRotation.x,this.rotation.y+=this.cameraRotation.y,this.rotationQuaternion){this.rotation.lengthSquared()&&e.Quaternion.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this.rotationQuaternion)}if(!this.noRotationConstraint){var n=Math.PI/2*.95;this.rotation.x>n&&(this.rotation.x=n),this.rotation.x<-n&&(this.rotation.x=-n)}}i&&(Math.abs(this.cameraDirection.x)e.Engine.CollisionsEpsilon&&(o.position.addInPlace(o._diffPosition),o.onCollide&&r&&o.onCollide(r))})(i)},o.inputs=new e.FreeCameraInputsManager(o),o.inputs.addKeyboard().addMouse(),o}return __extends(i,t),Object.defineProperty(i.prototype,"angularSensibility",{get:function(){var e=this.inputs.attached.mouse;if(e)return e.angularSensibility},set:function(e){var t=this.inputs.attached.mouse;t&&(t.angularSensibility=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"keysUp",{get:function(){var e=this.inputs.attached.keyboard;if(e)return e.keysUp},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysUp=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"keysDown",{get:function(){var e=this.inputs.attached.keyboard;if(e)return e.keysDown},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysDown=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"keysLeft",{get:function(){var e=this.inputs.attached.keyboard;if(e)return e.keysLeft},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysLeft=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"keysRight",{get:function(){var e=this.inputs.attached.keyboard;if(e)return e.keysRight},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysRight=e)},enumerable:!0,configurable:!0}),i.prototype.attachControl=function(e,t){this.inputs.attachElement(e,t)},i.prototype.detachControl=function(t){this.inputs.detachElement(t),this.cameraDirection=new e.Vector3(0,0,0),this.cameraRotation=new e.Vector2(0,0)},Object.defineProperty(i.prototype,"collisionMask",{get:function(){return this._collisionMask},set:function(e){this._collisionMask=isNaN(e)?-1:e},enumerable:!0,configurable:!0}),i.prototype._collideWithWorld=function(t){var i;i=this.parent?e.Vector3.TransformCoordinates(this.position,this.parent.getWorldMatrix()):this.position,i.subtractFromFloatsToRef(0,this.ellipsoid.y,0,this._oldPosition),this._collider||(this._collider=new e.Collider),this._collider.radius=this.ellipsoid,this._collider.collisionMask=this._collisionMask;var r=t;this.applyGravity&&(r=t.add(this.getScene().gravity)),this.getScene().collisionCoordinator.getNewPosition(this._oldPosition,r,this._collider,3,null,this._onCollisionPositionChange,this.uniqueId)},i.prototype._checkInputs=function(){this._localDirection||(this._localDirection=e.Vector3.Zero(),this._transformedDirection=e.Vector3.Zero()),this.inputs.checkInputs(),t.prototype._checkInputs.call(this)},i.prototype._decideIfNeedsToMove=function(){return this._needMoveForGravity||Math.abs(this.cameraDirection.x)>0||Math.abs(this.cameraDirection.y)>0||Math.abs(this.cameraDirection.z)>0},i.prototype._updatePosition=function(){this.checkCollisions&&this.getScene().collisionsEnabled?this._collideWithWorld(this.cameraDirection):t.prototype._updatePosition.call(this)},i.prototype.dispose=function(){this.inputs.clear(),t.prototype.dispose.call(this)},i.prototype.getClassName=function(){return"FreeCamera"},i})(e.TargetCamera);__decorate([e.serializeAsVector3()],t.prototype,"ellipsoid",void 0),__decorate([e.serialize()],t.prototype,"checkCollisions",void 0),__decorate([e.serialize()],t.prototype,"applyGravity",void 0),e.FreeCamera=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this._keys=[],this.keysUp=[38],this.keysDown=[40],this.keysLeft=[37],this.keysRight=[39]}return t.prototype.attachControl=function(t,i){var r=this;t.tabIndex=1,this._onKeyDown=function(e){if(-1!==r.keysUp.indexOf(e.keyCode)||-1!==r.keysDown.indexOf(e.keyCode)||-1!==r.keysLeft.indexOf(e.keyCode)||-1!==r.keysRight.indexOf(e.keyCode)){-1===r._keys.indexOf(e.keyCode)&&r._keys.push(e.keyCode),e.preventDefault&&(i||e.preventDefault())}},this._onKeyUp=function(e){if(-1!==r.keysUp.indexOf(e.keyCode)||-1!==r.keysDown.indexOf(e.keyCode)||-1!==r.keysLeft.indexOf(e.keyCode)||-1!==r.keysRight.indexOf(e.keyCode)){var t=r._keys.indexOf(e.keyCode);t>=0&&r._keys.splice(t,1),e.preventDefault&&(i||e.preventDefault())}},this._onLostFocus=function(){r._keys=[]},t.addEventListener("keydown",this._onKeyDown,!1),t.addEventListener("keyup",this._onKeyUp,!1),e.Tools.RegisterTopRootEvents([{name:"blur",handler:this._onLostFocus}])},t.prototype.detachControl=function(t){t&&(t.removeEventListener("keydown",this._onKeyDown),t.removeEventListener("keyup",this._onKeyUp)),e.Tools.UnregisterTopRootEvents([{name:"blur",handler:this._onLostFocus}]),this._keys=[],this._onKeyDown=null,this._onKeyUp=null,this._onLostFocus=null},t.prototype.checkInputs=function(){if(this._onKeyDown)for(var e=this.camera,t=0;tMath.PI&&(this.beta=this.beta-2*Math.PI):this.betathis.upperBetaLimit&&(this.beta=this.upperBetaLimit),this.lowerAlphaLimit&&this.alphathis.upperAlphaLimit&&(this.alpha=this.upperAlphaLimit),this.lowerRadiusLimit&&this.radiusthis.upperRadiusLimit&&(this.radius=this.upperRadiusLimit)},i.prototype.rebuildAnglesAndRadius=function(){var e=this.position.subtract(this._getTargetPosition());this.radius=e.length(),this.alpha=Math.acos(e.x/Math.sqrt(Math.pow(e.x,2)+Math.pow(e.z,2))),e.z<0&&(this.alpha=2*Math.PI-this.alpha),this.beta=Math.acos(e.y/this.radius),this._checkLimits()},i.prototype.setPosition=function(e){this.position.equals(e)||(this.position.copyFrom(e),this.rebuildAnglesAndRadius())},i.prototype.setTarget=function(e,t,i){if(void 0===t&&(t=!1),void 0===i&&(i=!1),e.getBoundingInfo)this._targetBoundingCenter=t?e.getBoundingInfo().boundingBox.centerWorld.clone():null,this._targetHost=e,this._target=this._getTargetPosition();else{var r=e,n=this._getTargetPosition();if(n&&!i&&n.equals(r))return;this._target=r,this._targetBoundingCenter=null}this.rebuildAnglesAndRadius()},i.prototype._getViewMatrix=function(){var t=Math.cos(this.alpha),i=Math.sin(this.alpha),r=Math.cos(this.beta),n=Math.sin(this.beta);0===n&&(n=1e-4);var o=this._getTargetPosition();if(o.addToRef(new e.Vector3(this.radius*t*n,this.radius*r,this.radius*i*n),this._newPosition),this.getScene().collisionsEnabled&&this.checkCollisions)this._collider||(this._collider=new e.Collider),this._collider.radius=this.collisionRadius,this._newPosition.subtractToRef(this.position,this._collisionVelocity),this._collisionTriggered=!0,this.getScene().collisionCoordinator.getNewPosition(this.position,this._collisionVelocity,this._collider,3,null,this._onCollisionPositionChange,this.uniqueId);else{this.position.copyFrom(this._newPosition);var s=this.upVector;this.allowUpsideDown&&n<0&&(s=s.clone(),s=s.negate()),this.getScene().useRightHandedSystem?e.Matrix.LookAtRHToRef(this.position,o,s,this._viewMatrix):e.Matrix.LookAtLHToRef(this.position,o,s,this._viewMatrix),this._viewMatrix.m[12]+=this.targetScreenOffset.x,this._viewMatrix.m[13]+=this.targetScreenOffset.y}return this._currentTarget=o,this._viewMatrix},i.prototype.zoomOn=function(t,i){void 0===i&&(i=!1),t=t||this.getScene().meshes;var r=e.Mesh.MinMax(t),n=e.Vector3.Distance(r.min,r.max);this.radius=n*this.zoomOnFactor,this.focusOn({min:r.min,max:r.max,distance:n},i)},i.prototype.focusOn=function(t,i){void 0===i&&(i=!1);var r,n;void 0===t.min?(r=t||this.getScene().meshes,r=e.Mesh.MinMax(r),n=e.Vector3.Distance(r.min,r.max)):(r=t,n=t.distance),this._target=e.Mesh.Center(r),i||(this.maxZ=2*n)},i.prototype.createRigCamera=function(t,r){var n;switch(this.cameraRigMode){case e.Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case e.Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER:case e.Camera.RIG_MODE_VR:n=this._cameraRigParams.stereoHalfAngle*(0===r?1:-1);break;case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:n=this._cameraRigParams.stereoHalfAngle*(0===r?-1:1)}var o=new i(t,this.alpha+n,this.beta,this.radius,this._target,this.getScene());return o._cameraRigParams={},o},i.prototype._updateRigCameras=function(){var i=this._rigCameras[0],r=this._rigCameras[1];switch(i.beta=r.beta=this.beta,i.radius=r.radius=this.radius,this.cameraRigMode){case e.Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case e.Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER:case e.Camera.RIG_MODE_VR:i.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle,r.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle;break;case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:i.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle,r.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle}t.prototype._updateRigCameras.call(this)},i.prototype.dispose=function(){this.inputs.clear(),t.prototype.dispose.call(this)},i.prototype.getClassName=function(){return"ArcRotateCamera"},i})(e.TargetCamera);__decorate([e.serialize()],t.prototype,"alpha",void 0),__decorate([e.serialize()],t.prototype,"beta",void 0),__decorate([e.serialize()],t.prototype,"radius",void 0),__decorate([e.serializeAsVector3("target")],t.prototype,"_target",void 0),__decorate([e.serialize()],t.prototype,"inertialAlphaOffset",void 0),__decorate([e.serialize()],t.prototype,"inertialBetaOffset",void 0),__decorate([e.serialize()],t.prototype,"inertialRadiusOffset",void 0),__decorate([e.serialize()],t.prototype,"lowerAlphaLimit",void 0),__decorate([e.serialize()],t.prototype,"upperAlphaLimit",void 0),__decorate([e.serialize()],t.prototype,"lowerBetaLimit",void 0),__decorate([e.serialize()],t.prototype,"upperBetaLimit",void 0),__decorate([e.serialize()],t.prototype,"lowerRadiusLimit",void 0),__decorate([e.serialize()],t.prototype,"upperRadiusLimit",void 0),__decorate([e.serialize()],t.prototype,"inertialPanningX",void 0),__decorate([e.serialize()],t.prototype,"inertialPanningY",void 0),__decorate([e.serialize()],t.prototype,"panningInertia",void 0),__decorate([e.serialize()],t.prototype,"zoomOnFactor",void 0),__decorate([e.serialize()],t.prototype,"allowUpsideDown",void 0),e.ArcRotateCamera=t +})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e){return t.call(this,e)||this}return __extends(i,t),i.prototype.addMouseWheel=function(){return this.add(new e.ArcRotateCameraMouseWheelInput),this},i.prototype.addPointers=function(){return this.add(new e.ArcRotateCameraPointersInput),this},i.prototype.addKeyboard=function(){return this.add(new e.ArcRotateCameraKeyboardMoveInput),this},i.prototype.addGamepad=function(){return this.add(new e.ArcRotateCameraGamepadInput),this},i.prototype.addVRDeviceOrientation=function(){return this.add(new e.ArcRotateCameraVRDeviceOrientationInput),this},i})(e.CameraInputsManager);e.ArcRotateCameraInputsManager=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n){var o=t.call(this,i,n)||this;return o.groundColor=new e.Color3(0,0,0),o.direction=r||e.Vector3.Up(),o}return __extends(i,t),i.prototype._buildUniformLayout=function(){this._uniformBuffer.addUniform("vLightData",4),this._uniformBuffer.addUniform("vLightDiffuse",4),this._uniformBuffer.addUniform("vLightSpecular",3),this._uniformBuffer.addUniform("vLightGround",3),this._uniformBuffer.addUniform("shadowsInfo",3),this._uniformBuffer.addUniform("depthValues",2),this._uniformBuffer.create()},i.prototype.getClassName=function(){return"HemisphericLight"},i.prototype.setDirectionToTarget=function(t){return this.direction=e.Vector3.Normalize(t.subtract(e.Vector3.Zero())),this.direction},i.prototype.getShadowGenerator=function(){return null},i.prototype.transferToEffect=function(t,i){var r=e.Vector3.Normalize(this.direction);return this._uniformBuffer.updateFloat4("vLightData",r.x,r.y,r.z,0,i),this._uniformBuffer.updateColor3("vLightGround",this.groundColor.scale(this.intensity),i),this},i.prototype._getWorldMatrix=function(){return this._worldMatrix||(this._worldMatrix=e.Matrix.Identity()),this._worldMatrix},i.prototype.getTypeID=function(){return e.Light.LIGHTTYPEID_HEMISPHERICLIGHT},i})(e.Light);__decorate([e.serializeAsColor3()],t.prototype,"groundColor",void 0),__decorate([e.serializeAsVector3()],t.prototype,"direction",void 0),e.HemisphericLight=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(){var e=null!==t&&t.apply(this,arguments)||this;return e._needProjectionMatrixCompute=!0,e}return __extends(i,t),Object.defineProperty(i.prototype,"direction",{get:function(){return this._direction},set:function(e){this._direction=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"shadowMinZ",{get:function(){return this._shadowMinZ},set:function(e){this._shadowMinZ=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"shadowMaxZ",{get:function(){return this._shadowMaxZ},set:function(e){this._shadowMaxZ=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),i.prototype.computeTransformedInformation=function(){return!(!this.parent||!this.parent.getWorldMatrix)&&(this.transformedPosition||(this.transformedPosition=e.Vector3.Zero()),e.Vector3.TransformCoordinatesToRef(this.position,this.parent.getWorldMatrix(),this.transformedPosition),this.direction&&(this.transformedDirection||(this.transformedDirection=e.Vector3.Zero()),e.Vector3.TransformNormalToRef(this.direction,this.parent.getWorldMatrix(),this.transformedDirection)),!0)},i.prototype.getDepthScale=function(){return 50},i.prototype.getShadowDirection=function(e){return this.transformedDirection?this.transformedDirection:this.direction},i.prototype.getAbsolutePosition=function(){return this.transformedPosition?this.transformedPosition:this.position},i.prototype.setDirectionToTarget=function(t){return this.direction=e.Vector3.Normalize(t.subtract(this.position)),this.direction},i.prototype.getRotation=function(){this.direction.normalize();var t=e.Vector3.Cross(this.direction,e.Axis.Y),i=e.Vector3.Cross(t,this.direction);return e.Vector3.RotationFromAxis(t,i,this.direction)},i.prototype.needCube=function(){return!1},i.prototype.needProjectionMatrixCompute=function(){return this._needProjectionMatrixCompute},i.prototype.forceProjectionMatrixCompute=function(){this._needProjectionMatrixCompute=!0},i.prototype._getWorldMatrix=function(){return this._worldMatrix||(this._worldMatrix=e.Matrix.Identity()),e.Matrix.TranslationToRef(this.position.x,this.position.y,this.position.z,this._worldMatrix),this._worldMatrix},i.prototype.getDepthMinZ=function(e){return void 0!==this.shadowMinZ?this.shadowMinZ:e.minZ},i.prototype.getDepthMaxZ=function(e){return void 0!==this.shadowMaxZ?this.shadowMaxZ:e.maxZ},i.prototype.setShadowProjectionMatrix=function(e,t,i){return this.customProjectionMatrixBuilder?this.customProjectionMatrixBuilder(t,i,e):this._setDefaultShadowProjectionMatrix(e,t,i),this},i})(e.Light);__decorate([e.serializeAsVector3()],t.prototype,"position",void 0),__decorate([e.serializeAsVector3()],t.prototype,"direction",null),__decorate([e.serialize()],t.prototype,"shadowMinZ",null),__decorate([e.serialize()],t.prototype,"shadowMaxZ",null),e.ShadowLight=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e,i,r){var n=t.call(this,e,r)||this;return n._shadowAngle=Math.PI/2,n.position=i,n}return __extends(i,t),Object.defineProperty(i.prototype,"shadowAngle",{get:function(){return this._shadowAngle},set:function(e){this._shadowAngle=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"direction",{get:function(){return this._direction},set:function(e){var t=this.needCube();this._direction=e,this.needCube()!==t&&this._shadowGenerator&&this._shadowGenerator.recreateShadowMap()},enumerable:!0,configurable:!0}),i.prototype.getClassName=function(){return"PointLight"},i.prototype.getTypeID=function(){return e.Light.LIGHTTYPEID_POINTLIGHT},i.prototype.needCube=function(){return!this.direction},i.prototype.getShadowDirection=function(i){if(this.direction)return t.prototype.getShadowDirection.call(this,i);switch(i){case 0:return new e.Vector3(1,0,0);case 1:return new e.Vector3(-1,0,0);case 2:return new e.Vector3(0,-1,0);case 3:return new e.Vector3(0,1,0);case 4:return new e.Vector3(0,0,1);case 5:return new e.Vector3(0,0,-1)}return e.Vector3.Zero()},i.prototype._setDefaultShadowProjectionMatrix=function(t,i,r){var n=this.getScene().activeCamera;e.Matrix.PerspectiveFovLHToRef(this.shadowAngle,1,this.getDepthMinZ(n),this.getDepthMaxZ(n),t)},i.prototype._buildUniformLayout=function(){this._uniformBuffer.addUniform("vLightData",4),this._uniformBuffer.addUniform("vLightDiffuse",4),this._uniformBuffer.addUniform("vLightSpecular",3),this._uniformBuffer.addUniform("shadowsInfo",3),this._uniformBuffer.addUniform("depthValues",2),this._uniformBuffer.create()},i.prototype.transferToEffect=function(e,t){return this.computeTransformedInformation()?(this._uniformBuffer.updateFloat4("vLightData",this.transformedPosition.x,this.transformedPosition.y,this.transformedPosition.z,0,t),this):(this._uniformBuffer.updateFloat4("vLightData",this.position.x,this.position.y,this.position.z,0,t),this)},i})(e.ShadowLight);__decorate([e.serialize()],t.prototype,"shadowAngle",null),e.PointLight=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e,i,r){var n=t.call(this,e,r)||this;return n._shadowFrustumSize=0,n._shadowOrthoScale=.5,n.autoUpdateExtends=!0,n._orthoLeft=Number.MAX_VALUE,n._orthoRight=Number.MIN_VALUE,n._orthoTop=Number.MIN_VALUE,n._orthoBottom=Number.MAX_VALUE,n.position=i.scale(-1),n.direction=i,n}return __extends(i,t),Object.defineProperty(i.prototype,"shadowFrustumSize",{get:function(){return this._shadowFrustumSize},set:function(e){this._shadowFrustumSize=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"shadowOrthoScale",{get:function(){return this._shadowOrthoScale},set:function(e){this._shadowOrthoScale=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),i.prototype.getClassName=function(){return"DirectionalLight"},i.prototype.getTypeID=function(){return e.Light.LIGHTTYPEID_DIRECTIONALLIGHT},i.prototype._setDefaultShadowProjectionMatrix=function(e,t,i){this.shadowFrustumSize>0?this._setDefaultFixedFrustumShadowProjectionMatrix(e,t):this._setDefaultAutoExtendShadowProjectionMatrix(e,t,i)},i.prototype._setDefaultFixedFrustumShadowProjectionMatrix=function(t,i){var r=this.getScene().activeCamera;e.Matrix.OrthoLHToRef(this.shadowFrustumSize,this.shadowFrustumSize,void 0!==this.shadowMinZ?this.shadowMinZ:r.minZ,void 0!==this.shadowMaxZ?this.shadowMaxZ:r.maxZ,t)},i.prototype._setDefaultAutoExtendShadowProjectionMatrix=function(t,i,r){var n=this.getScene().activeCamera;if(this.autoUpdateExtends||this._orthoLeft===Number.MAX_VALUE){var o=e.Vector3.Zero();this._orthoLeft=Number.MAX_VALUE,this._orthoRight=Number.MIN_VALUE,this._orthoTop=Number.MIN_VALUE,this._orthoBottom=Number.MAX_VALUE;for(var s=0;sthis._orthoRight&&(this._orthoRight=o.x),o.y>this._orthoTop&&(this._orthoTop=o.y)}}}var u=this._orthoRight-this._orthoLeft,f=this._orthoTop-this._orthoBottom;e.Matrix.OrthoOffCenterLHToRef(this._orthoLeft-u*this.shadowOrthoScale,this._orthoRight+u*this.shadowOrthoScale,this._orthoBottom-f*this.shadowOrthoScale,this._orthoTop+f*this.shadowOrthoScale,void 0!==this.shadowMinZ?this.shadowMinZ:n.minZ,void 0!==this.shadowMaxZ?this.shadowMaxZ:n.maxZ,t)},i.prototype._buildUniformLayout=function(){this._uniformBuffer.addUniform("vLightData",4),this._uniformBuffer.addUniform("vLightDiffuse",4),this._uniformBuffer.addUniform("vLightSpecular",3),this._uniformBuffer.addUniform("shadowsInfo",3),this._uniformBuffer.addUniform("depthValues",2),this._uniformBuffer.create()},i.prototype.transferToEffect=function(e,t){return this.computeTransformedInformation()?(this._uniformBuffer.updateFloat4("vLightData",this.transformedDirection.x,this.transformedDirection.y,this.transformedDirection.z,1,t),this):(this._uniformBuffer.updateFloat4("vLightData",this.direction.x,this.direction.y,this.direction.z,1,t),this)},i.prototype.getDepthMinZ=function(e){return 1},i.prototype.getDepthMaxZ=function(e){return 1},i})(e.ShadowLight);__decorate([e.serialize()],t.prototype,"shadowFrustumSize",null),__decorate([e.serialize()],t.prototype,"shadowOrthoScale",null),__decorate([e.serialize()],t.prototype,"autoUpdateExtends",void 0),e.DirectionalLight=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e,i,r,n,o,s){var a=t.call(this,e,s)||this;return a.position=i,a.direction=r,a.angle=n,a.exponent=o,a}return __extends(i,t),Object.defineProperty(i.prototype,"angle",{get:function(){return this._angle},set:function(e){this._angle=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"shadowAngleScale",{get:function(){return this._shadowAngleScale},set:function(e){this._shadowAngleScale=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),i.prototype.getClassName=function(){return"SpotLight"},i.prototype.getTypeID=function(){return e.Light.LIGHTTYPEID_SPOTLIGHT},i.prototype._setDefaultShadowProjectionMatrix=function(t,i,r){var n=this.getScene().activeCamera;this._shadowAngleScale=this._shadowAngleScale||1;var o=this._shadowAngleScale*this._angle;e.Matrix.PerspectiveFovLHToRef(o,1,this.getDepthMinZ(n),this.getDepthMaxZ(n),t)},i.prototype._buildUniformLayout=function(){this._uniformBuffer.addUniform("vLightData",4),this._uniformBuffer.addUniform("vLightDiffuse",4),this._uniformBuffer.addUniform("vLightSpecular",3),this._uniformBuffer.addUniform("vLightDirection",3),this._uniformBuffer.addUniform("shadowsInfo",3),this._uniformBuffer.addUniform("depthValues",2),this._uniformBuffer.create()},i.prototype.transferToEffect=function(t,i){var r;return this.computeTransformedInformation()?(this._uniformBuffer.updateFloat4("vLightData",this.transformedPosition.x,this.transformedPosition.y,this.transformedPosition.z,this.exponent,i),r=e.Vector3.Normalize(this.transformedDirection)):(this._uniformBuffer.updateFloat4("vLightData",this.position.x,this.position.y,this.position.z,this.exponent,i),r=e.Vector3.Normalize(this.direction)),this._uniformBuffer.updateFloat4("vLightDirection",r.x,r.y,r.z,Math.cos(.5*this.angle),i),this},i})(e.ShadowLight);__decorate([e.serialize()],t.prototype,"angle",null),__decorate([e.serialize()],t.prototype,"shadowAngleScale",null),__decorate([e.serialize()],t.prototype,"exponent",void 0),e.SpotLight=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(e,t,i){this.name=e,this.from=t,this.to=i}return e.prototype.clone=function(){return new e(this.name,this.from,this.to)},e})();e.AnimationRange=t;var i=(function(){function e(e,t,i){this.frame=e,this.action=t,this.onlyOnce=i,this.isDone=!1}return e})();e.AnimationEvent=i;var r=(function(){function t(e){this.path=e,this._onchange=new Array,this.value=0,this.animations=new Array}return t.prototype.getPoint=function(){var t=this.path.getPointAtLengthPosition(this.value);return new e.Vector3(t.x,0,t.y)},t.prototype.moveAhead=function(e){return void 0===e&&(e=.002),this.move(e),this},t.prototype.moveBack=function(e){return void 0===e&&(e=.002),this.move(-e),this},t.prototype.move=function(e){if(Math.abs(e)>1)throw"step size should be less than 1.";return this.value+=e,this.ensureLimits(),this.raiseOnChange(),this},t.prototype.ensureLimits=function(){for(;this.value>1;)this.value-=1;for(;this.value<0;)this.value+=1;return this},t.prototype.markAsDirty=function(e){return this.ensureLimits(),this.raiseOnChange(),this},t.prototype.raiseOnChange=function(){var e=this;return this._onchange.forEach((function(t){return t(e)})),this},t.prototype.onchange=function(e){return this._onchange.push(e),this},t})();e.PathCursor=r;var n=(function(){function i(e,t,r,n,o,s){this.name=e,this.targetProperty=t,this.framePerSecond=r,this.dataType=n,this.loopMode=o,this.enableBlending=s,this._offsetsCache={},this._highLimitsCache={},this._stopped=!1,this._blendingFactor=0,this._events=new Array,this.allowMatricesInterpolation=!1,this.blendingSpeed=.01,this._ranges={},this.targetPropertyPath=t.split("."),this.dataType=n,this.loopMode=void 0===o?i.ANIMATIONLOOPMODE_CYCLE:o}return i._PrepareAnimation=function(t,r,n,o,s,a,h,l){var c=void 0;if(!isNaN(parseFloat(s))&&isFinite(s)?c=i.ANIMATIONTYPE_FLOAT:s instanceof e.Quaternion?c=i.ANIMATIONTYPE_QUATERNION:s instanceof e.Vector3?c=i.ANIMATIONTYPE_VECTOR3:s instanceof e.Vector2?c=i.ANIMATIONTYPE_VECTOR2:s instanceof e.Color3?c=i.ANIMATIONTYPE_COLOR3:s instanceof e.Size&&(c=i.ANIMATIONTYPE_SIZE),void 0==c)return null;var u=new i(t,r,n,c,h),f=[{frame:0,value:s},{frame:o,value:a}];return u.setKeys(f),void 0!==l&&u.setEasingFunction(l),u},i.CreateAndStartAnimation=function(e,t,r,n,o,s,a,h,l,c){var u=i._PrepareAnimation(e,r,n,o,s,a,h,l);return t.getScene().beginDirectAnimation(t,[u],0,o,1===u.loopMode,1,c)},i.CreateMergeAndStartAnimation=function(e,t,r,n,o,s,a,h,l,c){var u=i._PrepareAnimation(e,r,n,o,s,a,h,l);return t.animations.push(u),t.getScene().beginAnimation(t,0,o,1===u.loopMode,1,c)},i.prototype.toString=function(e){var t="Name: "+this.name+", property: "+this.targetProperty;if(t+=", datatype: "+["Float","Vector3","Quaternion","Matrix","Color3","Vector2"][this.dataType],t+=", nKeys: "+(this._keys?this._keys.length:"none"),t+=", nRanges: "+(this._ranges?Object.keys(this._ranges).length:"none"),e){t+=", Ranges: {";var i=!0;for(var r in this._ranges)i&&(t+=", ",i=!1),t+=r;t+="}"}return t},i.prototype.addEvent=function(e){this._events.push(e)},i.prototype.removeEvents=function(e){for(var t=0;t=0;n--)this._keys[n].frame>=i&&this._keys[n].frame<=r&&this._keys.splice(n,1);this._ranges[e]=void 0}},i.prototype.getRange=function(e){return this._ranges[e]},i.prototype.reset=function(){this._offsetsCache={},this._highLimitsCache={},this.currentFrame=0,this._blendingFactor=0,this._originalBlendValue=null},i.prototype.isStopped=function(){return this._stopped},i.prototype.getKeys=function(){return this._keys},i.prototype.getHighestFrame=function(){for(var e=0,t=0,i=this._keys.length;t0)return o.clone?o.clone():o;this.currentFrame=e;var s=Math.max(0,Math.min(this._keys.length-1,Math.floor(this._keys.length*(e-this._keys[0].frame)/(this._keys[this._keys.length-1].frame-this._keys[0].frame))-1));if(this._keys[s].frame>=e)for(;s-1>=0&&this._keys[s].frame>=e;)s--;for(var a=s;a=e){var l=this._keys[a],c=this._getKeyValue(l.value),u=this._getKeyValue(h.value),f=void 0!==l.outTangent&&void 0!==h.inTangent,d=h.frame-l.frame,p=(e-l.frame)/d;switch(null!=this._easingFunction&&(p=this._easingFunction.ease(p)),this.dataType){case i.ANIMATIONTYPE_FLOAT:var m=f?this.floatInterpolateFunctionWithTangents(c,l.outTangent*d,u,h.inTangent*d,p):this.floatInterpolateFunction(c,u,p);switch(r){case i.ANIMATIONLOOPMODE_CYCLE:case i.ANIMATIONLOOPMODE_CONSTANT:return m;case i.ANIMATIONLOOPMODE_RELATIVE:return n*t+m}break;case i.ANIMATIONTYPE_QUATERNION:var _=f?this.quaternionInterpolateFunctionWithTangents(c,l.outTangent.scale(d),u,h.inTangent.scale(d),p):this.quaternionInterpolateFunction(c,u,p);switch(r){case i.ANIMATIONLOOPMODE_CYCLE:case i.ANIMATIONLOOPMODE_CONSTANT:return _;case i.ANIMATIONLOOPMODE_RELATIVE:return _.add(n.scale(t))}return _;case i.ANIMATIONTYPE_VECTOR3:var g=f?this.vector3InterpolateFunctionWithTangents(c,l.outTangent.scale(d),u,h.inTangent.scale(d),p):this.vector3InterpolateFunction(c,u,p);switch(r){case i.ANIMATIONLOOPMODE_CYCLE:case i.ANIMATIONLOOPMODE_CONSTANT:return g;case i.ANIMATIONLOOPMODE_RELATIVE:return g.add(n.scale(t))}case i.ANIMATIONTYPE_VECTOR2:var v=f?this.vector2InterpolateFunctionWithTangents(c,l.outTangent.scale(d),u,h.inTangent.scale(d),p):this.vector2InterpolateFunction(c,u,p);switch(r){case i.ANIMATIONLOOPMODE_CYCLE:case i.ANIMATIONLOOPMODE_CONSTANT:return v;case i.ANIMATIONLOOPMODE_RELATIVE:return v.add(n.scale(t))}case i.ANIMATIONTYPE_SIZE:switch(r){case i.ANIMATIONLOOPMODE_CYCLE:case i.ANIMATIONLOOPMODE_CONSTANT:return this.sizeInterpolateFunction(c,u,p);case i.ANIMATIONLOOPMODE_RELATIVE:return this.sizeInterpolateFunction(c,u,p).add(n.scale(t))}case i.ANIMATIONTYPE_COLOR3:switch(r){case i.ANIMATIONLOOPMODE_CYCLE:case i.ANIMATIONLOOPMODE_CONSTANT:return this.color3InterpolateFunction(c,u,p);case i.ANIMATIONLOOPMODE_RELATIVE:return this.color3InterpolateFunction(c,u,p).add(n.scale(t))}case i.ANIMATIONTYPE_MATRIX:switch(r){case i.ANIMATIONLOOPMODE_CYCLE:case i.ANIMATIONLOOPMODE_CONSTANT:if(this.allowMatricesInterpolation)return this.matrixInterpolateFunction(c,u,p);case i.ANIMATIONLOOPMODE_RELATIVE:return c}}break}}return this._getKeyValue(this._keys[this._keys.length-1].value)},i.prototype.setValue=function(t,i){void 0===i&&(i=!1);var r,n;if(this.targetPropertyPath.length>1){for(var o=this._target[this.targetPropertyPath[0]],s=1;sthis._keys[this._keys.length-1].frame&&(e=this._keys[this._keys.length-1].frame);var t=this._interpolate(e,0,this.loopMode);this.setValue(t)},i.prototype.animate=function(t,r,n,o,s,a){if(void 0===a&&(a=!1),!this.targetPropertyPath||this.targetPropertyPath.length<1)return this._stopped=!0,!1;var h=!0;if(0!==this._keys[0].frame){var l={frame:0,value:this._keys[0].value};this._keys.splice(0,0,l)}(rthis._keys[this._keys.length-1].frame)&&(r=this._keys[0].frame),(nthis._keys[this._keys.length-1].frame)&&(n=this._keys[this._keys.length-1].frame),r===n&&r++;var c,u=n-r,f=t*(this.framePerSecond*s)/1e3,d=0;if((n>r&&f>u||r>n&&f>0,v=h?r+f%u:n,y=this._interpolate(v,g,this.loopMode,c,d);this.setValue(y);for(var x=0;x0&&v>=this._events[x].frame&&this._events[x].frame>=r||u<0&&v<=this._events[x].frame&&this._events[x].frame<=r){var b=this._events[x];b.isDone||(b.onlyOnce&&(this._events.splice(x,1),x--),b.isDone=!0,b.action())}else this._events[x].isDone&&!this._events[x].onlyOnce&&(this._events[x].isDone=!1);return h||(this._stopped=!0),h},i.prototype.serialize=function(){var e={};e.name=this.name,e.property=this.targetProperty,e.framePerSecond=this.framePerSecond,e.dataType=this.dataType,e.loopBehavior=this.loopMode,e.enableBlending=this.enableBlending,e.blendingSpeed=this.blendingSpeed;var t=this.dataType;e.keys=[];for(var r=this.getKeys(),n=0;n-1){for(var i=this._animations,r=i.length-1;r>=0;r--)"string"==typeof e&&i[r].name!=e||(i[r].reset(),i.splice(r,1));0==i.length&&(this._scene._activeAnimatables.splice(t,1),this.onAnimationEnd&&this.onAnimationEnd())}}else{var r=this._scene._activeAnimatables.indexOf(this);if(r>-1){this._scene._activeAnimatables.splice(r,1);for(var i=this._animations,r=0;r=.5?.5*(1-this.easeInCore(2*(1-t)))+.5:.5*this.easeInCore(2*t)},e})();t._EASINGMODE_EASEIN=0,t._EASINGMODE_EASEOUT=1,t._EASINGMODE_EASEINOUT=2,e.EasingFunction=t;var i=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.easeInCore=function(e){return e=Math.max(0,Math.min(1,e)),1-Math.sqrt(1-e*e)},t})(t);e.CircleEase=i;var r=(function(e){function t(t){void 0===t&&(t=1);var i=e.call(this)||this;return i.amplitude=t,i}return __extends(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.amplitude);return Math.pow(e,3)-e*t*Math.sin(3.141592653589793*e)},t})(t);e.BackEase=r;var n=(function(e){function t(t,i){void 0===t&&(t=3),void 0===i&&(i=2);var r=e.call(this)||this +;return r.bounces=t,r.bounciness=i,r}return __extends(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.bounces),i=this.bounciness;i<=1&&(i=1.001);var r=Math.pow(i,t),n=1-i,o=(1-r)/n+.5*r,s=e*o,a=Math.log(-s*(1-i)+1)/Math.log(i),h=Math.floor(a),l=h+1,c=(1-Math.pow(i,h))/(n*o),u=(1-Math.pow(i,l))/(n*o),f=.5*(c+u),d=e-f,p=f-c;return-Math.pow(1/i,t-h)/(p*p)*(d-p)*(d+p)},t})(t);e.BounceEase=n;var o=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.easeInCore=function(e){return e*e*e},t})(t);e.CubicEase=o;var s=(function(e){function t(t,i){void 0===t&&(t=3),void 0===i&&(i=3);var r=e.call(this)||this;return r.oscillations=t,r.springiness=i,r}return __extends(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.oscillations),i=Math.max(0,this.springiness);return(0==i?e:(Math.exp(i*e)-1)/(Math.exp(i)-1))*Math.sin((6.283185307179586*t+1.5707963267948966)*e)},t})(t);e.ElasticEase=s;var a=(function(e){function t(t){void 0===t&&(t=2);var i=e.call(this)||this;return i.exponent=t,i}return __extends(t,e),t.prototype.easeInCore=function(e){return this.exponent<=0?e:(Math.exp(this.exponent*e)-1)/(Math.exp(this.exponent)-1)},t})(t);e.ExponentialEase=a;var h=(function(e){function t(t){void 0===t&&(t=2);var i=e.call(this)||this;return i.power=t,i}return __extends(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.power);return Math.pow(e,t)},t})(t);e.PowerEase=h;var l=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.easeInCore=function(e){return e*e},t})(t);e.QuadraticEase=l;var c=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.easeInCore=function(e){return e*e*e*e},t})(t);e.QuarticEase=c;var u=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.easeInCore=function(e){return e*e*e*e*e},t})(t);e.QuinticEase=u;var f=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.easeInCore=function(e){return 1-Math.sin(1.5707963267948966*(1-e))},t})(t);e.SineEase=f;var d=(function(t){function i(e,i,r,n){void 0===e&&(e=0),void 0===i&&(i=0),void 0===r&&(r=1),void 0===n&&(n=1);var o=t.call(this)||this;return o.x1=e,o.y1=i,o.x2=r,o.y2=n,o}return __extends(i,t),i.prototype.easeInCore=function(t){return e.BezierCurve.interpolate(t,this.x1,this.y1,this.x2,this.y2)},i})(t);e.BezierCurveEase=d})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(e){this._actionManager=e}return e.prototype.isValid=function(){return!0},e.prototype._getProperty=function(e){return this._actionManager._getProperty(e)},e.prototype._getEffectiveTarget=function(e,t){return this._actionManager._getEffectiveTarget(e,t)},e.prototype.serialize=function(){},e.prototype._serialize=function(e){return{type:2,children:[],name:e.name,properties:e.properties}},e})();e.Condition=t;var i=(function(t){function i(e,r,n,o,s){void 0===s&&(s=i.IsEqual);var a=t.call(this,e)||this;return a.propertyPath=n,a.value=o,a.operator=s,a._target=r,a._effectiveTarget=a._getEffectiveTarget(r,a.propertyPath),a._property=a._getProperty(a.propertyPath),a}return __extends(i,t),Object.defineProperty(i,"IsEqual",{get:function(){return i._IsEqual},enumerable:!0,configurable:!0}),Object.defineProperty(i,"IsDifferent",{get:function(){return i._IsDifferent},enumerable:!0,configurable:!0}),Object.defineProperty(i,"IsGreater",{get:function(){return i._IsGreater},enumerable:!0,configurable:!0}),Object.defineProperty(i,"IsLesser",{get:function(){return i._IsLesser},enumerable:!0,configurable:!0}),i.prototype.isValid=function(){switch(this.operator){case i.IsGreater:return this._effectiveTarget[this._property]>this.value;case i.IsLesser:return this._effectiveTarget[this._property]-1&&this._scene._actionManagers.splice(e,1)},t.prototype.getScene=function(){return this._scene},t.prototype.hasSpecificTriggers=function(e){for(var t=0;t-1)return!0}return!1},t.prototype.hasSpecificTrigger=function(e){for(var t=0;t=t._OnPickTrigger&&i.trigger<=t._OnPointerOutTrigger)return!0}return!1},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"hasPickTriggers",{get:function(){for(var e=0;e=t._OnPickTrigger&&i.trigger<=t._OnPickUpTrigger)return!0}return!1},enumerable:!0,configurable:!0}),Object.defineProperty(t,"HasTriggers",{get:function(){for(var e in t.Triggers)if(t.Triggers.hasOwnProperty(e))return!0;return!1},enumerable:!0,configurable:!0}),Object.defineProperty(t,"HasPickTriggers",{get:function(){for(var e in t.Triggers)if(t.Triggers.hasOwnProperty(e)){var i=parseInt(e);if(i>=t._OnPickTrigger&&i<=t._OnPickUpTrigger)return!0}return!1},enumerable:!0,configurable:!0}),t.HasSpecificTrigger=function(e){for(var i in t.Triggers)if(t.Triggers.hasOwnProperty(i)){var r=parseInt(i);if(r===e)return!0}return!1},t.prototype.registerAction=function(i){return i.trigger===t.OnEveryFrameTrigger&&this.getScene().actionManager!==this?(e.Tools.Warn("OnEveryFrameTrigger can only be used with scene.actionManager"),null):(this.actions.push(i),t.Triggers[i.trigger]?t.Triggers[i.trigger]++:t.Triggers[i.trigger]=1,i._actionManager=this,i._prepare(),i)},t.prototype.processTrigger=function(e,i){for(var r=0;r0;if(2===i.type?f.push(o):f.push(r),m){for(var _=new Array,g=0;g0){var f=u.properties[0].value,d=null===u.properties[0].targetType?f:n.getMeshByName(f);d._meshId&&(d.mesh=n.getMeshByID(d._meshId)),c={trigger:e.ActionManager[u.name],parameter:d}}else c=e.ActionManager[u.name];for(var p=0;p>0;this._vertexData[o+10]=t.cellIndex-s*n,this._vertexData[o+11]=s,this._vertexData[o+12]=t.color.r,this._vertexData[o+13]=t.color.g,this._vertexData[o+14]=t.color.b,this._vertexData[o+15]=t.color.a},t.prototype.intersects=function(t,i,r,n){for(var o,s=Math.min(this._capacity,this.sprites.length),a=e.Vector3.Zero(),h=e.Vector3.Zero(),l=Number.MAX_VALUE,c=e.Vector3.Zero(),u=i.getViewMatrix(),f=0;fp&&(l=p,o=d,n))break}}}if(o){var m=new e.PickingInfo;return m.hit=!0,m.pickedSprite=o,m.distance=l,m}return null},t.prototype.render=function(){if(this._effectBase.isReady()&&this._effectFog.isReady()&&this._spriteTexture&&this._spriteTexture.isReady()){for(var t=this._scene.getEngine(),i=this._spriteTexture.getBaseSize(),r=t.getDeltaTime(),n=Math.min(this._capacity,this.sprites.length),o=i.width/this.cellWidth,s=0,a=0;athis._delay&&(this._time=this._time%this._delay,this.cellIndex+=this._direction,this.cellIndex===this._toIndex&&(this._loopAnimation?this.cellIndex=this._fromIndex:(this._animationStarted=!1,this._onAnimationEnd&&this._onAnimationEnd(),this.disposeWhenFinishedAnimating&&this.dispose()))))},t.prototype.dispose=function(){for(var e=0;et.x)return!1}else if(i=1/this.direction.x,r=(e.x-this.origin.x)*i,n=(t.x-this.origin.x)*i,n===-1/0&&(n=1/0),r>n&&(o=r,r=n,n=o),s=Math.max(r,s),a=Math.min(n,a),s>a)return!1;if(Math.abs(this.direction.y)<1e-7){if(this.origin.yt.y)return!1}else if(i=1/this.direction.y,r=(e.y-this.origin.y)*i,n=(t.y-this.origin.y)*i,n===-1/0&&(n=1/0),r>n&&(o=r,r=n,n=o),s=Math.max(r,s),a=Math.min(n,a),s>a)return!1;if(Math.abs(this.direction.z)<1e-7){if(this.origin.zt.z)return!1}else if(i=1/this.direction.z,r=(e.z-this.origin.z)*i,n=(t.z-this.origin.z)*i,n===-1/0&&(n=1/0),r>n&&(o=r,r=n,n=o),s=Math.max(r,s),a=Math.min(n,a),s>a)return!1;return!0},t.prototype.intersectsBox=function(e){return this.intersectsBoxMinMax(e.minimum,e.maximum)},t.prototype.intersectsSphere=function(e){var t=e.center.x-this.origin.x,i=e.center.y-this.origin.y,r=e.center.z-this.origin.z,n=t*t+i*i+r*r,o=e.radius*e.radius;if(n<=o)return!0;var s=t*this.direction.x+i*this.direction.y+r*this.direction.z;return!(s<0)&&n-s*s<=o},t.prototype.intersectsTriangle=function(t,i,r){this._edge1||(this._edge1=e.Vector3.Zero(),this._edge2=e.Vector3.Zero(),this._pvec=e.Vector3.Zero(),this._tvec=e.Vector3.Zero(),this._qvec=e.Vector3.Zero()),i.subtractToRef(t,this._edge1),r.subtractToRef(t,this._edge2),e.Vector3.CrossToRef(this.direction,this._edge2,this._pvec);var n=e.Vector3.Dot(this._edge1,this._pvec);if(0===n)return null;var o=1/n;this.origin.subtractToRef(t,this._tvec);var s=e.Vector3.Dot(this._tvec,this._pvec)*o;if(s<0||s>1)return null;e.Vector3.CrossToRef(this._tvec,this._edge1,this._qvec);var a=e.Vector3.Dot(this.direction,this._qvec)*o;if(a<0||s+a>1)return null;var h=e.Vector3.Dot(this._edge2,this._qvec)*o;return h>this.length?null:new e.IntersectionInfo(s,a,h)},t.prototype.intersectsPlane=function(t){var i,r=e.Vector3.Dot(t.normal,this.direction);if(Math.abs(r)<9.99999997475243e-7)return null;var n=e.Vector3.Dot(t.normal,this.origin);return i=(-t.d-n)/r,i<0?i<-9.99999997475243e-7?null:0:i},t.prototype.intersectsMesh=function(i,r){var n=e.Tmp.Matrix[0];return i.getWorldMatrix().invertToRef(n),this._tmpRay?t.TransformToRef(this,n,this._tmpRay):this._tmpRay=t.Transform(this,n),i.intersects(this._tmpRay,r)},t.prototype.intersectsMeshes=function(e,t,i){i?i.length=0:i=[];for(var r=0;rt.distance?1:0},t.prototype.intersectionSegment=function(i,r,n){var o,s,a,h,l=this.origin.add(this.direction.multiplyByFloats(t.rayl,t.rayl,t.rayl)),c=r.subtract(i),u=l.subtract(this.origin),f=i.subtract(this.origin),d=e.Vector3.Dot(c,c),p=e.Vector3.Dot(c,u),m=e.Vector3.Dot(u,u),_=e.Vector3.Dot(c,f),g=e.Vector3.Dot(u,f),v=d*m-p*p,y=v,x=v;vy&&(s=y,h=g+p,x=m)),h<0?(h=0,-_<0?s=0:-_>d?s=y:(s=-_,y=d)):h>x&&(h=x,-_+p<0?s=0:-_+p>d?s=y:(s=-_+p,y=d)),o=Math.abs(s)0&&a<=this.length&&A.lengthSquared()i.x+r)&&(!(i.x-r>t.x)&&(!(e.y>i.y+r)&&(!(i.y-r>t.y)&&(!(e.z>i.z+r)&&!(i.z-r>t.z)))))},i=(function(){var e={root:0,found:!1};return function(t,i,r,n){e.root=0,e.found=!1;var o=i*i-4*t*r;if(o<0)return e;var s=Math.sqrt(o),a=(-i-s)/(2*t),h=(-i+s)/(2*t);if(a>h){var l=h;h=a,a=l}return a>0&&a0&&h=0))},r.prototype._canDoCollision=function(i,r,n,o){var s=e.Vector3.Distance(this.basePointWorld,i),a=Math.max(this.radius.x,this.radius.y,this.radius.z);return!(s>this.velocityWorldLength+a+r)&&!!t(n,o,this.basePointWorld,this.velocityWorldLength+a)},r.prototype._testTriangle=function(t,r,n,o,s,a){var h,l=!1;r||(r=[]),r[t]||(r[t]=new e.Plane(0,0,0,0),r[t].copyFromPoints(n,o,s));var c=r[t];if(a||c.isFrontFacingTo(this.normalizedVelocity,0)){var u=c.signedDistanceTo(this.basePoint),f=e.Vector3.Dot(c.normal,this.velocity);if(0==f){if(Math.abs(u)>=1)return;l=!0,h=0}else{h=(-1-u)/f;var d=(1-u)/f;if(h>d){var p=d;d=h,h=p}if(h>1||d<0)return;h<0&&(h=0),h>1&&(h=1)}this._collisionPoint.copyFromFloats(0,0,0);var m=!1,_=1;if(l||(this.basePoint.subtractToRef(c.normal,this._planeIntersectionPoint),this.velocity.scaleToRef(h,this._tempVector),this._planeIntersectionPoint.addInPlace(this._tempVector),this._checkPointInTriangle(this._planeIntersectionPoint,n,o,s,c.normal)&&(m=!0,_=h,this._collisionPoint.copyFrom(this._planeIntersectionPoint))),!m){var g=this.velocity.lengthSquared(),v=g;this.basePoint.subtractToRef(n,this._tempVector);var y=2*e.Vector3.Dot(this.velocity,this._tempVector),x=this._tempVector.lengthSquared()-1,b=i(v,y,x,_);b.found&&(_=b.root,m=!0,this._collisionPoint.copyFrom(n)),this.basePoint.subtractToRef(o,this._tempVector),y=2*e.Vector3.Dot(this.velocity,this._tempVector),x=this._tempVector.lengthSquared()-1,b=i(v,y,x,_),b.found&&(_=b.root,m=!0,this._collisionPoint.copyFrom(o)),this.basePoint.subtractToRef(s,this._tempVector),y=2*e.Vector3.Dot(this.velocity,this._tempVector),x=this._tempVector.lengthSquared()-1,b=i(v,y,x,_),b.found&&(_=b.root,m=!0,this._collisionPoint.copyFrom(s)),o.subtractToRef(n,this._edge),n.subtractToRef(this.basePoint,this._baseToVertex);var A=this._edge.lengthSquared(),T=e.Vector3.Dot(this._edge,this.velocity),E=e.Vector3.Dot(this._edge,this._baseToVertex);if(v=A*-g+T*T,y=A*(2*e.Vector3.Dot(this.velocity,this._baseToVertex))-2*T*E,x=A*(1-this._baseToVertex.lengthSquared())+E*E,b=i(v,y,x,_),b.found){var P=(T*b.root-E)/A;P>=0&&P<=1&&(_=b.root,m=!0,this._edge.scaleInPlace(P),n.addToRef(this._edge,this._collisionPoint))}s.subtractToRef(o,this._edge),o.subtractToRef(this.basePoint,this._baseToVertex),A=this._edge.lengthSquared(),T=e.Vector3.Dot(this._edge,this.velocity),E=e.Vector3.Dot(this._edge,this._baseToVertex),v=A*-g+T*T,y=A*(2*e.Vector3.Dot(this.velocity,this._baseToVertex))-2*T*E,x=A*(1-this._baseToVertex.lengthSquared())+E*E,b=i(v,y,x,_),b.found&&(P=(T*b.root-E)/A)>=0&&P<=1&&(_=b.root,m=!0,this._edge.scaleInPlace(P),o.addToRef(this._edge,this._collisionPoint)),n.subtractToRef(s,this._edge),s.subtractToRef(this.basePoint,this._baseToVertex),A=this._edge.lengthSquared(),T=e.Vector3.Dot(this._edge,this.velocity),E=e.Vector3.Dot(this._edge,this._baseToVertex),v=A*-g+T*T,y=A*(2*e.Vector3.Dot(this.velocity,this._baseToVertex))-2*T*E,x=A*(1-this._baseToVertex.lengthSquared())+E*E,b=i(v,y,x,_),b.found&&(P=(T*b.root-E)/A)>=0&&P<=1&&(_=b.root,m=!0,this._edge.scaleInPlace(P),s.addToRef(this._edge,this._collisionPoint))}if(m){var M=_*this.velocity.length();(!this.collisionFound||M4)){++n._runningUpdated;var e={updatedMeshes:n._addUpdateMeshesList,updatedGeometries:n._addUpdateGeometriesList,removedGeometries:n._toRemoveGeometryArray,removedMeshes:n._toRemoveMeshesArray},i={payload:e,taskType:t.UPDATE},r=[];for(var o in e.updatedGeometries)e.updatedGeometries.hasOwnProperty(o)&&(r.push(i.payload.updatedGeometries[o].indices.buffer),r.push(i.payload.updatedGeometries[o].normals.buffer),r.push(i.payload.updatedGeometries[o].positions.buffer));n._worker.postMessage(i,r),n._addUpdateMeshesList={},n._addUpdateGeometriesList={},n._toRemoveGeometryArray=[],n._toRemoveMeshesArray=[]}},this._onMessageFromWorker=function(r){var o=r.data;if(o.error!=i.SUCCESS)return void e.Tools.Warn("error returned from worker!");switch(o.taskType){case t.INIT:n._init=!0,n._scene.meshes.forEach((function(e){n.onMeshAdded(e)})),n._scene.getGeometries().forEach((function(e){n.onGeometryAdded(e)}));break;case t.UPDATE:n._runningUpdated--;break;case t.COLLIDE:n._runningCollisionTask=!1;var s=o.payload;if(!n._collisionsCallbackArray[s.collisionId])return;n._collisionsCallbackArray[s.collisionId](s.collisionId,e.Vector3.FromArray(s.newPosition),n._scene.getMeshByUniqueID(s.collidedMeshUniqueId)),n._collisionsCallbackArray[s.collisionId]=void 0}},this._collisionsCallbackArray=[],this._init=!1,this._runningUpdated=0,this._runningCollisionTask=!1,this._addUpdateMeshesList={},this._addUpdateGeometriesList={},this._toRemoveGeometryArray=[],this._toRemoveMeshesArray=[]}return r.prototype.getNewPosition=function(e,i,r,n,o,s,a){if(this._init&&!this._collisionsCallbackArray[a]&&!this._collisionsCallbackArray[a+1e5]){e.divideToRef(r.radius,this._scaledPosition),i.divideToRef(r.radius,this._scaledVelocity),this._collisionsCallbackArray[a]=s;var h={collider:{position:this._scaledPosition.asArray(),velocity:this._scaledVelocity.asArray(),radius:r.radius.asArray()},collisionId:a,excludedMeshUniqueId:o?o.uniqueId:null,maximumRetry:n},l={payload:h,taskType:t.COLLIDE};this._worker.postMessage(l)}},r.prototype.init=function(i){this._scene=i,this._scene.registerAfterRender(this._afterRender);var r=e.WorkerIncluded?e.Engine.CodeRepository+"Collisions/babylon.collisionWorker.js":URL.createObjectURL(new Blob([e.CollisionWorker],{type:"application/javascript"}));this._worker=new Worker(r),this._worker.onmessage=this._onMessageFromWorker;var n={payload:{},taskType:t.INIT};this._worker.postMessage(n)},r.prototype.destroy=function(){this._scene.unregisterAfterRender(this._afterRender),this._worker.terminate()},r.prototype.onMeshAdded=function(e){e.registerAfterWorldMatrixUpdate(this.onMeshUpdated),this.onMeshUpdated(e)},r.prototype.onMeshRemoved=function(e){this._toRemoveMeshesArray.push(e.uniqueId)},r.prototype.onGeometryAdded=function(e){e.onGeometryUpdated=this.onGeometryUpdated,this.onGeometryUpdated(e)},r.prototype.onGeometryDeleted=function(e){this._toRemoveGeometryArray.push(e.id)},r})();r.SerializeMesh=function(t){var i=[];t.subMeshes&&(i=t.subMeshes.map((function(e,t){return{position:t,verticesStart:e.verticesStart,verticesCount:e.verticesCount,indexStart:e.indexStart,indexCount:e.indexCount,hasMaterial:!!e.getMaterial(),sphereCenter:e.getBoundingInfo().boundingSphere.centerWorld.asArray(),sphereRadius:e.getBoundingInfo().boundingSphere.radiusWorld,boxMinimum:e.getBoundingInfo().boundingBox.minimumWorld.asArray(),boxMaximum:e.getBoundingInfo().boundingBox.maximumWorld.asArray()}})));var r=null;return t instanceof e.Mesh?r=t.geometry?t.geometry.id:null:t instanceof e.InstancedMesh&&(r=t.sourceMesh&&t.sourceMesh.geometry?t.sourceMesh.geometry.id:null),{uniqueId:t.uniqueId,id:t.id,name:t.name,geometryId:r,sphereCenter:t.getBoundingInfo().boundingSphere.centerWorld.asArray(),sphereRadius:t.getBoundingInfo().boundingSphere.radiusWorld,boxMinimum:t.getBoundingInfo().boundingBox.minimumWorld.asArray(),boxMaximum:t.getBoundingInfo().boundingBox.maximumWorld.asArray(),worldMatrixFromCache:t.worldMatrixFromCache.asArray(),subMeshes:i,checkCollisions:t.checkCollisions}},r.SerializeGeometry=function(t){return{id:t.id,positions:new Float32Array(t.getVerticesData(e.VertexBuffer.PositionKind)||[]),normals:new Float32Array(t.getVerticesData(e.VertexBuffer.NormalKind)||[]),indices:new Uint32Array(t.getIndices()||[])}},e.CollisionCoordinatorWorker=r;var n=(function(){function t(){this._scaledPosition=e.Vector3.Zero(),this._scaledVelocity=e.Vector3.Zero(),this._finalPosition=e.Vector3.Zero()}return t.prototype.getNewPosition=function(e,t,i,r,n,o,s){e.divideToRef(i.radius,this._scaledPosition),t.divideToRef(i.radius,this._scaledVelocity),i.collidedMesh=null,i.retry=0,i.initialVelocity=this._scaledVelocity,i.initialPosition=this._scaledPosition,this._collideWithWorld(this._scaledPosition,this._scaledVelocity,i,r,this._finalPosition,n),this._finalPosition.multiplyInPlace(i.radius),o(s,this._finalPosition,i.collidedMesh)},t.prototype.init=function(e){this._scene=e},t.prototype.destroy=function(){},t.prototype.onMeshAdded=function(e){},t.prototype.onMeshUpdated=function(e){},t.prototype.onMeshRemoved=function(e){},t.prototype.onGeometryAdded=function(e){},t.prototype.onGeometryUpdated=function(e){},t.prototype.onGeometryDeleted=function(e){},t.prototype._collideWithWorld=function(t,i,r,n,o,s){void 0===s&&(s=null);var a=10*e.Engine.CollisionsEpsilon;if(r.retry>=n)return void o.copyFrom(t);var h=s?s.collisionMask:r.collisionMask;r._initialize(t,i,a);for(var l=0;l=i.lifeTime?(a.recycleParticle(i),t--):(i.colorStep.scaleToRef(a._scaledUpdateSpeed,a._scaledColorStep),i.color.addInPlace(a._scaledColorStep),i.color.a<0&&(i.color.a=0),i.angle+=i.angularSpeed*a._scaledUpdateSpeed,i.direction.scaleToRef(a._scaledUpdateSpeed,a._scaledDirection),i.position.addInPlace(a._scaledDirection),a.gravity.scaleToRef(a._scaledUpdateSpeed,a._scaledGravity),i.direction.addInPlace(a._scaledGravity))}}}return Object.defineProperty(i.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!0,configurable:!0}),i.prototype.recycleParticle=function(e){var t=this.particles.pop();t!==e&&(t.copyTo(e),this._stockParticles.push(t))},i.prototype.getCapacity=function(){return this._capacity},i.prototype.isAlive=function(){return this._alive},i.prototype.isStarted=function(){return this._started},i.prototype.start=function(){this._started=!0,this._stopped=!1,this._actualFrame=0},i.prototype.stop=function(){this._stopped=!0},i.prototype._appendParticleVertex=function(e,t,i,r){var n=11*e;this._vertexData[n]=t.position.x,this._vertexData[n+1]=t.position.y,this._vertexData[n+2]=t.position.z,this._vertexData[n+3]=t.color.r,this._vertexData[n+4]=t.color.g,this._vertexData[n+5]=t.color.b,this._vertexData[n+6]=t.color.a,this._vertexData[n+7]=t.angle,this._vertexData[n+8]=t.size,this._vertexData[n+9]=i,this._vertexData[n+10]=r},i.prototype._update=function(i){this._alive=this.particles.length>0,this.updateFunction(this.particles);var r;if(this.emitter.position){r=this.emitter.getWorldMatrix()}else{var n=this.emitter;r=e.Matrix.Translation(n.x,n.y,n.z)}for(var o,s=0;s-1?(t=this.manualEmitCount,this._newPartsExcess=0,this.manualEmitCount=0):(t=this.emitRate*this._scaledUpdateSpeed>>0,this._newPartsExcess+=this.emitRate*this._scaledUpdateSpeed-t),this._newPartsExcess>1&&(t+=this._newPartsExcess>>0,this._newPartsExcess-=this._newPartsExcess>>0),this._alive=!1,this._stopped?t=0:(this._actualFrame+=this._scaledUpdateSpeed,this.targetStopDuration&&this._actualFrame>=this.targetStopDuration&&this.stop()),this._update(t),this._stopped&&(this._alive||(this._started=!1,this.onAnimationEnd&&this.onAnimationEnd(),this.disposeOnStop&&this._scene._toBeDisposed.push(this)));for(var i=0,r=0;r-1&&this._scene.particleSystems.splice(e,1),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear()},i.prototype.clone=function(t,r){var n=null,o=null;if(null!=this.customShader){o=this.customShader;var s=o.shaderOptions.defines.length>0?o.shaderOptions.defines.join("\n"):"";n=this._scene.getEngine().createEffectForParticles(o.shaderPath.fragmentElement,o.shaderOptions.uniforms,o.shaderOptions.samplers,s)}var a=new i(t,this._capacity,this._scene,n);return a.customShader=o,e.Tools.DeepCopy(this,a,["particles","customShader"]),void 0===r&&(r=this.emitter),a.emitter=r,this.particleTexture&&(a.particleTexture=new e.Texture(this.particleTexture.url,this._scene)),this.preventAutoStart||a.start(),a},i.prototype.serialize=function(){var t={};if(t.name=this.name,t.id=this.id,this.emitter.position){var i=this.emitter;t.emitterId=i.id}else{var r=this.emitter;t.emitter=r.asArray()}return t.capacity=this.getCapacity(),this.particleTexture&&(t.textureName=this.particleTexture.name),e.Animation.AppendSerializedAnimations(this,t),t.minAngularSpeed=this.minAngularSpeed,t.maxAngularSpeed=this.maxAngularSpeed,t.minSize=this.minSize,t.maxSize=this.maxSize,t.minEmitPower=this.minEmitPower,t.maxEmitPower=this.maxEmitPower,t.minLifeTime=this.minLifeTime,t.maxLifeTime=this.maxLifeTime,t.emitRate=this.emitRate,t.minEmitBox=this.minEmitBox.asArray(),t.maxEmitBox=this.maxEmitBox.asArray(),t.gravity=this.gravity.asArray(),t.direction1=this.direction1.asArray(),t.direction2=this.direction2.asArray(),t.color1=this.color1.asArray(),t.color2=this.color2.asArray(),t.colorDead=this.colorDead.asArray(),t.updateSpeed=this.updateSpeed,t.targetStopDuration=this.targetStopDuration,t.textureMask=this.textureMask.asArray(),t.blendMode=this.blendMode,t.customShader=this.customShader,t.preventAutoStart=this.preventAutoStart,t},i.Parse=function(t,r,n){var o=t.name,s=null,a=null;if(t.customShader){a=t.customShader;var h=a.shaderOptions.defines.length>0?a.shaderOptions.defines.join("\n"):"";s=r.getEngine().createEffectForParticles(a.shaderPath.fragmentElement,a.shaderOptions.uniforms,a.shaderOptions.samplers,h)}var l=new i(o,t.capacity,r,s);if(l.customShader=a,t.id&&(l.id=t.id),t.preventAutoStart&&(l.preventAutoStart=t.preventAutoStart),t.textureName&&(l.particleTexture=new e.Texture(n+t.textureName,r),l.particleTexture.name=t.textureName),t.emitterId?l.emitter=r.getLastMeshByID(t.emitterId):l.emitter=e.Vector3.FromArray(t.emitter),t.animations)for(var c=0;cf?f:n,r=Math.round(f/n),o=0):r=r>f?f:r;for(var d=[],p=[],m=[],_=[],g=e.Tmp.Vector3[0],v=r;uf-r&&(r=f-u),d.length=0,p.length=0,m.length=0,_.length=0;for(var y=0,x=3*u;x<3*(u+r);x++){p.push(y);var b=a[x];d.push(s[3*b],s[3*b+1],s[3*b+2]),h&&m.push(h[2*b],h[2*b+1]),l&&_.push(l[4*b],l[4*b+1],l[4*b+2],l[4*b+3]),y++}var A,T=this.nbParticles,E=this._posToShape(d),P=this._uvsToShapeUV(m);for(A=0;A=this.nbParticles?this.nbParticles-1:i,this._computeBoundingBox&&(0==t&&i==this.nbParticles-1?(e.Vector3.FromFloatsToRef(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,this._minimum),e.Vector3.FromFloatsToRef(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE,this._maximum)):(this._minimum.copyFrom(this.mesh._boundingInfo.boundingBox.minimum),this._maximum.copyFrom(this.mesh._boundingInfo.boundingBox.maximum))),s=this.particles[t]._pos;var f=s/3|0;h=4*f,c=2*f;for(var d=t;d<=i;d++){if(this._particle=this.particles[d],this._shape=this._particle._model._shape,this._shapeUV=this._particle._model._shapeUV,this.updateParticle(this._particle),this._particle.isVisible)for(this.billboard&&(this._particle.rotation.x=0,this._particle.rotation.y=0),(this._computeParticleRotation||this.billboard)&&(this._particle.rotationQuaternion?this._quaternion.copyFrom(this._particle.rotationQuaternion):(this._yaw=this._particle.rotation.y,this._pitch=this._particle.rotation.x,this._roll=this._particle.rotation.z,this._quaternionRotationYPR()),this._quaternionToRotationMatrix()),u=0;uthis._maximum.x&&(this._maximum.x=this._positions32[o]),this._positions32[o+1]this._maximum.y&&(this._maximum.y=this._positions32[o+1]),this._positions32[o+2]this._maximum.z&&(this._maximum.z=this._positions32[o+2])),this._computeParticleVertex||(this._normal.x=this._fixedNormal32[o],this._normal.y=this._fixedNormal32[o+1],this._normal.z=this._fixedNormal32[o+2],this._rotated.x=this._normal.x*this._rotMatrix.m[0]+this._normal.y*this._rotMatrix.m[4]+this._normal.z*this._rotMatrix.m[8]+this._rotMatrix.m[12],this._rotated.y=this._normal.x*this._rotMatrix.m[1]+this._normal.y*this._rotMatrix.m[5]+this._normal.z*this._rotMatrix.m[9]+this._rotMatrix.m[13],this._rotated.z=this._normal.x*this._rotMatrix.m[2]+this._normal.y*this._rotMatrix.m[6]+this._normal.z*this._rotMatrix.m[10]+this._rotMatrix.m[14],this._normals32[o]=this._cam_axisX.x*this._rotated.x+this._cam_axisY.x*this._rotated.y+this._cam_axisZ.x*this._rotated.z,this._normals32[o+1]=this._cam_axisX.y*this._rotated.x+this._cam_axisY.y*this._rotated.y+this._cam_axisZ.y*this._rotated.z,this._normals32[o+2]=this._cam_axisX.z*this._rotated.x+this._cam_axisY.z*this._rotated.y+this._cam_axisZ.z*this._rotated.z),this._computeParticleColor&&(this._colors32[a]=this._particle.color.r,this._colors32[a+1]=this._particle.color.g,this._colors32[a+2]=this._particle.color.b,this._colors32[a+3]=this._particle.color.a),this._computeParticleTexture&&(this._uvs32[l]=this._shapeUV[2*u]*(this._particle.uvs.z-this._particle.uvs.x)+this._particle.uvs.x,this._uvs32[l+1]=this._shapeUV[2*u+1]*(this._particle.uvs.w-this._particle.uvs.y)+this._particle.uvs.y);else for(u=0;uthis._maxX||ithis._maxZ)return this.position.y;this._heightQuads&&0!=this._heightQuads.length||(this._initHeightQuads(),this._computeHeightQuads());var s=this._getFacetAt(t,i),a=-(s.x*t+s.z*i+s.w)/s.y;return e.Vector3.TransformCoordinatesFromFloatsToRef(0,a,0,r,o),o.y},i.prototype.getNormalAtCoordinates=function(t,i){var r=new e.Vector3(0,1,0);return this.getNormalAtCoordinatesToRef(t,i,r),r},i.prototype.getNormalAtCoordinatesToRef=function(t,i,r){var n=this.getWorldMatrix(),o=e.Tmp.Matrix[5];n.invertToRef(o);var s=e.Tmp.Vector3[8];if(e.Vector3.TransformCoordinatesFromFloatsToRef(t,0,i,o,s),t=s.x,i=s.z,tthis._maxX||ithis._maxZ)return this;this._heightQuads&&0!=this._heightQuads.length||(this._initHeightQuads(),this._computeHeightQuads());var a=this._getFacetAt(t,i);return e.Vector3.TransformNormalFromFloatsToRef(a.x,a.y,a.z,n,r),this},i.prototype.updateCoordinateHeights=function(){return this._heightQuads&&0!=this._heightQuads.length||this._initHeightQuads(),this._computeHeightQuads(),this},i.prototype._getFacetAt=function(e,t){var i=(this._subdivisionsX,this._subdivisionsY,Math.floor((e+this._maxX)*this._subdivisionsX/this._width)),r=Math.floor(-(t+this._maxZ)*this._subdivisionsY/this._height+this._subdivisionsY),n=this._heightQuads[r*this._subdivisionsX+i];return t4&&(s.push(e.VertexBuffer.MatricesIndicesExtraKind),s.push(e.VertexBuffer.MatricesWeightsExtraKind)),o.push("#define NUM_BONE_INFLUENCERS "+t.numBoneInfluencers),o.push("#define BonesPerMesh "+(t.skeleton.bones.length+1)),a.addCPUSkinningFallback(0,t),-1===this._options.uniforms.indexOf("mBones")&&this._options.uniforms.push("mBones")):o.push("#define NUM_BONE_INFLUENCERS 0");for(var l in this._textures)if(!this._textures[l].isReady())return!1;n.getAlphaTesting()&&o.push("#define ALPHATEST");var c=this._effect,u=o.join("\n");return this._effect=n.createEffect(this._shaderPath,{attributes:s,uniformsNames:this._options.uniforms,uniformBuffersNames:this._options.uniformBuffers,samplers:this._options.samplers,defines:u,fallbacks:a,onCompiled:this.onCompiled,onError:this.onError},n),!!this._effect.isReady()&&(c!==this._effect&&r.resetCachedMaterial(),this._renderId=r.getRenderId(),!0)},i.prototype.bindOnlyWorldMatrix=function(e){var t=this.getScene();-1!==this._options.uniforms.indexOf("world")&&this._effect.setMatrix("world",e),-1!==this._options.uniforms.indexOf("worldView")&&(e.multiplyToRef(t.getViewMatrix(),this._cachedWorldViewMatrix),this._effect.setMatrix("worldView",this._cachedWorldViewMatrix)),-1!==this._options.uniforms.indexOf("worldViewProjection")&&this._effect.setMatrix("worldViewProjection",e.multiply(t.getTransformMatrix()))},i.prototype.bind=function(t,i){if(this.bindOnlyWorldMatrix(t),this.getScene().getCachedMaterial()!==this){-1!==this._options.uniforms.indexOf("view")&&this._effect.setMatrix("view",this.getScene().getViewMatrix()),-1!==this._options.uniforms.indexOf("projection")&&this._effect.setMatrix("projection",this.getScene().getProjectionMatrix()),-1!==this._options.uniforms.indexOf("viewProjection")&&this._effect.setMatrix("viewProjection",this.getScene().getTransformMatrix()),e.MaterialHelper.BindBonesParameters(i,this._effect);var r;for(r in this._textures)this._effect.setTexture(r,this._textures[r]);for(r in this._textureArrays)this._effect.setTextureArray(r,this._textureArrays[r]);for(r in this._floats)this._effect.setFloat(r,this._floats[r]);for(r in this._floatsArrays)this._effect.setArray(r,this._floatsArrays[r]);for(r in this._colors3)this._effect.setColor3(r,this._colors3[r]);for(r in this._colors3Arrays)this._effect.setArray3(r,this._colors3Arrays[r]);for(r in this._colors4){var n=this._colors4[r];this._effect.setFloat4(r,n.r,n.g,n.b,n.a)}for(r in this._vectors2)this._effect.setVector2(r,this._vectors2[r]);for(r in this._vectors3)this._effect.setVector3(r,this._vectors3[r]);for(r in this._vectors4)this._effect.setVector4(r,this._vectors4[r]);for(r in this._matrices)this._effect.setMatrix(r,this._matrices[r]);for(r in this._matrices3x3)this._effect.setMatrix3x3(r,this._matrices3x3[r]);for(r in this._matrices2x2)this._effect.setMatrix2x2(r,this._matrices2x2[r]);for(r in this._vectors3Arrays)this._effect.setArray3(r,this._vectors3Arrays[r])}this._afterBind(i)},i.prototype.getActiveTextures=function(){var e=t.prototype.getActiveTextures.call(this);for(var i in this._textures)e.push(this._textures[i]);for(var i in this._textureArrays)for(var r=this._textureArrays[i],n=0;ne.Tmp.Vector3[1].x&&(e.Tmp.Vector3[1].x=h[u].x),h[u].ye.Tmp.Vector3[1].y&&(e.Tmp.Vector3[1].y=h[u].y),h[u].ze.Tmp.Vector3[1].z&&(e.Tmp.Vector3[1].z=h[u].z),u++,r+=3;l._closePath&&(t[r]=h[0].x,t[r+1]=h[0].y,t[r+2]=h[0].z,r+=3)}}(u),l._boundingInfo=new e.BoundingInfo(e.Tmp.Vector3[0],e.Tmp.Vector3[1]),l._boundingInfo.update(l._worldMatrix),l.updateVerticesData(e.VertexBuffer.PositionKind,u,!1,!1),r.colors){for(var f=l.getVerticesData(e.VertexBuffer.ColorKind),d=0;d1?1:r.arc:1,a=void 0===r.closed||r.closed,h=r.shape,l=r.radius||1,c=r.tessellation||64,u=r.updatable,f=t.updateSideOrientation(r.sideOrientation,n),d=r.cap||e.Mesh.NO_CAP,p=2*Math.PI,m=new Array,_=r.invertUV||!1,g=0,v=0,y=p/c*s,x=new Array;for(g=0;g<=c;g++){var x=[];for(d!=e.Mesh.CAP_START&&d!=e.Mesh.CAP_ALL||(x.push(new e.Vector3(0,h[0].y,0)),x.push(new e.Vector3(Math.cos(g*y)*h[0].x*l,h[0].y,Math.sin(g*y)*h[0].x*l))),v=0;v1?1:r.arc||1;var p,m,_=function(t,i,r,n,o,s,a,h){for(var l,c,u,f,d=i.getTangents(),p=i.getNormals(),m=i.getDistances(),_=2*Math.PI,g=_/o*h,v=function(){return n},y=s||v,x=e.Tmp.Matrix[0],b=a===e.Mesh._NO_CAP||a===e.Mesh.CAP_END?0:2,A=0;A3?0:l,m=_(o,p,v,s,a,h,l,r.arc);var y=t.CreateRibbon(i,{pathArray:m,closePath:!0,closeArray:!1,updatable:u,sideOrientation:f,invertUV:c,frontUVs:r.frontUVs,backUVs:r.backUVs},n);return y.pathArray=m,y.path3D=p,y.tessellation=a,y.cap=l,y.arc=r.arc,y},t.CreatePolyhedron=function(i,r,n){var o=new e.Mesh(i,n);return r.sideOrientation=t.updateSideOrientation(r.sideOrientation,n),o.sideOrientation=r.sideOrientation,e.VertexData.CreatePolyhedron(r).applyToMesh(o,r.updatable),o},t.CreateDecal=function(t,i,r){var n=i.getIndices(),o=i.getVerticesData(e.VertexBuffer.PositionKind),s=i.getVerticesData(e.VertexBuffer.NormalKind),a=r.position||e.Vector3.Zero(),h=r.normal||e.Vector3.Up(),l=r.size||e.Vector3.One(),c=r.angle||0;if(!h){var u=new e.Vector3(0,0,1),f=i.getScene().activeCamera,d=e.Vector3.TransformCoordinates(u,f.getWorldMatrix());h=f.globalPosition.subtract(d)}var p=-Math.atan2(h.z,h.x)-Math.PI/2,m=Math.sqrt(h.x*h.x+h.z*h.z),_=Math.atan2(h.y,m),g=e.Matrix.RotationYawPitchRoll(p,_,c).multiply(e.Matrix.Translation(a.x,a.y,a.z)),v=e.Matrix.Invert(g),y=i.getWorldMatrix(),x=y.multiply(v),b=new e.VertexData;b.indices=[],b.positions=[],b.normals=[],b.uvs=[];for(var A=0,T=function(t){var i=n[t],r=new e.PositionNormalVertex;return r.position=new e.Vector3(o[3*i],o[3*i+1],o[3*i+2]),r.position=e.Vector3.TransformCoordinates(r.position,x),r.normal=new e.Vector3(s[3*i],s[3*i+1],s[3*i+2]),r.normal=e.Vector3.TransformNormal(r.normal,x),r},E=function(t,i){if(0===t.length)return t;for(var r=.5*Math.abs(e.Vector3.Dot(l,i)),n=function(t,n){var o=e.Vector3.GetClipFactor(t.position,n.position,i,r);return new e.PositionNormalVertex(e.Vector3.Lerp(t.position,n.position,o),e.Vector3.Lerp(t.normal,n.normal,o))},o=new Array,s=0;s0,h=_>0,c=g>0,(a?1:0)+(h?1:0)+(c?1:0)){case 0:o.push(t[s]),o.push(t[s+1]),o.push(t[s+2]);break;case 1:if(a&&(u=t[s+1],f=t[s+2],d=n(t[s],u),p=n(t[s],f)),h){u=t[s],f=t[s+2],d=n(t[s+1],u),p=n(t[s+1],f),o.push(d),o.push(f.clone()),o.push(u.clone()),o.push(f.clone()),o.push(d.clone()),o.push(p);break}c&&(u=t[s],f=t[s+1],d=n(t[s+2],u),p=n(t[s+2],f)),o.push(u.clone()),o.push(f.clone()),o.push(d),o.push(p),o.push(d.clone()),o.push(f.clone());break;case 2:a||(u=t[s].clone(),f=n(u,t[s+1]),d=n(u,t[s+2]),o.push(u),o.push(f),o.push(d)),h||(u=t[s+1].clone(),f=n(u,t[s+2]),d=n(u,t[s]),o.push(u),o.push(f),o.push(d)),c||(u=t[s+2].clone(),f=n(u,t[s]),d=n(u,t[s+1]),o.push(u),o.push(f),o.push(d))}}return o},P=0;P3?0:u,b=A(r,n,x,T,o,s,a,h,u,f);var E=t.CreateRibbon(i,{pathArray:b,closeArray:l,closePath:c,updatable:p,sideOrientation:m,invertUV:g,frontUVs:v,backUVs:y},d);return E.pathArray=b,E.path3D=x,E.cap=u,E},t})();e.MeshBuilder=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this._audioContext=null,this._audioContextInitialized=!1,this.canUseWebAudio=!1,this.WarnedWebAudioUnsupported=!1,this.unlocked=!1,this.isMP3supported=!1,this.isOGGsupported=!1,void 0===window.AudioContext&&void 0===window.webkitAudioContext||(window.AudioContext=window.AudioContext||window.webkitAudioContext,this.canUseWebAudio=!0);var e=document.createElement("audio");try{e&&e.canPlayType&&e.canPlayType('audio/mpeg; codecs="mp3"').replace(/^no$/,"")&&(this.isMP3supported=!0)}catch(e){}try{e&&e.canPlayType&&e.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,"")&&(this.isOGGsupported=!0)}catch(e){}/iPad|iPhone|iPod/.test(navigator.platform)?this._unlockiOSaudio():this.unlocked=!0}return Object.defineProperty(t.prototype,"audioContext",{get:function(){return this._audioContextInitialized||this._initializeAudioContext(),this._audioContext},enumerable:!0,configurable:!0}),t.prototype._unlockiOSaudio=function(){var e=this,t=function(){var i=e.audioContext.createBuffer(1,1,22050),r=e.audioContext.createBufferSource();r.buffer=i,r.connect(e.audioContext.destination),r.start(0),setTimeout((function(){r.playbackState!==r.PLAYING_STATE&&r.playbackState!==r.FINISHED_STATE||(e.unlocked=!0,window.removeEventListener("touchend",t,!1),e.onAudioUnlocked&&e.onAudioUnlocked())}),0)};window.addEventListener("touchend",t,!1)},t.prototype._initializeAudioContext=function(){try{this.canUseWebAudio&&(this._audioContext=new AudioContext,this.masterGain=this._audioContext.createGain(),this.masterGain.gain.value=1,this.masterGain.connect(this._audioContext.destination),this._audioContextInitialized=!0)}catch(t){this.canUseWebAudio=!1,e.Tools.Error("Web Audio: "+t.message)}},t.prototype.dispose=function(){this.canUseWebAudio&&this._audioContextInitialized&&(this._connectedAnalyser&&(this._connectedAnalyser.stopDebugCanvas(),this._connectedAnalyser.dispose(),this.masterGain.disconnect(),this.masterGain.connect(this._audioContext.destination),this._connectedAnalyser=null),this.masterGain.gain.value=1),this.WarnedWebAudioUnsupported=!1},t.prototype.getGlobalVolume=function(){return this.canUseWebAudio&&this._audioContextInitialized?this.masterGain.gain.value:-1},t.prototype.setGlobalVolume=function(e){this.canUseWebAudio&&this._audioContextInitialized&&(this.masterGain.gain.value=e)},t.prototype.connectToAnalyser=function(e){this._connectedAnalyser&&this._connectedAnalyser.stopDebugCanvas(),this.canUseWebAudio&&this._audioContextInitialized&&(this._connectedAnalyser=e,this.masterGain.disconnect(),this._connectedAnalyser.connectAudioNodes(this.masterGain,this._audioContext.destination))},t})();e.AudioEngine=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t,i,r,n,o){var s=this;if(this.autoplay=!1,this.loop=!1,this.useCustomAttenuation=!1,this.spatialSound=!1,this.refDistance=1,this.rolloffFactor=1,this.maxDistance=100,this.distanceModel="linear",this._panningModel="equalpower",this._playbackRate=1,this._streaming=!1,this._startTime=0,this._startOffset=0,this._position=e.Vector3.Zero(),this._localDirection=new e.Vector3(1,0,0),this._volume=1,this._isLoaded=!1,this._isReadyToPlay=!1,this.isPlaying=!1,this.isPaused=!1,this._isDirectional=!1,this._coneInnerAngle=360,this._coneOuterAngle=360,this._coneOuterGain=0,this._isOutputConnected=!1,this._urlType="Unknown",this.name=t,this._scene=r,this._readyToPlayCallback=n,this._customAttenuationFunction=function(e,t,i,r,n){return t0&&(l=!0,this._soundLoaded(i));break;case"String":h.push(i);case"Array":0===h.length&&(h=i);for(var c=0;c0&&(this._htmlAudioElement.currentTime=0);else{var i=t?e.Engine.audioEngine.audioContext.currentTime+t:e.Engine.audioEngine.audioContext.currentTime;this._soundSource.stop(i),this._soundSource.onended=null,this.isPaused||(this._startOffset=0)}this.isPlaying=!1}},t.prototype.pause=function(){this.isPlaying&&(this.isPaused=!0,this._streaming?this._htmlAudioElement.pause():(this.stop(0),this._startOffset+=e.Engine.audioEngine.audioContext.currentTime-this._startTime))},t.prototype.setVolume=function(t,i){e.Engine.audioEngine.canUseWebAudio&&(i?(this._soundGain.gain.cancelScheduledValues(e.Engine.audioEngine.audioContext.currentTime),this._soundGain.gain.setValueAtTime(this._soundGain.gain.value,e.Engine.audioEngine.audioContext.currentTime),this._soundGain.gain.linearRampToValueAtTime(t,e.Engine.audioEngine.audioContext.currentTime+i)):this._soundGain.gain.value=t),this._volume=t},t.prototype.setPlaybackRate=function(e){this._playbackRate=e,this.isPlaying&&(this._streaming?this._htmlAudioElement.playbackRate=this._playbackRate:this._soundSource.playbackRate.value=this._playbackRate)},t.prototype.getVolume=function(){return this._volume},t.prototype.attachToMesh=function(e){var t=this;this._connectedMesh&&(this._connectedMesh.unregisterAfterWorldMatrixUpdate(this._registerFunc),this._registerFunc=null),this._connectedMesh=e,this.spatialSound||(this.spatialSound=!0,this._createSpatialParameters(),this.isPlaying&&this.loop&&(this.stop(),this.play())),this._onRegisterAfterWorldMatrixUpdate(this._connectedMesh),this._registerFunc=function(e){return t._onRegisterAfterWorldMatrixUpdate(e)},e.registerAfterWorldMatrixUpdate(this._registerFunc)},t.prototype.detachFromMesh=function(){this._connectedMesh&&(this._connectedMesh.unregisterAfterWorldMatrixUpdate(this._registerFunc),this._registerFunc=null,this._connectedMesh=null)},t.prototype._onRegisterAfterWorldMatrixUpdate=function(t){this.setPosition(t.getBoundingInfo().boundingSphere.centerWorld),e.Engine.audioEngine.canUseWebAudio&&this._isDirectional&&this.isPlaying&&this._updateDirection()},t.prototype.clone=function(){var e=this;if(this._streaming)return null;var i=function(){e._isReadyToPlay?(n._audioBuffer=e.getAudioBuffer(),n._isReadyToPlay=!0,n.autoplay&&n.play()):window.setTimeout(i,300)},r={autoplay:this.autoplay,loop:this.loop,volume:this._volume,spatialSound:this.spatialSound,maxDistance:this.maxDistance,useCustomAttenuation:this.useCustomAttenuation,rolloffFactor:this.rolloffFactor,refDistance:this.refDistance,distanceModel:this.distanceModel},n=new t(this.name+"_cloned",new ArrayBuffer(0),this._scene,null,r);return this.useCustomAttenuation&&n.setAttenuationFunction(this._customAttenuationFunction),n.setPosition(this._position),n.setPlaybackRate(this._playbackRate),i(),n},t.prototype.getAudioBuffer=function(){return this._audioBuffer},t.prototype.serialize=function(){var e={name:this.name,url:this.name,autoplay:this.autoplay,loop:this.loop,volume:this._volume,spatialSound:this.spatialSound,maxDistance:this.maxDistance,rolloffFactor:this.rolloffFactor,refDistance:this.refDistance,distanceModel:this.distanceModel,playbackRate:this._playbackRate,panningModel:this._panningModel,soundTrackId:this.soundTrackId};return this.spatialSound&&(this._connectedMesh&&(e.connectedMeshId=this._connectedMesh.id),e.position=this._position.asArray(),e.refDistance=this.refDistance,e.distanceModel=this.distanceModel,e.isDirectional=this._isDirectional,e.localDirectionToMesh=this._localDirection.asArray(),e.coneInnerAngle=this._coneInnerAngle,e.coneOuterAngle=this._coneOuterAngle,e.coneOuterGain=this._coneOuterGain),e},t.Parse=function(i,r,n,o){var s,a=i.name;s=i.url?n+i.url:n+a;var h,l={autoplay:i.autoplay,loop:i.loop,volume:i.volume,spatialSound:i.spatialSound,maxDistance:i.maxDistance,rolloffFactor:i.rolloffFactor,refDistance:i.refDistance,distanceModel:i.distanceModel,playbackRate:i.playbackRate};if(o){var c=function(){o._isReadyToPlay?(h._audioBuffer=o.getAudioBuffer(),h._isReadyToPlay=!0,h.autoplay&&h.play()):window.setTimeout(c,300)};h=new t(a,new ArrayBuffer(0),r,null,l),c()}else h=new t(a,s,r,function(){r._removePendingData(h)},l),r._addPendingData(h);if(i.position){var u=e.Vector3.FromArray(i.position);h.setPosition(u)}if(i.isDirectional&&(h.setDirectionalCone(i.coneInnerAngle||360,i.coneOuterAngle||360,i.coneOuterGain||0),i.localDirectionToMesh)){var f=e.Vector3.FromArray(i.localDirectionToMesh);h.setLocalDirectionToMesh(f)}if(i.connectedMeshId){var d=r.getMeshByID(i.connectedMeshId);d&&h.attachToMesh(d)}return h},t})();e.Sound=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e,t){this.id=-1,this._isMainTrack=!1,this._isInitialized=!1,this._scene=e,this.soundCollection=new Array,this._options=t,this._isMainTrack||(this._scene.soundTracks.push(this),this.id=this._scene.soundTracks.length-1)}return t.prototype._initializeSoundTrackAudioGraph=function(){e.Engine.audioEngine.canUseWebAudio&&(this._outputAudioNode=e.Engine.audioEngine.audioContext.createGain(),this._outputAudioNode.connect(e.Engine.audioEngine.masterGain),this._options&&(this._options.volume&&(this._outputAudioNode.gain.value=this._options.volume),this._options.mainTrack&&(this._isMainTrack=this._options.mainTrack)),this._isInitialized=!0)},t.prototype.dispose=function(){if(e.Engine.audioEngine.canUseWebAudio){for(this._connectedAnalyser&&this._connectedAnalyser.stopDebugCanvas();this.soundCollection.length;)this.soundCollection[0].dispose();this._outputAudioNode&&this._outputAudioNode.disconnect(),this._outputAudioNode=null}},t.prototype.AddSound=function(t){this._isInitialized||this._initializeSoundTrackAudioGraph(),e.Engine.audioEngine.canUseWebAudio&&t.connectToSoundTrackAudioNode(this._outputAudioNode),t.soundTrackId&&(-1===t.soundTrackId?this._scene.mainSoundTrack.RemoveSound(t):this._scene.soundTracks[t.soundTrackId].RemoveSound(t)),this.soundCollection.push(t),t.soundTrackId=this.id},t.prototype.RemoveSound=function(e){var t=this.soundCollection.indexOf(e);-1!==t&&this.soundCollection.splice(t,1)},t.prototype.setVolume=function(t){e.Engine.audioEngine.canUseWebAudio&&(this._outputAudioNode.gain.value=t)},t.prototype.switchPanningModelToHRTF=function(){if(e.Engine.audioEngine.canUseWebAudio)for(var t=0;t0&&(this._postProcesses[0].autoClear=!1))}},i.prototype._shouldRender=function(){return-1===this._currentRefreshId?(this._currentRefreshId=1,!0):this.refreshRate===this._currentRefreshId?(this._currentRefreshId=1,!0):(this._currentRefreshId++,!1)},i.prototype.isReady=function(){return!!this.getScene().renderTargetsEnabled&&t.prototype.isReady.call(this)},i.prototype.getRenderSize=function(){return this._size},Object.defineProperty(i.prototype,"canRescale",{get:function(){return!0},enumerable:!0,configurable:!0}),i.prototype.scale=function(e){var t=this._size*e;this.resize(t)},i.prototype.getReflectionTextureMatrix=function(){return this.isCube?this._textureMatrix:t.prototype.getReflectionTextureMatrix.call(this)},i.prototype.resize=function(e){this.releaseInternalTexture(),this.isCube?this._texture=this.getScene().getEngine().createRenderTargetCubeTexture(e,this._renderTargetOptions):this._texture=this.getScene().getEngine().createRenderTargetTexture(e,this._renderTargetOptions)},i.prototype.render=function(e,t){var i=this.getScene(),r=i.getEngine();if(void 0!==this.useCameraPostProcesses&&(e=this.useCameraPostProcesses),this._waitingRenderList){this.renderList=[];for(var n=0;n=0&&this._renderingManager.dispatchParticles(g))}if(this.isCube)for(var y=0;y<6;y++)this.renderToTarget(y,l,c,e,t),i.incrementRenderId(),i.resetCachedMaterial();else this.renderToTarget(0,l,c,e,t);this.onAfterUnbindObservable.notifyObservers(this),this.activeCamera&&this.activeCamera!==i.activeCamera&&i.setTransformMatrix(i.activeCamera.getViewMatrix(),i.activeCamera.getProjectionMatrix(!0)),r.setViewport(i.activeCamera.viewport),i.resetCachedMaterial()}},i.prototype.renderToTarget=function(t,i,r,n,o){var s=this,a=this.getScene(),h=a.getEngine();this._postProcessManager?this._postProcessManager._prepareFrame(this._texture,this._postProcesses):n&&a.postProcessManager._prepareFrame(this._texture)||(this.isCube?h.bindFramebuffer(this._texture,t):h.bindFramebuffer(this._texture)),this.onBeforeRenderObservable.notifyObservers(t),this.onClearObservable.hasObservers()?this.onClearObservable.notifyObservers(h):h.clear(a.clearColor,!0,!0,!0),this._doNotChangeAspectRatio||a.updateTransformMatrix(!0),this._renderingManager.render(this.customRenderFunction,i,this.renderParticles,this.renderSprites),this._postProcessManager?this._postProcessManager._finalizeFrame(!1,this._texture,t,this._postProcesses):n&&a.postProcessManager._finalizeFrame(!1,this._texture,t),this._doNotChangeAspectRatio||a.updateTransformMatrix(!0),o&&e.Tools.DumpFramebuffer(this._size,this._size,h),this.isCube&&5!==t?this.onAfterRenderObservable.notifyObservers(t):(this.isCube&&5===t&&h.generateMipMapsForCubemap(this._texture),h.unBindFramebuffer(this._texture,this.isCube,(function(){s.onAfterRenderObservable.notifyObservers(t)})))},i.prototype.setRenderingOrder=function(e,t,i,r){void 0===t&&(t=null),void 0===i&&(i=null),void 0===r&&(r=null),this._renderingManager.setRenderingOrder(e,t,i,r)},i.prototype.setRenderingAutoClearDepthStencil=function(e,t){this._renderingManager.setRenderingAutoClearDepthStencil(e,t)},i.prototype.clone=function(){var e=this.getSize(),t=new i(this.name,e.width,this.getScene(),this._renderTargetOptions.generateMipMaps,this._doNotChangeAspectRatio,this._renderTargetOptions.type,this.isCube,this._renderTargetOptions.samplingMode,this._renderTargetOptions.generateDepthBuffer,this._renderTargetOptions.generateStencilBuffer);return t.hasAlpha=this.hasAlpha,t.level=this.level,t.coordinatesMode=this.coordinatesMode,t.renderList=this.renderList.slice(0),t},i.prototype.serialize=function(){if(!this.name)return null;var e=t.prototype.serialize.call(this);e.renderTargetSize=this.getRenderSize(),e.renderList=[];for(var i=0;i=0&&e.customRenderTargets.splice(i,1);for(var r=0,n=e.cameras;r=0&&o.customRenderTargets.splice(i,1)}t.prototype.dispose.call(this)},i})(e.Texture);t._REFRESHRATE_RENDER_ONCE=0,t._REFRESHRATE_RENDER_ONEVERYFRAME=1,t._REFRESHRATE_RENDER_ONEVERYTWOFRAMES=2,e.RenderTargetTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o,s){var a=this;s=s||{};var h=!!s.generateMipMaps&&s.generateMipMaps,l=!!s.generateDepthTexture&&s.generateDepthTexture,c=void 0===s.doNotChangeAspectRatio||s.doNotChangeAspectRatio;if(a=t.call(this,i,r,o,h,c)||this,!a.isSupported)return void a.dispose();for(var u=[],f=[],d=0;d1||e.getCaps().drawBuffersExtension},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"textures",{get:function(){return this._textures},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"depthTexture",{get:function(){return this._textures[this._textures.length-1]},enumerable:!0,configurable:!0}),i.prototype._createInternalTextures=function(){this._textures=[];for(var t=0;t=0;e--)void 0!==this._webGLTextures[e]&&(this.getScene().getEngine().releaseInternalTexture(this._webGLTextures[e]),this._webGLTextures.splice(e,1))},i})(e.RenderTargetTexture);e.MultiRenderTarget=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o,s,a,h){void 0===s&&(s=e.Engine.TEXTURETYPE_UNSIGNED_INT),void 0===a&&(a=e.Texture.BILINEAR_SAMPLINGMODE),void 0===h&&(h=!0);var l=t.call(this,i,r,n,o,!0,s,!1,a,h)||this;return l.mirrorPlane=new e.Plane(0,1,0,1),l._transformMatrix=e.Matrix.Zero(),l._mirrorMatrix=e.Matrix.Zero(),l._blurKernelX=0,l._blurKernelY=0,l._blurRatio=1,l.onBeforeRenderObservable.add((function(){e.Matrix.ReflectionToRef(l.mirrorPlane,l._mirrorMatrix),l._savedViewMatrix=n.getViewMatrix(),l._mirrorMatrix.multiplyToRef(l._savedViewMatrix,l._transformMatrix),n.setTransformMatrix(l._transformMatrix,n.getProjectionMatrix()),n.clipPlane=l.mirrorPlane,n.getEngine().cullBackFaces=!1,n._mirroredCameraPosition=e.Vector3.TransformCoordinates(n.activeCamera.globalPosition,l._mirrorMatrix)})),l.onAfterRenderObservable.add((function(){n.setTransformMatrix(l._savedViewMatrix,n.getProjectionMatrix()),n.getEngine().cullBackFaces=!0,n._mirroredCameraPosition=null,delete n.clipPlane})),l}return __extends(i,t),Object.defineProperty(i.prototype,"blurRatio",{get:function(){return this._blurRatio},set:function(e){this._blurRatio!==e&&(this._blurRatio=e,this._preparePostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"blurKernel",{set:function(e){this.blurKernelX=e,this.blurKernelY=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"blurKernelX",{get:function(){return this._blurKernelX},set:function(e){this._blurKernelX!==e&&(this._blurKernelX=e,this._preparePostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"blurKernelY",{get:function(){return this._blurKernelY},set:function(e){this._blurKernelY!==e&&(this._blurKernelY=e,this._preparePostProcesses())},enumerable:!0,configurable:!0}),i.prototype._preparePostProcesses=function(){if(this.clearPostProcesses(!0),this._blurKernelX&&this._blurKernelY){var t=this.getScene().getEngine(),i=t.getCaps().textureFloatRender?e.Engine.TEXTURETYPE_FLOAT:e.Engine.TEXTURETYPE_HALF_FLOAT;this._blurX=new e.BlurPostProcess("horizontal blur",new e.Vector2(1,0),this._blurKernelX,this._blurRatio,null,e.Texture.BILINEAR_SAMPLINGMODE,t,!1,i),this._blurX.autoClear=!1,1===this._blurRatio&&this.samples<2?this._blurX.outputTexture=this._texture:this._blurX.alwaysForcePOT=!0,this._blurY=new e.BlurPostProcess("vertical blur",new e.Vector2(0,1),this._blurKernelY,this._blurRatio,null,e.Texture.BILINEAR_SAMPLINGMODE,t,!1,i),this._blurY.autoClear=!1,this._blurY.alwaysForcePOT=1!==this._blurRatio,this.addPostProcess(this._blurX),this.addPostProcess(this._blurY)}},i.prototype.clone=function(){var e=this.getSize(),t=new i(this.name,e.width,this.getScene(),this._renderTargetOptions.generateMipMaps,this._renderTargetOptions.type,this._renderTargetOptions.samplingMode,this._renderTargetOptions.generateDepthBuffer);return t.hasAlpha=this.hasAlpha,t.level=this.level,t.mirrorPlane=this.mirrorPlane.clone(),t.renderList=this.renderList.slice(0),t},i.prototype.serialize=function(){if(!this.name)return null;var e=t.prototype.serialize.call(this);return e.mirrorPlane=this.mirrorPlane.asArray(),e},i})(e.RenderTargetTexture);e.MirrorTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o){var s=t.call(this,i,r,n,o,!0)||this;return s.refractionPlane=new e.Plane(0,1,0,1),s.depth=2,s.onBeforeRenderObservable.add((function(){n.clipPlane=s.refractionPlane})),s.onAfterRenderObservable.add((function(){delete n.clipPlane})),s}return __extends(i,t),i.prototype.clone=function(){var e=this.getSize(),t=new i(this.name,e.width,this.getScene(),this._generateMipMaps);return t.hasAlpha=this.hasAlpha,t.level=this.level,t.refractionPlane=this.refractionPlane.clone(),t.renderList=this.renderList.slice(0),t.depth=this.depth,t},i.prototype.serialize=function(){if(!this.name)return null;var e=t.prototype.serialize.call(this);return e.mirrorPlane=this.refractionPlane.asArray(),e.depth=this.depth,e},i})(e.RenderTargetTexture);e.RefractionTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o,s,a){void 0===s&&(s=e.Texture.TRILINEAR_SAMPLINGMODE),void 0===a&&(a=e.Engine.TEXTUREFORMAT_RGBA);var h=t.call(this,null,n,!o,void 0,s,void 0,void 0,void 0,void 0,a)||this;h.name=i;var l=h.getScene().getEngine();h.wrapU=e.Texture.CLAMP_ADDRESSMODE,h.wrapV=e.Texture.CLAMP_ADDRESSMODE,h._generateMipMaps=o,r.getContext?(h._canvas=r,h._texture=l.createDynamicTexture(r.width,r.height,o,s)):(h._canvas=document.createElement("canvas"),r.width?h._texture=l.createDynamicTexture(r.width,r.height,o,s):h._texture=l.createDynamicTexture(r,r,o,s));var c=h.getSize();return h._canvas.width=c.width,h._canvas.height=c.height,h._context=h._canvas.getContext("2d"),h}return __extends(i,t),Object.defineProperty(i.prototype,"canRescale",{get:function(){return!0},enumerable:!0,configurable:!0}),i.prototype._recreate=function(e){this._canvas.width=e.width,this._canvas.height=e.height,this.releaseInternalTexture(),this._texture=this.getScene().getEngine().createDynamicTexture(e.width,e.height,this._generateMipMaps,this._samplingMode)},i.prototype.scale=function(e){var t=this.getSize();t.width*=e,t.height*=e,this._recreate(t)},i.prototype.scaleTo=function(e,t){var i=this.getSize();i.width=e,i.height=t,this._recreate(i)},i.prototype.getContext=function(){return this._context},i.prototype.clear=function(){var e=this.getSize();this._context.fillRect(0,0,e.width,e.height)},i.prototype.update=function(e){this.getScene().getEngine().updateDynamicTexture(this._texture,this._canvas,void 0===e||e,void 0,this._format)},i.prototype.drawText=function(e,t,i,r,n,o,s,a){void 0===a&&(a=!0);var h=this.getSize();if(o&&(this._context.fillStyle=o,this._context.fillRect(0,0,h.width,h.height)),this._context.font=r,null===t||void 0===t){var l=this._context.measureText(e);t=(h.width-l.width)/2}if(null===i||void 0===i){var c=parseInt(r.replace(/\D/g,""));i=h.height/2+c/3.65}this._context.fillStyle=n,this._context.fillText(e,t,i),a&&this.update(s)},i.prototype.clone=function(){var e=this.getSize(),t=new i(this.name,e,this.getScene(),this._generateMipMaps);return t.hasAlpha=this.hasAlpha,t.level=this.level,t.wrapU=this.wrapU,t.wrapV=this.wrapV,t},i})(e.Texture);e.DynamicTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o,s,a){void 0===o&&(o=!1),void 0===s&&(s=!1),void 0===a&&(a=e.Texture.TRILINEAR_SAMPLINGMODE);var h=t.call(this,null,n,!o,s)||this;h._autoLaunch=!0;var l;return h.name=i,r instanceof HTMLVideoElement?h.video=r:(l=r,h.video=document.createElement("video"),h.video.autoplay=!1,h.video.loop=!0),h._generateMipMaps=o,h._samplingMode=a,!h.getScene().getEngine().needPOTTextures||e.Tools.IsExponentOfTwo(h.video.videoWidth)&&e.Tools.IsExponentOfTwo(h.video.videoHeight)?(h.wrapU=e.Texture.WRAP_ADDRESSMODE,h.wrapV=e.Texture.WRAP_ADDRESSMODE):(h.wrapU=e.Texture.CLAMP_ADDRESSMODE,h.wrapV=e.Texture.CLAMP_ADDRESSMODE,h._generateMipMaps=!1),l?(h.video.addEventListener("canplay",(function(){h._createTexture()})),l.forEach((function(e){var t=document.createElement("source");t.src=e,h.video.appendChild(t)}))):h._createTexture(),h._lastUpdate=e.Tools.Now,h}return __extends(i,t),i.prototype.__setTextureReady=function(){this._texture.isReady=!0},i.prototype._createTexture=function(){this._texture=this.getScene().getEngine().createDynamicTexture(this.video.videoWidth,this.video.videoHeight,this._generateMipMaps,this._samplingMode),this._autoLaunch&&(this._autoLaunch=!1,this.video.play()),this._setTextureReady=this.__setTextureReady.bind(this),this.video.addEventListener("playing",this._setTextureReady)},i.prototype.update=function(){var t=e.Tools.Now;return!(t-this._lastUpdate<15||this.video.readyState!==this.video.HAVE_ENOUGH_DATA)&&(this._lastUpdate=t,this.getScene().getEngine().updateVideoTexture(this._texture,this.video,this._invertY),!0)},i.prototype.dispose=function(){t.prototype.dispose.call(this),this.video.removeEventListener("playing",this._setTextureReady)},i.CreateFromWebCam=function(t,i,r){var n,o=document.createElement("video");r&&r.deviceId&&(n={exact:r.deviceId}),navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia,window.URL=window.URL||window.webkitURL||window.mozURL||window.msURL,navigator.getUserMedia&&navigator.getUserMedia({video:{deviceId:n,width:{min:r&&r.minWidth||256,max:r&&r.maxWidth||640},height:{min:r&&r.minHeight||256,max:r&&r.maxHeight||480}}},(function(r){void 0!==o.mozSrcObject?o.mozSrcObject=r:o.src=window.URL&&window.URL.createObjectURL(r)||r,o.play(),i&&i(new e.VideoTexture("video",o,t,!0,!0))}),(function(t){e.Tools.Error(t.name)}))},i})(e.Texture);e.VideoTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o,s,a,h,l){void 0===a&&(a=!0),void 0===h&&(h=!1),void 0===l&&(l=e.Texture.TRILINEAR_SAMPLINGMODE);var c=t.call(this,null,s,!a,h)||this;return c.format=o,c._texture=s.getEngine().createRawTexture(i,r,n,o,a,h,l),c.wrapU=e.Texture.CLAMP_ADDRESSMODE,c.wrapV=e.Texture.CLAMP_ADDRESSMODE,c}return __extends(i,t),i.prototype.update=function(e){this.getScene().getEngine().updateRawTexture(this._texture,e,this.format,this._invertY)},i.CreateLuminanceTexture=function(t,r,n,o,s,a,h){return void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===h&&(h=e.Texture.TRILINEAR_SAMPLINGMODE),new i(t,r,n,e.Engine.TEXTUREFORMAT_LUMINANCE,o,s,a,h)},i.CreateLuminanceAlphaTexture=function(t,r,n,o,s,a,h){return void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===h&&(h=e.Texture.TRILINEAR_SAMPLINGMODE),new i(t,r,n,e.Engine.TEXTUREFORMAT_LUMINANCE_ALPHA,o,s,a,h)},i.CreateAlphaTexture=function(t,r,n,o,s,a,h){return void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===h&&(h=e.Texture.TRILINEAR_SAMPLINGMODE),new i(t,r,n,e.Engine.TEXTUREFORMAT_ALPHA,o,s,a,h)},i.CreateRGBTexture=function(t,r,n,o,s,a,h){return void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===h&&(h=e.Texture.TRILINEAR_SAMPLINGMODE),new i(t,r,n,e.Engine.TEXTUREFORMAT_RGB,o,s,a,h)},i.CreateRGBATexture=function(t,r,n,o,s,a,h){return void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===h&&(h=e.Texture.TRILINEAR_SAMPLINGMODE),new i(t,r,n,e.Engine.TEXTUREFORMAT_RGBA,o,s,a,h)},i})(e.Texture);e.RawTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t,i,r,n,o,s,a,h,l,c,u,f,d,p){void 0===a&&(a=e.Texture.NEAREST_SAMPLINGMODE),void 0===u&&(u=e.Engine.TEXTURETYPE_UNSIGNED_INT),void 0===f&&(f="postprocess"),void 0===p&&(p=!1),this.name=t,this.width=-1,this.height=-1,this.autoClear=!0,this.alphaMode=e.Engine.ALPHA_DISABLE,this.enablePixelPerfectMode=!1,this.scaleMode=e.Engine.SCALEMODE_FLOOR,this.alwaysForcePOT=!1,this.samples=1,this._reusable=!1,this._textures=new e.SmartArray(2),this._currentRenderTextureInd=0,this._scaleRatio=new e.Vector2(1,1),this._texelSize=e.Vector2.Zero(),this.onActivateObservable=new e.Observable,this.onSizeChangedObservable=new e.Observable,this.onApplyObservable=new e.Observable,this.onBeforeRenderObservable=new e.Observable,this.onAfterRenderObservable=new e.Observable,null!=s?(this._camera=s,this._scene=s.getScene(),s.attachPostProcess(this),this._engine=this._scene.getEngine()):this._engine=h,this._options=o,this.renderTargetSamplingMode=a||e.Texture.NEAREST_SAMPLINGMODE,this._reusable=l||!1,this._textureType=u,this._samplers=n||[],this._samplers.push("textureSampler"),this._fragmentUrl=i,this._vertexUrl=f,this._parameters=r||[],this._parameters.push("scale"),this._indexParameters=d,p||this.updateEffect(c)}return Object.defineProperty(t.prototype,"onActivate",{set:function(e){this._onActivateObserver&&this.onActivateObservable.remove(this._onActivateObserver),this._onActivateObserver=this.onActivateObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onSizeChanged",{set:function(e){this._onSizeChangedObserver&&this.onSizeChangedObservable.remove(this._onSizeChangedObserver),this._onSizeChangedObserver=this.onSizeChangedObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onApply",{set:function(e){this._onApplyObserver&&this.onApplyObservable.remove(this._onApplyObserver),this._onApplyObserver=this.onApplyObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onBeforeRender",{set:function(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onAfterRender",{set:function(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=this.onAfterRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"outputTexture",{get:function(){return this._textures.data[this._currentRenderTextureInd]},set:function(e){this._forcedOutputTexture=e},enumerable:!0,configurable:!0}),t.prototype.getCamera=function(){return this._camera},Object.defineProperty(t.prototype,"texelSize",{get:function(){return this._shareOutputWithPostProcess?this._shareOutputWithPostProcess.texelSize:(this._forcedOutputTexture&&this._texelSize.copyFromFloats(1/this._forcedOutputTexture._width,1/this._forcedOutputTexture._height),this._texelSize)},enumerable:!0,configurable:!0}),t.prototype.getEngine=function(){return this._engine},t.prototype.getEffect=function(){return this._effect},t.prototype.shareOutputWith=function(e){return this._disposeTextures(),this._shareOutputWithPostProcess=e,this},t.prototype.updateEffect=function(e,t,i,r,n,o){this._effect=this._engine.createEffect({vertex:this._vertexUrl,fragment:this._fragmentUrl},["position"],t||this._parameters,i||this._samplers,void 0!==e?e:"",null,n,o,r||this._indexParameters)},t.prototype.isReusable=function(){return this._reusable},t.prototype.markTextureDirty=function(){this.width=-1},t.prototype.activate=function(t,i,r){var n=this;if(!this._shareOutputWithPostProcess&&!this._forcedOutputTexture){t=t||this._camera;var o=t.getScene(),s=o.getEngine(),a=s.getCaps().maxTextureSize,h=(i?i._width:this._engine.getRenderingCanvas().width)*this._options|0,l=(i?i._height:this._engine.getRenderingCanvas().height)*this._options|0,c=this._options.width||h,u=this._options.height||l;if((this.renderTargetSamplingMode===e.Texture.TRILINEAR_SAMPLINGMODE||this.alwaysForcePOT)&&(this._options.width||(c=s.needPOTTextures?e.Tools.GetExponentOfTwo(c,a,this.scaleMode):c),this._options.height||(u=s.needPOTTextures?e.Tools.GetExponentOfTwo(u,a,this.scaleMode):u)),this.width!==c||this.height!==u){if(this._textures.length>0){for(var f=0;f0)for(var e=0;e0&&this._camera._postProcesses[0].markTextureDirty(),this.onActivateObservable.clear(),this.onAfterRenderObservable.clear(),this.onApplyObservable.clear(),this.onBeforeRenderObservable.clear(),this.onSizeChangedObservable.clear()}},t})();e.PostProcess=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o,s,a,h){return void 0===h&&(h=e.Engine.TEXTURETYPE_UNSIGNED_INT),t.call(this,i,"pass",null,null,r,n,o,s,a,null,h)||this}return __extends(i,t),i})(e.PostProcess);e.PassPostProcess=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(i,r,n){this._bias=5e-5,this._blurBoxOffset=1,this._blurScale=2,this._blurKernel=1,this._useKernelBlur=!1,this._filter=t.FILTER_NONE,this._darkness=0,this._transparencyShadow=!1,this.frustumEdgeFalloff=0,this.forceBackFacesOnly=!1,this._lightDirection=e.Vector3.Zero(),this._viewMatrix=e.Matrix.Zero(),this._projectionMatrix=e.Matrix.Zero(),this._transformMatrix=e.Matrix.Zero(),this._worldViewProjection=e.Matrix.Zero(),this._currentFaceIndex=0,this._currentFaceIndexCache=0,this._isCube=!1,this._defaultTextureMatrix=e.Matrix.Identity(),this._mapSize=i,this._light=r,this._scene=r.getScene(),r._shadowGenerator=this;var o=this._scene.getEngine().getCaps();n?o.textureFloatRender&&o.textureFloatLinearFiltering?this._textureType=e.Engine.TEXTURETYPE_FLOAT:o.textureHalfFloatRender&&o.textureHalfFloatLinearFiltering?this._textureType=e.Engine.TEXTURETYPE_HALF_FLOAT:this._textureType=e.Engine.TEXTURETYPE_UNSIGNED_INT:o.textureHalfFloatRender&&o.textureHalfFloatLinearFiltering?this._textureType=e.Engine.TEXTURETYPE_HALF_FLOAT:o.textureFloatRender&&o.textureFloatLinearFiltering?this._textureType=e.Engine.TEXTURETYPE_FLOAT:this._textureType=e.Engine.TEXTURETYPE_UNSIGNED_INT,this._initializeGenerator()}return Object.defineProperty(t,"FILTER_NONE",{get:function(){return t._FILTER_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FILTER_POISSONSAMPLING",{get:function(){return t._FILTER_POISSONSAMPLING},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FILTER_EXPONENTIALSHADOWMAP",{get:function(){return t._FILTER_EXPONENTIALSHADOWMAP},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FILTER_BLUREXPONENTIALSHADOWMAP",{get:function(){return t._FILTER_BLUREXPONENTIALSHADOWMAP},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FILTER_CLOSEEXPONENTIALSHADOWMAP",{get:function(){return t._FILTER_CLOSEEXPONENTIALSHADOWMAP},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FILTER_BLURCLOSEEXPONENTIALSHADOWMAP",{get:function(){return t._FILTER_BLURCLOSEEXPONENTIALSHADOWMAP},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"bias",{get:function(){return this._bias},set:function(e){this._bias=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"blurBoxOffset",{get:function(){return this._blurBoxOffset},set:function(e){this._blurBoxOffset!==e&&(this._blurBoxOffset=e,this._disposeBlurPostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"blurScale",{get:function(){return this._blurScale},set:function(e){this._blurScale!==e&&(this._blurScale=e,this._disposeBlurPostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"blurKernel",{get:function(){return this._blurKernel},set:function(e){this._blurKernel!==e&&(this._blurKernel=e,this._disposeBlurPostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useKernelBlur",{get:function(){return this._useKernelBlur},set:function(e){this._useKernelBlur!==e&&(this._useKernelBlur=e,this._disposeBlurPostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"depthScale",{get:function(){return void 0!==this._depthScale?this._depthScale:this._light.getDepthScale()},set:function(e){this._depthScale=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"filter",{get:function(){return this._filter},set:function(e){if(this._light.needCube()){if(e===t.FILTER_BLUREXPONENTIALSHADOWMAP)return void(this.useExponentialShadowMap=!0);if(e===t.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP)return void(this.useCloseExponentialShadowMap=!0)}this._filter!==e&&(this._filter=e,this._disposeBlurPostProcesses(),this._applyFilterValues(),this._light._markMeshesAsLightDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"usePoissonSampling",{get:function(){return this.filter===t.FILTER_POISSONSAMPLING},set:function(e){this.filter=e?t.FILTER_POISSONSAMPLING:t.FILTER_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useVarianceShadowMap",{get:function(){return e.Tools.Warn("VSM are now replaced by ESM. Please use useExponentialShadowMap instead."),this.useExponentialShadowMap},set:function(t){e.Tools.Warn("VSM are now replaced by ESM. Please use useExponentialShadowMap instead."),this.useExponentialShadowMap=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useBlurVarianceShadowMap",{get:function(){return e.Tools.Warn("VSM are now replaced by ESM. Please use useBlurExponentialShadowMap instead."),this.useBlurExponentialShadowMap},set:function(t){e.Tools.Warn("VSM are now replaced by ESM. Please use useBlurExponentialShadowMap instead."),this.useBlurExponentialShadowMap=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useExponentialShadowMap",{get:function(){return this.filter===t.FILTER_EXPONENTIALSHADOWMAP},set:function(e){this.filter=e?t.FILTER_EXPONENTIALSHADOWMAP:t.FILTER_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useBlurExponentialShadowMap",{get:function(){return this.filter===t.FILTER_BLUREXPONENTIALSHADOWMAP},set:function(e){this.filter=e?t.FILTER_BLUREXPONENTIALSHADOWMAP:t.FILTER_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useCloseExponentialShadowMap",{get:function(){return this.filter===t.FILTER_CLOSEEXPONENTIALSHADOWMAP},set:function(e){this.filter=e?t.FILTER_CLOSEEXPONENTIALSHADOWMAP:t.FILTER_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useBlurCloseExponentialShadowMap",{get:function(){return this.filter===t.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP},set:function(e){this.filter=e?t.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP:t.FILTER_NONE},enumerable:!0,configurable:!0}),t.prototype.getDarkness=function(){return this._darkness},t.prototype.setDarkness=function(e){return this._darkness=e>=1?1:e<=0?0:e,this},t.prototype.setTransparencyShadow=function(e){return this._transparencyShadow=e,this},t.prototype.getShadowMap=function(){return this._shadowMap},t.prototype.getShadowMapForRendering=function(){return this._shadowMap2?this._shadowMap2:this._shadowMap},t.prototype.getLight=function(){return this._light},t.prototype._initializeGenerator=function(){this._light._markMeshesAsLightDirty(),this._initializeShadowMap()},t.prototype._initializeShadowMap=function(){var t=this;this._shadowMap=new e.RenderTargetTexture(this._light.name+"_shadowMap",this._mapSize,this._scene,!1,!0,this._textureType,this._light.needCube()),this._shadowMap.wrapU=e.Texture.CLAMP_ADDRESSMODE,this._shadowMap.wrapV=e.Texture.CLAMP_ADDRESSMODE,this._shadowMap.anisotropicFilteringLevel=1,this._shadowMap.updateSamplingMode(e.Texture.BILINEAR_SAMPLINGMODE),this._shadowMap.renderParticles=!1,this._shadowMap.onBeforeRenderObservable.add((function(e){t._currentFaceIndex=e})),this._shadowMap.customRenderFunction=this._renderForShadowMap.bind(this),this._shadowMap.onAfterUnbindObservable.add((function(){(t.useBlurExponentialShadowMap||t.useBlurCloseExponentialShadowMap)&&(t._blurPostProcesses||t._initializeBlurRTTAndPostProcesses(),t._scene.postProcessManager.directRender(t._blurPostProcesses,t.getShadowMapForRendering().getInternalTexture()))})),this._shadowMap.onClearObservable.add((function(i){t.useExponentialShadowMap||t.useBlurExponentialShadowMap?i.clear(new e.Color4(0,0,0,0),!0,!0,!0):i.clear(new e.Color4(1,1,1,1),!0,!0,!0)}))},t.prototype._initializeBlurRTTAndPostProcesses=function(){var t=this,i=this._scene.getEngine(),r=this._mapSize/this.blurScale;this.useKernelBlur&&1===this.blurScale||(this._shadowMap2=new e.RenderTargetTexture(this._light.name+"_shadowMap2",r,this._scene,!1,!0,this._textureType),this._shadowMap2.wrapU=e.Texture.CLAMP_ADDRESSMODE,this._shadowMap2.wrapV=e.Texture.CLAMP_ADDRESSMODE,this._shadowMap2.updateSamplingMode(e.Texture.BILINEAR_SAMPLINGMODE)),this.useKernelBlur?(this._kernelBlurXPostprocess=new e.BlurPostProcess(this._light.name+"KernelBlurX",new e.Vector2(1,0),this.blurKernel,1,null,e.Texture.BILINEAR_SAMPLINGMODE,i,!1,this._textureType),this._kernelBlurXPostprocess.width=r,this._kernelBlurXPostprocess.height=r,this._kernelBlurXPostprocess.onApplyObservable.add((function(e){e.setTexture("textureSampler",t._shadowMap)})),this._kernelBlurYPostprocess=new e.BlurPostProcess(this._light.name+"KernelBlurY",new e.Vector2(0,1),this.blurKernel,1,null,e.Texture.BILINEAR_SAMPLINGMODE,i,!1,this._textureType),this._kernelBlurXPostprocess.autoClear=!1,this._kernelBlurYPostprocess.autoClear=!1,this._textureType===e.Engine.TEXTURETYPE_UNSIGNED_INT&&(this._kernelBlurXPostprocess.packedFloat=!0,this._kernelBlurYPostprocess.packedFloat=!0),this._blurPostProcesses=[this._kernelBlurXPostprocess,this._kernelBlurYPostprocess]):(this._boxBlurPostprocess=new e.PostProcess(this._light.name+"DepthBoxBlur","depthBoxBlur",["screenSize","boxOffset"],[],1,null,e.Texture.BILINEAR_SAMPLINGMODE,i,!1,"#define OFFSET "+this._blurBoxOffset,this._textureType),this._boxBlurPostprocess.onApplyObservable.add((function(e){e.setFloat2("screenSize",r,r),e.setTexture("textureSampler",t._shadowMap)})),this._boxBlurPostprocess.autoClear=!1,this._blurPostProcesses=[this._boxBlurPostprocess])},t.prototype._renderForShadowMap=function(e,t,i){var r;for(r=0;r=n.length)return void(e&&e(i));setTimeout(l,16)}};n.length>0&&l()},t.prototype.isReady=function(t,i){var r=[];this._textureType!==e.Engine.TEXTURETYPE_UNSIGNED_INT&&r.push("#define FLOAT"),(this.useExponentialShadowMap||this.useBlurExponentialShadowMap)&&r.push("#define ESM");var n=[e.VertexBuffer.PositionKind],o=t.getMesh(),s=t.getMaterial();if(s&&s.needAlphaTesting()){var a=s.getAlphaTestTexture();a&&(r.push("#define ALPHATEST"),o.isVerticesDataPresent(e.VertexBuffer.UVKind)&&(n.push(e.VertexBuffer.UVKind),r.push("#define UV1")),o.isVerticesDataPresent(e.VertexBuffer.UV2Kind)&&1===a.coordinatesIndex&&(n.push(e.VertexBuffer.UV2Kind),r.push("#define UV2")))}o.useBones&&o.computeBonesUsingShaders?(n.push(e.VertexBuffer.MatricesIndicesKind),n.push(e.VertexBuffer.MatricesWeightsKind),o.numBoneInfluencers>4&&(n.push(e.VertexBuffer.MatricesIndicesExtraKind),n.push(e.VertexBuffer.MatricesWeightsExtraKind)),r.push("#define NUM_BONE_INFLUENCERS "+o.numBoneInfluencers),r.push("#define BonesPerMesh "+(o.skeleton.bones.length+1))):r.push("#define NUM_BONE_INFLUENCERS 0"),i&&(r.push("#define INSTANCES"),n.push("world0"),n.push("world1"),n.push("world2"),n.push("world3"));var h=r.join("\n");return this._cachedDefines!==h&&(this._cachedDefines=h,this._effect=this._scene.getEngine().createEffect("shadowMap",n,["world","mBones","viewProjection","diffuseMatrix","lightPosition","depthValues","biasAndScale"],["diffuseSampler"],h)),this._effect.isReady()},t.prototype.prepareDefines=function(e,t){var i=this._scene,r=this._light;i.shadowsEnabled&&r.shadowEnabled&&(e["SHADOW"+t]=!0,this.usePoissonSampling?e["SHADOWPCF"+t]=!0:this.useExponentialShadowMap||this.useBlurExponentialShadowMap?e["SHADOWESM"+t]=!0:(this.useCloseExponentialShadowMap||this.useBlurCloseExponentialShadowMap)&&(e["SHADOWCLOSEESM"+t]=!0),r.needCube()&&(e["SHADOWCUBE"+t]=!0))},t.prototype.bindShadowLight=function(e,t){ +var i=this._light,r=this._scene;r.shadowsEnabled&&i.shadowEnabled&&(i.needCube()||t.setMatrix("lightMatrix"+e,this.getTransformMatrix()),t.setTexture("shadowSampler"+e,this.getShadowMapForRendering()),i._uniformBuffer.updateFloat4("shadowsInfo",this.getDarkness(),this.blurScale/this.getShadowMap().getSize().width,this.depthScale,this.frustumEdgeFalloff,e),i._uniformBuffer.updateFloat2("depthValues",this.getLight().getDepthMinZ(r.activeCamera),this.getLight().getDepthMinZ(r.activeCamera)+this.getLight().getDepthMaxZ(r.activeCamera),e))},t.prototype.getTransformMatrix=function(){var t=this._scene;if(this._currentRenderID===t.getRenderId()&&this._currentFaceIndexCache===this._currentFaceIndex)return this._transformMatrix;this._currentRenderID=t.getRenderId(),this._currentFaceIndexCache=this._currentFaceIndex;var i=this._light.position;return this._light.computeTransformedInformation()&&(i=this._light.transformedPosition),e.Vector3.NormalizeToRef(this._light.getShadowDirection(this._currentFaceIndex),this._lightDirection),1===Math.abs(e.Vector3.Dot(this._lightDirection,e.Vector3.Up()))&&(this._lightDirection.z=1e-13),!this._light.needProjectionMatrixCompute()&&this._cachedPosition&&this._cachedDirection&&i.equals(this._cachedPosition)&&this._lightDirection.equals(this._cachedDirection)||(this._cachedPosition=i.clone(),this._cachedDirection=this._lightDirection.clone(),e.Matrix.LookAtLHToRef(i,i.add(this._lightDirection),e.Vector3.Up(),this._viewMatrix),this._light.setShadowProjectionMatrix(this._projectionMatrix,this._viewMatrix,this.getShadowMap().renderList),this._viewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix)),this._transformMatrix},t.prototype.recreateShadowMap=function(){var e=this._shadowMap.renderList;this._disposeRTTandPostProcesses(),this._initializeGenerator(),this.filter=this.filter,this._applyFilterValues(),this._shadowMap.renderList=e},t.prototype._disposeBlurPostProcesses=function(){this._shadowMap2&&(this._shadowMap2.dispose(),this._shadowMap2=null),this._downSamplePostprocess&&(this._downSamplePostprocess.dispose(),this._downSamplePostprocess=null),this._boxBlurPostprocess&&(this._boxBlurPostprocess.dispose(),this._boxBlurPostprocess=null),this._kernelBlurXPostprocess&&(this._kernelBlurXPostprocess.dispose(),this._kernelBlurXPostprocess=null),this._kernelBlurYPostprocess&&(this._kernelBlurYPostprocess.dispose(),this._kernelBlurYPostprocess=null),this._blurPostProcesses=null},t.prototype._disposeRTTandPostProcesses=function(){this._shadowMap&&(this._shadowMap.dispose(),this._shadowMap=null),this._disposeBlurPostProcesses()},t.prototype.dispose=function(){this._disposeRTTandPostProcesses(),this._light._shadowGenerator=null,this._light._markMeshesAsLightDirty()},t.prototype.serialize=function(){var e={},t=this.getShadowMap();e.lightId=this._light.id,e.mapSize=t.getRenderSize(),e.useExponentialShadowMap=this.useExponentialShadowMap,e.useBlurExponentialShadowMap=this.useBlurExponentialShadowMap,e.useCloseExponentialShadowMap=this.useBlurExponentialShadowMap,e.useBlurCloseExponentialShadowMap=this.useBlurExponentialShadowMap,e.usePoissonSampling=this.usePoissonSampling,e.forceBackFacesOnly=this.forceBackFacesOnly,e.depthScale=this.depthScale,e.darkness=this.getDarkness(),e.blurBoxOffset=this.blurBoxOffset,e.blurKernel=this.blurKernel,e.blurScale=this.blurScale,e.useKernelBlur=this.useKernelBlur,e.transparencyShadow=this._transparencyShadow,e.renderList=[];for(var i=0;i-1&&void 0!==f.skeletons&&null!==f.skeletons){if(!1===_.indexOf(y.skeletonId)>-1)for(var O=0,I=f.skeletons.length;O0){for(var $=0;$0){for(var te=0;te0&&this._textureLoadingCallback(e)}this._currentScene.render()}},t.prototype.drag=function(e){e.stopPropagation(),e.preventDefault()},t.prototype.drop=function(e){ +e.stopPropagation(),e.preventDefault(),this.loadFiles(e)},t.prototype._handleFolderDrop=function(e,t,i){var r=e.createReader(),n=e.fullPath.replace(/^\//,"").replace(/(.+?)\/?$/,"$1/");r.readEntries((function(e){for(var r=e.length,o=0,s=e;o0){for(var i=[],r=[],n=0;n0&&(e.Tools.ClearLogCache(),e.Tools.Log("Babylon.js engine (v"+e.Engine.Version+") launched")),this._engine.stopRenderLoop(),this._currentScene.dispose()),e.SceneLoader.Load("file:",this._sceneFileToLoad,this._engine,(function(e){i._currentScene=e,i._currentScene.executeWhenReady((function(){i._sceneLoadedCallback&&i._sceneLoadedCallback(t._sceneFileToLoad,i._currentScene),i._engine.runRenderLoop((function(){i.renderFunction()}))}))}),(function(e){t._progressCallback&&t._progressCallback(e)}))):e.Tools.Error("Please provide a valid .babylon file.")},t})();t.FilesToLoad=new Array,e.FilesInput=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(){this._count=0,this._data={}}return e.prototype.copyFrom=function(e){var t=this;this.clear(),e.forEach((function(e,i){return t.add(e,i)}))},e.prototype.get=function(e){var t=this._data[e];if(void 0!==t)return t},e.prototype.getOrAddWithFactory=function(e,t){var i=this.get(e);return void 0!==i?i:(i=t(e),i&&this.add(e,i),i)},e.prototype.getOrAdd=function(e,t){var i=this.get(e);return void 0!==i?i:(this.add(e,t),t)},e.prototype.contains=function(e){return void 0!==this._data[e]},e.prototype.add=function(e,t){return void 0===this._data[e]&&(this._data[e]=t,++this._count,!0)},e.prototype.set=function(e,t){return void 0!==this._data[e]&&(this._data[e]=t,!0)},e.prototype.getAndRemove=function(e){var t=this.get(e);return void 0!==t?(delete this._data[e],--this._count,t):null},e.prototype.remove=function(e){return!!this.contains(e)&&(delete this._data[e],--this._count,!0)},e.prototype.clear=function(){this._data={},this._count=0},Object.defineProperty(e.prototype,"count",{get:function(){return this._count},enumerable:!0,configurable:!0}),e.prototype.forEach=function(e){for(var t in this._data){e(t,this._data[t])}},e.prototype.first=function(e){for(var t in this._data){var i=this._data[t],r=e(t,i);if(r)return r}return null},e})();e.StringDictionary=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){}return t.EnableFor=function(e){e._tags=e._tags||{},e.hasTags=function(){return t.HasTags(e)},e.addTags=function(i){return t.AddTagsTo(e,i)},e.removeTags=function(i){return t.RemoveTagsFrom(e,i)},e.matchesTagsQuery=function(i){return t.MatchesQuery(e,i)}},t.DisableFor=function(e){delete e._tags,delete e.hasTags,delete e.addTags,delete e.removeTags,delete e.matchesTagsQuery},t.HasTags=function(t){return!!t._tags&&!e.Tools.IsEmpty(t._tags)},t.GetTags=function(e,t){if(void 0===t&&(t=!0),!e._tags)return null;if(t){var i=[];for(var r in e._tags)e._tags.hasOwnProperty(r)&&!0===e._tags[r]&&i.push(r);return i.join(" ")}return e._tags},t.AddTagsTo=function(e,i){if(i&&"string"==typeof i){i.split(" ").forEach((function(i,r,n){t._AddTagTo(e,i)}))}},t._AddTagTo=function(e,i){""!==(i=i.trim())&&"true"!==i&&"false"!==i&&(i.match(/[\s]/)||i.match(/^([!]|([|]|[&]){2})/)||(t.EnableFor(e),e._tags[i]=!0))},t.RemoveTagsFrom=function(e,i){if(t.HasTags(e)){var r=i.split(" ");for(var n in r)t._RemoveTagFrom(e,r[n])}},t._RemoveTagFrom=function(e,t){delete e._tags[t]},t.MatchesQuery=function(i,r){return void 0===r||(""===r?t.HasTags(i):e.Internals.AndOrNotEvaluator.Eval(r,(function(e){return t.HasTags(i)&&i._tags[e]})))},t})();e.Tags=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(e){var t=(function(){function e(){}return e.Eval=function(t,i){return"true"===(t=t.match(/\([^\(\)]*\)/g)?t.replace(/\([^\(\)]*\)/g,(function(t){return t=t.slice(1,t.length-1),e._HandleParenthesisContent(t,i)})):e._HandleParenthesisContent(t,i))||"false"!==t&&e.Eval(t,i)},e._HandleParenthesisContent=function(t,i){i=i||function(e){return"true"===e};var r,n=t.split("||");for(var o in n)if(n.hasOwnProperty(o)){var s=e._SimplifyNegation(n[o].trim()),a=s.split("&&");if(a.length>1)for(var h=0;ho.data?(n.mustUpdateRessources=!0,r()):i(o.data):(n.mustUpdateRessources=!0,r())},s.onabort=function(e){i(-1)};var a=s.objectStore("versions").get(t);a.onsuccess=function(e){o=e.target.result},a.onerror=function(r){e.Tools.Error("Error loading version for scene "+t+" from DB."),i(-1)}}catch(t){e.Tools.Error("Error while accessing 'versions' object store (READ OP). Exception: "+t.message),i(-1)}}else e.Tools.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."),i(-1)},t.prototype._saveVersionIntoDBAsync=function(t,i){var r=this;if(this.isSupported&&!this.hasReachedQuota)try{var n=this.db.transaction(["versions"],"readwrite");n.onabort=function(e){try{e.srcElement.error&&"QuotaExceededError"===e.srcElement.error.name&&(r.hasReachedQuota=!0)}catch(e){}i(-1)},n.oncomplete=function(e){i(r.manifestVersionFound)};var o={sceneUrl:t,data:this.manifestVersionFound},s=n.objectStore("versions").put(o);s.onsuccess=function(e){},s.onerror=function(t){e.Tools.Error("Error in DB add version request in BABYLON.Database.")}}catch(t){e.Tools.Error("Error while accessing 'versions' object store (WRITE OP). Exception: "+t.message),i(-1)}else i(-1)},t.prototype.loadFileFromDB=function(e,i,r,n,o){var s=this,a=t.ReturnFullUrlLocation(e),h=function(e){s._saveFileIntoDBAsync(a,i,r)};this._checkVersionFromDB(a,(function(e){-1!==e?s.mustUpdateRessources?s._saveFileIntoDBAsync(a,i,r,o):s._loadFileFromDBAsync(a,i,h,o):n()}))},t.prototype._loadFileFromDBAsync=function(t,i,r,n){if(this.isSupported){var o;o=-1!==t.indexOf(".babylon")?"scenes":"textures";var s,a=this.db.transaction([o]);a.oncomplete=function(e){s?i(s.data):r()},a.onabort=function(e){r()};var h=a.objectStore(o).get(t);h.onsuccess=function(e){s=e.target.result},h.onerror=function(i){e.Tools.Error("Error loading file "+t+" from DB."),r()}}else e.Tools.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."),i()},t.prototype._saveFileIntoDBAsync=function(t,i,r,n){var o=this;if(this.isSupported){var s;s=-1!==t.indexOf(".babylon")?"scenes":"textures";var a,h=new XMLHttpRequest;h.open("GET",t,!0),n&&(h.responseType="arraybuffer"),h.onprogress=r,h.addEventListener("load",(function(){if(200===h.status||e.Tools.ValidateXHRData(h,n?6:1))if(a=n?h.response:h.responseText,o.hasReachedQuota)i(a);else{var r=o.db.transaction([s],"readwrite");r.onabort=function(e){try{e.srcElement.error&&"QuotaExceededError"===e.srcElement.error.name&&(o.hasReachedQuota=!0)}catch(e){}i(a)},r.oncomplete=function(e){i(a)};var l;l="scenes"===s?{sceneUrl:t,data:a,version:o.manifestVersionFound}:{textureUrl:t,data:a};try{var c=r.objectStore(s).put(l);c.onsuccess=function(e){},c.onerror=function(t){e.Tools.Error("Error in DB add file request in BABYLON.Database.")}}catch(e){i(a)}}else i()}),!1),h.addEventListener("error",(function(t){e.Tools.Error("error on XHR request."),i()}),!1),h.send()}else e.Tools.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."),i()},t})();t.IsUASupportingBlobStorage=!0,t.IDBStorageEnabled=!0,t.parseURL=function(e){document.createElement("a").href=e;var t=e.substring(0,e.lastIndexOf("#")),i=e.substring(t.lastIndexOf("/")+1,e.length);return e.substring(0,e.indexOf(i,0))},t.ReturnFullUrlLocation=function(e){return-1===e.indexOf("http:/")&&-1===e.indexOf("https:/")?t.parseURL(window.location.href)+e:e},e.Database=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this._isEnabled=!0,this.leftColor=e.Color3.White(),this.rightColor=e.Color3.Black(),this.bias=0,this.power=1}return Object.defineProperty(t.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(t){this._isEnabled!==t&&(this._isEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.FresnelDirtyFlag))},enumerable:!0,configurable:!0}),t.prototype.clone=function(){var i=new t;return e.Tools.DeepCopy(this,i),i},t.prototype.serialize=function(){var e={};return e.isEnabled=this.isEnabled,e.leftColor=this.leftColor,e.rightColor=this.rightColor,e.bias=this.bias,e.power=this.power,e},t.Parse=function(i){var r=new t;return r.isEnabled=i.isEnabled,r.leftColor=e.Color3.FromArray(i.leftColor),r.rightColor=e.Color3.FromArray(i.rightColor),r.bias=i.bias,r.power=i.power||1,r},t})();e.FresnelParameters=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e,i){var r=t.call(this,e,i,!0)||this;return i.multiMaterials.push(r),r.subMaterials=new Array,r.storeEffectOnSubMeshes=!0,r}return __extends(i,t),Object.defineProperty(i.prototype,"subMaterials",{get:function(){return this._subMaterials},set:function(e){this._subMaterials=e,this._hookArray(e)},enumerable:!0,configurable:!0}),i.prototype._hookArray=function(e){var t=this,i=e.push;e.push=function(){for(var r=[],n=0;n=this.subMaterials.length?this.getScene().defaultMaterial:this.subMaterials[e]},i.prototype.getActiveTextures=function(){return(e=t.prototype.getActiveTextures.call(this)).concat.apply(e,this.subMaterials.map((function(e){return e.getActiveTextures()})));var e},i.prototype.getClassName=function(){return"MultiMaterial"},i.prototype.isReadyForSubMesh=function(e,t,i){for(var r=0;r=0&&r.multiMaterials.splice(n,1),t.prototype.dispose.call(this,e,i)}},i})(e.Material);e.MultiMaterial=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this._offsetX=null,this._offsetY=null,this._pointerCount=0,this._pointerPressed=[],this.touchAngularSensibility=2e5,this.touchMoveSensibility=250}return t.prototype.attachControl=function(t,i){var r,n=this;void 0===this._pointerInput&&(this._onLostFocus=function(e){n._offsetX=null,n._offsetY=null},this._pointerInput=function(t,o){var s=t.event;if("mouse"!==s.pointerType)if(t.type===e.PointerEventTypes.POINTERDOWN){if(i||s.preventDefault(),n._pointerPressed.push(s.pointerId),1!==n._pointerPressed.length)return;r={x:s.clientX,y:s.clientY}}else if(t.type===e.PointerEventTypes.POINTERUP){i||s.preventDefault();var a=n._pointerPressed.indexOf(s.pointerId);if(-1===a)return;if(n._pointerPressed.splice(a,1),0!=a)return;r=null,n._offsetX=null,n._offsetY=null}else if(t.type===e.PointerEventTypes.POINTERMOVE){if(i||s.preventDefault(),!r)return;var a=n._pointerPressed.indexOf(s.pointerId);if(0!=a)return;n._offsetX=s.clientX-r.x,n._offsetY=-(s.clientY-r.y)}}),this._observer=this.camera.getScene().onPointerObservable.add(this._pointerInput,e.PointerEventTypes.POINTERDOWN|e.PointerEventTypes.POINTERUP|e.PointerEventTypes.POINTERMOVE),t.addEventListener("blur",this._onLostFocus)},t.prototype.detachControl=function(e){this._pointerInput&&e&&(this.camera.getScene().onPointerObservable.remove(this._observer),this._observer=null,e.removeEventListener("blur",this._onLostFocus),this._onLostFocus=null,this._pointerPressed=[],this._offsetX=null,this._offsetY=null,this._pointerCount=0)},t.prototype.checkInputs=function(){if(this._offsetX){var t=this.camera;if(t.cameraRotation.y+=this._offsetX/this.touchAngularSensibility,this._pointerPressed.length>1)t.cameraRotation.x+=-this._offsetY/this.touchAngularSensibility;else{var i=t._computeLocalCameraSpeed(),r=new e.Vector3(0,0,i*this._offsetY/this.touchMoveSensibility);e.Matrix.RotationYawPitchRollToRef(t.rotation.y,t.rotation.x,0,t._cameraRotationMatrix),t.cameraDirection.addInPlace(e.Vector3.TransformCoordinates(r,t._cameraRotationMatrix))}}},t.prototype.getClassName=function(){return"FreeCameraTouchInput"},t.prototype.getSimpleName=function(){return"touch"},t})();__decorate([e.serialize()],t.prototype,"touchAngularSensibility",void 0),__decorate([e.serialize()],t.prototype,"touchMoveSensibility",void 0),e.FreeCameraTouchInput=t,e.CameraInputTypes.FreeCameraTouchInput=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(e){function t(t,i,r){var n=e.call(this,t,i,r)||this;return n.inputs.addTouch(),n._setupInputs(),n}return __extends(t,e),Object.defineProperty(t.prototype,"touchAngularSensibility",{get:function(){var e=this.inputs.attached.touch;if(e)return e.touchAngularSensibility},set:function(e){var t=this.inputs.attached.touch;t&&(t.touchAngularSensibility=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"touchMoveSensibility",{get:function(){var e=this.inputs.attached.touch;if(e)return e.touchMoveSensibility},set:function(e){var t=this.inputs.attached.touch;t&&(t.touchMoveSensibility=e)},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return"TouchCamera"},t.prototype._setupInputs=function(){var e=this.inputs.attached.mouse;e&&(e.touchEnabled=!1)},t})(e.FreeCamera);e.TouchCamera=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o,s,a,h){void 0===a&&(a=!0),void 0===h&&(h=!1);var l=t.call(this,null,o,!a)||this;l.isCube=h,l.isEnabled=!0,l._currentRefreshId=-1,l._refreshRate=1,l._vertexBuffers={},l._uniforms=new Array,l._samplers=new Array,l._textures=new Array,l._floats=new Array,l._floatsArrays={},l._colors3=new Array,l._colors4=new Array,l._vectors2=new Array,l._vectors3=new Array,l._matrices=new Array,l._fallbackTextureUsed=!1,o._proceduralTextures.push(l),l.name=i,l.isRenderTarget=!0,l._size=r,l._generateMipMaps=a,l.setFragment(n),l._fallbackTexture=s;var c=o.getEngine();h?(l._texture=c.createRenderTargetCubeTexture(r,{generateMipMaps:a}),l.setFloat("face",0)):l._texture=c.createRenderTargetTexture(r,a);var u=[];u.push(1,1),u.push(-1,1),u.push(-1,-1),u.push(1,-1),l._vertexBuffers[e.VertexBuffer.PositionKind]=new e.VertexBuffer(c,u,e.VertexBuffer.PositionKind,!1,!1,2);var f=[];return f.push(0),f.push(1),f.push(2),f.push(0),f.push(2),f.push(3),l._indexBuffer=c.createIndexBuffer(f),l}return __extends(i,t),i.prototype.reset=function(){if(void 0!==this._effect){this.getScene().getEngine()._releaseEffect(this._effect)}},i.prototype.isReady=function(){var t,i=this,r=this.getScene().getEngine();return!!this._fragment&&(!!this._fallbackTextureUsed||(t=void 0!==this._fragment.fragmentElement?{vertex:"procedural",fragmentElement:this._fragment.fragmentElement}:{vertex:"procedural",fragment:this._fragment},this._effect=r.createEffect(t,[e.VertexBuffer.PositionKind],this._uniforms,this._samplers,"",null,null,(function(){i.releaseInternalTexture(),i._fallbackTexture&&(i._texture=i._fallbackTexture._texture,i._texture.references++),i._fallbackTextureUsed=!0})),this._effect.isReady()))},i.prototype.resetRefreshCounter=function(){this._currentRefreshId=-1},i.prototype.setFragment=function(e){this._fragment=e},Object.defineProperty(i.prototype,"refreshRate",{get:function(){return this._refreshRate},set:function(e){this._refreshRate=e,this.resetRefreshCounter()},enumerable:!0,configurable:!0}),i.prototype._shouldRender=function(){return!!(this.isEnabled&&this.isReady()&&this._texture)&&(!this._fallbackTextureUsed&&(-1===this._currentRefreshId?(this._currentRefreshId=1,!0):this.refreshRate===this._currentRefreshId?(this._currentRefreshId=1,!0):(this._currentRefreshId++,!1)))},i.prototype.getRenderSize=function(){return this._size},i.prototype.resize=function(e,t){this._fallbackTextureUsed||(this.releaseInternalTexture(),this._texture=this.getScene().getEngine().createRenderTargetTexture(e,t))},i.prototype._checkUniform=function(e){-1===this._uniforms.indexOf(e)&&this._uniforms.push(e)},i.prototype.setTexture=function(e,t){return-1===this._samplers.indexOf(e)&&this._samplers.push(e),this._textures[e]=t,this},i.prototype.setFloat=function(e,t){return this._checkUniform(e),this._floats[e]=t,this},i.prototype.setFloats=function(e,t){return this._checkUniform(e),this._floatsArrays[e]=t,this},i.prototype.setColor3=function(e,t){return this._checkUniform(e),this._colors3[e]=t,this},i.prototype.setColor4=function(e,t){return this._checkUniform(e),this._colors4[e]=t,this},i.prototype.setVector2=function(e,t){return this._checkUniform(e),this._vectors2[e]=t,this},i.prototype.setVector3=function(e,t){return this._checkUniform(e),this._vectors3[e]=t,this},i.prototype.setMatrix=function(e,t){return this._checkUniform(e),this._matrices[e]=t,this},i.prototype.render=function(e){var t=this.getScene(),i=t.getEngine();i.enableEffect(this._effect),i.setState(!1);for(var r in this._textures)this._effect.setTexture(r,this._textures[r]);for(r in this._floats)this._effect.setFloat(r,this._floats[r]);for(r in this._floatsArrays)this._effect.setArray(r,this._floatsArrays[r]);for(r in this._colors3)this._effect.setColor3(r,this._colors3[r]);for(r in this._colors4){var n=this._colors4[r];this._effect.setFloat4(r,n.r,n.g,n.b,n.a)}for(r in this._vectors2)this._effect.setVector2(r,this._vectors2[r]);for(r in this._vectors3)this._effect.setVector3(r,this._vectors3[r]);for(r in this._matrices)this._effect.setMatrix(r,this._matrices[r]);if(this.isCube)for(var o=0;o<6;o++)i.bindFramebuffer(this._texture,o),i.bindBuffers(this._vertexBuffers,this._indexBuffer,this._effect),this._effect.setFloat("face",o),i.clear(t.clearColor,!0,!0,!0),i.draw(!0,0,6),5===o&&i.generateMipMapsForCubemap(this._texture);else i.bindFramebuffer(this._texture),i.bindBuffers(this._vertexBuffers,this._indexBuffer,this._effect),i.clear(t.clearColor,!0,!0,!0),i.draw(!0,0,6);i.unBindFramebuffer(this._texture,this.isCube),this.onGenerated&&this.onGenerated()},i.prototype.clone=function(){var e=this.getSize(),t=new i(this.name,e.width,this._fragment,this.getScene(),this._fallbackTexture,this._generateMipMaps);return t.hasAlpha=this.hasAlpha,t.level=this.level,t.coordinatesMode=this.coordinatesMode,t},i.prototype.dispose=function(){var i=this.getScene()._proceduralTextures.indexOf(this);i>=0&&this.getScene()._proceduralTextures.splice(i,1);var r=this._vertexBuffers[e.VertexBuffer.PositionKind];r&&(r.dispose(),this._vertexBuffers[e.VertexBuffer.PositionKind]=null),this._indexBuffer&&this.getScene().getEngine()._releaseBuffer(this._indexBuffer)&&(this._indexBuffer=null),t.prototype.dispose.call(this)},i})(e.Texture);e.ProceduralTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e,i,r,n,o,s){var a=t.call(this,e,r,null,n,o,s)||this;return a._animate=!0,a._time=0,a._texturePath=i,a.loadJson(i),a.refreshRate=1,a}return __extends(i,t),i.prototype.loadJson=function(t){function i(){e.Tools.Log("No config file found in "+t+" trying to use ShadersStore or DOM element");try{n.setFragment(n._texturePath)}catch(t){e.Tools.Error("No json or ShaderStore or DOM element found for CustomProceduralTexture")}}var r=this,n=this,o=t+"/config.json",s=new XMLHttpRequest;s.open("GET",o,!0),s.addEventListener("load",(function(){if(200===s.status||e.Tools.ValidateXHRData(s,1))try{r._config=JSON.parse(s.response),r.updateShaderUniforms(),r.updateTextures(),r.setFragment(r._texturePath+"/custom"),r._animate=r._config.animate,r.refreshRate=r._config.refreshrate}catch(e){i()}else i()}),!1),s.addEventListener("error",(function(){i()}),!1);try{s.send()}catch(t){e.Tools.Error("CustomProceduralTexture: Error on XHR send request.")}},i.prototype.isReady=function(){if(!t.prototype.isReady.call(this))return!1;for(var e in this._textures){if(!this._textures[e].isReady())return!1}return!0},i.prototype.render=function(e){this._animate&&(this._time+=.03*this.getScene().getAnimationRatio(),this.updateShaderUniforms()),t.prototype.render.call(this,e)},i.prototype.updateTextures=function(){for(var t=0;t.005?0+r:0,i.y=Math.abs(n)>.005?0+n:0;var o=this.gamepad.rightStick;if(o){var s=o.x/this.gamepadAngularSensibility,a=o.y/this.gamepadAngularSensibility;o.x=Math.abs(s)>.001?0+s:0,o.y=Math.abs(a)>.001?0+a:0}else o={x:0,y:0};t.rotationQuaternion?t.rotationQuaternion.toRotationMatrix(this._cameraTransform):e.Matrix.RotationYawPitchRollToRef(t.rotation.y,t.rotation.x,0,this._cameraTransform);var h=50*t._computeLocalCameraSpeed();this._vector3.copyFromFloats(i.x*h,0,-i.y*h),e.Vector3.TransformCoordinatesToRef(this._vector3,this._cameraTransform,this._deltaTransform),t.cameraDirection.addInPlace(this._deltaTransform),this._vector2.copyFromFloats(o.y,o.x),t.cameraRotation.addInPlace(this._vector2)}},t.prototype._onNewGameConnected=function(t){t.type!==e.Gamepad.POSE_ENABLED&&(this.gamepad&&t.type!==e.Gamepad.XBOX||(this.gamepad=t))},t.prototype.getClassName=function(){return"FreeCameraGamepadInput"},t.prototype.getSimpleName=function(){return"gamepad"},t})();__decorate([e.serialize()],t.prototype,"gamepadAngularSensibility",void 0),__decorate([e.serialize()],t.prototype,"gamepadMoveSensibility",void 0),e.FreeCameraGamepadInput=t,e.CameraInputTypes.FreeCameraGamepadInput=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this.gamepadRotationSensibility=80,this.gamepadMoveSensibility=40}return t.prototype.attachControl=function(t,i){var r=this;this._gamepads=new e.Gamepads(function(e){r._onNewGameConnected(e)})},t.prototype.detachControl=function(e){this._gamepads&&this._gamepads.dispose(),this.gamepad=null},t.prototype.checkInputs=function(){if(this.gamepad){var e=this.camera,t=this.gamepad.rightStick;if(t){if(0!=t.x){var i=t.x/this.gamepadRotationSensibility;0!=i&&Math.abs(i)>.005&&(e.inertialAlphaOffset+=i)}if(0!=t.y){var r=t.y/this.gamepadRotationSensibility;0!=r&&Math.abs(r)>.005&&(e.inertialBetaOffset+=r)}}var n=this.gamepad.leftStick;if(n&&0!=n.y){var o=n.y/this.gamepadMoveSensibility;0!=o&&Math.abs(o)>.005&&(this.camera.inertialRadiusOffset-=o)}}},t.prototype._onNewGameConnected=function(t){t.type!==e.Gamepad.POSE_ENABLED&&(this.gamepad&&t.type!==e.Gamepad.XBOX||(this.gamepad=t))},t.prototype.getClassName=function(){return"ArcRotateCameraGamepadInput"},t.prototype.getSimpleName=function(){return"gamepad"},t})();__decorate([e.serialize()],t.prototype,"gamepadRotationSensibility",void 0),__decorate([e.serialize()],t.prototype,"gamepadMoveSensibility",void 0),e.ArcRotateCameraGamepadInput=t,e.CameraInputTypes.ArcRotateCameraGamepadInput=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e,t){var i=this;this.babylonGamepads=[],this.oneGamepadConnected=!1,this.isMonitoring=!1,this.gamepadEventSupported="GamepadEvent"in window,this.gamepadSupport=navigator.getGamepads||navigator.webkitGetGamepads||navigator.msGetGamepads||navigator.webkitGamepads,this._callbackGamepadConnected=e,this._callbackGamepadDisconnected=t,this.gamepadSupport&&(this._updateGamepadObjects(),this.babylonGamepads.length&&this._startMonitoringGamepads(),this.gamepadEventSupported?(this._onGamepadConnectedEvent=function(e){i._onGamepadConnected(e.gamepad)},this._onGamepadDisonnectedEvent=function(e){i._onGamepadDisconnected(e.gamepad)},window.addEventListener("gamepadconnected",this._onGamepadConnectedEvent,!1),window.addEventListener("gamepaddisconnected",this._onGamepadDisonnectedEvent,!1)):this._startMonitoringGamepads())}return t.prototype.dispose=function(){this._onGamepadConnectedEvent&&(window.removeEventListener("gamepadconnected",this._onGamepadConnectedEvent,!1),window.removeEventListener("gamepaddisconnected",this._onGamepadDisonnectedEvent,!1), +this._onGamepadConnectedEvent=null,this._onGamepadDisonnectedEvent=null),this.oneGamepadConnected=!1,this._stopMonitoringGamepads(),this.babylonGamepads=[]},t.prototype._onGamepadConnected=function(e){if(!(e.index in this.babylonGamepads)){var t=this._addNewGamepad(e);this._callbackGamepadConnected&&this._callbackGamepadConnected(t),this._startMonitoringGamepads()}},t.prototype._addNewGamepad=function(t){this.oneGamepadConnected||(this.oneGamepadConnected=!0);var i,r=-1!==t.id.search("Xbox One");return i=r||-1!==t.id.search("Xbox 360")||-1!==t.id.search("xinput")?new a(t.id,t.index,t,r):t.pose?e.PoseEnabledControllerHelper.InitiateController(t):new n(t.id,t.index,t),this.babylonGamepads.push(i),i},t.prototype._onGamepadDisconnected=function(e){for(var t in this.babylonGamepads)if(this.babylonGamepads[t].index==e.index){this.babylonGamepads.splice(+t,1);break}0==this.babylonGamepads.length&&(this._stopMonitoringGamepads(),this.oneGamepadConnected=!1),this._callbackGamepadDisconnected&&this._callbackGamepadDisconnected(e)},t.prototype._startMonitoringGamepads=function(){this.isMonitoring||(this.isMonitoring=!0,this._checkGamepadsStatus())},t.prototype._stopMonitoringGamepads=function(){this.isMonitoring=!1},t.prototype._checkGamepadsStatus=function(){var e=this;this._updateGamepadObjects();for(var t in this.babylonGamepads)this.babylonGamepads[t].update();this.isMonitoring&&(window.requestAnimationFrame?window.requestAnimationFrame((function(){e._checkGamepadsStatus()})):window.mozRequestAnimationFrame?window.mozRequestAnimationFrame((function(){e._checkGamepadsStatus()})):window.webkitRequestAnimationFrame&&window.webkitRequestAnimationFrame((function(){e._checkGamepadsStatus()})))},t.prototype._updateGamepadObjects=function(){for(var e=navigator.getGamepads?navigator.getGamepads():navigator.webkitGetGamepads?navigator.webkitGetGamepads():[],t=0;t=2&&(this._leftStick={x:this.browserGamepad.axes[this._leftStickAxisX],y:this.browserGamepad.axes[this._leftStickAxisY]}),this.browserGamepad.axes.length>=4&&(this._rightStick={x:this.browserGamepad.axes[this._rightStickAxisX],y:this.browserGamepad.axes[this._rightStickAxisY]})}return e.prototype.onleftstickchanged=function(e){this._onleftstickchanged=e},e.prototype.onrightstickchanged=function(e){this._onrightstickchanged=e},Object.defineProperty(e.prototype,"leftStick",{get:function(){return this._leftStick},set:function(e){!this._onleftstickchanged||this._leftStick.x===e.x&&this._leftStick.y===e.y||this._onleftstickchanged(e),this._leftStick=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rightStick",{get:function(){return this._rightStick},set:function(e){!this._onrightstickchanged||this._rightStick.x===e.x&&this._rightStick.y===e.y||this._onrightstickchanged(e),this._rightStick=e},enumerable:!0,configurable:!0}),e.prototype.update=function(){this._leftStick&&(this.leftStick={x:this.browserGamepad.axes[this._leftStickAxisX],y:this.browserGamepad.axes[this._leftStickAxisY]}),this._rightStick&&(this.rightStick={x:this.browserGamepad.axes[this._rightStickAxisX],y:this.browserGamepad.axes[this._rightStickAxisY]})},e})();r.GAMEPAD=0,r.GENERIC=1,r.XBOX=2,r.POSE_ENABLED=3,e.Gamepad=r;var n=(function(e){function t(t,i,n){var o=e.call(this,t,i,n)||this;return o.type=r.GENERIC,o._buttons=new Array(n.buttons.length),o}return __extends(t,e),t.prototype.onbuttondown=function(e){this._onbuttondown=e},t.prototype.onbuttonup=function(e){this._onbuttonup=e},t.prototype._setButtonValue=function(e,t,i){return e!==t&&(this._onbuttondown&&1===e&&this._onbuttondown(i),this._onbuttonup&&0===e&&this._onbuttonup(i)),e},t.prototype.update=function(){e.prototype.update.call(this);for(var t=0;tthis.maxCameraSpeed||u<-this.maxCameraSpeed)&&(u=u<1?-this.maxCameraSpeed:this.maxCameraSpeed),(f>this.maxCameraSpeed||f<-this.maxCameraSpeed)&&(f=f<1?-this.maxCameraSpeed:this.maxCameraSpeed),(d>this.maxCameraSpeed||d<-this.maxCameraSpeed)&&(d=d<1?-this.maxCameraSpeed:this.maxCameraSpeed),this.position=new e.Vector3(this.position.x+u,this.position.y+f,this.position.z+d),this.setTarget(o)}},i.prototype._checkInputs=function(){t.prototype._checkInputs.call(this),this.follow(this.lockedTarget)},i.prototype.getClassName=function(){return"FollowCamera"},i})(e.TargetCamera);__decorate([e.serialize()],t.prototype,"radius",void 0),__decorate([e.serialize()],t.prototype,"rotationOffset",void 0),__decorate([e.serialize()],t.prototype,"heightOffset",void 0),__decorate([e.serialize()],t.prototype,"cameraAcceleration",void 0),__decorate([e.serialize()],t.prototype,"maxCameraSpeed",void 0),__decorate([e.serializeAsMeshReference("lockedTargetId")],t.prototype,"lockedTarget",void 0),e.FollowCamera=t;var i=(function(t){function i(i,r,n,o,s,a){var h=t.call(this,i,e.Vector3.Zero(),a)||this;return h.alpha=r,h.beta=n,h.radius=o,h.target=s,h._cartesianCoordinates=e.Vector3.Zero(),h.follow(),h}return __extends(i,t),i.prototype.follow=function(){this._cartesianCoordinates.x=this.radius*Math.cos(this.alpha)*Math.cos(this.beta),this._cartesianCoordinates.y=this.radius*Math.sin(this.beta),this._cartesianCoordinates.z=this.radius*Math.sin(this.alpha)*Math.cos(this.beta);var e=this.target.getAbsolutePosition();this.position=e.add(this._cartesianCoordinates),this.setTarget(e)},i.prototype._checkInputs=function(){t.prototype._checkInputs.call(this),this.follow()},i.prototype.getClassName=function(){return"ArcFollowCamera"},i})(e.TargetCamera);e.ArcFollowCamera=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(e){function t(t,i,r){var n=e.call(this,t,i,r)||this;return n.inputs.addGamepad(),n}return __extends(t,e),Object.defineProperty(t.prototype,"gamepadAngularSensibility",{get:function(){var e=this.inputs.attached.gamepad;if(e)return e.gamepadAngularSensibility},set:function(e){var t=this.inputs.attached.gamepad;t&&(t.gamepadAngularSensibility=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"gamepadMoveSensibility",{get:function(){var e=this.inputs.attached.gamepad;if(e)return e.gamepadMoveSensibility},set:function(e){var t=this.inputs.attached.gamepad;t&&(t.gamepadMoveSensibility=e)},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return"UniversalCamera"},t})(e.TouchCamera);e.UniversalCamera=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(e){function t(t,i,r){return e.call(this,t,i,r)||this}return __extends(t,e),Object.defineProperty(t.prototype,"gamepadAngularSensibility",{get:function(){var e=this.inputs.attached.gamepad;if(e)return e.gamepadAngularSensibility},set:function(e){var t=this.inputs.attached.gamepad;t&&(t.gamepadAngularSensibility=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"gamepadMoveSensibility",{get:function(){var e=this.inputs.attached.gamepad;if(e)return e.gamepadMoveSensibility},set:function(e){var t=this.inputs.attached.gamepad;t&&(t.gamepadMoveSensibility=e)},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return"GamepadCamera"},t})(e.UniversalCamera);e.GamepadCamera=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(){this._renderPipelines={}}return e.prototype.addPipeline=function(e){this._renderPipelines[e._name]=e},e.prototype.attachCamerasToRenderPipeline=function(e,t,i){var r=this._renderPipelines[e];r&&r._attachCameras(t,i)},e.prototype.detachCamerasFromRenderPipeline=function(e,t){var i=this._renderPipelines[e];i&&i._detachCameras(t)},e.prototype.enableEffectInPipeline=function(e,t,i){var r=this._renderPipelines[e];r&&r._enableEffect(t,i)},e.prototype.disableEffectInPipeline=function(e,t,i){var r=this._renderPipelines[e];r&&r._disableEffect(t,i)},e.prototype.enableDisplayOnlyPassInPipeline=function(e,t,i){var r=this._renderPipelines[e];r&&r._enableDisplayOnlyPass(t,i)},e.prototype.disableDisplayOnlyPassInPipeline=function(e,t){var i=this._renderPipelines[e];i&&i._disableDisplayOnlyPass(t)},e.prototype.update=function(){for(var e in this._renderPipelines){var t=this._renderPipelines[e];t.isSupported?t._update():(t.dispose(),delete this._renderPipelines[e])}},e})();e.PostProcessRenderPipelineManager=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t,i,r,n,o,s){this._enabled=!0,this._refCount=0,this._name=i,this._renderTexture=new e.RenderTargetTexture(i,r,t),this.setRenderList(n),this._renderTexture.onBeforeRenderObservable.add(o),this._renderTexture.onAfterRenderObservable.add(s),this._scene=t,this._renderList=n}return t.prototype._incRefCount=function(){return 0===this._refCount&&this._scene.customRenderTargets.push(this._renderTexture),++this._refCount},t.prototype._decRefCount=function(){return this._refCount--,this._refCount<=0&&this._scene.customRenderTargets.splice(this._scene.customRenderTargets.indexOf(this._renderTexture),1),this._refCount},t.prototype._update=function(){this.setRenderList(this._renderList)},t.prototype.setRenderList=function(e){this._renderTexture.renderList=e},t.prototype.getRenderTexture=function(){return this._renderTexture},t})();e.PostProcessRenderPass=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e,t,i,r){this._engine=e,this._name=t,this._singleInstance=r||!0,this._getPostProcess=i,this._cameras=[],this._indicesForCamera=[],this._postProcesses={},this._renderPasses={},this._renderEffectAsPasses={}}return Object.defineProperty(t.prototype,"isSupported",{get:function(){for(var e in this._postProcesses)if(!this._postProcesses[e].isSupported)return!1;return!0},enumerable:!0,configurable:!0}),t.prototype._update=function(){for(var e in this._renderPasses)this._renderPasses[e]._update()},t.prototype.addPass=function(e){this._renderPasses[e._name]=e,this._linkParameters()},t.prototype.removePass=function(e){delete this._renderPasses[e._name],this._linkParameters()},t.prototype.addRenderEffectAsPass=function(e){this._renderEffectAsPasses[e._name]=e,this._linkParameters()},t.prototype.getPass=function(e){for(var t in this._renderPasses)if(t===e)return this._renderPasses[e]},t.prototype.emptyPasses=function(){this._renderPasses={},this._linkParameters()},t.prototype._attachCameras=function(t){for(var i,r=e.Tools.MakeArray(t||this._cameras),n=0;n4&&(o.push(e.VertexBuffer.MatricesIndicesExtraKind),o.push(e.VertexBuffer.MatricesWeightsExtraKind)),n.push("#define NUM_BONE_INFLUENCERS "+s.numBoneInfluencers),n.push("#define BonesPerMesh "+(s.skeleton.bones.length+1))):n.push("#define NUM_BONE_INFLUENCERS 0"),i&&(n.push("#define INSTANCES"),o.push("world0"),o.push("world1"),o.push("world2"),o.push("world3"));var a=n.join("\n");return this._cachedDefines!==a&&(this._cachedDefines=a,this._effect=this._scene.getEngine().createEffect("depth",o,["world","mBones","viewProjection","diffuseMatrix","depthValues"],["diffuseSampler"],a)),this._effect.isReady()},t.prototype.getDepthMap=function(){return this._depthMap},t.prototype.dispose=function(){this._depthMap.dispose()},t})();e.DepthRenderer=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o){var s=t.call(this,r.getEngine(),i)||this;s.SSAOOriginalSceneColorEffect="SSAOOriginalSceneColorEffect",s.SSAORenderEffect="SSAORenderEffect",s.SSAOBlurHRenderEffect="SSAOBlurHRenderEffect",s.SSAOBlurVRenderEffect="SSAOBlurVRenderEffect",s.SSAOCombineRenderEffect="SSAOCombineRenderEffect",s.totalStrength=1,s.radius=1e-4,s.area=.0075,s.fallOff=1e-6,s.base=.5,s._firstUpdate=!0,s._scene=r,s._createRandomTexture(),s._depthTexture=r.enableDepthRenderer().getDepthMap();var a=n.ssaoRatio||n,h=n.combineRatio||n;return s._ratio={ssaoRatio:a,combineRatio:h},s._originalColorPostProcess=new e.PassPostProcess("SSAOOriginalSceneColor",h,null,e.Texture.BILINEAR_SAMPLINGMODE,r.getEngine(),!1),s._createSSAOPostProcess(a),s._createBlurPostProcess(a),s._createSSAOCombinePostProcess(h),s.addEffect(new e.PostProcessRenderEffect(r.getEngine(),s.SSAOOriginalSceneColorEffect,function(){return s._originalColorPostProcess},!0)),s.addEffect(new e.PostProcessRenderEffect(r.getEngine(),s.SSAORenderEffect,function(){return s._ssaoPostProcess},!0)),s.addEffect(new e.PostProcessRenderEffect(r.getEngine(),s.SSAOBlurHRenderEffect,function(){return s._blurHPostProcess},!0)),s.addEffect(new e.PostProcessRenderEffect(r.getEngine(),s.SSAOBlurVRenderEffect,function(){return s._blurVPostProcess},!0)),s.addEffect(new e.PostProcessRenderEffect(r.getEngine(),s.SSAOCombineRenderEffect,function(){return s._ssaoCombinePostProcess},!0)),r.postProcessRenderPipelineManager.addPipeline(s),o&&r.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(i,o),s}return __extends(i,t),i.prototype.dispose=function(e){void 0===e&&(e=!1);for(var i=0;i1},enumerable:!0,configurable:!0}),i.prototype.dispose=function(e){void 0===e&&(e=!1);for(var i=0;i=0;a--){var o=Math.pow(3,a),h="#define LUMINANCE_DOWN_SAMPLE\n";0===a&&(h+="#define FINAL_DOWN_SAMPLER");var l=new e.PostProcess("HDRLuminanceDownSample"+a,"standard",["dsOffsets","halfDestPixelSize"],[],{width:o,height:o},null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,h,r);this.luminanceDownSamplePostProcesses.push(l)}var c=this.luminancePostProcess;this.luminanceDownSamplePostProcesses.forEach((function(i,r){var o=new Array(18);i.onApply=function(e){for(var t=0,s=-1;s<2;s++)for(var a=-1;a<2;a++)o[t]=s/c.width,o[t+1]=a/c.height,t+=2;e.setArray2("dsOffsets",o),e.setFloat("halfDestPixelSize",.5/c.width),c=r===n.luminanceDownSamplePostProcesses.length-1?n.luminancePostProcess:i},r===n.luminanceDownSamplePostProcesses.length-1&&(i.onAfterRender=function(i){var r=t.getEngine().readPixels(0,0,1,1),o=new e.Vector4(1/16581375,1/65025,1/255,1);n._hdrCurrentLuminance=(r[0]*o.x+r[1]*o.y+r[2]*o.z+r[3]*o.w)/100}),n.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRLuminanceDownSample"+r,function(){return i},!0))}))},i.prototype._createHdrPostProcess=function(t,i){var r=this;this.hdrPostProcess=new e.PostProcess("HDR","standard",["averageLuminance"],["textureAdderSampler"],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,"#define HDR",e.Engine.TEXTURETYPE_UNSIGNED_INT);var n=1,o=0,s=0;this.hdrPostProcess.onApply=function(i){if(i.setTextureFromPostProcess("textureAdderSampler",r._currentDepthOfFieldSource),o+=t.getEngine().getDeltaTime(),n<0)n=r._hdrCurrentLuminance;else{var a=(s-o)/1e3;r._hdrCurrentLuminancen-r.hdrIncreaseRate*a?n-=r.hdrIncreaseRate*a:n=r._hdrCurrentLuminance}n=e.Scalar.Clamp(n,r.hdrMinimumLuminance,1e20),i.setFloat("averageLuminance",n),s=o,r._currentDepthOfFieldSource=r.hdrFinalPostProcess},this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDR",function(){return r.hdrPostProcess},!0))},i.prototype._createLensFlarePostProcess=function(t,i){var r=this;this.lensFlarePostProcess=new e.PostProcess("HDRLensFlare","standard",["strength","ghostDispersal","haloWidth","resolution","distortionStrength"],["lensColorSampler"],i/2,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,"#define LENS_FLARE",e.Engine.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRLensFlare",function(){return r.lensFlarePostProcess},!0)),this._createBlurPostProcesses(t,i/4,2),this.lensFlareComposePostProcess=new e.PostProcess("HDRLensFlareCompose","standard",["lensStarMatrix"],["otherSampler","lensDirtSampler","lensStarSampler"],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,"#define LENS_FLARE_COMPOSE",e.Engine.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRLensFlareCompose",function(){return r.lensFlareComposePostProcess},!0));var n=new e.Vector2(0,0);this.lensFlarePostProcess.onApply=function(e){e.setTextureFromPostProcess("textureSampler",r._bloomEnabled?r.blurHPostProcesses[0]:r.originalPostProcess),e.setTexture("lensColorSampler",r.lensColorTexture),e.setFloat("strength",r.lensFlareStrength),e.setFloat("ghostDispersal",r.lensFlareGhostDispersal),e.setFloat("haloWidth",r.lensFlareHaloWidth),n.x=r.lensFlarePostProcess.width,n.y=r.lensFlarePostProcess.height,e.setVector2("resolution",n),e.setFloat("distortionStrength",r.lensFlareDistortionStrength)};var o=e.Matrix.FromValues(2,0,-1,0,0,2,-1,0,0,0,1,0,0,0,0,1),s=e.Matrix.FromValues(.5,0,.5,0,0,.5,.5,0,0,0,1,0,0,0,0,1);this.lensFlareComposePostProcess.onApply=function(t){t.setTextureFromPostProcess("otherSampler",r._currentDepthOfFieldSource),t.setTexture("lensDirtSampler",r.lensFlareDirtTexture),t.setTexture("lensStarSampler",r.lensStarTexture);var i=r._scene.activeCamera.getViewMatrix().getRow(0),n=r._scene.activeCamera.getViewMatrix().getRow(2),a=e.Vector3.Dot(i.toVector3(),new e.Vector3(1,0,0))+e.Vector3.Dot(n.toVector3(),new e.Vector3(0,0,1));a*=4;var h=e.Matrix.FromValues(.5*Math.cos(a),-Math.sin(a),0,0,Math.sin(a),.5*Math.cos(a),0,0,0,0,1,0,0,0,0,1),l=s.multiply(h).multiply(o);t.setMatrix("lensStarMatrix",l),r._currentDepthOfFieldSource=r.lensFlareFinalPostProcess}},i.prototype._createDepthOfFieldPostProcess=function(t,i){var r=this;this.depthOfFieldPostProcess=new e.PostProcess("HDRDepthOfField","standard",["distance"],["otherSampler","depthSampler"],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,"#define DEPTH_OF_FIELD",e.Engine.TEXTURETYPE_UNSIGNED_INT),this.depthOfFieldPostProcess.onApply=function(e){e.setTextureFromPostProcess("otherSampler",r._currentDepthOfFieldSource),e.setTexture("depthSampler",r._getDepthTexture()),e.setFloat("distance",r.depthOfFieldDistance)},this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRDepthOfField",function(){return r.depthOfFieldPostProcess},!0))},i.prototype._createMotionBlurPostProcess=function(t,i){var r=this;this.motionBlurPostProcess=new e.PostProcess("HDRMotionBlur","standard",["inverseViewProjection","prevViewProjection","screenSize","motionScale","motionStrength"],["depthSampler"],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,"#define MOTION_BLUR\n#define MAX_MOTION_SAMPLES "+this.motionBlurSamples.toFixed(1),e.Engine.TEXTURETYPE_UNSIGNED_INT);var n=0,o=e.Matrix.Identity(),s=e.Matrix.Identity(),a=e.Matrix.Identity(),h=e.Vector2.Zero();this.motionBlurPostProcess.onApply=function(e){a=t.getProjectionMatrix().multiply(t.getViewMatrix()),a.invertToRef(s),e.setMatrix("inverseViewProjection",s),e.setMatrix("prevViewProjection",o),o=a,h.x=r.motionBlurPostProcess.width,h.y=r.motionBlurPostProcess.height,e.setVector2("screenSize",h),n=t.getEngine().getFps()/60,e.setFloat("motionScale",n),e.setFloat("motionStrength",r.motionStrength),e.setTexture("depthSampler",r._getDepthTexture())},this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRMotionBlur",function(){return r.motionBlurPostProcess},!0))},i.prototype._getDepthTexture=function(){var e=this._scene.enableGeometryBufferRenderer();return e?e.getGBuffer().textures[0]:this._scene.enableDepthRenderer().getDepthMap()},i.prototype._disposePostProcesses=function(){for(var e=0;e4&&(o.push(e.VertexBuffer.MatricesIndicesExtraKind),o.push(e.VertexBuffer.MatricesWeightsExtraKind)),n.push("#define NUM_BONE_INFLUENCERS "+s.numBoneInfluencers),n.push("#define BonesPerMesh "+(s.skeleton.bones.length+1))):n.push("#define NUM_BONE_INFLUENCERS 0"),i&&(n.push("#define INSTANCES"),o.push("world0"),o.push("world1"),o.push("world2"),o.push("world3"));var a=n.join("\n");return this._cachedDefines!==a&&(this._cachedDefines=a,this._effect=this._scene.getEngine().createEffect("geometry",o,["world","mBones","viewProjection","diffuseMatrix","view"],["diffuseSampler"],a)),this._effect.isReady()},t.prototype.getGBuffer=function(){return this._multiRenderTarget},t.prototype.dispose=function(){this.getGBuffer().dispose()},t.prototype._createRenderTargets=function(){var t=this,i=this._scene.getEngine(),r=this._enablePosition?3:2;if(this._multiRenderTarget=new e.MultiRenderTarget("gBuffer",{width:i.getRenderWidth()*this._ratio,height:i.getRenderHeight()*this._ratio},r,this._scene,{generateMipMaps:!1,generateDepthTexture:!0}),!this.isSupported)return null;this._multiRenderTarget.wrapU=e.Texture.CLAMP_ADDRESSMODE,this._multiRenderTarget.wrapV=e.Texture.CLAMP_ADDRESSMODE,this._multiRenderTarget.refreshRate=1,this._multiRenderTarget.renderParticles=!1,this._multiRenderTarget.renderList=null,this._multiRenderTarget.onClearObservable.add((function(t){t.clear(new e.Color4(0,0,0,1),!0,!0,!0)}));var n=function(i){var r=i.getRenderingMesh(),n=t._scene,o=n.getEngine();o.setState(i.getMaterial().backFaceCulling);var s=r._getInstancesRenderList(i._id);if(!s.mustReturn){var a=o.getCaps().instancedArrays&&null!==s.visibleInstances[i._id];if(t.isReady(i,a)){o.enableEffect(t._effect),r._bind(i,t._effect,e.Material.TriangleFillMode);var h=i.getMaterial();if(t._effect.setMatrix("viewProjection",n.getTransformMatrix()),t._effect.setMatrix("view",n.getViewMatrix()),h&&h.needAlphaTesting()){var l=h.getAlphaTestTexture();t._effect.setTexture("diffuseSampler",l),t._effect.setMatrix("diffuseMatrix",l.getTextureMatrix())}r.useBones&&r.computeBonesUsingShaders&&t._effect.setMatrices("mBones",r.skeleton.getTransformMatrices(r)),r._processRendering(i,t._effect,e.Material.TriangleFillMode,s,a,(function(e,i){return t._effect.setMatrix("world",i)}))}}};this._multiRenderTarget.customRenderFunction=function(e,t){var i;for(i=0;i0&&-1!==this.excludedMeshes.indexOf(e)},i.prototype._createPass=function(t,i){var r=this,n=t.getEngine();this._volumetricLightScatteringRTT=new e.RenderTargetTexture("volumetricLightScatteringMap",{width:n.getRenderWidth()*i,height:n.getRenderHeight()*i},t,!1,!0,e.Engine.TEXTURETYPE_UNSIGNED_INT),this._volumetricLightScatteringRTT.wrapU=e.Texture.CLAMP_ADDRESSMODE,this._volumetricLightScatteringRTT.wrapV=e.Texture.CLAMP_ADDRESSMODE,this._volumetricLightScatteringRTT.renderList=null,this._volumetricLightScatteringRTT.renderParticles=!1,t.customRenderTargets.push(this._volumetricLightScatteringRTT);var o,s=function(t){var i=t.getRenderingMesh();if(!r._meshExcluded(i)){var n=i.getScene(),o=n.getEngine();o.setState(t.getMaterial().backFaceCulling);var s=i._getInstancesRenderList(t._id);if(!s.mustReturn){var a=o.getCaps().instancedArrays&&null!==s.visibleInstances[t._id];if(r.isReady(t,a)){var h=r._volumetricLightScatteringPass;if(i===r.mesh&&(h=t.effect?t.effect:t.getMaterial().getEffect()),o.enableEffect(h),i._bind(t,h,e.Material.TriangleFillMode),i===r.mesh)t.getMaterial().bind(i.getWorldMatrix(),i);else{var l=t.getMaterial();if(r._volumetricLightScatteringPass.setMatrix("viewProjection",n.getTransformMatrix()),l&&l.needAlphaTesting()){var c=l.getAlphaTestTexture();r._volumetricLightScatteringPass.setTexture("diffuseSampler",c),c&&r._volumetricLightScatteringPass.setMatrix("diffuseMatrix",c.getTextureMatrix())}i.useBones&&i.computeBonesUsingShaders&&r._volumetricLightScatteringPass.setMatrices("mBones",i.skeleton.getTransformMatrices(i))}i._processRendering(t,r._volumetricLightScatteringPass,e.Material.TriangleFillMode,s,a,(function(e,t){return h.setMatrix("world",t)}))}}}},a=new e.Color4(0,0,0,1);this._volumetricLightScatteringRTT.onBeforeRenderObservable.add((function(){o=t.clearColor,t.clearColor=a})),this._volumetricLightScatteringRTT.onAfterRenderObservable.add((function(){t.clearColor=o})),this._volumetricLightScatteringRTT.customRenderFunction=function(i,r,n){var o,a=t.getEngine();for(o=0;ot._alphaIndex?1:e._alphaIndext._distanceToCamera?-1:0})),a.setAlphaMode(e.Engine.ALPHA_COMBINE),o=0;o0)return Math.max(n,3)}return Math.max(t,3)},i.prototype._gaussianWeight=function(e){var t=Math.sqrt(2*Math.PI)*(1/3),i=-e*e/(1/3*2*(1/3));return 1/t*Math.exp(i)},i.prototype._glslFloat=function(e,t){return void 0===t&&(t=8),e.toFixed(t).replace(/0+$/,"")},i})(e.PostProcess);e.BlurPostProcess=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o,s){void 0===n&&(n=null);var a=t.call(this,i,r.getScene())||this;return a.name=i,a.children=new Array,a.animations=new Array,a._worldTransform=new e.Matrix,a._absoluteTransform=new e.Matrix,a._invertedAbsoluteTransform=new e.Matrix,a._scaleMatrix=e.Matrix.Identity(),a._scaleVector=e.Vector3.One(),a._negateScaleChildren=e.Vector3.One(),a._scalingDeterminant=1,a._skeleton=r,a._localMatrix=o||e.Matrix.Identity(),a._baseMatrix=a._localMatrix.clone(),a._restPose=s||a._localMatrix.clone(),r.bones.push(a),a.setParent(n,!1),a._updateDifferenceMatrix(),a}return __extends(i,t),Object.defineProperty(i.prototype,"_matrix",{get:function(){return this._localMatrix},set:function(e){this._localMatrix?this._localMatrix.copyFrom(e):this._localMatrix=e},enumerable:!0,configurable:!0}),i.prototype.getSkeleton=function(){return this._skeleton},i.prototype.getParent=function(){return this._parent},i.prototype.setParent=function(e,t){if(void 0===t&&(t=!0),this._parent!==e){if(this._parent){var i=this._parent.children.indexOf(this);-1!==i&&this._parent.children.splice(i)}this._parent=e,this._parent&&this._parent.children.push(this),t&&this._updateDifferenceMatrix()}},i.prototype.getLocalMatrix=function(){return this._localMatrix},i.prototype.getBaseMatrix=function(){return this._baseMatrix},i.prototype.getRestPose=function(){return this._restPose},i.prototype.returnToRest=function(){this.updateMatrix(this._restPose.clone())},i.prototype.getWorldMatrix=function(){return this._worldTransform},i.prototype.getInvertedAbsoluteTransform=function(){return this._invertedAbsoluteTransform},i.prototype.getAbsoluteTransform=function(){return this._absoluteTransform},Object.defineProperty(i.prototype,"position",{get:function(){return this.getPosition()},set:function(e){this.setPosition(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"rotation",{get:function(){return this.getRotation()},set:function(e){this.setRotation(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"rotationQuaternion",{get:function(){return this.getRotationQuaternion()},set:function(e){this.setRotationQuaternion(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"scaling",{get:function(){return this.getScale()},set:function(e){this.setScale(e.x,e.y,e.z)},enumerable:!0,configurable:!0}),i.prototype.updateMatrix=function(e,t){void 0===t&&(t=!0),this._baseMatrix=e.clone(),this._localMatrix=e.clone(),this._skeleton._markAsDirty(),t&&this._updateDifferenceMatrix()},i.prototype._updateDifferenceMatrix=function(e){e||(e=this._baseMatrix),this._parent?e.multiplyToRef(this._parent._absoluteTransform,this._absoluteTransform):this._absoluteTransform.copyFrom(e),this._absoluteTransform.invertToRef(this._invertedAbsoluteTransform);for(var t=0;t=c&&a.frame<=u&&(n?(l=a.value.clone(),_?(h=l.getTranslation(),l.setTranslation(h.scaleInPlace(g))):v?(h=l.getTranslation(),l.setTranslation(h.multiplyInPlace(o))):l=a.value):l=a.value,y.push({frame:a.frame+r,value:l}));return this.animations[0].createRange(i,c+r,u+r),!0},i.prototype.translate=function(t,r,n){void 0===r&&(r=e.Space.LOCAL);var o=this.getLocalMatrix();if(r==e.Space.LOCAL)o.m[12]+=t.x,o.m[13]+=t.y,o.m[14]+=t.z;else{var s;n&&(s=n.getWorldMatrix()),this._skeleton.computeAbsoluteTransforms();var a=i._tmpMats[0],h=i._tmpVecs[0];n?(a.copyFrom(this._parent.getAbsoluteTransform()),a.multiplyToRef(s,a)):a.copyFrom(this._parent.getAbsoluteTransform()),a.m[12]=0,a.m[13]=0,a.m[14]=0,a.invert(),e.Vector3.TransformCoordinatesToRef(t,a,h),o.m[12]+=h.x,o.m[13]+=h.y,o.m[14]+=h.z}this.markAsDirty()},i.prototype.setPosition=function(t,r,n){void 0===r&&(r=e.Space.LOCAL);var o=this.getLocalMatrix();if(r==e.Space.LOCAL)o.m[12]=t.x,o.m[13]=t.y,o.m[14]=t.z;else{var s;n&&(s=n.getWorldMatrix()),this._skeleton.computeAbsoluteTransforms();var a=i._tmpMats[0],h=i._tmpVecs[0];n?(a.copyFrom(this._parent.getAbsoluteTransform()),a.multiplyToRef(s,a)):a.copyFrom(this._parent.getAbsoluteTransform()),a.invert(),e.Vector3.TransformCoordinatesToRef(t,a,h),o.m[12]=h.x,o.m[13]=h.y,o.m[14]=h.z}this.markAsDirty()},i.prototype.setAbsolutePosition=function(t,i){this.setPosition(t,e.Space.WORLD,i)},i.prototype.setScale=function(e,t,i,r){void 0===r&&(r=!1),this.animations[0]&&!this.animations[0].isStopped()&&(r||(this._negateScaleChildren.x=1/e,this._negateScaleChildren.y=1/t,this._negateScaleChildren.z=1/i),this._syncScaleVector()),this.scale(e/this._scaleVector.x,t/this._scaleVector.y,i/this._scaleVector.z,r)},i.prototype.scale=function(t,r,n,o){void 0===o&&(o=!1);var s=this.getLocalMatrix(),a=i._tmpMats[0];a.copyFrom(s);var h=i._tmpMats[1];h.copyFrom(a),h.invert();var l=i._tmpMats[2];e.Matrix.FromValuesToRef(t,0,0,0,0,r,0,0,0,0,n,0,0,0,0,1,l),this._scaleMatrix.multiplyToRef(l,this._scaleMatrix),this._scaleVector.x*=t,this._scaleVector.y*=r,this._scaleVector.z*=n,s.multiplyToRef(h,s),s.multiplyToRef(l,s),s.multiplyToRef(a,s);var c=this.getParent();c?s.multiplyToRef(c.getAbsoluteTransform(),this.getAbsoluteTransform()):this.getAbsoluteTransform().copyFrom(s);var u=this.children.length;l.invert();for(var f=0;f0&&(this._rightHandedSystem=!0,this._bendAxis.x=0,this._bendAxis.y=0,this._bendAxis.z=-1,n.x>n.y&&n.x>n.z&&(this._adjustRoll=.5*Math.PI,this._bendAxis.z=1)),this._bone1.length){var o=this._bone1.getScale(),s=this._bone2.getScale();this._bone1Length=this._bone1.length*o.y*this.mesh.scaling.y,this._bone2Length=this._bone2.length*s.y*this.mesh.scaling.y}else if(this._bone1.children[0]){t.computeWorldMatrix(!0);var a=this._bone2.children[0].getAbsolutePosition(t),h=this._bone2.getAbsolutePosition(t),l=this._bone1.getAbsolutePosition(t);this._bone1Length=e.Vector3.Distance(a,h),this._bone2Length=e.Vector3.Distance(h,l)}this._bone1.getRotationMatrixToRef(e.Space.WORLD,t,this._bone1Mat),this.maxAngle=Math.PI,r&&(r.targetMesh&&(this.targetMesh=r.targetMesh,this.targetMesh.computeWorldMatrix(!0)),r.poleTargetMesh?(this.poleTargetMesh=r.poleTargetMesh,this.poleTargetMesh.computeWorldMatrix(!0)):r.poleTargetBone?this.poleTargetBone=r.poleTargetBone:this._bone1.getParent()&&(this.poleTargetBone=this._bone1.getParent()),r.poleTargetLocalOffset&&this.poleTargetLocalOffset.copyFrom(r.poleTargetLocalOffset),r.poleAngle&&(this.poleAngle=r.poleAngle),r.bendAxis&&this._bendAxis.copyFrom(r.bendAxis),r.maxAngle&&(this.maxAngle=r.maxAngle),r.slerpAmount&&(this.slerpAmount=r.slerpAmount))}return Object.defineProperty(t.prototype,"maxAngle",{get:function(){return this._maxAngle},set:function(e){this._setMaxAngle(e)},enumerable:!0,configurable:!0}),t.prototype._setMaxAngle=function(e){e<0&&(e=0),(e>Math.PI||void 0==e)&&(e=Math.PI),this._maxAngle=e;var t=this._bone1Length,i=this._bone2Length;this._maxReach=Math.sqrt(t*t+i*i-2*t*i*Math.cos(e))},t.prototype.update=function(){var i=this._bone1,r=this.targetPosition,n=this.poleTargetPosition,o=t._tmpMats[0],s=t._tmpMats[1];this.targetMesh&&r.copyFrom(this.targetMesh.getAbsolutePosition()),this.poleTargetBone?this.poleTargetBone.getAbsolutePositionFromLocalToRef(this.poleTargetLocalOffset,this.mesh,n):this.poleTargetMesh&&e.Vector3.TransformCoordinatesToRef(this.poleTargetLocalOffset,this.poleTargetMesh.getWorldMatrix(),n);var a=t._tmpVecs[0],h=t._tmpVecs[1],l=t._tmpVecs[2],c=t._tmpVecs[3],u=t._tmpVecs[4],f=t._tmpQuat;i.getAbsolutePositionToRef(this.mesh,a),n.subtractToRef(a,u),0==u.x&&0==u.y&&0==u.z?u.y=1:u.normalize(),r.subtractToRef(a,c),c.normalize(),e.Vector3.CrossToRef(c,u,h),h.normalize(),e.Vector3.CrossToRef(c,h,l),l.normalize(),e.Matrix.FromXYZAxesToRef(l,c,h,o);var d=this._bone1Length,p=this._bone2Length,m=e.Vector3.Distance(a,r);this._maxReach>0&&(m=Math.min(this._maxReach,m));var _=(p*p+m*m-d*d)/(2*p*m),g=(m*m+d*d-p*p)/(2*m*d);_>1&&(_=1),g>1&&(g=1),_<-1&&(_=-1),g<-1&&(g=-1);var v=Math.acos(_),y=Math.acos(g),x=-v-y;if(this._rightHandedSystem)e.Matrix.RotationYawPitchRollToRef(0,0,this._adjustRoll,s),s.multiplyToRef(o,o), +e.Matrix.RotationAxisToRef(this._bendAxis,y,s),s.multiplyToRef(o,o);else{var b=t._tmpVecs[5];b.copyFrom(this._bendAxis),b.x*=-1,e.Matrix.RotationAxisToRef(b,-y,s),s.multiplyToRef(o,o)}this.poleAngle&&(e.Matrix.RotationAxisToRef(c,this.poleAngle,s),o.multiplyToRef(s,o)),this.slerpAmount<1?(this._slerping||e.Quaternion.FromRotationMatrixToRef(this._bone1Mat,this._bone1Quat),e.Quaternion.FromRotationMatrixToRef(o,f),e.Quaternion.SlerpToRef(this._bone1Quat,f,this.slerpAmount,this._bone1Quat),x=this._bone2Ang*(1-this.slerpAmount)+x*this.slerpAmount,this._bone1.setRotationQuaternion(this._bone1Quat,e.Space.WORLD,this.mesh),this._slerping=!0):(this._bone1.setRotationMatrix(o,e.Space.WORLD,this.mesh),this._bone1Mat.copyFrom(o),this._slerping=!1),this._bone2.setAxisAngle(this._bendAxis,x,e.Space.LOCAL),this._bone2Ang=x},t})();t._tmpVecs=[e.Vector3.Zero(),e.Vector3.Zero(),e.Vector3.Zero(),e.Vector3.Zero(),e.Vector3.Zero(),e.Vector3.Zero()],t._tmpQuat=e.Quaternion.Identity(),t._tmpMats=[e.Matrix.Identity(),e.Matrix.Identity()],e.BoneIKController=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t,i,r,n){if(this.upAxis=e.Vector3.Up(),this.upAxisSpace=e.Space.LOCAL,this.adjustYaw=0,this.adjustPitch=0,this.adjustRoll=0,this.slerpAmount=1,this._boneQuat=e.Quaternion.Identity(),this._slerping=!1,this._firstFrameSkipped=!1,this._fowardAxis=e.Vector3.Forward(),this.mesh=t,this.bone=i,this.target=r,n&&(n.adjustYaw&&(this.adjustYaw=n.adjustYaw),n.adjustPitch&&(this.adjustPitch=n.adjustPitch),n.adjustRoll&&(this.adjustRoll=n.adjustRoll),null!=n.maxYaw?this.maxYaw=n.maxYaw:this.maxYaw=Math.PI,null!=n.minYaw?this.minYaw=n.minYaw:this.minYaw=-Math.PI,null!=n.maxPitch?this.maxPitch=n.maxPitch:this.maxPitch=Math.PI,null!=n.minPitch?this.minPitch=n.minPitch:this.minPitch=-Math.PI,null!=n.slerpAmount&&(this.slerpAmount=n.slerpAmount),null!=n.upAxis&&(this.upAxis=n.upAxis),null!=n.upAxisSpace&&(this.upAxisSpace=n.upAxisSpace),null!=n.yawAxis||null!=n.pitchAxis)){var o=e.Axis.Y,s=e.Axis.X;null!=n.yawAxis&&(o=n.yawAxis.clone(),o.normalize()),null!=n.pitchAxis&&(s=n.pitchAxis.clone(),s.normalize());var a=e.Vector3.Cross(s,o);this._transformYawPitch=e.Matrix.Identity(),e.Matrix.FromXYZAxesToRef(s,o,a,this._transformYawPitch),this._transformYawPitchInv=this._transformYawPitch.clone(),this._transformYawPitch.invert()}i.getParent()||this.upAxisSpace!=e.Space.BONE||(this.upAxisSpace=e.Space.LOCAL)}return Object.defineProperty(t.prototype,"minYaw",{get:function(){return this._minYaw},set:function(e){this._minYaw=e,this._minYawSin=Math.sin(e),this._minYawCos=Math.cos(e),null!=this._maxYaw&&(this._midYawConstraint=.5*this._getAngleDiff(this._minYaw,this._maxYaw)+this._minYaw,this._yawRange=this._maxYaw-this._minYaw)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"maxYaw",{get:function(){return this._maxYaw},set:function(e){this._maxYaw=e,this._maxYawSin=Math.sin(e),this._maxYawCos=Math.cos(e),null!=this._minYaw&&(this._midYawConstraint=.5*this._getAngleDiff(this._minYaw,this._maxYaw)+this._minYaw,this._yawRange=this._maxYaw-this._minYaw)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"minPitch",{get:function(){return this._minPitch},set:function(e){this._minPitch=e,this._minPitchTan=Math.tan(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"maxPitch",{get:function(){return this._maxPitch},set:function(e){this._maxPitch=e,this._maxPitchTan=Math.tan(e)},enumerable:!0,configurable:!0}),t.prototype.update=function(){if(this.slerpAmount<1&&!this._firstFrameSkipped)return void(this._firstFrameSkipped=!0);var i=this.bone,r=t._tmpVecs[0];i.getAbsolutePositionToRef(this.mesh,r);var n=this.target,o=t._tmpMats[0],s=t._tmpMats[1],a=this.mesh,h=i.getParent(),l=t._tmpVecs[1];l.copyFrom(this.upAxis),this.upAxisSpace==e.Space.BONE?(this._transformYawPitch&&e.Vector3.TransformCoordinatesToRef(l,this._transformYawPitchInv,l),h.getDirectionToRef(l,this.mesh,l)):this.upAxisSpace==e.Space.LOCAL&&(a.getDirectionToRef(l,l),1==a.scaling.x&&1==a.scaling.y&&1==a.scaling.z||l.normalize());var c=!1,u=!1;if(this._maxYaw==Math.PI&&this._minYaw==-Math.PI||(c=!0),this._maxPitch==Math.PI&&this._minPitch==-Math.PI||(u=!0),c||u){var f=t._tmpMats[2],d=t._tmpMats[3];if(this.upAxisSpace==e.Space.BONE&&1==l.y)h.getRotationMatrixToRef(e.Space.WORLD,this.mesh,f);else if(this.upAxisSpace!=e.Space.LOCAL||1!=l.y||h){var p=t._tmpVecs[2];p.copyFrom(this._fowardAxis),this._transformYawPitch&&e.Vector3.TransformCoordinatesToRef(p,this._transformYawPitchInv,p),h?h.getDirectionToRef(p,this.mesh,p):a.getDirectionToRef(p,p);var m=e.Vector3.Cross(l,p);m.normalize();var p=e.Vector3.Cross(m,l);e.Matrix.FromXYZAxesToRef(m,l,p,f)}else f.copyFrom(a.getWorldMatrix());f.invertToRef(d);var _;if(u){var g=t._tmpVecs[3];n.subtractToRef(r,g),e.Vector3.TransformCoordinatesToRef(g,d,g);var _=Math.sqrt(g.x*g.x+g.z*g.z),v=Math.atan2(g.y,_),y=v;v>this._maxPitch?(g.y=this._maxPitchTan*_,y=this._maxPitch):vthis._maxYaw||xMath.PI?this._isAngleBetween(x,this._maxYaw,this._midYawConstraint)?(g.z=this._maxYawCos*_,g.x=this._maxYawSin*_,b=this._maxYaw):this._isAngleBetween(x,this._midYawConstraint,this._minYaw)&&(g.z=this._minYawCos*_,g.x=this._minYawSin*_,b=this._minYaw):x>this._maxYaw?(g.z=this._maxYawCos*_,g.x=this._maxYawSin*_,b=this._maxYaw):xMath.PI){var A=t._tmpVecs[8];A.copyFrom(e.Axis.Z),this._transformYawPitch&&e.Vector3.TransformCoordinatesToRef(A,this._transformYawPitchInv,A);var T=e.BoneLookController._tmpMats[4];this._boneQuat.toRotationMatrix(T),this.mesh.getWorldMatrix().multiplyToRef(T,T),e.Vector3.TransformCoordinatesToRef(A,T,A),e.Vector3.TransformCoordinatesToRef(A,d,A);var E=Math.atan2(A.x,A.z);if(this._getAngleBetween(E,x)>this._getAngleBetween(E,this._midYawConstraint)){null==_&&(_=Math.sqrt(g.x*g.x+g.z*g.z));var P=this._getAngleBetween(E,this._maxYaw);this._getAngleBetween(E,this._minYaw)Math.PI?i-=2*Math.PI:i<-Math.PI&&(i+=2*Math.PI),i},t.prototype._getAngleBetween=function(e,t){e%=2*Math.PI,e=e<0?e+2*Math.PI:e,t%=2*Math.PI,t=t<0?t+2*Math.PI:t;var i=0;return i=eMath.PI&&(i=2*Math.PI-i),i},t.prototype._isAngleBetween=function(e,t,i){if(e%=2*Math.PI,e=e<0?e+2*Math.PI:e,t%=2*Math.PI,t=t<0?t+2*Math.PI:t,i%=2*Math.PI,i=i<0?i+2*Math.PI:i,tt&&ei&&e-1&&this._meshesWithPoseMatrix.splice(t,1)},t.prototype._computeTransformMatrices=function(e,t){this.onBeforeComputeObservable.notifyObservers(this);for(var i=0;i0&&(r.animation=i.animations[0].serialize()),e.ranges=[];for(var n in this._ranges){var o={};o.name=n,o.from=this._ranges[n].from,o.to=this._ranges[n].to,e.ranges.push(o)}}return e},t.Parse=function(i,r){var n=new t(i.name,i.id,r);i.dimensionsAtRest&&(n.dimensionsAtRest=e.Vector3.FromArray(i.dimensionsAtRest)),n.needInitialSkinMatrix=i.needInitialSkinMatrix;var o;for(o=0;o-1&&(a=n.bones[s.parentBoneIndex]);var h=s.rest?e.Matrix.FromArray(s.rest):null,l=new e.Bone(s.name,n,a,e.Matrix.FromArray(s.matrix),h);s.length&&(l.length=s.length),s.animation&&l.animations.push(e.Animation.Parse(s.animation))}if(i.ranges)for(o=0;o0&&(e=this._meshesWithPoseMatrix[0].getPoseMatrix()),e},t})();e.Skeleton=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this.x=e.Vector3.Zero(),this.y=e.Vector3.Zero(),this.z=e.Vector3.Zero(),this.xx=e.Vector3.Zero(),this.yy=e.Vector3.Zero(),this.zz=e.Vector3.Zero(),this.xy=e.Vector3.Zero(),this.yz=e.Vector3.Zero(),this.zx=e.Vector3.Zero()}return t.prototype.addAmbient=function(t){var i=new e.Vector3(t.r,t.g,t.b);this.xx=this.xx.add(i),this.yy=this.yy.add(i),this.zz=this.zz.add(i)},t.getSphericalPolynomialFromHarmonics=function(e){var i=new t;return i.x=e.L11.scale(1.02333),i.y=e.L1_1.scale(1.02333),i.z=e.L10.scale(1.02333),i.xx=e.L00.scale(.886277).subtract(e.L20.scale(.247708)).add(e.L22.scale(.429043)),i.yy=e.L00.scale(.886277).subtract(e.L20.scale(.247708)).subtract(e.L22.scale(.429043)),i.zz=e.L00.scale(.886277).add(e.L20.scale(.495417)),i.yz=e.L2_1.scale(.858086),i.zx=e.L21.scale(.858086),i.xy=e.L2_2.scale(.858086),i.scale(1/Math.PI),i},t.prototype.scale=function(e){this.x=this.x.scale(e),this.y=this.y.scale(e),this.z=this.z.scale(e),this.xx=this.xx.scale(e),this.yy=this.yy.scale(e),this.zz=this.zz.scale(e),this.yz=this.yz.scale(e),this.zx=this.zx.scale(e),this.xy=this.xy.scale(e)},t})();e.SphericalPolynomial=t;var i=(function(){function t(){this.L00=e.Vector3.Zero(),this.L1_1=e.Vector3.Zero(),this.L10=e.Vector3.Zero(),this.L11=e.Vector3.Zero(),this.L2_2=e.Vector3.Zero(),this.L2_1=e.Vector3.Zero(),this.L20=e.Vector3.Zero(),this.L21=e.Vector3.Zero(),this.L22=e.Vector3.Zero()}return t.prototype.addLight=function(t,i,r){var n=new e.Vector3(i.r,i.g,i.b),o=n.scale(r);this.L00=this.L00.add(o.scale(.282095)),this.L1_1=this.L1_1.add(o.scale(.488603*t.y)),this.L10=this.L10.add(o.scale(.488603*t.z)),this.L11=this.L11.add(o.scale(.488603*t.x)),this.L2_2=this.L2_2.add(o.scale(1.092548*t.x*t.y)),this.L2_1=this.L2_1.add(o.scale(1.092548*t.y*t.z)),this.L21=this.L21.add(o.scale(1.092548*t.x*t.z)),this.L20=this.L20.add(o.scale(.315392*(3*t.z*t.z-1))),this.L22=this.L22.add(o.scale(.546274*(t.x*t.x-t.y*t.y)))},t.prototype.scale=function(e){this.L00=this.L00.scale(e),this.L1_1=this.L1_1.scale(e),this.L10=this.L10.scale(e),this.L11=this.L11.scale(e),this.L2_2=this.L2_2.scale(e),this.L2_1=this.L2_1.scale(e),this.L20=this.L20.scale(e),this.L21=this.L21.scale(e),this.L22=this.L22.scale(e)},t.prototype.convertIncidentRadianceToIrradiance=function(){this.L00=this.L00.scale(3.141593),this.L1_1=this.L1_1.scale(2.094395),this.L10=this.L10.scale(2.094395),this.L11=this.L11.scale(2.094395),this.L2_2=this.L2_2.scale(.785398),this.L2_1=this.L2_1.scale(.785398),this.L20=this.L20.scale(.785398),this.L21=this.L21.scale(.785398),this.L22=this.L22.scale(.785398)},t.prototype.convertIrradianceToLambertianRadiance=function(){this.scale(1/Math.PI)},t.getsphericalHarmonicsFromPolynomial=function(e){var i=new t;return i.L00=e.xx.scale(.376127).add(e.yy.scale(.376127)).add(e.zz.scale(.376126)),i.L1_1=e.y.scale(.977204),i.L10=e.z.scale(.977204),i.L11=e.x.scale(.977204),i.L2_2=e.xy.scale(1.16538),i.L2_1=e.yz.scale(1.16538),i.L20=e.zz.scale(1.34567).subtract(e.xx.scale(.672834)).subtract(e.yy.scale(.672834)),i.L21=e.zx.scale(1.16538),i.L22=e.xx.scale(1.16538).subtract(e.yy.scale(1.16538)),i.scale(Math.PI),i},t})();e.SphericalHarmonics=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){var i=(function(){function e(e,t,i,r){this.name=e,this.worldAxisForNormal=t,this.worldAxisForFileX=i,this.worldAxisForFileY=r}return e})(),r=(function(){function t(){}return t.ConvertCubeMapTextureToSphericalPolynomial=function(t){if(!t.isCube)return null;var i,r,n=t.getSize().width,o=t.readPixels(0),s=t.readPixels(1);t.isRenderTarget?(i=t.readPixels(3),r=t.readPixels(2)):(i=t.readPixels(2),r=t.readPixels(3));var a=t.readPixels(4),h=t.readPixels(5),l=t.gammaSpace,c=e.Engine.TEXTUREFORMAT_RGBA,u=e.Engine.TEXTURETYPE_UNSIGNED_INT;t.textureType&&t.textureType!==e.Engine.TEXTURETYPE_UNSIGNED_INT&&(u=e.Engine.TEXTURETYPE_FLOAT);var f={size:n,right:o,left:s,up:i,down:r,front:a,back:h,format:c,type:u,gammaSpace:l};return this.ConvertCubeMapToSphericalPolynomial(f)},t.ConvertCubeMapToSphericalPolynomial=function(t){for(var i=new e.SphericalHarmonics,r=0,n=2/t.size,o=n,s=.5*n-1,a=0;a<6;a++)for(var h=this.FileFaces[a],l=t[h.name],c=s,u=t.format===e.Engine.TEXTUREFORMAT_RGBA?4:3,f=0;fMath.PI;)n-=2*Math.PI;var s=n/Math.PI,a=o/Math.PI;s=.5*s+.5;var h=Math.round(s*i);h<0?h=0:h>=i&&(h=i-1);var l=Math.round(a*r);l<0?l=0:l>=r&&(l=r-1);var c=r-l-1;return{r:t[c*i*3+3*h+0],g:t[c*i*3+3*h+1],b:t[c*i*3+3*h+2]}},t})();i.FACE_FRONT=[new e.Vector3(-1,-1,-1),new e.Vector3(1,-1,-1),new e.Vector3(-1,1,-1),new e.Vector3(1,1,-1)],i.FACE_BACK=[new e.Vector3(1,-1,1),new e.Vector3(-1,-1,1),new e.Vector3(1,1,1),new e.Vector3(-1,1,1)],i.FACE_RIGHT=[new e.Vector3(1,-1,-1),new e.Vector3(1,-1,1),new e.Vector3(1,1,-1),new e.Vector3(1,1,1)],i.FACE_LEFT=[new e.Vector3(-1,-1,1),new e.Vector3(-1,-1,-1),new e.Vector3(-1,1,1),new e.Vector3(-1,1,-1)],i.FACE_DOWN=[new e.Vector3(-1,1,-1),new e.Vector3(1,1,-1),new e.Vector3(-1,1,1),new e.Vector3(1,1,1)],i.FACE_UP=[new e.Vector3(-1,-1,1),new e.Vector3(1,-1,1),new e.Vector3(-1,-1,-1),new e.Vector3(1,-1,-1)],t.PanoramaToCubeMapTools=i})(e.Internals||(e.Internals={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(e){var t=(function(){function t(){}return t.Ldexp=function(e,t){return t>1023?e*Math.pow(2,1023)*Math.pow(2,t-1023):t<-1074?e*Math.pow(2,-1074)*Math.pow(2,t+1074):e*Math.pow(2,t)},t.Rgbe2float=function(e,t,i,r,n,o){n>0?(n=this.Ldexp(1,n-136),e[o+0]=t*n,e[o+1]=i*n,e[o+2]=r*n):(e[o+0]=0,e[o+1]=0,e[o+2]=0)},t.readStringLine=function(e,t){for(var i="",r="",n=t;n32767)throw"HDR Bad header format, unsupported size";return s+=r.length+1,{height:t,width:i,dataPosition:s}},t.GetCubeMapTextureData=function(t,i){var r=new Uint8Array(t),n=this.RGBE_ReadHeader(r),o=this.RGBE_ReadPixels_RLE(r,n);return e.PanoramaToCubeMapTools.ConvertPanoramaToCubemap(o,n.width,n.height,i)},t.RGBE_ReadPixels=function(e,t){return this.RGBE_ReadPixels_RLE(e,t)},t.RGBE_ReadPixels_RLE=function(e,t){for(var i,r,n,o,s,a=t.height,h=t.width,l=t.dataPosition,c=0,u=0,f=0,d=new ArrayBuffer(4*h),p=new Uint8Array(d),m=new ArrayBuffer(t.width*t.height*4*3),_=new Float32Array(m);a>0;){if(i=e[l++],r=e[l++],n=e[l++],o=e[l++],2!=i||2!=r||128&n)throw"HDR Bad header format, not RLE";if((n<<8|o)!=h)throw"HDR Bad header format, wrong scan line width";for(c=0,f=0;f<4;f++)for(u=(f+1)*h;c128){if(0==(s=i-128)||s>u-c)throw"HDR Bad Format, bad scanline data (run)";for(;s-- >0;)p[c++]=r}else{if(0==(s=i)||s>u-c)throw"HDR Bad Format, bad scanline data (non-run)";if(p[c++]=r,--s>0)for(var g=0;g>s,2),h=0;h<6;h++){var l=r.subarray(o,o+a);n[s].push(l),o+=a}}return n}:null,o=function(o){var s=new Int32Array(o);r=new Float32Array(o);var a=s[0];t._size=s[1],t.getScene().getEngine().updateTextureSize(t._texture,t._size,t._size);var h=new e.SphericalPolynomial;h.x.copyFromFloats(r[2],r[3],r[4]),h.y.copyFromFloats(r[5],r[6],r[7]),h.z.copyFromFloats(r[8],r[9],r[10]),h.xx.copyFromFloats(r[11],r[12],r[13]),h.yy.copyFromFloats(r[14],r[15],r[16]),h.zz.copyFromFloats(r[17],r[18],r[19]),h.xy.copyFromFloats(r[20],r[21],r[22]),h.yz.copyFromFloats(r[23],r[24],r[25]),h.zx.copyFromFloats(r[26],r[27],r[28]),t.sphericalPolynomial=h,i=s[29];for(var l=30,c=[],u=3*Math.pow(t._size,2),f=0;f<6;f++)c.push(r.subarray(l,l+u)),l+=u;for(var d=[],p=null,m=0;m<6;m++){var _=null;if(1===a){_=c[[0,2,4,1,3,5][m]]}if(!n){if(!t.getScene().getEngine().getCaps().textureFloat){var g=new ArrayBuffer(u);p=new Uint8Array(g)}for(var v=0;v255){var T=255/A;y*=T,x*=T,b*=T}p[3*v+0]=y,p[3*v+1]=x,p[3*v+2]=b}}p?d.push(p):d.push(_)}return d};this._texture=this.getScene().getEngine().createRawCubeTextureFromUrl(this.url,this.getScene(),this._size,e.Engine.TEXTUREFORMAT_RGB,this.getScene().getEngine().getCaps().textureFloat?e.Engine.TEXTURETYPE_FLOAT:e.Engine.TEXTURETYPE_UNSIGNED_INT,this._noMipmap,o,n,this._onLoad,this._onError)},i.prototype.loadHDRTexture=function(){var t=this,r=function(r){var n=e.Internals.HDRTools.GetCubeMapTextureData(r,t._size);if(t._generateHarmonics){var o=e.Internals.CubeMapToSphericalPolynomialTools.ConvertCubeMapToSphericalPolynomial(n);t.sphericalPolynomial=o}for(var s=[],a=null,h=0;h<6;h++){if(!t.getScene().getEngine().getCaps().textureFloat){var l=new ArrayBuffer(t._size*t._size*3);a=new Uint8Array(l)}var c=n[i._facesMapping[h]];if(t._useInGammaSpace||a)for(var u=0;u255){var _=255/m;f*=_,d*=_,p*=_}a[3*u+0]=f,a[3*u+1]=d,a[3*u+2]=p}a?s.push(a):s.push(c)}return s};this._texture=this.getScene().getEngine().createRawCubeTextureFromUrl(this.url,this.getScene(),this._size,e.Engine.TEXTUREFORMAT_RGB,this.getScene().getEngine().getCaps().textureFloat?e.Engine.TEXTURETYPE_FLOAT:e.Engine.TEXTURETYPE_UNSIGNED_INT,this._noMipmap,r,null,this._onLoad,this._onError)},i.prototype.loadTexture=function(){this._isBABYLONPreprocessed?this.loadBabylonTexture():this.loadHDRTexture()},i.prototype.clone=function(){var e=this._isBABYLONPreprocessed?null:this._size,t=new i(this.url,this.getScene(),e,this._noMipmap,this._generateHarmonics,this._useInGammaSpace,this._usePMREMGenerator);return t.level=this.level,t.wrapU=this.wrapU,t.wrapV=this.wrapV,t.coordinatesIndex=this.coordinatesIndex,t.coordinatesMode=this.coordinatesMode,t},i.prototype.delayLoad=function(){this.delayLoadState===e.Engine.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=e.Engine.DELAYLOADSTATE_LOADED,this._texture=this._getFromCache(this.url,this._noMipmap),this._texture||this.loadTexture())},i.prototype.getReflectionTextureMatrix=function(){return this._textureMatrix},i.prototype.setReflectionTextureMatrix=function(e){this._textureMatrix=e},i.Parse=function(t,i,r){var n=null;if(t.name&&!t.isRenderTarget){var o=t.isBABYLONPreprocessed?null:t.size;n=new e.HDRCubeTexture(r+t.name,i,o,t.noMipmap,t.generateHarmonics,t.useInGammaSpace,t.usePMREMGenerator),n.name=t.name,n.hasAlpha=t.hasAlpha,n.level=t.level,n.coordinatesMode=t.coordinatesMode,n.isBlocking=t.isBlocking}return n},i.prototype.serialize=function(){if(!this.name)return null;var e={};return e.name=this.name,e.hasAlpha=this.hasAlpha,e.isCube=!0,e.level=this.level,e.size=this._size,e.coordinatesMode=this.coordinatesMode,e.useInGammaSpace=this._useInGammaSpace,e.generateHarmonics=this._generateHarmonics,e.usePMREMGenerator=this._usePMREMGenerator,e.isBABYLONPreprocessed=this._isBABYLONPreprocessed,e.customType="BABYLON.HDRCubeTexture",e.noMipmap=this._noMipmap,e.isBlocking=this._isBlocking,e},i.generateBabylonHDROnDisk=function(e,t,r){void 0===r&&(r=null);var n=function(e){var t=new Blob([e],{type:"application/octet-stream"}),i=window.URL.createObjectURL(t),r=document.createElement("a");document.body.appendChild(r),r.style.display="none",r.href=i,r.download="envmap.babylon.hdr",r.click()};i.generateBabylonHDR(e,t,n,r)},i.generateBabylonHDR=function(t,i,r,n){return void 0===n&&(n=null),t&&e.Tools.IsExponentOfTwo(i)?(e.Tools.Error("Generation of Babylon HDR is coming back in 3.1."),null):null},i +})(e.BaseTexture);t._facesMapping=["right","left","up","down","front","back"],e.HDRCubeTexture=t})(BABYLON||(BABYLON={}));var Earcut;!(function(e){function t(e,t,r){r=r||2;var o=t&&t.length,s=o?t[0]*r:e.length,a=i(e,0,s,r,!0),h=[];if(!a)return h;var c,u,f,d,p,m,_;if(o&&(a=l(e,t,a,r)),e.length>80*r){c=f=e[0],u=d=e[1];for(var g=r;gf&&(f=p),m>d&&(d=m);_=Math.max(f-c,d-u)}return n(a,h,r,c,u,_,void 0),h}function i(e,t,i,r,n){var o,s;if(n===O(e,t,i,r)>0)for(o=t;o=t;o-=r)s=M(o,e[o],e[o+1],s);return s&&x(s,s.next)&&(S(s),s=s.next),s}function r(e,t){if(!e)return e;t||(t=e);var i,r=e;do{if(i=!1,r.steiner||!x(r,r.next)&&0!==y(r.prev,r,r.next))r=r.next;else{if(S(r),(r=t=r.prev)===r.next)return null;i=!0}}while(i||r!==t);return t}function n(e,t,i,l,c,u,f){if(e){!f&&u&&d(e,l,c,u);for(var p,m,_=e;e.prev!==e.next;)if(p=e.prev,m=e.next,u?s(e,l,c,u):o(e))t.push(p.i/i),t.push(e.i/i),t.push(m.i/i),S(e),e=m.next,_=m.next;else if((e=m)===_){f?1===f?(e=a(e,t,i),n(e,t,i,l,c,u,2)):2===f&&h(e,t,i,l,c,u):n(r(e,void 0),t,i,l,c,u,1);break}}}function o(e){var t=e.prev,i=e,r=e.next;if(y(t,i,r)>=0)return!1;for(var n=e.next.next;n!==e.prev;){if(g(t.x,t.y,i.x,i.y,r.x,r.y,n.x,n.y)&&y(n.prev,n,n.next)>=0)return!1;n=n.next}return!0}function s(e,t,i,r){var n=e.prev,o=e,s=e.next;if(y(n,o,s)>=0)return!1;for(var a=n.xo.x?n.x>s.x?n.x:s.x:o.x>s.x?o.x:s.x,c=n.y>o.y?n.y>s.y?n.y:s.y:o.y>s.y?o.y:s.y,u=m(a,h,t,i,r),f=m(l,c,t,i,r),d=e.nextZ;d&&d.z<=f;){if(d!==e.prev&&d!==e.next&&g(n.x,n.y,o.x,o.y,s.x,s.y,d.x,d.y)&&y(d.prev,d,d.next)>=0)return!1;d=d.nextZ}for(d=e.prevZ;d&&d.z>=u;){if(d!==e.prev&&d!==e.next&&g(n.x,n.y,o.x,o.y,s.x,s.y,d.x,d.y)&&y(d.prev,d,d.next)>=0)return!1;d=d.prevZ}return!0}function a(e,t,i){var r=e;do{var n=r.prev,o=r.next.next;!x(n,o)&&b(n,r,r.next,o)&&T(n,o)&&T(o,n)&&(t.push(n.i/i),t.push(r.i/i),t.push(o.i/i),S(r),S(r.next),r=e=o),r=r.next}while(r!==e);return r}function h(e,t,i,o,s,a){var h=e;do{for(var l=h.next.next;l!==h.prev;){if(h.i!==l.i&&v(h,l)){var c=P(h,l);return h=r(h,h.next),c=r(c,c.next),n(h,t,i,o,s,a,void 0),void n(c,t,i,o,s,a,void 0)}l=l.next}h=h.next}while(h!==e)}function l(e,t,n,o){var s,a,h,l,f,d=[];for(s=0,a=t.length;s=r.next.y){var a=r.x+(o-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(a<=n&&a>s){if(s=a,a===n){if(o===r.y)return r;if(o===r.next.y)return r.next}i=r.x=r.x&&r.x>=c&&g(oi.x)&&T(r,e)&&(i=r,f=h),r=r.next;return i}function d(e,t,i,r){var n=e;do{null===n.z&&(n.z=m(n.x,n.y,t,i,r)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next}while(n!==e);n.prevZ.nextZ=null,n.prevZ=null,p(n)}function p(e){var t,i,r,n,o,s,a,h,l=1;do{for(i=e,e=null,o=null,s=0;i;){for(s++,r=i,a=0,t=0;t0||h>0&&r;)0===a?(n=r,r=r.nextZ,h--):0!==h&&r?i.z<=r.z?(n=i,i=i.nextZ,a--):(n=r,r=r.nextZ,h--):(n=i,i=i.nextZ,a--),o?o.nextZ=n:e=n,n.prevZ=o,o=n;i=r}o.nextZ=null,l*=2}while(s>1);return e}function m(e,t,i,r,n){return e=32767*(e-i)/n,t=32767*(t-r)/n,e=16711935&(e|e<<8),e=252645135&(e|e<<4),e=858993459&(e|e<<2),e=1431655765&(e|e<<1),t=16711935&(t|t<<8),t=252645135&(t|t<<4),t=858993459&(t|t<<2),t=1431655765&(t|t<<1),e|t<<1}function _(e){var t=e,i=e;do{t.x=0&&(e-s)*(r-a)-(i-s)*(t-a)>=0&&(i-s)*(o-a)-(n-s)*(r-a)>=0}function v(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!A(e,t)&&T(e,t)&&T(t,e)&&E(e,t)}function y(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function x(e,t){return e.x===t.x&&e.y===t.y}function b(e,t,i,r){return!!(x(e,t)&&x(i,r)||x(e,r)&&x(i,t))||y(e,t,i)>0!=y(e,t,r)>0&&y(i,r,e)>0!=y(i,r,t)>0}function A(e,t){var i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&b(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}function T(e,t){return y(e.prev,e,e.next)<0?y(e,t,e.next)>=0&&y(e,e.prev,t)>=0:y(e,t,e.prev)<0||y(e,e.next,t)<0}function E(e,t){var i=e,r=!1,n=(e.x+t.x)/2,o=(e.y+t.y)/2;do{i.y>o!=i.next.y>o&&n<(i.next.x-i.x)*(o-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next}while(i!==e);return r}function P(e,t){var i=new C(e.i,e.x,e.y),r=new C(t.i,t.x,t.y),n=e.next,o=t.prev;return e.next=t,t.prev=e,i.next=n,n.prev=i,r.next=i,i.prev=r,o.next=r,r.prev=o,r}function M(e,t,i,r){var n=new C(e,t,i);return r?(n.next=r.next,n.prev=r,r.next.prev=n,r.next=n):(n.prev=n,n.next=n),n}function S(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function C(e,t,i){this.i=e,this.x=t,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function R(e,t,i,r){var n=t&&t.length,o=n?t[0]*i:e.length,s=Math.abs(O(e,0,o,i));if(n)for(var a=0,h=t.length;a0&&(r+=e[n-1].length,i.holes.push(r))}return i}e.earcut=t,e.deviation=R,e.flatten=I})(Earcut||(Earcut={}));var BABYLON;!(function(e){var t=(function(e){function t(t,i){var r=e.call(this,t.x,t.y)||this;return r.index=i,r}return __extends(t,e),t})(e.Vector2),i=(function(){function i(){this.elements=new Array}return i.prototype.add=function(e){var i=this,r=new Array;return e.forEach((function(e){if(0===r.length||!e.equalsWithEpsilon(r[0])){var n=new t(e,i.elements.length);r.push(n),i.elements.push(n)}})),r},i.prototype.computeBounds=function(){var t=new e.Vector2(this.elements[0].x,this.elements[0].y),i=new e.Vector2(this.elements[0].x,this.elements[0].y);return this.elements.forEach((function(e){e.xi.x&&(i.x=e.x),e.yi.y&&(i.y=e.y)})),{min:t,max:i,width:i.x-t.x,height:i.y-t.y}},i})(),r=(function(){function t(){}return t.Rectangle=function(t,i,r,n){return[new e.Vector2(t,i),new e.Vector2(r,i),new e.Vector2(r,n),new e.Vector2(t,n)]},t.Circle=function(t,i,r,n){void 0===i&&(i=0),void 0===r&&(r=0),void 0===n&&(n=32);for(var o=new Array,s=0,a=2*Math.PI/n,h=0;h0){var f=s.length/3;this._points.elements.forEach((function(e){o.push(0,-1,0),s.push(e.x,-i,e.y),a.push(1-(e.x-h.min.x)/h.width,1-(e.y-h.min.y)/h.height)}));for(var d=l.length,u=0;us.elements.length-1?s.elements[0]:s.elements[u+1],t.push(d.x,0,d.y),t.push(d.x,-a,d.y),t.push(f.x,0,f.y),t.push(f.x,-a,f.y);var p=new e.Vector3(d.x,0,d.y),m=new e.Vector3(f.x,0,f.y),_=m.subtract(p),g=new e.Vector3(0,1,0),v=e.Vector3.Cross(_,g);v=v.normalize(),r.push(c/o.width,0),r.push(c/o.width,1),c+=_.length(),r.push(c/o.width,0),r.push(c/o.width,1),h?(i.push(v.x,v.y,v.z),i.push(v.x,v.y,v.z),i.push(v.x,v.y,v.z),i.push(v.x,v.y,v.z),n.push(l),n.push(l+2),n.push(l+1),n.push(l+1),n.push(l+2),n.push(l+3)):(i.push(-v.x,-v.y,-v.z),i.push(-v.x,-v.y,-v.z),i.push(-v.x,-v.y,-v.z),i.push(-v.x,-v.y,-v.z),n.push(l),n.push(l+1),n.push(l+2),n.push(l+1),n.push(l+3),n.push(l+2)),l+=4}},t})();e.PolygonMeshBuilder=n})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=0,i=(function(){function t(e,t,i){this.pos=e,this.normal=t,this.uv=i}return t.prototype.clone=function(){return new t(this.pos.clone(),this.normal.clone(),this.uv.clone())},t.prototype.flip=function(){this.normal=this.normal.scale(-1)},t.prototype.interpolate=function(i,r){return new t(e.Vector3.Lerp(this.pos,i.pos,r),e.Vector3.Lerp(this.normal,i.normal,r),e.Vector2.Lerp(this.uv,i.uv,r))},t})(),r=(function(){function t(e,t){this.normal=e,this.w=t}return t.FromPoints=function(i,r,n){var o=n.subtract(i),s=r.subtract(i);if(0===o.lengthSquared()||0===s.lengthSquared())return null;var a=e.Vector3.Normalize(e.Vector3.Cross(o,s));return new t(a,e.Vector3.Dot(a,i))},t.prototype.clone=function(){return new t(this.normal.clone(),this.w)},t.prototype.flip=function(){this.normal.scaleInPlace(-1),this.w=-this.w},t.prototype.splitPolygon=function(i,r,o,s,a){var h,l,c=0,u=[];for(h=0;ht.EPSILON?1:0;c|=f,u.push(f)}switch(c){case 0:(e.Vector3.Dot(this.normal,i.plane.normal)>0?r:o).push(i);break;case 1:s.push(i);break;case 2:a.push(i);break;case 3:var d=[],p=[];for(h=0;h=3&&(b=new n(d,i.shared),b.plane&&s.push(b)),p.length>=3&&(b=new n(p,i.shared),b.plane&&a.push(b))}},t})();r.EPSILON=1e-5;var n=(function(){function e(e,t){this.vertices=e,this.shared=t,this.plane=r.FromPoints(e[0].pos,e[1].pos,e[2].pos)}return e.prototype.clone=function(){return new e(this.vertices.map((function(e){return e.clone()})),this.shared)},e.prototype.flip=function(){this.vertices.reverse().map((function(e){e.flip()})),this.plane.flip()},e})(),o=(function(){function e(e){this.plane=null,this.front=null,this.back=null,this.polygons=[],e&&this.build(e)}return e.prototype.clone=function(){var t=new e;return t.plane=this.plane&&this.plane.clone(),t.front=this.front&&this.front.clone(),t.back=this.back&&this.back.clone(),t.polygons=this.polygons.map((function(e){return e.clone()})),t},e.prototype.invert=function(){for(var e=0;e0&&(t.x-=this.viewportBorder,t.y-=this.viewportBorder,t.width+=2*this.viewportBorder,t.height+=2*this.viewportBorder,i.x+=this.viewportBorder,i.y+=this.viewportBorder,this._positionX+=this.viewportBorder,this._positionY+=this.viewportBorder),i.z>0&&(this._positionX>t.x&&this._positionXt.y&&(this._positionY,t.y,t.height),!0)},t.prototype._isVisible=function(){if(!this._isEnabled)return!1;var t=this.getEmitterPosition(),i=t.subtract(this._scene.activeCamera.globalPosition),r=i.length();i.normalize();var n=new e.Ray(this._scene.activeCamera.globalPosition,i),o=this._scene.pickWithRay(n,this.meshesSelectionPredicate,!0);return!o.hit||o.distance>r},t.prototype.render=function(){if(!this._effect.isReady())return!1;var t=this._scene.getEngine(),i=this._scene.activeCamera.viewport,r=i.toGlobal(t.getRenderWidth(!0),t.getRenderHeight(!0));if(!this.computeEffectivePosition(r))return!1;if(!this._isVisible())return!1;var n,o;n=this._positionXr.x+r.width-this.borderLimit?this._positionX-r.x-r.width+this.borderLimit:0,o=this._positionYr.y+r.height-this.borderLimit?this._positionY-r.y-r.height+this.borderLimit:0;var s=n>o?n:o;(s-=this.viewportBorder)>this.borderLimit&&(s=this.borderLimit);var a=1-s/this.borderLimit;if(a<0)return!1;a>1&&(a=1),this.viewportBorder>0&&(r.x+=this.viewportBorder,r.y+=this.viewportBorder,r.width-=2*this.viewportBorder,r.height-=2*this.viewportBorder,this._positionX-=this.viewportBorder,this._positionY-=this.viewportBorder);var h=r.x+r.width/2,l=r.y+r.height/2,c=h-this._positionX,u=l-this._positionY;t.enableEffect(this._effect),t.setState(!1),t.setDepthBuffer(!1),t.bindBuffers(this._vertexBuffers,this._indexBuffer,this._effect);for(var f=0;f-1?this._onBeforePhysicsStepCallbacks.splice(i,1):e.Tools.Warn("Function to remove was not found")},t.prototype.registerAfterPhysicsStep=function(e){this._onAfterPhysicsStepCallbacks.push(e)},t.prototype.unregisterAfterPhysicsStep=function(t){var i=this._onAfterPhysicsStepCallbacks.indexOf(t);i>-1?this._onAfterPhysicsStepCallbacks.splice(i,1):e.Tools.Warn("Function to remove was not found")},t.prototype.registerOnPhysicsCollide=function(e,t){ +var i=e instanceof Array?e:[e];this._onPhysicsCollideCallbacks.push({callback:t,otherImpostors:i})},t.prototype.unregisterOnPhysicsCollide=function(t,i){var r=t instanceof Array?t:[t],n=this._onPhysicsCollideCallbacks.indexOf({callback:i,otherImpostors:r});n>-1?this._onPhysicsCollideCallbacks.splice(n,1):e.Tools.Warn("Function to remove was not found")},t.prototype.applyForce=function(e,t){this._physicsEngine.getPhysicsPlugin().applyForce(this,e,t)},t.prototype.applyImpulse=function(e,t){this._physicsEngine.getPhysicsPlugin().applyImpulse(this,e,t)},t.prototype.createJoint=function(t,i,r){var n=new e.PhysicsJoint(i,r);this.addJoint(t,n)},t.prototype.addJoint=function(e,t){this._joints.push({otherImpostor:e,joint:t}),this._physicsEngine.addJoint(this,e,t)},t.prototype.sleep=function(){this._physicsEngine.getPhysicsPlugin().sleepBody(this)},t.prototype.wakeUp=function(){this._physicsEngine.getPhysicsPlugin().wakeUpBody(this)},t.prototype.clone=function(e){return e?new t(e,this.type,this._options,this._scene):null},t.prototype.dispose=function(){var e=this;this._physicsEngine&&(this._joints.forEach((function(t){e._physicsEngine.removeJoint(e,t.otherImpostor,t.joint)})),this._physicsEngine.removeImpostor(this),this.parent&&this.parent.forceUpdate(),this._isDisposed=!0)},t.prototype.setDeltaPosition=function(e){this._deltaPosition.copyFrom(e)},t.prototype.setDeltaRotation=function(t){this._deltaRotation||(this._deltaRotation=new e.Quaternion),this._deltaRotation.copyFrom(t),this._deltaRotationConjugated=this._deltaRotation.conjugate()},t.prototype.getBoxSizeToRef=function(e){this._physicsEngine.getPhysicsPlugin().getBoxSizeToRef(this,e)},t.prototype.getRadius=function(){return this._physicsEngine.getPhysicsPlugin().getRadius(this)},t.prototype.syncBoneWithImpostor=function(i,r,n,o,s){var a=t._tmpVecs[0],h=this.object;if(s){var l=t._tmpQuat;h.rotationQuaternion.multiplyToRef(s,l),i.setRotationQuaternion(l,e.Space.WORLD,r)}else i.setRotationQuaternion(h.rotationQuaternion,e.Space.WORLD,r);a.x=0,a.y=0,a.z=0,n&&(a.x=n.x,a.y=n.y,a.z=n.z,i.getDirectionToRef(a,r,a),void 0!==o&&null!==o||(o=n.length()),a.x*=o,a.y*=o,a.z*=o),i.getParent()?(a.addInPlace(h.getAbsolutePosition()),i.setAbsolutePosition(a,r)):(r.setAbsolutePosition(h.getAbsolutePosition()),r.position.x-=a.x,r.position.y-=a.y,r.position.z-=a.z)},t.prototype.syncImpostorWithBone=function(i,r,n,o,s,a){var h=this.object;if(s){var l=t._tmpQuat;i.getRotationQuaternionToRef(e.Space.WORLD,r,l),l.multiplyToRef(s,h.rotationQuaternion)}else i.getRotationQuaternionToRef(e.Space.WORLD,r,h.rotationQuaternion);var c=t._tmpVecs[0],u=t._tmpVecs[1];a||(a=t._tmpVecs[2],a.x=0,a.y=1,a.z=0),i.getDirectionToRef(a,r,u),i.getAbsolutePositionToRef(r,c),void 0!==o&&null!==o||!n||(o=n.length()),void 0!==o&&null!==o&&(c.x+=u.x*o,c.y+=u.y*o,c.z+=u.z*o),h.setAbsolutePosition(c)},t})();t.DEFAULT_OBJECT_SIZE=new e.Vector3(1,1,1),t.IDENTITY_QUATERNION=e.Quaternion.Identity(),t._tmpVecs=[e.Vector3.Zero(),e.Vector3.Zero(),e.Vector3.Zero()],t._tmpQuat=e.Quaternion.Identity(),t.NoImpostor=0,t.SphereImpostor=1,t.BoxImpostor=2,t.PlaneImpostor=3,t.MeshImpostor=4,t.CylinderImpostor=7,t.ParticleImpostor=8,t.HeightmapImpostor=9,e.PhysicsImpostor=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t,i){if(void 0===i&&(i=new e.CannonJSPlugin),this._physicsPlugin=i,this._impostors=[],this._joints=[],!this._physicsPlugin.isSupported())throw new Error("Physics Engine "+this._physicsPlugin.name+" cannot be found. Please make sure it is included.");t=t||new e.Vector3(0,-9.807,0),this.setGravity(t),this.setTimeStep()}return t.prototype.setGravity=function(e){this.gravity=e,this._physicsPlugin.setGravity(this.gravity)},t.prototype.setTimeStep=function(e){void 0===e&&(e=1/60),this._physicsPlugin.setTimeStep(e)},t.prototype.dispose=function(){this._impostors.forEach((function(e){e.dispose()})),this._physicsPlugin.dispose()},t.prototype.getPhysicsPluginName=function(){return this._physicsPlugin.name},t.prototype.addImpostor=function(e){e.uniqueId=this._impostors.push(e),e.parent||this._physicsPlugin.generatePhysicsBody(e)},t.prototype.removeImpostor=function(e){var t=this._impostors.indexOf(e);if(t>-1){var i=this._impostors.splice(t,1);i.length&&(i[0].physicsBody=null)}},t.prototype.addJoint=function(e,t,i){var r={mainImpostor:e,connectedImpostor:t,joint:i};i.physicsPlugin=this._physicsPlugin,this._joints.push(r),this._physicsPlugin.generateJoint(r)},t.prototype.removeJoint=function(e,t,i){var r=this._joints.filter((function(r){return r.connectedImpostor===t&&r.joint===i&&r.mainImpostor===e}));r.length&&this._physicsPlugin.removeJoint(r[0])},t.prototype._step=function(e){var t=this;this._impostors.forEach((function(e){e.isBodyInitRequired()&&t._physicsPlugin.generatePhysicsBody(e)})),e>.1?e=.1:e<=0&&(e=1/60),this._physicsPlugin.executeStep(e,this._impostors)},t.prototype.getPhysicsPlugin=function(){return this._physicsPlugin},t.prototype.getImpostorForPhysicsObject=function(e){for(var t=0;tr.length)return void e.Tools.Error("Unable to load TGA file - Not enough data");n+=o.id_length;var s=!1,a=!1,h=!1;switch(o.image_type){case t._TYPE_RLE_INDEXED:s=!0;case t._TYPE_INDEXED:a=!0;break;case t._TYPE_RLE_RGB:s=!0;case t._TYPE_RGB:!0;break;case t._TYPE_RLE_GREY:s=!0;case t._TYPE_GREY:h=!0}var l,c,u=(o.flags,o.pixel_size>>3),f=o.width*o.height*u;if(a&&(c=r.subarray(n,n+=o.colormap_length*(o.colormap_size>>3))),s){l=new Uint8Array(f);for(var d,p,m,_=0,g=new Uint8Array(u);n>t._ORIGIN_SHIFT){default:case t._ORIGIN_UL:v=0,x=1,T=o.width,y=0,b=1,A=o.height;break;case t._ORIGIN_BL:v=0,x=1,T=o.width,y=o.height-1,b=-1,A=-1;break;case t._ORIGIN_UR:v=o.width-1,x=-1,T=-1,y=0,b=1,A=o.height;break;case t._ORIGIN_BR:v=o.width-1,x=-1,T=-1,y=o.height-1,b=-1,A=-1}var E="_getImageData"+(h?"Grey":"")+o.pixel_size+"bits",P=t[E](o,c,l,y,b,A,v,x,T);i.texImage2D(i.TEXTURE_2D,0,i.RGBA,o.width,o.height,0,i.RGBA,i.UNSIGNED_BYTE,P)},t._getImageData8bits=function(e,t,i,r,n,o,s,a,h){var l,c,u,f=i,d=t,p=e.width,m=e.height,_=0,g=new Uint8Array(p*m*4);for(u=r;u!==o;u+=n)for(c=s;c!==h;c+=a,_++)l=f[_],g[4*(c+p*u)+3]=255,g[4*(c+p*u)+2]=d[3*l+0],g[4*(c+p*u)+1]=d[3*l+1],g[4*(c+p*u)+0]=d[3*l+2];return g},t._getImageData16bits=function(e,t,i,r,n,o,s,a,h){var l,c,u,f=i,d=e.width,p=e.height,m=0,_=new Uint8Array(d*p*4);for(u=r;u!==o;u+=n)for(c=s;c!==h;c+=a,m+=2)l=f[m+0]+(f[m+1]<<8),_[4*(c+d*u)+0]=(31744&l)>>7,_[4*(c+d*u)+1]=(992&l)>>2,_[4*(c+d*u)+2]=(31&l)>>3,_[4*(c+d*u)+3]=32768&l?0:255;return _},t._getImageData24bits=function(e,t,i,r,n,o,s,a,h){var l,c,u=i,f=e.width,d=e.height,p=0,m=new Uint8Array(f*d*4);for(c=r;c!==o;c+=n)for(l=s;l!==h;l+=a,p+=3)m[4*(l+f*c)+3]=255,m[4*(l+f*c)+2]=u[p+0],m[4*(l+f*c)+1]=u[p+1],m[4*(l+f*c)+0]=u[p+2];return m},t._getImageData32bits=function(e,t,i,r,n,o,s,a,h){var l,c,u=i,f=e.width,d=e.height,p=0,m=new Uint8Array(f*d*4);for(c=r;c!==o;c+=n)for(l=s;l!==h;l+=a,p+=4)m[4*(l+f*c)+2]=u[p+0],m[4*(l+f*c)+1]=u[p+1],m[4*(l+f*c)+0]=u[p+2],m[4*(l+f*c)+3]=u[p+3];return m},t._getImageDataGrey8bits=function(e,t,i,r,n,o,s,a,h){var l,c,u,f=i,d=e.width,p=e.height,m=0,_=new Uint8Array(d*p*4);for(u=r;u!==o;u+=n)for(c=s;c!==h;c+=a,m++)l=f[m],_[4*(c+d*u)+0]=l,_[4*(c+d*u)+1]=l,_[4*(c+d*u)+2]=l,_[4*(c+d*u)+3]=255;return _},t._getImageDataGrey16bits=function(e,t,i,r,n,o,s,a,h){var l,c,u=i,f=e.width,d=e.height,p=0,m=new Uint8Array(f*d*4);for(c=r;c!==o;c+=n)for(l=s;l!==h;l+=a,p+=2)m[4*(l+f*c)+0]=u[p+0],m[4*(l+f*c)+1]=u[p+0],m[4*(l+f*c)+2]=u[p+0],m[4*(l+f*c)+3]=u[p+1];return m},t})();i._TYPE_NO_DATA=0,i._TYPE_INDEXED=1,i._TYPE_RGB=2,i._TYPE_GREY=3,i._TYPE_RLE_INDEXED=9,i._TYPE_RLE_RGB=10,i._TYPE_RLE_GREY=11,i._ORIGIN_MASK=48,i._ORIGIN_SHIFT=4,i._ORIGIN_BL=0,i._ORIGIN_BR=1,i._ORIGIN_UL=2,i._ORIGIN_UR=3,t.TGATools=i})(e.Internals||(e.Internals={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){function i(e){return e.charCodeAt(0)+(e.charCodeAt(1)<<8)+(e.charCodeAt(2)<<16)+(e.charCodeAt(3)<<24)}function r(e){return String.fromCharCode(255&e,e>>8&255,e>>16&255,e>>24&255)}var n=i("DXT1"),o=i("DXT3"),s=i("DXT5"),a=i("DX10"),h=(function(){function t(){}return t.GetDDSInfo=function(t){var i=new Int32Array(t,0,31),r=new Int32Array(t,0,35),h=1;131072&i[2]&&(h=Math.max(1,i[7]));var l=i[21],c=l===a?r[32]:0,u=e.Engine.TEXTURETYPE_UNSIGNED_INT;switch(l){case 113:u=e.Engine.TEXTURETYPE_HALF_FLOAT;break;case 116:u=e.Engine.TEXTURETYPE_FLOAT;break;case a:if(10===c){u=e.Engine.TEXTURETYPE_HALF_FLOAT;break}}return{width:i[4],height:i[3],mipmapCount:h,isFourCC:4==(4&i[20]),isRGB:64==(64&i[20]),isLuminance:131072==(131072&i[20]),isCube:512==(512&i[28]),isCompressed:l===n||l===o||n===s,dxgiFormat:c,textureType:u}},t._ToHalfFloat=function(e){t._FloatView||(t._FloatView=new Float32Array(1),t._Int32View=new Int32Array(t._FloatView.buffer)),t._FloatView[0]=e;var i=t._Int32View[0],r=i>>16&32768,n=i>>12&2047,o=i>>23&255;return o<103?r:o>142?(r|=31744,r|=(255==o?0:1)&&8388607&i):o<113?(n|=2048,r|=(n>>114-o)+(n>>113-o&1)):(r|=o-112<<10|n>>1,r+=1&n)},t._FromHalfFloat=function(e){var t=(32768&e)>>15,i=(31744&e)>>10,r=1023&e;return 0===i?(t?-1:1)*Math.pow(2,-14)*(r/Math.pow(2,10)):31==i?r?NaN:1/0*(t?-1:1):(t?-1:1)*Math.pow(2,i-15)*(1+r/Math.pow(2,10))},t._GetHalfFloatAsFloatRGBAArrayBuffer=function(e,i,r,n,o,s){for(var a=new Float32Array(n),h=new Uint16Array(o,r),l=0,c=0;c>8&65280|e>>24&255},t.prototype.uploadLevels=function(e,i){switch(this.loadType){case t.COMPRESSED_2D:this._upload2DCompressedLevels(e,i);break;case t.TEX_2D:case t.COMPRESSED_3D:case t.TEX_3D:}},t.prototype._upload2DCompressedLevels=function(e,i){for(var r=t.HEADER_LEN+this.bytesOfKeyValueData,n=this.pixelWidth,o=this.pixelHeight,s=i?this.numberOfMipmapLevels:1,a=0;a0?this._firstFree=this._freeEntries[this._freeEntries.length-1].offset:this._firstFree+=this._stride),e},e.prototype.freeElement=function(e){this._firstFree=Math.min(e.offset,this._firstFree),this._freeEntries.push(e)},e.prototype.pack=function(){if(0===this._freeEntries.length)return this.buffer;if(this._lastUsed=a);l++){var c=r[l],u=c.offset,f=u-h;if(f!==e){for(var d=f/e-1,p=u-e,m=Math.min(s,d),_=0;_=0;s--){var a=t[s],h=a.getParent();if(h){var l=this._debugLines[n];l||(l=[e.Vector3.Zero(),e.Vector3.Zero()],this._debugLines[n]=l),a.getAbsolutePositionToRef(this.mesh,l[0]),h.getAbsolutePositionToRef(this.mesh,l[1]),l[0].subtractInPlace(o),l[1].subtractInPlace(o),n++}}},t.prototype.update=function(){this.autoUpdateBonesMatrices&&this.skeleton.computeAbsoluteTransforms(),void 0===this.skeleton.bones[0].length?this._getLinesForBonesNoLength(this.skeleton.bones,this.mesh.getWorldMatrix()):this._getLinesForBonesWithLength(this.skeleton.bones,this.mesh.getWorldMatrix()),this._debugMesh?e.MeshBuilder.CreateLineSystem(null,{lines:this._debugLines,updatable:!0,instance:this._debugMesh},this._scene):(this._debugMesh=e.MeshBuilder.CreateLineSystem(null,{lines:this._debugLines,updatable:!0},this._scene),this._debugMesh.renderingGroupId=this.renderingGroupId),this._debugMesh.position.copyFrom(this.mesh.position),this._debugMesh.color=this.color},t.prototype.dispose=function(){this._debugMesh&&(this.isEnabled=!1,this._debugMesh.dispose(),this._debugMesh=null)},t})();t.SkeletonViewer=i})(e.Debug||(e.Debug={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){var i=(function(){function t(t,i){void 0===i&&(i=1),this._xline=[e.Vector3.Zero(),e.Vector3.Zero()],this._yline=[e.Vector3.Zero(),e.Vector3.Zero()],this._zline=[e.Vector3.Zero(),e.Vector3.Zero()],this.scaleLines=1,this.scaleLines=i,this._xmesh=e.Mesh.CreateLines("xline",this._xline,t,!0),this._ymesh=e.Mesh.CreateLines("yline",this._yline,t,!0),this._zmesh=e.Mesh.CreateLines("zline",this._zline,t,!0),this._xmesh.renderingGroupId=2,this._ymesh.renderingGroupId=2,this._zmesh.renderingGroupId=2,this._xmesh.material.checkReadyOnlyOnce=!0,this._xmesh.color=new e.Color3(1,0,0),this._ymesh.material.checkReadyOnlyOnce=!0,this._ymesh.color=new e.Color3(0,1,0),this._zmesh.material.checkReadyOnlyOnce=!0,this._zmesh.color=new e.Color3(0,0,1),this.scene=t}return t.prototype.update=function(t,i,r,n){var o=this.scaleLines;this._xmesh.position.copyFrom(t),this._ymesh.position.copyFrom(t),this._zmesh.position.copyFrom(t);var s=this._xline[1];s.x=i.x*o,s.y=i.y*o,s.z=i.z*o,e.Mesh.CreateLines(null,this._xline,null,null,this._xmesh),s=this._yline[1],s.x=r.x*o,s.y=r.y*o,s.z=r.z*o,e.Mesh.CreateLines(null,this._yline,null,null,this._ymesh),s=this._zline[1],s.x=n.x*o,s.y=n.y*o,s.z=n.z*o,e.Mesh.CreateLines(null,this._zline,null,null,this._zmesh)},t.prototype.dispose=function(){this._xmesh&&(this._xmesh.dispose(),this._ymesh.dispose(),this._zmesh.dispose(),this._xmesh=null,this._ymesh=null,this._zmesh=null,this._xline=null,this._yline=null,this._zline=null,this.scene=null)},t})();t.AxesViewer=i})(e.Debug||(e.Debug={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){var i=(function(t){function i(i,r,n,o){void 0===o&&(o=1);var s=t.call(this,i,o)||this;return s.pos=e.Vector3.Zero(),s.xaxis=e.Vector3.Zero(),s.yaxis=e.Vector3.Zero(),s.zaxis=e.Vector3.Zero(),s.mesh=n,s.bone=r,s}return __extends(i,t),i.prototype.update=function(){var i=this.bone;i.getAbsolutePositionToRef(this.mesh,this.pos),i.getDirectionToRef(e.Axis.X,this.mesh,this.xaxis),i.getDirectionToRef(e.Axis.Y,this.mesh,this.yaxis),i.getDirectionToRef(e.Axis.Z,this.mesh,this.zaxis),t.prototype.update.call(this,this.pos,this.xaxis,this.yaxis,this.zaxis)},i.prototype.dispose=function(){this.pos&&(this.pos=null,this.xaxis=null,this.yaxis=null,this.zaxis=null,this.mesh=null,this.bone=null,t.prototype.dispose.call(this))},i})(t.AxesViewer);t.BoneAxesViewer=i})(e.Debug||(e.Debug={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e){this.ray=e}return t.CreateAndShow=function(e,i,r){var n=new t(e);return n.show(i,r),n},t.prototype.show=function(t,i){if(!this._renderFunction){var r=this.ray;this._renderFunction=this._render.bind(this),this._scene=t,this._renderPoints=[r.origin,r.origin.add(r.direction.scale(r.length))],this._renderLine=e.Mesh.CreateLines("ray",this._renderPoints,t,!0),this._scene.registerBeforeRender(this._renderFunction)}i&&this._renderLine.color.copyFrom(i)},t.prototype.hide=function(){this._renderFunction&&(this._scene.unregisterBeforeRender(this._renderFunction),this._scene=null,this._renderFunction=null,this._renderLine.dispose(),this._renderLine=null,this._renderPoints=null)},t.prototype._render=function(){var t=this.ray,i=this._renderPoints[1],r=Math.min(t.length,1e6);i.copyFrom(t.direction),i.scaleInPlace(r),i.addInPlace(t.origin),e.Mesh.CreateLines("ray",this._renderPoints,this._scene,!0,this._renderLine)},t.prototype.attachToMesh=function(t,i,r,n){this._attachedToMesh=t;var o=this.ray;o.direction||(o.direction=e.Vector3.Zero()),o.origin||(o.origin=e.Vector3.Zero()),n&&(o.length=n),r||(r=e.Vector3.Zero()),i||(i=new e.Vector3(0,0,-1)),this._meshSpaceDirection?(this._meshSpaceDirection.copyFrom(i),this._meshSpaceOrigin.copyFrom(r)):(this._meshSpaceDirection=i.clone(),this._meshSpaceOrigin=r.clone()),this._updateToMeshFunction||(this._updateToMeshFunction=this._updateToMesh.bind(this),this._attachedToMesh.getScene().registerBeforeRender(this._updateToMeshFunction)),this._updateToMesh()},t.prototype.detachFromMesh=function(){this._attachedToMesh&&(this._attachedToMesh.getScene().unregisterBeforeRender(this._updateToMeshFunction),this._attachedToMesh=null,this._updateToMeshFunction=null)},t.prototype._updateToMesh=function(){var t=this.ray;if(this._attachedToMesh._isDisposed)return void this.detachFromMesh();this._attachedToMesh.getDirectionToRef(this._meshSpaceDirection,t.direction),e.Vector3.TransformCoordinatesToRef(this._meshSpaceOrigin,this._attachedToMesh.getWorldMatrix(),t.origin)},t.prototype.dispose=function(){this.hide(),this.detachFromMesh(),this.ray=null},t})();e.RayHelper=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e){this._scene=e}return t.prototype._createInspector=function(e){void 0===e&&(e={});var t=e.popup||!1,i=e.initialTab||0,r=e.parentElement||null;this._inspector||(this._inspector=new INSPECTOR.Inspector(this._scene,t,i,r,e.newColors))},t.prototype.isVisible=function(){return!!this._inspector},t.prototype.hide=function(){if(this._inspector){try{this._inspector.dispose()}catch(e){}this._inspector=null}},t.prototype.show=function(i){void 0===i&&(i={}),"undefined"==typeof INSPECTOR?e.Tools.LoadScript(t.InspectorURL,this._createInspector.bind(this,i)):this._createInspector(i)},t})();t.InspectorURL=window.location.href.split("/")[0]+"//preview.babylonjs.com/inspector/babylon.inspector.bundle.js",e.DebugLayer=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){var i=(function(){function t(t){this._impostors=[],this._meshes=[],this._numMeshes=0,this._scene=t||e.Engine.LastCreatedScene,this._physicsEnginePlugin=this._scene.getPhysicsEngine().getPhysicsPlugin()}return t.prototype._updateDebugMeshes=function(){for(var e=this._physicsEnginePlugin,t=0;t0?(this._meshes[i]=this._meshes[this._numMeshes],this._impostors[i]=this._impostors[this._numMeshes],this._meshes[this._numMeshes]=null,this._impostors[this._numMeshes]=null):(this._meshes[0]=null,this._impostors[0]=null),t=!0;break}t&&0===this._numMeshes&&this._scene.unregisterBeforeRender(this._renderFunction)},t.prototype._getDebugMaterial=function(t){return this._debugMaterial||(this._debugMaterial=new e.StandardMaterial("",t),this._debugMaterial.wireframe=!0),this._debugMaterial},t.prototype._getDebugBoxMesh=function(t){return this._debugBoxMesh||(this._debugBoxMesh=e.MeshBuilder.CreateBox("physicsBodyBoxViewMesh",{size:1},t),this._debugBoxMesh.renderingGroupId=1,this._debugBoxMesh.rotationQuaternion=e.Quaternion.Identity(),this._debugBoxMesh.material=this._getDebugMaterial(t),t.removeMesh(this._debugBoxMesh)),this._debugBoxMesh.createInstance("physicsBodyBoxViewInstance")},t.prototype._getDebugSphereMesh=function(t){return this._debugSphereMesh||(this._debugSphereMesh=e.MeshBuilder.CreateSphere("physicsBodySphereViewMesh",{diameter:1},t),this._debugSphereMesh.renderingGroupId=1,this._debugSphereMesh.rotationQuaternion=e.Quaternion.Identity(),this._debugSphereMesh.material=this._getDebugMaterial(t),t.removeMesh(this._debugSphereMesh)),this._debugSphereMesh.createInstance("physicsBodyBoxViewInstance")},t.prototype._getDebugMesh=function(t,i){var r,n=t.physicsBody;n.shapes[0];if(t.type==e.PhysicsImpostor.BoxImpostor)r=this._getDebugBoxMesh(i),t.getBoxSizeToRef(r.scaling);else if(t.type==e.PhysicsImpostor.SphereImpostor){r=this._getDebugSphereMesh(i);var o=t.getRadius();r.scaling.x=2*o,r.scaling.y=2*o,r.scaling.z=2*o}return r},t.prototype.dispose=function(){for(var e=0;e=0&&(this._targets.splice(t,1),e.onInfluenceChanged.remove(this._targetObservable.splice(t,1)[0]),this._vertexCount=0,this._syncActiveTargets(!0))},t.prototype.serialize=function(){var e={};e.id=this.uniqueId,e.targets=[];for(var t=0,i=this._targets;t0&&(this._activeTargets.push(n),this._tempInfluences[t++]=n.influence,this._supportsNormals=this._supportsNormals&&n.hasNormals,this._supportsTangents=this._supportsTangents&&n.hasTangents,0===this._vertexCount&&(this._vertexCount=n.getPositions().length/3))}this._influences&&this._influences.length===t||(this._influences=new Float32Array(t));for(var o=0;o0&&(p+1)%4==0)o[p]=255;else{var x=s[p];o[p]=x/d*255}t.getScene().getEngine().updateTextureSize(r,l*l,l),t.getScene().getEngine().updateRawTexture(r,o,e.Engine.TEXTUREFORMAT_RGBA,!1)};return e.Tools.LoadFile(this.url,n),this._texture},i.prototype.loadTexture=function(){this.url&&this.url.toLocaleLowerCase().indexOf(".3dl")==this.url.length-4&&this.load3dlTexture()},i.prototype.clone=function(){var e=new i(this.url,this.getScene());return e.level=this.level,e},i.prototype.delayLoad=function(){this.delayLoadState===e.Engine.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=e.Engine.DELAYLOADSTATE_LOADED,this._texture=this._getFromCache(this.url,!0),this._texture||this.loadTexture())},i.Parse=function(t,i,r){var n=null;return t.name&&!t.isRenderTarget&&(n=new e.ColorGradingTexture(t.name,i),n.name=t.name,n.level=t.level),n},i.prototype.serialize=function(){if(!this.name)return null;var e={};return e.name=this.name,e.level=this.level,e.customType="BABYLON.ColorGradingTexture",e},i})(e.BaseTexture);t._noneEmptyLineRegex=/\S+/,e.ColorGradingTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this._dirty=!0,this._tempColor=new e.Color4(0,0,0,0),this._globalCurve=new e.Color4(0,0,0,0),this._highlightsCurve=new e.Color4(0,0,0,0),this._midtonesCurve=new e.Color4(0,0,0,0),this._shadowsCurve=new e.Color4(0,0,0,0),this._positiveCurve=new e.Color4(0,0,0,0),this._negativeCurve=new e.Color4(0,0,0,0),this._globalHue=30,this._globalDensity=0,this._globalSaturation=0,this._globalExposure=0,this._highlightsHue=30,this._highlightsDensity=0,this._highlightsSaturation=0,this._highlightsExposure=0,this._midtonesHue=30,this._midtonesDensity=0,this._midtonesSaturation=0,this._midtonesExposure=0,this._shadowsHue=30,this._shadowsDensity=0,this._shadowsSaturation=0,this._shadowsExposure=0}return Object.defineProperty(t.prototype,"globalHue",{get:function(){return this._globalHue},set:function(e){this._globalHue=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"globalDensity",{get:function(){return this._globalDensity},set:function(e){this._globalDensity=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"globalSaturation",{get:function(){return this._globalSaturation},set:function(e){this._globalSaturation=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"highlightsHue",{get:function(){return this._highlightsHue},set:function(e){this._highlightsHue=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"highlightsDensity",{get:function(){return this._highlightsDensity},set:function(e){this._highlightsDensity=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"highlightsSaturation",{get:function(){return this._highlightsSaturation},set:function(e){this._highlightsSaturation=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"highlightsExposure",{get:function(){return this._highlightsExposure},set:function(e){this._highlightsExposure=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"midtonesHue",{get:function(){return this._midtonesHue},set:function(e){this._midtonesHue=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"midtonesDensity",{get:function(){return this._midtonesDensity},set:function(e){this._midtonesDensity=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"midtonesSaturation",{get:function(){return this._midtonesSaturation},set:function(e){this._midtonesSaturation=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"midtonesExposure",{get:function(){return this._midtonesExposure},set:function(e){this._midtonesExposure=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"shadowsHue",{get:function(){return this._shadowsHue},set:function(e){this._shadowsHue=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"shadowsDensity",{get:function(){return this._shadowsDensity},set:function(e){this._shadowsDensity=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"shadowsSaturation",{get:function(){return this._shadowsSaturation},set:function(e){this._shadowsSaturation=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"shadowsExposure",{get:function(){return this._shadowsExposure},set:function(e){ +this._shadowsExposure=e,this._dirty=!0},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return"ColorCurves"},t.Bind=function(e,t,i,r,n){void 0===i&&(i="vCameraColorCurvePositive"),void 0===r&&(r="vCameraColorCurveNeutral"),void 0===n&&(n="vCameraColorCurveNegative"),e._dirty&&(e._dirty=!1,e.getColorGradingDataToRef(e._globalHue,e._globalDensity,e._globalSaturation,e._globalExposure,e._globalCurve),e.getColorGradingDataToRef(e._highlightsHue,e._highlightsDensity,e._highlightsSaturation,e._highlightsExposure,e._tempColor),e._tempColor.multiplyToRef(e._globalCurve,e._highlightsCurve),e.getColorGradingDataToRef(e._midtonesHue,e._midtonesDensity,e._midtonesSaturation,e._midtonesExposure,e._tempColor),e._tempColor.multiplyToRef(e._globalCurve,e._midtonesCurve),e.getColorGradingDataToRef(e._shadowsHue,e._shadowsDensity,e._shadowsSaturation,e._shadowsExposure,e._tempColor),e._tempColor.multiplyToRef(e._globalCurve,e._shadowsCurve),e._highlightsCurve.subtractToRef(e._midtonesCurve,e._positiveCurve),e._midtonesCurve.subtractToRef(e._shadowsCurve,e._negativeCurve)),t&&(t.setFloat4(i,e._positiveCurve.r,e._positiveCurve.g,e._positiveCurve.b,e._positiveCurve.a),t.setFloat4(r,e._midtonesCurve.r,e._midtonesCurve.g,e._midtonesCurve.b,e._midtonesCurve.a),t.setFloat4(n,e._negativeCurve.r,e._negativeCurve.g,e._negativeCurve.b,e._negativeCurve.a))},t.PrepareUniforms=function(e){e.push("vCameraColorCurveNeutral","vCameraColorCurvePositive","vCameraColorCurveNegative")},t.prototype.getColorGradingDataToRef=function(e,i,r,n,o){null!=e&&(e=t.clamp(e,0,360),i=t.clamp(i,-100,100),r=t.clamp(r,-100,100),n=t.clamp(n,-100,100),i=t.applyColorGradingSliderNonlinear(i),i*=.5,n=t.applyColorGradingSliderNonlinear(n),i<0&&(i*=-1,e=(e+180)%360),t.fromHSBToRef(e,i,50+.25*n,o),o.scaleToRef(2,o),o.a=1+.01*r)},t.applyColorGradingSliderNonlinear=function(e){e/=100;var t=Math.abs(e);return t=Math.pow(t,2),e<0&&(t*=-1),t*=100},t.fromHSBToRef=function(e,i,r,n){var o=t.clamp(e,0,360),s=t.clamp(i/100,0,1),a=t.clamp(r/100,0,1);if(0===s)n.r=a,n.g=a,n.b=a;else{o/=60;var h=Math.floor(o),l=o-h,c=a*(1-s),u=a*(1-s*l),f=a*(1-s*(1-l));switch(h){case 0:n.r=a,n.g=f,n.b=c;break;case 1:n.r=u,n.g=a,n.b=c;break;case 2:n.r=c,n.g=a,n.b=f;break;case 3:n.r=c,n.g=u,n.b=a;break;case 4:n.r=f,n.g=c,n.b=a;break;default:n.r=a,n.g=c,n.b=u}}n.a=1},t.clamp=function(e,t,i){return Math.min(Math.max(e,t),i)},t.prototype.clone=function(){return e.SerializationHelper.Clone((function(){return new t}),this)},t.prototype.serialize=function(){return e.SerializationHelper.Serialize(this)},t.Parse=function(i){return e.SerializationHelper.Parse((function(){return new t}),i,null,null)},t})();__decorate([e.serialize()],t.prototype,"_globalHue",void 0),__decorate([e.serialize()],t.prototype,"_globalDensity",void 0),__decorate([e.serialize()],t.prototype,"_globalSaturation",void 0),__decorate([e.serialize()],t.prototype,"_globalExposure",void 0),__decorate([e.serialize()],t.prototype,"_highlightsHue",void 0),__decorate([e.serialize()],t.prototype,"_highlightsDensity",void 0),__decorate([e.serialize()],t.prototype,"_highlightsSaturation",void 0),__decorate([e.serialize()],t.prototype,"_highlightsExposure",void 0),__decorate([e.serialize()],t.prototype,"_midtonesHue",void 0),__decorate([e.serialize()],t.prototype,"_midtonesDensity",void 0),__decorate([e.serialize()],t.prototype,"_midtonesSaturation",void 0),__decorate([e.serialize()],t.prototype,"_midtonesExposure",void 0),e.ColorCurves=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t,i,r){void 0===r&&(r=2),this.maxDepth=r,this.dynamicContent=new Array,this._maxBlockCapacity=i||64,this._selectionContent=new e.SmartArray(1024),this._creationFunc=t}return t.prototype.update=function(e,i,r){t._CreateBlocks(e,i,r,this._maxBlockCapacity,0,this.maxDepth,this,this._creationFunc)},t.prototype.addMesh=function(e){for(var t=0;tthis.capacity&&this._depth>>16&65535,r=65535&e,n=t>>>16&65535,o=65535&t;return r*o+(i*o+r*n<<16>>>0)|0}),e.Matrix.prototype.multiplyToArray=i.prototype.multiplyToArraySIMD,e.Matrix.prototype.invertToRef=i.prototype.invertToRefSIMD,e.Matrix.LookAtLHToRef=i.LookAtLHToRefSIMD,e.Vector3.TransformCoordinatesToRef=t.TransformCoordinatesToRefSIMD,e.Vector3.TransformCoordinatesFromFloatsToRef=t.TransformCoordinatesFromFloatsToRefSIMD,h._isEnabled=!0)},h})();h._isEnabled=!1,e.SIMDHelper=h})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o){var s=t.call(this,i,"vrDistortionCorrection",["LensCenter","Scale","ScaleIn","HmdWarpParam"],null,o.postProcessScaleFactor,r,e.Texture.BILINEAR_SAMPLINGMODE,null,null)||this;return s._isRightEye=n,s._distortionFactors=o.distortionK,s._postProcessScaleFactor=o.postProcessScaleFactor,s._lensCenterOffset=o.lensCenterOffset,s.onSizeChangedObservable.add((function(){s.aspectRatio=.5*s.width/s.height,s._scaleIn=new e.Vector2(2,2/s.aspectRatio),s._scaleFactor=new e.Vector2(1/s._postProcessScaleFactor*.5,1/s._postProcessScaleFactor*.5*s.aspectRatio),s._lensCenter=new e.Vector2(s._isRightEye?.5-.5*s._lensCenterOffset:.5+.5*s._lensCenterOffset,.5)})),s.onApplyObservable.add((function(e){e.setFloat2("LensCenter",s._lensCenter.x,s._lensCenter.y),e.setFloat2("Scale",s._scaleFactor.x,s._scaleFactor.y),e.setFloat2("ScaleIn",s._scaleIn.x,s._scaleIn.y),e.setFloat4("HmdWarpParam",s._distortionFactors[0],s._distortionFactors[1],s._distortionFactors[2],s._distortionFactors[3])})),s}return __extends(i,t),i})(e.PostProcess);e.VRDistortionCorrectionPostProcess=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(e){function t(t,i,r,n,o,s){var a=e.call(this,t,"anaglyph",null,["leftSampler"],i,r[1],n,o,s)||this;return a._passedProcess=r[0]._rigPostProcess,a.onApplyObservable.add((function(e){e.setTextureFromPostProcess("leftSampler",a._passedProcess)})),a}return __extends(t,e),t})(e.PostProcess);e.AnaglyphPostProcess=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o,s,a){var h=t.call(this,i,"stereoscopicInterlace",["stepSize"],["camASampler"],1,r[1],o,s,a,n?"#define IS_STEREOSCOPIC_HORIZ 1":void 0)||this;return h._passedProcess=r[0]._rigPostProcess,h._stepSize=new e.Vector2(1/h.width,1/h.height),h.onSizeChangedObservable.add((function(){h._stepSize=new e.Vector2(1/h.width,1/h.height)})),h.onApplyObservable.add((function(e){e.setTextureFromPostProcess("camASampler",h._passedProcess),e.setFloat2("stepSize",h._stepSize.x,h._stepSize.y)})),h}return __extends(i,t),i})(e.PostProcess);e.StereoscopicInterlacePostProcess=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){var t=this;this._screenOrientationAngle=0,this._screenQuaternion=new e.Quaternion,this._alpha=0,this._beta=0,this._gamma=0,this._orientationChanged=function(){t._screenOrientationAngle=void 0!==window.orientation?+window.orientation:window.screen.orientation&&window.screen.orientation.angle?window.screen.orientation.angle:0,t._screenOrientationAngle=-e.Tools.ToRadians(t._screenOrientationAngle/2),t._screenQuaternion.copyFromFloats(0,Math.sin(t._screenOrientationAngle),0,Math.cos(t._screenOrientationAngle))},this._deviceOrientation=function(e){t._alpha=e.alpha,t._beta=e.beta,t._gamma=e.gamma},this._constantTranform=new e.Quaternion(-Math.sqrt(.5),0,0,Math.sqrt(.5)),this._orientationChanged()}return Object.defineProperty(t.prototype,"camera",{get:function(){return this._camera},set:function(t){this._camera=t,this._camera.rotationQuaternion||(this._camera.rotationQuaternion=new e.Quaternion)},enumerable:!0,configurable:!0}),t.prototype.attachControl=function(e,t){window.addEventListener("orientationchange",this._orientationChanged),window.addEventListener("deviceorientation",this._deviceOrientation),this._orientationChanged()},t.prototype.detachControl=function(e){window.removeEventListener("orientationchange",this._orientationChanged),window.removeEventListener("deviceorientation",this._deviceOrientation)},t.prototype.checkInputs=function(){this._alpha&&(e.Quaternion.RotationYawPitchRollToRef(e.Tools.ToRadians(this._alpha),e.Tools.ToRadians(this._beta),-e.Tools.ToRadians(this._gamma),this.camera.rotationQuaternion),this._camera.rotationQuaternion.multiplyInPlace(this._screenQuaternion),this._camera.rotationQuaternion.multiplyInPlace(this._constantTranform),this._camera.rotationQuaternion.z*=-1,this._camera.rotationQuaternion.w*=-1)},t.prototype.getClassName=function(){return"FreeCameraDeviceOrientationInput"},t.prototype.getSimpleName=function(){return"deviceOrientation"},t})();e.FreeCameraDeviceOrientationInput=t,e.CameraInputTypes.FreeCameraDeviceOrientationInput=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(){this.alphaCorrection=1,this.betaCorrection=1,this.gammaCorrection=1,this._alpha=0,this._beta=0,this._gamma=0,this._dirty=!1,this._deviceOrientationHandler=this._onOrientationEvent.bind(this)}return e.prototype.attachControl=function(e,t){this.camera.attachControl(e,t),window.addEventListener("deviceorientation",this._deviceOrientationHandler)},e.prototype._onOrientationEvent=function(e){this.camera;this._alpha=0|+e.alpha,this._beta=0|+e.beta,this._gamma=0|+e.gamma,this._dirty=!0},e.prototype.checkInputs=function(){this._dirty&&(this._dirty=!1,this._gamma<0&&(this._gamma=180+this._gamma),this.camera.alpha=-this._alpha/180*Math.PI%Math.PI*2,this.camera.beta=this._gamma/180*Math.PI)},e.prototype.detachControl=function(e){window.removeEventListener("deviceorientation",this._deviceOrientationHandler)},e.prototype.getClassName=function(){return"ArcRotateCameraVRDeviceOrientationInput"},e.prototype.getSimpleName=function(){return"VRDeviceOrientation"},e})();e.ArcRotateCameraVRDeviceOrientationInput=t,e.CameraInputTypes.ArcRotateCameraVRDeviceOrientationInput=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this.compensateDistortion=!0}return Object.defineProperty(t.prototype,"aspectRatio",{get:function(){return this.hResolution/(2*this.vResolution)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"aspectRatioFov",{get:function(){return 2*Math.atan(this.postProcessScaleFactor*this.vScreenSize/(2*this.eyeToScreenDistance))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"leftHMatrix",{get:function(){var t=this.hScreenSize/4-this.lensSeparationDistance/2,i=4*t/this.hScreenSize;return e.Matrix.Translation(i,0,0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rightHMatrix",{get:function(){var t=this.hScreenSize/4-this.lensSeparationDistance/2,i=4*t/this.hScreenSize;return e.Matrix.Translation(-i,0,0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"leftPreViewMatrix",{get:function(){return e.Matrix.Translation(.5*this.interpupillaryDistance,0,0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rightPreViewMatrix",{get:function(){return e.Matrix.Translation(-.5*this.interpupillaryDistance,0,0)},enumerable:!0,configurable:!0}),t.GetDefault=function(){var e=new t;return e.hResolution=1280,e.vResolution=800,e.hScreenSize=.149759993,e.vScreenSize=.0935999975,e.vScreenCenter=.0467999987,e.eyeToScreenDistance=.0410000011,e.lensSeparationDistance=.063500002,e.interpupillaryDistance=.064000003,e.distortionK=[1,.219999999,.239999995,0],e.chromaAbCorrection=[.995999992,-.00400000019,1.01400006,0],e.postProcessScaleFactor=1.714605507808412,e.lensCenterOffset=.151976421,e},t})();e.VRCameraMetrics=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o){void 0===o&&(o={});var s=t.call(this,i,r,n)||this;return s.webVROptions=o,s._vrDevice=null,s.rawPose=null,s._vrEnabled=!1,s._specsVersion=1.1,s._attached=!1,s._positionOffset=e.Vector3.Zero(),s._descendants=[],s.devicePosition=e.Vector3.Zero(),s.deviceScaleFactor=1,s.controllers=[],s.nonVRControllers=[],s.rigParenting=!0,5===arguments.length&&(s.webVROptions=arguments[4]),void 0==s.webVROptions.trackPosition&&(s.webVROptions.trackPosition=!0),void 0==s.webVROptions.controllerMeshes&&(s.webVROptions.controllerMeshes=!0),void 0==s.webVROptions.defaultLightningOnControllers&&(s.webVROptions.defaultLightningOnControllers=!0),s.rotationQuaternion=new e.Quaternion,s.deviceRotationQuaternion=new e.Quaternion,s.webVROptions&&s.webVROptions.positionScale&&(s.deviceScaleFactor=s.webVROptions.positionScale),s.getEngine().initWebVR(),window.VRFrameData?s._frameData=new VRFrameData:(s._specsVersion=1,s._frameData={}),s.getEngine().getVRDevice(s.webVROptions.displayName,(function(t){t&&(s._vrEnabled=!0,s._vrDevice=t,s.setCameraRigMode(e.Camera.RIG_MODE_WEBVR,{parentCamera:s,vrDisplay:s._vrDevice,frameData:s._frameData,specs:s._specsVersion}),s._attached&&s.getEngine().enableVR(s._vrDevice))})),s.initControllers(),n.onBeforeCameraRenderObservable.add((function(e){e.parent===s&&s.rigParenting&&(s._descendants=s.getDescendants(!0,(function(e){var t=s.controllers.some((function(t){return t._mesh===e})),i=-1!==s._rigCameras.indexOf(e);return!t&&!i})),s._descendants.forEach((function(t){t.parent=e})))})),n.onAfterCameraRenderObservable.add((function(e){e.parent===s&&s.rigParenting&&s._descendants.forEach((function(e){e.parent=s}))})),s}return __extends(i,t),Object.defineProperty(i.prototype,"onControllersAttached",{set:function(e){this._onControllersAttached=e,this.controllers.length>=2&&e(this.controllers)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"onNonVRControllerAttached",{set:function(e){this._onNonVRControllerAttached=e,this.nonVRControllers.forEach((function(t){e(t)}))},enumerable:!0,configurable:!0}),i.prototype.getControllerByName=function(e){for(var t=0,i=this.controllers;t=2)){for(var n=!1,o=0;oi.halfWidth,t&&this._joystickPointerID<0?(this._joystickPointerID=e.pointerId,this._joystickPointerStartPos.x=e.clientX,this._joystickPointerStartPos.y=e.clientY,this._joystickPointerPos=this._joystickPointerStartPos.clone(),this._joystickPreviousPointerPos=this._joystickPointerStartPos.clone(),this._deltaJoystickVector.x=0,this._deltaJoystickVector.y=0,this.pressed=!0,this._touches.add(e.pointerId.toString(),e)):i._globalJoystickIndex<2&&this._action&&(this._action(),this._touches.add(e.pointerId.toString(),{x:e.clientX,y:e.clientY,prevX:e.clientX,prevY:e.clientY}))},i.prototype._onPointerMove=function(e){if(this._joystickPointerID==e.pointerId){this._joystickPointerPos.x=e.clientX,this._joystickPointerPos.y=e.clientY,this._deltaJoystickVector=this._joystickPointerPos.clone(),this._deltaJoystickVector=this._deltaJoystickVector.subtract(this._joystickPointerStartPos);var i=this.reverseLeftRight?-1:1,r=i*this._deltaJoystickVector.x/this._inversedSensibility;switch(this._axisTargetedByLeftAndRight){case t.X:this.deltaPosition.x=Math.min(1,Math.max(-1,r));break;case t.Y:this.deltaPosition.y=Math.min(1,Math.max(-1,r));break;case t.Z:this.deltaPosition.z=Math.min(1,Math.max(-1,r))}var n=this.reverseUpDown?1:-1,o=n*this._deltaJoystickVector.y/this._inversedSensibility;switch(this._axisTargetedByUpAndDown){case t.X:this.deltaPosition.x=Math.min(1,Math.max(-1,o));break;case t.Y:this.deltaPosition.y=Math.min(1,Math.max(-1,o));break;case t.Z:this.deltaPosition.z=Math.min(1,Math.max(-1,o))}}else{var s=this._touches.get(e.pointerId.toString());s&&(s.x=e.clientX,s.y=e.clientY)}},i.prototype._onPointerUp=function(e){if(this._joystickPointerID==e.pointerId)i.vjCanvasContext.clearRect(this._joystickPointerStartPos.x-64,this._joystickPointerStartPos.y-64,128,128),i.vjCanvasContext.clearRect(this._joystickPreviousPointerPos.x-42,this._joystickPreviousPointerPos.y-42,84,84),this._joystickPointerID=-1,this.pressed=!1;else{var t=this._touches.get(e.pointerId.toString());t&&i.vjCanvasContext.clearRect(t.prevX-44,t.prevY-44,88,88)}this._deltaJoystickVector.x=0,this._deltaJoystickVector.y=0,this._touches.remove(e.pointerId.toString())},i.prototype.setJoystickColor=function(e){this._joystickColor=e},i.prototype.setActionOnTouch=function(e){this._action=e},i.prototype.setAxisForLeftRight=function(e){switch(e){case t.X:case t.Y:case t.Z:this._axisTargetedByLeftAndRight=e;break;default:this._axisTargetedByLeftAndRight=t.X}},i.prototype.setAxisForUpDown=function(e){switch(e){case t.X:case t.Y:case t.Z:this._axisTargetedByUpAndDown=e;break;default:this._axisTargetedByUpAndDown=t.Y}},i.prototype._clearCanvas=function(){this._leftJoystick?i.vjCanvasContext.clearRect(0,0,i.vjCanvasWidth/2,i.vjCanvasHeight):i.vjCanvasContext.clearRect(i.vjCanvasWidth/2,0,i.vjCanvasWidth,i.vjCanvasHeight)},i.prototype._drawVirtualJoystick=function(){var e=this;this.pressed&&this._touches.forEach((function(t,r){r.pointerId===e._joystickPointerID?(i.vjCanvasContext.clearRect(e._joystickPointerStartPos.x-64,e._joystickPointerStartPos.y-64,128,128),i.vjCanvasContext.clearRect(e._joystickPreviousPointerPos.x-42,e._joystickPreviousPointerPos.y-42,84,84),i.vjCanvasContext.beginPath(),i.vjCanvasContext.lineWidth=6,i.vjCanvasContext.strokeStyle=e._joystickColor,i.vjCanvasContext.arc(e._joystickPointerStartPos.x,e._joystickPointerStartPos.y,40,0,2*Math.PI,!0),i.vjCanvasContext.stroke(),i.vjCanvasContext.closePath(),i.vjCanvasContext.beginPath(),i.vjCanvasContext.strokeStyle=e._joystickColor,i.vjCanvasContext.lineWidth=2,i.vjCanvasContext.arc(e._joystickPointerStartPos.x,e._joystickPointerStartPos.y,60,0,2*Math.PI,!0),i.vjCanvasContext.stroke(),i.vjCanvasContext.closePath(),i.vjCanvasContext.beginPath(),i.vjCanvasContext.strokeStyle=e._joystickColor,i.vjCanvasContext.arc(e._joystickPointerPos.x,e._joystickPointerPos.y,40,0,2*Math.PI,!0),i.vjCanvasContext.stroke(),i.vjCanvasContext.closePath(),e._joystickPreviousPointerPos=e._joystickPointerPos.clone()):(i.vjCanvasContext.clearRect(r.prevX-44,r.prevY-44,88,88),i.vjCanvasContext.beginPath(),i.vjCanvasContext.fillStyle="white",i.vjCanvasContext.beginPath(),i.vjCanvasContext.strokeStyle="red",i.vjCanvasContext.lineWidth=6,i.vjCanvasContext.arc(r.x,r.y,40,0,2*Math.PI,!0),i.vjCanvasContext.stroke(),i.vjCanvasContext.closePath(),r.prevX=r.x,r.prevY=r.y)})),requestAnimationFrame((function(){e._drawVirtualJoystick()}))},i.prototype.releaseCanvas=function(){i.vjCanvas&&(i.vjCanvas.removeEventListener("pointerdown",this._onPointerDownHandlerRef),i.vjCanvas.removeEventListener("pointermove",this._onPointerMoveHandlerRef),i.vjCanvas.removeEventListener("pointerup",this._onPointerUpHandlerRef),i.vjCanvas.removeEventListener("pointerout",this._onPointerUpHandlerRef),window.removeEventListener("resize",this._onResize),document.body.removeChild(i.vjCanvas),i.vjCanvas=null)},i})();i._globalJoystickIndex=0,e.VirtualJoystick=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(e){function t(t,i,r){var n=e.call(this,t,i,r)||this;return n.inputs.addVirtualJoystick(),n}return __extends(t,e),t.prototype.getClassName=function(){return"VirtualJoysticksCamera"},t})(e.FreeCamera);e.VirtualJoysticksCamera=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){}return t.prototype.getLeftJoystick=function(){return this._leftjoystick},t.prototype.getRightJoystick=function(){return this._rightjoystick},t.prototype.checkInputs=function(){if(this._leftjoystick){var t=this.camera,i=50*t._computeLocalCameraSpeed(),r=e.Matrix.RotationYawPitchRoll(t.rotation.y,t.rotation.x,0),n=e.Vector3.TransformCoordinates(new e.Vector3(this._leftjoystick.deltaPosition.x*i,this._leftjoystick.deltaPosition.y*i,this._leftjoystick.deltaPosition.z*i),r);t.cameraDirection=t.cameraDirection.add(n),t.cameraRotation=t.cameraRotation.addVector3(this._rightjoystick.deltaPosition),this._leftjoystick.pressed||(this._leftjoystick.deltaPosition=this._leftjoystick.deltaPosition.scale(.9)),this._rightjoystick.pressed||(this._rightjoystick.deltaPosition=this._rightjoystick.deltaPosition.scale(.9))}},t.prototype.attachControl=function(t,i){this._leftjoystick=new e.VirtualJoystick(!0),this._leftjoystick.setAxisForUpDown(e.JoystickAxis.Z),this._leftjoystick.setAxisForLeftRight(e.JoystickAxis.X),this._leftjoystick.setJoystickSensibility(.15),this._rightjoystick=new e.VirtualJoystick(!1),this._rightjoystick.setAxisForUpDown(e.JoystickAxis.X),this._rightjoystick.setAxisForLeftRight(e.JoystickAxis.Y),this._rightjoystick.reverseUpDown=!0,this._rightjoystick.setJoystickSensibility(.05),this._rightjoystick.setJoystickColor("yellow")},t.prototype.detachControl=function(e){this._leftjoystick.releaseCanvas(),this._rightjoystick.releaseCanvas()},t.prototype.getClassName=function(){return"FreeCameraVirtualJoystickInput"},t.prototype.getSimpleName=function(){return"virtualJoystick"},t})();e.FreeCameraVirtualJoystickInput=t,e.CameraInputTypes.FreeCameraVirtualJoystickInput=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(e,t,i){this.quality=e,this.distance=t,this.optimizeMesh=i}return e})();e.SimplificationSettings=t;var i=(function(){function t(){this.running=!1,this._simplificationArray=[]}return t.prototype.addTask=function(e){this._simplificationArray.push(e)},t.prototype.executeNext=function(){var e=this._simplificationArray.pop();e?(this.running=!0,this.runSimplification(e)):this.running=!1},t.prototype.runSimplification=function(t){var i=this;if(t.parallelProcessing)t.settings.forEach((function(e){i.getSimplifier(t).simplify(e,(function(r){t.mesh.addLODLevel(e.distance,r),r.isVisible=!0,e.quality===t.settings[t.settings.length-1].quality&&t.successCallback&&t.successCallback(),i.executeNext()}))}));else{var r=this.getSimplifier(t),n=function(e,i){r.simplify(e,(function(r){t.mesh.addLODLevel(e.distance,r),r.isVisible=!0,i()}))};e.AsyncLoop.Run(t.settings.length,(function(e){n(t.settings[e.index],(function(){e.executeNext()}))}),(function(){t.successCallback&&t.successCallback(),i.executeNext()}))}},t.prototype.getSimplifier=function(e){switch(e.simplificationType){case r.QUADRATIC:default:return new h(e.mesh)}},t})();e.SimplificationQueue=i;var r;!(function(e){e[e.QUADRATIC=0]="QUADRATIC"})(r=e.SimplificationType||(e.SimplificationType={}));var n=(function(){function e(e){this.vertices=e,this.error=new Array(4),this.deleted=!1,this.isDirty=!1,this.deletePending=!1,this.borderFactor=0}return e})();e.DecimationTriangle=n;var o=(function(){function e(e,t){this.position=e,this.id=t,this.isBorder=!0,this.q=new s,this.triangleCount=0,this.triangleStart=0,this.originalOffsets=[]}return e.prototype.updatePosition=function(e){this.position.copyFrom(e)},e})();e.DecimationVertex=o;var s=(function(){function e(e){this.data=new Array(10);for(var t=0;t<10;++t)e&&e[t]?this.data[t]=e[t]:this.data[t]=0}return e.prototype.det=function(e,t,i,r,n,o,s,a,h){return this.data[e]*this.data[n]*this.data[h]+this.data[i]*this.data[r]*this.data[a]+this.data[t]*this.data[o]*this.data[s]-this.data[i]*this.data[n]*this.data[s]-this.data[e]*this.data[o]*this.data[a]-this.data[t]*this.data[r]*this.data[h]},e.prototype.addInPlace=function(e){for(var t=0;t<10;++t)this.data[t]+=e.data[t]},e.prototype.addArrayInPlace=function(e){for(var t=0;t<10;++t)this.data[t]+=e[t]},e.prototype.add=function(t){for(var i=new e,r=0;r<10;++r)i.data[r]=this.data[r]+t.data[r];return i},e.FromData=function(t,i,r,n){return new e(e.DataFromNumbers(t,i,r,n))},e.DataFromNumbers=function(e,t,i,r){return[e*e,e*t,e*i,e*r,t*t,t*i,t*r,i*i,i*r,r*r]},e})();e.QuadraticMatrix=s;var a=(function(){function e(e,t){this.vertexId=e,this.triangleId=t}return e})();e.Reference=a;var h=(function(){function t(t){this._mesh=t,this.initialized=!1,this.syncIterations=5e3,this.aggressiveness=7,this.decimationIterations=100,this.boundingBoxEpsilon=e.Epsilon}return t.prototype.simplify=function(t,i){var r=this;this.initDecimatedMesh(),e.AsyncLoop.Run(this._mesh.subMeshes.length,(function(e){r.initWithMesh(e.index,(function(){r.runDecimation(t,e.index,(function(){e.executeNext()}))}),t.optimizeMesh)}),(function(){setTimeout((function(){i(r._reconstructedMesh)}),0)}))},t.prototype.isTriangleOnBoundingBox=function(e){var t=this,i=0;return e.vertices.forEach((function(e){var r=0,n=e.position,o=t._mesh.getBoundingInfo().boundingBox;(o.maximum.x-n.xt.boundingBoxEpsilon)&&++r,o.maximum.y!==n.y&&n.y!==o.minimum.y||++r,o.maximum.z!==n.z&&n.z!==o.minimum.z||++r,r>1&&++i})),i>1&&console.log(e,i),i>1},t.prototype.runDecimation=function(t,i,r){var n=this,o=~~(this.triangles.length*t.quality),s=0,a=this.triangles.length,h=function(t,i){setTimeout((function(){t%5==0&&n.updateMesh(0===t);for(var r=0;rh||r.deleted||r.isDirty))for(var o=0;o<3;++o)if(r.error[o]>0,f,(function(){var t=function(e){var t=l.indexStart/3+e,i=3*t,r=h[i+0],o=h[i+1],a=h[i+2],c=s.vertices[u[r-l.verticesStart]],f=s.vertices[u[o-l.verticesStart]],d=s.vertices[u[a-l.verticesStart]],p=new n([c,f,d]);p.originalOffset=i,s.triangles.push(p)};e.AsyncLoop.SyncAsyncForLoop(l.indexCount/3,s.syncIterations,t,(function(){s.init(i)}))}))},t.prototype.init=function(t){var i=this,r=function(t){var r=i.triangles[t];r.normal=e.Vector3.Cross(r.vertices[1].position.subtract(r.vertices[0].position),r.vertices[2].position.subtract(r.vertices[0].position)).normalize();for(var n=0;n<3;n++)r.vertices[n].q.addArrayInPlace(s.DataFromNumbers(r.normal.x,r.normal.y,r.normal.z,-e.Vector3.Dot(r.normal,r.vertices[0].position)))};e.AsyncLoop.SyncAsyncForLoop(this.triangles.length,this.syncIterations,r,(function(){var r=function(e){for(var t=i.triangles[e],r=0;r<3;++r)t.error[r]=i.calculateError(t.vertices[r],t.vertices[(r+1)%3]);t.error[3]=Math.min(t.error[0],t.error[1],t.error[2])};e.AsyncLoop.SyncAsyncForLoop(i.triangles.length,i.syncIterations,r,(function(){i.initialized=!0,t()}))}))},t.prototype.reconstructMesh=function(t){var i,r=[];for(i=0;i0&&this._reconstructedMesh.setVerticesData(e.VertexBuffer.UVKind,h),l.length>0&&this._reconstructedMesh.setVerticesData(e.VertexBuffer.ColorKind,l);var x=this._mesh.subMeshes[t];if(t>0){this._reconstructedMesh.subMeshes=[],g.forEach((function(t){new e.SubMesh(t.materialIndex,t.verticesStart,t.verticesCount,t.indexStart,t.indexCount,t.getMesh())}));new e.SubMesh(x.materialIndex,_,d,m,3*r.length,this._reconstructedMesh)}},t.prototype.initDecimatedMesh=function(){this._reconstructedMesh=new e.Mesh(this._mesh.name+"Decimated",this._mesh.getScene()),this._reconstructedMesh.material=this._mesh.material,this._reconstructedMesh.parent=this._mesh.parent,this._reconstructedMesh.isVisible=!1,this._reconstructedMesh.renderingGroupId=this._mesh.renderingGroupId},t.prototype.isFlipped=function(t,i,r,n,o,s){for(var a=0;a.999)return!0;var p=e.Vector3.Cross(f,d).normalize();if(n[a]=!1,e.Vector3.Dot(p,h.normal)<.2)return!0}else n[a]=!0,s.push(h)}}return!1},t.prototype.updateTriangles=function(e,t,i,r){for(var n=r,o=0;or.maximumSize&&(n.scale(.5),t=!1)}}return t},r}return __extends(t,e),t})(t);e.TextureOptimization=i;var r=(function(e){function t(t,i){void 0===t&&(t=0),void 0===i&&(i=2);var r=e.call(this,t)||this;return r.priority=t,r.maximumScale=i,r._currentScale=1,r.apply=function(e){return r._currentScale++,e.getEngine().setHardwareScalingLevel(r._currentScale),r._currentScale>=r.maximumScale},r}return __extends(t,e),t})(t);e.HardwareScalingOptimization=r;var n=(function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.apply=function(e){return e.shadowsEnabled=!1,!0},t}return __extends(t,e),t})(t);e.ShadowsOptimization=n;var o=(function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.apply=function(e){return e.postProcessesEnabled=!1,!0},t}return __extends(t,e),t})(t);e.PostProcessesOptimization=o;var s=(function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.apply=function(e){return e.lensFlaresEnabled=!1,!0},t}return __extends(t,e),t})(t);e.LensFlaresOptimization=s;var a=(function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.apply=function(e){return e.particlesEnabled=!1,!0},t}return __extends(t,e),t})(t);e.ParticlesOptimization=a;var h=(function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.apply=function(e){return e.renderTargetsEnabled=!1,!0},t}return __extends(t,e),t})(t);e.RenderTargetsOptimization=h;var l=(function(t){function i(){var r=null!==t&&t.apply(this,arguments)||this;return r._canBeMerged=function(t){if(!(t instanceof e.Mesh))return!1;var i=t;return!(!i.isVisible||!i.isEnabled())&&(!(i.instances.length>0)&&(!i.skeleton&&!i.hasLODLevels&&!i.parent))},r.apply=function(t,n){for(var o=t.meshes.slice(0),s=o.length,a=0;a=i.targetFrameRate)return void(n&&n());for(var s=!0,a=!0,h=0;h4&&(n.push(e.VertexBuffer.MatricesIndicesExtraKind),n.push(e.VertexBuffer.MatricesWeightsExtraKind)),r.push("#define NUM_BONE_INFLUENCERS "+o.numBoneInfluencers),r.push("#define BonesPerMesh "+(o.skeleton.bones.length+1))):r.push("#define NUM_BONE_INFLUENCERS 0"),i&&(r.push("#define INSTANCES"),n.push("world0"),n.push("world1"),n.push("world2"),n.push("world3"));var a=r.join("\n");return this._cachedDefines!==a&&(this._cachedDefines=a,this._effect=this._scene.getEngine().createEffect("outline",n,["world","mBones","viewProjection","diffuseMatrix","offset","color"],["diffuseSampler"],a)),this._effect.isReady()},t})();e.OutlineRenderer=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(){this.edges=new Array,this.edgesConnectedCount=0}return e})(),i=(function(){function i(e,t,i){void 0===t&&(t=.95),void 0===i&&(i=!1),this.edgesWidthScalerForOrthographic=1e3,this.edgesWidthScalerForPerspective=50,this._linesPositions=new Array,this._linesNormals=new Array,this._linesIndices=new Array,this._buffers={},this._checkVerticesInsteadOfIndices=!1,this._source=e,this._checkVerticesInsteadOfIndices=i,this._epsilon=t,this._prepareRessources(),this._generateEdgesLines()}return i.prototype._prepareRessources=function(){this._lineShader||(this._lineShader=new e.ShaderMaterial("lineShader",this._source.getScene(),"line",{attributes:["position","normal"],uniforms:["worldViewProjection","color","width","aspectRatio"]}),this._lineShader.disableDepthWrite=!0,this._lineShader.backFaceCulling=!1)},i.prototype.dispose=function(){var t=this._buffers[e.VertexBuffer.PositionKind];t&&(t.dispose(),this._buffers[e.VertexBuffer.PositionKind]=null),t=this._buffers[e.VertexBuffer.NormalKind],t&&(t.dispose(),this._buffers[e.VertexBuffer.NormalKind]=null),this._source.getScene().getEngine()._releaseBuffer(this._ib),this._lineShader.dispose()},i.prototype._processEdgeForAdjacencies=function(e,t,i,r,n){return e===i&&t===r||e===r&&t===i?0:e===r&&t===n||e===n&&t===r?1:e===n&&t===i||e===i&&t===n?2:-1},i.prototype._processEdgeForAdjacenciesWithVertices=function(e,t,i,r,n){return e.equalsWithEpsilon(i)&&t.equalsWithEpsilon(r)||e.equalsWithEpsilon(r)&&t.equalsWithEpsilon(i)?0:e.equalsWithEpsilon(r)&&t.equalsWithEpsilon(n)||e.equalsWithEpsilon(n)&&t.equalsWithEpsilon(r)?1:e.equalsWithEpsilon(n)&&t.equalsWithEpsilon(i)||e.equalsWithEpsilon(i)&&t.equalsWithEpsilon(n)?2:-1},i.prototype._checkEdge=function(t,i,r,n,o){var s;if(void 0===i)s=!0;else{s=e.Vector3.Dot(r[t],r[i])4&&(o.push(e.VertexBuffer.MatricesIndicesExtraKind),o.push(e.VertexBuffer.MatricesWeightsExtraKind)),n.push("#define NUM_BONE_INFLUENCERS "+s.numBoneInfluencers),n.push("#define BonesPerMesh "+(s.skeleton.bones.length+1))):n.push("#define NUM_BONE_INFLUENCERS 0"),i&&(n.push("#define INSTANCES"),o.push("world0"),o.push("world1"),o.push("world2"),o.push("world3"));var u=n.join("\n");return this._cachedDefines!==u&&(this._cachedDefines=u,this._glowMapGenerationEffect=this._scene.getEngine().createEffect("glowMapGeneration",o,["world","mBones","viewProjection","diffuseMatrix","color","emissiveMatrix"],["diffuseSampler","emissiveSampler"],u)),this._glowMapGenerationEffect.isReady()},i.prototype.render=function(){var t=this._glowMapMergeEffect;if(t.isReady()&&this._blurTexture.isReady()){var i=this._scene.getEngine();this.onBeforeComposeObservable.notifyObservers(this),i.enableEffect(t),i.setState(!1);var r=i.getStencilBuffer(),n=i.getStencilFunction(),o=i.getStencilMask(),s=i.getStencilOperationPass(),a=i.getStencilOperationFail(),h=i.getStencilOperationDepthFail(),l=i.getAlphaMode();t.setTexture("textureSampler",this._blurTexture),i.bindBuffers(this._vertexBuffers,this._indexBuffer,t),i.setStencilOperationPass(e.Engine.REPLACE),i.setStencilOperationFail(e.Engine.KEEP),i.setStencilOperationDepthFail(e.Engine.KEEP),i.setAlphaMode(this._options.alphaBlendingMode),i.setStencilMask(0),i.setStencilBuffer(!0),i.setStencilFunctionReference(this._instanceGlowingMeshStencilReference),this.outerGlow&&(t.setFloat("offset",0),i.setStencilFunction(e.Engine.NOTEQUAL),i.draw(!0,0,6)),this.innerGlow&&(t.setFloat("offset",1),i.setStencilFunction(e.Engine.EQUAL),i.draw(!0,0,6)),i.setStencilFunction(n),i.setStencilMask(o),i.setAlphaMode(l),i.setStencilBuffer(r),i.setStencilOperationPass(s),i.setStencilOperationFail(a),i.setStencilOperationDepthFail(h),i._stencilState.reset(),this.onAfterComposeObservable.notifyObservers(this);var c=this._mainTexture.getSize();this.setMainTextureSize(),c.width===this._mainTextureDesiredSize.width&&c.height===this._mainTextureDesiredSize.height||(this.onSizeChangedObservable.notifyObservers(this),this.disposeTextureAndPostProcesses(),this.createTextureAndPostProcesses())}},i.prototype.addExcludedMesh=function(e){this._excludedMeshes[e.uniqueId]||(this._excludedMeshes[e.uniqueId]={mesh:e,beforeRender:e.onBeforeRenderObservable.add((function(e){e.getEngine().setStencilBuffer(!1)})),afterRender:e.onAfterRenderObservable.add((function(e){e.getEngine().setStencilBuffer(!0)}))})},i.prototype.removeExcludedMesh=function(e){var t=this._excludedMeshes[e.uniqueId];t&&(e.onBeforeRenderObservable.remove(t.beforeRender),e.onAfterRenderObservable.remove(t.afterRender)),this._excludedMeshes[e.uniqueId]=void 0},i.prototype.addMesh=function(e,t,i){var r=this;void 0===i&&(i=!1);var n=this._meshes[e.uniqueId];n?n.color=t:this._meshes[e.uniqueId]={mesh:e,color:t,observerHighlight:e.onBeforeRenderObservable.add((function(e){r._excludedMeshes[e.uniqueId]?r.defaultStencilReference(e):e.getScene().getEngine().setStencilFunctionReference(r._instanceGlowingMeshStencilReference)})),observerDefault:e.onAfterRenderObservable.add(this.defaultStencilReference),glowEmissiveOnly:i},this._shouldRender=!0},i.prototype.removeMesh=function(e){var t=this._meshes[e.uniqueId];t&&(e.onBeforeRenderObservable.remove(t.observerHighlight),e.onAfterRenderObservable.remove(t.observerDefault)),this._meshes[e.uniqueId]=void 0,this._shouldRender=!1;for(var i in this._meshes)if(i){this._shouldRender=!0;break}},i.prototype.shouldRender=function(){return this.isEnabled&&this._shouldRender},i.prototype.setMainTextureSize=function(){this._options.mainTextureFixedSize?(this._mainTextureDesiredSize.width=this._options.mainTextureFixedSize,this._mainTextureDesiredSize.height=this._options.mainTextureFixedSize):(this._mainTextureDesiredSize.width=this._engine.getRenderingCanvas().width*this._options.mainTextureRatio,this._mainTextureDesiredSize.height=this._engine.getRenderingCanvas().height*this._options.mainTextureRatio,this._mainTextureDesiredSize.width=this._engine.needPOTTextures?e.Tools.GetExponentOfTwo(this._mainTextureDesiredSize.width,this._maxSize):this._mainTextureDesiredSize.width,this._mainTextureDesiredSize.height=this._engine.needPOTTextures?e.Tools.GetExponentOfTwo(this._mainTextureDesiredSize.height,this._maxSize):this._mainTextureDesiredSize.height)},i.prototype.defaultStencilReference=function(e){e.getScene().getEngine().setStencilFunctionReference(i.normalMeshStencilReference)},i.prototype.disposeTextureAndPostProcesses=function(){this._blurTexture.dispose(),this._mainTexture.dispose(),this._downSamplePostprocess.dispose(),this._horizontalBlurPostprocess.dispose(),this._verticalBlurPostprocess.dispose()},i.prototype.dispose=function(){var t=this._vertexBuffers[e.VertexBuffer.PositionKind];t&&(t.dispose(),this._vertexBuffers[e.VertexBuffer.PositionKind]=null),this._indexBuffer&&(this._scene.getEngine()._releaseBuffer(this._indexBuffer),this._indexBuffer=null),this.disposeTextureAndPostProcesses();for(var i in this._meshes){var r=this._meshes[i];r&&r.mesh&&(r.mesh.onBeforeRenderObservable.remove(r.observerHighlight),r.mesh.onAfterRenderObservable.remove(r.observerDefault))}this._meshes=null;for(var i in this._excludedMeshes){var r=this._excludedMeshes[i];r&&(r.mesh.onBeforeRenderObservable.remove(r.beforeRender),r.mesh.onAfterRenderObservable.remove(r.afterRender))}this._excludedMeshes=null;var n=this._scene.highlightLayers.indexOf(this,0);n>-1&&this._scene.highlightLayers.splice(n,1),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onBeforeRenderMainTextureObservable.clear(),this.onBeforeBlurObservable.clear(),this.onBeforeComposeObservable.clear(),this.onAfterComposeObservable.clear(),this.onSizeChangedObservable.clear()},i})();i.neutralColor=new e.Color4(0,0,0,0),i.glowingMeshStencilReference=2,i.normalMeshStencilReference=1,e.HighlightLayer=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e,t,i,r){this.name=e,this.meshesNames=t,this.rootUrl=i,this.sceneFilename=r,this.isCompleted=!1}return t.prototype.run=function(t,i,r){var n=this;e.SceneLoader.ImportMesh(this.meshesNames,this.rootUrl,this.sceneFilename,t,(function(e,t,r){n.loadedMeshes=e,n.loadedParticleSystems=t,n.loadedSkeletons=r,n.isCompleted=!0,n.onSuccess&&n.onSuccess(n),i()}),null,(function(){n.onError&&n.onError(n),r()}))},t})();e.MeshAssetTask=t;var i=(function(){function t(e,t){this.name=e,this.url=t,this.isCompleted=!1}return t.prototype.run=function(t,i,r){var n=this;e.Tools.LoadFile(this.url,(function(e){n.text=e,n.isCompleted=!0,n.onSuccess&&n.onSuccess(n),i()}),null,t.database,!1,(function(){n.onError&&n.onError(n),r()}))},t})();e.TextFileAssetTask=i;var r=(function(){function t(e,t){this.name=e,this.url=t,this.isCompleted=!1}return t.prototype.run=function(t,i,r){var n=this;e.Tools.LoadFile(this.url,(function(e){n.data=e,n.isCompleted=!0,n.onSuccess&&n.onSuccess(n),i()}),null,t.database,!0,(function(){n.onError&&n.onError(n),r()}))},t})();e.BinaryFileAssetTask=r;var n=(function(){function t(e,t){this.name=e,this.url=t,this.isCompleted=!1}return t.prototype.run=function(t,i,r){var n=this,o=new Image;e.Tools.SetCorsBehavior(this.url,o),o.onload=function(){n.image=o,n.isCompleted=!0,n.onSuccess&&n.onSuccess(n),i()},o.onerror=function(){n.onError&&n.onError(n),r()},o.src=this.url},t})();e.ImageAssetTask=n;var o=(function(){function t(t,i,r,n,o){void 0===o&&(o=e.Texture.TRILINEAR_SAMPLINGMODE),this.name=t,this.url=i,this.noMipmap=r,this.invertY=n,this.samplingMode=o,this.isCompleted=!1}return t.prototype.run=function(t,i,r){var n=this,o=function(){n.isCompleted=!0,n.onSuccess&&n.onSuccess(n),i()},s=function(){n.onError&&n.onError(n),r()};this.texture=new e.Texture(this.url,t,this.noMipmap,this.invertY,this.samplingMode,o,s)},t})();e.TextureAssetTask=o;var s=(function(){function t(e,t,i,r,n){this.name=e,this.url=t,this.extensions=i,this.noMipmap=r,this.files=n,this.isCompleted=!1}return t.prototype.run=function(t,i,r){var n=this,o=function(){n.isCompleted=!0,n.onSuccess&&n.onSuccess(n),i()},s=function(){n.onError&&n.onError(n),r()};this.texture=new e.CubeTexture(this.url,t,this.extensions,this.noMipmap,this.files,o,s)},t})();e.CubeTextureAssetTask=s;var a=(function(){function t(e,t,i,r,n,o,s){void 0===r&&(r=!1),void 0===n&&(n=!0),void 0===o&&(o=!1),void 0===s&&(s=!1),this.name=e,this.url=t,this.size=i,this.noMipmap=r,this.generateHarmonics=n,this.useInGammaSpace=o,this.usePMREMGenerator=s,this.isCompleted=!1}return t.prototype.run=function(t,i,r){var n=this,o=function(){n.isCompleted=!0,n.onSuccess&&n.onSuccess(n),i()},s=function(){n.onError&&n.onError(n),r()};this.texture=new e.HDRCubeTexture(this.url,t,this.size,this.noMipmap,this.generateHarmonics,this.useInGammaSpace,this.usePMREMGenerator,o,s)},t})();e.HDRCubeTextureAssetTask=a;var h=(function(){function h(e){this.tasks=new Array,this.waitingTasksCount=0,this.useDefaultLoadingScreen=!0,this._scene=e}return h.prototype.addMeshTask=function(e,i,r,n){var o=new t(e,i,r,n);return this.tasks.push(o),o},h.prototype.addTextFileTask=function(e,t){var r=new i(e,t);return this.tasks.push(r),r},h.prototype.addBinaryFileTask=function(e,t){var i=new r(e,t);return this.tasks.push(i),i},h.prototype.addImageTask=function(e,t){var i=new n(e,t);return this.tasks.push(i),i},h.prototype.addTextureTask=function(t,i,r,n,s){void 0===s&&(s=e.Texture.TRILINEAR_SAMPLINGMODE);var a=new o(t,i,r,n,s);return this.tasks.push(a),a},h.prototype.addCubeTextureTask=function(e,t,i,r,n){var o=new s(e,t,i,r,n);return this.tasks.push(o),o},h.prototype.addHDRCubeTextureTask=function(e,t,i,r,n,o,s){void 0===r&&(r=!1),void 0===n&&(n=!0),void 0===o&&(o=!1),void 0===s&&(s=!1);var h=new a(e,t,i,r,n,o,s);return this.tasks.push(h),h},h.prototype._decreaseWaitingTasksCount=function(){0===--this.waitingTasksCount&&(this.onFinish&&this.onFinish(this.tasks),this._scene.getEngine().hideLoadingUI())},h.prototype._runTask=function(e){var t=this;e.run(this._scene,(function(){t.onTaskSuccess&&t.onTaskSuccess(e),t._decreaseWaitingTasksCount()}),(function(){t.onTaskError&&t.onTaskError(e),t._decreaseWaitingTasksCount()}))},h.prototype.reset=function(){return this.tasks=new Array,this},h.prototype.load=function(){if(this.waitingTasksCount=this.tasks.length,0===this.waitingTasksCount)return this.onFinish&&this.onFinish(this.tasks),this;this.useDefaultLoadingScreen&&this._scene.getEngine().displayLoadingUI();for(var e=0;e\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef TANGENT\nattribute vec4 tangent;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include\n\n#include\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0\nvarying vec2 vDiffuseUV;\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nvarying vec2 vAmbientUV;\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nvarying vec2 vOpacityUV;\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nvarying vec2 vEmissiveUV;\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nvarying vec2 vLightmapUV;\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM) && SPECULARDIRECTUV == 0\nvarying vec2 vSpecularUV;\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nvarying vec2 vBumpUV;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include\n#include\n#include\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include\n#include[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#include\nvoid main(void) {\nvec3 positionUpdated=position;\n#ifdef NORMAL \nvec3 normalUpdated=normal;\n#endif\n#ifdef TANGENT\nvec4 tangentUpdated=tangent;\n#endif\n#include[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvPositionUVW=positionUpdated;\n#endif \n#include\n#include\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normalUpdated,0.0)));\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef MAINUV1\nvMainUV1=uv;\n#endif\n#ifdef MAINUV2\nvMainUV2=uv2;\n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0\nif (vDiffuseInfos.x == 0.)\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nif (vAmbientInfos.x == 0.)\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nif (vOpacityInfos.x == 0.)\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nif (vEmissiveInfos.x == 0.)\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nif (vLightmapInfos.x == 0.)\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM) && SPECULARDIRECTUV == 0\nif (vSpecularInfos.x == 0.)\n{\nvSpecularUV=vec2(specularMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvSpecularUV=vec2(specularMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nif (vBumpInfos.x == 0.)\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#include\n#include\n#include\n#include[0..maxSimultaneousLights]\n#ifdef VERTEXCOLOR\n\nvColor=color;\n#endif\n#include\n#include\n}",defaultPixelShader:"#include<__decl__defaultFragment>\n#if defined(BUMP) || !defined(NORMAL)\n#extension GL_OES_standard_derivatives : enable\n#endif\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\n\n#define RECIPROCAL_PI2 0.15915494\nuniform vec3 vEyePosition;\nuniform vec3 vAmbientColor;\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n\n#include\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include\n#include\n\n#ifdef DIFFUSE\n#if DIFFUSEDIRECTUV == 1\n#define vDiffuseUV vMainUV1\n#elif DIFFUSEDIRECTUV == 2\n#define vDiffuseUV vMainUV2\n#else\nvarying vec2 vDiffuseUV;\n#endif\nuniform sampler2D diffuseSampler;\n#endif\n#ifdef AMBIENT\n#if AMBIENTDIRECTUV == 1\n#define vAmbientUV vMainUV1\n#elif AMBIENTDIRECTUV == 2\n#define vAmbientUV vMainUV2\n#else\nvarying vec2 vAmbientUV;\n#endif\nuniform sampler2D ambientSampler;\n#endif\n#ifdef OPACITY \n#if OPACITYDIRECTUV == 1\n#define vOpacityUV vMainUV1\n#elif OPACITYDIRECTUV == 2\n#define vOpacityUV vMainUV2\n#else\nvarying vec2 vOpacityUV;\n#endif\nuniform sampler2D opacitySampler;\n#endif\n#ifdef EMISSIVE\n#if EMISSIVEDIRECTUV == 1\n#define vEmissiveUV vMainUV1\n#elif EMISSIVEDIRECTUV == 2\n#define vEmissiveUV vMainUV2\n#else\nvarying vec2 vEmissiveUV;\n#endif\nuniform sampler2D emissiveSampler;\n#endif\n#ifdef LIGHTMAP\n#if LIGHTMAPDIRECTUV == 1\n#define vLightmapUV vMainUV1\n#elif LIGHTMAPDIRECTUV == 2\n#define vLightmapUV vMainUV2\n#else\nvarying vec2 vLightmapUV;\n#endif\nuniform sampler2D lightmapSampler;\n#endif\n#ifdef REFRACTION\n#ifdef REFRACTIONMAP_3D\nuniform samplerCube refractionCubeSampler;\n#else\nuniform sampler2D refraction2DSampler;\n#endif\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\n#if SPECULARDIRECTUV == 1\n#define vSpecularUV vMainUV1\n#elif SPECULARDIRECTUV == 2\n#define vSpecularUV vMainUV2\n#else\nvarying vec2 vSpecularUV;\n#endif\nuniform sampler2D specularSampler;\n#endif\n\n#include\n\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\nuniform samplerCube reflectionCubeSampler;\n#else\nuniform sampler2D reflection2DSampler;\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#endif\n#include\n#endif\n#include\n#include\n#include\n#include\n#include\n#include\nvoid main(void) {\n#include\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\nvec4 baseColor=vec4(1.,1.,1.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\n\nfloat alpha=vDiffuseColor.a;\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=normalize(-cross(dFdx(vPositionW),dFdy(vPositionW)));\n#endif\n#include\n#ifdef TWOSIDEDLIGHTING\nnormalW=gl_FrontFacing ? normalW : -normalW;\n#endif\n#ifdef DIFFUSE\nbaseColor=texture2D(diffuseSampler,vDiffuseUV+uvOffset);\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\n#ifdef ALPHAFROMDIFFUSE\nalpha*=baseColor.a;\n#endif\nbaseColor.rgb*=vDiffuseInfos.y;\n#endif\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n\nvec3 baseAmbientColor=vec3(1.,1.,1.);\n#ifdef AMBIENT\nbaseAmbientColor=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb*vAmbientInfos.y;\n#endif\n\n#ifdef SPECULARTERM\nfloat glossiness=vSpecularColor.a;\nvec3 specularColor=vSpecularColor.rgb;\n#ifdef SPECULAR\nvec4 specularMapColor=texture2D(specularSampler,vSpecularUV+uvOffset);\nspecularColor=specularMapColor.rgb;\n#ifdef GLOSSINESS\nglossiness=glossiness*specularMapColor.a;\n#endif\n#endif\n#else\nfloat glossiness=0.;\n#endif\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\nfloat shadow=1.;\n#ifdef LIGHTMAP\nvec3 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset).rgb*vLightmapInfos.y;\n#endif\n#include[0..maxSimultaneousLights]\n\nvec3 refractionColor=vec3(0.,0.,0.);\n#ifdef REFRACTION\nvec3 refractionVector=normalize(refract(-viewDirectionW,normalW,vRefractionInfos.y));\n#ifdef REFRACTIONMAP_3D\nrefractionVector.y=refractionVector.y*vRefractionInfos.w;\nif (dot(refractionVector,viewDirectionW)<1.0)\n{\nrefractionColor=textureCube(refractionCubeSampler,refractionVector).rgb*vRefractionInfos.x;\n}\n#else\nvec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));\nvec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;\nrefractionCoords.y=1.0-refractionCoords.y;\nrefractionColor=texture2D(refraction2DSampler,refractionCoords).rgb*vRefractionInfos.x;\n#endif\n#endif\n\nvec3 reflectionColor=vec3(0.,0.,0.);\n#ifdef REFLECTION\nvec3 vReflectionUVW=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#ifdef REFLECTIONMAP_3D\n#ifdef ROUGHNESS\nfloat bias=vReflectionInfos.y;\n#ifdef SPECULARTERM\n#ifdef SPECULAR\n#ifdef GLOSSINESS\nbias*=(1.0-specularMapColor.a);\n#endif\n#endif\n#endif\nreflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW,bias).rgb*vReflectionInfos.x;\n#else\nreflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW).rgb*vReflectionInfos.x;\n#endif\n#else\nvec2 coords=vReflectionUVW.xy;\n#ifdef REFLECTIONMAP_PROJECTION\ncoords/=vReflectionUVW.z;\n#endif\ncoords.y=1.0-coords.y;\nreflectionColor=texture2D(reflection2DSampler,coords).rgb*vReflectionInfos.x;\n#endif\n#ifdef REFLECTIONFRESNEL\nfloat reflectionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,reflectionRightColor.a,reflectionLeftColor.a);\n#ifdef REFLECTIONFRESNELFROMSPECULAR\n#ifdef SPECULARTERM\nreflectionColor*=specularColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#else\nreflectionColor*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#endif\n#else\nreflectionColor*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#endif\n#endif\n#endif\n#ifdef REFRACTIONFRESNEL\nfloat refractionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,refractionRightColor.a,refractionLeftColor.a);\nrefractionColor*=refractionLeftColor.rgb*(1.0-refractionFresnelTerm)+refractionFresnelTerm*refractionRightColor.rgb;\n#endif\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);\n#ifdef OPACITYRGB\nopacityMap.rgb=opacityMap.rgb*vec3(0.3,0.59,0.11);\nalpha*=(opacityMap.x+opacityMap.y+opacityMap.z)* vOpacityInfos.y;\n#else\nalpha*=opacityMap.a*vOpacityInfos.y;\n#endif\n#endif\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#ifdef OPACITYFRESNEL\nfloat opacityFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,opacityParts.z,opacityParts.w);\nalpha+=opacityParts.x*(1.0-opacityFresnelTerm)+opacityFresnelTerm*opacityParts.y;\n#endif\n\nvec3 emissiveColor=vEmissiveColor;\n#ifdef EMISSIVE\nemissiveColor+=texture2D(emissiveSampler,vEmissiveUV+uvOffset).rgb*vEmissiveInfos.y;\n#endif\n#ifdef EMISSIVEFRESNEL\nfloat emissiveFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,emissiveRightColor.a,emissiveLeftColor.a);\nemissiveColor*=emissiveLeftColor.rgb*(1.0-emissiveFresnelTerm)+emissiveFresnelTerm*emissiveRightColor.rgb;\n#endif\n\n#ifdef DIFFUSEFRESNEL\nfloat diffuseFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,diffuseRightColor.a,diffuseLeftColor.a);\ndiffuseBase*=diffuseLeftColor.rgb*(1.0-diffuseFresnelTerm)+diffuseFresnelTerm*diffuseRightColor.rgb;\n#endif\n\n#ifdef EMISSIVEASILLUMINATION\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#else\n#ifdef LINKEMISSIVEWITHDIFFUSE\nvec3 finalDiffuse=clamp((diffuseBase+emissiveColor)*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#else\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor+emissiveColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#endif\n#endif\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase*specularColor;\n#ifdef SPECULAROVERALPHA\nalpha=clamp(alpha+dot(finalSpecular,vec3(0.3,0.59,0.11)),0.,1.);\n#endif\n#else\nvec3 finalSpecular=vec3(0.0);\n#endif\n#ifdef REFLECTIONOVERALPHA\nalpha=clamp(alpha+dot(reflectionColor,vec3(0.3,0.59,0.11)),0.,1.);\n#endif\n\n#ifdef EMISSIVEASILLUMINATION\nvec4 color=vec4(clamp(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor+emissiveColor+refractionColor,0.0,1.0),alpha);\n#else\nvec4 color=vec4(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor+refractionColor,alpha);\n#endif\n\n#ifdef LIGHTMAP\n#ifndef LIGHTMAPEXCLUDED\n#ifdef USELIGHTMAPASSHADOWMAP\ncolor.rgb*=lightmapColor;\n#else\ncolor.rgb+=lightmapColor;\n#endif\n#endif\n#endif\n#include\n#include\n\n\n#ifdef IMAGEPROCESSINGPOSTPROCESS\ncolor.rgb=toLinearSpace(color.rgb);\n#else\n#ifdef IMAGEPROCESSING\ncolor.rgb=toLinearSpace(color.rgb);\ncolor=applyImageProcessing(color);\n#endif\n#endif\ngl_FragColor=color;\n}",pbrVertexShader:"precision highp float;\n#include<__decl__pbrVertex>\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef TANGENT\nattribute vec4 tangent;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2; \n#endif \n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include\n\n#include\n#if defined(ALBEDO) && ALBEDODIRECTUV == 0\nvarying vec2 vAlbedoUV;\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nvarying vec2 vAmbientUV;\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nvarying vec2 vOpacityUV;\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nvarying vec2 vEmissiveUV;\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nvarying vec2 vLightmapUV;\n#endif\n#if defined(REFLECTIVITY) && REFLECTIVITYDIRECTUV == 0\nvarying vec2 vReflectivityUV;\n#endif\n#if defined(MICROSURFACEMAP) && MICROSURFACEMAPDIRECTUV == 0\nvarying vec2 vMicroSurfaceSamplerUV;\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nvarying vec2 vBumpUV;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#if defined(USESPHERICALFROMREFLECTIONMAP) && !defined(USESPHERICALINFRAGMENT)\nvarying vec3 vEnvironmentIrradiance;\n#include\n#endif\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include\n#include\n#include\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include\n#include[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#include\nvoid main(void) {\nvec3 positionUpdated=position;\n#ifdef NORMAL\nvec3 normalUpdated=normal;\n#endif\n#ifdef TANGENT\nvec4 tangentUpdated=tangent;\n#endif\n#include[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvPositionUVW=positionUpdated;\n#endif \n#include\n#include\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normalUpdated,0.0)));\n#if defined(USESPHERICALFROMREFLECTIONMAP) && !defined(USESPHERICALINFRAGMENT)\nvec3 reflectionVector=vec3(reflectionMatrix*vec4(vNormalW,0)).xyz;\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\nvEnvironmentIrradiance=environmentIrradianceJones(reflectionVector);\n#endif\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef MAINUV1\nvMainUV1=uv;\n#endif \n#ifdef MAINUV2\nvMainUV2=uv2;\n#endif \n#if defined(ALBEDO) && ALBEDODIRECTUV == 0 \nif (vAlbedoInfos.x == 0.)\n{\nvAlbedoUV=vec2(albedoMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAlbedoUV=vec2(albedoMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0 \nif (vAmbientInfos.x == 0.)\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0 \nif (vOpacityInfos.x == 0.)\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0 \nif (vEmissiveInfos.x == 0.)\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0 \nif (vLightmapInfos.x == 0.)\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(REFLECTIVITY) && REFLECTIVITYDIRECTUV == 0 \nif (vReflectivityInfos.x == 0.)\n{\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(MICROSURFACEMAP) && MICROSURFACEMAPDIRECTUV == 0 \nif (vMicroSurfaceSamplerInfos.x == 0.)\n{\nvMicroSurfaceSamplerUV=vec2(microSurfaceSamplerMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvMicroSurfaceSamplerUV=vec2(microSurfaceSamplerMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0 \nif (vBumpInfos.x == 0.)\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n\n#include\n\n#include\n\n#include\n\n#include[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n\n#include\n}", pbrPixelShader:"#if defined(BUMP) || !defined(NORMAL) || defined(FORCENORMALFORWARD)\n#extension GL_OES_standard_derivatives : enable\n#endif\n#ifdef LODBASEDMICROSFURACE\n#extension GL_EXT_shader_texture_lod : enable\n#endif\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\nprecision highp float;\n#include<__decl__pbrFragment>\nuniform vec4 vEyePosition;\nuniform vec3 vAmbientColor;\nuniform vec4 vCameraInfos;\n\nvarying vec3 vPositionW;\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif \n#ifdef MAINUV2 \nvarying vec2 vMainUV2; \n#endif \n#ifdef NORMAL\nvarying vec3 vNormalW;\n#if defined(USESPHERICALFROMREFLECTIONMAP) && !defined(USESPHERICALINFRAGMENT)\nvarying vec3 vEnvironmentIrradiance;\n#endif\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n\n#ifdef ALBEDO\n#if ALBEDODIRECTUV == 1\n#define vAlbedoUV vMainUV1\n#elif ALBEDODIRECTUV == 2\n#define vAlbedoUV vMainUV2\n#else\nvarying vec2 vAlbedoUV;\n#endif\nuniform sampler2D albedoSampler;\n#endif\n#ifdef AMBIENT\n#if AMBIENTDIRECTUV == 1\n#define vAmbientUV vMainUV1\n#elif AMBIENTDIRECTUV == 2\n#define vAmbientUV vMainUV2\n#else\nvarying vec2 vAmbientUV;\n#endif\nuniform sampler2D ambientSampler;\n#endif\n#ifdef OPACITY\n#if OPACITYDIRECTUV == 1\n#define vOpacityUV vMainUV1\n#elif OPACITYDIRECTUV == 2\n#define vOpacityUV vMainUV2\n#else\nvarying vec2 vOpacityUV;\n#endif\nuniform sampler2D opacitySampler;\n#endif\n#ifdef EMISSIVE\n#if EMISSIVEDIRECTUV == 1\n#define vEmissiveUV vMainUV1\n#elif EMISSIVEDIRECTUV == 2\n#define vEmissiveUV vMainUV2\n#else\nvarying vec2 vEmissiveUV;\n#endif\nuniform sampler2D emissiveSampler;\n#endif\n#ifdef LIGHTMAP\n#if LIGHTMAPDIRECTUV == 1\n#define vLightmapUV vMainUV1\n#elif LIGHTMAPDIRECTUV == 2\n#define vLightmapUV vMainUV2\n#else\nvarying vec2 vLightmapUV;\n#endif\nuniform sampler2D lightmapSampler;\n#endif\n#ifdef REFLECTIVITY\n#if REFLECTIVITYDIRECTUV == 1\n#define vReflectivityUV vMainUV1\n#elif REFLECTIVITYDIRECTUV == 2\n#define vReflectivityUV vMainUV2\n#else\nvarying vec2 vReflectivityUV;\n#endif\nuniform sampler2D reflectivitySampler;\n#endif\n#ifdef MICROSURFACEMAP\n#if MICROSURFACEMAPDIRECTUV == 1\n#define vMicroSurfaceSamplerUV vMainUV1\n#elif MICROSURFACEMAPDIRECTUV == 2\n#define vMicroSurfaceSamplerUV vMainUV2\n#else\nvarying vec2 vMicroSurfaceSamplerUV;\n#endif\nuniform sampler2D microSurfaceSampler;\n#endif\n\n#ifdef REFRACTION\n#ifdef REFRACTIONMAP_3D\n#define sampleRefraction(s,c) textureCube(s,c)\nuniform samplerCube refractionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleRefractionLod(s,c,l) textureCubeLodEXT(s,c,l)\n#else\nuniform samplerCube refractionSamplerLow;\nuniform samplerCube refractionSamplerHigh;\n#endif\n#else\n#define sampleRefraction(s,c) texture2D(s,c)\nuniform sampler2D refractionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleRefractionLod(s,c,l) texture2DLodEXT(s,c,l)\n#else\nuniform samplerCube refractionSamplerLow;\nuniform samplerCube refractionSamplerHigh;\n#endif\n#endif\n#endif\n\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\n#define sampleReflection(s,c) textureCube(s,c)\nuniform samplerCube reflectionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleReflectionLod(s,c,l) textureCubeLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#else\n#define sampleReflection(s,c) texture2D(s,c)\nuniform sampler2D reflectionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleReflectionLod(s,c,l) texture2DLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#endif\n#include\n#endif\n#ifdef ENVIRONMENTBRDF\nuniform sampler2D environmentBrdfSampler;\n#endif\n\n#ifndef FROMLINEARSPACE\n#define FROMLINEARSPACE;\n#endif\n#include\n#include\n#include\n\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n\n#include\nvoid main(void) {\n#include\n\n\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;\n#endif\n#include\n#if defined(FORCENORMALFORWARD) && defined(NORMAL)\nvec3 faceNormal=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;\n#if defined(TWOSIDEDLIGHTING)\nfaceNormal=gl_FrontFacing ? faceNormal : -faceNormal;\n#endif\nfloat comp=sign(dot(normalW,faceNormal));\nnormalW*=-comp;\n#endif\n#if defined(TWOSIDEDLIGHTING) && defined(NORMAL)\nnormalW=gl_FrontFacing ? normalW : -normalW;\n#endif\n\n\nvec3 surfaceAlbedo=vAlbedoColor.rgb;\n\nfloat alpha=vAlbedoColor.a;\n#ifdef ALBEDO\nvec4 albedoTexture=texture2D(albedoSampler,vAlbedoUV+uvOffset);\n#if defined(ALPHAFROMALBEDO) || defined(ALPHATEST)\nalpha*=albedoTexture.a;\n#endif\nsurfaceAlbedo*=toLinearSpace(albedoTexture.rgb);\nsurfaceAlbedo*=vAlbedoInfos.y;\n#endif\n\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);\n#ifdef OPACITYRGB\nalpha=getLuminance(opacityMap.rgb);\n#else\nalpha*=opacityMap.a;\n#endif\nalpha*=vOpacityInfos.y;\n#endif\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#if !defined(LINKREFRACTIONTOTRANSPARENCY) && !defined(ALPHAFRESNEL)\n#ifdef ALPHATEST\nif (alpha<=ALPHATESTVALUE)\ndiscard;\n#ifndef ALPHABLEND\n\nalpha=1.0;\n#endif\n#endif\n#endif\n#ifdef VERTEXCOLOR\nsurfaceAlbedo*=vColor.rgb;\n#endif\n\nvec3 ambientOcclusionColor=vec3(1.,1.,1.);\n#ifdef AMBIENT\nvec3 ambientOcclusionColorMap=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb*vAmbientInfos.y;\n#ifdef AMBIENTINGRAYSCALE\nambientOcclusionColorMap=vec3(ambientOcclusionColorMap.r,ambientOcclusionColorMap.r,ambientOcclusionColorMap.r);\n#endif\nambientOcclusionColor=mix(ambientOcclusionColor,ambientOcclusionColorMap,vAmbientInfos.z);\n#endif\n\nfloat microSurface=vReflectivityColor.a;\nvec3 surfaceReflectivityColor=vReflectivityColor.rgb;\n#ifdef METALLICWORKFLOW\nvec2 metallicRoughness=surfaceReflectivityColor.rg;\n#ifdef REFLECTIVITY\nvec4 surfaceMetallicColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset);\n#ifdef AOSTOREINMETALMAPRED\nvec3 aoStoreInMetalMap=vec3(surfaceMetallicColorMap.r,surfaceMetallicColorMap.r,surfaceMetallicColorMap.r);\nambientOcclusionColor=mix(ambientOcclusionColor,aoStoreInMetalMap,vReflectivityInfos.z);\n#endif\n#ifdef METALLNESSSTOREINMETALMAPBLUE\nmetallicRoughness.r*=surfaceMetallicColorMap.b;\n#else\nmetallicRoughness.r*=surfaceMetallicColorMap.r;\n#endif\n#ifdef ROUGHNESSSTOREINMETALMAPALPHA\nmetallicRoughness.g*=surfaceMetallicColorMap.a;\n#else\n#ifdef ROUGHNESSSTOREINMETALMAPGREEN\nmetallicRoughness.g*=surfaceMetallicColorMap.g;\n#endif\n#endif\n#endif\n#ifdef MICROSURFACEMAP\nvec4 microSurfaceTexel=texture2D(microSurfaceSampler,vMicroSurfaceSamplerUV+uvOffset)*vMicroSurfaceSamplerInfos.y;\nmetallicRoughness.g*=microSurfaceTexel.r;\n#endif\n\nmicroSurface=1.0-metallicRoughness.g;\n\nvec3 baseColor=surfaceAlbedo;\n\n\nconst vec3 DefaultSpecularReflectanceDielectric=vec3(0.04,0.04,0.04);\n\nsurfaceAlbedo=mix(baseColor.rgb*(1.0-DefaultSpecularReflectanceDielectric.r),vec3(0.,0.,0.),metallicRoughness.r);\n\nsurfaceReflectivityColor=mix(DefaultSpecularReflectanceDielectric,baseColor,metallicRoughness.r);\n#else\n#ifdef REFLECTIVITY\nvec4 surfaceReflectivityColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset);\nsurfaceReflectivityColor*=toLinearSpace(surfaceReflectivityColorMap.rgb);\nsurfaceReflectivityColor*=vReflectivityInfos.y;\n#ifdef MICROSURFACEFROMREFLECTIVITYMAP\nmicroSurface*=surfaceReflectivityColorMap.a;\nmicroSurface*=vReflectivityInfos.z;\n#else\n#ifdef MICROSURFACEAUTOMATIC\nmicroSurface*=computeDefaultMicroSurface(microSurface,surfaceReflectivityColor);\n#endif\n#ifdef MICROSURFACEMAP\nvec4 microSurfaceTexel=texture2D(microSurfaceSampler,vMicroSurfaceSamplerUV+uvOffset)*vMicroSurfaceSamplerInfos.y;\nmicroSurface*=microSurfaceTexel.r;\n#endif\n#endif\n#endif\n#endif\n\nmicroSurface=clamp(microSurface,0.,1.);\n\nfloat roughness=1.-microSurface;\n\n#ifdef ALPHAFRESNEL\n#if defined(ALPHATEST) || defined(ALPHABLEND)\n\n\n\nfloat opacityPerceptual=alpha;\nfloat opacity0=opacityPerceptual*opacityPerceptual;\nfloat opacity90=fresnelGrazingReflectance(opacity0);\nvec3 normalForward=faceforward(normalW,-viewDirectionW,normalW);\n\nalpha=fresnelSchlickEnvironmentGGX(clamp(dot(viewDirectionW,normalForward),0.0,1.0),vec3(opacity0),vec3(opacity90),sqrt(microSurface)).x;\n#ifdef ALPHATEST\nif (alpha<=ALPHATESTVALUE)\ndiscard;\n#ifndef ALPHABLEND\n\nalpha=1.0;\n#endif\n#endif\n#endif\n#endif\n\n\nfloat NdotVUnclamped=dot(normalW,viewDirectionW);\nfloat NdotV=clamp(NdotVUnclamped,0.,1.)+0.00001;\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\n\n#ifdef REFRACTION\nvec3 environmentRefraction=vec3(0.,0.,0.);\nvec3 refractionVector=refract(-viewDirectionW,normalW,vRefractionInfos.y);\n#ifdef REFRACTIONMAP_OPPOSITEZ\nrefractionVector.z*=-1.0;\n#endif\n\n#ifdef REFRACTIONMAP_3D\nrefractionVector.y=refractionVector.y*vRefractionInfos.w;\nvec3 refractionCoords=refractionVector;\nrefractionCoords=vec3(refractionMatrix*vec4(refractionCoords,0));\n#else\nvec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));\nvec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;\nrefractionCoords.y=1.0-refractionCoords.y;\n#endif\n#ifdef LODINREFRACTIONALPHA\nfloat refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,alphaG,NdotVUnclamped);\n#else\nfloat refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,alphaG,1.0);\n#endif\n#ifdef LODBASEDMICROSFURACE\n\nrefractionLOD=refractionLOD*vRefractionMicrosurfaceInfos.y+vRefractionMicrosurfaceInfos.z;\n#ifdef LODINREFRACTIONALPHA\n\n\n\n\n\n\n\n\n\nfloat automaticRefractionLOD=UNPACK_LOD(sampleRefraction(refractionSampler,refractionCoords).a);\nfloat requestedRefractionLOD=max(automaticRefractionLOD,refractionLOD);\n#else\nfloat requestedRefractionLOD=refractionLOD;\n#endif\nenvironmentRefraction=sampleRefractionLod(refractionSampler,refractionCoords,requestedRefractionLOD).rgb;\n#else\nfloat lodRefractionNormalized=clamp(refractionLOD/log2(vRefractionMicrosurfaceInfos.x),0.,1.);\nfloat lodRefractionNormalizedDoubled=lodRefractionNormalized*2.0;\nvec3 environmentRefractionMid=sampleRefraction(refractionSampler,refractionCoords).rgb;\nif(lodRefractionNormalizedDoubled<1.0){\nenvironmentRefraction=mix(\nsampleRefraction(refractionSamplerHigh,refractionCoords).rgb,\nenvironmentRefractionMid,\nlodRefractionNormalizedDoubled\n);\n}else{\nenvironmentRefraction=mix(\nenvironmentRefractionMid,\nsampleRefraction(refractionSamplerLow,refractionCoords).rgb,\nlodRefractionNormalizedDoubled-1.0\n);\n}\n#endif\n#ifdef GAMMAREFRACTION\nenvironmentRefraction=toLinearSpace(environmentRefraction.rgb);\n#endif\n\nenvironmentRefraction*=vRefractionInfos.x;\n#endif\n\n#ifdef REFLECTION\nvec3 environmentRadiance=vec3(0.,0.,0.);\nvec3 environmentIrradiance=vec3(0.,0.,0.);\nvec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\n\n#ifdef REFLECTIONMAP_3D\nvec3 reflectionCoords=reflectionVector;\n#else\nvec2 reflectionCoords=reflectionVector.xy;\n#ifdef REFLECTIONMAP_PROJECTION\nreflectionCoords/=reflectionVector.z;\n#endif\nreflectionCoords.y=1.0-reflectionCoords.y;\n#endif\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nfloat reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG,NdotVUnclamped);\n#else\nfloat reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG,1.);\n#endif\n#ifdef LODBASEDMICROSFURACE\n\nreflectionLOD=reflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;\n#ifdef LODINREFLECTIONALPHA\n\n\n\n\n\n\n\n\n\nfloat automaticReflectionLOD=UNPACK_LOD(sampleReflection(reflectionSampler,reflectionCoords).a);\nfloat requestedReflectionLOD=max(automaticReflectionLOD,reflectionLOD);\n#else\nfloat requestedReflectionLOD=reflectionLOD;\n#endif\nenvironmentRadiance=sampleReflectionLod(reflectionSampler,reflectionCoords,requestedReflectionLOD).rgb;\n#else\nfloat lodReflectionNormalized=clamp(reflectionLOD/log2(vReflectionMicrosurfaceInfos.x),0.,1.);\nfloat lodReflectionNormalizedDoubled=lodReflectionNormalized*2.0;\nvec3 environmentSpecularMid=sampleReflection(reflectionSampler,reflectionCoords).rgb;\nif(lodReflectionNormalizedDoubled<1.0){\nenvironmentRadiance=mix(\nsampleReflection(reflectionSamplerHigh,reflectionCoords).rgb,\nenvironmentSpecularMid,\nlodReflectionNormalizedDoubled\n);\n}else{\nenvironmentRadiance=mix(\nenvironmentSpecularMid,\nsampleReflection(reflectionSamplerLow,reflectionCoords).rgb,\nlodReflectionNormalizedDoubled-1.0\n);\n}\n#endif\n#ifdef GAMMAREFLECTION\nenvironmentRadiance=toLinearSpace(environmentRadiance.rgb);\n#endif\n\n#ifdef USESPHERICALFROMREFLECTIONMAP\n#if defined(NORMAL) && !defined(USESPHERICALINFRAGMENT)\nenvironmentIrradiance=vEnvironmentIrradiance;\n#else\nvec3 irradianceVector=vec3(reflectionMatrix*vec4(normalW,0)).xyz;\n#ifdef REFLECTIONMAP_OPPOSITEZ\nirradianceVector.z*=-1.0;\n#endif\nenvironmentIrradiance=environmentIrradianceJones(irradianceVector);\n#endif\n#endif\n\nenvironmentRadiance*=vReflectionInfos.x;\nenvironmentRadiance*=vReflectionColor.rgb;\nenvironmentIrradiance*=vReflectionColor.rgb;\n#endif\n\n\n\nfloat reflectance=max(max(surfaceReflectivityColor.r,surfaceReflectivityColor.g),surfaceReflectivityColor.b);\nfloat reflectance90=fresnelGrazingReflectance(reflectance);\nvec3 specularEnvironmentR0=surfaceReflectivityColor.rgb;\nvec3 specularEnvironmentR90=vec3(1.0,1.0,1.0)*reflectance90;\n\nvec3 diffuseBase=vec3(0.,0.,0.);\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\n#ifdef LIGHTMAP\nvec3 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset).rgb*vLightmapInfos.y;\n#endif\nlightingInfo info;\nfloat shadow=1.; \nfloat NdotL=-1.;\n#include[0..maxSimultaneousLights]\n\n#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\n\nvec2 brdfSamplerUV=vec2(NdotV,roughness);\n\nvec4 environmentBrdf=texture2D(environmentBrdfSampler,brdfSamplerUV);\nvec3 specularEnvironmentReflectance=specularEnvironmentR0*environmentBrdf.x+environmentBrdf.y;\n#ifdef AMBIENTINGRAYSCALE\nfloat ambientMonochrome=ambientOcclusionColor.r;\n#else\nfloat ambientMonochrome=getLuminance(ambientOcclusionColor);\n#endif\nfloat seo=environmentRadianceOcclusion(ambientMonochrome,NdotVUnclamped);\nspecularEnvironmentReflectance*=seo;\n#ifdef BUMP\n#ifdef REFLECTIONMAP_3D\nfloat eho=environmentHorizonOcclusion(reflectionCoords,normalW);\nspecularEnvironmentReflectance*=eho;\n#endif\n#endif\n#else\n\nvec3 specularEnvironmentReflectance=fresnelSchlickEnvironmentGGX(NdotV,specularEnvironmentR0,specularEnvironmentR90,sqrt(microSurface));\n#endif\n\n#ifdef REFRACTION\nvec3 refractance=vec3(0.0,0.0,0.0);\nvec3 transmission=vec3(1.0,1.0,1.0);\n#ifdef LINKREFRACTIONTOTRANSPARENCY\n\ntransmission*=(1.0-alpha);\n\n\nvec3 mixedAlbedo=surfaceAlbedo;\nfloat maxChannel=max(max(mixedAlbedo.r,mixedAlbedo.g),mixedAlbedo.b);\nvec3 tint=clamp(maxChannel*mixedAlbedo,0.0,1.0);\n\nsurfaceAlbedo*=alpha;\n\nenvironmentIrradiance*=alpha;\n\nenvironmentRefraction*=tint;\n\nalpha=1.0;\n#endif\n\nvec3 bounceSpecularEnvironmentReflectance=(2.0*specularEnvironmentReflectance)/(1.0+specularEnvironmentReflectance);\nspecularEnvironmentReflectance=mix(bounceSpecularEnvironmentReflectance,specularEnvironmentReflectance,alpha);\n\ntransmission*=1.0-specularEnvironmentReflectance;\n\nrefractance=transmission;\n#endif\n\n\n\n\nsurfaceAlbedo.rgb=(1.-reflectance)*surfaceAlbedo.rgb;\n\nvec3 finalDiffuse=diffuseBase;\nfinalDiffuse.rgb+=vAmbientColor;\nfinalDiffuse*=surfaceAlbedo.rgb;\nfinalDiffuse=max(finalDiffuse,0.0);\n\n#ifdef REFLECTION\nvec3 finalIrradiance=environmentIrradiance;\nfinalIrradiance*=surfaceAlbedo.rgb;\n#endif\n\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase;\nfinalSpecular=max(finalSpecular,0.0);\n\nvec3 finalSpecularScaled=finalSpecular*vLightingIntensity.x*vLightingIntensity.w;\n#endif\n\n#ifdef REFLECTION\nvec3 finalRadiance=environmentRadiance;\nfinalRadiance*=specularEnvironmentReflectance;\n\nvec3 finalRadianceScaled=finalRadiance*vLightingIntensity.z;\n#endif\n\n#ifdef REFRACTION\nvec3 finalRefraction=environmentRefraction;\nfinalRefraction*=refractance;\n#endif\n\nvec3 finalEmissive=vEmissiveColor;\n#ifdef EMISSIVE\nvec3 emissiveColorTex=texture2D(emissiveSampler,vEmissiveUV+uvOffset).rgb;\nfinalEmissive*=toLinearSpace(emissiveColorTex.rgb);\nfinalEmissive*=vEmissiveInfos.y;\n#endif\n\n#ifdef ALPHABLEND\nfloat luminanceOverAlpha=0.0;\n#if defined(REFLECTION) && defined(RADIANCEOVERALPHA)\nluminanceOverAlpha+=getLuminance(finalRadianceScaled);\n#endif\n#if defined(SPECULARTERM) && defined(SPECULAROVERALPHA)\nluminanceOverAlpha+=getLuminance(finalSpecularScaled);\n#endif\n#if defined(RADIANCEOVERALPHA) || defined(SPECULAROVERALPHA)\nalpha=clamp(alpha+luminanceOverAlpha*luminanceOverAlpha,0.,1.);\n#endif\n#endif\n\n\n\nvec4 finalColor=vec4(finalDiffuse*ambientOcclusionColor*vLightingIntensity.x +\n#ifdef REFLECTION\nfinalIrradiance*ambientOcclusionColor*vLightingIntensity.z +\n#endif\n#ifdef SPECULARTERM\n\n\nfinalSpecularScaled +\n#endif\n#ifdef REFLECTION\n\n\nfinalRadianceScaled +\n#endif\n#ifdef REFRACTION\nfinalRefraction*vLightingIntensity.z +\n#endif\nfinalEmissive*vLightingIntensity.y,\nalpha);\n\n#ifdef LIGHTMAP\n#ifndef LIGHTMAPEXCLUDED\n#ifdef USELIGHTMAPASSHADOWMAP\nfinalColor.rgb*=lightmapColor;\n#else\nfinalColor.rgb+=lightmapColor;\n#endif\n#endif\n#endif\n\nfinalColor=max(finalColor,0.0);\n#include\n#include(color,finalColor)\n#ifdef IMAGEPROCESSINGPOSTPROCESS\n\n\nfinalColor.rgb=clamp(finalColor.rgb,0.,30.0);\n#else\n\nfinalColor=applyImageProcessing(finalColor);\n#endif\n#ifdef PREMULTIPLYALPHA\n\nfinalColor.rgb*=finalColor.a;\n#endif\ngl_FragColor=finalColor;\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n}",spritesVertexShader:"\nattribute vec4 position;\nattribute vec4 options;\nattribute vec4 cellInfo;\nattribute vec4 color;\n\nuniform vec2 textureInfos;\nuniform mat4 view;\nuniform mat4 projection;\n\nvarying vec2 vUV;\nvarying vec4 vColor;\n#include\nvoid main(void) { \nvec3 viewPos=(view*vec4(position.xyz,1.0)).xyz; \nvec2 cornerPos;\nfloat angle=position.w;\nvec2 size=vec2(options.x,options.y);\nvec2 offset=options.zw;\nvec2 uvScale=textureInfos.xy;\ncornerPos=vec2(offset.x-0.5,offset.y-0.5)*size;\n\nvec3 rotatedCorner;\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.z=0.;\n\nviewPos+=rotatedCorner;\ngl_Position=projection*vec4(viewPos,1.0); \n\nvColor=color;\n\nvec2 uvOffset=vec2(abs(offset.x-cellInfo.x),1.0-abs(offset.y-cellInfo.y));\nvUV=(uvOffset+cellInfo.zw)*uvScale;\n\n#ifdef FOG\nvFogDistance=viewPos;\n#endif\n}",spritesPixelShader:"uniform bool alphaTest;\nvarying vec4 vColor;\n\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n\n#include\nvoid main(void) {\nvec4 color=texture2D(diffuseSampler,vUV);\nif (alphaTest) \n{\nif (color.a<0.95)\ndiscard;\n}\ncolor*=vColor;\n#include\ngl_FragColor=color;\n}",particlesVertexShader:"\nattribute vec3 position;\nattribute vec4 color;\nattribute vec4 options;\n\nuniform mat4 view;\nuniform mat4 projection;\n\nvarying vec2 vUV;\nvarying vec4 vColor;\n#ifdef CLIPPLANE\nuniform vec4 vClipPlane;\nuniform mat4 invView;\nvarying float fClipDistance;\n#endif\nvoid main(void) { \nvec3 viewPos=(view*vec4(position,1.0)).xyz; \nvec3 cornerPos;\nfloat size=options.y;\nfloat angle=options.x;\nvec2 offset=options.zw;\ncornerPos=vec3(offset.x-0.5,offset.y-0.5,0.)*size;\n\nvec3 rotatedCorner;\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.z=0.;\n\nviewPos+=rotatedCorner;\ngl_Position=projection*vec4(viewPos,1.0); \nvColor=color;\nvUV=offset;\n\n#ifdef CLIPPLANE\nvec4 worldPos=invView*vec4(viewPos,1.0);\nfClipDistance=dot(worldPos,vClipPlane);\n#endif\n}",particlesPixelShader:"\nvarying vec2 vUV;\nvarying vec4 vColor;\nuniform vec4 textureMask;\nuniform sampler2D diffuseSampler;\n#ifdef CLIPPLANE\nvarying float fClipDistance;\n#endif\nvoid main(void) {\n#ifdef CLIPPLANE\nif (fClipDistance>0.0)\ndiscard;\n#endif\nvec4 baseColor=texture2D(diffuseSampler,vUV);\ngl_FragColor=(baseColor*textureMask+(vec4(1.,1.,1.,1.)-textureMask))*vColor;\n}",colorVertexShader:"\nattribute vec3 position;\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include\n\nuniform mat4 viewProjection;\nuniform mat4 world;\n\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\nvoid main(void) {\nmat4 finalWorld=world;\n#include\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\n#ifdef VERTEXCOLOR\n\nvColor=color;\n#endif\n}",colorPixelShader:"#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#else\nuniform vec4 color;\n#endif\nvoid main(void) {\n#ifdef VERTEXCOLOR\ngl_FragColor=vColor;\n#else\ngl_FragColor=color;\n#endif\n}",postprocessVertexShader:"\nattribute vec2 position;\nuniform vec2 scale;\n\nvarying vec2 vUV;\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) { \nvUV=(position*madd+madd)*scale;\ngl_Position=vec4(position,0.0,1.0);\n}",passPixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nvoid main(void) \n{\ngl_FragColor=texture2D(textureSampler,vUV);\n}",shadowMapVertexShader:"\nattribute vec3 position;\n#include\n\n#include\nuniform mat4 viewProjection;\nuniform vec2 biasAndScale;\nuniform vec2 depthValues;\nvarying float vDepthMetric;\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform mat4 diffuseMatrix;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#endif\nvoid main(void)\n{\n#include\n#include\nvec4 worldPos=finalWorld*vec4(position,1.0);\ngl_Position=viewProjection*worldPos;\nvDepthMetric=((gl_Position.z+depthValues.x)/(depthValues.y))+biasAndScale.x;\n#ifdef ALPHATEST\n#ifdef UV1\nvUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n#endif\n#ifdef UV2\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n}",shadowMapPixelShader:"#ifndef FLOAT\nvec4 pack(float depth)\n{\nconst vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);\nconst vec4 bit_mask=vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);\nvec4 res=fract(depth*bit_shift);\nres-=res.xxyz*bit_mask;\nreturn res;\n}\n#endif\nvarying float vDepthMetric;\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n#endif\nuniform vec2 biasAndScale;\nuniform vec2 depthValues;\nvoid main(void)\n{\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\nfloat depth=vDepthMetric;\n#ifdef ESM\ndepth=clamp(exp(-min(87.,biasAndScale.y*depth)),0.,1.);\n#endif\n#ifdef FLOAT\ngl_FragColor=vec4(depth,1.0,1.0,1.0);\n#else\ngl_FragColor=pack(depth);\n#endif\n}",depthBoxBlurPixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n\nuniform vec2 screenSize;\nvoid main(void)\n{\nvec4 colorDepth=vec4(0.0);\nfor (int x=-OFFSET; x<=OFFSET; x++)\nfor (int y=-OFFSET; y<=OFFSET; y++)\ncolorDepth+=texture2D(textureSampler,vUV+vec2(x,y)/screenSize);\ngl_FragColor=(colorDepth/float((OFFSET*2+1)*(OFFSET*2+1)));\n}",proceduralVertexShader:"\nattribute vec2 position;\n\nvarying vec2 vPosition;\nvarying vec2 vUV;\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) { \nvPosition=position;\nvUV=position*madd+madd;\ngl_Position=vec4(position,0.0,1.0);\n}",depthVertexShader:"\nattribute vec3 position;\n#include\n\n#include\nuniform mat4 viewProjection;\nuniform vec2 depthValues;\n#if defined(ALPHATEST) || defined(NEED_UV)\nvarying vec2 vUV;\nuniform mat4 diffuseMatrix;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#endif\nvarying float vDepthMetric;\nvoid main(void)\n{\n#include\n#include\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\nvDepthMetric=((gl_Position.z+depthValues.x)/(depthValues.y));\n#if defined(ALPHATEST) || defined(BASIC_RENDER)\n#ifdef UV1\nvUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n#endif\n#ifdef UV2\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n}",depthPixelShader:"#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n#endif\nvarying float vDepthMetric;\nvoid main(void)\n{\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\ngl_FragColor=vec4(vDepthMetric,vDepthMetric*vDepthMetric,0.0,1.0);\n}",ssaoPixelShader:"\nuniform sampler2D textureSampler;\nvarying vec2 vUV;\n#ifdef SSAO\nuniform sampler2D randomSampler;\nuniform float randTextureTiles;\nuniform float samplesFactor;\nuniform vec3 sampleSphere[SAMPLES];\nuniform float totalStrength;\nuniform float radius;\nuniform float area;\nuniform float fallOff;\nuniform float base;\nvec3 normalFromDepth(float depth,vec2 coords)\n{\nvec2 offset1=vec2(0.0,radius);\nvec2 offset2=vec2(radius,0.0);\nfloat depth1=texture2D(textureSampler,coords+offset1).r;\nfloat depth2=texture2D(textureSampler,coords+offset2).r;\nvec3 p1=vec3(offset1,depth1-depth);\nvec3 p2=vec3(offset2,depth2-depth);\nvec3 normal=cross(p1,p2);\nnormal.z=-normal.z;\nreturn normalize(normal);\n}\nvoid main()\n{\nvec3 random=normalize(texture2D(randomSampler,vUV*randTextureTiles).rgb);\nfloat depth=texture2D(textureSampler,vUV).r;\nvec3 position=vec3(vUV,depth);\nvec3 normal=normalFromDepth(depth,vUV);\nfloat radiusDepth=radius/depth;\nfloat occlusion=0.0;\nvec3 ray;\nvec3 hemiRay;\nfloat occlusionDepth;\nfloat difference;\nfor (int i=0; i any; - isMP3supported: boolean; - isOGGsupported: boolean; - readonly audioContext: AudioContext; - constructor(); - private _unlockiOSaudio(); - private _initializeAudioContext(); - dispose(): void; - getGlobalVolume(): number; - setGlobalVolume(newVolume: number): void; - connectToAnalyser(analyser: Analyser): void; - } -} - -declare module BABYLON { - class Sound { - name: string; - autoplay: boolean; - loop: boolean; - useCustomAttenuation: boolean; - soundTrackId: number; - spatialSound: boolean; - refDistance: number; - rolloffFactor: number; - maxDistance: number; - distanceModel: string; - private _panningModel; - onended: () => any; - private _playbackRate; - private _streaming; - private _startTime; - private _startOffset; - private _position; - private _localDirection; - private _volume; - private _isLoaded; - private _isReadyToPlay; - isPlaying: boolean; - isPaused: boolean; - private _isDirectional; - private _readyToPlayCallback; - private _audioBuffer; - private _soundSource; - private _streamingSource; - private _soundPanner; - private _soundGain; - private _inputAudioNode; - private _ouputAudioNode; - 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 - * @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?: () => void, options?: any); - dispose(): void; - isReady(): boolean; - private _soundLoaded(audioData); - setAudioBuffer(audioBuffer: AudioBuffer): void; - updateOptions(options: any): void; - private _createSpatialParameters(); - private _updateSpatialParameters(); - switchPanningModelToHRTF(): void; - switchPanningModelToEqualPower(): void; - private _switchPanningModel(); - 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; - setPosition(newPosition: Vector3): void; - setLocalDirectionToMesh(newLocalDirection: Vector3): void; - private _updateDirection(); - updateDistanceFromListener(): void; - 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; - pause(): void; - setVolume(newVolume: number, time?: number): void; - setPlaybackRate(newPlaybackRate: number): void; - getVolume(): number; - attachToMesh(meshToConnectTo: AbstractMesh): void; - detachFromMesh(): void; - private _onRegisterAfterWorldMatrixUpdate(connectedMesh); - clone(): Sound; - getAudioBuffer(): AudioBuffer; - serialize(): any; - static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound; - } -} - -declare module BABYLON { - class SoundTrack { - private _outputAudioNode; - private _inputAudioNode; - private _trackConvolver; - private _scene; - id: number; - soundCollection: Array; - private _isMainTrack; - private _connectedAnalyser; - private _options; - private _isInitialized; - constructor(scene: Scene, options?: any); - private _initializeSoundTrackAudioGraph(); - dispose(): void; - AddSound(sound: Sound): void; - RemoveSound(sound: Sound): void; - setVolume(newVolume: number): void; - switchPanningModelToHRTF(): void; - switchPanningModelToEqualPower(): void; - connectToAnalyser(analyser: Analyser): void; - } -} - declare module BABYLON { class Animatable { target: any; @@ -2916,23 +2734,205 @@ declare module BABYLON { } declare module BABYLON { - class Bone extends Node { + class Analyser { + SMOOTHING: number; + FFT_SIZE: number; + BARGRAPHAMPLITUDE: number; + DEBUGCANVASPOS: { + x: number; + y: number; + }; + DEBUGCANVASSIZE: { + width: number; + height: number; + }; + private _byteFreqs; + private _byteTime; + private _floatFreqs; + private _webAudioAnalyser; + private _debugCanvas; + private _debugCanvasContext; + private _scene; + private _registerFunc; + private _audioEngine; + constructor(scene: Scene); + getFrequencyBinCount(): number; + getByteFrequencyData(): Uint8Array; + getByteTimeDomainData(): Uint8Array; + getFloatFrequencyData(): Uint8Array; + drawDebugCanvas(): void; + stopDebugCanvas(): void; + connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void; + dispose(): void; + } +} + +declare module BABYLON { + class AudioEngine { + private _audioContext; + private _audioContextInitialized; + canUseWebAudio: boolean; + masterGain: GainNode; + private _connectedAnalyser; + WarnedWebAudioUnsupported: boolean; + unlocked: boolean; + onAudioUnlocked: () => any; + isMP3supported: boolean; + isOGGsupported: boolean; + readonly audioContext: AudioContext; + constructor(); + private _unlockiOSaudio(); + private _initializeAudioContext(); + dispose(): void; + getGlobalVolume(): number; + setGlobalVolume(newVolume: number): void; + connectToAnalyser(analyser: Analyser): void; + } +} + +declare module BABYLON { + class Sound { name: string; - private static _tmpVecs; - private static _tmpQuat; - private static _tmpMats; - children: Bone[]; - animations: Animation[]; - length: number; - private _skeleton; - private _localMatrix; - private _restPose; - private _baseMatrix; - private _worldTransform; - private _absoluteTransform; - private _invertedAbsoluteTransform; - private _parent; - private _scaleMatrix; + autoplay: boolean; + loop: boolean; + useCustomAttenuation: boolean; + soundTrackId: number; + spatialSound: boolean; + refDistance: number; + rolloffFactor: number; + maxDistance: number; + distanceModel: string; + private _panningModel; + onended: () => any; + private _playbackRate; + private _streaming; + private _startTime; + private _startOffset; + private _position; + private _localDirection; + private _volume; + private _isLoaded; + private _isReadyToPlay; + isPlaying: boolean; + isPaused: boolean; + private _isDirectional; + private _readyToPlayCallback; + private _audioBuffer; + private _soundSource; + private _streamingSource; + private _soundPanner; + private _soundGain; + private _inputAudioNode; + private _ouputAudioNode; + 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 + * @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?: () => void, options?: any); + dispose(): void; + isReady(): boolean; + private _soundLoaded(audioData); + setAudioBuffer(audioBuffer: AudioBuffer): void; + updateOptions(options: any): void; + private _createSpatialParameters(); + private _updateSpatialParameters(); + switchPanningModelToHRTF(): void; + switchPanningModelToEqualPower(): void; + private _switchPanningModel(); + 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; + setPosition(newPosition: Vector3): void; + setLocalDirectionToMesh(newLocalDirection: Vector3): void; + private _updateDirection(); + updateDistanceFromListener(): void; + 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; + pause(): void; + setVolume(newVolume: number, time?: number): void; + setPlaybackRate(newPlaybackRate: number): void; + getVolume(): number; + attachToMesh(meshToConnectTo: AbstractMesh): void; + detachFromMesh(): void; + private _onRegisterAfterWorldMatrixUpdate(connectedMesh); + clone(): Sound; + getAudioBuffer(): AudioBuffer; + serialize(): any; + static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound; + } +} + +declare module BABYLON { + class SoundTrack { + private _outputAudioNode; + private _inputAudioNode; + private _trackConvolver; + private _scene; + id: number; + soundCollection: Array; + private _isMainTrack; + private _connectedAnalyser; + private _options; + private _isInitialized; + constructor(scene: Scene, options?: any); + private _initializeSoundTrackAudioGraph(); + dispose(): void; + AddSound(sound: Sound): void; + RemoveSound(sound: Sound): void; + setVolume(newVolume: number): void; + switchPanningModelToHRTF(): void; + switchPanningModelToEqualPower(): void; + connectToAnalyser(analyser: Analyser): void; + } +} + +declare module BABYLON { + class Bone extends Node { + name: string; + private static _tmpVecs; + private static _tmpQuat; + private static _tmpMats; + children: Bone[]; + animations: Animation[]; + length: number; + private _skeleton; + private _localMatrix; + private _restPose; + private _baseMatrix; + private _worldTransform; + private _absoluteTransform; + private _invertedAbsoluteTransform; + private _parent; + private _scaleMatrix; private _scaleVector; private _negateScaleChildren; private _scalingDeterminant; @@ -4220,93 +4220,266 @@ declare module BABYLON { } } -declare module BABYLON { - /** - * 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?: Camera; +declare module BABYLON.Debug { + class AxesViewer { + private _xline; + private _yline; + private _zline; + private _xmesh; + private _ymesh; + private _zmesh; + scene: Scene; + scaleLines: number; + constructor(scene: Scene, scaleLines?: number); + update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void; + dispose(): void; } - /** - * 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 { - name: 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; +} + +declare module BABYLON.Debug { + class BoneAxesViewer extends Debug.AxesViewer { + mesh: Mesh; + bone: Bone; + pos: Vector3; + xaxis: Vector3; + yaxis: Vector3; + zaxis: Vector3; + constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number); + update(): void; + dispose(): void; + } +} + +declare module BABYLON { + class DebugLayer { private _scene; - private _engine; - private _options; - private _vertexBuffers; - private _indexBuffer; - private _downSamplePostprocess; - private _horizontalBlurPostprocess; - private _verticalBlurPostprocess; - private _cachedDefines; - private _glowMapGenerationEffect; - private _glowMapMergeEffect; - private _blurTexture; - private _mainTexture; - private _mainTextureDesiredSize; - private _meshes; - private _maxSize; - private _shouldRender; - private _instanceGlowingMeshStencilReference; - private _excludedMeshes; - /** - * 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; + static InspectorURL: string; + private _inspector; + constructor(scene: Scene); + /** Creates the inspector window. */ + private _createInspector(config?); + isVisible(): boolean; + hide(): void; + show(config?: { + popup?: boolean; + initialTab?: number; + parentElement?: HTMLElement; + newColors?: { + backgroundColor?: string; + backgroundColorLighter?: string; + backgroundColorLighter2?: string; + backgroundColorLighter3?: string; + color?: string; + colorTop?: string; + colorBot?: string; + }; + }): void; + } +} + +declare module BABYLON.Debug { + class PhysicsViewer { + protected _impostors: Array; + protected _meshes: Array; + protected _scene: Scene; + protected _numMeshes: number; + protected _physicsEnginePlugin: IPhysicsEnginePlugin; + private _renderFunction; + private _debugBoxMesh; + private _debugSphereMesh; + private _debugMaterial; + constructor(scene: Scene); + protected _updateDebugMeshes(): void; + showImpostor(impostor: PhysicsImpostor): void; + hideImpostor(impostor: PhysicsImpostor): void; + private _getDebugMaterial(scene); + private _getDebugBoxMesh(scene); + private _getDebugSphereMesh(scene); + private _getDebugMesh(impostor, scene); + dispose(): void; + } +} + +declare module BABYLON { + class RayHelper { + ray: Ray; + private _renderPoints; + private _renderLine; + private _renderFunction; + private _scene; + private _updateToMeshFunction; + private _attachedToMesh; + private _meshSpaceDirection; + private _meshSpaceOrigin; + static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper; + constructor(ray: Ray); + show(scene: Scene, color: Color3): void; + hide(): void; + private _render(); + attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void; + detachFromMesh(): void; + private _updateToMesh(); + dispose(): void; + } +} + +declare module BABYLON.Debug { + /** + * Demo available here: http://www.babylonjs-playground.com/#1BZJVJ#8 + */ + class SkeletonViewer { + skeleton: Skeleton; + mesh: AbstractMesh; + autoUpdateBonesMatrices: boolean; + renderingGroupId: number; + color: Color3; + private _scene; + private _debugLines; + private _debugMesh; + private _isEnabled; + private _renderFunction; + constructor(skeleton: Skeleton, mesh: AbstractMesh, scene: Scene, autoUpdateBonesMatrices?: boolean, renderingGroupId?: number); + isEnabled: boolean; + private _getBonePosition(position, bone, meshMat, x?, y?, z?); + private _getLinesForBonesWithLength(bones, meshMat); + private _getLinesForBonesNoLength(bones, meshMat); + update(): void; + dispose(): void; + } +} + +declare module BABYLON { + class LensFlare { + size: number; + position: number; + color: Color3; + texture: Texture; + alphaMode: number; + private _system; + constructor(size: number, position: number, color: any, imgUrl: string, system: LensFlareSystem); + dispose: () => void; + } +} + +declare module BABYLON { + class LensFlareSystem { + name: string; + lensFlares: LensFlare[]; + borderLimit: number; + viewportBorder: number; + meshesSelectionPredicate: (mesh: Mesh) => boolean; + layerMask: number; + id: string; + private _scene; + private _emitter; + private _vertexBuffers; + private _indexBuffer; + private _effect; + private _positionX; + private _positionY; + private _isEnabled; + constructor(name: string, emitter: any, scene: Scene); + isEnabled: boolean; + getScene(): Scene; + getEmitter(): any; + setEmitter(newEmitter: any): void; + getEmitterPosition(): Vector3; + computeEffectivePosition(globalViewport: Viewport): boolean; + _isVisible(): boolean; + render(): boolean; + dispose(): void; + static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem; + serialize(): any; + } +} + +declare module BABYLON { + /** + * 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?: Camera; + } + /** + * 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 { + name: 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; + private _scene; + private _engine; + private _options; + private _vertexBuffers; + private _indexBuffer; + private _downSamplePostprocess; + private _horizontalBlurPostprocess; + private _verticalBlurPostprocess; + private _cachedDefines; + private _glowMapGenerationEffect; + private _glowMapMergeEffect; + private _blurTexture; + private _mainTexture; + private _mainTextureDesiredSize; + private _meshes; + private _maxSize; + private _shouldRender; + private _instanceGlowingMeshStencilReference; + private _excludedMeshes; + /** + * 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 wether the highlight layer is enabled or not. */ @@ -4476,179 +4649,6 @@ declare module BABYLON { } } -declare module BABYLON { - class LensFlare { - size: number; - position: number; - color: Color3; - texture: Texture; - alphaMode: number; - private _system; - constructor(size: number, position: number, color: any, imgUrl: string, system: LensFlareSystem); - dispose: () => void; - } -} - -declare module BABYLON { - class LensFlareSystem { - name: string; - lensFlares: LensFlare[]; - borderLimit: number; - viewportBorder: number; - meshesSelectionPredicate: (mesh: Mesh) => boolean; - layerMask: number; - id: string; - private _scene; - private _emitter; - private _vertexBuffers; - private _indexBuffer; - private _effect; - private _positionX; - private _positionY; - private _isEnabled; - constructor(name: string, emitter: any, scene: Scene); - isEnabled: boolean; - getScene(): Scene; - getEmitter(): any; - setEmitter(newEmitter: any): void; - getEmitterPosition(): Vector3; - computeEffectivePosition(globalViewport: Viewport): boolean; - _isVisible(): boolean; - render(): boolean; - dispose(): void; - static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem; - serialize(): any; - } -} - -declare module BABYLON.Debug { - class AxesViewer { - private _xline; - private _yline; - private _zline; - private _xmesh; - private _ymesh; - private _zmesh; - scene: Scene; - scaleLines: number; - constructor(scene: Scene, scaleLines?: number); - update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void; - dispose(): void; - } -} - -declare module BABYLON.Debug { - class BoneAxesViewer extends Debug.AxesViewer { - mesh: Mesh; - bone: Bone; - pos: Vector3; - xaxis: Vector3; - yaxis: Vector3; - zaxis: Vector3; - constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number); - update(): void; - dispose(): void; - } -} - -declare module BABYLON { - class DebugLayer { - private _scene; - static InspectorURL: string; - private _inspector; - constructor(scene: Scene); - /** Creates the inspector window. */ - private _createInspector(config?); - isVisible(): boolean; - hide(): void; - show(config?: { - popup?: boolean; - initialTab?: number; - parentElement?: HTMLElement; - newColors?: { - backgroundColor?: string; - backgroundColorLighter?: string; - backgroundColorLighter2?: string; - backgroundColorLighter3?: string; - color?: string; - colorTop?: string; - colorBot?: string; - }; - }): void; - } -} - -declare module BABYLON.Debug { - class PhysicsViewer { - protected _impostors: Array; - protected _meshes: Array; - protected _scene: Scene; - protected _numMeshes: number; - protected _physicsEnginePlugin: IPhysicsEnginePlugin; - private _renderFunction; - private _debugBoxMesh; - private _debugSphereMesh; - private _debugMaterial; - constructor(scene: Scene); - protected _updateDebugMeshes(): void; - showImpostor(impostor: PhysicsImpostor): void; - hideImpostor(impostor: PhysicsImpostor): void; - private _getDebugMaterial(scene); - private _getDebugBoxMesh(scene); - private _getDebugSphereMesh(scene); - private _getDebugMesh(impostor, scene); - dispose(): void; - } -} - -declare module BABYLON { - class RayHelper { - ray: Ray; - private _renderPoints; - private _renderLine; - private _renderFunction; - private _scene; - private _updateToMeshFunction; - private _attachedToMesh; - private _meshSpaceDirection; - private _meshSpaceOrigin; - static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper; - constructor(ray: Ray); - show(scene: Scene, color: Color3): void; - hide(): void; - private _render(); - attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void; - detachFromMesh(): void; - private _updateToMesh(); - dispose(): void; - } -} - -declare module BABYLON.Debug { - /** - * Demo available here: http://www.babylonjs-playground.com/#1BZJVJ#8 - */ - class SkeletonViewer { - skeleton: Skeleton; - mesh: AbstractMesh; - autoUpdateBonesMatrices: boolean; - renderingGroupId: number; - color: Color3; - private _scene; - private _debugLines; - private _debugMesh; - private _isEnabled; - private _renderFunction; - constructor(skeleton: Skeleton, mesh: AbstractMesh, scene: Scene, autoUpdateBonesMatrices?: boolean, renderingGroupId?: number); - isEnabled: boolean; - private _getBonePosition(position, bone, meshMat, x?, y?, z?); - private _getLinesForBonesWithLength(bones, meshMat); - private _getLinesForBonesNoLength(bones, meshMat); - update(): void; - dispose(): void; - } -} - declare module BABYLON { class DirectionalLight extends ShadowLight { private _shadowFrustumSize; @@ -5282,3528 +5282,3528 @@ declare module BABYLON { } 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; + class Scalar { /** - * 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). + * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45) */ + static WithinEpsilon(a: number, b: number, epsilon?: number): boolean; /** - * 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). + * Returns a string : the upper case translation of the number i to hexadecimal. */ - globalHue: number; + static ToHex(i: number): string; /** - * 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. + * Returns -1 if value is negative and +1 is value is positive. + * Returns the value itself if it's equal to zero. */ + static Sign(value: number): number; /** - * 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. + * Returns the value itself if it's between min and max. + * Returns min if the value is lower than min. + * Returns max if the value is greater than max. */ - globalDensity: number; + static Clamp(value: number, min?: number, max?: number): 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. + * Returns the log2 of value. */ + static Log2(value: number): number; /** - * 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; - private _highlightsHue; - private _highlightsDensity; - private _highlightsSaturation; - private _highlightsExposure; + * Loops the value, so that it is never larger than length and never smaller than 0. + * + * This is similar to the modulo operator but it works with floating point numbers. + * For example, using 3.0 for t and 2.5 for length, the result would be 0.5. + * With t = 5 and length = 2.5, the result would be 0.0. + * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator + */ + static Repeat(value: number, length: number): number; /** - * 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). - */ + * Normalize the value between 0.0 and 1.0 using min and max values + */ + static Normalize(value: number, min: number, max: number): number; /** - * 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; + * Denormalize the value from 0.0 and 1.0 using min and max values + */ + static Denormalize(normalized: number, min: number, max: number): 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. - */ + * Calculates the shortest difference between two given angles given in degrees. + */ + static DeltaAngle(current: number, target: number): number; /** - * 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; + * PingPongs the value t, so that it is never larger than length and never smaller than 0. + * + * The returned value will move back and forth between 0 and length + */ + static PingPong(tx: number, length: number): 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. - */ + * Interpolates between min and max with smoothing at the limits. + * + * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up + * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions. + */ + static SmoothStep(from: number, to: number, tx: number): number; /** - * 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; + * Moves a value current towards target. + * + * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta. + * Negative values of maxDelta pushes the value away from target. + */ + static MoveTowards(current: number, target: number, maxDelta: number): 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. + * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees. + * + * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta + * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead. + */ + static MoveTowardsAngle(current: number, target: number, maxDelta: number): number; + /** + * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar. + */ + static Lerp(start: number, end: number, amount: number): number; + /** + * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees. + * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees. + */ + static LerpAngle(start: number, end: number, amount: number): number; + /** + * Calculates the linear parameter t that produces the interpolant value within the range [a, b]. + */ + static InverseLerp(a: number, b: number, value: number): number; + /** + * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2". */ + static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number; /** - * 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. + * Returns a random float number between and min and max values + */ + static RandomRange(min: number, max: number): number; + /** + * This function returns percentage of a number in a given range. + * + * RangeToPercent(40,20,60) will return 0.5 (50%) + * RangeToPercent(34,0,100) will return 0.34 (34%) + */ + static RangeToPercent(number: number, min: number, max: number): number; + /** + * This function returns number that corresponds to the percentage in a given range. + * + * PercentToRange(0.34,0,100) will return 34. + */ + static PercentToRange(percent: number, min: number, max: number): number; + } +} + +declare module BABYLON { + class SIMDHelper { + private static _isEnabled; + static readonly IsEnabled: boolean; + static DisableSIMD(): void; + static EnableSIMD(): void; + } +} + +declare module BABYLON { + const ToGammaSpace: number; + const ToLinearSpace = 2.2; + const Epsilon = 0.001; + class Color3 { + r: number; + g: number; + b: number; + /** + * Creates a new Color3 object from red, green, blue values, all between 0 and 1. */ - highlightsExposure: number; - private _midtonesHue; - private _midtonesDensity; - private _midtonesSaturation; - private _midtonesExposure; + constructor(r?: number, g?: number, b?: number); /** - * 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). + * Returns a string with the Color3 current values. */ + toString(): string; /** - * 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). + * Returns the string "Color3". */ - midtonesHue: number; + getClassName(): string; /** - * 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. + * Returns the Color3 hash code. */ + getHashCode(): number; /** - * 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. + * Stores in the passed array from the passed starting index the red, green, blue values as successive elements. + * Returns the Color3. */ - midtonesDensity: number; + toArray(array: number[] | Float32Array, index?: number): Color3; /** - * 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. + * Returns a new Color4 object from the current Color3 and the passed alpha. */ + toColor4(alpha?: number): Color4; /** - * 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. + * Returns a new array populated with 3 numeric elements : red, green and blue values. */ - midtonesSaturation: number; + asArray(): 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. + * Returns the luminance value (float). */ + toLuminance(): number; /** - * 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. + * Multiply each Color3 rgb values by the passed Color3 rgb values in a new Color3 object. + * Returns this new object. */ - midtonesExposure: number; - private _shadowsHue; - private _shadowsDensity; - private _shadowsSaturation; - private _shadowsExposure; + multiply(otherColor: Color3): Color3; /** - * 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). + * Multiply the rgb values of the Color3 and the passed Color3 and stores the result in the object "result". + * Returns the current Color3. */ + multiplyToRef(otherColor: Color3, result: Color3): Color3; /** - * 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). + * Boolean : True if the rgb values are equal to the passed ones. */ - shadowsHue: number; + equals(otherColor: Color3): boolean; /** - * 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. + * Boolean : True if the rgb values are equal to the passed ones. */ + equalsFloats(r: number, g: number, b: number): boolean; /** - * 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. + * Multiplies in place each rgb value by scale. + * Returns the updated Color3. */ - shadowsDensity: number; + scale(scale: number): Color3; /** - * 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. + * Multiplies the rgb values by scale and stores the result into "result". + * Returns the unmodified current Color3. */ + scaleToRef(scale: number, result: Color3): Color3; /** - * 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. + * Returns a new Color3 set with the added values of the current Color3 and of the passed one. */ - shadowsSaturation: number; + add(otherColor: Color3): Color3; /** - * 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. + * Stores the result of the addition of the current Color3 and passed one rgb values into "result". + * Returns the unmodified current Color3. */ + addToRef(otherColor: Color3, result: Color3): Color3; /** - * 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. + * Returns a new Color3 set with the subtracted values of the passed one from the current Color3 . */ - shadowsExposure: number; - getClassName(): string; + subtract(otherColor: Color3): Color3; /** - * Binds the color curves to the shader. - * @param colorCurves The color curve to bind - * @param effect The effect to bind to + * Stores the result of the subtraction of passed one from the current Color3 rgb values into "result". + * Returns the unmodified current Color3. */ - static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void; + subtractToRef(otherColor: Color3, result: Color3): Color3; /** - * Prepare the list of uniforms associated with the ColorCurves effects. - * @param uniformsList The list of uniforms used in the effect + * Returns a new Color3 copied the current one. */ - static PrepareUniforms(uniformsList: string[]): void; + clone(): Color3; /** - * 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. + * Copies the rgb values from the source in the current Color3. + * Returns the updated Color3. */ - private getColorGradingDataToRef(hue, density, saturation, exposure, result); + copyFrom(source: Color3): Color3; /** - * 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. + * Updates the Color3 rgb values from the passed floats. + * Returns the Color3. */ - private static applyColorGradingSliderNonlinear(value); + copyFromFloats(r: number, g: number, b: number): Color3; /** - * 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. + * Updates the Color3 rgb values from the passed floats. + * Returns the Color3. */ - private static fromHSBToRef(hue, saturation, brightness, result); + set(r: number, g: number, b: number): Color3; /** - * 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. + * Returns the Color3 hexadecimal code as a string. */ - private static clamp(value, min, max); + toHexString(): string; /** - * Clones the current color curve instance. - * @return The cloned curves + * Returns a new Color3 converted to linear space. */ - clone(): ColorCurves; + toLinearSpace(): Color3; /** - * Serializes the current color curve instance to a json representation. - * @return a JSON representation + * Converts the Color3 values to linear space and stores the result in "convertedColor". + * Returns the unmodified Color3. */ - serialize(): any; + toLinearSpaceToRef(convertedColor: Color3): Color3; /** - * Parses the color curve from a json representation. - * @param source the JSON source to parse - * @return The parsed curves + * Returns a new Color3 converted to gamma space. */ - static Parse(source: any): ColorCurves; + toGammaSpace(): Color3; + /** + * Converts the Color3 values to gamma space and stores the result in "convertedColor". + * Returns the unmodified Color3. + */ + toGammaSpaceToRef(convertedColor: Color3): Color3; + /** + * Creates a new Color3 from the string containing valid hexadecimal values. + */ + static FromHexString(hex: string): Color3; + /** + * Creates a new Vector3 from the startind index of the passed array. + */ + static FromArray(array: ArrayLike, offset?: number): Color3; + /** + * Creates a new Color3 from integer values ( < 256). + */ + static FromInts(r: number, g: number, b: number): Color3; + /** + * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3. + */ + static Lerp(start: Color3, end: Color3, amount: number): Color3; + static Red(): Color3; + static Green(): Color3; + static Blue(): Color3; + static Black(): Color3; + static White(): Color3; + static Purple(): Color3; + static Magenta(): Color3; + static Yellow(): Color3; + static Gray(): Color3; + static Teal(): Color3; + static Random(): Color3; } -} - -declare module BABYLON { - class EffectFallbacks { - private _defines; - private _currentRank; - private _maxRank; - private _mesh; - private _meshRank; - addFallback(rank: number, define: string): void; - addCPUSkinningFallback(rank: number, mesh: BABYLON.AbstractMesh): void; - readonly isMoreFallbacks: boolean; - reduce(currentDefines: string): string; - } - class EffectCreationOptions { - attributes: string[]; - uniformsNames: string[]; - uniformBuffersNames: string[]; - samplers: string[]; - defines: any; - fallbacks: EffectFallbacks; - onCompiled: (effect: Effect) => void; - onError: (effect: Effect, errors: string) => void; - indexParameters: any; - maxSimultaneousLights: number; - } - class Effect { - name: any; - defines: string; - onCompiled: (effect: Effect) => void; - onError: (effect: Effect, errors: string) => void; - onBind: (effect: Effect) => void; - uniqueId: number; - onCompileObservable: Observable; - onErrorObservable: Observable; - onBindObservable: Observable; - private static _uniqueIdSeed; - private _engine; - private _uniformBuffersNames; - private _uniformsNames; - private _samplers; - private _isReady; - private _compilationError; - private _attributesNames; - private _attributes; - private _uniforms; - _key: string; - private _indexParameters; - private _fallbacks; - private _program; - private _valueCache; - private static _baseCache; - constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], engine?: Engine, defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, indexParameters?: any); - readonly key: string; - isReady(): boolean; - getEngine(): Engine; - getProgram(): WebGLProgram; - getAttributesNames(): string[]; - getAttributeLocation(index: number): number; - getAttributeLocationByName(name: string): number; - getAttributesCount(): number; - getUniformIndex(uniformName: string): number; - getUniform(uniformName: string): WebGLUniformLocation; - getSamplers(): string[]; - getCompilationError(): string; - getVertexShaderSource(): string; - getFragmentShaderSource(): string; - executeWhenCompiled(func: (effect: Effect) => void): void; - _loadVertexShader(vertex: any, callback: (data: any) => void): void; - _loadFragmentShader(fragment: any, callback: (data: any) => void): void; - private _dumpShadersSource(vertexCode, fragmentCode, defines); - private _processShaderConversion(sourceCode, isFragment, callback); - private _processIncludes(sourceCode, callback); - private _processPrecision(source); - private _prepareEffect(vertexSourceCode, fragmentSourceCode, attributesNames, defines, fallbacks?); - readonly isSupported: boolean; - _bindTexture(channel: string, texture: WebGLTexture): void; - setTexture(channel: string, texture: BaseTexture): void; - setTextureArray(channel: string, textures: BaseTexture[]): void; - setTextureFromPostProcess(channel: string, postProcess: PostProcess): void; - _cacheMatrix(uniformName: string, matrix: Matrix): boolean; - _cacheFloat2(uniformName: string, x: number, y: number): boolean; - _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean; - _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean; - bindUniformBuffer(buffer: WebGLBuffer, name: string): void; - bindUniformBlock(blockName: string, index: number): void; - setIntArray(uniformName: string, array: Int32Array): Effect; - setIntArray2(uniformName: string, array: Int32Array): Effect; - setIntArray3(uniformName: string, array: Int32Array): Effect; - setIntArray4(uniformName: string, array: Int32Array): Effect; - setFloatArray(uniformName: string, array: Float32Array): Effect; - setFloatArray2(uniformName: string, array: Float32Array): Effect; - setFloatArray3(uniformName: string, array: Float32Array): Effect; - setFloatArray4(uniformName: string, array: Float32Array): Effect; - setArray(uniformName: string, array: number[]): Effect; - setArray2(uniformName: string, array: number[]): Effect; - setArray3(uniformName: string, array: number[]): Effect; - setArray4(uniformName: string, array: number[]): Effect; - setMatrices(uniformName: string, matrices: Float32Array): Effect; - setMatrix(uniformName: string, matrix: Matrix): Effect; - setMatrix3x3(uniformName: string, matrix: Float32Array): Effect; - setMatrix2x2(uniformName: string, matrix: Float32Array): Effect; - setFloat(uniformName: string, value: number): Effect; - setBool(uniformName: string, bool: boolean): Effect; - setVector2(uniformName: string, vector2: Vector2): Effect; - setFloat2(uniformName: string, x: number, y: number): Effect; - setVector3(uniformName: string, vector3: Vector3): Effect; - setFloat3(uniformName: string, x: number, y: number, z: number): Effect; - setVector4(uniformName: string, vector4: Vector4): Effect; - setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect; - setColor3(uniformName: string, color3: Color3): Effect; - setColor4(uniformName: string, color3: Color3, alpha: number): Effect; - private _recombineShader(node); - private _evaluateDefinesOnString(shaderString); - static ShadersStore: {}; - static IncludesShadersStore: {}; - static ResetCache(): void; - } -} - -declare module BABYLON { - class FresnelParameters { - private _isEnabled; - isEnabled: boolean; - leftColor: Color3; - rightColor: Color3; - bias: number; - power: number; - clone(): FresnelParameters; - serialize(): any; - static Parse(parsedFresnelParameters: any): FresnelParameters; - } -} - -declare module BABYLON { - /** - * Interface to follow in your material defines to integrate easily the - * Image proccessing functions. - */ - interface IImageProcessingConfigurationDefines { - IMAGEPROCESSING: boolean; - VIGNETTE: boolean; - VIGNETTEBLENDMODEMULTIPLY: boolean; - VIGNETTEBLENDMODEOPAQUE: boolean; - TONEMAPPING: boolean; - CONTRAST: boolean; - EXPOSURE: boolean; - COLORCURVES: boolean; - COLORGRADING: boolean; - SAMPLER3DGREENDEPTH: boolean; - SAMPLER3DBGRMAP: boolean; - IMAGEPROCESSINGPOSTPROCESS: boolean; - } - /** - * 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 { + class Color4 { + r: number; + g: number; + b: number; + a: number; /** - * Color curves setup used in the effect if colorCurvesEnabled is set to true + * Creates a new Color4 object from the passed float values ( < 1) : red, green, blue, alpha. */ - colorCurves: ColorCurves; - private _colorCurvesEnabled; + constructor(r?: number, g?: number, b?: number, a?: number); /** - * Gets wether the color curves effect is enabled. + * Adds in place the passed Color4 values to the current Color4. + * Returns the updated Color4. */ + addInPlace(right: any): Color4; /** - * Sets wether the color curves effect is enabled. + * Returns a new array populated with 4 numeric elements : red, green, blue, alpha values. */ - colorCurvesEnabled: boolean; + asArray(): number[]; /** - * Color grading LUT texture used in the effect if colorGradingEnabled is set to true + * Stores from the starting index in the passed array the Color4 successive values. + * Returns the Color4. */ - colorGradingTexture: BaseTexture; - private _colorGradingEnabled; + toArray(array: number[], index?: number): Color4; /** - * Gets wether the color grading effect is enabled. + * Returns a new Color4 set with the added values of the current Color4 and of the passed one. */ + add(right: Color4): Color4; /** - * Sets wether the color grading effect is enabled. + * Returns a new Color4 set with the subtracted values of the passed one from the current Color4. */ - colorGradingEnabled: boolean; - private _colorGradingWithGreenDepth; + subtract(right: Color4): Color4; /** - * Gets wether the color grading effect is using a green depth for the 3d Texture. + * Subtracts the passed ones from the current Color4 values and stores the results in "result". + * Returns the Color4. */ + subtractToRef(right: Color4, result: Color4): Color4; /** - * Sets wether the color grading effect is using a green depth for the 3d Texture. + * Creates a new Color4 with the current Color4 values multiplied by scale. */ - colorGradingWithGreenDepth: boolean; - private _colorGradingBGR; + scale(scale: number): Color4; /** - * Gets wether the color grading texture contains BGR values. + * Multiplies the current Color4 values by scale and stores the result in "result". + * Returns the Color4. */ + scaleToRef(scale: number, result: Color4): Color4; /** - * Sets wether the color grading texture contains BGR values. - */ - colorGradingBGR: boolean; - _exposure: number; + * Multipy an RGBA Color4 value by another and return a new Color4 object + * @param color The Color4 (RGBA) value to multiply by + * @returns A new Color4. + */ + multiply(color: Color4): Color4; /** - * Gets the Exposure used in the effect. + * Multipy an RGBA Color4 value by another and push the result in a reference value + * @param color The Color4 (RGBA) value to multiply by + * @param result The Color4 (RGBA) to fill the result in + * @returns the result Color4. */ + multiplyToRef(color: Color4, result: Color4): Color4; /** - * Sets the Exposure used in the effect. + * Returns a string with the Color4 values. */ - exposure: number; - private _toneMappingEnabled; + toString(): string; /** - * Gets wether the tone mapping effect is enabled. + * Returns the string "Color4" */ + getClassName(): string; /** - * Sets wether the tone mapping effect is enabled. + * Return the Color4 hash code as a number. */ - toneMappingEnabled: boolean; - protected _contrast: number; + getHashCode(): number; /** - * Gets the contrast used in the effect. + * Creates a new Color4 copied from the current one. */ + clone(): Color4; /** - * Sets the contrast used in the effect. + * Copies the passed Color4 values into the current one. + * Returns the updated Color4. */ - contrast: number; + copyFrom(source: Color4): Color4; /** - * Vignette stretch size. + * Copies the passed float values into the current one. + * Returns the updated Color4. */ - vignetteStretch: number; + copyFromFloats(r: number, g: number, b: number, a: number): Color4; /** - * Vignette centre X Offset. + * Copies the passed float values into the current one. + * Returns the updated Color4. */ - vignetteCentreX: number; + set(r: number, g: number, b: number, a: number): Color4; /** - * Vignette centre Y Offset. + * Returns a string containing the hexadecimal Color4 code. */ - vignetteCentreY: number; + toHexString(): string; /** - * Vignette weight or intensity of the vignette effect. + * Returns a new Color4 converted to linear space. */ - vignetteWeight: number; + toLinearSpace(): Color4; /** - * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode) - * if vignetteEnabled is set to true. + * Converts the Color4 values to linear space and stores the result in "convertedColor". + * Returns the unmodified Color4. */ - vignetteColor: BABYLON.Color4; + toLinearSpaceToRef(convertedColor: Color4): Color4; /** - * Camera field of view used by the Vignette effect. + * Returns a new Color4 converted to gamma space. */ - vignetteCameraFov: number; - private _vignetteBlendMode; + toGammaSpace(): Color4; /** - * Gets the vignette blend mode allowing different kind of effect. + * Converts the Color4 values to gamma space and stores the result in "convertedColor". + * Returns the unmodified Color4. */ + toGammaSpaceToRef(convertedColor: Color4): Color4; /** - * Sets the vignette blend mode allowing different kind of effect. + * Creates a new Color4 from the valid hexadecimal value contained in the passed string. */ - vignetteBlendMode: number; - private _vignetteEnabled; + static FromHexString(hex: string): Color4; /** - * Gets wether the vignette effect is enabled. + * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 and the right Color4. */ + static Lerp(left: Color4, right: Color4, amount: number): Color4; /** - * Sets wether the vignette effect is enabled. + * Set the passed "result" with the linearly interpolated values of "amount" between the left Color4 and the right Color4. */ - vignetteEnabled: boolean; - private _applyByPostProcess; + static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void; /** - * Gets wether the image processing is applied through a post process or not. + * Creates a new Color4 from the starting index element of the passed array. */ + static FromArray(array: ArrayLike, offset?: number): Color4; /** - * Sets wether the image processing is applied through a post process or not. + * Creates a new Color4 from the passed integers ( < 256 ). */ - applyByPostProcess: boolean; - /** - * An event triggered when the configuration changes and requires Shader to Update some parameters. - * @type {BABYLON.Observable} - */ - onUpdateParameters: Observable; + static FromInts(r: number, g: number, b: number, a: number): Color4; + static CheckColors4(colors: number[], count: number): number[]; + } + class Vector2 { + x: number; + y: number; /** - * Method called each time the image processing information changes requires to recompile the effect. + * Creates a new Vector2 from the passed x and y coordinates. */ - protected _updateParameters(): void; - getClassName(): string; + constructor(x: number, y: number); /** - * Prepare the list of uniforms associated with the Image Processing effects. - * @param uniformsList The list of uniforms used in the effect - * @param defines the list of defines currently in use + * Returns a string with the Vector2 coordinates. */ - static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void; + toString(): string; /** - * Prepare the list of samplers associated with the Image Processing effects. - * @param uniformsList The list of uniforms used in the effect - * @param defines the list of defines currently in use + * Returns the string "Vector2" */ - static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void; + getClassName(): string; /** - * Prepare the list of defines associated to the shader. - * @param defines the list of defines to complete + * Returns the Vector2 hash code as a number. */ - prepareDefines(defines: IImageProcessingConfigurationDefines): void; + getHashCode(): number; /** - * Returns true if all the image processing information are ready. + * Sets the Vector2 coordinates in the passed array or Float32Array from the passed index. + * Returns the Vector2. */ - isReady(): boolean; + toArray(array: number[] | Float32Array, index?: number): Vector2; /** - * Binds the image processing to the shader. - * @param effect The effect to bind to + * Returns a new array with 2 elements : the Vector2 coordinates. */ - bind(effect: Effect, aspectRatio?: number): void; + asArray(): number[]; /** - * Clones the current image processing instance. - * @return The cloned image processing + * Sets the Vector2 coordinates with the passed Vector2 coordinates. + * Returns the updated Vector2. */ - clone(): ImageProcessingConfiguration; + copyFrom(source: Vector2): Vector2; /** - * Serializes the current image processing instance to a json representation. - * @return a JSON representation + * Sets the Vector2 coordinates with the passed floats. + * Returns the updated Vector2. */ - serialize(): any; + copyFromFloats(x: number, y: number): Vector2; /** - * Parses the image processing from a json representation. - * @param source the JSON source to parse - * @return The parsed image processing + * Sets the Vector2 coordinates with the passed floats. + * Returns the updated Vector2. */ - static Parse(source: any): ImageProcessingConfiguration; - private static _VIGNETTEMODE_MULTIPLY; - private static _VIGNETTEMODE_OPAQUE; + set(x: number, y: number): Vector2; /** - * Used to apply the vignette as a mix with the pixel color. + * Returns a new Vector2 set with the addition of the current Vector2 and the passed one coordinates. */ - static readonly VIGNETTEMODE_MULTIPLY: number; + add(otherVector: Vector2): Vector2; /** - * Used to apply the vignette as a replacement of the pixel color. + * Sets the "result" coordinates with the addition of the current Vector2 and the passed one coordinates. + * Returns the Vector2. */ - static readonly VIGNETTEMODE_OPAQUE: number; - } -} - -declare module BABYLON { - class MaterialDefines { - private _keys; - private _isDirty; - _renderId: number; - _areLightsDirty: boolean; - _areAttributesDirty: boolean; - _areTexturesDirty: boolean; - _areFresnelDirty: boolean; - _areMiscDirty: boolean; - _areImageProcessingDirty: boolean; - _normals: boolean; - _uvs: boolean; - _needNormals: boolean; - _needUVs: boolean; - readonly isDirty: boolean; - markAsProcessed(): void; - markAsUnprocessed(): void; - markAllAsDirty(): void; - markAsImageProcessingDirty(): void; - markAsLightDirty(): void; - markAsAttributesDirty(): void; - markAsTexturesDirty(): void; - markAsFresnelDirty(): void; - markAsMiscDirty(): void; - rebuild(): void; - isEqual(other: MaterialDefines): boolean; - cloneTo(other: MaterialDefines): void; - reset(): void; - toString(): string; - } - class Material { - private static _TriangleFillMode; - private static _WireFrameFillMode; - private static _PointFillMode; - static readonly TriangleFillMode: number; - static readonly WireFrameFillMode: number; - static readonly PointFillMode: number; - private static _ClockWiseSideOrientation; - private static _CounterClockWiseSideOrientation; - static readonly ClockWiseSideOrientation: number; - static readonly CounterClockWiseSideOrientation: number; - private static _TextureDirtyFlag; - private static _LightDirtyFlag; - private static _FresnelDirtyFlag; - private static _AttributesDirtyFlag; - private static _MiscDirtyFlag; - static readonly TextureDirtyFlag: number; - static readonly LightDirtyFlag: number; - static readonly FresnelDirtyFlag: number; - static readonly AttributesDirtyFlag: number; - static readonly MiscDirtyFlag: number; - id: string; - name: string; - checkReadyOnEveryCall: boolean; - checkReadyOnlyOnce: boolean; - state: string; - alpha: number; - protected _backFaceCulling: boolean; - backFaceCulling: boolean; - sideOrientation: number; - onCompiled: (effect: Effect) => void; - onError: (effect: Effect, errors: string) => void; - getRenderTargetTextures: () => SmartArray; - doNotSerialize: boolean; - storeEffectOnSubMeshes: boolean; + addToRef(otherVector: Vector2, result: Vector2): Vector2; /** - * An event triggered when the material is disposed. - * @type {BABYLON.Observable} - */ - onDisposeObservable: Observable; - private _onDisposeObserver; - onDispose: () => void; + * Set the Vector2 coordinates by adding the passed Vector2 coordinates. + * Returns the updated Vector2. + */ + addInPlace(otherVector: Vector2): Vector2; /** - * An event triggered when the material is bound. - * @type {BABYLON.Observable} - */ - onBindObservable: Observable; - private _onBindObserver; - onBind: (Mesh: AbstractMesh) => void; + * Returns a new Vector2 by adding the current Vector2 coordinates to the passed Vector3 x, y coordinates. + */ + addVector3(otherVector: Vector3): Vector2; /** - * An event triggered when the material is unbound. - * @type {BABYLON.Observable} - */ - onUnBindObservable: Observable; - alphaMode: number; - disableDepthWrite: boolean; - private _fogEnabled; - fogEnabled: boolean; - pointSize: number; - zOffset: number; - wireframe: boolean; - pointsCloud: boolean; - fillMode: number; - _effect: Effect; - _wasPreviouslyReady: boolean; - private _useUBO; - private _scene; - private _fillMode; - private _cachedDepthWriteState; - protected _uniformBuffer: UniformBuffer; - constructor(name: string, scene: Scene, doNotAdd?: boolean); + * Returns a new Vector2 set with the subtracted coordinates of the passed one from the current Vector2. + */ + subtract(otherVector: Vector2): Vector2; /** - * @param {boolean} fullDetails - support for multiple levels of logging within scene loading - * subclasses should override adding information pertainent to themselves + * Sets the "result" coordinates with the subtraction of the passed one from the current Vector2 coordinates. + * Returns the Vector2. */ - toString(fullDetails?: boolean): string; + subtractToRef(otherVector: Vector2, result: Vector2): Vector2; /** - * Child classes can use it to update shaders + * Sets the current Vector2 coordinates by subtracting from it the passed one coordinates. + * Returns the updated Vector2. */ - getClassName(): string; - readonly isFrozen: boolean; - freeze(): void; - unfreeze(): void; - isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean; - isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean; - getEffect(): Effect; - getScene(): Scene; - needAlphaBlending(): boolean; - needAlphaTesting(): boolean; - getAlphaTestTexture(): BaseTexture; - markDirty(): void; - _preBind(effect?: Effect): void; - bind(world: Matrix, mesh?: Mesh): void; - bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void; - bindOnlyWorldMatrix(world: Matrix): void; - bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void; - bindView(effect: Effect): void; - bindViewProjection(effect: Effect): void; - protected _afterBind(mesh: Mesh): void; - unbind(): void; - getActiveTextures(): BaseTexture[]; - hasTexture(texture: BaseTexture): boolean; - clone(name: string): Material; - getBindedMeshes(): AbstractMesh[]; + subtractInPlace(otherVector: Vector2): Vector2; /** - * Force shader compilation including textures ready check - */ - forceCompilation(mesh: AbstractMesh, onCompiled: (material: Material) => void, options?: { - alphaTest: boolean; - clipPlane: boolean; - }): void; - markAsDirty(flag: number): void; - protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void; - protected _markAllSubMeshesAsImageProcessingDirty(): void; - protected _markAllSubMeshesAsTexturesDirty(): void; - protected _markAllSubMeshesAsFresnelDirty(): void; - protected _markAllSubMeshesAsLightsDirty(): void; - protected _markAllSubMeshesAsAttributesDirty(): void; - protected _markAllSubMeshesAsMiscDirty(): void; - dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void; - serialize(): any; - static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial; - static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any; - } -} - -declare module BABYLON { - class MaterialHelper { - static PrepareDefinesForMergedUV(texture: BaseTexture, defines: MaterialDefines, key: string): void; - static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void; - static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: any, fogEnabled: boolean, defines: MaterialDefines): void; - static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: MaterialDefines, useInstances: boolean, forceAlphaTest?: boolean): void; - static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: MaterialDefines, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean): boolean; - static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: MaterialDefines, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean; - static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: MaterialDefines, maxSimultaneousLights?: number): void; - static HandleFallbacksForShadows(defines: MaterialDefines, fallbacks: EffectFallbacks, maxSimultaneousLights?: number): void; - static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: MaterialDefines): void; - static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: MaterialDefines, fallbacks: EffectFallbacks): void; - static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void; - static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void; - static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void; - static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: MaterialDefines, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void; - static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect): void; - static BindBonesParameters(mesh: AbstractMesh, effect: Effect): void; - static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void; - static BindLogDepth(defines: MaterialDefines, effect: Effect, scene: Scene): void; - static BindClipPlane(effect: Effect, scene: Scene): void; - } -} - -declare module BABYLON { - class MultiMaterial extends Material { - private _subMaterials; - subMaterials: Material[]; - constructor(name: string, scene: Scene); - private _hookArray(array); - getSubMaterial(index: any): Material; - getActiveTextures(): BaseTexture[]; - getClassName(): string; - isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean; - clone(name: string, cloneChildren?: boolean): MultiMaterial; - serialize(): any; - dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void; - } -} - -declare module BABYLON { - class PushMaterial extends Material { - protected _activeEffect: Effect; - constructor(name: string, scene: Scene); - getEffect(): Effect; - isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean; - bindOnlyWorldMatrix(world: Matrix): void; - bind(world: Matrix, mesh?: Mesh): void; - protected _afterBind(mesh: Mesh, effect?: Effect): void; - protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean; - } -} - -declare module BABYLON { - class ShaderMaterial extends Material { - private _shaderPath; - private _options; - private _textures; - private _textureArrays; - private _floats; - private _floatsArrays; - private _colors3; - private _colors3Arrays; - private _colors4; - private _vectors2; - private _vectors3; - private _vectors4; - private _matrices; - private _matrices3x3; - private _matrices2x2; - private _vectors3Arrays; - private _cachedWorldViewMatrix; - private _renderId; - constructor(name: string, scene: Scene, shaderPath: any, options: any); - getClassName(): string; - needAlphaBlending(): boolean; - needAlphaTesting(): boolean; - private _checkUniform(uniformName); - setTexture(name: string, texture: Texture): ShaderMaterial; - setTextureArray(name: string, textures: Texture[]): ShaderMaterial; - setFloat(name: string, value: number): ShaderMaterial; - setFloats(name: string, value: number[]): ShaderMaterial; - setColor3(name: string, value: Color3): ShaderMaterial; - setColor3Array(name: string, value: Color3[]): ShaderMaterial; - setColor4(name: string, value: Color4): ShaderMaterial; - setVector2(name: string, value: Vector2): ShaderMaterial; - setVector3(name: string, value: Vector3): ShaderMaterial; - setVector4(name: string, value: Vector4): ShaderMaterial; - setMatrix(name: string, value: Matrix): ShaderMaterial; - setMatrix3x3(name: string, value: Float32Array): ShaderMaterial; - setMatrix2x2(name: string, value: Float32Array): ShaderMaterial; - setArray3(name: string, value: number[]): ShaderMaterial; - private _checkCache(scene, mesh?, useInstances?); - isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean; - bindOnlyWorldMatrix(world: Matrix): void; - bind(world: Matrix, mesh?: Mesh): void; - getActiveTextures(): BaseTexture[]; - hasTexture(texture: BaseTexture): boolean; - clone(name: string): ShaderMaterial; - dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void; - serialize(): any; - static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial; - } -} - -declare module BABYLON { - class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines { - MAINUV1: boolean; - MAINUV2: boolean; - DIFFUSE: boolean; - DIFFUSEDIRECTUV: number; - AMBIENT: boolean; - AMBIENTDIRECTUV: number; - OPACITY: boolean; - OPACITYDIRECTUV: number; - OPACITYRGB: boolean; - REFLECTION: boolean; - EMISSIVE: boolean; - EMISSIVEDIRECTUV: number; - SPECULAR: boolean; - SPECULARDIRECTUV: number; - BUMP: boolean; - BUMPDIRECTUV: number; - PARALLAX: boolean; - PARALLAXOCCLUSION: boolean; - SPECULAROVERALPHA: boolean; - CLIPPLANE: boolean; - ALPHATEST: boolean; - ALPHAFROMDIFFUSE: boolean; - POINTSIZE: boolean; - FOG: boolean; - SPECULARTERM: boolean; - DIFFUSEFRESNEL: boolean; - OPACITYFRESNEL: boolean; - REFLECTIONFRESNEL: boolean; - REFRACTIONFRESNEL: boolean; - EMISSIVEFRESNEL: boolean; - FRESNEL: boolean; - NORMAL: boolean; - UV1: boolean; - UV2: boolean; - VERTEXCOLOR: boolean; - VERTEXALPHA: boolean; - NUM_BONE_INFLUENCERS: number; - BonesPerMesh: number; - INSTANCES: boolean; - GLOSSINESS: boolean; - ROUGHNESS: boolean; - EMISSIVEASILLUMINATION: boolean; - LINKEMISSIVEWITHDIFFUSE: boolean; - REFLECTIONFRESNELFROMSPECULAR: boolean; - LIGHTMAP: boolean; - LIGHTMAPDIRECTUV: number; - USELIGHTMAPASSHADOWMAP: boolean; - REFLECTIONMAP_3D: boolean; - REFLECTIONMAP_SPHERICAL: boolean; - REFLECTIONMAP_PLANAR: boolean; - REFLECTIONMAP_CUBIC: boolean; - REFLECTIONMAP_PROJECTION: boolean; - REFLECTIONMAP_SKYBOX: boolean; - REFLECTIONMAP_EXPLICIT: boolean; - REFLECTIONMAP_EQUIRECTANGULAR: boolean; - REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean; - REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean; - INVERTCUBICMAP: boolean; - LOGARITHMICDEPTH: boolean; - REFRACTION: boolean; - REFRACTIONMAP_3D: boolean; - REFLECTIONOVERALPHA: boolean; - TWOSIDEDLIGHTING: boolean; - SHADOWFLOAT: boolean; - MORPHTARGETS: boolean; - MORPHTARGETS_NORMAL: boolean; - MORPHTARGETS_TANGENT: boolean; - NUM_MORPH_INFLUENCERS: number; - USERIGHTHANDEDSYSTEM: boolean; - IMAGEPROCESSING: boolean; - VIGNETTE: boolean; - VIGNETTEBLENDMODEMULTIPLY: boolean; - VIGNETTEBLENDMODEOPAQUE: boolean; - TONEMAPPING: boolean; - CONTRAST: boolean; - COLORCURVES: boolean; - COLORGRADING: boolean; - SAMPLER3DGREENDEPTH: boolean; - SAMPLER3DBGRMAP: boolean; - IMAGEPROCESSINGPOSTPROCESS: boolean; - EXPOSURE: boolean; - constructor(); - setReflectionMode(modeToEnable: string): void; - } - class StandardMaterial extends PushMaterial { - private _diffuseTexture; - diffuseTexture: BaseTexture; - private _ambientTexture; - ambientTexture: BaseTexture; - private _opacityTexture; - opacityTexture: BaseTexture; - private _reflectionTexture; - reflectionTexture: BaseTexture; - private _emissiveTexture; - emissiveTexture: BaseTexture; - private _specularTexture; - specularTexture: BaseTexture; - private _bumpTexture; - bumpTexture: BaseTexture; - private _lightmapTexture; - lightmapTexture: BaseTexture; - private _refractionTexture; - refractionTexture: BaseTexture; - ambientColor: Color3; - diffuseColor: Color3; - specularColor: Color3; - emissiveColor: Color3; - specularPower: number; - private _useAlphaFromDiffuseTexture; - useAlphaFromDiffuseTexture: boolean; - private _useEmissiveAsIllumination; - useEmissiveAsIllumination: boolean; - private _linkEmissiveWithDiffuse; - linkEmissiveWithDiffuse: boolean; - private _useSpecularOverAlpha; - useSpecularOverAlpha: boolean; - private _useReflectionOverAlpha; - useReflectionOverAlpha: boolean; - private _disableLighting; - disableLighting: boolean; - private _useParallax; - useParallax: boolean; - private _useParallaxOcclusion; - useParallaxOcclusion: boolean; - parallaxScaleBias: number; - private _roughness; - roughness: number; - indexOfRefraction: number; - invertRefractionY: boolean; - private _useLightmapAsShadowmap; - useLightmapAsShadowmap: boolean; - private _diffuseFresnelParameters; - diffuseFresnelParameters: FresnelParameters; - private _opacityFresnelParameters; - opacityFresnelParameters: FresnelParameters; - private _reflectionFresnelParameters; - reflectionFresnelParameters: FresnelParameters; - private _refractionFresnelParameters; - refractionFresnelParameters: FresnelParameters; - private _emissiveFresnelParameters; - emissiveFresnelParameters: FresnelParameters; - private _useReflectionFresnelFromSpecular; - useReflectionFresnelFromSpecular: boolean; - private _useGlossinessFromSpecularMapAlpha; - useGlossinessFromSpecularMapAlpha: boolean; - private _maxSimultaneousLights; - maxSimultaneousLights: number; - /** - * If sets to true, x component of normal map value will invert (x = 1.0 - x). - */ - private _invertNormalMapX; - invertNormalMapX: boolean; - /** - * If sets to true, y component of normal map value will invert (y = 1.0 - y). - */ - private _invertNormalMapY; - invertNormalMapY: boolean; - /** - * If sets to true and backfaceCulling is false, normals will be flipped on the backside. - */ - private _twoSidedLighting; - twoSidedLighting: boolean; - /** - * Default configuration related to image processing available in the standard Material. - */ - protected _imageProcessingConfiguration: ImageProcessingConfiguration; - /** - * Gets the image processing configuration used either in this material. - */ - /** - * Sets the Default image processing configuration used either in the this material. - * - * If sets to null, the scene one is in use. - */ - imageProcessingConfiguration: ImageProcessingConfiguration; - /** - * Keep track of the image processing observer to allow dispose and replace. - */ - private _imageProcessingObserver; - /** - * Attaches a new image processing configuration to the Standard Material. - * @param configuration - */ - protected _attachImageProcessingConfiguration(configuration: ImageProcessingConfiguration): void; - /** - * Gets wether the color curves effect is enabled. - */ - /** - * Sets wether the color curves effect is enabled. - */ - cameraColorCurvesEnabled: boolean; - /** - * Gets wether the color grading effect is enabled. - */ - /** - * Gets wether the color grading effect is enabled. - */ - cameraColorGradingEnabled: boolean; - /** - * Gets wether tonemapping is enabled or not. - */ - /** - * Sets wether tonemapping is enabled or not - */ - cameraToneMappingEnabled: boolean; - /** - * The camera exposure used on this material. - * This property is here and not in the camera to allow controlling exposure without full screen post process. - * This corresponds to a photographic exposure. - */ - /** - * The camera exposure used on this material. - * This property is here and not in the camera to allow controlling exposure without full screen post process. - * This corresponds to a photographic exposure. - */ - cameraExposure: number; - /** - * Gets The camera contrast used on this material. + * Multiplies in place the current Vector2 coordinates by the passed ones. + * Returns the updated Vector2. */ + multiplyInPlace(otherVector: Vector2): Vector2; /** - * Sets The camera contrast used on this material. + * Returns a new Vector2 set with the multiplication of the current Vector2 and the passed one coordinates. */ - cameraContrast: number; + multiply(otherVector: Vector2): Vector2; /** - * Gets the Color Grading 2D Lookup Texture. + * Sets "result" coordinates with the multiplication of the current Vector2 and the passed one coordinates. + * Returns the Vector2. */ + multiplyToRef(otherVector: Vector2, result: Vector2): Vector2; /** - * Sets the Color Grading 2D Lookup Texture. + * Returns a new Vector2 set with the Vector2 coordinates multiplied by the passed floats. */ - cameraColorGradingTexture: BaseTexture; - customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string; - protected _renderTargets: SmartArray; - protected _worldViewProjectionMatrix: Matrix; - protected _globalAmbientColor: Color3; - protected _useLogarithmicDepth: boolean; - constructor(name: string, scene: Scene); - getClassName(): string; - useLogarithmicDepth: boolean; - needAlphaBlending(): boolean; - needAlphaTesting(): boolean; - protected _shouldUseAlphaFromDiffuseTexture(): boolean; - getAlphaTestTexture(): BaseTexture; + multiplyByFloats(x: number, y: number): Vector2; /** - * Child classes can use it to update shaders - */ - isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean; - buildUniformLayout(): void; - unbind(): void; - bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void; - getAnimatables(): IAnimatable[]; - getActiveTextures(): BaseTexture[]; - hasTexture(texture: BaseTexture): boolean; - dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void; - clone(name: string): StandardMaterial; - serialize(): any; - static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial; - static _DiffuseTextureEnabled: boolean; - static DiffuseTextureEnabled: boolean; - static _AmbientTextureEnabled: boolean; - static AmbientTextureEnabled: boolean; - static _OpacityTextureEnabled: boolean; - static OpacityTextureEnabled: boolean; - static _ReflectionTextureEnabled: boolean; - static ReflectionTextureEnabled: boolean; - static _EmissiveTextureEnabled: boolean; - static EmissiveTextureEnabled: boolean; - static _SpecularTextureEnabled: boolean; - static SpecularTextureEnabled: boolean; - static _BumpTextureEnabled: boolean; - static BumpTextureEnabled: boolean; - static _LightmapTextureEnabled: boolean; - static LightmapTextureEnabled: boolean; - static _RefractionTextureEnabled: boolean; - static RefractionTextureEnabled: boolean; - static _ColorGradingTextureEnabled: boolean; - static ColorGradingTextureEnabled: boolean; - static _FresnelEnabled: boolean; - static FresnelEnabled: boolean; - } -} - -declare module BABYLON { - class UniformBuffer { - private _engine; - private _buffer; - private _data; - private _bufferData; - private _dynamic; - private _uniformName; - private _uniformLocations; - private _uniformSizes; - private _uniformLocationPointer; - private _needSync; - private _cache; - private _noUBO; - private _currentEffect; - private static _MAX_UNIFORM_SIZE; - private static _tempBuffer; + * Returns a new Vector2 set with the Vector2 coordinates divided by the passed one coordinates. + */ + divide(otherVector: Vector2): Vector2; /** - * Wrapper for updateUniform. - * @method updateMatrix3x3 - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {Float32Array} matrix + * Sets the "result" coordinates with the Vector2 divided by the passed one coordinates. + * Returns the Vector2. */ - updateMatrix3x3: (name: string, matrix: Float32Array) => void; + divideToRef(otherVector: Vector2, result: Vector2): Vector2; /** - * Wrapper for updateUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {Float32Array} matrix + * Returns a new Vector2 with current Vector2 negated coordinates. */ - updateMatrix2x2: (name: string, matrix: Float32Array) => void; + negate(): Vector2; /** - * Wrapper for updateUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {number} x + * Multiply the Vector2 coordinates by scale. + * Returns the updated Vector2. */ - updateFloat: (name: string, x: number) => void; + scaleInPlace(scale: number): Vector2; /** - * Wrapper for updateUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {number} x - * @param {number} y - * @param {string} [suffix] Suffix to add to the uniform name. + * Returns a new Vector2 scaled by "scale" from the current Vector2. */ - updateFloat2: (name: string, x: number, y: number, suffix?: string) => void; + scale(scale: number): Vector2; /** - * Wrapper for updateUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {number} x - * @param {number} y - * @param {number} z - * @param {string} [suffix] Suffix to add to the uniform name. + * Boolean : True if the passed vector coordinates strictly equal the current Vector2 ones. */ - updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void; + equals(otherVector: Vector2): boolean; /** - * Wrapper for updateUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {number} x - * @param {number} y - * @param {number} z - * @param {number} w - * @param {string} [suffix] Suffix to add to the uniform name. + * Boolean : True if the passed vector coordinates are close to the current ones by a distance of epsilon. */ - updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void; + equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean; /** - * Wrapper for updateUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {Matrix} A 4x4 matrix. + * Returns the vector length (float). */ - updateMatrix: (name: string, mat: Matrix) => void; + length(): number; /** - * Wrapper for updateUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {Vector3} vector + * Returns the vector squared length (float); */ - updateVector3: (name: string, vector: Vector3) => void; + lengthSquared(): number; /** - * Wrapper for updateUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {Vector4} vector + * Normalize the vector. + * Returns the updated Vector2. */ - updateVector4: (name: string, vector: Vector4) => void; + normalize(): Vector2; /** - * Wrapper for updateUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {Color3} color - * @param {string} [suffix] Suffix to add to the uniform name. + * Returns a new Vector2 copied from the Vector2. */ - updateColor3: (name: string, color: Color3, suffix?: string) => void; + clone(): Vector2; /** - * Wrapper for updateUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {Color3} color - * @param {number} alpha - * @param {string} [suffix] Suffix to add to the uniform name. + * Returns a new Vector2(0, 0) */ - updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void; + static Zero(): Vector2; /** - * Uniform buffer objects. - * - * Handles blocks of uniform on the GPU. - * - * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls. - * - * For more information, please refer to : - * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object + * Returns a new Vector2(1, 1) */ - constructor(engine: Engine, data?: number[], dynamic?: boolean); + static One(): Vector2; /** - * Indicates if the buffer is using the WebGL2 UBO implementation, - * or just falling back on setUniformXXX calls. + * Returns a new Vector2 set from the passed index element of the passed array. */ - readonly useUbo: boolean; + static FromArray(array: ArrayLike, offset?: number): Vector2; /** - * Indicates if the WebGL underlying uniform buffer is in sync - * with the javascript cache data. + * Sets "result" from the passed index element of the passed array. */ - readonly isSync: boolean; + static FromArrayToRef(array: ArrayLike, offset: number, result: Vector2): void; /** - * Indicates if the WebGL underlying uniform buffer is dynamic. - * Also, a dynamic UniformBuffer will disable cache verification and always - * update the underlying WebGL uniform buffer to the GPU. + * Retuns a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the passed four Vector2. */ - isDynamic(): boolean; + static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2; /** - * The data cache on JS side. + * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max". + * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate. + * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate. */ - getData(): Float32Array; + static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2; /** - * The underlying WebGL Uniform buffer. + * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2". */ - getBuffer(): WebGLBuffer; + static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2; /** - * std140 layout specifies how to align data within an UBO structure. - * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159 - * for specs. + * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end". */ - private _fillAlignment(size); + static Lerp(start: Vector2, end: Vector2, amount: number): Vector2; /** - * Adds an uniform in the buffer. - * Warning : the subsequents calls of this function must be in the same order as declared in the shader - * for the layout to be correct ! - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {number|number[]} size Data size, or data directly. + * Returns the dot product (float) of the vector "left" and the vector "right". */ - addUniform(name: string, size: number | number[]): void; + static Dot(left: Vector2, right: Vector2): number; /** - * Wrapper for addUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {Matrix} mat A 4x4 matrix. + * Returns a new Vector2 equal to the normalized passed vector. */ - addMatrix(name: string, mat: Matrix): void; + static Normalize(vector: Vector2): Vector2; /** - * Wrapper for addUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {number} x - * @param {number} y + * Returns a new Vecto2 set with the minimal coordinate values from the "left" and "right" vectors. */ - addFloat2(name: string, x: number, y: number): void; + static Minimize(left: Vector2, right: Vector2): Vector2; /** - * Wrapper for addUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {number} x - * @param {number} y - * @param {number} z + * Returns a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors. */ - addFloat3(name: string, x: number, y: number, z: number): void; + static Maximize(left: Vector2, right: Vector2): Vector2; /** - * Wrapper for addUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {Color3} color + * Returns a new Vecto2 set with the transformed coordinates of the passed vector by the passed transformation matrix. */ - addColor3(name: string, color: Color3): void; + static Transform(vector: Vector2, transformation: Matrix): Vector2; /** - * Wrapper for addUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {Color3} color - * @param {number} alpha + * Transforms the passed vector coordinates by the passed transformation matrix and stores the result in the vector "result" coordinates. */ - addColor4(name: string, color: Color3, alpha: number): void; + static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void; /** - * Wrapper for addUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {Vector3} vector + * Boolean : True if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2" */ - addVector3(name: string, vector: Vector3): void; + static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean; /** - * Wrapper for addUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * Returns the distance (float) between the vectors "value1" and "value2". */ - addMatrix3x3(name: string): void; + static Distance(value1: Vector2, value2: Vector2): number; /** - * Wrapper for addUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * Returns the squared distance (float) between the vectors "value1" and "value2". */ - addMatrix2x2(name: string): void; + static DistanceSquared(value1: Vector2, value2: Vector2): number; /** - * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`. + * Returns a new Vecto2 located at the center of the vectors "value1" and "value2". */ - create(): void; + static Center(value1: Vector2, value2: Vector2): Vector2; /** - * Updates the WebGL Uniform Buffer on the GPU. - * If the `dynamic` flag is set to true, no cache comparison is done. - * Otherwise, the buffer will be updated only if the cache differs. + * Returns the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB". */ - update(): void; + static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number; + } + class Vector3 { + x: number; + y: number; + z: number; /** - * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU. - * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader. - * @param {number[]|Float32Array} data Flattened data - * @param {number} size Size of the data. + * Creates a new Vector3 object from the passed x, y, z (floats) coordinates. + * A Vector3 is the main object used in 3D geometry. + * It can represent etiher the coordinates of a point the space, either a direction. */ - updateUniform(uniformName: string, data: number[] | Float32Array, size: number): void; - private _updateMatrix3x3ForUniform(name, matrix); - private _updateMatrix3x3ForEffect(name, matrix); - private _updateMatrix2x2ForEffect(name, matrix); - private _updateMatrix2x2ForUniform(name, matrix); - private _updateFloatForEffect(name, x); - private _updateFloatForUniform(name, x); - private _updateFloat2ForEffect(name, x, y, suffix?); - private _updateFloat2ForUniform(name, x, y, suffix?); - private _updateFloat3ForEffect(name, x, y, z, suffix?); - private _updateFloat3ForUniform(name, x, y, z, suffix?); - private _updateFloat4ForEffect(name, x, y, z, w, suffix?); - private _updateFloat4ForUniform(name, x, y, z, w, suffix?); - private _updateMatrixForEffect(name, mat); - private _updateMatrixForUniform(name, mat); - private _updateVector3ForEffect(name, vector); - private _updateVector3ForUniform(name, vector); - private _updateVector4ForEffect(name, vector); - private _updateVector4ForUniform(name, vector); - private _updateColor3ForEffect(name, color, suffix?); - private _updateColor3ForUniform(name, color, suffix?); - private _updateColor4ForEffect(name, color, alpha, suffix?); - private _updateColor4ForUniform(name, color, alpha, suffix?); + constructor(x: number, y: number, z: number); /** - * Sets a sampler uniform on the effect. - * @param {string} name Name of the sampler. - * @param {Texture} texture + * Returns a string with the Vector3 coordinates. */ - setTexture(name: string, texture: BaseTexture): void; + toString(): string; /** - * Directly updates the value of the uniform in the cache AND on the GPU. - * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader. - * @param {number[]|Float32Array} data Flattened data + * Returns the string "Vector3" */ - updateUniformDirectly(uniformName: string, data: number[] | Float32Array): void; + getClassName(): string; /** - * Binds this uniform buffer to an effect. - * @param {Effect} effect - * @param {string} name Name of the uniform block in the shader. + * Returns the Vector hash code. */ - bindToEffect(effect: Effect, name: string): void; + getHashCode(): number; /** - * Disposes the uniform buffer. + * Returns a new array with three elements : the coordinates the Vector3. + */ + asArray(): number[]; + /** + * Populates the passed array or Float32Array from the passed index with the successive coordinates of the Vector3. + * Returns the Vector3. */ - dispose(): void; - } -} - -declare module BABYLON { - class Scalar { + toArray(array: number[] | Float32Array, index?: number): Vector3; /** - * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45) + * Returns a new Quaternion object, computed from the Vector3 coordinates. */ - static WithinEpsilon(a: number, b: number, epsilon?: number): boolean; + toQuaternion(): Quaternion; /** - * Returns a string : the upper case translation of the number i to hexadecimal. + * Adds the passed vector to the current Vector3. + * Returns the updated Vector3. */ - static ToHex(i: number): string; + addInPlace(otherVector: Vector3): Vector3; /** - * Returns -1 if value is negative and +1 is value is positive. - * Returns the value itself if it's equal to zero. + * Returns a new Vector3, result of the addition the current Vector3 and the passed vector. */ - static Sign(value: number): number; + add(otherVector: Vector3): Vector3; /** - * Returns the value itself if it's between min and max. - * Returns min if the value is lower than min. - * Returns max if the value is greater than max. + * Adds the current Vector3 to the passed one and stores the result in the vector "result". + * Returns the current Vector3. */ - static Clamp(value: number, min?: number, max?: number): number; + addToRef(otherVector: Vector3, result: Vector3): Vector3; /** - * Returns the log2 of value. + * Subtract the passed vector from the current Vector3. + * Returns the updated Vector3. */ - static Log2(value: number): number; + subtractInPlace(otherVector: Vector3): Vector3; /** - * Loops the value, so that it is never larger than length and never smaller than 0. - * - * This is similar to the modulo operator but it works with floating point numbers. - * For example, using 3.0 for t and 2.5 for length, the result would be 0.5. - * With t = 5 and length = 2.5, the result would be 0.0. - * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator - */ - static Repeat(value: number, length: number): number; + * Returns a new Vector3, result of the subtraction of the passed vector from the current Vector3. + */ + subtract(otherVector: Vector3): Vector3; /** - * Normalize the value between 0.0 and 1.0 using min and max values - */ - static Normalize(value: number, min: number, max: number): number; + * Subtracts the passed vector from the current Vector3 and stores the result in the vector "result". + * Returns the current Vector3. + */ + subtractToRef(otherVector: Vector3, result: Vector3): Vector3; /** - * Denormalize the value from 0.0 and 1.0 using min and max values - */ - static Denormalize(normalized: number, min: number, max: number): number; + * Returns a new Vector3 set with the subtraction of the passed floats from the current Vector3 coordinates. + */ + subtractFromFloats(x: number, y: number, z: number): Vector3; /** - * Calculates the shortest difference between two given angles given in degrees. - */ - static DeltaAngle(current: number, target: number): number; + * Subtracts the passed floats from the current Vector3 coordinates and set the passed vector "result" with this result. + * Returns the current Vector3. + */ + subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3; /** - * PingPongs the value t, so that it is never larger than length and never smaller than 0. - * - * The returned value will move back and forth between 0 and length - */ - static PingPong(tx: number, length: number): number; + * Returns a new Vector3 set with the current Vector3 negated coordinates. + */ + negate(): Vector3; /** - * Interpolates between min and max with smoothing at the limits. - * - * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up - * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions. - */ - static SmoothStep(from: number, to: number, tx: number): number; + * Multiplies the Vector3 coordinates by the float "scale". + * Returns the updated Vector3. + */ + scaleInPlace(scale: number): Vector3; /** - * Moves a value current towards target. - * - * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta. - * Negative values of maxDelta pushes the value away from target. - */ - static MoveTowards(current: number, target: number, maxDelta: number): number; + * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale". + */ + scale(scale: number): Vector3; /** - * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees. - * - * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta - * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead. - */ - static MoveTowardsAngle(current: number, target: number, maxDelta: number): number; + * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the passed vector "result" coordinates. + * Returns the current Vector3. + */ + scaleToRef(scale: number, result: Vector3): Vector3; /** - * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar. - */ - static Lerp(start: number, end: number, amount: number): number; + * Boolean : True if the current Vector3 and the passed vector coordinates are strictly equal. + */ + equals(otherVector: Vector3): boolean; /** - * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees. - * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees. - */ - static LerpAngle(start: number, end: number, amount: number): number; + * Boolean : True if the current Vector3 and the passed vector coordinates are distant less than epsilon. + */ + equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean; /** - * Calculates the linear parameter t that produces the interpolant value within the range [a, b]. - */ - static InverseLerp(a: number, b: number, value: number): number; + * Boolean : True if the current Vector3 coordinate equal the passed floats. + */ + equalsToFloats(x: number, y: number, z: number): boolean; /** - * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2". + * Muliplies the current Vector3 coordinates by the passed ones. + * Returns the updated Vector3. */ - static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number; + multiplyInPlace(otherVector: Vector3): Vector3; /** - * Returns a random float number between and min and max values - */ - static RandomRange(min: number, max: number): number; + * Returns a new Vector3, result of the multiplication of the current Vector3 by the passed vector. + */ + multiply(otherVector: Vector3): Vector3; /** - * This function returns percentage of a number in a given range. - * - * RangeToPercent(40,20,60) will return 0.5 (50%) - * RangeToPercent(34,0,100) will return 0.34 (34%) - */ - static RangeToPercent(number: number, min: number, max: number): number; + * Multiplies the current Vector3 by the passed one and stores the result in the passed vector "result". + * Returns the current Vector3. + */ + multiplyToRef(otherVector: Vector3, result: Vector3): Vector3; /** - * This function returns number that corresponds to the percentage in a given range. - * - * PercentToRange(0.34,0,100) will return 34. - */ - static PercentToRange(percent: number, min: number, max: number): number; - } -} - -declare module BABYLON { - class SIMDHelper { - private static _isEnabled; - static readonly IsEnabled: boolean; - static DisableSIMD(): void; - static EnableSIMD(): void; - } -} - -declare module BABYLON { - const ToGammaSpace: number; - const ToLinearSpace = 2.2; - const Epsilon = 0.001; - class Color3 { - r: number; - g: number; - b: number; + * Returns a new Vector3 set witth the result of the mulliplication of the current Vector3 coordinates by the passed floats. + */ + multiplyByFloats(x: number, y: number, z: number): Vector3; /** - * Creates a new Color3 object from red, green, blue values, all between 0 and 1. + * Returns a new Vector3 set witth the result of the division of the current Vector3 coordinates by the passed ones. */ - constructor(r?: number, g?: number, b?: number); + divide(otherVector: Vector3): Vector3; /** - * Returns a string with the Color3 current values. + * Divides the current Vector3 coordinates by the passed ones and stores the result in the passed vector "result". + * Returns the current Vector3. */ - toString(): string; + divideToRef(otherVector: Vector3, result: Vector3): Vector3; /** - * Returns the string "Color3". + * Updates the current Vector3 with the minimal coordinate values between its and the passed vector ones. + * Returns the updated Vector3. */ - getClassName(): string; + MinimizeInPlace(other: Vector3): Vector3; /** - * Returns the Color3 hash code. + * Updates the current Vector3 with the maximal coordinate values between its and the passed vector ones. + * Returns the updated Vector3. */ - getHashCode(): number; + MaximizeInPlace(other: Vector3): Vector3; /** - * Stores in the passed array from the passed starting index the red, green, blue values as successive elements. - * Returns the Color3. + * Returns the length of the Vector3 (float). */ - toArray(array: number[] | Float32Array, index?: number): Color3; + length(): number; /** - * Returns a new Color4 object from the current Color3 and the passed alpha. + * Returns the squared length of the Vector3 (float). */ - toColor4(alpha?: number): Color4; + lengthSquared(): number; /** - * Returns a new array populated with 3 numeric elements : red, green and blue values. + * Normalize the current Vector3. + * Returns the updated Vector3. */ - asArray(): number[]; + normalize(): Vector3; /** - * Returns the luminance value (float). + * Returns a new Vector3 copied from the current Vector3. */ - toLuminance(): number; + clone(): Vector3; /** - * Multiply each Color3 rgb values by the passed Color3 rgb values in a new Color3 object. - * Returns this new object. + * Copies the passed vector coordinates to the current Vector3 ones. + * Returns the updated Vector3. */ - multiply(otherColor: Color3): Color3; + copyFrom(source: Vector3): Vector3; /** - * Multiply the rgb values of the Color3 and the passed Color3 and stores the result in the object "result". - * Returns the current Color3. + * Copies the passed floats to the current Vector3 coordinates. + * Returns the updated Vector3. */ - multiplyToRef(otherColor: Color3, result: Color3): Color3; + copyFromFloats(x: number, y: number, z: number): Vector3; /** - * Boolean : True if the rgb values are equal to the passed ones. + * Copies the passed floats to the current Vector3 coordinates. + * Returns the updated Vector3. */ - equals(otherColor: Color3): boolean; + set(x: number, y: number, z: number): Vector3; /** - * Boolean : True if the rgb values are equal to the passed ones. + * */ - equalsFloats(r: number, g: number, b: number): boolean; + static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: any): number; /** - * Multiplies in place each rgb value by scale. - * Returns the updated Color3. + * Returns a new Vector3 set from the index "offset" of the passed array. */ - scale(scale: number): Color3; + static FromArray(array: ArrayLike, offset?: number): Vector3; /** - * Multiplies the rgb values by scale and stores the result into "result". - * Returns the unmodified current Color3. + * Returns a new Vector3 set from the index "offset" of the passed Float32Array. + * This function is deprecated. Use FromArray instead. */ - scaleToRef(scale: number, result: Color3): Color3; + static FromFloatArray(array: Float32Array, offset?: number): Vector3; /** - * Returns a new Color3 set with the added values of the current Color3 and of the passed one. + * Sets the passed vector "result" with the element values from the index "offset" of the passed array. */ - add(otherColor: Color3): Color3; + static FromArrayToRef(array: ArrayLike, offset: number, result: Vector3): void; /** - * Stores the result of the addition of the current Color3 and passed one rgb values into "result". - * Returns the unmodified current Color3. + * Sets the passed vector "result" with the element values from the index "offset" of the passed Float32Array. + * This function is deprecated. Use FromArrayToRef instead. */ - addToRef(otherColor: Color3, result: Color3): Color3; + static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void; /** - * Returns a new Color3 set with the subtracted values of the passed one from the current Color3 . + * Sets the passed vector "result" with the passed floats. */ - subtract(otherColor: Color3): Color3; + static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void; /** - * Stores the result of the subtraction of passed one from the current Color3 rgb values into "result". - * Returns the unmodified current Color3. + * Returns a new Vector3 set to (0.0, 0.0, 0.0). */ - subtractToRef(otherColor: Color3, result: Color3): Color3; + static Zero(): Vector3; /** - * Returns a new Color3 copied the current one. + * Returns a new Vector3 set to (1.0, 1.0, 1.0). */ - clone(): Color3; + static One(): Vector3; /** - * Copies the rgb values from the source in the current Color3. - * Returns the updated Color3. + * Returns a new Vector3 set to (0.0, 1.0, 0.0) */ - copyFrom(source: Color3): Color3; + static Up(): Vector3; /** - * Updates the Color3 rgb values from the passed floats. - * Returns the Color3. + * Returns a new Vector3 set to (0.0, 0.0, 1.0) */ - copyFromFloats(r: number, g: number, b: number): Color3; + static Forward(): Vector3; /** - * Updates the Color3 rgb values from the passed floats. - * Returns the Color3. + * Returns a new Vector3 set to (1.0, 0.0, 0.0) */ - set(r: number, g: number, b: number): Color3; + static Right(): Vector3; /** - * Returns the Color3 hexadecimal code as a string. + * Returns a new Vector3 set to (-1.0, 0.0, 0.0) */ - toHexString(): string; + static Left(): Vector3; /** - * Returns a new Color3 converted to linear space. + * Returns a new Vector3 set with the result of the transformation by the passed matrix of the passed vector. + * This method computes tranformed coordinates only, not transformed direction vectors. */ - toLinearSpace(): Color3; + static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3; /** - * Converts the Color3 values to linear space and stores the result in "convertedColor". - * Returns the unmodified Color3. + * Sets the passed vector "result" coordinates with the result of the transformation by the passed matrix of the passed vector. + * This method computes tranformed coordinates only, not transformed direction vectors. */ - toLinearSpaceToRef(convertedColor: Color3): Color3; + static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void; /** - * Returns a new Color3 converted to gamma space. + * Sets the passed vector "result" coordinates with the result of the transformation by the passed matrix of the passed floats (x, y, z). + * This method computes tranformed coordinates only, not transformed direction vectors. */ - toGammaSpace(): Color3; + static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void; /** - * Converts the Color3 values to gamma space and stores the result in "convertedColor". - * Returns the unmodified Color3. + * Returns a new Vector3 set with the result of the normal transformation by the passed matrix of the passed vector. + * This methods computes transformed normalized direction vectors only. */ - toGammaSpaceToRef(convertedColor: Color3): Color3; + static TransformNormal(vector: Vector3, transformation: Matrix): Vector3; /** - * Creates a new Color3 from the string containing valid hexadecimal values. + * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed vector. + * This methods computes transformed normalized direction vectors only. */ - static FromHexString(hex: string): Color3; + static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void; /** - * Creates a new Vector3 from the startind index of the passed array. + * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed floats (x, y, z). + * This methods computes transformed normalized direction vectors only. */ - static FromArray(array: ArrayLike, offset?: number): Color3; + static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void; /** - * Creates a new Color3 from integer values ( < 256). + * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4". */ - static FromInts(r: number, g: number, b: number): Color3; + static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3; /** - * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3. + * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max". + * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one. + * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one. */ - static Lerp(start: Color3, end: Color3, amount: number): Color3; - static Red(): Color3; - static Green(): Color3; - static Blue(): Color3; - static Black(): Color3; - static White(): Color3; - static Purple(): Color3; - static Magenta(): Color3; - static Yellow(): Color3; - static Gray(): Color3; - static Teal(): Color3; - static Random(): Color3; - } - class Color4 { - r: number; - g: number; - b: number; - a: number; + static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3; /** - * Creates a new Color4 object from the passed float values ( < 1) : red, green, blue, alpha. + * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2". */ - constructor(r?: number, g?: number, b?: number, a?: number); + static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3; /** - * Adds in place the passed Color4 values to the current Color4. - * Returns the updated Color4. + * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end". */ - addInPlace(right: any): Color4; + static Lerp(start: Vector3, end: Vector3, amount: number): Vector3; /** - * Returns a new array populated with 4 numeric elements : red, green, blue, alpha values. + * Sets the passed vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end". */ - asArray(): number[]; + static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void; /** - * Stores from the starting index in the passed array the Color4 successive values. - * Returns the Color4. + * Returns the dot product (float) between the vectors "left" and "right". */ - toArray(array: number[], index?: number): Color4; + static Dot(left: Vector3, right: Vector3): number; /** - * Returns a new Color4 set with the added values of the current Color4 and of the passed one. + * Returns a new Vector3 as the cross product of the vectors "left" and "right". + * The cross product is then orthogonal to both "left" and "right". */ - add(right: Color4): Color4; + static Cross(left: Vector3, right: Vector3): Vector3; /** - * Returns a new Color4 set with the subtracted values of the passed one from the current Color4. + * Sets the passed vector "result" with the cross product of "left" and "right". + * The cross product is then orthogonal to both "left" and "right". */ - subtract(right: Color4): Color4; + static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void; /** - * Subtracts the passed ones from the current Color4 values and stores the results in "result". - * Returns the Color4. + * Returns a new Vector3 as the normalization of the passed vector. */ - subtractToRef(right: Color4, result: Color4): Color4; + static Normalize(vector: Vector3): Vector3; /** - * Creates a new Color4 with the current Color4 values multiplied by scale. + * Sets the passed vector "result" with the normalization of the passed first vector. */ - scale(scale: number): Color4; + static NormalizeToRef(vector: Vector3, result: Vector3): void; + private static _viewportMatrixCache; + static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3; + static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3; + static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3; + static Minimize(left: Vector3, right: Vector3): Vector3; + static Maximize(left: Vector3, right: Vector3): Vector3; /** - * Multiplies the current Color4 values by scale and stores the result in "result". - * Returns the Color4. + * Returns the distance (float) between the vectors "value1" and "value2". */ - scaleToRef(scale: number, result: Color4): Color4; + static Distance(value1: Vector3, value2: Vector3): number; /** - * Multipy an RGBA Color4 value by another and return a new Color4 object - * @param color The Color4 (RGBA) value to multiply by - * @returns A new Color4. - */ - multiply(color: Color4): Color4; + * Returns the squared distance (float) between the vectors "value1" and "value2". + */ + static DistanceSquared(value1: Vector3, value2: Vector3): number; /** - * Multipy an RGBA Color4 value by another and push the result in a reference value - * @param color The Color4 (RGBA) value to multiply by - * @param result The Color4 (RGBA) to fill the result in - * @returns the result Color4. + * Returns a new Vector3 located at the center between "value1" and "value2". */ - multiplyToRef(color: Color4, result: Color4): Color4; + static Center(value1: Vector3, value2: Vector3): Vector3; /** - * Returns a string with the Color4 values. + * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system), + * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply + * to something in order to rotate it from its local system to the given target system. + * Note : axis1, axis2 and axis3 are normalized during this operation. + * Returns a new Vector3. */ - toString(): string; + static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3; /** - * Returns the string "Color4" + * The same than RotationFromAxis but updates the passed ref Vector3 parameter instead of returning a new Vector3. */ - getClassName(): string; + static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void; + } + class Vector4 { + x: number; + y: number; + z: number; + w: number; /** - * Return the Color4 hash code as a number. + * Creates a Vector4 object from the passed floats. */ - getHashCode(): number; + constructor(x: number, y: number, z: number, w: number); /** - * Creates a new Color4 copied from the current one. + * Returns the string with the Vector4 coordinates. */ - clone(): Color4; + toString(): string; /** - * Copies the passed Color4 values into the current one. - * Returns the updated Color4. + * Returns the string "Vector4". */ - copyFrom(source: Color4): Color4; + getClassName(): string; /** - * Copies the passed float values into the current one. - * Returns the updated Color4. + * Returns the Vector4 hash code. */ - copyFromFloats(r: number, g: number, b: number, a: number): Color4; + getHashCode(): number; /** - * Copies the passed float values into the current one. - * Returns the updated Color4. + * Returns a new array populated with 4 elements : the Vector4 coordinates. */ - set(r: number, g: number, b: number, a: number): Color4; + asArray(): number[]; /** - * Returns a string containing the hexadecimal Color4 code. + * Populates the passed array from the passed index with the Vector4 coordinates. + * Returns the Vector4. */ - toHexString(): string; + toArray(array: number[] | Float32Array, index?: number): Vector4; /** - * Returns a new Color4 converted to linear space. + * Adds the passed vector to the current Vector4. + * Returns the updated Vector4. */ - toLinearSpace(): Color4; + addInPlace(otherVector: Vector4): Vector4; /** - * Converts the Color4 values to linear space and stores the result in "convertedColor". - * Returns the unmodified Color4. + * Returns a new Vector4 as the result of the addition of the current Vector4 and the passed one. */ - toLinearSpaceToRef(convertedColor: Color4): Color4; + add(otherVector: Vector4): Vector4; /** - * Returns a new Color4 converted to gamma space. + * Updates the passed vector "result" with the result of the addition of the current Vector4 and the passed one. + * Returns the current Vector4. */ - toGammaSpace(): Color4; + addToRef(otherVector: Vector4, result: Vector4): Vector4; /** - * Converts the Color4 values to gamma space and stores the result in "convertedColor". - * Returns the unmodified Color4. + * Subtract in place the passed vector from the current Vector4. + * Returns the updated Vector4. */ - toGammaSpaceToRef(convertedColor: Color4): Color4; + subtractInPlace(otherVector: Vector4): Vector4; /** - * Creates a new Color4 from the valid hexadecimal value contained in the passed string. + * Returns a new Vector4 with the result of the subtraction of the passed vector from the current Vector4. */ - static FromHexString(hex: string): Color4; + subtract(otherVector: Vector4): Vector4; /** - * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 and the right Color4. + * Sets the passed vector "result" with the result of the subtraction of the passed vector from the current Vector4. + * Returns the current Vector4. */ - static Lerp(left: Color4, right: Color4, amount: number): Color4; + subtractToRef(otherVector: Vector4, result: Vector4): Vector4; /** - * Set the passed "result" with the linearly interpolated values of "amount" between the left Color4 and the right Color4. + * Returns a new Vector4 set with the result of the subtraction of the passed floats from the current Vector4 coordinates. */ - static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void; + subtractFromFloats(x: number, y: number, z: number, w: number): Vector4; /** - * Creates a new Color4 from the starting index element of the passed array. + * Sets the passed vector "result" set with the result of the subtraction of the passed floats from the current Vector4 coordinates. + * Returns the current Vector4. */ - static FromArray(array: ArrayLike, offset?: number): Color4; + subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4; /** - * Creates a new Color4 from the passed integers ( < 256 ). + * Returns a new Vector4 set with the current Vector4 negated coordinates. */ - static FromInts(r: number, g: number, b: number, a: number): Color4; - static CheckColors4(colors: number[], count: number): number[]; - } - class Vector2 { - x: number; - y: number; + negate(): Vector4; /** - * Creates a new Vector2 from the passed x and y coordinates. + * Multiplies the current Vector4 coordinates by scale (float). + * Returns the updated Vector4. */ - constructor(x: number, y: number); + scaleInPlace(scale: number): Vector4; /** - * Returns a string with the Vector2 coordinates. + * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float). */ - toString(): string; + scale(scale: number): Vector4; /** - * Returns the string "Vector2" + * Sets the passed vector "result" with the current Vector4 coordinates multiplied by scale (float). + * Returns the current Vector4. */ - getClassName(): string; + scaleToRef(scale: number, result: Vector4): Vector4; /** - * Returns the Vector2 hash code as a number. + * Boolean : True if the current Vector4 coordinates are stricly equal to the passed ones. */ - getHashCode(): number; + equals(otherVector: Vector4): boolean; /** - * Sets the Vector2 coordinates in the passed array or Float32Array from the passed index. - * Returns the Vector2. + * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the passed vector ones. */ - toArray(array: number[] | Float32Array, index?: number): Vector2; + equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean; /** - * Returns a new array with 2 elements : the Vector2 coordinates. + * Boolean : True if the passed floats are strictly equal to the current Vector4 coordinates. */ - asArray(): number[]; + equalsToFloats(x: number, y: number, z: number, w: number): boolean; /** - * Sets the Vector2 coordinates with the passed Vector2 coordinates. - * Returns the updated Vector2. + * Multiplies in place the current Vector4 by the passed one. + * Returns the updated Vector4. */ - copyFrom(source: Vector2): Vector2; + multiplyInPlace(otherVector: Vector4): Vector4; /** - * Sets the Vector2 coordinates with the passed floats. - * Returns the updated Vector2. + * Returns a new Vector4 set with the multiplication result of the current Vector4 and the passed one. */ - copyFromFloats(x: number, y: number): Vector2; + multiply(otherVector: Vector4): Vector4; /** - * Sets the Vector2 coordinates with the passed floats. - * Returns the updated Vector2. + * Updates the passed vector "result" with the multiplication result of the current Vector4 and the passed one. + * Returns the current Vector4. */ - set(x: number, y: number): Vector2; + multiplyToRef(otherVector: Vector4, result: Vector4): Vector4; /** - * Returns a new Vector2 set with the addition of the current Vector2 and the passed one coordinates. + * Returns a new Vector4 set with the multiplication result of the passed floats and the current Vector4 coordinates. */ - add(otherVector: Vector2): Vector2; + multiplyByFloats(x: number, y: number, z: number, w: number): Vector4; /** - * Sets the "result" coordinates with the addition of the current Vector2 and the passed one coordinates. - * Returns the Vector2. + * Returns a new Vector4 set with the division result of the current Vector4 by the passed one. */ - addToRef(otherVector: Vector2, result: Vector2): Vector2; + divide(otherVector: Vector4): Vector4; /** - * Set the Vector2 coordinates by adding the passed Vector2 coordinates. - * Returns the updated Vector2. + * Updates the passed vector "result" with the division result of the current Vector4 by the passed one. + * Returns the current Vector4. */ - addInPlace(otherVector: Vector2): Vector2; + divideToRef(otherVector: Vector4, result: Vector4): Vector4; /** - * Returns a new Vector2 by adding the current Vector2 coordinates to the passed Vector3 x, y coordinates. + * Updates the Vector4 coordinates with the minimum values between its own and the passed vector ones. */ - addVector3(otherVector: Vector3): Vector2; + MinimizeInPlace(other: Vector4): Vector4; /** - * Returns a new Vector2 set with the subtracted coordinates of the passed one from the current Vector2. + * Updates the Vector4 coordinates with the maximum values between its own and the passed vector ones. */ - subtract(otherVector: Vector2): Vector2; + MaximizeInPlace(other: Vector4): Vector4; /** - * Sets the "result" coordinates with the subtraction of the passed one from the current Vector2 coordinates. - * Returns the Vector2. + * Returns the Vector4 length (float). */ - subtractToRef(otherVector: Vector2, result: Vector2): Vector2; + length(): number; /** - * Sets the current Vector2 coordinates by subtracting from it the passed one coordinates. - * Returns the updated Vector2. + * Returns the Vector4 squared length (float). */ - subtractInPlace(otherVector: Vector2): Vector2; + lengthSquared(): number; /** - * Multiplies in place the current Vector2 coordinates by the passed ones. - * Returns the updated Vector2. + * Normalizes in place the Vector4. + * Returns the updated Vector4. */ - multiplyInPlace(otherVector: Vector2): Vector2; + normalize(): Vector4; /** - * Returns a new Vector2 set with the multiplication of the current Vector2 and the passed one coordinates. + * Returns a new Vector3 from the Vector4 (x, y, z) coordinates. */ - multiply(otherVector: Vector2): Vector2; + toVector3(): Vector3; /** - * Sets "result" coordinates with the multiplication of the current Vector2 and the passed one coordinates. - * Returns the Vector2. + * Returns a new Vector4 copied from the current one. */ - multiplyToRef(otherVector: Vector2, result: Vector2): Vector2; + clone(): Vector4; /** - * Returns a new Vector2 set with the Vector2 coordinates multiplied by the passed floats. + * Updates the current Vector4 with the passed one coordinates. + * Returns the updated Vector4. */ - multiplyByFloats(x: number, y: number): Vector2; + copyFrom(source: Vector4): Vector4; /** - * Returns a new Vector2 set with the Vector2 coordinates divided by the passed one coordinates. + * Updates the current Vector4 coordinates with the passed floats. + * Returns the updated Vector4. */ - divide(otherVector: Vector2): Vector2; + copyFromFloats(x: number, y: number, z: number, w: number): Vector4; /** - * Sets the "result" coordinates with the Vector2 divided by the passed one coordinates. - * Returns the Vector2. + * Updates the current Vector4 coordinates with the passed floats. + * Returns the updated Vector4. */ - divideToRef(otherVector: Vector2, result: Vector2): Vector2; + set(x: number, y: number, z: number, w: number): Vector4; /** - * Returns a new Vector2 with current Vector2 negated coordinates. + * Returns a new Vector4 set from the starting index of the passed array. */ - negate(): Vector2; + static FromArray(array: ArrayLike, offset?: number): Vector4; /** - * Multiply the Vector2 coordinates by scale. - * Returns the updated Vector2. + * Updates the passed vector "result" from the starting index of the passed array. */ - scaleInPlace(scale: number): Vector2; + static FromArrayToRef(array: ArrayLike, offset: number, result: Vector4): void; /** - * Returns a new Vector2 scaled by "scale" from the current Vector2. + * Updates the passed vector "result" from the starting index of the passed Float32Array. */ - scale(scale: number): Vector2; + static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void; /** - * Boolean : True if the passed vector coordinates strictly equal the current Vector2 ones. + * Updates the passed vector "result" coordinates from the passed floats. */ - equals(otherVector: Vector2): boolean; + static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void; /** - * Boolean : True if the passed vector coordinates are close to the current ones by a distance of epsilon. + * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0) */ - equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean; + static Zero(): Vector4; /** - * Returns the vector length (float). + * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0) */ - length(): number; + static One(): Vector4; /** - * Returns the vector squared length (float); + * Returns a new normalized Vector4 from the passed one. */ - lengthSquared(): number; + static Normalize(vector: Vector4): Vector4; /** - * Normalize the vector. - * Returns the updated Vector2. + * Updates the passed vector "result" from the normalization of the passed one. */ - normalize(): Vector2; + static NormalizeToRef(vector: Vector4, result: Vector4): void; + static Minimize(left: Vector4, right: Vector4): Vector4; + static Maximize(left: Vector4, right: Vector4): Vector4; /** - * Returns a new Vector2 copied from the Vector2. + * Returns the distance (float) between the vectors "value1" and "value2". */ - clone(): Vector2; + static Distance(value1: Vector4, value2: Vector4): number; /** - * Returns a new Vector2(0, 0) + * Returns the squared distance (float) between the vectors "value1" and "value2". */ - static Zero(): Vector2; + static DistanceSquared(value1: Vector4, value2: Vector4): number; /** - * Returns a new Vector2(1, 1) + * Returns a new Vector4 located at the center between the vectors "value1" and "value2". */ - static One(): Vector2; + static Center(value1: Vector4, value2: Vector4): Vector4; /** - * Returns a new Vector2 set from the passed index element of the passed array. + * Returns a new Vector4 set with the result of the normal transformation by the passed matrix of the passed vector. + * This methods computes transformed normalized direction vectors only. */ - static FromArray(array: ArrayLike, offset?: number): Vector2; + static TransformNormal(vector: Vector4, transformation: Matrix): Vector4; /** - * Sets "result" from the passed index element of the passed array. + * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed vector. + * This methods computes transformed normalized direction vectors only. */ - static FromArrayToRef(array: ArrayLike, offset: number, result: Vector2): void; + static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void; /** - * Retuns a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the passed four Vector2. + * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed floats (x, y, z, w). + * This methods computes transformed normalized direction vectors only. */ - static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2; + static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void; + } + interface ISize { + width: number; + height: number; + } + class Size implements ISize { + width: number; + height: number; /** - * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max". - * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate. - * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate. + * Creates a Size object from the passed width and height (floats). */ - static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2; + constructor(width: number, height: number); + toString(): string; /** - * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2". + * Returns the string "Size" */ - static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2; + getClassName(): string; /** - * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end". + * Returns the Size hash code. */ - static Lerp(start: Vector2, end: Vector2, amount: number): Vector2; + getHashCode(): number; /** - * Returns the dot product (float) of the vector "left" and the vector "right". + * Updates the current size from the passed one. + * Returns the updated Size. */ - static Dot(left: Vector2, right: Vector2): number; + copyFrom(src: Size): void; /** - * Returns a new Vector2 equal to the normalized passed vector. + * Updates in place the current Size from the passed floats. + * Returns the updated Size. */ - static Normalize(vector: Vector2): Vector2; + copyFromFloats(width: number, height: number): Size; /** - * Returns a new Vecto2 set with the minimal coordinate values from the "left" and "right" vectors. + * Updates in place the current Size from the passed floats. + * Returns the updated Size. */ - static Minimize(left: Vector2, right: Vector2): Vector2; + set(width: number, height: number): Size; /** - * Returns a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors. + * Returns a new Size set with the multiplication result of the current Size and the passed floats. */ - static Maximize(left: Vector2, right: Vector2): Vector2; + multiplyByFloats(w: number, h: number): Size; /** - * Returns a new Vecto2 set with the transformed coordinates of the passed vector by the passed transformation matrix. + * Returns a new Size copied from the passed one. */ - static Transform(vector: Vector2, transformation: Matrix): Vector2; + clone(): Size; /** - * Transforms the passed vector coordinates by the passed transformation matrix and stores the result in the vector "result" coordinates. + * Boolean : True if the current Size and the passed one width and height are strictly equal. */ - static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void; + equals(other: Size): boolean; /** - * Boolean : True if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2" + * Returns the surface of the Size : width * height (float). */ - static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean; + readonly surface: number; /** - * Returns the distance (float) between the vectors "value1" and "value2". + * Returns a new Size set to (0.0, 0.0) */ - static Distance(value1: Vector2, value2: Vector2): number; + static Zero(): Size; /** - * Returns the squared distance (float) between the vectors "value1" and "value2". + * Returns a new Size set as the addition result of the current Size and the passed one. */ - static DistanceSquared(value1: Vector2, value2: Vector2): number; + add(otherSize: Size): Size; /** - * Returns a new Vecto2 located at the center of the vectors "value1" and "value2". + * Returns a new Size set as the subtraction result of the passed one from the current Size. */ - static Center(value1: Vector2, value2: Vector2): Vector2; + subtract(otherSize: Size): Size; /** - * Returns the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB". + * Returns a new Size set at the linear interpolation "amount" between "start" and "end". */ - static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number; + static Lerp(start: Size, end: Size, amount: number): Size; } - class Vector3 { + class Quaternion { x: number; y: number; z: number; + w: number; /** - * Creates a new Vector3 object from the passed x, y, z (floats) coordinates. - * A Vector3 is the main object used in 3D geometry. - * It can represent etiher the coordinates of a point the space, either a direction. + * Creates a new Quaternion from the passed floats. */ - constructor(x: number, y: number, z: number); + constructor(x?: number, y?: number, z?: number, w?: number); /** - * Returns a string with the Vector3 coordinates. + * Returns a string with the Quaternion coordinates. */ toString(): string; /** - * Returns the string "Vector3" + * Returns the string "Quaternion". */ getClassName(): string; /** - * Returns the Vector hash code. + * Returns the Quaternion hash code. */ getHashCode(): number; /** - * Returns a new array with three elements : the coordinates the Vector3. + * Returns a new array populated with 4 elements : the Quaternion coordinates. */ asArray(): number[]; /** - * Populates the passed array or Float32Array from the passed index with the successive coordinates of the Vector3. - * Returns the Vector3. - */ - toArray(array: number[] | Float32Array, index?: number): Vector3; - /** - * Returns a new Quaternion object, computed from the Vector3 coordinates. + * Boolean : True if the current Quaterion and the passed one coordinates are strictly equal. */ - toQuaternion(): Quaternion; + equals(otherQuaternion: Quaternion): boolean; /** - * Adds the passed vector to the current Vector3. - * Returns the updated Vector3. + * Returns a new Quaternion copied from the current one. */ - addInPlace(otherVector: Vector3): Vector3; + clone(): Quaternion; /** - * Returns a new Vector3, result of the addition the current Vector3 and the passed vector. + * Updates the current Quaternion from the passed one coordinates. + * Returns the updated Quaterion. */ - add(otherVector: Vector3): Vector3; + copyFrom(other: Quaternion): Quaternion; /** - * Adds the current Vector3 to the passed one and stores the result in the vector "result". - * Returns the current Vector3. + * Updates the current Quaternion from the passed float coordinates. + * Returns the updated Quaterion. */ - addToRef(otherVector: Vector3, result: Vector3): Vector3; + copyFromFloats(x: number, y: number, z: number, w: number): Quaternion; /** - * Subtract the passed vector from the current Vector3. - * Returns the updated Vector3. + * Updates the current Quaternion from the passed float coordinates. + * Returns the updated Quaterion. */ - subtractInPlace(otherVector: Vector3): Vector3; + set(x: number, y: number, z: number, w: number): Quaternion; /** - * Returns a new Vector3, result of the subtraction of the passed vector from the current Vector3. + * Returns a new Quaternion as the addition result of the passed one and the current Quaternion. */ - subtract(otherVector: Vector3): Vector3; + add(other: Quaternion): Quaternion; /** - * Subtracts the passed vector from the current Vector3 and stores the result in the vector "result". - * Returns the current Vector3. + * Returns a new Quaternion as the subtraction result of the passed one from the current Quaternion. */ - subtractToRef(otherVector: Vector3, result: Vector3): Vector3; + subtract(other: Quaternion): Quaternion; /** - * Returns a new Vector3 set with the subtraction of the passed floats from the current Vector3 coordinates. + * Returns a new Quaternion set by multiplying the current Quaterion coordinates by the float "scale". */ - subtractFromFloats(x: number, y: number, z: number): Vector3; + scale(value: number): Quaternion; /** - * Subtracts the passed floats from the current Vector3 coordinates and set the passed vector "result" with this result. - * Returns the current Vector3. + * Returns a new Quaternion set as the quaternion mulplication result of the current one with the passed one "q1". */ - subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3; + multiply(q1: Quaternion): Quaternion; /** - * Returns a new Vector3 set with the current Vector3 negated coordinates. + * Sets the passed "result" as the quaternion mulplication result of the current one with the passed one "q1". + * Returns the current Quaternion. */ - negate(): Vector3; + multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion; /** - * Multiplies the Vector3 coordinates by the float "scale". - * Returns the updated Vector3. + * Updates the current Quaternion with the quaternion mulplication result of itself with the passed one "q1". + * Returns the updated Quaternion. */ - scaleInPlace(scale: number): Vector3; + multiplyInPlace(q1: Quaternion): Quaternion; /** - * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale". + * Sets the passed "ref" with the conjugation of the current Quaternion. + * Returns the current Quaternion. */ - scale(scale: number): Vector3; + conjugateToRef(ref: Quaternion): Quaternion; /** - * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the passed vector "result" coordinates. - * Returns the current Vector3. + * Conjugates in place the current Quaternion. + * Returns the updated Quaternion. */ - scaleToRef(scale: number, result: Vector3): Vector3; + conjugateInPlace(): Quaternion; /** - * Boolean : True if the current Vector3 and the passed vector coordinates are strictly equal. + * Returns a new Quaternion as the conjugate of the current Quaternion. */ - equals(otherVector: Vector3): boolean; + conjugate(): Quaternion; /** - * Boolean : True if the current Vector3 and the passed vector coordinates are distant less than epsilon. + * Returns the Quaternion length (float). */ - equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean; + length(): number; /** - * Boolean : True if the current Vector3 coordinate equal the passed floats. + * Normalize in place the current Quaternion. + * Returns the updated Quaternion. */ - equalsToFloats(x: number, y: number, z: number): boolean; + normalize(): Quaternion; /** - * Muliplies the current Vector3 coordinates by the passed ones. - * Returns the updated Vector3. + * Returns a new Vector3 set with the Euler angles translated from the current Quaternion. */ - multiplyInPlace(otherVector: Vector3): Vector3; + toEulerAngles(order?: string): Vector3; /** - * Returns a new Vector3, result of the multiplication of the current Vector3 by the passed vector. + * Sets the passed vector3 "result" with the Euler angles translated from the current Quaternion. + * Returns the current Quaternion. */ - multiply(otherVector: Vector3): Vector3; + toEulerAnglesToRef(result: Vector3, order?: string): Quaternion; /** - * Multiplies the current Vector3 by the passed one and stores the result in the passed vector "result". - * Returns the current Vector3. + * Updates the passed rotation matrix with the current Quaternion values. + * Returns the current Quaternion. */ - multiplyToRef(otherVector: Vector3, result: Vector3): Vector3; + toRotationMatrix(result: Matrix): Quaternion; /** - * Returns a new Vector3 set witth the result of the mulliplication of the current Vector3 coordinates by the passed floats. + * Updates the current Quaternion from the passed rotation matrix values. + * Returns the updated Quaternion. */ - multiplyByFloats(x: number, y: number, z: number): Vector3; + fromRotationMatrix(matrix: Matrix): Quaternion; /** - * Returns a new Vector3 set witth the result of the division of the current Vector3 coordinates by the passed ones. + * Returns a new Quaternion set from the passed rotation matrix values. */ - divide(otherVector: Vector3): Vector3; + static FromRotationMatrix(matrix: Matrix): Quaternion; /** - * Divides the current Vector3 coordinates by the passed ones and stores the result in the passed vector "result". - * Returns the current Vector3. + * Updates the passed quaternion "result" with the passed rotation matrix values. */ - divideToRef(otherVector: Vector3, result: Vector3): Vector3; + static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void; /** - * Updates the current Vector3 with the minimal coordinate values between its and the passed vector ones. - * Returns the updated Vector3. + * Returns a new Quaternion set to (0.0, 0.0, 0.0). */ - MinimizeInPlace(other: Vector3): Vector3; + static Zero(): Quaternion; /** - * Updates the current Vector3 with the maximal coordinate values between its and the passed vector ones. - * Returns the updated Vector3. + * Returns a new Quaternion as the inverted current Quaternion. */ - MaximizeInPlace(other: Vector3): Vector3; + static Inverse(q: Quaternion): Quaternion; /** - * Returns the length of the Vector3 (float). + * Returns the identity Quaternion. */ - length(): number; + static Identity(): Quaternion; + static IsIdentity(quaternion: Quaternion): boolean; /** - * Returns the squared length of the Vector3 (float). + * Returns a new Quaternion set from the passed axis (Vector3) and angle in radians (float). */ - lengthSquared(): number; + static RotationAxis(axis: Vector3, angle: number): Quaternion; /** - * Normalize the current Vector3. - * Returns the updated Vector3. + * Sets the passed quaternion "result" from the passed axis (Vector3) and angle in radians (float). */ - normalize(): Vector3; + static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion; /** - * Returns a new Vector3 copied from the current Vector3. + * Retuns a new Quaternion set from the starting index of the passed array. */ - clone(): Vector3; + static FromArray(array: ArrayLike, offset?: number): Quaternion; /** - * Copies the passed vector coordinates to the current Vector3 ones. - * Returns the updated Vector3. + * Returns a new Quaternion set from the passed Euler float angles (y, x, z). */ - copyFrom(source: Vector3): Vector3; + static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion; /** - * Copies the passed floats to the current Vector3 coordinates. - * Returns the updated Vector3. + * Sets the passed quaternion "result" from the passed float Euler angles (y, x, z). */ - copyFromFloats(x: number, y: number, z: number): Vector3; + static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void; /** - * Copies the passed floats to the current Vector3 coordinates. - * Returns the updated Vector3. + * Returns a new Quaternion from the passed float Euler angles expressed in z-x-z orientation */ - set(x: number, y: number, z: number): Vector3; + static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion; /** - * + * Sets the passed quaternion "result" from the passed float Euler angles expressed in z-x-z orientation */ - static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: any): number; + static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void; /** - * Returns a new Vector3 set from the index "offset" of the passed array. + * Returns a new Quaternion as the quaternion rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system. + * cf to Vector3.RotationFromAxis() documentation. + * Note : axis1, axis2 and axis3 are normalized during this operation. */ - static FromArray(array: ArrayLike, offset?: number): Vector3; + static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): Quaternion; /** - * Returns a new Vector3 set from the index "offset" of the passed Float32Array. - * This function is deprecated. Use FromArray instead. + * Sets the passed quaternion "ref" with the quaternion rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system. + * cf to Vector3.RotationFromAxis() documentation. + * Note : axis1, axis2 and axis3 are normalized during this operation. */ - static FromFloatArray(array: Float32Array, offset?: number): Vector3; + static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void; + static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion; + static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void; /** - * Sets the passed vector "result" with the element values from the index "offset" of the passed array. + * Returns a new Quaternion located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2". */ - static FromArrayToRef(array: ArrayLike, offset: number, result: Vector3): void; + static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion; + } + class Matrix { + private static _tempQuaternion; + private static _xAxis; + private static _yAxis; + private static _zAxis; + private static _updateFlagSeed; + private _isIdentity; + private _isIdentityDirty; + updateFlag: number; + m: Float32Array; + _markAsUpdated(): void; + constructor(); /** - * Sets the passed vector "result" with the element values from the index "offset" of the passed Float32Array. - * This function is deprecated. Use FromArrayToRef instead. + * Boolean : True is the matrix is the identity matrix */ - static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void; + isIdentity(considerAsTextureMatrix?: boolean): boolean; /** - * Sets the passed vector "result" with the passed floats. + * Returns the matrix determinant (float). */ - static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void; + determinant(): number; /** - * Returns a new Vector3 set to (0.0, 0.0, 0.0). + * Returns the matrix underlying array. */ - static Zero(): Vector3; + toArray(): Float32Array; /** - * Returns a new Vector3 set to (1.0, 1.0, 1.0). + * Returns the matrix underlying array. + */ + asArray(): Float32Array; + /** + * Inverts in place the Matrix. + * Returns the Matrix inverted. */ - static One(): Vector3; + invert(): Matrix; /** - * Returns a new Vector3 set to (0.0, 1.0, 0.0) + * Sets all the matrix elements to zero. + * Returns the Matrix. */ - static Up(): Vector3; + reset(): Matrix; /** - * Returns a new Vector3 set to (0.0, 0.0, 1.0) + * Returns a new Matrix as the addition result of the current Matrix and the passed one. */ - static Forward(): Vector3; + add(other: Matrix): Matrix; /** - * Returns a new Vector3 set to (1.0, 0.0, 0.0) + * Sets the passed matrix "result" with the ddition result of the current Matrix and the passed one. + * Returns the Matrix. */ - static Right(): Vector3; + addToRef(other: Matrix, result: Matrix): Matrix; /** - * Returns a new Vector3 set to (-1.0, 0.0, 0.0) + * Adds in place the passed matrix to the current Matrix. + * Returns the updated Matrix. */ - static Left(): Vector3; + addToSelf(other: Matrix): Matrix; /** - * Returns a new Vector3 set with the result of the transformation by the passed matrix of the passed vector. - * This method computes tranformed coordinates only, not transformed direction vectors. + * Sets the passed matrix with the current inverted Matrix. + * Returns the unmodified current Matrix. */ - static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3; + invertToRef(other: Matrix): Matrix; /** - * Sets the passed vector "result" coordinates with the result of the transformation by the passed matrix of the passed vector. - * This method computes tranformed coordinates only, not transformed direction vectors. + * Inserts the translation vector (using 3 x floats) in the current Matrix. + * Returns the updated Matrix. */ - static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void; + setTranslationFromFloats(x: number, y: number, z: number): Matrix; /** - * Sets the passed vector "result" coordinates with the result of the transformation by the passed matrix of the passed floats (x, y, z). - * This method computes tranformed coordinates only, not transformed direction vectors. + * Inserts the translation vector in the current Matrix. + * Returns the updated Matrix. + */ + setTranslation(vector3: Vector3): Matrix; + /** + * Returns a new Vector3 as the extracted translation from the Matrix. */ - static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void; + getTranslation(): Vector3; /** - * Returns a new Vector3 set with the result of the normal transformation by the passed matrix of the passed vector. - * This methods computes transformed normalized direction vectors only. + * Fill a Vector3 with the extracted translation from the Matrix. */ - static TransformNormal(vector: Vector3, transformation: Matrix): Vector3; + getTranslationToRef(result: Vector3): Matrix; /** - * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed vector. - * This methods computes transformed normalized direction vectors only. + * Remove rotation and scaling part from the Matrix. + * Returns the updated Matrix. */ - static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void; + removeRotationAndScaling(): Matrix; /** - * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed floats (x, y, z). - * This methods computes transformed normalized direction vectors only. + * Returns a new Matrix set with the multiplication result of the current Matrix and the passed one. */ - static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void; + multiply(other: Matrix): Matrix; /** - * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4". + * Updates the current Matrix from the passed one values. + * Returns the updated Matrix. */ - static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3; + copyFrom(other: Matrix): Matrix; /** - * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max". - * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one. - * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one. + * Populates the passed array from the starting index with the Matrix values. + * Returns the Matrix. */ - static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3; + copyToArray(array: Float32Array, offset?: number): Matrix; /** - * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2". + * Sets the passed matrix "result" with the multiplication result of the current Matrix and the passed one. */ - static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3; + multiplyToRef(other: Matrix, result: Matrix): Matrix; /** - * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end". + * Sets the Float32Array "result" from the passed index "offset" with the multiplication result of the current Matrix and the passed one. */ - static Lerp(start: Vector3, end: Vector3, amount: number): Vector3; + multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix; /** - * Sets the passed vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end". + * Boolean : True is the current Matrix and the passed one values are strictly equal. */ - static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void; + equals(value: Matrix): boolean; /** - * Returns the dot product (float) between the vectors "left" and "right". + * Returns a new Matrix from the current Matrix. */ - static Dot(left: Vector3, right: Vector3): number; + clone(): Matrix; /** - * Returns a new Vector3 as the cross product of the vectors "left" and "right". - * The cross product is then orthogonal to both "left" and "right". + * Returns the string "Matrix" */ - static Cross(left: Vector3, right: Vector3): Vector3; + getClassName(): string; /** - * Sets the passed vector "result" with the cross product of "left" and "right". - * The cross product is then orthogonal to both "left" and "right". + * Returns the Matrix hash code. */ - static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void; + getHashCode(): number; /** - * Returns a new Vector3 as the normalization of the passed vector. + * Decomposes the current Matrix into : + * - a scale vector3 passed as a reference to update, + * - a rotation quaternion passed as a reference to update, + * - a translation vector3 passed as a reference to update. + * Returns the boolean `true`. */ - static Normalize(vector: Vector3): Vector3; + decompose(scale: Vector3, rotation: Quaternion, translation: Vector3): boolean; /** - * Sets the passed vector "result" with the normalization of the passed first vector. + * Returns a new Matrix as the extracted rotation matrix from the current one. */ - static NormalizeToRef(vector: Vector3, result: Vector3): void; - private static _viewportMatrixCache; - static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3; - static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3; - static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3; - static Minimize(left: Vector3, right: Vector3): Vector3; - static Maximize(left: Vector3, right: Vector3): Vector3; + getRotationMatrix(): Matrix; /** - * Returns the distance (float) between the vectors "value1" and "value2". + * Extracts the rotation matrix from the current one and sets it as the passed "result". + * Returns the current Matrix. */ - static Distance(value1: Vector3, value2: Vector3): number; + getRotationMatrixToRef(result: Matrix): Matrix; /** - * Returns the squared distance (float) between the vectors "value1" and "value2". + * Returns a new Matrix set from the starting index of the passed array. */ - static DistanceSquared(value1: Vector3, value2: Vector3): number; + static FromArray(array: ArrayLike, offset?: number): Matrix; /** - * Returns a new Vector3 located at the center between "value1" and "value2". + * Sets the passed "result" matrix from the starting index of the passed array. */ - static Center(value1: Vector3, value2: Vector3): Vector3; + static FromArrayToRef(array: ArrayLike, offset: number, result: Matrix): void; /** - * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system), - * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply - * to something in order to rotate it from its local system to the given target system. - * Note : axis1, axis2 and axis3 are normalized during this operation. - * Returns a new Vector3. + * Sets the passed "result" matrix from the starting index of the passed Float32Array by multiplying each element by the float "scale". */ - static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3; + static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void; /** - * The same than RotationFromAxis but updates the passed ref Vector3 parameter instead of returning a new Vector3. + * Sets the passed matrix "result" with the 16 passed floats. */ - static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void; - } - class Vector4 { - x: number; - y: number; - z: number; - w: number; + static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void; /** - * Creates a Vector4 object from the passed floats. + * Returns the index-th row of the current matrix as a new Vector4. */ - constructor(x: number, y: number, z: number, w: number); + getRow(index: number): Vector4; /** - * Returns the string with the Vector4 coordinates. + * Sets the index-th row of the current matrix with the passed Vector4 values. + * Returns the updated Matrix. */ - toString(): string; + setRow(index: number, row: Vector4): Matrix; /** - * Returns the string "Vector4". + * Sets the index-th row of the current matrix with the passed 4 x float values. + * Returns the updated Matrix. */ - getClassName(): string; + setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix; /** - * Returns the Vector4 hash code. + * Returns a new Matrix set from the 16 passed floats. */ - getHashCode(): number; + static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix; /** - * Returns a new array populated with 4 elements : the Vector4 coordinates. + * Returns a new Matrix composed by the passed scale (vector3), rotation (quaternion) and translation (vector3). */ - asArray(): number[]; + static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix; /** - * Populates the passed array from the passed index with the Vector4 coordinates. - * Returns the Vector4. + * Update a Matrix with values composed by the passed scale (vector3), rotation (quaternion) and translation (vector3). + */ + static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void; + /** + * Returns a new indentity Matrix. */ - toArray(array: number[] | Float32Array, index?: number): Vector4; + static Identity(): Matrix; /** - * Adds the passed vector to the current Vector4. - * Returns the updated Vector4. + * Sets the passed "result" as an identity matrix. */ - addInPlace(otherVector: Vector4): Vector4; + static IdentityToRef(result: Matrix): void; /** - * Returns a new Vector4 as the result of the addition of the current Vector4 and the passed one. + * Returns a new zero Matrix. */ - add(otherVector: Vector4): Vector4; + static Zero(): Matrix; /** - * Updates the passed vector "result" with the result of the addition of the current Vector4 and the passed one. - * Returns the current Vector4. + * Returns a new rotation matrix for "angle" radians around the X axis. */ - addToRef(otherVector: Vector4, result: Vector4): Vector4; + static RotationX(angle: number): Matrix; /** - * Subtract in place the passed vector from the current Vector4. - * Returns the updated Vector4. + * Returns a new Matrix as the passed inverted one. */ - subtractInPlace(otherVector: Vector4): Vector4; + static Invert(source: Matrix): Matrix; /** - * Returns a new Vector4 with the result of the subtraction of the passed vector from the current Vector4. + * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the X axis. */ - subtract(otherVector: Vector4): Vector4; + static RotationXToRef(angle: number, result: Matrix): void; /** - * Sets the passed vector "result" with the result of the subtraction of the passed vector from the current Vector4. - * Returns the current Vector4. + * Returns a new rotation matrix for "angle" radians around the Y axis. */ - subtractToRef(otherVector: Vector4, result: Vector4): Vector4; + static RotationY(angle: number): Matrix; /** - * Returns a new Vector4 set with the result of the subtraction of the passed floats from the current Vector4 coordinates. + * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the Y axis. */ - subtractFromFloats(x: number, y: number, z: number, w: number): Vector4; + static RotationYToRef(angle: number, result: Matrix): void; /** - * Sets the passed vector "result" set with the result of the subtraction of the passed floats from the current Vector4 coordinates. - * Returns the current Vector4. + * Returns a new rotation matrix for "angle" radians around the Z axis. */ - subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4; + static RotationZ(angle: number): Matrix; /** - * Returns a new Vector4 set with the current Vector4 negated coordinates. + * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the Z axis. */ - negate(): Vector4; + static RotationZToRef(angle: number, result: Matrix): void; /** - * Multiplies the current Vector4 coordinates by scale (float). - * Returns the updated Vector4. + * Returns a new rotation matrix for "angle" radians around the passed axis. */ - scaleInPlace(scale: number): Vector4; + static RotationAxis(axis: Vector3, angle: number): Matrix; /** - * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float). + * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the passed axis. */ - scale(scale: number): Vector4; + static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void; /** - * Sets the passed vector "result" with the current Vector4 coordinates multiplied by scale (float). - * Returns the current Vector4. + * Returns a new Matrix as a rotation matrix from the Euler angles (y, x, z). */ - scaleToRef(scale: number, result: Vector4): Vector4; + static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix; /** - * Boolean : True if the current Vector4 coordinates are stricly equal to the passed ones. + * Sets the passed matrix "result" as a rotation matrix from the Euler angles (y, x, z). */ - equals(otherVector: Vector4): boolean; + static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void; /** - * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the passed vector ones. + * Returns a new Matrix as a scaling matrix from the passed floats (x, y, z). */ - equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean; + static Scaling(x: number, y: number, z: number): Matrix; /** - * Boolean : True if the passed floats are strictly equal to the current Vector4 coordinates. + * Sets the passed matrix "result" as a scaling matrix from the passed floats (x, y, z). */ - equalsToFloats(x: number, y: number, z: number, w: number): boolean; + static ScalingToRef(x: number, y: number, z: number, result: Matrix): void; /** - * Multiplies in place the current Vector4 by the passed one. - * Returns the updated Vector4. + * Returns a new Matrix as a translation matrix from the passed floats (x, y, z). */ - multiplyInPlace(otherVector: Vector4): Vector4; + static Translation(x: number, y: number, z: number): Matrix; /** - * Returns a new Vector4 set with the multiplication result of the current Vector4 and the passed one. + * Sets the passed matrix "result" as a translation matrix from the passed floats (x, y, z). */ - multiply(otherVector: Vector4): Vector4; + static TranslationToRef(x: number, y: number, z: number, result: Matrix): void; /** - * Updates the passed vector "result" with the multiplication result of the current Vector4 and the passed one. - * Returns the current Vector4. + * Returns a new Matrix whose values are the interpolated values for "gradien" (float) between the ones of the matrices "startValue" and "endValue". */ - multiplyToRef(otherVector: Vector4, result: Vector4): Vector4; + static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix; /** - * Returns a new Vector4 set with the multiplication result of the passed floats and the current Vector4 coordinates. + * Returns a new Matrix whose values are computed by : + * - decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices, + * - interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end, + * - recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices. */ - multiplyByFloats(x: number, y: number, z: number, w: number): Vector4; + static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix; /** - * Returns a new Vector4 set with the division result of the current Vector4 by the passed one. + * Returns a new rotation Matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up". + * This methods works for a Left-Handed system. */ - divide(otherVector: Vector4): Vector4; + static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix; /** - * Updates the passed vector "result" with the division result of the current Vector4 by the passed one. - * Returns the current Vector4. + * Sets the passed "result" Matrix as a rotation matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up". + * This methods works for a Left-Handed system. */ - divideToRef(otherVector: Vector4, result: Vector4): Vector4; + static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void; /** - * Updates the Vector4 coordinates with the minimum values between its own and the passed vector ones. + * Returns a new rotation Matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up". + * This methods works for a Right-Handed system. */ - MinimizeInPlace(other: Vector4): Vector4; + static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix; /** - * Updates the Vector4 coordinates with the maximum values between its own and the passed vector ones. + * Sets the passed "result" Matrix as a rotation matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up". + * This methods works for a Left-Handed system. */ - MaximizeInPlace(other: Vector4): Vector4; + static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void; /** - * Returns the Vector4 length (float). + * Returns a new Matrix as a left-handed orthographic projection matrix computed from the passed floats : width and height of the projection plane, z near and far limits. */ - length(): number; + static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix; /** - * Returns the Vector4 squared length (float). + * Sets the passed matrix "result" as a left-handed orthographic projection matrix computed from the passed floats : width and height of the projection plane, z near and far limits. */ - lengthSquared(): number; + static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void; /** - * Normalizes in place the Vector4. - * Returns the updated Vector4. + * Returns a new Matrix as a left-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits. */ - normalize(): Vector4; + static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix; /** - * Returns a new Vector3 from the Vector4 (x, y, z) coordinates. + * Sets the passed matrix "result" as a left-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits. */ - toVector3(): Vector3; + static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void; /** - * Returns a new Vector4 copied from the current one. + * Returns a new Matrix as a right-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits. */ - clone(): Vector4; + static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix; /** - * Updates the current Vector4 with the passed one coordinates. - * Returns the updated Vector4. + * Sets the passed matrix "result" as a right-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits. */ - copyFrom(source: Vector4): Vector4; + static OrthoOffCenterRHToRef(left: number, right: any, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void; /** - * Updates the current Vector4 coordinates with the passed floats. - * Returns the updated Vector4. + * Returns a new Matrix as a left-handed perspective projection matrix computed from the passed floats : width and height of the projection plane, z near and far limits. */ - copyFromFloats(x: number, y: number, z: number, w: number): Vector4; + static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix; /** - * Updates the current Vector4 coordinates with the passed floats. - * Returns the updated Vector4. + * Returns a new Matrix as a left-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits. */ - set(x: number, y: number, z: number, w: number): Vector4; + static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix; /** - * Returns a new Vector4 set from the starting index of the passed array. + * Sets the passed matrix "result" as a left-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits. */ - static FromArray(array: ArrayLike, offset?: number): Vector4; + static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void; /** - * Updates the passed vector "result" from the starting index of the passed array. + * Returns a new Matrix as a right-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits. */ - static FromArrayToRef(array: ArrayLike, offset: number, result: Vector4): void; + static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix; /** - * Updates the passed vector "result" from the starting index of the passed Float32Array. + * Sets the passed matrix "result" as a right-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits. */ - static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void; + static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void; /** - * Updates the passed vector "result" coordinates from the passed floats. + * Sets the passed matrix "result" as a left-handed perspective projection matrix for WebVR computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits. */ - static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void; + static PerspectiveFovWebVRToRef(fov: any, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void; /** - * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0) + * Returns the final transformation matrix : world * view * projection * viewport */ - static Zero(): Vector4; + static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix; /** - * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0) + * Returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the passed Matrix. */ - static One(): Vector4; + static GetAsMatrix2x2(matrix: Matrix): Float32Array; /** - * Returns a new normalized Vector4 from the passed one. + * Returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the passed Matrix. */ - static Normalize(vector: Vector4): Vector4; + static GetAsMatrix3x3(matrix: Matrix): Float32Array; /** - * Updates the passed vector "result" from the normalization of the passed one. + * Compute the transpose of the passed Matrix. + * Returns a new Matrix. */ - static NormalizeToRef(vector: Vector4, result: Vector4): void; - static Minimize(left: Vector4, right: Vector4): Vector4; - static Maximize(left: Vector4, right: Vector4): Vector4; + static Transpose(matrix: Matrix): Matrix; /** - * Returns the distance (float) between the vectors "value1" and "value2". + * Returns a new Matrix as the reflection matrix across the passed plane. */ - static Distance(value1: Vector4, value2: Vector4): number; + static Reflection(plane: Plane): Matrix; /** - * Returns the squared distance (float) between the vectors "value1" and "value2". + * Sets the passed matrix "result" as the reflection matrix across the passed plane. */ - static DistanceSquared(value1: Vector4, value2: Vector4): number; + static ReflectionToRef(plane: Plane, result: Matrix): void; /** - * Returns a new Vector4 located at the center between the vectors "value1" and "value2". + * Sets the passed matrix "mat" as a rotation matrix composed from the 3 passed left handed axis. */ - static Center(value1: Vector4, value2: Vector4): Vector4; + static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void; /** - * Returns a new Vector4 set with the result of the normal transformation by the passed matrix of the passed vector. - * This methods computes transformed normalized direction vectors only. + * Sets the passed matrix "result" as a rotation matrix according to the passed quaternion. */ - static TransformNormal(vector: Vector4, transformation: Matrix): Vector4; + static FromQuaternionToRef(quat: Quaternion, result: Matrix): void; + } + class Plane { + normal: Vector3; + d: number; /** - * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed vector. - * This methods computes transformed normalized direction vectors only. + * Creates a Plane object according to the passed floats a, b, c, d and the plane equation : ax + by + cz + d = 0 */ - static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void; + constructor(a: number, b: number, c: number, d: number); /** - * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed floats (x, y, z, w). - * This methods computes transformed normalized direction vectors only. + * Returns the plane coordinates as a new array of 4 elements [a, b, c, d]. */ - static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void; - } - interface ISize { - width: number; - height: number; - } - class Size implements ISize { - width: number; - height: number; + asArray(): number[]; /** - * Creates a Size object from the passed width and height (floats). + * Returns a new plane copied from the current Plane. */ - constructor(width: number, height: number); - toString(): string; + clone(): Plane; /** - * Returns the string "Size" + * Returns the string "Plane". */ getClassName(): string; /** - * Returns the Size hash code. + * Returns the Plane hash code. */ getHashCode(): number; /** - * Updates the current size from the passed one. - * Returns the updated Size. - */ - copyFrom(src: Size): void; - /** - * Updates in place the current Size from the passed floats. - * Returns the updated Size. + * Normalize the current Plane in place. + * Returns the updated Plane. */ - copyFromFloats(width: number, height: number): Size; + normalize(): Plane; /** - * Updates in place the current Size from the passed floats. - * Returns the updated Size. + * Returns a new Plane as the result of the transformation of the current Plane by the passed matrix. */ - set(width: number, height: number): Size; + transform(transformation: Matrix): Plane; /** - * Returns a new Size set with the multiplication result of the current Size and the passed floats. + * Returns the dot product (float) of the point coordinates and the plane normal. */ - multiplyByFloats(w: number, h: number): Size; + dotCoordinate(point: any): number; /** - * Returns a new Size copied from the passed one. + * Updates the current Plane from the plane defined by the three passed points. + * Returns the updated Plane. */ - clone(): Size; + copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane; /** - * Boolean : True if the current Size and the passed one width and height are strictly equal. + * Boolean : True is the vector "direction" is the same side than the plane normal. */ - equals(other: Size): boolean; + isFrontFacingTo(direction: Vector3, epsilon: number): boolean; /** - * Returns the surface of the Size : width * height (float). + * Returns the signed distance (float) from the passed point to the Plane. */ - readonly surface: number; + signedDistanceTo(point: Vector3): number; /** - * Returns a new Size set to (0.0, 0.0) + * Returns a new Plane from the passed array. */ - static Zero(): Size; + static FromArray(array: ArrayLike): Plane; /** - * Returns a new Size set as the addition result of the current Size and the passed one. + * Returns a new Plane defined by the three passed points. */ - add(otherSize: Size): Size; + static FromPoints(point1: any, point2: any, point3: any): Plane; /** - * Returns a new Size set as the subtraction result of the passed one from the current Size. + * Returns a new Plane the normal vector to this plane at the passed origin point. + * Note : the vector "normal" is updated because normalized. */ - subtract(otherSize: Size): Size; + static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane; /** - * Returns a new Size set at the linear interpolation "amount" between "start" and "end". + * Returns the signed distance between the plane defined by the normal vector at the "origin"" point and the passed other point. */ - static Lerp(start: Size, end: Size, amount: number): Size; + static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number; } - class Quaternion { + class Viewport { x: number; y: number; - z: number; - w: number; - /** - * Creates a new Quaternion from the passed floats. - */ - constructor(x?: number, y?: number, z?: number, w?: number); + width: number; + height: number; /** - * Returns a string with the Quaternion coordinates. + * Creates a Viewport object located at (x, y) and sized (width, height). */ - toString(): string; + constructor(x: number, y: number, width: number, height: number); + toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport; /** - * Returns the string "Quaternion". + * Returns a new Viewport copied from the current one. */ - getClassName(): string; + clone(): Viewport; + } + class Frustum { /** - * Returns the Quaternion hash code. + * Returns a new array of 6 Frustum planes computed by the passed transformation matrix. */ - getHashCode(): number; + static GetPlanes(transform: Matrix): Plane[]; /** - * Returns a new array populated with 4 elements : the Quaternion coordinates. + * Sets the passed array "frustumPlanes" with the 6 Frustum planes computed by the passed transformation matrix. */ - asArray(): number[]; + static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void; + } + enum Space { + LOCAL = 0, + WORLD = 1, + BONE = 2, + } + class Axis { + static X: Vector3; + static Y: Vector3; + static Z: Vector3; + } + class BezierCurve { /** - * Boolean : True if the current Quaterion and the passed one coordinates are strictly equal. + * Returns the cubic Bezier interpolated value (float) at "t" (float) from the passed x1, y1, x2, y2 floats. */ - equals(otherQuaternion: Quaternion): boolean; + static interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number; + } + enum Orientation { + CW = 0, + CCW = 1, + } + class Angle { + private _radians; /** - * Returns a new Quaternion copied from the current one. + * Creates an Angle object of "radians" radians (float). */ - clone(): Quaternion; + constructor(radians: number); /** - * Updates the current Quaternion from the passed one coordinates. - * Returns the updated Quaterion. + * Returns the Angle value in degrees (float). */ - copyFrom(other: Quaternion): Quaternion; + degrees: () => number; /** - * Updates the current Quaternion from the passed float coordinates. - * Returns the updated Quaterion. + * Returns the Angle value in radians (float). */ - copyFromFloats(x: number, y: number, z: number, w: number): Quaternion; + radians: () => number; /** - * Updates the current Quaternion from the passed float coordinates. - * Returns the updated Quaterion. + * Returns a new Angle object valued with the angle value in radians between the two passed vectors. */ - set(x: number, y: number, z: number, w: number): Quaternion; + static BetweenTwoPoints(a: Vector2, b: Vector2): Angle; /** - * Returns a new Quaternion as the addition result of the passed one and the current Quaternion. + * Returns a new Angle object from the passed float in radians. */ - add(other: Quaternion): Quaternion; + static FromRadians(radians: number): Angle; /** - * Returns a new Quaternion as the subtraction result of the passed one from the current Quaternion. + * Returns a new Angle object from the passed float in degrees. */ - subtract(other: Quaternion): Quaternion; + static FromDegrees(degrees: number): Angle; + } + class Arc2 { + startPoint: Vector2; + midPoint: Vector2; + endPoint: Vector2; + centerPoint: Vector2; + radius: number; + angle: Angle; + startAngle: Angle; + orientation: Orientation; /** - * Returns a new Quaternion set by multiplying the current Quaterion coordinates by the float "scale". + * Creates an Arc object from the three passed points : start, middle and end. */ - scale(value: number): Quaternion; + constructor(startPoint: Vector2, midPoint: Vector2, endPoint: Vector2); + } + class Path2 { + private _points; + private _length; + closed: boolean; /** - * Returns a new Quaternion set as the quaternion mulplication result of the current one with the passed one "q1". + * Creates a Path2 object from the starting 2D coordinates x and y. */ - multiply(q1: Quaternion): Quaternion; + constructor(x: number, y: number); /** - * Sets the passed "result" as the quaternion mulplication result of the current one with the passed one "q1". - * Returns the current Quaternion. + * Adds a new segment until the passed coordinates (x, y) to the current Path2. + * Returns the updated Path2. */ - multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion; + addLineTo(x: number, y: number): Path2; /** - * Updates the current Quaternion with the quaternion mulplication result of itself with the passed one "q1". - * Returns the updated Quaternion. + * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2. + * Returns the updated Path2. */ - multiplyInPlace(q1: Quaternion): Quaternion; + addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2; /** - * Sets the passed "ref" with the conjugation of the current Quaternion. - * Returns the current Quaternion. + * Closes the Path2. + * Returns the Path2. */ - conjugateToRef(ref: Quaternion): Quaternion; + close(): Path2; /** - * Conjugates in place the current Quaternion. - * Returns the updated Quaternion. + * Returns the Path2 total length (float). */ - conjugateInPlace(): Quaternion; + length(): number; /** - * Returns a new Quaternion as the conjugate of the current Quaternion. + * Returns the Path2 internal array of points. */ - conjugate(): Quaternion; + getPoints(): Vector2[]; /** - * Returns the Quaternion length (float). + * Returns a new Vector2 located at a percentage of the Path2 total length on this path. */ - length(): number; + getPointAtLengthPosition(normalizedLengthPosition: number): Vector2; /** - * Normalize in place the current Quaternion. - * Returns the updated Quaternion. + * Returns a new Path2 starting at the coordinates (x, y). */ - normalize(): Quaternion; + static StartingAt(x: number, y: number): Path2; + } + class Path3D { + path: Vector3[]; + private _curve; + private _distances; + private _tangents; + private _normals; + private _binormals; + private _raw; /** - * Returns a new Vector3 set with the Euler angles translated from the current Quaternion. + * new Path3D(path, normal, raw) + * Creates a Path3D. A Path3D is a logical math object, so not a mesh. + * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D + * path : an array of Vector3, the curve axis of the Path3D + * normal (optional) : Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal. + * raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed. + */ + constructor(path: Vector3[], firstNormal?: Vector3, raw?: boolean); + /** + * Returns the Path3D array of successive Vector3 designing its curve. */ - toEulerAngles(order?: string): Vector3; + getCurve(): Vector3[]; /** - * Sets the passed vector3 "result" with the Euler angles translated from the current Quaternion. - * Returns the current Quaternion. + * Returns an array populated with tangent vectors on each Path3D curve point. */ - toEulerAnglesToRef(result: Vector3, order?: string): Quaternion; + getTangents(): Vector3[]; /** - * Updates the passed rotation matrix with the current Quaternion values. - * Returns the current Quaternion. + * Returns an array populated with normal vectors on each Path3D curve point. */ - toRotationMatrix(result: Matrix): Quaternion; + getNormals(): Vector3[]; /** - * Updates the current Quaternion from the passed rotation matrix values. - * Returns the updated Quaternion. + * Returns an array populated with binormal vectors on each Path3D curve point. */ - fromRotationMatrix(matrix: Matrix): Quaternion; + getBinormals(): Vector3[]; /** - * Returns a new Quaternion set from the passed rotation matrix values. + * Returns an array populated with distances (float) of the i-th point from the first curve point. */ - static FromRotationMatrix(matrix: Matrix): Quaternion; + getDistances(): number[]; /** - * Updates the passed quaternion "result" with the passed rotation matrix values. + * Forces the Path3D tangent, normal, binormal and distance recomputation. + * Returns the same object updated. */ - static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void; + update(path: Vector3[], firstNormal?: Vector3): Path3D; + private _compute(firstNormal); + private _getFirstNonNullVector(index); + private _getLastNonNullVector(index); + private _normalVector(v0, vt, va); + } + class Curve3 { + private _points; + private _length; /** - * Returns a new Quaternion set to (0.0, 0.0, 0.0). + * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve + * @param v0 (Vector3) the origin point of the Quadratic Bezier + * @param v1 (Vector3) the control point + * @param v2 (Vector3) the end point of the Quadratic Bezier + * @param nbPoints (integer) the wanted number of points in the curve */ - static Zero(): Quaternion; + static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3; /** - * Returns a new Quaternion as the inverted current Quaternion. + * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve + * @param v0 (Vector3) the origin point of the Cubic Bezier + * @param v1 (Vector3) the first control point + * @param v2 (Vector3) the second control point + * @param v3 (Vector3) the end point of the Cubic Bezier + * @param nbPoints (integer) the wanted number of points in the curve */ - static Inverse(q: Quaternion): Quaternion; + static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3; /** - * Returns the identity Quaternion. + * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline + * @param p1 (Vector3) the origin point of the Hermite Spline + * @param t1 (Vector3) the tangent vector at the origin point + * @param p2 (Vector3) the end point of the Hermite Spline + * @param t2 (Vector3) the tangent vector at the end point + * @param nbPoints (integer) the wanted number of points in the curve */ - static Identity(): Quaternion; - static IsIdentity(quaternion: Quaternion): boolean; + static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3; /** - * Returns a new Quaternion set from the passed axis (Vector3) and angle in radians (float). + * Returns a Curve3 object along a CatmullRom Spline curve : + * @param points (array of Vector3) the points the spline must pass through. At least, four points required. + * @param nbPoints (integer) the wanted number of points between each curve control points. */ - static RotationAxis(axis: Vector3, angle: number): Quaternion; + static CreateCatmullRomSpline(points: Vector3[], nbPoints: number): Curve3; /** - * Sets the passed quaternion "result" from the passed axis (Vector3) and angle in radians (float). + * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space. + * A Curve3 is designed from a series of successive Vector3. + * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object */ - static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion; + constructor(points: Vector3[]); /** - * Retuns a new Quaternion set from the starting index of the passed array. + * Returns the Curve3 stored array of successive Vector3 */ - static FromArray(array: ArrayLike, offset?: number): Quaternion; + getPoints(): Vector3[]; /** - * Returns a new Quaternion set from the passed Euler float angles (y, x, z). + * Returns the computed length (float) of the curve. */ - static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion; + length(): number; /** - * Sets the passed quaternion "result" from the passed float Euler angles (y, x, z). + * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB); + * This new Curve3 is built by translating and sticking the curveB at the end of the curveA. + * curveA and curveB keep unchanged. */ - static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void; + continue(curve: Curve3): Curve3; + private _computeLength(path); + } + class PositionNormalVertex { + position: Vector3; + normal: Vector3; + constructor(position?: Vector3, normal?: Vector3); + clone(): PositionNormalVertex; + } + class PositionNormalTextureVertex { + position: Vector3; + normal: Vector3; + uv: Vector2; + constructor(position?: Vector3, normal?: Vector3, uv?: Vector2); + clone(): PositionNormalTextureVertex; + } + class Tmp { + static Color3: Color3[]; + static Vector2: Vector2[]; + static Vector3: Vector3[]; + static Vector4: Vector4[]; + static Quaternion: Quaternion[]; + static Matrix: Matrix[]; + } +} + +declare module BABYLON { + class SphericalPolynomial { + x: Vector3; + y: Vector3; + z: Vector3; + xx: Vector3; + yy: Vector3; + zz: Vector3; + xy: Vector3; + yz: Vector3; + zx: Vector3; + addAmbient(color: Color3): void; + static getSphericalPolynomialFromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial; + scale(scale: number): void; + } + class SphericalHarmonics { + L00: Vector3; + L1_1: Vector3; + L10: Vector3; + L11: Vector3; + L2_2: Vector3; + L2_1: Vector3; + L20: Vector3; + L21: Vector3; + L22: Vector3; + addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void; + scale(scale: number): void; + convertIncidentRadianceToIrradiance(): void; + convertIrradianceToLambertianRadiance(): void; + static getsphericalHarmonicsFromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics; + } +} + +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; /** - * Returns a new Quaternion from the passed float Euler angles expressed in z-x-z orientation + * 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). */ - static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion; /** - * Sets the passed quaternion "result" from the passed float Euler angles expressed in z-x-z orientation + * 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). */ - static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void; + globalHue: number; /** - * Returns a new Quaternion as the quaternion rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system. - * cf to Vector3.RotationFromAxis() documentation. - * Note : axis1, axis2 and axis3 are normalized during this operation. + * 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. */ - static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): Quaternion; /** - * Sets the passed quaternion "ref" with the quaternion rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system. - * cf to Vector3.RotationFromAxis() documentation. - * Note : axis1, axis2 and axis3 are normalized during this operation. + * 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. */ - static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void; - static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion; - static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void; + globalDensity: number; /** - * Returns a new Quaternion located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2". + * 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. */ - static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion; - } - class Matrix { - private static _tempQuaternion; - private static _xAxis; - private static _yAxis; - private static _zAxis; - private static _updateFlagSeed; - private _isIdentity; - private _isIdentityDirty; - updateFlag: number; - m: Float32Array; - _markAsUpdated(): void; - constructor(); /** - * Boolean : True is the matrix is the identity matrix + * 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; + 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). */ - isIdentity(considerAsTextureMatrix?: boolean): boolean; /** - * Returns the matrix determinant (float). + * 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). */ - determinant(): number; + highlightsHue: number; /** - * Returns the matrix underlying array. + * 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. */ - toArray(): Float32Array; /** - * Returns the matrix underlying array. - */ - asArray(): Float32Array; + * 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; /** - * Inverts in place the Matrix. - * Returns the Matrix inverted. + * 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. */ - invert(): Matrix; /** - * Sets all the matrix elements to zero. - * Returns the Matrix. + * 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. */ - reset(): Matrix; + highlightsSaturation: number; /** - * Returns a new Matrix as the addition result of the current Matrix and the passed one. + * 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. */ - add(other: Matrix): Matrix; /** - * Sets the passed matrix "result" with the ddition result of the current Matrix and the passed one. - * Returns the Matrix. + * 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. */ - addToRef(other: Matrix, result: Matrix): Matrix; + highlightsExposure: number; + private _midtonesHue; + private _midtonesDensity; + private _midtonesSaturation; + private _midtonesExposure; /** - * Adds in place the passed matrix to the current Matrix. - * Returns the updated Matrix. + * 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). */ - addToSelf(other: Matrix): Matrix; /** - * Sets the passed matrix with the current inverted Matrix. - * Returns the unmodified current Matrix. + * 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). */ - invertToRef(other: Matrix): Matrix; + midtonesHue: number; /** - * Inserts the translation vector (using 3 x floats) in the current Matrix. - * Returns the updated Matrix. + * 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. */ - setTranslationFromFloats(x: number, y: number, z: number): Matrix; /** - * Inserts the translation vector in the current Matrix. - * Returns the updated Matrix. - */ - setTranslation(vector3: Vector3): Matrix; + * 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; /** - * Returns a new Vector3 as the extracted translation from the Matrix. + * 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. */ - getTranslation(): Vector3; /** - * Fill a Vector3 with the extracted translation from the Matrix. + * 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. */ - getTranslationToRef(result: Vector3): Matrix; + midtonesSaturation: number; /** - * Remove rotation and scaling part from the Matrix. - * Returns the updated Matrix. + * 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. */ - removeRotationAndScaling(): Matrix; /** - * Returns a new Matrix set with the multiplication result of the current Matrix and the passed one. + * 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. */ - multiply(other: Matrix): Matrix; + midtonesExposure: number; + private _shadowsHue; + private _shadowsDensity; + private _shadowsSaturation; + private _shadowsExposure; /** - * Updates the current Matrix from the passed one values. - * Returns the updated Matrix. + * 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). */ - copyFrom(other: Matrix): Matrix; /** - * Populates the passed array from the starting index with the Matrix values. - * Returns the Matrix. + * 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). */ - copyToArray(array: Float32Array, offset?: number): Matrix; + shadowsHue: number; /** - * Sets the passed matrix "result" with the multiplication result of the current Matrix and the passed one. + * 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. */ - multiplyToRef(other: Matrix, result: Matrix): Matrix; /** - * Sets the Float32Array "result" from the passed index "offset" with the multiplication result of the current Matrix and the passed one. + * 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. */ - multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix; + shadowsDensity: number; /** - * Boolean : True is the current Matrix and the passed one values are strictly equal. + * 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. */ - equals(value: Matrix): boolean; /** - * Returns a new Matrix from the current Matrix. + * 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. */ - clone(): Matrix; + shadowsSaturation: number; /** - * Returns the string "Matrix" + * 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; getClassName(): string; /** - * Returns the Matrix hash code. + * Binds the color curves to the shader. + * @param colorCurves The color curve to bind + * @param effect The effect to bind to */ - getHashCode(): number; + static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void; /** - * Decomposes the current Matrix into : - * - a scale vector3 passed as a reference to update, - * - a rotation quaternion passed as a reference to update, - * - a translation vector3 passed as a reference to update. - * Returns the boolean `true`. + * Prepare the list of uniforms associated with the ColorCurves effects. + * @param uniformsList The list of uniforms used in the effect */ - decompose(scale: Vector3, rotation: Quaternion, translation: Vector3): boolean; + static PrepareUniforms(uniformsList: string[]): void; /** - * Returns a new Matrix as the extracted rotation matrix from the current one. + * 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. */ - getRotationMatrix(): Matrix; + private getColorGradingDataToRef(hue, density, saturation, exposure, result); /** - * Extracts the rotation matrix from the current one and sets it as the passed "result". - * Returns the current Matrix. + * 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. */ - getRotationMatrixToRef(result: Matrix): Matrix; + private static applyColorGradingSliderNonlinear(value); /** - * Returns a new Matrix set from the starting index of the passed array. + * 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. */ - static FromArray(array: ArrayLike, offset?: number): Matrix; + private static fromHSBToRef(hue, saturation, brightness, result); /** - * Sets the passed "result" matrix from the starting index of the passed array. + * 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. */ - static FromArrayToRef(array: ArrayLike, offset: number, result: Matrix): void; + private static clamp(value, min, max); /** - * Sets the passed "result" matrix from the starting index of the passed Float32Array by multiplying each element by the float "scale". + * Clones the current color curve instance. + * @return The cloned curves */ - static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void; + clone(): ColorCurves; /** - * Sets the passed matrix "result" with the 16 passed floats. + * Serializes the current color curve instance to a json representation. + * @return a JSON representation */ - static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void; + 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 { + class EffectFallbacks { + private _defines; + private _currentRank; + private _maxRank; + private _mesh; + private _meshRank; + addFallback(rank: number, define: string): void; + addCPUSkinningFallback(rank: number, mesh: BABYLON.AbstractMesh): void; + readonly isMoreFallbacks: boolean; + reduce(currentDefines: string): string; + } + class EffectCreationOptions { + attributes: string[]; + uniformsNames: string[]; + uniformBuffersNames: string[]; + samplers: string[]; + defines: any; + fallbacks: EffectFallbacks; + onCompiled: (effect: Effect) => void; + onError: (effect: Effect, errors: string) => void; + indexParameters: any; + maxSimultaneousLights: number; + } + class Effect { + name: any; + defines: string; + onCompiled: (effect: Effect) => void; + onError: (effect: Effect, errors: string) => void; + onBind: (effect: Effect) => void; + uniqueId: number; + onCompileObservable: Observable; + onErrorObservable: Observable; + onBindObservable: Observable; + private static _uniqueIdSeed; + private _engine; + private _uniformBuffersNames; + private _uniformsNames; + private _samplers; + private _isReady; + private _compilationError; + private _attributesNames; + private _attributes; + private _uniforms; + _key: string; + private _indexParameters; + private _fallbacks; + private _program; + private _valueCache; + private static _baseCache; + constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], engine?: Engine, defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, indexParameters?: any); + readonly key: string; + isReady(): boolean; + getEngine(): Engine; + getProgram(): WebGLProgram; + getAttributesNames(): string[]; + getAttributeLocation(index: number): number; + getAttributeLocationByName(name: string): number; + getAttributesCount(): number; + getUniformIndex(uniformName: string): number; + getUniform(uniformName: string): WebGLUniformLocation; + getSamplers(): string[]; + getCompilationError(): string; + getVertexShaderSource(): string; + getFragmentShaderSource(): string; + executeWhenCompiled(func: (effect: Effect) => void): void; + _loadVertexShader(vertex: any, callback: (data: any) => void): void; + _loadFragmentShader(fragment: any, callback: (data: any) => void): void; + private _dumpShadersSource(vertexCode, fragmentCode, defines); + private _processShaderConversion(sourceCode, isFragment, callback); + private _processIncludes(sourceCode, callback); + private _processPrecision(source); + private _prepareEffect(vertexSourceCode, fragmentSourceCode, attributesNames, defines, fallbacks?); + readonly isSupported: boolean; + _bindTexture(channel: string, texture: WebGLTexture): void; + setTexture(channel: string, texture: BaseTexture): void; + setTextureArray(channel: string, textures: BaseTexture[]): void; + setTextureFromPostProcess(channel: string, postProcess: PostProcess): void; + _cacheMatrix(uniformName: string, matrix: Matrix): boolean; + _cacheFloat2(uniformName: string, x: number, y: number): boolean; + _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean; + _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean; + bindUniformBuffer(buffer: WebGLBuffer, name: string): void; + bindUniformBlock(blockName: string, index: number): void; + setIntArray(uniformName: string, array: Int32Array): Effect; + setIntArray2(uniformName: string, array: Int32Array): Effect; + setIntArray3(uniformName: string, array: Int32Array): Effect; + setIntArray4(uniformName: string, array: Int32Array): Effect; + setFloatArray(uniformName: string, array: Float32Array): Effect; + setFloatArray2(uniformName: string, array: Float32Array): Effect; + setFloatArray3(uniformName: string, array: Float32Array): Effect; + setFloatArray4(uniformName: string, array: Float32Array): Effect; + setArray(uniformName: string, array: number[]): Effect; + setArray2(uniformName: string, array: number[]): Effect; + setArray3(uniformName: string, array: number[]): Effect; + setArray4(uniformName: string, array: number[]): Effect; + setMatrices(uniformName: string, matrices: Float32Array): Effect; + setMatrix(uniformName: string, matrix: Matrix): Effect; + setMatrix3x3(uniformName: string, matrix: Float32Array): Effect; + setMatrix2x2(uniformName: string, matrix: Float32Array): Effect; + setFloat(uniformName: string, value: number): Effect; + setBool(uniformName: string, bool: boolean): Effect; + setVector2(uniformName: string, vector2: Vector2): Effect; + setFloat2(uniformName: string, x: number, y: number): Effect; + setVector3(uniformName: string, vector3: Vector3): Effect; + setFloat3(uniformName: string, x: number, y: number, z: number): Effect; + setVector4(uniformName: string, vector4: Vector4): Effect; + setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect; + setColor3(uniformName: string, color3: Color3): Effect; + setColor4(uniformName: string, color3: Color3, alpha: number): Effect; + private _recombineShader(node); + private _evaluateDefinesOnString(shaderString); + static ShadersStore: {}; + static IncludesShadersStore: {}; + static ResetCache(): void; + } +} + +declare module BABYLON { + class FresnelParameters { + private _isEnabled; + isEnabled: boolean; + leftColor: Color3; + rightColor: Color3; + bias: number; + power: number; + clone(): FresnelParameters; + serialize(): any; + static Parse(parsedFresnelParameters: any): FresnelParameters; + } +} + +declare module BABYLON { + /** + * Interface to follow in your material defines to integrate easily the + * Image proccessing functions. + */ + interface IImageProcessingConfigurationDefines { + IMAGEPROCESSING: boolean; + VIGNETTE: boolean; + VIGNETTEBLENDMODEMULTIPLY: boolean; + VIGNETTEBLENDMODEOPAQUE: boolean; + TONEMAPPING: boolean; + CONTRAST: boolean; + EXPOSURE: boolean; + COLORCURVES: boolean; + COLORGRADING: boolean; + SAMPLER3DGREENDEPTH: boolean; + SAMPLER3DBGRMAP: boolean; + IMAGEPROCESSINGPOSTPROCESS: boolean; + } + /** + * 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 { /** - * Returns the index-th row of the current matrix as a new Vector4. + * Color curves setup used in the effect if colorCurvesEnabled is set to true */ - getRow(index: number): Vector4; + colorCurves: ColorCurves; + private _colorCurvesEnabled; /** - * Sets the index-th row of the current matrix with the passed Vector4 values. - * Returns the updated Matrix. + * Gets wether the color curves effect is enabled. */ - setRow(index: number, row: Vector4): Matrix; /** - * Sets the index-th row of the current matrix with the passed 4 x float values. - * Returns the updated Matrix. + * Sets wether the color curves effect is enabled. */ - setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix; + colorCurvesEnabled: boolean; /** - * Returns a new Matrix set from the 16 passed floats. + * Color grading LUT texture used in the effect if colorGradingEnabled is set to true */ - static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix; + colorGradingTexture: BaseTexture; + private _colorGradingEnabled; /** - * Returns a new Matrix composed by the passed scale (vector3), rotation (quaternion) and translation (vector3). + * Gets wether the color grading effect is enabled. */ - static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix; - /** - * Update a Matrix with values composed by the passed scale (vector3), rotation (quaternion) and translation (vector3). - */ - static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void; /** - * Returns a new indentity Matrix. + * Sets wether the color grading effect is enabled. */ - static Identity(): Matrix; + colorGradingEnabled: boolean; + private _colorGradingWithGreenDepth; /** - * Sets the passed "result" as an identity matrix. + * Gets wether the color grading effect is using a green depth for the 3d Texture. */ - static IdentityToRef(result: Matrix): void; /** - * Returns a new zero Matrix. + * Sets wether the color grading effect is using a green depth for the 3d Texture. */ - static Zero(): Matrix; + colorGradingWithGreenDepth: boolean; + private _colorGradingBGR; /** - * Returns a new rotation matrix for "angle" radians around the X axis. + * Gets wether the color grading texture contains BGR values. */ - static RotationX(angle: number): Matrix; /** - * Returns a new Matrix as the passed inverted one. + * Sets wether the color grading texture contains BGR values. */ - static Invert(source: Matrix): Matrix; + colorGradingBGR: boolean; + _exposure: number; /** - * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the X axis. + * Gets the Exposure used in the effect. */ - static RotationXToRef(angle: number, result: Matrix): void; /** - * Returns a new rotation matrix for "angle" radians around the Y axis. + * Sets the Exposure used in the effect. */ - static RotationY(angle: number): Matrix; + exposure: number; + private _toneMappingEnabled; /** - * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the Y axis. + * Gets wether the tone mapping effect is enabled. */ - static RotationYToRef(angle: number, result: Matrix): void; /** - * Returns a new rotation matrix for "angle" radians around the Z axis. + * Sets wether the tone mapping effect is enabled. */ - static RotationZ(angle: number): Matrix; + toneMappingEnabled: boolean; + protected _contrast: number; /** - * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the Z axis. + * Gets the contrast used in the effect. */ - static RotationZToRef(angle: number, result: Matrix): void; /** - * Returns a new rotation matrix for "angle" radians around the passed axis. + * Sets the contrast used in the effect. */ - static RotationAxis(axis: Vector3, angle: number): Matrix; + contrast: number; /** - * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the passed axis. + * Vignette stretch size. */ - static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void; + vignetteStretch: number; /** - * Returns a new Matrix as a rotation matrix from the Euler angles (y, x, z). + * Vignette centre X Offset. */ - static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix; + vignetteCentreX: number; /** - * Sets the passed matrix "result" as a rotation matrix from the Euler angles (y, x, z). + * Vignette centre Y Offset. */ - static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void; + vignetteCentreY: number; /** - * Returns a new Matrix as a scaling matrix from the passed floats (x, y, z). + * Vignette weight or intensity of the vignette effect. */ - static Scaling(x: number, y: number, z: number): Matrix; + vignetteWeight: number; /** - * Sets the passed matrix "result" as a scaling matrix from the passed floats (x, y, z). + * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode) + * if vignetteEnabled is set to true. */ - static ScalingToRef(x: number, y: number, z: number, result: Matrix): void; + vignetteColor: BABYLON.Color4; /** - * Returns a new Matrix as a translation matrix from the passed floats (x, y, z). + * Camera field of view used by the Vignette effect. */ - static Translation(x: number, y: number, z: number): Matrix; + vignetteCameraFov: number; + private _vignetteBlendMode; /** - * Sets the passed matrix "result" as a translation matrix from the passed floats (x, y, z). + * Gets the vignette blend mode allowing different kind of effect. */ - static TranslationToRef(x: number, y: number, z: number, result: Matrix): void; /** - * Returns a new Matrix whose values are the interpolated values for "gradien" (float) between the ones of the matrices "startValue" and "endValue". + * Sets the vignette blend mode allowing different kind of effect. */ - static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix; + vignetteBlendMode: number; + private _vignetteEnabled; /** - * Returns a new Matrix whose values are computed by : - * - decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices, - * - interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end, - * - recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices. + * Gets wether the vignette effect is enabled. */ - static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix; /** - * Returns a new rotation Matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up". - * This methods works for a Left-Handed system. + * Sets wether the vignette effect is enabled. */ - static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix; + vignetteEnabled: boolean; + private _applyByPostProcess; /** - * Sets the passed "result" Matrix as a rotation matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up". - * This methods works for a Left-Handed system. + * Gets wether the image processing is applied through a post process or not. */ - static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void; /** - * Returns a new rotation Matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up". - * This methods works for a Right-Handed system. + * Sets wether the image processing is applied through a post process or not. */ - static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix; + applyByPostProcess: boolean; /** - * Sets the passed "result" Matrix as a rotation matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up". - * This methods works for a Left-Handed system. - */ - static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void; + * An event triggered when the configuration changes and requires Shader to Update some parameters. + * @type {BABYLON.Observable} + */ + onUpdateParameters: Observable; /** - * Returns a new Matrix as a left-handed orthographic projection matrix computed from the passed floats : width and height of the projection plane, z near and far limits. + * Method called each time the image processing information changes requires to recompile the effect. */ - static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix; + protected _updateParameters(): void; + getClassName(): string; /** - * Sets the passed matrix "result" as a left-handed orthographic projection matrix computed from the passed floats : width and height of the projection plane, z near and far limits. + * Prepare the list of uniforms associated with the Image Processing effects. + * @param uniformsList The list of uniforms used in the effect + * @param defines the list of defines currently in use */ - static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void; + static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void; /** - * Returns a new Matrix as a left-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits. + * Prepare the list of samplers associated with the Image Processing effects. + * @param uniformsList The list of uniforms used in the effect + * @param defines the list of defines currently in use */ - static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix; + static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void; /** - * Sets the passed matrix "result" as a left-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits. + * Prepare the list of defines associated to the shader. + * @param defines the list of defines to complete */ - static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void; + prepareDefines(defines: IImageProcessingConfigurationDefines): void; /** - * Returns a new Matrix as a right-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits. + * Returns true if all the image processing information are ready. */ - static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix; + isReady(): boolean; /** - * Sets the passed matrix "result" as a right-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits. + * Binds the image processing to the shader. + * @param effect The effect to bind to */ - static OrthoOffCenterRHToRef(left: number, right: any, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void; + bind(effect: Effect, aspectRatio?: number): void; /** - * Returns a new Matrix as a left-handed perspective projection matrix computed from the passed floats : width and height of the projection plane, z near and far limits. + * Clones the current image processing instance. + * @return The cloned image processing */ - static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix; + clone(): ImageProcessingConfiguration; /** - * Returns a new Matrix as a left-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits. + * Serializes the current image processing instance to a json representation. + * @return a JSON representation */ - static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix; + serialize(): any; /** - * Sets the passed matrix "result" as a left-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits. + * Parses the image processing from a json representation. + * @param source the JSON source to parse + * @return The parsed image processing */ - static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void; + static Parse(source: any): ImageProcessingConfiguration; + private static _VIGNETTEMODE_MULTIPLY; + private static _VIGNETTEMODE_OPAQUE; /** - * Returns a new Matrix as a right-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits. + * Used to apply the vignette as a mix with the pixel color. */ - static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix; + static readonly VIGNETTEMODE_MULTIPLY: number; /** - * Sets the passed matrix "result" as a right-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits. + * Used to apply the vignette as a replacement of the pixel color. */ - static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void; + static readonly VIGNETTEMODE_OPAQUE: number; + } +} + +declare module BABYLON { + class MaterialDefines { + private _keys; + private _isDirty; + _renderId: number; + _areLightsDirty: boolean; + _areAttributesDirty: boolean; + _areTexturesDirty: boolean; + _areFresnelDirty: boolean; + _areMiscDirty: boolean; + _areImageProcessingDirty: boolean; + _normals: boolean; + _uvs: boolean; + _needNormals: boolean; + _needUVs: boolean; + readonly isDirty: boolean; + markAsProcessed(): void; + markAsUnprocessed(): void; + markAllAsDirty(): void; + markAsImageProcessingDirty(): void; + markAsLightDirty(): void; + markAsAttributesDirty(): void; + markAsTexturesDirty(): void; + markAsFresnelDirty(): void; + markAsMiscDirty(): void; + rebuild(): void; + isEqual(other: MaterialDefines): boolean; + cloneTo(other: MaterialDefines): void; + reset(): void; + toString(): string; + } + class Material { + private static _TriangleFillMode; + private static _WireFrameFillMode; + private static _PointFillMode; + static readonly TriangleFillMode: number; + static readonly WireFrameFillMode: number; + static readonly PointFillMode: number; + private static _ClockWiseSideOrientation; + private static _CounterClockWiseSideOrientation; + static readonly ClockWiseSideOrientation: number; + static readonly CounterClockWiseSideOrientation: number; + private static _TextureDirtyFlag; + private static _LightDirtyFlag; + private static _FresnelDirtyFlag; + private static _AttributesDirtyFlag; + private static _MiscDirtyFlag; + static readonly TextureDirtyFlag: number; + static readonly LightDirtyFlag: number; + static readonly FresnelDirtyFlag: number; + static readonly AttributesDirtyFlag: number; + static readonly MiscDirtyFlag: number; + id: string; + name: string; + checkReadyOnEveryCall: boolean; + checkReadyOnlyOnce: boolean; + state: string; + alpha: number; + protected _backFaceCulling: boolean; + backFaceCulling: boolean; + sideOrientation: number; + onCompiled: (effect: Effect) => void; + onError: (effect: Effect, errors: string) => void; + getRenderTargetTextures: () => SmartArray; + doNotSerialize: boolean; + storeEffectOnSubMeshes: boolean; /** - * Sets the passed matrix "result" as a left-handed perspective projection matrix for WebVR computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits. - */ - static PerspectiveFovWebVRToRef(fov: any, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void; + * An event triggered when the material is disposed. + * @type {BABYLON.Observable} + */ + onDisposeObservable: Observable; + private _onDisposeObserver; + onDispose: () => void; /** - * Returns the final transformation matrix : world * view * projection * viewport - */ - static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix; + * An event triggered when the material is bound. + * @type {BABYLON.Observable} + */ + onBindObservable: Observable; + private _onBindObserver; + onBind: (Mesh: AbstractMesh) => void; /** - * Returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the passed Matrix. + * An event triggered when the material is unbound. + * @type {BABYLON.Observable} + */ + onUnBindObservable: Observable; + alphaMode: number; + disableDepthWrite: boolean; + private _fogEnabled; + fogEnabled: boolean; + pointSize: number; + zOffset: number; + wireframe: boolean; + pointsCloud: boolean; + fillMode: number; + _effect: Effect; + _wasPreviouslyReady: boolean; + private _useUBO; + private _scene; + private _fillMode; + private _cachedDepthWriteState; + protected _uniformBuffer: UniformBuffer; + constructor(name: string, scene: Scene, doNotAdd?: boolean); + /** + * @param {boolean} fullDetails - support for multiple levels of logging within scene loading + * subclasses should override adding information pertainent to themselves */ - static GetAsMatrix2x2(matrix: Matrix): Float32Array; + toString(fullDetails?: boolean): string; /** - * Returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the passed Matrix. + * Child classes can use it to update shaders */ - static GetAsMatrix3x3(matrix: Matrix): Float32Array; + getClassName(): string; + readonly isFrozen: boolean; + freeze(): void; + unfreeze(): void; + isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean; + isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean; + getEffect(): Effect; + getScene(): Scene; + needAlphaBlending(): boolean; + needAlphaTesting(): boolean; + getAlphaTestTexture(): BaseTexture; + markDirty(): void; + _preBind(effect?: Effect): void; + bind(world: Matrix, mesh?: Mesh): void; + bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void; + bindOnlyWorldMatrix(world: Matrix): void; + bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void; + bindView(effect: Effect): void; + bindViewProjection(effect: Effect): void; + protected _afterBind(mesh: Mesh): void; + unbind(): void; + getActiveTextures(): BaseTexture[]; + hasTexture(texture: BaseTexture): boolean; + clone(name: string): Material; + getBindedMeshes(): AbstractMesh[]; /** - * Compute the transpose of the passed Matrix. - * Returns a new Matrix. + * Force shader compilation including textures ready check */ - static Transpose(matrix: Matrix): Matrix; + forceCompilation(mesh: AbstractMesh, onCompiled: (material: Material) => void, options?: { + alphaTest: boolean; + clipPlane: boolean; + }): void; + markAsDirty(flag: number): void; + protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void; + protected _markAllSubMeshesAsImageProcessingDirty(): void; + protected _markAllSubMeshesAsTexturesDirty(): void; + protected _markAllSubMeshesAsFresnelDirty(): void; + protected _markAllSubMeshesAsLightsDirty(): void; + protected _markAllSubMeshesAsAttributesDirty(): void; + protected _markAllSubMeshesAsMiscDirty(): void; + dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void; + serialize(): any; + static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial; + static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any; + } +} + +declare module BABYLON { + class MaterialHelper { + static PrepareDefinesForMergedUV(texture: BaseTexture, defines: MaterialDefines, key: string): void; + static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void; + static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: any, fogEnabled: boolean, defines: MaterialDefines): void; + static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: MaterialDefines, useInstances: boolean, forceAlphaTest?: boolean): void; + static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: MaterialDefines, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean): boolean; + static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: MaterialDefines, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean; + static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: MaterialDefines, maxSimultaneousLights?: number): void; + static HandleFallbacksForShadows(defines: MaterialDefines, fallbacks: EffectFallbacks, maxSimultaneousLights?: number): void; + static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: MaterialDefines): void; + static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: MaterialDefines, fallbacks: EffectFallbacks): void; + static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void; + static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void; + static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void; + static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: MaterialDefines, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void; + static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect): void; + static BindBonesParameters(mesh: AbstractMesh, effect: Effect): void; + static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void; + static BindLogDepth(defines: MaterialDefines, effect: Effect, scene: Scene): void; + static BindClipPlane(effect: Effect, scene: Scene): void; + } +} + +declare module BABYLON { + class MultiMaterial extends Material { + private _subMaterials; + subMaterials: Material[]; + constructor(name: string, scene: Scene); + private _hookArray(array); + getSubMaterial(index: any): Material; + getActiveTextures(): BaseTexture[]; + getClassName(): string; + isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean; + clone(name: string, cloneChildren?: boolean): MultiMaterial; + serialize(): any; + dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void; + } +} + +declare module BABYLON { + class PushMaterial extends Material { + protected _activeEffect: Effect; + constructor(name: string, scene: Scene); + getEffect(): Effect; + isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean; + bindOnlyWorldMatrix(world: Matrix): void; + bind(world: Matrix, mesh?: Mesh): void; + protected _afterBind(mesh: Mesh, effect?: Effect): void; + protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean; + } +} + +declare module BABYLON { + class ShaderMaterial extends Material { + private _shaderPath; + private _options; + private _textures; + private _textureArrays; + private _floats; + private _floatsArrays; + private _colors3; + private _colors3Arrays; + private _colors4; + private _vectors2; + private _vectors3; + private _vectors4; + private _matrices; + private _matrices3x3; + private _matrices2x2; + private _vectors3Arrays; + private _cachedWorldViewMatrix; + private _renderId; + constructor(name: string, scene: Scene, shaderPath: any, options: any); + getClassName(): string; + needAlphaBlending(): boolean; + needAlphaTesting(): boolean; + private _checkUniform(uniformName); + setTexture(name: string, texture: Texture): ShaderMaterial; + setTextureArray(name: string, textures: Texture[]): ShaderMaterial; + setFloat(name: string, value: number): ShaderMaterial; + setFloats(name: string, value: number[]): ShaderMaterial; + setColor3(name: string, value: Color3): ShaderMaterial; + setColor3Array(name: string, value: Color3[]): ShaderMaterial; + setColor4(name: string, value: Color4): ShaderMaterial; + setVector2(name: string, value: Vector2): ShaderMaterial; + setVector3(name: string, value: Vector3): ShaderMaterial; + setVector4(name: string, value: Vector4): ShaderMaterial; + setMatrix(name: string, value: Matrix): ShaderMaterial; + setMatrix3x3(name: string, value: Float32Array): ShaderMaterial; + setMatrix2x2(name: string, value: Float32Array): ShaderMaterial; + setArray3(name: string, value: number[]): ShaderMaterial; + private _checkCache(scene, mesh?, useInstances?); + isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean; + bindOnlyWorldMatrix(world: Matrix): void; + bind(world: Matrix, mesh?: Mesh): void; + getActiveTextures(): BaseTexture[]; + hasTexture(texture: BaseTexture): boolean; + clone(name: string): ShaderMaterial; + dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void; + serialize(): any; + static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial; + } +} + +declare module BABYLON { + class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines { + MAINUV1: boolean; + MAINUV2: boolean; + DIFFUSE: boolean; + DIFFUSEDIRECTUV: number; + AMBIENT: boolean; + AMBIENTDIRECTUV: number; + OPACITY: boolean; + OPACITYDIRECTUV: number; + OPACITYRGB: boolean; + REFLECTION: boolean; + EMISSIVE: boolean; + EMISSIVEDIRECTUV: number; + SPECULAR: boolean; + SPECULARDIRECTUV: number; + BUMP: boolean; + BUMPDIRECTUV: number; + PARALLAX: boolean; + PARALLAXOCCLUSION: boolean; + SPECULAROVERALPHA: boolean; + CLIPPLANE: boolean; + ALPHATEST: boolean; + ALPHAFROMDIFFUSE: boolean; + POINTSIZE: boolean; + FOG: boolean; + SPECULARTERM: boolean; + DIFFUSEFRESNEL: boolean; + OPACITYFRESNEL: boolean; + REFLECTIONFRESNEL: boolean; + REFRACTIONFRESNEL: boolean; + EMISSIVEFRESNEL: boolean; + FRESNEL: boolean; + NORMAL: boolean; + UV1: boolean; + UV2: boolean; + VERTEXCOLOR: boolean; + VERTEXALPHA: boolean; + NUM_BONE_INFLUENCERS: number; + BonesPerMesh: number; + INSTANCES: boolean; + GLOSSINESS: boolean; + ROUGHNESS: boolean; + EMISSIVEASILLUMINATION: boolean; + LINKEMISSIVEWITHDIFFUSE: boolean; + REFLECTIONFRESNELFROMSPECULAR: boolean; + LIGHTMAP: boolean; + LIGHTMAPDIRECTUV: number; + USELIGHTMAPASSHADOWMAP: boolean; + REFLECTIONMAP_3D: boolean; + REFLECTIONMAP_SPHERICAL: boolean; + REFLECTIONMAP_PLANAR: boolean; + REFLECTIONMAP_CUBIC: boolean; + REFLECTIONMAP_PROJECTION: boolean; + REFLECTIONMAP_SKYBOX: boolean; + REFLECTIONMAP_EXPLICIT: boolean; + REFLECTIONMAP_EQUIRECTANGULAR: boolean; + REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean; + REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean; + INVERTCUBICMAP: boolean; + LOGARITHMICDEPTH: boolean; + REFRACTION: boolean; + REFRACTIONMAP_3D: boolean; + REFLECTIONOVERALPHA: boolean; + TWOSIDEDLIGHTING: boolean; + SHADOWFLOAT: boolean; + MORPHTARGETS: boolean; + MORPHTARGETS_NORMAL: boolean; + MORPHTARGETS_TANGENT: boolean; + NUM_MORPH_INFLUENCERS: number; + USERIGHTHANDEDSYSTEM: boolean; + IMAGEPROCESSING: boolean; + VIGNETTE: boolean; + VIGNETTEBLENDMODEMULTIPLY: boolean; + VIGNETTEBLENDMODEOPAQUE: boolean; + TONEMAPPING: boolean; + CONTRAST: boolean; + COLORCURVES: boolean; + COLORGRADING: boolean; + SAMPLER3DGREENDEPTH: boolean; + SAMPLER3DBGRMAP: boolean; + IMAGEPROCESSINGPOSTPROCESS: boolean; + EXPOSURE: boolean; + constructor(); + setReflectionMode(modeToEnable: string): void; + } + class StandardMaterial extends PushMaterial { + private _diffuseTexture; + diffuseTexture: BaseTexture; + private _ambientTexture; + ambientTexture: BaseTexture; + private _opacityTexture; + opacityTexture: BaseTexture; + private _reflectionTexture; + reflectionTexture: BaseTexture; + private _emissiveTexture; + emissiveTexture: BaseTexture; + private _specularTexture; + specularTexture: BaseTexture; + private _bumpTexture; + bumpTexture: BaseTexture; + private _lightmapTexture; + lightmapTexture: BaseTexture; + private _refractionTexture; + refractionTexture: BaseTexture; + ambientColor: Color3; + diffuseColor: Color3; + specularColor: Color3; + emissiveColor: Color3; + specularPower: number; + private _useAlphaFromDiffuseTexture; + useAlphaFromDiffuseTexture: boolean; + private _useEmissiveAsIllumination; + useEmissiveAsIllumination: boolean; + private _linkEmissiveWithDiffuse; + linkEmissiveWithDiffuse: boolean; + private _useSpecularOverAlpha; + useSpecularOverAlpha: boolean; + private _useReflectionOverAlpha; + useReflectionOverAlpha: boolean; + private _disableLighting; + disableLighting: boolean; + private _useParallax; + useParallax: boolean; + private _useParallaxOcclusion; + useParallaxOcclusion: boolean; + parallaxScaleBias: number; + private _roughness; + roughness: number; + indexOfRefraction: number; + invertRefractionY: boolean; + private _useLightmapAsShadowmap; + useLightmapAsShadowmap: boolean; + private _diffuseFresnelParameters; + diffuseFresnelParameters: FresnelParameters; + private _opacityFresnelParameters; + opacityFresnelParameters: FresnelParameters; + private _reflectionFresnelParameters; + reflectionFresnelParameters: FresnelParameters; + private _refractionFresnelParameters; + refractionFresnelParameters: FresnelParameters; + private _emissiveFresnelParameters; + emissiveFresnelParameters: FresnelParameters; + private _useReflectionFresnelFromSpecular; + useReflectionFresnelFromSpecular: boolean; + private _useGlossinessFromSpecularMapAlpha; + useGlossinessFromSpecularMapAlpha: boolean; + private _maxSimultaneousLights; + maxSimultaneousLights: number; /** - * Returns a new Matrix as the reflection matrix across the passed plane. + * If sets to true, x component of normal map value will invert (x = 1.0 - x). */ - static Reflection(plane: Plane): Matrix; + private _invertNormalMapX; + invertNormalMapX: boolean; /** - * Sets the passed matrix "result" as the reflection matrix across the passed plane. + * If sets to true, y component of normal map value will invert (y = 1.0 - y). */ - static ReflectionToRef(plane: Plane, result: Matrix): void; + private _invertNormalMapY; + invertNormalMapY: boolean; /** - * Sets the passed matrix "mat" as a rotation matrix composed from the 3 passed left handed axis. + * If sets to true and backfaceCulling is false, normals will be flipped on the backside. */ - static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void; + private _twoSidedLighting; + twoSidedLighting: boolean; /** - * Sets the passed matrix "result" as a rotation matrix according to the passed quaternion. + * Default configuration related to image processing available in the standard Material. */ - static FromQuaternionToRef(quat: Quaternion, result: Matrix): void; - } - class Plane { - normal: Vector3; - d: number; + protected _imageProcessingConfiguration: ImageProcessingConfiguration; /** - * Creates a Plane object according to the passed floats a, b, c, d and the plane equation : ax + by + cz + d = 0 + * Gets the image processing configuration used either in this material. */ - constructor(a: number, b: number, c: number, d: number); /** - * Returns the plane coordinates as a new array of 4 elements [a, b, c, d]. + * Sets the Default image processing configuration used either in the this material. + * + * If sets to null, the scene one is in use. */ - asArray(): number[]; + imageProcessingConfiguration: ImageProcessingConfiguration; /** - * Returns a new plane copied from the current Plane. + * Keep track of the image processing observer to allow dispose and replace. */ - clone(): Plane; + private _imageProcessingObserver; /** - * Returns the string "Plane". + * Attaches a new image processing configuration to the Standard Material. + * @param configuration */ - getClassName(): string; + protected _attachImageProcessingConfiguration(configuration: ImageProcessingConfiguration): void; /** - * Returns the Plane hash code. + * Gets wether the color curves effect is enabled. */ - getHashCode(): number; /** - * Normalize the current Plane in place. - * Returns the updated Plane. + * Sets wether the color curves effect is enabled. */ - normalize(): Plane; + cameraColorCurvesEnabled: boolean; /** - * Returns a new Plane as the result of the transformation of the current Plane by the passed matrix. + * Gets wether the color grading effect is enabled. */ - transform(transformation: Matrix): Plane; /** - * Returns the dot product (float) of the point coordinates and the plane normal. + * Gets wether the color grading effect is enabled. */ - dotCoordinate(point: any): number; + cameraColorGradingEnabled: boolean; /** - * Updates the current Plane from the plane defined by the three passed points. - * Returns the updated Plane. + * Gets wether tonemapping is enabled or not. */ - copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane; /** - * Boolean : True is the vector "direction" is the same side than the plane normal. + * Sets wether tonemapping is enabled or not */ - isFrontFacingTo(direction: Vector3, epsilon: number): boolean; + cameraToneMappingEnabled: boolean; /** - * Returns the signed distance (float) from the passed point to the Plane. + * The camera exposure used on this material. + * This property is here and not in the camera to allow controlling exposure without full screen post process. + * This corresponds to a photographic exposure. */ - signedDistanceTo(point: Vector3): number; /** - * Returns a new Plane from the passed array. + * The camera exposure used on this material. + * This property is here and not in the camera to allow controlling exposure without full screen post process. + * This corresponds to a photographic exposure. */ - static FromArray(array: ArrayLike): Plane; + cameraExposure: number; /** - * Returns a new Plane defined by the three passed points. + * Gets The camera contrast used on this material. */ - static FromPoints(point1: any, point2: any, point3: any): Plane; /** - * Returns a new Plane the normal vector to this plane at the passed origin point. - * Note : the vector "normal" is updated because normalized. + * Sets The camera contrast used on this material. */ - static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane; + cameraContrast: number; /** - * Returns the signed distance between the plane defined by the normal vector at the "origin"" point and the passed other point. + * Gets the Color Grading 2D Lookup Texture. */ - static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number; - } - class Viewport { - x: number; - y: number; - width: number; - height: number; /** - * Creates a Viewport object located at (x, y) and sized (width, height). + * Sets the Color Grading 2D Lookup Texture. */ - constructor(x: number, y: number, width: number, height: number); - toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport; + cameraColorGradingTexture: BaseTexture; + customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string; + protected _renderTargets: SmartArray; + protected _worldViewProjectionMatrix: Matrix; + protected _globalAmbientColor: Color3; + protected _useLogarithmicDepth: boolean; + constructor(name: string, scene: Scene); + getClassName(): string; + useLogarithmicDepth: boolean; + needAlphaBlending(): boolean; + needAlphaTesting(): boolean; + protected _shouldUseAlphaFromDiffuseTexture(): boolean; + getAlphaTestTexture(): BaseTexture; /** - * Returns a new Viewport copied from the current one. + * Child classes can use it to update shaders */ - clone(): Viewport; + isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean; + buildUniformLayout(): void; + unbind(): void; + bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void; + getAnimatables(): IAnimatable[]; + getActiveTextures(): BaseTexture[]; + hasTexture(texture: BaseTexture): boolean; + dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void; + clone(name: string): StandardMaterial; + serialize(): any; + static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial; + static _DiffuseTextureEnabled: boolean; + static DiffuseTextureEnabled: boolean; + static _AmbientTextureEnabled: boolean; + static AmbientTextureEnabled: boolean; + static _OpacityTextureEnabled: boolean; + static OpacityTextureEnabled: boolean; + static _ReflectionTextureEnabled: boolean; + static ReflectionTextureEnabled: boolean; + static _EmissiveTextureEnabled: boolean; + static EmissiveTextureEnabled: boolean; + static _SpecularTextureEnabled: boolean; + static SpecularTextureEnabled: boolean; + static _BumpTextureEnabled: boolean; + static BumpTextureEnabled: boolean; + static _LightmapTextureEnabled: boolean; + static LightmapTextureEnabled: boolean; + static _RefractionTextureEnabled: boolean; + static RefractionTextureEnabled: boolean; + static _ColorGradingTextureEnabled: boolean; + static ColorGradingTextureEnabled: boolean; + static _FresnelEnabled: boolean; + static FresnelEnabled: boolean; } - class Frustum { +} + +declare module BABYLON { + class UniformBuffer { + private _engine; + private _buffer; + private _data; + private _bufferData; + private _dynamic; + private _uniformName; + private _uniformLocations; + private _uniformSizes; + private _uniformLocationPointer; + private _needSync; + private _cache; + private _noUBO; + private _currentEffect; + private static _MAX_UNIFORM_SIZE; + private static _tempBuffer; /** - * Returns a new array of 6 Frustum planes computed by the passed transformation matrix. + * Wrapper for updateUniform. + * @method updateMatrix3x3 + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {Float32Array} matrix */ - static GetPlanes(transform: Matrix): Plane[]; + updateMatrix3x3: (name: string, matrix: Float32Array) => void; /** - * Sets the passed array "frustumPlanes" with the 6 Frustum planes computed by the passed transformation matrix. + * Wrapper for updateUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {Float32Array} matrix */ - static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void; - } - enum Space { - LOCAL = 0, - WORLD = 1, - BONE = 2, - } - class Axis { - static X: Vector3; - static Y: Vector3; - static Z: Vector3; - } - class BezierCurve { + updateMatrix2x2: (name: string, matrix: Float32Array) => void; /** - * Returns the cubic Bezier interpolated value (float) at "t" (float) from the passed x1, y1, x2, y2 floats. + * Wrapper for updateUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {number} x */ - static interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number; - } - enum Orientation { - CW = 0, - CCW = 1, - } - class Angle { - private _radians; + updateFloat: (name: string, x: number) => void; /** - * Creates an Angle object of "radians" radians (float). + * Wrapper for updateUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {number} x + * @param {number} y + * @param {string} [suffix] Suffix to add to the uniform name. */ - constructor(radians: number); + updateFloat2: (name: string, x: number, y: number, suffix?: string) => void; /** - * Returns the Angle value in degrees (float). + * Wrapper for updateUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {number} x + * @param {number} y + * @param {number} z + * @param {string} [suffix] Suffix to add to the uniform name. */ - degrees: () => number; + updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void; /** - * Returns the Angle value in radians (float). + * Wrapper for updateUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {number} x + * @param {number} y + * @param {number} z + * @param {number} w + * @param {string} [suffix] Suffix to add to the uniform name. */ - radians: () => number; + updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void; /** - * Returns a new Angle object valued with the angle value in radians between the two passed vectors. + * Wrapper for updateUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {Matrix} A 4x4 matrix. */ - static BetweenTwoPoints(a: Vector2, b: Vector2): Angle; + updateMatrix: (name: string, mat: Matrix) => void; /** - * Returns a new Angle object from the passed float in radians. + * Wrapper for updateUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {Vector3} vector */ - static FromRadians(radians: number): Angle; + updateVector3: (name: string, vector: Vector3) => void; /** - * Returns a new Angle object from the passed float in degrees. + * Wrapper for updateUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {Vector4} vector */ - static FromDegrees(degrees: number): Angle; - } - class Arc2 { - startPoint: Vector2; - midPoint: Vector2; - endPoint: Vector2; - centerPoint: Vector2; - radius: number; - angle: Angle; - startAngle: Angle; - orientation: Orientation; + updateVector4: (name: string, vector: Vector4) => void; /** - * Creates an Arc object from the three passed points : start, middle and end. + * Wrapper for updateUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {Color3} color + * @param {string} [suffix] Suffix to add to the uniform name. */ - constructor(startPoint: Vector2, midPoint: Vector2, endPoint: Vector2); - } - class Path2 { - private _points; - private _length; - closed: boolean; + updateColor3: (name: string, color: Color3, suffix?: string) => void; /** - * Creates a Path2 object from the starting 2D coordinates x and y. + * Wrapper for updateUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {Color3} color + * @param {number} alpha + * @param {string} [suffix] Suffix to add to the uniform name. */ - constructor(x: number, y: number); + updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void; /** - * Adds a new segment until the passed coordinates (x, y) to the current Path2. - * Returns the updated Path2. + * Uniform buffer objects. + * + * Handles blocks of uniform on the GPU. + * + * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls. + * + * For more information, please refer to : + * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object */ - addLineTo(x: number, y: number): Path2; + constructor(engine: Engine, data?: number[], dynamic?: boolean); /** - * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2. - * Returns the updated Path2. + * Indicates if the buffer is using the WebGL2 UBO implementation, + * or just falling back on setUniformXXX calls. */ - addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2; + readonly useUbo: boolean; /** - * Closes the Path2. - * Returns the Path2. + * Indicates if the WebGL underlying uniform buffer is in sync + * with the javascript cache data. */ - close(): Path2; + readonly isSync: boolean; + /** + * Indicates if the WebGL underlying uniform buffer is dynamic. + * Also, a dynamic UniformBuffer will disable cache verification and always + * update the underlying WebGL uniform buffer to the GPU. + */ + isDynamic(): boolean; /** - * Returns the Path2 total length (float). + * The data cache on JS side. */ - length(): number; + getData(): Float32Array; /** - * Returns the Path2 internal array of points. + * The underlying WebGL Uniform buffer. */ - getPoints(): Vector2[]; + getBuffer(): WebGLBuffer; /** - * Returns a new Vector2 located at a percentage of the Path2 total length on this path. + * std140 layout specifies how to align data within an UBO structure. + * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159 + * for specs. */ - getPointAtLengthPosition(normalizedLengthPosition: number): Vector2; + private _fillAlignment(size); /** - * Returns a new Path2 starting at the coordinates (x, y). + * Adds an uniform in the buffer. + * Warning : the subsequents calls of this function must be in the same order as declared in the shader + * for the layout to be correct ! + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {number|number[]} size Data size, or data directly. */ - static StartingAt(x: number, y: number): Path2; - } - class Path3D { - path: Vector3[]; - private _curve; - private _distances; - private _tangents; - private _normals; - private _binormals; - private _raw; + addUniform(name: string, size: number | number[]): void; /** - * new Path3D(path, normal, raw) - * Creates a Path3D. A Path3D is a logical math object, so not a mesh. - * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D - * path : an array of Vector3, the curve axis of the Path3D - * normal (optional) : Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal. - * raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed. - */ - constructor(path: Vector3[], firstNormal?: Vector3, raw?: boolean); + * Wrapper for addUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {Matrix} mat A 4x4 matrix. + */ + addMatrix(name: string, mat: Matrix): void; /** - * Returns the Path3D array of successive Vector3 designing its curve. + * Wrapper for addUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {number} x + * @param {number} y */ - getCurve(): Vector3[]; + addFloat2(name: string, x: number, y: number): void; /** - * Returns an array populated with tangent vectors on each Path3D curve point. + * Wrapper for addUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {number} x + * @param {number} y + * @param {number} z */ - getTangents(): Vector3[]; + addFloat3(name: string, x: number, y: number, z: number): void; /** - * Returns an array populated with normal vectors on each Path3D curve point. + * Wrapper for addUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {Color3} color */ - getNormals(): Vector3[]; + addColor3(name: string, color: Color3): void; /** - * Returns an array populated with binormal vectors on each Path3D curve point. + * Wrapper for addUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {Color3} color + * @param {number} alpha */ - getBinormals(): Vector3[]; + addColor4(name: string, color: Color3, alpha: number): void; /** - * Returns an array populated with distances (float) of the i-th point from the first curve point. + * Wrapper for addUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {Vector3} vector */ - getDistances(): number[]; + addVector3(name: string, vector: Vector3): void; /** - * Forces the Path3D tangent, normal, binormal and distance recomputation. - * Returns the same object updated. + * Wrapper for addUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. */ - update(path: Vector3[], firstNormal?: Vector3): Path3D; - private _compute(firstNormal); - private _getFirstNonNullVector(index); - private _getLastNonNullVector(index); - private _normalVector(v0, vt, va); - } - class Curve3 { - private _points; - private _length; + addMatrix3x3(name: string): void; /** - * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve - * @param v0 (Vector3) the origin point of the Quadratic Bezier - * @param v1 (Vector3) the control point - * @param v2 (Vector3) the end point of the Quadratic Bezier - * @param nbPoints (integer) the wanted number of points in the curve + * Wrapper for addUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. */ - static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3; + addMatrix2x2(name: string): void; /** - * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve - * @param v0 (Vector3) the origin point of the Cubic Bezier - * @param v1 (Vector3) the first control point - * @param v2 (Vector3) the second control point - * @param v3 (Vector3) the end point of the Cubic Bezier - * @param nbPoints (integer) the wanted number of points in the curve + * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`. */ - static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3; + create(): void; /** - * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline - * @param p1 (Vector3) the origin point of the Hermite Spline - * @param t1 (Vector3) the tangent vector at the origin point - * @param p2 (Vector3) the end point of the Hermite Spline - * @param t2 (Vector3) the tangent vector at the end point - * @param nbPoints (integer) the wanted number of points in the curve + * Updates the WebGL Uniform Buffer on the GPU. + * If the `dynamic` flag is set to true, no cache comparison is done. + * Otherwise, the buffer will be updated only if the cache differs. */ - static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3; + update(): void; /** - * Returns a Curve3 object along a CatmullRom Spline curve : - * @param points (array of Vector3) the points the spline must pass through. At least, four points required. - * @param nbPoints (integer) the wanted number of points between each curve control points. + * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU. + * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader. + * @param {number[]|Float32Array} data Flattened data + * @param {number} size Size of the data. */ - static CreateCatmullRomSpline(points: Vector3[], nbPoints: number): Curve3; + updateUniform(uniformName: string, data: number[] | Float32Array, size: number): void; + private _updateMatrix3x3ForUniform(name, matrix); + private _updateMatrix3x3ForEffect(name, matrix); + private _updateMatrix2x2ForEffect(name, matrix); + private _updateMatrix2x2ForUniform(name, matrix); + private _updateFloatForEffect(name, x); + private _updateFloatForUniform(name, x); + private _updateFloat2ForEffect(name, x, y, suffix?); + private _updateFloat2ForUniform(name, x, y, suffix?); + private _updateFloat3ForEffect(name, x, y, z, suffix?); + private _updateFloat3ForUniform(name, x, y, z, suffix?); + private _updateFloat4ForEffect(name, x, y, z, w, suffix?); + private _updateFloat4ForUniform(name, x, y, z, w, suffix?); + private _updateMatrixForEffect(name, mat); + private _updateMatrixForUniform(name, mat); + private _updateVector3ForEffect(name, vector); + private _updateVector3ForUniform(name, vector); + private _updateVector4ForEffect(name, vector); + private _updateVector4ForUniform(name, vector); + private _updateColor3ForEffect(name, color, suffix?); + private _updateColor3ForUniform(name, color, suffix?); + private _updateColor4ForEffect(name, color, alpha, suffix?); + private _updateColor4ForUniform(name, color, alpha, suffix?); /** - * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space. - * A Curve3 is designed from a series of successive Vector3. - * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object + * Sets a sampler uniform on the effect. + * @param {string} name Name of the sampler. + * @param {Texture} texture */ - constructor(points: Vector3[]); + setTexture(name: string, texture: BaseTexture): void; /** - * Returns the Curve3 stored array of successive Vector3 + * Directly updates the value of the uniform in the cache AND on the GPU. + * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader. + * @param {number[]|Float32Array} data Flattened data */ - getPoints(): Vector3[]; + updateUniformDirectly(uniformName: string, data: number[] | Float32Array): void; /** - * Returns the computed length (float) of the curve. + * Binds this uniform buffer to an effect. + * @param {Effect} effect + * @param {string} name Name of the uniform block in the shader. */ - length(): number; + bindToEffect(effect: Effect, name: string): void; /** - * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB); - * This new Curve3 is built by translating and sticking the curveB at the end of the curveA. - * curveA and curveB keep unchanged. + * Disposes the uniform buffer. */ - continue(curve: Curve3): Curve3; - private _computeLength(path); - } - class PositionNormalVertex { - position: Vector3; - normal: Vector3; - constructor(position?: Vector3, normal?: Vector3); - clone(): PositionNormalVertex; - } - class PositionNormalTextureVertex { - position: Vector3; - normal: Vector3; - uv: Vector2; - constructor(position?: Vector3, normal?: Vector3, uv?: Vector2); - clone(): PositionNormalTextureVertex; - } - class Tmp { - static Color3: Color3[]; - static Vector2: Vector2[]; - static Vector3: Vector3[]; - static Vector4: Vector4[]; - static Quaternion: Quaternion[]; - static Matrix: Matrix[]; - } -} - -declare module BABYLON { - class SphericalPolynomial { - x: Vector3; - y: Vector3; - z: Vector3; - xx: Vector3; - yy: Vector3; - zz: Vector3; - xy: Vector3; - yz: Vector3; - zx: Vector3; - addAmbient(color: Color3): void; - static getSphericalPolynomialFromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial; - scale(scale: number): void; - } - class SphericalHarmonics { - L00: Vector3; - L1_1: Vector3; - L10: Vector3; - L11: Vector3; - L2_2: Vector3; - L2_1: Vector3; - L20: Vector3; - L21: Vector3; - L22: Vector3; - addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void; - scale(scale: number): void; - convertIncidentRadianceToIrradiance(): void; - convertIrradianceToLambertianRadiance(): void; - static getsphericalHarmonicsFromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics; + dispose(): void; } } @@ -13128,6 +13128,36 @@ declare module BABYLON { } } +declare module BABYLON { + class ReflectionProbe { + name: string; + private _scene; + private _renderTargetTexture; + private _projectionMatrix; + private _viewMatrix; + private _target; + private _add; + private _attachedMesh; + invertYAxis: boolean; + position: Vector3; + constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean); + samples: number; + refreshRate: number; + getScene(): Scene; + readonly cubeTexture: RenderTargetTexture; + readonly renderList: AbstractMesh[]; + attachToMesh(mesh: AbstractMesh): 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. + */ + setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void; + dispose(): void; + } +} + declare module BABYLON { class AnaglyphPostProcess extends PostProcess { private _passedProcess; @@ -13651,36 +13681,6 @@ declare module BABYLON { } } -declare module BABYLON { - class ReflectionProbe { - name: string; - private _scene; - private _renderTargetTexture; - private _projectionMatrix; - private _viewMatrix; - private _target; - private _add; - private _attachedMesh; - invertYAxis: boolean; - position: Vector3; - constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean); - samples: number; - refreshRate: number; - getScene(): Scene; - readonly cubeTexture: RenderTargetTexture; - readonly renderList: AbstractMesh[]; - attachToMesh(mesh: AbstractMesh): 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. - */ - setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void; - dispose(): void; - } -} - declare module BABYLON { class BoundingBoxRenderer { frontColor: Color3; @@ -15471,247 +15471,114 @@ declare module BABYLON { private _lastSecAccumulated; private _lastSecTime; private _lastSecValueCount; - } - /** - * Use this className as a decorator on a given class definition to add it a name and optionally its module. - * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name. - * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified - * @param name The name of the class, case should be preserved - * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved. - */ - function className(name: string, module?: string): (target: Object) => void; - /** - * An implementation of a loop for asynchronous functions. - */ - class AsyncLoop { - iterations: number; - private _fn; - private _successCallback; - index: number; - private _done; - /** - * Constroctor. - * @param iterations the number of iterations. - * @param _fn the function to run each iteration - * @param _successCallback the callback that will be called upon succesful execution - * @param offset starting offset. - */ - constructor(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number); - /** - * Execute the next iteration. Must be called after the last iteration was finished. - */ - executeNext(): void; - /** - * Break the loop and run the success callback. - */ - breakLoop(): void; - /** - * Helper function - */ - static Run(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number): AsyncLoop; - /** - * A for-loop that will run a given number of iterations synchronous and the rest async. - * @param iterations total number of iterations - * @param syncedIterations number of synchronous iterations in each async iteration. - * @param fn the function to call each iteration. - * @param callback a success call back that will be called when iterating stops. - * @param breakFunction a break condition (optional) - * @param timeout timeout settings for the setTimeout function. default - 0. - * @constructor - */ - static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): void; - } -} - -declare module BABYLON { - enum JoystickAxis { - X = 0, - Y = 1, - Z = 2, - } - class VirtualJoystick { - reverseLeftRight: boolean; - reverseUpDown: boolean; - deltaPosition: Vector3; - pressed: boolean; - private static _globalJoystickIndex; - private static vjCanvas; - private static vjCanvasContext; - private static vjCanvasWidth; - private static vjCanvasHeight; - private static halfWidth; - private static halfHeight; - private _action; - private _axisTargetedByLeftAndRight; - private _axisTargetedByUpAndDown; - private _joystickSensibility; - private _inversedSensibility; - private _rotationSpeed; - private _inverseRotationSpeed; - private _rotateOnAxisRelativeToMesh; - private _joystickPointerID; - private _joystickColor; - private _joystickPointerPos; - private _joystickPreviousPointerPos; - private _joystickPointerStartPos; - private _deltaJoystickVector; - private _leftJoystick; - private _joystickIndex; - private _touches; - private _onPointerDownHandlerRef; - private _onPointerMoveHandlerRef; - private _onPointerUpHandlerRef; - private _onPointerOutHandlerRef; - private _onResize; - constructor(leftJoystick?: boolean); - setJoystickSensibility(newJoystickSensibility: number): void; - private _onPointerDown(e); - private _onPointerMove(e); - private _onPointerUp(e); - /** - * Change the color of the virtual joystick - * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000") - */ - setJoystickColor(newColor: string): void; - setActionOnTouch(action: () => any): void; - setAxisForLeftRight(axis: JoystickAxis): void; - setAxisForUpDown(axis: JoystickAxis): void; - private _clearCanvas(); - private _drawVirtualJoystick(); - releaseCanvas(): void; - } -} - -declare module BABYLON { - class VRCameraMetrics { - hResolution: number; - vResolution: number; - hScreenSize: number; - vScreenSize: number; - vScreenCenter: number; - eyeToScreenDistance: number; - lensSeparationDistance: number; - interpupillaryDistance: number; - distortionK: number[]; - chromaAbCorrection: number[]; - postProcessScaleFactor: number; - lensCenterOffset: number; - compensateDistortion: boolean; - readonly aspectRatio: number; - readonly aspectRatioFov: number; - readonly leftHMatrix: Matrix; - readonly rightHMatrix: Matrix; - readonly leftPreViewMatrix: Matrix; - readonly rightPreViewMatrix: Matrix; - static GetDefault(): VRCameraMetrics; - } -} - -declare module BABYLON { - class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera { - constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics); - getClassName(): string; - } - class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera { - constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics); - getClassName(): string; - } - class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera { - constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics); - getClassName(): string; - } -} - -declare var HMDVRDevice: any; -declare var VRDisplay: any; -declare var VRFrameData: any; -declare module BABYLON { - /** - * This is a copy of VRPose. - * IMPORTANT!! The data is right-hand data. - * @export - * @interface DevicePose - */ - interface DevicePose { - readonly position?: Float32Array; - readonly linearVelocity?: Float32Array; - readonly linearAcceleration?: Float32Array; - readonly orientation?: Float32Array; - readonly angularVelocity?: Float32Array; - readonly angularAcceleration?: Float32Array; - } - interface PoseControlled { - position: Vector3; - rotationQuaternion: Quaternion; - devicePosition?: Vector3; - deviceRotationQuaternion: Quaternion; - rawPose: DevicePose; - deviceScaleFactor: number; - updateFromDevice(poseData: DevicePose): any; - } - interface WebVROptions { - trackPosition?: boolean; - positionScale?: number; - displayName?: string; - controllerMeshes?: boolean; - defaultLightningOnControllers?: boolean; - } - class WebVRFreeCamera extends FreeCamera implements PoseControlled { - private webVROptions; - _vrDevice: any; - rawPose: DevicePose; - private _vrEnabled; - private _specsVersion; - private _attached; - private _oldSize; - private _oldHardwareScaleFactor; - private _frameData; - private _quaternionCache; - private _positionOffset; - protected _descendants: Array; - devicePosition: Vector3; - deviceRotationQuaternion: any; - deviceScaleFactor: number; - controllers: Array; - nonVRControllers: Array; - private _onControllersAttached; - private _onNonVRControllerAttached; - rigParenting: boolean; - private _lightOnControllers; - constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions); - onControllersAttached: (controllers: Array) => void; - onNonVRControllerAttached: (controller: Gamepad) => void; - getControllerByName(name: string): WebVRController; - private _leftController; - readonly leftController: WebVRController; - private _rightController; - readonly rightController: WebVRController; - getForwardRay(length?: number): Ray; - _checkInputs(): void; - updateFromDevice(poseData: DevicePose): void; + } + /** + * Use this className as a decorator on a given class definition to add it a name and optionally its module. + * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name. + * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified + * @param name The name of the class, case should be preserved + * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved. + */ + function className(name: string, module?: string): (target: Object) => void; + /** + * An implementation of a loop for asynchronous functions. + */ + class AsyncLoop { + iterations: number; + private _fn; + private _successCallback; + index: number; + private _done; /** - * WebVR's attach control will start broadcasting frames to the device. - * Note that in certain browsers (chrome for example) this function must be called - * within a user-interaction callback. Example: - *
 scene.onPointerDown = function() { camera.attachControl(canvas); }
- * - * @param {HTMLElement} element - * @param {boolean} [noPreventDefault] - * - * @memberOf WebVRFreeCamera + * Constroctor. + * @param iterations the number of iterations. + * @param _fn the function to run each iteration + * @param _successCallback the callback that will be called upon succesful execution + * @param offset starting offset. */ - attachControl(element: HTMLElement, noPreventDefault?: boolean): void; - detachControl(element: HTMLElement): void; - getClassName(): string; - resetToCurrentRotation(): void; - _updateRigCameras(): void; + constructor(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number); /** - * This function is called by the two RIG cameras. - * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance) + * Execute the next iteration. Must be called after the last iteration was finished. */ - protected _getWebVRViewMatrix(): Matrix; - protected _getWebVRProjectionMatrix(): Matrix; - initControllers(): void; + executeNext(): void; + /** + * Break the loop and run the success callback. + */ + breakLoop(): void; + /** + * Helper function + */ + static Run(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number): AsyncLoop; + /** + * A for-loop that will run a given number of iterations synchronous and the rest async. + * @param iterations total number of iterations + * @param syncedIterations number of synchronous iterations in each async iteration. + * @param fn the function to call each iteration. + * @param callback a success call back that will be called when iterating stops. + * @param breakFunction a break condition (optional) + * @param timeout timeout settings for the setTimeout function. default - 0. + * @constructor + */ + static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): void; + } +} + +declare module BABYLON { + enum JoystickAxis { + X = 0, + Y = 1, + Z = 2, + } + class VirtualJoystick { + reverseLeftRight: boolean; + reverseUpDown: boolean; + deltaPosition: Vector3; + pressed: boolean; + private static _globalJoystickIndex; + private static vjCanvas; + private static vjCanvasContext; + private static vjCanvasWidth; + private static vjCanvasHeight; + private static halfWidth; + private static halfHeight; + private _action; + private _axisTargetedByLeftAndRight; + private _axisTargetedByUpAndDown; + private _joystickSensibility; + private _inversedSensibility; + private _rotationSpeed; + private _inverseRotationSpeed; + private _rotateOnAxisRelativeToMesh; + private _joystickPointerID; + private _joystickColor; + private _joystickPointerPos; + private _joystickPreviousPointerPos; + private _joystickPointerStartPos; + private _deltaJoystickVector; + private _leftJoystick; + private _joystickIndex; + private _touches; + private _onPointerDownHandlerRef; + private _onPointerMoveHandlerRef; + private _onPointerUpHandlerRef; + private _onPointerOutHandlerRef; + private _onResize; + constructor(leftJoystick?: boolean); + setJoystickSensibility(newJoystickSensibility: number): void; + private _onPointerDown(e); + private _onPointerMove(e); + private _onPointerUp(e); + /** + * Change the color of the virtual joystick + * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000") + */ + setJoystickColor(newColor: string): void; + setActionOnTouch(action: () => any): void; + setAxisForLeftRight(axis: JoystickAxis): void; + setAxisForUpDown(axis: JoystickAxis): void; + private _clearCanvas(); + private _drawVirtualJoystick(); + releaseCanvas(): void; } } @@ -15923,6 +15790,139 @@ declare module BABYLON { } } +declare module BABYLON { + class VRCameraMetrics { + hResolution: number; + vResolution: number; + hScreenSize: number; + vScreenSize: number; + vScreenCenter: number; + eyeToScreenDistance: number; + lensSeparationDistance: number; + interpupillaryDistance: number; + distortionK: number[]; + chromaAbCorrection: number[]; + postProcessScaleFactor: number; + lensCenterOffset: number; + compensateDistortion: boolean; + readonly aspectRatio: number; + readonly aspectRatioFov: number; + readonly leftHMatrix: Matrix; + readonly rightHMatrix: Matrix; + readonly leftPreViewMatrix: Matrix; + readonly rightPreViewMatrix: Matrix; + static GetDefault(): VRCameraMetrics; + } +} + +declare module BABYLON { + class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera { + constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics); + getClassName(): string; + } + class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera { + constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics); + getClassName(): string; + } + class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera { + constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics); + getClassName(): string; + } +} + +declare var HMDVRDevice: any; +declare var VRDisplay: any; +declare var VRFrameData: any; +declare module BABYLON { + /** + * This is a copy of VRPose. + * IMPORTANT!! The data is right-hand data. + * @export + * @interface DevicePose + */ + interface DevicePose { + readonly position?: Float32Array; + readonly linearVelocity?: Float32Array; + readonly linearAcceleration?: Float32Array; + readonly orientation?: Float32Array; + readonly angularVelocity?: Float32Array; + readonly angularAcceleration?: Float32Array; + } + interface PoseControlled { + position: Vector3; + rotationQuaternion: Quaternion; + devicePosition?: Vector3; + deviceRotationQuaternion: Quaternion; + rawPose: DevicePose; + deviceScaleFactor: number; + updateFromDevice(poseData: DevicePose): any; + } + interface WebVROptions { + trackPosition?: boolean; + positionScale?: number; + displayName?: string; + controllerMeshes?: boolean; + defaultLightningOnControllers?: boolean; + } + class WebVRFreeCamera extends FreeCamera implements PoseControlled { + private webVROptions; + _vrDevice: any; + rawPose: DevicePose; + private _vrEnabled; + private _specsVersion; + private _attached; + private _oldSize; + private _oldHardwareScaleFactor; + private _frameData; + private _quaternionCache; + private _positionOffset; + protected _descendants: Array; + devicePosition: Vector3; + deviceRotationQuaternion: any; + deviceScaleFactor: number; + controllers: Array; + nonVRControllers: Array; + private _onControllersAttached; + private _onNonVRControllerAttached; + rigParenting: boolean; + private _lightOnControllers; + constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions); + onControllersAttached: (controllers: Array) => void; + onNonVRControllerAttached: (controller: Gamepad) => void; + getControllerByName(name: string): WebVRController; + private _leftController; + readonly leftController: WebVRController; + private _rightController; + readonly rightController: WebVRController; + getForwardRay(length?: number): Ray; + _checkInputs(): void; + updateFromDevice(poseData: DevicePose): void; + /** + * WebVR's attach control will start broadcasting frames to the device. + * Note that in certain browsers (chrome for example) this function must be called + * within a user-interaction callback. Example: + *
 scene.onPointerDown = function() { camera.attachControl(canvas); }
+ * + * @param {HTMLElement} element + * @param {boolean} [noPreventDefault] + * + * @memberOf WebVRFreeCamera + */ + attachControl(element: HTMLElement, noPreventDefault?: boolean): void; + detachControl(element: HTMLElement): void; + getClassName(): string; + resetToCurrentRotation(): void; + _updateRigCameras(): void; + /** + * This function is called by the two RIG cameras. + * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance) + */ + protected _getWebVRViewMatrix(): Matrix; + protected _getWebVRProjectionMatrix(): Matrix; + initControllers(): void; + } +} + declare module BABYLON { interface IOctreeContainer { blocks: Array>; @@ -17509,6 +17509,7 @@ declare module BABYLON { private _cachedUAng; private _cachedVAng; private _cachedWAng; + private _cachedProjectionMatrixId; private _cachedCoordinatesMode; _samplingMode: number; private _buffer; diff --git a/dist/preview release/customConfigurations/minimalGLTFViewer/babylon.js b/dist/preview release/customConfigurations/minimalGLTFViewer/babylon.js index ca45f9d7bba..a1d99a315ec 100644 --- a/dist/preview release/customConfigurations/minimalGLTFViewer/babylon.js +++ b/dist/preview release/customConfigurations/minimalGLTFViewer/babylon.js @@ -9,22 +9,22 @@ o._diffPositionForCollisions=new e.Vector3(0,0,0),o._newPositionForCollisions=ne return function(){return new e.StereoscopicArcRotateCamera(r,0,0,1,e.Vector3.Zero(),n,o,i)};case"StereoscopicFreeCamera":return function(){return new e.StereoscopicFreeCamera(r,e.Vector3.Zero(),n,o,i)};case"StereoscopicGamepadCamera":return function(){return new e.StereoscopicGamepadCamera(r,e.Vector3.Zero(),n,o,i)};case"StereoscopicUniversalCamera":return function(){return new e.StereoscopicUniversalCamera(r,e.Vector3.Zero(),n,o,i)};case"FreeCamera":default:return function(){return new e.UniversalCamera(r,e.Vector3.Zero(),i)}}},r.Parse=function(t,i){var n=t.type,o=r.GetConstructorFromName(n,t.name,i,t.interaxial_distance,t.isStereoscopicSideBySide),s=e.SerializationHelper.Parse(o,t,i);if(t.parentId&&(s._waitingParentId=t.parentId),s.inputs&&(s.inputs.parse(t),s._setupInputs()),s.setPosition&&(s.position.copyFromFloats(0,0,0),s.setPosition(e.Vector3.FromArray(t.position))),t.target&&s.setTarget&&s.setTarget(e.Vector3.FromArray(t.target)),t.cameraRigMode){var a=t.interaxial_distance?{interaxialDistance:t.interaxial_distance}:{};s.setCameraRigMode(t.cameraRigMode,a)}if(t.animations){for(var u=0;ur._alphaIndex?1:e._alphaIndext._distanceToCamera?-1:0},t.frontToBackSortCompare=function(e,t){return e._distanceToCamerat._distanceToCamera?1:0},t.prototype.prepare=function(){this._opaqueSubMeshes.reset(),this._transparentSubMeshes.reset(),this._alphaTestSubMeshes.reset(),this._particleSystems.reset(),this._spriteManagers.reset(),this._edgesRenderers.reset()},t.prototype.dispose=function(){this._opaqueSubMeshes.dispose(),this._transparentSubMeshes.dispose(),this._alphaTestSubMeshes.dispose(),this._particleSystems.dispose(),this._spriteManagers.dispose(),this._edgesRenderers.dispose()},t.prototype.dispatch=function(e){var t=e.getMaterial(),r=e.getMesh();t.needAlphaBlending()||r.visibility<1||r.hasVertexAlpha?this._transparentSubMeshes.push(e):t.needAlphaTesting()?this._alphaTestSubMeshes.push(e):this._opaqueSubMeshes.push(e),r._edgesRenderer&&this._edgesRenderers.push(r._edgesRenderer)},t.prototype.dispatchSprites=function(e){this._spriteManagers.push(e)},t.prototype.dispatchParticles=function(e){this._particleSystems.push(e)},t.prototype._renderParticles=function(e){if(0!==this._particleSystems.length){var t=this._scene.activeCamera;this._scene._particlesDuration.beginMonitoring();for(var r=0;ri.DoubleClickDelay&&!l._doubleClickOccured||e!==l._previousButtonPressed)&&(l._doubleClickOccured=!1,t.singleClick=!0,t.ignore=!1,r(t,l._currentPickResult))},this._initClickEvent=function(n,o,s,a){var u=new t;l._currentPickResult=null;var c,h=n.hasSpecificMask(r.POINTERPICK)||o.hasSpecificMask(r.POINTERPICK)||n.hasSpecificMask(r.POINTERTAP)||o.hasSpecificMask(r.POINTERTAP)||n.hasSpecificMask(r.POINTERDOUBLETAP)||o.hasSpecificMask(r.POINTERDOUBLETAP);if(!h&&e.ActionManager&&e.ActionManager.HasPickTriggers&&(c=l._initActionManager(c,u))&&(h=c.hasPickTriggers),h){var f=s.button;if(u.hasSwiped=Math.abs(l._startingPointerPosition.x-l._pointerX)>i.DragMovementThreshold||Math.abs(l._startingPointerPosition.y-l._pointerY)>i.DragMovementThreshold,!u.hasSwiped){var d=!i.ExclusiveDoubleClickMode;d||(d=!n.hasSpecificMask(r.POINTERDOUBLETAP)&&!o.hasSpecificMask(r.POINTERDOUBLETAP))&&!e.ActionManager.HasSpecificTrigger(e.ActionManager.OnDoublePickTrigger)&&(c=l._initActionManager(c,u))&&(d=!c.hasSpecificTrigger(e.ActionManager.OnDoublePickTrigger)),d?((new Date).getTime()-l._previousStartingPointerTime>i.DoubleClickDelay||f!==l._previousButtonPressed)&&(u.singleClick=!0,a(u,l._currentPickResult)):(l._previousDelayedSimpleClickTimeout=l._delayedSimpleClickTimeout,l._delayedSimpleClickTimeout=window.setTimeout(l._delayedSimpleClick.bind(l,f,u,a),i.DoubleClickDelay));var p=n.hasSpecificMask(r.POINTERDOUBLETAP)||o.hasSpecificMask(r.POINTERDOUBLETAP);!p&&e.ActionManager.HasSpecificTrigger(e.ActionManager.OnDoublePickTrigger)&&(c=l._initActionManager(c,u))&&(p=c.hasSpecificTrigger(e.ActionManager.OnDoublePickTrigger)),p&&(f===l._previousButtonPressed&&(new Date).getTime()-l._previousStartingPointerTimei.LongPressDelay&&Math.abs(this._startingPointerPosition.x-this._pointerX)0&&(u=l.pickSprite(l._unTranslatedPointerX,l._unTranslatedPointerY,c,!1,l.cameraToUseForPointers))&&u.hit&&u.pickedSprite&&u.pickedSprite.actionManager){switch(l._pickedDownSprite=u.pickedSprite,t.button){case 0:u.pickedSprite.actionManager.processTrigger(e.ActionManager.OnLeftPickTrigger,e.ActionEvent.CreateNewFromSprite(u.pickedSprite,l,t));break;case 1:u.pickedSprite.actionManager.processTrigger(e.ActionManager.OnCenterPickTrigger,e.ActionEvent.CreateNewFromSprite(u.pickedSprite,l,t));break;case 2:u.pickedSprite.actionManager.processTrigger(e.ActionManager.OnRightPickTrigger,e.ActionEvent.CreateNewFromSprite(u.pickedSprite,l,t))}u.pickedSprite.actionManager&&u.pickedSprite.actionManager.processTrigger(e.ActionManager.OnPickDownTrigger,e.ActionEvent.CreateNewFromSprite(u.pickedSprite,l,t))}}},this._onPointerUp=function(t){l._isButtonPressed=!1,l._pickedUpMesh=null,l._meshPickProceed=!1,l._updatePointerPosition(t),l._initClickEvent(l.onPrePointerObservable,l.onPointerObservable,t,function(s,a){if(this.onPrePointerObservable.hasObservers())if(s.ignore){var u=r.POINTERUP,l=new n(u,t,this._unTranslatedPointerX,this._unTranslatedPointerY);if(this.onPrePointerObservable.notifyObservers(l,u),l.skipOnPointerObservable)return}else if(!s.hasSwiped){if(s.singleClick&&this.onPrePointerObservable.hasSpecificMask(r.POINTERTAP)){var u=r.POINTERTAP,l=new n(u,t,this._unTranslatedPointerX,this._unTranslatedPointerY);if(this.onPrePointerObservable.notifyObservers(l,u),l.skipOnPointerObservable)return}if(s.doubleClick&&this.onPrePointerObservable.hasSpecificMask(r.POINTERDOUBLETAP)){var u=r.POINTERDOUBLETAP,l=new n(u,t,this._unTranslatedPointerX,this._unTranslatedPointerY);if(this.onPrePointerObservable.notifyObservers(l,u),l.skipOnPointerObservable)return}}if(this.cameraToUseForPointers||this.activeCamera){if(this.pointerUpPredicate||(this.pointerUpPredicate=function(e){return e.isPickable&&e.isVisible&&e.isReady()&&e.isEnabled()}),!this._meshPickProceed&&(e.ActionManager&&e.ActionManager.HasTriggers||this.onPointerObservable.hasObservers())&&this._initActionManager(null,s),a||(a=this._currentPickResult),a&&a&&a.pickedMesh){if(this._pickedUpMesh=a.pickedMesh,this._pickedDownMesh===this._pickedUpMesh&&(this.onPointerPick&&this.onPointerPick(t,a),s.singleClick&&!s.ignore&&this.onPointerObservable.hasObservers())){var u=r.POINTERPICK,l=new o(u,t,a);this.onPointerObservable.notifyObservers(l,u)}a.pickedMesh.actionManager&&(s.ignore&&a.pickedMesh.actionManager.processTrigger(e.ActionManager.OnPickUpTrigger,e.ActionEvent.CreateNew(a.pickedMesh,t)),s.hasSwiped||s.ignore||!s.singleClick||a.pickedMesh.actionManager.processTrigger(e.ActionManager.OnPickTrigger,e.ActionEvent.CreateNew(a.pickedMesh,t)),s.doubleClick&&!s.ignore&&a.pickedMesh.actionManager.hasSpecificTrigger(e.ActionManager.OnDoublePickTrigger)&&a.pickedMesh.actionManager.processTrigger(e.ActionManager.OnDoublePickTrigger,e.ActionEvent.CreateNew(a.pickedMesh,t)))}if(this._pickedDownMesh&&this._pickedDownMesh.actionManager&&this._pickedDownMesh.actionManager.hasSpecificTrigger(e.ActionManager.OnPickOutTrigger)&&this._pickedDownMesh!==this._pickedUpMesh&&this._pickedDownMesh.actionManager.processTrigger(e.ActionManager.OnPickOutTrigger,e.ActionEvent.CreateNew(this._pickedDownMesh,t)),this.onPointerUp&&this.onPointerUp(t,a),this.onPointerObservable.hasObservers())if(s.ignore){var u=r.POINTERUP,l=new o(u,t,a);this.onPointerObservable.notifyObservers(l,u)}else if(!s.hasSwiped){if(s.singleClick&&this.onPointerObservable.hasSpecificMask(r.POINTERTAP)){var u=r.POINTERTAP,l=new o(u,t,a);this.onPointerObservable.notifyObservers(l,u)}if(s.doubleClick&&this.onPointerObservable.hasSpecificMask(r.POINTERDOUBLETAP)){var u=r.POINTERDOUBLETAP,l=new o(u,t,a);this.onPointerObservable.notifyObservers(l,u)}}this.spriteManagers.length>0&&(a=this.pickSprite(this._unTranslatedPointerX,this._unTranslatedPointerY,c,!1,this.cameraToUseForPointers),a.hit&&a.pickedSprite&&a.pickedSprite.actionManager&&(a.pickedSprite.actionManager.processTrigger(e.ActionManager.OnPickUpTrigger,e.ActionEvent.CreateNewFromSprite(a.pickedSprite,this,t)),a.pickedSprite.actionManager&&Math.abs(this._startingPointerPosition.x-this._pointerX)0)return!1;var t;for(t=0;ti&&o>0&&(o*=-1),this.stopAnimation(t),a||(a=new e.Animatable(this,t,r,i,n,o,s)),t.animations&&a.appendAnimations(t,t.animations),t.getAnimatables)for(var u=t.getAnimatables(),l=0;l0)return;this._animationTimeLast=t}var r=(t-this._animationTimeLast)*this.animationTimeScale;this._animationTime+=r,this._animationTimeLast=t;for(var i=0;i0?this.activeCamera=this.cameras[0]:this.activeCamera=null),this.onCameraRemovedObservable.notifyObservers(e),t},i.prototype.addLight=function(e){e.uniqueId=this.getUniqueId(),this.lights.push(e),this.sortLightsByPriority(),this.onNewLightAddedObservable.notifyObservers(e)},i.prototype.sortLightsByPriority=function(){this.requireLightSorting&&this.lights.sort(e.Light.compareLightsPriority)},i.prototype.addCamera=function(e){e.uniqueId=this.getUniqueId();this.cameras.push(e);this.onNewCameraAddedObservable.notifyObservers(e)},i.prototype.switchActiveCamera=function(e,t){void 0===t&&(t=!0);var r=this._engine.getRenderingCanvas();this.activeCamera.detachControl(r),this.activeCamera=e,t&&e.attachControl(r)},i.prototype.setActiveCameraByID=function(e){var t=this.getCameraByID(e);return t?(this.activeCamera=t,t):null},i.prototype.setActiveCameraByName=function(e){var t=this.getCameraByName(e);return t?(this.activeCamera=t,t):null},i.prototype.getMaterialByID=function(e){for(var t=0;t-1&&(this._geometries.splice(t,1),this.collisionCoordinator&&this.collisionCoordinator.onGeometryDeleted(e),this.onGeometryRemovedObservable.notifyObservers(e),!0)},i.prototype.getGeometries=function(){return this._geometries},i.prototype.getMeshByID=function(e){for(var t=0;t=0;t--)if(this.meshes[t].id===e)return this.meshes[t];return null},i.prototype.getLastEntryByID=function(e){var t;for(t=this.meshes.length-1;t>=0;t--)if(this.meshes[t].id===e)return this.meshes[t];for(t=this.cameras.length-1;t>=0;t--)if(this.cameras[t].id===e)return this.cameras[t];for(t=this.lights.length-1;t>=0;t--)if(this.lights[t].id===e)return this.lights[t];return null},i.prototype.getNodeByID=function(e){var t=this.getMeshByID(e);if(t)return t;var r=this.getLightByID(e);if(r)return r;var i=this.getCameraByID(e);return i||this.getBoneByID(e)},i.prototype.getNodeByName=function(e){var t=this.getMeshByName(e);if(t)return t;var r=this.getLightByName(e);if(r)return r;var i=this.getCameraByName(e);return i||this.getBoneByName(e)},i.prototype.getMeshByName=function(e){for(var t=0;t=0;t--)if(this.skeletons[t].id===e)return this.skeletons[t];return null},i.prototype.getSkeletonById=function(e){for(var t=0;t0&&0!=(o.layerMask&this.activeCamera.layerMask)&&o.isInFrustum(this._frustumPlanes))&&(this._activeMeshes.push(o),this.activeCamera._activeMeshes.push(o),o._activate(this._renderId),this._activeMesh(o,s)))}}this._particlesDuration.beginMonitoring();e.Tools.Now;if(this.particlesEnabled){e.Tools.StartPerformanceCounter("Particles",this.particleSystems.length>0);for(var a=0;a0)}this._particlesDuration.endMonitoring(!1)},i.prototype._activeMesh=function(e,t){if(t.skeleton&&this.skeletonsEnabled&&(this._activeSkeletons.pushNoDuplicate(t.skeleton)&&t.skeleton.prepare(),t.computeBonesUsingShaders||this._softwareSkinnedMeshes.pushNoDuplicate(t)),(e.showBoundingBox||this.forceShowBoundingBoxes)&&this.getBoundingBoxRenderer().renderList.push(e.getBoundingInfo().boundingBox),t&&t.subMeshes){var r,i;if(t._submeshesOctree&&t.useOctreeForRenderingSelection){var n=t._submeshesOctree.select(this._frustumPlanes);r=n.length,i=n.data}else i=t.subMeshes,r=i.length;for(var o=0;o0&&this._renderTargets.concatWithNoDuplicate(t.customRenderTargets),this.renderTargetsEnabled&&this._renderTargets.length>0){this._intermediateRendering=!0,e.Tools.StartPerformanceCounter("Render targets",this._renderTargets.length>0);for(var s=0;s0),this._intermediateRendering=!1,this._renderId++,o=!0}var l=this._engine.getStencilBuffer(),c=!1;if(this.renderTargetsEnabled&&this.highlightLayers&&this.highlightLayers.length>0){this._intermediateRendering=!0;for(var h=0;h-1)){c=!0;var a=f._mainTexture;a._shouldRender()&&(this._renderId++,a.render(!1,!1),o=!0)}}this._intermediateRendering=!1,this._renderId++}o&&r.restoreDefaultFramebuffer(),this._renderTargetsDuration.endMonitoring(!1),this.postProcessManager._prepareFrame(),this._renderDuration.beginMonitoring();var d,p;if(this.layers.length){for(r.setDepthBuffer(!1),d=0;d0);for(var g=0;g0)}if(this.layers.length){for(r.setDepthBuffer(!1),d=0;d-1&&(n.trigger===e.ActionManager.OnIntersectionExitTrigger&&n._executeCurrent(e.ActionEvent.CreateNew(r,null,s)),r.actionManager.hasSpecificTrigger(e.ActionManager.OnIntersectionExitTrigger)&&n.trigger!==e.ActionManager.OnIntersectionExitTrigger||r._intersectionsInProgress.splice(u,1))}}},i.prototype.render=function(){if(!this.isDisposed){this._lastFrameDuration.beginMonitoring(),this._particlesDuration.fetchNewFrame(),this._spritesDuration.fetchNewFrame(),this._activeParticles.fetchNewFrame(),this._renderDuration.fetchNewFrame(),this._renderTargetsDuration.fetchNewFrame(),this._evaluateActiveMeshesDuration.fetchNewFrame(),this._totalVertices.fetchNewFrame(),this._activeIndices.fetchNewFrame(),this._activeBones.fetchNewFrame(),this.getEngine().drawCallsPerfCounter.fetchNewFrame(),this._meshesForIntersections.reset(),this.resetCachedMaterial(),e.Tools.StartPerformanceCounter("Scene rendering"),this.actionManager&&this.actionManager.processTrigger(e.ActionManager.OnEveryFrameTrigger,null),this.simplificationQueue&&!this.simplificationQueue.running&&this.simplificationQueue.executeNext();var t=Math.max(i.MinDeltaTime,Math.min(this._engine.getDeltaTime(),i.MaxDeltaTime));this._animationRatio=.06*t,this._animate(),this._physicsEngine&&(e.Tools.StartPerformanceCounter("Physics"),this._physicsEngine._step(t/1e3),e.Tools.EndPerformanceCounter("Physics")),this.onBeforeRenderObservable.notifyObservers(this),this._renderTargetsDuration.beginMonitoring();var r=(e.Tools.Now,this.getEngine()),n=this.activeCamera;if(this.renderTargetsEnabled){e.Tools.StartPerformanceCounter("Custom render targets",this.customRenderTargets.length>0);for(var o=0;o0),this._renderId++}if(this.customRenderTargets.length>0&&r.restoreDefaultFramebuffer(),this._renderTargetsDuration.endMonitoring(),this.activeCamera=n,this.proceduralTexturesEnabled){e.Tools.StartPerformanceCounter("Procedural textures",this._proceduralTextures.length>0);for(var a=0;a0)} if((this.autoClearDepthAndStencil||this.autoClear)&&this._engine.clear(this.clearColor,this.autoClear||this.forceWireframe||this.forcePointsCloud,this.autoClearDepthAndStencil,this.autoClearDepthAndStencil),this.shadowsEnabled)for(var l=0;l0)for(var d=0;d0&&this._engine.clear(null,!1,!0,!0),this._processSubCameras(this.activeCameras[d]);else{if(!this.activeCamera)throw new Error("No camera defined");this._processSubCameras(this.activeCamera)}this._checkIntersections(),e.AudioEngine&&this._updateAudioParameters(),this.afterRender&&this.afterRender(),this.onAfterRenderObservable.notifyObservers(this);for(var p=0;p0?this.activeCameras[0]:this.activeCamera)&&r.canUseWebAudio){r.audioContext.listener.setPosition(t.position.x,t.position.y,t.position.z),t.rigCameras&&t.rigCameras.length>0&&(t=t.rigCameras[0]);var i=e.Matrix.Invert(t.getViewMatrix()),n=e.Vector3.TransformNormal(new e.Vector3(0,0,-1),i);n.normalize(),isNaN(n.x)||isNaN(n.y)||isNaN(n.z)||r.audioContext.listener.setOrientation(n.x,n.y,n.z,0,1,0);var o;for(o=0;o-1&&this._engine.scenes.splice(t,1),this._engine.wipeCaches(),this._engine=null,this.defaultMaterial=null,this.multiMaterials=null,this.materials=null},Object.defineProperty(i.prototype,"isDisposed",{get:function(){return!this._engine},enumerable:!0,configurable:!0}),i.prototype.disposeSounds=function(){this.mainSoundTrack.dispose();for(var e=0;e=n.distance))&&(n=l,i)))break}return n||new e.PickingInfo},i.prototype._internalMultiPick=function(t,r){if(!e.PickingInfo)return null;for(var i=new Array,n=0;n0)for(var s=0;s=o.distance))&&(o=u,i))break}}return o||new e.PickingInfo},i.prototype.pick=function(e,t,r,i,n){var o=this;return this._internalPick((function(r){return o.createPickingRay(e,t,r,n)}),r,i)},i.prototype.pickSprite=function(e,t,r,i,n){return this._internalPickSprites(this.createPickingRayInCameraSpace(e,t,n),r,i,n)},i.prototype.pickWithRay=function(t,r,i){var n=this;return this._internalPick((function(r){return n._pickWithRayInverseMatrix||(n._pickWithRayInverseMatrix=e.Matrix.Identity()),r.invertToRef(n._pickWithRayInverseMatrix),e.Ray.Transform(t,n._pickWithRayInverseMatrix)}),r,i)},i.prototype.multiPick=function(e,t,r,i){var n=this;return this._internalMultiPick((function(r){return n.createPickingRay(e,t,r,i)}),r)},i.prototype.multiPickWithRay=function(t,r){var i=this;return this._internalMultiPick((function(r){return i._pickWithRayInverseMatrix||(i._pickWithRayInverseMatrix=e.Matrix.Identity()),r.invertToRef(i._pickWithRayInverseMatrix),e.Ray.Transform(t,i._pickWithRayInverseMatrix)}),r)},i.prototype.setPointerOverMesh=function(t){this._pointerOverMesh!==t&&(this._pointerOverMesh&&this._pointerOverMesh.actionManager&&this._pointerOverMesh.actionManager.processTrigger(e.ActionManager.OnPointerOutTrigger,e.ActionEvent.CreateNew(this._pointerOverMesh)),this._pointerOverMesh=t,this._pointerOverMesh&&this._pointerOverMesh.actionManager&&this._pointerOverMesh.actionManager.processTrigger(e.ActionManager.OnPointerOverTrigger,e.ActionEvent.CreateNew(this._pointerOverMesh)))},i.prototype.getPointerOverMesh=function(){return this._pointerOverMesh},i.prototype.setPointerOverSprite=function(t){this._pointerOverSprite!==t&&(this._pointerOverSprite&&this._pointerOverSprite.actionManager&&this._pointerOverSprite.actionManager.processTrigger(e.ActionManager.OnPointerOutTrigger,e.ActionEvent.CreateNewFromSprite(this._pointerOverSprite,this)),this._pointerOverSprite=t,this._pointerOverSprite&&this._pointerOverSprite.actionManager&&this._pointerOverSprite.actionManager.processTrigger(e.ActionManager.OnPointerOverTrigger,e.ActionEvent.CreateNewFromSprite(this._pointerOverSprite,this)))},i.prototype.getPointerOverSprite=function(){return this._pointerOverSprite},i.prototype.getPhysicsEngine=function(){return this._physicsEngine},i.prototype.enablePhysics=function(t,r){if(this._physicsEngine)return!0;try{return this._physicsEngine=new e.PhysicsEngine(t,r),!0}catch(t){return e.Tools.Error(t.message),!1}},i.prototype.disablePhysicsEngine=function(){this._physicsEngine&&(this._physicsEngine.dispose(),this._physicsEngine=void 0)},i.prototype.isPhysicsEnabled=function(){return void 0!==this._physicsEngine},i.prototype.deleteCompoundImpostor=function(e){var t=e.parts[0].mesh;t.physicsImpostor.dispose(),t.physicsImpostor=null},i.prototype.createDefaultCameraOrLight=function(t,r,i){if(void 0===t&&(t=!1),void 0===r&&(r=!1),void 0===i&&(i=!1),r&&(this.activeCamera&&(this.activeCamera.dispose(),this.activeCamera=null),this.lights))for(var n=0;n=0&&this._scene.textures.splice(e,1),void 0!==this._texture&&(this.releaseInternalTexture(),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear())},t.prototype.serialize=function(){if(!this.name)return null;var t=e.SerializationHelper.Serialize(this);return e.Animation.AppendSerializedAnimations(this,t),t},t.WhenAllReady=function(e,t){var r=e.length;if(0===r)return void t();for(var i,n,o=0;o0},enumerable:!0,configurable:!0}),i.prototype._sortLODLevels=function(){this._LODLevels.sort((function(e,t){return e.distancet.distance?-1:0}))},i.prototype.addLODLevel=function(t,r){if(r&&r._masterMesh)return e.Tools.Warn("You cannot use a mesh as LOD level twice"),this;var i=new e.Internals.MeshLODLevel(t,r);return this._LODLevels.push(i),r&&(r._masterMesh=this),this._sortLODLevels(),this},i.prototype.getLODLevelAtDistance=function(e){for(var t=0;tr)return this.onLODLevelSelection&&this.onLODLevelSelection(r,this,this._LODLevels[this._LODLevels.length-1].mesh),this;for(var i=0;i0){var i=this.getIndices().length,n=!1;if(t)n=!0;else for(var o=0,s=this.subMeshes;o=i){n=!0;break}if(a.verticesStart+a.verticesCount>=r){n=!0;break}}if(!n)return}return this.releaseSubMeshes(),new e.SubMesh(0,0,r,0,this.getTotalIndices(),this)},i.prototype.subdivide=function(t){if(!(t<1)){for(var r=this.getTotalIndices(),i=r/t|0,n=0;i%3!=0;)i++;this.releaseSubMeshes();for(var o=0;o=r);o++)e.SubMesh.CreateFromIndices(0,n,Math.min(i,r-n),this),n+=i;this.synchronizeInstances()}},i.prototype.setVerticesData=function(t,r,i,n){if(this._geometry)this._geometry.setVerticesData(t,r,i,n);else{var o=new e.VertexData;o.set(r,t);var s=this.getScene();new e.Geometry(e.Geometry.RandomId(),s,o,i,this)}return this},i.prototype.markVerticesDataAsUpdatable=function(e,t){void 0===t&&(t=!0),this.getVertexBuffer(e).isUpdatable()!==t&&this.setVerticesData(e,this.getVerticesData(e),t)},i.prototype.setVerticesBuffer=function(t){if(!this._geometry){var r=this.getScene();new e.Geometry(e.Geometry.RandomId(),r).applyToMesh(this)}return this._geometry.setVerticesBuffer(t),this},i.prototype.updateVerticesData=function(e,t,r,i){if(this._geometry)return i?(this.makeGeometryUnique(),this.updateVerticesData(e,t,r,!1)):this._geometry.updateVerticesData(e,t,r),this},i.prototype.updateMeshPositions=function(t,r){void 0===r&&(r=!0);var i=this.getVerticesData(e.VertexBuffer.PositionKind);if(t(i),this.updateVerticesData(e.VertexBuffer.PositionKind,i,!1,!1),r){var n=this.getIndices(),o=this.getVerticesData(e.VertexBuffer.NormalKind);e.VertexData.ComputeNormals(i,n,o),this.updateVerticesData(e.VertexBuffer.NormalKind,o,!1,!1)}return this},i.prototype.makeGeometryUnique=function(){if(this._geometry){var t=this._geometry,r=this._geometry.copy(e.Geometry.RandomId());return t.releaseForMesh(this,!0),r.applyToMesh(this),this}},i.prototype.setIndices=function(t,r){if(this._geometry)this._geometry.setIndices(t,r);else{var i=new e.VertexData;i.indices=t;var n=this.getScene();new e.Geometry(e.Geometry.RandomId(),n,i,!1,this)}return this},i.prototype.toLeftHanded=function(){if(this._geometry)return this._geometry.toLeftHanded(),this},i.prototype._bind=function(t,r,i){var n,o=this.getScene().getEngine();if(this._unIndexed)n=null;else switch(i){case e.Material.PointFillMode:n=null;break;case e.Material.WireFrameFillMode:n=t.getLinesIndexBuffer(this.getIndices(),o);break;default:case e.Material.TriangleFillMode:n=this._unIndexed?null:this._geometry.getIndexBuffer()}return this._geometry._bind(r,n),this},i.prototype._draw=function(t,r,i){if(!this._geometry||!this._geometry.getVertexBuffers()||!this._geometry.getIndexBuffer())return this;this.onBeforeDrawObservable.notifyObservers(this);var n=this.getScene().getEngine();switch(r){case e.Material.PointFillMode:n.drawPointClouds(t.verticesStart,t.verticesCount,i);break;case e.Material.WireFrameFillMode:this._unIndexed?n.drawUnIndexed(!1,t.verticesStart,t.verticesCount,i):n.draw(!1,0,i>0?t.linesIndexCount/2:t.linesIndexCount,i);break;default:this._unIndexed?n.drawUnIndexed(!0,t.verticesStart,t.verticesCount,i):n.draw(!0,t.indexStart,t.indexCount,i)}return this},i.prototype.registerBeforeRender=function(e){return this.onBeforeRenderObservable.add(e),this},i.prototype.unregisterBeforeRender=function(e){return this.onBeforeRenderObservable.removeCallback(e),this},i.prototype.registerAfterRender=function(e){return this.onAfterRenderObservable.add(e),this},i.prototype.unregisterAfterRender=function(e){return this.onAfterRenderObservable.removeCallback(e),this},i.prototype._getInstancesRenderList=function(e){var t=this.getScene();if(this._batchCache.mustReturn=!1,this._batchCache.renderSelf[e]=this.isEnabled()&&this.isVisible,this._batchCache.visibleInstances[e]=null,this._visibleInstances){var r=t.getRenderId(),i=t._isInIntermediateRendering()?this._visibleInstances.intermediateDefaultRenderId:this._visibleInstances.defaultRenderId;this._batchCache.visibleInstances[e]=this._visibleInstances[r];var n=this._renderId;if(!this._batchCache.visibleInstances[e]&&i&&(this._batchCache.visibleInstances[e]=this._visibleInstances[i],r=Math.max(i,r),n=Math.max(this._visibleInstances.selfDefaultRenderId,r)),this._batchCache.visibleInstances[e]&&this._batchCache.visibleInstances[e].length){if(this._renderIdForInstances[e]===r)return this._batchCache.mustReturn=!0,this._batchCache;r!==n&&(this._batchCache.renderSelf[e]=!1)}this._renderIdForInstances[e]=r}return this._batchCache},i.prototype._renderWithInstances=function(t,r,i,n,o){for(var s=i.visibleInstances[t._id],a=s.length+1,u=16*a*4,l=this._instancesBufferSize,c=this._instancesBuffer;this._instancesBufferSize-1;t--)if(r[t].id===e)return this.material=r[t],this;var i=this.getScene().multiMaterials;for(t=i.length-1;t>-1;t--)if(i[t].id===e)return this.material=i[t],this;return this},i.prototype.getAnimatables=function(){var e=[];return this.material&&e.push(this.material),this.skeleton&&e.push(this.skeleton),e},i.prototype.bakeTransformIntoVertices=function(t){if(!this.isVerticesDataPresent(e.VertexBuffer.PositionKind))return this;var r=this.subMeshes.splice(0);this._resetPointsArrayCache();var i,n=this.getVerticesData(e.VertexBuffer.PositionKind),o=[];for(i=0;i-1&&(o.morphTargetManager=r.getMorphTargetManagerById(t.morphTargetManagerId)),t.skeletonId>-1&&(o.skeleton=r.getLastSkeletonByID(t.skeletonId),t.numBoneInfluencers&&(o.numBoneInfluencers=t.numBoneInfluencers)),t.animations){for(var s=0;s4,l=u?this.getVerticesData(e.VertexBuffer.MatricesIndicesExtraKind):null,c=u?this.getVerticesData(e.VertexBuffer.MatricesWeightsExtraKind):null,h=t.getTransformMatrices(this),f=e.Vector3.Zero(),d=new e.Matrix,p=new e.Matrix,g=0,_=0;_0;o++)e.Matrix.FromFloat32ArrayToRefScaled(h,16*s[g+o],m,p),d.addToSelf(p);if(u)for(o=0;o<4&&(m=c[g+o])>0;o++)e.Matrix.FromFloat32ArrayToRefScaled(h,16*l[g+o],m,p),d.addToSelf(p);e.Vector3.TransformCoordinatesFromFloatsToRef(this._sourcePositions[_],this._sourcePositions[_+1],this._sourcePositions[_+2],d,f),f.toArray(i,_),e.Vector3.TransformNormalFromFloatsToRef(this._sourceNormals[_],this._sourceNormals[_+1],this._sourceNormals[_+2],d,f),f.toArray(n,_),d.reset()}return this.updateVerticesData(e.VertexBuffer.PositionKind,i),this.updateVerticesData(e.VertexBuffer.NormalKind,n),this},i.MinMax=function(e){var t=null,r=null;return e.forEach((function(e,i,n){var o=e.getBoundingInfo().boundingBox;t?(t.MinimizeInPlace(o.minimumWorld),r.MaximizeInPlace(o.maximumWorld)):(t=o.minimumWorld,r=o.maximumWorld)})),{min:t,max:r}},i.Center=function(t){var r=t instanceof Array?e.Mesh.MinMax(t):t;return e.Vector3.Center(r.min,r.max)},i.MergeMeshes=function(t,r,n,o,s){void 0===r&&(r=!0);var a;if(!n){var u=0;for(a=0;a65536)return e.Tools.Warn("Cannot merge meshes because resulting mesh will have more than 65536 vertices. Please use allow32BitsIndices = true to use 32 bits indices"),null}var l,c,h,f=new Array;for(a=0;aa&&(a=c)}return new r(e,s,a-s+1,t,i,n,o)},r})(t);e.SubMesh=r})(BABYLON||(BABYLON={}));var BABYLON;!(function(BABYLON){var EffectFallbacks=(function(){function e(){this._defines={},this._currentRank=32,this._maxRank=-1}return e.prototype.addFallback=function(e,t){this._defines[e]||(ethis._maxRank&&(this._maxRank=e),this._defines[e]=new Array),this._defines[e].push(t)},e.prototype.addCPUSkinningFallback=function(e,t){this._meshRank=e,this._mesh=t,ethis._maxRank&&(this._maxRank=e)},Object.defineProperty(e.prototype,"isMoreFallbacks",{get:function(){return this._currentRank<=this._maxRank},enumerable:!0,configurable:!0}),e.prototype.reduce=function(e){if(this._mesh&&this._mesh.computeBonesUsingShaders&&this._mesh.numBoneInfluencers>0){this._mesh.computeBonesUsingShaders=!1,e=e.replace("#define NUM_BONE_INFLUENCERS "+this._mesh.numBoneInfluencers,"#define NUM_BONE_INFLUENCERS 0"),BABYLON.Tools.Log("Falling back to CPU skinning for "+this._mesh.name);for(var t=this._mesh.getScene(),r=0;r0&&(i.computeBonesUsingShaders=!1)}}else{var n=this._defines[this._currentRank];if(n)for(var r=0;r-1?e:BABYLON.Engine.ShadersRepository+e,BABYLON.Tools.LoadFile(r+".vertex.fx",t)},Effect.prototype._loadFragmentShader=function(e,t){if(e instanceof HTMLElement){return void t(BABYLON.Tools.GetDOMTextContent(e))}if("base64:"===e.substr(0,7)){return void t(window.atob(e.substr(7)))}if(Effect.ShadersStore[e+"PixelShader"])return void t(Effect.ShadersStore[e+"PixelShader"]);if(Effect.ShadersStore[e+"FragmentShader"])return void t(Effect.ShadersStore[e+"FragmentShader"]);var r;r="."===e[0]||"/"===e[0]||e.indexOf("http")>-1?e:BABYLON.Engine.ShadersRepository+e,BABYLON.Tools.LoadFile(r+".fragment.fx",t)},Effect.prototype._dumpShadersSource=function(e,t,r){var i=this._engine.webGLVersion>1?"#version 300 es\n":"",n=i+(r?r+"\n":"");e=n+e,t=n+t;var o=2,s="\n1\t"+e.replace(/\n/gm,(function(){return"\n"+o+++"\t"}));o=2;var a="\n1\t"+t.replace(/\n/gm,(function(){return"\n"+o+++"\t"}));this.name.vertexElement?(BABYLON.Tools.Error("Vertex shader: "+this.name.vertexElement+s),BABYLON.Tools.Error("Fragment shader: "+this.name.fragmentElement+a)):this.name.vertex?(BABYLON.Tools.Error("Vertex shader: "+this.name.vertex+s),BABYLON.Tools.Error("Fragment shader: "+this.name.fragment+a)):(BABYLON.Tools.Error("Vertex shader: "+this.name+s),BABYLON.Tools.Error("Fragment shader: "+this.name+a))},Effect.prototype._processShaderConversion=function(e,t,r){var i=this._processPrecision(e);if(1==this._engine.webGLVersion)return void r(i);if(-1!==i.indexOf("#version 3"))return void r(i.replace("#version 300 es",""));var n=i.replace(/#extension.+(GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth).+enable/g,"");n=n.replace(/varying(?![\n\r])\s/g,t?"in ":"out "),n=n.replace(/attribute[ \t]/g,"in "),n=n.replace(/[ \t]attribute/g," in"),t&&(n=n.replace(/texture2DLodEXT\(/g,"textureLod("),n=n.replace(/textureCubeLodEXT\(/g,"textureLod("),n=n.replace(/texture2D\(/g,"texture("),n=n.replace(/textureCube\(/g,"texture("),n=n.replace(/gl_FragDepthEXT/g,"gl_FragDepth"),n=n.replace(/gl_FragColor/g,"glFragColor"),n=n.replace(/void\s+?main\(/g,"out vec4 glFragColor;\nvoid main(")),r(n)},Effect.prototype._processIncludes=function(e,t){for(var r=this,i=/#include<(.+)>(\((.*)\))*(\[(.*)\])*/g,n=i.exec(e),o=new String(e);null!=n;){var s=n[1];if(-1!==s.indexOf("__decl__")&&(s=s.replace(/__decl__/,""),1!=this._engine.webGLVersion&&(s=s.replace(/Vertex/,"Ubo"),s=s.replace(/Fragment/,"Ubo")),s+="Declaration"),!Effect.IncludesShadersStore[s]){var a=BABYLON.Engine.ShadersRepository+"ShadersInclude/"+s+".fx";return void BABYLON.Tools.LoadFile(a,(function(e){Effect.IncludesShadersStore[s]=e,r._processIncludes(o,t)}))}var u=Effect.IncludesShadersStore[s];if(n[2])for(var l=n[3].split(","),c=0;c1)for(var s in this._uniformBuffersNames)this.bindUniformBlock(s,this._uniformBuffersNames[s]);this._uniforms=o.getUniforms(this._program,this._uniformsNames),this._attributes=o.getAttributes(this._program,r);var a;for(a=0;a0&&(result+=line+"\r\n")}return result},Effect.prototype._evaluateDefinesOnString=function(e){for(var t={children:[]},r=t,i=e.split("\n"),n=0;n0,r.NUM_MORPH_INFLUENCERS=s.numInfluencers}else r.MORPHTARGETS_TANGENT=!1,r.MORPHTARGETS_NORMAL=!1,r.MORPHTARGETS=!1,r.NUM_MORPH_INFLUENCERS=0;return!0},t.PrepareDefinesForLights=function(t,r,i,n,o,s){if(void 0===o&&(o=4),void 0===s&&(s=!1),!i._areLightsDirty)return i._needNormals;var a=0,u=!1,l=!1,c=!1,h=!1,f=!1;if(t.lightsEnabled&&!s)for(var d=0,p=r._lightSources;d0&&t.addFallback(i,"LIGHT"+i),e["SHADOW"+i]&&t.addFallback(0,"SHADOW"+i),e["SHADOWPCF"+i]&&t.addFallback(0,"SHADOWPCF"+i),e["SHADOWESM"+i]&&t.addFallback(0,"SHADOWESM"+i)},t.PrepareAttributesForMorphTargets=function(t,r,i){var n=i.NUM_MORPH_INFLUENCERS;if(n>0)for(var o=e.Engine.LastCreatedEngine.getCaps().maxVertexAttribs,s=r.morphTargetManager,a=s.supportsNormals&&i.NORMAL,u=s.supportsTangents&&i.TANGENT,l=0;lo&&e.Tools.Error("Cannot add more vertex attributes for mesh "+r.name)},t.PrepareAttributesForBones=function(t,r,i,n){i.NUM_BONE_INFLUENCERS>0&&(n.addCPUSkinningFallback(0,r),t.push(e.VertexBuffer.MatricesIndicesKind),t.push(e.VertexBuffer.MatricesWeightsKind),i.NUM_BONE_INFLUENCERS>4&&(t.push(e.VertexBuffer.MatricesIndicesExtraKind),t.push(e.VertexBuffer.MatricesWeightsExtraKind)))},t.PrepareAttributesForInstances=function(e,t){t.INSTANCES&&(e.push("world0"),e.push("world1"),e.push("world2"),e.push("world3"))},t.BindLightShadow=function(e,t,r,i,n){if(e.shadowEnabled&&r.receiveShadows){var o=e.getShadowGenerator();o&&o.bindShadowLight(i,n)}},t.BindLightProperties=function(e,t,r){e.transferToEffect(t,r+"")},t.BindLights=function(r,i,n,o,s,a){void 0===s&&(s=4),void 0===a&&(a=!1);for(var u=0,l=0,c=i._lightSources;l1,n||this._scene.materials.push(this)}return Object.defineProperty(t,"TriangleFillMode",{get:function(){return t._TriangleFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(t,"WireFrameFillMode",{get:function(){return t._WireFrameFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(t,"PointFillMode",{get:function(){return t._PointFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(t,"ClockWiseSideOrientation",{get:function(){return t._ClockWiseSideOrientation},enumerable:!0,configurable:!0}),Object.defineProperty(t,"CounterClockWiseSideOrientation",{get:function(){return t._CounterClockWiseSideOrientation},enumerable:!0,configurable:!0}),Object.defineProperty(t,"TextureDirtyFlag",{get:function(){return t._TextureDirtyFlag},enumerable:!0,configurable:!0}),Object.defineProperty(t,"LightDirtyFlag",{get:function(){return t._LightDirtyFlag},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FresnelDirtyFlag",{get:function(){return t._FresnelDirtyFlag},enumerable:!0,configurable:!0}),Object.defineProperty(t,"AttributesDirtyFlag",{get:function(){return t._AttributesDirtyFlag},enumerable:!0,configurable:!0}),Object.defineProperty(t,"MiscDirtyFlag",{get:function(){return t._MiscDirtyFlag},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"backFaceCulling",{get:function(){return this._backFaceCulling},set:function(e){this._backFaceCulling!==e&&(this._backFaceCulling=e,this.markAsDirty(t.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onBind",{set:function(e){this._onBindObserver&&this.onBindObservable.remove(this._onBindObserver),this._onBindObserver=this.onBindObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"fogEnabled",{get:function(){return this._fogEnabled},set:function(e){this._fogEnabled!==e&&(this._fogEnabled=e,this.markAsDirty(t.MiscDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"wireframe",{get:function(){return this._fillMode===t.WireFrameFillMode},set:function(e){this._fillMode=e?t.WireFrameFillMode:t.TriangleFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"pointsCloud",{get:function(){return this._fillMode===t.PointFillMode},set:function(e){this._fillMode=e?t.PointFillMode:t.TriangleFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"fillMode",{get:function(){return this._fillMode},set:function(e){this._fillMode!==e&&(this._fillMode=e,this.markAsDirty(t.MiscDirtyFlag))},enumerable:!0,configurable:!0}),t.prototype.toString=function(e){return"Name: "+this.name},t.prototype.getClassName=function(){return"Material"},Object.defineProperty(t.prototype,"isFrozen",{get:function(){return this.checkReadyOnlyOnce},enumerable:!0,configurable:!0}),t.prototype.freeze=function(){this.checkReadyOnlyOnce=!0},t.prototype.unfreeze=function(){this.checkReadyOnlyOnce=!1},t.prototype.isReady=function(e,t){return!0},t.prototype.isReadyForSubMesh=function(e,t,r){return!1},t.prototype.getEffect=function(){return this._effect},t.prototype.getScene=function(){return this._scene},t.prototype.needAlphaBlending=function(){return this.alpha<1},t.prototype.needAlphaTesting=function(){return!1},t.prototype.getAlphaTestTexture=function(){return null},t.prototype.markDirty=function(){this._wasPreviouslyReady=!1},t.prototype._preBind=function(e){var r=this._scene.getEngine(),i=this.sideOrientation===t.ClockWiseSideOrientation;r.enableEffect(e||this._effect),r.setState(this.backFaceCulling,this.zOffset,!1,i)},t.prototype.bind=function(e,t){},t.prototype.bindForSubMesh=function(e,t,r){},t.prototype.bindOnlyWorldMatrix=function(e){},t.prototype.bindSceneUniformBuffer=function(e,t){t.bindToEffect(e,"Scene")},t.prototype.bindView=function(e){this._useUBO?this.bindSceneUniformBuffer(e,this.getScene().getSceneUniformBuffer()):e.setMatrix("view",this.getScene().getViewMatrix())},t.prototype.bindViewProjection=function(e){this._useUBO?this.bindSceneUniformBuffer(e,this.getScene().getSceneUniformBuffer()):e.setMatrix("viewProjection",this.getScene().getTransformMatrix())},t.prototype._afterBind=function(e){if(this._scene._cachedMaterial=this,this.onBindObservable.notifyObservers(e),this.disableDepthWrite){var t=this._scene.getEngine();this._cachedDepthWriteState=t.getDepthWrite(),t.setDepthWrite(!1)}},t.prototype.unbind=function(){if(this.onUnBindObservable.notifyObservers(this),this.disableDepthWrite){this._scene.getEngine().setDepthWrite(this._cachedDepthWriteState)}},t.prototype.getActiveTextures=function(){return[]},t.prototype.hasTexture=function(e){return!1},t.prototype.clone=function(e){return null},t.prototype.getBindedMeshes=function(){for(var e=new Array,t=0;t=0&&this._scene.materials.splice(r,1),r=0;ra?a:Math.floor(u);var l,c,h,f,d=0===r.sideOrientation?0:r.sideOrientation||e.Mesh.DEFAULTSIDE,p=r.uvs,g=r.colors,_=[],m=[],v=[],y=[],A=[],E=[],T=[],b=[],x=[],M=[];if(i.length<2){var P=[],R=[];for(h=0;h0&&(L=C[f].subtract(C[f-1]).length(),D=L+T[c],A[c].push(D),T[c]=D),f++;o&&(f--,_.push(C[0].x,C[0].y,C[0].z),L=C[f].subtract(C[0]).length(),D=L+T[c],A[c].push(D),T[c]=D),x[c]=S+I,M[c]=O,O+=S+I}var B,N,F,w;for(h=0;h1?1:r.arc||1,u=r.slice<=0?1:r.slice||1,l=0===r.sideOrientation?0:r.sideOrientation||e.Mesh.DEFAULTSIDE,c=new e.Vector3(n/2,o/2,s/2),h=2+i,f=2*h,d=[],p=[],g=[],_=[],m=0;m<=h;m++){for(var v=m/h,y=v*Math.PI*u,A=0;A<=f;A++){var E=A/f,T=E*Math.PI*2*a,b=e.Matrix.RotationZ(-y),x=e.Matrix.RotationY(T),M=e.Vector3.TransformCoordinates(e.Vector3.Up(),b),P=e.Vector3.TransformCoordinates(M,x),R=P.multiply(c),C=P.divide(c).normalize();p.push(R.x,R.y,R.z),g.push(C.x,C.y,C.z),_.push(E,v)}if(m>0)for(var S=p.length/3,O=S-2*(f+1);O+f+21?1:r.arc||1,f=0===r.sideOrientation?0:r.sideOrientation||e.Mesh.DEFAULTSIDE,d=r.faceUV||new Array(3),p=r.faceColors,g=1!==h&&c?2:0,_=l?u:1,m=2+(1+g)*_;for(i=0;i0&&(r.push(o-1),r.push(o)),o++;var l=new t;return l.indices=r,l.positions=i,l},t.CreateDashedLines=function(r){var i=r.dashSize||3,n=r.gapSize||1,o=r.dashNb||200,s=r.points,a=new Array,u=new Array,l=e.Vector3.Zero(),c=0,h=0,f=0,d=0,p=0,g=0,_=0;for(_=0;_1?1:r.arc||1,c=0===r.sideOrientation?0:r.sideOrientation||e.Mesh.DEFAULTSIDE;i.push(0,0,0),s.push(.5,.5);for(var h=2*Math.PI*l,f=h/u,d=0;d=i.length?0:r.type||0,h=r.size,f=r.sizeX||h||1,d=r.sizeY||h||1,p=r.sizeZ||h||1,g=r.custom||i[c],_=g.face.length,m=r.faceUV||new Array(_),v=r.faceColors,y=void 0===r.flat||r.flat,A=0===r.sideOrientation?0:r.sideOrientation||e.Mesh.DEFAULTSIDE,E=[],T=[],b=[],x=[],M=[],P=0,R=0,C=[],S=0,O=0;if(y)for(O=0;O<_;O++)v&&void 0===v[O]&&(v[O]=new e.Color4(1,1,1,1)),m&&void 0===m[O]&&(m[O]=new e.Vector4(0,0,1,1));if(y)for(O=0;O<_;O++){var I=g.face[O].length;for(s=2*Math.PI/I,a=.5*Math.tan(s/2),u=.5,S=0;Si.bbSize.y?i.bbSize.x:i.bbSize.y;Y=Y>i.bbSize.z?Y:i.bbSize.z;var W=i.subDiv.X*i.ratio/i.bbSize.x,X=i.subDiv.Y*i.ratio/i.bbSize.y,K=i.subDiv.Z*i.ratio/i.bbSize.z,j=i.subDiv.max*i.subDiv.max;i.facetPartitioning.length=0}for(n=0;n0&&(this._indexBuffer=this._engine.createIndexBuffer(this._indices)),this._indexBuffer&&(this._indexBuffer.references=r)},t.prototype.notifyUpdate=function(e){this.onGeometryUpdated&&this.onGeometryUpdated(this,e);for(var t=0,r=this._meshes;t0){for(var r=0;r0){for(var r=0;r0){for(var r=0;r0){var u=new Float32Array(r,a.positionsAttrDesc.offset,a.positionsAttrDesc.count);i.setVerticesData(e.VertexBuffer.PositionKind,u,!1)}if(a.normalsAttrDesc&&a.normalsAttrDesc.count>0){var l=new Float32Array(r,a.normalsAttrDesc.offset,a.normalsAttrDesc.count);i.setVerticesData(e.VertexBuffer.NormalKind,l,!1)}if(a.uvsAttrDesc&&a.uvsAttrDesc.count>0){var c=new Float32Array(r,a.uvsAttrDesc.offset,a.uvsAttrDesc.count);i.setVerticesData(e.VertexBuffer.UVKind,c,!1)}if(a.uvs2AttrDesc&&a.uvs2AttrDesc.count>0){var h=new Float32Array(r,a.uvs2AttrDesc.offset,a.uvs2AttrDesc.count);i.setVerticesData(e.VertexBuffer.UV2Kind,h,!1)}if(a.uvs3AttrDesc&&a.uvs3AttrDesc.count>0){var f=new Float32Array(r,a.uvs3AttrDesc.offset,a.uvs3AttrDesc.count);i.setVerticesData(e.VertexBuffer.UV3Kind,f,!1)}if(a.uvs4AttrDesc&&a.uvs4AttrDesc.count>0){var d=new Float32Array(r,a.uvs4AttrDesc.offset,a.uvs4AttrDesc.count);i.setVerticesData(e.VertexBuffer.UV4Kind,d,!1)}if(a.uvs5AttrDesc&&a.uvs5AttrDesc.count>0){var p=new Float32Array(r,a.uvs5AttrDesc.offset,a.uvs5AttrDesc.count);i.setVerticesData(e.VertexBuffer.UV5Kind,p,!1)}if(a.uvs6AttrDesc&&a.uvs6AttrDesc.count>0){var g=new Float32Array(r,a.uvs6AttrDesc.offset,a.uvs6AttrDesc.count);i.setVerticesData(e.VertexBuffer.UV6Kind,g,!1)}if(a.colorsAttrDesc&&a.colorsAttrDesc.count>0){var _=new Float32Array(r,a.colorsAttrDesc.offset,a.colorsAttrDesc.count);i.setVerticesData(e.VertexBuffer.ColorKind,_,!1,a.colorsAttrDesc.stride)}if(a.matricesIndicesAttrDesc&&a.matricesIndicesAttrDesc.count>0){var m=new Int32Array(r,a.matricesIndicesAttrDesc.offset,a.matricesIndicesAttrDesc.count);i.setVerticesData(e.VertexBuffer.MatricesIndicesKind,m,!1)}if(a.matricesWeightsAttrDesc&&a.matricesWeightsAttrDesc.count>0){var v=new Float32Array(r,a.matricesWeightsAttrDesc.offset,a.matricesWeightsAttrDesc.count);i.setVerticesData(e.VertexBuffer.MatricesWeightsKind,v,!1)}if(a.indicesAttrDesc&&a.indicesAttrDesc.count>0){var y=new Int32Array(r,a.indicesAttrDesc.offset,a.indicesAttrDesc.count);i.setIndices(y)}if(a.subMeshesAttrDesc&&a.subMeshesAttrDesc.count>0){var A=new Int32Array(r,a.subMeshesAttrDesc.offset,5*a.subMeshesAttrDesc.count);i.subMeshes=[];for(var E=0;E>8),R.push((16711680&C)>>16),R.push(C>>24)}i.setVerticesData(e.VertexBuffer.MatricesIndicesKind,R,r.matricesIndices._updatable)}if(r.matricesIndicesExtra)if(r.matricesIndicesExtra._isExpanded)delete r.matricesIndices._isExpanded,i.setVerticesData(e.VertexBuffer.MatricesIndicesExtraKind,r.matricesIndicesExtra,r.matricesIndicesExtra._updatable);else{for(var R=[],E=0;E>8),R.push((16711680&C)>>16),R.push(C>>24)}i.setVerticesData(e.VertexBuffer.MatricesIndicesExtraKind,R,r.matricesIndicesExtra._updatable)}r.matricesWeights&&(t._CleanMatricesWeights(r.matricesWeights,r.numBoneInfluencers),i.setVerticesData(e.VertexBuffer.MatricesWeightsKind,r.matricesWeights,r.matricesWeights._updatable)),r.matricesWeightsExtra&&(t._CleanMatricesWeights(r.matricesWeightsExtra,r.numBoneInfluencers),i.setVerticesData(e.VertexBuffer.MatricesWeightsExtraKind,r.matricesWeightsExtra,r.matricesWeights._updatable)),i.setIndices(r.indices)}if(r.subMeshes){i.subMeshes=[];for(var S=0;Sa&&(a=t[n+u],s=n+u);t[s]+=Math.max(0,1-o)}},t.Parse=function(r,i,n){if(i.getGeometryByID(r.id))return null;var o=new t(r.id,i,null,r.updatable);return e.Tags&&e.Tags.AddTagsTo(o,r.tags),r.delayLoadingFile?(o.delayLoadState=e.Engine.DELAYLOADSTATE_NOTLOADED,o.delayLoadingFile=n+r.delayLoadingFile,o._boundingInfo=new e.BoundingInfo(e.Vector3.FromArray(r.boundingBoxMinimum),e.Vector3.FromArray(r.boundingBoxMaximum)),o._delayInfo=[],r.hasUVs&&o._delayInfo.push(e.VertexBuffer.UVKind),r.hasUVs2&&o._delayInfo.push(e.VertexBuffer.UV2Kind),r.hasUVs3&&o._delayInfo.push(e.VertexBuffer.UV3Kind),r.hasUVs4&&o._delayInfo.push(e.VertexBuffer.UV4Kind),r.hasUVs5&&o._delayInfo.push(e.VertexBuffer.UV5Kind),r.hasUVs6&&o._delayInfo.push(e.VertexBuffer.UV6Kind),r.hasColors&&o._delayInfo.push(e.VertexBuffer.ColorKind),r.hasMatricesIndices&&o._delayInfo.push(e.VertexBuffer.MatricesIndicesKind),r.hasMatricesWeights&&o._delayInfo.push(e.VertexBuffer.MatricesWeightsKind),o._delayLoadingFunction=e.VertexData.ImportVertexData):e.VertexData.ImportVertexData(r,o),i.pushGeometry(o,!0),o},t})();e.Geometry=t,(function(t){!(function(r){var i=(function(e){function t(t,r,i,n){var o=e.call(this,t,r,null,!1,n)||this;return o._canBeRegenerated=i,o._beingRegenerated=!0,o.regenerate(),o._beingRegenerated=!1,o}return __extends(t,e),t.prototype.canBeRegenerated=function(){return this._canBeRegenerated},t.prototype.regenerate=function(){this._canBeRegenerated&&(this._beingRegenerated=!0,this.setAllVerticesData(this._regenerateVertexData(),!1),this._beingRegenerated=!1)},t.prototype.asNewGeometry=function(t){return e.prototype.copy.call(this,t)},t.prototype.setAllVerticesData=function(t,r){this._beingRegenerated&&e.prototype.setAllVerticesData.call(this,t,!1)},t.prototype.setVerticesData=function(t,r,i){this._beingRegenerated&&e.prototype.setVerticesData.call(this,t,r,!1)},t.prototype._regenerateVertexData=function(){throw new Error("Abstract method")},t.prototype.copy=function(e){throw new Error("Must be overriden in sub-classes.")},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.canBeRegenerated=this.canBeRegenerated(),t},t})(t);r._Primitive=i;var n=(function(t){function r(r,i,n,o,s,a,u,l,c){void 0===c&&(c=e.Mesh.DEFAULTSIDE);var h=t.call(this,r,i,u,l)||this;return h.pathArray=n,h.closeArray=o,h.closePath=s,h.offset=a,h.side=c,h}return __extends(r,t),r.prototype._regenerateVertexData=function(){return e.VertexData.CreateRibbon({pathArray:this.pathArray,closeArray:this.closeArray,closePath:this.closePath,offset:this.offset,sideOrientation:this.side})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.pathArray,this.closeArray,this.closePath,this.offset,this.canBeRegenerated(),null,this.side)},r})(i);r.Ribbon=n;var o=(function(r){function i(t,i,n,o,s,a){void 0===a&&(a=e.Mesh.DEFAULTSIDE);var u=r.call(this,t,i,o,s)||this;return u.size=n,u.side=a,u}return __extends(i,r),i.prototype._regenerateVertexData=function(){return e.VertexData.CreateBox({size:this.size,sideOrientation:this.side})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.size,this.canBeRegenerated(),null,this.side)},i.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.size=this.size,e},i.Parse=function(r,i){if(i.getGeometryByID(r.id))return null;var n=new t.Primitives.Box(r.id,i,r.size,r.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,r.tags),i.pushGeometry(n,!0),n},i})(i);r.Box=o;var s=(function(r){function i(t,i,n,o,s,a,u){void 0===u&&(u=e.Mesh.DEFAULTSIDE);var l=r.call(this,t,i,s,a)||this;return l.segments=n,l.diameter=o,l.side=u,l}return __extends(i,r),i.prototype._regenerateVertexData=function(){return e.VertexData.CreateSphere({segments:this.segments,diameter:this.diameter,sideOrientation:this.side})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.segments,this.diameter,this.canBeRegenerated(),null,this.side)},i.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.segments=this.segments,e.diameter=this.diameter,e},i.Parse=function(r,i){if(i.getGeometryByID(r.id))return null;var n=new t.Primitives.Sphere(r.id,i,r.segments,r.diameter,r.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,r.tags),i.pushGeometry(n,!0),n},i})(i);r.Sphere=s;var a=(function(t){function r(r,i,n,o,s,a,u){void 0===u&&(u=e.Mesh.DEFAULTSIDE);var l=t.call(this,r,i,s,a)||this;return l.radius=n,l.tessellation=o,l.side=u,l}return __extends(r,t),r.prototype._regenerateVertexData=function(){return e.VertexData.CreateDisc({radius:this.radius,tessellation:this.tessellation,sideOrientation:this.side})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.radius,this.tessellation,this.canBeRegenerated(),null,this.side)},r})(i);r.Disc=a;var u=(function(r){function i(t,i,n,o,s,a,u,l,c,h){void 0===u&&(u=1),void 0===h&&(h=e.Mesh.DEFAULTSIDE);var f=r.call(this,t,i,l,c)||this;return f.height=n,f.diameterTop=o,f.diameterBottom=s,f.tessellation=a,f.subdivisions=u,f.side=h,f}return __extends(i,r),i.prototype._regenerateVertexData=function(){return e.VertexData.CreateCylinder({height:this.height,diameterTop:this.diameterTop,diameterBottom:this.diameterBottom,tessellation:this.tessellation,subdivisions:this.subdivisions,sideOrientation:this.side})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.height,this.diameterTop,this.diameterBottom,this.tessellation,this.subdivisions,this.canBeRegenerated(),null,this.side)},i.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.height=this.height,e.diameterTop=this.diameterTop,e.diameterBottom=this.diameterBottom,e.tessellation=this.tessellation,e},i.Parse=function(r,i){if(i.getGeometryByID(r.id))return null;var n=new t.Primitives.Cylinder(r.id,i,r.height,r.diameterTop,r.diameterBottom,r.tessellation,r.subdivisions,r.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,r.tags),i.pushGeometry(n,!0),n},i})(i);r.Cylinder=u;var l=(function(r){function i(t,i,n,o,s,a,u,l){void 0===l&&(l=e.Mesh.DEFAULTSIDE);var c=r.call(this,t,i,a,u)||this;return c.diameter=n,c.thickness=o,c.tessellation=s,c.side=l,c}return __extends(i,r),i.prototype._regenerateVertexData=function(){return e.VertexData.CreateTorus({diameter:this.diameter,thickness:this.thickness,tessellation:this.tessellation,sideOrientation:this.side})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.diameter,this.thickness,this.tessellation,this.canBeRegenerated(),null,this.side)},i.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.diameter=this.diameter,e.thickness=this.thickness,e.tessellation=this.tessellation,e},i.Parse=function(r,i){if(i.getGeometryByID(r.id))return null;var n=new t.Primitives.Torus(r.id,i,r.diameter,r.thickness,r.tessellation,r.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,r.tags),i.pushGeometry(n,!0),n},i})(i);r.Torus=l;var c=(function(r){function i(e,t,i,n,o,s,a){var u=r.call(this,e,t,s,a)||this;return u.width=i,u.height=n,u.subdivisions=o,u}return __extends(i,r),i.prototype._regenerateVertexData=function(){return e.VertexData.CreateGround({width:this.width,height:this.height,subdivisions:this.subdivisions})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.width,this.height,this.subdivisions,this.canBeRegenerated(),null)},i.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.width=this.width,e.height=this.height,e.subdivisions=this.subdivisions,e},i.Parse=function(r,i){if(i.getGeometryByID(r.id))return null;var n=new t.Primitives.Ground(r.id,i,r.width,r.height,r.subdivisions,r.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,r.tags),i.pushGeometry(n,!0),n},i})(i);r.Ground=c;var h=(function(t){function r(e,r,i,n,o,s,a,u,l,c){var h=t.call(this,e,r,l,c)||this;return h.xmin=i,h.zmin=n,h.xmax=o,h.zmax=s,h.subdivisions=a,h.precision=u,h}return __extends(r,t),r.prototype._regenerateVertexData=function(){return e.VertexData.CreateTiledGround({xmin:this.xmin,zmin:this.zmin,xmax:this.xmax,zmax:this.zmax,subdivisions:this.subdivisions,precision:this.precision})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.xmin,this.zmin,this.xmax,this.zmax,this.subdivisions,this.precision,this.canBeRegenerated(),null)},r})(i);r.TiledGround=h;var f=(function(r){function i(t,i,n,o,s,a){void 0===a&&(a=e.Mesh.DEFAULTSIDE);var u=r.call(this,t,i,o,s)||this;return u.size=n,u.side=a,u}return __extends(i,r),i.prototype._regenerateVertexData=function(){return e.VertexData.CreatePlane({size:this.size,sideOrientation:this.side})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.size,this.canBeRegenerated(),null,this.side)},i.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.size=this.size,e},i.Parse=function(r,i){if(i.getGeometryByID(r.id))return null;var n=new t.Primitives.Plane(r.id,i,r.size,r.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,r.tags),i.pushGeometry(n,!0),n},i})(i);r.Plane=f;var d=(function(r){function i(t,i,n,o,s,a,u,l,c,h,f){void 0===f&&(f=e.Mesh.DEFAULTSIDE);var d=r.call(this,t,i,c,h)||this;return d.radius=n,d.tube=o,d.radialSegments=s,d.tubularSegments=a,d.p=u,d.q=l,d.side=f,d}return __extends(i,r),i.prototype._regenerateVertexData=function(){return e.VertexData.CreateTorusKnot({radius:this.radius,tube:this.tube,radialSegments:this.radialSegments,tubularSegments:this.tubularSegments,p:this.p,q:this.q,sideOrientation:this.side})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.radius,this.tube,this.radialSegments,this.tubularSegments,this.p,this.q,this.canBeRegenerated(),null,this.side)},i.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.radius=this.radius,e.tube=this.tube,e.radialSegments=this.radialSegments,e.tubularSegments=this.tubularSegments,e.p=this.p,e.q=this.q,e},i.Parse=function(r,i){if(i.getGeometryByID(r.id))return null;var n=new t.Primitives.TorusKnot(r.id,i,r.radius,r.tube,r.radialSegments,r.tubularSegments,r.p,r.q,r.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,r.tags),i.pushGeometry(n,!0),n},i})(i);r.TorusKnot=d})(t.Primitives||(t.Primitives={}))})(t=e.Geometry||(e.Geometry={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e){this._vertexBuffers={},this._scene=e}return t.prototype._prepareBuffers=function(){if(!this._vertexBuffers[e.VertexBuffer.PositionKind]){var t=[];t.push(1,1),t.push(-1,1),t.push(-1,-1),t.push(1,-1),this._vertexBuffers[e.VertexBuffer.PositionKind]=new e.VertexBuffer(this._scene.getEngine(),t,e.VertexBuffer.PositionKind,!1,!1,2);var r=[];r.push(0),r.push(1),r.push(2),r.push(0),r.push(2),r.push(3),this._indexBuffer=this._scene.getEngine().createIndexBuffer(r)}},t.prototype._prepareFrame=function(e,t){var t=t||this._scene.activeCamera._postProcesses;return!(0===t.length||!this._scene.postProcessesEnabled)&&(t[0].activate(this._scene.activeCamera,e,null!==t&&void 0!==t),!0)},t.prototype.directRender=function(e,t){for(var r=this._scene.getEngine(),i=0;i=this._sampleCount||e>=this._samples.length)return null;var t=this._wrapPosition(this._pos-1);return this._samples[this._wrapPosition(t-e)]},e.prototype.isSaturated=function(){return this._sampleCount>=this._samples.length},e.prototype.reset=function(){this.average=0,this.variance=0,this._sampleCount=0,this._pos=0,this._m2=0},e.prototype._wrapPosition=function(e){var t=this._samples.length;return(e%t+t)%t},e})();e.RollingAverage=r})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(e,t,r){this.name=e,this.from=t,this.to=r}return e.prototype.clone=function(){return new e(this.name,this.from,this.to)},e})();e.AnimationRange=t;var r=(function(){function e(e,t,r){this.frame=e,this.action=t,this.onlyOnce=r,this.isDone=!1}return e})();e.AnimationEvent=r;var i=(function(){function t(e){this.path=e,this._onchange=new Array,this.value=0,this.animations=new Array}return t.prototype.getPoint=function(){var t=this.path.getPointAtLengthPosition(this.value);return new e.Vector3(t.x,0,t.y)},t.prototype.moveAhead=function(e){return void 0===e&&(e=.002),this.move(e),this},t.prototype.moveBack=function(e){return void 0===e&&(e=.002),this.move(-e),this},t.prototype.move=function(e){if(Math.abs(e)>1)throw"step size should be less than 1.";return this.value+=e,this.ensureLimits(),this.raiseOnChange(),this},t.prototype.ensureLimits=function(){for(;this.value>1;)this.value-=1;for(;this.value<0;)this.value+=1;return this},t.prototype.markAsDirty=function(e){return this.ensureLimits(),this.raiseOnChange(),this},t.prototype.raiseOnChange=function(){var e=this;return this._onchange.forEach((function(t){return t(e)})),this},t.prototype.onchange=function(e){return this._onchange.push(e),this},t})();e.PathCursor=i;var n=(function(){function r(e,t,i,n,o,s){this.name=e,this.targetProperty=t,this.framePerSecond=i,this.dataType=n,this.loopMode=o,this.enableBlending=s,this._offsetsCache={},this._highLimitsCache={},this._stopped=!1,this._blendingFactor=0,this._events=new Array,this.allowMatricesInterpolation=!1,this.blendingSpeed=.01,this._ranges={},this.targetPropertyPath=t.split("."),this.dataType=n,this.loopMode=void 0===o?r.ANIMATIONLOOPMODE_CYCLE:o}return r._PrepareAnimation=function(t,i,n,o,s,a,u,l){var c=void 0;if(!isNaN(parseFloat(s))&&isFinite(s)?c=r.ANIMATIONTYPE_FLOAT:s instanceof e.Quaternion?c=r.ANIMATIONTYPE_QUATERNION:s instanceof e.Vector3?c=r.ANIMATIONTYPE_VECTOR3:s instanceof e.Vector2?c=r.ANIMATIONTYPE_VECTOR2:s instanceof e.Color3?c=r.ANIMATIONTYPE_COLOR3:s instanceof e.Size&&(c=r.ANIMATIONTYPE_SIZE),void 0==c)return null;var h=new r(t,i,n,c,u),f=[{frame:0,value:s},{frame:o,value:a}];return h.setKeys(f),void 0!==l&&h.setEasingFunction(l),h},r.CreateAndStartAnimation=function(e,t,i,n,o,s,a,u,l,c){var h=r._PrepareAnimation(e,i,n,o,s,a,u,l);return t.getScene().beginDirectAnimation(t,[h],0,o,1===h.loopMode,1,c)},r.CreateMergeAndStartAnimation=function(e,t,i,n,o,s,a,u,l,c){var h=r._PrepareAnimation(e,i,n,o,s,a,u,l);return t.animations.push(h),t.getScene().beginAnimation(t,0,o,1===h.loopMode,1,c)},r.prototype.toString=function(e){var t="Name: "+this.name+", property: "+this.targetProperty;if(t+=", datatype: "+["Float","Vector3","Quaternion","Matrix","Color3","Vector2"][this.dataType],t+=", nKeys: "+(this._keys?this._keys.length:"none"),t+=", nRanges: "+(this._ranges?Object.keys(this._ranges).length:"none"),e){t+=", Ranges: {";var r=!0;for(var i in this._ranges)r&&(t+=", ",r=!1),t+=i;t+="}"}return t},r.prototype.addEvent=function(e){this._events.push(e)},r.prototype.removeEvents=function(e){for(var t=0;t=0;n--)this._keys[n].frame>=r&&this._keys[n].frame<=i&&this._keys.splice(n,1);this._ranges[e]=void 0}},r.prototype.getRange=function(e){return this._ranges[e]},r.prototype.reset=function(){this._offsetsCache={},this._highLimitsCache={},this.currentFrame=0,this._blendingFactor=0,this._originalBlendValue=null},r.prototype.isStopped=function(){return this._stopped},r.prototype.getKeys=function(){return this._keys},r.prototype.getHighestFrame=function(){for(var e=0,t=0,r=this._keys.length;t0)return o.clone?o.clone():o;this.currentFrame=e;var s=Math.max(0,Math.min(this._keys.length-1,Math.floor(this._keys.length*(e-this._keys[0].frame)/(this._keys[this._keys.length-1].frame-this._keys[0].frame))-1));if(this._keys[s].frame>=e)for(;s-1>=0&&this._keys[s].frame>=e;)s--;for(var a=s;a=e){var l=this._keys[a],c=this._getKeyValue(l.value),h=this._getKeyValue(u.value),f=void 0!==l.outTangent&&void 0!==u.inTangent,d=u.frame-l.frame,p=(e-l.frame)/d;switch(null!=this._easingFunction&&(p=this._easingFunction.ease(p)),this.dataType){case r.ANIMATIONTYPE_FLOAT:var g=f?this.floatInterpolateFunctionWithTangents(c,l.outTangent*d,h,u.inTangent*d,p):this.floatInterpolateFunction(c,h,p);switch(i){case r.ANIMATIONLOOPMODE_CYCLE:case r.ANIMATIONLOOPMODE_CONSTANT:return g;case r.ANIMATIONLOOPMODE_RELATIVE:return n*t+g}break;case r.ANIMATIONTYPE_QUATERNION:var _=f?this.quaternionInterpolateFunctionWithTangents(c,l.outTangent.scale(d),h,u.inTangent.scale(d),p):this.quaternionInterpolateFunction(c,h,p);switch(i){case r.ANIMATIONLOOPMODE_CYCLE:case r.ANIMATIONLOOPMODE_CONSTANT:return _;case r.ANIMATIONLOOPMODE_RELATIVE:return _.add(n.scale(t))}return _;case r.ANIMATIONTYPE_VECTOR3:var m=f?this.vector3InterpolateFunctionWithTangents(c,l.outTangent.scale(d),h,u.inTangent.scale(d),p):this.vector3InterpolateFunction(c,h,p);switch(i){case r.ANIMATIONLOOPMODE_CYCLE:case r.ANIMATIONLOOPMODE_CONSTANT:return m;case r.ANIMATIONLOOPMODE_RELATIVE:return m.add(n.scale(t))}case r.ANIMATIONTYPE_VECTOR2:var v=f?this.vector2InterpolateFunctionWithTangents(c,l.outTangent.scale(d),h,u.inTangent.scale(d),p):this.vector2InterpolateFunction(c,h,p);switch(i){case r.ANIMATIONLOOPMODE_CYCLE:case r.ANIMATIONLOOPMODE_CONSTANT:return v;case r.ANIMATIONLOOPMODE_RELATIVE:return v.add(n.scale(t))}case r.ANIMATIONTYPE_SIZE:switch(i){case r.ANIMATIONLOOPMODE_CYCLE:case r.ANIMATIONLOOPMODE_CONSTANT:return this.sizeInterpolateFunction(c,h,p);case r.ANIMATIONLOOPMODE_RELATIVE:return this.sizeInterpolateFunction(c,h,p).add(n.scale(t))}case r.ANIMATIONTYPE_COLOR3:switch(i){case r.ANIMATIONLOOPMODE_CYCLE:case r.ANIMATIONLOOPMODE_CONSTANT:return this.color3InterpolateFunction(c,h,p);case r.ANIMATIONLOOPMODE_RELATIVE:return this.color3InterpolateFunction(c,h,p).add(n.scale(t))}case r.ANIMATIONTYPE_MATRIX:switch(i){case r.ANIMATIONLOOPMODE_CYCLE:case r.ANIMATIONLOOPMODE_CONSTANT:if(this.allowMatricesInterpolation)return this.matrixInterpolateFunction(c,h,p);case r.ANIMATIONLOOPMODE_RELATIVE:return c}}break}}return this._getKeyValue(this._keys[this._keys.length-1].value)},r.prototype.setValue=function(t,r){void 0===r&&(r=!1);var i,n;if(this.targetPropertyPath.length>1){for(var o=this._target[this.targetPropertyPath[0]],s=1;sthis._keys[this._keys.length-1].frame&&(e=this._keys[this._keys.length-1].frame);var t=this._interpolate(e,0,this.loopMode);this.setValue(t)},r.prototype.animate=function(t,i,n,o,s,a){if(void 0===a&&(a=!1),!this.targetPropertyPath||this.targetPropertyPath.length<1)return this._stopped=!0,!1;var u=!0;if(0!==this._keys[0].frame){var l={frame:0,value:this._keys[0].value};this._keys.splice(0,0,l)}(ithis._keys[this._keys.length-1].frame)&&(i=this._keys[0].frame),(nthis._keys[this._keys.length-1].frame)&&(n=this._keys[this._keys.length-1].frame),i===n&&i++;var c,h=n-i,f=t*(this.framePerSecond*s)/1e3,d=0;if((n>i&&f>h||i>n&&f>0,v=u?i+f%h:n,y=this._interpolate(v,m,this.loopMode,c,d);this.setValue(y);for(var A=0;A0&&v>=this._events[A].frame&&this._events[A].frame>=i||h<0&&v<=this._events[A].frame&&this._events[A].frame<=i){var E=this._events[A];E.isDone||(E.onlyOnce&&(this._events.splice(A,1),A--),E.isDone=!0,E.action())}else this._events[A].isDone&&!this._events[A].onlyOnce&&(this._events[A].isDone=!1);return u||(this._stopped=!0),u},r.prototype.serialize=function(){var e={};e.name=this.name,e.property=this.targetProperty,e.framePerSecond=this.framePerSecond,e.dataType=this.dataType,e.loopBehavior=this.loopMode,e.enableBlending=this.enableBlending,e.blendingSpeed=this.blendingSpeed;var t=this.dataType;e.keys=[];for(var i=this.getKeys(),n=0;n-1){for(var r=this._animations,i=r.length-1;i>=0;i--)"string"==typeof e&&r[i].name!=e||(r[i].reset(),r.splice(i,1));0==r.length&&(this._scene._activeAnimatables.splice(t,1),this.onAnimationEnd&&this.onAnimationEnd())}}else{var i=this._scene._activeAnimatables.indexOf(this);if(i>-1){this._scene._activeAnimatables.splice(i,1);for(var r=this._animations,i=0;i=.5?.5*(1-this.easeInCore(2*(1-t)))+.5:.5*this.easeInCore(2*t)},e})();t._EASINGMODE_EASEIN=0,t._EASINGMODE_EASEOUT=1,t._EASINGMODE_EASEINOUT=2,e.EasingFunction=t;var r=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.easeInCore=function(e){return e=Math.max(0,Math.min(1,e)),1-Math.sqrt(1-e*e)},t})(t);e.CircleEase=r;var i=(function(e){function t(t){void 0===t&&(t=1);var r=e.call(this)||this;return r.amplitude=t,r}return __extends(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.amplitude);return Math.pow(e,3)-e*t*Math.sin(3.141592653589793*e)},t})(t);e.BackEase=i;var n=(function(e){function t(t,r){void 0===t&&(t=3),void 0===r&&(r=2);var i=e.call(this)||this;return i.bounces=t,i.bounciness=r,i}return __extends(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.bounces),r=this.bounciness;r<=1&&(r=1.001);var i=Math.pow(r,t),n=1-r,o=(1-i)/n+.5*i,s=e*o,a=Math.log(-s*(1-r)+1)/Math.log(r),u=Math.floor(a),l=u+1,c=(1-Math.pow(r,u))/(n*o),h=(1-Math.pow(r,l))/(n*o),f=.5*(c+h),d=e-f,p=f-c;return-Math.pow(1/r,t-u)/(p*p)*(d-p)*(d+p)},t})(t);e.BounceEase=n;var o=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.easeInCore=function(e){return e*e*e},t})(t);e.CubicEase=o;var s=(function(e){function t(t,r){void 0===t&&(t=3),void 0===r&&(r=3);var i=e.call(this)||this;return i.oscillations=t,i.springiness=r,i}return __extends(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.oscillations),r=Math.max(0,this.springiness);return(0==r?e:(Math.exp(r*e)-1)/(Math.exp(r)-1))*Math.sin((6.283185307179586*t+1.5707963267948966)*e)},t})(t);e.ElasticEase=s;var a=(function(e){function t(t){void 0===t&&(t=2);var r=e.call(this)||this;return r.exponent=t,r}return __extends(t,e),t.prototype.easeInCore=function(e){return this.exponent<=0?e:(Math.exp(this.exponent*e)-1)/(Math.exp(this.exponent)-1)},t})(t);e.ExponentialEase=a;var u=(function(e){function t(t){void 0===t&&(t=2);var r=e.call(this)||this;return r.power=t,r}return __extends(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.power);return Math.pow(e,t)},t})(t);e.PowerEase=u;var l=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.easeInCore=function(e){return e*e},t})(t);e.QuadraticEase=l;var c=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.easeInCore=function(e){return e*e*e*e},t})(t);e.QuarticEase=c;var h=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.easeInCore=function(e){return e*e*e*e*e},t})(t);e.QuinticEase=h;var f=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.easeInCore=function(e){return 1-Math.sin(1.5707963267948966*(1-e))},t})(t);e.SineEase=f;var d=(function(t){function r(e,r,i,n){void 0===e&&(e=0),void 0===r&&(r=0),void 0===i&&(i=1),void 0===n&&(n=1);var o=t.call(this)||this;return o.x1=e,o.y1=r,o.x2=i,o.y2=n,o}return __extends(r,t),r.prototype.easeInCore=function(t){return e.BezierCurve.interpolate(t,this.x1,this.y1,this.x2,this.y2)},r})(t);e.BezierCurveEase=d})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){e.CameraInputTypes={};var t=(function(){function t(e){this.attached={},this.camera=e,this.checkInputs=function(){}}return t.prototype.add=function(t){var r=t.getSimpleName();if(this.attached[r])return void e.Tools.Warn("camera input of type "+r+" already exists on camera");this.attached[r]=t,t.camera=this.camera,t.checkInputs&&(this.checkInputs=this._addCheckInputs(t.checkInputs.bind(t))),this.attachedElement&&t.attachControl(this.attachedElement)},t.prototype.remove=function(e){for(var t in this.attached){var r=this.attached[t];r===e&&(r.detachControl(this.attachedElement),delete this.attached[t],this.rebuildInputCheck())}},t.prototype.removeByType=function(e){for(var t in this.attached){var r=this.attached[t];r.getClassName()===e&&(r.detachControl(this.attachedElement),delete this.attached[t],this.rebuildInputCheck())}},t.prototype._addCheckInputs=function(e){var t=this.checkInputs;return function(){t(),e()}},t.prototype.attachInput=function(e){e.attachControl(this.attachedElement,this.noPreventDefault)},t.prototype.attachElement=function(t,r){if(!this.attachedElement){r=!e.Camera.ForceAttachControlToAlwaysPreventDefault&&r,this.attachedElement=t,this.noPreventDefault=r;for(var i in this.attached){this.attached[i];this.attached[i].attachControl(t,r)}}},t.prototype.detachElement=function(e){if(this.attachedElement===e){for(var t in this.attached){this.attached[t];this.attached[t].detachControl(e)}this.attachedElement=null}},t.prototype.rebuildInputCheck=function(){this.checkInputs=function(){};for(var e in this.attached){var t=this.attached[e];t.checkInputs&&(this.checkInputs=this._addCheckInputs(t.checkInputs.bind(t)))}},t.prototype.clear=function(){this.attachedElement&&this.detachElement(this.attachedElement),this.attached={},this.attachedElement=null,this.checkInputs=function(){}},t.prototype.serialize=function(t){var r={};for(var i in this.attached){var n=this.attached[i],o=e.SerializationHelper.Serialize(n);r[n.getClassName()]=o}t.inputsmgr=r},t.prototype.parse=function(t){var r=t.inputsmgr;if(r){this.clear();for(var i in r){var n=e.CameraInputTypes[i];if(n){var o=r[i],s=e.SerializationHelper.Parse((function(){return new n}),o,null);this.add(s)}}}else for(var i in this.attached){var n=e.CameraInputTypes[this.attached[i].getClassName()];if(n){var s=e.SerializationHelper.Parse((function(){return new n}),t,null);this.remove(this.attached[i]),this.add(s)}}},t})();e.CameraInputsManager=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(r,i,n){var o=t.call(this,r,i,n)||this;return o.cameraDirection=new e.Vector3(0,0,0),o.cameraRotation=new e.Vector2(0,0),o.rotation=new e.Vector3(0,0,0),o.speed=2,o.noRotationConstraint=!1,o.lockedTarget=null,o._currentTarget=e.Vector3.Zero(),o._viewMatrix=e.Matrix.Zero(),o._camMatrix=e.Matrix.Zero(),o._cameraTransformMatrix=e.Matrix.Zero(),o._cameraRotationMatrix=e.Matrix.Zero(),o._referencePoint=new e.Vector3(0,0,1),o._defaultUpVector=new e.Vector3(0,1,0),o._transformedReferencePoint=e.Vector3.Zero(),o._lookAtTemp=e.Matrix.Zero(),o._tempMatrix=e.Matrix.Zero(),o}return __extends(r,t),r.prototype.getFrontPosition=function(e){var t=this.getTarget().subtract(this.position);return t.normalize(),t.scaleInPlace(e),this.globalPosition.add(t)},r.prototype._getLockedTargetPosition=function(){return this.lockedTarget?(this.lockedTarget.absolutePosition&&this.lockedTarget.computeWorldMatrix(),this.lockedTarget.absolutePosition||this.lockedTarget):null},r.prototype._initCache=function(){t.prototype._initCache.call(this),this._cache.lockedTarget=new e.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.rotation=new e.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.rotationQuaternion=new e.Quaternion(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)},r.prototype._updateCache=function(e){e||t.prototype._updateCache.call(this);var r=this._getLockedTargetPosition();r?this._cache.lockedTarget?this._cache.lockedTarget.copyFrom(r):this._cache.lockedTarget=r.clone():this._cache.lockedTarget=null,this._cache.rotation.copyFrom(this.rotation),this.rotationQuaternion&&this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion)},r.prototype._isSynchronizedViewMatrix=function(){if(!t.prototype._isSynchronizedViewMatrix.call(this))return!1;var e=this._getLockedTargetPosition();return(this._cache.lockedTarget?this._cache.lockedTarget.equals(e):!e)&&(this.rotationQuaternion?this.rotationQuaternion.equals(this._cache.rotationQuaternion):this._cache.rotation.equals(this.rotation))},r.prototype._computeLocalCameraSpeed=function(){var e=this.getEngine();return this.speed*Math.sqrt(e.getDeltaTime()/(100*e.getFps()))},r.prototype.setTarget=function(t){this.upVector.normalize(),e.Matrix.LookAtLHToRef(this.position,t,this._defaultUpVector,this._camMatrix),this._camMatrix.invert(),this.rotation.x=Math.atan(this._camMatrix.m[6]/this._camMatrix.m[10]);var r=t.subtract(this.position);r.x>=0?this.rotation.y=-Math.atan(r.z/r.x)+Math.PI/2:this.rotation.y=-Math.atan(r.z/r.x)-Math.PI/2,this.rotation.z=0,isNaN(this.rotation.x)&&(this.rotation.x=0),isNaN(this.rotation.y)&&(this.rotation.y=0),isNaN(this.rotation.z)&&(this.rotation.z=0),this.rotationQuaternion&&e.Quaternion.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this.rotationQuaternion)},r.prototype.getTarget=function(){return this._currentTarget},r.prototype._decideIfNeedsToMove=function(){return Math.abs(this.cameraDirection.x)>0||Math.abs(this.cameraDirection.y)>0||Math.abs(this.cameraDirection.z)>0},r.prototype._updatePosition=function(){if(this.parent)return this.parent.getWorldMatrix().invertToRef(e.Tmp.Matrix[0]),e.Vector3.TransformNormalToRef(this.cameraDirection,e.Tmp.Matrix[0],e.Tmp.Vector3[0]),void this.position.addInPlace(e.Tmp.Vector3[0]);this.position.addInPlace(this.cameraDirection)},r.prototype._checkInputs=function(){var r=this._decideIfNeedsToMove(),i=Math.abs(this.cameraRotation.x)>0||Math.abs(this.cameraRotation.y)>0;if(r&&this._updatePosition(),i){if(this.rotation.x+=this.cameraRotation.x,this.rotation.y+=this.cameraRotation.y,this.rotationQuaternion){this.rotation.lengthSquared()&&e.Quaternion.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this.rotationQuaternion)}if(!this.noRotationConstraint){var n=Math.PI/2*.95;this.rotation.x>n&&(this.rotation.x=n),this.rotation.x<-n&&(this.rotation.x=-n)}}r&&(Math.abs(this.cameraDirection.x)=0&&i._keys.splice(t,1),e.preventDefault&&(r||e.preventDefault())}},this._onLostFocus=function(){i._keys=[]},t.addEventListener("keydown",this._onKeyDown,!1),t.addEventListener("keyup",this._onKeyUp,!1),e.Tools.RegisterTopRootEvents([{name:"blur",handler:this._onLostFocus}])},t.prototype.detachControl=function(t){t&&(t.removeEventListener("keydown",this._onKeyDown),t.removeEventListener("keyup",this._onKeyUp)),e.Tools.UnregisterTopRootEvents([{name:"blur",handler:this._onLostFocus}]),this._keys=[],this._onKeyDown=null,this._onKeyUp=null,this._onLostFocus=null},t.prototype.checkInputs=function(){if(this._onKeyDown)for(var e=this.camera,t=0;tMath.PI&&(this.beta=this.beta-2*Math.PI):this.betathis.upperBetaLimit&&(this.beta=this.upperBetaLimit),this.lowerAlphaLimit&&this.alphathis.upperAlphaLimit&&(this.alpha=this.upperAlphaLimit),this.lowerRadiusLimit&&this.radiusthis.upperRadiusLimit&&(this.radius=this.upperRadiusLimit)},r.prototype.rebuildAnglesAndRadius=function(){var e=this.position.subtract(this._getTargetPosition());this.radius=e.length(),this.alpha=Math.acos(e.x/Math.sqrt(Math.pow(e.x,2)+Math.pow(e.z,2))),e.z<0&&(this.alpha=2*Math.PI-this.alpha),this.beta=Math.acos(e.y/this.radius),this._checkLimits()},r.prototype.setPosition=function(e){this.position.equals(e)||(this.position.copyFrom(e),this.rebuildAnglesAndRadius())},r.prototype.setTarget=function(e,t,r){if(void 0===t&&(t=!1),void 0===r&&(r=!1),e.getBoundingInfo)this._targetBoundingCenter=t?e.getBoundingInfo().boundingBox.centerWorld.clone():null,this._targetHost=e,this._target=this._getTargetPosition();else{var i=e,n=this._getTargetPosition();if(n&&!r&&n.equals(i))return;this._target=i,this._targetBoundingCenter=null}this.rebuildAnglesAndRadius()},r.prototype._getViewMatrix=function(){var t=Math.cos(this.alpha),r=Math.sin(this.alpha),i=Math.cos(this.beta),n=Math.sin(this.beta);0===n&&(n=1e-4);var o=this._getTargetPosition();if(o.addToRef(new e.Vector3(this.radius*t*n,this.radius*i,this.radius*r*n),this._newPosition),this.getScene().collisionsEnabled&&this.checkCollisions)this._collider||(this._collider=new e.Collider),this._collider.radius=this.collisionRadius,this._newPosition.subtractToRef(this.position,this._collisionVelocity),this._collisionTriggered=!0,this.getScene().collisionCoordinator.getNewPosition(this.position,this._collisionVelocity,this._collider,3,null,this._onCollisionPositionChange,this.uniqueId);else{this.position.copyFrom(this._newPosition);var s=this.upVector;this.allowUpsideDown&&n<0&&(s=s.clone(),s=s.negate()),this.getScene().useRightHandedSystem?e.Matrix.LookAtRHToRef(this.position,o,s,this._viewMatrix):e.Matrix.LookAtLHToRef(this.position,o,s,this._viewMatrix),this._viewMatrix.m[12]+=this.targetScreenOffset.x,this._viewMatrix.m[13]+=this.targetScreenOffset.y}return this._currentTarget=o,this._viewMatrix},r.prototype.zoomOn=function(t,r){void 0===r&&(r=!1),t=t||this.getScene().meshes;var i=e.Mesh.MinMax(t),n=e.Vector3.Distance(i.min,i.max);this.radius=n*this.zoomOnFactor,this.focusOn({min:i.min,max:i.max,distance:n},r)},r.prototype.focusOn=function(t,r){void 0===r&&(r=!1);var i,n;void 0===t.min?(i=t||this.getScene().meshes,i=e.Mesh.MinMax(i),n=e.Vector3.Distance(i.min,i.max)):(i=t,n=t.distance),this._target=e.Mesh.Center(i),r||(this.maxZ=2*n)},r.prototype.createRigCamera=function(t,i){var n;switch(this.cameraRigMode){case e.Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case e.Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER:case e.Camera.RIG_MODE_VR:n=this._cameraRigParams.stereoHalfAngle*(0===i?1:-1);break;case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:n=this._cameraRigParams.stereoHalfAngle*(0===i?-1:1)}var o=new r(t,this.alpha+n,this.beta,this.radius,this._target,this.getScene());return o._cameraRigParams={},o},r.prototype._updateRigCameras=function(){var r=this._rigCameras[0],i=this._rigCameras[1];switch(r.beta=i.beta=this.beta,r.radius=i.radius=this.radius,this.cameraRigMode){case e.Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case e.Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER:case e.Camera.RIG_MODE_VR:r.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle,i.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle;break;case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:r.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle,i.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle}t.prototype._updateRigCameras.call(this)},r.prototype.dispose=function(){this.inputs.clear(),t.prototype.dispose.call(this)},r.prototype.getClassName=function(){return"ArcRotateCamera"},r})(e.TargetCamera);__decorate([e.serialize()],t.prototype,"alpha",void 0),__decorate([e.serialize()],t.prototype,"beta",void 0),__decorate([e.serialize()],t.prototype,"radius",void 0),__decorate([e.serializeAsVector3("target")],t.prototype,"_target",void 0),__decorate([e.serialize()],t.prototype,"inertialAlphaOffset",void 0),__decorate([e.serialize()],t.prototype,"inertialBetaOffset",void 0),__decorate([e.serialize()],t.prototype,"inertialRadiusOffset",void 0),__decorate([e.serialize()],t.prototype,"lowerAlphaLimit",void 0),__decorate([e.serialize()],t.prototype,"upperAlphaLimit",void 0),__decorate([e.serialize()],t.prototype,"lowerBetaLimit",void 0),__decorate([e.serialize()],t.prototype,"upperBetaLimit",void 0),__decorate([e.serialize()],t.prototype,"lowerRadiusLimit",void 0),__decorate([e.serialize()],t.prototype,"upperRadiusLimit",void 0),__decorate([e.serialize()],t.prototype,"inertialPanningX",void 0),__decorate([e.serialize()],t.prototype,"inertialPanningY",void 0),__decorate([e.serialize()],t.prototype,"panningInertia",void 0),__decorate([e.serialize()],t.prototype,"zoomOnFactor",void 0),__decorate([e.serialize()],t.prototype,"allowUpsideDown",void 0),e.ArcRotateCamera=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(e){return t.call(this,e)||this}return __extends(r,t),r.prototype.addMouseWheel=function(){return this.add(new e.ArcRotateCameraMouseWheelInput),this},r.prototype.addPointers=function(){return this.add(new e.ArcRotateCameraPointersInput),this},r.prototype.addKeyboard=function(){return this.add(new e.ArcRotateCameraKeyboardMoveInput),this},r.prototype.addGamepad=function(){return this.add(new e.ArcRotateCameraGamepadInput),this},r.prototype.addVRDeviceOrientation=function(){return this.add(new e.ArcRotateCameraVRDeviceOrientationInput),this},r})(e.CameraInputsManager);e.ArcRotateCameraInputsManager=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(r,i,n,o,s,a,u,l,c,h){void 0===a&&(a=null),void 0===u&&(u=null),void 0===l&&(l=e.Engine.TEXTUREFORMAT_RGBA),void 0===c&&(c=!1),void 0===h&&(h=null);var f=t.call(this,i)||this;if(f.coordinatesMode=e.Texture.CUBIC_MODE,f.name=r,f.url=r,f._noMipmap=o,f.hasAlpha=!1,f._format=l,f._prefiltered=c,f.isCube=!0,f._textureMatrix=e.Matrix.Identity(),c&&(f.gammaSpace=!1),!r&&!s)return f;if(f._texture=f._getFromCache(r,o),!s){n||(n=["_px.jpg","_py.jpg","_pz.jpg","_nx.jpg","_ny.jpg","_nz.jpg"]),s=[];for(var d=0;d0&&(this._postProcesses[0].autoClear=!1))}},r.prototype._shouldRender=function(){return-1===this._currentRefreshId?(this._currentRefreshId=1,!0):this.refreshRate===this._currentRefreshId?(this._currentRefreshId=1,!0):(this._currentRefreshId++,!1)},r.prototype.isReady=function(){return!!this.getScene().renderTargetsEnabled&&t.prototype.isReady.call(this)},r.prototype.getRenderSize=function(){return this._size},Object.defineProperty(r.prototype,"canRescale",{get:function(){return!0},enumerable:!0,configurable:!0}),r.prototype.scale=function(e){var t=this._size*e;this.resize(t)},r.prototype.getReflectionTextureMatrix=function(){return this.isCube?this._textureMatrix:t.prototype.getReflectionTextureMatrix.call(this)},r.prototype.resize=function(e){this.releaseInternalTexture(),this.isCube?this._texture=this.getScene().getEngine().createRenderTargetCubeTexture(e,this._renderTargetOptions):this._texture=this.getScene().getEngine().createRenderTargetTexture(e,this._renderTargetOptions)},r.prototype.render=function(e,t){var r=this.getScene(),i=r.getEngine();if(void 0!==this.useCameraPostProcesses&&(e=this.useCameraPostProcesses),this._waitingRenderList){this.renderList=[];for(var n=0;n=0&&this._renderingManager.dispatchParticles(m))}if(this.isCube)for(var y=0;y<6;y++)this.renderToTarget(y,l,c,e,t),r.incrementRenderId(),r.resetCachedMaterial();else this.renderToTarget(0,l,c,e,t);this.onAfterUnbindObservable.notifyObservers(this),this.activeCamera&&this.activeCamera!==r.activeCamera&&r.setTransformMatrix(r.activeCamera.getViewMatrix(),r.activeCamera.getProjectionMatrix(!0)),i.setViewport(r.activeCamera.viewport),r.resetCachedMaterial()}},r.prototype.renderToTarget=function(t,r,i,n,o){var s=this,a=this.getScene(),u=a.getEngine();this._postProcessManager?this._postProcessManager._prepareFrame(this._texture,this._postProcesses):n&&a.postProcessManager._prepareFrame(this._texture)||(this.isCube?u.bindFramebuffer(this._texture,t):u.bindFramebuffer(this._texture)),this.onBeforeRenderObservable.notifyObservers(t),this.onClearObservable.hasObservers()?this.onClearObservable.notifyObservers(u):u.clear(a.clearColor,!0,!0,!0),this._doNotChangeAspectRatio||a.updateTransformMatrix(!0),this._renderingManager.render(this.customRenderFunction,r,this.renderParticles,this.renderSprites),this._postProcessManager?this._postProcessManager._finalizeFrame(!1,this._texture,t,this._postProcesses):n&&a.postProcessManager._finalizeFrame(!1,this._texture,t),this._doNotChangeAspectRatio||a.updateTransformMatrix(!0),o&&e.Tools.DumpFramebuffer(this._size,this._size,u), -this.isCube&&5!==t?this.onAfterRenderObservable.notifyObservers(t):(this.isCube&&5===t&&u.generateMipMapsForCubemap(this._texture),u.unBindFramebuffer(this._texture,this.isCube,(function(){s.onAfterRenderObservable.notifyObservers(t)})))},r.prototype.setRenderingOrder=function(e,t,r,i){void 0===t&&(t=null),void 0===r&&(r=null),void 0===i&&(i=null),this._renderingManager.setRenderingOrder(e,t,r,i)},r.prototype.setRenderingAutoClearDepthStencil=function(e,t){this._renderingManager.setRenderingAutoClearDepthStencil(e,t)},r.prototype.clone=function(){var e=this.getSize(),t=new r(this.name,e.width,this.getScene(),this._renderTargetOptions.generateMipMaps,this._doNotChangeAspectRatio,this._renderTargetOptions.type,this.isCube,this._renderTargetOptions.samplingMode,this._renderTargetOptions.generateDepthBuffer,this._renderTargetOptions.generateStencilBuffer);return t.hasAlpha=this.hasAlpha,t.level=this.level,t.coordinatesMode=this.coordinatesMode,t.renderList=this.renderList.slice(0),t},r.prototype.serialize=function(){if(!this.name)return null;var e=t.prototype.serialize.call(this);e.renderTargetSize=this.getRenderSize(),e.renderList=[];for(var r=0;r=0&&e.customRenderTargets.splice(r,1);for(var i=0,n=e.cameras;i=0&&o.customRenderTargets.splice(r,1)}t.prototype.dispose.call(this)},r})(e.Texture);t._REFRESHRATE_RENDER_ONCE=0,t._REFRESHRATE_RENDER_ONEVERYFRAME=1,t._REFRESHRATE_RENDER_ONEVERYTWOFRAMES=2,e.RenderTargetTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(r,i,n,o,s){var a=this;s=s||{};var u=!!s.generateMipMaps&&s.generateMipMaps,l=!!s.generateDepthTexture&&s.generateDepthTexture,c=void 0===s.doNotChangeAspectRatio||s.doNotChangeAspectRatio;if(a=t.call(this,r,i,o,u,c)||this,!a.isSupported)return void a.dispose();for(var h=[],f=[],d=0;d1||e.getCaps().drawBuffersExtension},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"textures",{get:function(){return this._textures},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"depthTexture",{get:function(){return this._textures[this._textures.length-1]},enumerable:!0,configurable:!0}),r.prototype._createInternalTextures=function(){this._textures=[];for(var t=0;t=0;e--)void 0!==this._webGLTextures[e]&&(this.getScene().getEngine().releaseInternalTexture(this._webGLTextures[e]),this._webGLTextures.splice(e,1))},r})(e.RenderTargetTexture);e.MultiRenderTarget=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(r,i,n,o,s,a,u){void 0===s&&(s=e.Engine.TEXTURETYPE_UNSIGNED_INT),void 0===a&&(a=e.Texture.BILINEAR_SAMPLINGMODE),void 0===u&&(u=!0);var l=t.call(this,r,i,n,o,!0,s,!1,a,u)||this;return l.mirrorPlane=new e.Plane(0,1,0,1),l._transformMatrix=e.Matrix.Zero(),l._mirrorMatrix=e.Matrix.Zero(),l._blurKernelX=0,l._blurKernelY=0,l._blurRatio=1,l.onBeforeRenderObservable.add((function(){e.Matrix.ReflectionToRef(l.mirrorPlane,l._mirrorMatrix),l._savedViewMatrix=n.getViewMatrix(),l._mirrorMatrix.multiplyToRef(l._savedViewMatrix,l._transformMatrix),n.setTransformMatrix(l._transformMatrix,n.getProjectionMatrix()),n.clipPlane=l.mirrorPlane,n.getEngine().cullBackFaces=!1,n._mirroredCameraPosition=e.Vector3.TransformCoordinates(n.activeCamera.globalPosition,l._mirrorMatrix)})),l.onAfterRenderObservable.add((function(){n.setTransformMatrix(l._savedViewMatrix,n.getProjectionMatrix()),n.getEngine().cullBackFaces=!0,n._mirroredCameraPosition=null,delete n.clipPlane})),l}return __extends(r,t),Object.defineProperty(r.prototype,"blurRatio",{get:function(){return this._blurRatio},set:function(e){this._blurRatio!==e&&(this._blurRatio=e,this._preparePostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"blurKernel",{set:function(e){this.blurKernelX=e,this.blurKernelY=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"blurKernelX",{get:function(){return this._blurKernelX},set:function(e){this._blurKernelX!==e&&(this._blurKernelX=e,this._preparePostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"blurKernelY",{get:function(){return this._blurKernelY},set:function(e){this._blurKernelY!==e&&(this._blurKernelY=e,this._preparePostProcesses())},enumerable:!0,configurable:!0}),r.prototype._preparePostProcesses=function(){if(this.clearPostProcesses(!0),this._blurKernelX&&this._blurKernelY){var t=this.getScene().getEngine(),r=t.getCaps().textureFloatRender?e.Engine.TEXTURETYPE_FLOAT:e.Engine.TEXTURETYPE_HALF_FLOAT;this._blurX=new e.BlurPostProcess("horizontal blur",new e.Vector2(1,0),this._blurKernelX,this._blurRatio,null,e.Texture.BILINEAR_SAMPLINGMODE,t,!1,r),this._blurX.autoClear=!1,1===this._blurRatio&&this.samples<2?this._blurX.outputTexture=this._texture:this._blurX.alwaysForcePOT=!0,this._blurY=new e.BlurPostProcess("vertical blur",new e.Vector2(0,1),this._blurKernelY,this._blurRatio,null,e.Texture.BILINEAR_SAMPLINGMODE,t,!1,r),this._blurY.autoClear=!1,this._blurY.alwaysForcePOT=1!==this._blurRatio,this.addPostProcess(this._blurX),this.addPostProcess(this._blurY)}},r.prototype.clone=function(){var e=this.getSize(),t=new r(this.name,e.width,this.getScene(),this._renderTargetOptions.generateMipMaps,this._renderTargetOptions.type,this._renderTargetOptions.samplingMode,this._renderTargetOptions.generateDepthBuffer);return t.hasAlpha=this.hasAlpha,t.level=this.level,t.mirrorPlane=this.mirrorPlane.clone(),t.renderList=this.renderList.slice(0),t},r.prototype.serialize=function(){if(!this.name)return null;var e=t.prototype.serialize.call(this);return e.mirrorPlane=this.mirrorPlane.asArray(),e},r})(e.RenderTargetTexture);e.MirrorTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(r,i,n,o){var s=t.call(this,r,i,n,o,!0)||this;return s.refractionPlane=new e.Plane(0,1,0,1),s.depth=2,s.onBeforeRenderObservable.add((function(){n.clipPlane=s.refractionPlane})),s.onAfterRenderObservable.add((function(){delete n.clipPlane})),s}return __extends(r,t),r.prototype.clone=function(){var e=this.getSize(),t=new r(this.name,e.width,this.getScene(),this._generateMipMaps);return t.hasAlpha=this.hasAlpha,t.level=this.level,t.refractionPlane=this.refractionPlane.clone(),t.renderList=this.renderList.slice(0),t.depth=this.depth,t},r.prototype.serialize=function(){if(!this.name)return null;var e=t.prototype.serialize.call(this);return e.mirrorPlane=this.refractionPlane.asArray(),e.depth=this.depth,e},r})(e.RenderTargetTexture);e.RefractionTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(r,i,n,o,s,a){void 0===s&&(s=e.Texture.TRILINEAR_SAMPLINGMODE),void 0===a&&(a=e.Engine.TEXTUREFORMAT_RGBA);var u=t.call(this,null,n,!o,void 0,s,void 0,void 0,void 0,void 0,a)||this;u.name=r;var l=u.getScene().getEngine();u.wrapU=e.Texture.CLAMP_ADDRESSMODE,u.wrapV=e.Texture.CLAMP_ADDRESSMODE,u._generateMipMaps=o,i.getContext?(u._canvas=i,u._texture=l.createDynamicTexture(i.width,i.height,o,s)):(u._canvas=document.createElement("canvas"),i.width?u._texture=l.createDynamicTexture(i.width,i.height,o,s):u._texture=l.createDynamicTexture(i,i,o,s));var c=u.getSize();return u._canvas.width=c.width,u._canvas.height=c.height,u._context=u._canvas.getContext("2d"),u}return __extends(r,t),Object.defineProperty(r.prototype,"canRescale",{get:function(){return!0},enumerable:!0,configurable:!0}),r.prototype._recreate=function(e){this._canvas.width=e.width,this._canvas.height=e.height,this.releaseInternalTexture(),this._texture=this.getScene().getEngine().createDynamicTexture(e.width,e.height,this._generateMipMaps,this._samplingMode)},r.prototype.scale=function(e){var t=this.getSize();t.width*=e,t.height*=e,this._recreate(t)},r.prototype.scaleTo=function(e,t){var r=this.getSize();r.width=e,r.height=t,this._recreate(r)},r.prototype.getContext=function(){return this._context},r.prototype.clear=function(){var e=this.getSize();this._context.fillRect(0,0,e.width,e.height)},r.prototype.update=function(e){this.getScene().getEngine().updateDynamicTexture(this._texture,this._canvas,void 0===e||e,void 0,this._format)},r.prototype.drawText=function(e,t,r,i,n,o,s,a){void 0===a&&(a=!0);var u=this.getSize();if(o&&(this._context.fillStyle=o,this._context.fillRect(0,0,u.width,u.height)),this._context.font=i,null===t||void 0===t){var l=this._context.measureText(e);t=(u.width-l.width)/2}if(null===r||void 0===r){var c=parseInt(i.replace(/\D/g,""));r=u.height/2+c/3.65}this._context.fillStyle=n,this._context.fillText(e,t,r),a&&this.update(s)},r.prototype.clone=function(){var e=this.getSize(),t=new r(this.name,e,this.getScene(),this._generateMipMaps);return t.hasAlpha=this.hasAlpha,t.level=this.level,t.wrapU=this.wrapU,t.wrapV=this.wrapV,t},r})(e.Texture);e.DynamicTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(r,i,n,o,s,a){void 0===o&&(o=!1),void 0===s&&(s=!1),void 0===a&&(a=e.Texture.TRILINEAR_SAMPLINGMODE);var u=t.call(this,null,n,!o,s)||this;u._autoLaunch=!0;var l;return u.name=r,i instanceof HTMLVideoElement?u.video=i:(l=i,u.video=document.createElement("video"),u.video.autoplay=!1,u.video.loop=!0),u._generateMipMaps=o,u._samplingMode=a,!u.getScene().getEngine().needPOTTextures||e.Tools.IsExponentOfTwo(u.video.videoWidth)&&e.Tools.IsExponentOfTwo(u.video.videoHeight)?(u.wrapU=e.Texture.WRAP_ADDRESSMODE,u.wrapV=e.Texture.WRAP_ADDRESSMODE):(u.wrapU=e.Texture.CLAMP_ADDRESSMODE,u.wrapV=e.Texture.CLAMP_ADDRESSMODE,u._generateMipMaps=!1),l?(u.video.addEventListener("canplay",(function(){u._createTexture()})),l.forEach((function(e){var t=document.createElement("source");t.src=e,u.video.appendChild(t)}))):u._createTexture(),u._lastUpdate=e.Tools.Now,u}return __extends(r,t),r.prototype.__setTextureReady=function(){this._texture.isReady=!0},r.prototype._createTexture=function(){this._texture=this.getScene().getEngine().createDynamicTexture(this.video.videoWidth,this.video.videoHeight,this._generateMipMaps,this._samplingMode),this._autoLaunch&&(this._autoLaunch=!1,this.video.play()),this._setTextureReady=this.__setTextureReady.bind(this),this.video.addEventListener("playing",this._setTextureReady)},r.prototype.update=function(){var t=e.Tools.Now;return!(t-this._lastUpdate<15||this.video.readyState!==this.video.HAVE_ENOUGH_DATA)&&(this._lastUpdate=t,this.getScene().getEngine().updateVideoTexture(this._texture,this.video,this._invertY),!0)},r.prototype.dispose=function(){t.prototype.dispose.call(this),this.video.removeEventListener("playing",this._setTextureReady)},r.CreateFromWebCam=function(t,r,i){var n,o=document.createElement("video");i&&i.deviceId&&(n={exact:i.deviceId}),navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia,window.URL=window.URL||window.webkitURL||window.mozURL||window.msURL,navigator.getUserMedia&&navigator.getUserMedia({video:{deviceId:n,width:{min:i&&i.minWidth||256,max:i&&i.maxWidth||640},height:{min:i&&i.minHeight||256,max:i&&i.maxHeight||480}}},(function(i){void 0!==o.mozSrcObject?o.mozSrcObject=i:o.src=window.URL&&window.URL.createObjectURL(i)||i,o.play(),r&&r(new e.VideoTexture("video",o,t,!0,!0))}),(function(t){e.Tools.Error(t.name)}))},r})(e.Texture);e.VideoTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(r,i,n,o,s,a,u,l){void 0===a&&(a=!0),void 0===u&&(u=!1),void 0===l&&(l=e.Texture.TRILINEAR_SAMPLINGMODE);var c=t.call(this,null,s,!a,u)||this;return c.format=o,c._texture=s.getEngine().createRawTexture(r,i,n,o,a,u,l),c.wrapU=e.Texture.CLAMP_ADDRESSMODE,c.wrapV=e.Texture.CLAMP_ADDRESSMODE,c}return __extends(r,t),r.prototype.update=function(e){this.getScene().getEngine().updateRawTexture(this._texture,e,this.format,this._invertY)},r.CreateLuminanceTexture=function(t,i,n,o,s,a,u){return void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===u&&(u=e.Texture.TRILINEAR_SAMPLINGMODE),new r(t,i,n,e.Engine.TEXTUREFORMAT_LUMINANCE,o,s,a,u)},r.CreateLuminanceAlphaTexture=function(t,i,n,o,s,a,u){return void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===u&&(u=e.Texture.TRILINEAR_SAMPLINGMODE),new r(t,i,n,e.Engine.TEXTUREFORMAT_LUMINANCE_ALPHA,o,s,a,u)},r.CreateAlphaTexture=function(t,i,n,o,s,a,u){return void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===u&&(u=e.Texture.TRILINEAR_SAMPLINGMODE),new r(t,i,n,e.Engine.TEXTUREFORMAT_ALPHA,o,s,a,u)},r.CreateRGBTexture=function(t,i,n,o,s,a,u){return void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===u&&(u=e.Texture.TRILINEAR_SAMPLINGMODE),new r(t,i,n,e.Engine.TEXTUREFORMAT_RGB,o,s,a,u)},r.CreateRGBATexture=function(t,i,n,o,s,a,u){return void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===u&&(u=e.Texture.TRILINEAR_SAMPLINGMODE),new r(t,i,n,e.Engine.TEXTUREFORMAT_RGBA,o,s,a,u)},r})(e.Texture);e.RawTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){var r=(function(){function t(){}return t.GetTGAHeader=function(e){var t=0;return{id_length:e[t++],colormap_type:e[t++],image_type:e[t++],colormap_index:e[t++]|e[t++]<<8,colormap_length:e[t++]|e[t++]<<8,colormap_size:e[t++],origin:[e[t++]|e[t++]<<8,e[t++]|e[t++]<<8],width:e[t++]|e[t++]<<8,height:e[t++]|e[t++]<<8,pixel_size:e[t++],flags:e[t++]}},t.UploadContent=function(r,i){if(i.length<19)return void e.Tools.Error("Unable to load TGA file - Not enough data to contain header");var n=18,o=t.GetTGAHeader(i);if(o.id_length+n>i.length)return void e.Tools.Error("Unable to load TGA file - Not enough data");n+=o.id_length;var s=!1,a=!1,u=!1;switch(o.image_type){case t._TYPE_RLE_INDEXED:s=!0;case t._TYPE_INDEXED:a=!0;break;case t._TYPE_RLE_RGB:s=!0;case t._TYPE_RGB:!0;break;case t._TYPE_RLE_GREY:s=!0;case t._TYPE_GREY:u=!0}var l,c,h=(o.flags,o.pixel_size>>3),f=o.width*o.height*h;if(a&&(c=i.subarray(n,n+=o.colormap_length*(o.colormap_size>>3))),s){l=new Uint8Array(f);for(var d,p,g,_=0,m=new Uint8Array(h);n>t._ORIGIN_SHIFT){default:case t._ORIGIN_UL:v=0,A=1,b=o.width,y=0,E=1,T=o.height;break;case t._ORIGIN_BL:v=0,A=1,b=o.width,y=o.height-1,E=-1,T=-1;break;case t._ORIGIN_UR:v=o.width-1,A=-1,b=-1,y=0,E=1,T=o.height;break;case t._ORIGIN_BR:v=o.width-1,A=-1,b=-1,y=o.height-1,E=-1,T=-1}var x="_getImageData"+(u?"Grey":"")+o.pixel_size+"bits",M=t[x](o,c,l,y,E,T,v,A,b);r.texImage2D(r.TEXTURE_2D,0,r.RGBA,o.width,o.height,0,r.RGBA,r.UNSIGNED_BYTE,M)},t._getImageData8bits=function(e,t,r,i,n,o,s,a,u){var l,c,h,f=r,d=t,p=e.width,g=e.height,_=0,m=new Uint8Array(p*g*4);for(h=i;h!==o;h+=n)for(c=s;c!==u;c+=a,_++)l=f[_],m[4*(c+p*h)+3]=255,m[4*(c+p*h)+2]=d[3*l+0],m[4*(c+p*h)+1]=d[3*l+1],m[4*(c+p*h)+0]=d[3*l+2];return m},t._getImageData16bits=function(e,t,r,i,n,o,s,a,u){var l,c,h,f=r,d=e.width,p=e.height,g=0,_=new Uint8Array(d*p*4);for(h=i;h!==o;h+=n)for(c=s;c!==u;c+=a,g+=2)l=f[g+0]+(f[g+1]<<8),_[4*(c+d*h)+0]=(31744&l)>>7,_[4*(c+d*h)+1]=(992&l)>>2,_[4*(c+d*h)+2]=(31&l)>>3,_[4*(c+d*h)+3]=32768&l?0:255;return _},t._getImageData24bits=function(e,t,r,i,n,o,s,a,u){var l,c,h=r,f=e.width,d=e.height,p=0,g=new Uint8Array(f*d*4);for(c=i;c!==o;c+=n)for(l=s;l!==u;l+=a,p+=3)g[4*(l+f*c)+3]=255,g[4*(l+f*c)+2]=h[p+0],g[4*(l+f*c)+1]=h[p+1],g[4*(l+f*c)+0]=h[p+2];return g},t._getImageData32bits=function(e,t,r,i,n,o,s,a,u){var l,c,h=r,f=e.width,d=e.height,p=0,g=new Uint8Array(f*d*4);for(c=i;c!==o;c+=n)for(l=s;l!==u;l+=a,p+=4)g[4*(l+f*c)+2]=h[p+0],g[4*(l+f*c)+1]=h[p+1],g[4*(l+f*c)+0]=h[p+2],g[4*(l+f*c)+3]=h[p+3];return g},t._getImageDataGrey8bits=function(e,t,r,i,n,o,s,a,u){var l,c,h,f=r,d=e.width,p=e.height,g=0,_=new Uint8Array(d*p*4);for(h=i;h!==o;h+=n)for(c=s;c!==u;c+=a,g++)l=f[g],_[4*(c+d*h)+0]=l,_[4*(c+d*h)+1]=l,_[4*(c+d*h)+2]=l,_[4*(c+d*h)+3]=255;return _},t._getImageDataGrey16bits=function(e,t,r,i,n,o,s,a,u){var l,c,h=r,f=e.width,d=e.height,p=0,g=new Uint8Array(f*d*4);for(c=i;c!==o;c+=n)for(l=s;l!==u;l+=a,p+=2)g[4*(l+f*c)+0]=h[p+0],g[4*(l+f*c)+1]=h[p+0],g[4*(l+f*c)+2]=h[p+0],g[4*(l+f*c)+3]=h[p+1];return g},t})();r._TYPE_NO_DATA=0,r._TYPE_INDEXED=1,r._TYPE_RGB=2,r._TYPE_GREY=3,r._TYPE_RLE_INDEXED=9,r._TYPE_RLE_RGB=10,r._TYPE_RLE_GREY=11,r._ORIGIN_MASK=48,r._ORIGIN_SHIFT=4,r._ORIGIN_BL=0,r._ORIGIN_BR=1,r._ORIGIN_UL=2,r._ORIGIN_UR=3,t.TGATools=r})(e.Internals||(e.Internals={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){function r(e){return e.charCodeAt(0)+(e.charCodeAt(1)<<8)+(e.charCodeAt(2)<<16)+(e.charCodeAt(3)<<24)}function i(e){return String.fromCharCode(255&e,e>>8&255,e>>16&255,e>>24&255)}var n=r("DXT1"),o=r("DXT3"),s=r("DXT5"),a=r("DX10"),u=(function(){function t(){}return t.GetDDSInfo=function(t){var r=new Int32Array(t,0,31),i=new Int32Array(t,0,35),u=1;131072&r[2]&&(u=Math.max(1,r[7]));var l=r[21],c=l===a?i[32]:0,h=e.Engine.TEXTURETYPE_UNSIGNED_INT;switch(l){case 113:h=e.Engine.TEXTURETYPE_HALF_FLOAT;break;case 116:h=e.Engine.TEXTURETYPE_FLOAT;break;case a:if(10===c){h=e.Engine.TEXTURETYPE_HALF_FLOAT;break}}return{width:r[4],height:r[3],mipmapCount:u,isFourCC:4==(4&r[20]),isRGB:64==(64&r[20]),isLuminance:131072==(131072&r[20]),isCube:512==(512&r[28]),isCompressed:l===n||l===o||n===s,dxgiFormat:c,textureType:h}},t._ToHalfFloat=function(e){t._FloatView||(t._FloatView=new Float32Array(1),t._Int32View=new Int32Array(t._FloatView.buffer)),t._FloatView[0]=e;var r=t._Int32View[0],i=r>>16&32768,n=r>>12&2047,o=r>>23&255;return o<103?i:o>142?(i|=31744,i|=(255==o?0:1)&&8388607&r):o<113?(n|=2048,i|=(n>>114-o)+(n>>113-o&1)):(i|=o-112<<10|n>>1,i+=1&n)},t._FromHalfFloat=function(e){var t=(32768&e)>>15,r=(31744&e)>>10,i=1023&e;return 0===r?(t?-1:1)*Math.pow(2,-14)*(i/Math.pow(2,10)):31==r?i?NaN:1/0*(t?-1:1):(t?-1:1)*Math.pow(2,r-15)*(1+i/Math.pow(2,10))},t._GetHalfFloatAsFloatRGBAArrayBuffer=function(e,r,i,n,o,s){for(var a=new Float32Array(n),u=new Uint16Array(o,i),l=0,c=0;c>8&65280|e>>24&255},t.prototype.uploadLevels=function(e,r){switch(this.loadType){case t.COMPRESSED_2D:this._upload2DCompressedLevels(e,r);break;case t.TEX_2D:case t.COMPRESSED_3D:case t.TEX_3D:}},t.prototype._upload2DCompressedLevels=function(e,r){for(var i=t.HEADER_LEN+this.bytesOfKeyValueData,n=this.pixelWidth,o=this.pixelHeight,s=r?this.numberOfMipmapLevels:1,a=0;a0){for(var f=0;f0)for(var e=0;e0&&this._camera._postProcesses[0].markTextureDirty(),this.onActivateObservable.clear(),this.onAfterRenderObservable.clear(),this.onApplyObservable.clear(),this.onBeforeRenderObservable.clear(),this.onSizeChangedObservable.clear()}},t})();e.PostProcess=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(r,i,n,o,s,a,u){return void 0===u&&(u=e.Engine.TEXTURETYPE_UNSIGNED_INT),t.call(this,r,"pass",null,null,i,n,o,s,a,null,u)||this}return __extends(r,t),r})(e.PostProcess);e.PassPostProcess=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(r,i,n){this._bias=5e-5,this._blurBoxOffset=1,this._blurScale=2,this._blurKernel=1,this._useKernelBlur=!1,this._filter=t.FILTER_NONE,this._darkness=0,this._transparencyShadow=!1,this.frustumEdgeFalloff=0,this.forceBackFacesOnly=!1,this._lightDirection=e.Vector3.Zero(),this._viewMatrix=e.Matrix.Zero(),this._projectionMatrix=e.Matrix.Zero(),this._transformMatrix=e.Matrix.Zero(),this._worldViewProjection=e.Matrix.Zero(),this._currentFaceIndex=0,this._currentFaceIndexCache=0,this._isCube=!1,this._defaultTextureMatrix=e.Matrix.Identity(),this._mapSize=r,this._light=i,this._scene=i.getScene(),i._shadowGenerator=this;var o=this._scene.getEngine().getCaps();n?o.textureFloatRender&&o.textureFloatLinearFiltering?this._textureType=e.Engine.TEXTURETYPE_FLOAT:o.textureHalfFloatRender&&o.textureHalfFloatLinearFiltering?this._textureType=e.Engine.TEXTURETYPE_HALF_FLOAT:this._textureType=e.Engine.TEXTURETYPE_UNSIGNED_INT:o.textureHalfFloatRender&&o.textureHalfFloatLinearFiltering?this._textureType=e.Engine.TEXTURETYPE_HALF_FLOAT:o.textureFloatRender&&o.textureFloatLinearFiltering?this._textureType=e.Engine.TEXTURETYPE_FLOAT:this._textureType=e.Engine.TEXTURETYPE_UNSIGNED_INT,this._initializeGenerator()}return Object.defineProperty(t,"FILTER_NONE",{get:function(){return t._FILTER_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FILTER_POISSONSAMPLING",{get:function(){return t._FILTER_POISSONSAMPLING},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FILTER_EXPONENTIALSHADOWMAP",{get:function(){return t._FILTER_EXPONENTIALSHADOWMAP},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FILTER_BLUREXPONENTIALSHADOWMAP",{get:function(){return t._FILTER_BLUREXPONENTIALSHADOWMAP},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FILTER_CLOSEEXPONENTIALSHADOWMAP",{get:function(){return t._FILTER_CLOSEEXPONENTIALSHADOWMAP},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FILTER_BLURCLOSEEXPONENTIALSHADOWMAP",{get:function(){return t._FILTER_BLURCLOSEEXPONENTIALSHADOWMAP},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"bias",{get:function(){return this._bias},set:function(e){this._bias=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"blurBoxOffset",{get:function(){return this._blurBoxOffset},set:function(e){this._blurBoxOffset!==e&&(this._blurBoxOffset=e,this._disposeBlurPostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"blurScale",{get:function(){return this._blurScale},set:function(e){this._blurScale!==e&&(this._blurScale=e,this._disposeBlurPostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"blurKernel",{get:function(){return this._blurKernel},set:function(e){this._blurKernel!==e&&(this._blurKernel=e,this._disposeBlurPostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useKernelBlur",{get:function(){return this._useKernelBlur},set:function(e){this._useKernelBlur!==e&&(this._useKernelBlur=e,this._disposeBlurPostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"depthScale",{get:function(){return void 0!==this._depthScale?this._depthScale:this._light.getDepthScale()},set:function(e){this._depthScale=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"filter",{get:function(){return this._filter},set:function(e){if(this._light.needCube()){if(e===t.FILTER_BLUREXPONENTIALSHADOWMAP)return void(this.useExponentialShadowMap=!0);if(e===t.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP)return void(this.useCloseExponentialShadowMap=!0)}this._filter!==e&&(this._filter=e,this._disposeBlurPostProcesses(),this._applyFilterValues(),this._light._markMeshesAsLightDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"usePoissonSampling",{get:function(){return this.filter===t.FILTER_POISSONSAMPLING},set:function(e){this.filter=e?t.FILTER_POISSONSAMPLING:t.FILTER_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useVarianceShadowMap",{get:function(){return e.Tools.Warn("VSM are now replaced by ESM. Please use useExponentialShadowMap instead."),this.useExponentialShadowMap},set:function(t){e.Tools.Warn("VSM are now replaced by ESM. Please use useExponentialShadowMap instead."),this.useExponentialShadowMap=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useBlurVarianceShadowMap",{get:function(){return e.Tools.Warn("VSM are now replaced by ESM. Please use useBlurExponentialShadowMap instead."),this.useBlurExponentialShadowMap},set:function(t){e.Tools.Warn("VSM are now replaced by ESM. Please use useBlurExponentialShadowMap instead."),this.useBlurExponentialShadowMap=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useExponentialShadowMap",{get:function(){return this.filter===t.FILTER_EXPONENTIALSHADOWMAP},set:function(e){this.filter=e?t.FILTER_EXPONENTIALSHADOWMAP:t.FILTER_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useBlurExponentialShadowMap",{get:function(){return this.filter===t.FILTER_BLUREXPONENTIALSHADOWMAP},set:function(e){this.filter=e?t.FILTER_BLUREXPONENTIALSHADOWMAP:t.FILTER_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useCloseExponentialShadowMap",{get:function(){return this.filter===t.FILTER_CLOSEEXPONENTIALSHADOWMAP},set:function(e){this.filter=e?t.FILTER_CLOSEEXPONENTIALSHADOWMAP:t.FILTER_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useBlurCloseExponentialShadowMap",{get:function(){return this.filter===t.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP},set:function(e){this.filter=e?t.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP:t.FILTER_NONE},enumerable:!0,configurable:!0}),t.prototype.getDarkness=function(){return this._darkness},t.prototype.setDarkness=function(e){return this._darkness=e>=1?1:e<=0?0:e,this},t.prototype.setTransparencyShadow=function(e){return this._transparencyShadow=e,this},t.prototype.getShadowMap=function(){return this._shadowMap},t.prototype.getShadowMapForRendering=function(){return this._shadowMap2?this._shadowMap2:this._shadowMap},t.prototype.getLight=function(){return this._light},t.prototype._initializeGenerator=function(){this._light._markMeshesAsLightDirty(),this._initializeShadowMap()},t.prototype._initializeShadowMap=function(){var t=this;this._shadowMap=new e.RenderTargetTexture(this._light.name+"_shadowMap",this._mapSize,this._scene,!1,!0,this._textureType,this._light.needCube()),this._shadowMap.wrapU=e.Texture.CLAMP_ADDRESSMODE,this._shadowMap.wrapV=e.Texture.CLAMP_ADDRESSMODE,this._shadowMap.anisotropicFilteringLevel=1,this._shadowMap.updateSamplingMode(e.Texture.BILINEAR_SAMPLINGMODE),this._shadowMap.renderParticles=!1,this._shadowMap.onBeforeRenderObservable.add((function(e){t._currentFaceIndex=e})),this._shadowMap.customRenderFunction=this._renderForShadowMap.bind(this),this._shadowMap.onAfterUnbindObservable.add((function(){(t.useBlurExponentialShadowMap||t.useBlurCloseExponentialShadowMap)&&(t._blurPostProcesses||t._initializeBlurRTTAndPostProcesses(),t._scene.postProcessManager.directRender(t._blurPostProcesses,t.getShadowMapForRendering().getInternalTexture()))})),this._shadowMap.onClearObservable.add((function(r){t.useExponentialShadowMap||t.useBlurExponentialShadowMap?r.clear(new e.Color4(0,0,0,0),!0,!0,!0):r.clear(new e.Color4(1,1,1,1),!0,!0,!0)}))},t.prototype._initializeBlurRTTAndPostProcesses=function(){var t=this,r=this._scene.getEngine(),i=this._mapSize/this.blurScale;this.useKernelBlur&&1===this.blurScale||(this._shadowMap2=new e.RenderTargetTexture(this._light.name+"_shadowMap2",i,this._scene,!1,!0,this._textureType),this._shadowMap2.wrapU=e.Texture.CLAMP_ADDRESSMODE,this._shadowMap2.wrapV=e.Texture.CLAMP_ADDRESSMODE,this._shadowMap2.updateSamplingMode(e.Texture.BILINEAR_SAMPLINGMODE)),this.useKernelBlur?(this._kernelBlurXPostprocess=new e.BlurPostProcess(this._light.name+"KernelBlurX",new e.Vector2(1,0),this.blurKernel,1,null,e.Texture.BILINEAR_SAMPLINGMODE,r,!1,this._textureType),this._kernelBlurXPostprocess.width=i,this._kernelBlurXPostprocess.height=i,this._kernelBlurXPostprocess.onApplyObservable.add((function(e){e.setTexture("textureSampler",t._shadowMap)})),this._kernelBlurYPostprocess=new e.BlurPostProcess(this._light.name+"KernelBlurY",new e.Vector2(0,1),this.blurKernel,1,null,e.Texture.BILINEAR_SAMPLINGMODE,r,!1,this._textureType),this._kernelBlurXPostprocess.autoClear=!1,this._kernelBlurYPostprocess.autoClear=!1,this._textureType===e.Engine.TEXTURETYPE_UNSIGNED_INT&&(this._kernelBlurXPostprocess.packedFloat=!0,this._kernelBlurYPostprocess.packedFloat=!0),this._blurPostProcesses=[this._kernelBlurXPostprocess,this._kernelBlurYPostprocess]):(this._boxBlurPostprocess=new e.PostProcess(this._light.name+"DepthBoxBlur","depthBoxBlur",["screenSize","boxOffset"],[],1,null,e.Texture.BILINEAR_SAMPLINGMODE,r,!1,"#define OFFSET "+this._blurBoxOffset,this._textureType),this._boxBlurPostprocess.onApplyObservable.add((function(e){e.setFloat2("screenSize",i,i),e.setTexture("textureSampler",t._shadowMap)})),this._boxBlurPostprocess.autoClear=!1,this._blurPostProcesses=[this._boxBlurPostprocess])},t.prototype._renderForShadowMap=function(e,t,r){var i;for(i=0;i=n.length)return void(e&&e(r));setTimeout(l,16)}};n.length>0&&l()},t.prototype.isReady=function(t,r){var i=[];this._textureType!==e.Engine.TEXTURETYPE_UNSIGNED_INT&&i.push("#define FLOAT"),(this.useExponentialShadowMap||this.useBlurExponentialShadowMap)&&i.push("#define ESM");var n=[e.VertexBuffer.PositionKind],o=t.getMesh(),s=t.getMaterial();if(s&&s.needAlphaTesting()){var a=s.getAlphaTestTexture();a&&(i.push("#define ALPHATEST"),o.isVerticesDataPresent(e.VertexBuffer.UVKind)&&(n.push(e.VertexBuffer.UVKind),i.push("#define UV1")),o.isVerticesDataPresent(e.VertexBuffer.UV2Kind)&&1===a.coordinatesIndex&&(n.push(e.VertexBuffer.UV2Kind),i.push("#define UV2")))}o.useBones&&o.computeBonesUsingShaders?(n.push(e.VertexBuffer.MatricesIndicesKind),n.push(e.VertexBuffer.MatricesWeightsKind),o.numBoneInfluencers>4&&(n.push(e.VertexBuffer.MatricesIndicesExtraKind),n.push(e.VertexBuffer.MatricesWeightsExtraKind)),i.push("#define NUM_BONE_INFLUENCERS "+o.numBoneInfluencers),i.push("#define BonesPerMesh "+(o.skeleton.bones.length+1))):i.push("#define NUM_BONE_INFLUENCERS 0"),r&&(i.push("#define INSTANCES"),n.push("world0"),n.push("world1"),n.push("world2"),n.push("world3"));var u=i.join("\n");return this._cachedDefines!==u&&(this._cachedDefines=u,this._effect=this._scene.getEngine().createEffect("shadowMap",n,["world","mBones","viewProjection","diffuseMatrix","lightPosition","depthValues","biasAndScale"],["diffuseSampler"],u)),this._effect.isReady()},t.prototype.prepareDefines=function(e,t){var r=this._scene,i=this._light;r.shadowsEnabled&&i.shadowEnabled&&(e["SHADOW"+t]=!0,this.usePoissonSampling?e["SHADOWPCF"+t]=!0:this.useExponentialShadowMap||this.useBlurExponentialShadowMap?e["SHADOWESM"+t]=!0:(this.useCloseExponentialShadowMap||this.useBlurCloseExponentialShadowMap)&&(e["SHADOWCLOSEESM"+t]=!0),i.needCube()&&(e["SHADOWCUBE"+t]=!0))},t.prototype.bindShadowLight=function(e,t){var r=this._light,i=this._scene;i.shadowsEnabled&&r.shadowEnabled&&(r.needCube()||t.setMatrix("lightMatrix"+e,this.getTransformMatrix()),t.setTexture("shadowSampler"+e,this.getShadowMapForRendering()),r._uniformBuffer.updateFloat4("shadowsInfo",this.getDarkness(),this.blurScale/this.getShadowMap().getSize().width,this.depthScale,this.frustumEdgeFalloff,e),r._uniformBuffer.updateFloat2("depthValues",this.getLight().getDepthMinZ(i.activeCamera),this.getLight().getDepthMinZ(i.activeCamera)+this.getLight().getDepthMaxZ(i.activeCamera),e))},t.prototype.getTransformMatrix=function(){var t=this._scene;if(this._currentRenderID===t.getRenderId()&&this._currentFaceIndexCache===this._currentFaceIndex)return this._transformMatrix;this._currentRenderID=t.getRenderId(),this._currentFaceIndexCache=this._currentFaceIndex;var r=this._light.position;return this._light.computeTransformedInformation()&&(r=this._light.transformedPosition),e.Vector3.NormalizeToRef(this._light.getShadowDirection(this._currentFaceIndex),this._lightDirection),1===Math.abs(e.Vector3.Dot(this._lightDirection,e.Vector3.Up()))&&(this._lightDirection.z=1e-13),!this._light.needProjectionMatrixCompute()&&this._cachedPosition&&this._cachedDirection&&r.equals(this._cachedPosition)&&this._lightDirection.equals(this._cachedDirection)||(this._cachedPosition=r.clone(),this._cachedDirection=this._lightDirection.clone(),e.Matrix.LookAtLHToRef(r,r.add(this._lightDirection),e.Vector3.Up(),this._viewMatrix),this._light.setShadowProjectionMatrix(this._projectionMatrix,this._viewMatrix,this.getShadowMap().renderList),this._viewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix)),this._transformMatrix},t.prototype.recreateShadowMap=function(){var e=this._shadowMap.renderList;this._disposeRTTandPostProcesses(),this._initializeGenerator(),this.filter=this.filter,this._applyFilterValues(),this._shadowMap.renderList=e},t.prototype._disposeBlurPostProcesses=function(){this._shadowMap2&&(this._shadowMap2.dispose(),this._shadowMap2=null),this._downSamplePostprocess&&(this._downSamplePostprocess.dispose(),this._downSamplePostprocess=null),this._boxBlurPostprocess&&(this._boxBlurPostprocess.dispose(),this._boxBlurPostprocess=null),this._kernelBlurXPostprocess&&(this._kernelBlurXPostprocess.dispose(),this._kernelBlurXPostprocess=null),this._kernelBlurYPostprocess&&(this._kernelBlurYPostprocess.dispose(),this._kernelBlurYPostprocess=null),this._blurPostProcesses=null},t.prototype._disposeRTTandPostProcesses=function(){this._shadowMap&&(this._shadowMap.dispose(),this._shadowMap=null),this._disposeBlurPostProcesses()},t.prototype.dispose=function(){this._disposeRTTandPostProcesses(),this._light._shadowGenerator=null,this._light._markMeshesAsLightDirty()},t.prototype.serialize=function(){var e={},t=this.getShadowMap();e.lightId=this._light.id,e.mapSize=t.getRenderSize(),e.useExponentialShadowMap=this.useExponentialShadowMap,e.useBlurExponentialShadowMap=this.useBlurExponentialShadowMap,e.useCloseExponentialShadowMap=this.useBlurExponentialShadowMap,e.useBlurCloseExponentialShadowMap=this.useBlurExponentialShadowMap,e.usePoissonSampling=this.usePoissonSampling,e.forceBackFacesOnly=this.forceBackFacesOnly,e.depthScale=this.depthScale,e.darkness=this.getDarkness(),e.blurBoxOffset=this.blurBoxOffset,e.blurKernel=this.blurKernel,e.blurScale=this.blurScale,e.useKernelBlur=this.useKernelBlur,e.transparencyShadow=this._transparencyShadow,e.renderList=[];for(var r=0;r0?this._setDefaultFixedFrustumShadowProjectionMatrix(e,t):this._setDefaultAutoExtendShadowProjectionMatrix(e,t,r)},r.prototype._setDefaultFixedFrustumShadowProjectionMatrix=function(t,r){var i=this.getScene().activeCamera;e.Matrix.OrthoLHToRef(this.shadowFrustumSize,this.shadowFrustumSize,void 0!==this.shadowMinZ?this.shadowMinZ:i.minZ,void 0!==this.shadowMaxZ?this.shadowMaxZ:i.maxZ,t)},r.prototype._setDefaultAutoExtendShadowProjectionMatrix=function(t,r,i){var n=this.getScene().activeCamera;if(this.autoUpdateExtends||this._orthoLeft===Number.MAX_VALUE){var o=e.Vector3.Zero();this._orthoLeft=Number.MAX_VALUE,this._orthoRight=Number.MIN_VALUE,this._orthoTop=Number.MIN_VALUE,this._orthoBottom=Number.MAX_VALUE;for(var s=0;sthis._orthoRight&&(this._orthoRight=o.x),o.y>this._orthoTop&&(this._orthoTop=o.y)}}}var h=this._orthoRight-this._orthoLeft,f=this._orthoTop-this._orthoBottom;e.Matrix.OrthoOffCenterLHToRef(this._orthoLeft-h*this.shadowOrthoScale,this._orthoRight+h*this.shadowOrthoScale,this._orthoBottom-f*this.shadowOrthoScale,this._orthoTop+f*this.shadowOrthoScale,void 0!==this.shadowMinZ?this.shadowMinZ:n.minZ,void 0!==this.shadowMaxZ?this.shadowMaxZ:n.maxZ,t)},r.prototype._buildUniformLayout=function(){this._uniformBuffer.addUniform("vLightData",4),this._uniformBuffer.addUniform("vLightDiffuse",4),this._uniformBuffer.addUniform("vLightSpecular",3),this._uniformBuffer.addUniform("shadowsInfo",3),this._uniformBuffer.addUniform("depthValues",2),this._uniformBuffer.create()},r.prototype.transferToEffect=function(e,t){return this.computeTransformedInformation()?(this._uniformBuffer.updateFloat4("vLightData",this.transformedDirection.x,this.transformedDirection.y,this.transformedDirection.z,1,t),this):(this._uniformBuffer.updateFloat4("vLightData",this.direction.x,this.direction.y,this.direction.z,1,t),this)},r.prototype.getDepthMinZ=function(e){return 1},r.prototype.getDepthMaxZ=function(e){return 1},r})(e.ShadowLight);__decorate([e.serialize()],t.prototype,"shadowFrustumSize",null),__decorate([e.serialize()],t.prototype,"shadowOrthoScale",null),__decorate([e.serialize()],t.prototype,"autoUpdateExtends",void 0),e.DirectionalLight=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(e,r,i,n,o,s){var a=t.call(this,e,s)||this;return a.position=r,a.direction=i,a.angle=n,a.exponent=o,a}return __extends(r,t),Object.defineProperty(r.prototype,"angle",{get:function(){return this._angle},set:function(e){this._angle=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"shadowAngleScale",{get:function(){return this._shadowAngleScale},set:function(e){this._shadowAngleScale=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),r.prototype.getClassName=function(){return"SpotLight"},r.prototype.getTypeID=function(){return e.Light.LIGHTTYPEID_SPOTLIGHT},r.prototype._setDefaultShadowProjectionMatrix=function(t,r,i){var n=this.getScene().activeCamera;this._shadowAngleScale=this._shadowAngleScale||1;var o=this._shadowAngleScale*this._angle;e.Matrix.PerspectiveFovLHToRef(o,1,this.getDepthMinZ(n),this.getDepthMaxZ(n),t)},r.prototype._buildUniformLayout=function(){this._uniformBuffer.addUniform("vLightData",4),this._uniformBuffer.addUniform("vLightDiffuse",4),this._uniformBuffer.addUniform("vLightSpecular",3),this._uniformBuffer.addUniform("vLightDirection",3),this._uniformBuffer.addUniform("shadowsInfo",3),this._uniformBuffer.addUniform("depthValues",2),this._uniformBuffer.create()},r.prototype.transferToEffect=function(t,r){var i;return this.computeTransformedInformation()?(this._uniformBuffer.updateFloat4("vLightData",this.transformedPosition.x,this.transformedPosition.y,this.transformedPosition.z,this.exponent,r),i=e.Vector3.Normalize(this.transformedDirection)):(this._uniformBuffer.updateFloat4("vLightData",this.position.x,this.position.y,this.position.z,this.exponent,r),i=e.Vector3.Normalize(this.direction)),this._uniformBuffer.updateFloat4("vLightDirection",i.x,i.y,i.z,Math.cos(.5*this.angle),r),this},r})(e.ShadowLight);__decorate([e.serialize()],t.prototype,"angle",null),__decorate([e.serialize()],t.prototype,"shadowAngleScale",null),__decorate([e.serialize()],t.prototype,"exponent",void 0),e.SpotLight=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(e,r){var i=t.call(this,e,r,!0)||this -;return r.multiMaterials.push(i),i.subMaterials=new Array,i.storeEffectOnSubMeshes=!0,i}return __extends(r,t),Object.defineProperty(r.prototype,"subMaterials",{get:function(){return this._subMaterials},set:function(e){this._subMaterials=e,this._hookArray(e)},enumerable:!0,configurable:!0}),r.prototype._hookArray=function(e){var t=this,r=e.push;e.push=function(){for(var i=[],n=0;n=this.subMaterials.length?this.getScene().defaultMaterial:this.subMaterials[e]},r.prototype.getActiveTextures=function(){return(e=t.prototype.getActiveTextures.call(this)).concat.apply(e,this.subMaterials.map((function(e){return e.getActiveTextures()})));var e},r.prototype.getClassName=function(){return"MultiMaterial"},r.prototype.isReadyForSubMesh=function(e,t,r){for(var i=0;i=0&&i.multiMaterials.splice(n,1),t.prototype.dispose.call(this,e,r)}},r})(e.Material);e.MultiMaterial=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(e){function t(){var t=e.call(this)||this;return t.PBR=!0,t.MAINUV1=!1,t.MAINUV2=!1,t.UV1=!1,t.UV2=!1,t.ALBEDO=!1,t.ALBEDODIRECTUV=0,t.VERTEXCOLOR=!1,t.AMBIENT=!1,t.AMBIENTDIRECTUV=0,t.AMBIENTINGRAYSCALE=!1,t.OPACITY=!1,t.VERTEXALPHA=!1,t.OPACITYDIRECTUV=0,t.OPACITYRGB=!1,t.ALPHATEST=!1,t.ALPHABLEND=!1,t.ALPHAFROMALBEDO=!1,t.ALPHATESTVALUE=.5,t.SPECULAROVERALPHA=!1,t.RADIANCEOVERALPHA=!1,t.ALPHAFRESNEL=!1,t.PREMULTIPLYALPHA=!1,t.EMISSIVE=!1,t.EMISSIVEDIRECTUV=0,t.REFLECTIVITY=!1,t.REFLECTIVITYDIRECTUV=0,t.SPECULARTERM=!1,t.MICROSURFACEFROMREFLECTIVITYMAP=!1,t.MICROSURFACEAUTOMATIC=!1,t.LODBASEDMICROSFURACE=!1,t.MICROSURFACEMAP=!1,t.MICROSURFACEMAPDIRECTUV=0,t.METALLICWORKFLOW=!1,t.ROUGHNESSSTOREINMETALMAPALPHA=!1,t.ROUGHNESSSTOREINMETALMAPGREEN=!1,t.METALLNESSSTOREINMETALMAPBLUE=!1,t.AOSTOREINMETALMAPRED=!1,t.ENVIRONMENTBRDF=!1,t.NORMAL=!1,t.TANGENT=!1,t.BUMP=!1,t.BUMPDIRECTUV=0,t.PARALLAX=!1,t.PARALLAXOCCLUSION=!1,t.NORMALXYSCALE=!0,t.LIGHTMAP=!1,t.LIGHTMAPDIRECTUV=0,t.USELIGHTMAPASSHADOWMAP=!1,t.REFLECTION=!1,t.REFLECTIONMAP_3D=!1,t.REFLECTIONMAP_SPHERICAL=!1,t.REFLECTIONMAP_PLANAR=!1,t.REFLECTIONMAP_CUBIC=!1,t.REFLECTIONMAP_PROJECTION=!1,t.REFLECTIONMAP_SKYBOX=!1,t.REFLECTIONMAP_EXPLICIT=!1,t.REFLECTIONMAP_EQUIRECTANGULAR=!1,t.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,t.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,t.INVERTCUBICMAP=!1,t.USESPHERICALFROMREFLECTIONMAP=!1,t.USESPHERICALINFRAGMENT=!1,t.REFLECTIONMAP_OPPOSITEZ=!1,t.LODINREFLECTIONALPHA=!1,t.GAMMAREFLECTION=!1,t.REFRACTION=!1,t.REFRACTIONMAP_3D=!1,t.REFRACTIONMAP_OPPOSITEZ=!1,t.LODINREFRACTIONALPHA=!1,t.GAMMAREFRACTION=!1,t.LINKREFRACTIONTOTRANSPARENCY=!1,t.INSTANCES=!1,t.NUM_BONE_INFLUENCERS=0,t.BonesPerMesh=0,t.MORPHTARGETS=!1,t.MORPHTARGETS_NORMAL=!1,t.MORPHTARGETS_TANGENT=!1,t.NUM_MORPH_INFLUENCERS=0,t.IMAGEPROCESSING=!1,t.VIGNETTE=!1,t.VIGNETTEBLENDMODEMULTIPLY=!1,t.VIGNETTEBLENDMODEOPAQUE=!1,t.TONEMAPPING=!1,t.CONTRAST=!1,t.COLORCURVES=!1,t.COLORGRADING=!1,t.SAMPLER3DGREENDEPTH=!1,t.SAMPLER3DBGRMAP=!1,t.IMAGEPROCESSINGPOSTPROCESS=!1,t.EXPOSURE=!1,t.USEPHYSICALLIGHTFALLOFF=!1,t.TWOSIDEDLIGHTING=!1,t.SHADOWFLOAT=!1,t.USERIGHTHANDEDSYSTEM=!1,t.CLIPPLANE=!1,t.POINTSIZE=!1,t.FOG=!1,t.LOGARITHMICDEPTH=!1,t.FORCENORMALFORWARD=!1,t.rebuild(),t}return __extends(t,e),t.prototype.reset=function(){e.prototype.reset.call(this),this.ALPHATESTVALUE=.5,this.PBR=!0},t})(e.MaterialDefines),r=(function(r){function i(t,i){var n=r.call(this,t,i)||this;return n._directIntensity=1,n._emissiveIntensity=1,n._environmentIntensity=1,n._specularIntensity=1,n._lightingInfos=new e.Vector4(n._directIntensity,n._emissiveIntensity,n._environmentIntensity,n._specularIntensity),n._disableBumpMap=!1,n._ambientTextureStrength=1,n._ambientColor=new e.Color3(0,0,0),n._albedoColor=new e.Color3(1,1,1),n._reflectivityColor=new e.Color3(1,1,1),n._reflectionColor=new e.Color3(1,1,1),n._emissiveColor=new e.Color3(0,0,0),n._microSurface=.9,n._indexOfRefraction=.66,n._invertRefractionY=!1,n._linkRefractionWithTransparency=!1,n._useLightmapAsShadowmap=!1,n._useAlphaFromAlbedoTexture=!1,n._useSpecularOverAlpha=!0,n._useMicroSurfaceFromReflectivityMapAlpha=!1,n._useRoughnessFromMetallicTextureAlpha=!0,n._useRoughnessFromMetallicTextureGreen=!1,n._useMetallnessFromMetallicTextureBlue=!1,n._useAmbientOcclusionFromMetallicTextureRed=!1,n._useAmbientInGrayScale=!1,n._useAutoMicroSurfaceFromReflectivityMap=!1,n._usePhysicalLightFalloff=!0,n._useRadianceOverAlpha=!0,n._useParallax=!1,n._useParallaxOcclusion=!1,n._parallaxScaleBias=.05,n._disableLighting=!1,n._maxSimultaneousLights=4,n._invertNormalMapX=!1,n._invertNormalMapY=!1,n._twoSidedLighting=!1,n._alphaCutOff=.4,n._forceAlphaTest=!1,n._preMultiplyAlpha=!1,n._useAlphaFresnel=!1,n._environmentBRDFTexture=null,n._forceIrradianceInFragment=!1,n._forceNormalForward=!1,n._renderTargets=new e.SmartArray(16),n._worldViewProjectionMatrix=e.Matrix.Zero(),n._globalAmbientColor=new e.Color3(0,0,0),n._tempColor=new e.Color3,n._attachImageProcessingConfiguration(null),n.getRenderTargetTextures=function(){return n._renderTargets.reset(),e.StandardMaterial.ReflectionTextureEnabled&&n._reflectionTexture&&n._reflectionTexture.isRenderTarget&&n._renderTargets.push(n._reflectionTexture),e.StandardMaterial.RefractionTextureEnabled&&n._refractionTexture&&n._refractionTexture.isRenderTarget&&n._renderTargets.push(n._refractionTexture),n._renderTargets},n._environmentBRDFTexture=e.TextureTools.GetEnvironmentBRDFTexture(i),n}return __extends(i,r),i.prototype._attachImageProcessingConfiguration=function(e){var t=this;e!==this._imageProcessingConfiguration&&(this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),this._imageProcessingConfiguration=e||this.getScene().imageProcessingConfiguration,this._imageProcessingObserver=this._imageProcessingConfiguration.onUpdateParameters.add((function(e){t._markAllSubMeshesAsImageProcessingDirty()})))},i.prototype.getClassName=function(){return"PBRBaseMaterial"},Object.defineProperty(i.prototype,"useLogarithmicDepth",{get:function(){return this._useLogarithmicDepth},set:function(e){this._useLogarithmicDepth=e&&this.getScene().getEngine().getCaps().fragmentDepthSupported},enumerable:!0,configurable:!0}),i.prototype.needAlphaBlending=function(){return!this._linkRefractionWithTransparency&&(this.alpha<1||null!=this._opacityTexture||this._shouldUseAlphaFromAlbedoTexture())},i.prototype.needAlphaTesting=function(){return!!this._forceAlphaTest||!this._linkRefractionWithTransparency&&(null!=this._albedoTexture&&this._albedoTexture.hasAlpha)},i.prototype._shouldUseAlphaFromAlbedoTexture=function(){return null!=this._albedoTexture&&this._albedoTexture.hasAlpha&&this._useAlphaFromAlbedoTexture},i.prototype.getAlphaTestTexture=function(){return this._albedoTexture},i.prototype.isReadyForSubMesh=function(r,i,n){if(this.isFrozen&&this._wasPreviouslyReady)return!0;i._materialDefines||(i._materialDefines=new t);var o=this.getScene(),s=i._materialDefines;if(!this.checkReadyOnEveryCall&&i.effect&&s._renderId===o.getRenderId())return!0;var a=o.getEngine();if(e.MaterialHelper.PrepareDefinesForLights(o,r,s,!0,this._maxSimultaneousLights,this._disableLighting),s._needNormals=!0,s._areTexturesDirty){if(s._needUVs=!1,o.texturesEnabled){if(o.getEngine().getCaps().textureLOD&&(s.LODBASEDMICROSFURACE=!0),this._albedoTexture&&e.StandardMaterial.DiffuseTextureEnabled){if(!this._albedoTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._albedoTexture,s,"ALBEDO")}else s.ALBEDO=!1;if(this._ambientTexture&&e.StandardMaterial.AmbientTextureEnabled){if(!this._ambientTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._ambientTexture,s,"AMBIENT"),s.AMBIENTINGRAYSCALE=this._useAmbientInGrayScale}else s.AMBIENT=!1;if(this._opacityTexture&&e.StandardMaterial.OpacityTextureEnabled){if(!this._opacityTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._opacityTexture,s,"OPACITY"),s.OPACITYRGB=this._opacityTexture.getAlphaFromRGB}else s.OPACITY=!1;var u=this._getReflectionTexture();if(u&&e.StandardMaterial.ReflectionTextureEnabled){if(!u.isReadyOrNotBlocking())return!1;switch(s.REFLECTION=!0,s.GAMMAREFLECTION=u.gammaSpace,s.REFLECTIONMAP_OPPOSITEZ=this.getScene().useRightHandedSystem?!u.invertZ:u.invertZ,s.LODINREFLECTIONALPHA=u.lodLevelInAlpha,u.coordinatesMode===e.Texture.INVCUBIC_MODE&&(s.INVERTCUBICMAP=!0),s.REFLECTIONMAP_3D=u.isCube,u.coordinatesMode){case e.Texture.CUBIC_MODE:case e.Texture.INVCUBIC_MODE:s.REFLECTIONMAP_CUBIC=!0;break;case e.Texture.EXPLICIT_MODE:s.REFLECTIONMAP_EXPLICIT=!0;break;case e.Texture.PLANAR_MODE:s.REFLECTIONMAP_PLANAR=!0;break;case e.Texture.PROJECTION_MODE:s.REFLECTIONMAP_PROJECTION=!0;break;case e.Texture.SKYBOX_MODE:s.REFLECTIONMAP_SKYBOX=!0;break;case e.Texture.SPHERICAL_MODE:s.REFLECTIONMAP_SPHERICAL=!0;break;case e.Texture.EQUIRECTANGULAR_MODE:s.REFLECTIONMAP_EQUIRECTANGULAR=!0;break;case e.Texture.FIXED_EQUIRECTANGULAR_MODE:s.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!0;break;case e.Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:s.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!0}u.coordinatesMode!==e.Texture.SKYBOX_MODE&&u.sphericalPolynomial&&(s.USESPHERICALFROMREFLECTIONMAP=!0,(this._forceIrradianceInFragment||o.getEngine().getCaps().maxVaryingVectors<=8)&&(s.USESPHERICALINFRAGMENT=!0))}else s.REFLECTION=!1,s.REFLECTIONMAP_3D=!1,s.REFLECTIONMAP_SPHERICAL=!1,s.REFLECTIONMAP_PLANAR=!1,s.REFLECTIONMAP_CUBIC=!1,s.REFLECTIONMAP_PROJECTION=!1,s.REFLECTIONMAP_SKYBOX=!1,s.REFLECTIONMAP_EXPLICIT=!1,s.REFLECTIONMAP_EQUIRECTANGULAR=!1,s.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,s.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,s.INVERTCUBICMAP=!1,s.USESPHERICALFROMREFLECTIONMAP=!1,s.USESPHERICALINFRAGMENT=!1,s.REFLECTIONMAP_OPPOSITEZ=!1,s.LODINREFLECTIONALPHA=!1,s.GAMMAREFLECTION=!1;if(this._lightmapTexture&&e.StandardMaterial.LightmapTextureEnabled){if(!this._lightmapTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._lightmapTexture,s,"LIGHTMAP"),s.USELIGHTMAPASSHADOWMAP=this._useLightmapAsShadowmap}else s.LIGHTMAP=!1;if(this._emissiveTexture&&e.StandardMaterial.EmissiveTextureEnabled){if(!this._emissiveTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._emissiveTexture,s,"EMISSIVE")}else s.EMISSIVE=!1;if(e.StandardMaterial.SpecularTextureEnabled){if(this._metallicTexture){if(!this._metallicTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._metallicTexture,s,"REFLECTIVITY"),s.METALLICWORKFLOW=!0,s.ROUGHNESSSTOREINMETALMAPALPHA=this._useRoughnessFromMetallicTextureAlpha,s.ROUGHNESSSTOREINMETALMAPGREEN=!this._useRoughnessFromMetallicTextureAlpha&&this._useRoughnessFromMetallicTextureGreen,s.METALLNESSSTOREINMETALMAPBLUE=this._useMetallnessFromMetallicTextureBlue,s.AOSTOREINMETALMAPRED=this._useAmbientOcclusionFromMetallicTextureRed}else if(this._reflectivityTexture){if(!this._reflectivityTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._reflectivityTexture,s,"REFLECTIVITY"),s.MICROSURFACEFROMREFLECTIVITYMAP=this._useMicroSurfaceFromReflectivityMapAlpha,s.MICROSURFACEAUTOMATIC=this._useAutoMicroSurfaceFromReflectivityMap}else s.REFLECTIVITY=!1;if(this._microSurfaceTexture){if(!this._microSurfaceTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._microSurfaceTexture,s,"MICROSURFACEMAP")}else s.MICROSURFACEMAP=!1}else s.REFLECTIVITY=!1,s.MICROSURFACEMAP=!1;if(o.getEngine().getCaps().standardDerivatives&&this._bumpTexture&&e.StandardMaterial.BumpTextureEnabled&&!this._disableBumpMap){if(!this._bumpTexture.isReady())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._bumpTexture,s,"BUMP"),this._useParallax&&this._albedoTexture&&e.StandardMaterial.DiffuseTextureEnabled?(s.PARALLAX=!0,s.PARALLAXOCCLUSION=!!this._useParallaxOcclusion):s.PARALLAX=!1,s.USERIGHTHANDEDSYSTEM=o.useRightHandedSystem}else s.BUMP=!1;var l=this._getRefractionTexture();if(l&&e.StandardMaterial.RefractionTextureEnabled){if(!l.isReadyOrNotBlocking())return!1;s.REFRACTION=!0,s.REFRACTIONMAP_3D=l.isCube,s.GAMMAREFRACTION=l.gammaSpace,s.REFRACTIONMAP_OPPOSITEZ=u.invertZ,s.LODINREFRACTIONALPHA=u.lodLevelInAlpha,this._linkRefractionWithTransparency&&(s.LINKREFRACTIONTOTRANSPARENCY=!0)}else s.REFRACTION=!1;if(this._environmentBRDFTexture&&e.StandardMaterial.ReflectionTextureEnabled){if(!this._environmentBRDFTexture.isReady())return!1;s.ENVIRONMENTBRDF=!0}this._shouldUseAlphaFromAlbedoTexture()&&(s.ALPHAFROMALBEDO=!0)}this._useSpecularOverAlpha&&(s.SPECULAROVERALPHA=!0),this._usePhysicalLightFalloff&&(s.USEPHYSICALLIGHTFALLOFF=!0),this._useRadianceOverAlpha&&(s.RADIANCEOVERALPHA=!0),(void 0!==this._metallic&&null!==this._metallic||void 0!==this._roughness&&null!==this._roughness)&&(s.METALLICWORKFLOW=!0),!this.backFaceCulling&&this._twoSidedLighting&&(s.TWOSIDEDLIGHTING=!0),s.ALPHATESTVALUE=this._alphaCutOff,s.PREMULTIPLYALPHA=this._preMultiplyAlpha,s.ALPHABLEND=this.needAlphaBlending(),s.ALPHAFRESNEL=this._useAlphaFresnel}if(s._areImageProcessingDirty){if(!this._imageProcessingConfiguration.isReady())return!1;this._imageProcessingConfiguration.prepareDefines(s)}if(s.FORCENORMALFORWARD=this._forceNormalForward,e.MaterialHelper.PrepareDefinesForMisc(r,o,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,s),e.MaterialHelper.PrepareDefinesForFrameBoundValues(o,a,s,n,this._forceAlphaTest),e.MaterialHelper.PrepareDefinesForAttributes(r,s,!0,!0,!0)&&r&&(o.getEngine().getCaps().standardDerivatives||r.isVerticesDataPresent(e.VertexBuffer.NormalKind)||(r.createNormals(!0),e.Tools.Warn("PBRMaterial: Normals have been created for the mesh: "+r.name))),s.isDirty){s.markAsProcessed(),o.resetCachedMaterial();var c=new e.EffectFallbacks;s.ENVIRONMENTBRDF&&c.addFallback(0,"ENVIRONMENTBRDF"),s.REFLECTION&&c.addFallback(0,"REFLECTION"),s.REFRACTION&&c.addFallback(0,"REFRACTION"),s.REFLECTIVITY&&c.addFallback(0,"REFLECTIVITY"),s.BUMP&&c.addFallback(0,"BUMP"),s.PARALLAX&&c.addFallback(1,"PARALLAX"),s.PARALLAXOCCLUSION&&c.addFallback(0,"PARALLAXOCCLUSION"),s.SPECULAROVERALPHA&&c.addFallback(0,"SPECULAROVERALPHA"),s.FOG&&c.addFallback(1,"FOG"),s.POINTSIZE&&c.addFallback(0,"POINTSIZE"),s.LOGARITHMICDEPTH&&c.addFallback(0,"LOGARITHMICDEPTH"),e.MaterialHelper.HandleFallbacksForShadows(s,c,this._maxSimultaneousLights),s.SPECULARTERM&&c.addFallback(0,"SPECULARTERM"),s.NUM_BONE_INFLUENCERS>0&&c.addCPUSkinningFallback(0,r);var h=[e.VertexBuffer.PositionKind];s.NORMAL&&h.push(e.VertexBuffer.NormalKind),s.TANGENT&&h.push(e.VertexBuffer.TangentKind),s.UV1&&h.push(e.VertexBuffer.UVKind),s.UV2&&h.push(e.VertexBuffer.UV2Kind),s.VERTEXCOLOR&&h.push(e.VertexBuffer.ColorKind),e.MaterialHelper.PrepareAttributesForBones(h,r,s,c),e.MaterialHelper.PrepareAttributesForInstances(h,s),e.MaterialHelper.PrepareAttributesForMorphTargets(h,r,s);var f=["world","view","viewProjection","vEyePosition","vLightsType","vAmbientColor","vAlbedoColor","vReflectivityColor","vEmissiveColor","vReflectionColor","vFogInfos","vFogColor","pointSize","vAlbedoInfos","vAmbientInfos","vOpacityInfos","vReflectionInfos","vEmissiveInfos","vReflectivityInfos","vMicroSurfaceSamplerInfos","vBumpInfos","vLightmapInfos","vRefractionInfos","mBones","vClipPlane","albedoMatrix","ambientMatrix","opacityMatrix","reflectionMatrix","emissiveMatrix","reflectivityMatrix","microSurfaceSamplerMatrix","bumpMatrix","lightmapMatrix","refractionMatrix","vLightingIntensity","logarithmicDepthConstant","vSphericalX","vSphericalY","vSphericalZ","vSphericalXX","vSphericalYY","vSphericalZZ","vSphericalXY","vSphericalYZ","vSphericalZX","vReflectionMicrosurfaceInfos","vRefractionMicrosurfaceInfos","vNormalReoderParams"],d=["albedoSampler","reflectivitySampler","ambientSampler","emissiveSampler","bumpSampler","lightmapSampler","opacitySampler","refractionSampler","refractionSamplerLow","refractionSamplerHigh","reflectionSampler","reflectionSamplerLow","reflectionSamplerHigh","microSurfaceSampler","environmentBrdfSampler"],p=["Material","Scene"];e.ImageProcessingConfiguration.PrepareUniforms(f,s),e.ImageProcessingConfiguration.PrepareSamplers(d,s),e.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:f,uniformBuffersNames:p,samplers:d,defines:s,maxSimultaneousLights:this._maxSimultaneousLights});var g=function(e){this.onCompiled&&this.onCompiled(e),this.bindSceneUniformBuffer(e,o.getSceneUniformBuffer())}.bind(this),_=s.toString();i.setEffect(o.getEngine().createEffect("pbr",{attributes:h,uniformsNames:f,uniformBuffersNames:p,samplers:d,defines:_,fallbacks:c,onCompiled:g,onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights,maxSimultaneousMorphTargets:s.NUM_MORPH_INFLUENCERS}},a),s),this.buildUniformLayout()}return!!i.effect.isReady()&&(s._renderId=o.getRenderId(),this._wasPreviouslyReady=!0,!0)},i.prototype.buildUniformLayout=function(){this._uniformBuffer.addUniform("vAlbedoInfos",2),this._uniformBuffer.addUniform("vAmbientInfos",3),this._uniformBuffer.addUniform("vOpacityInfos",2),this._uniformBuffer.addUniform("vEmissiveInfos",2),this._uniformBuffer.addUniform("vLightmapInfos",2),this._uniformBuffer.addUniform("vReflectivityInfos",3),this._uniformBuffer.addUniform("vMicroSurfaceSamplerInfos",2),this._uniformBuffer.addUniform("vRefractionInfos",4),this._uniformBuffer.addUniform("vReflectionInfos",2),this._uniformBuffer.addUniform("vBumpInfos",3),this._uniformBuffer.addUniform("albedoMatrix",16),this._uniformBuffer.addUniform("ambientMatrix",16),this._uniformBuffer.addUniform("opacityMatrix",16),this._uniformBuffer.addUniform("emissiveMatrix",16),this._uniformBuffer.addUniform("lightmapMatrix",16),this._uniformBuffer.addUniform("reflectivityMatrix",16),this._uniformBuffer.addUniform("microSurfaceSamplerMatrix",16),this._uniformBuffer.addUniform("bumpMatrix",16),this._uniformBuffer.addUniform("vNormalReoderParams",4),this._uniformBuffer.addUniform("refractionMatrix",16),this._uniformBuffer.addUniform("reflectionMatrix",16),this._uniformBuffer.addUniform("vReflectionColor",3),this._uniformBuffer.addUniform("vAlbedoColor",4),this._uniformBuffer.addUniform("vLightingIntensity",4),this._uniformBuffer.addUniform("vRefractionMicrosurfaceInfos",3),this._uniformBuffer.addUniform("vReflectionMicrosurfaceInfos",3),this._uniformBuffer.addUniform("vReflectivityColor",4),this._uniformBuffer.addUniform("vEmissiveColor",3),this._uniformBuffer.addUniform("pointSize",1),this._uniformBuffer.create()},i.prototype.unbind=function(){this._reflectionTexture&&this._reflectionTexture.isRenderTarget&&this._uniformBuffer.setTexture("reflectionSampler",null),this._refractionTexture&&this._refractionTexture.isRenderTarget&&this._uniformBuffer.setTexture("refractionSampler",null),r.prototype.unbind.call(this)},i.prototype.bindOnlyWorldMatrix=function(e){this._activeEffect.setMatrix("world",e)},i.prototype.bindForSubMesh=function(t,r,i){var n=this.getScene(),o=i._materialDefines;if(o){var s=i.effect;if(this._activeEffect=s,this.bindOnlyWorldMatrix(t),e.MaterialHelper.BindBonesParameters(r,this._activeEffect),this._mustRebind(n,s,r.visibility)){if(this._uniformBuffer.bindToEffect(s,"Material"),this.bindViewProjection(s),!this._uniformBuffer.useUbo||!this.isFrozen||!this._uniformBuffer.isSync){if(n.texturesEnabled){this._albedoTexture&&e.StandardMaterial.DiffuseTextureEnabled&&(this._uniformBuffer.updateFloat2("vAlbedoInfos",this._albedoTexture.coordinatesIndex,this._albedoTexture.level),e.MaterialHelper.BindTextureMatrix(this._albedoTexture,this._uniformBuffer,"albedo")),this._ambientTexture&&e.StandardMaterial.AmbientTextureEnabled&&(this._uniformBuffer.updateFloat3("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level,this._ambientTextureStrength),e.MaterialHelper.BindTextureMatrix(this._ambientTexture,this._uniformBuffer,"ambient")),this._opacityTexture&&e.StandardMaterial.OpacityTextureEnabled&&(this._uniformBuffer.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),e.MaterialHelper.BindTextureMatrix(this._opacityTexture,this._uniformBuffer,"opacity"));var a=this._getReflectionTexture();if(a&&e.StandardMaterial.ReflectionTextureEnabled){if(this._uniformBuffer.updateMatrix("reflectionMatrix",a.getReflectionTextureMatrix()),this._uniformBuffer.updateFloat2("vReflectionInfos",a.level,0),o.USESPHERICALFROMREFLECTIONMAP){var u=a.sphericalPolynomial;this._activeEffect.setFloat3("vSphericalX",u.x.x,u.x.y,u.x.z),this._activeEffect.setFloat3("vSphericalY",u.y.x,u.y.y,u.y.z),this._activeEffect.setFloat3("vSphericalZ",u.z.x,u.z.y,u.z.z),this._activeEffect.setFloat3("vSphericalXX_ZZ",u.xx.x-u.zz.x,u.xx.y-u.zz.y,u.xx.z-u.zz.z),this._activeEffect.setFloat3("vSphericalYY_ZZ",u.yy.x-u.zz.x,u.yy.y-u.zz.y,u.yy.z-u.zz.z),this._activeEffect.setFloat3("vSphericalZZ",u.zz.x,u.zz.y,u.zz.z),this._activeEffect.setFloat3("vSphericalXY",u.xy.x,u.xy.y,u.xy.z),this._activeEffect.setFloat3("vSphericalYZ",u.yz.x,u.yz.y,u.yz.z),this._activeEffect.setFloat3("vSphericalZX",u.zx.x,u.zx.y,u.zx.z)}this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos",a.getSize().width,a.lodGenerationScale,a.lodGenerationOffset)}this._emissiveTexture&&e.StandardMaterial.EmissiveTextureEnabled&&(this._uniformBuffer.updateFloat2("vEmissiveInfos",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),e.MaterialHelper.BindTextureMatrix(this._emissiveTexture,this._uniformBuffer,"emissive")),this._lightmapTexture&&e.StandardMaterial.LightmapTextureEnabled&&(this._uniformBuffer.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),e.MaterialHelper.BindTextureMatrix(this._lightmapTexture,this._uniformBuffer,"lightmap")),e.StandardMaterial.SpecularTextureEnabled&&(this._metallicTexture?(this._uniformBuffer.updateFloat3("vReflectivityInfos",this._metallicTexture.coordinatesIndex,this._metallicTexture.level,this._ambientTextureStrength),e.MaterialHelper.BindTextureMatrix(this._metallicTexture,this._uniformBuffer,"reflectivity")):this._reflectivityTexture&&(this._uniformBuffer.updateFloat3("vReflectivityInfos",this._reflectivityTexture.coordinatesIndex,this._reflectivityTexture.level,1),e.MaterialHelper.BindTextureMatrix(this._reflectivityTexture,this._uniformBuffer,"reflectivity")),this._microSurfaceTexture&&(this._uniformBuffer.updateFloat2("vMicroSurfaceSamplerInfos",this._microSurfaceTexture.coordinatesIndex,this._microSurfaceTexture.level),e.MaterialHelper.BindTextureMatrix(this._microSurfaceTexture,this._uniformBuffer,"microSurfaceSampler"))),this._bumpTexture&&n.getEngine().getCaps().standardDerivatives&&e.StandardMaterial.BumpTextureEnabled&&!this._disableBumpMap&&(this._uniformBuffer.updateFloat3("vBumpInfos",this._bumpTexture.coordinatesIndex,this._bumpTexture.level,this._parallaxScaleBias),e.MaterialHelper.BindTextureMatrix(this._bumpTexture,this._uniformBuffer,"bump"),n._mirroredCameraPosition?this._uniformBuffer.updateFloat4("vNormalReoderParams",this._invertNormalMapX?0:1,this._invertNormalMapX?1:-1,this._invertNormalMapY?0:1,this._invertNormalMapY?1:-1):this._uniformBuffer.updateFloat4("vNormalReoderParams",this._invertNormalMapX?1:0,this._invertNormalMapX?-1:1,this._invertNormalMapY?1:0,this._invertNormalMapY?-1:1));var l=this._getRefractionTexture();if(l&&e.StandardMaterial.RefractionTextureEnabled){this._uniformBuffer.updateMatrix("refractionMatrix",l.getReflectionTextureMatrix());var c=1;l.isCube||l.depth&&(c=l.depth),this._uniformBuffer.updateFloat4("vRefractionInfos",l.level,this._indexOfRefraction,c,this._invertRefractionY?-1:1),this._uniformBuffer.updateFloat3("vRefractionMicrosurfaceInfos",l.getSize().width,l.lodGenerationScale,l.lodGenerationOffset)}}this.pointsCloud&&this._uniformBuffer.updateFloat("pointSize",this.pointSize),o.METALLICWORKFLOW?(e.PBRMaterial._scaledReflectivity.r=void 0===this._metallic||null===this._metallic?1:this._metallic,e.PBRMaterial._scaledReflectivity.g=void 0===this._roughness||null===this._roughness?1:this._roughness,this._uniformBuffer.updateColor4("vReflectivityColor",e.PBRMaterial._scaledReflectivity,0)):this._uniformBuffer.updateColor4("vReflectivityColor",this._reflectivityColor,this._microSurface),this._uniformBuffer.updateColor3("vEmissiveColor",this._emissiveColor),this._uniformBuffer.updateColor3("vReflectionColor",this._reflectionColor),this._uniformBuffer.updateColor4("vAlbedoColor",this._albedoColor,this.alpha*r.visibility),this._lightingInfos.x=this._directIntensity,this._lightingInfos.y=this._emissiveIntensity,this._lightingInfos.z=this._environmentIntensity,this._lightingInfos.w=this._specularIntensity,this._uniformBuffer.updateVector4("vLightingIntensity",this._lightingInfos)}n.texturesEnabled&&(this._albedoTexture&&e.StandardMaterial.DiffuseTextureEnabled&&this._uniformBuffer.setTexture("albedoSampler",this._albedoTexture),this._ambientTexture&&e.StandardMaterial.AmbientTextureEnabled&&this._uniformBuffer.setTexture("ambientSampler",this._ambientTexture),this._opacityTexture&&e.StandardMaterial.OpacityTextureEnabled&&this._uniformBuffer.setTexture("opacitySampler",this._opacityTexture),a&&e.StandardMaterial.ReflectionTextureEnabled&&(o.LODBASEDMICROSFURACE?this._uniformBuffer.setTexture("reflectionSampler",a):(this._uniformBuffer.setTexture("reflectionSampler",a._lodTextureMid||a),this._uniformBuffer.setTexture("reflectionSamplerLow",a._lodTextureLow||a),this._uniformBuffer.setTexture("reflectionSamplerHigh",a._lodTextureHigh||a))),o.ENVIRONMENTBRDF&&this._uniformBuffer.setTexture("environmentBrdfSampler",this._environmentBRDFTexture),l&&e.StandardMaterial.RefractionTextureEnabled&&(o.LODBASEDMICROSFURACE?this._uniformBuffer.setTexture("refractionSampler",l):(this._uniformBuffer.setTexture("refractionSampler",l._lodTextureMid||l),this._uniformBuffer.setTexture("refractionSamplerLow",l._lodTextureLow||l),this._uniformBuffer.setTexture("refractionSamplerHigh",l._lodTextureHigh||l))),this._emissiveTexture&&e.StandardMaterial.EmissiveTextureEnabled&&this._uniformBuffer.setTexture("emissiveSampler",this._emissiveTexture),this._lightmapTexture&&e.StandardMaterial.LightmapTextureEnabled&&this._uniformBuffer.setTexture("lightmapSampler",this._lightmapTexture),e.StandardMaterial.SpecularTextureEnabled&&(this._metallicTexture?this._uniformBuffer.setTexture("reflectivitySampler",this._metallicTexture):this._reflectivityTexture&&this._uniformBuffer.setTexture("reflectivitySampler",this._reflectivityTexture),this._microSurfaceTexture&&this._uniformBuffer.setTexture("microSurfaceSampler",this._microSurfaceTexture)),this._bumpTexture&&n.getEngine().getCaps().standardDerivatives&&e.StandardMaterial.BumpTextureEnabled&&!this._disableBumpMap&&this._uniformBuffer.setTexture("bumpSampler",this._bumpTexture)),e.MaterialHelper.BindClipPlane(this._activeEffect,n),n.ambientColor.multiplyToRef(this._ambientColor,this._globalAmbientColor);var h=n._mirroredCameraPosition?n._mirroredCameraPosition:n.activeCamera.globalPosition;s.setFloat4("vEyePosition",h.x,h.y,h.z,n._mirroredCameraPosition?-1:1),s.setColor3("vAmbientColor",this._globalAmbientColor)}!this._mustRebind(n,s)&&this.isFrozen||(n.lightsEnabled&&!this._disableLighting&&e.MaterialHelper.BindLights(n,r,this._activeEffect,o,this._maxSimultaneousLights,this._usePhysicalLightFalloff),(n.fogEnabled&&r.applyFog&&n.fogMode!==e.Scene.FOGMODE_NONE||a)&&this.bindView(s),e.MaterialHelper.BindFogParameters(n,r,this._activeEffect),o.NUM_MORPH_INFLUENCERS&&e.MaterialHelper.BindMorphTargetParameters(r,this._activeEffect),this._imageProcessingConfiguration.bind(this._activeEffect),e.MaterialHelper.BindLogDepth(o,this._activeEffect,n)),this._uniformBuffer.update(),this._afterBind(r),n=null}},i.prototype.getAnimatables=function(){var e=[];return this._albedoTexture&&this._albedoTexture.animations&&this._albedoTexture.animations.length>0&&e.push(this._albedoTexture),this._ambientTexture&&this._ambientTexture.animations&&this._ambientTexture.animations.length>0&&e.push(this._ambientTexture),this._opacityTexture&&this._opacityTexture.animations&&this._opacityTexture.animations.length>0&&e.push(this._opacityTexture),this._reflectionTexture&&this._reflectionTexture.animations&&this._reflectionTexture.animations.length>0&&e.push(this._reflectionTexture),this._emissiveTexture&&this._emissiveTexture.animations&&this._emissiveTexture.animations.length>0&&e.push(this._emissiveTexture),this._metallicTexture&&this._metallicTexture.animations&&this._metallicTexture.animations.length>0?e.push(this._metallicTexture):this._reflectivityTexture&&this._reflectivityTexture.animations&&this._reflectivityTexture.animations.length>0&&e.push(this._reflectivityTexture),this._bumpTexture&&this._bumpTexture.animations&&this._bumpTexture.animations.length>0&&e.push(this._bumpTexture),this._lightmapTexture&&this._lightmapTexture.animations&&this._lightmapTexture.animations.length>0&&e.push(this._lightmapTexture),this._refractionTexture&&this._refractionTexture.animations&&this._refractionTexture.animations.length>0&&e.push(this._refractionTexture),e},i.prototype._getReflectionTexture=function(){return this._reflectionTexture?this._reflectionTexture:this.getScene().environmentTexture},i.prototype._getRefractionTexture=function(){return this._refractionTexture?this._refractionTexture:this._linkRefractionWithTransparency?this.getScene().environmentTexture:null},i.prototype.dispose=function(e,t){t&&(this._albedoTexture&&this._albedoTexture.dispose(),this._ambientTexture&&this._ambientTexture.dispose(),this._opacityTexture&&this._opacityTexture.dispose(),this._reflectionTexture&&this._reflectionTexture.dispose(),this._environmentBRDFTexture&&this._environmentBRDFTexture.dispose(),this._emissiveTexture&&this._emissiveTexture.dispose(),this._metallicTexture&&this._metallicTexture.dispose(),this._reflectivityTexture&&this._reflectivityTexture.dispose(),this._bumpTexture&&this._bumpTexture.dispose(),this._lightmapTexture&&this._lightmapTexture.dispose(),this._refractionTexture&&this._refractionTexture.dispose()),this._renderTargets.dispose(),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),r.prototype.dispose.call(this,e,t)},i})(e.PushMaterial);r._scaledReflectivity=new e.Color3,__decorate([e.serializeAsImageProcessingConfiguration()],r.prototype,"_imageProcessingConfiguration",void 0),__decorate([e.serialize()],r.prototype,"useLogarithmicDepth",null),e.PBRBaseMaterial=r})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){var r=(function(t){function r(r,i){var n=t.call(this,r,i)||this;return n.maxSimultaneousLights=4,n.disableLighting=!1,n.invertNormalMapX=!1,n.invertNormalMapY=!1,n.emissiveColor=new e.Color3(0,0,0),n.occlusionStrength=1,n._transparencyMode=e.PBRMaterial.PBRMATERIAL_OPAQUE,n._useAmbientInGrayScale=!0,n}return __extends(r,t), -Object.defineProperty(r.prototype,"transparencyMode",{get:function(){return this._transparencyMode},set:function(t){this._transparencyMode!==t&&(this._transparencyMode=t,t===e.PBRMaterial.PBRMATERIAL_ALPHATESTANDBLEND?this._forceAlphaTest=!0:this._forceAlphaTest=!1,this._markAllSubMeshesAsTexturesDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"doubleSided",{get:function(){return this._twoSidedLighting},set:function(e){this._twoSidedLighting!==e&&(this._twoSidedLighting=e,this.backFaceCulling=!e,this._markAllSubMeshesAsTexturesDirty())},enumerable:!0,configurable:!0}),r.prototype._shouldUseAlphaFromAlbedoTexture=function(){return this._albedoTexture&&this._albedoTexture.hasAlpha&&this._transparencyMode!==e.PBRMaterial.PBRMATERIAL_OPAQUE},r.prototype.needAlphaBlending=function(){return!this._linkRefractionWithTransparency&&(this.alpha<1||this._shouldUseAlphaFromAlbedoTexture()&&(this._transparencyMode===e.PBRMaterial.PBRMATERIAL_ALPHABLEND||this._transparencyMode===e.PBRMaterial.PBRMATERIAL_ALPHATESTANDBLEND))},r.prototype.needAlphaTesting=function(){return!this._linkRefractionWithTransparency&&(this._shouldUseAlphaFromAlbedoTexture()&&this._transparencyMode===e.PBRMaterial.PBRMATERIAL_ALPHATEST)},r.prototype.getActiveTextures=function(){var e=t.prototype.getActiveTextures.call(this);return this.environmentTexture&&e.push(this.environmentTexture),this.normalTexture&&e.push(this.normalTexture),this.emissiveTexture&&e.push(this.emissiveTexture),this.occlusionTexture&&e.push(this.occlusionTexture),e},r.prototype.getClassName=function(){return"PBRBaseSimpleMaterial"},r})(e.PBRBaseMaterial);__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsLightsDirty")],r.prototype,"maxSimultaneousLights",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsLightsDirty")],r.prototype,"disableLighting",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_reflectionTexture")],r.prototype,"environmentTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"invertNormalMapX",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"invertNormalMapY",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_bumpTexture")],r.prototype,"normalTexture",void 0),__decorate([e.serializeAsColor3("emissive"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"emissiveColor",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"emissiveTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_ambientTextureStrength")],r.prototype,"occlusionStrength",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_ambientTexture")],r.prototype,"occlusionTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_alphaCutOff")],r.prototype,"alphaCutOff",void 0),__decorate([e.serialize()],r.prototype,"transparencyMode",null),__decorate([e.serialize()],r.prototype,"doubleSided",null),t.PBRBaseSimpleMaterial=r})(e.Internals||(e.Internals={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(r,i){var n=t.call(this,r,i)||this;return n.directIntensity=1,n.emissiveIntensity=1,n.environmentIntensity=1,n.specularIntensity=1,n.disableBumpMap=!1,n.ambientTextureStrength=1,n.ambientColor=new e.Color3(0,0,0),n.albedoColor=new e.Color3(1,1,1),n.reflectivityColor=new e.Color3(1,1,1),n.reflectionColor=new e.Color3(1,1,1),n.emissiveColor=new e.Color3(0,0,0),n.microSurface=1,n.indexOfRefraction=.66,n.invertRefractionY=!1,n.linkRefractionWithTransparency=!1,n.useLightmapAsShadowmap=!1,n.useAlphaFromAlbedoTexture=!1,n.forceAlphaTest=!1,n.alphaCutOff=.4,n.useSpecularOverAlpha=!0,n.useMicroSurfaceFromReflectivityMapAlpha=!1,n.useRoughnessFromMetallicTextureAlpha=!0,n.useRoughnessFromMetallicTextureGreen=!1,n.useMetallnessFromMetallicTextureBlue=!1,n.useAmbientOcclusionFromMetallicTextureRed=!1,n.useAmbientInGrayScale=!1,n.useAutoMicroSurfaceFromReflectivityMap=!1,n.usePhysicalLightFalloff=!0,n.useRadianceOverAlpha=!0,n.useParallax=!1,n.useParallaxOcclusion=!1,n.parallaxScaleBias=.05,n.disableLighting=!1,n.forceIrradianceInFragment=!1,n.maxSimultaneousLights=4,n.invertNormalMapX=!1,n.invertNormalMapY=!1,n.twoSidedLighting=!1,n.preMultiplyAlpha=!1,n.useAlphaFresnel=!1,n.environmentBRDFTexture=null,n.forceNormalForward=!1,n._environmentBRDFTexture=e.TextureTools.GetEnvironmentBRDFTexture(i),n}return __extends(r,t),Object.defineProperty(r,"PBRMATERIAL_OPAQUE",{get:function(){return this._PBRMATERIAL_OPAQUE},enumerable:!0,configurable:!0}),Object.defineProperty(r,"PBRMATERIAL_ALPHATEST",{get:function(){return this._PBRMATERIAL_ALPHATEST},enumerable:!0,configurable:!0}),Object.defineProperty(r,"PBRMATERIAL_ALPHABLEND",{get:function(){return this._PBRMATERIAL_ALPHABLEND},enumerable:!0,configurable:!0}),Object.defineProperty(r,"PBRMATERIAL_ALPHATESTANDBLEND",{get:function(){return this._PBRMATERIAL_ALPHATESTANDBLEND},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(e){this._attachImageProcessingConfiguration(e),this._markAllSubMeshesAsTexturesDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"cameraColorCurvesEnabled",{get:function(){return this.imageProcessingConfiguration.colorCurvesEnabled},set:function(e){this.imageProcessingConfiguration.colorCurvesEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"cameraColorGradingEnabled",{get:function(){return this.imageProcessingConfiguration.colorGradingEnabled},set:function(e){this.imageProcessingConfiguration.colorGradingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"cameraToneMappingEnabled",{get:function(){return this._imageProcessingConfiguration.toneMappingEnabled},set:function(e){this._imageProcessingConfiguration.toneMappingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"cameraExposure",{get:function(){return this._imageProcessingConfiguration.exposure},set:function(e){this._imageProcessingConfiguration.exposure=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"cameraContrast",{get:function(){return this._imageProcessingConfiguration.contrast},set:function(e){this._imageProcessingConfiguration.contrast=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"cameraColorGradingTexture",{get:function(){return this._imageProcessingConfiguration.colorGradingTexture},set:function(e){this._imageProcessingConfiguration.colorGradingTexture=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"cameraColorCurves",{get:function(){return this._imageProcessingConfiguration.colorCurves},set:function(e){this._imageProcessingConfiguration.colorCurves=e},enumerable:!0,configurable:!0}),r.prototype.getClassName=function(){return"PBRMaterial"},r.prototype.getActiveTextures=function(){var e=t.prototype.getActiveTextures.call(this);return this._albedoTexture&&e.push(this._albedoTexture),this._ambientTexture&&e.push(this._ambientTexture),this._opacityTexture&&e.push(this._opacityTexture),this._reflectionTexture&&e.push(this._reflectionTexture),this._emissiveTexture&&e.push(this._emissiveTexture),this._reflectivityTexture&&e.push(this._reflectivityTexture),this._metallicTexture&&e.push(this._metallicTexture),this._microSurfaceTexture&&e.push(this._microSurfaceTexture),this._bumpTexture&&e.push(this._bumpTexture),this._lightmapTexture&&e.push(this._lightmapTexture),this._refractionTexture&&e.push(this._refractionTexture),e},r.prototype.hasTexture=function(e){return!!t.prototype.hasTexture.call(this,e)||(this._albedoTexture===e||(this._ambientTexture===e||(this._opacityTexture===e||(this._reflectionTexture===e||(this._reflectivityTexture===e||(this._metallicTexture===e||(this._microSurfaceTexture===e||(this._bumpTexture===e||(this._lightmapTexture===e||this._refractionTexture===e)))))))))},r.prototype.clone=function(t){var i=this;return e.SerializationHelper.Clone((function(){return new r(t,i.getScene())}),this)},r.prototype.serialize=function(){var t=e.SerializationHelper.Serialize(this);return t.customType="BABYLON.PBRMaterial",t},r.Parse=function(t,i,n){return e.SerializationHelper.Parse((function(){return new r(t.name,i)}),t,i,n)},r})(e.PBRBaseMaterial);t._PBRMATERIAL_OPAQUE=0,t._PBRMATERIAL_ALPHATEST=1,t._PBRMATERIAL_ALPHABLEND=2,t._PBRMATERIAL_ALPHATESTANDBLEND=3,__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"directIntensity",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveIntensity",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"environmentIntensity",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"specularIntensity",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"disableBumpMap",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"albedoTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientTextureStrength",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"opacityTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectivityTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallicTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallic",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"roughness",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"microSurfaceTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"bumpTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty",null)],t.prototype,"lightmapTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"refractionTexture",void 0),__decorate([e.serializeAsColor3("ambient"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientColor",void 0),__decorate([e.serializeAsColor3("albedo"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"albedoColor",void 0),__decorate([e.serializeAsColor3("reflectivity"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectivityColor",void 0),__decorate([e.serializeAsColor3("reflection"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionColor",void 0),__decorate([e.serializeAsColor3("emissive"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveColor",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"microSurface",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"indexOfRefraction",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertRefractionY",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"linkRefractionWithTransparency",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useLightmapAsShadowmap",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAlphaFromAlbedoTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"forceAlphaTest",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"alphaCutOff",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useSpecularOverAlpha",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useMicroSurfaceFromReflectivityMapAlpha",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRoughnessFromMetallicTextureAlpha",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRoughnessFromMetallicTextureGreen",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useMetallnessFromMetallicTextureBlue",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAmbientOcclusionFromMetallicTextureRed",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAmbientInGrayScale",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAutoMicroSurfaceFromReflectivityMap",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"usePhysicalLightFalloff",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRadianceOverAlpha",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useParallax",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useParallaxOcclusion",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"parallaxScaleBias",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsLightsDirty")],t.prototype,"disableLighting",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"forceIrradianceInFragment",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsLightsDirty")],t.prototype,"maxSimultaneousLights",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapX",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapY",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"twoSidedLighting",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"preMultiplyAlpha",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAlphaFresnel",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"environmentBRDFTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"forceNormalForward",void 0),e.PBRMaterial=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(e,r){var i=t.call(this,e,r)||this;return i._useRoughnessFromMetallicTextureAlpha=!1,i._useRoughnessFromMetallicTextureGreen=!0,i._useMetallnessFromMetallicTextureBlue=!0,i}return __extends(r,t),r.prototype.getClassName=function(){return"PBRMetallicRoughnessMaterial"},r.prototype.getActiveTextures=function(){var e=t.prototype.getActiveTextures.call(this);return this.baseTexture&&e.push(this.baseTexture),this.metallicRoughnessTexture&&e.push(this.metallicRoughnessTexture),e},r.prototype.hasTexture=function(e){return!!t.prototype.hasTexture.call(this,e)||(this.baseTexture===e||this.metallicRoughnessTexture===e)},r.prototype.clone=function(t){var i=this;return e.SerializationHelper.Clone((function(){return new r(t,i.getScene())}),this)},r.prototype.serialize=function(){var t=e.SerializationHelper.Serialize(this);return t.customType="BABYLON.PBRMetallicRoughnessMaterial",t},r.Parse=function(t,i,n){return e.SerializationHelper.Parse((function(){return new r(t.name,i)}),t,i,n)},r})(e.Internals.PBRBaseSimpleMaterial);__decorate([e.serializeAsColor3(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_albedoColor")],t.prototype,"baseColor",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_albedoTexture")],t.prototype,"baseTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallic",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"roughness",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_metallicTexture")],t.prototype,"metallicRoughnessTexture",void 0),e.PBRMetallicRoughnessMaterial=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(e,r){var i=t.call(this,e,r)||this;return i._useMicroSurfaceFromReflectivityMapAlpha=!0,i}return __extends(r,t),r.prototype.getClassName=function(){return"PBRSpecularGlossinessMaterial"},r.prototype.getActiveTextures=function(){var e=t.prototype.getActiveTextures.call(this);return this.diffuseTexture&&e.push(this.diffuseTexture),this.specularGlossinessTexture&&e.push(this.specularGlossinessTexture),e},r.prototype.hasTexture=function(e){return!!t.prototype.hasTexture.call(this,e)||(this.diffuseTexture===e||this.specularGlossinessTexture===e)},r.prototype.clone=function(t){var i=this;return e.SerializationHelper.Clone((function(){return new r(t,i.getScene())}),this)},r.prototype.serialize=function(){var t=e.SerializationHelper.Serialize(this);return t.customType="BABYLON.PBRSpecularGlossinessMaterial",t},r.Parse=function(t,i,n){return e.SerializationHelper.Parse((function(){return new r(t.name,i)}),t,i,n)},r})(e.Internals.PBRBaseSimpleMaterial);__decorate([e.serializeAsColor3("diffuse"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_albedoColor")],t.prototype,"diffuseColor",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_albedoTexture")],t.prototype,"diffuseTexture",void 0),__decorate([e.serializeAsColor3("specular"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_reflectivityColor")],t.prototype,"specularColor",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_microSurface")],t.prototype,"glossiness",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_reflectivityTexture")],t.prototype,"specularGlossinessTexture",void 0),e.PBRSpecularGlossinessMaterial=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(r,i,n,o){var s=t.call(this,r,i)||this;return s._textures={},s._textureArrays={},s._floats={},s._floatsArrays={},s._colors3={},s._colors3Arrays={},s._colors4={},s._vectors2={},s._vectors3={},s._vectors4={},s._matrices={},s._matrices3x3={},s._matrices2x2={},s._vectors3Arrays={},s._cachedWorldViewMatrix=new e.Matrix,s._shaderPath=n,o.needAlphaBlending=o.needAlphaBlending||!1,o.needAlphaTesting=o.needAlphaTesting||!1,o.attributes=o.attributes||["position","normal","uv"],o.uniforms=o.uniforms||["worldViewProjection"],o.uniformBuffers=o.uniformBuffers||[],o.samplers=o.samplers||[],o.defines=o.defines||[],s._options=o,s}return __extends(r,t),r.prototype.getClassName=function(){return"ShaderMaterial"},r.prototype.needAlphaBlending=function(){return this._options.needAlphaBlending},r.prototype.needAlphaTesting=function(){return this._options.needAlphaTesting},r.prototype._checkUniform=function(e){-1===this._options.uniforms.indexOf(e)&&this._options.uniforms.push(e)},r.prototype.setTexture=function(e,t){return-1===this._options.samplers.indexOf(e)&&this._options.samplers.push(e),this._textures[e]=t,this},r.prototype.setTextureArray=function(e,t){return-1===this._options.samplers.indexOf(e)&&this._options.samplers.push(e),this._checkUniform(e),this._textureArrays[e]=t,this},r.prototype.setFloat=function(e,t){return this._checkUniform(e),this._floats[e]=t,this},r.prototype.setFloats=function(e,t){return this._checkUniform(e),this._floatsArrays[e]=t,this},r.prototype.setColor3=function(e,t){return this._checkUniform(e),this._colors3[e]=t,this},r.prototype.setColor3Array=function(e,t){return this._checkUniform(e),this._colors3Arrays[e]=t.reduce((function(e,t){return t.toArray(e,e.length),e}),[]),this},r.prototype.setColor4=function(e,t){return this._checkUniform(e),this._colors4[e]=t,this},r.prototype.setVector2=function(e,t){return this._checkUniform(e),this._vectors2[e]=t,this},r.prototype.setVector3=function(e,t){return this._checkUniform(e),this._vectors3[e]=t,this},r.prototype.setVector4=function(e,t){return this._checkUniform(e),this._vectors4[e]=t,this},r.prototype.setMatrix=function(e,t){return this._checkUniform(e),this._matrices[e]=t,this},r.prototype.setMatrix3x3=function(e,t){return this._checkUniform(e),this._matrices3x3[e]=t,this},r.prototype.setMatrix2x2=function(e,t){return this._checkUniform(e),this._matrices2x2[e]=t,this},r.prototype.setArray3=function(e,t){return this._checkUniform(e),this._vectors3Arrays[e]=t,this},r.prototype._checkCache=function(e,t,r){return!t||(this._effect&&this._effect.defines.indexOf("#define INSTANCES"),!1)},r.prototype.isReady=function(t,r){var i=this.getScene(),n=i.getEngine();if(!this.checkReadyOnEveryCall&&this._renderId===i.getRenderId()&&this._checkCache(i,t,r))return!0;var o=[],s=[],a=new e.EffectFallbacks;r&&o.push("#define INSTANCES");for(var u=0;u4&&(s.push(e.VertexBuffer.MatricesIndicesExtraKind),s.push(e.VertexBuffer.MatricesWeightsExtraKind)),o.push("#define NUM_BONE_INFLUENCERS "+t.numBoneInfluencers),o.push("#define BonesPerMesh "+(t.skeleton.bones.length+1)),a.addCPUSkinningFallback(0,t),-1===this._options.uniforms.indexOf("mBones")&&this._options.uniforms.push("mBones")):o.push("#define NUM_BONE_INFLUENCERS 0");for(var l in this._textures)if(!this._textures[l].isReady())return!1;n.getAlphaTesting()&&o.push("#define ALPHATEST");var c=this._effect,h=o.join("\n");return this._effect=n.createEffect(this._shaderPath,{attributes:s,uniformsNames:this._options.uniforms,uniformBuffersNames:this._options.uniformBuffers,samplers:this._options.samplers,defines:h,fallbacks:a,onCompiled:this.onCompiled,onError:this.onError},n),!!this._effect.isReady()&&(c!==this._effect&&i.resetCachedMaterial(),this._renderId=i.getRenderId(),!0)},r.prototype.bindOnlyWorldMatrix=function(e){var t=this.getScene();-1!==this._options.uniforms.indexOf("world")&&this._effect.setMatrix("world",e),-1!==this._options.uniforms.indexOf("worldView")&&(e.multiplyToRef(t.getViewMatrix(),this._cachedWorldViewMatrix),this._effect.setMatrix("worldView",this._cachedWorldViewMatrix)),-1!==this._options.uniforms.indexOf("worldViewProjection")&&this._effect.setMatrix("worldViewProjection",e.multiply(t.getTransformMatrix()))},r.prototype.bind=function(t,r){if(this.bindOnlyWorldMatrix(t),this.getScene().getCachedMaterial()!==this){-1!==this._options.uniforms.indexOf("view")&&this._effect.setMatrix("view",this.getScene().getViewMatrix()),-1!==this._options.uniforms.indexOf("projection")&&this._effect.setMatrix("projection",this.getScene().getProjectionMatrix()),-1!==this._options.uniforms.indexOf("viewProjection")&&this._effect.setMatrix("viewProjection",this.getScene().getTransformMatrix()),e.MaterialHelper.BindBonesParameters(r,this._effect);var i;for(i in this._textures)this._effect.setTexture(i,this._textures[i]);for(i in this._textureArrays)this._effect.setTextureArray(i,this._textureArrays[i]);for(i in this._floats)this._effect.setFloat(i,this._floats[i]);for(i in this._floatsArrays)this._effect.setArray(i,this._floatsArrays[i]);for(i in this._colors3)this._effect.setColor3(i,this._colors3[i]);for(i in this._colors3Arrays)this._effect.setArray3(i,this._colors3Arrays[i]);for(i in this._colors4){var n=this._colors4[i];this._effect.setFloat4(i,n.r,n.g,n.b,n.a)}for(i in this._vectors2)this._effect.setVector2(i,this._vectors2[i]);for(i in this._vectors3)this._effect.setVector3(i,this._vectors3[i]);for(i in this._vectors4)this._effect.setVector4(i,this._vectors4[i]);for(i in this._matrices)this._effect.setMatrix(i,this._matrices[i]);for(i in this._matrices3x3)this._effect.setMatrix3x3(i,this._matrices3x3[i]);for(i in this._matrices2x2)this._effect.setMatrix2x2(i,this._matrices2x2[i]);for(i in this._vectors3Arrays)this._effect.setArray3(i,this._vectors3Arrays[i])}this._afterBind(r)},r.prototype.getActiveTextures=function(){var e=t.prototype.getActiveTextures.call(this);for(var r in this._textures)e.push(this._textures[r]);for(var r in this._textureArrays)for(var i=this._textureArrays[r],n=0;ne.Tmp.Vector3[1].x&&(e.Tmp.Vector3[1].x=u[h].x),u[h].ye.Tmp.Vector3[1].y&&(e.Tmp.Vector3[1].y=u[h].y),u[h].ze.Tmp.Vector3[1].z&&(e.Tmp.Vector3[1].z=u[h].z),h++,i+=3;l._closePath&&(t[i]=u[0].x,t[i+1]=u[0].y,t[i+2]=u[0].z,i+=3)}}(h),l._boundingInfo=new e.BoundingInfo(e.Tmp.Vector3[0],e.Tmp.Vector3[1]),l._boundingInfo.update(l._worldMatrix),l.updateVerticesData(e.VertexBuffer.PositionKind,h,!1,!1),i.colors){for(var f=l.getVerticesData(e.VertexBuffer.ColorKind),d=0;d1?1:i.arc:1,a=void 0===i.closed||i.closed,u=i.shape,l=i.radius||1,c=i.tessellation||64,h=i.updatable,f=t.updateSideOrientation(i.sideOrientation,n),d=i.cap||e.Mesh.NO_CAP,p=2*Math.PI,g=new Array,_=i.invertUV||!1,m=0,v=0,y=p/c*s,A=new Array;for(m=0;m<=c;m++){var A=[];for(d!=e.Mesh.CAP_START&&d!=e.Mesh.CAP_ALL||(A.push(new e.Vector3(0,u[0].y,0)),A.push(new e.Vector3(Math.cos(m*y)*u[0].x*l,u[0].y,Math.sin(m*y)*u[0].x*l))),v=0;v1?1:i.arc||1;var p,g,_=function(t,r,i,n,o,s,a,u){for(var l,c,h,f,d=r.getTangents(),p=r.getNormals(),g=r.getDistances(),_=2*Math.PI,m=_/o*u,v=function(){return n},y=s||v,A=e.Tmp.Matrix[0],E=a===e.Mesh._NO_CAP||a===e.Mesh.CAP_END?0:2,T=0;T3?0:l,g=_(o,p,v,s,a,u,l,i.arc);var y=t.CreateRibbon(r,{pathArray:g,closePath:!0,closeArray:!1,updatable:h,sideOrientation:f,invertUV:c,frontUVs:i.frontUVs,backUVs:i.backUVs},n);return y.pathArray=g,y.path3D=p,y.tessellation=a,y.cap=l,y.arc=i.arc,y},t.CreatePolyhedron=function(r,i,n){var o=new e.Mesh(r,n);return i.sideOrientation=t.updateSideOrientation(i.sideOrientation,n),o.sideOrientation=i.sideOrientation,e.VertexData.CreatePolyhedron(i).applyToMesh(o,i.updatable),o},t.CreateDecal=function(t,r,i){var n=r.getIndices(),o=r.getVerticesData(e.VertexBuffer.PositionKind),s=r.getVerticesData(e.VertexBuffer.NormalKind),a=i.position||e.Vector3.Zero(),u=i.normal||e.Vector3.Up(),l=i.size||e.Vector3.One(),c=i.angle||0;if(!u){var h=new e.Vector3(0,0,1),f=r.getScene().activeCamera,d=e.Vector3.TransformCoordinates(h,f.getWorldMatrix());u=f.globalPosition.subtract(d)}var p=-Math.atan2(u.z,u.x)-Math.PI/2,g=Math.sqrt(u.x*u.x+u.z*u.z),_=Math.atan2(u.y,g),m=e.Matrix.RotationYawPitchRoll(p,_,c).multiply(e.Matrix.Translation(a.x,a.y,a.z)),v=e.Matrix.Invert(m),y=r.getWorldMatrix(),A=y.multiply(v),E=new e.VertexData;E.indices=[],E.positions=[],E.normals=[],E.uvs=[];for(var T=0,b=function(t){var r=n[t],i=new e.PositionNormalVertex;return i.position=new e.Vector3(o[3*r],o[3*r+1],o[3*r+2]),i.position=e.Vector3.TransformCoordinates(i.position,A),i.normal=new e.Vector3(s[3*r],s[3*r+1],s[3*r+2]),i.normal=e.Vector3.TransformNormal(i.normal,A),i},x=function(t,r){if(0===t.length)return t;for(var i=.5*Math.abs(e.Vector3.Dot(l,r)),n=function(t,n){var o=e.Vector3.GetClipFactor(t.position,n.position,r,i);return new e.PositionNormalVertex(e.Vector3.Lerp(t.position,n.position,o),e.Vector3.Lerp(t.normal,n.normal,o))},o=new Array,s=0;s0,u=_>0,c=m>0,(a?1:0)+(u?1:0)+(c?1:0)){case 0:o.push(t[s]),o.push(t[s+1]),o.push(t[s+2]);break;case 1:if(a&&(h=t[s+1],f=t[s+2],d=n(t[s],h),p=n(t[s],f)),u){h=t[s],f=t[s+2],d=n(t[s+1],h),p=n(t[s+1],f),o.push(d),o.push(f.clone()),o.push(h.clone()),o.push(f.clone()),o.push(d.clone()),o.push(p);break}c&&(h=t[s],f=t[s+1],d=n(t[s+2],h),p=n(t[s+2],f)),o.push(h.clone()),o.push(f.clone()),o.push(d),o.push(p),o.push(d.clone()),o.push(f.clone());break;case 2:a||(h=t[s].clone(),f=n(h,t[s+1]),d=n(h,t[s+2]),o.push(h),o.push(f),o.push(d)),u||(h=t[s+1].clone(),f=n(h,t[s+2]),d=n(h,t[s]),o.push(h),o.push(f),o.push(d)),c||(h=t[s+2].clone(),f=n(h,t[s]),d=n(h,t[s+1]),o.push(h),o.push(f),o.push(d))}}return o},M=0;M3?0:h,E=T(i,n,A,b,o,s,a,u,h,f);var x=t.CreateRibbon(r,{pathArray:E,closeArray:l,closePath:c,updatable:p,sideOrientation:g,invertUV:m,frontUVs:v,backUVs:y},d);return x.pathArray=E,x.path3D=A,x.cap=h,x},t})();e.MeshBuilder=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t,r,i,n,o){this.name=t,this.scale=new e.Vector2(1,1),this.offset=new e.Vector2(0,0),this.alphaBlendingMode=e.Engine.ALPHA_COMBINE,this.layerMask=268435455,this._vertexBuffers={},this.onDisposeObservable=new e.Observable,this.onBeforeRenderObservable=new e.Observable,this.onAfterRenderObservable=new e.Observable,this.texture=r?new e.Texture(r,i,!0):null,this.isBackground=void 0===n||n,this.color=void 0===o?new e.Color4(1,1,1,1):o,this._scene=i||e.Engine.LastCreatedScene,this._scene.layers.push(this);var s=this._scene.getEngine(),a=[];a.push(1,1),a.push(-1,1),a.push(-1,-1),a.push(1,-1);var u=new e.VertexBuffer(s,a,e.VertexBuffer.PositionKind,!1,!1,2);this._vertexBuffers[e.VertexBuffer.PositionKind]=u;var l=[];l.push(0),l.push(1),l.push(2),l.push(0),l.push(2),l.push(3),this._indexBuffer=s.createIndexBuffer(l),this._effect=s.createEffect("layer",[e.VertexBuffer.PositionKind],["textureMatrix","color","scale","offset"],["textureSampler"],""),this._alphaTestEffect=s.createEffect("layer",[e.VertexBuffer.PositionKind],["textureMatrix","color","scale","offset"],["textureSampler"],"#define ALPHATEST")}return Object.defineProperty(t.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onBeforeRender",{set:function(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onAfterRender",{set:function(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=this.onAfterRenderObservable.add(e)},enumerable:!0,configurable:!0}),t.prototype.render=function(){var t=this.alphaTest?this._alphaTestEffect:this._effect;if(t.isReady()&&this.texture&&this.texture.isReady()){var r=this._scene.getEngine();this.onBeforeRenderObservable.notifyObservers(this),r.enableEffect(t),r.setState(!1),t.setTexture("textureSampler",this.texture),t.setMatrix("textureMatrix",this.texture.getTextureMatrix()),t.setFloat4("color",this.color.r,this.color.g,this.color.b,this.color.a),t.setVector2("offset",this.offset),t.setVector2("scale",this.scale),r.bindBuffers(this._vertexBuffers,this._indexBuffer,t),this.alphaTest?r.draw(!0,0,6):(r.setAlphaMode(this.alphaBlendingMode),r.draw(!0,0,6),r.setAlphaMode(e.Engine.ALPHA_DISABLE)),this.onAfterRenderObservable.notifyObservers(this)}},t.prototype.dispose=function(){var t=this._vertexBuffers[e.VertexBuffer.PositionKind];t&&(t.dispose(),this._vertexBuffers[e.VertexBuffer.PositionKind]=null),this._indexBuffer&&(this._scene.getEngine()._releaseBuffer(this._indexBuffer),this._indexBuffer=null),this.texture&&(this.texture.dispose(),this.texture=null);var r=this._scene.layers.indexOf(this);this._scene.layers.splice(r,1),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onAfterRenderObservable.clear(),this.onBeforeRenderObservable.clear()},t})();e.Layer=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(r,i,n,o,s,a,u,l,c){void 0===a&&(a=e.Texture.BILINEAR_SAMPLINGMODE),void 0===c&&(c=e.Engine.TEXTURETYPE_UNSIGNED_INT);var h=t.call(this,r,"kernelBlur",["delta","direction"],null,o,s,a,u,l,null,c,"kernelBlur",{varyingCount:0,depCount:0},!0)||this;return h.direction=i,h._packedFloat=!1,h.onApplyObservable.add((function(e){e.setFloat2("delta",1/h.width*h.direction.x,1/h.height*h.direction.y)})),h.kernel=n,h}return __extends(r,t),Object.defineProperty(r.prototype,"kernel",{get:function(){return this._idealKernel},set:function(e){this._idealKernel!==e&&(e=Math.max(e,1),this._idealKernel=e,this._kernel=this._nearestBestKernel(e),this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"packedFloat",{get:function(){return this._packedFloat},set:function(e){this._packedFloat!==e&&(this._packedFloat=e,this._updateParameters())},enumerable:!0,configurable:!0}),r.prototype._updateParameters=function(){for(var e=this._kernel,t=(e-1)/2,r=[],i=[],n=0,o=0;o0)return Math.max(n,3)}return Math.max(t,3)},r.prototype._gaussianWeight=function(e){var t=Math.sqrt(2*Math.PI)*(1/3),r=-e*e/(1/3*2*(1/3));return 1/t*Math.exp(r)},r.prototype._glslFloat=function(e,t){return void 0===t&&(t=8),e.toFixed(t).replace(/0+$/,"")},r})(e.PostProcess);e.BlurPostProcess=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(r,i,n,o,s,a,u){void 0===u&&(u=e.Engine.TEXTURETYPE_UNSIGNED_INT);var l=t.call(this,r,"fxaa",["texelSize"],null,i,n,o||e.Texture.BILINEAR_SAMPLINGMODE,s,a,null,u,"fxaa")||this;return l.onApplyObservable.add((function(e){var t=l.texelSize;e.setFloat2("texelSize",t.x,t.y)})),l}return __extends(r,t),r})(e.PostProcess);e.FxaaPostProcess=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(r,i,n,o,s,a,u){return void 0===u&&(u=e.Engine.TEXTURETYPE_UNSIGNED_INT),t.call(this,r,"highlights",null,null,i,n,o,s,a,null,u)||this}return __extends(r,t),r})(e.PostProcess);e.HighlightsPostProcess=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(r,i,n,o,s,a,u){void 0===u&&(u=e.Engine.TEXTURETYPE_UNSIGNED_INT);var l=t.call(this,r,"imageProcessing",[],[],i,n,o,s,a,null,u,"postprocess",null,!0)||this;return l._fromLinearSpace=!0,l._defines={IMAGEPROCESSING:!1,VIGNETTE:!1,VIGNETTEBLENDMODEMULTIPLY:!1,VIGNETTEBLENDMODEOPAQUE:!1,TONEMAPPING:!1,CONTRAST:!1,COLORCURVES:!1,COLORGRADING:!1,FROMLINEARSPACE:!1,SAMPLER3DGREENDEPTH:!1,SAMPLER3DBGRMAP:!1,IMAGEPROCESSINGPOSTPROCESS:!1,EXPOSURE:!1},l._attachImageProcessingConfiguration(null,!0),l.imageProcessingConfiguration.applyByPostProcess=!0,l.onApply=function(e){l.imageProcessingConfiguration.bind(e,l.aspectRatio)},l}return __extends(r,t),Object.defineProperty(r.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(e){this._attachImageProcessingConfiguration(e)},enumerable:!0,configurable:!0}),r.prototype._attachImageProcessingConfiguration=function(t,r){var i=this;if(void 0===r&&(r=!1),t!==this._imageProcessingConfiguration){if(this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),t)this._imageProcessingConfiguration=t;else{var n=this.getCamera(),o=n?n.getScene():e.Engine.LastCreatedScene;this._imageProcessingConfiguration=o.imageProcessingConfiguration}this._imageProcessingObserver=this._imageProcessingConfiguration.onUpdateParameters.add((function(e){i._updateParameters()})),r||this._updateParameters()}},Object.defineProperty(r.prototype,"colorCurves",{get:function(){return this.imageProcessingConfiguration.colorCurves},set:function(e){this.imageProcessingConfiguration.colorCurves=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"colorCurvesEnabled",{get:function(){return this.imageProcessingConfiguration.colorCurvesEnabled},set:function(e){this.imageProcessingConfiguration.colorCurvesEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"colorGradingTexture",{get:function(){return this.imageProcessingConfiguration.colorGradingTexture},set:function(e){this.imageProcessingConfiguration.colorGradingTexture=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"colorGradingEnabled",{get:function(){return this.imageProcessingConfiguration.colorGradingEnabled},set:function(e){this.imageProcessingConfiguration.colorGradingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"exposure",{get:function(){return this.imageProcessingConfiguration.exposure},set:function(e){this.imageProcessingConfiguration.exposure=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"toneMappingEnabled",{get:function(){return this._imageProcessingConfiguration.toneMappingEnabled},set:function(e){this._imageProcessingConfiguration.toneMappingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"contrast",{get:function(){return this.imageProcessingConfiguration.contrast},set:function(e){this.imageProcessingConfiguration.contrast=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"vignetteStretch",{get:function(){return this.imageProcessingConfiguration.vignetteStretch},set:function(e){this.imageProcessingConfiguration.vignetteStretch=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"vignetteCentreX",{get:function(){return this.imageProcessingConfiguration.vignetteCentreX},set:function(e){this.imageProcessingConfiguration.vignetteCentreX=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"vignetteCentreY",{get:function(){return this.imageProcessingConfiguration.vignetteCentreY},set:function(e){this.imageProcessingConfiguration.vignetteCentreY=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"vignetteWeight",{get:function(){return this.imageProcessingConfiguration.vignetteWeight},set:function(e){this.imageProcessingConfiguration.vignetteWeight=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"vignetteColor",{get:function(){return this.imageProcessingConfiguration.vignetteColor},set:function(e){this.imageProcessingConfiguration.vignetteColor=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"vignetteCameraFov",{get:function(){return this.imageProcessingConfiguration.vignetteCameraFov},set:function(e){this.imageProcessingConfiguration.vignetteCameraFov=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"vignetteBlendMode",{get:function(){return this.imageProcessingConfiguration.vignetteBlendMode},set:function(e){this.imageProcessingConfiguration.vignetteBlendMode=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"vignetteEnabled",{get:function(){return this.imageProcessingConfiguration.vignetteEnabled},set:function(e){this.imageProcessingConfiguration.vignetteEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"fromLinearSpace",{get:function(){return this._fromLinearSpace},set:function(e){this._fromLinearSpace!==e&&(this._fromLinearSpace=e,this._updateParameters())},enumerable:!0,configurable:!0}),r.prototype.getClassName=function(){return"ImageProcessingPostProcess"},r.prototype._updateParameters=function(){this._defines.FROMLINEARSPACE=this._fromLinearSpace,this.imageProcessingConfiguration.prepareDefines(this._defines);var t="";for(var r in this._defines)this._defines[r]&&(t+="#define "+r+";\r\n");var i=["textureSampler"];e.ImageProcessingConfiguration.PrepareSamplers(i,this._defines);var n=["scale"];e.ImageProcessingConfiguration.PrepareUniforms(n,this._defines),this.updateEffect(t,n,i)},r.prototype.dispose=function(e){t.prototype.dispose.call(this,e),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),this.imageProcessingConfiguration.applyByPostProcess=!1},r})(e.PostProcess);__decorate([e.serialize()],t.prototype,"_fromLinearSpace",void 0),e.ImageProcessingPostProcess=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(r,i){var n=t.call(this,i)||this;return r?(n._textureMatrix=e.Matrix.Identity(),n.name=r,n.url=r,n.hasAlpha=!1,n.isCube=!1,n.wrapU=e.Texture.CLAMP_ADDRESSMODE,n.wrapV=e.Texture.CLAMP_ADDRESSMODE,n.anisotropicFilteringLevel=1,n._texture=n._getFromCache(r,!0),n._texture||(i.useDelayedTextureLoading?n.delayLoadState=e.Engine.DELAYLOADSTATE_NOTLOADED:n.loadTexture()),n):n}return __extends(r,t),r.prototype.getTextureMatrix=function(){return this._textureMatrix},r.prototype.load3dlTexture=function(){var t=this,i=this.getScene().getEngine().createRawTexture(null,1,1,e.Engine.TEXTUREFORMAT_RGBA,!1,!1,e.Texture.BILINEAR_SAMPLINGMODE);this._texture=i;var n=function(n){for(var o,s,a,u=n.split("\n"),l=0,c=0,h=0,f=0,d=0,p=0;p0&&(p+1)%4==0)o[p]=255;else{var A=s[p];o[p]=A/d*255}t.getScene().getEngine().updateTextureSize(i,l*l,l),t.getScene().getEngine().updateRawTexture(i,o,e.Engine.TEXTUREFORMAT_RGBA,!1)};return e.Tools.LoadFile(this.url,n),this._texture},r.prototype.loadTexture=function(){this.url&&this.url.toLocaleLowerCase().indexOf(".3dl")==this.url.length-4&&this.load3dlTexture()},r.prototype.clone=function(){var e=new r(this.url,this.getScene());return e.level=this.level,e},r.prototype.delayLoad=function(){this.delayLoadState===e.Engine.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=e.Engine.DELAYLOADSTATE_LOADED,this._texture=this._getFromCache(this.url,!0),this._texture||this.loadTexture())},r.Parse=function(t,r,i){var n=null;return t.name&&!t.isRenderTarget&&(n=new e.ColorGradingTexture(t.name,r),n.name=t.name,n.level=t.level),n},r.prototype.serialize=function(){if(!this.name)return null;var e={};return e.name=this.name,e.level=this.level,e.customType="BABYLON.ColorGradingTexture",e},r})(e.BaseTexture);t._noneEmptyLineRegex=/\S+/,e.ColorGradingTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this._dirty=!0,this._tempColor=new e.Color4(0,0,0,0),this._globalCurve=new e.Color4(0,0,0,0),this._highlightsCurve=new e.Color4(0,0,0,0),this._midtonesCurve=new e.Color4(0,0,0,0),this._shadowsCurve=new e.Color4(0,0,0,0),this._positiveCurve=new e.Color4(0,0,0,0),this._negativeCurve=new e.Color4(0,0,0,0),this._globalHue=30,this._globalDensity=0,this._globalSaturation=0,this._globalExposure=0,this._highlightsHue=30,this._highlightsDensity=0,this._highlightsSaturation=0,this._highlightsExposure=0,this._midtonesHue=30,this._midtonesDensity=0,this._midtonesSaturation=0,this._midtonesExposure=0,this._shadowsHue=30,this._shadowsDensity=0,this._shadowsSaturation=0,this._shadowsExposure=0}return Object.defineProperty(t.prototype,"globalHue",{get:function(){return this._globalHue},set:function(e){this._globalHue=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"globalDensity",{get:function(){return this._globalDensity},set:function(e){this._globalDensity=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"globalSaturation",{get:function(){return this._globalSaturation},set:function(e){this._globalSaturation=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"highlightsHue",{get:function(){return this._highlightsHue},set:function(e){this._highlightsHue=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"highlightsDensity",{get:function(){return this._highlightsDensity},set:function(e){this._highlightsDensity=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"highlightsSaturation",{get:function(){return this._highlightsSaturation},set:function(e){this._highlightsSaturation=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"highlightsExposure",{get:function(){return this._highlightsExposure},set:function(e){this._highlightsExposure=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"midtonesHue",{get:function(){return this._midtonesHue},set:function(e){this._midtonesHue=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"midtonesDensity",{get:function(){return this._midtonesDensity},set:function(e){this._midtonesDensity=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"midtonesSaturation",{get:function(){return this._midtonesSaturation},set:function(e){this._midtonesSaturation=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"midtonesExposure",{get:function(){return this._midtonesExposure},set:function(e){this._midtonesExposure=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"shadowsHue",{get:function(){return this._shadowsHue},set:function(e){this._shadowsHue=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"shadowsDensity",{get:function(){return this._shadowsDensity},set:function(e){this._shadowsDensity=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"shadowsSaturation",{get:function(){return this._shadowsSaturation},set:function(e){this._shadowsSaturation=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"shadowsExposure",{get:function(){return this._shadowsExposure},set:function(e){this._shadowsExposure=e,this._dirty=!0},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return"ColorCurves"},t.Bind=function(e,t,r,i,n){void 0===r&&(r="vCameraColorCurvePositive"),void 0===i&&(i="vCameraColorCurveNeutral"),void 0===n&&(n="vCameraColorCurveNegative"),e._dirty&&(e._dirty=!1,e.getColorGradingDataToRef(e._globalHue,e._globalDensity,e._globalSaturation,e._globalExposure,e._globalCurve),e.getColorGradingDataToRef(e._highlightsHue,e._highlightsDensity,e._highlightsSaturation,e._highlightsExposure,e._tempColor),e._tempColor.multiplyToRef(e._globalCurve,e._highlightsCurve),e.getColorGradingDataToRef(e._midtonesHue,e._midtonesDensity,e._midtonesSaturation,e._midtonesExposure,e._tempColor),e._tempColor.multiplyToRef(e._globalCurve,e._midtonesCurve),e.getColorGradingDataToRef(e._shadowsHue,e._shadowsDensity,e._shadowsSaturation,e._shadowsExposure,e._tempColor),e._tempColor.multiplyToRef(e._globalCurve,e._shadowsCurve),e._highlightsCurve.subtractToRef(e._midtonesCurve,e._positiveCurve),e._midtonesCurve.subtractToRef(e._shadowsCurve,e._negativeCurve)),t&&(t.setFloat4(r,e._positiveCurve.r,e._positiveCurve.g,e._positiveCurve.b,e._positiveCurve.a),t.setFloat4(i,e._midtonesCurve.r,e._midtonesCurve.g,e._midtonesCurve.b,e._midtonesCurve.a), -t.setFloat4(n,e._negativeCurve.r,e._negativeCurve.g,e._negativeCurve.b,e._negativeCurve.a))},t.PrepareUniforms=function(e){e.push("vCameraColorCurveNeutral","vCameraColorCurvePositive","vCameraColorCurveNegative")},t.prototype.getColorGradingDataToRef=function(e,r,i,n,o){null!=e&&(e=t.clamp(e,0,360),r=t.clamp(r,-100,100),i=t.clamp(i,-100,100),n=t.clamp(n,-100,100),r=t.applyColorGradingSliderNonlinear(r),r*=.5,n=t.applyColorGradingSliderNonlinear(n),r<0&&(r*=-1,e=(e+180)%360),t.fromHSBToRef(e,r,50+.25*n,o),o.scaleToRef(2,o),o.a=1+.01*i)},t.applyColorGradingSliderNonlinear=function(e){e/=100;var t=Math.abs(e);return t=Math.pow(t,2),e<0&&(t*=-1),t*=100},t.fromHSBToRef=function(e,r,i,n){var o=t.clamp(e,0,360),s=t.clamp(r/100,0,1),a=t.clamp(i/100,0,1);if(0===s)n.r=a,n.g=a,n.b=a;else{o/=60;var u=Math.floor(o),l=o-u,c=a*(1-s),h=a*(1-s*l),f=a*(1-s*(1-l));switch(u){case 0:n.r=a,n.g=f,n.b=c;break;case 1:n.r=h,n.g=a,n.b=c;break;case 2:n.r=c,n.g=a,n.b=f;break;case 3:n.r=c,n.g=h,n.b=a;break;case 4:n.r=f,n.g=c,n.b=a;break;default:n.r=a,n.g=c,n.b=h}}n.a=1},t.clamp=function(e,t,r){return Math.min(Math.max(e,t),r)},t.prototype.clone=function(){return e.SerializationHelper.Clone((function(){return new t}),this)},t.prototype.serialize=function(){return e.SerializationHelper.Serialize(this)},t.Parse=function(r){return e.SerializationHelper.Parse((function(){return new t}),r,null,null)},t})();__decorate([e.serialize()],t.prototype,"_globalHue",void 0),__decorate([e.serialize()],t.prototype,"_globalDensity",void 0),__decorate([e.serialize()],t.prototype,"_globalSaturation",void 0),__decorate([e.serialize()],t.prototype,"_globalExposure",void 0),__decorate([e.serialize()],t.prototype,"_highlightsHue",void 0),__decorate([e.serialize()],t.prototype,"_highlightsDensity",void 0),__decorate([e.serialize()],t.prototype,"_highlightsSaturation",void 0),__decorate([e.serialize()],t.prototype,"_highlightsExposure",void 0),__decorate([e.serialize()],t.prototype,"_midtonesHue",void 0),__decorate([e.serialize()],t.prototype,"_midtonesDensity",void 0),__decorate([e.serialize()],t.prototype,"_midtonesSaturation",void 0),__decorate([e.serialize()],t.prototype,"_midtonesExposure",void 0),e.ColorCurves=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(){this._renderPipelines={}}return e.prototype.addPipeline=function(e){this._renderPipelines[e._name]=e},e.prototype.attachCamerasToRenderPipeline=function(e,t,r){var i=this._renderPipelines[e];i&&i._attachCameras(t,r)},e.prototype.detachCamerasFromRenderPipeline=function(e,t){var r=this._renderPipelines[e];r&&r._detachCameras(t)},e.prototype.enableEffectInPipeline=function(e,t,r){var i=this._renderPipelines[e];i&&i._enableEffect(t,r)},e.prototype.disableEffectInPipeline=function(e,t,r){var i=this._renderPipelines[e];i&&i._disableEffect(t,r)},e.prototype.enableDisplayOnlyPassInPipeline=function(e,t,r){var i=this._renderPipelines[e];i&&i._enableDisplayOnlyPass(t,r)},e.prototype.disableDisplayOnlyPassInPipeline=function(e,t){var r=this._renderPipelines[e];r&&r._disableDisplayOnlyPass(t)},e.prototype.update=function(){for(var e in this._renderPipelines){var t=this._renderPipelines[e];t.isSupported?t._update():(t.dispose(),delete this._renderPipelines[e])}},e})();e.PostProcessRenderPipelineManager=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t,r,i,n,o,s){this._enabled=!0,this._refCount=0,this._name=r,this._renderTexture=new e.RenderTargetTexture(r,i,t),this.setRenderList(n),this._renderTexture.onBeforeRenderObservable.add(o),this._renderTexture.onAfterRenderObservable.add(s),this._scene=t,this._renderList=n}return t.prototype._incRefCount=function(){return 0===this._refCount&&this._scene.customRenderTargets.push(this._renderTexture),++this._refCount},t.prototype._decRefCount=function(){return this._refCount--,this._refCount<=0&&this._scene.customRenderTargets.splice(this._scene.customRenderTargets.indexOf(this._renderTexture),1),this._refCount},t.prototype._update=function(){this.setRenderList(this._renderList)},t.prototype.setRenderList=function(e){this._renderTexture.renderList=e},t.prototype.getRenderTexture=function(){return this._renderTexture},t})();e.PostProcessRenderPass=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e,t,r,i){this._engine=e,this._name=t,this._singleInstance=i||!0,this._getPostProcess=r,this._cameras=[],this._indicesForCamera=[],this._postProcesses={},this._renderPasses={},this._renderEffectAsPasses={}}return Object.defineProperty(t.prototype,"isSupported",{get:function(){for(var e in this._postProcesses)if(!this._postProcesses[e].isSupported)return!1;return!0},enumerable:!0,configurable:!0}),t.prototype._update=function(){for(var e in this._renderPasses)this._renderPasses[e]._update()},t.prototype.addPass=function(e){this._renderPasses[e._name]=e,this._linkParameters()},t.prototype.removePass=function(e){delete this._renderPasses[e._name],this._linkParameters()},t.prototype.addRenderEffectAsPass=function(e){this._renderEffectAsPasses[e._name]=e,this._linkParameters()},t.prototype.getPass=function(e){for(var t in this._renderPasses)if(t===e)return this._renderPasses[e]},t.prototype.emptyPasses=function(){this._renderPasses={},this._linkParameters()},t.prototype._attachCameras=function(t){for(var r,i=e.Tools.MakeArray(t||this._cameras),n=0;nthis._maxX||rthis._maxZ)return this.position.y;this._heightQuads&&0!=this._heightQuads.length||(this._initHeightQuads(),this._computeHeightQuads());var s=this._getFacetAt(t,r),a=-(s.x*t+s.z*r+s.w)/s.y;return e.Vector3.TransformCoordinatesFromFloatsToRef(0,a,0,i,o),o.y},r.prototype.getNormalAtCoordinates=function(t,r){var i=new e.Vector3(0,1,0);return this.getNormalAtCoordinatesToRef(t,r,i),i},r.prototype.getNormalAtCoordinatesToRef=function(t,r,i){var n=this.getWorldMatrix(),o=e.Tmp.Matrix[5];n.invertToRef(o);var s=e.Tmp.Vector3[8];if(e.Vector3.TransformCoordinatesFromFloatsToRef(t,0,r,o,s),t=s.x,r=s.z,tthis._maxX||rthis._maxZ)return this;this._heightQuads&&0!=this._heightQuads.length||(this._initHeightQuads(),this._computeHeightQuads());var a=this._getFacetAt(t,r);return e.Vector3.TransformNormalFromFloatsToRef(a.x,a.y,a.z,n,i),this},r.prototype.updateCoordinateHeights=function(){return this._heightQuads&&0!=this._heightQuads.length||this._initHeightQuads(),this._computeHeightQuads(),this},r.prototype._getFacetAt=function(e,t){var r=(this._subdivisionsX,this._subdivisionsY,Math.floor((e+this._maxX)*this._subdivisionsX/this._width)),i=Math.floor(-(t+this._maxZ)*this._subdivisionsY/this._height+this._subdivisionsY),n=this._heightQuads[i*this._subdivisionsX+r];return t0,a.REFLECTIONOVERALPHA=this._useReflectionOverAlpha,a.INVERTCUBICMAP=this._reflectionTexture.coordinatesMode===e.Texture.INVCUBIC_MODE,a.REFLECTIONMAP_3D=this._reflectionTexture.isCube,this._reflectionTexture.coordinatesMode){case e.Texture.CUBIC_MODE:case e.Texture.INVCUBIC_MODE:a.setReflectionMode("REFLECTIONMAP_CUBIC");break;case e.Texture.EXPLICIT_MODE:a.setReflectionMode("REFLECTIONMAP_EXPLICIT");break;case e.Texture.PLANAR_MODE:a.setReflectionMode("REFLECTIONMAP_PLANAR");break;case e.Texture.PROJECTION_MODE:a.setReflectionMode("REFLECTIONMAP_PROJECTION");break;case e.Texture.SKYBOX_MODE:a.setReflectionMode("REFLECTIONMAP_SKYBOX");break;case e.Texture.SPHERICAL_MODE:a.setReflectionMode("REFLECTIONMAP_SPHERICAL");break;case e.Texture.EQUIRECTANGULAR_MODE:a.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR");break;case e.Texture.FIXED_EQUIRECTANGULAR_MODE:a.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR_FIXED");break;case e.Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:a.setReflectionMode("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED")}}else a.REFLECTION=!1;if(this._emissiveTexture&&i.EmissiveTextureEnabled){if(!this._emissiveTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._emissiveTexture,a,"EMISSIVE")}else a.EMISSIVE=!1;if(this._lightmapTexture&&i.LightmapTextureEnabled){if(!this._lightmapTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._lightmapTexture,a,"LIGHTMAP"),a.USELIGHTMAPASSHADOWMAP=this._useLightmapAsShadowmap}else a.LIGHTMAP=!1;if(this._specularTexture&&i.SpecularTextureEnabled){if(!this._specularTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._specularTexture,a,"SPECULAR"),a.GLOSSINESS=this._useGlossinessFromSpecularMapAlpha}else a.SPECULAR=!1;if(s.getEngine().getCaps().standardDerivatives&&this._bumpTexture&&i.BumpTextureEnabled){if(!this._bumpTexture.isReady())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._bumpTexture,a,"BUMP"),a.PARALLAX=this._useParallax,a.PARALLAXOCCLUSION=this._useParallaxOcclusion}else a.BUMP=!1;if(this._refractionTexture&&i.RefractionTextureEnabled){if(!this._refractionTexture.isReadyOrNotBlocking())return!1;a._needUVs=!0,a.REFRACTION=!0,a.REFRACTIONMAP_3D=this._refractionTexture.isCube}else a.REFRACTION=!1;a.TWOSIDEDLIGHTING=!this._backFaceCulling&&this._twoSidedLighting}else a.DIFFUSE=!1,a.AMBIENT=!1,a.OPACITY=!1,a.REFLECTION=!1,a.EMISSIVE=!1,a.LIGHTMAP=!1,a.BUMP=!1,a.REFRACTION=!1;a.ALPHAFROMDIFFUSE=this._shouldUseAlphaFromDiffuseTexture(),a.EMISSIVEASILLUMINATION=this._useEmissiveAsIllumination,a.LINKEMISSIVEWITHDIFFUSE=this._linkEmissiveWithDiffuse,a.SPECULAROVERALPHA=this._useSpecularOverAlpha}if(a._areImageProcessingDirty){if(!this._imageProcessingConfiguration.isReady())return!1;this._imageProcessingConfiguration.prepareDefines(a)}if(a._areFresnelDirty&&(i.FresnelEnabled?(this._diffuseFresnelParameters||this._opacityFresnelParameters||this._emissiveFresnelParameters||this._refractionFresnelParameters||this._reflectionFresnelParameters)&&(a.DIFFUSEFRESNEL=this._diffuseFresnelParameters&&this._diffuseFresnelParameters.isEnabled,a.OPACITYFRESNEL=this._opacityFresnelParameters&&this._opacityFresnelParameters.isEnabled,a.REFLECTIONFRESNEL=this._reflectionFresnelParameters&&this._reflectionFresnelParameters.isEnabled,a.REFLECTIONFRESNELFROMSPECULAR=this._useReflectionFresnelFromSpecular,a.REFRACTIONFRESNEL=this._refractionFresnelParameters&&this._refractionFresnelParameters.isEnabled,a.EMISSIVEFRESNEL=this._emissiveFresnelParameters&&this._emissiveFresnelParameters.isEnabled,a._needNormals=!0,a.FRESNEL=!0):a.FRESNEL=!1),e.MaterialHelper.PrepareDefinesForMisc(r,s,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,a),e.MaterialHelper.PrepareDefinesForAttributes(r,a,!0,!0,!0),e.MaterialHelper.PrepareDefinesForFrameBoundValues(s,u,a,o),a.isDirty){a.markAsProcessed(),s.resetCachedMaterial();var l=new e.EffectFallbacks;a.REFLECTION&&l.addFallback(0,"REFLECTION"),a.SPECULAR&&l.addFallback(0,"SPECULAR"),a.BUMP&&l.addFallback(0,"BUMP"),a.PARALLAX&&l.addFallback(1,"PARALLAX"),a.PARALLAXOCCLUSION&&l.addFallback(0,"PARALLAXOCCLUSION"),a.SPECULAROVERALPHA&&l.addFallback(0,"SPECULAROVERALPHA"),a.FOG&&l.addFallback(1,"FOG"),a.POINTSIZE&&l.addFallback(0,"POINTSIZE"),a.LOGARITHMICDEPTH&&l.addFallback(0,"LOGARITHMICDEPTH"),e.MaterialHelper.HandleFallbacksForShadows(a,l,this._maxSimultaneousLights),a.SPECULARTERM&&l.addFallback(0,"SPECULARTERM"),a.DIFFUSEFRESNEL&&l.addFallback(1,"DIFFUSEFRESNEL"),a.OPACITYFRESNEL&&l.addFallback(2,"OPACITYFRESNEL"),a.REFLECTIONFRESNEL&&l.addFallback(3,"REFLECTIONFRESNEL"),a.EMISSIVEFRESNEL&&l.addFallback(4,"EMISSIVEFRESNEL"),a.FRESNEL&&l.addFallback(4,"FRESNEL");var c=[e.VertexBuffer.PositionKind];a.NORMAL&&c.push(e.VertexBuffer.NormalKind),a.UV1&&c.push(e.VertexBuffer.UVKind),a.UV2&&c.push(e.VertexBuffer.UV2Kind),a.VERTEXCOLOR&&c.push(e.VertexBuffer.ColorKind),e.MaterialHelper.PrepareAttributesForBones(c,r,a,l),e.MaterialHelper.PrepareAttributesForInstances(c,a),e.MaterialHelper.PrepareAttributesForMorphTargets(c,r,a);var h="default",f=["world","view","viewProjection","vEyePosition","vLightsType","vAmbientColor","vDiffuseColor","vSpecularColor","vEmissiveColor","vFogInfos","vFogColor","pointSize","vDiffuseInfos","vAmbientInfos","vOpacityInfos","vReflectionInfos","vEmissiveInfos","vSpecularInfos","vBumpInfos","vLightmapInfos","vRefractionInfos","mBones","vClipPlane","diffuseMatrix","ambientMatrix","opacityMatrix","reflectionMatrix","emissiveMatrix","specularMatrix","bumpMatrix","lightmapMatrix","refractionMatrix","diffuseLeftColor","diffuseRightColor","opacityParts","reflectionLeftColor","reflectionRightColor","emissiveLeftColor","emissiveRightColor","refractionLeftColor","refractionRightColor","logarithmicDepthConstant","vNormalReoderParams"],d=["diffuseSampler","ambientSampler","opacitySampler","reflectionCubeSampler","reflection2DSampler","emissiveSampler","specularSampler","bumpSampler","lightmapSampler","refractionCubeSampler","refraction2DSampler"],p=["Material","Scene"];e.ImageProcessingConfiguration.PrepareUniforms(f,a),e.ImageProcessingConfiguration.PrepareSamplers(d,a),e.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:f,uniformBuffersNames:p,samplers:d,defines:a,maxSimultaneousLights:this._maxSimultaneousLights}),this.customShaderNameResolve&&(h=this.customShaderNameResolve(h,f,p,d,a));var g=a.toString();n.setEffect(s.getEngine().createEffect(h,{attributes:c,uniformsNames:f,uniformBuffersNames:p,samplers:d,defines:g,fallbacks:l,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights,maxSimultaneousMorphTargets:a.NUM_MORPH_INFLUENCERS}},u),a),this.buildUniformLayout()}return!!n.effect.isReady()&&(a._renderId=s.getRenderId(),this._wasPreviouslyReady=!0,!0)},i.prototype.buildUniformLayout=function(){this._uniformBuffer.addUniform("diffuseLeftColor",4),this._uniformBuffer.addUniform("diffuseRightColor",4),this._uniformBuffer.addUniform("opacityParts",4),this._uniformBuffer.addUniform("reflectionLeftColor",4),this._uniformBuffer.addUniform("reflectionRightColor",4),this._uniformBuffer.addUniform("refractionLeftColor",4),this._uniformBuffer.addUniform("refractionRightColor",4),this._uniformBuffer.addUniform("emissiveLeftColor",4),this._uniformBuffer.addUniform("emissiveRightColor",4),this._uniformBuffer.addUniform("vDiffuseInfos",2),this._uniformBuffer.addUniform("vAmbientInfos",2),this._uniformBuffer.addUniform("vOpacityInfos",2),this._uniformBuffer.addUniform("vReflectionInfos",2),this._uniformBuffer.addUniform("vEmissiveInfos",2),this._uniformBuffer.addUniform("vLightmapInfos",2),this._uniformBuffer.addUniform("vSpecularInfos",2),this._uniformBuffer.addUniform("vBumpInfos",3),this._uniformBuffer.addUniform("diffuseMatrix",16),this._uniformBuffer.addUniform("ambientMatrix",16),this._uniformBuffer.addUniform("opacityMatrix",16),this._uniformBuffer.addUniform("reflectionMatrix",16),this._uniformBuffer.addUniform("emissiveMatrix",16),this._uniformBuffer.addUniform("lightmapMatrix",16),this._uniformBuffer.addUniform("specularMatrix",16),this._uniformBuffer.addUniform("bumpMatrix",16),this._uniformBuffer.addUniform("vNormalReoderParams",4),this._uniformBuffer.addUniform("refractionMatrix",16),this._uniformBuffer.addUniform("vRefractionInfos",4),this._uniformBuffer.addUniform("vSpecularColor",4),this._uniformBuffer.addUniform("vEmissiveColor",3),this._uniformBuffer.addUniform("vDiffuseColor",4),this._uniformBuffer.addUniform("pointSize",1),this._uniformBuffer.create()},i.prototype.unbind=function(){this._activeEffect&&(this._reflectionTexture&&this._reflectionTexture.isRenderTarget&&this._activeEffect.setTexture("reflection2DSampler",null),this._refractionTexture&&this._refractionTexture.isRenderTarget&&this._activeEffect.setTexture("refraction2DSampler",null)),r.prototype.unbind.call(this)},i.prototype.bindForSubMesh=function(t,r,n){var o=this.getScene(),s=n._materialDefines;if(s){var a=n.effect;if(this._activeEffect=a,this.bindOnlyWorldMatrix(t),e.MaterialHelper.BindBonesParameters(r,a),this._mustRebind(o,a,r.visibility)){if(this._uniformBuffer.bindToEffect(a,"Material"),this.bindViewProjection(a),!this._uniformBuffer.useUbo||!this.isFrozen||!this._uniformBuffer.isSync){if(i.FresnelEnabled&&s.FRESNEL&&(this.diffuseFresnelParameters&&this.diffuseFresnelParameters.isEnabled&&(this._uniformBuffer.updateColor4("diffuseLeftColor",this.diffuseFresnelParameters.leftColor,this.diffuseFresnelParameters.power),this._uniformBuffer.updateColor4("diffuseRightColor",this.diffuseFresnelParameters.rightColor,this.diffuseFresnelParameters.bias)),this.opacityFresnelParameters&&this.opacityFresnelParameters.isEnabled&&this._uniformBuffer.updateColor4("opacityParts",new e.Color3(this.opacityFresnelParameters.leftColor.toLuminance(),this.opacityFresnelParameters.rightColor.toLuminance(),this.opacityFresnelParameters.bias),this.opacityFresnelParameters.power),this.reflectionFresnelParameters&&this.reflectionFresnelParameters.isEnabled&&(this._uniformBuffer.updateColor4("reflectionLeftColor",this.reflectionFresnelParameters.leftColor,this.reflectionFresnelParameters.power),this._uniformBuffer.updateColor4("reflectionRightColor",this.reflectionFresnelParameters.rightColor,this.reflectionFresnelParameters.bias)),this.refractionFresnelParameters&&this.refractionFresnelParameters.isEnabled&&(this._uniformBuffer.updateColor4("refractionLeftColor",this.refractionFresnelParameters.leftColor,this.refractionFresnelParameters.power),this._uniformBuffer.updateColor4("refractionRightColor",this.refractionFresnelParameters.rightColor,this.refractionFresnelParameters.bias)),this.emissiveFresnelParameters&&this.emissiveFresnelParameters.isEnabled&&(this._uniformBuffer.updateColor4("emissiveLeftColor",this.emissiveFresnelParameters.leftColor,this.emissiveFresnelParameters.power),this._uniformBuffer.updateColor4("emissiveRightColor",this.emissiveFresnelParameters.rightColor,this.emissiveFresnelParameters.bias))),o.texturesEnabled&&(this._diffuseTexture&&i.DiffuseTextureEnabled&&(this._uniformBuffer.updateFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),e.MaterialHelper.BindTextureMatrix(this._diffuseTexture,this._uniformBuffer,"diffuse")),this._ambientTexture&&i.AmbientTextureEnabled&&(this._uniformBuffer.updateFloat2("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level),e.MaterialHelper.BindTextureMatrix(this._ambientTexture,this._uniformBuffer,"ambient")),this._opacityTexture&&i.OpacityTextureEnabled&&(this._uniformBuffer.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),e.MaterialHelper.BindTextureMatrix(this._opacityTexture,this._uniformBuffer,"opacity")),this._reflectionTexture&&i.ReflectionTextureEnabled&&(this._uniformBuffer.updateFloat2("vReflectionInfos",this._reflectionTexture.level,this.roughness),this._uniformBuffer.updateMatrix("reflectionMatrix",this._reflectionTexture.getReflectionTextureMatrix())),this._emissiveTexture&&i.EmissiveTextureEnabled&&(this._uniformBuffer.updateFloat2("vEmissiveInfos",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),e.MaterialHelper.BindTextureMatrix(this._emissiveTexture,this._uniformBuffer,"emissive")),this._lightmapTexture&&i.LightmapTextureEnabled&&(this._uniformBuffer.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),e.MaterialHelper.BindTextureMatrix(this._lightmapTexture,this._uniformBuffer,"lightmap")),this._specularTexture&&i.SpecularTextureEnabled&&(this._uniformBuffer.updateFloat2("vSpecularInfos",this._specularTexture.coordinatesIndex,this._specularTexture.level),e.MaterialHelper.BindTextureMatrix(this._specularTexture,this._uniformBuffer,"specular")),this._bumpTexture&&o.getEngine().getCaps().standardDerivatives&&i.BumpTextureEnabled&&(this._uniformBuffer.updateFloat3("vBumpInfos",this._bumpTexture.coordinatesIndex,1/this._bumpTexture.level,this.parallaxScaleBias),e.MaterialHelper.BindTextureMatrix(this._bumpTexture,this._uniformBuffer,"bump"),o._mirroredCameraPosition?this._uniformBuffer.updateFloat4("vNormalReoderParams",this.invertNormalMapX?0:1,this.invertNormalMapX?1:-1,this.invertNormalMapY?0:1,this.invertNormalMapY?1:-1):this._uniformBuffer.updateFloat4("vNormalReoderParams",this.invertNormalMapX?1:0,this.invertNormalMapX?-1:1,this.invertNormalMapY?1:0,this.invertNormalMapY?-1:1)),this._refractionTexture&&i.RefractionTextureEnabled)){var u=1;this._refractionTexture.isCube||(this._uniformBuffer.updateMatrix("refractionMatrix",this._refractionTexture.getReflectionTextureMatrix()),this._refractionTexture.depth&&(u=this._refractionTexture.depth)),this._uniformBuffer.updateFloat4("vRefractionInfos",this._refractionTexture.level,this.indexOfRefraction,u,this.invertRefractionY?-1:1)}this.pointsCloud&&this._uniformBuffer.updateFloat("pointSize",this.pointSize),s.SPECULARTERM&&this._uniformBuffer.updateColor4("vSpecularColor",this.specularColor,this.specularPower),this._uniformBuffer.updateColor3("vEmissiveColor",this.emissiveColor),this._uniformBuffer.updateColor4("vDiffuseColor",this.diffuseColor,this.alpha*r.visibility)}if(o.texturesEnabled&&(this._diffuseTexture&&i.DiffuseTextureEnabled&&a.setTexture("diffuseSampler",this._diffuseTexture),this._ambientTexture&&i.AmbientTextureEnabled&&a.setTexture("ambientSampler",this._ambientTexture),this._opacityTexture&&i.OpacityTextureEnabled&&a.setTexture("opacitySampler",this._opacityTexture),this._reflectionTexture&&i.ReflectionTextureEnabled&&(this._reflectionTexture.isCube?a.setTexture("reflectionCubeSampler",this._reflectionTexture):a.setTexture("reflection2DSampler",this._reflectionTexture)),this._emissiveTexture&&i.EmissiveTextureEnabled&&a.setTexture("emissiveSampler",this._emissiveTexture),this._lightmapTexture&&i.LightmapTextureEnabled&&a.setTexture("lightmapSampler",this._lightmapTexture),this._specularTexture&&i.SpecularTextureEnabled&&a.setTexture("specularSampler",this._specularTexture),this._bumpTexture&&o.getEngine().getCaps().standardDerivatives&&i.BumpTextureEnabled&&a.setTexture("bumpSampler",this._bumpTexture),this._refractionTexture&&i.RefractionTextureEnabled)){var u=1;this._refractionTexture.isCube?a.setTexture("refractionCubeSampler",this._refractionTexture):a.setTexture("refraction2DSampler",this._refractionTexture)}e.MaterialHelper.BindClipPlane(a,o),o.ambientColor.multiplyToRef(this.ambientColor,this._globalAmbientColor),a.setVector3("vEyePosition",o._mirroredCameraPosition?o._mirroredCameraPosition:o.activeCamera.globalPosition),a.setColor3("vAmbientColor",this._globalAmbientColor)}!this._mustRebind(o,a)&&this.isFrozen||(o.lightsEnabled&&!this._disableLighting&&e.MaterialHelper.BindLights(o,r,a,s,this._maxSimultaneousLights),(o.fogEnabled&&r.applyFog&&o.fogMode!==e.Scene.FOGMODE_NONE||this._reflectionTexture||this._refractionTexture)&&this.bindView(a),e.MaterialHelper.BindFogParameters(o,r,a),s.NUM_MORPH_INFLUENCERS&&e.MaterialHelper.BindMorphTargetParameters(r,a),e.MaterialHelper.BindLogDepth(s,a,o),this._imageProcessingConfiguration.bind(this._activeEffect)),this._uniformBuffer.update(),this._afterBind(r,this._activeEffect)}},i.prototype.getAnimatables=function(){var e=[];return this._diffuseTexture&&this._diffuseTexture.animations&&this._diffuseTexture.animations.length>0&&e.push(this._diffuseTexture),this._ambientTexture&&this._ambientTexture.animations&&this._ambientTexture.animations.length>0&&e.push(this._ambientTexture),this._opacityTexture&&this._opacityTexture.animations&&this._opacityTexture.animations.length>0&&e.push(this._opacityTexture),this._reflectionTexture&&this._reflectionTexture.animations&&this._reflectionTexture.animations.length>0&&e.push(this._reflectionTexture),this._emissiveTexture&&this._emissiveTexture.animations&&this._emissiveTexture.animations.length>0&&e.push(this._emissiveTexture),this._specularTexture&&this._specularTexture.animations&&this._specularTexture.animations.length>0&&e.push(this._specularTexture),this._bumpTexture&&this._bumpTexture.animations&&this._bumpTexture.animations.length>0&&e.push(this._bumpTexture),this._lightmapTexture&&this._lightmapTexture.animations&&this._lightmapTexture.animations.length>0&&e.push(this._lightmapTexture),this._refractionTexture&&this._refractionTexture.animations&&this._refractionTexture.animations.length>0&&e.push(this._refractionTexture),e},i.prototype.getActiveTextures=function(){var e=r.prototype.getActiveTextures.call(this);return this._diffuseTexture&&e.push(this._diffuseTexture),this._ambientTexture&&e.push(this._ambientTexture),this._opacityTexture&&e.push(this._opacityTexture),this._reflectionTexture&&e.push(this._reflectionTexture),this._emissiveTexture&&e.push(this._emissiveTexture),this._specularTexture&&e.push(this._specularTexture),this._bumpTexture&&e.push(this._bumpTexture),this._lightmapTexture&&e.push(this._lightmapTexture),this._refractionTexture&&e.push(this._refractionTexture),e},i.prototype.hasTexture=function(e){return!!r.prototype.hasTexture.call(this,e)||(this._diffuseTexture===e||(this._ambientTexture===e||(this._opacityTexture===e||(this._reflectionTexture===e||(this._emissiveTexture===e||(this._specularTexture===e||(this._bumpTexture===e||(this._lightmapTexture===e||this._refractionTexture===e))))))))},i.prototype.dispose=function(e,t){t&&(this._diffuseTexture&&this._diffuseTexture.dispose(),this._ambientTexture&&this._ambientTexture.dispose(),this._opacityTexture&&this._opacityTexture.dispose(),this._reflectionTexture&&this._reflectionTexture.dispose(),this._emissiveTexture&&this._emissiveTexture.dispose(),this._specularTexture&&this._specularTexture.dispose(),this._bumpTexture&&this._bumpTexture.dispose(),this._lightmapTexture&&this._lightmapTexture.dispose(),this._refractionTexture&&this._refractionTexture.dispose()),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),r.prototype.dispose.call(this,e,t)},i.prototype.clone=function(t){var r=this,n=e.SerializationHelper.Clone((function(){return new i(t,r.getScene())}),this);return n.name=t,n.id=t,n},i.prototype.serialize=function(){return e.SerializationHelper.Serialize(this)},i.Parse=function(t,r,n){return e.SerializationHelper.Parse((function(){return new i(t.name,r)}),t,r,n)},Object.defineProperty(i,"DiffuseTextureEnabled",{get:function(){return i._DiffuseTextureEnabled},set:function(t){i._DiffuseTextureEnabled!==t&&(i._DiffuseTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(i,"AmbientTextureEnabled",{get:function(){return i._AmbientTextureEnabled},set:function(t){i._AmbientTextureEnabled!==t&&(i._AmbientTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(i,"OpacityTextureEnabled",{get:function(){return i._OpacityTextureEnabled},set:function(t){i._OpacityTextureEnabled!==t&&(i._OpacityTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(i,"ReflectionTextureEnabled",{get:function(){return i._ReflectionTextureEnabled},set:function(t){i._ReflectionTextureEnabled!==t&&(i._ReflectionTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(i,"EmissiveTextureEnabled",{get:function(){return i._EmissiveTextureEnabled},set:function(t){i._EmissiveTextureEnabled!==t&&(i._EmissiveTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(i,"SpecularTextureEnabled",{get:function(){return i._SpecularTextureEnabled},set:function(t){i._SpecularTextureEnabled!==t&&(i._SpecularTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(i,"BumpTextureEnabled",{get:function(){return i._BumpTextureEnabled},set:function(t){i._BumpTextureEnabled!==t&&(i._BumpTextureEnabled=t, -e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(i,"LightmapTextureEnabled",{get:function(){return i._LightmapTextureEnabled},set:function(t){i._LightmapTextureEnabled!==t&&(i._LightmapTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(i,"RefractionTextureEnabled",{get:function(){return i._RefractionTextureEnabled},set:function(t){i._RefractionTextureEnabled!==t&&(i._RefractionTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(i,"ColorGradingTextureEnabled",{get:function(){return i._ColorGradingTextureEnabled},set:function(t){i._ColorGradingTextureEnabled!==t&&(i._ColorGradingTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(i,"FresnelEnabled",{get:function(){return i._FresnelEnabled},set:function(t){i._FresnelEnabled!==t&&(i._FresnelEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.FresnelDirtyFlag))},enumerable:!0,configurable:!0}),i})(e.PushMaterial);r._DiffuseTextureEnabled=!0,r._AmbientTextureEnabled=!0,r._OpacityTextureEnabled=!0,r._ReflectionTextureEnabled=!0,r._EmissiveTextureEnabled=!0,r._SpecularTextureEnabled=!0,r._BumpTextureEnabled=!0,r._LightmapTextureEnabled=!0,r._RefractionTextureEnabled=!0,r._ColorGradingTextureEnabled=!0,r._FresnelEnabled=!0,__decorate([e.serializeAsTexture("diffuseTexture")],r.prototype,"_diffuseTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"diffuseTexture",void 0),__decorate([e.serializeAsTexture("ambientTexture")],r.prototype,"_ambientTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"ambientTexture",void 0),__decorate([e.serializeAsTexture("opacityTexture")],r.prototype,"_opacityTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"opacityTexture",void 0),__decorate([e.serializeAsTexture("reflectionTexture")],r.prototype,"_reflectionTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"reflectionTexture",void 0),__decorate([e.serializeAsTexture("emissiveTexture")],r.prototype,"_emissiveTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"emissiveTexture",void 0),__decorate([e.serializeAsTexture("specularTexture")],r.prototype,"_specularTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"specularTexture",void 0),__decorate([e.serializeAsTexture("bumpTexture")],r.prototype,"_bumpTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"bumpTexture",void 0),__decorate([e.serializeAsTexture("lightmapTexture")],r.prototype,"_lightmapTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"lightmapTexture",void 0),__decorate([e.serializeAsTexture("refractionTexture")],r.prototype,"_refractionTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"refractionTexture",void 0),__decorate([e.serializeAsColor3("ambient")],r.prototype,"ambientColor",void 0),__decorate([e.serializeAsColor3("diffuse")],r.prototype,"diffuseColor",void 0),__decorate([e.serializeAsColor3("specular")],r.prototype,"specularColor",void 0),__decorate([e.serializeAsColor3("emissive")],r.prototype,"emissiveColor",void 0),__decorate([e.serialize()],r.prototype,"specularPower",void 0),__decorate([e.serialize("useAlphaFromDiffuseTexture")],r.prototype,"_useAlphaFromDiffuseTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useAlphaFromDiffuseTexture",void 0),__decorate([e.serialize("useEmissiveAsIllumination")],r.prototype,"_useEmissiveAsIllumination",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useEmissiveAsIllumination",void 0),__decorate([e.serialize("linkEmissiveWithDiffuse")],r.prototype,"_linkEmissiveWithDiffuse",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"linkEmissiveWithDiffuse",void 0),__decorate([e.serialize("useSpecularOverAlpha")],r.prototype,"_useSpecularOverAlpha",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useSpecularOverAlpha",void 0),__decorate([e.serialize("useReflectionOverAlpha")],r.prototype,"_useReflectionOverAlpha",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useReflectionOverAlpha",void 0),__decorate([e.serialize("disableLighting")],r.prototype,"_disableLighting",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsLightsDirty")],r.prototype,"disableLighting",void 0),__decorate([e.serialize("useParallax")],r.prototype,"_useParallax",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useParallax",void 0),__decorate([e.serialize("useParallaxOcclusion")],r.prototype,"_useParallaxOcclusion",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useParallaxOcclusion",void 0),__decorate([e.serialize()],r.prototype,"parallaxScaleBias",void 0),__decorate([e.serialize("roughness")],r.prototype,"_roughness",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"roughness",void 0),__decorate([e.serialize()],r.prototype,"indexOfRefraction",void 0),__decorate([e.serialize()],r.prototype,"invertRefractionY",void 0),__decorate([e.serialize("useLightmapAsShadowmap")],r.prototype,"_useLightmapAsShadowmap",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useLightmapAsShadowmap",void 0),__decorate([e.serializeAsFresnelParameters("diffuseFresnelParameters")],r.prototype,"_diffuseFresnelParameters",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],r.prototype,"diffuseFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters("opacityFresnelParameters")],r.prototype,"_opacityFresnelParameters",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],r.prototype,"opacityFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters("reflectionFresnelParameters")],r.prototype,"_reflectionFresnelParameters",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],r.prototype,"reflectionFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters("refractionFresnelParameters")],r.prototype,"_refractionFresnelParameters",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],r.prototype,"refractionFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters("emissiveFresnelParameters")],r.prototype,"_emissiveFresnelParameters",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],r.prototype,"emissiveFresnelParameters",void 0),__decorate([e.serialize("useReflectionFresnelFromSpecular")],r.prototype,"_useReflectionFresnelFromSpecular",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],r.prototype,"useReflectionFresnelFromSpecular",void 0),__decorate([e.serialize("useGlossinessFromSpecularMapAlpha")],r.prototype,"_useGlossinessFromSpecularMapAlpha",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useGlossinessFromSpecularMapAlpha",void 0),__decorate([e.serialize("maxSimultaneousLights")],r.prototype,"_maxSimultaneousLights",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsLightsDirty")],r.prototype,"maxSimultaneousLights",void 0),__decorate([e.serialize("invertNormalMapX")],r.prototype,"_invertNormalMapX",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"invertNormalMapX",void 0),__decorate([e.serialize("invertNormalMapY")],r.prototype,"_invertNormalMapY",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"invertNormalMapY",void 0),__decorate([e.serialize("twoSidedLighting")],r.prototype,"_twoSidedLighting",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"twoSidedLighting",void 0),__decorate([e.serialize()],r.prototype,"useLogarithmicDepth",null),e.StandardMaterial=r})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(){this._count=0,this._data={}}return e.prototype.copyFrom=function(e){var t=this;this.clear(),e.forEach((function(e,r){return t.add(e,r)}))},e.prototype.get=function(e){var t=this._data[e];if(void 0!==t)return t},e.prototype.getOrAddWithFactory=function(e,t){var r=this.get(e);return void 0!==r?r:(r=t(e),r&&this.add(e,r),r)},e.prototype.getOrAdd=function(e,t){var r=this.get(e);return void 0!==r?r:(this.add(e,t),t)},e.prototype.contains=function(e){return void 0!==this._data[e]},e.prototype.add=function(e,t){return void 0===this._data[e]&&(this._data[e]=t,++this._count,!0)},e.prototype.set=function(e,t){return void 0!==this._data[e]&&(this._data[e]=t,!0)},e.prototype.getAndRemove=function(e){var t=this.get(e);return void 0!==t?(delete this._data[e],--this._count,t):null},e.prototype.remove=function(e){return!!this.contains(e)&&(delete this._data[e],--this._count,!0)},e.prototype.clear=function(){this._data={},this._count=0},Object.defineProperty(e.prototype,"count",{get:function(){return this._count},enumerable:!0,configurable:!0}),e.prototype.forEach=function(e){for(var t in this._data){e(t,this._data[t])}},e.prototype.first=function(e){for(var t in this._data){var r=this._data[t],i=e(t,r);if(i)return i}return null},e})();e.StringDictionary=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(){}return e})();e.DynamicFloatArrayElementInfo=t;var r=(function(){function e(e,r){this.compareValueOffset=null,this.sortingAscending=!0,this._stride=e,this.buffer=new Float32Array(e*r),this._lastUsed=0,this._firstFree=0,this._allEntries=new Array(r),this._freeEntries=new Array(r);for(var i=0;i0?this._firstFree=this._freeEntries[this._freeEntries.length-1].offset:this._firstFree+=this._stride),e},e.prototype.freeElement=function(e){this._firstFree=Math.min(e.offset,this._firstFree),this._freeEntries.push(e)},e.prototype.pack=function(){if(0===this._freeEntries.length)return this.buffer;if(this._lastUsed=a);l++){var c=i[l],h=c.offset,f=h-u;if(f!==e){for(var d=f/e-1,p=h-e,g=Math.min(s,d),_=0;_this.value;case r.IsLesser:return this._effectiveTarget[this._property]-1&&this._scene._actionManagers.splice(e,1)},t.prototype.getScene=function(){return this._scene},t.prototype.hasSpecificTriggers=function(e){for(var t=0;t-1)return!0}return!1},t.prototype.hasSpecificTrigger=function(e){for(var t=0;t=t._OnPickTrigger&&r.trigger<=t._OnPointerOutTrigger)return!0}return!1},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"hasPickTriggers",{get:function(){for(var e=0;e=t._OnPickTrigger&&r.trigger<=t._OnPickUpTrigger)return!0}return!1},enumerable:!0,configurable:!0}),Object.defineProperty(t,"HasTriggers",{get:function(){for(var e in t.Triggers)if(t.Triggers.hasOwnProperty(e))return!0;return!1},enumerable:!0,configurable:!0}),Object.defineProperty(t,"HasPickTriggers",{get:function(){for(var e in t.Triggers)if(t.Triggers.hasOwnProperty(e)){var r=parseInt(e);if(r>=t._OnPickTrigger&&r<=t._OnPickUpTrigger)return!0}return!1},enumerable:!0,configurable:!0}),t.HasSpecificTrigger=function(e){for(var r in t.Triggers)if(t.Triggers.hasOwnProperty(r)){var i=parseInt(r);if(i===e)return!0}return!1},t.prototype.registerAction=function(r){return r.trigger===t.OnEveryFrameTrigger&&this.getScene().actionManager!==this?(e.Tools.Warn("OnEveryFrameTrigger can only be used with scene.actionManager"),null):(this.actions.push(r),t.Triggers[r.trigger]?t.Triggers[r.trigger]++:t.Triggers[r.trigger]=1,r._actionManager=this,r._prepare(),r)},t.prototype.processTrigger=function(e,r){for(var i=0;i0;if(2===r.type?f.push(o):f.push(i),g){for(var _=new Array,m=0;m0){var f=h.properties[0].value,d=null===h.properties[0].targetType?f:n.getMeshByName(f);d._meshId&&(d.mesh=n.getMeshByID(d._meshId)),c={trigger:e.ActionManager[h.name],parameter:d}}else c=e.ActionManager[h.name];for(var p=0;p=0;s--){var a=t[s],u=a.getParent();if(u){var l=this._debugLines[n];l||(l=[e.Vector3.Zero(),e.Vector3.Zero()],this._debugLines[n]=l),a.getAbsolutePositionToRef(this.mesh,l[0]),u.getAbsolutePositionToRef(this.mesh,l[1]),l[0].subtractInPlace(o),l[1].subtractInPlace(o),n++}}},t.prototype.update=function(){this.autoUpdateBonesMatrices&&this.skeleton.computeAbsoluteTransforms(),void 0===this.skeleton.bones[0].length?this._getLinesForBonesNoLength(this.skeleton.bones,this.mesh.getWorldMatrix()):this._getLinesForBonesWithLength(this.skeleton.bones,this.mesh.getWorldMatrix()),this._debugMesh?e.MeshBuilder.CreateLineSystem(null,{lines:this._debugLines,updatable:!0,instance:this._debugMesh},this._scene):(this._debugMesh=e.MeshBuilder.CreateLineSystem(null,{lines:this._debugLines,updatable:!0},this._scene),this._debugMesh.renderingGroupId=this.renderingGroupId),this._debugMesh.position.copyFrom(this.mesh.position),this._debugMesh.color=this.color},t.prototype.dispose=function(){this._debugMesh&&(this.isEnabled=!1,this._debugMesh.dispose(),this._debugMesh=null)},t})();t.SkeletonViewer=r})(e.Debug||(e.Debug={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){var r=(function(){function t(t,r){void 0===r&&(r=1),this._xline=[e.Vector3.Zero(),e.Vector3.Zero()],this._yline=[e.Vector3.Zero(),e.Vector3.Zero()],this._zline=[e.Vector3.Zero(),e.Vector3.Zero()],this.scaleLines=1,this.scaleLines=r,this._xmesh=e.Mesh.CreateLines("xline",this._xline,t,!0),this._ymesh=e.Mesh.CreateLines("yline",this._yline,t,!0),this._zmesh=e.Mesh.CreateLines("zline",this._zline,t,!0),this._xmesh.renderingGroupId=2,this._ymesh.renderingGroupId=2,this._zmesh.renderingGroupId=2,this._xmesh.material.checkReadyOnlyOnce=!0,this._xmesh.color=new e.Color3(1,0,0),this._ymesh.material.checkReadyOnlyOnce=!0,this._ymesh.color=new e.Color3(0,1,0),this._zmesh.material.checkReadyOnlyOnce=!0,this._zmesh.color=new e.Color3(0,0,1),this.scene=t}return t.prototype.update=function(t,r,i,n){var o=this.scaleLines;this._xmesh.position.copyFrom(t),this._ymesh.position.copyFrom(t),this._zmesh.position.copyFrom(t);var s=this._xline[1];s.x=r.x*o,s.y=r.y*o,s.z=r.z*o,e.Mesh.CreateLines(null,this._xline,null,null,this._xmesh),s=this._yline[1],s.x=i.x*o,s.y=i.y*o,s.z=i.z*o,e.Mesh.CreateLines(null,this._yline,null,null,this._ymesh),s=this._zline[1],s.x=n.x*o,s.y=n.y*o,s.z=n.z*o,e.Mesh.CreateLines(null,this._zline,null,null,this._zmesh)},t.prototype.dispose=function(){this._xmesh&&(this._xmesh.dispose(),this._ymesh.dispose(),this._zmesh.dispose(),this._xmesh=null,this._ymesh=null,this._zmesh=null,this._xline=null,this._yline=null,this._zline=null,this.scene=null)},t})();t.AxesViewer=r})(e.Debug||(e.Debug={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){var r=(function(t){function r(r,i,n,o){void 0===o&&(o=1);var s=t.call(this,r,o)||this;return s.pos=e.Vector3.Zero(),s.xaxis=e.Vector3.Zero(),s.yaxis=e.Vector3.Zero(),s.zaxis=e.Vector3.Zero(),s.mesh=n,s.bone=i,s}return __extends(r,t),r.prototype.update=function(){var r=this.bone;r.getAbsolutePositionToRef(this.mesh,this.pos),r.getDirectionToRef(e.Axis.X,this.mesh,this.xaxis),r.getDirectionToRef(e.Axis.Y,this.mesh,this.yaxis),r.getDirectionToRef(e.Axis.Z,this.mesh,this.zaxis),t.prototype.update.call(this,this.pos,this.xaxis,this.yaxis,this.zaxis)},r.prototype.dispose=function(){this.pos&&(this.pos=null,this.xaxis=null,this.yaxis=null,this.zaxis=null,this.mesh=null,this.bone=null,t.prototype.dispose.call(this))},r})(t.AxesViewer);t.BoneAxesViewer=r})(e.Debug||(e.Debug={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e){this.ray=e}return t.CreateAndShow=function(e,r,i){var n=new t(e);return n.show(r,i),n},t.prototype.show=function(t,r){if(!this._renderFunction){var i=this.ray;this._renderFunction=this._render.bind(this),this._scene=t,this._renderPoints=[i.origin,i.origin.add(i.direction.scale(i.length))],this._renderLine=e.Mesh.CreateLines("ray",this._renderPoints,t,!0),this._scene.registerBeforeRender(this._renderFunction)}r&&this._renderLine.color.copyFrom(r)},t.prototype.hide=function(){this._renderFunction&&(this._scene.unregisterBeforeRender(this._renderFunction),this._scene=null,this._renderFunction=null,this._renderLine.dispose(),this._renderLine=null,this._renderPoints=null)},t.prototype._render=function(){var t=this.ray,r=this._renderPoints[1],i=Math.min(t.length,1e6);r.copyFrom(t.direction),r.scaleInPlace(i),r.addInPlace(t.origin),e.Mesh.CreateLines("ray",this._renderPoints,this._scene,!0,this._renderLine)},t.prototype.attachToMesh=function(t,r,i,n){this._attachedToMesh=t;var o=this.ray;o.direction||(o.direction=e.Vector3.Zero()),o.origin||(o.origin=e.Vector3.Zero()),n&&(o.length=n),i||(i=e.Vector3.Zero()),r||(r=new e.Vector3(0,0,-1)),this._meshSpaceDirection?(this._meshSpaceDirection.copyFrom(r),this._meshSpaceOrigin.copyFrom(i)):(this._meshSpaceDirection=r.clone(),this._meshSpaceOrigin=i.clone()),this._updateToMeshFunction||(this._updateToMeshFunction=this._updateToMesh.bind(this),this._attachedToMesh.getScene().registerBeforeRender(this._updateToMeshFunction)),this._updateToMesh()},t.prototype.detachFromMesh=function(){this._attachedToMesh&&(this._attachedToMesh.getScene().unregisterBeforeRender(this._updateToMeshFunction),this._attachedToMesh=null,this._updateToMeshFunction=null)},t.prototype._updateToMesh=function(){var t=this.ray;if(this._attachedToMesh._isDisposed)return void this.detachFromMesh();this._attachedToMesh.getDirectionToRef(this._meshSpaceDirection,t.direction),e.Vector3.TransformCoordinatesToRef(this._meshSpaceOrigin,this._attachedToMesh.getWorldMatrix(),t.origin)},t.prototype.dispose=function(){this.hide(),this.detachFromMesh(),this.ray=null},t})();e.RayHelper=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e){this._scene=e}return t.prototype._createInspector=function(e){void 0===e&&(e={});var t=e.popup||!1,r=e.initialTab||0,i=e.parentElement||null;this._inspector||(this._inspector=new INSPECTOR.Inspector(this._scene,t,r,i,e.newColors))},t.prototype.isVisible=function(){return!!this._inspector},t.prototype.hide=function(){if(this._inspector){try{this._inspector.dispose()}catch(e){}this._inspector=null}},t.prototype.show=function(r){void 0===r&&(r={}),"undefined"==typeof INSPECTOR?e.Tools.LoadScript(t.InspectorURL,this._createInspector.bind(this,r)):this._createInspector(r)},t})();t.InspectorURL=window.location.href.split("/")[0]+"//preview.babylonjs.com/inspector/babylon.inspector.bundle.js",e.DebugLayer=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){var r=(function(){function t(t){this._impostors=[],this._meshes=[],this._numMeshes=0,this._scene=t||e.Engine.LastCreatedScene,this._physicsEnginePlugin=this._scene.getPhysicsEngine().getPhysicsPlugin()}return t.prototype._updateDebugMeshes=function(){for(var e=this._physicsEnginePlugin,t=0;t0?(this._meshes[r]=this._meshes[this._numMeshes],this._impostors[r]=this._impostors[this._numMeshes],this._meshes[this._numMeshes]=null,this._impostors[this._numMeshes]=null):(this._meshes[0]=null,this._impostors[0]=null),t=!0;break}t&&0===this._numMeshes&&this._scene.unregisterBeforeRender(this._renderFunction)},t.prototype._getDebugMaterial=function(t){return this._debugMaterial||(this._debugMaterial=new e.StandardMaterial("",t),this._debugMaterial.wireframe=!0),this._debugMaterial},t.prototype._getDebugBoxMesh=function(t){return this._debugBoxMesh||(this._debugBoxMesh=e.MeshBuilder.CreateBox("physicsBodyBoxViewMesh",{size:1},t),this._debugBoxMesh.renderingGroupId=1,this._debugBoxMesh.rotationQuaternion=e.Quaternion.Identity(),this._debugBoxMesh.material=this._getDebugMaterial(t),t.removeMesh(this._debugBoxMesh)),this._debugBoxMesh.createInstance("physicsBodyBoxViewInstance")},t.prototype._getDebugSphereMesh=function(t){return this._debugSphereMesh||(this._debugSphereMesh=e.MeshBuilder.CreateSphere("physicsBodySphereViewMesh",{diameter:1},t),this._debugSphereMesh.renderingGroupId=1,this._debugSphereMesh.rotationQuaternion=e.Quaternion.Identity(),this._debugSphereMesh.material=this._getDebugMaterial(t),t.removeMesh(this._debugSphereMesh)),this._debugSphereMesh.createInstance("physicsBodyBoxViewInstance")},t.prototype._getDebugMesh=function(t,r){var i,n=t.physicsBody;n.shapes[0];if(t.type==e.PhysicsImpostor.BoxImpostor)i=this._getDebugBoxMesh(r),t.getBoxSizeToRef(i.scaling);else if(t.type==e.PhysicsImpostor.SphereImpostor){i=this._getDebugSphereMesh(r);var o=t.getRadius();i.scaling.x=2*o,i.scaling.y=2*o,i.scaling.z=2*o}return i},t.prototype.dispose=function(){for(var e=0;e0},enumerable:!0,configurable:!0}),i.prototype._sortLODLevels=function(){this._LODLevels.sort((function(e,t){return e.distancet.distance?-1:0}))},i.prototype.addLODLevel=function(t,r){if(r&&r._masterMesh)return e.Tools.Warn("You cannot use a mesh as LOD level twice"),this;var i=new e.Internals.MeshLODLevel(t,r);return this._LODLevels.push(i),r&&(r._masterMesh=this),this._sortLODLevels(),this},i.prototype.getLODLevelAtDistance=function(e){for(var t=0;tr)return this.onLODLevelSelection&&this.onLODLevelSelection(r,this,this._LODLevels[this._LODLevels.length-1].mesh),this;for(var i=0;i0){var i=this.getIndices().length,n=!1;if(t)n=!0;else for(var o=0,s=this.subMeshes;o=i){n=!0;break}if(a.verticesStart+a.verticesCount>=r){n=!0;break}}if(!n)return}return this.releaseSubMeshes(),new e.SubMesh(0,0,r,0,this.getTotalIndices(),this)},i.prototype.subdivide=function(t){if(!(t<1)){for(var r=this.getTotalIndices(),i=r/t|0,n=0;i%3!=0;)i++;this.releaseSubMeshes();for(var o=0;o=r);o++)e.SubMesh.CreateFromIndices(0,n,Math.min(i,r-n),this),n+=i;this.synchronizeInstances()}},i.prototype.setVerticesData=function(t,r,i,n){if(this._geometry)this._geometry.setVerticesData(t,r,i,n);else{var o=new e.VertexData;o.set(r,t);var s=this.getScene();new e.Geometry(e.Geometry.RandomId(),s,o,i,this)}return this},i.prototype.markVerticesDataAsUpdatable=function(e,t){void 0===t&&(t=!0),this.getVertexBuffer(e).isUpdatable()!==t&&this.setVerticesData(e,this.getVerticesData(e),t)},i.prototype.setVerticesBuffer=function(t){if(!this._geometry){var r=this.getScene();new e.Geometry(e.Geometry.RandomId(),r).applyToMesh(this)}return this._geometry.setVerticesBuffer(t),this},i.prototype.updateVerticesData=function(e,t,r,i){if(this._geometry)return i?(this.makeGeometryUnique(),this.updateVerticesData(e,t,r,!1)):this._geometry.updateVerticesData(e,t,r),this},i.prototype.updateMeshPositions=function(t,r){void 0===r&&(r=!0);var i=this.getVerticesData(e.VertexBuffer.PositionKind);if(t(i),this.updateVerticesData(e.VertexBuffer.PositionKind,i,!1,!1),r){var n=this.getIndices(),o=this.getVerticesData(e.VertexBuffer.NormalKind);e.VertexData.ComputeNormals(i,n,o),this.updateVerticesData(e.VertexBuffer.NormalKind,o,!1,!1)}return this},i.prototype.makeGeometryUnique=function(){if(this._geometry){var t=this._geometry,r=this._geometry.copy(e.Geometry.RandomId());return t.releaseForMesh(this,!0),r.applyToMesh(this),this}},i.prototype.setIndices=function(t,r){if(this._geometry)this._geometry.setIndices(t,r);else{var i=new e.VertexData;i.indices=t;var n=this.getScene();new e.Geometry(e.Geometry.RandomId(),n,i,!1,this)}return this},i.prototype.toLeftHanded=function(){if(this._geometry)return this._geometry.toLeftHanded(),this},i.prototype._bind=function(t,r,i){var n,o=this.getScene().getEngine();if(this._unIndexed)n=null;else switch(i){case e.Material.PointFillMode:n=null;break;case e.Material.WireFrameFillMode:n=t.getLinesIndexBuffer(this.getIndices(),o);break;default:case e.Material.TriangleFillMode:n=this._unIndexed?null:this._geometry.getIndexBuffer()}return this._geometry._bind(r,n),this},i.prototype._draw=function(t,r,i){if(!this._geometry||!this._geometry.getVertexBuffers()||!this._geometry.getIndexBuffer())return this;this.onBeforeDrawObservable.notifyObservers(this);var n=this.getScene().getEngine();switch(r){case e.Material.PointFillMode:n.drawPointClouds(t.verticesStart,t.verticesCount,i);break;case e.Material.WireFrameFillMode:this._unIndexed?n.drawUnIndexed(!1,t.verticesStart,t.verticesCount,i):n.draw(!1,0,i>0?t.linesIndexCount/2:t.linesIndexCount,i);break;default:this._unIndexed?n.drawUnIndexed(!0,t.verticesStart,t.verticesCount,i):n.draw(!0,t.indexStart,t.indexCount,i)}return this},i.prototype.registerBeforeRender=function(e){return this.onBeforeRenderObservable.add(e),this},i.prototype.unregisterBeforeRender=function(e){return this.onBeforeRenderObservable.removeCallback(e),this},i.prototype.registerAfterRender=function(e){return this.onAfterRenderObservable.add(e),this},i.prototype.unregisterAfterRender=function(e){return this.onAfterRenderObservable.removeCallback(e),this},i.prototype._getInstancesRenderList=function(e){var t=this.getScene();if(this._batchCache.mustReturn=!1,this._batchCache.renderSelf[e]=this.isEnabled()&&this.isVisible,this._batchCache.visibleInstances[e]=null,this._visibleInstances){var r=t.getRenderId(),i=t._isInIntermediateRendering()?this._visibleInstances.intermediateDefaultRenderId:this._visibleInstances.defaultRenderId;this._batchCache.visibleInstances[e]=this._visibleInstances[r];var n=this._renderId;if(!this._batchCache.visibleInstances[e]&&i&&(this._batchCache.visibleInstances[e]=this._visibleInstances[i],r=Math.max(i,r),n=Math.max(this._visibleInstances.selfDefaultRenderId,r)),this._batchCache.visibleInstances[e]&&this._batchCache.visibleInstances[e].length){if(this._renderIdForInstances[e]===r)return this._batchCache.mustReturn=!0,this._batchCache;r!==n&&(this._batchCache.renderSelf[e]=!1)}this._renderIdForInstances[e]=r}return this._batchCache},i.prototype._renderWithInstances=function(t,r,i,n,o){for(var s=i.visibleInstances[t._id],a=s.length+1,u=16*a*4,l=this._instancesBufferSize,c=this._instancesBuffer;this._instancesBufferSize-1;t--)if(r[t].id===e)return this.material=r[t],this;var i=this.getScene().multiMaterials;for(t=i.length-1;t>-1;t--)if(i[t].id===e)return this.material=i[t],this;return this},i.prototype.getAnimatables=function(){var e=[];return this.material&&e.push(this.material),this.skeleton&&e.push(this.skeleton),e},i.prototype.bakeTransformIntoVertices=function(t){if(!this.isVerticesDataPresent(e.VertexBuffer.PositionKind))return this;var r=this.subMeshes.splice(0);this._resetPointsArrayCache();var i,n=this.getVerticesData(e.VertexBuffer.PositionKind),o=[];for(i=0;i-1&&(o.morphTargetManager=r.getMorphTargetManagerById(t.morphTargetManagerId)),t.skeletonId>-1&&(o.skeleton=r.getLastSkeletonByID(t.skeletonId),t.numBoneInfluencers&&(o.numBoneInfluencers=t.numBoneInfluencers)),t.animations){for(var s=0;s4,l=u?this.getVerticesData(e.VertexBuffer.MatricesIndicesExtraKind):null,c=u?this.getVerticesData(e.VertexBuffer.MatricesWeightsExtraKind):null,h=t.getTransformMatrices(this),f=e.Vector3.Zero(),d=new e.Matrix,p=new e.Matrix,g=0,_=0;_0;o++)e.Matrix.FromFloat32ArrayToRefScaled(h,16*s[g+o],m,p),d.addToSelf(p);if(u)for(o=0;o<4&&(m=c[g+o])>0;o++)e.Matrix.FromFloat32ArrayToRefScaled(h,16*l[g+o],m,p),d.addToSelf(p);e.Vector3.TransformCoordinatesFromFloatsToRef(this._sourcePositions[_],this._sourcePositions[_+1],this._sourcePositions[_+2],d,f),f.toArray(i,_),e.Vector3.TransformNormalFromFloatsToRef(this._sourceNormals[_],this._sourceNormals[_+1],this._sourceNormals[_+2],d,f),f.toArray(n,_),d.reset()}return this.updateVerticesData(e.VertexBuffer.PositionKind,i),this.updateVerticesData(e.VertexBuffer.NormalKind,n),this},i.MinMax=function(e){var t=null,r=null;return e.forEach((function(e,i,n){var o=e.getBoundingInfo().boundingBox;t?(t.MinimizeInPlace(o.minimumWorld),r.MaximizeInPlace(o.maximumWorld)):(t=o.minimumWorld,r=o.maximumWorld)})),{min:t,max:r}},i.Center=function(t){var r=t instanceof Array?e.Mesh.MinMax(t):t;return e.Vector3.Center(r.min,r.max)},i.MergeMeshes=function(t,r,n,o,s){void 0===r&&(r=!0);var a;if(!n){var u=0;for(a=0;a65536)return e.Tools.Warn("Cannot merge meshes because resulting mesh will have more than 65536 vertices. Please use allow32BitsIndices = true to use 32 bits indices"),null}var l,c,h,f=new Array;for(a=0;aa&&(a=c)}return new r(e,s,a-s+1,t,i,n,o)},r})(t);e.SubMesh=r})(BABYLON||(BABYLON={}));var BABYLON;!(function(BABYLON){var EffectFallbacks=(function(){function e(){this._defines={},this._currentRank=32,this._maxRank=-1}return e.prototype.addFallback=function(e,t){this._defines[e]||(ethis._maxRank&&(this._maxRank=e),this._defines[e]=new Array),this._defines[e].push(t)},e.prototype.addCPUSkinningFallback=function(e,t){this._meshRank=e,this._mesh=t,ethis._maxRank&&(this._maxRank=e)},Object.defineProperty(e.prototype,"isMoreFallbacks",{get:function(){return this._currentRank<=this._maxRank},enumerable:!0,configurable:!0}),e.prototype.reduce=function(e){if(this._mesh&&this._mesh.computeBonesUsingShaders&&this._mesh.numBoneInfluencers>0){this._mesh.computeBonesUsingShaders=!1,e=e.replace("#define NUM_BONE_INFLUENCERS "+this._mesh.numBoneInfluencers,"#define NUM_BONE_INFLUENCERS 0"),BABYLON.Tools.Log("Falling back to CPU skinning for "+this._mesh.name);for(var t=this._mesh.getScene(),r=0;r0&&(i.computeBonesUsingShaders=!1)}}else{var n=this._defines[this._currentRank];if(n)for(var r=0;r-1?e:BABYLON.Engine.ShadersRepository+e,BABYLON.Tools.LoadFile(r+".vertex.fx",t)},Effect.prototype._loadFragmentShader=function(e,t){if(e instanceof HTMLElement){return void t(BABYLON.Tools.GetDOMTextContent(e))}if("base64:"===e.substr(0,7)){return void t(window.atob(e.substr(7)))}if(Effect.ShadersStore[e+"PixelShader"])return void t(Effect.ShadersStore[e+"PixelShader"]);if(Effect.ShadersStore[e+"FragmentShader"])return void t(Effect.ShadersStore[e+"FragmentShader"]);var r;r="."===e[0]||"/"===e[0]||e.indexOf("http")>-1?e:BABYLON.Engine.ShadersRepository+e,BABYLON.Tools.LoadFile(r+".fragment.fx",t)},Effect.prototype._dumpShadersSource=function(e,t,r){var i=this._engine.webGLVersion>1?"#version 300 es\n":"",n=i+(r?r+"\n":"");e=n+e,t=n+t;var o=2,s="\n1\t"+e.replace(/\n/gm,(function(){return"\n"+o+++"\t"}));o=2;var a="\n1\t"+t.replace(/\n/gm,(function(){return"\n"+o+++"\t"}));this.name.vertexElement?(BABYLON.Tools.Error("Vertex shader: "+this.name.vertexElement+s),BABYLON.Tools.Error("Fragment shader: "+this.name.fragmentElement+a)):this.name.vertex?(BABYLON.Tools.Error("Vertex shader: "+this.name.vertex+s),BABYLON.Tools.Error("Fragment shader: "+this.name.fragment+a)):(BABYLON.Tools.Error("Vertex shader: "+this.name+s),BABYLON.Tools.Error("Fragment shader: "+this.name+a))},Effect.prototype._processShaderConversion=function(e,t,r){var i=this._processPrecision(e);if(1==this._engine.webGLVersion)return void r(i);if(-1!==i.indexOf("#version 3"))return void r(i.replace("#version 300 es",""));var n=i.replace(/#extension.+(GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth).+enable/g,"");n=n.replace(/varying(?![\n\r])\s/g,t?"in ":"out "),n=n.replace(/attribute[ \t]/g,"in "),n=n.replace(/[ \t]attribute/g," in"),t&&(n=n.replace(/texture2DLodEXT\(/g,"textureLod("),n=n.replace(/textureCubeLodEXT\(/g,"textureLod("),n=n.replace(/texture2D\(/g,"texture("),n=n.replace(/textureCube\(/g,"texture("),n=n.replace(/gl_FragDepthEXT/g,"gl_FragDepth"),n=n.replace(/gl_FragColor/g,"glFragColor"),n=n.replace(/void\s+?main\(/g,"out vec4 glFragColor;\nvoid main(")),r(n)},Effect.prototype._processIncludes=function(e,t){for(var r=this,i=/#include<(.+)>(\((.*)\))*(\[(.*)\])*/g,n=i.exec(e),o=new String(e);null!=n;){var s=n[1];if(-1!==s.indexOf("__decl__")&&(s=s.replace(/__decl__/,""),1!=this._engine.webGLVersion&&(s=s.replace(/Vertex/,"Ubo"),s=s.replace(/Fragment/,"Ubo")),s+="Declaration"),!Effect.IncludesShadersStore[s]){var a=BABYLON.Engine.ShadersRepository+"ShadersInclude/"+s+".fx";return void BABYLON.Tools.LoadFile(a,(function(e){Effect.IncludesShadersStore[s]=e,r._processIncludes(o,t)}))}var u=Effect.IncludesShadersStore[s];if(n[2])for(var l=n[3].split(","),c=0;c1)for(var s in this._uniformBuffersNames)this.bindUniformBlock(s,this._uniformBuffersNames[s]);this._uniforms=o.getUniforms(this._program,this._uniformsNames),this._attributes=o.getAttributes(this._program,r);var a;for(a=0;a0&&(result+=line+"\r\n")}return result}, +Effect.prototype._evaluateDefinesOnString=function(e){for(var t={children:[]},r=t,i=e.split("\n"),n=0;n0,r.NUM_MORPH_INFLUENCERS=s.numInfluencers}else r.MORPHTARGETS_TANGENT=!1,r.MORPHTARGETS_NORMAL=!1,r.MORPHTARGETS=!1,r.NUM_MORPH_INFLUENCERS=0;return!0},t.PrepareDefinesForLights=function(t,r,i,n,o,s){if(void 0===o&&(o=4),void 0===s&&(s=!1),!i._areLightsDirty)return i._needNormals;var a=0,u=!1,l=!1,c=!1,h=!1,f=!1;if(t.lightsEnabled&&!s)for(var d=0,p=r._lightSources;d0&&t.addFallback(i,"LIGHT"+i),e["SHADOW"+i]&&t.addFallback(0,"SHADOW"+i),e["SHADOWPCF"+i]&&t.addFallback(0,"SHADOWPCF"+i),e["SHADOWESM"+i]&&t.addFallback(0,"SHADOWESM"+i)},t.PrepareAttributesForMorphTargets=function(t,r,i){var n=i.NUM_MORPH_INFLUENCERS;if(n>0)for(var o=e.Engine.LastCreatedEngine.getCaps().maxVertexAttribs,s=r.morphTargetManager,a=s.supportsNormals&&i.NORMAL,u=s.supportsTangents&&i.TANGENT,l=0;lo&&e.Tools.Error("Cannot add more vertex attributes for mesh "+r.name)},t.PrepareAttributesForBones=function(t,r,i,n){i.NUM_BONE_INFLUENCERS>0&&(n.addCPUSkinningFallback(0,r),t.push(e.VertexBuffer.MatricesIndicesKind),t.push(e.VertexBuffer.MatricesWeightsKind),i.NUM_BONE_INFLUENCERS>4&&(t.push(e.VertexBuffer.MatricesIndicesExtraKind),t.push(e.VertexBuffer.MatricesWeightsExtraKind)))},t.PrepareAttributesForInstances=function(e,t){t.INSTANCES&&(e.push("world0"),e.push("world1"),e.push("world2"),e.push("world3"))},t.BindLightShadow=function(e,t,r,i,n){if(e.shadowEnabled&&r.receiveShadows){var o=e.getShadowGenerator();o&&o.bindShadowLight(i,n)}},t.BindLightProperties=function(e,t,r){e.transferToEffect(t,r+"")},t.BindLights=function(r,i,n,o,s,a){void 0===s&&(s=4),void 0===a&&(a=!1);for(var u=0,l=0,c=i._lightSources;l1,n||this._scene.materials.push(this)}return Object.defineProperty(t,"TriangleFillMode",{get:function(){return t._TriangleFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(t,"WireFrameFillMode",{get:function(){return t._WireFrameFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(t,"PointFillMode",{get:function(){return t._PointFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(t,"ClockWiseSideOrientation",{get:function(){return t._ClockWiseSideOrientation},enumerable:!0,configurable:!0}),Object.defineProperty(t,"CounterClockWiseSideOrientation",{get:function(){return t._CounterClockWiseSideOrientation},enumerable:!0,configurable:!0}),Object.defineProperty(t,"TextureDirtyFlag",{get:function(){return t._TextureDirtyFlag},enumerable:!0,configurable:!0}),Object.defineProperty(t,"LightDirtyFlag",{get:function(){return t._LightDirtyFlag},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FresnelDirtyFlag",{get:function(){return t._FresnelDirtyFlag},enumerable:!0,configurable:!0}),Object.defineProperty(t,"AttributesDirtyFlag",{get:function(){return t._AttributesDirtyFlag},enumerable:!0,configurable:!0}),Object.defineProperty(t,"MiscDirtyFlag",{get:function(){return t._MiscDirtyFlag},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"backFaceCulling",{get:function(){return this._backFaceCulling},set:function(e){this._backFaceCulling!==e&&(this._backFaceCulling=e,this.markAsDirty(t.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onBind",{set:function(e){this._onBindObserver&&this.onBindObservable.remove(this._onBindObserver),this._onBindObserver=this.onBindObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"fogEnabled",{get:function(){return this._fogEnabled},set:function(e){this._fogEnabled!==e&&(this._fogEnabled=e,this.markAsDirty(t.MiscDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"wireframe",{get:function(){return this._fillMode===t.WireFrameFillMode},set:function(e){this._fillMode=e?t.WireFrameFillMode:t.TriangleFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"pointsCloud",{get:function(){return this._fillMode===t.PointFillMode},set:function(e){this._fillMode=e?t.PointFillMode:t.TriangleFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"fillMode",{get:function(){return this._fillMode},set:function(e){this._fillMode!==e&&(this._fillMode=e,this.markAsDirty(t.MiscDirtyFlag))},enumerable:!0,configurable:!0}),t.prototype.toString=function(e){return"Name: "+this.name},t.prototype.getClassName=function(){return"Material"},Object.defineProperty(t.prototype,"isFrozen",{get:function(){return this.checkReadyOnlyOnce},enumerable:!0,configurable:!0}),t.prototype.freeze=function(){this.checkReadyOnlyOnce=!0},t.prototype.unfreeze=function(){this.checkReadyOnlyOnce=!1},t.prototype.isReady=function(e,t){return!0},t.prototype.isReadyForSubMesh=function(e,t,r){return!1},t.prototype.getEffect=function(){return this._effect},t.prototype.getScene=function(){return this._scene},t.prototype.needAlphaBlending=function(){return this.alpha<1},t.prototype.needAlphaTesting=function(){return!1},t.prototype.getAlphaTestTexture=function(){return null},t.prototype.markDirty=function(){this._wasPreviouslyReady=!1},t.prototype._preBind=function(e){var r=this._scene.getEngine(),i=this.sideOrientation===t.ClockWiseSideOrientation;r.enableEffect(e||this._effect),r.setState(this.backFaceCulling,this.zOffset,!1,i)},t.prototype.bind=function(e,t){},t.prototype.bindForSubMesh=function(e,t,r){},t.prototype.bindOnlyWorldMatrix=function(e){},t.prototype.bindSceneUniformBuffer=function(e,t){t.bindToEffect(e,"Scene")},t.prototype.bindView=function(e){this._useUBO?this.bindSceneUniformBuffer(e,this.getScene().getSceneUniformBuffer()):e.setMatrix("view",this.getScene().getViewMatrix())},t.prototype.bindViewProjection=function(e){this._useUBO?this.bindSceneUniformBuffer(e,this.getScene().getSceneUniformBuffer()):e.setMatrix("viewProjection",this.getScene().getTransformMatrix())},t.prototype._afterBind=function(e){if(this._scene._cachedMaterial=this,this.onBindObservable.notifyObservers(e),this.disableDepthWrite){var t=this._scene.getEngine();this._cachedDepthWriteState=t.getDepthWrite(),t.setDepthWrite(!1)}},t.prototype.unbind=function(){if(this.onUnBindObservable.notifyObservers(this),this.disableDepthWrite){this._scene.getEngine().setDepthWrite(this._cachedDepthWriteState)}},t.prototype.getActiveTextures=function(){return[]},t.prototype.hasTexture=function(e){return!1},t.prototype.clone=function(e){return null},t.prototype.getBindedMeshes=function(){for(var e=new Array,t=0;t=0&&this._scene.materials.splice(r,1),r=0;ra?a:Math.floor(u);var l,c,h,f,d=0===r.sideOrientation?0:r.sideOrientation||e.Mesh.DEFAULTSIDE,p=r.uvs,g=r.colors,_=[],m=[],v=[],y=[],A=[],E=[],T=[],b=[],x=[],M=[];if(i.length<2){var P=[],R=[];for(h=0;h0&&(L=C[f].subtract(C[f-1]).length(),D=L+T[c],A[c].push(D),T[c]=D),f++;o&&(f--,_.push(C[0].x,C[0].y,C[0].z),L=C[f].subtract(C[0]).length(),D=L+T[c],A[c].push(D),T[c]=D),x[c]=S+I,M[c]=O,O+=S+I}var B,N,F,w;for(h=0;h1?1:r.arc||1,u=r.slice<=0?1:r.slice||1,l=0===r.sideOrientation?0:r.sideOrientation||e.Mesh.DEFAULTSIDE,c=new e.Vector3(n/2,o/2,s/2),h=2+i,f=2*h,d=[],p=[],g=[],_=[],m=0;m<=h;m++){for(var v=m/h,y=v*Math.PI*u,A=0;A<=f;A++){var E=A/f,T=E*Math.PI*2*a,b=e.Matrix.RotationZ(-y),x=e.Matrix.RotationY(T),M=e.Vector3.TransformCoordinates(e.Vector3.Up(),b),P=e.Vector3.TransformCoordinates(M,x),R=P.multiply(c),C=P.divide(c).normalize();p.push(R.x,R.y,R.z),g.push(C.x,C.y,C.z),_.push(E,v)}if(m>0)for(var S=p.length/3,O=S-2*(f+1);O+f+21?1:r.arc||1,f=0===r.sideOrientation?0:r.sideOrientation||e.Mesh.DEFAULTSIDE,d=r.faceUV||new Array(3),p=r.faceColors,g=1!==h&&c?2:0,_=l?u:1,m=2+(1+g)*_;for(i=0;i0&&(r.push(o-1),r.push(o)),o++;var l=new t;return l.indices=r,l.positions=i,l},t.CreateDashedLines=function(r){var i=r.dashSize||3,n=r.gapSize||1,o=r.dashNb||200,s=r.points,a=new Array,u=new Array,l=e.Vector3.Zero(),c=0,h=0,f=0,d=0,p=0,g=0,_=0;for(_=0;_1?1:r.arc||1,c=0===r.sideOrientation?0:r.sideOrientation||e.Mesh.DEFAULTSIDE;i.push(0,0,0),s.push(.5,.5);for(var h=2*Math.PI*l,f=h/u,d=0;d=i.length?0:r.type||0,h=r.size,f=r.sizeX||h||1,d=r.sizeY||h||1,p=r.sizeZ||h||1,g=r.custom||i[c],_=g.face.length,m=r.faceUV||new Array(_),v=r.faceColors,y=void 0===r.flat||r.flat,A=0===r.sideOrientation?0:r.sideOrientation||e.Mesh.DEFAULTSIDE,E=[],T=[],b=[],x=[],M=[],P=0,R=0,C=[],S=0,O=0;if(y)for(O=0;O<_;O++)v&&void 0===v[O]&&(v[O]=new e.Color4(1,1,1,1)),m&&void 0===m[O]&&(m[O]=new e.Vector4(0,0,1,1));if(y)for(O=0;O<_;O++){var I=g.face[O].length;for(s=2*Math.PI/I,a=.5*Math.tan(s/2),u=.5,S=0;Si.bbSize.y?i.bbSize.x:i.bbSize.y;Y=Y>i.bbSize.z?Y:i.bbSize.z;var W=i.subDiv.X*i.ratio/i.bbSize.x,X=i.subDiv.Y*i.ratio/i.bbSize.y,K=i.subDiv.Z*i.ratio/i.bbSize.z,j=i.subDiv.max*i.subDiv.max;i.facetPartitioning.length=0}for(n=0;n0&&(this._indexBuffer=this._engine.createIndexBuffer(this._indices)),this._indexBuffer&&(this._indexBuffer.references=r)},t.prototype.notifyUpdate=function(e){this.onGeometryUpdated&&this.onGeometryUpdated(this,e);for(var t=0,r=this._meshes;t0){for(var r=0;r0){for(var r=0;r0){for(var r=0;r0){var u=new Float32Array(r,a.positionsAttrDesc.offset,a.positionsAttrDesc.count);i.setVerticesData(e.VertexBuffer.PositionKind,u,!1)}if(a.normalsAttrDesc&&a.normalsAttrDesc.count>0){var l=new Float32Array(r,a.normalsAttrDesc.offset,a.normalsAttrDesc.count);i.setVerticesData(e.VertexBuffer.NormalKind,l,!1)}if(a.uvsAttrDesc&&a.uvsAttrDesc.count>0){var c=new Float32Array(r,a.uvsAttrDesc.offset,a.uvsAttrDesc.count);i.setVerticesData(e.VertexBuffer.UVKind,c,!1)}if(a.uvs2AttrDesc&&a.uvs2AttrDesc.count>0){var h=new Float32Array(r,a.uvs2AttrDesc.offset,a.uvs2AttrDesc.count);i.setVerticesData(e.VertexBuffer.UV2Kind,h,!1)}if(a.uvs3AttrDesc&&a.uvs3AttrDesc.count>0){var f=new Float32Array(r,a.uvs3AttrDesc.offset,a.uvs3AttrDesc.count);i.setVerticesData(e.VertexBuffer.UV3Kind,f,!1)}if(a.uvs4AttrDesc&&a.uvs4AttrDesc.count>0){var d=new Float32Array(r,a.uvs4AttrDesc.offset,a.uvs4AttrDesc.count);i.setVerticesData(e.VertexBuffer.UV4Kind,d,!1)}if(a.uvs5AttrDesc&&a.uvs5AttrDesc.count>0){var p=new Float32Array(r,a.uvs5AttrDesc.offset,a.uvs5AttrDesc.count);i.setVerticesData(e.VertexBuffer.UV5Kind,p,!1)}if(a.uvs6AttrDesc&&a.uvs6AttrDesc.count>0){var g=new Float32Array(r,a.uvs6AttrDesc.offset,a.uvs6AttrDesc.count);i.setVerticesData(e.VertexBuffer.UV6Kind,g,!1)}if(a.colorsAttrDesc&&a.colorsAttrDesc.count>0){var _=new Float32Array(r,a.colorsAttrDesc.offset,a.colorsAttrDesc.count);i.setVerticesData(e.VertexBuffer.ColorKind,_,!1,a.colorsAttrDesc.stride)}if(a.matricesIndicesAttrDesc&&a.matricesIndicesAttrDesc.count>0){var m=new Int32Array(r,a.matricesIndicesAttrDesc.offset,a.matricesIndicesAttrDesc.count);i.setVerticesData(e.VertexBuffer.MatricesIndicesKind,m,!1)}if(a.matricesWeightsAttrDesc&&a.matricesWeightsAttrDesc.count>0){var v=new Float32Array(r,a.matricesWeightsAttrDesc.offset,a.matricesWeightsAttrDesc.count);i.setVerticesData(e.VertexBuffer.MatricesWeightsKind,v,!1)}if(a.indicesAttrDesc&&a.indicesAttrDesc.count>0){var y=new Int32Array(r,a.indicesAttrDesc.offset,a.indicesAttrDesc.count);i.setIndices(y)}if(a.subMeshesAttrDesc&&a.subMeshesAttrDesc.count>0){var A=new Int32Array(r,a.subMeshesAttrDesc.offset,5*a.subMeshesAttrDesc.count);i.subMeshes=[];for(var E=0;E>8),R.push((16711680&C)>>16),R.push(C>>24)}i.setVerticesData(e.VertexBuffer.MatricesIndicesKind,R,r.matricesIndices._updatable)}if(r.matricesIndicesExtra)if(r.matricesIndicesExtra._isExpanded)delete r.matricesIndices._isExpanded,i.setVerticesData(e.VertexBuffer.MatricesIndicesExtraKind,r.matricesIndicesExtra,r.matricesIndicesExtra._updatable);else{for(var R=[],E=0;E>8),R.push((16711680&C)>>16),R.push(C>>24)}i.setVerticesData(e.VertexBuffer.MatricesIndicesExtraKind,R,r.matricesIndicesExtra._updatable)}r.matricesWeights&&(t._CleanMatricesWeights(r.matricesWeights,r.numBoneInfluencers),i.setVerticesData(e.VertexBuffer.MatricesWeightsKind,r.matricesWeights,r.matricesWeights._updatable)),r.matricesWeightsExtra&&(t._CleanMatricesWeights(r.matricesWeightsExtra,r.numBoneInfluencers),i.setVerticesData(e.VertexBuffer.MatricesWeightsExtraKind,r.matricesWeightsExtra,r.matricesWeights._updatable)),i.setIndices(r.indices)}if(r.subMeshes){i.subMeshes=[];for(var S=0;Sa&&(a=t[n+u],s=n+u);t[s]+=Math.max(0,1-o)}},t.Parse=function(r,i,n){if(i.getGeometryByID(r.id))return null;var o=new t(r.id,i,null,r.updatable);return e.Tags&&e.Tags.AddTagsTo(o,r.tags),r.delayLoadingFile?(o.delayLoadState=e.Engine.DELAYLOADSTATE_NOTLOADED,o.delayLoadingFile=n+r.delayLoadingFile,o._boundingInfo=new e.BoundingInfo(e.Vector3.FromArray(r.boundingBoxMinimum),e.Vector3.FromArray(r.boundingBoxMaximum)),o._delayInfo=[],r.hasUVs&&o._delayInfo.push(e.VertexBuffer.UVKind),r.hasUVs2&&o._delayInfo.push(e.VertexBuffer.UV2Kind),r.hasUVs3&&o._delayInfo.push(e.VertexBuffer.UV3Kind),r.hasUVs4&&o._delayInfo.push(e.VertexBuffer.UV4Kind),r.hasUVs5&&o._delayInfo.push(e.VertexBuffer.UV5Kind),r.hasUVs6&&o._delayInfo.push(e.VertexBuffer.UV6Kind),r.hasColors&&o._delayInfo.push(e.VertexBuffer.ColorKind),r.hasMatricesIndices&&o._delayInfo.push(e.VertexBuffer.MatricesIndicesKind),r.hasMatricesWeights&&o._delayInfo.push(e.VertexBuffer.MatricesWeightsKind),o._delayLoadingFunction=e.VertexData.ImportVertexData):e.VertexData.ImportVertexData(r,o),i.pushGeometry(o,!0),o},t})();e.Geometry=t,(function(t){!(function(r){var i=(function(e){function t(t,r,i,n){var o=e.call(this,t,r,null,!1,n)||this;return o._canBeRegenerated=i,o._beingRegenerated=!0,o.regenerate(),o._beingRegenerated=!1,o}return __extends(t,e),t.prototype.canBeRegenerated=function(){return this._canBeRegenerated},t.prototype.regenerate=function(){this._canBeRegenerated&&(this._beingRegenerated=!0,this.setAllVerticesData(this._regenerateVertexData(),!1),this._beingRegenerated=!1)},t.prototype.asNewGeometry=function(t){return e.prototype.copy.call(this,t)},t.prototype.setAllVerticesData=function(t,r){this._beingRegenerated&&e.prototype.setAllVerticesData.call(this,t,!1)},t.prototype.setVerticesData=function(t,r,i){this._beingRegenerated&&e.prototype.setVerticesData.call(this,t,r,!1)},t.prototype._regenerateVertexData=function(){throw new Error("Abstract method")},t.prototype.copy=function(e){throw new Error("Must be overriden in sub-classes.")},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.canBeRegenerated=this.canBeRegenerated(),t},t})(t);r._Primitive=i;var n=(function(t){function r(r,i,n,o,s,a,u,l,c){void 0===c&&(c=e.Mesh.DEFAULTSIDE);var h=t.call(this,r,i,u,l)||this;return h.pathArray=n,h.closeArray=o,h.closePath=s,h.offset=a,h.side=c,h}return __extends(r,t),r.prototype._regenerateVertexData=function(){return e.VertexData.CreateRibbon({pathArray:this.pathArray,closeArray:this.closeArray,closePath:this.closePath,offset:this.offset,sideOrientation:this.side})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.pathArray,this.closeArray,this.closePath,this.offset,this.canBeRegenerated(),null,this.side)},r})(i);r.Ribbon=n;var o=(function(r){function i(t,i,n,o,s,a){void 0===a&&(a=e.Mesh.DEFAULTSIDE);var u=r.call(this,t,i,o,s)||this;return u.size=n,u.side=a,u}return __extends(i,r),i.prototype._regenerateVertexData=function(){return e.VertexData.CreateBox({size:this.size,sideOrientation:this.side})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.size,this.canBeRegenerated(),null,this.side)},i.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.size=this.size,e},i.Parse=function(r,i){if(i.getGeometryByID(r.id))return null;var n=new t.Primitives.Box(r.id,i,r.size,r.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,r.tags),i.pushGeometry(n,!0),n},i})(i);r.Box=o;var s=(function(r){function i(t,i,n,o,s,a,u){void 0===u&&(u=e.Mesh.DEFAULTSIDE);var l=r.call(this,t,i,s,a)||this;return l.segments=n,l.diameter=o,l.side=u,l}return __extends(i,r),i.prototype._regenerateVertexData=function(){return e.VertexData.CreateSphere({segments:this.segments,diameter:this.diameter,sideOrientation:this.side})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.segments,this.diameter,this.canBeRegenerated(),null,this.side)},i.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.segments=this.segments,e.diameter=this.diameter,e},i.Parse=function(r,i){if(i.getGeometryByID(r.id))return null;var n=new t.Primitives.Sphere(r.id,i,r.segments,r.diameter,r.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,r.tags),i.pushGeometry(n,!0),n},i})(i);r.Sphere=s;var a=(function(t){function r(r,i,n,o,s,a,u){void 0===u&&(u=e.Mesh.DEFAULTSIDE);var l=t.call(this,r,i,s,a)||this;return l.radius=n,l.tessellation=o,l.side=u,l}return __extends(r,t),r.prototype._regenerateVertexData=function(){return e.VertexData.CreateDisc({radius:this.radius,tessellation:this.tessellation,sideOrientation:this.side})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.radius,this.tessellation,this.canBeRegenerated(),null,this.side)},r})(i);r.Disc=a;var u=(function(r){function i(t,i,n,o,s,a,u,l,c,h){void 0===u&&(u=1),void 0===h&&(h=e.Mesh.DEFAULTSIDE);var f=r.call(this,t,i,l,c)||this;return f.height=n,f.diameterTop=o,f.diameterBottom=s,f.tessellation=a,f.subdivisions=u,f.side=h,f}return __extends(i,r),i.prototype._regenerateVertexData=function(){return e.VertexData.CreateCylinder({height:this.height,diameterTop:this.diameterTop,diameterBottom:this.diameterBottom,tessellation:this.tessellation,subdivisions:this.subdivisions,sideOrientation:this.side})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.height,this.diameterTop,this.diameterBottom,this.tessellation,this.subdivisions,this.canBeRegenerated(),null,this.side)},i.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.height=this.height,e.diameterTop=this.diameterTop,e.diameterBottom=this.diameterBottom,e.tessellation=this.tessellation,e},i.Parse=function(r,i){if(i.getGeometryByID(r.id))return null;var n=new t.Primitives.Cylinder(r.id,i,r.height,r.diameterTop,r.diameterBottom,r.tessellation,r.subdivisions,r.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,r.tags),i.pushGeometry(n,!0),n},i})(i);r.Cylinder=u;var l=(function(r){function i(t,i,n,o,s,a,u,l){void 0===l&&(l=e.Mesh.DEFAULTSIDE);var c=r.call(this,t,i,a,u)||this;return c.diameter=n,c.thickness=o,c.tessellation=s,c.side=l,c}return __extends(i,r),i.prototype._regenerateVertexData=function(){return e.VertexData.CreateTorus({diameter:this.diameter,thickness:this.thickness,tessellation:this.tessellation,sideOrientation:this.side})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.diameter,this.thickness,this.tessellation,this.canBeRegenerated(),null,this.side)},i.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.diameter=this.diameter,e.thickness=this.thickness,e.tessellation=this.tessellation,e},i.Parse=function(r,i){if(i.getGeometryByID(r.id))return null;var n=new t.Primitives.Torus(r.id,i,r.diameter,r.thickness,r.tessellation,r.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,r.tags),i.pushGeometry(n,!0),n},i})(i);r.Torus=l;var c=(function(r){function i(e,t,i,n,o,s,a){var u=r.call(this,e,t,s,a)||this;return u.width=i,u.height=n,u.subdivisions=o,u}return __extends(i,r),i.prototype._regenerateVertexData=function(){return e.VertexData.CreateGround({width:this.width,height:this.height,subdivisions:this.subdivisions})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.width,this.height,this.subdivisions,this.canBeRegenerated(),null)},i.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.width=this.width,e.height=this.height,e.subdivisions=this.subdivisions,e},i.Parse=function(r,i){if(i.getGeometryByID(r.id))return null;var n=new t.Primitives.Ground(r.id,i,r.width,r.height,r.subdivisions,r.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,r.tags),i.pushGeometry(n,!0),n},i})(i);r.Ground=c;var h=(function(t){function r(e,r,i,n,o,s,a,u,l,c){var h=t.call(this,e,r,l,c)||this;return h.xmin=i,h.zmin=n,h.xmax=o,h.zmax=s,h.subdivisions=a,h.precision=u,h}return __extends(r,t),r.prototype._regenerateVertexData=function(){return e.VertexData.CreateTiledGround({xmin:this.xmin,zmin:this.zmin,xmax:this.xmax,zmax:this.zmax,subdivisions:this.subdivisions,precision:this.precision})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.xmin,this.zmin,this.xmax,this.zmax,this.subdivisions,this.precision,this.canBeRegenerated(),null)},r})(i);r.TiledGround=h;var f=(function(r){function i(t,i,n,o,s,a){void 0===a&&(a=e.Mesh.DEFAULTSIDE);var u=r.call(this,t,i,o,s)||this;return u.size=n,u.side=a,u}return __extends(i,r),i.prototype._regenerateVertexData=function(){return e.VertexData.CreatePlane({size:this.size,sideOrientation:this.side})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.size,this.canBeRegenerated(),null,this.side)},i.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.size=this.size,e},i.Parse=function(r,i){if(i.getGeometryByID(r.id))return null;var n=new t.Primitives.Plane(r.id,i,r.size,r.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,r.tags),i.pushGeometry(n,!0),n},i})(i);r.Plane=f;var d=(function(r){function i(t,i,n,o,s,a,u,l,c,h,f){void 0===f&&(f=e.Mesh.DEFAULTSIDE);var d=r.call(this,t,i,c,h)||this;return d.radius=n,d.tube=o,d.radialSegments=s,d.tubularSegments=a,d.p=u,d.q=l,d.side=f,d}return __extends(i,r),i.prototype._regenerateVertexData=function(){return e.VertexData.CreateTorusKnot({radius:this.radius,tube:this.tube,radialSegments:this.radialSegments,tubularSegments:this.tubularSegments,p:this.p,q:this.q,sideOrientation:this.side})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.radius,this.tube,this.radialSegments,this.tubularSegments,this.p,this.q,this.canBeRegenerated(),null,this.side)},i.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.radius=this.radius,e.tube=this.tube,e.radialSegments=this.radialSegments,e.tubularSegments=this.tubularSegments,e.p=this.p,e.q=this.q,e},i.Parse=function(r,i){if(i.getGeometryByID(r.id))return null;var n=new t.Primitives.TorusKnot(r.id,i,r.radius,r.tube,r.radialSegments,r.tubularSegments,r.p,r.q,r.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,r.tags),i.pushGeometry(n,!0),n},i})(i);r.TorusKnot=d})(t.Primitives||(t.Primitives={}))})(t=e.Geometry||(e.Geometry={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e){this._vertexBuffers={},this._scene=e}return t.prototype._prepareBuffers=function(){if(!this._vertexBuffers[e.VertexBuffer.PositionKind]){var t=[];t.push(1,1),t.push(-1,1),t.push(-1,-1),t.push(1,-1),this._vertexBuffers[e.VertexBuffer.PositionKind]=new e.VertexBuffer(this._scene.getEngine(),t,e.VertexBuffer.PositionKind,!1,!1,2);var r=[];r.push(0),r.push(1),r.push(2),r.push(0),r.push(2),r.push(3),this._indexBuffer=this._scene.getEngine().createIndexBuffer(r)}},t.prototype._prepareFrame=function(e,t){var t=t||this._scene.activeCamera._postProcesses;return!(0===t.length||!this._scene.postProcessesEnabled)&&(t[0].activate(this._scene.activeCamera,e,null!==t&&void 0!==t),!0)},t.prototype.directRender=function(e,t){for(var r=this._scene.getEngine(),i=0;i=this._sampleCount||e>=this._samples.length)return null;var t=this._wrapPosition(this._pos-1);return this._samples[this._wrapPosition(t-e)]},e.prototype.isSaturated=function(){return this._sampleCount>=this._samples.length},e.prototype.reset=function(){this.average=0,this.variance=0,this._sampleCount=0,this._pos=0,this._m2=0},e.prototype._wrapPosition=function(e){var t=this._samples.length;return(e%t+t)%t},e})();e.RollingAverage=r})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(e,t,r){this.name=e,this.from=t,this.to=r}return e.prototype.clone=function(){return new e(this.name,this.from,this.to)},e})();e.AnimationRange=t;var r=(function(){function e(e,t,r){this.frame=e,this.action=t,this.onlyOnce=r,this.isDone=!1}return e})();e.AnimationEvent=r;var i=(function(){function t(e){this.path=e,this._onchange=new Array,this.value=0,this.animations=new Array}return t.prototype.getPoint=function(){var t=this.path.getPointAtLengthPosition(this.value);return new e.Vector3(t.x,0,t.y)},t.prototype.moveAhead=function(e){return void 0===e&&(e=.002),this.move(e),this},t.prototype.moveBack=function(e){return void 0===e&&(e=.002),this.move(-e),this},t.prototype.move=function(e){if(Math.abs(e)>1)throw"step size should be less than 1.";return this.value+=e,this.ensureLimits(),this.raiseOnChange(),this},t.prototype.ensureLimits=function(){for(;this.value>1;)this.value-=1;for(;this.value<0;)this.value+=1;return this},t.prototype.markAsDirty=function(e){return this.ensureLimits(),this.raiseOnChange(),this},t.prototype.raiseOnChange=function(){var e=this;return this._onchange.forEach((function(t){return t(e)})),this},t.prototype.onchange=function(e){return this._onchange.push(e),this},t})();e.PathCursor=i;var n=(function(){function r(e,t,i,n,o,s){this.name=e,this.targetProperty=t,this.framePerSecond=i,this.dataType=n,this.loopMode=o,this.enableBlending=s,this._offsetsCache={},this._highLimitsCache={},this._stopped=!1,this._blendingFactor=0,this._events=new Array,this.allowMatricesInterpolation=!1,this.blendingSpeed=.01,this._ranges={},this.targetPropertyPath=t.split("."),this.dataType=n,this.loopMode=void 0===o?r.ANIMATIONLOOPMODE_CYCLE:o}return r._PrepareAnimation=function(t,i,n,o,s,a,u,l){var c=void 0;if(!isNaN(parseFloat(s))&&isFinite(s)?c=r.ANIMATIONTYPE_FLOAT:s instanceof e.Quaternion?c=r.ANIMATIONTYPE_QUATERNION:s instanceof e.Vector3?c=r.ANIMATIONTYPE_VECTOR3:s instanceof e.Vector2?c=r.ANIMATIONTYPE_VECTOR2:s instanceof e.Color3?c=r.ANIMATIONTYPE_COLOR3:s instanceof e.Size&&(c=r.ANIMATIONTYPE_SIZE),void 0==c)return null;var h=new r(t,i,n,c,u),f=[{frame:0,value:s},{frame:o,value:a}];return h.setKeys(f),void 0!==l&&h.setEasingFunction(l),h},r.CreateAndStartAnimation=function(e,t,i,n,o,s,a,u,l,c){var h=r._PrepareAnimation(e,i,n,o,s,a,u,l);return t.getScene().beginDirectAnimation(t,[h],0,o,1===h.loopMode,1,c)},r.CreateMergeAndStartAnimation=function(e,t,i,n,o,s,a,u,l,c){var h=r._PrepareAnimation(e,i,n,o,s,a,u,l);return t.animations.push(h),t.getScene().beginAnimation(t,0,o,1===h.loopMode,1,c)},r.prototype.toString=function(e){var t="Name: "+this.name+", property: "+this.targetProperty;if(t+=", datatype: "+["Float","Vector3","Quaternion","Matrix","Color3","Vector2"][this.dataType],t+=", nKeys: "+(this._keys?this._keys.length:"none"),t+=", nRanges: "+(this._ranges?Object.keys(this._ranges).length:"none"),e){t+=", Ranges: {";var r=!0;for(var i in this._ranges)r&&(t+=", ",r=!1),t+=i;t+="}"}return t},r.prototype.addEvent=function(e){this._events.push(e)},r.prototype.removeEvents=function(e){for(var t=0;t=0;n--)this._keys[n].frame>=r&&this._keys[n].frame<=i&&this._keys.splice(n,1);this._ranges[e]=void 0}},r.prototype.getRange=function(e){return this._ranges[e]},r.prototype.reset=function(){this._offsetsCache={},this._highLimitsCache={},this.currentFrame=0,this._blendingFactor=0,this._originalBlendValue=null},r.prototype.isStopped=function(){return this._stopped},r.prototype.getKeys=function(){return this._keys},r.prototype.getHighestFrame=function(){for(var e=0,t=0,r=this._keys.length;t0)return o.clone?o.clone():o;this.currentFrame=e;var s=Math.max(0,Math.min(this._keys.length-1,Math.floor(this._keys.length*(e-this._keys[0].frame)/(this._keys[this._keys.length-1].frame-this._keys[0].frame))-1));if(this._keys[s].frame>=e)for(;s-1>=0&&this._keys[s].frame>=e;)s--;for(var a=s;a=e){var l=this._keys[a],c=this._getKeyValue(l.value),h=this._getKeyValue(u.value),f=void 0!==l.outTangent&&void 0!==u.inTangent,d=u.frame-l.frame,p=(e-l.frame)/d;switch(null!=this._easingFunction&&(p=this._easingFunction.ease(p)),this.dataType){case r.ANIMATIONTYPE_FLOAT:var g=f?this.floatInterpolateFunctionWithTangents(c,l.outTangent*d,h,u.inTangent*d,p):this.floatInterpolateFunction(c,h,p);switch(i){case r.ANIMATIONLOOPMODE_CYCLE:case r.ANIMATIONLOOPMODE_CONSTANT:return g;case r.ANIMATIONLOOPMODE_RELATIVE:return n*t+g}break;case r.ANIMATIONTYPE_QUATERNION:var _=f?this.quaternionInterpolateFunctionWithTangents(c,l.outTangent.scale(d),h,u.inTangent.scale(d),p):this.quaternionInterpolateFunction(c,h,p);switch(i){case r.ANIMATIONLOOPMODE_CYCLE:case r.ANIMATIONLOOPMODE_CONSTANT:return _;case r.ANIMATIONLOOPMODE_RELATIVE:return _.add(n.scale(t))}return _;case r.ANIMATIONTYPE_VECTOR3:var m=f?this.vector3InterpolateFunctionWithTangents(c,l.outTangent.scale(d),h,u.inTangent.scale(d),p):this.vector3InterpolateFunction(c,h,p);switch(i){case r.ANIMATIONLOOPMODE_CYCLE:case r.ANIMATIONLOOPMODE_CONSTANT:return m;case r.ANIMATIONLOOPMODE_RELATIVE:return m.add(n.scale(t))}case r.ANIMATIONTYPE_VECTOR2:var v=f?this.vector2InterpolateFunctionWithTangents(c,l.outTangent.scale(d),h,u.inTangent.scale(d),p):this.vector2InterpolateFunction(c,h,p);switch(i){case r.ANIMATIONLOOPMODE_CYCLE:case r.ANIMATIONLOOPMODE_CONSTANT:return v;case r.ANIMATIONLOOPMODE_RELATIVE:return v.add(n.scale(t))}case r.ANIMATIONTYPE_SIZE:switch(i){case r.ANIMATIONLOOPMODE_CYCLE:case r.ANIMATIONLOOPMODE_CONSTANT:return this.sizeInterpolateFunction(c,h,p);case r.ANIMATIONLOOPMODE_RELATIVE:return this.sizeInterpolateFunction(c,h,p).add(n.scale(t))}case r.ANIMATIONTYPE_COLOR3:switch(i){case r.ANIMATIONLOOPMODE_CYCLE:case r.ANIMATIONLOOPMODE_CONSTANT:return this.color3InterpolateFunction(c,h,p);case r.ANIMATIONLOOPMODE_RELATIVE:return this.color3InterpolateFunction(c,h,p).add(n.scale(t))}case r.ANIMATIONTYPE_MATRIX:switch(i){case r.ANIMATIONLOOPMODE_CYCLE:case r.ANIMATIONLOOPMODE_CONSTANT:if(this.allowMatricesInterpolation)return this.matrixInterpolateFunction(c,h,p);case r.ANIMATIONLOOPMODE_RELATIVE:return c}}break}}return this._getKeyValue(this._keys[this._keys.length-1].value)},r.prototype.setValue=function(t,r){void 0===r&&(r=!1);var i,n;if(this.targetPropertyPath.length>1){for(var o=this._target[this.targetPropertyPath[0]],s=1;sthis._keys[this._keys.length-1].frame&&(e=this._keys[this._keys.length-1].frame);var t=this._interpolate(e,0,this.loopMode);this.setValue(t)},r.prototype.animate=function(t,i,n,o,s,a){if(void 0===a&&(a=!1),!this.targetPropertyPath||this.targetPropertyPath.length<1)return this._stopped=!0,!1;var u=!0;if(0!==this._keys[0].frame){var l={frame:0,value:this._keys[0].value};this._keys.splice(0,0,l)}(ithis._keys[this._keys.length-1].frame)&&(i=this._keys[0].frame),(nthis._keys[this._keys.length-1].frame)&&(n=this._keys[this._keys.length-1].frame),i===n&&i++;var c,h=n-i,f=t*(this.framePerSecond*s)/1e3,d=0;if((n>i&&f>h||i>n&&f>0,v=u?i+f%h:n,y=this._interpolate(v,m,this.loopMode,c,d);this.setValue(y);for(var A=0;A0&&v>=this._events[A].frame&&this._events[A].frame>=i||h<0&&v<=this._events[A].frame&&this._events[A].frame<=i){var E=this._events[A];E.isDone||(E.onlyOnce&&(this._events.splice(A,1),A--),E.isDone=!0,E.action())}else this._events[A].isDone&&!this._events[A].onlyOnce&&(this._events[A].isDone=!1);return u||(this._stopped=!0),u},r.prototype.serialize=function(){var e={};e.name=this.name,e.property=this.targetProperty,e.framePerSecond=this.framePerSecond,e.dataType=this.dataType,e.loopBehavior=this.loopMode,e.enableBlending=this.enableBlending,e.blendingSpeed=this.blendingSpeed;var t=this.dataType;e.keys=[];for(var i=this.getKeys(),n=0;n-1){for(var r=this._animations,i=r.length-1;i>=0;i--)"string"==typeof e&&r[i].name!=e||(r[i].reset(),r.splice(i,1));0==r.length&&(this._scene._activeAnimatables.splice(t,1),this.onAnimationEnd&&this.onAnimationEnd())}}else{var i=this._scene._activeAnimatables.indexOf(this);if(i>-1){this._scene._activeAnimatables.splice(i,1);for(var r=this._animations,i=0;i=.5?.5*(1-this.easeInCore(2*(1-t)))+.5:.5*this.easeInCore(2*t)},e})();t._EASINGMODE_EASEIN=0,t._EASINGMODE_EASEOUT=1,t._EASINGMODE_EASEINOUT=2,e.EasingFunction=t;var r=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.easeInCore=function(e){return e=Math.max(0,Math.min(1,e)),1-Math.sqrt(1-e*e)},t})(t);e.CircleEase=r;var i=(function(e){function t(t){void 0===t&&(t=1);var r=e.call(this)||this;return r.amplitude=t,r}return __extends(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.amplitude);return Math.pow(e,3)-e*t*Math.sin(3.141592653589793*e)},t})(t);e.BackEase=i;var n=(function(e){function t(t,r){void 0===t&&(t=3),void 0===r&&(r=2);var i=e.call(this)||this;return i.bounces=t,i.bounciness=r,i}return __extends(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.bounces),r=this.bounciness;r<=1&&(r=1.001);var i=Math.pow(r,t),n=1-r,o=(1-i)/n+.5*i,s=e*o,a=Math.log(-s*(1-r)+1)/Math.log(r),u=Math.floor(a),l=u+1,c=(1-Math.pow(r,u))/(n*o),h=(1-Math.pow(r,l))/(n*o),f=.5*(c+h),d=e-f,p=f-c;return-Math.pow(1/r,t-u)/(p*p)*(d-p)*(d+p)},t})(t);e.BounceEase=n;var o=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.easeInCore=function(e){return e*e*e},t})(t);e.CubicEase=o;var s=(function(e){function t(t,r){void 0===t&&(t=3),void 0===r&&(r=3);var i=e.call(this)||this;return i.oscillations=t,i.springiness=r,i}return __extends(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.oscillations),r=Math.max(0,this.springiness);return(0==r?e:(Math.exp(r*e)-1)/(Math.exp(r)-1))*Math.sin((6.283185307179586*t+1.5707963267948966)*e)},t})(t);e.ElasticEase=s;var a=(function(e){function t(t){void 0===t&&(t=2);var r=e.call(this)||this;return r.exponent=t,r}return __extends(t,e),t.prototype.easeInCore=function(e){return this.exponent<=0?e:(Math.exp(this.exponent*e)-1)/(Math.exp(this.exponent)-1)},t})(t);e.ExponentialEase=a;var u=(function(e){function t(t){void 0===t&&(t=2);var r=e.call(this)||this;return r.power=t,r}return __extends(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.power);return Math.pow(e,t)},t})(t);e.PowerEase=u;var l=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.easeInCore=function(e){return e*e},t})(t);e.QuadraticEase=l;var c=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.easeInCore=function(e){return e*e*e*e},t})(t);e.QuarticEase=c;var h=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.easeInCore=function(e){return e*e*e*e*e},t})(t);e.QuinticEase=h;var f=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.easeInCore=function(e){return 1-Math.sin(1.5707963267948966*(1-e))},t})(t);e.SineEase=f;var d=(function(t){function r(e,r,i,n){void 0===e&&(e=0),void 0===r&&(r=0),void 0===i&&(i=1),void 0===n&&(n=1);var o=t.call(this)||this;return o.x1=e,o.y1=r,o.x2=i,o.y2=n,o}return __extends(r,t),r.prototype.easeInCore=function(t){return e.BezierCurve.interpolate(t,this.x1,this.y1,this.x2,this.y2)},r})(t);e.BezierCurveEase=d})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){e.CameraInputTypes={};var t=(function(){function t(e){this.attached={},this.camera=e,this.checkInputs=function(){}}return t.prototype.add=function(t){var r=t.getSimpleName();if(this.attached[r])return void e.Tools.Warn("camera input of type "+r+" already exists on camera");this.attached[r]=t,t.camera=this.camera,t.checkInputs&&(this.checkInputs=this._addCheckInputs(t.checkInputs.bind(t))),this.attachedElement&&t.attachControl(this.attachedElement)},t.prototype.remove=function(e){for(var t in this.attached){var r=this.attached[t];r===e&&(r.detachControl(this.attachedElement),delete this.attached[t],this.rebuildInputCheck())}},t.prototype.removeByType=function(e){for(var t in this.attached){var r=this.attached[t];r.getClassName()===e&&(r.detachControl(this.attachedElement),delete this.attached[t],this.rebuildInputCheck())}},t.prototype._addCheckInputs=function(e){var t=this.checkInputs;return function(){t(),e()}},t.prototype.attachInput=function(e){e.attachControl(this.attachedElement,this.noPreventDefault)},t.prototype.attachElement=function(t,r){if(!this.attachedElement){r=!e.Camera.ForceAttachControlToAlwaysPreventDefault&&r,this.attachedElement=t,this.noPreventDefault=r;for(var i in this.attached){this.attached[i];this.attached[i].attachControl(t,r)}}},t.prototype.detachElement=function(e){if(this.attachedElement===e){for(var t in this.attached){this.attached[t];this.attached[t].detachControl(e)}this.attachedElement=null}},t.prototype.rebuildInputCheck=function(){this.checkInputs=function(){};for(var e in this.attached){var t=this.attached[e];t.checkInputs&&(this.checkInputs=this._addCheckInputs(t.checkInputs.bind(t)))}},t.prototype.clear=function(){this.attachedElement&&this.detachElement(this.attachedElement),this.attached={},this.attachedElement=null,this.checkInputs=function(){}},t.prototype.serialize=function(t){var r={};for(var i in this.attached){var n=this.attached[i],o=e.SerializationHelper.Serialize(n);r[n.getClassName()]=o}t.inputsmgr=r},t.prototype.parse=function(t){var r=t.inputsmgr;if(r){this.clear();for(var i in r){var n=e.CameraInputTypes[i];if(n){var o=r[i],s=e.SerializationHelper.Parse((function(){return new n}),o,null);this.add(s)}}}else for(var i in this.attached){var n=e.CameraInputTypes[this.attached[i].getClassName()];if(n){var s=e.SerializationHelper.Parse((function(){return new n}),t,null);this.remove(this.attached[i]),this.add(s)}}},t})();e.CameraInputsManager=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(r,i,n){var o=t.call(this,r,i,n)||this;return o.cameraDirection=new e.Vector3(0,0,0),o.cameraRotation=new e.Vector2(0,0),o.rotation=new e.Vector3(0,0,0),o.speed=2,o.noRotationConstraint=!1,o.lockedTarget=null,o._currentTarget=e.Vector3.Zero(),o._viewMatrix=e.Matrix.Zero(),o._camMatrix=e.Matrix.Zero(),o._cameraTransformMatrix=e.Matrix.Zero(),o._cameraRotationMatrix=e.Matrix.Zero(),o._referencePoint=new e.Vector3(0,0,1),o._defaultUpVector=new e.Vector3(0,1,0),o._transformedReferencePoint=e.Vector3.Zero(),o._lookAtTemp=e.Matrix.Zero(),o._tempMatrix=e.Matrix.Zero(),o}return __extends(r,t),r.prototype.getFrontPosition=function(e){var t=this.getTarget().subtract(this.position);return t.normalize(),t.scaleInPlace(e),this.globalPosition.add(t)},r.prototype._getLockedTargetPosition=function(){return this.lockedTarget?(this.lockedTarget.absolutePosition&&this.lockedTarget.computeWorldMatrix(),this.lockedTarget.absolutePosition||this.lockedTarget):null},r.prototype._initCache=function(){t.prototype._initCache.call(this),this._cache.lockedTarget=new e.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.rotation=new e.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.rotationQuaternion=new e.Quaternion(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)},r.prototype._updateCache=function(e){e||t.prototype._updateCache.call(this);var r=this._getLockedTargetPosition();r?this._cache.lockedTarget?this._cache.lockedTarget.copyFrom(r):this._cache.lockedTarget=r.clone():this._cache.lockedTarget=null,this._cache.rotation.copyFrom(this.rotation),this.rotationQuaternion&&this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion)},r.prototype._isSynchronizedViewMatrix=function(){if(!t.prototype._isSynchronizedViewMatrix.call(this))return!1;var e=this._getLockedTargetPosition();return(this._cache.lockedTarget?this._cache.lockedTarget.equals(e):!e)&&(this.rotationQuaternion?this.rotationQuaternion.equals(this._cache.rotationQuaternion):this._cache.rotation.equals(this.rotation))},r.prototype._computeLocalCameraSpeed=function(){var e=this.getEngine();return this.speed*Math.sqrt(e.getDeltaTime()/(100*e.getFps()))},r.prototype.setTarget=function(t){this.upVector.normalize(),e.Matrix.LookAtLHToRef(this.position,t,this._defaultUpVector,this._camMatrix),this._camMatrix.invert(),this.rotation.x=Math.atan(this._camMatrix.m[6]/this._camMatrix.m[10]);var r=t.subtract(this.position);r.x>=0?this.rotation.y=-Math.atan(r.z/r.x)+Math.PI/2:this.rotation.y=-Math.atan(r.z/r.x)-Math.PI/2,this.rotation.z=0,isNaN(this.rotation.x)&&(this.rotation.x=0),isNaN(this.rotation.y)&&(this.rotation.y=0),isNaN(this.rotation.z)&&(this.rotation.z=0),this.rotationQuaternion&&e.Quaternion.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this.rotationQuaternion)},r.prototype.getTarget=function(){return this._currentTarget},r.prototype._decideIfNeedsToMove=function(){return Math.abs(this.cameraDirection.x)>0||Math.abs(this.cameraDirection.y)>0||Math.abs(this.cameraDirection.z)>0},r.prototype._updatePosition=function(){if(this.parent)return this.parent.getWorldMatrix().invertToRef(e.Tmp.Matrix[0]),e.Vector3.TransformNormalToRef(this.cameraDirection,e.Tmp.Matrix[0],e.Tmp.Vector3[0]),void this.position.addInPlace(e.Tmp.Vector3[0]);this.position.addInPlace(this.cameraDirection)},r.prototype._checkInputs=function(){var r=this._decideIfNeedsToMove(),i=Math.abs(this.cameraRotation.x)>0||Math.abs(this.cameraRotation.y)>0;if(r&&this._updatePosition(),i){if(this.rotation.x+=this.cameraRotation.x,this.rotation.y+=this.cameraRotation.y,this.rotationQuaternion){this.rotation.lengthSquared()&&e.Quaternion.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this.rotationQuaternion)}if(!this.noRotationConstraint){var n=Math.PI/2*.95;this.rotation.x>n&&(this.rotation.x=n),this.rotation.x<-n&&(this.rotation.x=-n)}}r&&(Math.abs(this.cameraDirection.x)=0&&i._keys.splice(t,1),e.preventDefault&&(r||e.preventDefault())}},this._onLostFocus=function(){i._keys=[]},t.addEventListener("keydown",this._onKeyDown,!1),t.addEventListener("keyup",this._onKeyUp,!1),e.Tools.RegisterTopRootEvents([{name:"blur",handler:this._onLostFocus}])},t.prototype.detachControl=function(t){t&&(t.removeEventListener("keydown",this._onKeyDown),t.removeEventListener("keyup",this._onKeyUp)),e.Tools.UnregisterTopRootEvents([{name:"blur",handler:this._onLostFocus}]),this._keys=[],this._onKeyDown=null,this._onKeyUp=null,this._onLostFocus=null},t.prototype.checkInputs=function(){if(this._onKeyDown)for(var e=this.camera,t=0;tMath.PI&&(this.beta=this.beta-2*Math.PI):this.betathis.upperBetaLimit&&(this.beta=this.upperBetaLimit),this.lowerAlphaLimit&&this.alphathis.upperAlphaLimit&&(this.alpha=this.upperAlphaLimit),this.lowerRadiusLimit&&this.radiusthis.upperRadiusLimit&&(this.radius=this.upperRadiusLimit)},r.prototype.rebuildAnglesAndRadius=function(){var e=this.position.subtract(this._getTargetPosition());this.radius=e.length(),this.alpha=Math.acos(e.x/Math.sqrt(Math.pow(e.x,2)+Math.pow(e.z,2))),e.z<0&&(this.alpha=2*Math.PI-this.alpha),this.beta=Math.acos(e.y/this.radius),this._checkLimits()},r.prototype.setPosition=function(e){this.position.equals(e)||(this.position.copyFrom(e),this.rebuildAnglesAndRadius())},r.prototype.setTarget=function(e,t,r){if(void 0===t&&(t=!1),void 0===r&&(r=!1),e.getBoundingInfo)this._targetBoundingCenter=t?e.getBoundingInfo().boundingBox.centerWorld.clone():null,this._targetHost=e,this._target=this._getTargetPosition();else{var i=e,n=this._getTargetPosition();if(n&&!r&&n.equals(i))return;this._target=i,this._targetBoundingCenter=null}this.rebuildAnglesAndRadius()},r.prototype._getViewMatrix=function(){var t=Math.cos(this.alpha),r=Math.sin(this.alpha),i=Math.cos(this.beta),n=Math.sin(this.beta);0===n&&(n=1e-4);var o=this._getTargetPosition();if(o.addToRef(new e.Vector3(this.radius*t*n,this.radius*i,this.radius*r*n),this._newPosition),this.getScene().collisionsEnabled&&this.checkCollisions)this._collider||(this._collider=new e.Collider),this._collider.radius=this.collisionRadius,this._newPosition.subtractToRef(this.position,this._collisionVelocity),this._collisionTriggered=!0,this.getScene().collisionCoordinator.getNewPosition(this.position,this._collisionVelocity,this._collider,3,null,this._onCollisionPositionChange,this.uniqueId);else{this.position.copyFrom(this._newPosition);var s=this.upVector;this.allowUpsideDown&&n<0&&(s=s.clone(),s=s.negate()),this.getScene().useRightHandedSystem?e.Matrix.LookAtRHToRef(this.position,o,s,this._viewMatrix):e.Matrix.LookAtLHToRef(this.position,o,s,this._viewMatrix),this._viewMatrix.m[12]+=this.targetScreenOffset.x,this._viewMatrix.m[13]+=this.targetScreenOffset.y}return this._currentTarget=o,this._viewMatrix},r.prototype.zoomOn=function(t,r){void 0===r&&(r=!1),t=t||this.getScene().meshes;var i=e.Mesh.MinMax(t),n=e.Vector3.Distance(i.min,i.max);this.radius=n*this.zoomOnFactor,this.focusOn({min:i.min,max:i.max,distance:n},r)},r.prototype.focusOn=function(t,r){void 0===r&&(r=!1);var i,n;void 0===t.min?(i=t||this.getScene().meshes,i=e.Mesh.MinMax(i),n=e.Vector3.Distance(i.min,i.max)):(i=t,n=t.distance),this._target=e.Mesh.Center(i),r||(this.maxZ=2*n)},r.prototype.createRigCamera=function(t,i){var n;switch(this.cameraRigMode){case e.Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case e.Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER:case e.Camera.RIG_MODE_VR:n=this._cameraRigParams.stereoHalfAngle*(0===i?1:-1);break;case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:n=this._cameraRigParams.stereoHalfAngle*(0===i?-1:1)}var o=new r(t,this.alpha+n,this.beta,this.radius,this._target,this.getScene());return o._cameraRigParams={},o},r.prototype._updateRigCameras=function(){var r=this._rigCameras[0],i=this._rigCameras[1];switch(r.beta=i.beta=this.beta,r.radius=i.radius=this.radius,this.cameraRigMode){case e.Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case e.Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER:case e.Camera.RIG_MODE_VR:r.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle,i.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle;break;case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:r.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle,i.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle}t.prototype._updateRigCameras.call(this)},r.prototype.dispose=function(){this.inputs.clear(),t.prototype.dispose.call(this)},r.prototype.getClassName=function(){return"ArcRotateCamera"},r})(e.TargetCamera);__decorate([e.serialize()],t.prototype,"alpha",void 0),__decorate([e.serialize()],t.prototype,"beta",void 0),__decorate([e.serialize()],t.prototype,"radius",void 0),__decorate([e.serializeAsVector3("target")],t.prototype,"_target",void 0),__decorate([e.serialize()],t.prototype,"inertialAlphaOffset",void 0),__decorate([e.serialize()],t.prototype,"inertialBetaOffset",void 0),__decorate([e.serialize()],t.prototype,"inertialRadiusOffset",void 0),__decorate([e.serialize()],t.prototype,"lowerAlphaLimit",void 0),__decorate([e.serialize()],t.prototype,"upperAlphaLimit",void 0),__decorate([e.serialize()],t.prototype,"lowerBetaLimit",void 0),__decorate([e.serialize()],t.prototype,"upperBetaLimit",void 0),__decorate([e.serialize()],t.prototype,"lowerRadiusLimit",void 0),__decorate([e.serialize()],t.prototype,"upperRadiusLimit",void 0),__decorate([e.serialize()],t.prototype,"inertialPanningX",void 0),__decorate([e.serialize()],t.prototype,"inertialPanningY",void 0),__decorate([e.serialize()],t.prototype,"panningInertia",void 0),__decorate([e.serialize()],t.prototype,"zoomOnFactor",void 0),__decorate([e.serialize()],t.prototype,"allowUpsideDown",void 0),e.ArcRotateCamera=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(e){return t.call(this,e)||this}return __extends(r,t),r.prototype.addMouseWheel=function(){return this.add(new e.ArcRotateCameraMouseWheelInput),this},r.prototype.addPointers=function(){return this.add(new e.ArcRotateCameraPointersInput),this},r.prototype.addKeyboard=function(){return this.add(new e.ArcRotateCameraKeyboardMoveInput),this},r.prototype.addGamepad=function(){return this.add(new e.ArcRotateCameraGamepadInput),this},r.prototype.addVRDeviceOrientation=function(){return this.add(new e.ArcRotateCameraVRDeviceOrientationInput),this},r})(e.CameraInputsManager);e.ArcRotateCameraInputsManager=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(r,i,n,o,s,a,u,l,c,h){void 0===a&&(a=null),void 0===u&&(u=null),void 0===l&&(l=e.Engine.TEXTUREFORMAT_RGBA),void 0===c&&(c=!1),void 0===h&&(h=null);var f=t.call(this,i)||this;if(f.coordinatesMode=e.Texture.CUBIC_MODE,f.name=r,f.url=r,f._noMipmap=o,f.hasAlpha=!1,f._format=l,f._prefiltered=c,f.isCube=!0,f._textureMatrix=e.Matrix.Identity(),c&&(f.gammaSpace=!1),!r&&!s)return f;if(f._texture=f._getFromCache(r,o),!s){n||(n=["_px.jpg","_py.jpg","_pz.jpg","_nx.jpg","_ny.jpg","_nz.jpg"]),s=[];for(var d=0;d0&&(this._postProcesses[0].autoClear=!1))}},r.prototype._shouldRender=function(){return-1===this._currentRefreshId?(this._currentRefreshId=1,!0):this.refreshRate===this._currentRefreshId?(this._currentRefreshId=1,!0):(this._currentRefreshId++,!1)},r.prototype.isReady=function(){return!!this.getScene().renderTargetsEnabled&&t.prototype.isReady.call(this)},r.prototype.getRenderSize=function(){return this._size},Object.defineProperty(r.prototype,"canRescale",{get:function(){return!0},enumerable:!0,configurable:!0}),r.prototype.scale=function(e){var t=this._size*e;this.resize(t)},r.prototype.getReflectionTextureMatrix=function(){return this.isCube?this._textureMatrix:t.prototype.getReflectionTextureMatrix.call(this)},r.prototype.resize=function(e){this.releaseInternalTexture(),this.isCube?this._texture=this.getScene().getEngine().createRenderTargetCubeTexture(e,this._renderTargetOptions):this._texture=this.getScene().getEngine().createRenderTargetTexture(e,this._renderTargetOptions)},r.prototype.render=function(e,t){var r=this.getScene(),i=r.getEngine();if(void 0!==this.useCameraPostProcesses&&(e=this.useCameraPostProcesses),this._waitingRenderList){this.renderList=[];for(var n=0;n=0&&this._renderingManager.dispatchParticles(m))}if(this.isCube)for(var y=0;y<6;y++)this.renderToTarget(y,l,c,e,t),r.incrementRenderId(),r.resetCachedMaterial();else this.renderToTarget(0,l,c,e,t);this.onAfterUnbindObservable.notifyObservers(this),this.activeCamera&&this.activeCamera!==r.activeCamera&&r.setTransformMatrix(r.activeCamera.getViewMatrix(),r.activeCamera.getProjectionMatrix(!0)),i.setViewport(r.activeCamera.viewport),r.resetCachedMaterial()}},r.prototype.renderToTarget=function(t,r,i,n,o){var s=this,a=this.getScene(),u=a.getEngine();this._postProcessManager?this._postProcessManager._prepareFrame(this._texture,this._postProcesses):n&&a.postProcessManager._prepareFrame(this._texture)||(this.isCube?u.bindFramebuffer(this._texture,t):u.bindFramebuffer(this._texture)),this.onBeforeRenderObservable.notifyObservers(t),this.onClearObservable.hasObservers()?this.onClearObservable.notifyObservers(u):u.clear(a.clearColor,!0,!0,!0),this._doNotChangeAspectRatio||a.updateTransformMatrix(!0),this._renderingManager.render(this.customRenderFunction,r,this.renderParticles,this.renderSprites), +this._postProcessManager?this._postProcessManager._finalizeFrame(!1,this._texture,t,this._postProcesses):n&&a.postProcessManager._finalizeFrame(!1,this._texture,t),this._doNotChangeAspectRatio||a.updateTransformMatrix(!0),o&&e.Tools.DumpFramebuffer(this._size,this._size,u),this.isCube&&5!==t?this.onAfterRenderObservable.notifyObservers(t):(this.isCube&&5===t&&u.generateMipMapsForCubemap(this._texture),u.unBindFramebuffer(this._texture,this.isCube,(function(){s.onAfterRenderObservable.notifyObservers(t)})))},r.prototype.setRenderingOrder=function(e,t,r,i){void 0===t&&(t=null),void 0===r&&(r=null),void 0===i&&(i=null),this._renderingManager.setRenderingOrder(e,t,r,i)},r.prototype.setRenderingAutoClearDepthStencil=function(e,t){this._renderingManager.setRenderingAutoClearDepthStencil(e,t)},r.prototype.clone=function(){var e=this.getSize(),t=new r(this.name,e.width,this.getScene(),this._renderTargetOptions.generateMipMaps,this._doNotChangeAspectRatio,this._renderTargetOptions.type,this.isCube,this._renderTargetOptions.samplingMode,this._renderTargetOptions.generateDepthBuffer,this._renderTargetOptions.generateStencilBuffer);return t.hasAlpha=this.hasAlpha,t.level=this.level,t.coordinatesMode=this.coordinatesMode,t.renderList=this.renderList.slice(0),t},r.prototype.serialize=function(){if(!this.name)return null;var e=t.prototype.serialize.call(this);e.renderTargetSize=this.getRenderSize(),e.renderList=[];for(var r=0;r=0&&e.customRenderTargets.splice(r,1);for(var i=0,n=e.cameras;i=0&&o.customRenderTargets.splice(r,1)}t.prototype.dispose.call(this)},r})(e.Texture);t._REFRESHRATE_RENDER_ONCE=0,t._REFRESHRATE_RENDER_ONEVERYFRAME=1,t._REFRESHRATE_RENDER_ONEVERYTWOFRAMES=2,e.RenderTargetTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(r,i,n,o,s){var a=this;s=s||{};var u=!!s.generateMipMaps&&s.generateMipMaps,l=!!s.generateDepthTexture&&s.generateDepthTexture,c=void 0===s.doNotChangeAspectRatio||s.doNotChangeAspectRatio;if(a=t.call(this,r,i,o,u,c)||this,!a.isSupported)return void a.dispose();for(var h=[],f=[],d=0;d1||e.getCaps().drawBuffersExtension},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"textures",{get:function(){return this._textures},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"depthTexture",{get:function(){return this._textures[this._textures.length-1]},enumerable:!0,configurable:!0}),r.prototype._createInternalTextures=function(){this._textures=[];for(var t=0;t=0;e--)void 0!==this._webGLTextures[e]&&(this.getScene().getEngine().releaseInternalTexture(this._webGLTextures[e]),this._webGLTextures.splice(e,1))},r})(e.RenderTargetTexture);e.MultiRenderTarget=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(r,i,n,o,s,a,u){void 0===s&&(s=e.Engine.TEXTURETYPE_UNSIGNED_INT),void 0===a&&(a=e.Texture.BILINEAR_SAMPLINGMODE),void 0===u&&(u=!0);var l=t.call(this,r,i,n,o,!0,s,!1,a,u)||this;return l.mirrorPlane=new e.Plane(0,1,0,1),l._transformMatrix=e.Matrix.Zero(),l._mirrorMatrix=e.Matrix.Zero(),l._blurKernelX=0,l._blurKernelY=0,l._blurRatio=1,l.onBeforeRenderObservable.add((function(){e.Matrix.ReflectionToRef(l.mirrorPlane,l._mirrorMatrix),l._savedViewMatrix=n.getViewMatrix(),l._mirrorMatrix.multiplyToRef(l._savedViewMatrix,l._transformMatrix),n.setTransformMatrix(l._transformMatrix,n.getProjectionMatrix()),n.clipPlane=l.mirrorPlane,n.getEngine().cullBackFaces=!1,n._mirroredCameraPosition=e.Vector3.TransformCoordinates(n.activeCamera.globalPosition,l._mirrorMatrix)})),l.onAfterRenderObservable.add((function(){n.setTransformMatrix(l._savedViewMatrix,n.getProjectionMatrix()),n.getEngine().cullBackFaces=!0,n._mirroredCameraPosition=null,delete n.clipPlane})),l}return __extends(r,t),Object.defineProperty(r.prototype,"blurRatio",{get:function(){return this._blurRatio},set:function(e){this._blurRatio!==e&&(this._blurRatio=e,this._preparePostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"blurKernel",{set:function(e){this.blurKernelX=e,this.blurKernelY=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"blurKernelX",{get:function(){return this._blurKernelX},set:function(e){this._blurKernelX!==e&&(this._blurKernelX=e,this._preparePostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"blurKernelY",{get:function(){return this._blurKernelY},set:function(e){this._blurKernelY!==e&&(this._blurKernelY=e,this._preparePostProcesses())},enumerable:!0,configurable:!0}),r.prototype._preparePostProcesses=function(){if(this.clearPostProcesses(!0),this._blurKernelX&&this._blurKernelY){var t=this.getScene().getEngine(),r=t.getCaps().textureFloatRender?e.Engine.TEXTURETYPE_FLOAT:e.Engine.TEXTURETYPE_HALF_FLOAT;this._blurX=new e.BlurPostProcess("horizontal blur",new e.Vector2(1,0),this._blurKernelX,this._blurRatio,null,e.Texture.BILINEAR_SAMPLINGMODE,t,!1,r),this._blurX.autoClear=!1,1===this._blurRatio&&this.samples<2?this._blurX.outputTexture=this._texture:this._blurX.alwaysForcePOT=!0,this._blurY=new e.BlurPostProcess("vertical blur",new e.Vector2(0,1),this._blurKernelY,this._blurRatio,null,e.Texture.BILINEAR_SAMPLINGMODE,t,!1,r),this._blurY.autoClear=!1,this._blurY.alwaysForcePOT=1!==this._blurRatio,this.addPostProcess(this._blurX),this.addPostProcess(this._blurY)}},r.prototype.clone=function(){var e=this.getSize(),t=new r(this.name,e.width,this.getScene(),this._renderTargetOptions.generateMipMaps,this._renderTargetOptions.type,this._renderTargetOptions.samplingMode,this._renderTargetOptions.generateDepthBuffer);return t.hasAlpha=this.hasAlpha,t.level=this.level,t.mirrorPlane=this.mirrorPlane.clone(),t.renderList=this.renderList.slice(0),t},r.prototype.serialize=function(){if(!this.name)return null;var e=t.prototype.serialize.call(this);return e.mirrorPlane=this.mirrorPlane.asArray(),e},r})(e.RenderTargetTexture);e.MirrorTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(r,i,n,o){var s=t.call(this,r,i,n,o,!0)||this;return s.refractionPlane=new e.Plane(0,1,0,1),s.depth=2,s.onBeforeRenderObservable.add((function(){n.clipPlane=s.refractionPlane})),s.onAfterRenderObservable.add((function(){delete n.clipPlane})),s}return __extends(r,t),r.prototype.clone=function(){var e=this.getSize(),t=new r(this.name,e.width,this.getScene(),this._generateMipMaps);return t.hasAlpha=this.hasAlpha,t.level=this.level,t.refractionPlane=this.refractionPlane.clone(),t.renderList=this.renderList.slice(0),t.depth=this.depth,t},r.prototype.serialize=function(){if(!this.name)return null;var e=t.prototype.serialize.call(this);return e.mirrorPlane=this.refractionPlane.asArray(),e.depth=this.depth,e},r})(e.RenderTargetTexture);e.RefractionTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(r,i,n,o,s,a){void 0===s&&(s=e.Texture.TRILINEAR_SAMPLINGMODE),void 0===a&&(a=e.Engine.TEXTUREFORMAT_RGBA);var u=t.call(this,null,n,!o,void 0,s,void 0,void 0,void 0,void 0,a)||this;u.name=r;var l=u.getScene().getEngine();u.wrapU=e.Texture.CLAMP_ADDRESSMODE,u.wrapV=e.Texture.CLAMP_ADDRESSMODE,u._generateMipMaps=o,i.getContext?(u._canvas=i,u._texture=l.createDynamicTexture(i.width,i.height,o,s)):(u._canvas=document.createElement("canvas"),i.width?u._texture=l.createDynamicTexture(i.width,i.height,o,s):u._texture=l.createDynamicTexture(i,i,o,s));var c=u.getSize();return u._canvas.width=c.width,u._canvas.height=c.height,u._context=u._canvas.getContext("2d"),u}return __extends(r,t),Object.defineProperty(r.prototype,"canRescale",{get:function(){return!0},enumerable:!0,configurable:!0}),r.prototype._recreate=function(e){this._canvas.width=e.width,this._canvas.height=e.height,this.releaseInternalTexture(),this._texture=this.getScene().getEngine().createDynamicTexture(e.width,e.height,this._generateMipMaps,this._samplingMode)},r.prototype.scale=function(e){var t=this.getSize();t.width*=e,t.height*=e,this._recreate(t)},r.prototype.scaleTo=function(e,t){var r=this.getSize();r.width=e,r.height=t,this._recreate(r)},r.prototype.getContext=function(){return this._context},r.prototype.clear=function(){var e=this.getSize();this._context.fillRect(0,0,e.width,e.height)},r.prototype.update=function(e){this.getScene().getEngine().updateDynamicTexture(this._texture,this._canvas,void 0===e||e,void 0,this._format)},r.prototype.drawText=function(e,t,r,i,n,o,s,a){void 0===a&&(a=!0);var u=this.getSize();if(o&&(this._context.fillStyle=o,this._context.fillRect(0,0,u.width,u.height)),this._context.font=i,null===t||void 0===t){var l=this._context.measureText(e);t=(u.width-l.width)/2}if(null===r||void 0===r){var c=parseInt(i.replace(/\D/g,""));r=u.height/2+c/3.65}this._context.fillStyle=n,this._context.fillText(e,t,r),a&&this.update(s)},r.prototype.clone=function(){var e=this.getSize(),t=new r(this.name,e,this.getScene(),this._generateMipMaps);return t.hasAlpha=this.hasAlpha,t.level=this.level,t.wrapU=this.wrapU,t.wrapV=this.wrapV,t},r})(e.Texture);e.DynamicTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(r,i,n,o,s,a){void 0===o&&(o=!1),void 0===s&&(s=!1),void 0===a&&(a=e.Texture.TRILINEAR_SAMPLINGMODE);var u=t.call(this,null,n,!o,s)||this;u._autoLaunch=!0;var l;return u.name=r,i instanceof HTMLVideoElement?u.video=i:(l=i,u.video=document.createElement("video"),u.video.autoplay=!1,u.video.loop=!0),u._generateMipMaps=o,u._samplingMode=a,!u.getScene().getEngine().needPOTTextures||e.Tools.IsExponentOfTwo(u.video.videoWidth)&&e.Tools.IsExponentOfTwo(u.video.videoHeight)?(u.wrapU=e.Texture.WRAP_ADDRESSMODE,u.wrapV=e.Texture.WRAP_ADDRESSMODE):(u.wrapU=e.Texture.CLAMP_ADDRESSMODE,u.wrapV=e.Texture.CLAMP_ADDRESSMODE,u._generateMipMaps=!1),l?(u.video.addEventListener("canplay",(function(){u._createTexture()})),l.forEach((function(e){var t=document.createElement("source");t.src=e,u.video.appendChild(t)}))):u._createTexture(),u._lastUpdate=e.Tools.Now,u}return __extends(r,t),r.prototype.__setTextureReady=function(){this._texture.isReady=!0},r.prototype._createTexture=function(){this._texture=this.getScene().getEngine().createDynamicTexture(this.video.videoWidth,this.video.videoHeight,this._generateMipMaps,this._samplingMode),this._autoLaunch&&(this._autoLaunch=!1,this.video.play()),this._setTextureReady=this.__setTextureReady.bind(this),this.video.addEventListener("playing",this._setTextureReady)},r.prototype.update=function(){var t=e.Tools.Now;return!(t-this._lastUpdate<15||this.video.readyState!==this.video.HAVE_ENOUGH_DATA)&&(this._lastUpdate=t,this.getScene().getEngine().updateVideoTexture(this._texture,this.video,this._invertY),!0)},r.prototype.dispose=function(){t.prototype.dispose.call(this),this.video.removeEventListener("playing",this._setTextureReady)},r.CreateFromWebCam=function(t,r,i){var n,o=document.createElement("video");i&&i.deviceId&&(n={exact:i.deviceId}),navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia,window.URL=window.URL||window.webkitURL||window.mozURL||window.msURL,navigator.getUserMedia&&navigator.getUserMedia({video:{deviceId:n,width:{min:i&&i.minWidth||256,max:i&&i.maxWidth||640},height:{min:i&&i.minHeight||256,max:i&&i.maxHeight||480}}},(function(i){void 0!==o.mozSrcObject?o.mozSrcObject=i:o.src=window.URL&&window.URL.createObjectURL(i)||i,o.play(),r&&r(new e.VideoTexture("video",o,t,!0,!0))}),(function(t){e.Tools.Error(t.name)}))},r})(e.Texture);e.VideoTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(r,i,n,o,s,a,u,l){void 0===a&&(a=!0),void 0===u&&(u=!1),void 0===l&&(l=e.Texture.TRILINEAR_SAMPLINGMODE);var c=t.call(this,null,s,!a,u)||this;return c.format=o,c._texture=s.getEngine().createRawTexture(r,i,n,o,a,u,l),c.wrapU=e.Texture.CLAMP_ADDRESSMODE,c.wrapV=e.Texture.CLAMP_ADDRESSMODE,c}return __extends(r,t),r.prototype.update=function(e){this.getScene().getEngine().updateRawTexture(this._texture,e,this.format,this._invertY)},r.CreateLuminanceTexture=function(t,i,n,o,s,a,u){return void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===u&&(u=e.Texture.TRILINEAR_SAMPLINGMODE),new r(t,i,n,e.Engine.TEXTUREFORMAT_LUMINANCE,o,s,a,u)},r.CreateLuminanceAlphaTexture=function(t,i,n,o,s,a,u){return void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===u&&(u=e.Texture.TRILINEAR_SAMPLINGMODE),new r(t,i,n,e.Engine.TEXTUREFORMAT_LUMINANCE_ALPHA,o,s,a,u)},r.CreateAlphaTexture=function(t,i,n,o,s,a,u){return void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===u&&(u=e.Texture.TRILINEAR_SAMPLINGMODE),new r(t,i,n,e.Engine.TEXTUREFORMAT_ALPHA,o,s,a,u)},r.CreateRGBTexture=function(t,i,n,o,s,a,u){return void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===u&&(u=e.Texture.TRILINEAR_SAMPLINGMODE),new r(t,i,n,e.Engine.TEXTUREFORMAT_RGB,o,s,a,u)},r.CreateRGBATexture=function(t,i,n,o,s,a,u){return void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===u&&(u=e.Texture.TRILINEAR_SAMPLINGMODE),new r(t,i,n,e.Engine.TEXTUREFORMAT_RGBA,o,s,a,u)},r})(e.Texture);e.RawTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){var r=(function(){function t(){}return t.GetTGAHeader=function(e){var t=0;return{id_length:e[t++],colormap_type:e[t++],image_type:e[t++],colormap_index:e[t++]|e[t++]<<8,colormap_length:e[t++]|e[t++]<<8,colormap_size:e[t++],origin:[e[t++]|e[t++]<<8,e[t++]|e[t++]<<8],width:e[t++]|e[t++]<<8,height:e[t++]|e[t++]<<8,pixel_size:e[t++],flags:e[t++]}},t.UploadContent=function(r,i){if(i.length<19)return void e.Tools.Error("Unable to load TGA file - Not enough data to contain header");var n=18,o=t.GetTGAHeader(i);if(o.id_length+n>i.length)return void e.Tools.Error("Unable to load TGA file - Not enough data");n+=o.id_length;var s=!1,a=!1,u=!1;switch(o.image_type){case t._TYPE_RLE_INDEXED:s=!0;case t._TYPE_INDEXED:a=!0;break;case t._TYPE_RLE_RGB:s=!0;case t._TYPE_RGB:!0;break;case t._TYPE_RLE_GREY:s=!0;case t._TYPE_GREY:u=!0}var l,c,h=(o.flags,o.pixel_size>>3),f=o.width*o.height*h;if(a&&(c=i.subarray(n,n+=o.colormap_length*(o.colormap_size>>3))),s){l=new Uint8Array(f);for(var d,p,g,_=0,m=new Uint8Array(h);n>t._ORIGIN_SHIFT){default:case t._ORIGIN_UL:v=0,A=1,b=o.width,y=0,E=1,T=o.height;break;case t._ORIGIN_BL:v=0,A=1,b=o.width,y=o.height-1,E=-1,T=-1;break;case t._ORIGIN_UR:v=o.width-1,A=-1,b=-1,y=0,E=1,T=o.height;break;case t._ORIGIN_BR:v=o.width-1,A=-1,b=-1,y=o.height-1,E=-1,T=-1}var x="_getImageData"+(u?"Grey":"")+o.pixel_size+"bits",M=t[x](o,c,l,y,E,T,v,A,b);r.texImage2D(r.TEXTURE_2D,0,r.RGBA,o.width,o.height,0,r.RGBA,r.UNSIGNED_BYTE,M)},t._getImageData8bits=function(e,t,r,i,n,o,s,a,u){var l,c,h,f=r,d=t,p=e.width,g=e.height,_=0,m=new Uint8Array(p*g*4);for(h=i;h!==o;h+=n)for(c=s;c!==u;c+=a,_++)l=f[_],m[4*(c+p*h)+3]=255,m[4*(c+p*h)+2]=d[3*l+0],m[4*(c+p*h)+1]=d[3*l+1],m[4*(c+p*h)+0]=d[3*l+2];return m},t._getImageData16bits=function(e,t,r,i,n,o,s,a,u){var l,c,h,f=r,d=e.width,p=e.height,g=0,_=new Uint8Array(d*p*4);for(h=i;h!==o;h+=n)for(c=s;c!==u;c+=a,g+=2)l=f[g+0]+(f[g+1]<<8),_[4*(c+d*h)+0]=(31744&l)>>7,_[4*(c+d*h)+1]=(992&l)>>2,_[4*(c+d*h)+2]=(31&l)>>3,_[4*(c+d*h)+3]=32768&l?0:255;return _},t._getImageData24bits=function(e,t,r,i,n,o,s,a,u){var l,c,h=r,f=e.width,d=e.height,p=0,g=new Uint8Array(f*d*4);for(c=i;c!==o;c+=n)for(l=s;l!==u;l+=a,p+=3)g[4*(l+f*c)+3]=255,g[4*(l+f*c)+2]=h[p+0],g[4*(l+f*c)+1]=h[p+1],g[4*(l+f*c)+0]=h[p+2];return g},t._getImageData32bits=function(e,t,r,i,n,o,s,a,u){var l,c,h=r,f=e.width,d=e.height,p=0,g=new Uint8Array(f*d*4);for(c=i;c!==o;c+=n)for(l=s;l!==u;l+=a,p+=4)g[4*(l+f*c)+2]=h[p+0],g[4*(l+f*c)+1]=h[p+1],g[4*(l+f*c)+0]=h[p+2],g[4*(l+f*c)+3]=h[p+3];return g},t._getImageDataGrey8bits=function(e,t,r,i,n,o,s,a,u){var l,c,h,f=r,d=e.width,p=e.height,g=0,_=new Uint8Array(d*p*4);for(h=i;h!==o;h+=n)for(c=s;c!==u;c+=a,g++)l=f[g],_[4*(c+d*h)+0]=l,_[4*(c+d*h)+1]=l,_[4*(c+d*h)+2]=l,_[4*(c+d*h)+3]=255;return _},t._getImageDataGrey16bits=function(e,t,r,i,n,o,s,a,u){var l,c,h=r,f=e.width,d=e.height,p=0,g=new Uint8Array(f*d*4);for(c=i;c!==o;c+=n)for(l=s;l!==u;l+=a,p+=2)g[4*(l+f*c)+0]=h[p+0],g[4*(l+f*c)+1]=h[p+0],g[4*(l+f*c)+2]=h[p+0],g[4*(l+f*c)+3]=h[p+1];return g},t})();r._TYPE_NO_DATA=0,r._TYPE_INDEXED=1,r._TYPE_RGB=2,r._TYPE_GREY=3,r._TYPE_RLE_INDEXED=9,r._TYPE_RLE_RGB=10,r._TYPE_RLE_GREY=11,r._ORIGIN_MASK=48,r._ORIGIN_SHIFT=4,r._ORIGIN_BL=0,r._ORIGIN_BR=1,r._ORIGIN_UL=2,r._ORIGIN_UR=3,t.TGATools=r})(e.Internals||(e.Internals={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){function r(e){return e.charCodeAt(0)+(e.charCodeAt(1)<<8)+(e.charCodeAt(2)<<16)+(e.charCodeAt(3)<<24)}function i(e){return String.fromCharCode(255&e,e>>8&255,e>>16&255,e>>24&255)}var n=r("DXT1"),o=r("DXT3"),s=r("DXT5"),a=r("DX10"),u=(function(){function t(){}return t.GetDDSInfo=function(t){var r=new Int32Array(t,0,31),i=new Int32Array(t,0,35),u=1;131072&r[2]&&(u=Math.max(1,r[7]));var l=r[21],c=l===a?i[32]:0,h=e.Engine.TEXTURETYPE_UNSIGNED_INT;switch(l){case 113:h=e.Engine.TEXTURETYPE_HALF_FLOAT;break;case 116:h=e.Engine.TEXTURETYPE_FLOAT;break;case a:if(10===c){h=e.Engine.TEXTURETYPE_HALF_FLOAT;break}}return{width:r[4],height:r[3],mipmapCount:u,isFourCC:4==(4&r[20]),isRGB:64==(64&r[20]),isLuminance:131072==(131072&r[20]),isCube:512==(512&r[28]),isCompressed:l===n||l===o||n===s,dxgiFormat:c,textureType:h}},t._ToHalfFloat=function(e){t._FloatView||(t._FloatView=new Float32Array(1),t._Int32View=new Int32Array(t._FloatView.buffer)),t._FloatView[0]=e;var r=t._Int32View[0],i=r>>16&32768,n=r>>12&2047,o=r>>23&255;return o<103?i:o>142?(i|=31744,i|=(255==o?0:1)&&8388607&r):o<113?(n|=2048,i|=(n>>114-o)+(n>>113-o&1)):(i|=o-112<<10|n>>1,i+=1&n)},t._FromHalfFloat=function(e){var t=(32768&e)>>15,r=(31744&e)>>10,i=1023&e;return 0===r?(t?-1:1)*Math.pow(2,-14)*(i/Math.pow(2,10)):31==r?i?NaN:1/0*(t?-1:1):(t?-1:1)*Math.pow(2,r-15)*(1+i/Math.pow(2,10))},t._GetHalfFloatAsFloatRGBAArrayBuffer=function(e,r,i,n,o,s){for(var a=new Float32Array(n),u=new Uint16Array(o,i),l=0,c=0;c>8&65280|e>>24&255},t.prototype.uploadLevels=function(e,r){switch(this.loadType){case t.COMPRESSED_2D:this._upload2DCompressedLevels(e,r);break;case t.TEX_2D:case t.COMPRESSED_3D:case t.TEX_3D:}},t.prototype._upload2DCompressedLevels=function(e,r){for(var i=t.HEADER_LEN+this.bytesOfKeyValueData,n=this.pixelWidth,o=this.pixelHeight,s=r?this.numberOfMipmapLevels:1,a=0;a0){for(var f=0;f0)for(var e=0;e0&&this._camera._postProcesses[0].markTextureDirty(),this.onActivateObservable.clear(),this.onAfterRenderObservable.clear(),this.onApplyObservable.clear(),this.onBeforeRenderObservable.clear(),this.onSizeChangedObservable.clear()}},t})();e.PostProcess=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(r,i,n,o,s,a,u){return void 0===u&&(u=e.Engine.TEXTURETYPE_UNSIGNED_INT),t.call(this,r,"pass",null,null,i,n,o,s,a,null,u)||this}return __extends(r,t),r})(e.PostProcess);e.PassPostProcess=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(r,i,n){this._bias=5e-5,this._blurBoxOffset=1,this._blurScale=2,this._blurKernel=1,this._useKernelBlur=!1,this._filter=t.FILTER_NONE,this._darkness=0,this._transparencyShadow=!1,this.frustumEdgeFalloff=0,this.forceBackFacesOnly=!1,this._lightDirection=e.Vector3.Zero(),this._viewMatrix=e.Matrix.Zero(),this._projectionMatrix=e.Matrix.Zero(),this._transformMatrix=e.Matrix.Zero(),this._worldViewProjection=e.Matrix.Zero(),this._currentFaceIndex=0,this._currentFaceIndexCache=0,this._isCube=!1,this._defaultTextureMatrix=e.Matrix.Identity(),this._mapSize=r,this._light=i,this._scene=i.getScene(),i._shadowGenerator=this;var o=this._scene.getEngine().getCaps();n?o.textureFloatRender&&o.textureFloatLinearFiltering?this._textureType=e.Engine.TEXTURETYPE_FLOAT:o.textureHalfFloatRender&&o.textureHalfFloatLinearFiltering?this._textureType=e.Engine.TEXTURETYPE_HALF_FLOAT:this._textureType=e.Engine.TEXTURETYPE_UNSIGNED_INT:o.textureHalfFloatRender&&o.textureHalfFloatLinearFiltering?this._textureType=e.Engine.TEXTURETYPE_HALF_FLOAT:o.textureFloatRender&&o.textureFloatLinearFiltering?this._textureType=e.Engine.TEXTURETYPE_FLOAT:this._textureType=e.Engine.TEXTURETYPE_UNSIGNED_INT,this._initializeGenerator()}return Object.defineProperty(t,"FILTER_NONE",{get:function(){return t._FILTER_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FILTER_POISSONSAMPLING",{get:function(){return t._FILTER_POISSONSAMPLING},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FILTER_EXPONENTIALSHADOWMAP",{get:function(){return t._FILTER_EXPONENTIALSHADOWMAP},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FILTER_BLUREXPONENTIALSHADOWMAP",{get:function(){return t._FILTER_BLUREXPONENTIALSHADOWMAP},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FILTER_CLOSEEXPONENTIALSHADOWMAP",{get:function(){return t._FILTER_CLOSEEXPONENTIALSHADOWMAP},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FILTER_BLURCLOSEEXPONENTIALSHADOWMAP",{get:function(){return t._FILTER_BLURCLOSEEXPONENTIALSHADOWMAP},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"bias",{get:function(){return this._bias},set:function(e){this._bias=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"blurBoxOffset",{get:function(){return this._blurBoxOffset},set:function(e){this._blurBoxOffset!==e&&(this._blurBoxOffset=e,this._disposeBlurPostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"blurScale",{get:function(){return this._blurScale},set:function(e){this._blurScale!==e&&(this._blurScale=e,this._disposeBlurPostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"blurKernel",{get:function(){return this._blurKernel},set:function(e){this._blurKernel!==e&&(this._blurKernel=e,this._disposeBlurPostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useKernelBlur",{get:function(){return this._useKernelBlur},set:function(e){this._useKernelBlur!==e&&(this._useKernelBlur=e,this._disposeBlurPostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"depthScale",{get:function(){return void 0!==this._depthScale?this._depthScale:this._light.getDepthScale()},set:function(e){this._depthScale=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"filter",{get:function(){return this._filter},set:function(e){if(this._light.needCube()){if(e===t.FILTER_BLUREXPONENTIALSHADOWMAP)return void(this.useExponentialShadowMap=!0);if(e===t.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP)return void(this.useCloseExponentialShadowMap=!0)}this._filter!==e&&(this._filter=e,this._disposeBlurPostProcesses(),this._applyFilterValues(),this._light._markMeshesAsLightDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"usePoissonSampling",{get:function(){return this.filter===t.FILTER_POISSONSAMPLING},set:function(e){this.filter=e?t.FILTER_POISSONSAMPLING:t.FILTER_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useVarianceShadowMap",{get:function(){return e.Tools.Warn("VSM are now replaced by ESM. Please use useExponentialShadowMap instead."),this.useExponentialShadowMap},set:function(t){e.Tools.Warn("VSM are now replaced by ESM. Please use useExponentialShadowMap instead."),this.useExponentialShadowMap=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useBlurVarianceShadowMap",{get:function(){return e.Tools.Warn("VSM are now replaced by ESM. Please use useBlurExponentialShadowMap instead."),this.useBlurExponentialShadowMap},set:function(t){e.Tools.Warn("VSM are now replaced by ESM. Please use useBlurExponentialShadowMap instead."),this.useBlurExponentialShadowMap=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useExponentialShadowMap",{get:function(){return this.filter===t.FILTER_EXPONENTIALSHADOWMAP},set:function(e){this.filter=e?t.FILTER_EXPONENTIALSHADOWMAP:t.FILTER_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useBlurExponentialShadowMap",{get:function(){return this.filter===t.FILTER_BLUREXPONENTIALSHADOWMAP},set:function(e){this.filter=e?t.FILTER_BLUREXPONENTIALSHADOWMAP:t.FILTER_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useCloseExponentialShadowMap",{get:function(){return this.filter===t.FILTER_CLOSEEXPONENTIALSHADOWMAP},set:function(e){this.filter=e?t.FILTER_CLOSEEXPONENTIALSHADOWMAP:t.FILTER_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useBlurCloseExponentialShadowMap",{get:function(){return this.filter===t.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP},set:function(e){this.filter=e?t.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP:t.FILTER_NONE},enumerable:!0,configurable:!0}),t.prototype.getDarkness=function(){return this._darkness},t.prototype.setDarkness=function(e){return this._darkness=e>=1?1:e<=0?0:e,this},t.prototype.setTransparencyShadow=function(e){return this._transparencyShadow=e,this},t.prototype.getShadowMap=function(){return this._shadowMap},t.prototype.getShadowMapForRendering=function(){return this._shadowMap2?this._shadowMap2:this._shadowMap},t.prototype.getLight=function(){return this._light},t.prototype._initializeGenerator=function(){this._light._markMeshesAsLightDirty(),this._initializeShadowMap()},t.prototype._initializeShadowMap=function(){var t=this;this._shadowMap=new e.RenderTargetTexture(this._light.name+"_shadowMap",this._mapSize,this._scene,!1,!0,this._textureType,this._light.needCube()),this._shadowMap.wrapU=e.Texture.CLAMP_ADDRESSMODE,this._shadowMap.wrapV=e.Texture.CLAMP_ADDRESSMODE,this._shadowMap.anisotropicFilteringLevel=1,this._shadowMap.updateSamplingMode(e.Texture.BILINEAR_SAMPLINGMODE),this._shadowMap.renderParticles=!1,this._shadowMap.onBeforeRenderObservable.add((function(e){t._currentFaceIndex=e})),this._shadowMap.customRenderFunction=this._renderForShadowMap.bind(this),this._shadowMap.onAfterUnbindObservable.add((function(){(t.useBlurExponentialShadowMap||t.useBlurCloseExponentialShadowMap)&&(t._blurPostProcesses||t._initializeBlurRTTAndPostProcesses(),t._scene.postProcessManager.directRender(t._blurPostProcesses,t.getShadowMapForRendering().getInternalTexture()))})),this._shadowMap.onClearObservable.add((function(r){t.useExponentialShadowMap||t.useBlurExponentialShadowMap?r.clear(new e.Color4(0,0,0,0),!0,!0,!0):r.clear(new e.Color4(1,1,1,1),!0,!0,!0)}))},t.prototype._initializeBlurRTTAndPostProcesses=function(){var t=this,r=this._scene.getEngine(),i=this._mapSize/this.blurScale;this.useKernelBlur&&1===this.blurScale||(this._shadowMap2=new e.RenderTargetTexture(this._light.name+"_shadowMap2",i,this._scene,!1,!0,this._textureType),this._shadowMap2.wrapU=e.Texture.CLAMP_ADDRESSMODE,this._shadowMap2.wrapV=e.Texture.CLAMP_ADDRESSMODE,this._shadowMap2.updateSamplingMode(e.Texture.BILINEAR_SAMPLINGMODE)),this.useKernelBlur?(this._kernelBlurXPostprocess=new e.BlurPostProcess(this._light.name+"KernelBlurX",new e.Vector2(1,0),this.blurKernel,1,null,e.Texture.BILINEAR_SAMPLINGMODE,r,!1,this._textureType),this._kernelBlurXPostprocess.width=i,this._kernelBlurXPostprocess.height=i,this._kernelBlurXPostprocess.onApplyObservable.add((function(e){e.setTexture("textureSampler",t._shadowMap)})),this._kernelBlurYPostprocess=new e.BlurPostProcess(this._light.name+"KernelBlurY",new e.Vector2(0,1),this.blurKernel,1,null,e.Texture.BILINEAR_SAMPLINGMODE,r,!1,this._textureType),this._kernelBlurXPostprocess.autoClear=!1,this._kernelBlurYPostprocess.autoClear=!1,this._textureType===e.Engine.TEXTURETYPE_UNSIGNED_INT&&(this._kernelBlurXPostprocess.packedFloat=!0,this._kernelBlurYPostprocess.packedFloat=!0),this._blurPostProcesses=[this._kernelBlurXPostprocess,this._kernelBlurYPostprocess]):(this._boxBlurPostprocess=new e.PostProcess(this._light.name+"DepthBoxBlur","depthBoxBlur",["screenSize","boxOffset"],[],1,null,e.Texture.BILINEAR_SAMPLINGMODE,r,!1,"#define OFFSET "+this._blurBoxOffset,this._textureType),this._boxBlurPostprocess.onApplyObservable.add((function(e){e.setFloat2("screenSize",i,i),e.setTexture("textureSampler",t._shadowMap)})),this._boxBlurPostprocess.autoClear=!1,this._blurPostProcesses=[this._boxBlurPostprocess])},t.prototype._renderForShadowMap=function(e,t,r){var i;for(i=0;i=n.length)return void(e&&e(r));setTimeout(l,16)}};n.length>0&&l()},t.prototype.isReady=function(t,r){var i=[];this._textureType!==e.Engine.TEXTURETYPE_UNSIGNED_INT&&i.push("#define FLOAT"),(this.useExponentialShadowMap||this.useBlurExponentialShadowMap)&&i.push("#define ESM");var n=[e.VertexBuffer.PositionKind],o=t.getMesh(),s=t.getMaterial();if(s&&s.needAlphaTesting()){var a=s.getAlphaTestTexture();a&&(i.push("#define ALPHATEST"),o.isVerticesDataPresent(e.VertexBuffer.UVKind)&&(n.push(e.VertexBuffer.UVKind),i.push("#define UV1")),o.isVerticesDataPresent(e.VertexBuffer.UV2Kind)&&1===a.coordinatesIndex&&(n.push(e.VertexBuffer.UV2Kind),i.push("#define UV2")))}o.useBones&&o.computeBonesUsingShaders?(n.push(e.VertexBuffer.MatricesIndicesKind),n.push(e.VertexBuffer.MatricesWeightsKind),o.numBoneInfluencers>4&&(n.push(e.VertexBuffer.MatricesIndicesExtraKind),n.push(e.VertexBuffer.MatricesWeightsExtraKind)),i.push("#define NUM_BONE_INFLUENCERS "+o.numBoneInfluencers),i.push("#define BonesPerMesh "+(o.skeleton.bones.length+1))):i.push("#define NUM_BONE_INFLUENCERS 0"),r&&(i.push("#define INSTANCES"),n.push("world0"),n.push("world1"),n.push("world2"),n.push("world3"));var u=i.join("\n");return this._cachedDefines!==u&&(this._cachedDefines=u,this._effect=this._scene.getEngine().createEffect("shadowMap",n,["world","mBones","viewProjection","diffuseMatrix","lightPosition","depthValues","biasAndScale"],["diffuseSampler"],u)),this._effect.isReady()},t.prototype.prepareDefines=function(e,t){var r=this._scene,i=this._light;r.shadowsEnabled&&i.shadowEnabled&&(e["SHADOW"+t]=!0,this.usePoissonSampling?e["SHADOWPCF"+t]=!0:this.useExponentialShadowMap||this.useBlurExponentialShadowMap?e["SHADOWESM"+t]=!0:(this.useCloseExponentialShadowMap||this.useBlurCloseExponentialShadowMap)&&(e["SHADOWCLOSEESM"+t]=!0),i.needCube()&&(e["SHADOWCUBE"+t]=!0))},t.prototype.bindShadowLight=function(e,t){var r=this._light,i=this._scene;i.shadowsEnabled&&r.shadowEnabled&&(r.needCube()||t.setMatrix("lightMatrix"+e,this.getTransformMatrix()),t.setTexture("shadowSampler"+e,this.getShadowMapForRendering()),r._uniformBuffer.updateFloat4("shadowsInfo",this.getDarkness(),this.blurScale/this.getShadowMap().getSize().width,this.depthScale,this.frustumEdgeFalloff,e),r._uniformBuffer.updateFloat2("depthValues",this.getLight().getDepthMinZ(i.activeCamera),this.getLight().getDepthMinZ(i.activeCamera)+this.getLight().getDepthMaxZ(i.activeCamera),e))},t.prototype.getTransformMatrix=function(){var t=this._scene;if(this._currentRenderID===t.getRenderId()&&this._currentFaceIndexCache===this._currentFaceIndex)return this._transformMatrix;this._currentRenderID=t.getRenderId(),this._currentFaceIndexCache=this._currentFaceIndex;var r=this._light.position;return this._light.computeTransformedInformation()&&(r=this._light.transformedPosition),e.Vector3.NormalizeToRef(this._light.getShadowDirection(this._currentFaceIndex),this._lightDirection),1===Math.abs(e.Vector3.Dot(this._lightDirection,e.Vector3.Up()))&&(this._lightDirection.z=1e-13),!this._light.needProjectionMatrixCompute()&&this._cachedPosition&&this._cachedDirection&&r.equals(this._cachedPosition)&&this._lightDirection.equals(this._cachedDirection)||(this._cachedPosition=r.clone(),this._cachedDirection=this._lightDirection.clone(),e.Matrix.LookAtLHToRef(r,r.add(this._lightDirection),e.Vector3.Up(),this._viewMatrix),this._light.setShadowProjectionMatrix(this._projectionMatrix,this._viewMatrix,this.getShadowMap().renderList),this._viewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix)),this._transformMatrix},t.prototype.recreateShadowMap=function(){var e=this._shadowMap.renderList;this._disposeRTTandPostProcesses(),this._initializeGenerator(),this.filter=this.filter,this._applyFilterValues(),this._shadowMap.renderList=e},t.prototype._disposeBlurPostProcesses=function(){this._shadowMap2&&(this._shadowMap2.dispose(),this._shadowMap2=null),this._downSamplePostprocess&&(this._downSamplePostprocess.dispose(),this._downSamplePostprocess=null),this._boxBlurPostprocess&&(this._boxBlurPostprocess.dispose(),this._boxBlurPostprocess=null),this._kernelBlurXPostprocess&&(this._kernelBlurXPostprocess.dispose(),this._kernelBlurXPostprocess=null),this._kernelBlurYPostprocess&&(this._kernelBlurYPostprocess.dispose(),this._kernelBlurYPostprocess=null),this._blurPostProcesses=null},t.prototype._disposeRTTandPostProcesses=function(){this._shadowMap&&(this._shadowMap.dispose(),this._shadowMap=null),this._disposeBlurPostProcesses()},t.prototype.dispose=function(){this._disposeRTTandPostProcesses(),this._light._shadowGenerator=null,this._light._markMeshesAsLightDirty()},t.prototype.serialize=function(){var e={},t=this.getShadowMap();e.lightId=this._light.id,e.mapSize=t.getRenderSize(),e.useExponentialShadowMap=this.useExponentialShadowMap,e.useBlurExponentialShadowMap=this.useBlurExponentialShadowMap,e.useCloseExponentialShadowMap=this.useBlurExponentialShadowMap,e.useBlurCloseExponentialShadowMap=this.useBlurExponentialShadowMap,e.usePoissonSampling=this.usePoissonSampling,e.forceBackFacesOnly=this.forceBackFacesOnly,e.depthScale=this.depthScale,e.darkness=this.getDarkness(),e.blurBoxOffset=this.blurBoxOffset,e.blurKernel=this.blurKernel,e.blurScale=this.blurScale,e.useKernelBlur=this.useKernelBlur,e.transparencyShadow=this._transparencyShadow,e.renderList=[];for(var r=0;r0?this._setDefaultFixedFrustumShadowProjectionMatrix(e,t):this._setDefaultAutoExtendShadowProjectionMatrix(e,t,r)},r.prototype._setDefaultFixedFrustumShadowProjectionMatrix=function(t,r){var i=this.getScene().activeCamera;e.Matrix.OrthoLHToRef(this.shadowFrustumSize,this.shadowFrustumSize,void 0!==this.shadowMinZ?this.shadowMinZ:i.minZ,void 0!==this.shadowMaxZ?this.shadowMaxZ:i.maxZ,t)},r.prototype._setDefaultAutoExtendShadowProjectionMatrix=function(t,r,i){var n=this.getScene().activeCamera;if(this.autoUpdateExtends||this._orthoLeft===Number.MAX_VALUE){var o=e.Vector3.Zero();this._orthoLeft=Number.MAX_VALUE,this._orthoRight=Number.MIN_VALUE,this._orthoTop=Number.MIN_VALUE,this._orthoBottom=Number.MAX_VALUE;for(var s=0;sthis._orthoRight&&(this._orthoRight=o.x),o.y>this._orthoTop&&(this._orthoTop=o.y)}}}var h=this._orthoRight-this._orthoLeft,f=this._orthoTop-this._orthoBottom;e.Matrix.OrthoOffCenterLHToRef(this._orthoLeft-h*this.shadowOrthoScale,this._orthoRight+h*this.shadowOrthoScale,this._orthoBottom-f*this.shadowOrthoScale,this._orthoTop+f*this.shadowOrthoScale,void 0!==this.shadowMinZ?this.shadowMinZ:n.minZ,void 0!==this.shadowMaxZ?this.shadowMaxZ:n.maxZ,t)},r.prototype._buildUniformLayout=function(){this._uniformBuffer.addUniform("vLightData",4),this._uniformBuffer.addUniform("vLightDiffuse",4),this._uniformBuffer.addUniform("vLightSpecular",3),this._uniformBuffer.addUniform("shadowsInfo",3),this._uniformBuffer.addUniform("depthValues",2),this._uniformBuffer.create()},r.prototype.transferToEffect=function(e,t){return this.computeTransformedInformation()?(this._uniformBuffer.updateFloat4("vLightData",this.transformedDirection.x,this.transformedDirection.y,this.transformedDirection.z,1,t),this):(this._uniformBuffer.updateFloat4("vLightData",this.direction.x,this.direction.y,this.direction.z,1,t),this)},r.prototype.getDepthMinZ=function(e){return 1},r.prototype.getDepthMaxZ=function(e){return 1},r})(e.ShadowLight);__decorate([e.serialize()],t.prototype,"shadowFrustumSize",null),__decorate([e.serialize()],t.prototype,"shadowOrthoScale",null),__decorate([e.serialize()],t.prototype,"autoUpdateExtends",void 0),e.DirectionalLight=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(e,r,i,n,o,s){var a=t.call(this,e,s)||this;return a.position=r,a.direction=i,a.angle=n,a.exponent=o,a}return __extends(r,t),Object.defineProperty(r.prototype,"angle",{get:function(){return this._angle},set:function(e){this._angle=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"shadowAngleScale",{get:function(){return this._shadowAngleScale},set:function(e){this._shadowAngleScale=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),r.prototype.getClassName=function(){return"SpotLight"},r.prototype.getTypeID=function(){return e.Light.LIGHTTYPEID_SPOTLIGHT},r.prototype._setDefaultShadowProjectionMatrix=function(t,r,i){var n=this.getScene().activeCamera;this._shadowAngleScale=this._shadowAngleScale||1;var o=this._shadowAngleScale*this._angle;e.Matrix.PerspectiveFovLHToRef(o,1,this.getDepthMinZ(n),this.getDepthMaxZ(n),t)},r.prototype._buildUniformLayout=function(){this._uniformBuffer.addUniform("vLightData",4),this._uniformBuffer.addUniform("vLightDiffuse",4),this._uniformBuffer.addUniform("vLightSpecular",3),this._uniformBuffer.addUniform("vLightDirection",3),this._uniformBuffer.addUniform("shadowsInfo",3),this._uniformBuffer.addUniform("depthValues",2),this._uniformBuffer.create()},r.prototype.transferToEffect=function(t,r){var i;return this.computeTransformedInformation()?(this._uniformBuffer.updateFloat4("vLightData",this.transformedPosition.x,this.transformedPosition.y,this.transformedPosition.z,this.exponent,r),i=e.Vector3.Normalize(this.transformedDirection)):(this._uniformBuffer.updateFloat4("vLightData",this.position.x,this.position.y,this.position.z,this.exponent,r),i=e.Vector3.Normalize(this.direction)),this._uniformBuffer.updateFloat4("vLightDirection",i.x,i.y,i.z,Math.cos(.5*this.angle),r),this},r})(e.ShadowLight) +;__decorate([e.serialize()],t.prototype,"angle",null),__decorate([e.serialize()],t.prototype,"shadowAngleScale",null),__decorate([e.serialize()],t.prototype,"exponent",void 0),e.SpotLight=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(e,r){var i=t.call(this,e,r,!0)||this;return r.multiMaterials.push(i),i.subMaterials=new Array,i.storeEffectOnSubMeshes=!0,i}return __extends(r,t),Object.defineProperty(r.prototype,"subMaterials",{get:function(){return this._subMaterials},set:function(e){this._subMaterials=e,this._hookArray(e)},enumerable:!0,configurable:!0}),r.prototype._hookArray=function(e){var t=this,r=e.push;e.push=function(){for(var i=[],n=0;n=this.subMaterials.length?this.getScene().defaultMaterial:this.subMaterials[e]},r.prototype.getActiveTextures=function(){return(e=t.prototype.getActiveTextures.call(this)).concat.apply(e,this.subMaterials.map((function(e){return e.getActiveTextures()})));var e},r.prototype.getClassName=function(){return"MultiMaterial"},r.prototype.isReadyForSubMesh=function(e,t,r){for(var i=0;i=0&&i.multiMaterials.splice(n,1),t.prototype.dispose.call(this,e,r)}},r})(e.Material);e.MultiMaterial=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(e){function t(){var t=e.call(this)||this;return t.PBR=!0,t.MAINUV1=!1,t.MAINUV2=!1,t.UV1=!1,t.UV2=!1,t.ALBEDO=!1,t.ALBEDODIRECTUV=0,t.VERTEXCOLOR=!1,t.AMBIENT=!1,t.AMBIENTDIRECTUV=0,t.AMBIENTINGRAYSCALE=!1,t.OPACITY=!1,t.VERTEXALPHA=!1,t.OPACITYDIRECTUV=0,t.OPACITYRGB=!1,t.ALPHATEST=!1,t.ALPHABLEND=!1,t.ALPHAFROMALBEDO=!1,t.ALPHATESTVALUE=.5,t.SPECULAROVERALPHA=!1,t.RADIANCEOVERALPHA=!1,t.ALPHAFRESNEL=!1,t.PREMULTIPLYALPHA=!1,t.EMISSIVE=!1,t.EMISSIVEDIRECTUV=0,t.REFLECTIVITY=!1,t.REFLECTIVITYDIRECTUV=0,t.SPECULARTERM=!1,t.MICROSURFACEFROMREFLECTIVITYMAP=!1,t.MICROSURFACEAUTOMATIC=!1,t.LODBASEDMICROSFURACE=!1,t.MICROSURFACEMAP=!1,t.MICROSURFACEMAPDIRECTUV=0,t.METALLICWORKFLOW=!1,t.ROUGHNESSSTOREINMETALMAPALPHA=!1,t.ROUGHNESSSTOREINMETALMAPGREEN=!1,t.METALLNESSSTOREINMETALMAPBLUE=!1,t.AOSTOREINMETALMAPRED=!1,t.ENVIRONMENTBRDF=!1,t.NORMAL=!1,t.TANGENT=!1,t.BUMP=!1,t.BUMPDIRECTUV=0,t.PARALLAX=!1,t.PARALLAXOCCLUSION=!1,t.NORMALXYSCALE=!0,t.LIGHTMAP=!1,t.LIGHTMAPDIRECTUV=0,t.USELIGHTMAPASSHADOWMAP=!1,t.REFLECTION=!1,t.REFLECTIONMAP_3D=!1,t.REFLECTIONMAP_SPHERICAL=!1,t.REFLECTIONMAP_PLANAR=!1,t.REFLECTIONMAP_CUBIC=!1,t.REFLECTIONMAP_PROJECTION=!1,t.REFLECTIONMAP_SKYBOX=!1,t.REFLECTIONMAP_EXPLICIT=!1,t.REFLECTIONMAP_EQUIRECTANGULAR=!1,t.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,t.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,t.INVERTCUBICMAP=!1,t.USESPHERICALFROMREFLECTIONMAP=!1,t.USESPHERICALINFRAGMENT=!1,t.REFLECTIONMAP_OPPOSITEZ=!1,t.LODINREFLECTIONALPHA=!1,t.GAMMAREFLECTION=!1,t.REFRACTION=!1,t.REFRACTIONMAP_3D=!1,t.REFRACTIONMAP_OPPOSITEZ=!1,t.LODINREFRACTIONALPHA=!1,t.GAMMAREFRACTION=!1,t.LINKREFRACTIONTOTRANSPARENCY=!1,t.INSTANCES=!1,t.NUM_BONE_INFLUENCERS=0,t.BonesPerMesh=0,t.MORPHTARGETS=!1,t.MORPHTARGETS_NORMAL=!1,t.MORPHTARGETS_TANGENT=!1,t.NUM_MORPH_INFLUENCERS=0,t.IMAGEPROCESSING=!1,t.VIGNETTE=!1,t.VIGNETTEBLENDMODEMULTIPLY=!1,t.VIGNETTEBLENDMODEOPAQUE=!1,t.TONEMAPPING=!1,t.CONTRAST=!1,t.COLORCURVES=!1,t.COLORGRADING=!1,t.SAMPLER3DGREENDEPTH=!1,t.SAMPLER3DBGRMAP=!1,t.IMAGEPROCESSINGPOSTPROCESS=!1,t.EXPOSURE=!1,t.USEPHYSICALLIGHTFALLOFF=!1,t.TWOSIDEDLIGHTING=!1,t.SHADOWFLOAT=!1,t.USERIGHTHANDEDSYSTEM=!1,t.CLIPPLANE=!1,t.POINTSIZE=!1,t.FOG=!1,t.LOGARITHMICDEPTH=!1,t.FORCENORMALFORWARD=!1,t.rebuild(),t}return __extends(t,e),t.prototype.reset=function(){e.prototype.reset.call(this),this.ALPHATESTVALUE=.5,this.PBR=!0},t})(e.MaterialDefines),r=(function(r){function i(t,i){var n=r.call(this,t,i)||this;return n._directIntensity=1,n._emissiveIntensity=1,n._environmentIntensity=1,n._specularIntensity=1,n._lightingInfos=new e.Vector4(n._directIntensity,n._emissiveIntensity,n._environmentIntensity,n._specularIntensity),n._disableBumpMap=!1,n._ambientTextureStrength=1,n._ambientColor=new e.Color3(0,0,0),n._albedoColor=new e.Color3(1,1,1),n._reflectivityColor=new e.Color3(1,1,1),n._reflectionColor=new e.Color3(1,1,1),n._emissiveColor=new e.Color3(0,0,0),n._microSurface=.9,n._indexOfRefraction=.66,n._invertRefractionY=!1,n._linkRefractionWithTransparency=!1,n._useLightmapAsShadowmap=!1,n._useAlphaFromAlbedoTexture=!1,n._useSpecularOverAlpha=!0,n._useMicroSurfaceFromReflectivityMapAlpha=!1,n._useRoughnessFromMetallicTextureAlpha=!0,n._useRoughnessFromMetallicTextureGreen=!1,n._useMetallnessFromMetallicTextureBlue=!1,n._useAmbientOcclusionFromMetallicTextureRed=!1,n._useAmbientInGrayScale=!1,n._useAutoMicroSurfaceFromReflectivityMap=!1,n._usePhysicalLightFalloff=!0,n._useRadianceOverAlpha=!0,n._useParallax=!1,n._useParallaxOcclusion=!1,n._parallaxScaleBias=.05,n._disableLighting=!1,n._maxSimultaneousLights=4,n._invertNormalMapX=!1,n._invertNormalMapY=!1,n._twoSidedLighting=!1,n._alphaCutOff=.4,n._forceAlphaTest=!1,n._preMultiplyAlpha=!1,n._useAlphaFresnel=!1,n._environmentBRDFTexture=null,n._forceIrradianceInFragment=!1,n._forceNormalForward=!1,n._renderTargets=new e.SmartArray(16),n._worldViewProjectionMatrix=e.Matrix.Zero(),n._globalAmbientColor=new e.Color3(0,0,0),n._tempColor=new e.Color3,n._attachImageProcessingConfiguration(null),n.getRenderTargetTextures=function(){return n._renderTargets.reset(),e.StandardMaterial.ReflectionTextureEnabled&&n._reflectionTexture&&n._reflectionTexture.isRenderTarget&&n._renderTargets.push(n._reflectionTexture),e.StandardMaterial.RefractionTextureEnabled&&n._refractionTexture&&n._refractionTexture.isRenderTarget&&n._renderTargets.push(n._refractionTexture),n._renderTargets},n._environmentBRDFTexture=e.TextureTools.GetEnvironmentBRDFTexture(i),n}return __extends(i,r),i.prototype._attachImageProcessingConfiguration=function(e){var t=this;e!==this._imageProcessingConfiguration&&(this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),this._imageProcessingConfiguration=e||this.getScene().imageProcessingConfiguration,this._imageProcessingObserver=this._imageProcessingConfiguration.onUpdateParameters.add((function(e){t._markAllSubMeshesAsImageProcessingDirty()})))},i.prototype.getClassName=function(){return"PBRBaseMaterial"},Object.defineProperty(i.prototype,"useLogarithmicDepth",{get:function(){return this._useLogarithmicDepth},set:function(e){this._useLogarithmicDepth=e&&this.getScene().getEngine().getCaps().fragmentDepthSupported},enumerable:!0,configurable:!0}),i.prototype.needAlphaBlending=function(){return!this._linkRefractionWithTransparency&&(this.alpha<1||null!=this._opacityTexture||this._shouldUseAlphaFromAlbedoTexture())},i.prototype.needAlphaTesting=function(){return!!this._forceAlphaTest||!this._linkRefractionWithTransparency&&(null!=this._albedoTexture&&this._albedoTexture.hasAlpha)},i.prototype._shouldUseAlphaFromAlbedoTexture=function(){return null!=this._albedoTexture&&this._albedoTexture.hasAlpha&&this._useAlphaFromAlbedoTexture},i.prototype.getAlphaTestTexture=function(){return this._albedoTexture},i.prototype.isReadyForSubMesh=function(r,i,n){if(this.isFrozen&&this._wasPreviouslyReady)return!0;i._materialDefines||(i._materialDefines=new t);var o=this.getScene(),s=i._materialDefines;if(!this.checkReadyOnEveryCall&&i.effect&&s._renderId===o.getRenderId())return!0;var a=o.getEngine();if(e.MaterialHelper.PrepareDefinesForLights(o,r,s,!0,this._maxSimultaneousLights,this._disableLighting),s._needNormals=!0,s._areTexturesDirty){if(s._needUVs=!1,o.texturesEnabled){if(o.getEngine().getCaps().textureLOD&&(s.LODBASEDMICROSFURACE=!0),this._albedoTexture&&e.StandardMaterial.DiffuseTextureEnabled){if(!this._albedoTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._albedoTexture,s,"ALBEDO")}else s.ALBEDO=!1;if(this._ambientTexture&&e.StandardMaterial.AmbientTextureEnabled){if(!this._ambientTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._ambientTexture,s,"AMBIENT"),s.AMBIENTINGRAYSCALE=this._useAmbientInGrayScale}else s.AMBIENT=!1;if(this._opacityTexture&&e.StandardMaterial.OpacityTextureEnabled){if(!this._opacityTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._opacityTexture,s,"OPACITY"),s.OPACITYRGB=this._opacityTexture.getAlphaFromRGB}else s.OPACITY=!1;var u=this._getReflectionTexture();if(u&&e.StandardMaterial.ReflectionTextureEnabled){if(!u.isReadyOrNotBlocking())return!1;switch(s.REFLECTION=!0,s.GAMMAREFLECTION=u.gammaSpace,s.REFLECTIONMAP_OPPOSITEZ=this.getScene().useRightHandedSystem?!u.invertZ:u.invertZ,s.LODINREFLECTIONALPHA=u.lodLevelInAlpha,u.coordinatesMode===e.Texture.INVCUBIC_MODE&&(s.INVERTCUBICMAP=!0),s.REFLECTIONMAP_3D=u.isCube,u.coordinatesMode){case e.Texture.CUBIC_MODE:case e.Texture.INVCUBIC_MODE:s.REFLECTIONMAP_CUBIC=!0;break;case e.Texture.EXPLICIT_MODE:s.REFLECTIONMAP_EXPLICIT=!0;break;case e.Texture.PLANAR_MODE:s.REFLECTIONMAP_PLANAR=!0;break;case e.Texture.PROJECTION_MODE:s.REFLECTIONMAP_PROJECTION=!0;break;case e.Texture.SKYBOX_MODE:s.REFLECTIONMAP_SKYBOX=!0;break;case e.Texture.SPHERICAL_MODE:s.REFLECTIONMAP_SPHERICAL=!0;break;case e.Texture.EQUIRECTANGULAR_MODE:s.REFLECTIONMAP_EQUIRECTANGULAR=!0;break;case e.Texture.FIXED_EQUIRECTANGULAR_MODE:s.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!0;break;case e.Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:s.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!0}u.coordinatesMode!==e.Texture.SKYBOX_MODE&&u.sphericalPolynomial&&(s.USESPHERICALFROMREFLECTIONMAP=!0,(this._forceIrradianceInFragment||o.getEngine().getCaps().maxVaryingVectors<=8)&&(s.USESPHERICALINFRAGMENT=!0))}else s.REFLECTION=!1,s.REFLECTIONMAP_3D=!1,s.REFLECTIONMAP_SPHERICAL=!1,s.REFLECTIONMAP_PLANAR=!1,s.REFLECTIONMAP_CUBIC=!1,s.REFLECTIONMAP_PROJECTION=!1,s.REFLECTIONMAP_SKYBOX=!1,s.REFLECTIONMAP_EXPLICIT=!1,s.REFLECTIONMAP_EQUIRECTANGULAR=!1,s.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,s.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,s.INVERTCUBICMAP=!1,s.USESPHERICALFROMREFLECTIONMAP=!1,s.USESPHERICALINFRAGMENT=!1,s.REFLECTIONMAP_OPPOSITEZ=!1,s.LODINREFLECTIONALPHA=!1,s.GAMMAREFLECTION=!1;if(this._lightmapTexture&&e.StandardMaterial.LightmapTextureEnabled){if(!this._lightmapTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._lightmapTexture,s,"LIGHTMAP"),s.USELIGHTMAPASSHADOWMAP=this._useLightmapAsShadowmap}else s.LIGHTMAP=!1;if(this._emissiveTexture&&e.StandardMaterial.EmissiveTextureEnabled){if(!this._emissiveTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._emissiveTexture,s,"EMISSIVE")}else s.EMISSIVE=!1;if(e.StandardMaterial.SpecularTextureEnabled){if(this._metallicTexture){if(!this._metallicTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._metallicTexture,s,"REFLECTIVITY"),s.METALLICWORKFLOW=!0,s.ROUGHNESSSTOREINMETALMAPALPHA=this._useRoughnessFromMetallicTextureAlpha,s.ROUGHNESSSTOREINMETALMAPGREEN=!this._useRoughnessFromMetallicTextureAlpha&&this._useRoughnessFromMetallicTextureGreen,s.METALLNESSSTOREINMETALMAPBLUE=this._useMetallnessFromMetallicTextureBlue,s.AOSTOREINMETALMAPRED=this._useAmbientOcclusionFromMetallicTextureRed}else if(this._reflectivityTexture){if(!this._reflectivityTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._reflectivityTexture,s,"REFLECTIVITY"),s.MICROSURFACEFROMREFLECTIVITYMAP=this._useMicroSurfaceFromReflectivityMapAlpha,s.MICROSURFACEAUTOMATIC=this._useAutoMicroSurfaceFromReflectivityMap}else s.REFLECTIVITY=!1;if(this._microSurfaceTexture){if(!this._microSurfaceTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._microSurfaceTexture,s,"MICROSURFACEMAP")}else s.MICROSURFACEMAP=!1}else s.REFLECTIVITY=!1,s.MICROSURFACEMAP=!1;if(o.getEngine().getCaps().standardDerivatives&&this._bumpTexture&&e.StandardMaterial.BumpTextureEnabled&&!this._disableBumpMap){if(!this._bumpTexture.isReady())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._bumpTexture,s,"BUMP"),this._useParallax&&this._albedoTexture&&e.StandardMaterial.DiffuseTextureEnabled?(s.PARALLAX=!0,s.PARALLAXOCCLUSION=!!this._useParallaxOcclusion):s.PARALLAX=!1,s.USERIGHTHANDEDSYSTEM=o.useRightHandedSystem}else s.BUMP=!1;var l=this._getRefractionTexture();if(l&&e.StandardMaterial.RefractionTextureEnabled){if(!l.isReadyOrNotBlocking())return!1;s.REFRACTION=!0,s.REFRACTIONMAP_3D=l.isCube,s.GAMMAREFRACTION=l.gammaSpace,s.REFRACTIONMAP_OPPOSITEZ=u.invertZ,s.LODINREFRACTIONALPHA=u.lodLevelInAlpha,this._linkRefractionWithTransparency&&(s.LINKREFRACTIONTOTRANSPARENCY=!0)}else s.REFRACTION=!1;if(this._environmentBRDFTexture&&e.StandardMaterial.ReflectionTextureEnabled){if(!this._environmentBRDFTexture.isReady())return!1;s.ENVIRONMENTBRDF=!0}this._shouldUseAlphaFromAlbedoTexture()&&(s.ALPHAFROMALBEDO=!0)}this._useSpecularOverAlpha&&(s.SPECULAROVERALPHA=!0),this._usePhysicalLightFalloff&&(s.USEPHYSICALLIGHTFALLOFF=!0),this._useRadianceOverAlpha&&(s.RADIANCEOVERALPHA=!0),(void 0!==this._metallic&&null!==this._metallic||void 0!==this._roughness&&null!==this._roughness)&&(s.METALLICWORKFLOW=!0),!this.backFaceCulling&&this._twoSidedLighting&&(s.TWOSIDEDLIGHTING=!0),s.ALPHATESTVALUE=this._alphaCutOff,s.PREMULTIPLYALPHA=this._preMultiplyAlpha,s.ALPHABLEND=this.needAlphaBlending(),s.ALPHAFRESNEL=this._useAlphaFresnel}if(s._areImageProcessingDirty){if(!this._imageProcessingConfiguration.isReady())return!1;this._imageProcessingConfiguration.prepareDefines(s)}if(s.FORCENORMALFORWARD=this._forceNormalForward,e.MaterialHelper.PrepareDefinesForMisc(r,o,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,s),e.MaterialHelper.PrepareDefinesForFrameBoundValues(o,a,s,n,this._forceAlphaTest),e.MaterialHelper.PrepareDefinesForAttributes(r,s,!0,!0,!0)&&r&&(o.getEngine().getCaps().standardDerivatives||r.isVerticesDataPresent(e.VertexBuffer.NormalKind)||(r.createNormals(!0),e.Tools.Warn("PBRMaterial: Normals have been created for the mesh: "+r.name))),s.isDirty){s.markAsProcessed(),o.resetCachedMaterial();var c=new e.EffectFallbacks;s.ENVIRONMENTBRDF&&c.addFallback(0,"ENVIRONMENTBRDF"),s.REFLECTION&&c.addFallback(0,"REFLECTION"),s.REFRACTION&&c.addFallback(0,"REFRACTION"),s.REFLECTIVITY&&c.addFallback(0,"REFLECTIVITY"),s.BUMP&&c.addFallback(0,"BUMP"),s.PARALLAX&&c.addFallback(1,"PARALLAX"),s.PARALLAXOCCLUSION&&c.addFallback(0,"PARALLAXOCCLUSION"),s.SPECULAROVERALPHA&&c.addFallback(0,"SPECULAROVERALPHA"),s.FOG&&c.addFallback(1,"FOG"),s.POINTSIZE&&c.addFallback(0,"POINTSIZE"),s.LOGARITHMICDEPTH&&c.addFallback(0,"LOGARITHMICDEPTH"),e.MaterialHelper.HandleFallbacksForShadows(s,c,this._maxSimultaneousLights),s.SPECULARTERM&&c.addFallback(0,"SPECULARTERM"),s.NUM_BONE_INFLUENCERS>0&&c.addCPUSkinningFallback(0,r);var h=[e.VertexBuffer.PositionKind];s.NORMAL&&h.push(e.VertexBuffer.NormalKind),s.TANGENT&&h.push(e.VertexBuffer.TangentKind),s.UV1&&h.push(e.VertexBuffer.UVKind),s.UV2&&h.push(e.VertexBuffer.UV2Kind),s.VERTEXCOLOR&&h.push(e.VertexBuffer.ColorKind),e.MaterialHelper.PrepareAttributesForBones(h,r,s,c),e.MaterialHelper.PrepareAttributesForInstances(h,s),e.MaterialHelper.PrepareAttributesForMorphTargets(h,r,s);var f=["world","view","viewProjection","vEyePosition","vLightsType","vAmbientColor","vAlbedoColor","vReflectivityColor","vEmissiveColor","vReflectionColor","vFogInfos","vFogColor","pointSize","vAlbedoInfos","vAmbientInfos","vOpacityInfos","vReflectionInfos","vEmissiveInfos","vReflectivityInfos","vMicroSurfaceSamplerInfos","vBumpInfos","vLightmapInfos","vRefractionInfos","mBones","vClipPlane","albedoMatrix","ambientMatrix","opacityMatrix","reflectionMatrix","emissiveMatrix","reflectivityMatrix","microSurfaceSamplerMatrix","bumpMatrix","lightmapMatrix","refractionMatrix","vLightingIntensity","logarithmicDepthConstant","vSphericalX","vSphericalY","vSphericalZ","vSphericalXX","vSphericalYY","vSphericalZZ","vSphericalXY","vSphericalYZ","vSphericalZX","vReflectionMicrosurfaceInfos","vRefractionMicrosurfaceInfos","vNormalReoderParams"],d=["albedoSampler","reflectivitySampler","ambientSampler","emissiveSampler","bumpSampler","lightmapSampler","opacitySampler","refractionSampler","refractionSamplerLow","refractionSamplerHigh","reflectionSampler","reflectionSamplerLow","reflectionSamplerHigh","microSurfaceSampler","environmentBrdfSampler"],p=["Material","Scene"];e.ImageProcessingConfiguration.PrepareUniforms(f,s),e.ImageProcessingConfiguration.PrepareSamplers(d,s),e.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:f,uniformBuffersNames:p,samplers:d,defines:s,maxSimultaneousLights:this._maxSimultaneousLights});var g=function(e){this.onCompiled&&this.onCompiled(e),this.bindSceneUniformBuffer(e,o.getSceneUniformBuffer())}.bind(this),_=s.toString();i.setEffect(o.getEngine().createEffect("pbr",{attributes:h,uniformsNames:f,uniformBuffersNames:p,samplers:d,defines:_,fallbacks:c,onCompiled:g,onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights,maxSimultaneousMorphTargets:s.NUM_MORPH_INFLUENCERS}},a),s),this.buildUniformLayout()}return!!i.effect.isReady()&&(s._renderId=o.getRenderId(),this._wasPreviouslyReady=!0,!0)},i.prototype.buildUniformLayout=function(){this._uniformBuffer.addUniform("vAlbedoInfos",2),this._uniformBuffer.addUniform("vAmbientInfos",3),this._uniformBuffer.addUniform("vOpacityInfos",2),this._uniformBuffer.addUniform("vEmissiveInfos",2),this._uniformBuffer.addUniform("vLightmapInfos",2),this._uniformBuffer.addUniform("vReflectivityInfos",3),this._uniformBuffer.addUniform("vMicroSurfaceSamplerInfos",2),this._uniformBuffer.addUniform("vRefractionInfos",4),this._uniformBuffer.addUniform("vReflectionInfos",2),this._uniformBuffer.addUniform("vBumpInfos",3),this._uniformBuffer.addUniform("albedoMatrix",16),this._uniformBuffer.addUniform("ambientMatrix",16),this._uniformBuffer.addUniform("opacityMatrix",16),this._uniformBuffer.addUniform("emissiveMatrix",16),this._uniformBuffer.addUniform("lightmapMatrix",16),this._uniformBuffer.addUniform("reflectivityMatrix",16),this._uniformBuffer.addUniform("microSurfaceSamplerMatrix",16),this._uniformBuffer.addUniform("bumpMatrix",16),this._uniformBuffer.addUniform("vNormalReoderParams",4),this._uniformBuffer.addUniform("refractionMatrix",16),this._uniformBuffer.addUniform("reflectionMatrix",16),this._uniformBuffer.addUniform("vReflectionColor",3),this._uniformBuffer.addUniform("vAlbedoColor",4),this._uniformBuffer.addUniform("vLightingIntensity",4),this._uniformBuffer.addUniform("vRefractionMicrosurfaceInfos",3),this._uniformBuffer.addUniform("vReflectionMicrosurfaceInfos",3),this._uniformBuffer.addUniform("vReflectivityColor",4),this._uniformBuffer.addUniform("vEmissiveColor",3),this._uniformBuffer.addUniform("pointSize",1),this._uniformBuffer.create()},i.prototype.unbind=function(){this._reflectionTexture&&this._reflectionTexture.isRenderTarget&&this._uniformBuffer.setTexture("reflectionSampler",null),this._refractionTexture&&this._refractionTexture.isRenderTarget&&this._uniformBuffer.setTexture("refractionSampler",null),r.prototype.unbind.call(this)},i.prototype.bindOnlyWorldMatrix=function(e){this._activeEffect.setMatrix("world",e)},i.prototype.bindForSubMesh=function(t,r,i){var n=this.getScene(),o=i._materialDefines;if(o){var s=i.effect;if(this._activeEffect=s,this.bindOnlyWorldMatrix(t),e.MaterialHelper.BindBonesParameters(r,this._activeEffect),this._mustRebind(n,s,r.visibility)){if(this._uniformBuffer.bindToEffect(s,"Material"),this.bindViewProjection(s),!this._uniformBuffer.useUbo||!this.isFrozen||!this._uniformBuffer.isSync){if(n.texturesEnabled){this._albedoTexture&&e.StandardMaterial.DiffuseTextureEnabled&&(this._uniformBuffer.updateFloat2("vAlbedoInfos",this._albedoTexture.coordinatesIndex,this._albedoTexture.level),e.MaterialHelper.BindTextureMatrix(this._albedoTexture,this._uniformBuffer,"albedo")),this._ambientTexture&&e.StandardMaterial.AmbientTextureEnabled&&(this._uniformBuffer.updateFloat3("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level,this._ambientTextureStrength),e.MaterialHelper.BindTextureMatrix(this._ambientTexture,this._uniformBuffer,"ambient")),this._opacityTexture&&e.StandardMaterial.OpacityTextureEnabled&&(this._uniformBuffer.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),e.MaterialHelper.BindTextureMatrix(this._opacityTexture,this._uniformBuffer,"opacity"));var a=this._getReflectionTexture();if(a&&e.StandardMaterial.ReflectionTextureEnabled){if(this._uniformBuffer.updateMatrix("reflectionMatrix",a.getReflectionTextureMatrix()),this._uniformBuffer.updateFloat2("vReflectionInfos",a.level,0),o.USESPHERICALFROMREFLECTIONMAP){var u=a.sphericalPolynomial;this._activeEffect.setFloat3("vSphericalX",u.x.x,u.x.y,u.x.z),this._activeEffect.setFloat3("vSphericalY",u.y.x,u.y.y,u.y.z),this._activeEffect.setFloat3("vSphericalZ",u.z.x,u.z.y,u.z.z),this._activeEffect.setFloat3("vSphericalXX_ZZ",u.xx.x-u.zz.x,u.xx.y-u.zz.y,u.xx.z-u.zz.z),this._activeEffect.setFloat3("vSphericalYY_ZZ",u.yy.x-u.zz.x,u.yy.y-u.zz.y,u.yy.z-u.zz.z),this._activeEffect.setFloat3("vSphericalZZ",u.zz.x,u.zz.y,u.zz.z),this._activeEffect.setFloat3("vSphericalXY",u.xy.x,u.xy.y,u.xy.z),this._activeEffect.setFloat3("vSphericalYZ",u.yz.x,u.yz.y,u.yz.z),this._activeEffect.setFloat3("vSphericalZX",u.zx.x,u.zx.y,u.zx.z)}this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos",a.getSize().width,a.lodGenerationScale,a.lodGenerationOffset)}this._emissiveTexture&&e.StandardMaterial.EmissiveTextureEnabled&&(this._uniformBuffer.updateFloat2("vEmissiveInfos",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),e.MaterialHelper.BindTextureMatrix(this._emissiveTexture,this._uniformBuffer,"emissive")),this._lightmapTexture&&e.StandardMaterial.LightmapTextureEnabled&&(this._uniformBuffer.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),e.MaterialHelper.BindTextureMatrix(this._lightmapTexture,this._uniformBuffer,"lightmap")),e.StandardMaterial.SpecularTextureEnabled&&(this._metallicTexture?(this._uniformBuffer.updateFloat3("vReflectivityInfos",this._metallicTexture.coordinatesIndex,this._metallicTexture.level,this._ambientTextureStrength),e.MaterialHelper.BindTextureMatrix(this._metallicTexture,this._uniformBuffer,"reflectivity")):this._reflectivityTexture&&(this._uniformBuffer.updateFloat3("vReflectivityInfos",this._reflectivityTexture.coordinatesIndex,this._reflectivityTexture.level,1),e.MaterialHelper.BindTextureMatrix(this._reflectivityTexture,this._uniformBuffer,"reflectivity")),this._microSurfaceTexture&&(this._uniformBuffer.updateFloat2("vMicroSurfaceSamplerInfos",this._microSurfaceTexture.coordinatesIndex,this._microSurfaceTexture.level),e.MaterialHelper.BindTextureMatrix(this._microSurfaceTexture,this._uniformBuffer,"microSurfaceSampler"))),this._bumpTexture&&n.getEngine().getCaps().standardDerivatives&&e.StandardMaterial.BumpTextureEnabled&&!this._disableBumpMap&&(this._uniformBuffer.updateFloat3("vBumpInfos",this._bumpTexture.coordinatesIndex,this._bumpTexture.level,this._parallaxScaleBias),e.MaterialHelper.BindTextureMatrix(this._bumpTexture,this._uniformBuffer,"bump"),n._mirroredCameraPosition?this._uniformBuffer.updateFloat4("vNormalReoderParams",this._invertNormalMapX?0:1,this._invertNormalMapX?1:-1,this._invertNormalMapY?0:1,this._invertNormalMapY?1:-1):this._uniformBuffer.updateFloat4("vNormalReoderParams",this._invertNormalMapX?1:0,this._invertNormalMapX?-1:1,this._invertNormalMapY?1:0,this._invertNormalMapY?-1:1));var l=this._getRefractionTexture();if(l&&e.StandardMaterial.RefractionTextureEnabled){this._uniformBuffer.updateMatrix("refractionMatrix",l.getReflectionTextureMatrix());var c=1;l.isCube||l.depth&&(c=l.depth),this._uniformBuffer.updateFloat4("vRefractionInfos",l.level,this._indexOfRefraction,c,this._invertRefractionY?-1:1),this._uniformBuffer.updateFloat3("vRefractionMicrosurfaceInfos",l.getSize().width,l.lodGenerationScale,l.lodGenerationOffset)}}this.pointsCloud&&this._uniformBuffer.updateFloat("pointSize",this.pointSize),o.METALLICWORKFLOW?(e.PBRMaterial._scaledReflectivity.r=void 0===this._metallic||null===this._metallic?1:this._metallic,e.PBRMaterial._scaledReflectivity.g=void 0===this._roughness||null===this._roughness?1:this._roughness,this._uniformBuffer.updateColor4("vReflectivityColor",e.PBRMaterial._scaledReflectivity,0)):this._uniformBuffer.updateColor4("vReflectivityColor",this._reflectivityColor,this._microSurface),this._uniformBuffer.updateColor3("vEmissiveColor",this._emissiveColor),this._uniformBuffer.updateColor3("vReflectionColor",this._reflectionColor),this._uniformBuffer.updateColor4("vAlbedoColor",this._albedoColor,this.alpha*r.visibility),this._lightingInfos.x=this._directIntensity,this._lightingInfos.y=this._emissiveIntensity,this._lightingInfos.z=this._environmentIntensity,this._lightingInfos.w=this._specularIntensity,this._uniformBuffer.updateVector4("vLightingIntensity",this._lightingInfos)}n.texturesEnabled&&(this._albedoTexture&&e.StandardMaterial.DiffuseTextureEnabled&&this._uniformBuffer.setTexture("albedoSampler",this._albedoTexture),this._ambientTexture&&e.StandardMaterial.AmbientTextureEnabled&&this._uniformBuffer.setTexture("ambientSampler",this._ambientTexture),this._opacityTexture&&e.StandardMaterial.OpacityTextureEnabled&&this._uniformBuffer.setTexture("opacitySampler",this._opacityTexture),a&&e.StandardMaterial.ReflectionTextureEnabled&&(o.LODBASEDMICROSFURACE?this._uniformBuffer.setTexture("reflectionSampler",a):(this._uniformBuffer.setTexture("reflectionSampler",a._lodTextureMid||a),this._uniformBuffer.setTexture("reflectionSamplerLow",a._lodTextureLow||a),this._uniformBuffer.setTexture("reflectionSamplerHigh",a._lodTextureHigh||a))),o.ENVIRONMENTBRDF&&this._uniformBuffer.setTexture("environmentBrdfSampler",this._environmentBRDFTexture),l&&e.StandardMaterial.RefractionTextureEnabled&&(o.LODBASEDMICROSFURACE?this._uniformBuffer.setTexture("refractionSampler",l):(this._uniformBuffer.setTexture("refractionSampler",l._lodTextureMid||l),this._uniformBuffer.setTexture("refractionSamplerLow",l._lodTextureLow||l),this._uniformBuffer.setTexture("refractionSamplerHigh",l._lodTextureHigh||l))),this._emissiveTexture&&e.StandardMaterial.EmissiveTextureEnabled&&this._uniformBuffer.setTexture("emissiveSampler",this._emissiveTexture),this._lightmapTexture&&e.StandardMaterial.LightmapTextureEnabled&&this._uniformBuffer.setTexture("lightmapSampler",this._lightmapTexture),e.StandardMaterial.SpecularTextureEnabled&&(this._metallicTexture?this._uniformBuffer.setTexture("reflectivitySampler",this._metallicTexture):this._reflectivityTexture&&this._uniformBuffer.setTexture("reflectivitySampler",this._reflectivityTexture),this._microSurfaceTexture&&this._uniformBuffer.setTexture("microSurfaceSampler",this._microSurfaceTexture)),this._bumpTexture&&n.getEngine().getCaps().standardDerivatives&&e.StandardMaterial.BumpTextureEnabled&&!this._disableBumpMap&&this._uniformBuffer.setTexture("bumpSampler",this._bumpTexture)),e.MaterialHelper.BindClipPlane(this._activeEffect,n),n.ambientColor.multiplyToRef(this._ambientColor,this._globalAmbientColor);var h=n._mirroredCameraPosition?n._mirroredCameraPosition:n.activeCamera.globalPosition;s.setFloat4("vEyePosition",h.x,h.y,h.z,n._mirroredCameraPosition?-1:1),s.setColor3("vAmbientColor",this._globalAmbientColor)}!this._mustRebind(n,s)&&this.isFrozen||(n.lightsEnabled&&!this._disableLighting&&e.MaterialHelper.BindLights(n,r,this._activeEffect,o,this._maxSimultaneousLights,this._usePhysicalLightFalloff),(n.fogEnabled&&r.applyFog&&n.fogMode!==e.Scene.FOGMODE_NONE||a)&&this.bindView(s),e.MaterialHelper.BindFogParameters(n,r,this._activeEffect),o.NUM_MORPH_INFLUENCERS&&e.MaterialHelper.BindMorphTargetParameters(r,this._activeEffect),this._imageProcessingConfiguration.bind(this._activeEffect),e.MaterialHelper.BindLogDepth(o,this._activeEffect,n)),this._uniformBuffer.update(),this._afterBind(r),n=null}},i.prototype.getAnimatables=function(){var e=[];return this._albedoTexture&&this._albedoTexture.animations&&this._albedoTexture.animations.length>0&&e.push(this._albedoTexture),this._ambientTexture&&this._ambientTexture.animations&&this._ambientTexture.animations.length>0&&e.push(this._ambientTexture),this._opacityTexture&&this._opacityTexture.animations&&this._opacityTexture.animations.length>0&&e.push(this._opacityTexture),this._reflectionTexture&&this._reflectionTexture.animations&&this._reflectionTexture.animations.length>0&&e.push(this._reflectionTexture),this._emissiveTexture&&this._emissiveTexture.animations&&this._emissiveTexture.animations.length>0&&e.push(this._emissiveTexture),this._metallicTexture&&this._metallicTexture.animations&&this._metallicTexture.animations.length>0?e.push(this._metallicTexture):this._reflectivityTexture&&this._reflectivityTexture.animations&&this._reflectivityTexture.animations.length>0&&e.push(this._reflectivityTexture),this._bumpTexture&&this._bumpTexture.animations&&this._bumpTexture.animations.length>0&&e.push(this._bumpTexture),this._lightmapTexture&&this._lightmapTexture.animations&&this._lightmapTexture.animations.length>0&&e.push(this._lightmapTexture),this._refractionTexture&&this._refractionTexture.animations&&this._refractionTexture.animations.length>0&&e.push(this._refractionTexture),e},i.prototype._getReflectionTexture=function(){return this._reflectionTexture?this._reflectionTexture:this.getScene().environmentTexture},i.prototype._getRefractionTexture=function(){return this._refractionTexture?this._refractionTexture:this._linkRefractionWithTransparency?this.getScene().environmentTexture:null},i.prototype.dispose=function(e,t){t&&(this._albedoTexture&&this._albedoTexture.dispose(),this._ambientTexture&&this._ambientTexture.dispose(),this._opacityTexture&&this._opacityTexture.dispose(),this._reflectionTexture&&this._reflectionTexture.dispose(),this._environmentBRDFTexture&&this._environmentBRDFTexture.dispose(),this._emissiveTexture&&this._emissiveTexture.dispose(),this._metallicTexture&&this._metallicTexture.dispose(),this._reflectivityTexture&&this._reflectivityTexture.dispose(),this._bumpTexture&&this._bumpTexture.dispose(),this._lightmapTexture&&this._lightmapTexture.dispose(),this._refractionTexture&&this._refractionTexture.dispose()),this._renderTargets.dispose(),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),r.prototype.dispose.call(this,e,t)},i})(e.PushMaterial);r._scaledReflectivity=new e.Color3,__decorate([e.serializeAsImageProcessingConfiguration()],r.prototype,"_imageProcessingConfiguration",void 0),__decorate([e.serialize()],r.prototype,"useLogarithmicDepth",null),e.PBRBaseMaterial=r})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){var r=(function(t){function r(r,i){ +var n=t.call(this,r,i)||this;return n.maxSimultaneousLights=4,n.disableLighting=!1,n.invertNormalMapX=!1,n.invertNormalMapY=!1,n.emissiveColor=new e.Color3(0,0,0),n.occlusionStrength=1,n._transparencyMode=e.PBRMaterial.PBRMATERIAL_OPAQUE,n._useAmbientInGrayScale=!0,n}return __extends(r,t),Object.defineProperty(r.prototype,"transparencyMode",{get:function(){return this._transparencyMode},set:function(t){this._transparencyMode!==t&&(this._transparencyMode=t,t===e.PBRMaterial.PBRMATERIAL_ALPHATESTANDBLEND?this._forceAlphaTest=!0:this._forceAlphaTest=!1,this._markAllSubMeshesAsTexturesDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"doubleSided",{get:function(){return this._twoSidedLighting},set:function(e){this._twoSidedLighting!==e&&(this._twoSidedLighting=e,this.backFaceCulling=!e,this._markAllSubMeshesAsTexturesDirty())},enumerable:!0,configurable:!0}),r.prototype._shouldUseAlphaFromAlbedoTexture=function(){return this._albedoTexture&&this._albedoTexture.hasAlpha&&this._transparencyMode!==e.PBRMaterial.PBRMATERIAL_OPAQUE},r.prototype.needAlphaBlending=function(){return!this._linkRefractionWithTransparency&&(this.alpha<1||this._shouldUseAlphaFromAlbedoTexture()&&(this._transparencyMode===e.PBRMaterial.PBRMATERIAL_ALPHABLEND||this._transparencyMode===e.PBRMaterial.PBRMATERIAL_ALPHATESTANDBLEND))},r.prototype.needAlphaTesting=function(){return!this._linkRefractionWithTransparency&&(this._shouldUseAlphaFromAlbedoTexture()&&this._transparencyMode===e.PBRMaterial.PBRMATERIAL_ALPHATEST)},r.prototype.getActiveTextures=function(){var e=t.prototype.getActiveTextures.call(this);return this.environmentTexture&&e.push(this.environmentTexture),this.normalTexture&&e.push(this.normalTexture),this.emissiveTexture&&e.push(this.emissiveTexture),this.occlusionTexture&&e.push(this.occlusionTexture),e},r.prototype.getClassName=function(){return"PBRBaseSimpleMaterial"},r})(e.PBRBaseMaterial);__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsLightsDirty")],r.prototype,"maxSimultaneousLights",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsLightsDirty")],r.prototype,"disableLighting",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_reflectionTexture")],r.prototype,"environmentTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"invertNormalMapX",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"invertNormalMapY",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_bumpTexture")],r.prototype,"normalTexture",void 0),__decorate([e.serializeAsColor3("emissive"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"emissiveColor",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"emissiveTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_ambientTextureStrength")],r.prototype,"occlusionStrength",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_ambientTexture")],r.prototype,"occlusionTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_alphaCutOff")],r.prototype,"alphaCutOff",void 0),__decorate([e.serialize()],r.prototype,"transparencyMode",null),__decorate([e.serialize()],r.prototype,"doubleSided",null),t.PBRBaseSimpleMaterial=r})(e.Internals||(e.Internals={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(r,i){var n=t.call(this,r,i)||this;return n.directIntensity=1,n.emissiveIntensity=1,n.environmentIntensity=1,n.specularIntensity=1,n.disableBumpMap=!1,n.ambientTextureStrength=1,n.ambientColor=new e.Color3(0,0,0),n.albedoColor=new e.Color3(1,1,1),n.reflectivityColor=new e.Color3(1,1,1),n.reflectionColor=new e.Color3(1,1,1),n.emissiveColor=new e.Color3(0,0,0),n.microSurface=1,n.indexOfRefraction=.66,n.invertRefractionY=!1,n.linkRefractionWithTransparency=!1,n.useLightmapAsShadowmap=!1,n.useAlphaFromAlbedoTexture=!1,n.forceAlphaTest=!1,n.alphaCutOff=.4,n.useSpecularOverAlpha=!0,n.useMicroSurfaceFromReflectivityMapAlpha=!1,n.useRoughnessFromMetallicTextureAlpha=!0,n.useRoughnessFromMetallicTextureGreen=!1,n.useMetallnessFromMetallicTextureBlue=!1,n.useAmbientOcclusionFromMetallicTextureRed=!1,n.useAmbientInGrayScale=!1,n.useAutoMicroSurfaceFromReflectivityMap=!1,n.usePhysicalLightFalloff=!0,n.useRadianceOverAlpha=!0,n.useParallax=!1,n.useParallaxOcclusion=!1,n.parallaxScaleBias=.05,n.disableLighting=!1,n.forceIrradianceInFragment=!1,n.maxSimultaneousLights=4,n.invertNormalMapX=!1,n.invertNormalMapY=!1,n.twoSidedLighting=!1,n.preMultiplyAlpha=!1,n.useAlphaFresnel=!1,n.environmentBRDFTexture=null,n.forceNormalForward=!1,n._environmentBRDFTexture=e.TextureTools.GetEnvironmentBRDFTexture(i),n}return __extends(r,t),Object.defineProperty(r,"PBRMATERIAL_OPAQUE",{get:function(){return this._PBRMATERIAL_OPAQUE},enumerable:!0,configurable:!0}),Object.defineProperty(r,"PBRMATERIAL_ALPHATEST",{get:function(){return this._PBRMATERIAL_ALPHATEST},enumerable:!0,configurable:!0}),Object.defineProperty(r,"PBRMATERIAL_ALPHABLEND",{get:function(){return this._PBRMATERIAL_ALPHABLEND},enumerable:!0,configurable:!0}),Object.defineProperty(r,"PBRMATERIAL_ALPHATESTANDBLEND",{get:function(){return this._PBRMATERIAL_ALPHATESTANDBLEND},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(e){this._attachImageProcessingConfiguration(e),this._markAllSubMeshesAsTexturesDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"cameraColorCurvesEnabled",{get:function(){return this.imageProcessingConfiguration.colorCurvesEnabled},set:function(e){this.imageProcessingConfiguration.colorCurvesEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"cameraColorGradingEnabled",{get:function(){return this.imageProcessingConfiguration.colorGradingEnabled},set:function(e){this.imageProcessingConfiguration.colorGradingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"cameraToneMappingEnabled",{get:function(){return this._imageProcessingConfiguration.toneMappingEnabled},set:function(e){this._imageProcessingConfiguration.toneMappingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"cameraExposure",{get:function(){return this._imageProcessingConfiguration.exposure},set:function(e){this._imageProcessingConfiguration.exposure=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"cameraContrast",{get:function(){return this._imageProcessingConfiguration.contrast},set:function(e){this._imageProcessingConfiguration.contrast=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"cameraColorGradingTexture",{get:function(){return this._imageProcessingConfiguration.colorGradingTexture},set:function(e){this._imageProcessingConfiguration.colorGradingTexture=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"cameraColorCurves",{get:function(){return this._imageProcessingConfiguration.colorCurves},set:function(e){this._imageProcessingConfiguration.colorCurves=e},enumerable:!0,configurable:!0}),r.prototype.getClassName=function(){return"PBRMaterial"},r.prototype.getActiveTextures=function(){var e=t.prototype.getActiveTextures.call(this);return this._albedoTexture&&e.push(this._albedoTexture),this._ambientTexture&&e.push(this._ambientTexture),this._opacityTexture&&e.push(this._opacityTexture),this._reflectionTexture&&e.push(this._reflectionTexture),this._emissiveTexture&&e.push(this._emissiveTexture),this._reflectivityTexture&&e.push(this._reflectivityTexture),this._metallicTexture&&e.push(this._metallicTexture),this._microSurfaceTexture&&e.push(this._microSurfaceTexture),this._bumpTexture&&e.push(this._bumpTexture),this._lightmapTexture&&e.push(this._lightmapTexture),this._refractionTexture&&e.push(this._refractionTexture),e},r.prototype.hasTexture=function(e){return!!t.prototype.hasTexture.call(this,e)||(this._albedoTexture===e||(this._ambientTexture===e||(this._opacityTexture===e||(this._reflectionTexture===e||(this._reflectivityTexture===e||(this._metallicTexture===e||(this._microSurfaceTexture===e||(this._bumpTexture===e||(this._lightmapTexture===e||this._refractionTexture===e)))))))))},r.prototype.clone=function(t){var i=this;return e.SerializationHelper.Clone((function(){return new r(t,i.getScene())}),this)},r.prototype.serialize=function(){var t=e.SerializationHelper.Serialize(this);return t.customType="BABYLON.PBRMaterial",t},r.Parse=function(t,i,n){return e.SerializationHelper.Parse((function(){return new r(t.name,i)}),t,i,n)},r})(e.PBRBaseMaterial);t._PBRMATERIAL_OPAQUE=0,t._PBRMATERIAL_ALPHATEST=1,t._PBRMATERIAL_ALPHABLEND=2,t._PBRMATERIAL_ALPHATESTANDBLEND=3,__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"directIntensity",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveIntensity",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"environmentIntensity",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"specularIntensity",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"disableBumpMap",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"albedoTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientTextureStrength",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"opacityTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectivityTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallicTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallic",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"roughness",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"microSurfaceTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"bumpTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty",null)],t.prototype,"lightmapTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"refractionTexture",void 0),__decorate([e.serializeAsColor3("ambient"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientColor",void 0),__decorate([e.serializeAsColor3("albedo"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"albedoColor",void 0),__decorate([e.serializeAsColor3("reflectivity"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectivityColor",void 0),__decorate([e.serializeAsColor3("reflection"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionColor",void 0),__decorate([e.serializeAsColor3("emissive"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveColor",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"microSurface",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"indexOfRefraction",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertRefractionY",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"linkRefractionWithTransparency",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useLightmapAsShadowmap",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAlphaFromAlbedoTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"forceAlphaTest",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"alphaCutOff",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useSpecularOverAlpha",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useMicroSurfaceFromReflectivityMapAlpha",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRoughnessFromMetallicTextureAlpha",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRoughnessFromMetallicTextureGreen",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useMetallnessFromMetallicTextureBlue",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAmbientOcclusionFromMetallicTextureRed",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAmbientInGrayScale",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAutoMicroSurfaceFromReflectivityMap",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"usePhysicalLightFalloff",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRadianceOverAlpha",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useParallax",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useParallaxOcclusion",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"parallaxScaleBias",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsLightsDirty")],t.prototype,"disableLighting",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"forceIrradianceInFragment",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsLightsDirty")],t.prototype,"maxSimultaneousLights",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapX",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapY",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"twoSidedLighting",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"preMultiplyAlpha",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAlphaFresnel",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"environmentBRDFTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"forceNormalForward",void 0),e.PBRMaterial=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(e,r){var i=t.call(this,e,r)||this;return i._useRoughnessFromMetallicTextureAlpha=!1,i._useRoughnessFromMetallicTextureGreen=!0,i._useMetallnessFromMetallicTextureBlue=!0,i}return __extends(r,t),r.prototype.getClassName=function(){return"PBRMetallicRoughnessMaterial"},r.prototype.getActiveTextures=function(){var e=t.prototype.getActiveTextures.call(this);return this.baseTexture&&e.push(this.baseTexture),this.metallicRoughnessTexture&&e.push(this.metallicRoughnessTexture),e},r.prototype.hasTexture=function(e){return!!t.prototype.hasTexture.call(this,e)||(this.baseTexture===e||this.metallicRoughnessTexture===e)},r.prototype.clone=function(t){var i=this;return e.SerializationHelper.Clone((function(){return new r(t,i.getScene())}),this)},r.prototype.serialize=function(){var t=e.SerializationHelper.Serialize(this);return t.customType="BABYLON.PBRMetallicRoughnessMaterial",t},r.Parse=function(t,i,n){return e.SerializationHelper.Parse((function(){return new r(t.name,i)}),t,i,n)},r})(e.Internals.PBRBaseSimpleMaterial);__decorate([e.serializeAsColor3(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_albedoColor")],t.prototype,"baseColor",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_albedoTexture")],t.prototype,"baseTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallic",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"roughness",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_metallicTexture")],t.prototype,"metallicRoughnessTexture",void 0),e.PBRMetallicRoughnessMaterial=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(e,r){var i=t.call(this,e,r)||this;return i._useMicroSurfaceFromReflectivityMapAlpha=!0,i}return __extends(r,t),r.prototype.getClassName=function(){return"PBRSpecularGlossinessMaterial"},r.prototype.getActiveTextures=function(){var e=t.prototype.getActiveTextures.call(this);return this.diffuseTexture&&e.push(this.diffuseTexture),this.specularGlossinessTexture&&e.push(this.specularGlossinessTexture),e},r.prototype.hasTexture=function(e){return!!t.prototype.hasTexture.call(this,e)||(this.diffuseTexture===e||this.specularGlossinessTexture===e)},r.prototype.clone=function(t){var i=this;return e.SerializationHelper.Clone((function(){return new r(t,i.getScene())}),this)},r.prototype.serialize=function(){var t=e.SerializationHelper.Serialize(this);return t.customType="BABYLON.PBRSpecularGlossinessMaterial",t},r.Parse=function(t,i,n){return e.SerializationHelper.Parse((function(){return new r(t.name,i)}),t,i,n)},r})(e.Internals.PBRBaseSimpleMaterial);__decorate([e.serializeAsColor3("diffuse"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_albedoColor")],t.prototype,"diffuseColor",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_albedoTexture")],t.prototype,"diffuseTexture",void 0),__decorate([e.serializeAsColor3("specular"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_reflectivityColor")],t.prototype,"specularColor",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_microSurface")],t.prototype,"glossiness",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_reflectivityTexture")],t.prototype,"specularGlossinessTexture",void 0),e.PBRSpecularGlossinessMaterial=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(r,i,n,o){var s=t.call(this,r,i)||this;return s._textures={},s._textureArrays={},s._floats={},s._floatsArrays={},s._colors3={},s._colors3Arrays={},s._colors4={},s._vectors2={},s._vectors3={},s._vectors4={},s._matrices={},s._matrices3x3={},s._matrices2x2={},s._vectors3Arrays={},s._cachedWorldViewMatrix=new e.Matrix,s._shaderPath=n,o.needAlphaBlending=o.needAlphaBlending||!1,o.needAlphaTesting=o.needAlphaTesting||!1,o.attributes=o.attributes||["position","normal","uv"],o.uniforms=o.uniforms||["worldViewProjection"],o.uniformBuffers=o.uniformBuffers||[],o.samplers=o.samplers||[],o.defines=o.defines||[],s._options=o,s}return __extends(r,t),r.prototype.getClassName=function(){return"ShaderMaterial"},r.prototype.needAlphaBlending=function(){return this._options.needAlphaBlending},r.prototype.needAlphaTesting=function(){return this._options.needAlphaTesting},r.prototype._checkUniform=function(e){-1===this._options.uniforms.indexOf(e)&&this._options.uniforms.push(e)},r.prototype.setTexture=function(e,t){return-1===this._options.samplers.indexOf(e)&&this._options.samplers.push(e),this._textures[e]=t,this},r.prototype.setTextureArray=function(e,t){return-1===this._options.samplers.indexOf(e)&&this._options.samplers.push(e),this._checkUniform(e),this._textureArrays[e]=t,this},r.prototype.setFloat=function(e,t){return this._checkUniform(e),this._floats[e]=t,this},r.prototype.setFloats=function(e,t){return this._checkUniform(e),this._floatsArrays[e]=t,this},r.prototype.setColor3=function(e,t){return this._checkUniform(e),this._colors3[e]=t,this},r.prototype.setColor3Array=function(e,t){return this._checkUniform(e),this._colors3Arrays[e]=t.reduce((function(e,t){return t.toArray(e,e.length),e}),[]),this},r.prototype.setColor4=function(e,t){return this._checkUniform(e),this._colors4[e]=t,this},r.prototype.setVector2=function(e,t){return this._checkUniform(e),this._vectors2[e]=t,this},r.prototype.setVector3=function(e,t){return this._checkUniform(e),this._vectors3[e]=t,this},r.prototype.setVector4=function(e,t){return this._checkUniform(e),this._vectors4[e]=t,this},r.prototype.setMatrix=function(e,t){return this._checkUniform(e),this._matrices[e]=t,this},r.prototype.setMatrix3x3=function(e,t){return this._checkUniform(e),this._matrices3x3[e]=t,this},r.prototype.setMatrix2x2=function(e,t){return this._checkUniform(e),this._matrices2x2[e]=t,this},r.prototype.setArray3=function(e,t){return this._checkUniform(e),this._vectors3Arrays[e]=t,this},r.prototype._checkCache=function(e,t,r){return!t||(this._effect&&this._effect.defines.indexOf("#define INSTANCES"),!1)},r.prototype.isReady=function(t,r){var i=this.getScene(),n=i.getEngine();if(!this.checkReadyOnEveryCall&&this._renderId===i.getRenderId()&&this._checkCache(i,t,r))return!0;var o=[],s=[],a=new e.EffectFallbacks;r&&o.push("#define INSTANCES");for(var u=0;u4&&(s.push(e.VertexBuffer.MatricesIndicesExtraKind),s.push(e.VertexBuffer.MatricesWeightsExtraKind)),o.push("#define NUM_BONE_INFLUENCERS "+t.numBoneInfluencers),o.push("#define BonesPerMesh "+(t.skeleton.bones.length+1)),a.addCPUSkinningFallback(0,t),-1===this._options.uniforms.indexOf("mBones")&&this._options.uniforms.push("mBones")):o.push("#define NUM_BONE_INFLUENCERS 0");for(var l in this._textures)if(!this._textures[l].isReady())return!1;n.getAlphaTesting()&&o.push("#define ALPHATEST");var c=this._effect,h=o.join("\n");return this._effect=n.createEffect(this._shaderPath,{attributes:s,uniformsNames:this._options.uniforms,uniformBuffersNames:this._options.uniformBuffers,samplers:this._options.samplers,defines:h,fallbacks:a,onCompiled:this.onCompiled,onError:this.onError},n),!!this._effect.isReady()&&(c!==this._effect&&i.resetCachedMaterial(),this._renderId=i.getRenderId(),!0)},r.prototype.bindOnlyWorldMatrix=function(e){var t=this.getScene();-1!==this._options.uniforms.indexOf("world")&&this._effect.setMatrix("world",e),-1!==this._options.uniforms.indexOf("worldView")&&(e.multiplyToRef(t.getViewMatrix(),this._cachedWorldViewMatrix),this._effect.setMatrix("worldView",this._cachedWorldViewMatrix)),-1!==this._options.uniforms.indexOf("worldViewProjection")&&this._effect.setMatrix("worldViewProjection",e.multiply(t.getTransformMatrix()))},r.prototype.bind=function(t,r){if(this.bindOnlyWorldMatrix(t),this.getScene().getCachedMaterial()!==this){-1!==this._options.uniforms.indexOf("view")&&this._effect.setMatrix("view",this.getScene().getViewMatrix()),-1!==this._options.uniforms.indexOf("projection")&&this._effect.setMatrix("projection",this.getScene().getProjectionMatrix()),-1!==this._options.uniforms.indexOf("viewProjection")&&this._effect.setMatrix("viewProjection",this.getScene().getTransformMatrix()),e.MaterialHelper.BindBonesParameters(r,this._effect);var i;for(i in this._textures)this._effect.setTexture(i,this._textures[i]);for(i in this._textureArrays)this._effect.setTextureArray(i,this._textureArrays[i]);for(i in this._floats)this._effect.setFloat(i,this._floats[i]);for(i in this._floatsArrays)this._effect.setArray(i,this._floatsArrays[i]);for(i in this._colors3)this._effect.setColor3(i,this._colors3[i]);for(i in this._colors3Arrays)this._effect.setArray3(i,this._colors3Arrays[i]);for(i in this._colors4){var n=this._colors4[i];this._effect.setFloat4(i,n.r,n.g,n.b,n.a)}for(i in this._vectors2)this._effect.setVector2(i,this._vectors2[i]);for(i in this._vectors3)this._effect.setVector3(i,this._vectors3[i]);for(i in this._vectors4)this._effect.setVector4(i,this._vectors4[i]);for(i in this._matrices)this._effect.setMatrix(i,this._matrices[i]);for(i in this._matrices3x3)this._effect.setMatrix3x3(i,this._matrices3x3[i]);for(i in this._matrices2x2)this._effect.setMatrix2x2(i,this._matrices2x2[i]);for(i in this._vectors3Arrays)this._effect.setArray3(i,this._vectors3Arrays[i])}this._afterBind(r)},r.prototype.getActiveTextures=function(){var e=t.prototype.getActiveTextures.call(this);for(var r in this._textures)e.push(this._textures[r]);for(var r in this._textureArrays)for(var i=this._textureArrays[r],n=0;ne.Tmp.Vector3[1].x&&(e.Tmp.Vector3[1].x=u[h].x),u[h].ye.Tmp.Vector3[1].y&&(e.Tmp.Vector3[1].y=u[h].y),u[h].ze.Tmp.Vector3[1].z&&(e.Tmp.Vector3[1].z=u[h].z),h++,i+=3;l._closePath&&(t[i]=u[0].x,t[i+1]=u[0].y,t[i+2]=u[0].z,i+=3)}}(h),l._boundingInfo=new e.BoundingInfo(e.Tmp.Vector3[0],e.Tmp.Vector3[1]),l._boundingInfo.update(l._worldMatrix),l.updateVerticesData(e.VertexBuffer.PositionKind,h,!1,!1),i.colors){for(var f=l.getVerticesData(e.VertexBuffer.ColorKind),d=0;d1?1:i.arc:1,a=void 0===i.closed||i.closed,u=i.shape,l=i.radius||1,c=i.tessellation||64,h=i.updatable,f=t.updateSideOrientation(i.sideOrientation,n),d=i.cap||e.Mesh.NO_CAP,p=2*Math.PI,g=new Array,_=i.invertUV||!1,m=0,v=0,y=p/c*s,A=new Array;for(m=0;m<=c;m++){var A=[];for(d!=e.Mesh.CAP_START&&d!=e.Mesh.CAP_ALL||(A.push(new e.Vector3(0,u[0].y,0)),A.push(new e.Vector3(Math.cos(m*y)*u[0].x*l,u[0].y,Math.sin(m*y)*u[0].x*l))),v=0;v1?1:i.arc||1;var p,g,_=function(t,r,i,n,o,s,a,u){for(var l,c,h,f,d=r.getTangents(),p=r.getNormals(),g=r.getDistances(),_=2*Math.PI,m=_/o*u,v=function(){return n},y=s||v,A=e.Tmp.Matrix[0],E=a===e.Mesh._NO_CAP||a===e.Mesh.CAP_END?0:2,T=0;T3?0:l,g=_(o,p,v,s,a,u,l,i.arc);var y=t.CreateRibbon(r,{pathArray:g,closePath:!0,closeArray:!1,updatable:h,sideOrientation:f,invertUV:c,frontUVs:i.frontUVs,backUVs:i.backUVs},n);return y.pathArray=g,y.path3D=p,y.tessellation=a,y.cap=l,y.arc=i.arc,y},t.CreatePolyhedron=function(r,i,n){var o=new e.Mesh(r,n);return i.sideOrientation=t.updateSideOrientation(i.sideOrientation,n),o.sideOrientation=i.sideOrientation,e.VertexData.CreatePolyhedron(i).applyToMesh(o,i.updatable),o},t.CreateDecal=function(t,r,i){var n=r.getIndices(),o=r.getVerticesData(e.VertexBuffer.PositionKind),s=r.getVerticesData(e.VertexBuffer.NormalKind),a=i.position||e.Vector3.Zero(),u=i.normal||e.Vector3.Up(),l=i.size||e.Vector3.One(),c=i.angle||0;if(!u){var h=new e.Vector3(0,0,1),f=r.getScene().activeCamera,d=e.Vector3.TransformCoordinates(h,f.getWorldMatrix());u=f.globalPosition.subtract(d)}var p=-Math.atan2(u.z,u.x)-Math.PI/2,g=Math.sqrt(u.x*u.x+u.z*u.z),_=Math.atan2(u.y,g),m=e.Matrix.RotationYawPitchRoll(p,_,c).multiply(e.Matrix.Translation(a.x,a.y,a.z)),v=e.Matrix.Invert(m),y=r.getWorldMatrix(),A=y.multiply(v),E=new e.VertexData;E.indices=[],E.positions=[],E.normals=[],E.uvs=[];for(var T=0,b=function(t){var r=n[t],i=new e.PositionNormalVertex;return i.position=new e.Vector3(o[3*r],o[3*r+1],o[3*r+2]),i.position=e.Vector3.TransformCoordinates(i.position,A),i.normal=new e.Vector3(s[3*r],s[3*r+1],s[3*r+2]),i.normal=e.Vector3.TransformNormal(i.normal,A),i},x=function(t,r){if(0===t.length)return t;for(var i=.5*Math.abs(e.Vector3.Dot(l,r)),n=function(t,n){var o=e.Vector3.GetClipFactor(t.position,n.position,r,i);return new e.PositionNormalVertex(e.Vector3.Lerp(t.position,n.position,o),e.Vector3.Lerp(t.normal,n.normal,o))},o=new Array,s=0;s0,u=_>0,c=m>0,(a?1:0)+(u?1:0)+(c?1:0)){case 0:o.push(t[s]),o.push(t[s+1]),o.push(t[s+2]);break;case 1:if(a&&(h=t[s+1],f=t[s+2],d=n(t[s],h),p=n(t[s],f)),u){h=t[s],f=t[s+2],d=n(t[s+1],h),p=n(t[s+1],f),o.push(d),o.push(f.clone()),o.push(h.clone()),o.push(f.clone()),o.push(d.clone()),o.push(p);break}c&&(h=t[s],f=t[s+1],d=n(t[s+2],h),p=n(t[s+2],f)),o.push(h.clone()),o.push(f.clone()),o.push(d),o.push(p),o.push(d.clone()),o.push(f.clone());break;case 2:a||(h=t[s].clone(),f=n(h,t[s+1]),d=n(h,t[s+2]),o.push(h),o.push(f),o.push(d)),u||(h=t[s+1].clone(),f=n(h,t[s+2]),d=n(h,t[s]),o.push(h),o.push(f),o.push(d)),c||(h=t[s+2].clone(),f=n(h,t[s]),d=n(h,t[s+1]),o.push(h),o.push(f),o.push(d))}}return o},M=0;M3?0:h,E=T(i,n,A,b,o,s,a,u,h,f);var x=t.CreateRibbon(r,{pathArray:E,closeArray:l,closePath:c,updatable:p,sideOrientation:g,invertUV:m,frontUVs:v,backUVs:y},d);return x.pathArray=E,x.path3D=A,x.cap=h,x},t})();e.MeshBuilder=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t,r,i,n,o){this.name=t,this.scale=new e.Vector2(1,1),this.offset=new e.Vector2(0,0),this.alphaBlendingMode=e.Engine.ALPHA_COMBINE,this.layerMask=268435455,this._vertexBuffers={},this.onDisposeObservable=new e.Observable,this.onBeforeRenderObservable=new e.Observable,this.onAfterRenderObservable=new e.Observable,this.texture=r?new e.Texture(r,i,!0):null,this.isBackground=void 0===n||n,this.color=void 0===o?new e.Color4(1,1,1,1):o,this._scene=i||e.Engine.LastCreatedScene,this._scene.layers.push(this);var s=this._scene.getEngine(),a=[];a.push(1,1),a.push(-1,1),a.push(-1,-1),a.push(1,-1);var u=new e.VertexBuffer(s,a,e.VertexBuffer.PositionKind,!1,!1,2);this._vertexBuffers[e.VertexBuffer.PositionKind]=u;var l=[];l.push(0),l.push(1),l.push(2),l.push(0),l.push(2),l.push(3),this._indexBuffer=s.createIndexBuffer(l),this._effect=s.createEffect("layer",[e.VertexBuffer.PositionKind],["textureMatrix","color","scale","offset"],["textureSampler"],""),this._alphaTestEffect=s.createEffect("layer",[e.VertexBuffer.PositionKind],["textureMatrix","color","scale","offset"],["textureSampler"],"#define ALPHATEST")}return Object.defineProperty(t.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onBeforeRender",{set:function(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onAfterRender",{set:function(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=this.onAfterRenderObservable.add(e)},enumerable:!0,configurable:!0}),t.prototype.render=function(){var t=this.alphaTest?this._alphaTestEffect:this._effect;if(t.isReady()&&this.texture&&this.texture.isReady()){var r=this._scene.getEngine();this.onBeforeRenderObservable.notifyObservers(this),r.enableEffect(t),r.setState(!1),t.setTexture("textureSampler",this.texture),t.setMatrix("textureMatrix",this.texture.getTextureMatrix()),t.setFloat4("color",this.color.r,this.color.g,this.color.b,this.color.a),t.setVector2("offset",this.offset),t.setVector2("scale",this.scale),r.bindBuffers(this._vertexBuffers,this._indexBuffer,t),this.alphaTest?r.draw(!0,0,6):(r.setAlphaMode(this.alphaBlendingMode),r.draw(!0,0,6),r.setAlphaMode(e.Engine.ALPHA_DISABLE)),this.onAfterRenderObservable.notifyObservers(this)}},t.prototype.dispose=function(){var t=this._vertexBuffers[e.VertexBuffer.PositionKind];t&&(t.dispose(),this._vertexBuffers[e.VertexBuffer.PositionKind]=null),this._indexBuffer&&(this._scene.getEngine()._releaseBuffer(this._indexBuffer),this._indexBuffer=null),this.texture&&(this.texture.dispose(),this.texture=null);var r=this._scene.layers.indexOf(this);this._scene.layers.splice(r,1),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onAfterRenderObservable.clear(),this.onBeforeRenderObservable.clear()},t})();e.Layer=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(r,i,n,o,s,a,u,l,c){void 0===a&&(a=e.Texture.BILINEAR_SAMPLINGMODE),void 0===c&&(c=e.Engine.TEXTURETYPE_UNSIGNED_INT);var h=t.call(this,r,"kernelBlur",["delta","direction"],null,o,s,a,u,l,null,c,"kernelBlur",{varyingCount:0,depCount:0},!0)||this;return h.direction=i,h._packedFloat=!1,h.onApplyObservable.add((function(e){e.setFloat2("delta",1/h.width*h.direction.x,1/h.height*h.direction.y)})),h.kernel=n,h}return __extends(r,t),Object.defineProperty(r.prototype,"kernel",{get:function(){return this._idealKernel},set:function(e){this._idealKernel!==e&&(e=Math.max(e,1),this._idealKernel=e,this._kernel=this._nearestBestKernel(e),this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"packedFloat",{get:function(){return this._packedFloat},set:function(e){this._packedFloat!==e&&(this._packedFloat=e,this._updateParameters())},enumerable:!0,configurable:!0}),r.prototype._updateParameters=function(){for(var e=this._kernel,t=(e-1)/2,r=[],i=[],n=0,o=0;o0)return Math.max(n,3)}return Math.max(t,3)},r.prototype._gaussianWeight=function(e){var t=Math.sqrt(2*Math.PI)*(1/3),r=-e*e/(1/3*2*(1/3));return 1/t*Math.exp(r)},r.prototype._glslFloat=function(e,t){return void 0===t&&(t=8),e.toFixed(t).replace(/0+$/,"")},r})(e.PostProcess);e.BlurPostProcess=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(r,i,n,o,s,a,u){void 0===u&&(u=e.Engine.TEXTURETYPE_UNSIGNED_INT);var l=t.call(this,r,"fxaa",["texelSize"],null,i,n,o||e.Texture.BILINEAR_SAMPLINGMODE,s,a,null,u,"fxaa")||this;return l.onApplyObservable.add((function(e){var t=l.texelSize;e.setFloat2("texelSize",t.x,t.y)})),l}return __extends(r,t),r})(e.PostProcess);e.FxaaPostProcess=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(r,i,n,o,s,a,u){return void 0===u&&(u=e.Engine.TEXTURETYPE_UNSIGNED_INT),t.call(this,r,"highlights",null,null,i,n,o,s,a,null,u)||this}return __extends(r,t),r})(e.PostProcess);e.HighlightsPostProcess=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(r,i,n,o,s,a,u){void 0===u&&(u=e.Engine.TEXTURETYPE_UNSIGNED_INT);var l=t.call(this,r,"imageProcessing",[],[],i,n,o,s,a,null,u,"postprocess",null,!0)||this;return l._fromLinearSpace=!0,l._defines={IMAGEPROCESSING:!1,VIGNETTE:!1,VIGNETTEBLENDMODEMULTIPLY:!1,VIGNETTEBLENDMODEOPAQUE:!1,TONEMAPPING:!1,CONTRAST:!1,COLORCURVES:!1,COLORGRADING:!1,FROMLINEARSPACE:!1,SAMPLER3DGREENDEPTH:!1,SAMPLER3DBGRMAP:!1,IMAGEPROCESSINGPOSTPROCESS:!1,EXPOSURE:!1},l._attachImageProcessingConfiguration(null,!0),l.imageProcessingConfiguration.applyByPostProcess=!0,l.onApply=function(e){l.imageProcessingConfiguration.bind(e,l.aspectRatio)},l}return __extends(r,t),Object.defineProperty(r.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(e){this._attachImageProcessingConfiguration(e)},enumerable:!0,configurable:!0}),r.prototype._attachImageProcessingConfiguration=function(t,r){var i=this;if(void 0===r&&(r=!1),t!==this._imageProcessingConfiguration){if(this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),t)this._imageProcessingConfiguration=t;else{var n=this.getCamera(),o=n?n.getScene():e.Engine.LastCreatedScene;this._imageProcessingConfiguration=o.imageProcessingConfiguration}this._imageProcessingObserver=this._imageProcessingConfiguration.onUpdateParameters.add((function(e){i._updateParameters()})),r||this._updateParameters()}},Object.defineProperty(r.prototype,"colorCurves",{get:function(){return this.imageProcessingConfiguration.colorCurves},set:function(e){this.imageProcessingConfiguration.colorCurves=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"colorCurvesEnabled",{get:function(){return this.imageProcessingConfiguration.colorCurvesEnabled},set:function(e){this.imageProcessingConfiguration.colorCurvesEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"colorGradingTexture",{get:function(){return this.imageProcessingConfiguration.colorGradingTexture},set:function(e){this.imageProcessingConfiguration.colorGradingTexture=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"colorGradingEnabled",{get:function(){return this.imageProcessingConfiguration.colorGradingEnabled},set:function(e){this.imageProcessingConfiguration.colorGradingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"exposure",{get:function(){return this.imageProcessingConfiguration.exposure},set:function(e){this.imageProcessingConfiguration.exposure=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"toneMappingEnabled",{get:function(){return this._imageProcessingConfiguration.toneMappingEnabled},set:function(e){this._imageProcessingConfiguration.toneMappingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"contrast",{get:function(){return this.imageProcessingConfiguration.contrast},set:function(e){this.imageProcessingConfiguration.contrast=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"vignetteStretch",{get:function(){return this.imageProcessingConfiguration.vignetteStretch},set:function(e){this.imageProcessingConfiguration.vignetteStretch=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"vignetteCentreX",{get:function(){return this.imageProcessingConfiguration.vignetteCentreX},set:function(e){this.imageProcessingConfiguration.vignetteCentreX=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"vignetteCentreY",{get:function(){return this.imageProcessingConfiguration.vignetteCentreY},set:function(e){this.imageProcessingConfiguration.vignetteCentreY=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"vignetteWeight",{get:function(){return this.imageProcessingConfiguration.vignetteWeight},set:function(e){this.imageProcessingConfiguration.vignetteWeight=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"vignetteColor",{get:function(){return this.imageProcessingConfiguration.vignetteColor},set:function(e){this.imageProcessingConfiguration.vignetteColor=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"vignetteCameraFov",{get:function(){return this.imageProcessingConfiguration.vignetteCameraFov},set:function(e){this.imageProcessingConfiguration.vignetteCameraFov=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"vignetteBlendMode",{get:function(){return this.imageProcessingConfiguration.vignetteBlendMode},set:function(e){this.imageProcessingConfiguration.vignetteBlendMode=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"vignetteEnabled",{get:function(){return this.imageProcessingConfiguration.vignetteEnabled},set:function(e){this.imageProcessingConfiguration.vignetteEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"fromLinearSpace",{get:function(){return this._fromLinearSpace},set:function(e){this._fromLinearSpace!==e&&(this._fromLinearSpace=e,this._updateParameters())},enumerable:!0,configurable:!0}),r.prototype.getClassName=function(){return"ImageProcessingPostProcess"},r.prototype._updateParameters=function(){this._defines.FROMLINEARSPACE=this._fromLinearSpace,this.imageProcessingConfiguration.prepareDefines(this._defines);var t="";for(var r in this._defines)this._defines[r]&&(t+="#define "+r+";\r\n");var i=["textureSampler"];e.ImageProcessingConfiguration.PrepareSamplers(i,this._defines);var n=["scale"];e.ImageProcessingConfiguration.PrepareUniforms(n,this._defines),this.updateEffect(t,n,i)},r.prototype.dispose=function(e){t.prototype.dispose.call(this,e),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),this.imageProcessingConfiguration.applyByPostProcess=!1},r})(e.PostProcess);__decorate([e.serialize()],t.prototype,"_fromLinearSpace",void 0),e.ImageProcessingPostProcess=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(r,i){var n=t.call(this,i)||this;return r?(n._textureMatrix=e.Matrix.Identity(),n.name=r,n.url=r,n.hasAlpha=!1,n.isCube=!1,n.wrapU=e.Texture.CLAMP_ADDRESSMODE,n.wrapV=e.Texture.CLAMP_ADDRESSMODE,n.anisotropicFilteringLevel=1,n._texture=n._getFromCache(r,!0),n._texture||(i.useDelayedTextureLoading?n.delayLoadState=e.Engine.DELAYLOADSTATE_NOTLOADED:n.loadTexture()),n):n}return __extends(r,t),r.prototype.getTextureMatrix=function(){return this._textureMatrix},r.prototype.load3dlTexture=function(){var t=this,i=this.getScene().getEngine().createRawTexture(null,1,1,e.Engine.TEXTUREFORMAT_RGBA,!1,!1,e.Texture.BILINEAR_SAMPLINGMODE);this._texture=i;var n=function(n){for(var o,s,a,u=n.split("\n"),l=0,c=0,h=0,f=0,d=0,p=0;p0&&(p+1)%4==0)o[p]=255;else{var A=s[p];o[p]=A/d*255}t.getScene().getEngine().updateTextureSize(i,l*l,l),t.getScene().getEngine().updateRawTexture(i,o,e.Engine.TEXTUREFORMAT_RGBA,!1)};return e.Tools.LoadFile(this.url,n),this._texture},r.prototype.loadTexture=function(){this.url&&this.url.toLocaleLowerCase().indexOf(".3dl")==this.url.length-4&&this.load3dlTexture()},r.prototype.clone=function(){var e=new r(this.url,this.getScene());return e.level=this.level,e},r.prototype.delayLoad=function(){this.delayLoadState===e.Engine.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=e.Engine.DELAYLOADSTATE_LOADED,this._texture=this._getFromCache(this.url,!0),this._texture||this.loadTexture())},r.Parse=function(t,r,i){var n=null;return t.name&&!t.isRenderTarget&&(n=new e.ColorGradingTexture(t.name,r),n.name=t.name,n.level=t.level),n},r.prototype.serialize=function(){if(!this.name)return null;var e={};return e.name=this.name,e.level=this.level,e.customType="BABYLON.ColorGradingTexture",e},r})(e.BaseTexture);t._noneEmptyLineRegex=/\S+/,e.ColorGradingTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this._dirty=!0,this._tempColor=new e.Color4(0,0,0,0),this._globalCurve=new e.Color4(0,0,0,0),this._highlightsCurve=new e.Color4(0,0,0,0),this._midtonesCurve=new e.Color4(0,0,0,0),this._shadowsCurve=new e.Color4(0,0,0,0),this._positiveCurve=new e.Color4(0,0,0,0),this._negativeCurve=new e.Color4(0,0,0,0),this._globalHue=30,this._globalDensity=0,this._globalSaturation=0,this._globalExposure=0,this._highlightsHue=30,this._highlightsDensity=0,this._highlightsSaturation=0,this._highlightsExposure=0,this._midtonesHue=30,this._midtonesDensity=0,this._midtonesSaturation=0,this._midtonesExposure=0,this._shadowsHue=30,this._shadowsDensity=0,this._shadowsSaturation=0,this._shadowsExposure=0}return Object.defineProperty(t.prototype,"globalHue",{get:function(){return this._globalHue},set:function(e){this._globalHue=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"globalDensity",{get:function(){return this._globalDensity},set:function(e){this._globalDensity=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"globalSaturation",{get:function(){return this._globalSaturation},set:function(e){this._globalSaturation=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"highlightsHue",{get:function(){return this._highlightsHue},set:function(e){this._highlightsHue=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"highlightsDensity",{get:function(){return this._highlightsDensity},set:function(e){this._highlightsDensity=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"highlightsSaturation",{get:function(){return this._highlightsSaturation},set:function(e){this._highlightsSaturation=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"highlightsExposure",{get:function(){return this._highlightsExposure},set:function(e){this._highlightsExposure=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"midtonesHue",{get:function(){return this._midtonesHue},set:function(e){this._midtonesHue=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"midtonesDensity",{get:function(){return this._midtonesDensity},set:function(e){this._midtonesDensity=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"midtonesSaturation",{get:function(){return this._midtonesSaturation},set:function(e){this._midtonesSaturation=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"midtonesExposure",{get:function(){return this._midtonesExposure},set:function(e){this._midtonesExposure=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"shadowsHue",{get:function(){return this._shadowsHue},set:function(e){this._shadowsHue=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"shadowsDensity",{get:function(){return this._shadowsDensity},set:function(e){this._shadowsDensity=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"shadowsSaturation",{get:function(){return this._shadowsSaturation},set:function(e){this._shadowsSaturation=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"shadowsExposure",{get:function(){return this._shadowsExposure},set:function(e){this._shadowsExposure=e,this._dirty=!0},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return"ColorCurves"},t.Bind=function(e,t,r,i,n){void 0===r&&(r="vCameraColorCurvePositive"),void 0===i&&(i="vCameraColorCurveNeutral"),void 0===n&&(n="vCameraColorCurveNegative"),e._dirty&&(e._dirty=!1,e.getColorGradingDataToRef(e._globalHue,e._globalDensity,e._globalSaturation,e._globalExposure,e._globalCurve),e.getColorGradingDataToRef(e._highlightsHue,e._highlightsDensity,e._highlightsSaturation,e._highlightsExposure,e._tempColor),e._tempColor.multiplyToRef(e._globalCurve,e._highlightsCurve),e.getColorGradingDataToRef(e._midtonesHue,e._midtonesDensity,e._midtonesSaturation,e._midtonesExposure,e._tempColor),e._tempColor.multiplyToRef(e._globalCurve,e._midtonesCurve),e.getColorGradingDataToRef(e._shadowsHue,e._shadowsDensity,e._shadowsSaturation,e._shadowsExposure,e._tempColor),e._tempColor.multiplyToRef(e._globalCurve,e._shadowsCurve),e._highlightsCurve.subtractToRef(e._midtonesCurve,e._positiveCurve),e._midtonesCurve.subtractToRef(e._shadowsCurve,e._negativeCurve)), +t&&(t.setFloat4(r,e._positiveCurve.r,e._positiveCurve.g,e._positiveCurve.b,e._positiveCurve.a),t.setFloat4(i,e._midtonesCurve.r,e._midtonesCurve.g,e._midtonesCurve.b,e._midtonesCurve.a),t.setFloat4(n,e._negativeCurve.r,e._negativeCurve.g,e._negativeCurve.b,e._negativeCurve.a))},t.PrepareUniforms=function(e){e.push("vCameraColorCurveNeutral","vCameraColorCurvePositive","vCameraColorCurveNegative")},t.prototype.getColorGradingDataToRef=function(e,r,i,n,o){null!=e&&(e=t.clamp(e,0,360),r=t.clamp(r,-100,100),i=t.clamp(i,-100,100),n=t.clamp(n,-100,100),r=t.applyColorGradingSliderNonlinear(r),r*=.5,n=t.applyColorGradingSliderNonlinear(n),r<0&&(r*=-1,e=(e+180)%360),t.fromHSBToRef(e,r,50+.25*n,o),o.scaleToRef(2,o),o.a=1+.01*i)},t.applyColorGradingSliderNonlinear=function(e){e/=100;var t=Math.abs(e);return t=Math.pow(t,2),e<0&&(t*=-1),t*=100},t.fromHSBToRef=function(e,r,i,n){var o=t.clamp(e,0,360),s=t.clamp(r/100,0,1),a=t.clamp(i/100,0,1);if(0===s)n.r=a,n.g=a,n.b=a;else{o/=60;var u=Math.floor(o),l=o-u,c=a*(1-s),h=a*(1-s*l),f=a*(1-s*(1-l));switch(u){case 0:n.r=a,n.g=f,n.b=c;break;case 1:n.r=h,n.g=a,n.b=c;break;case 2:n.r=c,n.g=a,n.b=f;break;case 3:n.r=c,n.g=h,n.b=a;break;case 4:n.r=f,n.g=c,n.b=a;break;default:n.r=a,n.g=c,n.b=h}}n.a=1},t.clamp=function(e,t,r){return Math.min(Math.max(e,t),r)},t.prototype.clone=function(){return e.SerializationHelper.Clone((function(){return new t}),this)},t.prototype.serialize=function(){return e.SerializationHelper.Serialize(this)},t.Parse=function(r){return e.SerializationHelper.Parse((function(){return new t}),r,null,null)},t})();__decorate([e.serialize()],t.prototype,"_globalHue",void 0),__decorate([e.serialize()],t.prototype,"_globalDensity",void 0),__decorate([e.serialize()],t.prototype,"_globalSaturation",void 0),__decorate([e.serialize()],t.prototype,"_globalExposure",void 0),__decorate([e.serialize()],t.prototype,"_highlightsHue",void 0),__decorate([e.serialize()],t.prototype,"_highlightsDensity",void 0),__decorate([e.serialize()],t.prototype,"_highlightsSaturation",void 0),__decorate([e.serialize()],t.prototype,"_highlightsExposure",void 0),__decorate([e.serialize()],t.prototype,"_midtonesHue",void 0),__decorate([e.serialize()],t.prototype,"_midtonesDensity",void 0),__decorate([e.serialize()],t.prototype,"_midtonesSaturation",void 0),__decorate([e.serialize()],t.prototype,"_midtonesExposure",void 0),e.ColorCurves=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(){this._renderPipelines={}}return e.prototype.addPipeline=function(e){this._renderPipelines[e._name]=e},e.prototype.attachCamerasToRenderPipeline=function(e,t,r){var i=this._renderPipelines[e];i&&i._attachCameras(t,r)},e.prototype.detachCamerasFromRenderPipeline=function(e,t){var r=this._renderPipelines[e];r&&r._detachCameras(t)},e.prototype.enableEffectInPipeline=function(e,t,r){var i=this._renderPipelines[e];i&&i._enableEffect(t,r)},e.prototype.disableEffectInPipeline=function(e,t,r){var i=this._renderPipelines[e];i&&i._disableEffect(t,r)},e.prototype.enableDisplayOnlyPassInPipeline=function(e,t,r){var i=this._renderPipelines[e];i&&i._enableDisplayOnlyPass(t,r)},e.prototype.disableDisplayOnlyPassInPipeline=function(e,t){var r=this._renderPipelines[e];r&&r._disableDisplayOnlyPass(t)},e.prototype.update=function(){for(var e in this._renderPipelines){var t=this._renderPipelines[e];t.isSupported?t._update():(t.dispose(),delete this._renderPipelines[e])}},e})();e.PostProcessRenderPipelineManager=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t,r,i,n,o,s){this._enabled=!0,this._refCount=0,this._name=r,this._renderTexture=new e.RenderTargetTexture(r,i,t),this.setRenderList(n),this._renderTexture.onBeforeRenderObservable.add(o),this._renderTexture.onAfterRenderObservable.add(s),this._scene=t,this._renderList=n}return t.prototype._incRefCount=function(){return 0===this._refCount&&this._scene.customRenderTargets.push(this._renderTexture),++this._refCount},t.prototype._decRefCount=function(){return this._refCount--,this._refCount<=0&&this._scene.customRenderTargets.splice(this._scene.customRenderTargets.indexOf(this._renderTexture),1),this._refCount},t.prototype._update=function(){this.setRenderList(this._renderList)},t.prototype.setRenderList=function(e){this._renderTexture.renderList=e},t.prototype.getRenderTexture=function(){return this._renderTexture},t})();e.PostProcessRenderPass=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e,t,r,i){this._engine=e,this._name=t,this._singleInstance=i||!0,this._getPostProcess=r,this._cameras=[],this._indicesForCamera=[],this._postProcesses={},this._renderPasses={},this._renderEffectAsPasses={}}return Object.defineProperty(t.prototype,"isSupported",{get:function(){for(var e in this._postProcesses)if(!this._postProcesses[e].isSupported)return!1;return!0},enumerable:!0,configurable:!0}),t.prototype._update=function(){for(var e in this._renderPasses)this._renderPasses[e]._update()},t.prototype.addPass=function(e){this._renderPasses[e._name]=e,this._linkParameters()},t.prototype.removePass=function(e){delete this._renderPasses[e._name],this._linkParameters()},t.prototype.addRenderEffectAsPass=function(e){this._renderEffectAsPasses[e._name]=e,this._linkParameters()},t.prototype.getPass=function(e){for(var t in this._renderPasses)if(t===e)return this._renderPasses[e]},t.prototype.emptyPasses=function(){this._renderPasses={},this._linkParameters()},t.prototype._attachCameras=function(t){for(var r,i=e.Tools.MakeArray(t||this._cameras),n=0;nthis._maxX||rthis._maxZ)return this.position.y;this._heightQuads&&0!=this._heightQuads.length||(this._initHeightQuads(),this._computeHeightQuads());var s=this._getFacetAt(t,r),a=-(s.x*t+s.z*r+s.w)/s.y;return e.Vector3.TransformCoordinatesFromFloatsToRef(0,a,0,i,o),o.y},r.prototype.getNormalAtCoordinates=function(t,r){var i=new e.Vector3(0,1,0);return this.getNormalAtCoordinatesToRef(t,r,i),i},r.prototype.getNormalAtCoordinatesToRef=function(t,r,i){var n=this.getWorldMatrix(),o=e.Tmp.Matrix[5];n.invertToRef(o);var s=e.Tmp.Vector3[8];if(e.Vector3.TransformCoordinatesFromFloatsToRef(t,0,r,o,s),t=s.x,r=s.z,tthis._maxX||rthis._maxZ)return this;this._heightQuads&&0!=this._heightQuads.length||(this._initHeightQuads(),this._computeHeightQuads());var a=this._getFacetAt(t,r);return e.Vector3.TransformNormalFromFloatsToRef(a.x,a.y,a.z,n,i),this},r.prototype.updateCoordinateHeights=function(){return this._heightQuads&&0!=this._heightQuads.length||this._initHeightQuads(),this._computeHeightQuads(),this},r.prototype._getFacetAt=function(e,t){var r=(this._subdivisionsX,this._subdivisionsY,Math.floor((e+this._maxX)*this._subdivisionsX/this._width)),i=Math.floor(-(t+this._maxZ)*this._subdivisionsY/this._height+this._subdivisionsY),n=this._heightQuads[i*this._subdivisionsX+r];return t0,a.REFLECTIONOVERALPHA=this._useReflectionOverAlpha,a.INVERTCUBICMAP=this._reflectionTexture.coordinatesMode===e.Texture.INVCUBIC_MODE,a.REFLECTIONMAP_3D=this._reflectionTexture.isCube,this._reflectionTexture.coordinatesMode){case e.Texture.CUBIC_MODE:case e.Texture.INVCUBIC_MODE:a.setReflectionMode("REFLECTIONMAP_CUBIC");break;case e.Texture.EXPLICIT_MODE:a.setReflectionMode("REFLECTIONMAP_EXPLICIT");break;case e.Texture.PLANAR_MODE:a.setReflectionMode("REFLECTIONMAP_PLANAR");break;case e.Texture.PROJECTION_MODE:a.setReflectionMode("REFLECTIONMAP_PROJECTION");break;case e.Texture.SKYBOX_MODE:a.setReflectionMode("REFLECTIONMAP_SKYBOX");break;case e.Texture.SPHERICAL_MODE:a.setReflectionMode("REFLECTIONMAP_SPHERICAL");break;case e.Texture.EQUIRECTANGULAR_MODE:a.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR");break;case e.Texture.FIXED_EQUIRECTANGULAR_MODE:a.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR_FIXED");break;case e.Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:a.setReflectionMode("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED")}}else a.REFLECTION=!1;if(this._emissiveTexture&&i.EmissiveTextureEnabled){if(!this._emissiveTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._emissiveTexture,a,"EMISSIVE")}else a.EMISSIVE=!1;if(this._lightmapTexture&&i.LightmapTextureEnabled){if(!this._lightmapTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._lightmapTexture,a,"LIGHTMAP"),a.USELIGHTMAPASSHADOWMAP=this._useLightmapAsShadowmap}else a.LIGHTMAP=!1;if(this._specularTexture&&i.SpecularTextureEnabled){if(!this._specularTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._specularTexture,a,"SPECULAR"),a.GLOSSINESS=this._useGlossinessFromSpecularMapAlpha}else a.SPECULAR=!1;if(s.getEngine().getCaps().standardDerivatives&&this._bumpTexture&&i.BumpTextureEnabled){if(!this._bumpTexture.isReady())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._bumpTexture,a,"BUMP"),a.PARALLAX=this._useParallax,a.PARALLAXOCCLUSION=this._useParallaxOcclusion}else a.BUMP=!1;if(this._refractionTexture&&i.RefractionTextureEnabled){if(!this._refractionTexture.isReadyOrNotBlocking())return!1;a._needUVs=!0,a.REFRACTION=!0,a.REFRACTIONMAP_3D=this._refractionTexture.isCube}else a.REFRACTION=!1;a.TWOSIDEDLIGHTING=!this._backFaceCulling&&this._twoSidedLighting}else a.DIFFUSE=!1,a.AMBIENT=!1,a.OPACITY=!1,a.REFLECTION=!1,a.EMISSIVE=!1,a.LIGHTMAP=!1,a.BUMP=!1,a.REFRACTION=!1;a.ALPHAFROMDIFFUSE=this._shouldUseAlphaFromDiffuseTexture(),a.EMISSIVEASILLUMINATION=this._useEmissiveAsIllumination,a.LINKEMISSIVEWITHDIFFUSE=this._linkEmissiveWithDiffuse,a.SPECULAROVERALPHA=this._useSpecularOverAlpha}if(a._areImageProcessingDirty){if(!this._imageProcessingConfiguration.isReady())return!1;this._imageProcessingConfiguration.prepareDefines(a)}if(a._areFresnelDirty&&(i.FresnelEnabled?(this._diffuseFresnelParameters||this._opacityFresnelParameters||this._emissiveFresnelParameters||this._refractionFresnelParameters||this._reflectionFresnelParameters)&&(a.DIFFUSEFRESNEL=this._diffuseFresnelParameters&&this._diffuseFresnelParameters.isEnabled,a.OPACITYFRESNEL=this._opacityFresnelParameters&&this._opacityFresnelParameters.isEnabled,a.REFLECTIONFRESNEL=this._reflectionFresnelParameters&&this._reflectionFresnelParameters.isEnabled,a.REFLECTIONFRESNELFROMSPECULAR=this._useReflectionFresnelFromSpecular,a.REFRACTIONFRESNEL=this._refractionFresnelParameters&&this._refractionFresnelParameters.isEnabled,a.EMISSIVEFRESNEL=this._emissiveFresnelParameters&&this._emissiveFresnelParameters.isEnabled,a._needNormals=!0,a.FRESNEL=!0):a.FRESNEL=!1),e.MaterialHelper.PrepareDefinesForMisc(r,s,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,a),e.MaterialHelper.PrepareDefinesForAttributes(r,a,!0,!0,!0),e.MaterialHelper.PrepareDefinesForFrameBoundValues(s,u,a,o),a.isDirty){a.markAsProcessed(),s.resetCachedMaterial();var l=new e.EffectFallbacks;a.REFLECTION&&l.addFallback(0,"REFLECTION"),a.SPECULAR&&l.addFallback(0,"SPECULAR"),a.BUMP&&l.addFallback(0,"BUMP"),a.PARALLAX&&l.addFallback(1,"PARALLAX"),a.PARALLAXOCCLUSION&&l.addFallback(0,"PARALLAXOCCLUSION"),a.SPECULAROVERALPHA&&l.addFallback(0,"SPECULAROVERALPHA"),a.FOG&&l.addFallback(1,"FOG"),a.POINTSIZE&&l.addFallback(0,"POINTSIZE"),a.LOGARITHMICDEPTH&&l.addFallback(0,"LOGARITHMICDEPTH"),e.MaterialHelper.HandleFallbacksForShadows(a,l,this._maxSimultaneousLights),a.SPECULARTERM&&l.addFallback(0,"SPECULARTERM"),a.DIFFUSEFRESNEL&&l.addFallback(1,"DIFFUSEFRESNEL"),a.OPACITYFRESNEL&&l.addFallback(2,"OPACITYFRESNEL"),a.REFLECTIONFRESNEL&&l.addFallback(3,"REFLECTIONFRESNEL"),a.EMISSIVEFRESNEL&&l.addFallback(4,"EMISSIVEFRESNEL"),a.FRESNEL&&l.addFallback(4,"FRESNEL");var c=[e.VertexBuffer.PositionKind];a.NORMAL&&c.push(e.VertexBuffer.NormalKind),a.UV1&&c.push(e.VertexBuffer.UVKind),a.UV2&&c.push(e.VertexBuffer.UV2Kind),a.VERTEXCOLOR&&c.push(e.VertexBuffer.ColorKind),e.MaterialHelper.PrepareAttributesForBones(c,r,a,l),e.MaterialHelper.PrepareAttributesForInstances(c,a),e.MaterialHelper.PrepareAttributesForMorphTargets(c,r,a);var h="default",f=["world","view","viewProjection","vEyePosition","vLightsType","vAmbientColor","vDiffuseColor","vSpecularColor","vEmissiveColor","vFogInfos","vFogColor","pointSize","vDiffuseInfos","vAmbientInfos","vOpacityInfos","vReflectionInfos","vEmissiveInfos","vSpecularInfos","vBumpInfos","vLightmapInfos","vRefractionInfos","mBones","vClipPlane","diffuseMatrix","ambientMatrix","opacityMatrix","reflectionMatrix","emissiveMatrix","specularMatrix","bumpMatrix","lightmapMatrix","refractionMatrix","diffuseLeftColor","diffuseRightColor","opacityParts","reflectionLeftColor","reflectionRightColor","emissiveLeftColor","emissiveRightColor","refractionLeftColor","refractionRightColor","logarithmicDepthConstant","vNormalReoderParams"],d=["diffuseSampler","ambientSampler","opacitySampler","reflectionCubeSampler","reflection2DSampler","emissiveSampler","specularSampler","bumpSampler","lightmapSampler","refractionCubeSampler","refraction2DSampler"],p=["Material","Scene"];e.ImageProcessingConfiguration.PrepareUniforms(f,a),e.ImageProcessingConfiguration.PrepareSamplers(d,a),e.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:f,uniformBuffersNames:p,samplers:d,defines:a,maxSimultaneousLights:this._maxSimultaneousLights}),this.customShaderNameResolve&&(h=this.customShaderNameResolve(h,f,p,d,a));var g=a.toString();n.setEffect(s.getEngine().createEffect(h,{attributes:c,uniformsNames:f,uniformBuffersNames:p,samplers:d,defines:g,fallbacks:l,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights,maxSimultaneousMorphTargets:a.NUM_MORPH_INFLUENCERS}},u),a),this.buildUniformLayout()}return!!n.effect.isReady()&&(a._renderId=s.getRenderId(),this._wasPreviouslyReady=!0,!0)},i.prototype.buildUniformLayout=function(){this._uniformBuffer.addUniform("diffuseLeftColor",4),this._uniformBuffer.addUniform("diffuseRightColor",4),this._uniformBuffer.addUniform("opacityParts",4),this._uniformBuffer.addUniform("reflectionLeftColor",4),this._uniformBuffer.addUniform("reflectionRightColor",4),this._uniformBuffer.addUniform("refractionLeftColor",4),this._uniformBuffer.addUniform("refractionRightColor",4),this._uniformBuffer.addUniform("emissiveLeftColor",4),this._uniformBuffer.addUniform("emissiveRightColor",4),this._uniformBuffer.addUniform("vDiffuseInfos",2),this._uniformBuffer.addUniform("vAmbientInfos",2),this._uniformBuffer.addUniform("vOpacityInfos",2),this._uniformBuffer.addUniform("vReflectionInfos",2),this._uniformBuffer.addUniform("vEmissiveInfos",2),this._uniformBuffer.addUniform("vLightmapInfos",2),this._uniformBuffer.addUniform("vSpecularInfos",2),this._uniformBuffer.addUniform("vBumpInfos",3),this._uniformBuffer.addUniform("diffuseMatrix",16),this._uniformBuffer.addUniform("ambientMatrix",16),this._uniformBuffer.addUniform("opacityMatrix",16),this._uniformBuffer.addUniform("reflectionMatrix",16),this._uniformBuffer.addUniform("emissiveMatrix",16),this._uniformBuffer.addUniform("lightmapMatrix",16),this._uniformBuffer.addUniform("specularMatrix",16),this._uniformBuffer.addUniform("bumpMatrix",16),this._uniformBuffer.addUniform("vNormalReoderParams",4),this._uniformBuffer.addUniform("refractionMatrix",16),this._uniformBuffer.addUniform("vRefractionInfos",4),this._uniformBuffer.addUniform("vSpecularColor",4),this._uniformBuffer.addUniform("vEmissiveColor",3),this._uniformBuffer.addUniform("vDiffuseColor",4),this._uniformBuffer.addUniform("pointSize",1),this._uniformBuffer.create()},i.prototype.unbind=function(){this._activeEffect&&(this._reflectionTexture&&this._reflectionTexture.isRenderTarget&&this._activeEffect.setTexture("reflection2DSampler",null),this._refractionTexture&&this._refractionTexture.isRenderTarget&&this._activeEffect.setTexture("refraction2DSampler",null)),r.prototype.unbind.call(this)},i.prototype.bindForSubMesh=function(t,r,n){var o=this.getScene(),s=n._materialDefines;if(s){var a=n.effect;if(this._activeEffect=a,this.bindOnlyWorldMatrix(t),e.MaterialHelper.BindBonesParameters(r,a),this._mustRebind(o,a,r.visibility)){if(this._uniformBuffer.bindToEffect(a,"Material"),this.bindViewProjection(a),!this._uniformBuffer.useUbo||!this.isFrozen||!this._uniformBuffer.isSync){if(i.FresnelEnabled&&s.FRESNEL&&(this.diffuseFresnelParameters&&this.diffuseFresnelParameters.isEnabled&&(this._uniformBuffer.updateColor4("diffuseLeftColor",this.diffuseFresnelParameters.leftColor,this.diffuseFresnelParameters.power),this._uniformBuffer.updateColor4("diffuseRightColor",this.diffuseFresnelParameters.rightColor,this.diffuseFresnelParameters.bias)),this.opacityFresnelParameters&&this.opacityFresnelParameters.isEnabled&&this._uniformBuffer.updateColor4("opacityParts",new e.Color3(this.opacityFresnelParameters.leftColor.toLuminance(),this.opacityFresnelParameters.rightColor.toLuminance(),this.opacityFresnelParameters.bias),this.opacityFresnelParameters.power),this.reflectionFresnelParameters&&this.reflectionFresnelParameters.isEnabled&&(this._uniformBuffer.updateColor4("reflectionLeftColor",this.reflectionFresnelParameters.leftColor,this.reflectionFresnelParameters.power),this._uniformBuffer.updateColor4("reflectionRightColor",this.reflectionFresnelParameters.rightColor,this.reflectionFresnelParameters.bias)),this.refractionFresnelParameters&&this.refractionFresnelParameters.isEnabled&&(this._uniformBuffer.updateColor4("refractionLeftColor",this.refractionFresnelParameters.leftColor,this.refractionFresnelParameters.power),this._uniformBuffer.updateColor4("refractionRightColor",this.refractionFresnelParameters.rightColor,this.refractionFresnelParameters.bias)),this.emissiveFresnelParameters&&this.emissiveFresnelParameters.isEnabled&&(this._uniformBuffer.updateColor4("emissiveLeftColor",this.emissiveFresnelParameters.leftColor,this.emissiveFresnelParameters.power),this._uniformBuffer.updateColor4("emissiveRightColor",this.emissiveFresnelParameters.rightColor,this.emissiveFresnelParameters.bias))),o.texturesEnabled&&(this._diffuseTexture&&i.DiffuseTextureEnabled&&(this._uniformBuffer.updateFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),e.MaterialHelper.BindTextureMatrix(this._diffuseTexture,this._uniformBuffer,"diffuse")),this._ambientTexture&&i.AmbientTextureEnabled&&(this._uniformBuffer.updateFloat2("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level),e.MaterialHelper.BindTextureMatrix(this._ambientTexture,this._uniformBuffer,"ambient")),this._opacityTexture&&i.OpacityTextureEnabled&&(this._uniformBuffer.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),e.MaterialHelper.BindTextureMatrix(this._opacityTexture,this._uniformBuffer,"opacity")),this._reflectionTexture&&i.ReflectionTextureEnabled&&(this._uniformBuffer.updateFloat2("vReflectionInfos",this._reflectionTexture.level,this.roughness),this._uniformBuffer.updateMatrix("reflectionMatrix",this._reflectionTexture.getReflectionTextureMatrix())),this._emissiveTexture&&i.EmissiveTextureEnabled&&(this._uniformBuffer.updateFloat2("vEmissiveInfos",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),e.MaterialHelper.BindTextureMatrix(this._emissiveTexture,this._uniformBuffer,"emissive")),this._lightmapTexture&&i.LightmapTextureEnabled&&(this._uniformBuffer.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),e.MaterialHelper.BindTextureMatrix(this._lightmapTexture,this._uniformBuffer,"lightmap")),this._specularTexture&&i.SpecularTextureEnabled&&(this._uniformBuffer.updateFloat2("vSpecularInfos",this._specularTexture.coordinatesIndex,this._specularTexture.level),e.MaterialHelper.BindTextureMatrix(this._specularTexture,this._uniformBuffer,"specular")),this._bumpTexture&&o.getEngine().getCaps().standardDerivatives&&i.BumpTextureEnabled&&(this._uniformBuffer.updateFloat3("vBumpInfos",this._bumpTexture.coordinatesIndex,1/this._bumpTexture.level,this.parallaxScaleBias),e.MaterialHelper.BindTextureMatrix(this._bumpTexture,this._uniformBuffer,"bump"),o._mirroredCameraPosition?this._uniformBuffer.updateFloat4("vNormalReoderParams",this.invertNormalMapX?0:1,this.invertNormalMapX?1:-1,this.invertNormalMapY?0:1,this.invertNormalMapY?1:-1):this._uniformBuffer.updateFloat4("vNormalReoderParams",this.invertNormalMapX?1:0,this.invertNormalMapX?-1:1,this.invertNormalMapY?1:0,this.invertNormalMapY?-1:1)),this._refractionTexture&&i.RefractionTextureEnabled)){var u=1;this._refractionTexture.isCube||(this._uniformBuffer.updateMatrix("refractionMatrix",this._refractionTexture.getReflectionTextureMatrix()),this._refractionTexture.depth&&(u=this._refractionTexture.depth)),this._uniformBuffer.updateFloat4("vRefractionInfos",this._refractionTexture.level,this.indexOfRefraction,u,this.invertRefractionY?-1:1)}this.pointsCloud&&this._uniformBuffer.updateFloat("pointSize",this.pointSize),s.SPECULARTERM&&this._uniformBuffer.updateColor4("vSpecularColor",this.specularColor,this.specularPower),this._uniformBuffer.updateColor3("vEmissiveColor",this.emissiveColor),this._uniformBuffer.updateColor4("vDiffuseColor",this.diffuseColor,this.alpha*r.visibility)}if(o.texturesEnabled&&(this._diffuseTexture&&i.DiffuseTextureEnabled&&a.setTexture("diffuseSampler",this._diffuseTexture),this._ambientTexture&&i.AmbientTextureEnabled&&a.setTexture("ambientSampler",this._ambientTexture),this._opacityTexture&&i.OpacityTextureEnabled&&a.setTexture("opacitySampler",this._opacityTexture),this._reflectionTexture&&i.ReflectionTextureEnabled&&(this._reflectionTexture.isCube?a.setTexture("reflectionCubeSampler",this._reflectionTexture):a.setTexture("reflection2DSampler",this._reflectionTexture)),this._emissiveTexture&&i.EmissiveTextureEnabled&&a.setTexture("emissiveSampler",this._emissiveTexture),this._lightmapTexture&&i.LightmapTextureEnabled&&a.setTexture("lightmapSampler",this._lightmapTexture),this._specularTexture&&i.SpecularTextureEnabled&&a.setTexture("specularSampler",this._specularTexture),this._bumpTexture&&o.getEngine().getCaps().standardDerivatives&&i.BumpTextureEnabled&&a.setTexture("bumpSampler",this._bumpTexture),this._refractionTexture&&i.RefractionTextureEnabled)){var u=1;this._refractionTexture.isCube?a.setTexture("refractionCubeSampler",this._refractionTexture):a.setTexture("refraction2DSampler",this._refractionTexture)}e.MaterialHelper.BindClipPlane(a,o),o.ambientColor.multiplyToRef(this.ambientColor,this._globalAmbientColor),a.setVector3("vEyePosition",o._mirroredCameraPosition?o._mirroredCameraPosition:o.activeCamera.globalPosition),a.setColor3("vAmbientColor",this._globalAmbientColor)}!this._mustRebind(o,a)&&this.isFrozen||(o.lightsEnabled&&!this._disableLighting&&e.MaterialHelper.BindLights(o,r,a,s,this._maxSimultaneousLights),(o.fogEnabled&&r.applyFog&&o.fogMode!==e.Scene.FOGMODE_NONE||this._reflectionTexture||this._refractionTexture)&&this.bindView(a),e.MaterialHelper.BindFogParameters(o,r,a),s.NUM_MORPH_INFLUENCERS&&e.MaterialHelper.BindMorphTargetParameters(r,a),e.MaterialHelper.BindLogDepth(s,a,o),this._imageProcessingConfiguration.bind(this._activeEffect)),this._uniformBuffer.update(),this._afterBind(r,this._activeEffect)}},i.prototype.getAnimatables=function(){var e=[];return this._diffuseTexture&&this._diffuseTexture.animations&&this._diffuseTexture.animations.length>0&&e.push(this._diffuseTexture),this._ambientTexture&&this._ambientTexture.animations&&this._ambientTexture.animations.length>0&&e.push(this._ambientTexture),this._opacityTexture&&this._opacityTexture.animations&&this._opacityTexture.animations.length>0&&e.push(this._opacityTexture),this._reflectionTexture&&this._reflectionTexture.animations&&this._reflectionTexture.animations.length>0&&e.push(this._reflectionTexture),this._emissiveTexture&&this._emissiveTexture.animations&&this._emissiveTexture.animations.length>0&&e.push(this._emissiveTexture),this._specularTexture&&this._specularTexture.animations&&this._specularTexture.animations.length>0&&e.push(this._specularTexture),this._bumpTexture&&this._bumpTexture.animations&&this._bumpTexture.animations.length>0&&e.push(this._bumpTexture),this._lightmapTexture&&this._lightmapTexture.animations&&this._lightmapTexture.animations.length>0&&e.push(this._lightmapTexture),this._refractionTexture&&this._refractionTexture.animations&&this._refractionTexture.animations.length>0&&e.push(this._refractionTexture),e},i.prototype.getActiveTextures=function(){var e=r.prototype.getActiveTextures.call(this);return this._diffuseTexture&&e.push(this._diffuseTexture),this._ambientTexture&&e.push(this._ambientTexture),this._opacityTexture&&e.push(this._opacityTexture),this._reflectionTexture&&e.push(this._reflectionTexture),this._emissiveTexture&&e.push(this._emissiveTexture),this._specularTexture&&e.push(this._specularTexture),this._bumpTexture&&e.push(this._bumpTexture),this._lightmapTexture&&e.push(this._lightmapTexture),this._refractionTexture&&e.push(this._refractionTexture),e},i.prototype.hasTexture=function(e){return!!r.prototype.hasTexture.call(this,e)||(this._diffuseTexture===e||(this._ambientTexture===e||(this._opacityTexture===e||(this._reflectionTexture===e||(this._emissiveTexture===e||(this._specularTexture===e||(this._bumpTexture===e||(this._lightmapTexture===e||this._refractionTexture===e))))))))},i.prototype.dispose=function(e,t){t&&(this._diffuseTexture&&this._diffuseTexture.dispose(),this._ambientTexture&&this._ambientTexture.dispose(),this._opacityTexture&&this._opacityTexture.dispose(),this._reflectionTexture&&this._reflectionTexture.dispose(),this._emissiveTexture&&this._emissiveTexture.dispose(),this._specularTexture&&this._specularTexture.dispose(),this._bumpTexture&&this._bumpTexture.dispose(),this._lightmapTexture&&this._lightmapTexture.dispose(),this._refractionTexture&&this._refractionTexture.dispose()),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),r.prototype.dispose.call(this,e,t)},i.prototype.clone=function(t){var r=this,n=e.SerializationHelper.Clone((function(){return new i(t,r.getScene())}),this);return n.name=t,n.id=t,n},i.prototype.serialize=function(){return e.SerializationHelper.Serialize(this)},i.Parse=function(t,r,n){return e.SerializationHelper.Parse((function(){return new i(t.name,r)}),t,r,n)},Object.defineProperty(i,"DiffuseTextureEnabled",{get:function(){return i._DiffuseTextureEnabled},set:function(t){i._DiffuseTextureEnabled!==t&&(i._DiffuseTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(i,"AmbientTextureEnabled",{get:function(){return i._AmbientTextureEnabled},set:function(t){i._AmbientTextureEnabled!==t&&(i._AmbientTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(i,"OpacityTextureEnabled",{get:function(){return i._OpacityTextureEnabled},set:function(t){i._OpacityTextureEnabled!==t&&(i._OpacityTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(i,"ReflectionTextureEnabled",{get:function(){return i._ReflectionTextureEnabled},set:function(t){i._ReflectionTextureEnabled!==t&&(i._ReflectionTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(i,"EmissiveTextureEnabled",{get:function(){return i._EmissiveTextureEnabled},set:function(t){i._EmissiveTextureEnabled!==t&&(i._EmissiveTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(i,"SpecularTextureEnabled",{get:function(){return i._SpecularTextureEnabled},set:function(t){i._SpecularTextureEnabled!==t&&(i._SpecularTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(i,"BumpTextureEnabled",{get:function(){ +return i._BumpTextureEnabled},set:function(t){i._BumpTextureEnabled!==t&&(i._BumpTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(i,"LightmapTextureEnabled",{get:function(){return i._LightmapTextureEnabled},set:function(t){i._LightmapTextureEnabled!==t&&(i._LightmapTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(i,"RefractionTextureEnabled",{get:function(){return i._RefractionTextureEnabled},set:function(t){i._RefractionTextureEnabled!==t&&(i._RefractionTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(i,"ColorGradingTextureEnabled",{get:function(){return i._ColorGradingTextureEnabled},set:function(t){i._ColorGradingTextureEnabled!==t&&(i._ColorGradingTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(i,"FresnelEnabled",{get:function(){return i._FresnelEnabled},set:function(t){i._FresnelEnabled!==t&&(i._FresnelEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.FresnelDirtyFlag))},enumerable:!0,configurable:!0}),i})(e.PushMaterial);r._DiffuseTextureEnabled=!0,r._AmbientTextureEnabled=!0,r._OpacityTextureEnabled=!0,r._ReflectionTextureEnabled=!0,r._EmissiveTextureEnabled=!0,r._SpecularTextureEnabled=!0,r._BumpTextureEnabled=!0,r._LightmapTextureEnabled=!0,r._RefractionTextureEnabled=!0,r._ColorGradingTextureEnabled=!0,r._FresnelEnabled=!0,__decorate([e.serializeAsTexture("diffuseTexture")],r.prototype,"_diffuseTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"diffuseTexture",void 0),__decorate([e.serializeAsTexture("ambientTexture")],r.prototype,"_ambientTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"ambientTexture",void 0),__decorate([e.serializeAsTexture("opacityTexture")],r.prototype,"_opacityTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"opacityTexture",void 0),__decorate([e.serializeAsTexture("reflectionTexture")],r.prototype,"_reflectionTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"reflectionTexture",void 0),__decorate([e.serializeAsTexture("emissiveTexture")],r.prototype,"_emissiveTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"emissiveTexture",void 0),__decorate([e.serializeAsTexture("specularTexture")],r.prototype,"_specularTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"specularTexture",void 0),__decorate([e.serializeAsTexture("bumpTexture")],r.prototype,"_bumpTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"bumpTexture",void 0),__decorate([e.serializeAsTexture("lightmapTexture")],r.prototype,"_lightmapTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"lightmapTexture",void 0),__decorate([e.serializeAsTexture("refractionTexture")],r.prototype,"_refractionTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"refractionTexture",void 0),__decorate([e.serializeAsColor3("ambient")],r.prototype,"ambientColor",void 0),__decorate([e.serializeAsColor3("diffuse")],r.prototype,"diffuseColor",void 0),__decorate([e.serializeAsColor3("specular")],r.prototype,"specularColor",void 0),__decorate([e.serializeAsColor3("emissive")],r.prototype,"emissiveColor",void 0),__decorate([e.serialize()],r.prototype,"specularPower",void 0),__decorate([e.serialize("useAlphaFromDiffuseTexture")],r.prototype,"_useAlphaFromDiffuseTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useAlphaFromDiffuseTexture",void 0),__decorate([e.serialize("useEmissiveAsIllumination")],r.prototype,"_useEmissiveAsIllumination",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useEmissiveAsIllumination",void 0),__decorate([e.serialize("linkEmissiveWithDiffuse")],r.prototype,"_linkEmissiveWithDiffuse",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"linkEmissiveWithDiffuse",void 0),__decorate([e.serialize("useSpecularOverAlpha")],r.prototype,"_useSpecularOverAlpha",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useSpecularOverAlpha",void 0),__decorate([e.serialize("useReflectionOverAlpha")],r.prototype,"_useReflectionOverAlpha",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useReflectionOverAlpha",void 0),__decorate([e.serialize("disableLighting")],r.prototype,"_disableLighting",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsLightsDirty")],r.prototype,"disableLighting",void 0),__decorate([e.serialize("useParallax")],r.prototype,"_useParallax",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useParallax",void 0),__decorate([e.serialize("useParallaxOcclusion")],r.prototype,"_useParallaxOcclusion",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useParallaxOcclusion",void 0),__decorate([e.serialize()],r.prototype,"parallaxScaleBias",void 0),__decorate([e.serialize("roughness")],r.prototype,"_roughness",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"roughness",void 0),__decorate([e.serialize()],r.prototype,"indexOfRefraction",void 0),__decorate([e.serialize()],r.prototype,"invertRefractionY",void 0),__decorate([e.serialize("useLightmapAsShadowmap")],r.prototype,"_useLightmapAsShadowmap",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useLightmapAsShadowmap",void 0),__decorate([e.serializeAsFresnelParameters("diffuseFresnelParameters")],r.prototype,"_diffuseFresnelParameters",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],r.prototype,"diffuseFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters("opacityFresnelParameters")],r.prototype,"_opacityFresnelParameters",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],r.prototype,"opacityFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters("reflectionFresnelParameters")],r.prototype,"_reflectionFresnelParameters",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],r.prototype,"reflectionFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters("refractionFresnelParameters")],r.prototype,"_refractionFresnelParameters",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],r.prototype,"refractionFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters("emissiveFresnelParameters")],r.prototype,"_emissiveFresnelParameters",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],r.prototype,"emissiveFresnelParameters",void 0),__decorate([e.serialize("useReflectionFresnelFromSpecular")],r.prototype,"_useReflectionFresnelFromSpecular",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],r.prototype,"useReflectionFresnelFromSpecular",void 0),__decorate([e.serialize("useGlossinessFromSpecularMapAlpha")],r.prototype,"_useGlossinessFromSpecularMapAlpha",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useGlossinessFromSpecularMapAlpha",void 0),__decorate([e.serialize("maxSimultaneousLights")],r.prototype,"_maxSimultaneousLights",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsLightsDirty")],r.prototype,"maxSimultaneousLights",void 0),__decorate([e.serialize("invertNormalMapX")],r.prototype,"_invertNormalMapX",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"invertNormalMapX",void 0),__decorate([e.serialize("invertNormalMapY")],r.prototype,"_invertNormalMapY",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"invertNormalMapY",void 0),__decorate([e.serialize("twoSidedLighting")],r.prototype,"_twoSidedLighting",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"twoSidedLighting",void 0),__decorate([e.serialize()],r.prototype,"useLogarithmicDepth",null),e.StandardMaterial=r})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(){this._count=0,this._data={}}return e.prototype.copyFrom=function(e){var t=this;this.clear(),e.forEach((function(e,r){return t.add(e,r)}))},e.prototype.get=function(e){var t=this._data[e];if(void 0!==t)return t},e.prototype.getOrAddWithFactory=function(e,t){var r=this.get(e);return void 0!==r?r:(r=t(e),r&&this.add(e,r),r)},e.prototype.getOrAdd=function(e,t){var r=this.get(e);return void 0!==r?r:(this.add(e,t),t)},e.prototype.contains=function(e){return void 0!==this._data[e]},e.prototype.add=function(e,t){return void 0===this._data[e]&&(this._data[e]=t,++this._count,!0)},e.prototype.set=function(e,t){return void 0!==this._data[e]&&(this._data[e]=t,!0)},e.prototype.getAndRemove=function(e){var t=this.get(e);return void 0!==t?(delete this._data[e],--this._count,t):null},e.prototype.remove=function(e){return!!this.contains(e)&&(delete this._data[e],--this._count,!0)},e.prototype.clear=function(){this._data={},this._count=0},Object.defineProperty(e.prototype,"count",{get:function(){return this._count},enumerable:!0,configurable:!0}),e.prototype.forEach=function(e){for(var t in this._data){e(t,this._data[t])}},e.prototype.first=function(e){for(var t in this._data){var r=this._data[t],i=e(t,r);if(i)return i}return null},e})();e.StringDictionary=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(){}return e})();e.DynamicFloatArrayElementInfo=t;var r=(function(){function e(e,r){this.compareValueOffset=null,this.sortingAscending=!0,this._stride=e,this.buffer=new Float32Array(e*r),this._lastUsed=0,this._firstFree=0,this._allEntries=new Array(r),this._freeEntries=new Array(r);for(var i=0;i0?this._firstFree=this._freeEntries[this._freeEntries.length-1].offset:this._firstFree+=this._stride),e},e.prototype.freeElement=function(e){this._firstFree=Math.min(e.offset,this._firstFree),this._freeEntries.push(e)},e.prototype.pack=function(){if(0===this._freeEntries.length)return this.buffer;if(this._lastUsed=a);l++){var c=i[l],h=c.offset,f=h-u;if(f!==e){for(var d=f/e-1,p=h-e,g=Math.min(s,d),_=0;_this.value;case r.IsLesser:return this._effectiveTarget[this._property]-1&&this._scene._actionManagers.splice(e,1)},t.prototype.getScene=function(){return this._scene},t.prototype.hasSpecificTriggers=function(e){for(var t=0;t-1)return!0}return!1},t.prototype.hasSpecificTrigger=function(e){for(var t=0;t=t._OnPickTrigger&&r.trigger<=t._OnPointerOutTrigger)return!0}return!1},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"hasPickTriggers",{get:function(){for(var e=0;e=t._OnPickTrigger&&r.trigger<=t._OnPickUpTrigger)return!0}return!1},enumerable:!0,configurable:!0}),Object.defineProperty(t,"HasTriggers",{get:function(){for(var e in t.Triggers)if(t.Triggers.hasOwnProperty(e))return!0;return!1},enumerable:!0,configurable:!0}),Object.defineProperty(t,"HasPickTriggers",{get:function(){for(var e in t.Triggers)if(t.Triggers.hasOwnProperty(e)){var r=parseInt(e);if(r>=t._OnPickTrigger&&r<=t._OnPickUpTrigger)return!0}return!1},enumerable:!0,configurable:!0}),t.HasSpecificTrigger=function(e){for(var r in t.Triggers)if(t.Triggers.hasOwnProperty(r)){var i=parseInt(r);if(i===e)return!0}return!1},t.prototype.registerAction=function(r){return r.trigger===t.OnEveryFrameTrigger&&this.getScene().actionManager!==this?(e.Tools.Warn("OnEveryFrameTrigger can only be used with scene.actionManager"),null):(this.actions.push(r),t.Triggers[r.trigger]?t.Triggers[r.trigger]++:t.Triggers[r.trigger]=1,r._actionManager=this,r._prepare(),r)},t.prototype.processTrigger=function(e,r){for(var i=0;i0;if(2===r.type?f.push(o):f.push(i),g){for(var _=new Array,m=0;m0){var f=h.properties[0].value,d=null===h.properties[0].targetType?f:n.getMeshByName(f);d._meshId&&(d.mesh=n.getMeshByID(d._meshId)),c={trigger:e.ActionManager[h.name],parameter:d}}else c=e.ActionManager[h.name];for(var p=0;p=0;s--){var a=t[s],u=a.getParent();if(u){var l=this._debugLines[n];l||(l=[e.Vector3.Zero(),e.Vector3.Zero()],this._debugLines[n]=l),a.getAbsolutePositionToRef(this.mesh,l[0]),u.getAbsolutePositionToRef(this.mesh,l[1]),l[0].subtractInPlace(o),l[1].subtractInPlace(o),n++}}},t.prototype.update=function(){this.autoUpdateBonesMatrices&&this.skeleton.computeAbsoluteTransforms(),void 0===this.skeleton.bones[0].length?this._getLinesForBonesNoLength(this.skeleton.bones,this.mesh.getWorldMatrix()):this._getLinesForBonesWithLength(this.skeleton.bones,this.mesh.getWorldMatrix()),this._debugMesh?e.MeshBuilder.CreateLineSystem(null,{lines:this._debugLines,updatable:!0,instance:this._debugMesh},this._scene):(this._debugMesh=e.MeshBuilder.CreateLineSystem(null,{lines:this._debugLines,updatable:!0},this._scene),this._debugMesh.renderingGroupId=this.renderingGroupId),this._debugMesh.position.copyFrom(this.mesh.position),this._debugMesh.color=this.color},t.prototype.dispose=function(){this._debugMesh&&(this.isEnabled=!1,this._debugMesh.dispose(),this._debugMesh=null)},t})();t.SkeletonViewer=r})(e.Debug||(e.Debug={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){var r=(function(){function t(t,r){void 0===r&&(r=1),this._xline=[e.Vector3.Zero(),e.Vector3.Zero()],this._yline=[e.Vector3.Zero(),e.Vector3.Zero()],this._zline=[e.Vector3.Zero(),e.Vector3.Zero()],this.scaleLines=1,this.scaleLines=r,this._xmesh=e.Mesh.CreateLines("xline",this._xline,t,!0),this._ymesh=e.Mesh.CreateLines("yline",this._yline,t,!0),this._zmesh=e.Mesh.CreateLines("zline",this._zline,t,!0),this._xmesh.renderingGroupId=2,this._ymesh.renderingGroupId=2,this._zmesh.renderingGroupId=2,this._xmesh.material.checkReadyOnlyOnce=!0,this._xmesh.color=new e.Color3(1,0,0),this._ymesh.material.checkReadyOnlyOnce=!0,this._ymesh.color=new e.Color3(0,1,0),this._zmesh.material.checkReadyOnlyOnce=!0,this._zmesh.color=new e.Color3(0,0,1),this.scene=t}return t.prototype.update=function(t,r,i,n){var o=this.scaleLines;this._xmesh.position.copyFrom(t),this._ymesh.position.copyFrom(t),this._zmesh.position.copyFrom(t);var s=this._xline[1];s.x=r.x*o,s.y=r.y*o,s.z=r.z*o,e.Mesh.CreateLines(null,this._xline,null,null,this._xmesh),s=this._yline[1],s.x=i.x*o,s.y=i.y*o,s.z=i.z*o,e.Mesh.CreateLines(null,this._yline,null,null,this._ymesh),s=this._zline[1],s.x=n.x*o,s.y=n.y*o,s.z=n.z*o,e.Mesh.CreateLines(null,this._zline,null,null,this._zmesh)},t.prototype.dispose=function(){this._xmesh&&(this._xmesh.dispose(),this._ymesh.dispose(),this._zmesh.dispose(),this._xmesh=null,this._ymesh=null,this._zmesh=null,this._xline=null,this._yline=null,this._zline=null,this.scene=null)},t})();t.AxesViewer=r})(e.Debug||(e.Debug={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){var r=(function(t){function r(r,i,n,o){void 0===o&&(o=1);var s=t.call(this,r,o)||this;return s.pos=e.Vector3.Zero(),s.xaxis=e.Vector3.Zero(),s.yaxis=e.Vector3.Zero(),s.zaxis=e.Vector3.Zero(),s.mesh=n,s.bone=i,s}return __extends(r,t),r.prototype.update=function(){var r=this.bone;r.getAbsolutePositionToRef(this.mesh,this.pos),r.getDirectionToRef(e.Axis.X,this.mesh,this.xaxis),r.getDirectionToRef(e.Axis.Y,this.mesh,this.yaxis),r.getDirectionToRef(e.Axis.Z,this.mesh,this.zaxis),t.prototype.update.call(this,this.pos,this.xaxis,this.yaxis,this.zaxis)},r.prototype.dispose=function(){this.pos&&(this.pos=null,this.xaxis=null,this.yaxis=null,this.zaxis=null,this.mesh=null,this.bone=null,t.prototype.dispose.call(this))},r})(t.AxesViewer);t.BoneAxesViewer=r})(e.Debug||(e.Debug={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e){this.ray=e}return t.CreateAndShow=function(e,r,i){var n=new t(e);return n.show(r,i),n},t.prototype.show=function(t,r){if(!this._renderFunction){var i=this.ray;this._renderFunction=this._render.bind(this),this._scene=t,this._renderPoints=[i.origin,i.origin.add(i.direction.scale(i.length))],this._renderLine=e.Mesh.CreateLines("ray",this._renderPoints,t,!0),this._scene.registerBeforeRender(this._renderFunction)}r&&this._renderLine.color.copyFrom(r)},t.prototype.hide=function(){this._renderFunction&&(this._scene.unregisterBeforeRender(this._renderFunction),this._scene=null,this._renderFunction=null,this._renderLine.dispose(),this._renderLine=null,this._renderPoints=null)},t.prototype._render=function(){var t=this.ray,r=this._renderPoints[1],i=Math.min(t.length,1e6);r.copyFrom(t.direction),r.scaleInPlace(i),r.addInPlace(t.origin),e.Mesh.CreateLines("ray",this._renderPoints,this._scene,!0,this._renderLine)},t.prototype.attachToMesh=function(t,r,i,n){this._attachedToMesh=t;var o=this.ray;o.direction||(o.direction=e.Vector3.Zero()),o.origin||(o.origin=e.Vector3.Zero()),n&&(o.length=n),i||(i=e.Vector3.Zero()),r||(r=new e.Vector3(0,0,-1)),this._meshSpaceDirection?(this._meshSpaceDirection.copyFrom(r),this._meshSpaceOrigin.copyFrom(i)):(this._meshSpaceDirection=r.clone(),this._meshSpaceOrigin=i.clone()),this._updateToMeshFunction||(this._updateToMeshFunction=this._updateToMesh.bind(this),this._attachedToMesh.getScene().registerBeforeRender(this._updateToMeshFunction)),this._updateToMesh()},t.prototype.detachFromMesh=function(){this._attachedToMesh&&(this._attachedToMesh.getScene().unregisterBeforeRender(this._updateToMeshFunction),this._attachedToMesh=null,this._updateToMeshFunction=null)},t.prototype._updateToMesh=function(){var t=this.ray;if(this._attachedToMesh._isDisposed)return void this.detachFromMesh();this._attachedToMesh.getDirectionToRef(this._meshSpaceDirection,t.direction),e.Vector3.TransformCoordinatesToRef(this._meshSpaceOrigin,this._attachedToMesh.getWorldMatrix(),t.origin)},t.prototype.dispose=function(){this.hide(),this.detachFromMesh(),this.ray=null},t})();e.RayHelper=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e){this._scene=e}return t.prototype._createInspector=function(e){void 0===e&&(e={});var t=e.popup||!1,r=e.initialTab||0,i=e.parentElement||null;this._inspector||(this._inspector=new INSPECTOR.Inspector(this._scene,t,r,i,e.newColors))},t.prototype.isVisible=function(){return!!this._inspector},t.prototype.hide=function(){if(this._inspector){try{this._inspector.dispose()}catch(e){}this._inspector=null}},t.prototype.show=function(r){void 0===r&&(r={}),"undefined"==typeof INSPECTOR?e.Tools.LoadScript(t.InspectorURL,this._createInspector.bind(this,r)):this._createInspector(r)},t})();t.InspectorURL=window.location.href.split("/")[0]+"//preview.babylonjs.com/inspector/babylon.inspector.bundle.js",e.DebugLayer=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){var r=(function(){function t(t){this._impostors=[],this._meshes=[],this._numMeshes=0,this._scene=t||e.Engine.LastCreatedScene,this._physicsEnginePlugin=this._scene.getPhysicsEngine().getPhysicsPlugin()}return t.prototype._updateDebugMeshes=function(){for(var e=this._physicsEnginePlugin,t=0;t0?(this._meshes[r]=this._meshes[this._numMeshes],this._impostors[r]=this._impostors[this._numMeshes],this._meshes[this._numMeshes]=null,this._impostors[this._numMeshes]=null):(this._meshes[0]=null,this._impostors[0]=null),t=!0;break}t&&0===this._numMeshes&&this._scene.unregisterBeforeRender(this._renderFunction)},t.prototype._getDebugMaterial=function(t){return this._debugMaterial||(this._debugMaterial=new e.StandardMaterial("",t),this._debugMaterial.wireframe=!0),this._debugMaterial},t.prototype._getDebugBoxMesh=function(t){return this._debugBoxMesh||(this._debugBoxMesh=e.MeshBuilder.CreateBox("physicsBodyBoxViewMesh",{size:1},t),this._debugBoxMesh.renderingGroupId=1,this._debugBoxMesh.rotationQuaternion=e.Quaternion.Identity(),this._debugBoxMesh.material=this._getDebugMaterial(t),t.removeMesh(this._debugBoxMesh)),this._debugBoxMesh.createInstance("physicsBodyBoxViewInstance")},t.prototype._getDebugSphereMesh=function(t){return this._debugSphereMesh||(this._debugSphereMesh=e.MeshBuilder.CreateSphere("physicsBodySphereViewMesh",{diameter:1},t),this._debugSphereMesh.renderingGroupId=1,this._debugSphereMesh.rotationQuaternion=e.Quaternion.Identity(),this._debugSphereMesh.material=this._getDebugMaterial(t),t.removeMesh(this._debugSphereMesh)),this._debugSphereMesh.createInstance("physicsBodyBoxViewInstance")},t.prototype._getDebugMesh=function(t,r){var i,n=t.physicsBody;n.shapes[0];if(t.type==e.PhysicsImpostor.BoxImpostor)i=this._getDebugBoxMesh(r),t.getBoxSizeToRef(i.scaling);else if(t.type==e.PhysicsImpostor.SphereImpostor){i=this._getDebugSphereMesh(r);var o=t.getRadius();i.scaling.x=2*o,i.scaling.y=2*o,i.scaling.z=2*o}return i},t.prototype.dispose=function(){for(var e=0;eMath.PI;)n-=2*Math.PI;var s=n/Math.PI,a=o/Math.PI;s=.5*s+.5;var u=Math.round(s*r);u<0?u=0:u>=r&&(u=r-1);var l=Math.round(a*i);l<0?l=0:l>=i&&(l=i-1);var c=i-l-1;return{r:t[c*r*3+3*u+0],g:t[c*r*3+3*u+1],b:t[c*r*3+3*u+2]}},t})();r.FACE_FRONT=[new e.Vector3(-1,-1,-1),new e.Vector3(1,-1,-1),new e.Vector3(-1,1,-1),new e.Vector3(1,1,-1)],r.FACE_BACK=[new e.Vector3(1,-1,1),new e.Vector3(-1,-1,1),new e.Vector3(1,1,1),new e.Vector3(-1,1,1)],r.FACE_RIGHT=[new e.Vector3(1,-1,-1),new e.Vector3(1,-1,1),new e.Vector3(1,1,-1),new e.Vector3(1,1,1)],r.FACE_LEFT=[new e.Vector3(-1,-1,1),new e.Vector3(-1,-1,-1),new e.Vector3(-1,1,1),new e.Vector3(-1,1,-1)],r.FACE_DOWN=[new e.Vector3(-1,1,-1),new e.Vector3(1,1,-1),new e.Vector3(-1,1,1),new e.Vector3(1,1,1)],r.FACE_UP=[new e.Vector3(-1,-1,1),new e.Vector3(1,-1,1),new e.Vector3(-1,-1,-1),new e.Vector3(1,-1,-1)],t.PanoramaToCubeMapTools=r})(e.Internals||(e.Internals={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(e){var t=(function(){function t(){}return t.Ldexp=function(e,t){return t>1023?e*Math.pow(2,1023)*Math.pow(2,t-1023):t<-1074?e*Math.pow(2,-1074)*Math.pow(2,t+1074):e*Math.pow(2,t)},t.Rgbe2float=function(e,t,r,i,n,o){n>0?(n=this.Ldexp(1,n-136),e[o+0]=t*n,e[o+1]=r*n,e[o+2]=i*n):(e[o+0]=0,e[o+1]=0,e[o+2]=0)},t.readStringLine=function(e,t){for(var r="",i="",n=t;n32767)throw"HDR Bad header format, unsupported size";return s+=i.length+1,{height:t,width:r,dataPosition:s}},t.GetCubeMapTextureData=function(t,r){var i=new Uint8Array(t),n=this.RGBE_ReadHeader(i),o=this.RGBE_ReadPixels_RLE(i,n);return e.PanoramaToCubeMapTools.ConvertPanoramaToCubemap(o,n.width,n.height,r)},t.RGBE_ReadPixels=function(e,t){return this.RGBE_ReadPixels_RLE(e,t)},t.RGBE_ReadPixels_RLE=function(e,t){for(var r,i,n,o,s,a=t.height,u=t.width,l=t.dataPosition,c=0,h=0,f=0,d=new ArrayBuffer(4*u),p=new Uint8Array(d),g=new ArrayBuffer(t.width*t.height*4*3),_=new Float32Array(g);a>0;){if(r=e[l++],i=e[l++],n=e[l++],o=e[l++],2!=r||2!=i||128&n)throw"HDR Bad header format, not RLE";if((n<<8|o)!=u)throw"HDR Bad header format, wrong scan line width";for(c=0,f=0;f<4;f++)for(h=(f+1)*u;c128){if(0==(s=r-128)||s>h-c)throw"HDR Bad Format, bad scanline data (run)";for(;s-- >0;)p[c++]=i}else{if(0==(s=r)||s>h-c)throw"HDR Bad Format, bad scanline data (non-run)";if(p[c++]=i,--s>0)for(var m=0;m>s,2),u=0;u<6;u++){var l=i.subarray(o,o+a);n[s].push(l),o+=a}}return n}:null,o=function(o){var s=new Int32Array(o);i=new Float32Array(o);var a=s[0];t._size=s[1],t.getScene().getEngine().updateTextureSize(t._texture,t._size,t._size);var u=new e.SphericalPolynomial;u.x.copyFromFloats(i[2],i[3],i[4]),u.y.copyFromFloats(i[5],i[6],i[7]),u.z.copyFromFloats(i[8],i[9],i[10]),u.xx.copyFromFloats(i[11],i[12],i[13]),u.yy.copyFromFloats(i[14],i[15],i[16]),u.zz.copyFromFloats(i[17],i[18],i[19]),u.xy.copyFromFloats(i[20],i[21],i[22]),u.yz.copyFromFloats(i[23],i[24],i[25]),u.zx.copyFromFloats(i[26],i[27],i[28]),t.sphericalPolynomial=u,r=s[29];for(var l=30,c=[],h=3*Math.pow(t._size,2),f=0;f<6;f++)c.push(i.subarray(l,l+h)),l+=h;for(var d=[],p=null,g=0;g<6;g++){var _=null;if(1===a){_=c[[0,2,4,1,3,5][g]]}if(!n){if(!t.getScene().getEngine().getCaps().textureFloat){var m=new ArrayBuffer(h);p=new Uint8Array(m)}for(var v=0;v255){var b=255/T;y*=b,A*=b,E*=b}p[3*v+0]=y,p[3*v+1]=A,p[3*v+2]=E}}p?d.push(p):d.push(_)}return d};this._texture=this.getScene().getEngine().createRawCubeTextureFromUrl(this.url,this.getScene(),this._size,e.Engine.TEXTUREFORMAT_RGB,this.getScene().getEngine().getCaps().textureFloat?e.Engine.TEXTURETYPE_FLOAT:e.Engine.TEXTURETYPE_UNSIGNED_INT,this._noMipmap,o,n,this._onLoad,this._onError)},r.prototype.loadHDRTexture=function(){var t=this,i=function(i){var n=e.Internals.HDRTools.GetCubeMapTextureData(i,t._size);if(t._generateHarmonics){var o=e.Internals.CubeMapToSphericalPolynomialTools.ConvertCubeMapToSphericalPolynomial(n);t.sphericalPolynomial=o}for(var s=[],a=null,u=0;u<6;u++){if(!t.getScene().getEngine().getCaps().textureFloat){var l=new ArrayBuffer(t._size*t._size*3);a=new Uint8Array(l)}var c=n[r._facesMapping[u]];if(t._useInGammaSpace||a)for(var h=0;h255){var _=255/g;f*=_,d*=_,p*=_}a[3*h+0]=f,a[3*h+1]=d,a[3*h+2]=p}a?s.push(a):s.push(c)}return s};this._texture=this.getScene().getEngine().createRawCubeTextureFromUrl(this.url,this.getScene(),this._size,e.Engine.TEXTUREFORMAT_RGB,this.getScene().getEngine().getCaps().textureFloat?e.Engine.TEXTURETYPE_FLOAT:e.Engine.TEXTURETYPE_UNSIGNED_INT,this._noMipmap,i,null,this._onLoad,this._onError)},r.prototype.loadTexture=function(){this._isBABYLONPreprocessed?this.loadBabylonTexture():this.loadHDRTexture()},r.prototype.clone=function(){var e=this._isBABYLONPreprocessed?null:this._size,t=new r(this.url,this.getScene(),e,this._noMipmap,this._generateHarmonics,this._useInGammaSpace,this._usePMREMGenerator);return t.level=this.level,t.wrapU=this.wrapU,t.wrapV=this.wrapV,t.coordinatesIndex=this.coordinatesIndex,t.coordinatesMode=this.coordinatesMode,t},r.prototype.delayLoad=function(){this.delayLoadState===e.Engine.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=e.Engine.DELAYLOADSTATE_LOADED,this._texture=this._getFromCache(this.url,this._noMipmap),this._texture||this.loadTexture())},r.prototype.getReflectionTextureMatrix=function(){return this._textureMatrix},r.prototype.setReflectionTextureMatrix=function(e){this._textureMatrix=e},r.Parse=function(t,r,i){var n=null;if(t.name&&!t.isRenderTarget){var o=t.isBABYLONPreprocessed?null:t.size;n=new e.HDRCubeTexture(i+t.name,r,o,t.noMipmap,t.generateHarmonics,t.useInGammaSpace,t.usePMREMGenerator),n.name=t.name,n.hasAlpha=t.hasAlpha,n.level=t.level,n.coordinatesMode=t.coordinatesMode,n.isBlocking=t.isBlocking}return n},r.prototype.serialize=function(){if(!this.name)return null;var e={};return e.name=this.name,e.hasAlpha=this.hasAlpha,e.isCube=!0,e.level=this.level,e.size=this._size,e.coordinatesMode=this.coordinatesMode,e.useInGammaSpace=this._useInGammaSpace,e.generateHarmonics=this._generateHarmonics,e.usePMREMGenerator=this._usePMREMGenerator,e.isBABYLONPreprocessed=this._isBABYLONPreprocessed,e.customType="BABYLON.HDRCubeTexture",e.noMipmap=this._noMipmap,e.isBlocking=this._isBlocking,e},r.generateBabylonHDROnDisk=function(e,t,i){void 0===i&&(i=null);var n=function(e){var t=new Blob([e],{type:"application/octet-stream"}),r=window.URL.createObjectURL(t),i=document.createElement("a");document.body.appendChild(i),i.style.display="none",i.href=r,i.download="envmap.babylon.hdr",i.click()};r.generateBabylonHDR(e,t,n,i)},r.generateBabylonHDR=function(t,r,i,n){return void 0===n&&(n=null),t&&e.Tools.IsExponentOfTwo(r)?(e.Tools.Error("Generation of Babylon HDR is coming back in 3.1."),null):null},r})(e.BaseTexture);t._facesMapping=["right","left","up","down","front","back"],e.HDRCubeTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(e,t,r){void 0===t&&(t=""),void 0===r&&(r="black");var i=this;this._renderingCanvas=e,this._loadingText=t,this._loadingDivBackgroundColor=r,this._resizeLoadingUI=function(){var e=i._renderingCanvas.getBoundingClientRect(),t=window.getComputedStyle(i._renderingCanvas).position;i._loadingDiv.style.position="fixed"===t?"fixed":"absolute",i._loadingDiv.style.left=e.left+"px",i._loadingDiv.style.top=e.top+"px",i._loadingDiv.style.width=e.width+"px",i._loadingDiv.style.height=e.height+"px"}}return e.prototype.displayLoadingUI=function(){if(!this._loadingDiv){this._loadingDiv=document.createElement("div"),this._loadingDiv.id="babylonjsLoadingDiv",this._loadingDiv.style.opacity="0",this._loadingDiv.style.transition="opacity 1.5s ease",this._loadingTextDiv=document.createElement("div"),this._loadingTextDiv.style.position="absolute",this._loadingTextDiv.style.left="0",this._loadingTextDiv.style.top="50%",this._loadingTextDiv.style.marginTop="80px",this._loadingTextDiv.style.width="100%",this._loadingTextDiv.style.height="20px",this._loadingTextDiv.style.fontFamily="Arial",this._loadingTextDiv.style.fontSize="14px",this._loadingTextDiv.style.color="white",this._loadingTextDiv.style.textAlign="center",this._loadingTextDiv.innerHTML="Loading",this._loadingDiv.appendChild(this._loadingTextDiv),this._loadingTextDiv.innerHTML=this._loadingText;var e=document.createElement("style");e.type="text/css";e.innerHTML="@-webkit-keyframes spin1 { 0% { -webkit-transform: rotate(0deg);}\n 100% { -webkit-transform: rotate(360deg);}\n } @keyframes spin1 { 0% { transform: rotate(0deg);}\n 100% { transform: rotate(360deg);}\n }",document.getElementsByTagName("head")[0].appendChild(e);var t=new Image;t.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAYAAAA5ZDbSAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAZdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuMTZEaa/1AAAYq0lEQVR4Xu2dCZRcVZnHScAJUZSwjSOIbAJmEAZwQCCMoAInYRGIg8AwegQx7AFzUBBmzAFlE4EAwxz2GRk2w7AnAURZBiEOZgyEQDAQAjmEJqTpNd3V1V3Vmd+/6utKV7/1vnpVXd2p/zn3vOV+27vfu/fd/W3QQAPrBZqbm7fJZrN79vf3T+/r67uf4wO9vb37WXQDIwWtra0Tenp6voQTv5XP56/BkfcR3iLk1g6B7hEeI+zP5V+ZiAbqBZ2dnZ8lV+6Gg87CobfhpOc4byf0FjwYE9DneBkWcXrM2tmzNzTxDdQKJPyETCazI46YgiMuI9zJuXJltuChFIHsP/PSfIfTjU19A2mira1tcxy3ey6XO5vEnkV4kes11XBmENDVj97XOT2O03FmWgMuoNLzGRJva8IUnPkzjjcT/kLoKCZzfQB7XiX8M2G8md7AUJgzJ+Z6e88gZ1xGuj3HsY17PcVkrG9gp7CUF/F8PUvxqdZDrFq1ahNVfKjwTCYxZuDE2wjKlc2WViMePM+HPNsFPOdf22OPblD5OZQHvphnV65cjTMzxaQY3eA5V9OO/hmnm1lSjE7woFsQbiXki4++foHnXkW4mLC1JUl947333tsMY3emqfB9jtPJlXN5U0+bOXPmWCPxgOccSy4+AfqPio+9/oFnbyatbqVE28GSZfjQ1NT0KQzaHMcdyPfyaNoE12HcvdxT29K3Fkv8A2vWrPmcifAFZNtD91yRY+SBZ+9UsMtEgD+jTpeenp6JXI6xpKkuUDqRcA6Kr0Wpens+InQTnIpV6Fdi+BQT64ulS5eOIzefD62na7CeoGcnLCM8ykt5OWlzcPv772/BS/w3nP+K+xU11+DvQe5dcrQlTfWAwbNMb8XA8AyGX80xtLlA6TAJuteMbVhhia1v5VMcr+LWMeoZ4xiYw7q6urbhHbgG+paCkIRQehHu4pO3O5fVydEomF5Ulx548JfVD2wqfKE2I3R3ob/f2GoC1DWhdz7HG3i5j2pvb9+Z24m6HvVZQtYsZFWcowlzePEP4jJdR/OQhxTVpAs9NMXxmZxuZKo8IG4s+v8R2tUFphSBTBWzH+OAFwn/gS3TuN55xYoVqfc6dXd3fwHZ1xFaTX0iyGbwjJqXXAammxP00EXx6UMGEx7ram7+vKnzBZ/87Xiwp40tEdDTgYwlHG/CmadSjO7L+XiialOZAej7POFG2VK0Khngl6Pn8/LL0YEtlFh4n8oDAqvaAYH8tzH2iNDm1IIFn8Ax50G7xtgCAU07CfAG4RHOz+vLZL7e0dGxlYlKHaj8BHo25xgrsfV5wrYH4KmouxV+ZZDnCUdwmXxMGgFvFUVWD+jQuOot6rI0tb4gcfaG9v+MrcAn+wj38gL8C7cObmlp2ZRjOkWYD6ypuAf6zjFHLSJ0c/6YQ813DM/yZXgehreiVgP8cvSfsOeExYsXuzs6n8v9j8mqBRZQmdjXVPuira1NHSpn8UDf4Xu0vd2uCtDzacJOlDDf5ng94X8JTWarB8R1EK7ju7udiYgEz/v3pLFKm4oHUHhh3iZdfshpaEYpA4pvKLLXBujLYKRq71XLhUHg27z12rW9B6L/QhLrWWxRH7nzeDK8awi/5HRTEx0K6MZQ694LHk0DqrgfADkreIYz1q5c+UlTEQzesIuMryrggYQWjNL3RGO7p2tuFMeqjaOidgzyCz1yJMTJ6L6d66WEVCcHIO/dQkI75Chs2g97Hoc3jRz9Lge1ED5l4r0gckqRPB0gTw34t1B+h3IqxZkmrn2SULUa7ezZszdE5xfR9130Xsm5ilrnHrmkQOcKvrkncxqrIiY6wlewbw7BOUfDo/b84zzvj9C7J7eCS0NrUiRKCPjUE7ScMBdlF/B2HqBi0ERXBcuXL99YnQz9fX2ah3Up4UnsWGEmDRuUhoTn+Z5PfvbZZ2N/fuCZRJgnfhNVBu73EZoIKt7l0L2UBsYeDZg016nb5EUCWuXQewinUtTuyq2aTStF14a8SD+VDQVj6hDYxjuXf4Hjl83sSMCmTp8j4FtoMuRQ5dAZcii3kk/0s2bBhxIcBxjxUlib1hWInEDO/6qKV+y4geO5HAMntEE/pq+nZyo0ywsG1SmwL4Orf+0yqGCfmvR73LAn9lAeBjQTEhkA+1h49a08iRflcq4H5iuXFU9cz4lqihC/LXS/NZa6Bc+pz5gql5ub6VXD2tZWTSPeyS7XgeLhXrMnEhj6MSHSwaIhFGZH8oA/JzzFeexvJbRN2HW03moT6cEChx6w4QY2rurn85JWrxsiCy0FwjcIqos8w7GZNPulkawDEbFHlaBtjzODEDrVztuKXMmADPWA3RaljyJeNdKq98ilAez8iJdyGqfO31V4NoV/EvyaCqR54V2EshE5Lqcb+TrkstkTLD4WKB4PNNZQ8P05HAelMXNSPWChC8JsYvwthJo0jSoF6fIqjjqe08Aat+LIkd+AVjn09zxbZFqK3tjXAUbXUaWDjTUSyN4J45YZX2Igo4cEOVfFson2ALIxSjR0jog5YNgpfNHM90BxIjDyWIB8Z2NfB01HISJ20wPaw4w1FlavXq1v8aPGXhFw9JNRFTDItifU/RwwpfmKxYsDK180kU4x0lhAXvOSJUs+bezlIDL2N4xi4GpjK4MGCuzUA+SPxzn3m4iKgKyV2DCV08DeMWg0B+zHHOt2DpjS3Mz1BfFOM25C5ZH4LxldJBB0g7GVARkaXgv8VsKqZtIMPpN9RUnJgRzU5Wfp22vifcG3+2vQvmdsdQXsX2pm+oKX+GYjjQXkPWqsXshpRhcJ0RpbGShSHiSuheP37ZYHsGusVHOrU1lMxkO9od4eE+8LlSzQqfetpnPAooBN/2Um+gISp89MkF8K4G3RrMJYoOhbYGxlQEGhSOGogfoLwipExGtUZVVBYIVAluaAaUpuWA+YujlPF22Ra/iBLYEOsV6tV4w0FiitfmLsXiBMU0NiAVrfsp77Zd8MHPgbDoHtva6uLs1jiv1piAKy5tCG+4KJ9wVO/p6RDzvy+b5rzSwP9Okh/WKPERiCWzfk4K8bUSTiOljAyCdx5DZG4gE8W5Dov+NYUfsV/j50fUC4dmXIQDh0qQ6PVgJsOcLM8oA410Ggvo6Ojr81di+g2TKuQOiyJOKWxlpCJpM5zUjKAL3awTsamQfEbYhjtDGKa5tPsyn/wAuiURftlBO56h6aunEwCMxxvV1d+2Fr7Jce2vAu5LUtLeoGi/19gtbToCaR97BoD6BvUs+WkXqgbw6OuhC6wH5l4rRGaCFOvYnjYbyxnpcsCvDVhYOxo6+zszNwSNHVTtJEmSiwzlMAQmNPwIPW42Dds2hfEK/5WJo0Fth+5VNxFHSlkoTzFRh/N3wnq0OGWxXtdoO8enFwaI4jsyidYgNZTxhrMEjEJ4w+En65ESWRXZ7Q4K/COqDAPlhka87WedB8KawmngTIHREOJs5pMiRp+p/GGgxL1FiA9hxjK6G1tVVdhJGAV15+cPXq1f7dahVC20Wg4miCp0uTe3Xh4Hwu93rY1B7SR/t7xQbP5R1FGgpy8IlKe+MJhZ9Aa7u5jPm+pGLX2BMDOZ+hDXgQiXIJ5xoXHZg96anEEFcvOTi0SMUXS4w0FijSTzTWYEA3hkTSEtDI2qw6RoytDLA6jctCvzKqJ8oPFOO7kAhnYe9cZGiWiZ/N9ezguWaSL4h3TUfvKJIfoN0I4sjigYSdZyxlcDVMgEczEY41ER6oZFBOh2Yqegf2zYoziFC3DuZZrjSTPLDtMlxaNPmPP/54W2OPxksrVozP5fLPGr8vEOpbxJCr3jQSJyDvGRNRhv7iHh8vE5LMpKznHBz4zSTOaXwe+mXGGh9tbWvVQf+iyfCAON/ZlTj4v43ECfB94Le4CuMrWVpTtw7O9fZOM5M8oD7xVSOLBdLuNWN1g7bgJUF8+4qpBjf7Te9M6hD4tBDc0289Wh2MHbuaSR7gsHOMLBaQ9W/G6o5MJrNDPu9dcYdQ33Yc95I6OFV5hnp2cGCliDingX5KU+9MShd0dmqta/k8J4zwnV2JsuuNxAnI83VwNpO52kiSoC4djA255cuXBzYPycGzjTQWkPdNY00OfRcQVLafRnd39ySLLsG1i20AyPZ3cDb7AyNJgnp1cOhUHUhcFiL045v9jTUa8Gjlm29fsQQhb3DzJLUEhC+oiK7EISPOwapoEh+7JQJti5YfGXs0YNC62ouC1h9lsrlToClsjc/RM7uSe0kd3EmlzTO/Kqk8Q106mM/Yw2aOB9jnOg6sWTHxJ9FraSJMy6nGz7RbZUDYmN7e3BnQ5Gisez7u3J9c0JwA6Pb0aCFvNObgwKk6NoU59uJwaJ8y1viAT4vCtEFXYO8SFQGtCZpllyXQtNqL+4lmZ/BN/5qJKQFZozEHe9JtAGSaw4wsFnie4JmUQcjleh8yZq0Fnmq3y0D02IzPMgnonYqYIfA4pC+TcXrgIahLB+PEb5s5HrjaR0b7kbHGB0pK7TDO1/T39x1lUZGAPlUH0xTbz+KSoC4dDDx2DQCHzTCaWOB5zjbW+KCSpW0IS0BIJmy6zWCk7WDuxZ4r5oO6dHB7e/sBZo4H2OfUsYOv9jHW+ECJdkAtA/c6MpmMd+XaEKj7km9M4F5TEfBzSKovDLKG1cHobw+b6EDa3WOksYBPAhevBUJMxl8GJTRhFyMLBKSJFn5ls9nvmogS0DfaHOzb3h8AcUuNNBLQNiWa0gRv4MwMMyBwCqxAfCIH82JdYSJKQN+ocjA5NHD2I/e1aj/23iPyhbG6A+bAgXsZoUEII/UAkkQORu71JqIE7o22HBw4VaelpWU74mPPDc/39d1trO5Qb4vJ8QXxbwat06WofcTInMCzeToAtN4VXUn/l1AXDkan9tDSfmL6C81BZooHxDkN9CMveLFZFFAWWZtDwVta3G0sJcAbe3bmYEiniShBXabcL+wflQDD5mD0yKlvk0b/Tk33AG5F7idG+/ibRe54oEl1nLG6A+ZYe1jyAIuG/u2LB3MazxwAfL5vJFGJinxQUwcju6c/n3+FNPm5JhJyy2k/sQTp5nm+2HBJCGi1X1WpwzuBoQXAN+IcjDz8mdePKi/WhH1uxd7GcCjIVBcWpUYDfZ0VbclEJSr2akMBhVrdX6j+Jx3DpSh7vKB8CIiqKwcrcXGqdr05k3RKbU9ryTQVkUB3aHMrEshw7kGCXiv8xxG0h6Uzent6Fpn6MhA17A6GT/3yTxNO1coJbgWur3JFf1fXNuTes5AZe18xXobFHJKv04JZc3O7CtIcgGL9KW03u3QCfL4D4b292dhrpoYgsYOhEz4kaOuHqXKqiagYiN9QnUlyKgX84JUYsQFP9GKzMFRSe8XJb9upE9Dn62CK/KQT75wdTLz+NXgPNdrDuYzeUd0ByN4Wp07n+EdCRZuTY1/ymZQDwIjQye9pA32xdw6IiUgHc639mN8kzCLRjkxzQRzitUpkZ8LZBP1CILUd55EVvdgsCrzJl5i8mgCja+Zgjst4Pq3DUnMmtSWqyNIuQruRU3+CbO08n+pvBAZAjf1IU5kcGJc0YRMBfVV3MPd2RN4+YbvYukI/3sSpe+LUmbw0ryG/6ts1oSLeYrMw6C0xeaFAGc+Wq3hbfeRk582b55lrzf3UHJwWkD0Wp+6BQ3+BfXEXw6UCdHX4TVB0BoJi9Y1Cp59XbUWN8HW7lRjLli3zbINE+1hNiCRI1cGakIhT99ani/A6z1z1nDoUqNQfbO40kyqDfrCBwMg3E5rsCy+8sFlHR8dEnFzRTq/I8hQ9NFFOtGhXVOxgFeUqfknUK7Ctpjl1ANKJ/vmUkvrdwRZmWjpA4J9MTyja2toKY8TQa/ufxP/Whdd5c5cQJHIwfBsTvkKiaqd6/fRyOHKqavdL0H+V2sxmWvrQCAeKItfmQlNyDG/8SVwnetMHyxmA7lm0K2I7GFrlVBW/V6FPP9GqeU4V0Kt2+O2yhctUN6AJBEWD9ngMnessJxh5AfCoQe+8q+xQOYLuWbQrQh2MXP1XYh8S9DKC2sI1z6kCatW3/RCZ6Vj9fNPMqx2wQVNJQlcNEl/mGG5pv48bi7HxMVSOoHsW7QqPg5GlvnJtk6/B9+HMqYUfaXE6rampqWy4dVhgi8FfLprnBXEex+i/wCSkNiSNDSpUxxt7Ccj2nQQYAwUHc9yE3HEotuifDklnfFYMdGNC/lWCxotDf4PvB/jHZTs71c+f2n+ryqCPPcb5/pKdGrTvbH2MUjH4ByOLBDpON9YSFi5cuI1FOwFbbyTox5T6y+iwFL8CqvWvwVtolWgSv/N4sXbl5ZP3r8hRLT50d56KgYJDCYXVhYOhtqqReKDdZuGJtSQSOk8f67x581SspvH3lpoBe9Vefbg/lzveaXmnAf6tEDMNGRp3LnV3ch29o10lQIf+bOKZc+XnmMGARF2EK4vUwQiSw33n7ZlqDWwcaK9Ob29vd26vwj+OT8m3kKFxdd9tlILSJ1Wo8Y8RZT/YiKOY4le5P3SGZJAc7telg7FroL16Jc/n/a1cBBCxsSblwT8LOfofcCh4AQ4x1uoCXZtgVKnYDXLMUECnPSQD29VBcrhfVw7GHrVXb6WylGg0SvUZcrr+YPYuwWVfaE9ltmpA2Q6EQq2UY+yigzf2oqCH4v4MIysD94fdwdig9uqDnB4T5/d+gwHPGNVFcOopyJiPLOfmGTwa0Ek8qS8RKDKORLFWH95utwbDd94SRqqN/Cv4PDXbTFfXfUZWBvRUPJCRBJiIqfnnccy0Dz74wHkWoypY2D4ZGU8gK+kKjQKQ8RcTW1uQI2fmc7nH7LIMFEW+sw6xdyN4CgvNByNIDjp+ZyRVhzlV7dVLaZc7t1cRoW0w9of/No6ptbuRdZupqC3QPZY33HchMkbJiRPssgyaHkN82XaJXPtOJuN+JRuixQI6Cu1VXiZtJehcFGpeNPyXI6cqPWTIvsxU1R7o912akevre4OHfTHot3fEfRbD3y8+Qu0djO5Ce5UXNGl7dTt4z0RGqnOuhgLZgmcPk2FHrrd3jgwkAVQ58e1ioxjcHeMLPWQcq+5gZKm9+hJHjXo5z4xQBQsxxyDjEfir+nNq5GfQo/nYh6f9e4NUgGEFx3DEzvw1nPrOhSJ+kh6GUBUHw6//Kmls96dJ2qv6FxNF9z8g405kVLVXDfkaiFAd4JIkttYUGFpyDOf91Ch/YVEe8DA/gORpuywDfLNMjBOQt4qEupbTPTX4YeJig+/qrnoxkfMeIdH2UHGBfP0H6kFepElc1rY5lBQYXZbzuO7BWYH7b3V3d/+TX1FEG/JSExEJdOi7qsnrx3DuNM8Zdg2NqnN/BjK0EXlVhxORr56wP6Lv/DT+X1FzYLynaOWe2s1TjCQW4An9t6Jk4hBVdH6YpB9YNXoS+SRk/JaQZHd5J2CnesLuyGaze3KZ2hTemoNcpO+uB3pAQuzvC7SeJSfc0258Wo97aX9PT+TmMEMB73jsO0wJzXnVx4llL7pe5kWaFtSqGHHgu6rpPr5jsdx+hyI59G+hA4C25GDO1V69mbf/77h0+lZpzZX44B+Ye1X1cWKz92pKrYlcjtzc6gfN+ufhApd/ErcwTvuTRNI0m4c4Tg77u6gfbCHdTuQcrRFaRKiFU7Xl1O/RqX9RObevRxR43gmEBYUn9wEJIMeF/jk0yVKTta2tE0jg43kx1OatWifEYKDrHYKGDnfkMrU1xHUPaoh7k8i+030EvoV3c6i4aTCoc/9+9NVkFgh6BmZFaig08he3oxYkwBEkQGCzg7gfG6kzaDvuSyLfgIyqt1cF6SAspoS4iJf3c9xaf3JrGEgUzZcOGgvO4agzjTQUkI9V5z4851MuLhBvUUp1gR7tjXEHL+shXFZnduNIBomi6T73FVLLByQePu4N3CxMbVxyzfeQUTYZrdpA3yvoPVf/1jdTGggC6aXx0ieLSecFcWoj72vkhU4IcswU7gVORksb6FHnufbouJ4Xbv+gf1g0EADav9uSeO9YenpA3IfURFVZ0gqEms1rRg0qCzM4TuYy1T061jt0dXXpX0xJ96FMDXIqQXtJ3tSfze6OaY0KU1ogfTUgUJMK0lBIL06dS/F/LJeRe0k2kAAk7BgSWN2GVW/aCOjRuPCbBHVGBG6J3ECKIN3VlfjroguqA+RrMsFvCNqisf5mRox2qPlB4s8vuiMdIE/fVjVvLlRnhKlqYLig7QIpOiva40PAqR2E22neJFrN10AVgWMOIDgPuMOjmRFa+HVaR0fHliaugXoEOe80nBWrZg2dZkZoYffuaW5u1kCVkadmbT70AGdqJodWOhxHqP2eFg1UDvsLatnSFq41M+KKnp6eXbhsdB2OdGiCeX8+/2ecqgnmk/VXNYtqYLSAnNposzpjgw3+H/belpVa8J7TAAAAAElFTkSuQmCC",t.style.position="absolute",t.style.left="50%",t.style.top="50%",t.style.marginLeft="-60px",t.style.marginTop="-60px",t.style.animation="spin1 2s infinite ease-in-out",t.style.webkitAnimation="spin1 2s infinite ease-in-out",t.style.transformOrigin="50% 50%",t.style.webkitTransformOrigin="50% 50%",this._loadingDiv.appendChild(t),this._resizeLoadingUI(),window.addEventListener("resize",this._resizeLoadingUI),this._loadingDiv.style.backgroundColor=this._loadingDivBackgroundColor,document.body.appendChild(this._loadingDiv),this._loadingDiv.style.opacity="1"}},e.prototype.hideLoadingUI=function(){var e=this;if(this._loadingDiv){var t=function(){e._loadingDiv&&(document.body.removeChild(e._loadingDiv),window.removeEventListener("resize",e._resizeLoadingUI),e._loadingDiv=null)};this._loadingDiv.style.opacity="0",this._loadingDiv.addEventListener("transitionend",t)}},Object.defineProperty(e.prototype,"loadingUIText",{set:function(e){this._loadingText=e,this._loadingTextDiv&&(this._loadingTextDiv.innerHTML=this._loadingText)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"loadingUIBackgroundColor",{get:function(){return this._loadingDivBackgroundColor},set:function(e){this._loadingDivBackgroundColor=e,this._loadingDiv&&(this._loadingDiv.style.backgroundColor=this._loadingDivBackgroundColor)},enumerable:!0,configurable:!0}),e})();e.DefaultLoadingScreen=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){}return Object.defineProperty(t,"NO_LOGGING",{get:function(){return 0},enumerable:!0,configurable:!0}),Object.defineProperty(t,"MINIMAL_LOGGING",{get:function(){return 1},enumerable:!0,configurable:!0}),Object.defineProperty(t,"SUMMARY_LOGGING",{get:function(){return 2},enumerable:!0,configurable:!0}),Object.defineProperty(t,"DETAILED_LOGGING",{get:function(){return 3},enumerable:!0,configurable:!0}),Object.defineProperty(t,"ForceFullSceneLoadingForIncremental",{get:function(){return t._ForceFullSceneLoadingForIncremental},set:function(e){t._ForceFullSceneLoadingForIncremental=e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"ShowLoadingScreen",{get:function(){return t._ShowLoadingScreen},set:function(e){t._ShowLoadingScreen=e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"loggingLevel",{get:function(){return t._loggingLevel},set:function(e){t._loggingLevel=e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"CleanBoneMatrixWeights",{get:function(){return t._CleanBoneMatrixWeights},set:function(e){t._CleanBoneMatrixWeights=e},enumerable:!0,configurable:!0}),t._getDefaultPlugin=function(){return t._registeredPlugins[".babylon"]},t._getPluginForExtension=function(e){var r=t._registeredPlugins[e];return r||t._getDefaultPlugin()},t._getPluginForDirectLoad=function(e){for(var r in t._registeredPlugins){var i=t._registeredPlugins[r].plugin;if(i.canDirectLoad&&i.canDirectLoad(e))return t._registeredPlugins[r]}return t._getDefaultPlugin()},t._getPluginForFilename=function(e){e.name&&(e=e.name);var r=e.lastIndexOf("."),i=e.indexOf("?");-1===i&&(i=e.length);var n=e.substring(r,i).toLowerCase();return t._getPluginForExtension(n)},t._getDirectLoad=function(e){return e.substr&&"data:"===e.substr(0,5)?e.substr(5):null},t._loadData=function(r,i,n,o,s,a){var u,l=t._getDirectLoad(i),c=l?t._getPluginForDirectLoad(i):t._getPluginForFilename(i),h=c.plugin,f=c.isBinary;t.OnPluginActivatedObservable.notifyObservers(c.plugin);var d=function(e){if(n.isDisposed)return void a("Scene has been disposed");n.database=u;try{o(h,e)}catch(e){a(null,e)}},p=function(t){e.Tools.LoadFile(r+i,d,s,u,f,(function(e){a(e.status+" "+e.statusText)}))};if(l)return void d(l);-1===r.indexOf("file:")?n.getEngine().enableOfflineSupport?u=new e.Database(r+i,p):p():e.Tools.ReadFile(i,d,s,f)},t.GetPluginForExtension=function(e){return t._getPluginForExtension(e).plugin},t.RegisterPlugin=function(e){if("string"==typeof e.extensions){var r=e.extensions;t._registeredPlugins[r.toLowerCase()]={plugin:e,isBinary:!1}}else{var i=e.extensions;Object.keys(i).forEach((function(r){t._registeredPlugins[r.toLowerCase()]={plugin:e,isBinary:i[r].isBinary}}))}},t.ImportMesh=function(r,i,n,o,s,a,u){if(n.substr&&"/"===n.substr(0,1))return void e.Tools.Error("Wrong sceneFilename parameter");var l={};o._addPendingData(l);var c=function(e,t){u&&u(o,"Unable to import meshes from "+i+n+(e?": "+e:"")),o._removePendingData(l)},h=function(e){a&&a(e)};t._loadData(i,n,o,(function(e,t){if(e.importMesh){var a=e,u=[],f=[],d=[];if(!a.importMesh(r,o,t,i,u,f,d,c))return;s&&(o.importedMeshesFiles.push(i+n),s(u,f,d),o._removePendingData(l))}else{e.importMeshAsync(r,o,t,i,(function(e,t,r){s&&(o.importedMeshesFiles.push(i+n),s(e,t,r),o._removePendingData(l))}),h,c)}}),h,c)},t.Load=function(r,i,n,o,s,a){t.Append(r,i,new e.Scene(n),o,s,a)},t.Append=function(r,i,n,o,s,a){if(i.substr&&"/"===i.substr(0,1))return void e.Tools.Error("Wrong sceneFilename parameter");t.ShowLoadingScreen&&n.getEngine().displayLoadingUI();var u={};n._addPendingData(u);var l=function(e,t){a&&a(n,"Unable to load from "+r+i+(e?": "+e:"")),n._removePendingData(u),n.getEngine().hideLoadingUI()},c=function(e){s&&s(e)};t._loadData(r,i,n,(function(e,i){if(e.load){if(!e.load(n,i,r,l))return;o&&o(n),n.loadingPluginName=e.name,n._removePendingData(u)}else{e.loadAsync(n,i,r,(function(){o&&o(n),n.loadingPluginName=e.name,n._removePendingData(u)}),c,l)}t.ShowLoadingScreen&&n.executeWhenReady((function(){n.getEngine().hideLoadingUI()}))}),c,l)},t})();t._ForceFullSceneLoadingForIncremental=!1,t._ShowLoadingScreen=!0,t._CleanBoneMatrixWeights=!1,t._loggingLevel=t.NO_LOGGING, t.OnPluginActivatedObservable=new e.Observable,t._registeredPlugins={},e.SceneLoader=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){var r=function(t,r,i,n){for(var o=0,s=r.materials.length;o-1&&void 0!==f.skeletons&&null!==f.skeletons){if(!1===_.indexOf(y.skeletonId)>-1)for(var O=0,I=f.skeletons.length;O0){for(var $=0;$0){for(var te=0;te0&&this._textureLoadingCallback(e)}this._currentScene.render()}},t.prototype.drag=function(e){e.stopPropagation(),e.preventDefault()},t.prototype.drop=function(e){e.stopPropagation(),e.preventDefault(),this.loadFiles(e)},t.prototype._handleFolderDrop=function(e,t,r){var i=e.createReader(),n=e.fullPath.replace(/^\//,"").replace(/(.+?)\/?$/,"$1/");i.readEntries((function(e){for(var i=e.length,o=0,s=e;o0){for(var r=[],i=[],n=0;n0&&(e.Tools.ClearLogCache(),e.Tools.Log("Babylon.js engine (v"+e.Engine.Version+") launched")),this._engine.stopRenderLoop(),this._currentScene.dispose()),e.SceneLoader.Load("file:",this._sceneFileToLoad,this._engine,(function(e){r._currentScene=e,r._currentScene.executeWhenReady((function(){r._sceneLoadedCallback&&r._sceneLoadedCallback(t._sceneFileToLoad,r._currentScene),r._engine.runRenderLoop((function(){r.renderFunction()}))}))}),(function(e){t._progressCallback&&t._progressCallback(e)}))):e.Tools.Error("Please provide a valid .babylon file.")},t})();t.FilesToLoad=new Array,e.FilesInput=t})(BABYLON||(BABYLON={})),BABYLON.Effect.ShadersStore={postprocessVertexShader:"\nattribute vec2 position;\nuniform vec2 scale;\n\nvarying vec2 vUV;\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) { \nvUV=(position*madd+madd)*scale;\ngl_Position=vec4(position,0.0,1.0);\n}",passPixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nvoid main(void) \n{\ngl_FragColor=texture2D(textureSampler,vUV);\n}",shadowMapVertexShader:"\nattribute vec3 position;\n#include\n\n#include\nuniform mat4 viewProjection;\nuniform vec2 biasAndScale;\nuniform vec2 depthValues;\nvarying float vDepthMetric;\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform mat4 diffuseMatrix;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#endif\nvoid main(void)\n{\n#include\n#include\nvec4 worldPos=finalWorld*vec4(position,1.0);\ngl_Position=viewProjection*worldPos;\nvDepthMetric=((gl_Position.z+depthValues.x)/(depthValues.y))+biasAndScale.x;\n#ifdef ALPHATEST\n#ifdef UV1\nvUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n#endif\n#ifdef UV2\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n}",shadowMapPixelShader:"#ifndef FLOAT\nvec4 pack(float depth)\n{\nconst vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);\nconst vec4 bit_mask=vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);\nvec4 res=fract(depth*bit_shift);\nres-=res.xxyz*bit_mask;\nreturn res;\n}\n#endif\nvarying float vDepthMetric;\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n#endif\nuniform vec2 biasAndScale;\nuniform vec2 depthValues;\nvoid main(void)\n{\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\nfloat depth=vDepthMetric;\n#ifdef ESM\ndepth=clamp(exp(-min(87.,biasAndScale.y*depth)),0.,1.);\n#endif\n#ifdef FLOAT\ngl_FragColor=vec4(depth,1.0,1.0,1.0);\n#else\ngl_FragColor=pack(depth);\n#endif\n}",depthBoxBlurPixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n\nuniform vec2 screenSize;\nvoid main(void)\n{\nvec4 colorDepth=vec4(0.0);\nfor (int x=-OFFSET; x<=OFFSET; x++)\nfor (int y=-OFFSET; y<=OFFSET; y++)\ncolorDepth+=texture2D(textureSampler,vUV+vec2(x,y)/screenSize);\ngl_FragColor=(colorDepth/float((OFFSET*2+1)*(OFFSET*2+1)));\n}",pbrVertexShader:"precision highp float;\n#include<__decl__pbrVertex>\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef TANGENT\nattribute vec4 tangent;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2; \n#endif \n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include\n\n#include\n#if defined(ALBEDO) && ALBEDODIRECTUV == 0\nvarying vec2 vAlbedoUV;\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nvarying vec2 vAmbientUV;\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nvarying vec2 vOpacityUV;\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nvarying vec2 vEmissiveUV;\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nvarying vec2 vLightmapUV;\n#endif\n#if defined(REFLECTIVITY) && REFLECTIVITYDIRECTUV == 0\nvarying vec2 vReflectivityUV;\n#endif\n#if defined(MICROSURFACEMAP) && MICROSURFACEMAPDIRECTUV == 0\nvarying vec2 vMicroSurfaceSamplerUV;\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nvarying vec2 vBumpUV;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#if defined(USESPHERICALFROMREFLECTIONMAP) && !defined(USESPHERICALINFRAGMENT)\nvarying vec3 vEnvironmentIrradiance;\n#include\n#endif\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include\n#include\n#include\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include\n#include[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#include\nvoid main(void) {\nvec3 positionUpdated=position;\n#ifdef NORMAL\nvec3 normalUpdated=normal;\n#endif\n#ifdef TANGENT\nvec4 tangentUpdated=tangent;\n#endif\n#include[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvPositionUVW=positionUpdated;\n#endif \n#include\n#include\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normalUpdated,0.0)));\n#if defined(USESPHERICALFROMREFLECTIONMAP) && !defined(USESPHERICALINFRAGMENT)\nvec3 reflectionVector=vec3(reflectionMatrix*vec4(vNormalW,0)).xyz;\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\nvEnvironmentIrradiance=environmentIrradianceJones(reflectionVector);\n#endif\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef MAINUV1\nvMainUV1=uv;\n#endif \n#ifdef MAINUV2\nvMainUV2=uv2;\n#endif \n#if defined(ALBEDO) && ALBEDODIRECTUV == 0 \nif (vAlbedoInfos.x == 0.)\n{\nvAlbedoUV=vec2(albedoMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAlbedoUV=vec2(albedoMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0 \nif (vAmbientInfos.x == 0.)\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0 \nif (vOpacityInfos.x == 0.)\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0 \nif (vEmissiveInfos.x == 0.)\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0 \nif (vLightmapInfos.x == 0.)\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(REFLECTIVITY) && REFLECTIVITYDIRECTUV == 0 \nif (vReflectivityInfos.x == 0.)\n{\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(MICROSURFACEMAP) && MICROSURFACEMAPDIRECTUV == 0 \nif (vMicroSurfaceSamplerInfos.x == 0.)\n{\nvMicroSurfaceSamplerUV=vec2(microSurfaceSamplerMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvMicroSurfaceSamplerUV=vec2(microSurfaceSamplerMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0 \nif (vBumpInfos.x == 0.)\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n\n#include\n\n#include\n\n#include\n\n#include[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n\n#include\n}", diff --git a/dist/preview release/customConfigurations/minimalGLTFViewer/babylon.max.js b/dist/preview release/customConfigurations/minimalGLTFViewer/babylon.max.js index dc7b76ec4f9..b9407afaa9a 100644 --- a/dist/preview release/customConfigurations/minimalGLTFViewer/babylon.max.js +++ b/dist/preview release/customConfigurations/minimalGLTFViewer/babylon.max.js @@ -19996,12 +19996,20 @@ var BABYLON; }; Texture.prototype.getReflectionTextureMatrix = function () { var _this = this; + var scene = this.getScene(); if (this.uOffset === this._cachedUOffset && this.vOffset === this._cachedVOffset && this.uScale === this._cachedUScale && this.vScale === this._cachedVScale && this.coordinatesMode === this._cachedCoordinatesMode) { - return this._cachedTextureMatrix; + if (this.coordinatesMode === Texture.PROJECTION_MODE) { + if (this._cachedProjectionMatrixId === scene.getProjectionMatrix().updateFlag) { + return this._cachedTextureMatrix; + } + } + else { + return this._cachedTextureMatrix; + } } if (!this._cachedTextureMatrix) { this._cachedTextureMatrix = BABYLON.Matrix.Zero(); @@ -20029,13 +20037,15 @@ var BABYLON; this._projectionModeMatrix.m[13] = 0.5; this._projectionModeMatrix.m[14] = 1.0; this._projectionModeMatrix.m[15] = 1.0; - this.getScene().getProjectionMatrix().multiplyToRef(this._projectionModeMatrix, this._cachedTextureMatrix); + var projectionMatrix = scene.getProjectionMatrix(); + this._cachedProjectionMatrixId = projectionMatrix.updateFlag; + projectionMatrix.multiplyToRef(this._projectionModeMatrix, this._cachedTextureMatrix); break; default: BABYLON.Matrix.IdentityToRef(this._cachedTextureMatrix); break; } - this.getScene().markAllMaterialsAsDirty(BABYLON.Material.TextureDirtyFlag, function (mat) { + scene.markAllMaterialsAsDirty(BABYLON.Material.TextureDirtyFlag, function (mat) { return (mat.getActiveTextures().indexOf(_this) !== -1); }); return this._cachedTextureMatrix; diff --git a/dist/preview release/customConfigurations/minimalGLTFViewer/babylon.module.d.ts b/dist/preview release/customConfigurations/minimalGLTFViewer/babylon.module.d.ts index 0c160c99ba3..b7351884223 100644 --- a/dist/preview release/customConfigurations/minimalGLTFViewer/babylon.module.d.ts +++ b/dist/preview release/customConfigurations/minimalGLTFViewer/babylon.module.d.ts @@ -2502,188 +2502,6 @@ declare module BABYLON { } } -declare module BABYLON { - class Analyser { - SMOOTHING: number; - FFT_SIZE: number; - BARGRAPHAMPLITUDE: number; - DEBUGCANVASPOS: { - x: number; - y: number; - }; - DEBUGCANVASSIZE: { - width: number; - height: number; - }; - private _byteFreqs; - private _byteTime; - private _floatFreqs; - private _webAudioAnalyser; - private _debugCanvas; - private _debugCanvasContext; - private _scene; - private _registerFunc; - private _audioEngine; - constructor(scene: Scene); - getFrequencyBinCount(): number; - getByteFrequencyData(): Uint8Array; - getByteTimeDomainData(): Uint8Array; - getFloatFrequencyData(): Uint8Array; - drawDebugCanvas(): void; - stopDebugCanvas(): void; - connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void; - dispose(): void; - } -} - -declare module BABYLON { - class AudioEngine { - private _audioContext; - private _audioContextInitialized; - canUseWebAudio: boolean; - masterGain: GainNode; - private _connectedAnalyser; - WarnedWebAudioUnsupported: boolean; - unlocked: boolean; - onAudioUnlocked: () => any; - isMP3supported: boolean; - isOGGsupported: boolean; - readonly audioContext: AudioContext; - constructor(); - private _unlockiOSaudio(); - private _initializeAudioContext(); - dispose(): void; - getGlobalVolume(): number; - setGlobalVolume(newVolume: number): void; - connectToAnalyser(analyser: Analyser): void; - } -} - -declare module BABYLON { - class Sound { - name: string; - autoplay: boolean; - loop: boolean; - useCustomAttenuation: boolean; - soundTrackId: number; - spatialSound: boolean; - refDistance: number; - rolloffFactor: number; - maxDistance: number; - distanceModel: string; - private _panningModel; - onended: () => any; - private _playbackRate; - private _streaming; - private _startTime; - private _startOffset; - private _position; - private _localDirection; - private _volume; - private _isLoaded; - private _isReadyToPlay; - isPlaying: boolean; - isPaused: boolean; - private _isDirectional; - private _readyToPlayCallback; - private _audioBuffer; - private _soundSource; - private _streamingSource; - private _soundPanner; - private _soundGain; - private _inputAudioNode; - private _ouputAudioNode; - 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 - * @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?: () => void, options?: any); - dispose(): void; - isReady(): boolean; - private _soundLoaded(audioData); - setAudioBuffer(audioBuffer: AudioBuffer): void; - updateOptions(options: any): void; - private _createSpatialParameters(); - private _updateSpatialParameters(); - switchPanningModelToHRTF(): void; - switchPanningModelToEqualPower(): void; - private _switchPanningModel(); - 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; - setPosition(newPosition: Vector3): void; - setLocalDirectionToMesh(newLocalDirection: Vector3): void; - private _updateDirection(); - updateDistanceFromListener(): void; - 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; - pause(): void; - setVolume(newVolume: number, time?: number): void; - setPlaybackRate(newPlaybackRate: number): void; - getVolume(): number; - attachToMesh(meshToConnectTo: AbstractMesh): void; - detachFromMesh(): void; - private _onRegisterAfterWorldMatrixUpdate(connectedMesh); - clone(): Sound; - getAudioBuffer(): AudioBuffer; - serialize(): any; - static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound; - } -} - -declare module BABYLON { - class SoundTrack { - private _outputAudioNode; - private _inputAudioNode; - private _trackConvolver; - private _scene; - id: number; - soundCollection: Array; - private _isMainTrack; - private _connectedAnalyser; - private _options; - private _isInitialized; - constructor(scene: Scene, options?: any); - private _initializeSoundTrackAudioGraph(); - dispose(): void; - AddSound(sound: Sound): void; - RemoveSound(sound: Sound): void; - setVolume(newVolume: number): void; - switchPanningModelToHRTF(): void; - switchPanningModelToEqualPower(): void; - connectToAnalyser(analyser: Analyser): void; - } -} - declare module BABYLON { class Animatable { target: any; @@ -2916,23 +2734,205 @@ declare module BABYLON { } declare module BABYLON { - class Bone extends Node { + class Analyser { + SMOOTHING: number; + FFT_SIZE: number; + BARGRAPHAMPLITUDE: number; + DEBUGCANVASPOS: { + x: number; + y: number; + }; + DEBUGCANVASSIZE: { + width: number; + height: number; + }; + private _byteFreqs; + private _byteTime; + private _floatFreqs; + private _webAudioAnalyser; + private _debugCanvas; + private _debugCanvasContext; + private _scene; + private _registerFunc; + private _audioEngine; + constructor(scene: Scene); + getFrequencyBinCount(): number; + getByteFrequencyData(): Uint8Array; + getByteTimeDomainData(): Uint8Array; + getFloatFrequencyData(): Uint8Array; + drawDebugCanvas(): void; + stopDebugCanvas(): void; + connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void; + dispose(): void; + } +} + +declare module BABYLON { + class AudioEngine { + private _audioContext; + private _audioContextInitialized; + canUseWebAudio: boolean; + masterGain: GainNode; + private _connectedAnalyser; + WarnedWebAudioUnsupported: boolean; + unlocked: boolean; + onAudioUnlocked: () => any; + isMP3supported: boolean; + isOGGsupported: boolean; + readonly audioContext: AudioContext; + constructor(); + private _unlockiOSaudio(); + private _initializeAudioContext(); + dispose(): void; + getGlobalVolume(): number; + setGlobalVolume(newVolume: number): void; + connectToAnalyser(analyser: Analyser): void; + } +} + +declare module BABYLON { + class Sound { name: string; - private static _tmpVecs; - private static _tmpQuat; - private static _tmpMats; - children: Bone[]; - animations: Animation[]; - length: number; - private _skeleton; - private _localMatrix; - private _restPose; - private _baseMatrix; - private _worldTransform; - private _absoluteTransform; - private _invertedAbsoluteTransform; - private _parent; - private _scaleMatrix; + autoplay: boolean; + loop: boolean; + useCustomAttenuation: boolean; + soundTrackId: number; + spatialSound: boolean; + refDistance: number; + rolloffFactor: number; + maxDistance: number; + distanceModel: string; + private _panningModel; + onended: () => any; + private _playbackRate; + private _streaming; + private _startTime; + private _startOffset; + private _position; + private _localDirection; + private _volume; + private _isLoaded; + private _isReadyToPlay; + isPlaying: boolean; + isPaused: boolean; + private _isDirectional; + private _readyToPlayCallback; + private _audioBuffer; + private _soundSource; + private _streamingSource; + private _soundPanner; + private _soundGain; + private _inputAudioNode; + private _ouputAudioNode; + 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 + * @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?: () => void, options?: any); + dispose(): void; + isReady(): boolean; + private _soundLoaded(audioData); + setAudioBuffer(audioBuffer: AudioBuffer): void; + updateOptions(options: any): void; + private _createSpatialParameters(); + private _updateSpatialParameters(); + switchPanningModelToHRTF(): void; + switchPanningModelToEqualPower(): void; + private _switchPanningModel(); + 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; + setPosition(newPosition: Vector3): void; + setLocalDirectionToMesh(newLocalDirection: Vector3): void; + private _updateDirection(); + updateDistanceFromListener(): void; + 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; + pause(): void; + setVolume(newVolume: number, time?: number): void; + setPlaybackRate(newPlaybackRate: number): void; + getVolume(): number; + attachToMesh(meshToConnectTo: AbstractMesh): void; + detachFromMesh(): void; + private _onRegisterAfterWorldMatrixUpdate(connectedMesh); + clone(): Sound; + getAudioBuffer(): AudioBuffer; + serialize(): any; + static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound; + } +} + +declare module BABYLON { + class SoundTrack { + private _outputAudioNode; + private _inputAudioNode; + private _trackConvolver; + private _scene; + id: number; + soundCollection: Array; + private _isMainTrack; + private _connectedAnalyser; + private _options; + private _isInitialized; + constructor(scene: Scene, options?: any); + private _initializeSoundTrackAudioGraph(); + dispose(): void; + AddSound(sound: Sound): void; + RemoveSound(sound: Sound): void; + setVolume(newVolume: number): void; + switchPanningModelToHRTF(): void; + switchPanningModelToEqualPower(): void; + connectToAnalyser(analyser: Analyser): void; + } +} + +declare module BABYLON { + class Bone extends Node { + name: string; + private static _tmpVecs; + private static _tmpQuat; + private static _tmpMats; + children: Bone[]; + animations: Animation[]; + length: number; + private _skeleton; + private _localMatrix; + private _restPose; + private _baseMatrix; + private _worldTransform; + private _absoluteTransform; + private _invertedAbsoluteTransform; + private _parent; + private _scaleMatrix; private _scaleVector; private _negateScaleChildren; private _scalingDeterminant; @@ -4220,93 +4220,266 @@ declare module BABYLON { } } -declare module BABYLON { - /** - * 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?: Camera; +declare module BABYLON.Debug { + class AxesViewer { + private _xline; + private _yline; + private _zline; + private _xmesh; + private _ymesh; + private _zmesh; + scene: Scene; + scaleLines: number; + constructor(scene: Scene, scaleLines?: number); + update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void; + dispose(): void; } - /** - * 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 { - name: 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; +} + +declare module BABYLON.Debug { + class BoneAxesViewer extends Debug.AxesViewer { + mesh: Mesh; + bone: Bone; + pos: Vector3; + xaxis: Vector3; + yaxis: Vector3; + zaxis: Vector3; + constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number); + update(): void; + dispose(): void; + } +} + +declare module BABYLON { + class DebugLayer { private _scene; - private _engine; - private _options; - private _vertexBuffers; - private _indexBuffer; - private _downSamplePostprocess; - private _horizontalBlurPostprocess; - private _verticalBlurPostprocess; - private _cachedDefines; - private _glowMapGenerationEffect; - private _glowMapMergeEffect; - private _blurTexture; - private _mainTexture; - private _mainTextureDesiredSize; - private _meshes; - private _maxSize; - private _shouldRender; - private _instanceGlowingMeshStencilReference; - private _excludedMeshes; - /** - * 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; + static InspectorURL: string; + private _inspector; + constructor(scene: Scene); + /** Creates the inspector window. */ + private _createInspector(config?); + isVisible(): boolean; + hide(): void; + show(config?: { + popup?: boolean; + initialTab?: number; + parentElement?: HTMLElement; + newColors?: { + backgroundColor?: string; + backgroundColorLighter?: string; + backgroundColorLighter2?: string; + backgroundColorLighter3?: string; + color?: string; + colorTop?: string; + colorBot?: string; + }; + }): void; + } +} + +declare module BABYLON.Debug { + class PhysicsViewer { + protected _impostors: Array; + protected _meshes: Array; + protected _scene: Scene; + protected _numMeshes: number; + protected _physicsEnginePlugin: IPhysicsEnginePlugin; + private _renderFunction; + private _debugBoxMesh; + private _debugSphereMesh; + private _debugMaterial; + constructor(scene: Scene); + protected _updateDebugMeshes(): void; + showImpostor(impostor: PhysicsImpostor): void; + hideImpostor(impostor: PhysicsImpostor): void; + private _getDebugMaterial(scene); + private _getDebugBoxMesh(scene); + private _getDebugSphereMesh(scene); + private _getDebugMesh(impostor, scene); + dispose(): void; + } +} + +declare module BABYLON { + class RayHelper { + ray: Ray; + private _renderPoints; + private _renderLine; + private _renderFunction; + private _scene; + private _updateToMeshFunction; + private _attachedToMesh; + private _meshSpaceDirection; + private _meshSpaceOrigin; + static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper; + constructor(ray: Ray); + show(scene: Scene, color: Color3): void; + hide(): void; + private _render(); + attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void; + detachFromMesh(): void; + private _updateToMesh(); + dispose(): void; + } +} + +declare module BABYLON.Debug { + /** + * Demo available here: http://www.babylonjs-playground.com/#1BZJVJ#8 + */ + class SkeletonViewer { + skeleton: Skeleton; + mesh: AbstractMesh; + autoUpdateBonesMatrices: boolean; + renderingGroupId: number; + color: Color3; + private _scene; + private _debugLines; + private _debugMesh; + private _isEnabled; + private _renderFunction; + constructor(skeleton: Skeleton, mesh: AbstractMesh, scene: Scene, autoUpdateBonesMatrices?: boolean, renderingGroupId?: number); + isEnabled: boolean; + private _getBonePosition(position, bone, meshMat, x?, y?, z?); + private _getLinesForBonesWithLength(bones, meshMat); + private _getLinesForBonesNoLength(bones, meshMat); + update(): void; + dispose(): void; + } +} + +declare module BABYLON { + class LensFlare { + size: number; + position: number; + color: Color3; + texture: Texture; + alphaMode: number; + private _system; + constructor(size: number, position: number, color: any, imgUrl: string, system: LensFlareSystem); + dispose: () => void; + } +} + +declare module BABYLON { + class LensFlareSystem { + name: string; + lensFlares: LensFlare[]; + borderLimit: number; + viewportBorder: number; + meshesSelectionPredicate: (mesh: Mesh) => boolean; + layerMask: number; + id: string; + private _scene; + private _emitter; + private _vertexBuffers; + private _indexBuffer; + private _effect; + private _positionX; + private _positionY; + private _isEnabled; + constructor(name: string, emitter: any, scene: Scene); + isEnabled: boolean; + getScene(): Scene; + getEmitter(): any; + setEmitter(newEmitter: any): void; + getEmitterPosition(): Vector3; + computeEffectivePosition(globalViewport: Viewport): boolean; + _isVisible(): boolean; + render(): boolean; + dispose(): void; + static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem; + serialize(): any; + } +} + +declare module BABYLON { + /** + * 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?: Camera; + } + /** + * 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 { + name: 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; + private _scene; + private _engine; + private _options; + private _vertexBuffers; + private _indexBuffer; + private _downSamplePostprocess; + private _horizontalBlurPostprocess; + private _verticalBlurPostprocess; + private _cachedDefines; + private _glowMapGenerationEffect; + private _glowMapMergeEffect; + private _blurTexture; + private _mainTexture; + private _mainTextureDesiredSize; + private _meshes; + private _maxSize; + private _shouldRender; + private _instanceGlowingMeshStencilReference; + private _excludedMeshes; + /** + * 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 wether the highlight layer is enabled or not. */ @@ -4476,179 +4649,6 @@ declare module BABYLON { } } -declare module BABYLON { - class LensFlare { - size: number; - position: number; - color: Color3; - texture: Texture; - alphaMode: number; - private _system; - constructor(size: number, position: number, color: any, imgUrl: string, system: LensFlareSystem); - dispose: () => void; - } -} - -declare module BABYLON { - class LensFlareSystem { - name: string; - lensFlares: LensFlare[]; - borderLimit: number; - viewportBorder: number; - meshesSelectionPredicate: (mesh: Mesh) => boolean; - layerMask: number; - id: string; - private _scene; - private _emitter; - private _vertexBuffers; - private _indexBuffer; - private _effect; - private _positionX; - private _positionY; - private _isEnabled; - constructor(name: string, emitter: any, scene: Scene); - isEnabled: boolean; - getScene(): Scene; - getEmitter(): any; - setEmitter(newEmitter: any): void; - getEmitterPosition(): Vector3; - computeEffectivePosition(globalViewport: Viewport): boolean; - _isVisible(): boolean; - render(): boolean; - dispose(): void; - static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem; - serialize(): any; - } -} - -declare module BABYLON.Debug { - class AxesViewer { - private _xline; - private _yline; - private _zline; - private _xmesh; - private _ymesh; - private _zmesh; - scene: Scene; - scaleLines: number; - constructor(scene: Scene, scaleLines?: number); - update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void; - dispose(): void; - } -} - -declare module BABYLON.Debug { - class BoneAxesViewer extends Debug.AxesViewer { - mesh: Mesh; - bone: Bone; - pos: Vector3; - xaxis: Vector3; - yaxis: Vector3; - zaxis: Vector3; - constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number); - update(): void; - dispose(): void; - } -} - -declare module BABYLON { - class DebugLayer { - private _scene; - static InspectorURL: string; - private _inspector; - constructor(scene: Scene); - /** Creates the inspector window. */ - private _createInspector(config?); - isVisible(): boolean; - hide(): void; - show(config?: { - popup?: boolean; - initialTab?: number; - parentElement?: HTMLElement; - newColors?: { - backgroundColor?: string; - backgroundColorLighter?: string; - backgroundColorLighter2?: string; - backgroundColorLighter3?: string; - color?: string; - colorTop?: string; - colorBot?: string; - }; - }): void; - } -} - -declare module BABYLON.Debug { - class PhysicsViewer { - protected _impostors: Array; - protected _meshes: Array; - protected _scene: Scene; - protected _numMeshes: number; - protected _physicsEnginePlugin: IPhysicsEnginePlugin; - private _renderFunction; - private _debugBoxMesh; - private _debugSphereMesh; - private _debugMaterial; - constructor(scene: Scene); - protected _updateDebugMeshes(): void; - showImpostor(impostor: PhysicsImpostor): void; - hideImpostor(impostor: PhysicsImpostor): void; - private _getDebugMaterial(scene); - private _getDebugBoxMesh(scene); - private _getDebugSphereMesh(scene); - private _getDebugMesh(impostor, scene); - dispose(): void; - } -} - -declare module BABYLON { - class RayHelper { - ray: Ray; - private _renderPoints; - private _renderLine; - private _renderFunction; - private _scene; - private _updateToMeshFunction; - private _attachedToMesh; - private _meshSpaceDirection; - private _meshSpaceOrigin; - static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper; - constructor(ray: Ray); - show(scene: Scene, color: Color3): void; - hide(): void; - private _render(); - attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void; - detachFromMesh(): void; - private _updateToMesh(); - dispose(): void; - } -} - -declare module BABYLON.Debug { - /** - * Demo available here: http://www.babylonjs-playground.com/#1BZJVJ#8 - */ - class SkeletonViewer { - skeleton: Skeleton; - mesh: AbstractMesh; - autoUpdateBonesMatrices: boolean; - renderingGroupId: number; - color: Color3; - private _scene; - private _debugLines; - private _debugMesh; - private _isEnabled; - private _renderFunction; - constructor(skeleton: Skeleton, mesh: AbstractMesh, scene: Scene, autoUpdateBonesMatrices?: boolean, renderingGroupId?: number); - isEnabled: boolean; - private _getBonePosition(position, bone, meshMat, x?, y?, z?); - private _getLinesForBonesWithLength(bones, meshMat); - private _getLinesForBonesNoLength(bones, meshMat); - update(): void; - dispose(): void; - } -} - declare module BABYLON { class DirectionalLight extends ShadowLight { private _shadowFrustumSize; @@ -5282,3528 +5282,3528 @@ declare module BABYLON { } 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; + class Scalar { /** - * 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). + * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45) */ + static WithinEpsilon(a: number, b: number, epsilon?: number): boolean; /** - * 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). + * Returns a string : the upper case translation of the number i to hexadecimal. */ - globalHue: number; + static ToHex(i: number): string; /** - * 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. + * Returns -1 if value is negative and +1 is value is positive. + * Returns the value itself if it's equal to zero. */ + static Sign(value: number): number; /** - * 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. + * Returns the value itself if it's between min and max. + * Returns min if the value is lower than min. + * Returns max if the value is greater than max. */ - globalDensity: number; + static Clamp(value: number, min?: number, max?: number): 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. + * Returns the log2 of value. */ + static Log2(value: number): number; /** - * 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; - private _highlightsHue; - private _highlightsDensity; - private _highlightsSaturation; - private _highlightsExposure; + * Loops the value, so that it is never larger than length and never smaller than 0. + * + * This is similar to the modulo operator but it works with floating point numbers. + * For example, using 3.0 for t and 2.5 for length, the result would be 0.5. + * With t = 5 and length = 2.5, the result would be 0.0. + * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator + */ + static Repeat(value: number, length: number): number; /** - * 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). - */ + * Normalize the value between 0.0 and 1.0 using min and max values + */ + static Normalize(value: number, min: number, max: number): number; /** - * 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; + * Denormalize the value from 0.0 and 1.0 using min and max values + */ + static Denormalize(normalized: number, min: number, max: number): 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. - */ + * Calculates the shortest difference between two given angles given in degrees. + */ + static DeltaAngle(current: number, target: number): number; /** - * 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; + * PingPongs the value t, so that it is never larger than length and never smaller than 0. + * + * The returned value will move back and forth between 0 and length + */ + static PingPong(tx: number, length: number): 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. - */ + * Interpolates between min and max with smoothing at the limits. + * + * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up + * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions. + */ + static SmoothStep(from: number, to: number, tx: number): number; /** - * 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; + * Moves a value current towards target. + * + * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta. + * Negative values of maxDelta pushes the value away from target. + */ + static MoveTowards(current: number, target: number, maxDelta: number): 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. + * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees. + * + * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta + * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead. + */ + static MoveTowardsAngle(current: number, target: number, maxDelta: number): number; + /** + * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar. + */ + static Lerp(start: number, end: number, amount: number): number; + /** + * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees. + * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees. + */ + static LerpAngle(start: number, end: number, amount: number): number; + /** + * Calculates the linear parameter t that produces the interpolant value within the range [a, b]. + */ + static InverseLerp(a: number, b: number, value: number): number; + /** + * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2". */ + static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number; /** - * 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. + * Returns a random float number between and min and max values + */ + static RandomRange(min: number, max: number): number; + /** + * This function returns percentage of a number in a given range. + * + * RangeToPercent(40,20,60) will return 0.5 (50%) + * RangeToPercent(34,0,100) will return 0.34 (34%) + */ + static RangeToPercent(number: number, min: number, max: number): number; + /** + * This function returns number that corresponds to the percentage in a given range. + * + * PercentToRange(0.34,0,100) will return 34. + */ + static PercentToRange(percent: number, min: number, max: number): number; + } +} + +declare module BABYLON { + class SIMDHelper { + private static _isEnabled; + static readonly IsEnabled: boolean; + static DisableSIMD(): void; + static EnableSIMD(): void; + } +} + +declare module BABYLON { + const ToGammaSpace: number; + const ToLinearSpace = 2.2; + const Epsilon = 0.001; + class Color3 { + r: number; + g: number; + b: number; + /** + * Creates a new Color3 object from red, green, blue values, all between 0 and 1. */ - highlightsExposure: number; - private _midtonesHue; - private _midtonesDensity; - private _midtonesSaturation; - private _midtonesExposure; + constructor(r?: number, g?: number, b?: number); /** - * 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). + * Returns a string with the Color3 current values. */ + toString(): string; /** - * 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). + * Returns the string "Color3". */ - midtonesHue: number; + getClassName(): string; /** - * 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. + * Returns the Color3 hash code. */ + getHashCode(): number; /** - * 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. + * Stores in the passed array from the passed starting index the red, green, blue values as successive elements. + * Returns the Color3. */ - midtonesDensity: number; + toArray(array: number[] | Float32Array, index?: number): Color3; /** - * 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. + * Returns a new Color4 object from the current Color3 and the passed alpha. */ + toColor4(alpha?: number): Color4; /** - * 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. + * Returns a new array populated with 3 numeric elements : red, green and blue values. */ - midtonesSaturation: number; + asArray(): 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. + * Returns the luminance value (float). */ + toLuminance(): number; /** - * 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. + * Multiply each Color3 rgb values by the passed Color3 rgb values in a new Color3 object. + * Returns this new object. */ - midtonesExposure: number; - private _shadowsHue; - private _shadowsDensity; - private _shadowsSaturation; - private _shadowsExposure; + multiply(otherColor: Color3): Color3; /** - * 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). + * Multiply the rgb values of the Color3 and the passed Color3 and stores the result in the object "result". + * Returns the current Color3. */ + multiplyToRef(otherColor: Color3, result: Color3): Color3; /** - * 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). + * Boolean : True if the rgb values are equal to the passed ones. */ - shadowsHue: number; + equals(otherColor: Color3): boolean; /** - * 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. + * Boolean : True if the rgb values are equal to the passed ones. */ + equalsFloats(r: number, g: number, b: number): boolean; /** - * 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. + * Multiplies in place each rgb value by scale. + * Returns the updated Color3. */ - shadowsDensity: number; + scale(scale: number): Color3; /** - * 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. + * Multiplies the rgb values by scale and stores the result into "result". + * Returns the unmodified current Color3. */ + scaleToRef(scale: number, result: Color3): Color3; /** - * 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. + * Returns a new Color3 set with the added values of the current Color3 and of the passed one. */ - shadowsSaturation: number; + add(otherColor: Color3): Color3; /** - * 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. + * Stores the result of the addition of the current Color3 and passed one rgb values into "result". + * Returns the unmodified current Color3. */ + addToRef(otherColor: Color3, result: Color3): Color3; /** - * 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. + * Returns a new Color3 set with the subtracted values of the passed one from the current Color3 . */ - shadowsExposure: number; - getClassName(): string; + subtract(otherColor: Color3): Color3; /** - * Binds the color curves to the shader. - * @param colorCurves The color curve to bind - * @param effect The effect to bind to + * Stores the result of the subtraction of passed one from the current Color3 rgb values into "result". + * Returns the unmodified current Color3. */ - static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void; + subtractToRef(otherColor: Color3, result: Color3): Color3; /** - * Prepare the list of uniforms associated with the ColorCurves effects. - * @param uniformsList The list of uniforms used in the effect + * Returns a new Color3 copied the current one. */ - static PrepareUniforms(uniformsList: string[]): void; + clone(): Color3; /** - * 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. + * Copies the rgb values from the source in the current Color3. + * Returns the updated Color3. */ - private getColorGradingDataToRef(hue, density, saturation, exposure, result); + copyFrom(source: Color3): Color3; /** - * 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. + * Updates the Color3 rgb values from the passed floats. + * Returns the Color3. */ - private static applyColorGradingSliderNonlinear(value); + copyFromFloats(r: number, g: number, b: number): Color3; /** - * 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. + * Updates the Color3 rgb values from the passed floats. + * Returns the Color3. */ - private static fromHSBToRef(hue, saturation, brightness, result); + set(r: number, g: number, b: number): Color3; /** - * 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. + * Returns the Color3 hexadecimal code as a string. */ - private static clamp(value, min, max); + toHexString(): string; /** - * Clones the current color curve instance. - * @return The cloned curves + * Returns a new Color3 converted to linear space. */ - clone(): ColorCurves; + toLinearSpace(): Color3; /** - * Serializes the current color curve instance to a json representation. - * @return a JSON representation + * Converts the Color3 values to linear space and stores the result in "convertedColor". + * Returns the unmodified Color3. */ - serialize(): any; + toLinearSpaceToRef(convertedColor: Color3): Color3; /** - * Parses the color curve from a json representation. - * @param source the JSON source to parse - * @return The parsed curves + * Returns a new Color3 converted to gamma space. */ - static Parse(source: any): ColorCurves; + toGammaSpace(): Color3; + /** + * Converts the Color3 values to gamma space and stores the result in "convertedColor". + * Returns the unmodified Color3. + */ + toGammaSpaceToRef(convertedColor: Color3): Color3; + /** + * Creates a new Color3 from the string containing valid hexadecimal values. + */ + static FromHexString(hex: string): Color3; + /** + * Creates a new Vector3 from the startind index of the passed array. + */ + static FromArray(array: ArrayLike, offset?: number): Color3; + /** + * Creates a new Color3 from integer values ( < 256). + */ + static FromInts(r: number, g: number, b: number): Color3; + /** + * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3. + */ + static Lerp(start: Color3, end: Color3, amount: number): Color3; + static Red(): Color3; + static Green(): Color3; + static Blue(): Color3; + static Black(): Color3; + static White(): Color3; + static Purple(): Color3; + static Magenta(): Color3; + static Yellow(): Color3; + static Gray(): Color3; + static Teal(): Color3; + static Random(): Color3; } -} - -declare module BABYLON { - class EffectFallbacks { - private _defines; - private _currentRank; - private _maxRank; - private _mesh; - private _meshRank; - addFallback(rank: number, define: string): void; - addCPUSkinningFallback(rank: number, mesh: BABYLON.AbstractMesh): void; - readonly isMoreFallbacks: boolean; - reduce(currentDefines: string): string; - } - class EffectCreationOptions { - attributes: string[]; - uniformsNames: string[]; - uniformBuffersNames: string[]; - samplers: string[]; - defines: any; - fallbacks: EffectFallbacks; - onCompiled: (effect: Effect) => void; - onError: (effect: Effect, errors: string) => void; - indexParameters: any; - maxSimultaneousLights: number; - } - class Effect { - name: any; - defines: string; - onCompiled: (effect: Effect) => void; - onError: (effect: Effect, errors: string) => void; - onBind: (effect: Effect) => void; - uniqueId: number; - onCompileObservable: Observable; - onErrorObservable: Observable; - onBindObservable: Observable; - private static _uniqueIdSeed; - private _engine; - private _uniformBuffersNames; - private _uniformsNames; - private _samplers; - private _isReady; - private _compilationError; - private _attributesNames; - private _attributes; - private _uniforms; - _key: string; - private _indexParameters; - private _fallbacks; - private _program; - private _valueCache; - private static _baseCache; - constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], engine?: Engine, defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, indexParameters?: any); - readonly key: string; - isReady(): boolean; - getEngine(): Engine; - getProgram(): WebGLProgram; - getAttributesNames(): string[]; - getAttributeLocation(index: number): number; - getAttributeLocationByName(name: string): number; - getAttributesCount(): number; - getUniformIndex(uniformName: string): number; - getUniform(uniformName: string): WebGLUniformLocation; - getSamplers(): string[]; - getCompilationError(): string; - getVertexShaderSource(): string; - getFragmentShaderSource(): string; - executeWhenCompiled(func: (effect: Effect) => void): void; - _loadVertexShader(vertex: any, callback: (data: any) => void): void; - _loadFragmentShader(fragment: any, callback: (data: any) => void): void; - private _dumpShadersSource(vertexCode, fragmentCode, defines); - private _processShaderConversion(sourceCode, isFragment, callback); - private _processIncludes(sourceCode, callback); - private _processPrecision(source); - private _prepareEffect(vertexSourceCode, fragmentSourceCode, attributesNames, defines, fallbacks?); - readonly isSupported: boolean; - _bindTexture(channel: string, texture: WebGLTexture): void; - setTexture(channel: string, texture: BaseTexture): void; - setTextureArray(channel: string, textures: BaseTexture[]): void; - setTextureFromPostProcess(channel: string, postProcess: PostProcess): void; - _cacheMatrix(uniformName: string, matrix: Matrix): boolean; - _cacheFloat2(uniformName: string, x: number, y: number): boolean; - _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean; - _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean; - bindUniformBuffer(buffer: WebGLBuffer, name: string): void; - bindUniformBlock(blockName: string, index: number): void; - setIntArray(uniformName: string, array: Int32Array): Effect; - setIntArray2(uniformName: string, array: Int32Array): Effect; - setIntArray3(uniformName: string, array: Int32Array): Effect; - setIntArray4(uniformName: string, array: Int32Array): Effect; - setFloatArray(uniformName: string, array: Float32Array): Effect; - setFloatArray2(uniformName: string, array: Float32Array): Effect; - setFloatArray3(uniformName: string, array: Float32Array): Effect; - setFloatArray4(uniformName: string, array: Float32Array): Effect; - setArray(uniformName: string, array: number[]): Effect; - setArray2(uniformName: string, array: number[]): Effect; - setArray3(uniformName: string, array: number[]): Effect; - setArray4(uniformName: string, array: number[]): Effect; - setMatrices(uniformName: string, matrices: Float32Array): Effect; - setMatrix(uniformName: string, matrix: Matrix): Effect; - setMatrix3x3(uniformName: string, matrix: Float32Array): Effect; - setMatrix2x2(uniformName: string, matrix: Float32Array): Effect; - setFloat(uniformName: string, value: number): Effect; - setBool(uniformName: string, bool: boolean): Effect; - setVector2(uniformName: string, vector2: Vector2): Effect; - setFloat2(uniformName: string, x: number, y: number): Effect; - setVector3(uniformName: string, vector3: Vector3): Effect; - setFloat3(uniformName: string, x: number, y: number, z: number): Effect; - setVector4(uniformName: string, vector4: Vector4): Effect; - setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect; - setColor3(uniformName: string, color3: Color3): Effect; - setColor4(uniformName: string, color3: Color3, alpha: number): Effect; - private _recombineShader(node); - private _evaluateDefinesOnString(shaderString); - static ShadersStore: {}; - static IncludesShadersStore: {}; - static ResetCache(): void; - } -} - -declare module BABYLON { - class FresnelParameters { - private _isEnabled; - isEnabled: boolean; - leftColor: Color3; - rightColor: Color3; - bias: number; - power: number; - clone(): FresnelParameters; - serialize(): any; - static Parse(parsedFresnelParameters: any): FresnelParameters; - } -} - -declare module BABYLON { - /** - * Interface to follow in your material defines to integrate easily the - * Image proccessing functions. - */ - interface IImageProcessingConfigurationDefines { - IMAGEPROCESSING: boolean; - VIGNETTE: boolean; - VIGNETTEBLENDMODEMULTIPLY: boolean; - VIGNETTEBLENDMODEOPAQUE: boolean; - TONEMAPPING: boolean; - CONTRAST: boolean; - EXPOSURE: boolean; - COLORCURVES: boolean; - COLORGRADING: boolean; - SAMPLER3DGREENDEPTH: boolean; - SAMPLER3DBGRMAP: boolean; - IMAGEPROCESSINGPOSTPROCESS: boolean; - } - /** - * 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 { + class Color4 { + r: number; + g: number; + b: number; + a: number; /** - * Color curves setup used in the effect if colorCurvesEnabled is set to true + * Creates a new Color4 object from the passed float values ( < 1) : red, green, blue, alpha. */ - colorCurves: ColorCurves; - private _colorCurvesEnabled; + constructor(r?: number, g?: number, b?: number, a?: number); /** - * Gets wether the color curves effect is enabled. + * Adds in place the passed Color4 values to the current Color4. + * Returns the updated Color4. */ + addInPlace(right: any): Color4; /** - * Sets wether the color curves effect is enabled. + * Returns a new array populated with 4 numeric elements : red, green, blue, alpha values. */ - colorCurvesEnabled: boolean; + asArray(): number[]; /** - * Color grading LUT texture used in the effect if colorGradingEnabled is set to true + * Stores from the starting index in the passed array the Color4 successive values. + * Returns the Color4. */ - colorGradingTexture: BaseTexture; - private _colorGradingEnabled; + toArray(array: number[], index?: number): Color4; /** - * Gets wether the color grading effect is enabled. + * Returns a new Color4 set with the added values of the current Color4 and of the passed one. */ + add(right: Color4): Color4; /** - * Sets wether the color grading effect is enabled. + * Returns a new Color4 set with the subtracted values of the passed one from the current Color4. */ - colorGradingEnabled: boolean; - private _colorGradingWithGreenDepth; + subtract(right: Color4): Color4; /** - * Gets wether the color grading effect is using a green depth for the 3d Texture. + * Subtracts the passed ones from the current Color4 values and stores the results in "result". + * Returns the Color4. */ + subtractToRef(right: Color4, result: Color4): Color4; /** - * Sets wether the color grading effect is using a green depth for the 3d Texture. + * Creates a new Color4 with the current Color4 values multiplied by scale. */ - colorGradingWithGreenDepth: boolean; - private _colorGradingBGR; + scale(scale: number): Color4; /** - * Gets wether the color grading texture contains BGR values. + * Multiplies the current Color4 values by scale and stores the result in "result". + * Returns the Color4. */ + scaleToRef(scale: number, result: Color4): Color4; /** - * Sets wether the color grading texture contains BGR values. - */ - colorGradingBGR: boolean; - _exposure: number; + * Multipy an RGBA Color4 value by another and return a new Color4 object + * @param color The Color4 (RGBA) value to multiply by + * @returns A new Color4. + */ + multiply(color: Color4): Color4; /** - * Gets the Exposure used in the effect. + * Multipy an RGBA Color4 value by another and push the result in a reference value + * @param color The Color4 (RGBA) value to multiply by + * @param result The Color4 (RGBA) to fill the result in + * @returns the result Color4. */ + multiplyToRef(color: Color4, result: Color4): Color4; /** - * Sets the Exposure used in the effect. + * Returns a string with the Color4 values. */ - exposure: number; - private _toneMappingEnabled; + toString(): string; /** - * Gets wether the tone mapping effect is enabled. + * Returns the string "Color4" */ + getClassName(): string; /** - * Sets wether the tone mapping effect is enabled. + * Return the Color4 hash code as a number. */ - toneMappingEnabled: boolean; - protected _contrast: number; + getHashCode(): number; /** - * Gets the contrast used in the effect. + * Creates a new Color4 copied from the current one. */ + clone(): Color4; /** - * Sets the contrast used in the effect. + * Copies the passed Color4 values into the current one. + * Returns the updated Color4. */ - contrast: number; + copyFrom(source: Color4): Color4; /** - * Vignette stretch size. + * Copies the passed float values into the current one. + * Returns the updated Color4. */ - vignetteStretch: number; + copyFromFloats(r: number, g: number, b: number, a: number): Color4; /** - * Vignette centre X Offset. + * Copies the passed float values into the current one. + * Returns the updated Color4. */ - vignetteCentreX: number; + set(r: number, g: number, b: number, a: number): Color4; /** - * Vignette centre Y Offset. + * Returns a string containing the hexadecimal Color4 code. */ - vignetteCentreY: number; + toHexString(): string; /** - * Vignette weight or intensity of the vignette effect. + * Returns a new Color4 converted to linear space. */ - vignetteWeight: number; + toLinearSpace(): Color4; /** - * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode) - * if vignetteEnabled is set to true. + * Converts the Color4 values to linear space and stores the result in "convertedColor". + * Returns the unmodified Color4. */ - vignetteColor: BABYLON.Color4; + toLinearSpaceToRef(convertedColor: Color4): Color4; /** - * Camera field of view used by the Vignette effect. + * Returns a new Color4 converted to gamma space. */ - vignetteCameraFov: number; - private _vignetteBlendMode; + toGammaSpace(): Color4; /** - * Gets the vignette blend mode allowing different kind of effect. + * Converts the Color4 values to gamma space and stores the result in "convertedColor". + * Returns the unmodified Color4. */ + toGammaSpaceToRef(convertedColor: Color4): Color4; /** - * Sets the vignette blend mode allowing different kind of effect. + * Creates a new Color4 from the valid hexadecimal value contained in the passed string. */ - vignetteBlendMode: number; - private _vignetteEnabled; + static FromHexString(hex: string): Color4; /** - * Gets wether the vignette effect is enabled. + * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 and the right Color4. */ + static Lerp(left: Color4, right: Color4, amount: number): Color4; /** - * Sets wether the vignette effect is enabled. + * Set the passed "result" with the linearly interpolated values of "amount" between the left Color4 and the right Color4. */ - vignetteEnabled: boolean; - private _applyByPostProcess; + static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void; /** - * Gets wether the image processing is applied through a post process or not. + * Creates a new Color4 from the starting index element of the passed array. */ + static FromArray(array: ArrayLike, offset?: number): Color4; /** - * Sets wether the image processing is applied through a post process or not. + * Creates a new Color4 from the passed integers ( < 256 ). */ - applyByPostProcess: boolean; - /** - * An event triggered when the configuration changes and requires Shader to Update some parameters. - * @type {BABYLON.Observable} - */ - onUpdateParameters: Observable; + static FromInts(r: number, g: number, b: number, a: number): Color4; + static CheckColors4(colors: number[], count: number): number[]; + } + class Vector2 { + x: number; + y: number; /** - * Method called each time the image processing information changes requires to recompile the effect. + * Creates a new Vector2 from the passed x and y coordinates. */ - protected _updateParameters(): void; - getClassName(): string; + constructor(x: number, y: number); /** - * Prepare the list of uniforms associated with the Image Processing effects. - * @param uniformsList The list of uniforms used in the effect - * @param defines the list of defines currently in use + * Returns a string with the Vector2 coordinates. */ - static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void; + toString(): string; /** - * Prepare the list of samplers associated with the Image Processing effects. - * @param uniformsList The list of uniforms used in the effect - * @param defines the list of defines currently in use + * Returns the string "Vector2" */ - static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void; + getClassName(): string; /** - * Prepare the list of defines associated to the shader. - * @param defines the list of defines to complete + * Returns the Vector2 hash code as a number. */ - prepareDefines(defines: IImageProcessingConfigurationDefines): void; + getHashCode(): number; /** - * Returns true if all the image processing information are ready. + * Sets the Vector2 coordinates in the passed array or Float32Array from the passed index. + * Returns the Vector2. */ - isReady(): boolean; + toArray(array: number[] | Float32Array, index?: number): Vector2; /** - * Binds the image processing to the shader. - * @param effect The effect to bind to + * Returns a new array with 2 elements : the Vector2 coordinates. */ - bind(effect: Effect, aspectRatio?: number): void; + asArray(): number[]; /** - * Clones the current image processing instance. - * @return The cloned image processing + * Sets the Vector2 coordinates with the passed Vector2 coordinates. + * Returns the updated Vector2. */ - clone(): ImageProcessingConfiguration; + copyFrom(source: Vector2): Vector2; /** - * Serializes the current image processing instance to a json representation. - * @return a JSON representation + * Sets the Vector2 coordinates with the passed floats. + * Returns the updated Vector2. */ - serialize(): any; + copyFromFloats(x: number, y: number): Vector2; /** - * Parses the image processing from a json representation. - * @param source the JSON source to parse - * @return The parsed image processing + * Sets the Vector2 coordinates with the passed floats. + * Returns the updated Vector2. */ - static Parse(source: any): ImageProcessingConfiguration; - private static _VIGNETTEMODE_MULTIPLY; - private static _VIGNETTEMODE_OPAQUE; + set(x: number, y: number): Vector2; /** - * Used to apply the vignette as a mix with the pixel color. + * Returns a new Vector2 set with the addition of the current Vector2 and the passed one coordinates. */ - static readonly VIGNETTEMODE_MULTIPLY: number; + add(otherVector: Vector2): Vector2; /** - * Used to apply the vignette as a replacement of the pixel color. + * Sets the "result" coordinates with the addition of the current Vector2 and the passed one coordinates. + * Returns the Vector2. */ - static readonly VIGNETTEMODE_OPAQUE: number; - } -} - -declare module BABYLON { - class MaterialDefines { - private _keys; - private _isDirty; - _renderId: number; - _areLightsDirty: boolean; - _areAttributesDirty: boolean; - _areTexturesDirty: boolean; - _areFresnelDirty: boolean; - _areMiscDirty: boolean; - _areImageProcessingDirty: boolean; - _normals: boolean; - _uvs: boolean; - _needNormals: boolean; - _needUVs: boolean; - readonly isDirty: boolean; - markAsProcessed(): void; - markAsUnprocessed(): void; - markAllAsDirty(): void; - markAsImageProcessingDirty(): void; - markAsLightDirty(): void; - markAsAttributesDirty(): void; - markAsTexturesDirty(): void; - markAsFresnelDirty(): void; - markAsMiscDirty(): void; - rebuild(): void; - isEqual(other: MaterialDefines): boolean; - cloneTo(other: MaterialDefines): void; - reset(): void; - toString(): string; - } - class Material { - private static _TriangleFillMode; - private static _WireFrameFillMode; - private static _PointFillMode; - static readonly TriangleFillMode: number; - static readonly WireFrameFillMode: number; - static readonly PointFillMode: number; - private static _ClockWiseSideOrientation; - private static _CounterClockWiseSideOrientation; - static readonly ClockWiseSideOrientation: number; - static readonly CounterClockWiseSideOrientation: number; - private static _TextureDirtyFlag; - private static _LightDirtyFlag; - private static _FresnelDirtyFlag; - private static _AttributesDirtyFlag; - private static _MiscDirtyFlag; - static readonly TextureDirtyFlag: number; - static readonly LightDirtyFlag: number; - static readonly FresnelDirtyFlag: number; - static readonly AttributesDirtyFlag: number; - static readonly MiscDirtyFlag: number; - id: string; - name: string; - checkReadyOnEveryCall: boolean; - checkReadyOnlyOnce: boolean; - state: string; - alpha: number; - protected _backFaceCulling: boolean; - backFaceCulling: boolean; - sideOrientation: number; - onCompiled: (effect: Effect) => void; - onError: (effect: Effect, errors: string) => void; - getRenderTargetTextures: () => SmartArray; - doNotSerialize: boolean; - storeEffectOnSubMeshes: boolean; + addToRef(otherVector: Vector2, result: Vector2): Vector2; /** - * An event triggered when the material is disposed. - * @type {BABYLON.Observable} - */ - onDisposeObservable: Observable; - private _onDisposeObserver; - onDispose: () => void; + * Set the Vector2 coordinates by adding the passed Vector2 coordinates. + * Returns the updated Vector2. + */ + addInPlace(otherVector: Vector2): Vector2; /** - * An event triggered when the material is bound. - * @type {BABYLON.Observable} - */ - onBindObservable: Observable; - private _onBindObserver; - onBind: (Mesh: AbstractMesh) => void; + * Returns a new Vector2 by adding the current Vector2 coordinates to the passed Vector3 x, y coordinates. + */ + addVector3(otherVector: Vector3): Vector2; /** - * An event triggered when the material is unbound. - * @type {BABYLON.Observable} - */ - onUnBindObservable: Observable; - alphaMode: number; - disableDepthWrite: boolean; - private _fogEnabled; - fogEnabled: boolean; - pointSize: number; - zOffset: number; - wireframe: boolean; - pointsCloud: boolean; - fillMode: number; - _effect: Effect; - _wasPreviouslyReady: boolean; - private _useUBO; - private _scene; - private _fillMode; - private _cachedDepthWriteState; - protected _uniformBuffer: UniformBuffer; - constructor(name: string, scene: Scene, doNotAdd?: boolean); + * Returns a new Vector2 set with the subtracted coordinates of the passed one from the current Vector2. + */ + subtract(otherVector: Vector2): Vector2; /** - * @param {boolean} fullDetails - support for multiple levels of logging within scene loading - * subclasses should override adding information pertainent to themselves + * Sets the "result" coordinates with the subtraction of the passed one from the current Vector2 coordinates. + * Returns the Vector2. */ - toString(fullDetails?: boolean): string; + subtractToRef(otherVector: Vector2, result: Vector2): Vector2; /** - * Child classes can use it to update shaders + * Sets the current Vector2 coordinates by subtracting from it the passed one coordinates. + * Returns the updated Vector2. */ - getClassName(): string; - readonly isFrozen: boolean; - freeze(): void; - unfreeze(): void; - isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean; - isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean; - getEffect(): Effect; - getScene(): Scene; - needAlphaBlending(): boolean; - needAlphaTesting(): boolean; - getAlphaTestTexture(): BaseTexture; - markDirty(): void; - _preBind(effect?: Effect): void; - bind(world: Matrix, mesh?: Mesh): void; - bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void; - bindOnlyWorldMatrix(world: Matrix): void; - bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void; - bindView(effect: Effect): void; - bindViewProjection(effect: Effect): void; - protected _afterBind(mesh: Mesh): void; - unbind(): void; - getActiveTextures(): BaseTexture[]; - hasTexture(texture: BaseTexture): boolean; - clone(name: string): Material; - getBindedMeshes(): AbstractMesh[]; + subtractInPlace(otherVector: Vector2): Vector2; /** - * Force shader compilation including textures ready check - */ - forceCompilation(mesh: AbstractMesh, onCompiled: (material: Material) => void, options?: { - alphaTest: boolean; - clipPlane: boolean; - }): void; - markAsDirty(flag: number): void; - protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void; - protected _markAllSubMeshesAsImageProcessingDirty(): void; - protected _markAllSubMeshesAsTexturesDirty(): void; - protected _markAllSubMeshesAsFresnelDirty(): void; - protected _markAllSubMeshesAsLightsDirty(): void; - protected _markAllSubMeshesAsAttributesDirty(): void; - protected _markAllSubMeshesAsMiscDirty(): void; - dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void; - serialize(): any; - static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial; - static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any; - } -} - -declare module BABYLON { - class MaterialHelper { - static PrepareDefinesForMergedUV(texture: BaseTexture, defines: MaterialDefines, key: string): void; - static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void; - static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: any, fogEnabled: boolean, defines: MaterialDefines): void; - static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: MaterialDefines, useInstances: boolean, forceAlphaTest?: boolean): void; - static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: MaterialDefines, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean): boolean; - static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: MaterialDefines, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean; - static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: MaterialDefines, maxSimultaneousLights?: number): void; - static HandleFallbacksForShadows(defines: MaterialDefines, fallbacks: EffectFallbacks, maxSimultaneousLights?: number): void; - static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: MaterialDefines): void; - static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: MaterialDefines, fallbacks: EffectFallbacks): void; - static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void; - static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void; - static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void; - static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: MaterialDefines, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void; - static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect): void; - static BindBonesParameters(mesh: AbstractMesh, effect: Effect): void; - static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void; - static BindLogDepth(defines: MaterialDefines, effect: Effect, scene: Scene): void; - static BindClipPlane(effect: Effect, scene: Scene): void; - } -} - -declare module BABYLON { - class MultiMaterial extends Material { - private _subMaterials; - subMaterials: Material[]; - constructor(name: string, scene: Scene); - private _hookArray(array); - getSubMaterial(index: any): Material; - getActiveTextures(): BaseTexture[]; - getClassName(): string; - isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean; - clone(name: string, cloneChildren?: boolean): MultiMaterial; - serialize(): any; - dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void; - } -} - -declare module BABYLON { - class PushMaterial extends Material { - protected _activeEffect: Effect; - constructor(name: string, scene: Scene); - getEffect(): Effect; - isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean; - bindOnlyWorldMatrix(world: Matrix): void; - bind(world: Matrix, mesh?: Mesh): void; - protected _afterBind(mesh: Mesh, effect?: Effect): void; - protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean; - } -} - -declare module BABYLON { - class ShaderMaterial extends Material { - private _shaderPath; - private _options; - private _textures; - private _textureArrays; - private _floats; - private _floatsArrays; - private _colors3; - private _colors3Arrays; - private _colors4; - private _vectors2; - private _vectors3; - private _vectors4; - private _matrices; - private _matrices3x3; - private _matrices2x2; - private _vectors3Arrays; - private _cachedWorldViewMatrix; - private _renderId; - constructor(name: string, scene: Scene, shaderPath: any, options: any); - getClassName(): string; - needAlphaBlending(): boolean; - needAlphaTesting(): boolean; - private _checkUniform(uniformName); - setTexture(name: string, texture: Texture): ShaderMaterial; - setTextureArray(name: string, textures: Texture[]): ShaderMaterial; - setFloat(name: string, value: number): ShaderMaterial; - setFloats(name: string, value: number[]): ShaderMaterial; - setColor3(name: string, value: Color3): ShaderMaterial; - setColor3Array(name: string, value: Color3[]): ShaderMaterial; - setColor4(name: string, value: Color4): ShaderMaterial; - setVector2(name: string, value: Vector2): ShaderMaterial; - setVector3(name: string, value: Vector3): ShaderMaterial; - setVector4(name: string, value: Vector4): ShaderMaterial; - setMatrix(name: string, value: Matrix): ShaderMaterial; - setMatrix3x3(name: string, value: Float32Array): ShaderMaterial; - setMatrix2x2(name: string, value: Float32Array): ShaderMaterial; - setArray3(name: string, value: number[]): ShaderMaterial; - private _checkCache(scene, mesh?, useInstances?); - isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean; - bindOnlyWorldMatrix(world: Matrix): void; - bind(world: Matrix, mesh?: Mesh): void; - getActiveTextures(): BaseTexture[]; - hasTexture(texture: BaseTexture): boolean; - clone(name: string): ShaderMaterial; - dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void; - serialize(): any; - static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial; - } -} - -declare module BABYLON { - class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines { - MAINUV1: boolean; - MAINUV2: boolean; - DIFFUSE: boolean; - DIFFUSEDIRECTUV: number; - AMBIENT: boolean; - AMBIENTDIRECTUV: number; - OPACITY: boolean; - OPACITYDIRECTUV: number; - OPACITYRGB: boolean; - REFLECTION: boolean; - EMISSIVE: boolean; - EMISSIVEDIRECTUV: number; - SPECULAR: boolean; - SPECULARDIRECTUV: number; - BUMP: boolean; - BUMPDIRECTUV: number; - PARALLAX: boolean; - PARALLAXOCCLUSION: boolean; - SPECULAROVERALPHA: boolean; - CLIPPLANE: boolean; - ALPHATEST: boolean; - ALPHAFROMDIFFUSE: boolean; - POINTSIZE: boolean; - FOG: boolean; - SPECULARTERM: boolean; - DIFFUSEFRESNEL: boolean; - OPACITYFRESNEL: boolean; - REFLECTIONFRESNEL: boolean; - REFRACTIONFRESNEL: boolean; - EMISSIVEFRESNEL: boolean; - FRESNEL: boolean; - NORMAL: boolean; - UV1: boolean; - UV2: boolean; - VERTEXCOLOR: boolean; - VERTEXALPHA: boolean; - NUM_BONE_INFLUENCERS: number; - BonesPerMesh: number; - INSTANCES: boolean; - GLOSSINESS: boolean; - ROUGHNESS: boolean; - EMISSIVEASILLUMINATION: boolean; - LINKEMISSIVEWITHDIFFUSE: boolean; - REFLECTIONFRESNELFROMSPECULAR: boolean; - LIGHTMAP: boolean; - LIGHTMAPDIRECTUV: number; - USELIGHTMAPASSHADOWMAP: boolean; - REFLECTIONMAP_3D: boolean; - REFLECTIONMAP_SPHERICAL: boolean; - REFLECTIONMAP_PLANAR: boolean; - REFLECTIONMAP_CUBIC: boolean; - REFLECTIONMAP_PROJECTION: boolean; - REFLECTIONMAP_SKYBOX: boolean; - REFLECTIONMAP_EXPLICIT: boolean; - REFLECTIONMAP_EQUIRECTANGULAR: boolean; - REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean; - REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean; - INVERTCUBICMAP: boolean; - LOGARITHMICDEPTH: boolean; - REFRACTION: boolean; - REFRACTIONMAP_3D: boolean; - REFLECTIONOVERALPHA: boolean; - TWOSIDEDLIGHTING: boolean; - SHADOWFLOAT: boolean; - MORPHTARGETS: boolean; - MORPHTARGETS_NORMAL: boolean; - MORPHTARGETS_TANGENT: boolean; - NUM_MORPH_INFLUENCERS: number; - USERIGHTHANDEDSYSTEM: boolean; - IMAGEPROCESSING: boolean; - VIGNETTE: boolean; - VIGNETTEBLENDMODEMULTIPLY: boolean; - VIGNETTEBLENDMODEOPAQUE: boolean; - TONEMAPPING: boolean; - CONTRAST: boolean; - COLORCURVES: boolean; - COLORGRADING: boolean; - SAMPLER3DGREENDEPTH: boolean; - SAMPLER3DBGRMAP: boolean; - IMAGEPROCESSINGPOSTPROCESS: boolean; - EXPOSURE: boolean; - constructor(); - setReflectionMode(modeToEnable: string): void; - } - class StandardMaterial extends PushMaterial { - private _diffuseTexture; - diffuseTexture: BaseTexture; - private _ambientTexture; - ambientTexture: BaseTexture; - private _opacityTexture; - opacityTexture: BaseTexture; - private _reflectionTexture; - reflectionTexture: BaseTexture; - private _emissiveTexture; - emissiveTexture: BaseTexture; - private _specularTexture; - specularTexture: BaseTexture; - private _bumpTexture; - bumpTexture: BaseTexture; - private _lightmapTexture; - lightmapTexture: BaseTexture; - private _refractionTexture; - refractionTexture: BaseTexture; - ambientColor: Color3; - diffuseColor: Color3; - specularColor: Color3; - emissiveColor: Color3; - specularPower: number; - private _useAlphaFromDiffuseTexture; - useAlphaFromDiffuseTexture: boolean; - private _useEmissiveAsIllumination; - useEmissiveAsIllumination: boolean; - private _linkEmissiveWithDiffuse; - linkEmissiveWithDiffuse: boolean; - private _useSpecularOverAlpha; - useSpecularOverAlpha: boolean; - private _useReflectionOverAlpha; - useReflectionOverAlpha: boolean; - private _disableLighting; - disableLighting: boolean; - private _useParallax; - useParallax: boolean; - private _useParallaxOcclusion; - useParallaxOcclusion: boolean; - parallaxScaleBias: number; - private _roughness; - roughness: number; - indexOfRefraction: number; - invertRefractionY: boolean; - private _useLightmapAsShadowmap; - useLightmapAsShadowmap: boolean; - private _diffuseFresnelParameters; - diffuseFresnelParameters: FresnelParameters; - private _opacityFresnelParameters; - opacityFresnelParameters: FresnelParameters; - private _reflectionFresnelParameters; - reflectionFresnelParameters: FresnelParameters; - private _refractionFresnelParameters; - refractionFresnelParameters: FresnelParameters; - private _emissiveFresnelParameters; - emissiveFresnelParameters: FresnelParameters; - private _useReflectionFresnelFromSpecular; - useReflectionFresnelFromSpecular: boolean; - private _useGlossinessFromSpecularMapAlpha; - useGlossinessFromSpecularMapAlpha: boolean; - private _maxSimultaneousLights; - maxSimultaneousLights: number; - /** - * If sets to true, x component of normal map value will invert (x = 1.0 - x). - */ - private _invertNormalMapX; - invertNormalMapX: boolean; - /** - * If sets to true, y component of normal map value will invert (y = 1.0 - y). - */ - private _invertNormalMapY; - invertNormalMapY: boolean; - /** - * If sets to true and backfaceCulling is false, normals will be flipped on the backside. - */ - private _twoSidedLighting; - twoSidedLighting: boolean; - /** - * Default configuration related to image processing available in the standard Material. - */ - protected _imageProcessingConfiguration: ImageProcessingConfiguration; - /** - * Gets the image processing configuration used either in this material. - */ - /** - * Sets the Default image processing configuration used either in the this material. - * - * If sets to null, the scene one is in use. - */ - imageProcessingConfiguration: ImageProcessingConfiguration; - /** - * Keep track of the image processing observer to allow dispose and replace. - */ - private _imageProcessingObserver; - /** - * Attaches a new image processing configuration to the Standard Material. - * @param configuration - */ - protected _attachImageProcessingConfiguration(configuration: ImageProcessingConfiguration): void; - /** - * Gets wether the color curves effect is enabled. - */ - /** - * Sets wether the color curves effect is enabled. - */ - cameraColorCurvesEnabled: boolean; - /** - * Gets wether the color grading effect is enabled. - */ - /** - * Gets wether the color grading effect is enabled. - */ - cameraColorGradingEnabled: boolean; - /** - * Gets wether tonemapping is enabled or not. - */ - /** - * Sets wether tonemapping is enabled or not - */ - cameraToneMappingEnabled: boolean; - /** - * The camera exposure used on this material. - * This property is here and not in the camera to allow controlling exposure without full screen post process. - * This corresponds to a photographic exposure. - */ - /** - * The camera exposure used on this material. - * This property is here and not in the camera to allow controlling exposure without full screen post process. - * This corresponds to a photographic exposure. - */ - cameraExposure: number; - /** - * Gets The camera contrast used on this material. + * Multiplies in place the current Vector2 coordinates by the passed ones. + * Returns the updated Vector2. */ + multiplyInPlace(otherVector: Vector2): Vector2; /** - * Sets The camera contrast used on this material. + * Returns a new Vector2 set with the multiplication of the current Vector2 and the passed one coordinates. */ - cameraContrast: number; + multiply(otherVector: Vector2): Vector2; /** - * Gets the Color Grading 2D Lookup Texture. + * Sets "result" coordinates with the multiplication of the current Vector2 and the passed one coordinates. + * Returns the Vector2. */ + multiplyToRef(otherVector: Vector2, result: Vector2): Vector2; /** - * Sets the Color Grading 2D Lookup Texture. + * Returns a new Vector2 set with the Vector2 coordinates multiplied by the passed floats. */ - cameraColorGradingTexture: BaseTexture; - customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string; - protected _renderTargets: SmartArray; - protected _worldViewProjectionMatrix: Matrix; - protected _globalAmbientColor: Color3; - protected _useLogarithmicDepth: boolean; - constructor(name: string, scene: Scene); - getClassName(): string; - useLogarithmicDepth: boolean; - needAlphaBlending(): boolean; - needAlphaTesting(): boolean; - protected _shouldUseAlphaFromDiffuseTexture(): boolean; - getAlphaTestTexture(): BaseTexture; + multiplyByFloats(x: number, y: number): Vector2; /** - * Child classes can use it to update shaders - */ - isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean; - buildUniformLayout(): void; - unbind(): void; - bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void; - getAnimatables(): IAnimatable[]; - getActiveTextures(): BaseTexture[]; - hasTexture(texture: BaseTexture): boolean; - dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void; - clone(name: string): StandardMaterial; - serialize(): any; - static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial; - static _DiffuseTextureEnabled: boolean; - static DiffuseTextureEnabled: boolean; - static _AmbientTextureEnabled: boolean; - static AmbientTextureEnabled: boolean; - static _OpacityTextureEnabled: boolean; - static OpacityTextureEnabled: boolean; - static _ReflectionTextureEnabled: boolean; - static ReflectionTextureEnabled: boolean; - static _EmissiveTextureEnabled: boolean; - static EmissiveTextureEnabled: boolean; - static _SpecularTextureEnabled: boolean; - static SpecularTextureEnabled: boolean; - static _BumpTextureEnabled: boolean; - static BumpTextureEnabled: boolean; - static _LightmapTextureEnabled: boolean; - static LightmapTextureEnabled: boolean; - static _RefractionTextureEnabled: boolean; - static RefractionTextureEnabled: boolean; - static _ColorGradingTextureEnabled: boolean; - static ColorGradingTextureEnabled: boolean; - static _FresnelEnabled: boolean; - static FresnelEnabled: boolean; - } -} - -declare module BABYLON { - class UniformBuffer { - private _engine; - private _buffer; - private _data; - private _bufferData; - private _dynamic; - private _uniformName; - private _uniformLocations; - private _uniformSizes; - private _uniformLocationPointer; - private _needSync; - private _cache; - private _noUBO; - private _currentEffect; - private static _MAX_UNIFORM_SIZE; - private static _tempBuffer; + * Returns a new Vector2 set with the Vector2 coordinates divided by the passed one coordinates. + */ + divide(otherVector: Vector2): Vector2; /** - * Wrapper for updateUniform. - * @method updateMatrix3x3 - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {Float32Array} matrix + * Sets the "result" coordinates with the Vector2 divided by the passed one coordinates. + * Returns the Vector2. */ - updateMatrix3x3: (name: string, matrix: Float32Array) => void; + divideToRef(otherVector: Vector2, result: Vector2): Vector2; /** - * Wrapper for updateUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {Float32Array} matrix + * Returns a new Vector2 with current Vector2 negated coordinates. */ - updateMatrix2x2: (name: string, matrix: Float32Array) => void; + negate(): Vector2; /** - * Wrapper for updateUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {number} x + * Multiply the Vector2 coordinates by scale. + * Returns the updated Vector2. */ - updateFloat: (name: string, x: number) => void; + scaleInPlace(scale: number): Vector2; /** - * Wrapper for updateUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {number} x - * @param {number} y - * @param {string} [suffix] Suffix to add to the uniform name. + * Returns a new Vector2 scaled by "scale" from the current Vector2. */ - updateFloat2: (name: string, x: number, y: number, suffix?: string) => void; + scale(scale: number): Vector2; /** - * Wrapper for updateUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {number} x - * @param {number} y - * @param {number} z - * @param {string} [suffix] Suffix to add to the uniform name. + * Boolean : True if the passed vector coordinates strictly equal the current Vector2 ones. */ - updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void; + equals(otherVector: Vector2): boolean; /** - * Wrapper for updateUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {number} x - * @param {number} y - * @param {number} z - * @param {number} w - * @param {string} [suffix] Suffix to add to the uniform name. + * Boolean : True if the passed vector coordinates are close to the current ones by a distance of epsilon. */ - updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void; + equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean; /** - * Wrapper for updateUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {Matrix} A 4x4 matrix. + * Returns the vector length (float). */ - updateMatrix: (name: string, mat: Matrix) => void; + length(): number; /** - * Wrapper for updateUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {Vector3} vector + * Returns the vector squared length (float); */ - updateVector3: (name: string, vector: Vector3) => void; + lengthSquared(): number; /** - * Wrapper for updateUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {Vector4} vector + * Normalize the vector. + * Returns the updated Vector2. */ - updateVector4: (name: string, vector: Vector4) => void; + normalize(): Vector2; /** - * Wrapper for updateUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {Color3} color - * @param {string} [suffix] Suffix to add to the uniform name. + * Returns a new Vector2 copied from the Vector2. */ - updateColor3: (name: string, color: Color3, suffix?: string) => void; + clone(): Vector2; /** - * Wrapper for updateUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {Color3} color - * @param {number} alpha - * @param {string} [suffix] Suffix to add to the uniform name. + * Returns a new Vector2(0, 0) */ - updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void; + static Zero(): Vector2; /** - * Uniform buffer objects. - * - * Handles blocks of uniform on the GPU. - * - * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls. - * - * For more information, please refer to : - * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object + * Returns a new Vector2(1, 1) */ - constructor(engine: Engine, data?: number[], dynamic?: boolean); + static One(): Vector2; /** - * Indicates if the buffer is using the WebGL2 UBO implementation, - * or just falling back on setUniformXXX calls. + * Returns a new Vector2 set from the passed index element of the passed array. */ - readonly useUbo: boolean; + static FromArray(array: ArrayLike, offset?: number): Vector2; /** - * Indicates if the WebGL underlying uniform buffer is in sync - * with the javascript cache data. + * Sets "result" from the passed index element of the passed array. */ - readonly isSync: boolean; + static FromArrayToRef(array: ArrayLike, offset: number, result: Vector2): void; /** - * Indicates if the WebGL underlying uniform buffer is dynamic. - * Also, a dynamic UniformBuffer will disable cache verification and always - * update the underlying WebGL uniform buffer to the GPU. + * Retuns a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the passed four Vector2. */ - isDynamic(): boolean; + static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2; /** - * The data cache on JS side. + * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max". + * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate. + * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate. */ - getData(): Float32Array; + static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2; /** - * The underlying WebGL Uniform buffer. + * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2". */ - getBuffer(): WebGLBuffer; + static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2; /** - * std140 layout specifies how to align data within an UBO structure. - * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159 - * for specs. + * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end". */ - private _fillAlignment(size); + static Lerp(start: Vector2, end: Vector2, amount: number): Vector2; /** - * Adds an uniform in the buffer. - * Warning : the subsequents calls of this function must be in the same order as declared in the shader - * for the layout to be correct ! - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {number|number[]} size Data size, or data directly. + * Returns the dot product (float) of the vector "left" and the vector "right". */ - addUniform(name: string, size: number | number[]): void; + static Dot(left: Vector2, right: Vector2): number; /** - * Wrapper for addUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {Matrix} mat A 4x4 matrix. + * Returns a new Vector2 equal to the normalized passed vector. */ - addMatrix(name: string, mat: Matrix): void; + static Normalize(vector: Vector2): Vector2; /** - * Wrapper for addUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {number} x - * @param {number} y + * Returns a new Vecto2 set with the minimal coordinate values from the "left" and "right" vectors. */ - addFloat2(name: string, x: number, y: number): void; + static Minimize(left: Vector2, right: Vector2): Vector2; /** - * Wrapper for addUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {number} x - * @param {number} y - * @param {number} z + * Returns a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors. */ - addFloat3(name: string, x: number, y: number, z: number): void; + static Maximize(left: Vector2, right: Vector2): Vector2; /** - * Wrapper for addUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {Color3} color + * Returns a new Vecto2 set with the transformed coordinates of the passed vector by the passed transformation matrix. */ - addColor3(name: string, color: Color3): void; + static Transform(vector: Vector2, transformation: Matrix): Vector2; /** - * Wrapper for addUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {Color3} color - * @param {number} alpha + * Transforms the passed vector coordinates by the passed transformation matrix and stores the result in the vector "result" coordinates. */ - addColor4(name: string, color: Color3, alpha: number): void; + static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void; /** - * Wrapper for addUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. - * @param {Vector3} vector + * Boolean : True if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2" */ - addVector3(name: string, vector: Vector3): void; + static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean; /** - * Wrapper for addUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * Returns the distance (float) between the vectors "value1" and "value2". */ - addMatrix3x3(name: string): void; + static Distance(value1: Vector2, value2: Vector2): number; /** - * Wrapper for addUniform. - * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * Returns the squared distance (float) between the vectors "value1" and "value2". */ - addMatrix2x2(name: string): void; + static DistanceSquared(value1: Vector2, value2: Vector2): number; /** - * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`. + * Returns a new Vecto2 located at the center of the vectors "value1" and "value2". */ - create(): void; + static Center(value1: Vector2, value2: Vector2): Vector2; /** - * Updates the WebGL Uniform Buffer on the GPU. - * If the `dynamic` flag is set to true, no cache comparison is done. - * Otherwise, the buffer will be updated only if the cache differs. + * Returns the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB". */ - update(): void; + static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number; + } + class Vector3 { + x: number; + y: number; + z: number; /** - * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU. - * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader. - * @param {number[]|Float32Array} data Flattened data - * @param {number} size Size of the data. + * Creates a new Vector3 object from the passed x, y, z (floats) coordinates. + * A Vector3 is the main object used in 3D geometry. + * It can represent etiher the coordinates of a point the space, either a direction. */ - updateUniform(uniformName: string, data: number[] | Float32Array, size: number): void; - private _updateMatrix3x3ForUniform(name, matrix); - private _updateMatrix3x3ForEffect(name, matrix); - private _updateMatrix2x2ForEffect(name, matrix); - private _updateMatrix2x2ForUniform(name, matrix); - private _updateFloatForEffect(name, x); - private _updateFloatForUniform(name, x); - private _updateFloat2ForEffect(name, x, y, suffix?); - private _updateFloat2ForUniform(name, x, y, suffix?); - private _updateFloat3ForEffect(name, x, y, z, suffix?); - private _updateFloat3ForUniform(name, x, y, z, suffix?); - private _updateFloat4ForEffect(name, x, y, z, w, suffix?); - private _updateFloat4ForUniform(name, x, y, z, w, suffix?); - private _updateMatrixForEffect(name, mat); - private _updateMatrixForUniform(name, mat); - private _updateVector3ForEffect(name, vector); - private _updateVector3ForUniform(name, vector); - private _updateVector4ForEffect(name, vector); - private _updateVector4ForUniform(name, vector); - private _updateColor3ForEffect(name, color, suffix?); - private _updateColor3ForUniform(name, color, suffix?); - private _updateColor4ForEffect(name, color, alpha, suffix?); - private _updateColor4ForUniform(name, color, alpha, suffix?); + constructor(x: number, y: number, z: number); /** - * Sets a sampler uniform on the effect. - * @param {string} name Name of the sampler. - * @param {Texture} texture + * Returns a string with the Vector3 coordinates. */ - setTexture(name: string, texture: BaseTexture): void; + toString(): string; /** - * Directly updates the value of the uniform in the cache AND on the GPU. - * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader. - * @param {number[]|Float32Array} data Flattened data + * Returns the string "Vector3" */ - updateUniformDirectly(uniformName: string, data: number[] | Float32Array): void; + getClassName(): string; /** - * Binds this uniform buffer to an effect. - * @param {Effect} effect - * @param {string} name Name of the uniform block in the shader. + * Returns the Vector hash code. */ - bindToEffect(effect: Effect, name: string): void; + getHashCode(): number; /** - * Disposes the uniform buffer. + * Returns a new array with three elements : the coordinates the Vector3. + */ + asArray(): number[]; + /** + * Populates the passed array or Float32Array from the passed index with the successive coordinates of the Vector3. + * Returns the Vector3. */ - dispose(): void; - } -} - -declare module BABYLON { - class Scalar { + toArray(array: number[] | Float32Array, index?: number): Vector3; /** - * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45) + * Returns a new Quaternion object, computed from the Vector3 coordinates. */ - static WithinEpsilon(a: number, b: number, epsilon?: number): boolean; + toQuaternion(): Quaternion; /** - * Returns a string : the upper case translation of the number i to hexadecimal. + * Adds the passed vector to the current Vector3. + * Returns the updated Vector3. */ - static ToHex(i: number): string; + addInPlace(otherVector: Vector3): Vector3; /** - * Returns -1 if value is negative and +1 is value is positive. - * Returns the value itself if it's equal to zero. + * Returns a new Vector3, result of the addition the current Vector3 and the passed vector. */ - static Sign(value: number): number; + add(otherVector: Vector3): Vector3; /** - * Returns the value itself if it's between min and max. - * Returns min if the value is lower than min. - * Returns max if the value is greater than max. + * Adds the current Vector3 to the passed one and stores the result in the vector "result". + * Returns the current Vector3. */ - static Clamp(value: number, min?: number, max?: number): number; + addToRef(otherVector: Vector3, result: Vector3): Vector3; /** - * Returns the log2 of value. + * Subtract the passed vector from the current Vector3. + * Returns the updated Vector3. */ - static Log2(value: number): number; + subtractInPlace(otherVector: Vector3): Vector3; /** - * Loops the value, so that it is never larger than length and never smaller than 0. - * - * This is similar to the modulo operator but it works with floating point numbers. - * For example, using 3.0 for t and 2.5 for length, the result would be 0.5. - * With t = 5 and length = 2.5, the result would be 0.0. - * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator - */ - static Repeat(value: number, length: number): number; + * Returns a new Vector3, result of the subtraction of the passed vector from the current Vector3. + */ + subtract(otherVector: Vector3): Vector3; /** - * Normalize the value between 0.0 and 1.0 using min and max values - */ - static Normalize(value: number, min: number, max: number): number; + * Subtracts the passed vector from the current Vector3 and stores the result in the vector "result". + * Returns the current Vector3. + */ + subtractToRef(otherVector: Vector3, result: Vector3): Vector3; /** - * Denormalize the value from 0.0 and 1.0 using min and max values - */ - static Denormalize(normalized: number, min: number, max: number): number; + * Returns a new Vector3 set with the subtraction of the passed floats from the current Vector3 coordinates. + */ + subtractFromFloats(x: number, y: number, z: number): Vector3; /** - * Calculates the shortest difference between two given angles given in degrees. - */ - static DeltaAngle(current: number, target: number): number; + * Subtracts the passed floats from the current Vector3 coordinates and set the passed vector "result" with this result. + * Returns the current Vector3. + */ + subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3; /** - * PingPongs the value t, so that it is never larger than length and never smaller than 0. - * - * The returned value will move back and forth between 0 and length - */ - static PingPong(tx: number, length: number): number; + * Returns a new Vector3 set with the current Vector3 negated coordinates. + */ + negate(): Vector3; /** - * Interpolates between min and max with smoothing at the limits. - * - * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up - * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions. - */ - static SmoothStep(from: number, to: number, tx: number): number; + * Multiplies the Vector3 coordinates by the float "scale". + * Returns the updated Vector3. + */ + scaleInPlace(scale: number): Vector3; /** - * Moves a value current towards target. - * - * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta. - * Negative values of maxDelta pushes the value away from target. - */ - static MoveTowards(current: number, target: number, maxDelta: number): number; + * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale". + */ + scale(scale: number): Vector3; /** - * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees. - * - * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta - * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead. - */ - static MoveTowardsAngle(current: number, target: number, maxDelta: number): number; + * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the passed vector "result" coordinates. + * Returns the current Vector3. + */ + scaleToRef(scale: number, result: Vector3): Vector3; /** - * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar. - */ - static Lerp(start: number, end: number, amount: number): number; + * Boolean : True if the current Vector3 and the passed vector coordinates are strictly equal. + */ + equals(otherVector: Vector3): boolean; /** - * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees. - * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees. - */ - static LerpAngle(start: number, end: number, amount: number): number; + * Boolean : True if the current Vector3 and the passed vector coordinates are distant less than epsilon. + */ + equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean; /** - * Calculates the linear parameter t that produces the interpolant value within the range [a, b]. - */ - static InverseLerp(a: number, b: number, value: number): number; + * Boolean : True if the current Vector3 coordinate equal the passed floats. + */ + equalsToFloats(x: number, y: number, z: number): boolean; /** - * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2". + * Muliplies the current Vector3 coordinates by the passed ones. + * Returns the updated Vector3. */ - static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number; + multiplyInPlace(otherVector: Vector3): Vector3; /** - * Returns a random float number between and min and max values - */ - static RandomRange(min: number, max: number): number; + * Returns a new Vector3, result of the multiplication of the current Vector3 by the passed vector. + */ + multiply(otherVector: Vector3): Vector3; /** - * This function returns percentage of a number in a given range. - * - * RangeToPercent(40,20,60) will return 0.5 (50%) - * RangeToPercent(34,0,100) will return 0.34 (34%) - */ - static RangeToPercent(number: number, min: number, max: number): number; + * Multiplies the current Vector3 by the passed one and stores the result in the passed vector "result". + * Returns the current Vector3. + */ + multiplyToRef(otherVector: Vector3, result: Vector3): Vector3; /** - * This function returns number that corresponds to the percentage in a given range. - * - * PercentToRange(0.34,0,100) will return 34. - */ - static PercentToRange(percent: number, min: number, max: number): number; - } -} - -declare module BABYLON { - class SIMDHelper { - private static _isEnabled; - static readonly IsEnabled: boolean; - static DisableSIMD(): void; - static EnableSIMD(): void; - } -} - -declare module BABYLON { - const ToGammaSpace: number; - const ToLinearSpace = 2.2; - const Epsilon = 0.001; - class Color3 { - r: number; - g: number; - b: number; + * Returns a new Vector3 set witth the result of the mulliplication of the current Vector3 coordinates by the passed floats. + */ + multiplyByFloats(x: number, y: number, z: number): Vector3; /** - * Creates a new Color3 object from red, green, blue values, all between 0 and 1. + * Returns a new Vector3 set witth the result of the division of the current Vector3 coordinates by the passed ones. */ - constructor(r?: number, g?: number, b?: number); + divide(otherVector: Vector3): Vector3; /** - * Returns a string with the Color3 current values. + * Divides the current Vector3 coordinates by the passed ones and stores the result in the passed vector "result". + * Returns the current Vector3. */ - toString(): string; + divideToRef(otherVector: Vector3, result: Vector3): Vector3; /** - * Returns the string "Color3". + * Updates the current Vector3 with the minimal coordinate values between its and the passed vector ones. + * Returns the updated Vector3. */ - getClassName(): string; + MinimizeInPlace(other: Vector3): Vector3; /** - * Returns the Color3 hash code. + * Updates the current Vector3 with the maximal coordinate values between its and the passed vector ones. + * Returns the updated Vector3. */ - getHashCode(): number; + MaximizeInPlace(other: Vector3): Vector3; /** - * Stores in the passed array from the passed starting index the red, green, blue values as successive elements. - * Returns the Color3. + * Returns the length of the Vector3 (float). */ - toArray(array: number[] | Float32Array, index?: number): Color3; + length(): number; /** - * Returns a new Color4 object from the current Color3 and the passed alpha. + * Returns the squared length of the Vector3 (float). */ - toColor4(alpha?: number): Color4; + lengthSquared(): number; /** - * Returns a new array populated with 3 numeric elements : red, green and blue values. + * Normalize the current Vector3. + * Returns the updated Vector3. */ - asArray(): number[]; + normalize(): Vector3; /** - * Returns the luminance value (float). + * Returns a new Vector3 copied from the current Vector3. */ - toLuminance(): number; + clone(): Vector3; /** - * Multiply each Color3 rgb values by the passed Color3 rgb values in a new Color3 object. - * Returns this new object. + * Copies the passed vector coordinates to the current Vector3 ones. + * Returns the updated Vector3. */ - multiply(otherColor: Color3): Color3; + copyFrom(source: Vector3): Vector3; /** - * Multiply the rgb values of the Color3 and the passed Color3 and stores the result in the object "result". - * Returns the current Color3. + * Copies the passed floats to the current Vector3 coordinates. + * Returns the updated Vector3. */ - multiplyToRef(otherColor: Color3, result: Color3): Color3; + copyFromFloats(x: number, y: number, z: number): Vector3; /** - * Boolean : True if the rgb values are equal to the passed ones. + * Copies the passed floats to the current Vector3 coordinates. + * Returns the updated Vector3. */ - equals(otherColor: Color3): boolean; + set(x: number, y: number, z: number): Vector3; /** - * Boolean : True if the rgb values are equal to the passed ones. + * */ - equalsFloats(r: number, g: number, b: number): boolean; + static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: any): number; /** - * Multiplies in place each rgb value by scale. - * Returns the updated Color3. + * Returns a new Vector3 set from the index "offset" of the passed array. */ - scale(scale: number): Color3; + static FromArray(array: ArrayLike, offset?: number): Vector3; /** - * Multiplies the rgb values by scale and stores the result into "result". - * Returns the unmodified current Color3. + * Returns a new Vector3 set from the index "offset" of the passed Float32Array. + * This function is deprecated. Use FromArray instead. */ - scaleToRef(scale: number, result: Color3): Color3; + static FromFloatArray(array: Float32Array, offset?: number): Vector3; /** - * Returns a new Color3 set with the added values of the current Color3 and of the passed one. + * Sets the passed vector "result" with the element values from the index "offset" of the passed array. */ - add(otherColor: Color3): Color3; + static FromArrayToRef(array: ArrayLike, offset: number, result: Vector3): void; /** - * Stores the result of the addition of the current Color3 and passed one rgb values into "result". - * Returns the unmodified current Color3. + * Sets the passed vector "result" with the element values from the index "offset" of the passed Float32Array. + * This function is deprecated. Use FromArrayToRef instead. */ - addToRef(otherColor: Color3, result: Color3): Color3; + static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void; /** - * Returns a new Color3 set with the subtracted values of the passed one from the current Color3 . + * Sets the passed vector "result" with the passed floats. */ - subtract(otherColor: Color3): Color3; + static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void; /** - * Stores the result of the subtraction of passed one from the current Color3 rgb values into "result". - * Returns the unmodified current Color3. + * Returns a new Vector3 set to (0.0, 0.0, 0.0). */ - subtractToRef(otherColor: Color3, result: Color3): Color3; + static Zero(): Vector3; /** - * Returns a new Color3 copied the current one. + * Returns a new Vector3 set to (1.0, 1.0, 1.0). */ - clone(): Color3; + static One(): Vector3; /** - * Copies the rgb values from the source in the current Color3. - * Returns the updated Color3. + * Returns a new Vector3 set to (0.0, 1.0, 0.0) */ - copyFrom(source: Color3): Color3; + static Up(): Vector3; /** - * Updates the Color3 rgb values from the passed floats. - * Returns the Color3. + * Returns a new Vector3 set to (0.0, 0.0, 1.0) */ - copyFromFloats(r: number, g: number, b: number): Color3; + static Forward(): Vector3; /** - * Updates the Color3 rgb values from the passed floats. - * Returns the Color3. + * Returns a new Vector3 set to (1.0, 0.0, 0.0) */ - set(r: number, g: number, b: number): Color3; + static Right(): Vector3; /** - * Returns the Color3 hexadecimal code as a string. + * Returns a new Vector3 set to (-1.0, 0.0, 0.0) */ - toHexString(): string; + static Left(): Vector3; /** - * Returns a new Color3 converted to linear space. + * Returns a new Vector3 set with the result of the transformation by the passed matrix of the passed vector. + * This method computes tranformed coordinates only, not transformed direction vectors. */ - toLinearSpace(): Color3; + static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3; /** - * Converts the Color3 values to linear space and stores the result in "convertedColor". - * Returns the unmodified Color3. + * Sets the passed vector "result" coordinates with the result of the transformation by the passed matrix of the passed vector. + * This method computes tranformed coordinates only, not transformed direction vectors. */ - toLinearSpaceToRef(convertedColor: Color3): Color3; + static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void; /** - * Returns a new Color3 converted to gamma space. + * Sets the passed vector "result" coordinates with the result of the transformation by the passed matrix of the passed floats (x, y, z). + * This method computes tranformed coordinates only, not transformed direction vectors. */ - toGammaSpace(): Color3; + static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void; /** - * Converts the Color3 values to gamma space and stores the result in "convertedColor". - * Returns the unmodified Color3. + * Returns a new Vector3 set with the result of the normal transformation by the passed matrix of the passed vector. + * This methods computes transformed normalized direction vectors only. */ - toGammaSpaceToRef(convertedColor: Color3): Color3; + static TransformNormal(vector: Vector3, transformation: Matrix): Vector3; /** - * Creates a new Color3 from the string containing valid hexadecimal values. + * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed vector. + * This methods computes transformed normalized direction vectors only. */ - static FromHexString(hex: string): Color3; + static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void; /** - * Creates a new Vector3 from the startind index of the passed array. + * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed floats (x, y, z). + * This methods computes transformed normalized direction vectors only. */ - static FromArray(array: ArrayLike, offset?: number): Color3; + static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void; /** - * Creates a new Color3 from integer values ( < 256). + * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4". */ - static FromInts(r: number, g: number, b: number): Color3; + static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3; /** - * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3. + * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max". + * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one. + * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one. */ - static Lerp(start: Color3, end: Color3, amount: number): Color3; - static Red(): Color3; - static Green(): Color3; - static Blue(): Color3; - static Black(): Color3; - static White(): Color3; - static Purple(): Color3; - static Magenta(): Color3; - static Yellow(): Color3; - static Gray(): Color3; - static Teal(): Color3; - static Random(): Color3; - } - class Color4 { - r: number; - g: number; - b: number; - a: number; + static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3; /** - * Creates a new Color4 object from the passed float values ( < 1) : red, green, blue, alpha. + * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2". */ - constructor(r?: number, g?: number, b?: number, a?: number); + static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3; /** - * Adds in place the passed Color4 values to the current Color4. - * Returns the updated Color4. + * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end". */ - addInPlace(right: any): Color4; + static Lerp(start: Vector3, end: Vector3, amount: number): Vector3; /** - * Returns a new array populated with 4 numeric elements : red, green, blue, alpha values. + * Sets the passed vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end". */ - asArray(): number[]; + static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void; /** - * Stores from the starting index in the passed array the Color4 successive values. - * Returns the Color4. + * Returns the dot product (float) between the vectors "left" and "right". */ - toArray(array: number[], index?: number): Color4; + static Dot(left: Vector3, right: Vector3): number; /** - * Returns a new Color4 set with the added values of the current Color4 and of the passed one. + * Returns a new Vector3 as the cross product of the vectors "left" and "right". + * The cross product is then orthogonal to both "left" and "right". */ - add(right: Color4): Color4; + static Cross(left: Vector3, right: Vector3): Vector3; /** - * Returns a new Color4 set with the subtracted values of the passed one from the current Color4. + * Sets the passed vector "result" with the cross product of "left" and "right". + * The cross product is then orthogonal to both "left" and "right". */ - subtract(right: Color4): Color4; + static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void; /** - * Subtracts the passed ones from the current Color4 values and stores the results in "result". - * Returns the Color4. + * Returns a new Vector3 as the normalization of the passed vector. */ - subtractToRef(right: Color4, result: Color4): Color4; + static Normalize(vector: Vector3): Vector3; /** - * Creates a new Color4 with the current Color4 values multiplied by scale. + * Sets the passed vector "result" with the normalization of the passed first vector. */ - scale(scale: number): Color4; + static NormalizeToRef(vector: Vector3, result: Vector3): void; + private static _viewportMatrixCache; + static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3; + static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3; + static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3; + static Minimize(left: Vector3, right: Vector3): Vector3; + static Maximize(left: Vector3, right: Vector3): Vector3; /** - * Multiplies the current Color4 values by scale and stores the result in "result". - * Returns the Color4. + * Returns the distance (float) between the vectors "value1" and "value2". */ - scaleToRef(scale: number, result: Color4): Color4; + static Distance(value1: Vector3, value2: Vector3): number; /** - * Multipy an RGBA Color4 value by another and return a new Color4 object - * @param color The Color4 (RGBA) value to multiply by - * @returns A new Color4. - */ - multiply(color: Color4): Color4; + * Returns the squared distance (float) between the vectors "value1" and "value2". + */ + static DistanceSquared(value1: Vector3, value2: Vector3): number; /** - * Multipy an RGBA Color4 value by another and push the result in a reference value - * @param color The Color4 (RGBA) value to multiply by - * @param result The Color4 (RGBA) to fill the result in - * @returns the result Color4. + * Returns a new Vector3 located at the center between "value1" and "value2". */ - multiplyToRef(color: Color4, result: Color4): Color4; + static Center(value1: Vector3, value2: Vector3): Vector3; /** - * Returns a string with the Color4 values. + * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system), + * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply + * to something in order to rotate it from its local system to the given target system. + * Note : axis1, axis2 and axis3 are normalized during this operation. + * Returns a new Vector3. */ - toString(): string; + static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3; /** - * Returns the string "Color4" + * The same than RotationFromAxis but updates the passed ref Vector3 parameter instead of returning a new Vector3. */ - getClassName(): string; + static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void; + } + class Vector4 { + x: number; + y: number; + z: number; + w: number; /** - * Return the Color4 hash code as a number. + * Creates a Vector4 object from the passed floats. */ - getHashCode(): number; + constructor(x: number, y: number, z: number, w: number); /** - * Creates a new Color4 copied from the current one. + * Returns the string with the Vector4 coordinates. */ - clone(): Color4; + toString(): string; /** - * Copies the passed Color4 values into the current one. - * Returns the updated Color4. + * Returns the string "Vector4". */ - copyFrom(source: Color4): Color4; + getClassName(): string; /** - * Copies the passed float values into the current one. - * Returns the updated Color4. + * Returns the Vector4 hash code. */ - copyFromFloats(r: number, g: number, b: number, a: number): Color4; + getHashCode(): number; /** - * Copies the passed float values into the current one. - * Returns the updated Color4. + * Returns a new array populated with 4 elements : the Vector4 coordinates. */ - set(r: number, g: number, b: number, a: number): Color4; + asArray(): number[]; /** - * Returns a string containing the hexadecimal Color4 code. + * Populates the passed array from the passed index with the Vector4 coordinates. + * Returns the Vector4. */ - toHexString(): string; + toArray(array: number[] | Float32Array, index?: number): Vector4; /** - * Returns a new Color4 converted to linear space. + * Adds the passed vector to the current Vector4. + * Returns the updated Vector4. */ - toLinearSpace(): Color4; + addInPlace(otherVector: Vector4): Vector4; /** - * Converts the Color4 values to linear space and stores the result in "convertedColor". - * Returns the unmodified Color4. + * Returns a new Vector4 as the result of the addition of the current Vector4 and the passed one. */ - toLinearSpaceToRef(convertedColor: Color4): Color4; + add(otherVector: Vector4): Vector4; /** - * Returns a new Color4 converted to gamma space. + * Updates the passed vector "result" with the result of the addition of the current Vector4 and the passed one. + * Returns the current Vector4. */ - toGammaSpace(): Color4; + addToRef(otherVector: Vector4, result: Vector4): Vector4; /** - * Converts the Color4 values to gamma space and stores the result in "convertedColor". - * Returns the unmodified Color4. + * Subtract in place the passed vector from the current Vector4. + * Returns the updated Vector4. */ - toGammaSpaceToRef(convertedColor: Color4): Color4; + subtractInPlace(otherVector: Vector4): Vector4; /** - * Creates a new Color4 from the valid hexadecimal value contained in the passed string. + * Returns a new Vector4 with the result of the subtraction of the passed vector from the current Vector4. */ - static FromHexString(hex: string): Color4; + subtract(otherVector: Vector4): Vector4; /** - * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 and the right Color4. + * Sets the passed vector "result" with the result of the subtraction of the passed vector from the current Vector4. + * Returns the current Vector4. */ - static Lerp(left: Color4, right: Color4, amount: number): Color4; + subtractToRef(otherVector: Vector4, result: Vector4): Vector4; /** - * Set the passed "result" with the linearly interpolated values of "amount" between the left Color4 and the right Color4. + * Returns a new Vector4 set with the result of the subtraction of the passed floats from the current Vector4 coordinates. */ - static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void; + subtractFromFloats(x: number, y: number, z: number, w: number): Vector4; /** - * Creates a new Color4 from the starting index element of the passed array. + * Sets the passed vector "result" set with the result of the subtraction of the passed floats from the current Vector4 coordinates. + * Returns the current Vector4. */ - static FromArray(array: ArrayLike, offset?: number): Color4; + subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4; /** - * Creates a new Color4 from the passed integers ( < 256 ). + * Returns a new Vector4 set with the current Vector4 negated coordinates. */ - static FromInts(r: number, g: number, b: number, a: number): Color4; - static CheckColors4(colors: number[], count: number): number[]; - } - class Vector2 { - x: number; - y: number; + negate(): Vector4; /** - * Creates a new Vector2 from the passed x and y coordinates. + * Multiplies the current Vector4 coordinates by scale (float). + * Returns the updated Vector4. */ - constructor(x: number, y: number); + scaleInPlace(scale: number): Vector4; /** - * Returns a string with the Vector2 coordinates. + * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float). */ - toString(): string; + scale(scale: number): Vector4; /** - * Returns the string "Vector2" + * Sets the passed vector "result" with the current Vector4 coordinates multiplied by scale (float). + * Returns the current Vector4. */ - getClassName(): string; + scaleToRef(scale: number, result: Vector4): Vector4; /** - * Returns the Vector2 hash code as a number. + * Boolean : True if the current Vector4 coordinates are stricly equal to the passed ones. */ - getHashCode(): number; + equals(otherVector: Vector4): boolean; /** - * Sets the Vector2 coordinates in the passed array or Float32Array from the passed index. - * Returns the Vector2. + * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the passed vector ones. */ - toArray(array: number[] | Float32Array, index?: number): Vector2; + equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean; /** - * Returns a new array with 2 elements : the Vector2 coordinates. + * Boolean : True if the passed floats are strictly equal to the current Vector4 coordinates. */ - asArray(): number[]; + equalsToFloats(x: number, y: number, z: number, w: number): boolean; /** - * Sets the Vector2 coordinates with the passed Vector2 coordinates. - * Returns the updated Vector2. + * Multiplies in place the current Vector4 by the passed one. + * Returns the updated Vector4. */ - copyFrom(source: Vector2): Vector2; + multiplyInPlace(otherVector: Vector4): Vector4; /** - * Sets the Vector2 coordinates with the passed floats. - * Returns the updated Vector2. + * Returns a new Vector4 set with the multiplication result of the current Vector4 and the passed one. */ - copyFromFloats(x: number, y: number): Vector2; + multiply(otherVector: Vector4): Vector4; /** - * Sets the Vector2 coordinates with the passed floats. - * Returns the updated Vector2. + * Updates the passed vector "result" with the multiplication result of the current Vector4 and the passed one. + * Returns the current Vector4. */ - set(x: number, y: number): Vector2; + multiplyToRef(otherVector: Vector4, result: Vector4): Vector4; /** - * Returns a new Vector2 set with the addition of the current Vector2 and the passed one coordinates. + * Returns a new Vector4 set with the multiplication result of the passed floats and the current Vector4 coordinates. */ - add(otherVector: Vector2): Vector2; + multiplyByFloats(x: number, y: number, z: number, w: number): Vector4; /** - * Sets the "result" coordinates with the addition of the current Vector2 and the passed one coordinates. - * Returns the Vector2. + * Returns a new Vector4 set with the division result of the current Vector4 by the passed one. */ - addToRef(otherVector: Vector2, result: Vector2): Vector2; + divide(otherVector: Vector4): Vector4; /** - * Set the Vector2 coordinates by adding the passed Vector2 coordinates. - * Returns the updated Vector2. + * Updates the passed vector "result" with the division result of the current Vector4 by the passed one. + * Returns the current Vector4. */ - addInPlace(otherVector: Vector2): Vector2; + divideToRef(otherVector: Vector4, result: Vector4): Vector4; /** - * Returns a new Vector2 by adding the current Vector2 coordinates to the passed Vector3 x, y coordinates. + * Updates the Vector4 coordinates with the minimum values between its own and the passed vector ones. */ - addVector3(otherVector: Vector3): Vector2; + MinimizeInPlace(other: Vector4): Vector4; /** - * Returns a new Vector2 set with the subtracted coordinates of the passed one from the current Vector2. + * Updates the Vector4 coordinates with the maximum values between its own and the passed vector ones. */ - subtract(otherVector: Vector2): Vector2; + MaximizeInPlace(other: Vector4): Vector4; /** - * Sets the "result" coordinates with the subtraction of the passed one from the current Vector2 coordinates. - * Returns the Vector2. + * Returns the Vector4 length (float). */ - subtractToRef(otherVector: Vector2, result: Vector2): Vector2; + length(): number; /** - * Sets the current Vector2 coordinates by subtracting from it the passed one coordinates. - * Returns the updated Vector2. + * Returns the Vector4 squared length (float). */ - subtractInPlace(otherVector: Vector2): Vector2; + lengthSquared(): number; /** - * Multiplies in place the current Vector2 coordinates by the passed ones. - * Returns the updated Vector2. + * Normalizes in place the Vector4. + * Returns the updated Vector4. */ - multiplyInPlace(otherVector: Vector2): Vector2; + normalize(): Vector4; /** - * Returns a new Vector2 set with the multiplication of the current Vector2 and the passed one coordinates. + * Returns a new Vector3 from the Vector4 (x, y, z) coordinates. */ - multiply(otherVector: Vector2): Vector2; + toVector3(): Vector3; /** - * Sets "result" coordinates with the multiplication of the current Vector2 and the passed one coordinates. - * Returns the Vector2. + * Returns a new Vector4 copied from the current one. */ - multiplyToRef(otherVector: Vector2, result: Vector2): Vector2; + clone(): Vector4; /** - * Returns a new Vector2 set with the Vector2 coordinates multiplied by the passed floats. + * Updates the current Vector4 with the passed one coordinates. + * Returns the updated Vector4. */ - multiplyByFloats(x: number, y: number): Vector2; + copyFrom(source: Vector4): Vector4; /** - * Returns a new Vector2 set with the Vector2 coordinates divided by the passed one coordinates. + * Updates the current Vector4 coordinates with the passed floats. + * Returns the updated Vector4. */ - divide(otherVector: Vector2): Vector2; + copyFromFloats(x: number, y: number, z: number, w: number): Vector4; /** - * Sets the "result" coordinates with the Vector2 divided by the passed one coordinates. - * Returns the Vector2. + * Updates the current Vector4 coordinates with the passed floats. + * Returns the updated Vector4. */ - divideToRef(otherVector: Vector2, result: Vector2): Vector2; + set(x: number, y: number, z: number, w: number): Vector4; /** - * Returns a new Vector2 with current Vector2 negated coordinates. + * Returns a new Vector4 set from the starting index of the passed array. */ - negate(): Vector2; + static FromArray(array: ArrayLike, offset?: number): Vector4; /** - * Multiply the Vector2 coordinates by scale. - * Returns the updated Vector2. + * Updates the passed vector "result" from the starting index of the passed array. */ - scaleInPlace(scale: number): Vector2; + static FromArrayToRef(array: ArrayLike, offset: number, result: Vector4): void; /** - * Returns a new Vector2 scaled by "scale" from the current Vector2. + * Updates the passed vector "result" from the starting index of the passed Float32Array. */ - scale(scale: number): Vector2; + static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void; /** - * Boolean : True if the passed vector coordinates strictly equal the current Vector2 ones. + * Updates the passed vector "result" coordinates from the passed floats. */ - equals(otherVector: Vector2): boolean; + static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void; /** - * Boolean : True if the passed vector coordinates are close to the current ones by a distance of epsilon. + * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0) */ - equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean; + static Zero(): Vector4; /** - * Returns the vector length (float). + * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0) */ - length(): number; + static One(): Vector4; /** - * Returns the vector squared length (float); + * Returns a new normalized Vector4 from the passed one. */ - lengthSquared(): number; + static Normalize(vector: Vector4): Vector4; /** - * Normalize the vector. - * Returns the updated Vector2. + * Updates the passed vector "result" from the normalization of the passed one. */ - normalize(): Vector2; + static NormalizeToRef(vector: Vector4, result: Vector4): void; + static Minimize(left: Vector4, right: Vector4): Vector4; + static Maximize(left: Vector4, right: Vector4): Vector4; /** - * Returns a new Vector2 copied from the Vector2. + * Returns the distance (float) between the vectors "value1" and "value2". */ - clone(): Vector2; + static Distance(value1: Vector4, value2: Vector4): number; /** - * Returns a new Vector2(0, 0) + * Returns the squared distance (float) between the vectors "value1" and "value2". */ - static Zero(): Vector2; + static DistanceSquared(value1: Vector4, value2: Vector4): number; /** - * Returns a new Vector2(1, 1) + * Returns a new Vector4 located at the center between the vectors "value1" and "value2". */ - static One(): Vector2; + static Center(value1: Vector4, value2: Vector4): Vector4; /** - * Returns a new Vector2 set from the passed index element of the passed array. + * Returns a new Vector4 set with the result of the normal transformation by the passed matrix of the passed vector. + * This methods computes transformed normalized direction vectors only. */ - static FromArray(array: ArrayLike, offset?: number): Vector2; + static TransformNormal(vector: Vector4, transformation: Matrix): Vector4; /** - * Sets "result" from the passed index element of the passed array. + * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed vector. + * This methods computes transformed normalized direction vectors only. */ - static FromArrayToRef(array: ArrayLike, offset: number, result: Vector2): void; + static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void; /** - * Retuns a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the passed four Vector2. + * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed floats (x, y, z, w). + * This methods computes transformed normalized direction vectors only. */ - static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2; + static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void; + } + interface ISize { + width: number; + height: number; + } + class Size implements ISize { + width: number; + height: number; /** - * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max". - * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate. - * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate. + * Creates a Size object from the passed width and height (floats). */ - static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2; + constructor(width: number, height: number); + toString(): string; /** - * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2". + * Returns the string "Size" */ - static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2; + getClassName(): string; /** - * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end". + * Returns the Size hash code. */ - static Lerp(start: Vector2, end: Vector2, amount: number): Vector2; + getHashCode(): number; /** - * Returns the dot product (float) of the vector "left" and the vector "right". + * Updates the current size from the passed one. + * Returns the updated Size. */ - static Dot(left: Vector2, right: Vector2): number; + copyFrom(src: Size): void; /** - * Returns a new Vector2 equal to the normalized passed vector. + * Updates in place the current Size from the passed floats. + * Returns the updated Size. */ - static Normalize(vector: Vector2): Vector2; + copyFromFloats(width: number, height: number): Size; /** - * Returns a new Vecto2 set with the minimal coordinate values from the "left" and "right" vectors. + * Updates in place the current Size from the passed floats. + * Returns the updated Size. */ - static Minimize(left: Vector2, right: Vector2): Vector2; + set(width: number, height: number): Size; /** - * Returns a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors. + * Returns a new Size set with the multiplication result of the current Size and the passed floats. */ - static Maximize(left: Vector2, right: Vector2): Vector2; + multiplyByFloats(w: number, h: number): Size; /** - * Returns a new Vecto2 set with the transformed coordinates of the passed vector by the passed transformation matrix. + * Returns a new Size copied from the passed one. */ - static Transform(vector: Vector2, transformation: Matrix): Vector2; + clone(): Size; /** - * Transforms the passed vector coordinates by the passed transformation matrix and stores the result in the vector "result" coordinates. + * Boolean : True if the current Size and the passed one width and height are strictly equal. */ - static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void; + equals(other: Size): boolean; /** - * Boolean : True if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2" + * Returns the surface of the Size : width * height (float). */ - static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean; + readonly surface: number; /** - * Returns the distance (float) between the vectors "value1" and "value2". + * Returns a new Size set to (0.0, 0.0) */ - static Distance(value1: Vector2, value2: Vector2): number; + static Zero(): Size; /** - * Returns the squared distance (float) between the vectors "value1" and "value2". + * Returns a new Size set as the addition result of the current Size and the passed one. */ - static DistanceSquared(value1: Vector2, value2: Vector2): number; + add(otherSize: Size): Size; /** - * Returns a new Vecto2 located at the center of the vectors "value1" and "value2". + * Returns a new Size set as the subtraction result of the passed one from the current Size. */ - static Center(value1: Vector2, value2: Vector2): Vector2; + subtract(otherSize: Size): Size; /** - * Returns the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB". + * Returns a new Size set at the linear interpolation "amount" between "start" and "end". */ - static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number; + static Lerp(start: Size, end: Size, amount: number): Size; } - class Vector3 { + class Quaternion { x: number; y: number; z: number; + w: number; /** - * Creates a new Vector3 object from the passed x, y, z (floats) coordinates. - * A Vector3 is the main object used in 3D geometry. - * It can represent etiher the coordinates of a point the space, either a direction. + * Creates a new Quaternion from the passed floats. */ - constructor(x: number, y: number, z: number); + constructor(x?: number, y?: number, z?: number, w?: number); /** - * Returns a string with the Vector3 coordinates. + * Returns a string with the Quaternion coordinates. */ toString(): string; /** - * Returns the string "Vector3" + * Returns the string "Quaternion". */ getClassName(): string; /** - * Returns the Vector hash code. + * Returns the Quaternion hash code. */ getHashCode(): number; /** - * Returns a new array with three elements : the coordinates the Vector3. + * Returns a new array populated with 4 elements : the Quaternion coordinates. */ asArray(): number[]; /** - * Populates the passed array or Float32Array from the passed index with the successive coordinates of the Vector3. - * Returns the Vector3. - */ - toArray(array: number[] | Float32Array, index?: number): Vector3; - /** - * Returns a new Quaternion object, computed from the Vector3 coordinates. + * Boolean : True if the current Quaterion and the passed one coordinates are strictly equal. */ - toQuaternion(): Quaternion; + equals(otherQuaternion: Quaternion): boolean; /** - * Adds the passed vector to the current Vector3. - * Returns the updated Vector3. + * Returns a new Quaternion copied from the current one. */ - addInPlace(otherVector: Vector3): Vector3; + clone(): Quaternion; /** - * Returns a new Vector3, result of the addition the current Vector3 and the passed vector. + * Updates the current Quaternion from the passed one coordinates. + * Returns the updated Quaterion. */ - add(otherVector: Vector3): Vector3; + copyFrom(other: Quaternion): Quaternion; /** - * Adds the current Vector3 to the passed one and stores the result in the vector "result". - * Returns the current Vector3. + * Updates the current Quaternion from the passed float coordinates. + * Returns the updated Quaterion. */ - addToRef(otherVector: Vector3, result: Vector3): Vector3; + copyFromFloats(x: number, y: number, z: number, w: number): Quaternion; /** - * Subtract the passed vector from the current Vector3. - * Returns the updated Vector3. + * Updates the current Quaternion from the passed float coordinates. + * Returns the updated Quaterion. */ - subtractInPlace(otherVector: Vector3): Vector3; + set(x: number, y: number, z: number, w: number): Quaternion; /** - * Returns a new Vector3, result of the subtraction of the passed vector from the current Vector3. + * Returns a new Quaternion as the addition result of the passed one and the current Quaternion. */ - subtract(otherVector: Vector3): Vector3; + add(other: Quaternion): Quaternion; /** - * Subtracts the passed vector from the current Vector3 and stores the result in the vector "result". - * Returns the current Vector3. + * Returns a new Quaternion as the subtraction result of the passed one from the current Quaternion. */ - subtractToRef(otherVector: Vector3, result: Vector3): Vector3; + subtract(other: Quaternion): Quaternion; /** - * Returns a new Vector3 set with the subtraction of the passed floats from the current Vector3 coordinates. + * Returns a new Quaternion set by multiplying the current Quaterion coordinates by the float "scale". */ - subtractFromFloats(x: number, y: number, z: number): Vector3; + scale(value: number): Quaternion; /** - * Subtracts the passed floats from the current Vector3 coordinates and set the passed vector "result" with this result. - * Returns the current Vector3. + * Returns a new Quaternion set as the quaternion mulplication result of the current one with the passed one "q1". */ - subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3; + multiply(q1: Quaternion): Quaternion; /** - * Returns a new Vector3 set with the current Vector3 negated coordinates. + * Sets the passed "result" as the quaternion mulplication result of the current one with the passed one "q1". + * Returns the current Quaternion. */ - negate(): Vector3; + multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion; /** - * Multiplies the Vector3 coordinates by the float "scale". - * Returns the updated Vector3. + * Updates the current Quaternion with the quaternion mulplication result of itself with the passed one "q1". + * Returns the updated Quaternion. */ - scaleInPlace(scale: number): Vector3; + multiplyInPlace(q1: Quaternion): Quaternion; /** - * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale". + * Sets the passed "ref" with the conjugation of the current Quaternion. + * Returns the current Quaternion. */ - scale(scale: number): Vector3; + conjugateToRef(ref: Quaternion): Quaternion; /** - * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the passed vector "result" coordinates. - * Returns the current Vector3. + * Conjugates in place the current Quaternion. + * Returns the updated Quaternion. */ - scaleToRef(scale: number, result: Vector3): Vector3; + conjugateInPlace(): Quaternion; /** - * Boolean : True if the current Vector3 and the passed vector coordinates are strictly equal. + * Returns a new Quaternion as the conjugate of the current Quaternion. */ - equals(otherVector: Vector3): boolean; + conjugate(): Quaternion; /** - * Boolean : True if the current Vector3 and the passed vector coordinates are distant less than epsilon. + * Returns the Quaternion length (float). */ - equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean; + length(): number; /** - * Boolean : True if the current Vector3 coordinate equal the passed floats. + * Normalize in place the current Quaternion. + * Returns the updated Quaternion. */ - equalsToFloats(x: number, y: number, z: number): boolean; + normalize(): Quaternion; /** - * Muliplies the current Vector3 coordinates by the passed ones. - * Returns the updated Vector3. + * Returns a new Vector3 set with the Euler angles translated from the current Quaternion. */ - multiplyInPlace(otherVector: Vector3): Vector3; + toEulerAngles(order?: string): Vector3; /** - * Returns a new Vector3, result of the multiplication of the current Vector3 by the passed vector. + * Sets the passed vector3 "result" with the Euler angles translated from the current Quaternion. + * Returns the current Quaternion. */ - multiply(otherVector: Vector3): Vector3; + toEulerAnglesToRef(result: Vector3, order?: string): Quaternion; /** - * Multiplies the current Vector3 by the passed one and stores the result in the passed vector "result". - * Returns the current Vector3. + * Updates the passed rotation matrix with the current Quaternion values. + * Returns the current Quaternion. */ - multiplyToRef(otherVector: Vector3, result: Vector3): Vector3; + toRotationMatrix(result: Matrix): Quaternion; /** - * Returns a new Vector3 set witth the result of the mulliplication of the current Vector3 coordinates by the passed floats. + * Updates the current Quaternion from the passed rotation matrix values. + * Returns the updated Quaternion. */ - multiplyByFloats(x: number, y: number, z: number): Vector3; + fromRotationMatrix(matrix: Matrix): Quaternion; /** - * Returns a new Vector3 set witth the result of the division of the current Vector3 coordinates by the passed ones. + * Returns a new Quaternion set from the passed rotation matrix values. */ - divide(otherVector: Vector3): Vector3; + static FromRotationMatrix(matrix: Matrix): Quaternion; /** - * Divides the current Vector3 coordinates by the passed ones and stores the result in the passed vector "result". - * Returns the current Vector3. + * Updates the passed quaternion "result" with the passed rotation matrix values. */ - divideToRef(otherVector: Vector3, result: Vector3): Vector3; + static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void; /** - * Updates the current Vector3 with the minimal coordinate values between its and the passed vector ones. - * Returns the updated Vector3. + * Returns a new Quaternion set to (0.0, 0.0, 0.0). */ - MinimizeInPlace(other: Vector3): Vector3; + static Zero(): Quaternion; /** - * Updates the current Vector3 with the maximal coordinate values between its and the passed vector ones. - * Returns the updated Vector3. + * Returns a new Quaternion as the inverted current Quaternion. */ - MaximizeInPlace(other: Vector3): Vector3; + static Inverse(q: Quaternion): Quaternion; /** - * Returns the length of the Vector3 (float). + * Returns the identity Quaternion. */ - length(): number; + static Identity(): Quaternion; + static IsIdentity(quaternion: Quaternion): boolean; /** - * Returns the squared length of the Vector3 (float). + * Returns a new Quaternion set from the passed axis (Vector3) and angle in radians (float). */ - lengthSquared(): number; + static RotationAxis(axis: Vector3, angle: number): Quaternion; /** - * Normalize the current Vector3. - * Returns the updated Vector3. + * Sets the passed quaternion "result" from the passed axis (Vector3) and angle in radians (float). */ - normalize(): Vector3; + static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion; /** - * Returns a new Vector3 copied from the current Vector3. + * Retuns a new Quaternion set from the starting index of the passed array. */ - clone(): Vector3; + static FromArray(array: ArrayLike, offset?: number): Quaternion; /** - * Copies the passed vector coordinates to the current Vector3 ones. - * Returns the updated Vector3. + * Returns a new Quaternion set from the passed Euler float angles (y, x, z). */ - copyFrom(source: Vector3): Vector3; + static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion; /** - * Copies the passed floats to the current Vector3 coordinates. - * Returns the updated Vector3. + * Sets the passed quaternion "result" from the passed float Euler angles (y, x, z). */ - copyFromFloats(x: number, y: number, z: number): Vector3; + static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void; /** - * Copies the passed floats to the current Vector3 coordinates. - * Returns the updated Vector3. + * Returns a new Quaternion from the passed float Euler angles expressed in z-x-z orientation */ - set(x: number, y: number, z: number): Vector3; + static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion; /** - * + * Sets the passed quaternion "result" from the passed float Euler angles expressed in z-x-z orientation */ - static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: any): number; + static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void; /** - * Returns a new Vector3 set from the index "offset" of the passed array. + * Returns a new Quaternion as the quaternion rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system. + * cf to Vector3.RotationFromAxis() documentation. + * Note : axis1, axis2 and axis3 are normalized during this operation. */ - static FromArray(array: ArrayLike, offset?: number): Vector3; + static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): Quaternion; /** - * Returns a new Vector3 set from the index "offset" of the passed Float32Array. - * This function is deprecated. Use FromArray instead. + * Sets the passed quaternion "ref" with the quaternion rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system. + * cf to Vector3.RotationFromAxis() documentation. + * Note : axis1, axis2 and axis3 are normalized during this operation. */ - static FromFloatArray(array: Float32Array, offset?: number): Vector3; + static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void; + static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion; + static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void; /** - * Sets the passed vector "result" with the element values from the index "offset" of the passed array. + * Returns a new Quaternion located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2". */ - static FromArrayToRef(array: ArrayLike, offset: number, result: Vector3): void; + static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion; + } + class Matrix { + private static _tempQuaternion; + private static _xAxis; + private static _yAxis; + private static _zAxis; + private static _updateFlagSeed; + private _isIdentity; + private _isIdentityDirty; + updateFlag: number; + m: Float32Array; + _markAsUpdated(): void; + constructor(); /** - * Sets the passed vector "result" with the element values from the index "offset" of the passed Float32Array. - * This function is deprecated. Use FromArrayToRef instead. + * Boolean : True is the matrix is the identity matrix */ - static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void; + isIdentity(considerAsTextureMatrix?: boolean): boolean; /** - * Sets the passed vector "result" with the passed floats. + * Returns the matrix determinant (float). */ - static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void; + determinant(): number; /** - * Returns a new Vector3 set to (0.0, 0.0, 0.0). + * Returns the matrix underlying array. */ - static Zero(): Vector3; + toArray(): Float32Array; /** - * Returns a new Vector3 set to (1.0, 1.0, 1.0). + * Returns the matrix underlying array. + */ + asArray(): Float32Array; + /** + * Inverts in place the Matrix. + * Returns the Matrix inverted. */ - static One(): Vector3; + invert(): Matrix; /** - * Returns a new Vector3 set to (0.0, 1.0, 0.0) + * Sets all the matrix elements to zero. + * Returns the Matrix. */ - static Up(): Vector3; + reset(): Matrix; /** - * Returns a new Vector3 set to (0.0, 0.0, 1.0) + * Returns a new Matrix as the addition result of the current Matrix and the passed one. */ - static Forward(): Vector3; + add(other: Matrix): Matrix; /** - * Returns a new Vector3 set to (1.0, 0.0, 0.0) + * Sets the passed matrix "result" with the ddition result of the current Matrix and the passed one. + * Returns the Matrix. */ - static Right(): Vector3; + addToRef(other: Matrix, result: Matrix): Matrix; /** - * Returns a new Vector3 set to (-1.0, 0.0, 0.0) + * Adds in place the passed matrix to the current Matrix. + * Returns the updated Matrix. */ - static Left(): Vector3; + addToSelf(other: Matrix): Matrix; /** - * Returns a new Vector3 set with the result of the transformation by the passed matrix of the passed vector. - * This method computes tranformed coordinates only, not transformed direction vectors. + * Sets the passed matrix with the current inverted Matrix. + * Returns the unmodified current Matrix. */ - static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3; + invertToRef(other: Matrix): Matrix; /** - * Sets the passed vector "result" coordinates with the result of the transformation by the passed matrix of the passed vector. - * This method computes tranformed coordinates only, not transformed direction vectors. + * Inserts the translation vector (using 3 x floats) in the current Matrix. + * Returns the updated Matrix. */ - static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void; + setTranslationFromFloats(x: number, y: number, z: number): Matrix; /** - * Sets the passed vector "result" coordinates with the result of the transformation by the passed matrix of the passed floats (x, y, z). - * This method computes tranformed coordinates only, not transformed direction vectors. + * Inserts the translation vector in the current Matrix. + * Returns the updated Matrix. + */ + setTranslation(vector3: Vector3): Matrix; + /** + * Returns a new Vector3 as the extracted translation from the Matrix. */ - static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void; + getTranslation(): Vector3; /** - * Returns a new Vector3 set with the result of the normal transformation by the passed matrix of the passed vector. - * This methods computes transformed normalized direction vectors only. + * Fill a Vector3 with the extracted translation from the Matrix. */ - static TransformNormal(vector: Vector3, transformation: Matrix): Vector3; + getTranslationToRef(result: Vector3): Matrix; /** - * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed vector. - * This methods computes transformed normalized direction vectors only. + * Remove rotation and scaling part from the Matrix. + * Returns the updated Matrix. */ - static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void; + removeRotationAndScaling(): Matrix; /** - * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed floats (x, y, z). - * This methods computes transformed normalized direction vectors only. + * Returns a new Matrix set with the multiplication result of the current Matrix and the passed one. */ - static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void; + multiply(other: Matrix): Matrix; /** - * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4". + * Updates the current Matrix from the passed one values. + * Returns the updated Matrix. */ - static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3; + copyFrom(other: Matrix): Matrix; /** - * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max". - * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one. - * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one. + * Populates the passed array from the starting index with the Matrix values. + * Returns the Matrix. */ - static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3; + copyToArray(array: Float32Array, offset?: number): Matrix; /** - * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2". + * Sets the passed matrix "result" with the multiplication result of the current Matrix and the passed one. */ - static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3; + multiplyToRef(other: Matrix, result: Matrix): Matrix; /** - * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end". + * Sets the Float32Array "result" from the passed index "offset" with the multiplication result of the current Matrix and the passed one. */ - static Lerp(start: Vector3, end: Vector3, amount: number): Vector3; + multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix; /** - * Sets the passed vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end". + * Boolean : True is the current Matrix and the passed one values are strictly equal. */ - static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void; + equals(value: Matrix): boolean; /** - * Returns the dot product (float) between the vectors "left" and "right". + * Returns a new Matrix from the current Matrix. */ - static Dot(left: Vector3, right: Vector3): number; + clone(): Matrix; /** - * Returns a new Vector3 as the cross product of the vectors "left" and "right". - * The cross product is then orthogonal to both "left" and "right". + * Returns the string "Matrix" */ - static Cross(left: Vector3, right: Vector3): Vector3; + getClassName(): string; /** - * Sets the passed vector "result" with the cross product of "left" and "right". - * The cross product is then orthogonal to both "left" and "right". + * Returns the Matrix hash code. */ - static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void; + getHashCode(): number; /** - * Returns a new Vector3 as the normalization of the passed vector. + * Decomposes the current Matrix into : + * - a scale vector3 passed as a reference to update, + * - a rotation quaternion passed as a reference to update, + * - a translation vector3 passed as a reference to update. + * Returns the boolean `true`. */ - static Normalize(vector: Vector3): Vector3; + decompose(scale: Vector3, rotation: Quaternion, translation: Vector3): boolean; /** - * Sets the passed vector "result" with the normalization of the passed first vector. + * Returns a new Matrix as the extracted rotation matrix from the current one. */ - static NormalizeToRef(vector: Vector3, result: Vector3): void; - private static _viewportMatrixCache; - static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3; - static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3; - static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3; - static Minimize(left: Vector3, right: Vector3): Vector3; - static Maximize(left: Vector3, right: Vector3): Vector3; + getRotationMatrix(): Matrix; /** - * Returns the distance (float) between the vectors "value1" and "value2". + * Extracts the rotation matrix from the current one and sets it as the passed "result". + * Returns the current Matrix. */ - static Distance(value1: Vector3, value2: Vector3): number; + getRotationMatrixToRef(result: Matrix): Matrix; /** - * Returns the squared distance (float) between the vectors "value1" and "value2". + * Returns a new Matrix set from the starting index of the passed array. */ - static DistanceSquared(value1: Vector3, value2: Vector3): number; + static FromArray(array: ArrayLike, offset?: number): Matrix; /** - * Returns a new Vector3 located at the center between "value1" and "value2". + * Sets the passed "result" matrix from the starting index of the passed array. */ - static Center(value1: Vector3, value2: Vector3): Vector3; + static FromArrayToRef(array: ArrayLike, offset: number, result: Matrix): void; /** - * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system), - * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply - * to something in order to rotate it from its local system to the given target system. - * Note : axis1, axis2 and axis3 are normalized during this operation. - * Returns a new Vector3. + * Sets the passed "result" matrix from the starting index of the passed Float32Array by multiplying each element by the float "scale". */ - static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3; + static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void; /** - * The same than RotationFromAxis but updates the passed ref Vector3 parameter instead of returning a new Vector3. + * Sets the passed matrix "result" with the 16 passed floats. */ - static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void; - } - class Vector4 { - x: number; - y: number; - z: number; - w: number; + static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void; /** - * Creates a Vector4 object from the passed floats. + * Returns the index-th row of the current matrix as a new Vector4. */ - constructor(x: number, y: number, z: number, w: number); + getRow(index: number): Vector4; /** - * Returns the string with the Vector4 coordinates. + * Sets the index-th row of the current matrix with the passed Vector4 values. + * Returns the updated Matrix. */ - toString(): string; + setRow(index: number, row: Vector4): Matrix; /** - * Returns the string "Vector4". + * Sets the index-th row of the current matrix with the passed 4 x float values. + * Returns the updated Matrix. */ - getClassName(): string; + setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix; /** - * Returns the Vector4 hash code. + * Returns a new Matrix set from the 16 passed floats. */ - getHashCode(): number; + static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix; /** - * Returns a new array populated with 4 elements : the Vector4 coordinates. + * Returns a new Matrix composed by the passed scale (vector3), rotation (quaternion) and translation (vector3). */ - asArray(): number[]; + static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix; /** - * Populates the passed array from the passed index with the Vector4 coordinates. - * Returns the Vector4. + * Update a Matrix with values composed by the passed scale (vector3), rotation (quaternion) and translation (vector3). + */ + static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void; + /** + * Returns a new indentity Matrix. */ - toArray(array: number[] | Float32Array, index?: number): Vector4; + static Identity(): Matrix; /** - * Adds the passed vector to the current Vector4. - * Returns the updated Vector4. + * Sets the passed "result" as an identity matrix. */ - addInPlace(otherVector: Vector4): Vector4; + static IdentityToRef(result: Matrix): void; /** - * Returns a new Vector4 as the result of the addition of the current Vector4 and the passed one. + * Returns a new zero Matrix. */ - add(otherVector: Vector4): Vector4; + static Zero(): Matrix; /** - * Updates the passed vector "result" with the result of the addition of the current Vector4 and the passed one. - * Returns the current Vector4. + * Returns a new rotation matrix for "angle" radians around the X axis. */ - addToRef(otherVector: Vector4, result: Vector4): Vector4; + static RotationX(angle: number): Matrix; /** - * Subtract in place the passed vector from the current Vector4. - * Returns the updated Vector4. + * Returns a new Matrix as the passed inverted one. */ - subtractInPlace(otherVector: Vector4): Vector4; + static Invert(source: Matrix): Matrix; /** - * Returns a new Vector4 with the result of the subtraction of the passed vector from the current Vector4. + * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the X axis. */ - subtract(otherVector: Vector4): Vector4; + static RotationXToRef(angle: number, result: Matrix): void; /** - * Sets the passed vector "result" with the result of the subtraction of the passed vector from the current Vector4. - * Returns the current Vector4. + * Returns a new rotation matrix for "angle" radians around the Y axis. */ - subtractToRef(otherVector: Vector4, result: Vector4): Vector4; + static RotationY(angle: number): Matrix; /** - * Returns a new Vector4 set with the result of the subtraction of the passed floats from the current Vector4 coordinates. + * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the Y axis. */ - subtractFromFloats(x: number, y: number, z: number, w: number): Vector4; + static RotationYToRef(angle: number, result: Matrix): void; /** - * Sets the passed vector "result" set with the result of the subtraction of the passed floats from the current Vector4 coordinates. - * Returns the current Vector4. + * Returns a new rotation matrix for "angle" radians around the Z axis. */ - subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4; + static RotationZ(angle: number): Matrix; /** - * Returns a new Vector4 set with the current Vector4 negated coordinates. + * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the Z axis. */ - negate(): Vector4; + static RotationZToRef(angle: number, result: Matrix): void; /** - * Multiplies the current Vector4 coordinates by scale (float). - * Returns the updated Vector4. + * Returns a new rotation matrix for "angle" radians around the passed axis. */ - scaleInPlace(scale: number): Vector4; + static RotationAxis(axis: Vector3, angle: number): Matrix; /** - * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float). + * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the passed axis. */ - scale(scale: number): Vector4; + static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void; /** - * Sets the passed vector "result" with the current Vector4 coordinates multiplied by scale (float). - * Returns the current Vector4. + * Returns a new Matrix as a rotation matrix from the Euler angles (y, x, z). */ - scaleToRef(scale: number, result: Vector4): Vector4; + static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix; /** - * Boolean : True if the current Vector4 coordinates are stricly equal to the passed ones. + * Sets the passed matrix "result" as a rotation matrix from the Euler angles (y, x, z). */ - equals(otherVector: Vector4): boolean; + static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void; /** - * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the passed vector ones. + * Returns a new Matrix as a scaling matrix from the passed floats (x, y, z). */ - equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean; + static Scaling(x: number, y: number, z: number): Matrix; /** - * Boolean : True if the passed floats are strictly equal to the current Vector4 coordinates. + * Sets the passed matrix "result" as a scaling matrix from the passed floats (x, y, z). */ - equalsToFloats(x: number, y: number, z: number, w: number): boolean; + static ScalingToRef(x: number, y: number, z: number, result: Matrix): void; /** - * Multiplies in place the current Vector4 by the passed one. - * Returns the updated Vector4. + * Returns a new Matrix as a translation matrix from the passed floats (x, y, z). */ - multiplyInPlace(otherVector: Vector4): Vector4; + static Translation(x: number, y: number, z: number): Matrix; /** - * Returns a new Vector4 set with the multiplication result of the current Vector4 and the passed one. + * Sets the passed matrix "result" as a translation matrix from the passed floats (x, y, z). */ - multiply(otherVector: Vector4): Vector4; + static TranslationToRef(x: number, y: number, z: number, result: Matrix): void; /** - * Updates the passed vector "result" with the multiplication result of the current Vector4 and the passed one. - * Returns the current Vector4. + * Returns a new Matrix whose values are the interpolated values for "gradien" (float) between the ones of the matrices "startValue" and "endValue". */ - multiplyToRef(otherVector: Vector4, result: Vector4): Vector4; + static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix; /** - * Returns a new Vector4 set with the multiplication result of the passed floats and the current Vector4 coordinates. + * Returns a new Matrix whose values are computed by : + * - decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices, + * - interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end, + * - recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices. */ - multiplyByFloats(x: number, y: number, z: number, w: number): Vector4; + static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix; /** - * Returns a new Vector4 set with the division result of the current Vector4 by the passed one. + * Returns a new rotation Matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up". + * This methods works for a Left-Handed system. */ - divide(otherVector: Vector4): Vector4; + static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix; /** - * Updates the passed vector "result" with the division result of the current Vector4 by the passed one. - * Returns the current Vector4. + * Sets the passed "result" Matrix as a rotation matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up". + * This methods works for a Left-Handed system. */ - divideToRef(otherVector: Vector4, result: Vector4): Vector4; + static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void; /** - * Updates the Vector4 coordinates with the minimum values between its own and the passed vector ones. + * Returns a new rotation Matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up". + * This methods works for a Right-Handed system. */ - MinimizeInPlace(other: Vector4): Vector4; + static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix; /** - * Updates the Vector4 coordinates with the maximum values between its own and the passed vector ones. + * Sets the passed "result" Matrix as a rotation matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up". + * This methods works for a Left-Handed system. */ - MaximizeInPlace(other: Vector4): Vector4; + static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void; /** - * Returns the Vector4 length (float). + * Returns a new Matrix as a left-handed orthographic projection matrix computed from the passed floats : width and height of the projection plane, z near and far limits. */ - length(): number; + static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix; /** - * Returns the Vector4 squared length (float). + * Sets the passed matrix "result" as a left-handed orthographic projection matrix computed from the passed floats : width and height of the projection plane, z near and far limits. */ - lengthSquared(): number; + static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void; /** - * Normalizes in place the Vector4. - * Returns the updated Vector4. + * Returns a new Matrix as a left-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits. */ - normalize(): Vector4; + static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix; /** - * Returns a new Vector3 from the Vector4 (x, y, z) coordinates. + * Sets the passed matrix "result" as a left-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits. */ - toVector3(): Vector3; + static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void; /** - * Returns a new Vector4 copied from the current one. + * Returns a new Matrix as a right-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits. */ - clone(): Vector4; + static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix; /** - * Updates the current Vector4 with the passed one coordinates. - * Returns the updated Vector4. + * Sets the passed matrix "result" as a right-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits. */ - copyFrom(source: Vector4): Vector4; + static OrthoOffCenterRHToRef(left: number, right: any, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void; /** - * Updates the current Vector4 coordinates with the passed floats. - * Returns the updated Vector4. + * Returns a new Matrix as a left-handed perspective projection matrix computed from the passed floats : width and height of the projection plane, z near and far limits. */ - copyFromFloats(x: number, y: number, z: number, w: number): Vector4; + static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix; /** - * Updates the current Vector4 coordinates with the passed floats. - * Returns the updated Vector4. + * Returns a new Matrix as a left-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits. */ - set(x: number, y: number, z: number, w: number): Vector4; + static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix; /** - * Returns a new Vector4 set from the starting index of the passed array. + * Sets the passed matrix "result" as a left-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits. */ - static FromArray(array: ArrayLike, offset?: number): Vector4; + static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void; /** - * Updates the passed vector "result" from the starting index of the passed array. + * Returns a new Matrix as a right-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits. */ - static FromArrayToRef(array: ArrayLike, offset: number, result: Vector4): void; + static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix; /** - * Updates the passed vector "result" from the starting index of the passed Float32Array. + * Sets the passed matrix "result" as a right-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits. */ - static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void; + static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void; /** - * Updates the passed vector "result" coordinates from the passed floats. + * Sets the passed matrix "result" as a left-handed perspective projection matrix for WebVR computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits. */ - static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void; + static PerspectiveFovWebVRToRef(fov: any, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void; /** - * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0) + * Returns the final transformation matrix : world * view * projection * viewport */ - static Zero(): Vector4; + static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix; /** - * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0) + * Returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the passed Matrix. */ - static One(): Vector4; + static GetAsMatrix2x2(matrix: Matrix): Float32Array; /** - * Returns a new normalized Vector4 from the passed one. + * Returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the passed Matrix. */ - static Normalize(vector: Vector4): Vector4; + static GetAsMatrix3x3(matrix: Matrix): Float32Array; /** - * Updates the passed vector "result" from the normalization of the passed one. + * Compute the transpose of the passed Matrix. + * Returns a new Matrix. */ - static NormalizeToRef(vector: Vector4, result: Vector4): void; - static Minimize(left: Vector4, right: Vector4): Vector4; - static Maximize(left: Vector4, right: Vector4): Vector4; + static Transpose(matrix: Matrix): Matrix; /** - * Returns the distance (float) between the vectors "value1" and "value2". + * Returns a new Matrix as the reflection matrix across the passed plane. */ - static Distance(value1: Vector4, value2: Vector4): number; + static Reflection(plane: Plane): Matrix; /** - * Returns the squared distance (float) between the vectors "value1" and "value2". + * Sets the passed matrix "result" as the reflection matrix across the passed plane. */ - static DistanceSquared(value1: Vector4, value2: Vector4): number; + static ReflectionToRef(plane: Plane, result: Matrix): void; /** - * Returns a new Vector4 located at the center between the vectors "value1" and "value2". + * Sets the passed matrix "mat" as a rotation matrix composed from the 3 passed left handed axis. */ - static Center(value1: Vector4, value2: Vector4): Vector4; + static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void; /** - * Returns a new Vector4 set with the result of the normal transformation by the passed matrix of the passed vector. - * This methods computes transformed normalized direction vectors only. + * Sets the passed matrix "result" as a rotation matrix according to the passed quaternion. */ - static TransformNormal(vector: Vector4, transformation: Matrix): Vector4; + static FromQuaternionToRef(quat: Quaternion, result: Matrix): void; + } + class Plane { + normal: Vector3; + d: number; /** - * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed vector. - * This methods computes transformed normalized direction vectors only. + * Creates a Plane object according to the passed floats a, b, c, d and the plane equation : ax + by + cz + d = 0 */ - static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void; + constructor(a: number, b: number, c: number, d: number); /** - * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed floats (x, y, z, w). - * This methods computes transformed normalized direction vectors only. + * Returns the plane coordinates as a new array of 4 elements [a, b, c, d]. */ - static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void; - } - interface ISize { - width: number; - height: number; - } - class Size implements ISize { - width: number; - height: number; + asArray(): number[]; /** - * Creates a Size object from the passed width and height (floats). + * Returns a new plane copied from the current Plane. */ - constructor(width: number, height: number); - toString(): string; + clone(): Plane; /** - * Returns the string "Size" + * Returns the string "Plane". */ getClassName(): string; /** - * Returns the Size hash code. + * Returns the Plane hash code. */ getHashCode(): number; /** - * Updates the current size from the passed one. - * Returns the updated Size. - */ - copyFrom(src: Size): void; - /** - * Updates in place the current Size from the passed floats. - * Returns the updated Size. + * Normalize the current Plane in place. + * Returns the updated Plane. */ - copyFromFloats(width: number, height: number): Size; + normalize(): Plane; /** - * Updates in place the current Size from the passed floats. - * Returns the updated Size. + * Returns a new Plane as the result of the transformation of the current Plane by the passed matrix. */ - set(width: number, height: number): Size; + transform(transformation: Matrix): Plane; /** - * Returns a new Size set with the multiplication result of the current Size and the passed floats. + * Returns the dot product (float) of the point coordinates and the plane normal. */ - multiplyByFloats(w: number, h: number): Size; + dotCoordinate(point: any): number; /** - * Returns a new Size copied from the passed one. + * Updates the current Plane from the plane defined by the three passed points. + * Returns the updated Plane. */ - clone(): Size; + copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane; /** - * Boolean : True if the current Size and the passed one width and height are strictly equal. + * Boolean : True is the vector "direction" is the same side than the plane normal. */ - equals(other: Size): boolean; + isFrontFacingTo(direction: Vector3, epsilon: number): boolean; /** - * Returns the surface of the Size : width * height (float). + * Returns the signed distance (float) from the passed point to the Plane. */ - readonly surface: number; + signedDistanceTo(point: Vector3): number; /** - * Returns a new Size set to (0.0, 0.0) + * Returns a new Plane from the passed array. */ - static Zero(): Size; + static FromArray(array: ArrayLike): Plane; /** - * Returns a new Size set as the addition result of the current Size and the passed one. + * Returns a new Plane defined by the three passed points. */ - add(otherSize: Size): Size; + static FromPoints(point1: any, point2: any, point3: any): Plane; /** - * Returns a new Size set as the subtraction result of the passed one from the current Size. + * Returns a new Plane the normal vector to this plane at the passed origin point. + * Note : the vector "normal" is updated because normalized. */ - subtract(otherSize: Size): Size; + static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane; /** - * Returns a new Size set at the linear interpolation "amount" between "start" and "end". + * Returns the signed distance between the plane defined by the normal vector at the "origin"" point and the passed other point. */ - static Lerp(start: Size, end: Size, amount: number): Size; + static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number; } - class Quaternion { + class Viewport { x: number; y: number; - z: number; - w: number; - /** - * Creates a new Quaternion from the passed floats. - */ - constructor(x?: number, y?: number, z?: number, w?: number); + width: number; + height: number; /** - * Returns a string with the Quaternion coordinates. + * Creates a Viewport object located at (x, y) and sized (width, height). */ - toString(): string; + constructor(x: number, y: number, width: number, height: number); + toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport; /** - * Returns the string "Quaternion". + * Returns a new Viewport copied from the current one. */ - getClassName(): string; + clone(): Viewport; + } + class Frustum { /** - * Returns the Quaternion hash code. + * Returns a new array of 6 Frustum planes computed by the passed transformation matrix. */ - getHashCode(): number; + static GetPlanes(transform: Matrix): Plane[]; /** - * Returns a new array populated with 4 elements : the Quaternion coordinates. + * Sets the passed array "frustumPlanes" with the 6 Frustum planes computed by the passed transformation matrix. */ - asArray(): number[]; + static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void; + } + enum Space { + LOCAL = 0, + WORLD = 1, + BONE = 2, + } + class Axis { + static X: Vector3; + static Y: Vector3; + static Z: Vector3; + } + class BezierCurve { /** - * Boolean : True if the current Quaterion and the passed one coordinates are strictly equal. + * Returns the cubic Bezier interpolated value (float) at "t" (float) from the passed x1, y1, x2, y2 floats. */ - equals(otherQuaternion: Quaternion): boolean; + static interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number; + } + enum Orientation { + CW = 0, + CCW = 1, + } + class Angle { + private _radians; /** - * Returns a new Quaternion copied from the current one. + * Creates an Angle object of "radians" radians (float). */ - clone(): Quaternion; + constructor(radians: number); /** - * Updates the current Quaternion from the passed one coordinates. - * Returns the updated Quaterion. + * Returns the Angle value in degrees (float). */ - copyFrom(other: Quaternion): Quaternion; + degrees: () => number; /** - * Updates the current Quaternion from the passed float coordinates. - * Returns the updated Quaterion. + * Returns the Angle value in radians (float). */ - copyFromFloats(x: number, y: number, z: number, w: number): Quaternion; + radians: () => number; /** - * Updates the current Quaternion from the passed float coordinates. - * Returns the updated Quaterion. + * Returns a new Angle object valued with the angle value in radians between the two passed vectors. */ - set(x: number, y: number, z: number, w: number): Quaternion; + static BetweenTwoPoints(a: Vector2, b: Vector2): Angle; /** - * Returns a new Quaternion as the addition result of the passed one and the current Quaternion. + * Returns a new Angle object from the passed float in radians. */ - add(other: Quaternion): Quaternion; + static FromRadians(radians: number): Angle; /** - * Returns a new Quaternion as the subtraction result of the passed one from the current Quaternion. + * Returns a new Angle object from the passed float in degrees. */ - subtract(other: Quaternion): Quaternion; + static FromDegrees(degrees: number): Angle; + } + class Arc2 { + startPoint: Vector2; + midPoint: Vector2; + endPoint: Vector2; + centerPoint: Vector2; + radius: number; + angle: Angle; + startAngle: Angle; + orientation: Orientation; /** - * Returns a new Quaternion set by multiplying the current Quaterion coordinates by the float "scale". + * Creates an Arc object from the three passed points : start, middle and end. */ - scale(value: number): Quaternion; + constructor(startPoint: Vector2, midPoint: Vector2, endPoint: Vector2); + } + class Path2 { + private _points; + private _length; + closed: boolean; /** - * Returns a new Quaternion set as the quaternion mulplication result of the current one with the passed one "q1". + * Creates a Path2 object from the starting 2D coordinates x and y. */ - multiply(q1: Quaternion): Quaternion; + constructor(x: number, y: number); /** - * Sets the passed "result" as the quaternion mulplication result of the current one with the passed one "q1". - * Returns the current Quaternion. + * Adds a new segment until the passed coordinates (x, y) to the current Path2. + * Returns the updated Path2. */ - multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion; + addLineTo(x: number, y: number): Path2; /** - * Updates the current Quaternion with the quaternion mulplication result of itself with the passed one "q1". - * Returns the updated Quaternion. + * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2. + * Returns the updated Path2. */ - multiplyInPlace(q1: Quaternion): Quaternion; + addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2; /** - * Sets the passed "ref" with the conjugation of the current Quaternion. - * Returns the current Quaternion. + * Closes the Path2. + * Returns the Path2. */ - conjugateToRef(ref: Quaternion): Quaternion; + close(): Path2; /** - * Conjugates in place the current Quaternion. - * Returns the updated Quaternion. + * Returns the Path2 total length (float). */ - conjugateInPlace(): Quaternion; + length(): number; /** - * Returns a new Quaternion as the conjugate of the current Quaternion. + * Returns the Path2 internal array of points. */ - conjugate(): Quaternion; + getPoints(): Vector2[]; /** - * Returns the Quaternion length (float). + * Returns a new Vector2 located at a percentage of the Path2 total length on this path. */ - length(): number; + getPointAtLengthPosition(normalizedLengthPosition: number): Vector2; /** - * Normalize in place the current Quaternion. - * Returns the updated Quaternion. + * Returns a new Path2 starting at the coordinates (x, y). */ - normalize(): Quaternion; + static StartingAt(x: number, y: number): Path2; + } + class Path3D { + path: Vector3[]; + private _curve; + private _distances; + private _tangents; + private _normals; + private _binormals; + private _raw; /** - * Returns a new Vector3 set with the Euler angles translated from the current Quaternion. + * new Path3D(path, normal, raw) + * Creates a Path3D. A Path3D is a logical math object, so not a mesh. + * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D + * path : an array of Vector3, the curve axis of the Path3D + * normal (optional) : Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal. + * raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed. + */ + constructor(path: Vector3[], firstNormal?: Vector3, raw?: boolean); + /** + * Returns the Path3D array of successive Vector3 designing its curve. */ - toEulerAngles(order?: string): Vector3; + getCurve(): Vector3[]; /** - * Sets the passed vector3 "result" with the Euler angles translated from the current Quaternion. - * Returns the current Quaternion. + * Returns an array populated with tangent vectors on each Path3D curve point. */ - toEulerAnglesToRef(result: Vector3, order?: string): Quaternion; + getTangents(): Vector3[]; /** - * Updates the passed rotation matrix with the current Quaternion values. - * Returns the current Quaternion. + * Returns an array populated with normal vectors on each Path3D curve point. */ - toRotationMatrix(result: Matrix): Quaternion; + getNormals(): Vector3[]; /** - * Updates the current Quaternion from the passed rotation matrix values. - * Returns the updated Quaternion. + * Returns an array populated with binormal vectors on each Path3D curve point. */ - fromRotationMatrix(matrix: Matrix): Quaternion; + getBinormals(): Vector3[]; /** - * Returns a new Quaternion set from the passed rotation matrix values. + * Returns an array populated with distances (float) of the i-th point from the first curve point. */ - static FromRotationMatrix(matrix: Matrix): Quaternion; + getDistances(): number[]; /** - * Updates the passed quaternion "result" with the passed rotation matrix values. + * Forces the Path3D tangent, normal, binormal and distance recomputation. + * Returns the same object updated. */ - static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void; + update(path: Vector3[], firstNormal?: Vector3): Path3D; + private _compute(firstNormal); + private _getFirstNonNullVector(index); + private _getLastNonNullVector(index); + private _normalVector(v0, vt, va); + } + class Curve3 { + private _points; + private _length; /** - * Returns a new Quaternion set to (0.0, 0.0, 0.0). + * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve + * @param v0 (Vector3) the origin point of the Quadratic Bezier + * @param v1 (Vector3) the control point + * @param v2 (Vector3) the end point of the Quadratic Bezier + * @param nbPoints (integer) the wanted number of points in the curve */ - static Zero(): Quaternion; + static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3; /** - * Returns a new Quaternion as the inverted current Quaternion. + * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve + * @param v0 (Vector3) the origin point of the Cubic Bezier + * @param v1 (Vector3) the first control point + * @param v2 (Vector3) the second control point + * @param v3 (Vector3) the end point of the Cubic Bezier + * @param nbPoints (integer) the wanted number of points in the curve */ - static Inverse(q: Quaternion): Quaternion; + static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3; /** - * Returns the identity Quaternion. + * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline + * @param p1 (Vector3) the origin point of the Hermite Spline + * @param t1 (Vector3) the tangent vector at the origin point + * @param p2 (Vector3) the end point of the Hermite Spline + * @param t2 (Vector3) the tangent vector at the end point + * @param nbPoints (integer) the wanted number of points in the curve */ - static Identity(): Quaternion; - static IsIdentity(quaternion: Quaternion): boolean; + static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3; /** - * Returns a new Quaternion set from the passed axis (Vector3) and angle in radians (float). + * Returns a Curve3 object along a CatmullRom Spline curve : + * @param points (array of Vector3) the points the spline must pass through. At least, four points required. + * @param nbPoints (integer) the wanted number of points between each curve control points. */ - static RotationAxis(axis: Vector3, angle: number): Quaternion; + static CreateCatmullRomSpline(points: Vector3[], nbPoints: number): Curve3; /** - * Sets the passed quaternion "result" from the passed axis (Vector3) and angle in radians (float). + * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space. + * A Curve3 is designed from a series of successive Vector3. + * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object */ - static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion; + constructor(points: Vector3[]); /** - * Retuns a new Quaternion set from the starting index of the passed array. + * Returns the Curve3 stored array of successive Vector3 */ - static FromArray(array: ArrayLike, offset?: number): Quaternion; + getPoints(): Vector3[]; /** - * Returns a new Quaternion set from the passed Euler float angles (y, x, z). + * Returns the computed length (float) of the curve. */ - static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion; + length(): number; /** - * Sets the passed quaternion "result" from the passed float Euler angles (y, x, z). + * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB); + * This new Curve3 is built by translating and sticking the curveB at the end of the curveA. + * curveA and curveB keep unchanged. */ - static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void; + continue(curve: Curve3): Curve3; + private _computeLength(path); + } + class PositionNormalVertex { + position: Vector3; + normal: Vector3; + constructor(position?: Vector3, normal?: Vector3); + clone(): PositionNormalVertex; + } + class PositionNormalTextureVertex { + position: Vector3; + normal: Vector3; + uv: Vector2; + constructor(position?: Vector3, normal?: Vector3, uv?: Vector2); + clone(): PositionNormalTextureVertex; + } + class Tmp { + static Color3: Color3[]; + static Vector2: Vector2[]; + static Vector3: Vector3[]; + static Vector4: Vector4[]; + static Quaternion: Quaternion[]; + static Matrix: Matrix[]; + } +} + +declare module BABYLON { + class SphericalPolynomial { + x: Vector3; + y: Vector3; + z: Vector3; + xx: Vector3; + yy: Vector3; + zz: Vector3; + xy: Vector3; + yz: Vector3; + zx: Vector3; + addAmbient(color: Color3): void; + static getSphericalPolynomialFromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial; + scale(scale: number): void; + } + class SphericalHarmonics { + L00: Vector3; + L1_1: Vector3; + L10: Vector3; + L11: Vector3; + L2_2: Vector3; + L2_1: Vector3; + L20: Vector3; + L21: Vector3; + L22: Vector3; + addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void; + scale(scale: number): void; + convertIncidentRadianceToIrradiance(): void; + convertIrradianceToLambertianRadiance(): void; + static getsphericalHarmonicsFromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics; + } +} + +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; /** - * Returns a new Quaternion from the passed float Euler angles expressed in z-x-z orientation + * 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). */ - static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion; /** - * Sets the passed quaternion "result" from the passed float Euler angles expressed in z-x-z orientation + * 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). */ - static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void; + globalHue: number; /** - * Returns a new Quaternion as the quaternion rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system. - * cf to Vector3.RotationFromAxis() documentation. - * Note : axis1, axis2 and axis3 are normalized during this operation. + * 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. */ - static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): Quaternion; /** - * Sets the passed quaternion "ref" with the quaternion rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system. - * cf to Vector3.RotationFromAxis() documentation. - * Note : axis1, axis2 and axis3 are normalized during this operation. + * 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. */ - static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void; - static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion; - static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void; + globalDensity: number; /** - * Returns a new Quaternion located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2". + * 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. */ - static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion; - } - class Matrix { - private static _tempQuaternion; - private static _xAxis; - private static _yAxis; - private static _zAxis; - private static _updateFlagSeed; - private _isIdentity; - private _isIdentityDirty; - updateFlag: number; - m: Float32Array; - _markAsUpdated(): void; - constructor(); /** - * Boolean : True is the matrix is the identity matrix + * 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; + 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). */ - isIdentity(considerAsTextureMatrix?: boolean): boolean; /** - * Returns the matrix determinant (float). + * 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). */ - determinant(): number; + highlightsHue: number; /** - * Returns the matrix underlying array. + * 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. */ - toArray(): Float32Array; /** - * Returns the matrix underlying array. - */ - asArray(): Float32Array; + * 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; /** - * Inverts in place the Matrix. - * Returns the Matrix inverted. + * 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. */ - invert(): Matrix; /** - * Sets all the matrix elements to zero. - * Returns the Matrix. + * 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. */ - reset(): Matrix; + highlightsSaturation: number; /** - * Returns a new Matrix as the addition result of the current Matrix and the passed one. + * 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. */ - add(other: Matrix): Matrix; /** - * Sets the passed matrix "result" with the ddition result of the current Matrix and the passed one. - * Returns the Matrix. + * 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. */ - addToRef(other: Matrix, result: Matrix): Matrix; + highlightsExposure: number; + private _midtonesHue; + private _midtonesDensity; + private _midtonesSaturation; + private _midtonesExposure; /** - * Adds in place the passed matrix to the current Matrix. - * Returns the updated Matrix. + * 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). */ - addToSelf(other: Matrix): Matrix; /** - * Sets the passed matrix with the current inverted Matrix. - * Returns the unmodified current Matrix. + * 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). */ - invertToRef(other: Matrix): Matrix; + midtonesHue: number; /** - * Inserts the translation vector (using 3 x floats) in the current Matrix. - * Returns the updated Matrix. + * 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. */ - setTranslationFromFloats(x: number, y: number, z: number): Matrix; /** - * Inserts the translation vector in the current Matrix. - * Returns the updated Matrix. - */ - setTranslation(vector3: Vector3): Matrix; + * 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; /** - * Returns a new Vector3 as the extracted translation from the Matrix. + * 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. */ - getTranslation(): Vector3; /** - * Fill a Vector3 with the extracted translation from the Matrix. + * 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. */ - getTranslationToRef(result: Vector3): Matrix; + midtonesSaturation: number; /** - * Remove rotation and scaling part from the Matrix. - * Returns the updated Matrix. + * 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. */ - removeRotationAndScaling(): Matrix; /** - * Returns a new Matrix set with the multiplication result of the current Matrix and the passed one. + * 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. */ - multiply(other: Matrix): Matrix; + midtonesExposure: number; + private _shadowsHue; + private _shadowsDensity; + private _shadowsSaturation; + private _shadowsExposure; /** - * Updates the current Matrix from the passed one values. - * Returns the updated Matrix. + * 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). */ - copyFrom(other: Matrix): Matrix; /** - * Populates the passed array from the starting index with the Matrix values. - * Returns the Matrix. + * 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). */ - copyToArray(array: Float32Array, offset?: number): Matrix; + shadowsHue: number; /** - * Sets the passed matrix "result" with the multiplication result of the current Matrix and the passed one. + * 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. */ - multiplyToRef(other: Matrix, result: Matrix): Matrix; /** - * Sets the Float32Array "result" from the passed index "offset" with the multiplication result of the current Matrix and the passed one. + * 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. */ - multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix; + shadowsDensity: number; /** - * Boolean : True is the current Matrix and the passed one values are strictly equal. + * 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. */ - equals(value: Matrix): boolean; /** - * Returns a new Matrix from the current Matrix. + * 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. */ - clone(): Matrix; + shadowsSaturation: number; /** - * Returns the string "Matrix" + * 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; getClassName(): string; /** - * Returns the Matrix hash code. + * Binds the color curves to the shader. + * @param colorCurves The color curve to bind + * @param effect The effect to bind to */ - getHashCode(): number; + static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void; /** - * Decomposes the current Matrix into : - * - a scale vector3 passed as a reference to update, - * - a rotation quaternion passed as a reference to update, - * - a translation vector3 passed as a reference to update. - * Returns the boolean `true`. + * Prepare the list of uniforms associated with the ColorCurves effects. + * @param uniformsList The list of uniforms used in the effect */ - decompose(scale: Vector3, rotation: Quaternion, translation: Vector3): boolean; + static PrepareUniforms(uniformsList: string[]): void; /** - * Returns a new Matrix as the extracted rotation matrix from the current one. + * 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. */ - getRotationMatrix(): Matrix; + private getColorGradingDataToRef(hue, density, saturation, exposure, result); /** - * Extracts the rotation matrix from the current one and sets it as the passed "result". - * Returns the current Matrix. + * 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. */ - getRotationMatrixToRef(result: Matrix): Matrix; + private static applyColorGradingSliderNonlinear(value); /** - * Returns a new Matrix set from the starting index of the passed array. + * 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. */ - static FromArray(array: ArrayLike, offset?: number): Matrix; + private static fromHSBToRef(hue, saturation, brightness, result); /** - * Sets the passed "result" matrix from the starting index of the passed array. + * 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. */ - static FromArrayToRef(array: ArrayLike, offset: number, result: Matrix): void; + private static clamp(value, min, max); /** - * Sets the passed "result" matrix from the starting index of the passed Float32Array by multiplying each element by the float "scale". + * Clones the current color curve instance. + * @return The cloned curves */ - static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void; + clone(): ColorCurves; /** - * Sets the passed matrix "result" with the 16 passed floats. + * Serializes the current color curve instance to a json representation. + * @return a JSON representation */ - static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void; + 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 { + class EffectFallbacks { + private _defines; + private _currentRank; + private _maxRank; + private _mesh; + private _meshRank; + addFallback(rank: number, define: string): void; + addCPUSkinningFallback(rank: number, mesh: BABYLON.AbstractMesh): void; + readonly isMoreFallbacks: boolean; + reduce(currentDefines: string): string; + } + class EffectCreationOptions { + attributes: string[]; + uniformsNames: string[]; + uniformBuffersNames: string[]; + samplers: string[]; + defines: any; + fallbacks: EffectFallbacks; + onCompiled: (effect: Effect) => void; + onError: (effect: Effect, errors: string) => void; + indexParameters: any; + maxSimultaneousLights: number; + } + class Effect { + name: any; + defines: string; + onCompiled: (effect: Effect) => void; + onError: (effect: Effect, errors: string) => void; + onBind: (effect: Effect) => void; + uniqueId: number; + onCompileObservable: Observable; + onErrorObservable: Observable; + onBindObservable: Observable; + private static _uniqueIdSeed; + private _engine; + private _uniformBuffersNames; + private _uniformsNames; + private _samplers; + private _isReady; + private _compilationError; + private _attributesNames; + private _attributes; + private _uniforms; + _key: string; + private _indexParameters; + private _fallbacks; + private _program; + private _valueCache; + private static _baseCache; + constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], engine?: Engine, defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, indexParameters?: any); + readonly key: string; + isReady(): boolean; + getEngine(): Engine; + getProgram(): WebGLProgram; + getAttributesNames(): string[]; + getAttributeLocation(index: number): number; + getAttributeLocationByName(name: string): number; + getAttributesCount(): number; + getUniformIndex(uniformName: string): number; + getUniform(uniformName: string): WebGLUniformLocation; + getSamplers(): string[]; + getCompilationError(): string; + getVertexShaderSource(): string; + getFragmentShaderSource(): string; + executeWhenCompiled(func: (effect: Effect) => void): void; + _loadVertexShader(vertex: any, callback: (data: any) => void): void; + _loadFragmentShader(fragment: any, callback: (data: any) => void): void; + private _dumpShadersSource(vertexCode, fragmentCode, defines); + private _processShaderConversion(sourceCode, isFragment, callback); + private _processIncludes(sourceCode, callback); + private _processPrecision(source); + private _prepareEffect(vertexSourceCode, fragmentSourceCode, attributesNames, defines, fallbacks?); + readonly isSupported: boolean; + _bindTexture(channel: string, texture: WebGLTexture): void; + setTexture(channel: string, texture: BaseTexture): void; + setTextureArray(channel: string, textures: BaseTexture[]): void; + setTextureFromPostProcess(channel: string, postProcess: PostProcess): void; + _cacheMatrix(uniformName: string, matrix: Matrix): boolean; + _cacheFloat2(uniformName: string, x: number, y: number): boolean; + _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean; + _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean; + bindUniformBuffer(buffer: WebGLBuffer, name: string): void; + bindUniformBlock(blockName: string, index: number): void; + setIntArray(uniformName: string, array: Int32Array): Effect; + setIntArray2(uniformName: string, array: Int32Array): Effect; + setIntArray3(uniformName: string, array: Int32Array): Effect; + setIntArray4(uniformName: string, array: Int32Array): Effect; + setFloatArray(uniformName: string, array: Float32Array): Effect; + setFloatArray2(uniformName: string, array: Float32Array): Effect; + setFloatArray3(uniformName: string, array: Float32Array): Effect; + setFloatArray4(uniformName: string, array: Float32Array): Effect; + setArray(uniformName: string, array: number[]): Effect; + setArray2(uniformName: string, array: number[]): Effect; + setArray3(uniformName: string, array: number[]): Effect; + setArray4(uniformName: string, array: number[]): Effect; + setMatrices(uniformName: string, matrices: Float32Array): Effect; + setMatrix(uniformName: string, matrix: Matrix): Effect; + setMatrix3x3(uniformName: string, matrix: Float32Array): Effect; + setMatrix2x2(uniformName: string, matrix: Float32Array): Effect; + setFloat(uniformName: string, value: number): Effect; + setBool(uniformName: string, bool: boolean): Effect; + setVector2(uniformName: string, vector2: Vector2): Effect; + setFloat2(uniformName: string, x: number, y: number): Effect; + setVector3(uniformName: string, vector3: Vector3): Effect; + setFloat3(uniformName: string, x: number, y: number, z: number): Effect; + setVector4(uniformName: string, vector4: Vector4): Effect; + setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect; + setColor3(uniformName: string, color3: Color3): Effect; + setColor4(uniformName: string, color3: Color3, alpha: number): Effect; + private _recombineShader(node); + private _evaluateDefinesOnString(shaderString); + static ShadersStore: {}; + static IncludesShadersStore: {}; + static ResetCache(): void; + } +} + +declare module BABYLON { + class FresnelParameters { + private _isEnabled; + isEnabled: boolean; + leftColor: Color3; + rightColor: Color3; + bias: number; + power: number; + clone(): FresnelParameters; + serialize(): any; + static Parse(parsedFresnelParameters: any): FresnelParameters; + } +} + +declare module BABYLON { + /** + * Interface to follow in your material defines to integrate easily the + * Image proccessing functions. + */ + interface IImageProcessingConfigurationDefines { + IMAGEPROCESSING: boolean; + VIGNETTE: boolean; + VIGNETTEBLENDMODEMULTIPLY: boolean; + VIGNETTEBLENDMODEOPAQUE: boolean; + TONEMAPPING: boolean; + CONTRAST: boolean; + EXPOSURE: boolean; + COLORCURVES: boolean; + COLORGRADING: boolean; + SAMPLER3DGREENDEPTH: boolean; + SAMPLER3DBGRMAP: boolean; + IMAGEPROCESSINGPOSTPROCESS: boolean; + } + /** + * 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 { /** - * Returns the index-th row of the current matrix as a new Vector4. + * Color curves setup used in the effect if colorCurvesEnabled is set to true */ - getRow(index: number): Vector4; + colorCurves: ColorCurves; + private _colorCurvesEnabled; /** - * Sets the index-th row of the current matrix with the passed Vector4 values. - * Returns the updated Matrix. + * Gets wether the color curves effect is enabled. */ - setRow(index: number, row: Vector4): Matrix; /** - * Sets the index-th row of the current matrix with the passed 4 x float values. - * Returns the updated Matrix. + * Sets wether the color curves effect is enabled. */ - setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix; + colorCurvesEnabled: boolean; /** - * Returns a new Matrix set from the 16 passed floats. + * Color grading LUT texture used in the effect if colorGradingEnabled is set to true */ - static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix; + colorGradingTexture: BaseTexture; + private _colorGradingEnabled; /** - * Returns a new Matrix composed by the passed scale (vector3), rotation (quaternion) and translation (vector3). + * Gets wether the color grading effect is enabled. */ - static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix; - /** - * Update a Matrix with values composed by the passed scale (vector3), rotation (quaternion) and translation (vector3). - */ - static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void; /** - * Returns a new indentity Matrix. + * Sets wether the color grading effect is enabled. */ - static Identity(): Matrix; + colorGradingEnabled: boolean; + private _colorGradingWithGreenDepth; /** - * Sets the passed "result" as an identity matrix. + * Gets wether the color grading effect is using a green depth for the 3d Texture. */ - static IdentityToRef(result: Matrix): void; /** - * Returns a new zero Matrix. + * Sets wether the color grading effect is using a green depth for the 3d Texture. */ - static Zero(): Matrix; + colorGradingWithGreenDepth: boolean; + private _colorGradingBGR; /** - * Returns a new rotation matrix for "angle" radians around the X axis. + * Gets wether the color grading texture contains BGR values. */ - static RotationX(angle: number): Matrix; /** - * Returns a new Matrix as the passed inverted one. + * Sets wether the color grading texture contains BGR values. */ - static Invert(source: Matrix): Matrix; + colorGradingBGR: boolean; + _exposure: number; /** - * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the X axis. + * Gets the Exposure used in the effect. */ - static RotationXToRef(angle: number, result: Matrix): void; /** - * Returns a new rotation matrix for "angle" radians around the Y axis. + * Sets the Exposure used in the effect. */ - static RotationY(angle: number): Matrix; + exposure: number; + private _toneMappingEnabled; /** - * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the Y axis. + * Gets wether the tone mapping effect is enabled. */ - static RotationYToRef(angle: number, result: Matrix): void; /** - * Returns a new rotation matrix for "angle" radians around the Z axis. + * Sets wether the tone mapping effect is enabled. */ - static RotationZ(angle: number): Matrix; + toneMappingEnabled: boolean; + protected _contrast: number; /** - * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the Z axis. + * Gets the contrast used in the effect. */ - static RotationZToRef(angle: number, result: Matrix): void; /** - * Returns a new rotation matrix for "angle" radians around the passed axis. + * Sets the contrast used in the effect. */ - static RotationAxis(axis: Vector3, angle: number): Matrix; + contrast: number; /** - * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the passed axis. + * Vignette stretch size. */ - static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void; + vignetteStretch: number; /** - * Returns a new Matrix as a rotation matrix from the Euler angles (y, x, z). + * Vignette centre X Offset. */ - static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix; + vignetteCentreX: number; /** - * Sets the passed matrix "result" as a rotation matrix from the Euler angles (y, x, z). + * Vignette centre Y Offset. */ - static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void; + vignetteCentreY: number; /** - * Returns a new Matrix as a scaling matrix from the passed floats (x, y, z). + * Vignette weight or intensity of the vignette effect. */ - static Scaling(x: number, y: number, z: number): Matrix; + vignetteWeight: number; /** - * Sets the passed matrix "result" as a scaling matrix from the passed floats (x, y, z). + * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode) + * if vignetteEnabled is set to true. */ - static ScalingToRef(x: number, y: number, z: number, result: Matrix): void; + vignetteColor: BABYLON.Color4; /** - * Returns a new Matrix as a translation matrix from the passed floats (x, y, z). + * Camera field of view used by the Vignette effect. */ - static Translation(x: number, y: number, z: number): Matrix; + vignetteCameraFov: number; + private _vignetteBlendMode; /** - * Sets the passed matrix "result" as a translation matrix from the passed floats (x, y, z). + * Gets the vignette blend mode allowing different kind of effect. */ - static TranslationToRef(x: number, y: number, z: number, result: Matrix): void; /** - * Returns a new Matrix whose values are the interpolated values for "gradien" (float) between the ones of the matrices "startValue" and "endValue". + * Sets the vignette blend mode allowing different kind of effect. */ - static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix; + vignetteBlendMode: number; + private _vignetteEnabled; /** - * Returns a new Matrix whose values are computed by : - * - decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices, - * - interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end, - * - recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices. + * Gets wether the vignette effect is enabled. */ - static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix; /** - * Returns a new rotation Matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up". - * This methods works for a Left-Handed system. + * Sets wether the vignette effect is enabled. */ - static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix; + vignetteEnabled: boolean; + private _applyByPostProcess; /** - * Sets the passed "result" Matrix as a rotation matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up". - * This methods works for a Left-Handed system. + * Gets wether the image processing is applied through a post process or not. */ - static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void; /** - * Returns a new rotation Matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up". - * This methods works for a Right-Handed system. + * Sets wether the image processing is applied through a post process or not. */ - static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix; + applyByPostProcess: boolean; /** - * Sets the passed "result" Matrix as a rotation matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up". - * This methods works for a Left-Handed system. - */ - static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void; + * An event triggered when the configuration changes and requires Shader to Update some parameters. + * @type {BABYLON.Observable} + */ + onUpdateParameters: Observable; /** - * Returns a new Matrix as a left-handed orthographic projection matrix computed from the passed floats : width and height of the projection plane, z near and far limits. + * Method called each time the image processing information changes requires to recompile the effect. */ - static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix; + protected _updateParameters(): void; + getClassName(): string; /** - * Sets the passed matrix "result" as a left-handed orthographic projection matrix computed from the passed floats : width and height of the projection plane, z near and far limits. + * Prepare the list of uniforms associated with the Image Processing effects. + * @param uniformsList The list of uniforms used in the effect + * @param defines the list of defines currently in use */ - static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void; + static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void; /** - * Returns a new Matrix as a left-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits. + * Prepare the list of samplers associated with the Image Processing effects. + * @param uniformsList The list of uniforms used in the effect + * @param defines the list of defines currently in use */ - static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix; + static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void; /** - * Sets the passed matrix "result" as a left-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits. + * Prepare the list of defines associated to the shader. + * @param defines the list of defines to complete */ - static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void; + prepareDefines(defines: IImageProcessingConfigurationDefines): void; /** - * Returns a new Matrix as a right-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits. + * Returns true if all the image processing information are ready. */ - static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix; + isReady(): boolean; /** - * Sets the passed matrix "result" as a right-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits. + * Binds the image processing to the shader. + * @param effect The effect to bind to */ - static OrthoOffCenterRHToRef(left: number, right: any, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void; + bind(effect: Effect, aspectRatio?: number): void; /** - * Returns a new Matrix as a left-handed perspective projection matrix computed from the passed floats : width and height of the projection plane, z near and far limits. + * Clones the current image processing instance. + * @return The cloned image processing */ - static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix; + clone(): ImageProcessingConfiguration; /** - * Returns a new Matrix as a left-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits. + * Serializes the current image processing instance to a json representation. + * @return a JSON representation */ - static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix; + serialize(): any; /** - * Sets the passed matrix "result" as a left-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits. + * Parses the image processing from a json representation. + * @param source the JSON source to parse + * @return The parsed image processing */ - static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void; + static Parse(source: any): ImageProcessingConfiguration; + private static _VIGNETTEMODE_MULTIPLY; + private static _VIGNETTEMODE_OPAQUE; /** - * Returns a new Matrix as a right-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits. + * Used to apply the vignette as a mix with the pixel color. */ - static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix; + static readonly VIGNETTEMODE_MULTIPLY: number; /** - * Sets the passed matrix "result" as a right-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits. + * Used to apply the vignette as a replacement of the pixel color. */ - static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void; + static readonly VIGNETTEMODE_OPAQUE: number; + } +} + +declare module BABYLON { + class MaterialDefines { + private _keys; + private _isDirty; + _renderId: number; + _areLightsDirty: boolean; + _areAttributesDirty: boolean; + _areTexturesDirty: boolean; + _areFresnelDirty: boolean; + _areMiscDirty: boolean; + _areImageProcessingDirty: boolean; + _normals: boolean; + _uvs: boolean; + _needNormals: boolean; + _needUVs: boolean; + readonly isDirty: boolean; + markAsProcessed(): void; + markAsUnprocessed(): void; + markAllAsDirty(): void; + markAsImageProcessingDirty(): void; + markAsLightDirty(): void; + markAsAttributesDirty(): void; + markAsTexturesDirty(): void; + markAsFresnelDirty(): void; + markAsMiscDirty(): void; + rebuild(): void; + isEqual(other: MaterialDefines): boolean; + cloneTo(other: MaterialDefines): void; + reset(): void; + toString(): string; + } + class Material { + private static _TriangleFillMode; + private static _WireFrameFillMode; + private static _PointFillMode; + static readonly TriangleFillMode: number; + static readonly WireFrameFillMode: number; + static readonly PointFillMode: number; + private static _ClockWiseSideOrientation; + private static _CounterClockWiseSideOrientation; + static readonly ClockWiseSideOrientation: number; + static readonly CounterClockWiseSideOrientation: number; + private static _TextureDirtyFlag; + private static _LightDirtyFlag; + private static _FresnelDirtyFlag; + private static _AttributesDirtyFlag; + private static _MiscDirtyFlag; + static readonly TextureDirtyFlag: number; + static readonly LightDirtyFlag: number; + static readonly FresnelDirtyFlag: number; + static readonly AttributesDirtyFlag: number; + static readonly MiscDirtyFlag: number; + id: string; + name: string; + checkReadyOnEveryCall: boolean; + checkReadyOnlyOnce: boolean; + state: string; + alpha: number; + protected _backFaceCulling: boolean; + backFaceCulling: boolean; + sideOrientation: number; + onCompiled: (effect: Effect) => void; + onError: (effect: Effect, errors: string) => void; + getRenderTargetTextures: () => SmartArray; + doNotSerialize: boolean; + storeEffectOnSubMeshes: boolean; /** - * Sets the passed matrix "result" as a left-handed perspective projection matrix for WebVR computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits. - */ - static PerspectiveFovWebVRToRef(fov: any, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void; + * An event triggered when the material is disposed. + * @type {BABYLON.Observable} + */ + onDisposeObservable: Observable; + private _onDisposeObserver; + onDispose: () => void; /** - * Returns the final transformation matrix : world * view * projection * viewport - */ - static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix; + * An event triggered when the material is bound. + * @type {BABYLON.Observable} + */ + onBindObservable: Observable; + private _onBindObserver; + onBind: (Mesh: AbstractMesh) => void; /** - * Returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the passed Matrix. + * An event triggered when the material is unbound. + * @type {BABYLON.Observable} + */ + onUnBindObservable: Observable; + alphaMode: number; + disableDepthWrite: boolean; + private _fogEnabled; + fogEnabled: boolean; + pointSize: number; + zOffset: number; + wireframe: boolean; + pointsCloud: boolean; + fillMode: number; + _effect: Effect; + _wasPreviouslyReady: boolean; + private _useUBO; + private _scene; + private _fillMode; + private _cachedDepthWriteState; + protected _uniformBuffer: UniformBuffer; + constructor(name: string, scene: Scene, doNotAdd?: boolean); + /** + * @param {boolean} fullDetails - support for multiple levels of logging within scene loading + * subclasses should override adding information pertainent to themselves */ - static GetAsMatrix2x2(matrix: Matrix): Float32Array; + toString(fullDetails?: boolean): string; /** - * Returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the passed Matrix. + * Child classes can use it to update shaders */ - static GetAsMatrix3x3(matrix: Matrix): Float32Array; + getClassName(): string; + readonly isFrozen: boolean; + freeze(): void; + unfreeze(): void; + isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean; + isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean; + getEffect(): Effect; + getScene(): Scene; + needAlphaBlending(): boolean; + needAlphaTesting(): boolean; + getAlphaTestTexture(): BaseTexture; + markDirty(): void; + _preBind(effect?: Effect): void; + bind(world: Matrix, mesh?: Mesh): void; + bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void; + bindOnlyWorldMatrix(world: Matrix): void; + bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void; + bindView(effect: Effect): void; + bindViewProjection(effect: Effect): void; + protected _afterBind(mesh: Mesh): void; + unbind(): void; + getActiveTextures(): BaseTexture[]; + hasTexture(texture: BaseTexture): boolean; + clone(name: string): Material; + getBindedMeshes(): AbstractMesh[]; /** - * Compute the transpose of the passed Matrix. - * Returns a new Matrix. + * Force shader compilation including textures ready check */ - static Transpose(matrix: Matrix): Matrix; + forceCompilation(mesh: AbstractMesh, onCompiled: (material: Material) => void, options?: { + alphaTest: boolean; + clipPlane: boolean; + }): void; + markAsDirty(flag: number): void; + protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void; + protected _markAllSubMeshesAsImageProcessingDirty(): void; + protected _markAllSubMeshesAsTexturesDirty(): void; + protected _markAllSubMeshesAsFresnelDirty(): void; + protected _markAllSubMeshesAsLightsDirty(): void; + protected _markAllSubMeshesAsAttributesDirty(): void; + protected _markAllSubMeshesAsMiscDirty(): void; + dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void; + serialize(): any; + static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial; + static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any; + } +} + +declare module BABYLON { + class MaterialHelper { + static PrepareDefinesForMergedUV(texture: BaseTexture, defines: MaterialDefines, key: string): void; + static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void; + static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: any, fogEnabled: boolean, defines: MaterialDefines): void; + static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: MaterialDefines, useInstances: boolean, forceAlphaTest?: boolean): void; + static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: MaterialDefines, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean): boolean; + static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: MaterialDefines, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean; + static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: MaterialDefines, maxSimultaneousLights?: number): void; + static HandleFallbacksForShadows(defines: MaterialDefines, fallbacks: EffectFallbacks, maxSimultaneousLights?: number): void; + static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: MaterialDefines): void; + static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: MaterialDefines, fallbacks: EffectFallbacks): void; + static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void; + static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void; + static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void; + static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: MaterialDefines, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void; + static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect): void; + static BindBonesParameters(mesh: AbstractMesh, effect: Effect): void; + static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void; + static BindLogDepth(defines: MaterialDefines, effect: Effect, scene: Scene): void; + static BindClipPlane(effect: Effect, scene: Scene): void; + } +} + +declare module BABYLON { + class MultiMaterial extends Material { + private _subMaterials; + subMaterials: Material[]; + constructor(name: string, scene: Scene); + private _hookArray(array); + getSubMaterial(index: any): Material; + getActiveTextures(): BaseTexture[]; + getClassName(): string; + isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean; + clone(name: string, cloneChildren?: boolean): MultiMaterial; + serialize(): any; + dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void; + } +} + +declare module BABYLON { + class PushMaterial extends Material { + protected _activeEffect: Effect; + constructor(name: string, scene: Scene); + getEffect(): Effect; + isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean; + bindOnlyWorldMatrix(world: Matrix): void; + bind(world: Matrix, mesh?: Mesh): void; + protected _afterBind(mesh: Mesh, effect?: Effect): void; + protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean; + } +} + +declare module BABYLON { + class ShaderMaterial extends Material { + private _shaderPath; + private _options; + private _textures; + private _textureArrays; + private _floats; + private _floatsArrays; + private _colors3; + private _colors3Arrays; + private _colors4; + private _vectors2; + private _vectors3; + private _vectors4; + private _matrices; + private _matrices3x3; + private _matrices2x2; + private _vectors3Arrays; + private _cachedWorldViewMatrix; + private _renderId; + constructor(name: string, scene: Scene, shaderPath: any, options: any); + getClassName(): string; + needAlphaBlending(): boolean; + needAlphaTesting(): boolean; + private _checkUniform(uniformName); + setTexture(name: string, texture: Texture): ShaderMaterial; + setTextureArray(name: string, textures: Texture[]): ShaderMaterial; + setFloat(name: string, value: number): ShaderMaterial; + setFloats(name: string, value: number[]): ShaderMaterial; + setColor3(name: string, value: Color3): ShaderMaterial; + setColor3Array(name: string, value: Color3[]): ShaderMaterial; + setColor4(name: string, value: Color4): ShaderMaterial; + setVector2(name: string, value: Vector2): ShaderMaterial; + setVector3(name: string, value: Vector3): ShaderMaterial; + setVector4(name: string, value: Vector4): ShaderMaterial; + setMatrix(name: string, value: Matrix): ShaderMaterial; + setMatrix3x3(name: string, value: Float32Array): ShaderMaterial; + setMatrix2x2(name: string, value: Float32Array): ShaderMaterial; + setArray3(name: string, value: number[]): ShaderMaterial; + private _checkCache(scene, mesh?, useInstances?); + isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean; + bindOnlyWorldMatrix(world: Matrix): void; + bind(world: Matrix, mesh?: Mesh): void; + getActiveTextures(): BaseTexture[]; + hasTexture(texture: BaseTexture): boolean; + clone(name: string): ShaderMaterial; + dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void; + serialize(): any; + static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial; + } +} + +declare module BABYLON { + class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines { + MAINUV1: boolean; + MAINUV2: boolean; + DIFFUSE: boolean; + DIFFUSEDIRECTUV: number; + AMBIENT: boolean; + AMBIENTDIRECTUV: number; + OPACITY: boolean; + OPACITYDIRECTUV: number; + OPACITYRGB: boolean; + REFLECTION: boolean; + EMISSIVE: boolean; + EMISSIVEDIRECTUV: number; + SPECULAR: boolean; + SPECULARDIRECTUV: number; + BUMP: boolean; + BUMPDIRECTUV: number; + PARALLAX: boolean; + PARALLAXOCCLUSION: boolean; + SPECULAROVERALPHA: boolean; + CLIPPLANE: boolean; + ALPHATEST: boolean; + ALPHAFROMDIFFUSE: boolean; + POINTSIZE: boolean; + FOG: boolean; + SPECULARTERM: boolean; + DIFFUSEFRESNEL: boolean; + OPACITYFRESNEL: boolean; + REFLECTIONFRESNEL: boolean; + REFRACTIONFRESNEL: boolean; + EMISSIVEFRESNEL: boolean; + FRESNEL: boolean; + NORMAL: boolean; + UV1: boolean; + UV2: boolean; + VERTEXCOLOR: boolean; + VERTEXALPHA: boolean; + NUM_BONE_INFLUENCERS: number; + BonesPerMesh: number; + INSTANCES: boolean; + GLOSSINESS: boolean; + ROUGHNESS: boolean; + EMISSIVEASILLUMINATION: boolean; + LINKEMISSIVEWITHDIFFUSE: boolean; + REFLECTIONFRESNELFROMSPECULAR: boolean; + LIGHTMAP: boolean; + LIGHTMAPDIRECTUV: number; + USELIGHTMAPASSHADOWMAP: boolean; + REFLECTIONMAP_3D: boolean; + REFLECTIONMAP_SPHERICAL: boolean; + REFLECTIONMAP_PLANAR: boolean; + REFLECTIONMAP_CUBIC: boolean; + REFLECTIONMAP_PROJECTION: boolean; + REFLECTIONMAP_SKYBOX: boolean; + REFLECTIONMAP_EXPLICIT: boolean; + REFLECTIONMAP_EQUIRECTANGULAR: boolean; + REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean; + REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean; + INVERTCUBICMAP: boolean; + LOGARITHMICDEPTH: boolean; + REFRACTION: boolean; + REFRACTIONMAP_3D: boolean; + REFLECTIONOVERALPHA: boolean; + TWOSIDEDLIGHTING: boolean; + SHADOWFLOAT: boolean; + MORPHTARGETS: boolean; + MORPHTARGETS_NORMAL: boolean; + MORPHTARGETS_TANGENT: boolean; + NUM_MORPH_INFLUENCERS: number; + USERIGHTHANDEDSYSTEM: boolean; + IMAGEPROCESSING: boolean; + VIGNETTE: boolean; + VIGNETTEBLENDMODEMULTIPLY: boolean; + VIGNETTEBLENDMODEOPAQUE: boolean; + TONEMAPPING: boolean; + CONTRAST: boolean; + COLORCURVES: boolean; + COLORGRADING: boolean; + SAMPLER3DGREENDEPTH: boolean; + SAMPLER3DBGRMAP: boolean; + IMAGEPROCESSINGPOSTPROCESS: boolean; + EXPOSURE: boolean; + constructor(); + setReflectionMode(modeToEnable: string): void; + } + class StandardMaterial extends PushMaterial { + private _diffuseTexture; + diffuseTexture: BaseTexture; + private _ambientTexture; + ambientTexture: BaseTexture; + private _opacityTexture; + opacityTexture: BaseTexture; + private _reflectionTexture; + reflectionTexture: BaseTexture; + private _emissiveTexture; + emissiveTexture: BaseTexture; + private _specularTexture; + specularTexture: BaseTexture; + private _bumpTexture; + bumpTexture: BaseTexture; + private _lightmapTexture; + lightmapTexture: BaseTexture; + private _refractionTexture; + refractionTexture: BaseTexture; + ambientColor: Color3; + diffuseColor: Color3; + specularColor: Color3; + emissiveColor: Color3; + specularPower: number; + private _useAlphaFromDiffuseTexture; + useAlphaFromDiffuseTexture: boolean; + private _useEmissiveAsIllumination; + useEmissiveAsIllumination: boolean; + private _linkEmissiveWithDiffuse; + linkEmissiveWithDiffuse: boolean; + private _useSpecularOverAlpha; + useSpecularOverAlpha: boolean; + private _useReflectionOverAlpha; + useReflectionOverAlpha: boolean; + private _disableLighting; + disableLighting: boolean; + private _useParallax; + useParallax: boolean; + private _useParallaxOcclusion; + useParallaxOcclusion: boolean; + parallaxScaleBias: number; + private _roughness; + roughness: number; + indexOfRefraction: number; + invertRefractionY: boolean; + private _useLightmapAsShadowmap; + useLightmapAsShadowmap: boolean; + private _diffuseFresnelParameters; + diffuseFresnelParameters: FresnelParameters; + private _opacityFresnelParameters; + opacityFresnelParameters: FresnelParameters; + private _reflectionFresnelParameters; + reflectionFresnelParameters: FresnelParameters; + private _refractionFresnelParameters; + refractionFresnelParameters: FresnelParameters; + private _emissiveFresnelParameters; + emissiveFresnelParameters: FresnelParameters; + private _useReflectionFresnelFromSpecular; + useReflectionFresnelFromSpecular: boolean; + private _useGlossinessFromSpecularMapAlpha; + useGlossinessFromSpecularMapAlpha: boolean; + private _maxSimultaneousLights; + maxSimultaneousLights: number; /** - * Returns a new Matrix as the reflection matrix across the passed plane. + * If sets to true, x component of normal map value will invert (x = 1.0 - x). */ - static Reflection(plane: Plane): Matrix; + private _invertNormalMapX; + invertNormalMapX: boolean; /** - * Sets the passed matrix "result" as the reflection matrix across the passed plane. + * If sets to true, y component of normal map value will invert (y = 1.0 - y). */ - static ReflectionToRef(plane: Plane, result: Matrix): void; + private _invertNormalMapY; + invertNormalMapY: boolean; /** - * Sets the passed matrix "mat" as a rotation matrix composed from the 3 passed left handed axis. + * If sets to true and backfaceCulling is false, normals will be flipped on the backside. */ - static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void; + private _twoSidedLighting; + twoSidedLighting: boolean; /** - * Sets the passed matrix "result" as a rotation matrix according to the passed quaternion. + * Default configuration related to image processing available in the standard Material. */ - static FromQuaternionToRef(quat: Quaternion, result: Matrix): void; - } - class Plane { - normal: Vector3; - d: number; + protected _imageProcessingConfiguration: ImageProcessingConfiguration; /** - * Creates a Plane object according to the passed floats a, b, c, d and the plane equation : ax + by + cz + d = 0 + * Gets the image processing configuration used either in this material. */ - constructor(a: number, b: number, c: number, d: number); /** - * Returns the plane coordinates as a new array of 4 elements [a, b, c, d]. + * Sets the Default image processing configuration used either in the this material. + * + * If sets to null, the scene one is in use. */ - asArray(): number[]; + imageProcessingConfiguration: ImageProcessingConfiguration; /** - * Returns a new plane copied from the current Plane. + * Keep track of the image processing observer to allow dispose and replace. */ - clone(): Plane; + private _imageProcessingObserver; /** - * Returns the string "Plane". + * Attaches a new image processing configuration to the Standard Material. + * @param configuration */ - getClassName(): string; + protected _attachImageProcessingConfiguration(configuration: ImageProcessingConfiguration): void; /** - * Returns the Plane hash code. + * Gets wether the color curves effect is enabled. */ - getHashCode(): number; /** - * Normalize the current Plane in place. - * Returns the updated Plane. + * Sets wether the color curves effect is enabled. */ - normalize(): Plane; + cameraColorCurvesEnabled: boolean; /** - * Returns a new Plane as the result of the transformation of the current Plane by the passed matrix. + * Gets wether the color grading effect is enabled. */ - transform(transformation: Matrix): Plane; /** - * Returns the dot product (float) of the point coordinates and the plane normal. + * Gets wether the color grading effect is enabled. */ - dotCoordinate(point: any): number; + cameraColorGradingEnabled: boolean; /** - * Updates the current Plane from the plane defined by the three passed points. - * Returns the updated Plane. + * Gets wether tonemapping is enabled or not. */ - copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane; /** - * Boolean : True is the vector "direction" is the same side than the plane normal. + * Sets wether tonemapping is enabled or not */ - isFrontFacingTo(direction: Vector3, epsilon: number): boolean; + cameraToneMappingEnabled: boolean; /** - * Returns the signed distance (float) from the passed point to the Plane. + * The camera exposure used on this material. + * This property is here and not in the camera to allow controlling exposure without full screen post process. + * This corresponds to a photographic exposure. */ - signedDistanceTo(point: Vector3): number; /** - * Returns a new Plane from the passed array. + * The camera exposure used on this material. + * This property is here and not in the camera to allow controlling exposure without full screen post process. + * This corresponds to a photographic exposure. */ - static FromArray(array: ArrayLike): Plane; + cameraExposure: number; /** - * Returns a new Plane defined by the three passed points. + * Gets The camera contrast used on this material. */ - static FromPoints(point1: any, point2: any, point3: any): Plane; /** - * Returns a new Plane the normal vector to this plane at the passed origin point. - * Note : the vector "normal" is updated because normalized. + * Sets The camera contrast used on this material. */ - static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane; + cameraContrast: number; /** - * Returns the signed distance between the plane defined by the normal vector at the "origin"" point and the passed other point. + * Gets the Color Grading 2D Lookup Texture. */ - static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number; - } - class Viewport { - x: number; - y: number; - width: number; - height: number; /** - * Creates a Viewport object located at (x, y) and sized (width, height). + * Sets the Color Grading 2D Lookup Texture. */ - constructor(x: number, y: number, width: number, height: number); - toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport; + cameraColorGradingTexture: BaseTexture; + customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string; + protected _renderTargets: SmartArray; + protected _worldViewProjectionMatrix: Matrix; + protected _globalAmbientColor: Color3; + protected _useLogarithmicDepth: boolean; + constructor(name: string, scene: Scene); + getClassName(): string; + useLogarithmicDepth: boolean; + needAlphaBlending(): boolean; + needAlphaTesting(): boolean; + protected _shouldUseAlphaFromDiffuseTexture(): boolean; + getAlphaTestTexture(): BaseTexture; /** - * Returns a new Viewport copied from the current one. + * Child classes can use it to update shaders */ - clone(): Viewport; + isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean; + buildUniformLayout(): void; + unbind(): void; + bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void; + getAnimatables(): IAnimatable[]; + getActiveTextures(): BaseTexture[]; + hasTexture(texture: BaseTexture): boolean; + dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void; + clone(name: string): StandardMaterial; + serialize(): any; + static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial; + static _DiffuseTextureEnabled: boolean; + static DiffuseTextureEnabled: boolean; + static _AmbientTextureEnabled: boolean; + static AmbientTextureEnabled: boolean; + static _OpacityTextureEnabled: boolean; + static OpacityTextureEnabled: boolean; + static _ReflectionTextureEnabled: boolean; + static ReflectionTextureEnabled: boolean; + static _EmissiveTextureEnabled: boolean; + static EmissiveTextureEnabled: boolean; + static _SpecularTextureEnabled: boolean; + static SpecularTextureEnabled: boolean; + static _BumpTextureEnabled: boolean; + static BumpTextureEnabled: boolean; + static _LightmapTextureEnabled: boolean; + static LightmapTextureEnabled: boolean; + static _RefractionTextureEnabled: boolean; + static RefractionTextureEnabled: boolean; + static _ColorGradingTextureEnabled: boolean; + static ColorGradingTextureEnabled: boolean; + static _FresnelEnabled: boolean; + static FresnelEnabled: boolean; } - class Frustum { +} + +declare module BABYLON { + class UniformBuffer { + private _engine; + private _buffer; + private _data; + private _bufferData; + private _dynamic; + private _uniformName; + private _uniformLocations; + private _uniformSizes; + private _uniformLocationPointer; + private _needSync; + private _cache; + private _noUBO; + private _currentEffect; + private static _MAX_UNIFORM_SIZE; + private static _tempBuffer; /** - * Returns a new array of 6 Frustum planes computed by the passed transformation matrix. + * Wrapper for updateUniform. + * @method updateMatrix3x3 + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {Float32Array} matrix */ - static GetPlanes(transform: Matrix): Plane[]; + updateMatrix3x3: (name: string, matrix: Float32Array) => void; /** - * Sets the passed array "frustumPlanes" with the 6 Frustum planes computed by the passed transformation matrix. + * Wrapper for updateUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {Float32Array} matrix */ - static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void; - } - enum Space { - LOCAL = 0, - WORLD = 1, - BONE = 2, - } - class Axis { - static X: Vector3; - static Y: Vector3; - static Z: Vector3; - } - class BezierCurve { + updateMatrix2x2: (name: string, matrix: Float32Array) => void; /** - * Returns the cubic Bezier interpolated value (float) at "t" (float) from the passed x1, y1, x2, y2 floats. + * Wrapper for updateUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {number} x */ - static interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number; - } - enum Orientation { - CW = 0, - CCW = 1, - } - class Angle { - private _radians; + updateFloat: (name: string, x: number) => void; /** - * Creates an Angle object of "radians" radians (float). + * Wrapper for updateUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {number} x + * @param {number} y + * @param {string} [suffix] Suffix to add to the uniform name. */ - constructor(radians: number); + updateFloat2: (name: string, x: number, y: number, suffix?: string) => void; /** - * Returns the Angle value in degrees (float). + * Wrapper for updateUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {number} x + * @param {number} y + * @param {number} z + * @param {string} [suffix] Suffix to add to the uniform name. */ - degrees: () => number; + updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void; /** - * Returns the Angle value in radians (float). + * Wrapper for updateUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {number} x + * @param {number} y + * @param {number} z + * @param {number} w + * @param {string} [suffix] Suffix to add to the uniform name. */ - radians: () => number; + updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void; /** - * Returns a new Angle object valued with the angle value in radians between the two passed vectors. + * Wrapper for updateUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {Matrix} A 4x4 matrix. */ - static BetweenTwoPoints(a: Vector2, b: Vector2): Angle; + updateMatrix: (name: string, mat: Matrix) => void; /** - * Returns a new Angle object from the passed float in radians. + * Wrapper for updateUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {Vector3} vector */ - static FromRadians(radians: number): Angle; + updateVector3: (name: string, vector: Vector3) => void; /** - * Returns a new Angle object from the passed float in degrees. + * Wrapper for updateUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {Vector4} vector */ - static FromDegrees(degrees: number): Angle; - } - class Arc2 { - startPoint: Vector2; - midPoint: Vector2; - endPoint: Vector2; - centerPoint: Vector2; - radius: number; - angle: Angle; - startAngle: Angle; - orientation: Orientation; + updateVector4: (name: string, vector: Vector4) => void; /** - * Creates an Arc object from the three passed points : start, middle and end. + * Wrapper for updateUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {Color3} color + * @param {string} [suffix] Suffix to add to the uniform name. */ - constructor(startPoint: Vector2, midPoint: Vector2, endPoint: Vector2); - } - class Path2 { - private _points; - private _length; - closed: boolean; + updateColor3: (name: string, color: Color3, suffix?: string) => void; /** - * Creates a Path2 object from the starting 2D coordinates x and y. + * Wrapper for updateUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {Color3} color + * @param {number} alpha + * @param {string} [suffix] Suffix to add to the uniform name. */ - constructor(x: number, y: number); + updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void; /** - * Adds a new segment until the passed coordinates (x, y) to the current Path2. - * Returns the updated Path2. + * Uniform buffer objects. + * + * Handles blocks of uniform on the GPU. + * + * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls. + * + * For more information, please refer to : + * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object */ - addLineTo(x: number, y: number): Path2; + constructor(engine: Engine, data?: number[], dynamic?: boolean); /** - * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2. - * Returns the updated Path2. + * Indicates if the buffer is using the WebGL2 UBO implementation, + * or just falling back on setUniformXXX calls. */ - addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2; + readonly useUbo: boolean; /** - * Closes the Path2. - * Returns the Path2. + * Indicates if the WebGL underlying uniform buffer is in sync + * with the javascript cache data. */ - close(): Path2; + readonly isSync: boolean; + /** + * Indicates if the WebGL underlying uniform buffer is dynamic. + * Also, a dynamic UniformBuffer will disable cache verification and always + * update the underlying WebGL uniform buffer to the GPU. + */ + isDynamic(): boolean; /** - * Returns the Path2 total length (float). + * The data cache on JS side. */ - length(): number; + getData(): Float32Array; /** - * Returns the Path2 internal array of points. + * The underlying WebGL Uniform buffer. */ - getPoints(): Vector2[]; + getBuffer(): WebGLBuffer; /** - * Returns a new Vector2 located at a percentage of the Path2 total length on this path. + * std140 layout specifies how to align data within an UBO structure. + * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159 + * for specs. */ - getPointAtLengthPosition(normalizedLengthPosition: number): Vector2; + private _fillAlignment(size); /** - * Returns a new Path2 starting at the coordinates (x, y). + * Adds an uniform in the buffer. + * Warning : the subsequents calls of this function must be in the same order as declared in the shader + * for the layout to be correct ! + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {number|number[]} size Data size, or data directly. */ - static StartingAt(x: number, y: number): Path2; - } - class Path3D { - path: Vector3[]; - private _curve; - private _distances; - private _tangents; - private _normals; - private _binormals; - private _raw; + addUniform(name: string, size: number | number[]): void; /** - * new Path3D(path, normal, raw) - * Creates a Path3D. A Path3D is a logical math object, so not a mesh. - * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D - * path : an array of Vector3, the curve axis of the Path3D - * normal (optional) : Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal. - * raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed. - */ - constructor(path: Vector3[], firstNormal?: Vector3, raw?: boolean); + * Wrapper for addUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {Matrix} mat A 4x4 matrix. + */ + addMatrix(name: string, mat: Matrix): void; /** - * Returns the Path3D array of successive Vector3 designing its curve. + * Wrapper for addUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {number} x + * @param {number} y */ - getCurve(): Vector3[]; + addFloat2(name: string, x: number, y: number): void; /** - * Returns an array populated with tangent vectors on each Path3D curve point. + * Wrapper for addUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {number} x + * @param {number} y + * @param {number} z */ - getTangents(): Vector3[]; + addFloat3(name: string, x: number, y: number, z: number): void; /** - * Returns an array populated with normal vectors on each Path3D curve point. + * Wrapper for addUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {Color3} color */ - getNormals(): Vector3[]; + addColor3(name: string, color: Color3): void; /** - * Returns an array populated with binormal vectors on each Path3D curve point. + * Wrapper for addUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {Color3} color + * @param {number} alpha */ - getBinormals(): Vector3[]; + addColor4(name: string, color: Color3, alpha: number): void; /** - * Returns an array populated with distances (float) of the i-th point from the first curve point. + * Wrapper for addUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. + * @param {Vector3} vector */ - getDistances(): number[]; + addVector3(name: string, vector: Vector3): void; /** - * Forces the Path3D tangent, normal, binormal and distance recomputation. - * Returns the same object updated. + * Wrapper for addUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. */ - update(path: Vector3[], firstNormal?: Vector3): Path3D; - private _compute(firstNormal); - private _getFirstNonNullVector(index); - private _getLastNonNullVector(index); - private _normalVector(v0, vt, va); - } - class Curve3 { - private _points; - private _length; + addMatrix3x3(name: string): void; /** - * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve - * @param v0 (Vector3) the origin point of the Quadratic Bezier - * @param v1 (Vector3) the control point - * @param v2 (Vector3) the end point of the Quadratic Bezier - * @param nbPoints (integer) the wanted number of points in the curve + * Wrapper for addUniform. + * @param {string} name Name of the uniform, as used in the uniform block in the shader. */ - static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3; + addMatrix2x2(name: string): void; /** - * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve - * @param v0 (Vector3) the origin point of the Cubic Bezier - * @param v1 (Vector3) the first control point - * @param v2 (Vector3) the second control point - * @param v3 (Vector3) the end point of the Cubic Bezier - * @param nbPoints (integer) the wanted number of points in the curve + * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`. */ - static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3; + create(): void; /** - * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline - * @param p1 (Vector3) the origin point of the Hermite Spline - * @param t1 (Vector3) the tangent vector at the origin point - * @param p2 (Vector3) the end point of the Hermite Spline - * @param t2 (Vector3) the tangent vector at the end point - * @param nbPoints (integer) the wanted number of points in the curve + * Updates the WebGL Uniform Buffer on the GPU. + * If the `dynamic` flag is set to true, no cache comparison is done. + * Otherwise, the buffer will be updated only if the cache differs. */ - static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3; + update(): void; /** - * Returns a Curve3 object along a CatmullRom Spline curve : - * @param points (array of Vector3) the points the spline must pass through. At least, four points required. - * @param nbPoints (integer) the wanted number of points between each curve control points. + * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU. + * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader. + * @param {number[]|Float32Array} data Flattened data + * @param {number} size Size of the data. */ - static CreateCatmullRomSpline(points: Vector3[], nbPoints: number): Curve3; + updateUniform(uniformName: string, data: number[] | Float32Array, size: number): void; + private _updateMatrix3x3ForUniform(name, matrix); + private _updateMatrix3x3ForEffect(name, matrix); + private _updateMatrix2x2ForEffect(name, matrix); + private _updateMatrix2x2ForUniform(name, matrix); + private _updateFloatForEffect(name, x); + private _updateFloatForUniform(name, x); + private _updateFloat2ForEffect(name, x, y, suffix?); + private _updateFloat2ForUniform(name, x, y, suffix?); + private _updateFloat3ForEffect(name, x, y, z, suffix?); + private _updateFloat3ForUniform(name, x, y, z, suffix?); + private _updateFloat4ForEffect(name, x, y, z, w, suffix?); + private _updateFloat4ForUniform(name, x, y, z, w, suffix?); + private _updateMatrixForEffect(name, mat); + private _updateMatrixForUniform(name, mat); + private _updateVector3ForEffect(name, vector); + private _updateVector3ForUniform(name, vector); + private _updateVector4ForEffect(name, vector); + private _updateVector4ForUniform(name, vector); + private _updateColor3ForEffect(name, color, suffix?); + private _updateColor3ForUniform(name, color, suffix?); + private _updateColor4ForEffect(name, color, alpha, suffix?); + private _updateColor4ForUniform(name, color, alpha, suffix?); /** - * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space. - * A Curve3 is designed from a series of successive Vector3. - * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object + * Sets a sampler uniform on the effect. + * @param {string} name Name of the sampler. + * @param {Texture} texture */ - constructor(points: Vector3[]); + setTexture(name: string, texture: BaseTexture): void; /** - * Returns the Curve3 stored array of successive Vector3 + * Directly updates the value of the uniform in the cache AND on the GPU. + * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader. + * @param {number[]|Float32Array} data Flattened data */ - getPoints(): Vector3[]; + updateUniformDirectly(uniformName: string, data: number[] | Float32Array): void; /** - * Returns the computed length (float) of the curve. + * Binds this uniform buffer to an effect. + * @param {Effect} effect + * @param {string} name Name of the uniform block in the shader. */ - length(): number; + bindToEffect(effect: Effect, name: string): void; /** - * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB); - * This new Curve3 is built by translating and sticking the curveB at the end of the curveA. - * curveA and curveB keep unchanged. + * Disposes the uniform buffer. */ - continue(curve: Curve3): Curve3; - private _computeLength(path); - } - class PositionNormalVertex { - position: Vector3; - normal: Vector3; - constructor(position?: Vector3, normal?: Vector3); - clone(): PositionNormalVertex; - } - class PositionNormalTextureVertex { - position: Vector3; - normal: Vector3; - uv: Vector2; - constructor(position?: Vector3, normal?: Vector3, uv?: Vector2); - clone(): PositionNormalTextureVertex; - } - class Tmp { - static Color3: Color3[]; - static Vector2: Vector2[]; - static Vector3: Vector3[]; - static Vector4: Vector4[]; - static Quaternion: Quaternion[]; - static Matrix: Matrix[]; - } -} - -declare module BABYLON { - class SphericalPolynomial { - x: Vector3; - y: Vector3; - z: Vector3; - xx: Vector3; - yy: Vector3; - zz: Vector3; - xy: Vector3; - yz: Vector3; - zx: Vector3; - addAmbient(color: Color3): void; - static getSphericalPolynomialFromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial; - scale(scale: number): void; - } - class SphericalHarmonics { - L00: Vector3; - L1_1: Vector3; - L10: Vector3; - L11: Vector3; - L2_2: Vector3; - L2_1: Vector3; - L20: Vector3; - L21: Vector3; - L22: Vector3; - addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void; - scale(scale: number): void; - convertIncidentRadianceToIrradiance(): void; - convertIrradianceToLambertianRadiance(): void; - static getsphericalHarmonicsFromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics; + dispose(): void; } } @@ -13128,6 +13128,36 @@ declare module BABYLON { } } +declare module BABYLON { + class ReflectionProbe { + name: string; + private _scene; + private _renderTargetTexture; + private _projectionMatrix; + private _viewMatrix; + private _target; + private _add; + private _attachedMesh; + invertYAxis: boolean; + position: Vector3; + constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean); + samples: number; + refreshRate: number; + getScene(): Scene; + readonly cubeTexture: RenderTargetTexture; + readonly renderList: AbstractMesh[]; + attachToMesh(mesh: AbstractMesh): 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. + */ + setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void; + dispose(): void; + } +} + declare module BABYLON { class AnaglyphPostProcess extends PostProcess { private _passedProcess; @@ -13651,36 +13681,6 @@ declare module BABYLON { } } -declare module BABYLON { - class ReflectionProbe { - name: string; - private _scene; - private _renderTargetTexture; - private _projectionMatrix; - private _viewMatrix; - private _target; - private _add; - private _attachedMesh; - invertYAxis: boolean; - position: Vector3; - constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean); - samples: number; - refreshRate: number; - getScene(): Scene; - readonly cubeTexture: RenderTargetTexture; - readonly renderList: AbstractMesh[]; - attachToMesh(mesh: AbstractMesh): 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. - */ - setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void; - dispose(): void; - } -} - declare module BABYLON { class BoundingBoxRenderer { frontColor: Color3; @@ -15471,247 +15471,114 @@ declare module BABYLON { private _lastSecAccumulated; private _lastSecTime; private _lastSecValueCount; - } - /** - * Use this className as a decorator on a given class definition to add it a name and optionally its module. - * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name. - * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified - * @param name The name of the class, case should be preserved - * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved. - */ - function className(name: string, module?: string): (target: Object) => void; - /** - * An implementation of a loop for asynchronous functions. - */ - class AsyncLoop { - iterations: number; - private _fn; - private _successCallback; - index: number; - private _done; - /** - * Constroctor. - * @param iterations the number of iterations. - * @param _fn the function to run each iteration - * @param _successCallback the callback that will be called upon succesful execution - * @param offset starting offset. - */ - constructor(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number); - /** - * Execute the next iteration. Must be called after the last iteration was finished. - */ - executeNext(): void; - /** - * Break the loop and run the success callback. - */ - breakLoop(): void; - /** - * Helper function - */ - static Run(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number): AsyncLoop; - /** - * A for-loop that will run a given number of iterations synchronous and the rest async. - * @param iterations total number of iterations - * @param syncedIterations number of synchronous iterations in each async iteration. - * @param fn the function to call each iteration. - * @param callback a success call back that will be called when iterating stops. - * @param breakFunction a break condition (optional) - * @param timeout timeout settings for the setTimeout function. default - 0. - * @constructor - */ - static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): void; - } -} - -declare module BABYLON { - enum JoystickAxis { - X = 0, - Y = 1, - Z = 2, - } - class VirtualJoystick { - reverseLeftRight: boolean; - reverseUpDown: boolean; - deltaPosition: Vector3; - pressed: boolean; - private static _globalJoystickIndex; - private static vjCanvas; - private static vjCanvasContext; - private static vjCanvasWidth; - private static vjCanvasHeight; - private static halfWidth; - private static halfHeight; - private _action; - private _axisTargetedByLeftAndRight; - private _axisTargetedByUpAndDown; - private _joystickSensibility; - private _inversedSensibility; - private _rotationSpeed; - private _inverseRotationSpeed; - private _rotateOnAxisRelativeToMesh; - private _joystickPointerID; - private _joystickColor; - private _joystickPointerPos; - private _joystickPreviousPointerPos; - private _joystickPointerStartPos; - private _deltaJoystickVector; - private _leftJoystick; - private _joystickIndex; - private _touches; - private _onPointerDownHandlerRef; - private _onPointerMoveHandlerRef; - private _onPointerUpHandlerRef; - private _onPointerOutHandlerRef; - private _onResize; - constructor(leftJoystick?: boolean); - setJoystickSensibility(newJoystickSensibility: number): void; - private _onPointerDown(e); - private _onPointerMove(e); - private _onPointerUp(e); - /** - * Change the color of the virtual joystick - * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000") - */ - setJoystickColor(newColor: string): void; - setActionOnTouch(action: () => any): void; - setAxisForLeftRight(axis: JoystickAxis): void; - setAxisForUpDown(axis: JoystickAxis): void; - private _clearCanvas(); - private _drawVirtualJoystick(); - releaseCanvas(): void; - } -} - -declare module BABYLON { - class VRCameraMetrics { - hResolution: number; - vResolution: number; - hScreenSize: number; - vScreenSize: number; - vScreenCenter: number; - eyeToScreenDistance: number; - lensSeparationDistance: number; - interpupillaryDistance: number; - distortionK: number[]; - chromaAbCorrection: number[]; - postProcessScaleFactor: number; - lensCenterOffset: number; - compensateDistortion: boolean; - readonly aspectRatio: number; - readonly aspectRatioFov: number; - readonly leftHMatrix: Matrix; - readonly rightHMatrix: Matrix; - readonly leftPreViewMatrix: Matrix; - readonly rightPreViewMatrix: Matrix; - static GetDefault(): VRCameraMetrics; - } -} - -declare module BABYLON { - class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera { - constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics); - getClassName(): string; - } - class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera { - constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics); - getClassName(): string; - } - class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera { - constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics); - getClassName(): string; - } -} - -declare var HMDVRDevice: any; -declare var VRDisplay: any; -declare var VRFrameData: any; -declare module BABYLON { - /** - * This is a copy of VRPose. - * IMPORTANT!! The data is right-hand data. - * @export - * @interface DevicePose - */ - interface DevicePose { - readonly position?: Float32Array; - readonly linearVelocity?: Float32Array; - readonly linearAcceleration?: Float32Array; - readonly orientation?: Float32Array; - readonly angularVelocity?: Float32Array; - readonly angularAcceleration?: Float32Array; - } - interface PoseControlled { - position: Vector3; - rotationQuaternion: Quaternion; - devicePosition?: Vector3; - deviceRotationQuaternion: Quaternion; - rawPose: DevicePose; - deviceScaleFactor: number; - updateFromDevice(poseData: DevicePose): any; - } - interface WebVROptions { - trackPosition?: boolean; - positionScale?: number; - displayName?: string; - controllerMeshes?: boolean; - defaultLightningOnControllers?: boolean; - } - class WebVRFreeCamera extends FreeCamera implements PoseControlled { - private webVROptions; - _vrDevice: any; - rawPose: DevicePose; - private _vrEnabled; - private _specsVersion; - private _attached; - private _oldSize; - private _oldHardwareScaleFactor; - private _frameData; - private _quaternionCache; - private _positionOffset; - protected _descendants: Array; - devicePosition: Vector3; - deviceRotationQuaternion: any; - deviceScaleFactor: number; - controllers: Array; - nonVRControllers: Array; - private _onControllersAttached; - private _onNonVRControllerAttached; - rigParenting: boolean; - private _lightOnControllers; - constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions); - onControllersAttached: (controllers: Array) => void; - onNonVRControllerAttached: (controller: Gamepad) => void; - getControllerByName(name: string): WebVRController; - private _leftController; - readonly leftController: WebVRController; - private _rightController; - readonly rightController: WebVRController; - getForwardRay(length?: number): Ray; - _checkInputs(): void; - updateFromDevice(poseData: DevicePose): void; + } + /** + * Use this className as a decorator on a given class definition to add it a name and optionally its module. + * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name. + * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified + * @param name The name of the class, case should be preserved + * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved. + */ + function className(name: string, module?: string): (target: Object) => void; + /** + * An implementation of a loop for asynchronous functions. + */ + class AsyncLoop { + iterations: number; + private _fn; + private _successCallback; + index: number; + private _done; /** - * WebVR's attach control will start broadcasting frames to the device. - * Note that in certain browsers (chrome for example) this function must be called - * within a user-interaction callback. Example: - *
 scene.onPointerDown = function() { camera.attachControl(canvas); }
- * - * @param {HTMLElement} element - * @param {boolean} [noPreventDefault] - * - * @memberOf WebVRFreeCamera + * Constroctor. + * @param iterations the number of iterations. + * @param _fn the function to run each iteration + * @param _successCallback the callback that will be called upon succesful execution + * @param offset starting offset. */ - attachControl(element: HTMLElement, noPreventDefault?: boolean): void; - detachControl(element: HTMLElement): void; - getClassName(): string; - resetToCurrentRotation(): void; - _updateRigCameras(): void; + constructor(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number); /** - * This function is called by the two RIG cameras. - * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance) + * Execute the next iteration. Must be called after the last iteration was finished. */ - protected _getWebVRViewMatrix(): Matrix; - protected _getWebVRProjectionMatrix(): Matrix; - initControllers(): void; + executeNext(): void; + /** + * Break the loop and run the success callback. + */ + breakLoop(): void; + /** + * Helper function + */ + static Run(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number): AsyncLoop; + /** + * A for-loop that will run a given number of iterations synchronous and the rest async. + * @param iterations total number of iterations + * @param syncedIterations number of synchronous iterations in each async iteration. + * @param fn the function to call each iteration. + * @param callback a success call back that will be called when iterating stops. + * @param breakFunction a break condition (optional) + * @param timeout timeout settings for the setTimeout function. default - 0. + * @constructor + */ + static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): void; + } +} + +declare module BABYLON { + enum JoystickAxis { + X = 0, + Y = 1, + Z = 2, + } + class VirtualJoystick { + reverseLeftRight: boolean; + reverseUpDown: boolean; + deltaPosition: Vector3; + pressed: boolean; + private static _globalJoystickIndex; + private static vjCanvas; + private static vjCanvasContext; + private static vjCanvasWidth; + private static vjCanvasHeight; + private static halfWidth; + private static halfHeight; + private _action; + private _axisTargetedByLeftAndRight; + private _axisTargetedByUpAndDown; + private _joystickSensibility; + private _inversedSensibility; + private _rotationSpeed; + private _inverseRotationSpeed; + private _rotateOnAxisRelativeToMesh; + private _joystickPointerID; + private _joystickColor; + private _joystickPointerPos; + private _joystickPreviousPointerPos; + private _joystickPointerStartPos; + private _deltaJoystickVector; + private _leftJoystick; + private _joystickIndex; + private _touches; + private _onPointerDownHandlerRef; + private _onPointerMoveHandlerRef; + private _onPointerUpHandlerRef; + private _onPointerOutHandlerRef; + private _onResize; + constructor(leftJoystick?: boolean); + setJoystickSensibility(newJoystickSensibility: number): void; + private _onPointerDown(e); + private _onPointerMove(e); + private _onPointerUp(e); + /** + * Change the color of the virtual joystick + * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000") + */ + setJoystickColor(newColor: string): void; + setActionOnTouch(action: () => any): void; + setAxisForLeftRight(axis: JoystickAxis): void; + setAxisForUpDown(axis: JoystickAxis): void; + private _clearCanvas(); + private _drawVirtualJoystick(); + releaseCanvas(): void; } } @@ -15923,6 +15790,139 @@ declare module BABYLON { } } +declare module BABYLON { + class VRCameraMetrics { + hResolution: number; + vResolution: number; + hScreenSize: number; + vScreenSize: number; + vScreenCenter: number; + eyeToScreenDistance: number; + lensSeparationDistance: number; + interpupillaryDistance: number; + distortionK: number[]; + chromaAbCorrection: number[]; + postProcessScaleFactor: number; + lensCenterOffset: number; + compensateDistortion: boolean; + readonly aspectRatio: number; + readonly aspectRatioFov: number; + readonly leftHMatrix: Matrix; + readonly rightHMatrix: Matrix; + readonly leftPreViewMatrix: Matrix; + readonly rightPreViewMatrix: Matrix; + static GetDefault(): VRCameraMetrics; + } +} + +declare module BABYLON { + class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera { + constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics); + getClassName(): string; + } + class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera { + constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics); + getClassName(): string; + } + class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera { + constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics); + getClassName(): string; + } +} + +declare var HMDVRDevice: any; +declare var VRDisplay: any; +declare var VRFrameData: any; +declare module BABYLON { + /** + * This is a copy of VRPose. + * IMPORTANT!! The data is right-hand data. + * @export + * @interface DevicePose + */ + interface DevicePose { + readonly position?: Float32Array; + readonly linearVelocity?: Float32Array; + readonly linearAcceleration?: Float32Array; + readonly orientation?: Float32Array; + readonly angularVelocity?: Float32Array; + readonly angularAcceleration?: Float32Array; + } + interface PoseControlled { + position: Vector3; + rotationQuaternion: Quaternion; + devicePosition?: Vector3; + deviceRotationQuaternion: Quaternion; + rawPose: DevicePose; + deviceScaleFactor: number; + updateFromDevice(poseData: DevicePose): any; + } + interface WebVROptions { + trackPosition?: boolean; + positionScale?: number; + displayName?: string; + controllerMeshes?: boolean; + defaultLightningOnControllers?: boolean; + } + class WebVRFreeCamera extends FreeCamera implements PoseControlled { + private webVROptions; + _vrDevice: any; + rawPose: DevicePose; + private _vrEnabled; + private _specsVersion; + private _attached; + private _oldSize; + private _oldHardwareScaleFactor; + private _frameData; + private _quaternionCache; + private _positionOffset; + protected _descendants: Array; + devicePosition: Vector3; + deviceRotationQuaternion: any; + deviceScaleFactor: number; + controllers: Array; + nonVRControllers: Array; + private _onControllersAttached; + private _onNonVRControllerAttached; + rigParenting: boolean; + private _lightOnControllers; + constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions); + onControllersAttached: (controllers: Array) => void; + onNonVRControllerAttached: (controller: Gamepad) => void; + getControllerByName(name: string): WebVRController; + private _leftController; + readonly leftController: WebVRController; + private _rightController; + readonly rightController: WebVRController; + getForwardRay(length?: number): Ray; + _checkInputs(): void; + updateFromDevice(poseData: DevicePose): void; + /** + * WebVR's attach control will start broadcasting frames to the device. + * Note that in certain browsers (chrome for example) this function must be called + * within a user-interaction callback. Example: + *
 scene.onPointerDown = function() { camera.attachControl(canvas); }
+ * + * @param {HTMLElement} element + * @param {boolean} [noPreventDefault] + * + * @memberOf WebVRFreeCamera + */ + attachControl(element: HTMLElement, noPreventDefault?: boolean): void; + detachControl(element: HTMLElement): void; + getClassName(): string; + resetToCurrentRotation(): void; + _updateRigCameras(): void; + /** + * This function is called by the two RIG cameras. + * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance) + */ + protected _getWebVRViewMatrix(): Matrix; + protected _getWebVRProjectionMatrix(): Matrix; + initControllers(): void; + } +} + declare module BABYLON { interface IOctreeContainer { blocks: Array>; @@ -17509,6 +17509,7 @@ declare module BABYLON { private _cachedUAng; private _cachedVAng; private _cachedWAng; + private _cachedProjectionMatrixId; private _cachedCoordinatesMode; _samplingMode: number; private _buffer; diff --git a/dist/preview release/gui/babylon.gui.d.ts b/dist/preview release/gui/babylon.gui.d.ts index 0c4dc427d6c..e1af9a16599 100644 --- a/dist/preview release/gui/babylon.gui.d.ts +++ b/dist/preview release/gui/babylon.gui.d.ts @@ -25,6 +25,7 @@ declare module BABYLON.GUI { idealHeight: number; renderAtIdealSize: boolean; readonly layer: Layer; + readonly rootContainer: Container; constructor(name: string, width: number, height: number, scene: Scene, generateMipMaps?: boolean, samplingMode?: number); executeOnAllControls(func: (control: Control) => void, container?: Container): void; markAsDirty(): void; diff --git a/dist/preview release/gui/babylon.gui.js b/dist/preview release/gui/babylon.gui.js index 944fa6767a2..93c49240767 100644 --- a/dist/preview release/gui/babylon.gui.js +++ b/dist/preview release/gui/babylon.gui.js @@ -104,6 +104,13 @@ var BABYLON; enumerable: true, configurable: true }); + Object.defineProperty(AdvancedDynamicTexture.prototype, "rootContainer", { + get: function () { + return this._rootContainer; + }, + enumerable: true, + configurable: true + }); AdvancedDynamicTexture.prototype.executeOnAllControls = function (func, container) { if (!container) { container = this._rootContainer; diff --git a/dist/preview release/gui/babylon.gui.min.js b/dist/preview release/gui/babylon.gui.min.js index 17ebf3cd29e..63769e2dc82 100644 --- a/dist/preview release/gui/babylon.gui.min.js +++ b/dist/preview release/gui/babylon.gui.min.js @@ -1,3 +1,3 @@ -var BABYLON;!(function(t){!(function(e){var i=(function(i){function r(r,n,s,o,h,a){void 0===n&&(n=0),void 0===s&&(s=0),void 0===h&&(h=!1),void 0===a&&(a=t.Texture.NEAREST_SAMPLINGMODE);var u=i.call(this,r,{width:n,height:s},o,h,a,t.Engine.TEXTUREFORMAT_RGBA)||this;return u._isDirty=!1,u._rootContainer=new e.Container("root"),u._linkedControls=new Array,u._isFullscreen=!1,u._fullscreenViewport=new t.Viewport(0,0,1,1),u._idealWidth=0,u._idealHeight=0,u._renderAtIdealSize=!1,u._renderObserver=u.getScene().onBeforeCameraRenderObservable.add((function(t){return u._checkUpdate(t)})),u._rootContainer._link(null,u),u.hasAlpha=!0,n&&s||(u._resizeObserver=u.getScene().getEngine().onResizeObservable.add((function(){return u._onResize()})),u._onResize()),u._texture.isReady=!0,u}return __extends(r,i),Object.defineProperty(r.prototype,"background",{get:function(){return this._background},set:function(t){this._background!==t&&(this._background=t,this.markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"idealWidth",{get:function(){return this._idealWidth},set:function(t){this._idealWidth!==t&&(this._idealWidth=t,this.markAsDirty(),this._rootContainer._markAllAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"idealHeight",{get:function(){return this._idealHeight},set:function(t){this._idealHeight!==t&&(this._idealHeight=t,this.markAsDirty(),this._rootContainer._markAllAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"renderAtIdealSize",{get:function(){return this._renderAtIdealSize},set:function(t){this._renderAtIdealSize!==t&&(this._renderAtIdealSize=t,this._onResize())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"layer",{get:function(){return this._layerToDispose},enumerable:!0,configurable:!0}),r.prototype.executeOnAllControls=function(t,e){e||(e=this._rootContainer);for(var i=0,r=e.children;i1?o.notRenderable=!0:(o.notRenderable=!1,o._moveToProjectedPosition(u))}}}(this._isDirty||this._rootContainer.isDirty)&&(this._isDirty=!1,this._render(),this.update())}},r.prototype._render=function(){var t=(this.getScene().getEngine(),this.getSize()),i=t.width,r=t.height,n=this.getContext();n.clearRect(0,0,i,r),this._background&&(n.save(),n.fillStyle=this._background,n.fillRect(0,0,i,r),n.restore()),n.font="18px Arial";var s=new e.Measure(0,0,i,r);this._rootContainer._draw(s,n)},r.prototype._doPicking=function(e,i,r){var n=this.getScene().getEngine(),s=this.getSize();if(this._isFullscreen&&(e*=s.width/n.getRenderWidth(),i*=s.height/n.getRenderHeight()),this._capturingControl)return void this._capturingControl._processObservables(r,e,i);this._rootContainer._processPicking(e,i,r)||r===t.PointerEventTypes.POINTERMOVE&&(this._lastControlOver&&this._lastControlOver._onPointerOut(),this._lastControlOver=null)},r.prototype.attach=function(){var e=this,i=this.getScene();this._pointerMoveObserver=i.onPrePointerObservable.add((function(r,n){r.type!==t.PointerEventTypes.POINTERMOVE&&r.type!==t.PointerEventTypes.POINTERUP&&r.type!==t.PointerEventTypes.POINTERDOWN||(e._shouldBlockPointer=!1,e._doPicking(i.pointerX,i.pointerY,r.type),r.skipOnPointerObservable=e._shouldBlockPointer&&r.type!==t.PointerEventTypes.POINTERUP)})),this._attachToOnBlur(i)},r.prototype.attachToMesh=function(e,i){var r=this;void 0===i&&(i=!0);var n=this.getScene();this._pointerObserver=n.onPointerObservable.add((function(i,n){if(i.type===t.PointerEventTypes.POINTERMOVE||i.type===t.PointerEventTypes.POINTERUP||i.type===t.PointerEventTypes.POINTERDOWN)if(i.pickInfo.hit&&i.pickInfo.pickedMesh===e){var s=i.pickInfo.getTextureCoordinates(),o=r.getSize();r._doPicking(s.x*o.width,(1-s.y)*o.height,i.type)}else i.type===t.PointerEventTypes.POINTERUP?(r._lastControlDown&&r._lastControlDown.forcePointerUp(),r._lastControlDown=null):i.type===t.PointerEventTypes.POINTERMOVE&&(r._lastControlOver&&r._lastControlOver._onPointerOut(),r._lastControlOver=null)})),e.enablePointerMoveEvents=i,this._attachToOnBlur(n)},r.prototype._attachToOnBlur=function(t){var e=this;this._canvasBlurObserver=t.getEngine().onCanvasBlurObservable.add((function(){e._lastControlOver&&e._lastControlOver._onPointerOut(),e._lastControlOver=null,e._lastControlDown&&e._lastControlDown.forcePointerUp(),e._lastControlDown=null}))},r.CreateForMesh=function(e,i,n,s){void 0===i&&(i=1024),void 0===n&&(n=1024),void 0===s&&(s=!0);var o=new r(e.name+" AdvancedDynamicTexture",i,n,e.getScene(),!0,t.Texture.TRILINEAR_SAMPLINGMODE),h=new t.StandardMaterial("AdvancedDynamicTextureMaterial",e.getScene());return h.backFaceCulling=!1,h.diffuseColor=t.Color3.Black(),h.specularColor=t.Color3.Black(),h.emissiveTexture=o,h.opacityTexture=o,e.material=h,o.attachToMesh(e,s),o},r.CreateFullscreenUI=function(e,i,n){void 0===i&&(i=!0),void 0===n&&(n=null);var s=new r(e,0,0,n),o=new t.Layer(e+"_layer",null,n,!i);return o.texture=s,s._layerToDispose=o,s._isFullscreen=!0,s.attach(),s},r})(t.DynamicTexture);e.AdvancedDynamicTexture=i})(t.GUI||(t.GUI={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(t){!(function(t){var e=(function(){function t(t,e,i,r){this.left=t,this.top=e,this.width=i,this.height=r}return t.prototype.copyFrom=function(t){this.left=t.left,this.top=t.top,this.width=t.width,this.height=t.height},t.prototype.isEqualsTo=function(t){return this.left===t.left&&(this.top===t.top&&(this.width===t.width&&this.height===t.height))},t.Empty=function(){return new t(0,0,0,0)},t})();t.Measure=e})(t.GUI||(t.GUI={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(t){!(function(e){var i=(function(){function e(t,e,i,r,n,s){this.m=new Float32Array(6),this.fromValues(t,e,i,r,n,s)}return e.prototype.fromValues=function(t,e,i,r,n,s){return this.m[0]=t,this.m[1]=e,this.m[2]=i,this.m[3]=r,this.m[4]=n,this.m[5]=s,this},e.prototype.determinant=function(){return this.m[0]*this.m[3]-this.m[1]*this.m[2]},e.prototype.invertToRef=function(e){var i=this.m[0],r=this.m[1],n=this.m[2],s=this.m[3],o=this.m[4],h=this.m[5],a=this.determinant();if(a1)return void(this.notRenderable=!0);this.notRenderable=!1},i.prototype.linkWithMesh=function(e){if(!this._host||this._root!==this._host._rootContainer)return void t.Tools.Error("Cannot link a control to a mesh if the control is not at root level");var i=this._host._linkedControls.indexOf(this);if(-1!==i)return this._linkedMesh=e,void(e||this._host._linkedControls.splice(i,1));this.horizontalAlignment=t.GUI.Control.HORIZONTAL_ALIGNMENT_LEFT,this.verticalAlignment=t.GUI.Control.VERTICAL_ALIGNMENT_TOP,this._linkedMesh=e,this._host._linkedControls.push(this)},i.prototype._moveToProjectedPosition=function(t){this.left=t.x+this._linkOffsetX.getValue(this._host)-this._currentMeasure.width/2+"px",this.top=t.y+this._linkOffsetY.getValue(this._host)-this._currentMeasure.height/2+"px",this._left.ignoreAdaptiveScaling=!0,this._top.ignoreAdaptiveScaling=!0},i.prototype._markMatrixAsDirty=function(){this._isMatrixDirty=!0,this._markAsDirty()},i.prototype._markAsDirty=function(){this._isDirty=!0,this._host&&this._host.markAsDirty()},i.prototype._markAllAsDirty=function(){this._markAsDirty(),this._font&&this._prepareFont()},i.prototype._link=function(t,e){this._root=t,this._host=e},i.prototype._transform=function(t){if(this._isMatrixDirty||1!==this._scaleX||1!==this._scaleY||0!==this._rotation){var i=this._currentMeasure.width*this._transformCenterX+this._currentMeasure.left,r=this._currentMeasure.height*this._transformCenterY+this._currentMeasure.top;t.translate(i,r),t.rotate(this._rotation),t.scale(this._scaleX,this._scaleY),t.translate(-i,-r),(this._isMatrixDirty||this._cachedOffsetX!==i||this._cachedOffsetY!==r)&&(this._cachedOffsetX=i,this._cachedOffsetY=r,this._isMatrixDirty=!1,e.Matrix2D.ComposeToRef(-i,-r,this._rotation,this._scaleX,this._scaleY,this._root?this._root._transformMatrix:null,this._transformMatrix),this._transformMatrix.invertToRef(this._invertTransformMatrix))}},i.prototype._applyStates=function(t){this._fontSet&&(this._prepareFont(),this._fontSet=!1),this._font&&(t.font=this._font),this._color&&(t.fillStyle=this._color),this._alphaSet&&(t.globalAlpha=this._alpha)},i.prototype._processMeasures=function(t,e){return!this._isDirty&&this._cachedParentMeasure.isEqualsTo(t)||(this._isDirty=!1,this._currentMeasure.copyFrom(t),this._preMeasure(t,e),this._measure(),this._computeAlignment(t,e),this._currentMeasure.left=0|this._currentMeasure.left,this._currentMeasure.top=0|this._currentMeasure.top,this._currentMeasure.width=0|this._currentMeasure.width,this._currentMeasure.height=0|this._currentMeasure.height,this._additionalProcessing(t,e),this._cachedParentMeasure.copyFrom(t),this.onDirtyObservable.hasObservers()&&this.onDirtyObservable.notifyObservers(this)),!(this._currentMeasure.left>t.left+t.width)&&(!(this._currentMeasure.left+this._currentMeasure.widtht.top+t.height)&&(!(this._currentMeasure.top+this._currentMeasure.heightthis._currentMeasure.left+this._currentMeasure.width)&&(!(ethis._currentMeasure.top+this._currentMeasure.height)&&(this.isPointerBlocker&&(this._host._shouldBlockPointer=!0),!0))))},i.prototype._processPicking=function(t,e,i){return!(!this.isHitTestVisible||!this.isVisible||this._doNotRender)&&(!!this.contains(t,e)&&(this._processObservables(i,t,e),!0))},i.prototype._onPointerMove=function(t){this.onPointerMoveObservable.hasObservers()&&this.onPointerMoveObservable.notifyObservers(t)},i.prototype._onPointerEnter=function(){return 0===this._enterCount&&(this._enterCount++,this.onPointerEnterObservable.hasObservers()&&this.onPointerEnterObservable.notifyObservers(this),!0)},i.prototype._onPointerOut=function(){this._enterCount=0,this.onPointerOutObservable.hasObservers()&&this.onPointerOutObservable.notifyObservers(this)},i.prototype._onPointerDown=function(t){return 0===this._downCount&&(this._downCount++,this.onPointerDownObservable.hasObservers()&&this.onPointerDownObservable.notifyObservers(t),!0)},i.prototype._onPointerUp=function(t){this._downCount=0,this.onPointerUpObservable.hasObservers()&&this.onPointerUpObservable.notifyObservers(t)},i.prototype.forcePointerUp=function(){this._onPointerUp(t.Vector2.Zero())},i.prototype._processObservables=function(e,i,r){if(this._dummyVector2.copyFromFloats(i,r),e===t.PointerEventTypes.POINTERMOVE){this._onPointerMove(this._dummyVector2);var n=this._host._lastControlOver;return n&&n!==this&&n._onPointerOut(),n!==this&&this._onPointerEnter(),this._host._lastControlOver=this,!0}return e===t.PointerEventTypes.POINTERDOWN?(this._onPointerDown(this._dummyVector2),this._host._lastControlDown=this,!0):e===t.PointerEventTypes.POINTERUP&&(this._host._lastControlDown&&this._host._lastControlDown._onPointerUp(this._dummyVector2),this._host._lastControlDown=null,!0)},i.prototype._prepareFont=function(){(this._font||this._fontSet)&&(this._font=this._fontSize.getValue(this._host)+"px "+this._fontFamily,this._fontOffset=i._GetFontOffset(this._font))},Object.defineProperty(i,"HORIZONTAL_ALIGNMENT_LEFT",{get:function(){return i._HORIZONTAL_ALIGNMENT_LEFT},enumerable:!0,configurable:!0}),Object.defineProperty(i,"HORIZONTAL_ALIGNMENT_RIGHT",{get:function(){return i._HORIZONTAL_ALIGNMENT_RIGHT},enumerable:!0,configurable:!0}),Object.defineProperty(i,"HORIZONTAL_ALIGNMENT_CENTER",{get:function(){return i._HORIZONTAL_ALIGNMENT_CENTER},enumerable:!0,configurable:!0}),Object.defineProperty(i,"VERTICAL_ALIGNMENT_TOP",{get:function(){return i._VERTICAL_ALIGNMENT_TOP},enumerable:!0,configurable:!0}),Object.defineProperty(i,"VERTICAL_ALIGNMENT_BOTTOM",{get:function(){return i._VERTICAL_ALIGNMENT_BOTTOM},enumerable:!0,configurable:!0}),Object.defineProperty(i,"VERTICAL_ALIGNMENT_CENTER",{get:function(){return i._VERTICAL_ALIGNMENT_CENTER},enumerable:!0,configurable:!0}),i._GetFontOffset=function(t){if(i._FontHeightSizes[t])return i._FontHeightSizes[t];var e=document.createElement("span");e.innerHTML="Hg",e.style.font=t;var r=document.createElement("div");r.style.display="inline-block",r.style.width="1px",r.style.height="0px",r.style.verticalAlign="bottom";var n=document.createElement("div");n.appendChild(e),n.appendChild(r),document.body.appendChild(n);var s=0,o=0;try{o=r.getBoundingClientRect().top-e.getBoundingClientRect().top,r.style.verticalAlign="baseline",s=r.getBoundingClientRect().top-e.getBoundingClientRect().top}finally{document.body.removeChild(n)}var h={ascent:s,height:o,descent:o-s};return i._FontHeightSizes[t]=h,h},i.AddHeader=function(e,r,n,s){var o=new t.GUI.StackPanel("panel"),h=!s||s.isHorizontal,a=!s||s.controlFirst;o.isVertical=!h;var u=new t.GUI.TextBlock("header");return u.text=r,u.textHorizontalAlignment=i.HORIZONTAL_ALIGNMENT_LEFT,h?u.width=n:u.height=n,a?(o.addControl(e),o.addControl(u),u.paddingLeft="5px"):(o.addControl(u),o.addControl(e),u.paddingRight="5px"),o},i.drawEllipse=function(t,e,i,r,n){n.translate(t,e),n.scale(i,r),n.beginPath(),n.arc(0,0,1,0,2*Math.PI),n.closePath(),n.scale(1/i,1/r),n.translate(-t,-e)},i})();i._HORIZONTAL_ALIGNMENT_LEFT=0,i._HORIZONTAL_ALIGNMENT_RIGHT=1,i._HORIZONTAL_ALIGNMENT_CENTER=2,i._VERTICAL_ALIGNMENT_TOP=0,i._VERTICAL_ALIGNMENT_BOTTOM=1,i._VERTICAL_ALIGNMENT_CENTER=2,i._FontHeightSizes={},e.Control=i})(t.GUI||(t.GUI={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(t){!(function(t){var e=(function(e){function i(i){var r=e.call(this,i)||this;return r.name=i,r._children=new Array,r._measureForChildren=t.Measure.Empty(),r}return __extends(i,e),Object.defineProperty(i.prototype,"background",{get:function(){return this._background},set:function(t){this._background!==t&&(this._background=t,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"children",{get:function(){return this._children},enumerable:!0,configurable:!0}),i.prototype._getTypeName=function(){return"Container"},i.prototype.getChildByName=function(t){for(var e=0,i=this._children;et.zIndex)return void this._children.splice(e,0,t);this._children.push(t),this._markAsDirty()},i.prototype._markMatrixAsDirty=function(){e.prototype._markMatrixAsDirty.call(this);for(var t=0;t=0;n--){if(this._children[n]._processPicking(t,i,r))return!0}return this._processObservables(r,t,i)},i.prototype._clipForChildren=function(t){},i.prototype._additionalProcessing=function(t,i){e.prototype._additionalProcessing.call(this,t,i),this._measureForChildren.copyFrom(this._currentMeasure)},i})(t.Control);t.Container=e})(t.GUI||(t.GUI={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(t){!(function(e){var i=(function(i){function r(t){var r=i.call(this,t)||this;return r.name=t,r._isVertical=!0,r._tempMeasureStore=e.Measure.Empty(),r}return __extends(r,i),Object.defineProperty(r.prototype,"isVertical",{get:function(){return this._isVertical},set:function(t){this._isVertical!==t&&(this._isVertical=t,this._markAsDirty())},enumerable:!0,configurable:!0}),r.prototype._getTypeName=function(){return"StackPanel"},r.prototype._preMeasure=function(e,r){for(var n=0,s=0,o=this._children;s0?t+" "+i[s]:i[0],h=e.measureText(o),a=h.width;a>r&&s>0?(this._lines.push({text:t,width:n}),t=i[s],n=e.measureText(t).width):(n=a,t=o)}return{text:t,width:n}},i.prototype._renderLines=function(e){var i=(this._currentMeasure.width,this._currentMeasure.height);this._fontOffset||(this._fontOffset=t.Control._GetFontOffset(e.font));var r=0;switch(this._textVerticalAlignment){case t.Control.VERTICAL_ALIGNMENT_TOP:r=this._fontOffset.ascent;break;case t.Control.VERTICAL_ALIGNMENT_BOTTOM:r=i-this._fontOffset.height*(this._lines.length-1)-this._fontOffset.descent;break;case t.Control.VERTICAL_ALIGNMENT_CENTER:r=this._fontOffset.ascent+(i-this._fontOffset.height*this._lines.length)/2}r+=this._currentMeasure.top;for(var n=0,s=this._lines;nh||l150?.04:-.16*(t-50)/100+.2;var g=(p-a)/(t-a);s[d+3]=g1-m?255*(1-(g-(1-m))/m):255}}return r.putImageData(n,0,0),i},i.prototype._RGBtoHSV=function(t,e){var i=t.r,r=t.g,n=t.b,s=Math.max(i,r,n),o=Math.min(i,r,n),h=0,a=0,u=s,_=s-o;0!==s&&(a=_/s),s!=o&&(s==i?(h=(r-n)/_,r=0&&s<=1?(h=n,a=o):s>=1&&s<=2?(h=o,a=n):s>=2&&s<=3?(a=n,u=o):s>=3&&s<=4?(a=o,u=n):s>=4&&s<=5?(h=o,u=n):s>=5&&s<=6&&(h=n,u=o);var _=i-n;r.set(h+_,a+_,u+_)},i.prototype._draw=function(t,e){if(e.save(),this._applyStates(e),this._processMeasures(t,e)){var i=.5*Math.min(this._currentMeasure.width,this._currentMeasure.height),r=.2*i,n=this._currentMeasure.left,s=this._currentMeasure.top;this._colorWheelCanvas&&this._colorWheelCanvas.width==2*i||(this._colorWheelCanvas=this._createColorWheelCanvas(i,r)),e.drawImage(this._colorWheelCanvas,n,s),this._updateSquareProps(),this._drawGradientSquare(this._h,this._squareLeft,this._squareTop,this._squareSize,this._squareSize,e);var o=this._squareLeft+this._squareSize*this._s,h=this._squareTop+this._squareSize*(1-this._v);this._drawCircle(o,h,.04*i,e);var a=i-.5*r;o=n+i+Math.cos((this._h-180)*Math.PI/180)*a,h=s+i+Math.sin((this._h-180)*Math.PI/180)*a,this._drawCircle(o,h,.35*r,e)}e.restore()},i.prototype._updateValueFromPointer=function(t,e){if(this._pointerStartedOnWheel){var i=.5*Math.min(this._currentMeasure.width,this._currentMeasure.height),r=i+this._currentMeasure.left,n=i+this._currentMeasure.top;this._h=180*Math.atan2(e-n,t-r)/Math.PI+180 -}else this._pointerStartedOnSquare&&(this._updateSquareProps(),this._s=(t-this._squareLeft)/this._squareSize,this._v=1-(e-this._squareTop)/this._squareSize,this._s=Math.min(this._s,1),this._s=Math.max(this._s,1e-5),this._v=Math.min(this._v,1),this._v=Math.max(this._v,1e-5));this._HSVtoRGB(this._h,this._s,this._v,this._tmpColor),this.value=this._tmpColor},i.prototype._isPointOnSquare=function(t){this._updateSquareProps();var e=this._squareLeft,i=this._squareTop,r=this._squareSize;return t.x>=e&&t.x<=e+r&&t.y>=i&&t.y<=i+r},i.prototype._isPointOnWheel=function(t){var e=.5*Math.min(this._currentMeasure.width,this._currentMeasure.height),i=e+this._currentMeasure.left,r=e+this._currentMeasure.top,n=.2*e,s=e-n,o=e*e,h=s*s,a=t.x-i,u=t.y-r,_=a*a+u*u;return _<=o&&_>=h},i.prototype._onPointerDown=function(t){return!!e.prototype._onPointerDown.call(this,t)&&(this._pointerIsDown=!0,this._pointerStartedOnSquare=!1,this._pointerStartedOnWheel=!1,this._isPointOnSquare(t)?this._pointerStartedOnSquare=!0:this._isPointOnWheel(t)&&(this._pointerStartedOnWheel=!0),this._updateValueFromPointer(t.x,t.y),this._host._capturingControl=this,!0)},i.prototype._onPointerMove=function(t){this._pointerIsDown&&this._updateValueFromPointer(t.x,t.y),e.prototype._onPointerMove.call(this,t)},i.prototype._onPointerUp=function(t){this._pointerIsDown=!1,this._host._capturingControl=null,e.prototype._onPointerUp.call(this,t)},i})(e.Control);e.ColorPicker=i})(t.GUI||(t.GUI={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(t){!(function(t){var e=(function(e){function i(i,r){void 0===r&&(r="");var n=e.call(this,i)||this;return n.name=i,n._text="",n._background="black",n._thickness=1,n._margin=new t.ValueAndUnit(10,t.ValueAndUnit.UNITMODE_PIXEL),n._autoStretchWidth=!0,n._maxWidth=new t.ValueAndUnit(1,t.ValueAndUnit.UNITMODE_PERCENTAGE,!1),n.text=r,n}return __extends(i,e),Object.defineProperty(i.prototype,"maxWidth",{get:function(){return this._maxWidth.toString(this._host)},set:function(t){this._maxWidth.toString(this._host)!==t&&this._maxWidth.fromString(t)&&this._markAsDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"margin",{get:function(){return this._margin.toString(this._host)},set:function(t){this._margin.toString(this._host)!==t&&this._margin.fromString(t)&&this._markAsDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"autoStretchWidth",{get:function(){return this._autoStretchWidth},set:function(t){this._autoStretchWidth!==t&&(this._autoStretchWidth=t,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"thickness",{get:function(){return this._thickness},set:function(t){this._thickness!==t&&(this._thickness=t,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"background",{get:function(){return this._background},set:function(t){this._background!==t&&(this._background=t,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"text",{get:function(){return this._text},set:function(t){this._text!==t&&(this._text=t,this._markAsDirty())},enumerable:!0,configurable:!0}),i.prototype._getTypeName=function(){return"InputText"},i.prototype._draw=function(t,e){if(e.save(),this._applyStates(e),this._processMeasures(t,e)){if(this._background&&(e.fillStyle=this._background,e.fillRect(this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height)),this._text){this.color&&(e.fillStyle=this.color);var i=this._fontOffset.ascent+(this._currentMeasure.height-this._fontOffset.height)/2;e.fillText(this._text,this._currentMeasure.left+this._margin.getValueInPixel(this._host,t.width),this._currentMeasure.top+i),this._autoStretchWidth&&(this.width=Math.min(this._maxWidth.getValueInPixel(this._host,t.width),e.measureText(this._text).width+2*this._margin.getValueInPixel(this._host,t.width))+"px")}this._thickness&&(this.color&&(e.strokeStyle=this.color),e.lineWidth=this._thickness,e.strokeRect(this._currentMeasure.left+this._thickness/2,this._currentMeasure.top+this._thickness/2,this._currentMeasure.width-this._thickness,this._currentMeasure.height-this._thickness))}e.restore()},i})(t.Control);t.InputText=e})(t.GUI||(t.GUI={}))})(BABYLON||(BABYLON={})); \ No newline at end of file +var BABYLON;!(function(t){!(function(e){var i=(function(i){function r(r,n,o,s,h,a){void 0===n&&(n=0),void 0===o&&(o=0),void 0===h&&(h=!1),void 0===a&&(a=t.Texture.NEAREST_SAMPLINGMODE);var u=i.call(this,r,{width:n,height:o},s,h,a,t.Engine.TEXTUREFORMAT_RGBA)||this;return u._isDirty=!1,u._rootContainer=new e.Container("root"),u._linkedControls=new Array,u._isFullscreen=!1,u._fullscreenViewport=new t.Viewport(0,0,1,1),u._idealWidth=0,u._idealHeight=0,u._renderAtIdealSize=!1,u._renderObserver=u.getScene().onBeforeCameraRenderObservable.add((function(t){return u._checkUpdate(t)})),u._rootContainer._link(null,u),u.hasAlpha=!0,n&&o||(u._resizeObserver=u.getScene().getEngine().onResizeObservable.add((function(){return u._onResize()})),u._onResize()),u._texture.isReady=!0,u}return __extends(r,i),Object.defineProperty(r.prototype,"background",{get:function(){return this._background},set:function(t){this._background!==t&&(this._background=t,this.markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"idealWidth",{get:function(){return this._idealWidth},set:function(t){this._idealWidth!==t&&(this._idealWidth=t,this.markAsDirty(),this._rootContainer._markAllAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"idealHeight",{get:function(){return this._idealHeight},set:function(t){this._idealHeight!==t&&(this._idealHeight=t,this.markAsDirty(),this._rootContainer._markAllAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"renderAtIdealSize",{get:function(){return this._renderAtIdealSize},set:function(t){this._renderAtIdealSize!==t&&(this._renderAtIdealSize=t,this._onResize())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"layer",{get:function(){return this._layerToDispose},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"rootContainer",{get:function(){return this._rootContainer},enumerable:!0,configurable:!0}),r.prototype.executeOnAllControls=function(t,e){e||(e=this._rootContainer);for(var i=0,r=e.children;i1?s.notRenderable=!0:(s.notRenderable=!1,s._moveToProjectedPosition(u))}}}(this._isDirty||this._rootContainer.isDirty)&&(this._isDirty=!1,this._render(),this.update())}},r.prototype._render=function(){var t=(this.getScene().getEngine(),this.getSize()),i=t.width,r=t.height,n=this.getContext();n.clearRect(0,0,i,r),this._background&&(n.save(),n.fillStyle=this._background,n.fillRect(0,0,i,r),n.restore()),n.font="18px Arial";var o=new e.Measure(0,0,i,r);this._rootContainer._draw(o,n)},r.prototype._doPicking=function(e,i,r){var n=this.getScene().getEngine(),o=this.getSize();if(this._isFullscreen&&(e*=o.width/n.getRenderWidth(),i*=o.height/n.getRenderHeight()),this._capturingControl)return void this._capturingControl._processObservables(r,e,i);this._rootContainer._processPicking(e,i,r)||r===t.PointerEventTypes.POINTERMOVE&&(this._lastControlOver&&this._lastControlOver._onPointerOut(),this._lastControlOver=null)},r.prototype.attach=function(){var e=this,i=this.getScene();this._pointerMoveObserver=i.onPrePointerObservable.add((function(r,n){r.type!==t.PointerEventTypes.POINTERMOVE&&r.type!==t.PointerEventTypes.POINTERUP&&r.type!==t.PointerEventTypes.POINTERDOWN||(e._shouldBlockPointer=!1,e._doPicking(i.pointerX,i.pointerY,r.type),r.skipOnPointerObservable=e._shouldBlockPointer&&r.type!==t.PointerEventTypes.POINTERUP)})),this._attachToOnBlur(i)},r.prototype.attachToMesh=function(e,i){var r=this;void 0===i&&(i=!0);var n=this.getScene();this._pointerObserver=n.onPointerObservable.add((function(i,n){if(i.type===t.PointerEventTypes.POINTERMOVE||i.type===t.PointerEventTypes.POINTERUP||i.type===t.PointerEventTypes.POINTERDOWN)if(i.pickInfo.hit&&i.pickInfo.pickedMesh===e){var o=i.pickInfo.getTextureCoordinates(),s=r.getSize();r._doPicking(o.x*s.width,(1-o.y)*s.height,i.type)}else i.type===t.PointerEventTypes.POINTERUP?(r._lastControlDown&&r._lastControlDown.forcePointerUp(),r._lastControlDown=null):i.type===t.PointerEventTypes.POINTERMOVE&&(r._lastControlOver&&r._lastControlOver._onPointerOut(),r._lastControlOver=null)})),e.enablePointerMoveEvents=i,this._attachToOnBlur(n)},r.prototype._attachToOnBlur=function(t){var e=this;this._canvasBlurObserver=t.getEngine().onCanvasBlurObservable.add((function(){e._lastControlOver&&e._lastControlOver._onPointerOut(),e._lastControlOver=null,e._lastControlDown&&e._lastControlDown.forcePointerUp(),e._lastControlDown=null}))},r.CreateForMesh=function(e,i,n,o){void 0===i&&(i=1024),void 0===n&&(n=1024),void 0===o&&(o=!0);var s=new r(e.name+" AdvancedDynamicTexture",i,n,e.getScene(),!0,t.Texture.TRILINEAR_SAMPLINGMODE),h=new t.StandardMaterial("AdvancedDynamicTextureMaterial",e.getScene());return h.backFaceCulling=!1,h.diffuseColor=t.Color3.Black(),h.specularColor=t.Color3.Black(),h.emissiveTexture=s,h.opacityTexture=s,e.material=h,s.attachToMesh(e,o),s},r.CreateFullscreenUI=function(e,i,n){void 0===i&&(i=!0),void 0===n&&(n=null);var o=new r(e,0,0,n),s=new t.Layer(e+"_layer",null,n,!i);return s.texture=o,o._layerToDispose=s,o._isFullscreen=!0,o.attach(),o},r})(t.DynamicTexture);e.AdvancedDynamicTexture=i})(t.GUI||(t.GUI={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(t){!(function(t){var e=(function(){function t(t,e,i,r){this.left=t,this.top=e,this.width=i,this.height=r}return t.prototype.copyFrom=function(t){this.left=t.left,this.top=t.top,this.width=t.width,this.height=t.height},t.prototype.isEqualsTo=function(t){return this.left===t.left&&(this.top===t.top&&(this.width===t.width&&this.height===t.height))},t.Empty=function(){return new t(0,0,0,0)},t})();t.Measure=e})(t.GUI||(t.GUI={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(t){!(function(e){var i=(function(){function e(t,e,i,r,n,o){this.m=new Float32Array(6),this.fromValues(t,e,i,r,n,o)}return e.prototype.fromValues=function(t,e,i,r,n,o){return this.m[0]=t,this.m[1]=e,this.m[2]=i,this.m[3]=r,this.m[4]=n,this.m[5]=o,this},e.prototype.determinant=function(){return this.m[0]*this.m[3]-this.m[1]*this.m[2]},e.prototype.invertToRef=function(e){var i=this.m[0],r=this.m[1],n=this.m[2],o=this.m[3],s=this.m[4],h=this.m[5],a=this.determinant();if(a1)return void(this.notRenderable=!0);this.notRenderable=!1},i.prototype.linkWithMesh=function(e){if(!this._host||this._root!==this._host._rootContainer)return void t.Tools.Error("Cannot link a control to a mesh if the control is not at root level");var i=this._host._linkedControls.indexOf(this);if(-1!==i)return this._linkedMesh=e,void(e||this._host._linkedControls.splice(i,1));this.horizontalAlignment=t.GUI.Control.HORIZONTAL_ALIGNMENT_LEFT,this.verticalAlignment=t.GUI.Control.VERTICAL_ALIGNMENT_TOP,this._linkedMesh=e,this._host._linkedControls.push(this)},i.prototype._moveToProjectedPosition=function(t){this.left=t.x+this._linkOffsetX.getValue(this._host)-this._currentMeasure.width/2+"px",this.top=t.y+this._linkOffsetY.getValue(this._host)-this._currentMeasure.height/2+"px",this._left.ignoreAdaptiveScaling=!0,this._top.ignoreAdaptiveScaling=!0},i.prototype._markMatrixAsDirty=function(){this._isMatrixDirty=!0,this._markAsDirty()},i.prototype._markAsDirty=function(){this._isDirty=!0,this._host&&this._host.markAsDirty()},i.prototype._markAllAsDirty=function(){this._markAsDirty(),this._font&&this._prepareFont()},i.prototype._link=function(t,e){this._root=t,this._host=e},i.prototype._transform=function(t){if(this._isMatrixDirty||1!==this._scaleX||1!==this._scaleY||0!==this._rotation){var i=this._currentMeasure.width*this._transformCenterX+this._currentMeasure.left,r=this._currentMeasure.height*this._transformCenterY+this._currentMeasure.top;t.translate(i,r),t.rotate(this._rotation),t.scale(this._scaleX,this._scaleY),t.translate(-i,-r),(this._isMatrixDirty||this._cachedOffsetX!==i||this._cachedOffsetY!==r)&&(this._cachedOffsetX=i,this._cachedOffsetY=r,this._isMatrixDirty=!1,e.Matrix2D.ComposeToRef(-i,-r,this._rotation,this._scaleX,this._scaleY,this._root?this._root._transformMatrix:null,this._transformMatrix),this._transformMatrix.invertToRef(this._invertTransformMatrix))}},i.prototype._applyStates=function(t){this._fontSet&&(this._prepareFont(),this._fontSet=!1),this._font&&(t.font=this._font),this._color&&(t.fillStyle=this._color),this._alphaSet&&(t.globalAlpha=this._alpha)},i.prototype._processMeasures=function(t,e){return!this._isDirty&&this._cachedParentMeasure.isEqualsTo(t)||(this._isDirty=!1,this._currentMeasure.copyFrom(t),this._preMeasure(t,e),this._measure(),this._computeAlignment(t,e),this._currentMeasure.left=0|this._currentMeasure.left,this._currentMeasure.top=0|this._currentMeasure.top,this._currentMeasure.width=0|this._currentMeasure.width,this._currentMeasure.height=0|this._currentMeasure.height,this._additionalProcessing(t,e),this._cachedParentMeasure.copyFrom(t),this.onDirtyObservable.hasObservers()&&this.onDirtyObservable.notifyObservers(this)),!(this._currentMeasure.left>t.left+t.width)&&(!(this._currentMeasure.left+this._currentMeasure.widtht.top+t.height)&&(!(this._currentMeasure.top+this._currentMeasure.heightthis._currentMeasure.left+this._currentMeasure.width)&&(!(ethis._currentMeasure.top+this._currentMeasure.height)&&(this.isPointerBlocker&&(this._host._shouldBlockPointer=!0),!0))))},i.prototype._processPicking=function(t,e,i){return!(!this.isHitTestVisible||!this.isVisible||this._doNotRender)&&(!!this.contains(t,e)&&(this._processObservables(i,t,e),!0))},i.prototype._onPointerMove=function(t){this.onPointerMoveObservable.hasObservers()&&this.onPointerMoveObservable.notifyObservers(t)},i.prototype._onPointerEnter=function(){return 0===this._enterCount&&(this._enterCount++,this.onPointerEnterObservable.hasObservers()&&this.onPointerEnterObservable.notifyObservers(this),!0)},i.prototype._onPointerOut=function(){this._enterCount=0,this.onPointerOutObservable.hasObservers()&&this.onPointerOutObservable.notifyObservers(this)},i.prototype._onPointerDown=function(t){return 0===this._downCount&&(this._downCount++,this.onPointerDownObservable.hasObservers()&&this.onPointerDownObservable.notifyObservers(t),!0)},i.prototype._onPointerUp=function(t){this._downCount=0,this.onPointerUpObservable.hasObservers()&&this.onPointerUpObservable.notifyObservers(t)},i.prototype.forcePointerUp=function(){this._onPointerUp(t.Vector2.Zero())},i.prototype._processObservables=function(e,i,r){if(this._dummyVector2.copyFromFloats(i,r),e===t.PointerEventTypes.POINTERMOVE){this._onPointerMove(this._dummyVector2);var n=this._host._lastControlOver;return n&&n!==this&&n._onPointerOut(),n!==this&&this._onPointerEnter(),this._host._lastControlOver=this,!0}return e===t.PointerEventTypes.POINTERDOWN?(this._onPointerDown(this._dummyVector2),this._host._lastControlDown=this,!0):e===t.PointerEventTypes.POINTERUP&&(this._host._lastControlDown&&this._host._lastControlDown._onPointerUp(this._dummyVector2),this._host._lastControlDown=null,!0)},i.prototype._prepareFont=function(){(this._font||this._fontSet)&&(this._font=this._fontSize.getValue(this._host)+"px "+this._fontFamily,this._fontOffset=i._GetFontOffset(this._font))},Object.defineProperty(i,"HORIZONTAL_ALIGNMENT_LEFT",{get:function(){return i._HORIZONTAL_ALIGNMENT_LEFT},enumerable:!0,configurable:!0}),Object.defineProperty(i,"HORIZONTAL_ALIGNMENT_RIGHT",{get:function(){return i._HORIZONTAL_ALIGNMENT_RIGHT},enumerable:!0,configurable:!0}),Object.defineProperty(i,"HORIZONTAL_ALIGNMENT_CENTER",{get:function(){return i._HORIZONTAL_ALIGNMENT_CENTER},enumerable:!0,configurable:!0}),Object.defineProperty(i,"VERTICAL_ALIGNMENT_TOP",{get:function(){return i._VERTICAL_ALIGNMENT_TOP},enumerable:!0,configurable:!0}),Object.defineProperty(i,"VERTICAL_ALIGNMENT_BOTTOM",{get:function(){return i._VERTICAL_ALIGNMENT_BOTTOM},enumerable:!0,configurable:!0}),Object.defineProperty(i,"VERTICAL_ALIGNMENT_CENTER",{get:function(){return i._VERTICAL_ALIGNMENT_CENTER},enumerable:!0,configurable:!0}),i._GetFontOffset=function(t){if(i._FontHeightSizes[t])return i._FontHeightSizes[t];var e=document.createElement("span");e.innerHTML="Hg",e.style.font=t;var r=document.createElement("div");r.style.display="inline-block",r.style.width="1px",r.style.height="0px",r.style.verticalAlign="bottom";var n=document.createElement("div");n.appendChild(e),n.appendChild(r),document.body.appendChild(n);var o=0,s=0;try{s=r.getBoundingClientRect().top-e.getBoundingClientRect().top,r.style.verticalAlign="baseline",o=r.getBoundingClientRect().top-e.getBoundingClientRect().top}finally{document.body.removeChild(n)}var h={ascent:o,height:s,descent:s-o};return i._FontHeightSizes[t]=h,h},i.AddHeader=function(e,r,n,o){var s=new t.GUI.StackPanel("panel"),h=!o||o.isHorizontal,a=!o||o.controlFirst;s.isVertical=!h;var u=new t.GUI.TextBlock("header");return u.text=r,u.textHorizontalAlignment=i.HORIZONTAL_ALIGNMENT_LEFT,h?u.width=n:u.height=n,a?(s.addControl(e),s.addControl(u),u.paddingLeft="5px"):(s.addControl(u),s.addControl(e),u.paddingRight="5px"),s},i.drawEllipse=function(t,e,i,r,n){n.translate(t,e),n.scale(i,r),n.beginPath(),n.arc(0,0,1,0,2*Math.PI),n.closePath(),n.scale(1/i,1/r),n.translate(-t,-e)},i})();i._HORIZONTAL_ALIGNMENT_LEFT=0,i._HORIZONTAL_ALIGNMENT_RIGHT=1,i._HORIZONTAL_ALIGNMENT_CENTER=2,i._VERTICAL_ALIGNMENT_TOP=0,i._VERTICAL_ALIGNMENT_BOTTOM=1,i._VERTICAL_ALIGNMENT_CENTER=2,i._FontHeightSizes={},e.Control=i})(t.GUI||(t.GUI={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(t){!(function(t){var e=(function(e){function i(i){var r=e.call(this,i)||this;return r.name=i,r._children=new Array,r._measureForChildren=t.Measure.Empty(),r}return __extends(i,e),Object.defineProperty(i.prototype,"background",{get:function(){return this._background},set:function(t){this._background!==t&&(this._background=t,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"children",{get:function(){return this._children},enumerable:!0,configurable:!0}),i.prototype._getTypeName=function(){return"Container"},i.prototype.getChildByName=function(t){for(var e=0,i=this._children;et.zIndex)return void this._children.splice(e,0,t);this._children.push(t),this._markAsDirty()},i.prototype._markMatrixAsDirty=function(){e.prototype._markMatrixAsDirty.call(this);for(var t=0;t=0;n--){if(this._children[n]._processPicking(t,i,r))return!0}return this._processObservables(r,t,i)},i.prototype._clipForChildren=function(t){},i.prototype._additionalProcessing=function(t,i){e.prototype._additionalProcessing.call(this,t,i),this._measureForChildren.copyFrom(this._currentMeasure)},i})(t.Control);t.Container=e})(t.GUI||(t.GUI={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(t){!(function(e){var i=(function(i){function r(t){var r=i.call(this,t)||this;return r.name=t,r._isVertical=!0,r._tempMeasureStore=e.Measure.Empty(),r}return __extends(r,i),Object.defineProperty(r.prototype,"isVertical",{get:function(){return this._isVertical},set:function(t){this._isVertical!==t&&(this._isVertical=t,this._markAsDirty())},enumerable:!0,configurable:!0}),r.prototype._getTypeName=function(){return"StackPanel"},r.prototype._preMeasure=function(e,r){for(var n=0,o=0,s=this._children;o0?t+" "+i[o]:i[0],h=e.measureText(s),a=h.width;a>r&&o>0?(this._lines.push({text:t,width:n}),t=i[o],n=e.measureText(t).width):(n=a,t=s)}return{text:t,width:n}},i.prototype._renderLines=function(e){var i=(this._currentMeasure.width,this._currentMeasure.height);this._fontOffset||(this._fontOffset=t.Control._GetFontOffset(e.font));var r=0;switch(this._textVerticalAlignment){case t.Control.VERTICAL_ALIGNMENT_TOP:r=this._fontOffset.ascent;break;case t.Control.VERTICAL_ALIGNMENT_BOTTOM:r=i-this._fontOffset.height*(this._lines.length-1)-this._fontOffset.descent;break;case t.Control.VERTICAL_ALIGNMENT_CENTER:r=this._fontOffset.ascent+(i-this._fontOffset.height*this._lines.length)/2}r+=this._currentMeasure.top;for(var n=0,o=this._lines;nh||l150?.04:-.16*(t-50)/100+.2;var g=(p-a)/(t-a);o[d+3]=g1-m?255*(1-(g-(1-m))/m):255}}return r.putImageData(n,0,0),i},i.prototype._RGBtoHSV=function(t,e){var i=t.r,r=t.g,n=t.b,o=Math.max(i,r,n),s=Math.min(i,r,n),h=0,a=0,u=o,_=o-s;0!==o&&(a=_/o),o!=s&&(o==i?(h=(r-n)/_,r=0&&o<=1?(h=n,a=s):o>=1&&o<=2?(h=s,a=n):o>=2&&o<=3?(a=n,u=s):o>=3&&o<=4?(a=s,u=n):o>=4&&o<=5?(h=s,u=n):o>=5&&o<=6&&(h=n,u=s);var _=i-n;r.set(h+_,a+_,u+_)},i.prototype._draw=function(t,e){if(e.save(),this._applyStates(e),this._processMeasures(t,e)){var i=.5*Math.min(this._currentMeasure.width,this._currentMeasure.height),r=.2*i,n=this._currentMeasure.left,o=this._currentMeasure.top;this._colorWheelCanvas&&this._colorWheelCanvas.width==2*i||(this._colorWheelCanvas=this._createColorWheelCanvas(i,r)),e.drawImage(this._colorWheelCanvas,n,o),this._updateSquareProps(),this._drawGradientSquare(this._h,this._squareLeft,this._squareTop,this._squareSize,this._squareSize,e);var s=this._squareLeft+this._squareSize*this._s,h=this._squareTop+this._squareSize*(1-this._v);this._drawCircle(s,h,.04*i,e);var a=i-.5*r;s=n+i+Math.cos((this._h-180)*Math.PI/180)*a,h=o+i+Math.sin((this._h-180)*Math.PI/180)*a,this._drawCircle(s,h,.35*r,e)}e.restore()},i.prototype._updateValueFromPointer=function(t,e){if(this._pointerStartedOnWheel){var i=.5*Math.min(this._currentMeasure.width,this._currentMeasure.height),r=i+this._currentMeasure.left,n=i+this._currentMeasure.top +;this._h=180*Math.atan2(e-n,t-r)/Math.PI+180}else this._pointerStartedOnSquare&&(this._updateSquareProps(),this._s=(t-this._squareLeft)/this._squareSize,this._v=1-(e-this._squareTop)/this._squareSize,this._s=Math.min(this._s,1),this._s=Math.max(this._s,1e-5),this._v=Math.min(this._v,1),this._v=Math.max(this._v,1e-5));this._HSVtoRGB(this._h,this._s,this._v,this._tmpColor),this.value=this._tmpColor},i.prototype._isPointOnSquare=function(t){this._updateSquareProps();var e=this._squareLeft,i=this._squareTop,r=this._squareSize;return t.x>=e&&t.x<=e+r&&t.y>=i&&t.y<=i+r},i.prototype._isPointOnWheel=function(t){var e=.5*Math.min(this._currentMeasure.width,this._currentMeasure.height),i=e+this._currentMeasure.left,r=e+this._currentMeasure.top,n=.2*e,o=e-n,s=e*e,h=o*o,a=t.x-i,u=t.y-r,_=a*a+u*u;return _<=s&&_>=h},i.prototype._onPointerDown=function(t){return!!e.prototype._onPointerDown.call(this,t)&&(this._pointerIsDown=!0,this._pointerStartedOnSquare=!1,this._pointerStartedOnWheel=!1,this._isPointOnSquare(t)?this._pointerStartedOnSquare=!0:this._isPointOnWheel(t)&&(this._pointerStartedOnWheel=!0),this._updateValueFromPointer(t.x,t.y),this._host._capturingControl=this,!0)},i.prototype._onPointerMove=function(t){this._pointerIsDown&&this._updateValueFromPointer(t.x,t.y),e.prototype._onPointerMove.call(this,t)},i.prototype._onPointerUp=function(t){this._pointerIsDown=!1,this._host._capturingControl=null,e.prototype._onPointerUp.call(this,t)},i})(e.Control);e.ColorPicker=i})(t.GUI||(t.GUI={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(t){!(function(t){var e=(function(e){function i(i,r){void 0===r&&(r="");var n=e.call(this,i)||this;return n.name=i,n._text="",n._background="black",n._thickness=1,n._margin=new t.ValueAndUnit(10,t.ValueAndUnit.UNITMODE_PIXEL),n._autoStretchWidth=!0,n._maxWidth=new t.ValueAndUnit(1,t.ValueAndUnit.UNITMODE_PERCENTAGE,!1),n.text=r,n}return __extends(i,e),Object.defineProperty(i.prototype,"maxWidth",{get:function(){return this._maxWidth.toString(this._host)},set:function(t){this._maxWidth.toString(this._host)!==t&&this._maxWidth.fromString(t)&&this._markAsDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"margin",{get:function(){return this._margin.toString(this._host)},set:function(t){this._margin.toString(this._host)!==t&&this._margin.fromString(t)&&this._markAsDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"autoStretchWidth",{get:function(){return this._autoStretchWidth},set:function(t){this._autoStretchWidth!==t&&(this._autoStretchWidth=t,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"thickness",{get:function(){return this._thickness},set:function(t){this._thickness!==t&&(this._thickness=t,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"background",{get:function(){return this._background},set:function(t){this._background!==t&&(this._background=t,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"text",{get:function(){return this._text},set:function(t){this._text!==t&&(this._text=t,this._markAsDirty())},enumerable:!0,configurable:!0}),i.prototype._getTypeName=function(){return"InputText"},i.prototype._draw=function(t,e){if(e.save(),this._applyStates(e),this._processMeasures(t,e)){if(this._background&&(e.fillStyle=this._background,e.fillRect(this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height)),this._text){this.color&&(e.fillStyle=this.color);var i=this._fontOffset.ascent+(this._currentMeasure.height-this._fontOffset.height)/2;e.fillText(this._text,this._currentMeasure.left+this._margin.getValueInPixel(this._host,t.width),this._currentMeasure.top+i),this._autoStretchWidth&&(this.width=Math.min(this._maxWidth.getValueInPixel(this._host,t.width),e.measureText(this._text).width+2*this._margin.getValueInPixel(this._host,t.width))+"px")}this._thickness&&(this.color&&(e.strokeStyle=this.color),e.lineWidth=this._thickness,e.strokeRect(this._currentMeasure.left+this._thickness/2,this._currentMeasure.top+this._thickness/2,this._currentMeasure.width-this._thickness,this._currentMeasure.height-this._thickness))}e.restore()},i})(t.Control);t.InputText=e})(t.GUI||(t.GUI={}))})(BABYLON||(BABYLON={})); \ No newline at end of file diff --git a/dist/preview release/gui/babylon.gui.module.d.ts b/dist/preview release/gui/babylon.gui.module.d.ts index d6ff829e625..6138e50a3d1 100644 --- a/dist/preview release/gui/babylon.gui.module.d.ts +++ b/dist/preview release/gui/babylon.gui.module.d.ts @@ -25,6 +25,7 @@ declare module BABYLON.GUI { idealHeight: number; renderAtIdealSize: boolean; readonly layer: Layer; + readonly rootContainer: Container; constructor(name: string, width: number, height: number, scene: Scene, generateMipMaps?: boolean, samplingMode?: number); executeOnAllControls(func: (control: Control) => void, container?: Container): void; markAsDirty(): void; diff --git a/gui/src/advancedDynamicTexture.ts b/gui/src/advancedDynamicTexture.ts index eddaf195752..9e2a587e6c6 100644 --- a/gui/src/advancedDynamicTexture.ts +++ b/gui/src/advancedDynamicTexture.ts @@ -79,6 +79,10 @@ module BABYLON.GUI { public get layer(): Layer { return this._layerToDispose; } + + public get rootContainer(): Container { + return this._rootContainer; + } constructor(name: string, width = 0, height = 0, scene: Scene, generateMipMaps = false, samplingMode = Texture.NEAREST_SAMPLINGMODE) { super(name, {width: width, height: height}, scene, generateMipMaps, samplingMode, Engine.TEXTUREFORMAT_RGBA); diff --git a/tests/validation/ReferenceImages/refprobe.png b/tests/validation/ReferenceImages/refprobe.png index b1fe69cda59..cb0ecde3003 100644 Binary files a/tests/validation/ReferenceImages/refprobe.png and b/tests/validation/ReferenceImages/refprobe.png differ diff --git a/tests/validation/config.json b/tests/validation/config.json index 415b84d974a..9e5bf5b0642 100644 --- a/tests/validation/config.json +++ b/tests/validation/config.json @@ -189,10 +189,11 @@ }, { "title": "Reflection probes", + "renderCount": 10, "scriptToRun": "/Demos/RefProbe/reflectionProbe.js", "functionToCall": "CreateReflectionProbeTestScene ", "referenceImage": "refprobe.png" - }, + }, { "title": "PBRMetallicRoughnessMaterial", "playgroundId": "#2FDQT5#13",