diff --git a/dist/preview release/babylon.d.ts b/dist/preview release/babylon.d.ts index 0ccc7feb980..27e12e9a000 100644 --- a/dist/preview release/babylon.d.ts +++ b/dist/preview release/babylon.d.ts @@ -2289,6 +2289,108 @@ declare module BABYLON { } } +declare module BABYLON { + class BoundingBox { + minimum: Vector3; + maximum: Vector3; + vectors: Vector3[]; + center: Vector3; + extendSize: Vector3; + directions: Vector3[]; + vectorsWorld: Vector3[]; + minimumWorld: Vector3; + maximumWorld: Vector3; + private _worldMatrix; + constructor(minimum: Vector3, maximum: Vector3); + getWorldMatrix(): Matrix; + setWorldMatrix(matrix: Matrix): BoundingBox; + _update(world: Matrix): void; + isInFrustum(frustumPlanes: Plane[]): boolean; + isCompletelyInFrustum(frustumPlanes: Plane[]): boolean; + intersectsPoint(point: Vector3): boolean; + intersectsSphere(sphere: BoundingSphere): boolean; + intersectsMinMax(min: Vector3, max: Vector3): boolean; + static Intersects(box0: BoundingBox, box1: BoundingBox): boolean; + static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean; + static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean; + static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean; + } +} + +declare module BABYLON { + class BoundingInfo { + minimum: Vector3; + maximum: Vector3; + boundingBox: BoundingBox; + boundingSphere: BoundingSphere; + private _isLocked; + constructor(minimum: Vector3, maximum: Vector3); + isLocked: boolean; + update(world: Matrix): void; + isInFrustum(frustumPlanes: Plane[]): boolean; + isCompletelyInFrustum(frustumPlanes: Plane[]): boolean; + _checkCollision(collider: Collider): boolean; + intersectsPoint(point: Vector3): boolean; + intersects(boundingInfo: BoundingInfo, precise: boolean): boolean; + } +} + +declare module BABYLON { + class BoundingSphere { + minimum: Vector3; + maximum: Vector3; + center: Vector3; + radius: number; + centerWorld: Vector3; + radiusWorld: number; + private _tempRadiusVector; + constructor(minimum: Vector3, maximum: Vector3); + _update(world: Matrix): void; + isInFrustum(frustumPlanes: Plane[]): boolean; + intersectsPoint(point: Vector3): boolean; + static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean; + } +} + +declare module BABYLON { + class Ray { + origin: Vector3; + direction: Vector3; + length: number; + private _edge1; + private _edge2; + private _pvec; + private _tvec; + private _qvec; + constructor(origin: Vector3, direction: Vector3, length?: number); + intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean; + intersectsBox(box: BoundingBox): boolean; + intersectsSphere(sphere: BoundingSphere): boolean; + intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): IntersectionInfo; + intersectsPlane(plane: Plane): number; + private static smallnum; + private static rayl; + /** + * Intersection test between the ray and a given segment whithin a given tolerance (threshold) + * @param sega the first point of the segment to test the intersection against + * @param segb the second point of the segment to test the intersection against + * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful + * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection + */ + intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number; + static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray; + /** + * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be + * transformed to the given world matrix. + * @param origin The origin point + * @param end The end point + * @param world a matrix to transform the ray to. Default is the identity matrix. + */ + static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray; + static Transform(ray: Ray, matrix: Matrix): Ray; + } +} + declare module BABYLON { class Collider { radius: Vector3; @@ -2530,108 +2632,6 @@ declare module BABYLON { } } -declare module BABYLON { - class BoundingBox { - minimum: Vector3; - maximum: Vector3; - vectors: Vector3[]; - center: Vector3; - extendSize: Vector3; - directions: Vector3[]; - vectorsWorld: Vector3[]; - minimumWorld: Vector3; - maximumWorld: Vector3; - private _worldMatrix; - constructor(minimum: Vector3, maximum: Vector3); - getWorldMatrix(): Matrix; - setWorldMatrix(matrix: Matrix): BoundingBox; - _update(world: Matrix): void; - isInFrustum(frustumPlanes: Plane[]): boolean; - isCompletelyInFrustum(frustumPlanes: Plane[]): boolean; - intersectsPoint(point: Vector3): boolean; - intersectsSphere(sphere: BoundingSphere): boolean; - intersectsMinMax(min: Vector3, max: Vector3): boolean; - static Intersects(box0: BoundingBox, box1: BoundingBox): boolean; - static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean; - static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean; - static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean; - } -} - -declare module BABYLON { - class BoundingInfo { - minimum: Vector3; - maximum: Vector3; - boundingBox: BoundingBox; - boundingSphere: BoundingSphere; - private _isLocked; - constructor(minimum: Vector3, maximum: Vector3); - isLocked: boolean; - update(world: Matrix): void; - isInFrustum(frustumPlanes: Plane[]): boolean; - isCompletelyInFrustum(frustumPlanes: Plane[]): boolean; - _checkCollision(collider: Collider): boolean; - intersectsPoint(point: Vector3): boolean; - intersects(boundingInfo: BoundingInfo, precise: boolean): boolean; - } -} - -declare module BABYLON { - class BoundingSphere { - minimum: Vector3; - maximum: Vector3; - center: Vector3; - radius: number; - centerWorld: Vector3; - radiusWorld: number; - private _tempRadiusVector; - constructor(minimum: Vector3, maximum: Vector3); - _update(world: Matrix): void; - isInFrustum(frustumPlanes: Plane[]): boolean; - intersectsPoint(point: Vector3): boolean; - static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean; - } -} - -declare module BABYLON { - class Ray { - origin: Vector3; - direction: Vector3; - length: number; - private _edge1; - private _edge2; - private _pvec; - private _tvec; - private _qvec; - constructor(origin: Vector3, direction: Vector3, length?: number); - intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean; - intersectsBox(box: BoundingBox): boolean; - intersectsSphere(sphere: BoundingSphere): boolean; - intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): IntersectionInfo; - intersectsPlane(plane: Plane): number; - private static smallnum; - private static rayl; - /** - * Intersection test between the ray and a given segment whithin a given tolerance (threshold) - * @param sega the first point of the segment to test the intersection against - * @param segb the second point of the segment to test the intersection against - * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful - * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection - */ - intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number; - static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray; - /** - * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be - * transformed to the given world matrix. - * @param origin The origin point - * @param end The end point - * @param world a matrix to transform the ray to. Default is the identity matrix. - */ - static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray; - static Transform(ray: Ray, matrix: Matrix): Ray; - } -} - declare module BABYLON { class DebugLayer { private _scene; @@ -2922,6 +2922,50 @@ declare module BABYLON { } } +declare module BABYLON { + interface ISceneLoaderPlugin { + extensions: string; + importMesh: (meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => boolean; + load: (scene: Scene, data: string, rootUrl: string) => boolean; + } + interface ISceneLoaderPluginAsync { + extensions: string; + importMeshAsync: (meshesNames: any, scene: Scene, data: any, rootUrl: string, onsuccess?: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, onerror?: () => void) => void; + loadAsync: (scene: Scene, data: string, rootUrl: string, onsuccess: () => void, onerror: () => void) => boolean; + } + class SceneLoader { + private static _ForceFullSceneLoadingForIncremental; + private static _ShowLoadingScreen; + static NO_LOGGING: number; + static MINIMAL_LOGGING: number; + static SUMMARY_LOGGING: number; + static DETAILED_LOGGING: number; + private static _loggingLevel; + static ForceFullSceneLoadingForIncremental: boolean; + static ShowLoadingScreen: boolean; + static loggingLevel: number; + private static _registeredPlugins; + private static _getPluginForFilename(sceneFilename); + static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync; + static RegisterPlugin(plugin: ISceneLoaderPlugin): void; + static ImportMesh(meshesNames: any, rootUrl: string, sceneFilename: string, scene: Scene, onsuccess?: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, progressCallBack?: () => 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 + */ + static Load(rootUrl: string, sceneFilename: any, engine: Engine, onsuccess?: (scene: Scene) => void, progressCallBack?: any, onerror?: (scene: Scene) => 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 + */ + static Append(rootUrl: string, sceneFilename: any, scene: Scene, onsuccess?: (scene: Scene) => void, progressCallBack?: any, onerror?: (scene: Scene) => void): void; + } +} + declare module BABYLON { class EffectFallbacks { private _defines; @@ -3492,53 +3536,9 @@ declare module BABYLON { } declare module BABYLON { - interface ISceneLoaderPlugin { - extensions: string; - importMesh: (meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => boolean; - load: (scene: Scene, data: string, rootUrl: string) => boolean; - } - interface ISceneLoaderPluginAsync { - extensions: string; - importMeshAsync: (meshesNames: any, scene: Scene, data: any, rootUrl: string, onsuccess?: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, onerror?: () => void) => void; - loadAsync: (scene: Scene, data: string, rootUrl: string, onsuccess: () => void, onerror: () => void) => boolean; - } - class SceneLoader { - private static _ForceFullSceneLoadingForIncremental; - private static _ShowLoadingScreen; - static NO_LOGGING: number; - static MINIMAL_LOGGING: number; - static SUMMARY_LOGGING: number; - static DETAILED_LOGGING: number; - private static _loggingLevel; - static ForceFullSceneLoadingForIncremental: boolean; - static ShowLoadingScreen: boolean; - static loggingLevel: number; - private static _registeredPlugins; - private static _getPluginForFilename(sceneFilename); - static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync; - static RegisterPlugin(plugin: ISceneLoaderPlugin): void; - static ImportMesh(meshesNames: any, rootUrl: string, sceneFilename: string, scene: Scene, onsuccess?: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, progressCallBack?: () => 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 - */ - static Load(rootUrl: string, sceneFilename: any, engine: Engine, onsuccess?: (scene: Scene) => void, progressCallBack?: any, onerror?: (scene: Scene) => 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 - */ - static Append(rootUrl: string, sceneFilename: any, scene: Scene, onsuccess?: (scene: Scene) => void, progressCallBack?: any, onerror?: (scene: Scene) => void): void; - } -} - -declare module BABYLON { - class SIMDVector3 { - static TransformCoordinatesToRefSIMD(vector: Vector3, transformation: Matrix, result: Vector3): void; - static TransformCoordinatesFromFloatsToRefSIMD(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void; + class SIMDVector3 { + static TransformCoordinatesToRefSIMD(vector: Vector3, transformation: Matrix, result: Vector3): void; + static TransformCoordinatesFromFloatsToRefSIMD(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void; } class SIMDMatrix { multiplyToArraySIMD(other: Matrix, result: Matrix, offset?: number): void; @@ -4152,277 +4152,671 @@ declare module BABYLON { } declare module BABYLON { - class AbstractMesh extends Node implements IDisposable { - private static _BILLBOARDMODE_NONE; - private static _BILLBOARDMODE_X; - private static _BILLBOARDMODE_Y; - private static _BILLBOARDMODE_Z; - private static _BILLBOARDMODE_ALL; - static BILLBOARDMODE_NONE: number; - static BILLBOARDMODE_X: number; - static BILLBOARDMODE_Y: number; - static BILLBOARDMODE_Z: number; - static BILLBOARDMODE_ALL: number; + class Particle { + position: Vector3; + direction: Vector3; + color: Color4; + colorStep: Color4; + lifeTime: number; + age: number; + size: number; + angle: number; + angularSpeed: number; + copyTo(other: Particle): void; + } +} + +declare module BABYLON { + class ParticleSystem implements IDisposable, IAnimatable { + name: string; + static BLENDMODE_ONEONE: number; + static BLENDMODE_STANDARD: number; + animations: Animation[]; + id: string; + renderingGroupId: number; + emitter: any; + emitRate: number; + manualEmitCount: number; + updateSpeed: number; + targetStopDuration: number; + disposeOnStop: boolean; + minEmitPower: number; + maxEmitPower: number; + minLifeTime: number; + maxLifeTime: number; + minSize: number; + maxSize: number; + minAngularSpeed: number; + maxAngularSpeed: number; + particleTexture: Texture; + layerMask: number; + onDispose: () => void; + updateFunction: (particles: Particle[]) => void; + blendMode: number; + forceDepthWrite: boolean; + gravity: Vector3; + direction1: Vector3; + direction2: Vector3; + minEmitBox: Vector3; + maxEmitBox: Vector3; + color1: Color4; + color2: Color4; + colorDead: Color4; + textureMask: Color4; + startDirectionFunction: (emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void; + startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void; + private particles; + private _capacity; + private _scene; + private _vertexDeclaration; + private _vertexStrideSize; + private _stockParticles; + private _newPartsExcess; + private _vertexBuffer; + private _indexBuffer; + private _vertices; + private _effect; + private _customEffect; + private _cachedDefines; + private _scaledColorStep; + private _colorDiff; + private _scaledDirection; + private _scaledGravity; + private _currentRenderId; + private _alive; + private _started; + private _stopped; + private _actualFrame; + private _scaledUpdateSpeed; + constructor(name: string, capacity: number, scene: Scene, customEffect?: Effect); + recycleParticle(particle: Particle): void; + getCapacity(): number; + isAlive(): boolean; + isStarted(): boolean; + start(): void; + stop(): void; + _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void; + private _update(newParticles); + private _getEffect(); + animate(): void; + render(): number; + dispose(): void; + clone(name: string, newEmitter: any): ParticleSystem; + serialize(): any; + static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): ParticleSystem; + } +} + +declare module BABYLON { + class SolidParticle { + idx: number; + color: Color4; + position: Vector3; + rotation: Vector3; + rotationQuaternion: Quaternion; + scaling: Vector3; + uvs: Vector4; + velocity: Vector3; + alive: boolean; + _pos: number; + _model: ModelShape; + shapeId: number; + idxInShape: number; + constructor(particleIndex: number, positionIndex: number, model: ModelShape, shapeId: number, idxInShape: number); + scale: Vector3; + quaternion: Quaternion; + } + class ModelShape { + shapeID: number; + _shape: Vector3[]; + _shapeUV: number[]; + _positionFunction: (particle: SolidParticle, i: number, s: number) => void; + _vertexFunction: (particle: SolidParticle, vertex: Vector3, i: number) => void; + constructor(id: number, shape: Vector3[], shapeUV: number[], posFunction: (particle: SolidParticle, i: number, s: number) => void, vtxFunction: (particle: SolidParticle, vertex: Vector3, i: number) => void); + } +} + +declare module BABYLON { + /** + * Full documentation here : http://doc.babylonjs.com/tutorials/Solid_Particle_System + */ + class SolidParticleSystem implements IDisposable { /** - * An event triggered when this mesh collides with another one - * @type {BABYLON.Observable} + * The SPS array of Solid Particle objects. Just access each particle as with any classic array. + * Example : var p = SPS.particles[i]; */ - onCollideObservable: Observable; - private _onCollideObserver; - onCollide: () => void; + particles: SolidParticle[]; /** - * An event triggered when the collision's position changes - * @type {BABYLON.Observable} + * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value. */ - onCollisionPositionChangeObservable: Observable; - private _onCollisionPositionChangeObserver; - onCollisionPositionChange: () => void; + nbParticles: number; /** - * An event triggered after the world matrix is updated - * @type {BABYLON.Observable} + * If the particles must ever face the camera (default false). Useful for planar particles. */ - onAfterWorldMatrixUpdateObservable: Observable; - definedFacingForward: boolean; - position: Vector3; - private _rotation; - _rotationQuaternion: Quaternion; - private _scaling; - billboardMode: number; - visibility: number; - alphaIndex: number; - infiniteDistance: boolean; - isVisible: boolean; - isPickable: boolean; - showBoundingBox: boolean; - showSubMeshesBoundingBox: boolean; - onDispose: any; - isBlocker: boolean; - renderingGroupId: number; - material: Material; - receiveShadows: boolean; - actionManager: ActionManager; - renderOutline: boolean; - outlineColor: Color3; - outlineWidth: number; - renderOverlay: boolean; - overlayColor: Color3; - overlayAlpha: number; - hasVertexAlpha: boolean; - useVertexColors: boolean; - applyFog: boolean; - computeBonesUsingShaders: boolean; - scalingDeterminant: number; - numBoneInfluencers: number; - useOctreeForRenderingSelection: boolean; - useOctreeForPicking: boolean; - useOctreeForCollisions: boolean; - layerMask: number; - alwaysSelectAsActiveMesh: boolean; - physicsImpostor: BABYLON.PhysicsImpostor; - onPhysicsCollide: (collidedMesh: AbstractMesh, contact: any) => void; - private _checkCollisions; - ellipsoid: Vector3; - ellipsoidOffset: Vector3; - private _collider; - private _oldPositionForCollisions; - private _diffPositionForCollisions; - private _newPositionForCollisions; - private _meshToBoneReferal; - edgesWidth: number; - edgesColor: Color4; - _edgesRenderer: EdgesRenderer; - private _localWorld; - _worldMatrix: Matrix; - private _rotateYByPI; - private _absolutePosition; - private _collisionsTransformMatrix; - private _collisionsScalingMatrix; - _positions: Vector3[]; - private _isDirty; - _masterMesh: AbstractMesh; - _materialDefines: MaterialDefines; - _boundingInfo: BoundingInfo; - private _pivotMatrix; - _isDisposed: boolean; - _renderId: number; - subMeshes: SubMesh[]; - _submeshesOctree: Octree; - _intersectionsInProgress: AbstractMesh[]; - private _isWorldMatrixFrozen; - _unIndexed: boolean; - _poseMatrix: Matrix; - _waitingActions: any; - _waitingFreezeWorldMatrix: boolean; - private _skeleton; - _bonesTransformMatrices: Float32Array; - skeleton: Skeleton; - constructor(name: string, scene: Scene); - /** - * @param {boolean} fullDetails - support for multiple levels of logging within scene loading - */ - toString(fullDetails?: boolean): string; - /** - * Getting the rotation object. - * If rotation quaternion is set, this vector will (almost always) be the Zero vector! - */ - rotation: Vector3; - scaling: Vector3; - rotationQuaternion: Quaternion; - updatePoseMatrix(matrix: Matrix): void; - getPoseMatrix(): Matrix; - disableEdgesRendering(): void; - enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): void; - isBlocked: boolean; - getLOD(camera: Camera): AbstractMesh; - getTotalVertices(): number; - getIndices(): number[] | Int32Array; - getVerticesData(kind: string): number[] | Float32Array; - isVerticesDataPresent(kind: string): boolean; - getBoundingInfo(): BoundingInfo; - useBones: boolean; - _preActivate(): void; - _preActivateForIntermediateRendering(renderId: number): void; - _activate(renderId: number): void; - getWorldMatrix(): Matrix; - worldMatrixFromCache: Matrix; - absolutePosition: Vector3; - freezeWorldMatrix(): void; - unfreezeWorldMatrix(): void; - isWorldMatrixFrozen: boolean; - rotate(axis: Vector3, amount: number, space?: Space): void; - translate(axis: Vector3, distance: number, space?: Space): void; - getAbsolutePosition(): Vector3; - setAbsolutePosition(absolutePosition: Vector3): void; + billboard: boolean; /** - * Perform relative position change from the point of view of behind the front of the mesh. - * This is performed taking into account the meshes current rotation, so you do not have to care. - * Supports definition of mesh facing forward or backward. - * @param {number} amountRight - * @param {number} amountUp - * @param {number} amountForward - */ - movePOV(amountRight: number, amountUp: number, amountForward: number): void; + * This a counter ofr your own usage. It's not set by any SPS functions. + */ + counter: number; /** - * Calculate relative position change from the point of view of behind the front of the mesh. - * This is performed taking into account the meshes current rotation, so you do not have to care. - * Supports definition of mesh facing forward or backward. - * @param {number} amountRight - * @param {number} amountUp - * @param {number} amountForward - */ - calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3; + * The SPS name. This name is also given to the underlying mesh. + */ + name: string; /** - * Perform relative rotation change from the point of view of behind the front of the mesh. - * Supports definition of mesh facing forward or backward. - * @param {number} flipBack - * @param {number} twirlClockwise - * @param {number} tiltRight - */ - rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): void; + * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible. + */ + mesh: Mesh; /** - * Calculate relative rotation change from the point of view of behind the front of the mesh. - * Supports definition of mesh facing forward or backward. - * @param {number} flipBack - * @param {number} twirlClockwise - * @param {number} tiltRight - */ - calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3; - setPivotMatrix(matrix: Matrix): void; - getPivotMatrix(): Matrix; - _isSynchronized(): boolean; - _initCache(): void; - markAsDirty(property: string): void; - _updateBoundingInfo(): void; - _updateSubMeshesBoundingInfo(matrix: Matrix): void; - computeWorldMatrix(force?: boolean): Matrix; + * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity. + * Please read : http://doc.babylonjs.com/tutorials/Solid_Particle_System#garbage-collector-concerns + */ + vars: any; /** - * If you'd like to be callbacked after the mesh position, rotation or scaling has been updated - * @param func: callback function to add + * This array is populated when the SPS is set as 'pickable'. + * Each key of this array is a `faceId` value that you can get from a pickResult object. + * Each element of this array is an object `{idx: int, faceId: int}`. + * `idx` is the picked particle index in the `SPS.particles` array + * `faceId` is the picked face index counted within this particle. + * Please read : http://doc.babylonjs.com/tutorials/Solid_Particle_System#pickable-particles */ - registerAfterWorldMatrixUpdate(func: (mesh: AbstractMesh) => void): void; - unregisterAfterWorldMatrixUpdate(func: (mesh: AbstractMesh) => void): void; - setPositionWithLocalVector(vector3: Vector3): void; - getPositionExpressedInLocalSpace(): Vector3; - locallyTranslate(vector3: Vector3): void; - lookAt(targetPoint: Vector3, yawCor: number, pitchCor: number, rollCor: number): void; - attachToBone(bone: Bone, affectedMesh: AbstractMesh): void; - detachFromBone(): void; - isInFrustum(frustumPlanes: Plane[]): boolean; - isCompletelyInFrustum(camera?: Camera): boolean; - intersectsMesh(mesh: AbstractMesh, precise?: boolean): boolean; - intersectsPoint(point: Vector3): boolean; + pickedParticles: { + idx: number; + faceId: number; + }[]; + private _scene; + private _positions; + private _indices; + private _normals; + private _colors; + private _uvs; + private _positions32; + private _normals32; + private _fixedNormal32; + private _colors32; + private _uvs32; + private _index; + private _updatable; + private _pickable; + private _isVisibilityBoxLocked; + private _alwaysVisible; + private _shapeCounter; + private _copy; + private _shape; + private _shapeUV; + private _color; + private _computeParticleColor; + private _computeParticleTexture; + private _computeParticleRotation; + private _computeParticleVertex; + private _computeBoundingBox; + private _cam_axisZ; + private _cam_axisY; + private _cam_axisX; + private _axisX; + private _axisY; + private _axisZ; + private _camera; + private _particle; + private _fakeCamPos; + private _rotMatrix; + private _invertMatrix; + private _rotated; + private _quaternion; + private _vertex; + private _normal; + private _yaw; + private _pitch; + private _roll; + private _halfroll; + private _halfpitch; + private _halfyaw; + private _sinRoll; + private _cosRoll; + private _sinPitch; + private _cosPitch; + private _sinYaw; + private _cosYaw; + private _w; + private _minimum; + private _maximum; /** - * @Deprecated. Use new PhysicsImpostor instead. - * */ - setPhysicsState(impostor?: any, options?: PhysicsImpostorParameters): any; - getPhysicsImpostor(): PhysicsImpostor; + * Creates a SPS (Solid Particle System) object. + * `name` (String) is the SPS name, this will be the underlying mesh name. + * `scene` (Scene) is the scene in which the SPS is added. + * `updatableè (default true) : if the SPS must be updatable or immutable. + * `isPickable` (default false) : if the solid particles must be pickable. + */ + constructor(name: string, scene: Scene, options?: { + updatable?: boolean; + isPickable?: boolean; + }); /** - * @Deprecated. Use getPhysicsImpostor().getParam("mass"); - */ - getPhysicsMass(): number; + * Builds the SPS underlying mesh. Returns a standard Mesh. + * If no model shape was added to the SPS, the returned mesh is just a single triangular plane. + */ + buildMesh(): Mesh; /** - * @Deprecated. Use getPhysicsImpostor().getParam("friction"); - */ - getPhysicsFriction(): number; + * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS. + * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places. + * Thus the particles generated from `digest()` have their property `position` set yet. + * `mesh` (`Mesh`) is the mesh to be digested + * `facetNb` (optional integer, default 1) is the number of mesh facets per particle, this parameter is overriden by the parameter `number` if any + * `delta` (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets + * `number` (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets + */ + digest(mesh: Mesh, options?: { + facetNb?: number; + number?: number; + delta?: number; + }): SolidParticleSystem; + private _resetCopy(); + private _meshBuilder(p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, idx, idxInShape, options); + private _posToShape(positions); + private _uvsToShapeUV(uvs); + private _addParticle(idx, idxpos, model, shapeId, idxInShape); /** - * @Deprecated. Use getPhysicsImpostor().getParam("restitution"); - */ - getPhysicsRestitution(): number; - getPositionInCameraSpace(camera?: Camera): Vector3; - getDistanceToCamera(camera?: Camera): number; - applyImpulse(force: Vector3, contactPoint: Vector3): void; - setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): void; + * Adds some particles to the SPS from the model shape. Returns the shape id. + * Please read the doc : http://doc.babylonjs.com/tutorials/Solid_Particle_System#create-an-immutable-sps + * `mesh` is any `Mesh` object that will be used as a model for the solid particles. + * `nb` (positive integer) the number of particles to be created from this model + * `positionFunction` is an optional javascript function to called for each particle on SPS creation. + * `vertexFunction` is an optional javascript function to called for each vertex of each particle on SPS creation + */ + addShape(mesh: Mesh, nb: number, options?: { + positionFunction?: any; + vertexFunction?: any; + }): number; + private _rebuildParticle(particle); /** - * @Deprecated - */ - updatePhysicsBodyPosition(): void; + * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed. + */ + rebuildMesh(): void; /** - * @Deprecated - * Calling this function is not needed anymore. - * The physics engine takes care of transofmration automatically. - */ - updatePhysicsBody(): void; - checkCollisions: boolean; - moveWithCollisions(velocity: Vector3): void; - private _onCollisionPositionChange; + * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc. + * This method calls `updateParticle()` for each particle of the SPS. + * For an animated SPS, it is usually called within the render loop. + * @param start (default 0) the particle index in the particle array where to start to compute the particle property values + * @param end (default nbParticle - 1) the particle index in the particle array where to stop to compute the particle property values + * @param update (default true) if the mesh must be finally updated on this call after all the particle computations. + */ + setParticles(start?: number, end?: number, update?: boolean): void; + private _quaternionRotationYPR(); + private _quaternionToRotationMatrix(); /** - * This function will create an octree to help select the right submeshes for rendering, picking and collisions - * Please note that you must have a decent number of submeshes to get performance improvements when using octree + * Disposes the SPS */ - createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree; - _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): void; - _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): void; - _checkCollision(collider: Collider): void; - _generatePointsArray(): boolean; - intersects(ray: Ray, fastCheck?: boolean): PickingInfo; - clone(name: string, newParent: Node, doNotCloneChildren?: boolean): AbstractMesh; - releaseSubMeshes(): void; - dispose(doNotRecurse?: boolean): void; + dispose(): void; + /** + * Visibilty helper : Recomputes the visible size according to the mesh bounding box + * doc : http://doc.babylonjs.com/tutorials/Solid_Particle_System#sps-visibility + */ + refreshVisibleSize(): void; + /** + * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box. + * @param size the size (float) of the visibility box + * note : this doesn't lock the SPS mesh bounding box. + * doc : http://doc.babylonjs.com/tutorials/Solid_Particle_System#sps-visibility + */ + setVisibilityBox(size: number): void; + /** + * Sets the SPS as always visible or not + * doc : http://doc.babylonjs.com/tutorials/Solid_Particle_System#sps-visibility + */ + isAlwaysVisible: boolean; + /** + * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates. + * doc : http://doc.babylonjs.com/tutorials/Solid_Particle_System#sps-visibility + */ + isVisibilityBoxLocked: boolean; + /** + * Tells to `setParticles()` to compute the particle rotations or not. + * Default value : true. The SPS is faster when it's set to false. + * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate. + */ + computeParticleRotation: boolean; + /** + * Tells to `setParticles()` to compute the particle colors or not. + * Default value : true. The SPS is faster when it's set to false. + * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set. + */ + computeParticleColor: boolean; + /** + * Tells to `setParticles()` to compute the particle textures or not. + * Default value : true. The SPS is faster when it's set to false. + * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set. + */ + computeParticleTexture: boolean; + /** + * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not. + * Default value : false. The SPS is faster when it's set to false. + * Note : the particle custom vertex positions aren't stored values. + */ + computeParticleVertex: boolean; + /** + * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions. + */ + computeBoundingBox: boolean; + /** + * This function does nothing. It may be overwritten to set all the particle first values. + * The SPS doesn't call this function, you may have to call it by your own. + * doc : http://doc.babylonjs.com/tutorials/Solid_Particle_System#particle-management + */ + initParticles(): void; + /** + * This function does nothing. It may be overwritten to recycle a particle. + * The SPS doesn't call this function, you may have to call it by your own. + * doc : http://doc.babylonjs.com/tutorials/Solid_Particle_System#particle-management + */ + recycleParticle(particle: SolidParticle): SolidParticle; + /** + * Updates a particle : this function should be overwritten by the user. + * It is called on each particle by `setParticles()`. This is the place to code each particle behavior. + * doc : http://doc.babylonjs.com/tutorials/Solid_Particle_System#particle-management + * ex : just set a particle position or velocity and recycle conditions + */ + updateParticle(particle: SolidParticle): SolidParticle; + /** + * Updates a vertex of a particle : it can be overwritten by the user. + * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only. + * @param particle the current particle + * @param vertex the current index of the current particle + * @param pt the index of the current vertex in the particle shape + * doc : http://doc.babylonjs.com/tutorials/Solid_Particle_System#update-each-particle-shape + * ex : just set a vertex particle position + */ + updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3; + /** + * This will be called before any other treatment by `setParticles()` and will be passed three parameters. + * This does nothing and may be overwritten by the user. + * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle() + * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle() + * @param update the boolean update value actually passed to setParticles() + */ + beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void; + /** + * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update. + * This will be passed three parameters. + * This does nothing and may be overwritten by the user. + * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle() + * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle() + * @param update the boolean update value actually passed to setParticles() + */ + afterUpdateParticles(start?: number, stop?: number, update?: boolean): void; } } declare module BABYLON { - class CSG { - private polygons; - matrix: Matrix; + class AbstractMesh extends Node implements IDisposable { + private static _BILLBOARDMODE_NONE; + private static _BILLBOARDMODE_X; + private static _BILLBOARDMODE_Y; + private static _BILLBOARDMODE_Z; + private static _BILLBOARDMODE_ALL; + static BILLBOARDMODE_NONE: number; + static BILLBOARDMODE_X: number; + static BILLBOARDMODE_Y: number; + static BILLBOARDMODE_Z: number; + static BILLBOARDMODE_ALL: number; + /** + * An event triggered when this mesh collides with another one + * @type {BABYLON.Observable} + */ + onCollideObservable: Observable; + private _onCollideObserver; + onCollide: () => void; + /** + * An event triggered when the collision's position changes + * @type {BABYLON.Observable} + */ + onCollisionPositionChangeObservable: Observable; + private _onCollisionPositionChangeObserver; + onCollisionPositionChange: () => void; + /** + * An event triggered after the world matrix is updated + * @type {BABYLON.Observable} + */ + onAfterWorldMatrixUpdateObservable: Observable; + definedFacingForward: boolean; position: Vector3; + private _rotation; + _rotationQuaternion: Quaternion; + private _scaling; + billboardMode: number; + visibility: number; + alphaIndex: number; + infiniteDistance: boolean; + isVisible: boolean; + isPickable: boolean; + showBoundingBox: boolean; + showSubMeshesBoundingBox: boolean; + onDispose: any; + isBlocker: boolean; + renderingGroupId: number; + material: Material; + receiveShadows: boolean; + actionManager: ActionManager; + renderOutline: boolean; + outlineColor: Color3; + outlineWidth: number; + renderOverlay: boolean; + overlayColor: Color3; + overlayAlpha: number; + hasVertexAlpha: boolean; + useVertexColors: boolean; + applyFog: boolean; + computeBonesUsingShaders: boolean; + scalingDeterminant: number; + numBoneInfluencers: number; + useOctreeForRenderingSelection: boolean; + useOctreeForPicking: boolean; + useOctreeForCollisions: boolean; + layerMask: number; + alwaysSelectAsActiveMesh: boolean; + physicsImpostor: BABYLON.PhysicsImpostor; + onPhysicsCollide: (collidedMesh: AbstractMesh, contact: any) => void; + private _checkCollisions; + ellipsoid: Vector3; + ellipsoidOffset: Vector3; + private _collider; + private _oldPositionForCollisions; + private _diffPositionForCollisions; + private _newPositionForCollisions; + private _meshToBoneReferal; + edgesWidth: number; + edgesColor: Color4; + _edgesRenderer: EdgesRenderer; + private _localWorld; + _worldMatrix: Matrix; + private _rotateYByPI; + private _absolutePosition; + private _collisionsTransformMatrix; + private _collisionsScalingMatrix; + _positions: Vector3[]; + private _isDirty; + _masterMesh: AbstractMesh; + _materialDefines: MaterialDefines; + _boundingInfo: BoundingInfo; + private _pivotMatrix; + _isDisposed: boolean; + _renderId: number; + subMeshes: SubMesh[]; + _submeshesOctree: Octree; + _intersectionsInProgress: AbstractMesh[]; + private _isWorldMatrixFrozen; + _unIndexed: boolean; + _poseMatrix: Matrix; + _waitingActions: any; + _waitingFreezeWorldMatrix: boolean; + private _skeleton; + _bonesTransformMatrices: Float32Array; + skeleton: Skeleton; + constructor(name: string, scene: Scene); + /** + * @param {boolean} fullDetails - support for multiple levels of logging within scene loading + */ + toString(fullDetails?: boolean): string; + /** + * Getting the rotation object. + * If rotation quaternion is set, this vector will (almost always) be the Zero vector! + */ rotation: Vector3; - rotationQuaternion: Quaternion; scaling: Vector3; - static FromMesh(mesh: Mesh): CSG; - private static FromPolygons(polygons); - clone(): CSG; - private toPolygons(); - union(csg: CSG): CSG; - unionInPlace(csg: CSG): void; - subtract(csg: CSG): CSG; - subtractInPlace(csg: CSG): void; - intersect(csg: CSG): CSG; - intersectInPlace(csg: CSG): void; - inverse(): CSG; - inverseInPlace(): void; - copyTransformAttributes(csg: CSG): CSG; - buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh; + rotationQuaternion: Quaternion; + updatePoseMatrix(matrix: Matrix): void; + getPoseMatrix(): Matrix; + disableEdgesRendering(): void; + enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): void; + isBlocked: boolean; + getLOD(camera: Camera): AbstractMesh; + getTotalVertices(): number; + getIndices(): number[] | Int32Array; + getVerticesData(kind: string): number[] | Float32Array; + isVerticesDataPresent(kind: string): boolean; + getBoundingInfo(): BoundingInfo; + useBones: boolean; + _preActivate(): void; + _preActivateForIntermediateRendering(renderId: number): void; + _activate(renderId: number): void; + getWorldMatrix(): Matrix; + worldMatrixFromCache: Matrix; + absolutePosition: Vector3; + freezeWorldMatrix(): void; + unfreezeWorldMatrix(): void; + isWorldMatrixFrozen: boolean; + rotate(axis: Vector3, amount: number, space?: Space): void; + translate(axis: Vector3, distance: number, space?: Space): void; + getAbsolutePosition(): Vector3; + setAbsolutePosition(absolutePosition: Vector3): void; + /** + * Perform relative position change from the point of view of behind the front of the mesh. + * This is performed taking into account the meshes current rotation, so you do not have to care. + * Supports definition of mesh facing forward or backward. + * @param {number} amountRight + * @param {number} amountUp + * @param {number} amountForward + */ + movePOV(amountRight: number, amountUp: number, amountForward: number): void; + /** + * Calculate relative position change from the point of view of behind the front of the mesh. + * This is performed taking into account the meshes current rotation, so you do not have to care. + * Supports definition of mesh facing forward or backward. + * @param {number} amountRight + * @param {number} amountUp + * @param {number} amountForward + */ + calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3; + /** + * Perform relative rotation change from the point of view of behind the front of the mesh. + * Supports definition of mesh facing forward or backward. + * @param {number} flipBack + * @param {number} twirlClockwise + * @param {number} tiltRight + */ + rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): void; + /** + * Calculate relative rotation change from the point of view of behind the front of the mesh. + * Supports definition of mesh facing forward or backward. + * @param {number} flipBack + * @param {number} twirlClockwise + * @param {number} tiltRight + */ + calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3; + setPivotMatrix(matrix: Matrix): void; + getPivotMatrix(): Matrix; + _isSynchronized(): boolean; + _initCache(): void; + markAsDirty(property: string): void; + _updateBoundingInfo(): void; + _updateSubMeshesBoundingInfo(matrix: Matrix): void; + computeWorldMatrix(force?: boolean): Matrix; + /** + * If you'd like to be callbacked after the mesh position, rotation or scaling has been updated + * @param func: callback function to add + */ + registerAfterWorldMatrixUpdate(func: (mesh: AbstractMesh) => void): void; + unregisterAfterWorldMatrixUpdate(func: (mesh: AbstractMesh) => void): void; + setPositionWithLocalVector(vector3: Vector3): void; + getPositionExpressedInLocalSpace(): Vector3; + locallyTranslate(vector3: Vector3): void; + lookAt(targetPoint: Vector3, yawCor: number, pitchCor: number, rollCor: number): void; + attachToBone(bone: Bone, affectedMesh: AbstractMesh): void; + detachFromBone(): void; + isInFrustum(frustumPlanes: Plane[]): boolean; + isCompletelyInFrustum(camera?: Camera): boolean; + intersectsMesh(mesh: AbstractMesh, precise?: boolean): boolean; + intersectsPoint(point: Vector3): boolean; + /** + * @Deprecated. Use new PhysicsImpostor instead. + * */ + setPhysicsState(impostor?: any, options?: PhysicsImpostorParameters): any; + getPhysicsImpostor(): PhysicsImpostor; + /** + * @Deprecated. Use getPhysicsImpostor().getParam("mass"); + */ + getPhysicsMass(): number; + /** + * @Deprecated. Use getPhysicsImpostor().getParam("friction"); + */ + getPhysicsFriction(): number; + /** + * @Deprecated. Use getPhysicsImpostor().getParam("restitution"); + */ + getPhysicsRestitution(): number; + getPositionInCameraSpace(camera?: Camera): Vector3; + getDistanceToCamera(camera?: Camera): number; + applyImpulse(force: Vector3, contactPoint: Vector3): void; + setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): void; + /** + * @Deprecated + */ + updatePhysicsBodyPosition(): void; + /** + * @Deprecated + * Calling this function is not needed anymore. + * The physics engine takes care of transofmration automatically. + */ + updatePhysicsBody(): void; + checkCollisions: boolean; + moveWithCollisions(velocity: Vector3): void; + private _onCollisionPositionChange; + /** + * This function will create an octree to help select the right submeshes for rendering, picking and collisions + * Please note that you must have a decent number of submeshes to get performance improvements when using octree + */ + createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree; + _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): void; + _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): void; + _checkCollision(collider: Collider): void; + _generatePointsArray(): boolean; + intersects(ray: Ray, fastCheck?: boolean): PickingInfo; + clone(name: string, newParent: Node, doNotCloneChildren?: boolean): AbstractMesh; + releaseSubMeshes(): void; + dispose(doNotRecurse?: boolean): void; + } +} + +declare module BABYLON { + class CSG { + private polygons; + matrix: Matrix; + position: Vector3; + rotation: Vector3; + rotationQuaternion: Quaternion; + scaling: Vector3; + static FromMesh(mesh: Mesh): CSG; + private static FromPolygons(polygons); + clone(): CSG; + private toPolygons(); + union(csg: CSG): CSG; + unionInPlace(csg: CSG): void; + subtract(csg: CSG): CSG; + subtractInPlace(csg: CSG): void; + intersect(csg: CSG): CSG; + intersectInPlace(csg: CSG): void; + inverse(): CSG; + inverseInPlace(): void; + copyTransformAttributes(csg: CSG): CSG; + buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh; toMesh(name: string, material: Material, scene: Scene, keepSubMeshes: boolean): Mesh; } } @@ -6425,443 +6819,49 @@ declare module BABYLON { } declare module BABYLON { - class VertexBuffer { - private _mesh; - private _engine; - private _buffer; - private _data; - private _updatable; - private _kind; - private _strideSize; - constructor(engine: any, data: number[] | Float32Array, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number); - isUpdatable(): boolean; - getData(): number[] | Float32Array; - getBuffer(): WebGLBuffer; - getStrideSize(): number; - create(data?: number[] | Float32Array): void; - update(data: number[] | Float32Array): void; - updateDirectly(data: Float32Array, offset: number): void; - dispose(): void; - private static _PositionKind; - private static _NormalKind; - 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 PositionKind: string; - static NormalKind: string; - static UVKind: string; - static UV2Kind: string; - static UV3Kind: string; - static UV4Kind: string; - static UV5Kind: string; - static UV6Kind: string; - static ColorKind: string; - static MatricesIndicesKind: string; - static MatricesWeightsKind: string; - static MatricesIndicesExtraKind: string; - static MatricesWeightsExtraKind: string; - } -} - -declare module BABYLON { - class Particle { - position: Vector3; - direction: Vector3; - color: Color4; - colorStep: Color4; - lifeTime: number; - age: number; - size: number; - angle: number; - angularSpeed: number; - copyTo(other: Particle): void; - } -} - -declare module BABYLON { - class ParticleSystem implements IDisposable, IAnimatable { - name: string; - static BLENDMODE_ONEONE: number; - static BLENDMODE_STANDARD: number; - animations: Animation[]; - id: string; - renderingGroupId: number; - emitter: any; - emitRate: number; - manualEmitCount: number; - updateSpeed: number; - targetStopDuration: number; - disposeOnStop: boolean; - minEmitPower: number; - maxEmitPower: number; - minLifeTime: number; - maxLifeTime: number; - minSize: number; - maxSize: number; - minAngularSpeed: number; - maxAngularSpeed: number; - particleTexture: Texture; - layerMask: number; - onDispose: () => void; - updateFunction: (particles: Particle[]) => void; - blendMode: number; - forceDepthWrite: boolean; - gravity: Vector3; - direction1: Vector3; - direction2: Vector3; - minEmitBox: Vector3; - maxEmitBox: Vector3; - color1: Color4; - color2: Color4; - colorDead: Color4; - textureMask: Color4; - startDirectionFunction: (emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void; - startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void; - private particles; - private _capacity; - private _scene; - private _vertexDeclaration; - private _vertexStrideSize; - private _stockParticles; - private _newPartsExcess; - private _vertexBuffer; - private _indexBuffer; - private _vertices; - private _effect; - private _customEffect; - private _cachedDefines; - private _scaledColorStep; - private _colorDiff; - private _scaledDirection; - private _scaledGravity; - private _currentRenderId; - private _alive; - private _started; - private _stopped; - private _actualFrame; - private _scaledUpdateSpeed; - constructor(name: string, capacity: number, scene: Scene, customEffect?: Effect); - recycleParticle(particle: Particle): void; - getCapacity(): number; - isAlive(): boolean; - isStarted(): boolean; - start(): void; - stop(): void; - _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void; - private _update(newParticles); - private _getEffect(); - animate(): void; - render(): number; - dispose(): void; - clone(name: string, newEmitter: any): ParticleSystem; - serialize(): any; - static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): ParticleSystem; - } -} - -declare module BABYLON { - class SolidParticle { - idx: number; - color: Color4; - position: Vector3; - rotation: Vector3; - rotationQuaternion: Quaternion; - scaling: Vector3; - uvs: Vector4; - velocity: Vector3; - alive: boolean; - _pos: number; - _model: ModelShape; - shapeId: number; - idxInShape: number; - constructor(particleIndex: number, positionIndex: number, model: ModelShape, shapeId: number, idxInShape: number); - scale: Vector3; - quaternion: Quaternion; - } - class ModelShape { - shapeID: number; - _shape: Vector3[]; - _shapeUV: number[]; - _positionFunction: (particle: SolidParticle, i: number, s: number) => void; - _vertexFunction: (particle: SolidParticle, vertex: Vector3, i: number) => void; - constructor(id: number, shape: Vector3[], shapeUV: number[], posFunction: (particle: SolidParticle, i: number, s: number) => void, vtxFunction: (particle: SolidParticle, vertex: Vector3, i: number) => void); - } -} - -declare module BABYLON { - /** - * Full documentation here : http://doc.babylonjs.com/tutorials/Solid_Particle_System - */ - class SolidParticleSystem implements IDisposable { - /** - * The SPS array of Solid Particle objects. Just access each particle as with any classic array. - * Example : var p = SPS.particles[i]; - */ - particles: SolidParticle[]; - /** - * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value. - */ - nbParticles: number; - /** - * If the particles must ever face the camera (default false). Useful for planar particles. - */ - billboard: boolean; - /** - * This a counter ofr your own usage. It's not set by any SPS functions. - */ - counter: number; - /** - * The SPS name. This name is also given to the underlying mesh. - */ - name: string; - /** - * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible. - */ - mesh: Mesh; - /** - * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity. - * Please read : http://doc.babylonjs.com/tutorials/Solid_Particle_System#garbage-collector-concerns - */ - vars: any; - /** - * This array is populated when the SPS is set as 'pickable'. - * Each key of this array is a `faceId` value that you can get from a pickResult object. - * Each element of this array is an object `{idx: int, faceId: int}`. - * `idx` is the picked particle index in the `SPS.particles` array - * `faceId` is the picked face index counted within this particle. - * Please read : http://doc.babylonjs.com/tutorials/Solid_Particle_System#pickable-particles - */ - pickedParticles: { - idx: number; - faceId: number; - }[]; - private _scene; - private _positions; - private _indices; - private _normals; - private _colors; - private _uvs; - private _positions32; - private _normals32; - private _fixedNormal32; - private _colors32; - private _uvs32; - private _index; - private _updatable; - private _pickable; - private _isVisibilityBoxLocked; - private _alwaysVisible; - private _shapeCounter; - private _copy; - private _shape; - private _shapeUV; - private _color; - private _computeParticleColor; - private _computeParticleTexture; - private _computeParticleRotation; - private _computeParticleVertex; - private _computeBoundingBox; - private _cam_axisZ; - private _cam_axisY; - private _cam_axisX; - private _axisX; - private _axisY; - private _axisZ; - private _camera; - private _particle; - private _fakeCamPos; - private _rotMatrix; - private _invertMatrix; - private _rotated; - private _quaternion; - private _vertex; - private _normal; - private _yaw; - private _pitch; - private _roll; - private _halfroll; - private _halfpitch; - private _halfyaw; - private _sinRoll; - private _cosRoll; - private _sinPitch; - private _cosPitch; - private _sinYaw; - private _cosYaw; - private _w; - private _minimum; - private _maximum; - /** - * Creates a SPS (Solid Particle System) object. - * `name` (String) is the SPS name, this will be the underlying mesh name. - * `scene` (Scene) is the scene in which the SPS is added. - * `updatableè (default true) : if the SPS must be updatable or immutable. - * `isPickable` (default false) : if the solid particles must be pickable. - */ - constructor(name: string, scene: Scene, options?: { - updatable?: boolean; - isPickable?: boolean; - }); - /** - * Builds the SPS underlying mesh. Returns a standard Mesh. - * If no model shape was added to the SPS, the returned mesh is just a single triangular plane. - */ - buildMesh(): Mesh; - /** - * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS. - * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places. - * Thus the particles generated from `digest()` have their property `position` set yet. - * `mesh` (`Mesh`) is the mesh to be digested - * `facetNb` (optional integer, default 1) is the number of mesh facets per particle, this parameter is overriden by the parameter `number` if any - * `delta` (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets - * `number` (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets - */ - digest(mesh: Mesh, options?: { - facetNb?: number; - number?: number; - delta?: number; - }): SolidParticleSystem; - private _resetCopy(); - private _meshBuilder(p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, idx, idxInShape, options); - private _posToShape(positions); - private _uvsToShapeUV(uvs); - private _addParticle(idx, idxpos, model, shapeId, idxInShape); - /** - * Adds some particles to the SPS from the model shape. Returns the shape id. - * Please read the doc : http://doc.babylonjs.com/tutorials/Solid_Particle_System#create-an-immutable-sps - * `mesh` is any `Mesh` object that will be used as a model for the solid particles. - * `nb` (positive integer) the number of particles to be created from this model - * `positionFunction` is an optional javascript function to called for each particle on SPS creation. - * `vertexFunction` is an optional javascript function to called for each vertex of each particle on SPS creation - */ - addShape(mesh: Mesh, nb: number, options?: { - positionFunction?: any; - vertexFunction?: any; - }): number; - private _rebuildParticle(particle); - /** - * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed. - */ - rebuildMesh(): void; - /** - * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc. - * This method calls `updateParticle()` for each particle of the SPS. - * For an animated SPS, it is usually called within the render loop. - * @param start (default 0) the particle index in the particle array where to start to compute the particle property values - * @param end (default nbParticle - 1) the particle index in the particle array where to stop to compute the particle property values - * @param update (default true) if the mesh must be finally updated on this call after all the particle computations. - */ - setParticles(start?: number, end?: number, update?: boolean): void; - private _quaternionRotationYPR(); - private _quaternionToRotationMatrix(); - /** - * Disposes the SPS - */ - dispose(): void; - /** - * Visibilty helper : Recomputes the visible size according to the mesh bounding box - * doc : http://doc.babylonjs.com/tutorials/Solid_Particle_System#sps-visibility - */ - refreshVisibleSize(): void; - /** - * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box. - * @param size the size (float) of the visibility box - * note : this doesn't lock the SPS mesh bounding box. - * doc : http://doc.babylonjs.com/tutorials/Solid_Particle_System#sps-visibility - */ - setVisibilityBox(size: number): void; - /** - * Sets the SPS as always visible or not - * doc : http://doc.babylonjs.com/tutorials/Solid_Particle_System#sps-visibility - */ - isAlwaysVisible: boolean; - /** - * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates. - * doc : http://doc.babylonjs.com/tutorials/Solid_Particle_System#sps-visibility - */ - isVisibilityBoxLocked: boolean; - /** - * Tells to `setParticles()` to compute the particle rotations or not. - * Default value : true. The SPS is faster when it's set to false. - * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate. - */ - computeParticleRotation: boolean; - /** - * Tells to `setParticles()` to compute the particle colors or not. - * Default value : true. The SPS is faster when it's set to false. - * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set. - */ - computeParticleColor: boolean; - /** - * Tells to `setParticles()` to compute the particle textures or not. - * Default value : true. The SPS is faster when it's set to false. - * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set. - */ - computeParticleTexture: boolean; - /** - * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not. - * Default value : false. The SPS is faster when it's set to false. - * Note : the particle custom vertex positions aren't stored values. - */ - computeParticleVertex: boolean; - /** - * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions. - */ - computeBoundingBox: boolean; - /** - * This function does nothing. It may be overwritten to set all the particle first values. - * The SPS doesn't call this function, you may have to call it by your own. - * doc : http://doc.babylonjs.com/tutorials/Solid_Particle_System#particle-management - */ - initParticles(): void; - /** - * This function does nothing. It may be overwritten to recycle a particle. - * The SPS doesn't call this function, you may have to call it by your own. - * doc : http://doc.babylonjs.com/tutorials/Solid_Particle_System#particle-management - */ - recycleParticle(particle: SolidParticle): SolidParticle; - /** - * Updates a particle : this function should be overwritten by the user. - * It is called on each particle by `setParticles()`. This is the place to code each particle behavior. - * doc : http://doc.babylonjs.com/tutorials/Solid_Particle_System#particle-management - * ex : just set a particle position or velocity and recycle conditions - */ - updateParticle(particle: SolidParticle): SolidParticle; - /** - * Updates a vertex of a particle : it can be overwritten by the user. - * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only. - * @param particle the current particle - * @param vertex the current index of the current particle - * @param pt the index of the current vertex in the particle shape - * doc : http://doc.babylonjs.com/tutorials/Solid_Particle_System#update-each-particle-shape - * ex : just set a vertex particle position - */ - updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3; - /** - * This will be called before any other treatment by `setParticles()` and will be passed three parameters. - * This does nothing and may be overwritten by the user. - * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle() - * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle() - * @param update the boolean update value actually passed to setParticles() - */ - beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void; - /** - * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update. - * This will be passed three parameters. - * This does nothing and may be overwritten by the user. - * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle() - * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle() - * @param update the boolean update value actually passed to setParticles() - */ - afterUpdateParticles(start?: number, stop?: number, update?: boolean): void; + class VertexBuffer { + private _mesh; + private _engine; + private _buffer; + private _data; + private _updatable; + private _kind; + private _strideSize; + constructor(engine: any, data: number[] | Float32Array, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number); + isUpdatable(): boolean; + getData(): number[] | Float32Array; + getBuffer(): WebGLBuffer; + getStrideSize(): number; + create(data?: number[] | Float32Array): void; + update(data: number[] | Float32Array): void; + updateDirectly(data: Float32Array, offset: number): void; + dispose(): void; + private static _PositionKind; + private static _NormalKind; + 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 PositionKind: string; + static NormalKind: string; + static UVKind: string; + static UV2Kind: string; + static UV3Kind: string; + static UV4Kind: string; + static UV5Kind: string; + static UV6Kind: string; + static ColorKind: string; + static MatricesIndicesKind: string; + static MatricesWeightsKind: string; + static MatricesIndicesExtraKind: string; + static MatricesWeightsExtraKind: string; } } @@ -7240,6 +7240,28 @@ 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); + refreshRate: number; + getScene(): Scene; + cubeTexture: RenderTargetTexture; + renderList: AbstractMesh[]; + attachToMesh(mesh: AbstractMesh): void; + dispose(): void; + } +} + declare module BABYLON { class AnaglyphPostProcess extends PostProcess { constructor(name: string, ratio: number, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean); @@ -7818,28 +7840,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); - refreshRate: number; - getScene(): Scene; - cubeTexture: RenderTargetTexture; - renderList: AbstractMesh[]; - attachToMesh(mesh: AbstractMesh): void; - dispose(): void; - } -} - declare module BABYLON { class BoundingBoxRenderer { frontColor: Color3; @@ -8462,32 +8462,9 @@ declare module BABYLON { declare module BABYLON { /** - * The purpose of this class is to pack several Rectangles into a big map, while trying to fit everything as optimaly 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 lifecycle. - */ - 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. - */ - constructor(size: Size); - /** - * 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 {} - */ - freeSpace: number; - } - /** - * This class describe a rectangle that were added to the map. - * You have access to its coordinates either in pixel or normalized (UV) - */ + * 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: PackedRect, parent: PackedRect, pos: Vector2, size: Size); /** @@ -8526,6 +8503,29 @@ declare module BABYLON { 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 optimaly 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 lifecycle. + */ + 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. + */ + constructor(size: Size); + /** + * 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 {} + */ + freeSpace: number; + } } declare module BABYLON { @@ -8609,26 +8609,6 @@ declare module BABYLON { } } -declare module BABYLON { - class SmartCollection { - count: number; - items: any; - private _keys; - private _initialCapacity; - constructor(capacity?: number); - add(key: any, item: any): number; - remove(key: any): number; - removeItemOfIndex(index: number): number; - indexOf(key: any): number; - item(key: any): any; - getAllKeys(): any[]; - getKeyByIndex(index: number): any; - getItemByIndex(index: number): any; - empty(): void; - forEach(block: (item: any) => void): void; - } -} - declare module BABYLON { /** * This class implement a typical dictionary using a string as key and the generic type T as value. @@ -8957,61 +8937,6 @@ 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; - aspectRatio: number; - aspectRatioFov: number; - leftHMatrix: Matrix; - rightHMatrix: Matrix; - leftPreViewMatrix: Matrix; - rightPreViewMatrix: Matrix; - static GetDefault(): VRCameraMetrics; - } -} - -declare module BABYLON { - class VRDeviceOrientationFreeCamera extends FreeCamera { - constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean); - getTypeName(): string; - } - class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera { - constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean); - getTypeName(): string; - } -} - -declare var HMDVRDevice: any; -declare var PositionSensorVRDevice: any; -declare module BABYLON { - class WebVRFreeCamera extends FreeCamera { - _hmdDevice: any; - _sensorDevice: any; - _cacheState: any; - _cacheQuaternion: Quaternion; - _cacheRotation: Vector3; - _vrEnabled: boolean; - constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean); - private _getWebVRDevices(devices); - _checkInputs(): void; - attachControl(element: HTMLElement, noPreventDefault?: boolean): void; - detachControl(element: HTMLElement): void; - getTypeName(): string; - } -} - declare module BABYLON { class ArcRotateCameraGamepadInput implements ICameraInput { camera: ArcRotateCamera; @@ -9241,6 +9166,61 @@ 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; + aspectRatio: number; + aspectRatioFov: number; + leftHMatrix: Matrix; + rightHMatrix: Matrix; + leftPreViewMatrix: Matrix; + rightPreViewMatrix: Matrix; + static GetDefault(): VRCameraMetrics; + } +} + +declare module BABYLON { + class VRDeviceOrientationFreeCamera extends FreeCamera { + constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean); + getTypeName(): string; + } + class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera { + constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean); + getTypeName(): string; + } +} + +declare var HMDVRDevice: any; +declare var PositionSensorVRDevice: any; +declare module BABYLON { + class WebVRFreeCamera extends FreeCamera { + _hmdDevice: any; + _sensorDevice: any; + _cacheState: any; + _cacheQuaternion: Quaternion; + _cacheRotation: Vector3; + _vrEnabled: boolean; + constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean); + private _getWebVRDevices(devices); + _checkInputs(): void; + attachControl(element: HTMLElement, noPreventDefault?: boolean): void; + detachControl(element: HTMLElement): void; + getTypeName(): string; + } +} + declare module BABYLON { interface IOctreeContainer { blocks: Array>; @@ -9346,6 +9326,9 @@ declare module BABYLON { } } +declare module BABYLON.Internals { +} + declare module BABYLON { class BaseTexture { name: string; @@ -9668,9 +9651,6 @@ declare module BABYLON { } } -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 5b9bb452be1..aea20037837 100644 --- a/dist/preview release/babylon.js +++ b/dist/preview release/babylon.js @@ -19,7 +19,7 @@ a=a>s?s:Math.floor(a);var h,c,l,u,d=0===i.sideOrientation?0:i.sideOrientation||e this._renderEffectsForIsolatedPass[l]._attachCameras(c)}}},t.prototype._disableDisplayOnlyPass=function(i){for(var n=this,r=e.Tools.MakeArray(i||this._cameras),o=0;othis.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}),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),i._actionManager=this,i._prepare(),i)},t.prototype.processTrigger=function(e,i){for(var n=0;n0;if(2===i.type?d.push(o):d.push(n),m){for(var _=new Array,g=0;g0){var d=u.properties[0].value,f=null===u.properties[0].targetType?d:r.getMeshByName(d);l={trigger:e.ActionManager[u.name],parameter:f}}else l=e.ActionManager[u.name];for(var p=0;pa;a++){var h=o[a];h._resetPointsArrayCache(),h._boundingInfo=new e.BoundingInfo(this._extend.minimum,this._extend.maximum),h._createGlobalSubMesh(),h.computeWorldMatrix(!0)}}this.notifyUpdate(t)},t.prototype.updateVerticesDataDirectly=function(e,t,i){var n=this.getVertexBuffer(e);n&&(n.updateDirectly(t,i),this.notifyUpdate(e))},t.prototype.updateVerticesData=function(t,i,n){var r=this.getVertexBuffer(t);if(r){if(r.update(i),t===e.VertexBuffer.PositionKind){var o=r.getStrideSize();this._totalVertices=i.length/o,this.updateBoundingInfo(n,i)}this.notifyUpdate(t)}},t.prototype.updateBoundingInfo=function(t,i){t&&this.updateExtend(i);for(var n=this._meshes,r=n.length,o=0;r>o;o++){var s=n[o];if(s._resetPointsArrayCache(),t){s._boundingInfo=new e.BoundingInfo(this._extend.minimum,this._extend.maximum);for(var a=0;as;s++)o.push(n[s]);return o}return n},t.prototype.getVertexBuffer=function(e){return this.isReady()?this._vertexBuffers[e]:null},t.prototype.getVertexBuffers=function(){return this.isReady()?this._vertexBuffers:null},t.prototype.isVerticesDataPresent=function(e){return this._vertexBuffers?void 0!==this._vertexBuffers[e]:this._delayInfo?-1!==this._delayInfo.indexOf(e):!1},t.prototype.getVerticesDataKinds=function(){var e,t=[];if(!this._vertexBuffers&&this._delayInfo)for(e in this._delayInfo)t.push(e);else for(e in this._vertexBuffers)t.push(e);return t},t.prototype.setIndices=function(e,t){this._indexBuffer&&this._engine._releaseBuffer(this._indexBuffer),this._indices=e,0!==this._meshes.length&&this._indices&&(this._indexBuffer=this._engine.createIndexBuffer(this._indices)),void 0!==t&&(this._totalVertices=t);for(var i=this._meshes,n=i.length,r=0;n>r;r++)i[r]._createGlobalSubMesh();this.notifyUpdate()},t.prototype.getTotalIndices=function(){return this.isReady()?this._indices.length:0},t.prototype.getIndices=function(e){if(!this.isReady())return null;var t=this._indices;if(e&&1!==this._meshes.length){for(var i=t.length,n=[],r=0;i>r;r++)n.push(t[r]);return n}return t},t.prototype.getIndexBuffer=function(){return this.isReady()?this._indexBuffer:null},t.prototype.releaseForMesh=function(e,t){var i=this._meshes,n=i.indexOf(e);if(-1!==n){for(var r in this._vertexBuffers)this._vertexBuffers[r].dispose();this._indexBuffer&&this._engine._releaseBuffer(this._indexBuffer)&&(this._indexBuffer=null),i.splice(n,1),e._geometry=null,0===i.length&&t&&this.dispose()}},t.prototype.applyToMesh=function(e){if(e._geometry!==this){var t=e._geometry;t&&t.releaseForMesh(e);var i=this._meshes;e._geometry=this,this._scene.pushGeometry(this),i.push(e),this.isReady()?this._applyToMesh(e):e._boundingInfo=this._boundingInfo}},t.prototype.updateExtend=function(t){void 0===t&&(t=null),t||(t=this._vertexBuffers[e.VertexBuffer.PositionKind].getData()),this._extend=e.Tools.ExtractMinAndMax(t,0,this._totalVertices,this.boundingBias)},t.prototype._applyToMesh=function(t){var i=this._meshes.length;for(var n in this._vertexBuffers)1===i&&this._vertexBuffers[n].create(),this._vertexBuffers[n]._buffer.references=i,n===e.VertexBuffer.PositionKind&&(t._resetPointsArrayCache(),this._extend||this.updateExtend(this._vertexBuffers[n].getData()),t._boundingInfo=new e.BoundingInfo(this._extend.minimum,this._extend.maximum),t._createGlobalSubMesh(),t._updateBoundingInfo());1===i&&this._indices&&(this._indexBuffer=this._engine.createIndexBuffer(this._indices)),this._indexBuffer&&(this._indexBuffer.references=i)},t.prototype.notifyUpdate=function(e){this.onGeometryUpdated&&this.onGeometryUpdated(this,e)},t.prototype.load=function(t,i){var n=this;if(this.delayLoadState!==e.Engine.DELAYLOADSTATE_LOADING){if(this.isReady())return void(i&&i());this.delayLoadState=e.Engine.DELAYLOADSTATE_LOADING,t._addPendingData(this),e.Tools.LoadFile(this.delayLoadingFile,function(r){n._delayLoadingFunction(JSON.parse(r),n),n.delayLoadState=e.Engine.DELAYLOADSTATE_LOADED,n._delayInfo=[],t._removePendingData(n);for(var o=n._meshes,s=o.length,a=0;s>a;a++)n._applyToMesh(o[a]);i&&i()},function(){},t.database)}},t.prototype.isDisposed=function(){return this._isDisposed},t.prototype.dispose=function(){var t,i=this._meshes,n=i.length;for(t=0;n>t;t++)this.releaseForMesh(i[t]);this._meshes=[];for(var r in this._vertexBuffers)this._vertexBuffers[r].dispose();this._vertexBuffers=[],this._totalVertices=0,this._indexBuffer&&this._engine._releaseBuffer(this._indexBuffer),this._indexBuffer=null,this._indices=[],this.delayLoadState=e.Engine.DELAYLOADSTATE_NONE,this.delayLoadingFile=null,this._delayLoadingFunction=null,this._delayInfo=[],this._boundingInfo=null,this._scene.removeGeometry(this),this._isDisposed=!0},t.prototype.copy=function(i){var n=new e.VertexData;n.indices=[];for(var r=this.getIndices(),o=0;o0){var a=new Float32Array(t,s.positionsAttrDesc.offset,s.positionsAttrDesc.count);i.setVerticesData(e.VertexBuffer.PositionKind,a,!1)}if(s.normalsAttrDesc&&s.normalsAttrDesc.count>0){var h=new Float32Array(t,s.normalsAttrDesc.offset,s.normalsAttrDesc.count);i.setVerticesData(e.VertexBuffer.NormalKind,h,!1)}if(s.uvsAttrDesc&&s.uvsAttrDesc.count>0){var c=new Float32Array(t,s.uvsAttrDesc.offset,s.uvsAttrDesc.count);i.setVerticesData(e.VertexBuffer.UVKind,c,!1)}if(s.uvs2AttrDesc&&s.uvs2AttrDesc.count>0){var l=new Float32Array(t,s.uvs2AttrDesc.offset,s.uvs2AttrDesc.count);i.setVerticesData(e.VertexBuffer.UV2Kind,l,!1)}if(s.uvs3AttrDesc&&s.uvs3AttrDesc.count>0){var u=new Float32Array(t,s.uvs3AttrDesc.offset,s.uvs3AttrDesc.count);i.setVerticesData(e.VertexBuffer.UV3Kind,u,!1)}if(s.uvs4AttrDesc&&s.uvs4AttrDesc.count>0){var d=new Float32Array(t,s.uvs4AttrDesc.offset,s.uvs4AttrDesc.count);i.setVerticesData(e.VertexBuffer.UV4Kind,d,!1)}if(s.uvs5AttrDesc&&s.uvs5AttrDesc.count>0){var f=new Float32Array(t,s.uvs5AttrDesc.offset,s.uvs5AttrDesc.count);i.setVerticesData(e.VertexBuffer.UV5Kind,f,!1)}if(s.uvs6AttrDesc&&s.uvs6AttrDesc.count>0){var p=new Float32Array(t,s.uvs6AttrDesc.offset,s.uvs6AttrDesc.count);i.setVerticesData(e.VertexBuffer.UV6Kind,p,!1)}if(s.colorsAttrDesc&&s.colorsAttrDesc.count>0){var m=new Float32Array(t,s.colorsAttrDesc.offset,s.colorsAttrDesc.count);i.setVerticesData(e.VertexBuffer.ColorKind,m,!1,s.colorsAttrDesc.stride)}if(s.matricesIndicesAttrDesc&&s.matricesIndicesAttrDesc.count>0){var _=new Int32Array(t,s.matricesIndicesAttrDesc.offset,s.matricesIndicesAttrDesc.count);i.setVerticesData(e.VertexBuffer.MatricesIndicesKind,_,!1)}if(s.matricesWeightsAttrDesc&&s.matricesWeightsAttrDesc.count>0){var g=new Float32Array(t,s.matricesWeightsAttrDesc.offset,s.matricesWeightsAttrDesc.count);i.setVerticesData(e.VertexBuffer.MatricesWeightsKind,g,!1)}if(s.indicesAttrDesc&&s.indicesAttrDesc.count>0){var v=new Int32Array(t,s.indicesAttrDesc.offset,s.indicesAttrDesc.count);i.setIndices(v)}if(s.subMeshesAttrDesc&&s.subMeshesAttrDesc.count>0){var y=new Int32Array(t,s.subMeshesAttrDesc.offset,5*s.subMeshesAttrDesc.count);i.subMeshes=[];for(var x=0;x>8),M.push((16711680&S)>>16),M.push(S>>24)}i.setVerticesData(e.VertexBuffer.MatricesIndicesKind,M,!1)}if(t.matricesIndicesExtra)if(t.matricesIndicesExtra._isExpanded)delete t.matricesIndices._isExpanded,i.setVerticesData(e.VertexBuffer.MatricesIndicesExtraKind,t.matricesIndicesExtra,!1);else{for(var M=[],x=0;x>8),M.push((16711680&S)>>16),M.push(S>>24)}i.setVerticesData(e.VertexBuffer.MatricesIndicesExtraKind,M,!1)}t.matricesWeights&&i.setVerticesData(e.VertexBuffer.MatricesWeightsKind,t.matricesWeights,!1),t.matricesWeightsExtra&&i.setVerticesData(e.VertexBuffer.MatricesWeightsExtraKind,t.matricesWeightsExtra,!1),i.setIndices(t.indices)}if(t.subMeshes){i.subMeshes=[];for(var C=0;Cthis._maxX||tthis._maxZ)return this.position.y;this._heightQuads&&0!=this._heightQuads.length||(this._initHeightQuads(),this._computeHeightQuads());var i=this._getFacetAt(e,t),n=-(i.x*e+i.z*t+i.w)/i.y;return n*this.scaling.y+this.position.y},i.prototype.getNormalAtCoordinates=function(t,i){var n=new e.Vector3(0,1,0);return this.getNormalAtCoordinatesToRef(t,i,n),n},i.prototype.getNormalAtCoordinatesToRef=function(e,t,i){if(e-=this.position.x,t-=this.position.z,e/=this.scaling.x,t/=this.scaling.z,!(ethis._maxX||tthis._maxZ)){this._heightQuads&&0!=this._heightQuads.length||(this._initHeightQuads(),this._computeHeightQuads());var n=this._getFacetAt(e,t);i.x=n.x,i.y=n.y,i.z=n.z}},i.prototype.updateCoordinateHeights=function(){this._heightQuads&&0!=this._heightQuads.length||this._initHeightQuads(),this._computeHeightQuads()},i.prototype._getFacetAt=function(e,t){var i,n=Math.floor((e+this._maxX)*this._subdivisions/this._width),r=Math.floor(-(t+this._maxZ)*this._subdivisions/this._height+this._subdivisions),o=this._heightQuads[r*this._subdivisions+n];return i=tt.name?1:-1});for(var t=0;t0&&t.z<1){this._drawingContext.font="normal 12px Segoe UI";var o=this._drawingContext.measureText(e),s=t.x-o.width/2,a=t.y,h=this._drawingCanvas.getBoundingClientRect();this._showUI&&this._isClickInsideRect(h.left*this._ratio+s-5,h.top*this._ratio+a-i-12,o.width+10,17)&&n(),this._drawingContext.beginPath(),this._drawingContext.rect(s-5,a-i-12,o.width+10,17),this._drawingContext.fillStyle=r(),this._drawingContext.globalAlpha=.5,this._drawingContext.fill(),this._drawingContext.globalAlpha=1,this._drawingContext.strokeStyle="#FFFFFF",this._drawingContext.lineWidth=1,this._drawingContext.stroke(),this._drawingContext.fillStyle="#FFFFFF",this._drawingContext.fillText(e,s,a-i),this._drawingContext.beginPath(),this._drawingContext.arc(t.x,a,5,0,2*Math.PI,!1),this._drawingContext.fill()}},t.prototype._isClickInsideRect=function(e,t,i,n){return this._clickPosition?this._clickPosition.xe+i?!1:!(this._clickPosition.yt+n):!1},t.prototype.isVisible=function(){return this._enabled},t.prototype.hide=function(){if(this._enabled){this._enabled=!1;var t=this._scene.getEngine();this._scene.unregisterBeforeRender(this._syncData),this._scene.unregisterAfterRender(this._syncUI),this._rootElement.removeChild(this._globalDiv),this._scene.forceShowBoundingBoxes=!1,this._scene.forceWireframe=!1,e.StandardMaterial.DiffuseTextureEnabled=!0,e.StandardMaterial.AmbientTextureEnabled=!0,e.StandardMaterial.SpecularTextureEnabled=!0,e.StandardMaterial.EmissiveTextureEnabled=!0,e.StandardMaterial.BumpTextureEnabled=!0,e.StandardMaterial.OpacityTextureEnabled=!0,e.StandardMaterial.ReflectionTextureEnabled=!0,e.StandardMaterial.LightmapTextureEnabled=!0,e.StandardMaterial.RefractionTextureEnabled=!0,this._scene.shadowsEnabled=!0,this._scene.particlesEnabled=!0,this._scene.postProcessesEnabled=!0,this._scene.collisionsEnabled=!0,this._scene.lightsEnabled=!0,this._scene.texturesEnabled=!0,this._scene.lensFlaresEnabled=!0,this._scene.proceduralTexturesEnabled=!0,this._scene.renderTargetsEnabled=!0,this._scene.probesEnabled=!0,t.getRenderingCanvas().removeEventListener("click",this._onCanvasClick),this._clearSkeletonViewers()}},t.prototype._clearSkeletonViewers=function(){for(var e=0;eWindows:",this.accentColor),this._generateCheckBox(this._optionsSubsetDiv,"Statistics",this._displayStatistics,function(e){t._displayStatistics=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Logs",this._displayLogs,function(e){t._displayLogs=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Meshes tree",this._displayTree,function(e){t._displayTree=e.checked,t._needToRefreshMeshesTree=!0}),this._optionsSubsetDiv.appendChild(document.createElement("br")),this._generateTexBox(this._optionsSubsetDiv,"General:",this.accentColor),this._generateCheckBox(this._optionsSubsetDiv,"Bounding boxes",this._scene.forceShowBoundingBoxes,function(e){t._scene.forceShowBoundingBoxes=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Clickable labels",this._labelsEnabled,function(e){t._labelsEnabled=e.checked,t._labelsEnabled||t._clearLabels()}),this._generateCheckBox(this._optionsSubsetDiv,"Generate user marks (F12)",e.Tools.PerformanceLogLevel===e.Tools.PerformanceUserMarkLogLevel,function(t){t.checked?e.Tools.PerformanceLogLevel=e.Tools.PerformanceUserMarkLogLevel:e.Tools.PerformanceLogLevel=e.Tools.PerformanceNoneLogLevel}),this._optionsSubsetDiv.appendChild(document.createElement("br")),this._generateTexBox(this._optionsSubsetDiv,"Rendering mode:",this.accentColor),this._generateRadio(this._optionsSubsetDiv,"Solid","renderMode",!this._scene.forceWireframe&&!this._scene.forcePointsCloud,function(e){e.checked&&(t._scene.forceWireframe=!1,t._scene.forcePointsCloud=!1)}),this._generateRadio(this._optionsSubsetDiv,"Wireframe","renderMode",this._scene.forceWireframe,function(e){e.checked&&(t._scene.forceWireframe=!0,t._scene.forcePointsCloud=!1)}),this._generateRadio(this._optionsSubsetDiv,"Point","renderMode",this._scene.forcePointsCloud,function(e){e.checked&&(t._scene.forceWireframe=!1,t._scene.forcePointsCloud=!0)}),this._optionsSubsetDiv.appendChild(document.createElement("br")),this._generateTexBox(this._optionsSubsetDiv,"Texture channels:",this.accentColor),this._generateCheckBox(this._optionsSubsetDiv,"Diffuse",e.StandardMaterial.DiffuseTextureEnabled,function(t){e.StandardMaterial.DiffuseTextureEnabled=t.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Ambient",e.StandardMaterial.AmbientTextureEnabled,function(t){e.StandardMaterial.AmbientTextureEnabled=t.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Specular",e.StandardMaterial.SpecularTextureEnabled,function(t){e.StandardMaterial.SpecularTextureEnabled=t.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Emissive",e.StandardMaterial.EmissiveTextureEnabled,function(t){e.StandardMaterial.EmissiveTextureEnabled=t.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Bump",e.StandardMaterial.BumpTextureEnabled,function(t){e.StandardMaterial.BumpTextureEnabled=t.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Opacity",e.StandardMaterial.OpacityTextureEnabled,function(t){e.StandardMaterial.OpacityTextureEnabled=t.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Reflection",e.StandardMaterial.ReflectionTextureEnabled,function(t){e.StandardMaterial.ReflectionTextureEnabled=t.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Refraction",e.StandardMaterial.RefractionTextureEnabled,function(t){e.StandardMaterial.RefractionTextureEnabled=t.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Lightmap",e.StandardMaterial.LightmapTextureEnabled,function(t){e.StandardMaterial.LightmapTextureEnabled=t.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Fresnel",e.StandardMaterial.FresnelEnabled,function(t){e.StandardMaterial.FresnelEnabled=t.checked}),this._optionsSubsetDiv.appendChild(document.createElement("br")),this._generateTexBox(this._optionsSubsetDiv,"Options:",this.accentColor),this._generateCheckBox(this._optionsSubsetDiv,"Animations",this._scene.animationsEnabled,function(e){t._scene.animationsEnabled=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Collisions",this._scene.collisionsEnabled,function(e){t._scene.collisionsEnabled=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Fog",this._scene.fogEnabled,function(e){t._scene.fogEnabled=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Lens flares",this._scene.lensFlaresEnabled,function(e){t._scene.lensFlaresEnabled=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Lights",this._scene.lightsEnabled,function(e){t._scene.lightsEnabled=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Particles",this._scene.particlesEnabled,function(e){t._scene.particlesEnabled=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Post-processes",this._scene.postProcessesEnabled,function(e){t._scene.postProcessesEnabled=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Probes",this._scene.probesEnabled,function(e){t._scene.probesEnabled=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Procedural textures",this._scene.proceduralTexturesEnabled,function(e){t._scene.proceduralTexturesEnabled=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Render targets",this._scene.renderTargetsEnabled,function(e){t._scene.renderTargetsEnabled=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Shadows",this._scene.shadowsEnabled,function(e){t._scene.shadowsEnabled=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Skeletons",this._scene.skeletonsEnabled,function(e){t._scene.skeletonsEnabled=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Sprites",this._scene.spritesEnabled,function(e){t._scene.spritesEnabled=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Textures",this._scene.texturesEnabled,function(e){t._scene.texturesEnabled=e.checked}),e.AudioEngine&&e.Engine.audioEngine.canUseWebAudio&&(this._optionsSubsetDiv.appendChild(document.createElement("br")),this._generateTexBox(this._optionsSubsetDiv,"Audio:",this.accentColor),this._generateRadio(this._optionsSubsetDiv,"Headphones","panningModel",this._scene.headphone,function(e){e.checked&&(t._scene.headphone=!0)}),this._generateRadio(this._optionsSubsetDiv,"Normal Speakers","panningModel",!this._scene.headphone,function(e){e.checked&&(t._scene.headphone=!1)}),this._generateCheckBox(this._optionsSubsetDiv,"Disable audio",!this._scene.audioEnabled,function(e){t._scene.audioEnabled=!e.checked})),this._optionsSubsetDiv.appendChild(document.createElement("br")),this._generateTexBox(this._optionsSubsetDiv,"Viewers:",this.accentColor),this._generateCheckBox(this._optionsSubsetDiv,"Skeletons",!1,function(i){if(!i.checked)return void t._clearSkeletonViewers();for(var n=0;nTools:",this.accentColor),this._generateButton(this._optionsSubsetDiv,"Dump rendertargets",function(e){t._scene.dumpNextRenderTargets=!0}),this._generateButton(this._optionsSubsetDiv,"Run SceneOptimizer",function(i){e.SceneOptimizer.OptimizeAsync(t._scene)}),this._generateButton(this._optionsSubsetDiv,"Log camera object",function(e){t._camera?console.log(t._camera):console.warn("No camera defined, or debug layer created before camera creation!")}),this._optionsSubsetDiv.appendChild(document.createElement("br")),this._globalDiv.appendChild(this._statsDiv),this._globalDiv.appendChild(this._logDiv),this._globalDiv.appendChild(this._optionsDiv),this._globalDiv.appendChild(this._treeDiv)}},t.prototype._displayStats=function(){var t=this._scene,i=t.getEngine(),n=i.getGlInfo();this._statsSubsetDiv.innerHTML="Babylon.js v"+e.Engine.Version+" - "+e.Tools.Format(i.getFps(),0)+" fps

Count
Total meshes: "+t.meshes.length+"
Total lights: "+t.lights.length+"
Total vertices: "+t.getTotalVertices()+"
Total materials: "+t.materials.length+"
Total textures: "+t.textures.length+"
Active meshes: "+t.getActiveMeshes().length+"
Active indices: "+t.getActiveIndices()+"
Active bones: "+t.getActiveBones()+"
Active particles: "+t.getActiveParticles()+"
Draw calls: "+i.drawCalls+"

Duration
Meshes selection: "+e.Tools.Format(t.getEvaluateActiveMeshesDuration())+" ms
Render Targets: "+e.Tools.Format(t.getRenderTargetsDuration())+" ms
Particles: "+e.Tools.Format(t.getParticlesDuration())+" ms
Sprites: "+e.Tools.Format(t.getSpritesDuration())+" ms

Render: "+e.Tools.Format(t.getRenderDuration())+" ms
Frame: "+e.Tools.Format(t.getLastFrameDuration())+" ms
Potential FPS: "+e.Tools.Format(1e3/t.getLastFrameDuration(),0)+"
Resolution: "+i.getRenderWidth()+"x"+i.getRenderHeight()+"

Extensions
Std derivatives: "+(i.getCaps().standardDerivatives?"Yes":"No")+"
Compressed textures: "+(i.getCaps().s3tc?"Yes":"No")+"
Hardware instances: "+(i.getCaps().instancedArrays?"Yes":"No")+"
Texture float: "+(i.getCaps().textureFloat?"Yes":"No")+"

32bits indices: "+(i.getCaps().uintIndices?"Yes":"No")+"
Fragment depth: "+(i.getCaps().fragmentDepthSupported?"Yes":"No")+"
High precision shaders: "+(i.getCaps().highPrecisionShaderSupported?"Yes":"No")+"
Draw buffers: "+(i.getCaps().drawBuffersExtension?"Yes":"No")+"

Caps.
Max textures units: "+i.getCaps().maxTexturesImageUnits+"
Max textures size: "+i.getCaps().maxTextureSize+"
Max anisotropy: "+i.getCaps().maxAnisotropy+"
Info
WebGL feature level: "+i.webGLVersion+"
"+n.version+"

"+n.renderer+"
",this.customStatsFunction&&(this._statsSubsetDiv.innerHTML+=this._statsSubsetDiv.innerHTML)},t}();e.DebugLayer=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function e(e,t,i){var n=this;void 0===t&&(t=""),void 0===i&&(i="black"),this._renderingCanvas=e,this._loadingText=t,this._loadingDivBackgroundColor=i,this._resizeLoadingUI=function(){var e=n._renderingCanvas.getBoundingClientRect();n._loadingDiv.style.position="absolute",n._loadingDiv.style.left=e.left+"px",n._loadingDiv.style.top=e.top+"px",n._loadingDiv.style.width=e.width+"px",n._loadingDiv.style.height=e.height+"px"}}return e.prototype.displayLoadingUI=function(){var e=this;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 t=new Image;t.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAYdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuM4zml1AAAARbSURBVHhe7Z09aFNRFMc716kuLrq4FdyLq4Wi4CAoRQcR0UJBUBdRiuLSIYMo6CA4FF2sgw6CFAdFUOpSQYcWO4hD26UQCfXrIQrx/JJzw1OSWq3NPeL/B4Fy+0jg/HO+7j3vpUcI8b/Q39+/49ihfWdPHT94Yf/e3Se3bd263f8lus218TPn6vV6Ya8Wi/MzNRNmj18iusX9W1evmP1/EKNEIVG6CMbG6E3bt+fT++pHha8NoHdT72bLE8NDg7tGU64gLLndV4Wc4m8j/pS+vr4tGB/DT16v3Fyr8dvBe/jbit8BL0AES9LX1iPAz+BR/hFiLVCynj95dPzNy6fv3IZ/k4L3948Sq7FzYGBg4vLFGxitabuOFCbWNKGrMnbiUuo18KaV6tIHv6YtvL9/nOgE31jCktmrY7k6+/zhE4yP4Vf7hiNqh/BWWEl8mzDol4p22Lf7cIdvdUMEvv0Y2S9fE5S1hLzpqTsPkiep//gFGPnR3Yl7GL5p/xYFBrTwM+iXio3GqpwDGL5p/xYNIX7XG8Q6IJRgdIzf1KBBgafII7oMidhyQtVFaMA2Bt7il4huQRhaXphbcR2g4RXqBzKAGHiCCwGFVUAj/m/RTRDj29cvn10I0PZ3LghH5f4CL1EFlQmqqXK3jDDKFxmhQ3Yt6oQseUZGKmMnTpsOqc8o1F9kBOMjQlOLeqEeIyOc6JV6jYLJD/+XyIFvnzdgl9aXRQ5I2qZDK1SpospMqaoqON/wZZGDciLnMMiXRS7IF4hhqMTNTdk7CFu+LHLhR7BQqBvPDJUUQqCGvCMATHUgBmhWNgApmdOda9YpM+VwRYfuyyIXDK8hBlilNerLIheMZCKGwlUAyru6GlwOgPUbRxADdJ9FAChxXY864viyyEXqPxhc0M2TAfAbatSdRyHtXymhByEdRnE3ky+JnHAIhSA0h74kckETmHoQbSgGwJrCIRMEPSRIBCRIMAhZaYhaggQhJXUJEoRU9mofKwh+F22dLRRfEjlJM7w6KQwCoQpBOKTyJZETjmwRxKqtGV8SOSkNOGjKPQppBEgDDkFgpxdBVGkFgaYQQXRIFQSObk0P5ZFIpAZRHXsQ0r0hCluBWKkuvVbYCkQaCdL5ehBScudJP4yY+rLISdps1NBDEJKXMMmoSfggWC4ZQRR17oFYXph7hSiquIKQ+hJGTX1J5MYSPD/GVdNzsgLBwZVCVyAQAkF0ohiI/c1fS6tNXq9UfEnkhudmIQolsS+J3Hh/UtNDzQLhj42VKJFInqLwFYiUU5ToA+HdfI0JevUpQUAIn+vSz2lHIuUV/dJOIHhOY/IWVWGBIHQtzs88s9zyWBuTgcBLzGOmeNnfF/QslSDgMeQW85i3DOQxuipxAkCyZ8SIm4Omp+7MMlCB59j6sKZcMoM4iIEoeI2J9AKxrFobZx0v4vYInuHFS4J1GQRCAGaLEYQXfyMML5XSQgghhBBCCCH+cXp6vgNhKpSKX/XdOAAAAABJRU5ErkJggg==",t.style.position="absolute",t.style.left="50%",t.style.top="50%",t.style.marginLeft="-50px",t.style.marginTop="-50px",t.style.transition="transform 1.0s ease",t.style.webkitTransition="-webkit-transform 1.0s ease";var i=360,n=function(){i+=360,t.style.transform="rotateZ("+i+"deg)",t.style.webkitTransform="rotateZ("+i+"deg)"};t.addEventListener("transitionend",n),t.addEventListener("webkitTransitionEnd",n),this._loadingDiv.appendChild(t);var r=new Image;r.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAYdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuM4zml1AAAAYJSURBVHhe7Zy/qx1FFMff/2Av2Nvbi4WFiiAEY/OQ2IgQsbCJQoqkCAgpFLXyoZURLfwBIiIpgqZJoYQYlWelNsIrNOxDJcrzfHe+G97dnTl75u7euzv7zgcWHrlnZmfOmXPmzI/NjuM4juM4juM4juM4juM4juM4juM4juM45fPic08/uHf5/CvffH7lnT8PfrtxdHS0n3p+/fHGl5+89/prr5599iEWd8bg0rkXHoFyqehKnlxQpjYSDHTm9JMPsGrHylOPPXofvICKXMcIGtXdf/76AYbm6xyNW9e/eAtKC7rbKLXnvHHx5Sf4auc4Ek7OQkFU1Dap/vv37k/wSjblZANFiFIGzw98hhizwqBgs04mCBdQRNCHidoAEtY+lLIvtSdoGFeyql2ZH57HBH4sE7O+o/r9l+8/ZXUni68+2jsHBQQ9qNRGeP/tSxdSYQX/roUcpL4/f3vtM9TD+jTq92n1LQ7jxF1hhGPtwWL3gGccy8JuS1r8sVWBGXNVdSKMYjBGPUJjCzooiGuSpnwlnnOGP2dhHRSLNgpHp2oMKIriK8TmG4Qh/rwW8D6pps9b9im+LDDipXOqMVJrAngBfg9i98gevWKA+/nnCod3Dr5GfaHaDgidVym6HKRjGIkpqthcAVKGxNqBImbEo66kjCih8AOpNmkUmbMuUrR8kEqiU6FvHZLGAPJ71JCYSyhiBqmwFE2GoD6jLGIfDHtG6EzoU4dK21PCqIRMEF0FGRjFzGDtIkXVAdATvsqfT9CJ0JcOFdYiFIsiMlqYy1YOFpQo2OddqBtyEaq9y+efoVh5oPHoROjLKn0j3JIE5Ka8UqZRtGrMnneX6yVofOhDh94MSbznTcpqmDOt1vyQzOgaJAF4F3JBfIXesrNEGWWmjIX7UBZ6jRJbBMLg/DmJiKUGVHleIpnVNTa+jakzkAviJqLhi4MC9XQGBrZeKJZESSrKy7ik0VGFWhQBRDTHIACKQ5l9nAjy75gya4a2w+Jhs0FJdc0xX/GwUbAqFBkZi7QpJ2w16WUbjFyK9MJF3KaoEM74KhVtLrQOrsmRxkbdHEqmSC/c+EuGnIFkjW7Ih2Kr4CCMIvNG2hrrgLpCjiFloooYCjyYrzCRyvhyBthkIPuQtsZGdnbMTezyDiU71KTC5zr7aVsHbsz2tllrEkS5UHwU1tq1HbtPW4UbeB0O7xx8R5EsMJql+BheUmHjkNVmIRP7LutoM3+D4O4tG7vCkNO9ESZ4lL3J6rKRMPx4qKbD/A0icf8CG7tC7kTahnMTwleuYSrsS7GatRAvfZh1tTm5BmmQCdZ8a0Sefe28xUrRBkmFLKy8KTIKUDRX0Y1xagPgwbaIdeFnQULmKak3xvwNMkVGgok/N5XNoehJvejRlCDl9escI28dJU0tZ++nBTJE9mEF647x5Ehbo4s5hDOKFIU0PdofeA5F5k1q63zIWmQqNI/P3ZubjFTqKxQ3jyjHAOX0RdlgVO9hzRFpczRcjZ3Gbxxpc7Qj6+5pTYF2OFXawNI+yDGf1k2NcvOlzBQeDQ/t7zD7DsEDpJ2xATXaNtDWUS4IzP4DS2ljajAVu57SUkYw245ptxZxA5JiZaJ0DswudGn3kYUy54426EjoT4dZfYbccxC2nI92cDkZHQr96jD4AGkMDKeSy/COBsRe6VTSKFN6irLeaCh3IteQjt1E5+oudsG/b/2DfZ5AqsYo8vMDK9LB1HzSsLWvlGThdxXvC6+NsqyPPWP0pMINtbdsajfVeC6f/GZ+cdAofQoB1d+Hf9waY98I7+RXWab3Lt4zYkjHtTnlOLXHYMsCh1zWeQYehu1zfNPOOiys/d91LAKEBSgh6MJMbSA82AaHofDgAIwbgvVvlLNS11nModMm4UZergLHZBZrodmBuA3lBB1thdorSjkOmATMDwg/UBQVtglqQyx6fbEJ+H3IWIapjYAjAfeIgeCMHldueJvFaqDaAHhwf8qNsEEQ1iQbOoUUGIbCLRc8+Bvfp4jyd2FEijuO4ziO4ziO4ziO4ziO4ziO4ziO4ziOUzw7O/8D0P7rcZ/GEboAAAAASUVORK5CYII=",r.style.position="absolute",r.style.left="50%",r.style.top="50%",r.style.marginLeft="-50px",r.style.marginTop="-50px",this._loadingDiv.appendChild(r),this._resizeLoadingUI(),window.addEventListener("resize",this._resizeLoadingUI),this._loadingDiv.style.backgroundColor=this._loadingDivBackgroundColor,document.body.appendChild(this._loadingDiv),setTimeout(function(){e._loadingDiv.style.opacity="1",t.style.transform="rotateZ(360deg)",t.style.webkitTransform="rotateZ(360deg)"},0)}},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(){this._audioContext=null,this._audioContextInitialized=!1,this.canUseWebAudio=!1,this.WarnedWebAudioUnsupported=!1,this.unlocked=!1,"undefined"==typeof window.AudioContext&&"undefined"==typeof window.webkitAudioContext||(window.AudioContext=window.AudioContext||window.webkitAudioContext,this.canUseWebAudio=!0),/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),n=e.audioContext.createBufferSource();n.buffer=i,n.connect(e.audioContext.destination),n.start(0),setTimeout(function(){n.playbackState!==n.PLAYING_STATE&&n.playbackState!==n.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,n,r,o){var s=this;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.name=t,this._scene=n,this._readyToPlayCallback=r,this._customAttenuationFunction=function(e,t,i,n,r){return i>t?e*(1-t/i):0},o&&(this.autoplay=o.autoplay||!1,this.loop=o.loop||!1,void 0!==o.volume&&(this._volume=o.volume),this.spatialSound=o.spatialSound||!1,this.maxDistance=o.maxDistance||100,this.useCustomAttenuation=o.useCustomAttenuation||!1,this.rolloffFactor=o.rolloffFactor||1,this.refDistance=o.refDistance||1,this.distanceModel=o.distanceModel||"linear",this._playbackRate=o.playbackRate||1,this._streaming=o.streaming||!1),e.Engine.audioEngine.canUseWebAudio?(this._soundGain=e.Engine.audioEngine.audioContext.createGain(),this._soundGain.gain.value=this._volume,this._inputAudioNode=this._soundGain,this._ouputAudioNode=this._soundGain,this.spatialSound&&this._createSpatialParameters(),this._scene.mainSoundTrack.AddSound(this),i&&("string"==typeof i?this._streaming?(this._htmlAudioElement=new Audio(i),this._htmlAudioElement.controls=!1,this._htmlAudioElement.loop=this.loop,this._htmlAudioElement.crossOrigin="anonymous",this._htmlAudioElement.preload="auto",this._htmlAudioElement.addEventListener("canplaythrough",function(){s._isReadyToPlay=!0,s.autoplay&&s.play(),s._readyToPlayCallback&&s._readyToPlayCallback()}),document.body.appendChild(this._htmlAudioElement)):e.Tools.LoadFile(i,function(e){s._soundLoaded(e)},null,this._scene.database,!0):i instanceof ArrayBuffer?i.byteLength>0&&this._soundLoaded(i):e.Tools.Error("Parameter must be a URL to the sound or an ArrayBuffer of the sound."))):(this._scene.mainSoundTrack.AddSound(this),e.Engine.audioEngine.WarnedWebAudioUnsupported||(e.Tools.Error("Web Audio is not supported by your browser."),e.Engine.audioEngine.WarnedWebAudioUnsupported=!0),this._readyToPlayCallback&&window.setTimeout(function(){s._readyToPlayCallback()},1e3))}return t.prototype.dispose=function(){e.Engine.audioEngine.canUseWebAudio&&this._isReadyToPlay&&(this.isPlaying&&this.stop(),this._isReadyToPlay=!1,-1===this.soundTrackId?this._scene.mainSoundTrack.RemoveSound(this):this._scene.soundTracks[this.soundTrackId].RemoveSound(this),this._soundGain&&(this._soundGain.disconnect(),this._soundGain=null),this._soundPanner&&(this._soundPanner.disconnect(),this._soundPanner=null),this._soundSource&&(this._soundSource.disconnect(),this._soundSource=null),this._audioBuffer=null,this._htmlAudioElement&&(this._htmlAudioElement.pause(),this._htmlAudioElement.src="",document.body.removeChild(this._htmlAudioElement)),this._connectedMesh&&(this._connectedMesh.unregisterAfterWorldMatrixUpdate(this._registerFunc),this._connectedMesh=null))},t.prototype._soundLoaded=function(t){var i=this;this._isLoaded=!0,e.Engine.audioEngine.audioContext.decodeAudioData(t,function(e){i._audioBuffer=e,i._isReadyToPlay=!0,i.autoplay&&i.play(),i._readyToPlayCallback&&i._readyToPlayCallback()},function(){e.Tools.Error("Error while decoding audio data for: "+i.name)})},t.prototype.setAudioBuffer=function(t){e.Engine.audioEngine.canUseWebAudio&&(this._audioBuffer=t,this._isReadyToPlay=!0)},t.prototype.updateOptions=function(e){e&&(this.loop=e.loop||this.loop,this.maxDistance=e.maxDistance||this.maxDistance,this.useCustomAttenuation=e.useCustomAttenuation||this.useCustomAttenuation,this.rolloffFactor=e.rolloffFactor||this.rolloffFactor,this.refDistance=e.refDistance||this.refDistance,this.distanceModel=e.distanceModel||this.distanceModel,this._playbackRate=e.playbackRate||this._playbackRate,this._updateSpatialParameters(),this.isPlaying&&(this._streaming?this._htmlAudioElement.playbackRate=this._playbackRate:this._soundSource.playbackRate.value=this._playbackRate))},t.prototype._createSpatialParameters=function(){e.Engine.audioEngine.canUseWebAudio&&(this._scene.headphone&&(this._panningModel="HRTF"),this._soundPanner=e.Engine.audioEngine.audioContext.createPanner(),this._updateSpatialParameters(),this._soundPanner.connect(this._ouputAudioNode),this._inputAudioNode=this._soundPanner)},t.prototype._updateSpatialParameters=function(){this.spatialSound&&(this.useCustomAttenuation?(this._soundPanner.distanceModel="linear",this._soundPanner.maxDistance=Number.MAX_VALUE,this._soundPanner.refDistance=1,this._soundPanner.rolloffFactor=1,this._soundPanner.panningModel=this._panningModel):(this._soundPanner.distanceModel=this.distanceModel,this._soundPanner.maxDistance=this.maxDistance,this._soundPanner.refDistance=this.refDistance,this._soundPanner.rolloffFactor=this.rolloffFactor,this._soundPanner.panningModel=this._panningModel))},t.prototype.switchPanningModelToHRTF=function(){this._panningModel="HRTF",this._switchPanningModel()},t.prototype.switchPanningModelToEqualPower=function(){this._panningModel="equalpower",this._switchPanningModel()},t.prototype._switchPanningModel=function(){e.Engine.audioEngine.canUseWebAudio&&this.spatialSound&&(this._soundPanner.panningModel=this._panningModel)},t.prototype.connectToSoundTrackAudioNode=function(t){e.Engine.audioEngine.canUseWebAudio&&(this._isOutputConnected&&this._ouputAudioNode.disconnect(),this._ouputAudioNode.connect(t),this._isOutputConnected=!0)},t.prototype.setDirectionalCone=function(t,i,n){return t>i?void e.Tools.Error("setDirectionalCone(): outer angle of the cone must be superior or equal to the inner angle."):(this._coneInnerAngle=t,this._coneOuterAngle=i,this._coneOuterGain=n,this._isDirectional=!0,void(this.isPlaying&&this.loop&&(this.stop(),this.play())))},t.prototype.setPosition=function(t){this._position=t,e.Engine.audioEngine.canUseWebAudio&&this.spatialSound&&this._soundPanner.setPosition(this._position.x,this._position.y,this._position.z)},t.prototype.setLocalDirectionToMesh=function(t){this._localDirection=t,e.Engine.audioEngine.canUseWebAudio&&this._connectedMesh&&this.isPlaying&&this._updateDirection()},t.prototype._updateDirection=function(){var t=this._connectedMesh.getWorldMatrix(),i=e.Vector3.TransformNormal(this._localDirection,t);i.normalize(),this._soundPanner.setOrientation(i.x,i.y,i.z)},t.prototype.updateDistanceFromListener=function(){if(e.Engine.audioEngine.canUseWebAudio&&this._connectedMesh&&this.useCustomAttenuation){var t=this._connectedMesh.getDistanceToCamera(this._scene.activeCamera);this._soundGain.gain.value=this._customAttenuationFunction(this._volume,t,this.maxDistance,this.refDistance,this.rolloffFactor)}},t.prototype.setAttenuationFunction=function(e){this._customAttenuationFunction=e},t.prototype.play=function(t){var i=this;if(this._isReadyToPlay&&this._scene.audioEnabled)try{this._startOffset<0&&(t=-this._startOffset,this._startOffset=0);var n=t?e.Engine.audioEngine.audioContext.currentTime+t:e.Engine.audioEngine.audioContext.currentTime;this._soundSource&&this._streamingSource||this.spatialSound&&(this._soundPanner.setPosition(this._position.x,this._position.y,this._position.z),this._isDirectional&&(this._soundPanner.coneInnerAngle=this._coneInnerAngle,this._soundPanner.coneOuterAngle=this._coneOuterAngle,this._soundPanner.coneOuterGain=this._coneOuterGain,this._connectedMesh?this._updateDirection():this._soundPanner.setOrientation(this._localDirection.x,this._localDirection.y,this._localDirection.z))),this._streaming?(this._streamingSource||(this._streamingSource=e.Engine.audioEngine.audioContext.createMediaElementSource(this._htmlAudioElement),this._htmlAudioElement.onended=function(){i._onended()},this._htmlAudioElement.playbackRate=this._playbackRate),this._streamingSource.disconnect(),this._streamingSource.connect(this._inputAudioNode),this._htmlAudioElement.play()):(this._soundSource=e.Engine.audioEngine.audioContext.createBufferSource(),this._soundSource.buffer=this._audioBuffer,this._soundSource.connect(this._inputAudioNode),this._soundSource.loop=this.loop,this._soundSource.playbackRate.value=this._playbackRate,this._soundSource.onended=function(){i._onended()},this._soundSource.start(n,this.isPaused?this._startOffset%this._soundSource.buffer.duration:0)),this._startTime=n,this.isPlaying=!0,this.isPaused=!1}catch(r){e.Tools.Error("Error while trying to play audio: "+this.name+", "+r.message)}},t.prototype._onended=function(){this.isPlaying=!1,this.onended&&this.onended()},t.prototype.stop=function(t){if(this.isPlaying){if(this._streaming)this._htmlAudioElement.pause(),this._htmlAudioElement.currentTime>0&&(this._htmlAudioElement.currentTime=0);else{ -var i=t?e.Engine.audioEngine.audioContext.currentTime+t:e.Engine.audioEngine.audioContext.currentTime;this._soundSource.stop(i),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._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?(r._audioBuffer=e.getAudioBuffer(),r._isReadyToPlay=!0,r.autoplay&&r.play()):window.setTimeout(i,300)},n={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},r=new t(this.name+"_cloned",new ArrayBuffer(0),this._scene,null,n);return this.useCustomAttenuation&&r.setAttenuationFunction(this._customAttenuationFunction),r.setPosition(this._position),r.setPlaybackRate(this._playbackRate),i(),r},t.prototype.getAudioBuffer=function(){return this._audioBuffer},t.Parse=function(i,n,r,o){var s,a=i.name;s=i.url?r+i.url:r+a;var h,c={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 l=function(){o._isReadyToPlay?(h._audioBuffer=o.getAudioBuffer(),h._isReadyToPlay=!0,h.autoplay&&h.play()):window.setTimeout(l,300)};h=new t(a,new ArrayBuffer(0),n,null,c),l()}else h=new t(a,s,n,function(){n._removePendingData(h)},c),n._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 d=e.Vector3.FromArray(i.localDirectionToMesh);h.setLocalDirectionToMesh(d)}if(i.connectedMeshId){var f=n.getMeshByID(i.connectedMeshId);f&&h.attachToMesh(f)}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;tn;n++){var r=new i;r.offset=n*e,this.allEntries[n]=r,this.freeEntries[t-n-1]=r}}return e.prototype.allocElement=function(){0===this.freeEntries.length&&this._growBuffer();var e=this.freeEntries.pop();return e},e.prototype.freeElement=function(e){this.freeEntries.push(e)},e.prototype.pack=function(){if(0===this.freeEntries.length)return this.buffer;var e=this.stride,t=this.freeEntries.sort(function(e,t){return e.offset-t.offset}),n=this.allEntries.sort(function(e,t){return e.offset-t.offset}),r=new i;r.offset=this.entryCount*e,t.push(r);for(var o=t[0].offset,s=1,a=t[0].offset,h=1;hm;m++){var _=o/e,g=f/e,v=n[g];this._moveEntry(v,o);var y=n[_];y.offset=f,n[_]=v,n[g]=y,f-=e,o+=e}d>=s?(o=l,s=1):s=(l-o)/e+1,a=l}else++s,a=l}this.entryCount=o/e;var x=this.buffer.subarray(0,o);return this.freeEntries.splice(0),this.allEntries=n.slice(0,this.entryCount),x},e.prototype._moveEntry=function(e,t){for(var i=0;ir;r++){var o=new i;o.offset=r*this.stride,this.allEntries[r]=o,this.freeEntries[r]=o}this.buffer=t,this.entryCount=e},e}();e.DynamicFloatArray=t;var i=function(){function e(){}return e}();e.DynamicFloatArrayEntry=i}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t){function i(i,n,r,o){t.call(this,i,n),this._textures={},this._floats={},this._floatsArrays={},this._colors3={},this._colors4={},this._vectors2={},this._vectors3={},this._vectors4={},this._matrices={},this._matrices3x3={},this._matrices2x2={},this._cachedWorldViewMatrix=new e.Matrix,this._shaderPath=r,o.needAlphaBlending=o.needAlphaBlending||!1,o.needAlphaTesting=o.needAlphaTesting||!1,o.attributes=o.attributes||["position","normal","uv"],o.uniforms=o.uniforms||["worldViewProjection"],o.samplers=o.samplers||[],o.defines=o.defines||[],this._options=o}return __extends(i,t),i.prototype.needAlphaBlending=function(){return this._options.needAlphaBlending},i.prototype.needAlphaTesting=function(){return this._options.needAlphaTesting},i.prototype._checkUniform=function(e){-1===this._options.uniforms.indexOf(e)&&this._options.uniforms.push(e)},i.prototype.setTexture=function(e,t){return-1===this._options.samplers.indexOf(e)&&this._options.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.setVector4=function(e,t){return this._checkUniform(e),this._vectors4[e]=t,this},i.prototype.setMatrix=function(e,t){return this._checkUniform(e),this._matrices[e]=t,this},i.prototype.setMatrix3x3=function(e,t){return this._checkUniform(e),this._matrices3x3[e]=t,this},i.prototype.setMatrix2x2=function(e,t){return this._checkUniform(e),this._matrices2x2[e]=t,this},i.prototype.isReady=function(t,i){var n=this.getScene(),r=n.getEngine();if(!this.checkReadyOnEveryCall&&this._renderId===n.getRenderId())return!0;var o=[],s=new e.EffectFallbacks;i&&o.push("#define INSTANCES");for(var a=0;a>8&255,e>>16&255,e>>24&255)}var r=542327876,o=131072,s=512,a=4,h=64,c=131072,l=i("DXT1"),u=i("DXT3"),d=i("DXT5"),f=31,p=0,m=1,_=2,g=3,v=4,y=7,x=20,b=21,A=22,E=28,T=function(){function t(){}return t.GetDDSInfo=function(e){var t=new Int32Array(e,0,f),i=1;return t[_]&o&&(i=Math.max(1,t[y])),{width:t[v],height:t[g],mipmapCount:i,isFourCC:(t[x]&a)===a,isRGB:(t[x]&h)===h,isLuminance:(t[x]&c)===c,isCube:(t[E]&s)===s}},t.GetRGBAArrayBuffer=function(e,t,i,n,r){for(var o=new Uint8Array(n),s=new Uint8Array(r),a=0,h=t-1;h>=0;h--)for(var c=0;e>c;c++){var l=i+4*(c+h*e);o[a+2]=s[l],o[a+1]=s[l+1],o[a]=s[l+2],o[a+3]=s[l+3],a+=4}return o},t.GetRGBArrayBuffer=function(e,t,i,n,r){for(var o=new Uint8Array(n),s=new Uint8Array(r),a=0,h=t-1;h>=0;h--)for(var c=0;e>c;c++){var l=i+3*(c+h*e);o[a+2]=s[l],o[a+1]=s[l+1],o[a]=s[l+2],a+=3}return o},t.GetLuminanceArrayBuffer=function(e,t,i,n,r){for(var o=new Uint8Array(n),s=new Uint8Array(r),a=0,h=t-1;h>=0;h--)for(var c=0;e>c;c++){var l=i+(c+h*e);o[a]=s[l],a++}return o},t.UploadDDSLevels=function(i,s,a,h,c,x){var E,T,P,M,S,C,R,I,D,w,O=new Int32Array(a,0,f);if(O[p]!=r)return void e.Tools.Error("Invalid magic number in DDS header");if(!h.isFourCC&&!h.isRGB&&!h.isLuminance)return void e.Tools.Error("Unsupported format, must contain a FourCC, RGB or LUMINANCE code");if(h.isFourCC)switch(E=O[b]){case l:T=8,P=s.COMPRESSED_RGBA_S3TC_DXT1_EXT;break;case u:T=16,P=s.COMPRESSED_RGBA_S3TC_DXT3_EXT;break;case d:T=16,P=s.COMPRESSED_RGBA_S3TC_DXT5_EXT;break;default:return void console.error("Unsupported FourCC code:",n(E))}D=1,O[_]&o&&c!==!1&&(D=Math.max(1,O[y]));for(var L=O[A],B=0;x>B;B++){var F=1===x?i.TEXTURE_2D:i.TEXTURE_CUBE_MAP_POSITIVE_X+B;for(M=O[v],S=O[g],R=O[m]+4,w=0;D>w;++w){if(h.isRGB)24===L?(C=M*S*3,I=t.GetRGBArrayBuffer(M,S,R,C,a),i.texImage2D(F,w,i.RGB,M,S,0,i.RGB,i.UNSIGNED_BYTE,I)):(C=M*S*4,I=t.GetRGBAArrayBuffer(M,S,R,C,a),i.texImage2D(F,w,i.RGBA,M,S,0,i.RGBA,i.UNSIGNED_BYTE,I));else if(h.isLuminance){var V=i.getParameter(i.UNPACK_ALIGNMENT),N=M,z=Math.floor((M+V-1)/V)*V;C=z*(S-1)+N,I=t.GetLuminanceArrayBuffer(M,S,R,C,a),i.texImage2D(F,w,i.LUMINANCE,M,S,0,i.LUMINANCE,i.UNSIGNED_BYTE,I)}else C=Math.max(4,M)/4*Math.max(4,S)/4*T,I=new Uint8Array(a,R,C),i.compressedTexImage2D(F,w,P,M,S,0,I);R+=C,M*=.5,S*=.5,M=Math.max(1,M),S=Math.max(1,S)}}},t}();t.DDSTools=T}(t=e.Internals||(e.Internals={}))}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(t,i){return void 0===t&&(t=!0),void 0===i&&(i=10),this._useDeltaForWorldStep=t,this.name="CannonJSPlugin",this._physicsMaterials=[],this._fixedTimeStep=1/60,this._currentCollisionGroup=2,this._minus90X=new e.Quaternion(-.7071067811865475,0,0,.7071067811865475),this._plus90X=new e.Quaternion(.7071067811865475,0,0,.7071067811865475),this._tmpPosition=e.Vector3.Zero(),this._tmpQuaternion=new e.Quaternion,this._tmpDeltaPosition=e.Vector3.Zero(),this._tmpDeltaRotation=new e.Quaternion,this._tmpUnityRotation=new e.Quaternion,this.isSupported()?(this.world=new CANNON.World,this.world.broadphase=new CANNON.NaiveBroadphase,void(this.world.solver.iterations=i)):void e.Tools.Error("CannonJS is not available. Please make sure you included the js file.")}return t.prototype.setGravity=function(e){this.world.gravity.copy(e)},t.prototype.setTimeStep=function(e){this._fixedTimeStep=e},t.prototype.executeStep=function(e,t){this.world.step(this._fixedTimeStep,this._useDeltaForWorldStep?1e3*e:0,3)},t.prototype.applyImpulse=function(e,t,i){var n=new CANNON.Vec3(i.x,i.y,i.z),r=new CANNON.Vec3(t.x,t.y,t.z);e.physicsBody.applyImpulse(r,n)},t.prototype.applyForce=function(e,t,i){var n=new CANNON.Vec3(i.x,i.y,i.z),r=new CANNON.Vec3(t.x,t.y,t.z);e.physicsBody.applyImpulse(r,n)},t.prototype.generatePhysicsBody=function(e){if(e.parent)return void(e.physicsBody&&(this.removePhysicsBody(e),e.forceUpdate()));if(e.isBodyInitRequired()){var t=this._createShape(e),i=e.physicsBody;i&&this.removePhysicsBody(e); +var i=t?e.Engine.audioEngine.audioContext.currentTime+t:e.Engine.audioEngine.audioContext.currentTime;this._soundSource.stop(i),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._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?(r._audioBuffer=e.getAudioBuffer(),r._isReadyToPlay=!0,r.autoplay&&r.play()):window.setTimeout(i,300)},n={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},r=new t(this.name+"_cloned",new ArrayBuffer(0),this._scene,null,n);return this.useCustomAttenuation&&r.setAttenuationFunction(this._customAttenuationFunction),r.setPosition(this._position),r.setPlaybackRate(this._playbackRate),i(),r},t.prototype.getAudioBuffer=function(){return this._audioBuffer},t.Parse=function(i,n,r,o){var s,a=i.name;s=i.url?r+i.url:r+a;var h,c={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 l=function(){o._isReadyToPlay?(h._audioBuffer=o.getAudioBuffer(),h._isReadyToPlay=!0,h.autoplay&&h.play()):window.setTimeout(l,300)};h=new t(a,new ArrayBuffer(0),n,null,c),l()}else h=new t(a,s,n,function(){n._removePendingData(h)},c),n._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 d=e.Vector3.FromArray(i.localDirectionToMesh);h.setLocalDirectionToMesh(d)}if(i.connectedMeshId){var f=n.getMeshByID(i.connectedMeshId);f&&h.attachToMesh(f)}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;tn;n++){var r=new i;r.offset=n*e,this.allEntries[n]=r,this.freeEntries[t-n-1]=r}}return e.prototype.allocElement=function(){0===this.freeEntries.length&&this._growBuffer();var e=this.freeEntries.pop();return e},e.prototype.freeElement=function(e){this.freeEntries.push(e)},e.prototype.pack=function(){if(0===this.freeEntries.length)return this.buffer;var e=this.stride,t=this.freeEntries.sort(function(e,t){return e.offset-t.offset}),n=this.allEntries.sort(function(e,t){return e.offset-t.offset}),r=new i;r.offset=this.entryCount*e,t.push(r);for(var o=t[0].offset,s=1,a=t[0].offset,h=1;hm;m++){var _=o/e,g=f/e,v=n[g];this._moveEntry(v,o);var y=n[_];y.offset=f,n[_]=v,n[g]=y,f-=e,o+=e}d>=s?(o=l,s=1):s=(l-o)/e+1,a=l}else++s,a=l}this.entryCount=o/e;var x=this.buffer.subarray(0,o);return this.freeEntries.splice(0),this.allEntries=n.slice(0,this.entryCount),x},e.prototype._moveEntry=function(e,t){for(var i=0;ir;r++){var o=new i;o.offset=r*this.stride,this.allEntries[r]=o,this.freeEntries[r]=o}this.buffer=t,this.entryCount=e},e}();e.DynamicFloatArray=t;var i=function(){function e(){}return e}();e.DynamicFloatArrayEntry=i}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t){function i(i,n,r,o){t.call(this,i,n),this._textures={},this._floats={},this._floatsArrays={},this._colors3={},this._colors4={},this._vectors2={},this._vectors3={},this._vectors4={},this._matrices={},this._matrices3x3={},this._matrices2x2={},this._cachedWorldViewMatrix=new e.Matrix,this._shaderPath=r,o.needAlphaBlending=o.needAlphaBlending||!1,o.needAlphaTesting=o.needAlphaTesting||!1,o.attributes=o.attributes||["position","normal","uv"],o.uniforms=o.uniforms||["worldViewProjection"],o.samplers=o.samplers||[],o.defines=o.defines||[],this._options=o}return __extends(i,t),i.prototype.needAlphaBlending=function(){return this._options.needAlphaBlending},i.prototype.needAlphaTesting=function(){return this._options.needAlphaTesting},i.prototype._checkUniform=function(e){-1===this._options.uniforms.indexOf(e)&&this._options.uniforms.push(e)},i.prototype.setTexture=function(e,t){return-1===this._options.samplers.indexOf(e)&&this._options.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.setVector4=function(e,t){return this._checkUniform(e),this._vectors4[e]=t,this},i.prototype.setMatrix=function(e,t){return this._checkUniform(e),this._matrices[e]=t,this},i.prototype.setMatrix3x3=function(e,t){return this._checkUniform(e),this._matrices3x3[e]=t,this},i.prototype.setMatrix2x2=function(e,t){return this._checkUniform(e),this._matrices2x2[e]=t,this},i.prototype.isReady=function(t,i){var n=this.getScene(),r=n.getEngine();if(!this.checkReadyOnEveryCall&&this._renderId===n.getRenderId())return!0;var o=[],s=new e.EffectFallbacks;i&&o.push("#define INSTANCES");for(var a=0;a>8&255,e>>16&255,e>>24&255)}var r=542327876,o=131072,s=512,a=4,h=64,c=131072,l=i("DXT1"),u=i("DXT3"),d=i("DXT5"),f=31,p=0,m=1,_=2,g=3,v=4,y=7,x=20,b=21,A=22,E=28,T=function(){function t(){}return t.GetDDSInfo=function(e){var t=new Int32Array(e,0,f),i=1;return t[_]&o&&(i=Math.max(1,t[y])),{width:t[v],height:t[g],mipmapCount:i,isFourCC:(t[x]&a)===a,isRGB:(t[x]&h)===h,isLuminance:(t[x]&c)===c,isCube:(t[E]&s)===s}},t.GetRGBAArrayBuffer=function(e,t,i,n,r){for(var o=new Uint8Array(n),s=new Uint8Array(r),a=0,h=t-1;h>=0;h--)for(var c=0;e>c;c++){var l=i+4*(c+h*e);o[a+2]=s[l],o[a+1]=s[l+1],o[a]=s[l+2],o[a+3]=s[l+3],a+=4}return o},t.GetRGBArrayBuffer=function(e,t,i,n,r){for(var o=new Uint8Array(n),s=new Uint8Array(r),a=0,h=t-1;h>=0;h--)for(var c=0;e>c;c++){var l=i+3*(c+h*e);o[a+2]=s[l],o[a+1]=s[l+1],o[a]=s[l+2],a+=3}return o},t.GetLuminanceArrayBuffer=function(e,t,i,n,r){for(var o=new Uint8Array(n),s=new Uint8Array(r),a=0,h=t-1;h>=0;h--)for(var c=0;e>c;c++){var l=i+(c+h*e);o[a]=s[l],a++}return o},t.UploadDDSLevels=function(i,s,a,h,c,x){var E,T,P,M,S,C,R,I,D,w,O=new Int32Array(a,0,f);if(O[p]!=r)return void e.Tools.Error("Invalid magic number in DDS header");if(!h.isFourCC&&!h.isRGB&&!h.isLuminance)return void e.Tools.Error("Unsupported format, must contain a FourCC, RGB or LUMINANCE code");if(h.isFourCC)switch(E=O[b]){case l:T=8,P=s.COMPRESSED_RGBA_S3TC_DXT1_EXT;break;case u:T=16,P=s.COMPRESSED_RGBA_S3TC_DXT3_EXT;break;case d:T=16,P=s.COMPRESSED_RGBA_S3TC_DXT5_EXT;break;default:return void console.error("Unsupported FourCC code:",n(E))}D=1,O[_]&o&&c!==!1&&(D=Math.max(1,O[y]));for(var L=O[A],B=0;x>B;B++){var F=1===x?i.TEXTURE_2D:i.TEXTURE_CUBE_MAP_POSITIVE_X+B;for(M=O[v],S=O[g],R=O[m]+4,w=0;D>w;++w){if(h.isRGB)24===L?(C=M*S*3,I=t.GetRGBArrayBuffer(M,S,R,C,a),i.texImage2D(F,w,i.RGB,M,S,0,i.RGB,i.UNSIGNED_BYTE,I)):(C=M*S*4,I=t.GetRGBAArrayBuffer(M,S,R,C,a),i.texImage2D(F,w,i.RGBA,M,S,0,i.RGBA,i.UNSIGNED_BYTE,I));else if(h.isLuminance){var V=i.getParameter(i.UNPACK_ALIGNMENT),N=M,z=Math.floor((M+V-1)/V)*V;C=z*(S-1)+N,I=t.GetLuminanceArrayBuffer(M,S,R,C,a),i.texImage2D(F,w,i.LUMINANCE,M,S,0,i.LUMINANCE,i.UNSIGNED_BYTE,I)}else C=Math.max(4,M)/4*Math.max(4,S)/4*T,I=new Uint8Array(a,R,C),i.compressedTexImage2D(F,w,P,M,S,0,I);R+=C,M*=.5,S*=.5,M=Math.max(1,M),S=Math.max(1,S)}}},t}();t.DDSTools=T}(t=e.Internals||(e.Internals={}))}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(t,i){return void 0===t&&(t=!0),void 0===i&&(i=10),this._useDeltaForWorldStep=t,this.name="CannonJSPlugin",this._physicsMaterials=[],this._fixedTimeStep=1/60,this._currentCollisionGroup=2,this._minus90X=new e.Quaternion(-.7071067811865475,0,0,.7071067811865475),this._plus90X=new e.Quaternion(.7071067811865475,0,0,.7071067811865475),this._tmpPosition=e.Vector3.Zero(),this._tmpQuaternion=new e.Quaternion,this._tmpDeltaPosition=e.Vector3.Zero(),this._tmpDeltaRotation=new e.Quaternion,this._tmpUnityRotation=new e.Quaternion,this.isSupported()?(this.world=new CANNON.World,this.world.broadphase=new CANNON.NaiveBroadphase,void(this.world.solver.iterations=i)):void e.Tools.Error("CannonJS is not available. Please make sure you included the js file.")}return t.prototype.setGravity=function(e){this.world.gravity.copy(e)},t.prototype.setTimeStep=function(e){this._fixedTimeStep=e},t.prototype.executeStep=function(e,t){this.world.step(this._fixedTimeStep,this._useDeltaForWorldStep?1e3*e:0,3)},t.prototype.applyImpulse=function(e,t,i){var n=new CANNON.Vec3(i.x,i.y,i.z),r=new CANNON.Vec3(t.x,t.y,t.z);e.physicsBody.applyImpulse(r,n)},t.prototype.applyForce=function(e,t,i){var n=new CANNON.Vec3(i.x,i.y,i.z),r=new CANNON.Vec3(t.x,t.y,t.z);e.physicsBody.applyImpulse(r,n)},t.prototype.generatePhysicsBody=function(e){if(e.parent)return void(e.physicsBody&&(this.removePhysicsBody(e),e.forceUpdate()));if(e.isBodyInitRequired()){var t=this._createShape(e),i=e.physicsBody;i&&this.removePhysicsBody(e); var n=this._addMaterial("mat-"+e.uniqueId,e.getParam("friction"),e.getParam("restitution")),r={mass:e.getParam("mass"),material:n},o=e.getParam("nativeOptions");for(var s in o)o.hasOwnProperty(s)&&(r[s]=o[s]);e.physicsBody=new CANNON.Body(r),e.physicsBody.addEventListener("collide",e.onCollide),this.world.addEventListener("preStep",e.beforeStep),this.world.addEventListener("postStep",e.afterStep),e.physicsBody.addShape(t),this.world.add(e.physicsBody),i&&["force","torque","velocity","angularVelocity"].forEach(function(t){e.physicsBody[t].copy(i[t])}),this._processChildMeshes(e)}this._updatePhysicsBodyTransformation(e)},t.prototype._processChildMeshes=function(t){var i=this,n=t.object.getChildMeshes?t.object.getChildMeshes():[];if(n.length){var r=function(e,n){var o=n.getPhysicsImpostor();if(o){var s=o.parent;if(s!==t){var e=n.position;o.physicsBody&&(i.removePhysicsBody(o),o.physicsBody=null),o.parent=t,o.resetUpdateFlags(),t.physicsBody.addShape(i._createShape(o),new CANNON.Vec3(e.x,e.y,e.z)),t.physicsBody.mass+=o.getParam("mass")}}n.getChildMeshes().forEach(r.bind(i,n.position))};n.forEach(r.bind(this,e.Vector3.Zero()))}},t.prototype.removePhysicsBody=function(e){e.physicsBody.removeEventListener("collide",e.onCollide),this.world.removeEventListener("preStep",e.beforeStep),this.world.removeEventListener("postStep",e.afterStep),this.world.remove(e.physicsBody)},t.prototype.generateJoint=function(t){var i=t.mainImpostor.physicsBody,n=t.connectedImpostor.physicsBody;if(i&&n){var r,o=t.joint.jointData,s={pivotA:o.mainPivot?(new CANNON.Vec3).copy(o.mainPivot):null,pivotB:o.connectedPivot?(new CANNON.Vec3).copy(o.connectedPivot):null,axisA:o.mainAxis?(new CANNON.Vec3).copy(o.mainAxis):null,axisB:o.connectedAxis?(new CANNON.Vec3).copy(o.connectedAxis):null,maxForce:o.nativeParams.maxForce,collideConnected:!!o.collision};switch(t.joint.type){case e.PhysicsJoint.HingeJoint:case e.PhysicsJoint.Hinge2Joint:r=new CANNON.HingeConstraint(i,n,s);break;case e.PhysicsJoint.DistanceJoint:r=new CANNON.DistanceConstraint(i,n,o.maxDistance||2);break;case e.PhysicsJoint.SpringJoint:var a=o;r=new CANNON.Spring(i,n,{restLength:a.length,stiffness:a.stiffness,damping:a.damping,localAnchorA:s.pivotA,localAnchorB:s.pivotB});break;case e.PhysicsJoint.PointToPointJoint:case e.PhysicsJoint.BallAndSocketJoint:default:r=new CANNON.PointToPointConstraint(i,s.pivotA,n,s.pivotA,s.maxForce)}r.collideConnected=!!o.collision,t.joint.physicsJoint=r,t.joint.type!==e.PhysicsJoint.SpringJoint?this.world.addConstraint(r):t.mainImpostor.registerAfterPhysicsStep(function(){r.applyForce()})}},t.prototype.removeJoint=function(e){this.world.removeConstraint(e.joint.physicsJoint)},t.prototype._addMaterial=function(e,t,i){var n,r;for(n=0;n=l;++l){if(!r[l]){for(var f=1;!r[(l+f)%o];)f++;r[l]=r[(l+f)%o].slice()}for(var u=0;o>=u;++u)if(!r[l][u]){for(var p,f=1;void 0===p;)p=r[l][(u+f++)%o];r[l][u]=p}}var m=new CANNON.Heightfield(r,{elementSize:a});return m.minY=h,m},t.prototype._updatePhysicsBodyTransformation=function(t){var i=t.object;i.computeWorldMatrix&&i.computeWorldMatrix(!0);var n=t.getObjectCenter();t.getObjectExtendSize();this._tmpDeltaPosition.copyFrom(i.position.subtract(n)),this._tmpPosition.copyFrom(n);var r=i.rotationQuaternion;if(t.type!==e.PhysicsImpostor.PlaneImpostor&&t.type!==e.PhysicsImpostor.HeightmapImpostor&&t.type!==e.PhysicsImpostor.CylinderImpostor||(r=r.multiply(this._minus90X),t.setDeltaRotation(this._plus90X)),t.type===e.PhysicsEngine.HeightmapImpostor){var o=i,s=o.rotationQuaternion;o.rotationQuaternion=this._tmpUnityRotation,o.computeWorldMatrix(!0);var a=n.clone(),h=o.getPivotMatrix()||e.Matrix.Translation(0,0,0);o.rotationQuaternion=s;var c=e.Matrix.Translation(o.getBoundingInfo().boundingBox.extendSize.x,0,-o.getBoundingInfo().boundingBox.extendSize.z);o.setPivotMatrix(c),o.computeWorldMatrix(!0);var l=o.getBoundingInfo().boundingBox.center.subtract(n).subtract(o.position).negate();this._tmpPosition.copyFromFloats(l.x,l.y-o.getBoundingInfo().boundingBox.extendSize.y,l.z),this._tmpDeltaPosition.copyFrom(o.getBoundingInfo().boundingBox.center.subtract(a)),this._tmpDeltaPosition.y+=o.getBoundingInfo().boundingBox.extendSize.y,o.setPivotMatrix(h),o.computeWorldMatrix(!0)}else t.type===e.PhysicsEngine.MeshImpostor&&(this._tmpDeltaPosition.copyFromFloats(0,0,0),this._tmpPosition.copyFrom(i.position));t.setDeltaPosition(this._tmpDeltaPosition),t.physicsBody.position.copy(this._tmpPosition),t.physicsBody.quaternion.copy(r)},t.prototype.setTransformationFromPhysicsBody=function(e){e.object.position.copyFrom(e.physicsBody.position),e.object.rotationQuaternion.copyFrom(e.physicsBody.quaternion)},t.prototype.setPhysicsBodyTransformation=function(e,t,i){e.physicsBody.position.copy(t),e.physicsBody.quaternion.copy(i)},t.prototype.isSupported=function(){return void 0!==window.CANNON},t.prototype.setLinearVelocity=function(e,t){e.physicsBody.velocity.copy(t)},t.prototype.setAngularVelocity=function(e,t){e.physicsBody.angularVelocity.copy(t)},t.prototype.getLinearVelocity=function(t){var i=t.physicsBody.velocity;return i?new e.Vector3(i.x,i.y,i.z):null},t.prototype.getAngularVelocity=function(t){var i=t.physicsBody.angularVelocity;return i?new e.Vector3(i.x,i.y,i.z):null},t.prototype.setBodyMass=function(e,t){e.physicsBody.mass=t,e.physicsBody.updateMassProperties()},t.prototype.sleepBody=function(e){e.physicsBody.sleep()},t.prototype.wakeUpBody=function(e){e.physicsBody.wakeUp()},t.prototype.updateDistanceJoint=function(e,t,i){e.physicsJoint.distance=t},t.prototype.enableMotor=function(e,t){t||e.physicsJoint.enableMotor()},t.prototype.disableMotor=function(e,t){t||e.physicsJoint.disableMotor()},t.prototype.setMotor=function(e,t,i,n){n||(e.physicsJoint.enableMotor(),e.physicsJoint.setMotorSpeed(t),i&&this.setLimit(e,i))},t.prototype.setLimit=function(e,t,i){e.physicsJoint.motorEquation.maxForce=t,e.physicsJoint.motorEquation.minForce=void 0===i?-t:i},t.prototype.dispose=function(){},t}();e.CannonJSPlugin=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(t){this.name="OimoJSPlugin",this._tmpImpostorsArray=[],this._tmpPositionVector=e.Vector3.Zero(),this.world=new OIMO.World(1/60,2,t,!0),this.world.clear(),this.world.isNoStat=!0}return t.prototype.setGravity=function(e){this.world.gravity.copy(e)},t.prototype.setTimeStep=function(e){this.world.timeStep=e},t.prototype.executeStep=function(e,t){var i=this;t.forEach(function(e){e.beforeStep()}),this.world.step(),t.forEach(function(e){e.afterStep(),i._tmpImpostorsArray[e.uniqueId]=e});for(var n=this.world.contacts;null!==n;)if(!n.touching||n.body1.sleeping||n.body2.sleeping){var r=this._tmpImpostorsArray[+n.body1.name],o=this._tmpImpostorsArray[+n.body2.name];r&&o?(r.onCollide({body:o.physicsBody}),o.onCollide({body:r.physicsBody}),n=n.next):n=n.next}else n=n.next},t.prototype.applyImpulse=function(e,t,i){var n=e.physicsBody.massInfo.mass;e.physicsBody.applyImpulse(i.scale(OIMO.INV_SCALE),t.scale(OIMO.INV_SCALE*n))},t.prototype.applyForce=function(t,i,n){e.Tools.Warn("Oimo doesn't support applying force. Using impule instead."),this.applyImpulse(t,i,n)},t.prototype.generatePhysicsBody=function(t){function i(e){e.getChildMeshes&&e.getChildMeshes().forEach(function(e){e.physicsImpostor&&(s.push(e.physicsImpostor),e.physicsImpostor._init())})}function n(t){return Math.max(t,e.PhysicsEngine.Epsilon)}var r=this;if(t.parent)return void(t.physicsBody&&(this.removePhysicsBody(t),t.forceUpdate()));if(t.isBodyInitRequired()){var o={name:t.uniqueId,config:[t.getParam("mass")||1,t.getParam("friction"),t.getParam("restitution")],size:[],type:[],pos:[],rot:[],move:0!==t.getParam("mass"),world:this.world},s=[t];i(t.object),s.forEach(function(i){var s=i.object.rotationQuaternion,a=(new OIMO.Euler).setFromQuaternion({x:t.object.rotationQuaternion.x,y:t.object.rotationQuaternion.y,z:t.object.rotationQuaternion.z,s:t.object.rotationQuaternion.w}),h=i.getObjectExtendSize();if(i===t){var c=t.getObjectCenter();t.object.position.subtractToRef(c,r._tmpPositionVector),o.pos.push(c.x),o.pos.push(c.y),o.pos.push(c.z),o.rot.push(a.x/(OIMO.degtorad||OIMO.TO_RAD)),o.rot.push(a.y/(OIMO.degtorad||OIMO.TO_RAD)),o.rot.push(a.z/(OIMO.degtorad||OIMO.TO_RAD))}else o.pos.push(i.object.position.x),o.pos.push(i.object.position.y),o.pos.push(i.object.position.z),o.rot.push(0),o.rot.push(0),o.rot.push(0);switch(i.type){case e.PhysicsImpostor.ParticleImpostor:e.Tools.Warn("No Particle support in Oimo.js. using SphereImpostor instead");case e.PhysicsImpostor.SphereImpostor:var l=h.x,u=h.y,d=h.z,f=Math.max(n(l),n(u),n(d))/2;o.type.push("sphere"),o.size.push(f),o.size.push(f),o.size.push(f);break;case e.PhysicsImpostor.CylinderImpostor:var p=n(h.x)/2,m=n(h.y);o.type.push("cylinder"),o.size.push(p),o.size.push(m),o.size.push(m);break;case e.PhysicsImpostor.PlaneImpostor:case e.PhysicsImpostor.BoxImpostor:default:var p=n(h.x),m=n(h.y),_=n(h.z);o.type.push("box"),o.size.push(p),o.size.push(m),o.size.push(_)}i.object.rotationQuaternion=s}),t.physicsBody=new OIMO.Body(o).body}else this._tmpPositionVector.copyFromFloats(0,0,0);t.setDeltaPosition(this._tmpPositionVector)},t.prototype.removePhysicsBody=function(e){this.world.removeRigidBody(e.physicsBody)},t.prototype.generateJoint=function(t){var i=t.mainImpostor.physicsBody,n=t.connectedImpostor.physicsBody;if(i&&n){var r,o=t.joint.jointData,s=o.nativeParams||{},a={body1:i,body2:n,axe1:s.axe1||(o.mainAxis?o.mainAxis.asArray():null),axe2:s.axe2||(o.connectedAxis?o.connectedAxis.asArray():null),pos1:s.pos1||(o.mainPivot?o.mainPivot.asArray():null),pos2:s.pos2||(o.connectedPivot?o.connectedPivot.asArray():null),min:s.min,max:s.max,collision:s.collision||o.collision,spring:s.spring,world:this.world};switch(t.joint.type){case e.PhysicsJoint.BallAndSocketJoint:r="jointBall";break;case e.PhysicsJoint.SpringJoint:e.Tools.Warn("Oimo.js doesn't support Spring Constraint. Simulating using DistanceJoint instead");var h=o;a.min=h.length||a.min,a.max=Math.max(a.min,a.max);case e.PhysicsJoint.DistanceJoint:r="jointDistance",a.max=o.maxDistance;break;case e.PhysicsJoint.PrismaticJoint:r="jointPrisme";break;case e.PhysicsJoint.SliderJoint:r="jointSlide";break;case e.PhysicsJoint.WheelJoint:r="jointWheel";break;case e.PhysicsJoint.HingeJoint:default:r="jointHinge"}a.type=r,t.joint.physicsJoint=new OIMO.Link(a).joint}},t.prototype.removeJoint=function(t){try{this.world.removeJoint(t.joint.physicsJoint)}catch(i){e.Tools.Warn(i)}},t.prototype.isSupported=function(){return void 0!==OIMO},t.prototype.setTransformationFromPhysicsBody=function(e){if(!e.physicsBody.sleeping){if(e.physicsBody.shapes.next){var t=this._getLastShape(e.physicsBody);e.object.position.x=t.position.x*OIMO.WORLD_SCALE,e.object.position.y=t.position.y*OIMO.WORLD_SCALE,e.object.position.z=t.position.z*OIMO.WORLD_SCALE}else e.object.position.copyFrom(e.physicsBody.getPosition());e.object.rotationQuaternion.copyFrom(e.physicsBody.getQuaternion())}},t.prototype.setPhysicsBodyTransformation=function(e,t,i){var n=e.physicsBody;n.position.init(t.x*OIMO.INV_SCALE,t.y*OIMO.INV_SCALE,t.z*OIMO.INV_SCALE),n.orientation.init(i.w,i.x,i.y,i.z),n.syncShapes(),n.awake()},t.prototype._getLastShape=function(e){for(var t=e.shapes;t.next;)t=t.next;return t},t.prototype.setLinearVelocity=function(e,t){e.physicsBody.linearVelocity.init(t.x,t.y,t.z)},t.prototype.setAngularVelocity=function(e,t){e.physicsBody.angularVelocity.init(t.x,t.y,t.z)},t.prototype.getLinearVelocity=function(t){var i=t.physicsBody.linearVelocity;return i?new e.Vector3(i.x,i.y,i.z):null},t.prototype.getAngularVelocity=function(t){var i=t.physicsBody.angularVelocity;return i?new e.Vector3(i.x,i.y,i.z):null},t.prototype.setBodyMass=function(e,t){var i=0===t;e.physicsBody.shapes.density=i?1:t,e.physicsBody.setupMass(i?2:1)},t.prototype.sleepBody=function(e){e.physicsBody.sleep()},t.prototype.wakeUpBody=function(e){e.physicsBody.awake()},t.prototype.updateDistanceJoint=function(e,t,i){e.physicsJoint.limitMotoe.upperLimit=t,void 0!==i&&(e.physicsJoint.limitMotoe.lowerLimit=i)},t.prototype.setMotor=function(e,t,i,n){var r=n?e.physicsJoint.rotationalLimitMotor2:e.physicsJoint.rotationalLimitMotor1||e.physicsJoint.rotationalLimitMotor||e.physicsJoint.limitMotor;r&&r.setMotor(t,i)},t.prototype.setLimit=function(e,t,i,n){var r=n?e.physicsJoint.rotationalLimitMotor2:e.physicsJoint.rotationalLimitMotor1||e.physicsJoint.rotationalLimitMotor||e.physicsJoint.limitMotor;r&&r.setLimit(t,void 0===i?-t:i)},t.prototype.dispose=function(){this.world.clear()},t}();e.OimoJSPlugin=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(e){function t(t,i,n,r,o,s){e.call(this,t,"displayPass",["passSampler"],["passSampler"],i,n,r,o,s)}return __extends(t,e),t}(e.PostProcess);e.DisplayPassPostProcess=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){var n=i.getSimplifier(t);n.simplify(e,function(n){t.mesh.addLODLevel(e.distance,n),n.isVisible=!0,e.quality===t.settings[t.settings.length-1].quality&&t.successCallback&&t.successCallback(),i.executeNext()})});else{var n=this.getSimplifier(t),r=function(e,i){n.simplify(e,function(n){t.mesh.addLODLevel(e.distance,n),n.isVisible=!0,i()})};e.AsyncLoop.Run(t.settings.length,function(e){r(t.settings[e.index],function(){e.executeNext()})},function(){t.successCallback&&t.successCallback(),i.executeNext()})}},t.prototype.getSimplifier=function(e){switch(e.simplificationType){case n.QUADRATIC:default:return new h(e.mesh)}},t}();e.SimplificationQueue=i,function(e){e[e.QUADRATIC=0]="QUADRATIC"}(e.SimplificationType||(e.SimplificationType={}));var n=e.SimplificationType,r=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=r;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;10>t;++t)e&&e[t]?this.data[t]=e[t]:this.data[t]=0}return e.prototype.det=function(e,t,i,n,r,o,s,a,h){var c=this.data[e]*this.data[r]*this.data[h]+this.data[i]*this.data[n]*this.data[a]+this.data[t]*this.data[o]*this.data[s]-this.data[i]*this.data[r]*this.data[s]-this.data[e]*this.data[o]*this.data[a]-this.data[t]*this.data[n]*this.data[h];return c},e.prototype.addInPlace=function(e){for(var t=0;10>t;++t)this.data[t]+=e.data[t]},e.prototype.addArrayInPlace=function(e){for(var t=0;10>t;++t)this.data[t]+=e[t]},e.prototype.add=function(t){for(var i=new e,n=0;10>n;++n)i.data[n]=this.data[n]+t.data[n];return i},e.FromData=function(t,i,n,r){return new e(e.DataFromNumbers(t,i,n,r))},e.DataFromNumbers=function(e,t,i,n){return[e*e,e*t,e*i,e*n,t*t,t*i,t*n,i*i,i*n,n*n]},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 n=this;this.initDecimatedMesh(),e.AsyncLoop.Run(this._mesh.subMeshes.length,function(e){n.initWithMesh(e.index,function(){n.runDecimation(t,e.index,function(){e.executeNext()})},t.optimizeMesh)},function(){setTimeout(function(){i(n._reconstructedMesh)},0)})},t.prototype.isTriangleOnBoundingBox=function(e){var t=this,i=0;return e.vertices.forEach(function(e){var n=0,r=e.position,o=t._mesh.getBoundingInfo().boundingBox;(o.maximum.x-r.xt.boundingBoxEpsilon)&&++n,o.maximum.y!==r.y&&r.y!==o.minimum.y||++n,o.maximum.z!==r.z&&r.z!==o.minimum.z||++n,n>1&&++i}),i>1&&console.log(e,i),i>1},t.prototype.runDecimation=function(t,i,n){var r=this,o=~~(this.triangles.length*t.quality),s=0,a=this.triangles.length,h=function(t,i){setTimeout(function(){t%5===0&&r.updateMesh(0===t);for(var n=0;nh||n.deleted||n.isDirty))for(var o=0;3>o;++o)if(n.error[o]x;x++)r.references[l.triangleStart+x]=r.references[v+x]}else l.triangleStart=v;l.triangleCount=y;break}};e.AsyncLoop.SyncAsyncForLoop(r.triangles.length,r.syncIterations,c,i,function(){return o>=a-s})},0)};e.AsyncLoop.Run(this.decimationIterations,function(e){o>=a-s?e.breakLoop():h(e.index,function(){e.executeNext()})},function(){setTimeout(function(){r.reconstructMesh(i),n()},0)})},t.prototype.initWithMesh=function(t,i,n){var s=this;this.vertices=[],this.triangles=[];var a=this._mesh.getVerticesData(e.VertexBuffer.PositionKind),h=this._mesh.getIndices(),c=this._mesh.subMeshes[t],l=function(e){if(n)for(var t=0;t>0,d,function(){var t=function(e){var t=c.indexStart/3+e,i=3*t,n=h[i+0],o=h[i+1],a=h[i+2],l=s.vertices[u[n-c.verticesStart]],d=s.vertices[u[o-c.verticesStart]],f=s.vertices[u[a-c.verticesStart]],p=new r([l,d,f]);p.originalOffset=i,s.triangles.push(p)};e.AsyncLoop.SyncAsyncForLoop(c.indexCount/3,s.syncIterations,t,function(){s.init(i)})})},t.prototype.init=function(t){var i=this,n=function(t){var n=i.triangles[t];n.normal=e.Vector3.Cross(n.vertices[1].position.subtract(n.vertices[0].position),n.vertices[2].position.subtract(n.vertices[0].position)).normalize();for(var r=0;3>r;r++)n.vertices[r].q.addArrayInPlace(s.DataFromNumbers(n.normal.x,n.normal.y,n.normal.z,-e.Vector3.Dot(n.normal,n.vertices[0].position)))};e.AsyncLoop.SyncAsyncForLoop(this.triangles.length,this.syncIterations,n,function(){var n=function(e){for(var t=i.triangles[e],n=0;3>n;++n)t.error[n]=i.calculateError(t.vertices[n],t.vertices[(n+1)%3]);t.error[3]=Math.min(t.error[0],t.error[1],t.error[2])};e.AsyncLoop.SyncAsyncForLoop(i.triangles.length,i.syncIterations,n,function(){i.initialized=!0,t()})})},t.prototype.reconstructMesh=function(t){var i,n=[];for(i=0;io;++o)r.vertices[o].triangleCount=1;n.push(r)}var s=this._reconstructedMesh.getVerticesData(e.VertexBuffer.PositionKind)||[],a=this._reconstructedMesh.getVerticesData(e.VertexBuffer.NormalKind)||[],h=this._reconstructedMesh.getVerticesData(e.VertexBuffer.UVKind)||[],c=this._reconstructedMesh.getVerticesData(e.VertexBuffer.ColorKind)||[],l=this._mesh.getVerticesData(e.VertexBuffer.NormalKind),u=this._mesh.getVerticesData(e.VertexBuffer.UVKind),d=this._mesh.getVerticesData(e.VertexBuffer.ColorKind),f=0;for(i=0;ii&&(i=0),v.push(r.vertices[e].id+i+_)});this._reconstructedMesh.setIndices(v),this._reconstructedMesh.setVerticesData(e.VertexBuffer.PositionKind,s),this._reconstructedMesh.setVerticesData(e.VertexBuffer.NormalKind,a),h.length>0&&this._reconstructedMesh.setVerticesData(e.VertexBuffer.UVKind,h),c.length>0&&this._reconstructedMesh.setVerticesData(e.VertexBuffer.ColorKind,c);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,_,f,m,3*n.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,n,r,o,s){for(var a=0;a.999)return!0;var p=e.Vector3.Cross(d,f).normalize();if(r[a]=!1,e.Vector3.Dot(p,h.normal)<.2)return!0}else r[a]=!0,s.push(h)}}return!1},t.prototype.updateTriangles=function(e,t,i,n){for(var r=n,o=0;os;s++){for(var a=0,h=o.vertices[s];ar;++r)o=n.vertices[r],o.triangleCount++;var s=0;for(t=0;tr;++r)o=n.vertices[r],h[o.triangleStart+o.triangleCount]=new a(r,t),o.triangleCount++;this.references=h,e&&this.identifyBorder()},t.prototype.vertexError=function(e,t){var i=t.x,n=t.y,r=t.z;return e.data[0]*i*i+2*e.data[1]*i*n+2*e.data[2]*i*r+2*e.data[3]*i+e.data[4]*n*n+2*e.data[5]*n*r+2*e.data[6]*n+e.data[7]*r*r+2*e.data[8]*r+e.data[9]},t.prototype.calculateError=function(t,i,n,r,o,s){var a=t.q.add(i.q),h=t.isBorder&&i.isBorder,c=0,l=a.det(0,1,2,1,4,5,2,5,7);if(0===l||h){var u=t.position.add(i.position).divide(new e.Vector3(2,2,2)),d=this.vertexError(a,t.position),f=this.vertexError(a,i.position),p=this.vertexError(a,u);c=Math.min(d,f,p),c===d?n&&n.copyFrom(t.position):c===f?n&&n.copyFrom(i.position):n&&n.copyFrom(u)}else n||(n=e.Vector3.Zero()),n.x=-1/l*a.det(1,2,3,4,5,6,5,7,8),n.y=1/l*a.det(0,2,3,1,5,6,2,7,8),n.z=-1/l*a.det(0,1,3,1,4,6,2,5,8),c=this.vertexError(a,n);return c},t}();e.QuadraticErrorSimplification=h}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=[],i=function(i,n){if(!t[i.id]){if(i instanceof e.Geometry.Primitives.Box)n.boxes.push(i.serialize());else if(i instanceof e.Geometry.Primitives.Sphere)n.spheres.push(i.serialize());else if(i instanceof e.Geometry.Primitives.Cylinder)n.cylinders.push(i.serialize());else if(i instanceof e.Geometry.Primitives.Torus)n.toruses.push(i.serialize());else if(i instanceof e.Geometry.Primitives.Ground)n.grounds.push(i.serialize());else if(i instanceof e.Geometry.Primitives.Plane)n.planes.push(i.serialize());else if(i instanceof e.Geometry.Primitives.TorusKnot)n.torusKnots.push(i.serialize());else{if(i instanceof e.Geometry.Primitives._Primitive)throw new Error("Unknown primitive type");n.vertexData.push(i.serializeVerticeData())}t[i.id]=!0}},n=function(t,n){var r={};r.name=t.name,r.id=t.id,e.Tags.HasTags(t)&&(r.tags=e.Tags.GetTags(t)),r.position=t.position.asArray(),t.rotationQuaternion?r.rotationQuaternion=t.rotationQuaternion.asArray():t.rotation&&(r.rotation=t.rotation.asArray()),r.scaling=t.scaling.asArray(),r.localMatrix=t.getPivotMatrix().asArray(),r.isEnabled=t.isEnabled(),r.isVisible=t.isVisible,r.infiniteDistance=t.infiniteDistance,r.pickable=t.isPickable,r.receiveShadows=t.receiveShadows,r.billboardMode=t.billboardMode,r.visibility=t.visibility,r.checkCollisions=t.checkCollisions,t.parent&&(r.parentId=t.parent.id);var o=t._geometry;if(o){var s=o.id;r.geometryId=s,t.getScene().getGeometryByID(s)||i(o,n.geometries),r.subMeshes=[];for(var a=0;at.EPSILON?u:l;p|=_,m.push(_)}switch(p){case l:(e.Vector3.Dot(this.normal,i.plane.normal)>0?n:o).push(i);break;case u:s.push(i);break;case d:a.push(i);break;case f:var g=[],v=[];for(h=0;h=3&&(P=new r(g,i.shared),P.plane&&s.push(P)),v.length>=3&&(P=new r(v,i.shared),P.plane&&a.push(P))}},t.EPSILON=1e-5,t}(),r=function(){function e(e,t){this.vertices=e,this.shared=t,this.plane=n.FromPoints(e[0].pos,e[1].pos,e[2].pos)}return e.prototype.clone=function(){var t=this.vertices.map(function(e){return e.clone()});return new e(t,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;eE;E++)for(var P=A[E].indexStart,M=A[E].indexCount+A[E].indexStart;M>P;P+=3){u=[];for(var S=0;3>S;S++){var C=new e.Vector3(x[3*v[P+S]],x[3*v[P+S]+1],x[3*v[P+S]+2]);h=new e.Vector2(b[2*v[P+S]],b[2*v[P+S]+1]);var R=new e.Vector3(y[3*v[P+S]],y[3*v[P+S]+1],y[3*v[P+S]+2]);c=e.Vector3.TransformCoordinates(R,d),a=e.Vector3.TransformNormal(C,d),s=new i(c,a,h),u.push(s)}l=new r(u,{subMeshId:E,meshId:t,materialIndex:A[E].materialIndex}),l.plane&&g.push(l)}var I=n.FromPolygons(g);return I.matrix=d,I.position=f,I.rotation=p,I.scaling=_,I.rotationQuaternion=m,t++,I},n.FromPolygons=function(e){var t=new n;return t.polygons=e,t},n.prototype.clone=function(){var e=new n;return e.polygons=this.polygons.map(function(e){return e.clone()}),e.copyTransformAttributes(this),e},n.prototype.toPolygons=function(){return this.polygons},n.prototype.union=function(e){var t=new o(this.clone().polygons),i=new o(e.clone().polygons);return t.clipTo(i),i.clipTo(t),i.invert(),i.clipTo(t),i.invert(),t.build(i.allPolygons()),n.FromPolygons(t.allPolygons()).copyTransformAttributes(this)},n.prototype.unionInPlace=function(e){var t=new o(this.polygons),i=new o(e.polygons);t.clipTo(i),i.clipTo(t),i.invert(),i.clipTo(t),i.invert(),t.build(i.allPolygons()),this.polygons=t.allPolygons()},n.prototype.subtract=function(e){var t=new o(this.clone().polygons),i=new o(e.clone().polygons);return t.invert(),t.clipTo(i),i.clipTo(t),i.invert(),i.clipTo(t),i.invert(),t.build(i.allPolygons()),t.invert(),n.FromPolygons(t.allPolygons()).copyTransformAttributes(this)},n.prototype.subtractInPlace=function(e){var t=new o(this.polygons),i=new o(e.polygons);t.invert(),t.clipTo(i),i.clipTo(t),i.invert(),i.clipTo(t),i.invert(),t.build(i.allPolygons()),t.invert(),this.polygons=t.allPolygons()},n.prototype.intersect=function(e){var t=new o(this.clone().polygons),i=new o(e.clone().polygons);return t.invert(),i.clipTo(t),i.invert(),t.clipTo(i),i.clipTo(t),t.build(i.allPolygons()),t.invert(),n.FromPolygons(t.allPolygons()).copyTransformAttributes(this)},n.prototype.intersectInPlace=function(e){var t=new o(this.polygons),i=new o(e.polygons);t.invert(),i.clipTo(t),i.invert(),t.clipTo(i),i.clipTo(t),t.build(i.allPolygons()),t.invert(),this.polygons=t.allPolygons()},n.prototype.inverse=function(){var e=this.clone();return e.inverseInPlace(),e},n.prototype.inverseInPlace=function(){this.polygons.map(function(e){e.flip()})},n.prototype.copyTransformAttributes=function(e){return this.matrix=e.matrix,this.position=e.position,this.rotation=e.rotation,this.scaling=e.scaling,this.rotationQuaternion=e.rotationQuaternion,this},n.prototype.buildMeshGeometry=function(t,i,n){var r=this.matrix.clone();r.invert();var o,s,a,h=new e.Mesh(t,i),c=[],l=[],u=[],d=[],f=e.Vector3.Zero(),p=e.Vector3.Zero(),m=e.Vector2.Zero(),_=this.polygons,g=[0,0,0],v={},y=0,x={};n&&_.sort(function(e,t){return e.shared.meshId===t.shared.meshId?e.shared.subMeshId-t.shared.subMeshId:e.shared.meshId-t.shared.meshId});for(var b=0,A=_.length;A>b;b++){o=_[b],x[o.shared.meshId]||(x[o.shared.meshId]={}),x[o.shared.meshId][o.shared.subMeshId]||(x[o.shared.meshId][o.shared.subMeshId]={indexStart:+(1/0),indexEnd:-(1/0),materialIndex:o.shared.materialIndex}),a=x[o.shared.meshId][o.shared.subMeshId];for(var E=2,T=o.vertices.length;T>E;E++){g[0]=0,g[1]=E-1,g[2]=E;for(var P=0;3>P;P++){f.copyFrom(o.vertices[g[P]].pos),p.copyFrom(o.vertices[g[P]].normal),m.copyFrom(o.vertices[g[P]].uv);var M=e.Vector3.TransformCoordinates(f,r),S=e.Vector3.TransformNormal(p,r);s=v[M.x+","+M.y+","+M.z],"undefined"!=typeof s&&u[3*s]===S.x&&u[3*s+1]===S.y&&u[3*s+2]===S.z&&d[2*s]===m.x&&d[2*s+1]===m.y||(c.push(M.x,M.y,M.z),d.push(m.x,m.y),u.push(p.x,p.y,p.z),s=v[M.x+","+M.y+","+M.z]=c.length/3-1),l.push(s),a.indexStart=Math.min(y,a.indexStart),a.indexEnd=Math.max(y,a.indexEnd),y++}}}if(h.setVerticesData(e.VertexBuffer.PositionKind,c),h.setVerticesData(e.VertexBuffer.NormalKind,u),h.setVerticesData(e.VertexBuffer.UVKind,d),h.setIndices(l),n){var C,R=0;h.subMeshes=new Array;for(var I in x){C=-1;for(var D in x[I])a=x[I][D],e.SubMesh.CreateFromIndices(a.materialIndex+R,a.indexStart,a.indexEnd-a.indexStart+1,h),C=Math.max(a.materialIndex,C);R+=++C}}return h},n.prototype.toMesh=function(e,t,i,n){var r=this.buildMeshGeometry(e,i,n);return r.material=t,r.position.copyFrom(this.position),r.rotation.copyFrom(this.rotation),this.rotationQuaternion&&(r.rotationQuaternion=this.rotationQuaternion.clone()),r.scaling.copyFrom(this.scaling),r.computeWorldMatrix(!0),r},n}();e.CSG=s}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t){function i(i,n,r,o){var s=this;t.call(this,i,"vrDistortionCorrection",["LensCenter","Scale","ScaleIn","HmdWarpParam"],null,o.postProcessScaleFactor,n,e.Texture.BILINEAR_SAMPLINGMODE,null,null),this._isRightEye=r,this._distortionFactors=o.distortionK,this._postProcessScaleFactor=o.postProcessScaleFactor,this._lensCenterOffset=o.lensCenterOffset,this.onSizeChanged=function(){s.aspectRatio=.5*s.width/s.height,s._scaleIn=new e.Vector2(2,2/s.aspectRatio),s._scaleFactor=new e.Vector2(.5*(1/s._postProcessScaleFactor),.5*(1/s._postProcessScaleFactor)*s.aspectRatio),s._lensCenter=new e.Vector2(s._isRightEye?.5-.5*s._lensCenterOffset:.5+.5*s._lensCenterOffset,.5)},this.onApply=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])}}return __extends(i,t),i}(e.PostProcess);e.VRDistortionCorrectionPostProcess=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){!function(e){e[e.X=0]="X",e[e.Y=1]="Y",e[e.Z=2]="Z"}(e.JoystickAxis||(e.JoystickAxis={}));var t=e.JoystickAxis,i=function(){function i(n){var r=this;n?this._leftJoystick=!0:this._leftJoystick=!1,this._joystickIndex=i._globalJoystickIndex,i._globalJoystickIndex++,this._axisTargetedByLeftAndRight=t.X,this._axisTargetedByUpAndDown=t.Y,this.reverseLeftRight=!1,this.reverseUpDown=!1,this._touches=new e.StringDictionary,this.deltaPosition=e.Vector3.Zero(),this._joystickSensibility=25,this._inversedSensibility=1/(this._joystickSensibility/1e3),this._rotationSpeed=25,this._inverseRotationSpeed=1/(this._rotationSpeed/1e3),this._rotateOnAxisRelativeToMesh=!1,this._onResize=function(e){i.vjCanvasWidth=window.innerWidth,i.vjCanvasHeight=window.innerHeight,i.vjCanvas.width=i.vjCanvasWidth,i.vjCanvas.height=i.vjCanvasHeight,i.halfWidth=i.vjCanvasWidth/2,i.halfHeight=i.vjCanvasHeight/2},i.vjCanvas||(window.addEventListener("resize",this._onResize,!1),i.vjCanvas=document.createElement("canvas"),i.vjCanvasWidth=window.innerWidth,i.vjCanvasHeight=window.innerHeight,i.vjCanvas.width=window.innerWidth,i.vjCanvas.height=window.innerHeight,i.vjCanvas.style.width="100%",i.vjCanvas.style.height="100%",i.vjCanvas.style.position="absolute",i.vjCanvas.style.backgroundColor="transparent",i.vjCanvas.style.top="0px",i.vjCanvas.style.left="0px",i.vjCanvas.style.zIndex="5",i.vjCanvas.style.msTouchAction="none",i.vjCanvas.setAttribute("touch-action","none"),i.vjCanvasContext=i.vjCanvas.getContext("2d"),i.vjCanvasContext.strokeStyle="#ffffff",i.vjCanvasContext.lineWidth=2,document.body.appendChild(i.vjCanvas)),i.halfWidth=i.vjCanvas.width/2,i.halfHeight=i.vjCanvas.height/2,this.pressed=!1,this._joystickColor="cyan",this._joystickPointerID=-1,this._joystickPointerPos=new e.Vector2(0,0),this._joystickPreviousPointerPos=new e.Vector2(0,0),this._joystickPointerStartPos=new e.Vector2(0,0),this._deltaJoystickVector=new e.Vector2(0,0),this._onPointerDownHandlerRef=function(e){r._onPointerDown(e)},this._onPointerMoveHandlerRef=function(e){r._onPointerMove(e)},this._onPointerOutHandlerRef=function(e){r._onPointerUp(e)},this._onPointerUpHandlerRef=function(e){r._onPointerUp(e)},i.vjCanvas.addEventListener("pointerdown",this._onPointerDownHandlerRef,!1),i.vjCanvas.addEventListener("pointermove",this._onPointerMoveHandlerRef,!1),i.vjCanvas.addEventListener("pointerup",this._onPointerUpHandlerRef,!1),i.vjCanvas.addEventListener("pointerout",this._onPointerUpHandlerRef,!1),i.vjCanvas.addEventListener("contextmenu",function(e){e.preventDefault()},!1),requestAnimationFrame(function(){r._drawVirtualJoystick()})}return i.prototype.setJoystickSensibility=function(e){this._joystickSensibility=e,this._inversedSensibility=1/(this._joystickSensibility/1e3)},i.prototype._onPointerDown=function(e){var t;e.preventDefault(),t=this._leftJoystick===!0?e.clientXi.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,n=i*this._deltaJoystickVector.x/this._inversedSensibility;switch(this._axisTargetedByLeftAndRight){case t.X:this.deltaPosition.x=Math.min(1,Math.max(-1,n));break;case t.Y:this.deltaPosition.y=Math.min(1,Math.max(-1,n));break;case t.Z:this.deltaPosition.z=Math.min(1,Math.max(-1,n))}var r=this.reverseUpDown?1:-1,o=r*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-63,this._joystickPointerStartPos.y-63,126,126),i.vjCanvasContext.clearRect(this._joystickPreviousPointerPos.x-41,this._joystickPreviousPointerPos.y-41,82,82),this._joystickPointerID=-1,this.pressed=!1;else{var t=this._touches.get(e.pointerId.toString());t&&i.vjCanvasContext.clearRect(t.prevX-43,t.prevY-43,86,86)}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){t.pointerId===e._joystickPointerID?(i.vjCanvasContext.clearRect(e._joystickPointerStartPos.x-63,e._joystickPointerStartPos.y-63,126,126),i.vjCanvasContext.clearRect(e._joystickPreviousPointerPos.x-41,e._joystickPreviousPointerPos.y-41,82,82),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(t.prevX-43,t.prevY-43,86,86),i.vjCanvasContext.beginPath(),i.vjCanvasContext.fillStyle="white",i.vjCanvasContext.beginPath(),i.vjCanvasContext.strokeStyle="red",i.vjCanvasContext.lineWidth=6,i.vjCanvasContext.arc(t.x,t.y,40,0,2*Math.PI,!0),i.vjCanvasContext.stroke(),i.vjCanvasContext.closePath(),t.prevX=t.x,t.prevY=t.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._globalJoystickIndex=0,i}();e.VirtualJoystick=i}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(e){function t(t,i,n){e.call(this,t,i,n),this.inputs.addVirtualJoystick()}return __extends(t,e),t}(e.FreeCamera);e.VirtualJoysticksCamera=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(e){function t(t,i,n,r,o,s){e.call(this,t,"anaglyph",null,["leftSampler"],i,n,r,o,s)}return __extends(t,e),t}(e.PostProcess);e.AnaglyphPostProcess=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(e){this._scene=e}return t.prototype.render=function(t,i,n){var r=this;void 0===n&&(n=!1);var o=this._scene,s=this._scene.getEngine(),a=null!==s.getCaps().instancedArrays&&null!==i.visibleInstances[t._id]&&void 0!==i.visibleInstances[t._id];if(this.isReady(t,a)){var h=t.getRenderingMesh(),c=t.getMaterial();if(s.enableEffect(this._effect),this._effect.setFloat("offset",n?0:h.outlineWidth),this._effect.setColor4("color",n?h.overlayColor:h.outlineColor,n?h.overlayAlpha:1),this._effect.setMatrix("viewProjection",o.getTransformMatrix()),h.useBones&&h.computeBonesUsingShaders&&this._effect.setMatrices("mBones",h.skeleton.getTransformMatrices(h)),h._bind(t,this._effect,e.Material.TriangleFillMode),c&&c.needAlphaTesting()){var l=c.getAlphaTestTexture();this._effect.setTexture("diffuseSampler",l),this._effect.setMatrix("diffuseMatrix",l.getTextureMatrix())}h._processRendering(t,this._effect,e.Material.TriangleFillMode,i,a,function(e,t){r._effect.setMatrix("world",t)})}},t.prototype.isReady=function(t,i){var n=[],r=[e.VertexBuffer.PositionKind,e.VertexBuffer.NormalKind],o=t.getMesh(),s=t.getMaterial();s&&s.needAlphaTesting()&&(n.push("#define ALPHATEST"),o.isVerticesDataPresent(e.VertexBuffer.UVKind)&&(r.push(e.VertexBuffer.UVKind),n.push("#define UV1")),o.isVerticesDataPresent(e.VertexBuffer.UV2Kind)&&(r.push(e.VertexBuffer.UV2Kind),n.push("#define UV2"))),o.useBones&&o.computeBonesUsingShaders?(r.push(e.VertexBuffer.MatricesIndicesKind),r.push(e.VertexBuffer.MatricesWeightsKind),o.numBoneInfluencers>4&&(r.push(e.VertexBuffer.MatricesIndicesExtraKind),r.push(e.VertexBuffer.MatricesWeightsExtraKind)),n.push("#define NUM_BONE_INFLUENCERS "+o.numBoneInfluencers),n.push("#define BonesPerMesh "+(o.skeleton.bones.length+1))):n.push("#define NUM_BONE_INFLUENCERS 0"),i&&(n.push("#define INSTANCES"),r.push("world0"),r.push("world1"),r.push("world2"),r.push("world3"));var a=n.join("\n");return this._cachedDefines!==a&&(this._cachedDefines=a,this._effect=this._scene.getEngine().createEffect("outline",r,["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 t(e,t,i,n){this.name=e,this.meshesNames=t,this.rootUrl=i,this.sceneFilename=n,this.isCompleted=!1}return t.prototype.run=function(t,i,n){var r=this;e.SceneLoader.ImportMesh(this.meshesNames,this.rootUrl,this.sceneFilename,t,function(e,t,n){r.loadedMeshes=e,r.loadedParticleSystems=t,r.loadedSkeletons=n,r.isCompleted=!0,r.onSuccess&&r.onSuccess(r),i()},null,function(){r.onError&&r.onError(r),n()})},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,n){var r=this;e.Tools.LoadFile(this.url,function(e){r.text=e,r.isCompleted=!0,r.onSuccess&&r.onSuccess(r),i()},null,t.database,!1,function(){r.onError&&r.onError(r),n()})},t}();e.TextFileAssetTask=i;var n=function(){function t(e,t){this.name=e,this.url=t,this.isCompleted=!1}return t.prototype.run=function(t,i,n){var r=this;e.Tools.LoadFile(this.url,function(e){r.data=e,r.isCompleted=!0,r.onSuccess&&r.onSuccess(r),i()},null,t.database,!0,function(){r.onError&&r.onError(r),n()})},t}();e.BinaryFileAssetTask=n;var r=function(){function e(e,t){this.name=e,this.url=t,this.isCompleted=!1}return e.prototype.run=function(e,t,i){var n=this,r=new Image;r.onload=function(){n.image=r,n.isCompleted=!0,n.onSuccess&&n.onSuccess(n),t()},r.onerror=function(){n.onError&&n.onError(n),i()},r.src=this.url},e}();e.ImageAssetTask=r;var o=function(){function t(t,i,n,r,o){void 0===o&&(o=e.Texture.TRILINEAR_SAMPLINGMODE),this.name=t,this.url=i,this.noMipmap=n,this.invertY=r,this.samplingMode=o,this.isCompleted=!1}return t.prototype.run=function(t,i,n){var r=this,o=function(){r.isCompleted=!0,r.onSuccess&&r.onSuccess(r),i()},s=function(){r.onError&&r.onError(r),n()};this.texture=new e.Texture(this.url,t,this.noMipmap,this.invertY,this.samplingMode,o,s)},t}();e.TextureAssetTask=o;var s=function(){function s(e){this._tasks=new Array,this._waitingTasksCount=0,this.useDefaultLoadingScreen=!0,this._scene=e}return s.prototype.addMeshTask=function(e,i,n,r){var o=new t(e,i,n,r);return this._tasks.push(o),o},s.prototype.addTextFileTask=function(e,t){var n=new i(e,t);return this._tasks.push(n),n},s.prototype.addBinaryFileTask=function(e,t){var i=new n(e,t);return this._tasks.push(i),i},s.prototype.addImageTask=function(e,t){var i=new r(e,t);return this._tasks.push(i),i},s.prototype.addTextureTask=function(t,i,n,r,s){void 0===s&&(s=e.Texture.TRILINEAR_SAMPLINGMODE);var a=new o(t,i,n,r,s);return this._tasks.push(a),a},s.prototype._decreaseWaitingTasksCount=function(){this._waitingTasksCount--,0===this._waitingTasksCount&&(this.onFinish&&this.onFinish(this._tasks),this._scene.getEngine().hideLoadingUI())},s.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()})},s.prototype.reset=function(){return this._tasks=new Array,this},s.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;ei&&null===this._hmdDevice;)e[i]instanceof HMDVRDevice&&(this._hmdDevice=e[i]),i++;for(i=0;t>i&&null===this._sensorDevice;)e[i]instanceof PositionSensorVRDevice&&(!this._hmdDevice||e[i].hardwareUnitId===this._hmdDevice.hardwareUnitId)&&(this._sensorDevice=e[i]),i++;this._vrEnabled=!(!this._sensorDevice||!this._hmdDevice)},i.prototype._checkInputs=function(){this._vrEnabled&&(this._cacheState=this._sensorDevice.getState(),this._cacheQuaternion.copyFromFloats(this._cacheState.orientation.x,this._cacheState.orientation.y,this._cacheState.orientation.z,this._cacheState.orientation.w),this._cacheQuaternion.toEulerAnglesToRef(this._cacheRotation),this.rotation.x=-this._cacheRotation.x,this.rotation.y=-this._cacheRotation.y,this.rotation.z=this._cacheRotation.z),t.prototype._checkInputs.call(this)},i.prototype.attachControl=function(i,n){t.prototype.attachControl.call(this,i,n),n=e.Camera.ForceAttachControlToAlwaysPreventDefault?!1:n,navigator.getVRDevices?navigator.getVRDevices().then(this._getWebVRDevices):navigator.mozGetVRDevices&&navigator.mozGetVRDevices(this._getWebVRDevices)},i.prototype.detachControl=function(e){t.prototype.detachControl.call(this,e),this._vrEnabled=!1},i.prototype.getTypeName=function(){return"WebVRFreeCamera"},i}(e.FreeCamera);e.WebVRFreeCamera=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function e(e){void 0===e&&(e=0),this.priority=e,this.apply=function(e){return!0}}return e}();e.SceneOptimization=t;var i=function(e){function t(t,i){var n=this;void 0===t&&(t=0),void 0===i&&(i=1024),e.call(this,t),this.priority=t,this.maximumSize=i,this.apply=function(e){for(var t=!0,i=0;in.maximumSize&&(r.scale(.5),t=!1)}}return t}}return __extends(t,e),t}(t);e.TextureOptimization=i;var n=function(e){function t(t,i){var n=this;void 0===t&&(t=0),void 0===i&&(i=2),e.call(this,t),this.priority=t,this.maximumScale=i,this._currentScale=1,this.apply=function(e){return n._currentScale++,e.getEngine().setHardwareScalingLevel(n._currentScale),n._currentScale>=n.maximumScale}}return __extends(t,e),t}(t);e.HardwareScalingOptimization=n;var r=function(e){function t(){e.apply(this,arguments),this.apply=function(e){return e.shadowsEnabled=!1,!0}}return __extends(t,e),t}(t);e.ShadowsOptimization=r;var o=function(e){function t(){e.apply(this,arguments),this.apply=function(e){return e.postProcessesEnabled=!1,!0}}return __extends(t,e),t}(t);e.PostProcessesOptimization=o;var s=function(e){function t(){e.apply(this,arguments),this.apply=function(e){return e.lensFlaresEnabled=!1,!0}}return __extends(t,e),t}(t);e.LensFlaresOptimization=s;var a=function(e){function t(){e.apply(this,arguments),this.apply=function(e){return e.particlesEnabled=!1,!0}}return __extends(t,e),t}(t);e.ParticlesOptimization=a;var h=function(e){function t(){e.apply(this,arguments),this.apply=function(e){return e.renderTargetsEnabled=!1,!0}}return __extends(t,e),t}(t);e.RenderTargetsOptimization=h;var c=function(t){function i(){var n=this;t.apply(this,arguments),this._canBeMerged=function(t){if(!(t instanceof e.Mesh))return!1;var i=t;return i.isVisible&&i.isEnabled()?i.instances.length>0?!1:i.skeleton||i.hasLODLevels?!1:!i.parent:!1},this.apply=function(t,r){for(var o=t.meshes.slice(0),s=o.length,a=0;s>a;a++){var h=new Array,c=o[a];if(n._canBeMerged(c)){h.push(c);for(var l=a+1;s>l;l++){var u=o[l];n._canBeMerged(u)&&u.material===c.material&&u.checkCollisions===c.checkCollisions&&(h.push(u),s--,o.splice(l,1),l--)}h.length<2||e.Mesh.MergeMeshes(h)}}return void 0!=r?r&&t.createOrUpdateSelectionOctree():i.UpdateSelectionTree&&t.createOrUpdateSelectionOctree(),!0}}return __extends(i,t),Object.defineProperty(i,"UpdateSelectionTree",{get:function(){return i._UpdateSelectionTree},set:function(e){i._UpdateSelectionTree=e},enumerable:!0,configurable:!0}),i._UpdateSelectionTree=!1,i}(t);e.MergeMeshesOptimization=c;var l=function(){function e(e,t){void 0===e&&(e=60),void 0===t&&(t=2e3),this.targetFrameRate=e,this.trackerDuration=t,this.optimizations=new Array}return e.LowDegradationAllowed=function(t){var n=new e(t),h=0;return n.optimizations.push(new c(h)),n.optimizations.push(new r(h)),n.optimizations.push(new s(h)),h++,n.optimizations.push(new o(h)),n.optimizations.push(new a(h)),h++,n.optimizations.push(new i(h,1024)), n},e.ModerateDegradationAllowed=function(t){var l=new e(t),u=0;return l.optimizations.push(new c(u)),l.optimizations.push(new r(u)),l.optimizations.push(new s(u)),u++,l.optimizations.push(new o(u)),l.optimizations.push(new a(u)),u++,l.optimizations.push(new i(u,512)),u++,l.optimizations.push(new h(u)),u++,l.optimizations.push(new n(u,2)),l},e.HighDegradationAllowed=function(t){var l=new e(t),u=0;return l.optimizations.push(new c(u)),l.optimizations.push(new r(u)),l.optimizations.push(new s(u)),u++,l.optimizations.push(new o(u)),l.optimizations.push(new a(u)),u++,l.optimizations.push(new i(u,256)),u++,l.optimizations.push(new h(u)),u++,l.optimizations.push(new n(u,4)),l},e}();e.SceneOptimizerOptions=l;var u=function(){function e(){}return e._CheckCurrentState=function(t,i,n,r,o){if(t.getEngine().getFps()>=i.targetFrameRate)return void(r&&r());for(var s=!0,a=!0,h=0;hi.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}(),n=function(){function t(){}return t.Rectangle=function(t,i,n,r){return[new e.Vector2(t,i),new e.Vector2(n,i),new e.Vector2(n,r),new e.Vector2(t,r)]},t.Circle=function(t,i,n,r){void 0===i&&(i=0),void 0===n&&(n=0),void 0===r&&(r=32);for(var o=new Array,s=0,a=2*Math.PI/r,h=0;r>h;h++)o.push(new e.Vector2(i+Math.cos(s)*t,n+Math.sin(s)*t)),s-=a;return o},t.Parse=function(t){var i,n=t.split(/[^-+eE\.\d]+/).map(parseFloat).filter(function(e){return!isNaN(e)}),r=[];for(i=0;i<(2147483646&n.length);i+=2)r.push(new e.Vector2(n[i],n[i+1]));return r},t.StartingAt=function(t,i){return e.Path2.StartingAt(t,i)},t}();e.Polygon=n;var r=function(){function t(t,n,r){if(this._points=new i,this._outlinepoints=new i,this._holes=[],!("poly2tri"in window))throw"PolygonMeshBuilder cannot be used because poly2tri is not referenced";this._name=t,this._scene=r;var o;o=n instanceof e.Path2?n.getPoints():n,this._swctx=new poly2tri.SweepContext(this._points.add(o)),this._outlinepoints.add(o)}return t.prototype.addHole=function(e){this._swctx.addHole(this._points.add(e));var t=new i;return t.add(e),this._holes.push(t),this},t.prototype.build=function(t,i){var n=this;void 0===t&&(t=!1);var r=new e.Mesh(this._name,this._scene),o=[],s=[],a=[],h=this._points.computeBounds();this._points.elements.forEach(function(e){o.push(0,1,0),s.push(e.x,0,e.y),a.push((e.x-h.min.x)/h.width,(e.y-h.min.y)/h.height)});var c=[];if(this._swctx.triangulate(),this._swctx.getTriangles().forEach(function(e){e.getPoints().forEach(function(e){c.push(e.index)})}),i>0){var l=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)});var u,d,f=0;this._swctx.getTriangles().forEach(function(e){e.getPoints().forEach(function(e){switch(f){case 0:u=e;break;case 1:d=e;break;case 2:c.push(e.index+l),c.push(d.index+l),c.push(u.index+l),f=-1}f++})}),this.addSide(s,o,a,c,h,this._outlinepoints,i,!1),this._holes.forEach(function(e){n.addSide(s,o,a,c,h,e,i,!0)})}return r.setVerticesData(e.VertexBuffer.PositionKind,s,t),r.setVerticesData(e.VertexBuffer.NormalKind,o,t),r.setVerticesData(e.VertexBuffer.UVKind,a,t),r.setIndices(c),r},t.prototype.addSide=function(t,i,n,r,o,s,a,h){for(var c=t.length/3,l=0,u=0;us.elements.length-1?s.elements[0]:s.elements[u+1],t.push(f.x,0,f.y),t.push(f.x,-a,f.y),t.push(d.x,0,d.y),t.push(d.x,-a,d.y);var p=new e.Vector3(f.x,0,f.y),m=new e.Vector3(d.x,0,d.y),_=m.subtract(p),g=new e.Vector3(0,1,0),v=e.Vector3.Cross(_,g);v=v.normalize(),n.push(l/o.width,0),n.push(l/o.width,1),l+=_.length(),n.push(l/o.width,0),n.push(l/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),r.push(c),r.push(c+2),r.push(c+1),r.push(c+1),r.push(c+2),r.push(c+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),r.push(c),r.push(c+1),r.push(c+2),r.push(c+1),r.push(c+3),r.push(c+2)),c+=4}},t}();e.PolygonMeshBuilder=r}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(t,i,n){void 0===n&&(n=2),this.maxDepth=n,this.dynamicContent=new Array,this._maxBlockCapacity=i||64,this._selectionContent=new e.SmartArray(1024),this._creationFunc=t}return t.prototype.update=function(e,i,n){t._CreateBlocks(e,i,n,this._maxBlockCapacity,0,this.maxDepth,this,this._creationFunc)},t.prototype.addMesh=function(e){for(var t=0;tl;l++)for(var u=0;2>u;u++)for(var d=0;2>d;d++){var f=t.add(c.multiplyByFloats(l,u,d)),p=t.add(c.multiplyByFloats(l+1,u+1,d+1)),m=new e.OctreeBlock(f,p,r,o+1,s,h);m.addEntries(n),a.blocks.push(m)}},t.CreationFuncForMeshes=function(e,t){!e.isBlocked&&e.getBoundingInfo().boundingBox.intersectsMinMax(t.minPoint,t.maxPoint)&&t.entries.push(e)},t.CreationFuncForSubMeshes=function(e,t){e.getBoundingInfo().boundingBox.intersectsMinMax(t.minPoint,t.maxPoint)&&t.entries.push(e)},t}();e.Octree=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(e,t,i,n,r,o){this.entries=new Array,this._boundingVectors=new Array,this._capacity=i,this._depth=n,this._maxDepth=r,this._creationFunc=o,this._minPoint=e,this._maxPoint=t,this._boundingVectors.push(e.clone()),this._boundingVectors.push(t.clone()),this._boundingVectors.push(e.clone()),this._boundingVectors[2].x=t.x,this._boundingVectors.push(e.clone()),this._boundingVectors[3].y=t.y,this._boundingVectors.push(e.clone()),this._boundingVectors[4].z=t.z,this._boundingVectors.push(t.clone()),this._boundingVectors[5].z=e.z,this._boundingVectors.push(t.clone()),this._boundingVectors[6].x=e.x,this._boundingVectors.push(t.clone()),this._boundingVectors[7].y=e.y}return Object.defineProperty(t.prototype,"capacity",{get:function(){return this._capacity},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"minPoint",{get:function(){return this._minPoint},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"maxPoint",{get:function(){return this._maxPoint},enumerable:!0,configurable:!0}),t.prototype.addEntry=function(e){if(this.blocks)for(var t=0;tthis.capacity&&this._depth0&&this._positionX>t.x&&this._positionXt.y&&this._positionYn},t.prototype.render=function(){if(!this._effect.isReady())return!1;var t=this._scene.getEngine(),i=this._scene.activeCamera.viewport,n=i.toGlobal(t.getRenderWidth(!0),t.getRenderHeight(!0));if(!this.computeEffectivePosition(n))return!1;if(!this._isVisible())return!1;var r,o;r=this._positionXn.x+n.width-this.borderLimit?this._positionX-n.x-n.width+this.borderLimit:0,o=this._positionYn.y+n.height-this.borderLimit?this._positionY-n.y-n.height+this.borderLimit:0;var s=r>o?r:o;s>this.borderLimit&&(s=this.borderLimit);var a=1-s/this.borderLimit;if(0>a)return!1;a>1&&(a=1);var h=n.x+n.width/2,c=n.y+n.height/2,l=h-this._positionX,u=c-this._positionY;t.enableEffect(this._effect),t.setState(!1),t.setDepthBuffer(!1),t.setAlphaMode(e.Engine.ALPHA_ONEONE),t.bindBuffers(this._vertexBuffer,this._indexBuffer,this._vertexDeclaration,this._vertexStrideSize,this._effect);for(var d=0;d=2&&(this._leftStick={x:this.browserGamepad.axes[0],y:this.browserGamepad.axes[1]}),this.browserGamepad.axes.length>=4&&(this._rightStick={x:this.browserGamepad.axes[2],y:this.browserGamepad.axes[3]})}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[0],y:this.browserGamepad.axes[1]}),this._rightStick&&(this.rightStick={x:this.browserGamepad.axes[2],y:this.browserGamepad.axes[3]})},e}();e.Gamepad=n;var r=function(e){function t(t,i,n){e.call(this,t,i,n),this.id=t,this.index=i,this.gamepad=n,this._buttons=new Array(n.buttons.length)}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;ts?s:Math.floor(a);var h,c,l,u,d=0===i.sideOrientation?0:i.sideOrientation||e this._renderEffectsForIsolatedPass[l]._attachCameras(c)}}},t.prototype._disableDisplayOnlyPass=function(i){for(var r=this,n=e.Tools.MakeArray(i||this._cameras),o=0;othis.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}),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),i._actionManager=this,i._prepare(),i)},t.prototype.processTrigger=function(e,i){for(var r=0;r0;if(2===i.type?d.push(o):d.push(r),_){for(var m=new Array,g=0;g0){var d=u.properties[0].value,f=null===u.properties[0].targetType?d:n.getMeshByName(d);l={trigger:e.ActionManager[u.name],parameter:f}}else l=e.ActionManager[u.name];for(var p=0;pa;a++){var h=o[a];h._resetPointsArrayCache(),h._boundingInfo=new e.BoundingInfo(this._extend.minimum,this._extend.maximum),h._createGlobalSubMesh(),h.computeWorldMatrix(!0)}}this.notifyUpdate(t)},t.prototype.updateVerticesDataDirectly=function(e,t,i){var r=this.getVertexBuffer(e);r&&(r.updateDirectly(t,i),this.notifyUpdate(e))},t.prototype.updateVerticesData=function(t,i,r){var n=this.getVertexBuffer(t);if(n){if(n.update(i),t===e.VertexBuffer.PositionKind){var o=n.getStrideSize();this._totalVertices=i.length/o,this.updateBoundingInfo(r,i)}this.notifyUpdate(t)}},t.prototype.updateBoundingInfo=function(t,i){t&&this.updateExtend(i);for(var r=this._meshes,n=r.length,o=0;n>o;o++){var s=r[o];if(s._resetPointsArrayCache(),t){s._boundingInfo=new e.BoundingInfo(this._extend.minimum,this._extend.maximum);for(var a=0;as;s++)o.push(r[s]);return o}return r},t.prototype.getVertexBuffer=function(e){return this.isReady()?this._vertexBuffers[e]:null},t.prototype.getVertexBuffers=function(){return this.isReady()?this._vertexBuffers:null},t.prototype.isVerticesDataPresent=function(e){return this._vertexBuffers?void 0!==this._vertexBuffers[e]:this._delayInfo?-1!==this._delayInfo.indexOf(e):!1},t.prototype.getVerticesDataKinds=function(){var e,t=[];if(!this._vertexBuffers&&this._delayInfo)for(e in this._delayInfo)t.push(e);else for(e in this._vertexBuffers)t.push(e);return t},t.prototype.setIndices=function(e,t){this._indexBuffer&&this._engine._releaseBuffer(this._indexBuffer),this._indices=e,0!==this._meshes.length&&this._indices&&(this._indexBuffer=this._engine.createIndexBuffer(this._indices)),void 0!==t&&(this._totalVertices=t);for(var i=this._meshes,r=i.length,n=0;r>n;n++)i[n]._createGlobalSubMesh();this.notifyUpdate()},t.prototype.getTotalIndices=function(){return this.isReady()?this._indices.length:0},t.prototype.getIndices=function(e){if(!this.isReady())return null;var t=this._indices;if(e&&1!==this._meshes.length){for(var i=t.length,r=[],n=0;i>n;n++)r.push(t[n]);return r}return t},t.prototype.getIndexBuffer=function(){return this.isReady()?this._indexBuffer:null},t.prototype.releaseForMesh=function(e,t){var i=this._meshes,r=i.indexOf(e);if(-1!==r){for(var n in this._vertexBuffers)this._vertexBuffers[n].dispose();this._indexBuffer&&this._engine._releaseBuffer(this._indexBuffer)&&(this._indexBuffer=null),i.splice(r,1),e._geometry=null,0===i.length&&t&&this.dispose()}},t.prototype.applyToMesh=function(e){if(e._geometry!==this){var t=e._geometry;t&&t.releaseForMesh(e);var i=this._meshes;e._geometry=this,this._scene.pushGeometry(this),i.push(e),this.isReady()?this._applyToMesh(e):e._boundingInfo=this._boundingInfo}},t.prototype.updateExtend=function(t){void 0===t&&(t=null),t||(t=this._vertexBuffers[e.VertexBuffer.PositionKind].getData()),this._extend=e.Tools.ExtractMinAndMax(t,0,this._totalVertices,this.boundingBias)},t.prototype._applyToMesh=function(t){var i=this._meshes.length;for(var r in this._vertexBuffers)1===i&&this._vertexBuffers[r].create(),this._vertexBuffers[r]._buffer.references=i,r===e.VertexBuffer.PositionKind&&(t._resetPointsArrayCache(),this._extend||this.updateExtend(this._vertexBuffers[r].getData()),t._boundingInfo=new e.BoundingInfo(this._extend.minimum,this._extend.maximum),t._createGlobalSubMesh(),t._updateBoundingInfo());1===i&&this._indices&&(this._indexBuffer=this._engine.createIndexBuffer(this._indices)),this._indexBuffer&&(this._indexBuffer.references=i)},t.prototype.notifyUpdate=function(e){this.onGeometryUpdated&&this.onGeometryUpdated(this,e)},t.prototype.load=function(t,i){var r=this;if(this.delayLoadState!==e.Engine.DELAYLOADSTATE_LOADING){if(this.isReady())return void(i&&i());this.delayLoadState=e.Engine.DELAYLOADSTATE_LOADING,t._addPendingData(this),e.Tools.LoadFile(this.delayLoadingFile,function(n){r._delayLoadingFunction(JSON.parse(n),r),r.delayLoadState=e.Engine.DELAYLOADSTATE_LOADED,r._delayInfo=[],t._removePendingData(r);for(var o=r._meshes,s=o.length,a=0;s>a;a++)r._applyToMesh(o[a]);i&&i()},function(){},t.database)}},t.prototype.isDisposed=function(){return this._isDisposed},t.prototype.dispose=function(){var t,i=this._meshes,r=i.length;for(t=0;r>t;t++)this.releaseForMesh(i[t]);this._meshes=[];for(var n in this._vertexBuffers)this._vertexBuffers[n].dispose();this._vertexBuffers=[],this._totalVertices=0,this._indexBuffer&&this._engine._releaseBuffer(this._indexBuffer),this._indexBuffer=null,this._indices=[],this.delayLoadState=e.Engine.DELAYLOADSTATE_NONE,this.delayLoadingFile=null,this._delayLoadingFunction=null,this._delayInfo=[],this._boundingInfo=null,this._scene.removeGeometry(this),this._isDisposed=!0},t.prototype.copy=function(i){var r=new e.VertexData;r.indices=[];for(var n=this.getIndices(),o=0;o0){var a=new Float32Array(t,s.positionsAttrDesc.offset,s.positionsAttrDesc.count);i.setVerticesData(e.VertexBuffer.PositionKind,a,!1)}if(s.normalsAttrDesc&&s.normalsAttrDesc.count>0){var h=new Float32Array(t,s.normalsAttrDesc.offset,s.normalsAttrDesc.count);i.setVerticesData(e.VertexBuffer.NormalKind,h,!1)}if(s.uvsAttrDesc&&s.uvsAttrDesc.count>0){var c=new Float32Array(t,s.uvsAttrDesc.offset,s.uvsAttrDesc.count);i.setVerticesData(e.VertexBuffer.UVKind,c,!1)}if(s.uvs2AttrDesc&&s.uvs2AttrDesc.count>0){var l=new Float32Array(t,s.uvs2AttrDesc.offset,s.uvs2AttrDesc.count);i.setVerticesData(e.VertexBuffer.UV2Kind,l,!1)}if(s.uvs3AttrDesc&&s.uvs3AttrDesc.count>0){var u=new Float32Array(t,s.uvs3AttrDesc.offset,s.uvs3AttrDesc.count);i.setVerticesData(e.VertexBuffer.UV3Kind,u,!1)}if(s.uvs4AttrDesc&&s.uvs4AttrDesc.count>0){var d=new Float32Array(t,s.uvs4AttrDesc.offset,s.uvs4AttrDesc.count);i.setVerticesData(e.VertexBuffer.UV4Kind,d,!1)}if(s.uvs5AttrDesc&&s.uvs5AttrDesc.count>0){var f=new Float32Array(t,s.uvs5AttrDesc.offset,s.uvs5AttrDesc.count);i.setVerticesData(e.VertexBuffer.UV5Kind,f,!1)}if(s.uvs6AttrDesc&&s.uvs6AttrDesc.count>0){var p=new Float32Array(t,s.uvs6AttrDesc.offset,s.uvs6AttrDesc.count);i.setVerticesData(e.VertexBuffer.UV6Kind,p,!1)}if(s.colorsAttrDesc&&s.colorsAttrDesc.count>0){var _=new Float32Array(t,s.colorsAttrDesc.offset,s.colorsAttrDesc.count);i.setVerticesData(e.VertexBuffer.ColorKind,_,!1,s.colorsAttrDesc.stride)}if(s.matricesIndicesAttrDesc&&s.matricesIndicesAttrDesc.count>0){var m=new Int32Array(t,s.matricesIndicesAttrDesc.offset,s.matricesIndicesAttrDesc.count);i.setVerticesData(e.VertexBuffer.MatricesIndicesKind,m,!1)}if(s.matricesWeightsAttrDesc&&s.matricesWeightsAttrDesc.count>0){var g=new Float32Array(t,s.matricesWeightsAttrDesc.offset,s.matricesWeightsAttrDesc.count);i.setVerticesData(e.VertexBuffer.MatricesWeightsKind,g,!1)}if(s.indicesAttrDesc&&s.indicesAttrDesc.count>0){var v=new Int32Array(t,s.indicesAttrDesc.offset,s.indicesAttrDesc.count);i.setIndices(v)}if(s.subMeshesAttrDesc&&s.subMeshesAttrDesc.count>0){var y=new Int32Array(t,s.subMeshesAttrDesc.offset,5*s.subMeshesAttrDesc.count);i.subMeshes=[];for(var x=0;x>8),M.push((16711680&S)>>16),M.push(S>>24)}i.setVerticesData(e.VertexBuffer.MatricesIndicesKind,M,!1)}if(t.matricesIndicesExtra)if(t.matricesIndicesExtra._isExpanded)delete t.matricesIndices._isExpanded,i.setVerticesData(e.VertexBuffer.MatricesIndicesExtraKind,t.matricesIndicesExtra,!1);else{for(var M=[],x=0;x>8),M.push((16711680&S)>>16),M.push(S>>24)}i.setVerticesData(e.VertexBuffer.MatricesIndicesExtraKind,M,!1)}t.matricesWeights&&i.setVerticesData(e.VertexBuffer.MatricesWeightsKind,t.matricesWeights,!1),t.matricesWeightsExtra&&i.setVerticesData(e.VertexBuffer.MatricesWeightsExtraKind,t.matricesWeightsExtra,!1),i.setIndices(t.indices)}if(t.subMeshes){i.subMeshes=[];for(var C=0;Cthis._maxX||tthis._maxZ)return this.position.y;this._heightQuads&&0!=this._heightQuads.length||(this._initHeightQuads(),this._computeHeightQuads());var i=this._getFacetAt(e,t),r=-(i.x*e+i.z*t+i.w)/i.y;return r*this.scaling.y+this.position.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(e,t,i){if(e-=this.position.x,t-=this.position.z,e/=this.scaling.x,t/=this.scaling.z,!(ethis._maxX||tthis._maxZ)){this._heightQuads&&0!=this._heightQuads.length||(this._initHeightQuads(),this._computeHeightQuads());var r=this._getFacetAt(e,t);i.x=r.x,i.y=r.y,i.z=r.z}},i.prototype.updateCoordinateHeights=function(){this._heightQuads&&0!=this._heightQuads.length||this._initHeightQuads(),this._computeHeightQuads()},i.prototype._getFacetAt=function(e,t){var i,r=Math.floor((e+this._maxX)*this._subdivisions/this._width),n=Math.floor(-(t+this._maxZ)*this._subdivisions/this._height+this._subdivisions),o=this._heightQuads[n*this._subdivisions+r];return i=tt.name?1:-1});for(var t=0;t0&&t.z<1){this._drawingContext.font="normal 12px Segoe UI";var o=this._drawingContext.measureText(e),s=t.x-o.width/2,a=t.y,h=this._drawingCanvas.getBoundingClientRect();this._showUI&&this._isClickInsideRect(h.left*this._ratio+s-5,h.top*this._ratio+a-i-12,o.width+10,17)&&r(),this._drawingContext.beginPath(),this._drawingContext.rect(s-5,a-i-12,o.width+10,17),this._drawingContext.fillStyle=n(),this._drawingContext.globalAlpha=.5,this._drawingContext.fill(),this._drawingContext.globalAlpha=1,this._drawingContext.strokeStyle="#FFFFFF",this._drawingContext.lineWidth=1,this._drawingContext.stroke(),this._drawingContext.fillStyle="#FFFFFF",this._drawingContext.fillText(e,s,a-i),this._drawingContext.beginPath(),this._drawingContext.arc(t.x,a,5,0,2*Math.PI,!1),this._drawingContext.fill()}},t.prototype._isClickInsideRect=function(e,t,i,r){return this._clickPosition?this._clickPosition.xe+i?!1:!(this._clickPosition.yt+r):!1},t.prototype.isVisible=function(){return this._enabled},t.prototype.hide=function(){if(this._enabled){this._enabled=!1;var t=this._scene.getEngine();this._scene.unregisterBeforeRender(this._syncData),this._scene.unregisterAfterRender(this._syncUI),this._rootElement.removeChild(this._globalDiv),this._scene.forceShowBoundingBoxes=!1,this._scene.forceWireframe=!1,e.StandardMaterial.DiffuseTextureEnabled=!0,e.StandardMaterial.AmbientTextureEnabled=!0,e.StandardMaterial.SpecularTextureEnabled=!0,e.StandardMaterial.EmissiveTextureEnabled=!0,e.StandardMaterial.BumpTextureEnabled=!0,e.StandardMaterial.OpacityTextureEnabled=!0,e.StandardMaterial.ReflectionTextureEnabled=!0,e.StandardMaterial.LightmapTextureEnabled=!0,e.StandardMaterial.RefractionTextureEnabled=!0,this._scene.shadowsEnabled=!0,this._scene.particlesEnabled=!0,this._scene.postProcessesEnabled=!0,this._scene.collisionsEnabled=!0,this._scene.lightsEnabled=!0,this._scene.texturesEnabled=!0,this._scene.lensFlaresEnabled=!0,this._scene.proceduralTexturesEnabled=!0,this._scene.renderTargetsEnabled=!0,this._scene.probesEnabled=!0,t.getRenderingCanvas().removeEventListener("click",this._onCanvasClick),this._clearSkeletonViewers()}},t.prototype._clearSkeletonViewers=function(){for(var e=0;eWindows:",this.accentColor),this._generateCheckBox(this._optionsSubsetDiv,"Statistics",this._displayStatistics,function(e){t._displayStatistics=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Logs",this._displayLogs,function(e){t._displayLogs=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Meshes tree",this._displayTree,function(e){t._displayTree=e.checked,t._needToRefreshMeshesTree=!0}),this._optionsSubsetDiv.appendChild(document.createElement("br")),this._generateTexBox(this._optionsSubsetDiv,"General:",this.accentColor),this._generateCheckBox(this._optionsSubsetDiv,"Bounding boxes",this._scene.forceShowBoundingBoxes,function(e){t._scene.forceShowBoundingBoxes=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Clickable labels",this._labelsEnabled,function(e){t._labelsEnabled=e.checked,t._labelsEnabled||t._clearLabels()}),this._generateCheckBox(this._optionsSubsetDiv,"Generate user marks (F12)",e.Tools.PerformanceLogLevel===e.Tools.PerformanceUserMarkLogLevel,function(t){t.checked?e.Tools.PerformanceLogLevel=e.Tools.PerformanceUserMarkLogLevel:e.Tools.PerformanceLogLevel=e.Tools.PerformanceNoneLogLevel}),this._optionsSubsetDiv.appendChild(document.createElement("br")),this._generateTexBox(this._optionsSubsetDiv,"Rendering mode:",this.accentColor),this._generateRadio(this._optionsSubsetDiv,"Solid","renderMode",!this._scene.forceWireframe&&!this._scene.forcePointsCloud,function(e){e.checked&&(t._scene.forceWireframe=!1,t._scene.forcePointsCloud=!1)}),this._generateRadio(this._optionsSubsetDiv,"Wireframe","renderMode",this._scene.forceWireframe,function(e){e.checked&&(t._scene.forceWireframe=!0,t._scene.forcePointsCloud=!1)}),this._generateRadio(this._optionsSubsetDiv,"Point","renderMode",this._scene.forcePointsCloud,function(e){e.checked&&(t._scene.forceWireframe=!1,t._scene.forcePointsCloud=!0)}),this._optionsSubsetDiv.appendChild(document.createElement("br")),this._generateTexBox(this._optionsSubsetDiv,"Texture channels:",this.accentColor),this._generateCheckBox(this._optionsSubsetDiv,"Diffuse",e.StandardMaterial.DiffuseTextureEnabled,function(t){e.StandardMaterial.DiffuseTextureEnabled=t.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Ambient",e.StandardMaterial.AmbientTextureEnabled,function(t){e.StandardMaterial.AmbientTextureEnabled=t.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Specular",e.StandardMaterial.SpecularTextureEnabled,function(t){e.StandardMaterial.SpecularTextureEnabled=t.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Emissive",e.StandardMaterial.EmissiveTextureEnabled,function(t){e.StandardMaterial.EmissiveTextureEnabled=t.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Bump",e.StandardMaterial.BumpTextureEnabled,function(t){e.StandardMaterial.BumpTextureEnabled=t.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Opacity",e.StandardMaterial.OpacityTextureEnabled,function(t){e.StandardMaterial.OpacityTextureEnabled=t.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Reflection",e.StandardMaterial.ReflectionTextureEnabled,function(t){e.StandardMaterial.ReflectionTextureEnabled=t.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Refraction",e.StandardMaterial.RefractionTextureEnabled,function(t){e.StandardMaterial.RefractionTextureEnabled=t.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Lightmap",e.StandardMaterial.LightmapTextureEnabled,function(t){e.StandardMaterial.LightmapTextureEnabled=t.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Fresnel",e.StandardMaterial.FresnelEnabled,function(t){e.StandardMaterial.FresnelEnabled=t.checked}),this._optionsSubsetDiv.appendChild(document.createElement("br")),this._generateTexBox(this._optionsSubsetDiv,"Options:",this.accentColor),this._generateCheckBox(this._optionsSubsetDiv,"Animations",this._scene.animationsEnabled,function(e){t._scene.animationsEnabled=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Collisions",this._scene.collisionsEnabled,function(e){t._scene.collisionsEnabled=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Fog",this._scene.fogEnabled,function(e){t._scene.fogEnabled=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Lens flares",this._scene.lensFlaresEnabled,function(e){t._scene.lensFlaresEnabled=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Lights",this._scene.lightsEnabled,function(e){t._scene.lightsEnabled=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Particles",this._scene.particlesEnabled,function(e){t._scene.particlesEnabled=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Post-processes",this._scene.postProcessesEnabled,function(e){t._scene.postProcessesEnabled=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Probes",this._scene.probesEnabled,function(e){t._scene.probesEnabled=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Procedural textures",this._scene.proceduralTexturesEnabled,function(e){t._scene.proceduralTexturesEnabled=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Render targets",this._scene.renderTargetsEnabled,function(e){t._scene.renderTargetsEnabled=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Shadows",this._scene.shadowsEnabled,function(e){t._scene.shadowsEnabled=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Skeletons",this._scene.skeletonsEnabled,function(e){t._scene.skeletonsEnabled=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Sprites",this._scene.spritesEnabled,function(e){t._scene.spritesEnabled=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Textures",this._scene.texturesEnabled,function(e){t._scene.texturesEnabled=e.checked}),e.AudioEngine&&e.Engine.audioEngine.canUseWebAudio&&(this._optionsSubsetDiv.appendChild(document.createElement("br")),this._generateTexBox(this._optionsSubsetDiv,"Audio:",this.accentColor),this._generateRadio(this._optionsSubsetDiv,"Headphones","panningModel",this._scene.headphone,function(e){e.checked&&(t._scene.headphone=!0)}),this._generateRadio(this._optionsSubsetDiv,"Normal Speakers","panningModel",!this._scene.headphone,function(e){e.checked&&(t._scene.headphone=!1)}),this._generateCheckBox(this._optionsSubsetDiv,"Disable audio",!this._scene.audioEnabled,function(e){t._scene.audioEnabled=!e.checked})),this._optionsSubsetDiv.appendChild(document.createElement("br")),this._generateTexBox(this._optionsSubsetDiv,"Viewers:",this.accentColor),this._generateCheckBox(this._optionsSubsetDiv,"Skeletons",!1,function(i){if(!i.checked)return void t._clearSkeletonViewers();for(var r=0;rTools:",this.accentColor),this._generateButton(this._optionsSubsetDiv,"Dump rendertargets",function(e){t._scene.dumpNextRenderTargets=!0}),this._generateButton(this._optionsSubsetDiv,"Run SceneOptimizer",function(i){e.SceneOptimizer.OptimizeAsync(t._scene)}),this._generateButton(this._optionsSubsetDiv,"Log camera object",function(e){t._camera?console.log(t._camera):console.warn("No camera defined, or debug layer created before camera creation!")}),this._optionsSubsetDiv.appendChild(document.createElement("br")),this._globalDiv.appendChild(this._statsDiv),this._globalDiv.appendChild(this._logDiv),this._globalDiv.appendChild(this._optionsDiv),this._globalDiv.appendChild(this._treeDiv)}},t.prototype._displayStats=function(){var t=this._scene,i=t.getEngine(),r=i.getGlInfo();this._statsSubsetDiv.innerHTML="Babylon.js v"+e.Engine.Version+" - "+e.Tools.Format(i.getFps(),0)+" fps

Count
Total meshes: "+t.meshes.length+"
Total lights: "+t.lights.length+"
Total vertices: "+t.getTotalVertices()+"
Total materials: "+t.materials.length+"
Total textures: "+t.textures.length+"
Active meshes: "+t.getActiveMeshes().length+"
Active indices: "+t.getActiveIndices()+"
Active bones: "+t.getActiveBones()+"
Active particles: "+t.getActiveParticles()+"
Draw calls: "+i.drawCalls+"

Duration
Meshes selection: "+e.Tools.Format(t.getEvaluateActiveMeshesDuration())+" ms
Render Targets: "+e.Tools.Format(t.getRenderTargetsDuration())+" ms
Particles: "+e.Tools.Format(t.getParticlesDuration())+" ms
Sprites: "+e.Tools.Format(t.getSpritesDuration())+" ms

Render: "+e.Tools.Format(t.getRenderDuration())+" ms
Frame: "+e.Tools.Format(t.getLastFrameDuration())+" ms
Potential FPS: "+e.Tools.Format(1e3/t.getLastFrameDuration(),0)+"
Resolution: "+i.getRenderWidth()+"x"+i.getRenderHeight()+"

Extensions
Std derivatives: "+(i.getCaps().standardDerivatives?"Yes":"No")+"
Compressed textures: "+(i.getCaps().s3tc?"Yes":"No")+"
Hardware instances: "+(i.getCaps().instancedArrays?"Yes":"No")+"
Texture float: "+(i.getCaps().textureFloat?"Yes":"No")+"

32bits indices: "+(i.getCaps().uintIndices?"Yes":"No")+"
Fragment depth: "+(i.getCaps().fragmentDepthSupported?"Yes":"No")+"
High precision shaders: "+(i.getCaps().highPrecisionShaderSupported?"Yes":"No")+"
Draw buffers: "+(i.getCaps().drawBuffersExtension?"Yes":"No")+"

Caps.
Max textures units: "+i.getCaps().maxTexturesImageUnits+"
Max textures size: "+i.getCaps().maxTextureSize+"
Max anisotropy: "+i.getCaps().maxAnisotropy+"
Info
WebGL feature level: "+i.webGLVersion+"
"+r.version+"

"+r.renderer+"
",this.customStatsFunction&&(this._statsSubsetDiv.innerHTML+=this._statsSubsetDiv.innerHTML)},t}();e.DebugLayer=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function e(e,t,i){var r=this;void 0===t&&(t=""),void 0===i&&(i="black"),this._renderingCanvas=e,this._loadingText=t,this._loadingDivBackgroundColor=i,this._resizeLoadingUI=function(){var e=r._renderingCanvas.getBoundingClientRect();r._loadingDiv.style.position="absolute",r._loadingDiv.style.left=e.left+"px",r._loadingDiv.style.top=e.top+"px",r._loadingDiv.style.width=e.width+"px",r._loadingDiv.style.height=e.height+"px"}}return e.prototype.displayLoadingUI=function(){var e=this;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 t=new Image;t.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAYdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuM4zml1AAAARbSURBVHhe7Z09aFNRFMc716kuLrq4FdyLq4Wi4CAoRQcR0UJBUBdRiuLSIYMo6CA4FF2sgw6CFAdFUOpSQYcWO4hD26UQCfXrIQrx/JJzw1OSWq3NPeL/B4Fy+0jg/HO+7j3vpUcI8b/Q39+/49ihfWdPHT94Yf/e3Se3bd263f8lus218TPn6vV6Ya8Wi/MzNRNmj18iusX9W1evmP1/EKNEIVG6CMbG6E3bt+fT++pHha8NoHdT72bLE8NDg7tGU64gLLndV4Wc4m8j/pS+vr4tGB/DT16v3Fyr8dvBe/jbit8BL0AES9LX1iPAz+BR/hFiLVCynj95dPzNy6fv3IZ/k4L3948Sq7FzYGBg4vLFGxitabuOFCbWNKGrMnbiUuo18KaV6tIHv6YtvL9/nOgE31jCktmrY7k6+/zhE4yP4Vf7hiNqh/BWWEl8mzDol4p22Lf7cIdvdUMEvv0Y2S9fE5S1hLzpqTsPkiep//gFGPnR3Yl7GL5p/xYFBrTwM+iXio3GqpwDGL5p/xYNIX7XG8Q6IJRgdIzf1KBBgafII7oMidhyQtVFaMA2Bt7il4huQRhaXphbcR2g4RXqBzKAGHiCCwGFVUAj/m/RTRDj29cvn10I0PZ3LghH5f4CL1EFlQmqqXK3jDDKFxmhQ3Yt6oQseUZGKmMnTpsOqc8o1F9kBOMjQlOLeqEeIyOc6JV6jYLJD/+XyIFvnzdgl9aXRQ5I2qZDK1SpospMqaoqON/wZZGDciLnMMiXRS7IF4hhqMTNTdk7CFu+LHLhR7BQqBvPDJUUQqCGvCMATHUgBmhWNgApmdOda9YpM+VwRYfuyyIXDK8hBlilNerLIheMZCKGwlUAyru6GlwOgPUbRxADdJ9FAChxXY864viyyEXqPxhc0M2TAfAbatSdRyHtXymhByEdRnE3ky+JnHAIhSA0h74kckETmHoQbSgGwJrCIRMEPSRIBCRIMAhZaYhaggQhJXUJEoRU9mofKwh+F22dLRRfEjlJM7w6KQwCoQpBOKTyJZETjmwRxKqtGV8SOSkNOGjKPQppBEgDDkFgpxdBVGkFgaYQQXRIFQSObk0P5ZFIpAZRHXsQ0r0hCluBWKkuvVbYCkQaCdL5ehBScudJP4yY+rLISdps1NBDEJKXMMmoSfggWC4ZQRR17oFYXph7hSiquIKQ+hJGTX1J5MYSPD/GVdNzsgLBwZVCVyAQAkF0ohiI/c1fS6tNXq9UfEnkhudmIQolsS+J3Hh/UtNDzQLhj42VKJFInqLwFYiUU5ToA+HdfI0JevUpQUAIn+vSz2lHIuUV/dJOIHhOY/IWVWGBIHQtzs88s9zyWBuTgcBLzGOmeNnfF/QslSDgMeQW85i3DOQxuipxAkCyZ8SIm4Omp+7MMlCB59j6sKZcMoM4iIEoeI2J9AKxrFobZx0v4vYInuHFS4J1GQRCAGaLEYQXfyMML5XSQgghhBBCCCH+cXp6vgNhKpSKX/XdOAAAAABJRU5ErkJggg==",t.style.position="absolute",t.style.left="50%",t.style.top="50%",t.style.marginLeft="-50px",t.style.marginTop="-50px",t.style.transition="transform 1.0s ease",t.style.webkitTransition="-webkit-transform 1.0s ease";var i=360,r=function(){i+=360,t.style.transform="rotateZ("+i+"deg)",t.style.webkitTransform="rotateZ("+i+"deg)"};t.addEventListener("transitionend",r),t.addEventListener("webkitTransitionEnd",r),this._loadingDiv.appendChild(t);var n=new Image;n.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAYdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuM4zml1AAAAYJSURBVHhe7Zy/qx1FFMff/2Av2Nvbi4WFiiAEY/OQ2IgQsbCJQoqkCAgpFLXyoZURLfwBIiIpgqZJoYQYlWelNsIrNOxDJcrzfHe+G97dnTl75u7euzv7zgcWHrlnZmfOmXPmzI/NjuM4juM4juM4juM4juM4juM4juM4juM45fPic08/uHf5/CvffH7lnT8PfrtxdHS0n3p+/fHGl5+89/prr5599iEWd8bg0rkXHoFyqehKnlxQpjYSDHTm9JMPsGrHylOPPXofvICKXMcIGtXdf/76AYbm6xyNW9e/eAtKC7rbKLXnvHHx5Sf4auc4Ek7OQkFU1Dap/vv37k/wSjblZANFiFIGzw98hhizwqBgs04mCBdQRNCHidoAEtY+lLIvtSdoGFeyql2ZH57HBH4sE7O+o/r9l+8/ZXUni68+2jsHBQQ9qNRGeP/tSxdSYQX/roUcpL4/f3vtM9TD+jTq92n1LQ7jxF1hhGPtwWL3gGccy8JuS1r8sVWBGXNVdSKMYjBGPUJjCzooiGuSpnwlnnOGP2dhHRSLNgpHp2oMKIriK8TmG4Qh/rwW8D6pps9b9im+LDDipXOqMVJrAngBfg9i98gevWKA+/nnCod3Dr5GfaHaDgidVym6HKRjGIkpqthcAVKGxNqBImbEo66kjCih8AOpNmkUmbMuUrR8kEqiU6FvHZLGAPJ71JCYSyhiBqmwFE2GoD6jLGIfDHtG6EzoU4dK21PCqIRMEF0FGRjFzGDtIkXVAdATvsqfT9CJ0JcOFdYiFIsiMlqYy1YOFpQo2OddqBtyEaq9y+efoVh5oPHoROjLKn0j3JIE5Ka8UqZRtGrMnneX6yVofOhDh94MSbznTcpqmDOt1vyQzOgaJAF4F3JBfIXesrNEGWWmjIX7UBZ6jRJbBMLg/DmJiKUGVHleIpnVNTa+jakzkAviJqLhi4MC9XQGBrZeKJZESSrKy7ik0VGFWhQBRDTHIACKQ5l9nAjy75gya4a2w+Jhs0FJdc0xX/GwUbAqFBkZi7QpJ2w16WUbjFyK9MJF3KaoEM74KhVtLrQOrsmRxkbdHEqmSC/c+EuGnIFkjW7Ih2Kr4CCMIvNG2hrrgLpCjiFloooYCjyYrzCRyvhyBthkIPuQtsZGdnbMTezyDiU71KTC5zr7aVsHbsz2tllrEkS5UHwU1tq1HbtPW4UbeB0O7xx8R5EsMJql+BheUmHjkNVmIRP7LutoM3+D4O4tG7vCkNO9ESZ4lL3J6rKRMPx4qKbD/A0icf8CG7tC7kTahnMTwleuYSrsS7GatRAvfZh1tTm5BmmQCdZ8a0Sefe28xUrRBkmFLKy8KTIKUDRX0Y1xagPgwbaIdeFnQULmKak3xvwNMkVGgok/N5XNoehJvejRlCDl9escI28dJU0tZ++nBTJE9mEF647x5Ehbo4s5hDOKFIU0PdofeA5F5k1q63zIWmQqNI/P3ZubjFTqKxQ3jyjHAOX0RdlgVO9hzRFpczRcjZ3Gbxxpc7Qj6+5pTYF2OFXawNI+yDGf1k2NcvOlzBQeDQ/t7zD7DsEDpJ2xATXaNtDWUS4IzP4DS2ljajAVu57SUkYw245ptxZxA5JiZaJ0DswudGn3kYUy54426EjoT4dZfYbccxC2nI92cDkZHQr96jD4AGkMDKeSy/COBsRe6VTSKFN6irLeaCh3IteQjt1E5+oudsG/b/2DfZ5AqsYo8vMDK9LB1HzSsLWvlGThdxXvC6+NsqyPPWP0pMINtbdsajfVeC6f/GZ+cdAofQoB1d+Hf9waY98I7+RXWab3Lt4zYkjHtTnlOLXHYMsCh1zWeQYehu1zfNPOOiys/d91LAKEBSgh6MJMbSA82AaHofDgAIwbgvVvlLNS11nModMm4UZergLHZBZrodmBuA3lBB1thdorSjkOmATMDwg/UBQVtglqQyx6fbEJ+H3IWIapjYAjAfeIgeCMHldueJvFaqDaAHhwf8qNsEEQ1iQbOoUUGIbCLRc8+Bvfp4jyd2FEijuO4ziO4ziO4ziO4ziO4ziO4ziO4ziOUzw7O/8D0P7rcZ/GEboAAAAASUVORK5CYII=",n.style.position="absolute",n.style.left="50%",n.style.top="50%",n.style.marginLeft="-50px",n.style.marginTop="-50px",this._loadingDiv.appendChild(n),this._resizeLoadingUI(),window.addEventListener("resize",this._resizeLoadingUI),this._loadingDiv.style.backgroundColor=this._loadingDivBackgroundColor,document.body.appendChild(this._loadingDiv),setTimeout(function(){e._loadingDiv.style.opacity="1",t.style.transform="rotateZ(360deg)",t.style.webkitTransform="rotateZ(360deg)"},0)}},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(){this._audioContext=null,this._audioContextInitialized=!1,this.canUseWebAudio=!1,this.WarnedWebAudioUnsupported=!1,this.unlocked=!1,"undefined"==typeof window.AudioContext&&"undefined"==typeof window.webkitAudioContext||(window.AudioContext=window.AudioContext||window.webkitAudioContext,this.canUseWebAudio=!0),/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;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.name=t,this._scene=r,this._readyToPlayCallback=n,this._customAttenuationFunction=function(e,t,i,r,n){return i>t?e*(1-t/i):0},o&&(this.autoplay=o.autoplay||!1,this.loop=o.loop||!1,void 0!==o.volume&&(this._volume=o.volume),this.spatialSound=o.spatialSound||!1,this.maxDistance=o.maxDistance||100,this.useCustomAttenuation=o.useCustomAttenuation||!1,this.rolloffFactor=o.rolloffFactor||1,this.refDistance=o.refDistance||1,this.distanceModel=o.distanceModel||"linear",this._playbackRate=o.playbackRate||1,this._streaming=o.streaming||!1),e.Engine.audioEngine.canUseWebAudio?(this._soundGain=e.Engine.audioEngine.audioContext.createGain(),this._soundGain.gain.value=this._volume,this._inputAudioNode=this._soundGain,this._ouputAudioNode=this._soundGain,this.spatialSound&&this._createSpatialParameters(),this._scene.mainSoundTrack.AddSound(this),i&&("string"==typeof i?this._streaming?(this._htmlAudioElement=new Audio(i),this._htmlAudioElement.controls=!1,this._htmlAudioElement.loop=this.loop,this._htmlAudioElement.crossOrigin="anonymous",this._htmlAudioElement.preload="auto",this._htmlAudioElement.addEventListener("canplaythrough",function(){s._isReadyToPlay=!0,s.autoplay&&s.play(),s._readyToPlayCallback&&s._readyToPlayCallback()}),document.body.appendChild(this._htmlAudioElement)):e.Tools.LoadFile(i,function(e){s._soundLoaded(e)},null,this._scene.database,!0):i instanceof ArrayBuffer?i.byteLength>0&&this._soundLoaded(i):e.Tools.Error("Parameter must be a URL to the sound or an ArrayBuffer of the sound."))):(this._scene.mainSoundTrack.AddSound(this),e.Engine.audioEngine.WarnedWebAudioUnsupported||(e.Tools.Error("Web Audio is not supported by your browser."),e.Engine.audioEngine.WarnedWebAudioUnsupported=!0),this._readyToPlayCallback&&window.setTimeout(function(){s._readyToPlayCallback()},1e3))}return t.prototype.dispose=function(){e.Engine.audioEngine.canUseWebAudio&&this._isReadyToPlay&&(this.isPlaying&&this.stop(),this._isReadyToPlay=!1,-1===this.soundTrackId?this._scene.mainSoundTrack.RemoveSound(this):this._scene.soundTracks[this.soundTrackId].RemoveSound(this),this._soundGain&&(this._soundGain.disconnect(),this._soundGain=null),this._soundPanner&&(this._soundPanner.disconnect(),this._soundPanner=null),this._soundSource&&(this._soundSource.disconnect(),this._soundSource=null),this._audioBuffer=null,this._htmlAudioElement&&(this._htmlAudioElement.pause(),this._htmlAudioElement.src="",document.body.removeChild(this._htmlAudioElement)),this._connectedMesh&&(this._connectedMesh.unregisterAfterWorldMatrixUpdate(this._registerFunc),this._connectedMesh=null))},t.prototype._soundLoaded=function(t){var i=this;this._isLoaded=!0,e.Engine.audioEngine.audioContext.decodeAudioData(t,function(e){i._audioBuffer=e,i._isReadyToPlay=!0,i.autoplay&&i.play(),i._readyToPlayCallback&&i._readyToPlayCallback()},function(){e.Tools.Error("Error while decoding audio data for: "+i.name)})},t.prototype.setAudioBuffer=function(t){e.Engine.audioEngine.canUseWebAudio&&(this._audioBuffer=t,this._isReadyToPlay=!0)},t.prototype.updateOptions=function(e){e&&(this.loop=e.loop||this.loop,this.maxDistance=e.maxDistance||this.maxDistance,this.useCustomAttenuation=e.useCustomAttenuation||this.useCustomAttenuation,this.rolloffFactor=e.rolloffFactor||this.rolloffFactor,this.refDistance=e.refDistance||this.refDistance,this.distanceModel=e.distanceModel||this.distanceModel,this._playbackRate=e.playbackRate||this._playbackRate,this._updateSpatialParameters(),this.isPlaying&&(this._streaming?this._htmlAudioElement.playbackRate=this._playbackRate:this._soundSource.playbackRate.value=this._playbackRate))},t.prototype._createSpatialParameters=function(){e.Engine.audioEngine.canUseWebAudio&&(this._scene.headphone&&(this._panningModel="HRTF"),this._soundPanner=e.Engine.audioEngine.audioContext.createPanner(),this._updateSpatialParameters(),this._soundPanner.connect(this._ouputAudioNode),this._inputAudioNode=this._soundPanner)},t.prototype._updateSpatialParameters=function(){this.spatialSound&&(this.useCustomAttenuation?(this._soundPanner.distanceModel="linear",this._soundPanner.maxDistance=Number.MAX_VALUE,this._soundPanner.refDistance=1,this._soundPanner.rolloffFactor=1,this._soundPanner.panningModel=this._panningModel):(this._soundPanner.distanceModel=this.distanceModel,this._soundPanner.maxDistance=this.maxDistance,this._soundPanner.refDistance=this.refDistance,this._soundPanner.rolloffFactor=this.rolloffFactor,this._soundPanner.panningModel=this._panningModel))},t.prototype.switchPanningModelToHRTF=function(){this._panningModel="HRTF",this._switchPanningModel()},t.prototype.switchPanningModelToEqualPower=function(){this._panningModel="equalpower",this._switchPanningModel()},t.prototype._switchPanningModel=function(){e.Engine.audioEngine.canUseWebAudio&&this.spatialSound&&(this._soundPanner.panningModel=this._panningModel)},t.prototype.connectToSoundTrackAudioNode=function(t){e.Engine.audioEngine.canUseWebAudio&&(this._isOutputConnected&&this._ouputAudioNode.disconnect(),this._ouputAudioNode.connect(t),this._isOutputConnected=!0)},t.prototype.setDirectionalCone=function(t,i,r){return t>i?void e.Tools.Error("setDirectionalCone(): outer angle of the cone must be superior or equal to the inner angle."):(this._coneInnerAngle=t,this._coneOuterAngle=i,this._coneOuterGain=r,this._isDirectional=!0,void(this.isPlaying&&this.loop&&(this.stop(),this.play())))},t.prototype.setPosition=function(t){this._position=t,e.Engine.audioEngine.canUseWebAudio&&this.spatialSound&&this._soundPanner.setPosition(this._position.x,this._position.y,this._position.z)},t.prototype.setLocalDirectionToMesh=function(t){this._localDirection=t,e.Engine.audioEngine.canUseWebAudio&&this._connectedMesh&&this.isPlaying&&this._updateDirection()},t.prototype._updateDirection=function(){var t=this._connectedMesh.getWorldMatrix(),i=e.Vector3.TransformNormal(this._localDirection,t);i.normalize(),this._soundPanner.setOrientation(i.x,i.y,i.z)},t.prototype.updateDistanceFromListener=function(){if(e.Engine.audioEngine.canUseWebAudio&&this._connectedMesh&&this.useCustomAttenuation){var t=this._connectedMesh.getDistanceToCamera(this._scene.activeCamera);this._soundGain.gain.value=this._customAttenuationFunction(this._volume,t,this.maxDistance,this.refDistance,this.rolloffFactor)}},t.prototype.setAttenuationFunction=function(e){this._customAttenuationFunction=e},t.prototype.play=function(t){var i=this;if(this._isReadyToPlay&&this._scene.audioEnabled)try{this._startOffset<0&&(t=-this._startOffset,this._startOffset=0);var r=t?e.Engine.audioEngine.audioContext.currentTime+t:e.Engine.audioEngine.audioContext.currentTime;this._soundSource&&this._streamingSource||this.spatialSound&&(this._soundPanner.setPosition(this._position.x,this._position.y,this._position.z),this._isDirectional&&(this._soundPanner.coneInnerAngle=this._coneInnerAngle,this._soundPanner.coneOuterAngle=this._coneOuterAngle,this._soundPanner.coneOuterGain=this._coneOuterGain,this._connectedMesh?this._updateDirection():this._soundPanner.setOrientation(this._localDirection.x,this._localDirection.y,this._localDirection.z))),this._streaming?(this._streamingSource||(this._streamingSource=e.Engine.audioEngine.audioContext.createMediaElementSource(this._htmlAudioElement),this._htmlAudioElement.onended=function(){i._onended()},this._htmlAudioElement.playbackRate=this._playbackRate),this._streamingSource.disconnect(),this._streamingSource.connect(this._inputAudioNode),this._htmlAudioElement.play()):(this._soundSource=e.Engine.audioEngine.audioContext.createBufferSource(),this._soundSource.buffer=this._audioBuffer,this._soundSource.connect(this._inputAudioNode),this._soundSource.loop=this.loop,this._soundSource.playbackRate.value=this._playbackRate,this._soundSource.onended=function(){i._onended()},this._soundSource.start(r,this.isPaused?this._startOffset%this._soundSource.buffer.duration:0)),this._startTime=r,this.isPlaying=!0,this.isPaused=!1}catch(n){e.Tools.Error("Error while trying to play audio: "+this.name+", "+n.message)}},t.prototype._onended=function(){this.isPlaying=!1,this.onended&&this.onended()},t.prototype.stop=function(t){if(this.isPlaying){if(this._streaming)this._htmlAudioElement.pause(),this._htmlAudioElement.currentTime>0&&(this._htmlAudioElement.currentTime=0);else{ -var i=t?e.Engine.audioEngine.audioContext.currentTime+t:e.Engine.audioEngine.audioContext.currentTime;this._soundSource.stop(i),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._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.Parse=function(i,r,n,o){var s,a=i.name;s=i.url?n+i.url:n+a;var h,c={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 l=function(){o._isReadyToPlay?(h._audioBuffer=o.getAudioBuffer(),h._isReadyToPlay=!0,h.autoplay&&h.play()):window.setTimeout(l,300)};h=new t(a,new ArrayBuffer(0),r,null,c),l()}else h=new t(a,s,r,function(){r._removePendingData(h)},c),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 d=e.Vector3.FromArray(i.localDirectionToMesh);h.setLocalDirectionToMesh(d)}if(i.connectedMeshId){var f=r.getMeshByID(i.connectedMeshId);f&&h.attachToMesh(f)}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;tr;r++){var n=new i;n.offset=r*e,this.allEntries[r]=n,this.freeEntries[t-r-1]=n}}return e.prototype.allocElement=function(){0===this.freeEntries.length&&this._growBuffer();var e=this.freeEntries.pop();return e},e.prototype.freeElement=function(e){this.freeEntries.push(e)},e.prototype.pack=function(){if(0===this.freeEntries.length)return this.buffer;var e=this.stride,t=this.freeEntries.sort(function(e,t){return e.offset-t.offset}),r=this.allEntries.sort(function(e,t){return e.offset-t.offset}),n=new i;n.offset=this.entryCount*e,t.push(n);for(var o=t[0].offset,s=1,a=t[0].offset,h=1;h_;_++){var m=o/e,g=f/e,v=r[g];this._moveEntry(v,o);var y=r[m];y.offset=f,r[m]=v,r[g]=y,f-=e,o+=e}d>=s?(o=l,s=1):s=(l-o)/e+1,a=l}else++s,a=l}this.entryCount=o/e;var x=this.buffer.subarray(0,o);return this.freeEntries.splice(0),this.allEntries=r.slice(0,this.entryCount),x},e.prototype._moveEntry=function(e,t){for(var i=0;in;n++){var o=new i;o.offset=n*this.stride,this.allEntries[n]=o,this.freeEntries[n]=o}this.buffer=t,this.entryCount=e},e}();e.DynamicFloatArray=t;var i=function(){function e(){}return e}();e.DynamicFloatArrayEntry=i}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t){function i(i,r,n,o){t.call(this,i,r),this._textures={},this._floats={},this._floatsArrays={},this._colors3={},this._colors4={},this._vectors2={},this._vectors3={},this._vectors4={},this._matrices={},this._matrices3x3={},this._matrices2x2={},this._cachedWorldViewMatrix=new e.Matrix,this._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.samplers=o.samplers||[],o.defines=o.defines||[],this._options=o}return __extends(i,t),i.prototype.needAlphaBlending=function(){return this._options.needAlphaBlending},i.prototype.needAlphaTesting=function(){return this._options.needAlphaTesting},i.prototype._checkUniform=function(e){-1===this._options.uniforms.indexOf(e)&&this._options.uniforms.push(e)},i.prototype.setTexture=function(e,t){return-1===this._options.samplers.indexOf(e)&&this._options.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.setVector4=function(e,t){return this._checkUniform(e),this._vectors4[e]=t,this},i.prototype.setMatrix=function(e,t){return this._checkUniform(e),this._matrices[e]=t,this},i.prototype.setMatrix3x3=function(e,t){return this._checkUniform(e),this._matrices3x3[e]=t,this},i.prototype.setMatrix2x2=function(e,t){return this._checkUniform(e),this._matrices2x2[e]=t,this},i.prototype.isReady=function(t,i){var r=this.getScene(),n=r.getEngine();if(!this.checkReadyOnEveryCall&&this._renderId===r.getRenderId())return!0;var o=[],s=new e.EffectFallbacks;i&&o.push("#define INSTANCES");for(var a=0;a>8&255,e>>16&255,e>>24&255)}var n=542327876,o=131072,s=512,a=4,h=64,c=131072,l=i("DXT1"),u=i("DXT3"),d=i("DXT5"),f=31,p=0,_=1,m=2,g=3,v=4,y=7,x=20,b=21,E=22,A=28,T=function(){function t(){}return t.GetDDSInfo=function(e){var t=new Int32Array(e,0,f),i=1;return t[m]&o&&(i=Math.max(1,t[y])),{width:t[v],height:t[g],mipmapCount:i,isFourCC:(t[x]&a)===a,isRGB:(t[x]&h)===h,isLuminance:(t[x]&c)===c,isCube:(t[A]&s)===s}},t.GetRGBAArrayBuffer=function(e,t,i,r,n){for(var o=new Uint8Array(r),s=new Uint8Array(n),a=0,h=t-1;h>=0;h--)for(var c=0;e>c;c++){var l=i+4*(c+h*e);o[a+2]=s[l],o[a+1]=s[l+1],o[a]=s[l+2],o[a+3]=s[l+3],a+=4}return o},t.GetRGBArrayBuffer=function(e,t,i,r,n){for(var o=new Uint8Array(r),s=new Uint8Array(n),a=0,h=t-1;h>=0;h--)for(var c=0;e>c;c++){var l=i+3*(c+h*e);o[a+2]=s[l],o[a+1]=s[l+1],o[a]=s[l+2],a+=3}return o},t.GetLuminanceArrayBuffer=function(e,t,i,r,n){for(var o=new Uint8Array(r),s=new Uint8Array(n),a=0,h=t-1;h>=0;h--)for(var c=0;e>c;c++){var l=i+(c+h*e);o[a]=s[l],a++}return o},t.UploadDDSLevels=function(i,s,a,h,c,x){var A,T,P,M,S,C,I,R,D,O,L=new Int32Array(a,0,f);if(L[p]!=n)return void e.Tools.Error("Invalid magic number in DDS header");if(!h.isFourCC&&!h.isRGB&&!h.isLuminance)return void e.Tools.Error("Unsupported format, must contain a FourCC, RGB or LUMINANCE code");if(h.isFourCC)switch(A=L[b]){case l:T=8,P=s.COMPRESSED_RGBA_S3TC_DXT1_EXT;break;case u:T=16,P=s.COMPRESSED_RGBA_S3TC_DXT3_EXT;break;case d:T=16,P=s.COMPRESSED_RGBA_S3TC_DXT5_EXT;break;default:return void console.error("Unsupported FourCC code:",r(A))}D=1,L[m]&o&&c!==!1&&(D=Math.max(1,L[y]));for(var w=L[E],B=0;x>B;B++){var F=1===x?i.TEXTURE_2D:i.TEXTURE_CUBE_MAP_POSITIVE_X+B;for(M=L[v],S=L[g],I=L[_]+4,O=0;D>O;++O){if(h.isRGB)24===w?(C=M*S*3,R=t.GetRGBArrayBuffer(M,S,I,C,a),i.texImage2D(F,O,i.RGB,M,S,0,i.RGB,i.UNSIGNED_BYTE,R)):(C=M*S*4,R=t.GetRGBAArrayBuffer(M,S,I,C,a),i.texImage2D(F,O,i.RGBA,M,S,0,i.RGBA,i.UNSIGNED_BYTE,R));else if(h.isLuminance){var V=i.getParameter(i.UNPACK_ALIGNMENT),N=M,U=Math.floor((M+V-1)/V)*V;C=U*(S-1)+N,R=t.GetLuminanceArrayBuffer(M,S,I,C,a),i.texImage2D(F,O,i.LUMINANCE,M,S,0,i.LUMINANCE,i.UNSIGNED_BYTE,R)}else C=Math.max(4,M)/4*Math.max(4,S)/4*T,R=new Uint8Array(a,I,C),i.compressedTexImage2D(F,O,P,M,S,0,R);I+=C,M*=.5,S*=.5,M=Math.max(1,M),S=Math.max(1,S)}}},t}();t.DDSTools=T}(t=e.Internals||(e.Internals={}))}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(t,i){return void 0===t&&(t=!0),void 0===i&&(i=10),this._useDeltaForWorldStep=t,this.name="CannonJSPlugin",this._physicsMaterials=[],this._fixedTimeStep=1/60,this._currentCollisionGroup=2,this._minus90X=new e.Quaternion(-.7071067811865475,0,0,.7071067811865475),this._plus90X=new e.Quaternion(.7071067811865475,0,0,.7071067811865475),this._tmpPosition=e.Vector3.Zero(),this._tmpQuaternion=new e.Quaternion,this._tmpDeltaPosition=e.Vector3.Zero(),this._tmpDeltaRotation=new e.Quaternion,this._tmpUnityRotation=new e.Quaternion,this.isSupported()?(this.world=new CANNON.World,this.world.broadphase=new CANNON.NaiveBroadphase,void(this.world.solver.iterations=i)):void e.Tools.Error("CannonJS is not available. Please make sure you included the js file.")}return t.prototype.setGravity=function(e){this.world.gravity.copy(e)},t.prototype.setTimeStep=function(e){this._fixedTimeStep=e},t.prototype.executeStep=function(e,t){this.world.step(this._fixedTimeStep,this._useDeltaForWorldStep?1e3*e:0,3)},t.prototype.applyImpulse=function(e,t,i){var r=new CANNON.Vec3(i.x,i.y,i.z),n=new CANNON.Vec3(t.x,t.y,t.z);e.physicsBody.applyImpulse(n,r)},t.prototype.applyForce=function(e,t,i){var r=new CANNON.Vec3(i.x,i.y,i.z),n=new CANNON.Vec3(t.x,t.y,t.z);e.physicsBody.applyImpulse(n,r)},t.prototype.generatePhysicsBody=function(e){if(e.parent)return void(e.physicsBody&&(this.removePhysicsBody(e),e.forceUpdate()));if(e.isBodyInitRequired()){var t=this._createShape(e),i=e.physicsBody;i&&this.removePhysicsBody(e); +var i=t?e.Engine.audioEngine.audioContext.currentTime+t:e.Engine.audioEngine.audioContext.currentTime;this._soundSource.stop(i),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._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.Parse=function(i,r,n,o){var s,a=i.name;s=i.url?n+i.url:n+a;var h,c={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 l=function(){o._isReadyToPlay?(h._audioBuffer=o.getAudioBuffer(),h._isReadyToPlay=!0,h.autoplay&&h.play()):window.setTimeout(l,300)};h=new t(a,new ArrayBuffer(0),r,null,c),l()}else h=new t(a,s,r,function(){r._removePendingData(h)},c),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 d=e.Vector3.FromArray(i.localDirectionToMesh);h.setLocalDirectionToMesh(d)}if(i.connectedMeshId){var f=r.getMeshByID(i.connectedMeshId);f&&h.attachToMesh(f)}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;tr;r++){var n=new i;n.offset=r*e,this.allEntries[r]=n,this.freeEntries[t-r-1]=n}}return e.prototype.allocElement=function(){0===this.freeEntries.length&&this._growBuffer();var e=this.freeEntries.pop();return e},e.prototype.freeElement=function(e){this.freeEntries.push(e)},e.prototype.pack=function(){if(0===this.freeEntries.length)return this.buffer;var e=this.stride,t=this.freeEntries.sort(function(e,t){return e.offset-t.offset}),r=this.allEntries.sort(function(e,t){return e.offset-t.offset}),n=new i;n.offset=this.entryCount*e,t.push(n);for(var o=t[0].offset,s=1,a=t[0].offset,h=1;h_;_++){var m=o/e,g=f/e,v=r[g];this._moveEntry(v,o);var y=r[m];y.offset=f,r[m]=v,r[g]=y,f-=e,o+=e}d>=s?(o=l,s=1):s=(l-o)/e+1,a=l}else++s,a=l}this.entryCount=o/e;var x=this.buffer.subarray(0,o);return this.freeEntries.splice(0),this.allEntries=r.slice(0,this.entryCount),x},e.prototype._moveEntry=function(e,t){for(var i=0;in;n++){var o=new i;o.offset=n*this.stride,this.allEntries[n]=o,this.freeEntries[n]=o}this.buffer=t,this.entryCount=e},e}();e.DynamicFloatArray=t;var i=function(){function e(){}return e}();e.DynamicFloatArrayEntry=i}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t){function i(i,r,n,o){t.call(this,i,r),this._textures={},this._floats={},this._floatsArrays={},this._colors3={},this._colors4={},this._vectors2={},this._vectors3={},this._vectors4={},this._matrices={},this._matrices3x3={},this._matrices2x2={},this._cachedWorldViewMatrix=new e.Matrix,this._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.samplers=o.samplers||[],o.defines=o.defines||[],this._options=o}return __extends(i,t),i.prototype.needAlphaBlending=function(){return this._options.needAlphaBlending},i.prototype.needAlphaTesting=function(){return this._options.needAlphaTesting},i.prototype._checkUniform=function(e){-1===this._options.uniforms.indexOf(e)&&this._options.uniforms.push(e)},i.prototype.setTexture=function(e,t){return-1===this._options.samplers.indexOf(e)&&this._options.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.setVector4=function(e,t){return this._checkUniform(e),this._vectors4[e]=t,this},i.prototype.setMatrix=function(e,t){return this._checkUniform(e),this._matrices[e]=t,this},i.prototype.setMatrix3x3=function(e,t){return this._checkUniform(e),this._matrices3x3[e]=t,this},i.prototype.setMatrix2x2=function(e,t){return this._checkUniform(e),this._matrices2x2[e]=t,this},i.prototype.isReady=function(t,i){var r=this.getScene(),n=r.getEngine();if(!this.checkReadyOnEveryCall&&this._renderId===r.getRenderId())return!0;var o=[],s=new e.EffectFallbacks;i&&o.push("#define INSTANCES");for(var a=0;a>8&255,e>>16&255,e>>24&255)}var n=542327876,o=131072,s=512,a=4,h=64,c=131072,l=i("DXT1"),u=i("DXT3"),d=i("DXT5"),f=31,p=0,_=1,m=2,g=3,v=4,y=7,x=20,b=21,E=22,A=28,T=function(){function t(){}return t.GetDDSInfo=function(e){var t=new Int32Array(e,0,f),i=1;return t[m]&o&&(i=Math.max(1,t[y])),{width:t[v],height:t[g],mipmapCount:i,isFourCC:(t[x]&a)===a,isRGB:(t[x]&h)===h,isLuminance:(t[x]&c)===c,isCube:(t[A]&s)===s}},t.GetRGBAArrayBuffer=function(e,t,i,r,n){for(var o=new Uint8Array(r),s=new Uint8Array(n),a=0,h=t-1;h>=0;h--)for(var c=0;e>c;c++){var l=i+4*(c+h*e);o[a+2]=s[l],o[a+1]=s[l+1],o[a]=s[l+2],o[a+3]=s[l+3],a+=4}return o},t.GetRGBArrayBuffer=function(e,t,i,r,n){for(var o=new Uint8Array(r),s=new Uint8Array(n),a=0,h=t-1;h>=0;h--)for(var c=0;e>c;c++){var l=i+3*(c+h*e);o[a+2]=s[l],o[a+1]=s[l+1],o[a]=s[l+2],a+=3}return o},t.GetLuminanceArrayBuffer=function(e,t,i,r,n){for(var o=new Uint8Array(r),s=new Uint8Array(n),a=0,h=t-1;h>=0;h--)for(var c=0;e>c;c++){var l=i+(c+h*e);o[a]=s[l],a++}return o},t.UploadDDSLevels=function(i,s,a,h,c,x){var A,T,P,M,S,C,I,R,D,O,L=new Int32Array(a,0,f);if(L[p]!=n)return void e.Tools.Error("Invalid magic number in DDS header");if(!h.isFourCC&&!h.isRGB&&!h.isLuminance)return void e.Tools.Error("Unsupported format, must contain a FourCC, RGB or LUMINANCE code");if(h.isFourCC)switch(A=L[b]){case l:T=8,P=s.COMPRESSED_RGBA_S3TC_DXT1_EXT;break;case u:T=16,P=s.COMPRESSED_RGBA_S3TC_DXT3_EXT;break;case d:T=16,P=s.COMPRESSED_RGBA_S3TC_DXT5_EXT;break;default:return void console.error("Unsupported FourCC code:",r(A))}D=1,L[m]&o&&c!==!1&&(D=Math.max(1,L[y]));for(var w=L[E],B=0;x>B;B++){var F=1===x?i.TEXTURE_2D:i.TEXTURE_CUBE_MAP_POSITIVE_X+B;for(M=L[v],S=L[g],I=L[_]+4,O=0;D>O;++O){if(h.isRGB)24===w?(C=M*S*3,R=t.GetRGBArrayBuffer(M,S,I,C,a),i.texImage2D(F,O,i.RGB,M,S,0,i.RGB,i.UNSIGNED_BYTE,R)):(C=M*S*4,R=t.GetRGBAArrayBuffer(M,S,I,C,a),i.texImage2D(F,O,i.RGBA,M,S,0,i.RGBA,i.UNSIGNED_BYTE,R));else if(h.isLuminance){var V=i.getParameter(i.UNPACK_ALIGNMENT),N=M,U=Math.floor((M+V-1)/V)*V;C=U*(S-1)+N,R=t.GetLuminanceArrayBuffer(M,S,I,C,a),i.texImage2D(F,O,i.LUMINANCE,M,S,0,i.LUMINANCE,i.UNSIGNED_BYTE,R)}else C=Math.max(4,M)/4*Math.max(4,S)/4*T,R=new Uint8Array(a,I,C),i.compressedTexImage2D(F,O,P,M,S,0,R);I+=C,M*=.5,S*=.5,M=Math.max(1,M),S=Math.max(1,S)}}},t}();t.DDSTools=T}(t=e.Internals||(e.Internals={}))}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(t,i){return void 0===t&&(t=!0),void 0===i&&(i=10),this._useDeltaForWorldStep=t,this.name="CannonJSPlugin",this._physicsMaterials=[],this._fixedTimeStep=1/60,this._currentCollisionGroup=2,this._minus90X=new e.Quaternion(-.7071067811865475,0,0,.7071067811865475),this._plus90X=new e.Quaternion(.7071067811865475,0,0,.7071067811865475),this._tmpPosition=e.Vector3.Zero(),this._tmpQuaternion=new e.Quaternion,this._tmpDeltaPosition=e.Vector3.Zero(),this._tmpDeltaRotation=new e.Quaternion,this._tmpUnityRotation=new e.Quaternion,this.isSupported()?(this.world=new CANNON.World,this.world.broadphase=new CANNON.NaiveBroadphase,void(this.world.solver.iterations=i)):void e.Tools.Error("CannonJS is not available. Please make sure you included the js file.")}return t.prototype.setGravity=function(e){this.world.gravity.copy(e)},t.prototype.setTimeStep=function(e){this._fixedTimeStep=e},t.prototype.executeStep=function(e,t){this.world.step(this._fixedTimeStep,this._useDeltaForWorldStep?1e3*e:0,3)},t.prototype.applyImpulse=function(e,t,i){var r=new CANNON.Vec3(i.x,i.y,i.z),n=new CANNON.Vec3(t.x,t.y,t.z);e.physicsBody.applyImpulse(n,r)},t.prototype.applyForce=function(e,t,i){var r=new CANNON.Vec3(i.x,i.y,i.z),n=new CANNON.Vec3(t.x,t.y,t.z);e.physicsBody.applyImpulse(n,r)},t.prototype.generatePhysicsBody=function(e){if(e.parent)return void(e.physicsBody&&(this.removePhysicsBody(e),e.forceUpdate()));if(e.isBodyInitRequired()){var t=this._createShape(e),i=e.physicsBody;i&&this.removePhysicsBody(e); var r=this._addMaterial("mat-"+e.uniqueId,e.getParam("friction"),e.getParam("restitution")),n={mass:e.getParam("mass"),material:r},o=e.getParam("nativeOptions");for(var s in o)o.hasOwnProperty(s)&&(n[s]=o[s]);e.physicsBody=new CANNON.Body(n),e.physicsBody.addEventListener("collide",e.onCollide),this.world.addEventListener("preStep",e.beforeStep),this.world.addEventListener("postStep",e.afterStep),e.physicsBody.addShape(t),this.world.add(e.physicsBody),i&&["force","torque","velocity","angularVelocity"].forEach(function(t){e.physicsBody[t].copy(i[t])}),this._processChildMeshes(e)}this._updatePhysicsBodyTransformation(e)},t.prototype._processChildMeshes=function(t){var i=this,r=t.object.getChildMeshes?t.object.getChildMeshes():[];if(r.length){var n=function(e,r){var o=r.getPhysicsImpostor();if(o){var s=o.parent;if(s!==t){var e=r.position;o.physicsBody&&(i.removePhysicsBody(o),o.physicsBody=null),o.parent=t,o.resetUpdateFlags(),t.physicsBody.addShape(i._createShape(o),new CANNON.Vec3(e.x,e.y,e.z)),t.physicsBody.mass+=o.getParam("mass")}}r.getChildMeshes().forEach(n.bind(i,r.position))};r.forEach(n.bind(this,e.Vector3.Zero()))}},t.prototype.removePhysicsBody=function(e){e.physicsBody.removeEventListener("collide",e.onCollide),this.world.removeEventListener("preStep",e.beforeStep),this.world.removeEventListener("postStep",e.afterStep),this.world.remove(e.physicsBody)},t.prototype.generateJoint=function(t){var i=t.mainImpostor.physicsBody,r=t.connectedImpostor.physicsBody;if(i&&r){var n,o=t.joint.jointData,s={pivotA:o.mainPivot?(new CANNON.Vec3).copy(o.mainPivot):null,pivotB:o.connectedPivot?(new CANNON.Vec3).copy(o.connectedPivot):null,axisA:o.mainAxis?(new CANNON.Vec3).copy(o.mainAxis):null,axisB:o.connectedAxis?(new CANNON.Vec3).copy(o.connectedAxis):null,maxForce:o.nativeParams.maxForce,collideConnected:!!o.collision};switch(t.joint.type){case e.PhysicsJoint.HingeJoint:case e.PhysicsJoint.Hinge2Joint:n=new CANNON.HingeConstraint(i,r,s);break;case e.PhysicsJoint.DistanceJoint:n=new CANNON.DistanceConstraint(i,r,o.maxDistance||2);break;case e.PhysicsJoint.SpringJoint:var a=o;n=new CANNON.Spring(i,r,{restLength:a.length,stiffness:a.stiffness,damping:a.damping,localAnchorA:s.pivotA,localAnchorB:s.pivotB});break;case e.PhysicsJoint.PointToPointJoint:case e.PhysicsJoint.BallAndSocketJoint:default:n=new CANNON.PointToPointConstraint(i,s.pivotA,r,s.pivotA,s.maxForce)}n.collideConnected=!!o.collision,t.joint.physicsJoint=n,t.joint.type!==e.PhysicsJoint.SpringJoint?this.world.addConstraint(n):t.mainImpostor.registerAfterPhysicsStep(function(){n.applyForce()})}},t.prototype.removeJoint=function(e){this.world.removeConstraint(e.joint.physicsJoint)},t.prototype._addMaterial=function(e,t,i){var r,n;for(r=0;r=l;++l){if(!n[l]){for(var f=1;!n[(l+f)%o];)f++;n[l]=n[(l+f)%o].slice()}for(var u=0;o>=u;++u)if(!n[l][u]){for(var p,f=1;void 0===p;)p=n[l][(u+f++)%o];n[l][u]=p}}var _=new CANNON.Heightfield(n,{elementSize:a});return _.minY=h,_},t.prototype._updatePhysicsBodyTransformation=function(t){var i=t.object;i.computeWorldMatrix&&i.computeWorldMatrix(!0);var r=t.getObjectCenter();t.getObjectExtendSize();this._tmpDeltaPosition.copyFrom(i.position.subtract(r)),this._tmpPosition.copyFrom(r);var n=i.rotationQuaternion;if(t.type!==e.PhysicsImpostor.PlaneImpostor&&t.type!==e.PhysicsImpostor.HeightmapImpostor&&t.type!==e.PhysicsImpostor.CylinderImpostor||(n=n.multiply(this._minus90X),t.setDeltaRotation(this._plus90X)),t.type===e.PhysicsEngine.HeightmapImpostor){var o=i,s=o.rotationQuaternion;o.rotationQuaternion=this._tmpUnityRotation,o.computeWorldMatrix(!0);var a=r.clone(),h=o.getPivotMatrix()||e.Matrix.Translation(0,0,0);o.rotationQuaternion=s;var c=e.Matrix.Translation(o.getBoundingInfo().boundingBox.extendSize.x,0,-o.getBoundingInfo().boundingBox.extendSize.z);o.setPivotMatrix(c),o.computeWorldMatrix(!0);var l=o.getBoundingInfo().boundingBox.center.subtract(r).subtract(o.position).negate();this._tmpPosition.copyFromFloats(l.x,l.y-o.getBoundingInfo().boundingBox.extendSize.y,l.z),this._tmpDeltaPosition.copyFrom(o.getBoundingInfo().boundingBox.center.subtract(a)),this._tmpDeltaPosition.y+=o.getBoundingInfo().boundingBox.extendSize.y,o.setPivotMatrix(h),o.computeWorldMatrix(!0)}else t.type===e.PhysicsEngine.MeshImpostor&&(this._tmpDeltaPosition.copyFromFloats(0,0,0),this._tmpPosition.copyFrom(i.position));t.setDeltaPosition(this._tmpDeltaPosition),t.physicsBody.position.copy(this._tmpPosition),t.physicsBody.quaternion.copy(n)},t.prototype.setTransformationFromPhysicsBody=function(e){e.object.position.copyFrom(e.physicsBody.position),e.object.rotationQuaternion.copyFrom(e.physicsBody.quaternion)},t.prototype.setPhysicsBodyTransformation=function(e,t,i){e.physicsBody.position.copy(t),e.physicsBody.quaternion.copy(i)},t.prototype.isSupported=function(){return void 0!==window.CANNON},t.prototype.setLinearVelocity=function(e,t){e.physicsBody.velocity.copy(t)},t.prototype.setAngularVelocity=function(e,t){e.physicsBody.angularVelocity.copy(t)},t.prototype.getLinearVelocity=function(t){var i=t.physicsBody.velocity;return i?new e.Vector3(i.x,i.y,i.z):null},t.prototype.getAngularVelocity=function(t){var i=t.physicsBody.angularVelocity;return i?new e.Vector3(i.x,i.y,i.z):null},t.prototype.setBodyMass=function(e,t){e.physicsBody.mass=t,e.physicsBody.updateMassProperties()},t.prototype.sleepBody=function(e){e.physicsBody.sleep()},t.prototype.wakeUpBody=function(e){e.physicsBody.wakeUp()},t.prototype.updateDistanceJoint=function(e,t,i){e.physicsJoint.distance=t},t.prototype.enableMotor=function(e,t){t||e.physicsJoint.enableMotor()},t.prototype.disableMotor=function(e,t){t||e.physicsJoint.disableMotor()},t.prototype.setMotor=function(e,t,i,r){r||(e.physicsJoint.enableMotor(),e.physicsJoint.setMotorSpeed(t),i&&this.setLimit(e,i))},t.prototype.setLimit=function(e,t,i){e.physicsJoint.motorEquation.maxForce=t,e.physicsJoint.motorEquation.minForce=void 0===i?-t:i},t.prototype.dispose=function(){},t}();e.CannonJSPlugin=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(t){this.name="OimoJSPlugin",this._tmpImpostorsArray=[],this._tmpPositionVector=e.Vector3.Zero(),this.world=new OIMO.World(1/60,2,t,!0),this.world.clear(),this.world.isNoStat=!0}return t.prototype.setGravity=function(e){this.world.gravity.copy(e)},t.prototype.setTimeStep=function(e){this.world.timeStep=e},t.prototype.executeStep=function(e,t){var i=this;t.forEach(function(e){e.beforeStep()}),this.world.step(),t.forEach(function(e){e.afterStep(),i._tmpImpostorsArray[e.uniqueId]=e});for(var r=this.world.contacts;null!==r;)if(!r.touching||r.body1.sleeping||r.body2.sleeping){var n=this._tmpImpostorsArray[+r.body1.name],o=this._tmpImpostorsArray[+r.body2.name];n&&o?(n.onCollide({body:o.physicsBody}),o.onCollide({body:n.physicsBody}),r=r.next):r=r.next}else r=r.next},t.prototype.applyImpulse=function(e,t,i){var r=e.physicsBody.massInfo.mass;e.physicsBody.applyImpulse(i.scale(OIMO.INV_SCALE),t.scale(OIMO.INV_SCALE*r))},t.prototype.applyForce=function(t,i,r){e.Tools.Warn("Oimo doesn't support applying force. Using impule instead."),this.applyImpulse(t,i,r)},t.prototype.generatePhysicsBody=function(t){function i(e){e.getChildMeshes&&e.getChildMeshes().forEach(function(e){e.physicsImpostor&&(s.push(e.physicsImpostor),e.physicsImpostor._init())})}function r(t){return Math.max(t,e.PhysicsEngine.Epsilon)}var n=this;if(t.parent)return void(t.physicsBody&&(this.removePhysicsBody(t),t.forceUpdate()));if(t.isBodyInitRequired()){var o={name:t.uniqueId,config:[t.getParam("mass")||1,t.getParam("friction"),t.getParam("restitution")],size:[],type:[],pos:[],rot:[],move:0!==t.getParam("mass"),world:this.world},s=[t];i(t.object),s.forEach(function(i){var s=i.object.rotationQuaternion,a=(new OIMO.Euler).setFromQuaternion({x:t.object.rotationQuaternion.x,y:t.object.rotationQuaternion.y,z:t.object.rotationQuaternion.z,s:t.object.rotationQuaternion.w}),h=i.getObjectExtendSize();if(i===t){var c=t.getObjectCenter();t.object.position.subtractToRef(c,n._tmpPositionVector),o.pos.push(c.x),o.pos.push(c.y),o.pos.push(c.z),o.rot.push(a.x/(OIMO.degtorad||OIMO.TO_RAD)),o.rot.push(a.y/(OIMO.degtorad||OIMO.TO_RAD)),o.rot.push(a.z/(OIMO.degtorad||OIMO.TO_RAD))}else o.pos.push(i.object.position.x),o.pos.push(i.object.position.y),o.pos.push(i.object.position.z),o.rot.push(0),o.rot.push(0),o.rot.push(0);switch(i.type){case e.PhysicsImpostor.ParticleImpostor:e.Tools.Warn("No Particle support in Oimo.js. using SphereImpostor instead");case e.PhysicsImpostor.SphereImpostor:var l=h.x,u=h.y,d=h.z,f=Math.max(r(l),r(u),r(d))/2;o.type.push("sphere"),o.size.push(f),o.size.push(f),o.size.push(f);break;case e.PhysicsImpostor.CylinderImpostor:var p=r(h.x)/2,_=r(h.y);o.type.push("cylinder"),o.size.push(p),o.size.push(_),o.size.push(_);break;case e.PhysicsImpostor.PlaneImpostor:case e.PhysicsImpostor.BoxImpostor:default:var p=r(h.x),_=r(h.y),m=r(h.z);o.type.push("box"),o.size.push(p),o.size.push(_),o.size.push(m)}i.object.rotationQuaternion=s}),t.physicsBody=new OIMO.Body(o).body}else this._tmpPositionVector.copyFromFloats(0,0,0);t.setDeltaPosition(this._tmpPositionVector)},t.prototype.removePhysicsBody=function(e){this.world.removeRigidBody(e.physicsBody)},t.prototype.generateJoint=function(t){var i=t.mainImpostor.physicsBody,r=t.connectedImpostor.physicsBody;if(i&&r){var n,o=t.joint.jointData,s=o.nativeParams||{},a={body1:i,body2:r,axe1:s.axe1||(o.mainAxis?o.mainAxis.asArray():null),axe2:s.axe2||(o.connectedAxis?o.connectedAxis.asArray():null),pos1:s.pos1||(o.mainPivot?o.mainPivot.asArray():null),pos2:s.pos2||(o.connectedPivot?o.connectedPivot.asArray():null),min:s.min,max:s.max,collision:s.collision||o.collision,spring:s.spring,world:this.world};switch(t.joint.type){case e.PhysicsJoint.BallAndSocketJoint:n="jointBall";break;case e.PhysicsJoint.SpringJoint:e.Tools.Warn("Oimo.js doesn't support Spring Constraint. Simulating using DistanceJoint instead");var h=o;a.min=h.length||a.min,a.max=Math.max(a.min,a.max);case e.PhysicsJoint.DistanceJoint:n="jointDistance",a.max=o.maxDistance;break;case e.PhysicsJoint.PrismaticJoint:n="jointPrisme";break;case e.PhysicsJoint.SliderJoint:n="jointSlide";break;case e.PhysicsJoint.WheelJoint:n="jointWheel";break;case e.PhysicsJoint.HingeJoint:default:n="jointHinge"}a.type=n,t.joint.physicsJoint=new OIMO.Link(a).joint}},t.prototype.removeJoint=function(t){try{this.world.removeJoint(t.joint.physicsJoint)}catch(i){e.Tools.Warn(i)}},t.prototype.isSupported=function(){return void 0!==OIMO},t.prototype.setTransformationFromPhysicsBody=function(e){if(!e.physicsBody.sleeping){if(e.physicsBody.shapes.next){var t=this._getLastShape(e.physicsBody);e.object.position.x=t.position.x*OIMO.WORLD_SCALE,e.object.position.y=t.position.y*OIMO.WORLD_SCALE,e.object.position.z=t.position.z*OIMO.WORLD_SCALE}else e.object.position.copyFrom(e.physicsBody.getPosition());e.object.rotationQuaternion.copyFrom(e.physicsBody.getQuaternion())}},t.prototype.setPhysicsBodyTransformation=function(e,t,i){var r=e.physicsBody;r.position.init(t.x*OIMO.INV_SCALE,t.y*OIMO.INV_SCALE,t.z*OIMO.INV_SCALE),r.orientation.init(i.w,i.x,i.y,i.z),r.syncShapes(),r.awake()},t.prototype._getLastShape=function(e){for(var t=e.shapes;t.next;)t=t.next;return t},t.prototype.setLinearVelocity=function(e,t){e.physicsBody.linearVelocity.init(t.x,t.y,t.z)},t.prototype.setAngularVelocity=function(e,t){e.physicsBody.angularVelocity.init(t.x,t.y,t.z)},t.prototype.getLinearVelocity=function(t){var i=t.physicsBody.linearVelocity;return i?new e.Vector3(i.x,i.y,i.z):null},t.prototype.getAngularVelocity=function(t){var i=t.physicsBody.angularVelocity;return i?new e.Vector3(i.x,i.y,i.z):null},t.prototype.setBodyMass=function(e,t){var i=0===t;e.physicsBody.shapes.density=i?1:t,e.physicsBody.setupMass(i?2:1)},t.prototype.sleepBody=function(e){e.physicsBody.sleep()},t.prototype.wakeUpBody=function(e){e.physicsBody.awake()},t.prototype.updateDistanceJoint=function(e,t,i){e.physicsJoint.limitMotoe.upperLimit=t,void 0!==i&&(e.physicsJoint.limitMotoe.lowerLimit=i)},t.prototype.setMotor=function(e,t,i,r){var n=r?e.physicsJoint.rotationalLimitMotor2:e.physicsJoint.rotationalLimitMotor1||e.physicsJoint.rotationalLimitMotor||e.physicsJoint.limitMotor;n&&n.setMotor(t,i)},t.prototype.setLimit=function(e,t,i,r){var n=r?e.physicsJoint.rotationalLimitMotor2:e.physicsJoint.rotationalLimitMotor1||e.physicsJoint.rotationalLimitMotor||e.physicsJoint.limitMotor;n&&n.setLimit(t,void 0===i?-t:i)},t.prototype.dispose=function(){this.world.clear()},t}();e.OimoJSPlugin=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(e){function t(t,i,r,n,o,s){e.call(this,t,"displayPass",["passSampler"],["passSampler"],i,r,n,o,s)}return __extends(t,e),t}(e.PostProcess);e.DisplayPassPostProcess=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){var r=i.getSimplifier(t);r.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,function(e){e[e.QUADRATIC=0]="QUADRATIC"}(e.SimplificationType||(e.SimplificationType={}));var r=e.SimplificationType,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;10>t;++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){var c=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];return c},e.prototype.addInPlace=function(e){for(var t=0;10>t;++t)this.data[t]+=e.data[t]},e.prototype.addArrayInPlace=function(e){for(var t=0;10>t;++t)this.data[t]+=e[t]},e.prototype.add=function(t){for(var i=new e,r=0;10>r;++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;3>o;++o)if(r.error[o]x;x++)n.references[l.triangleStart+x]=n.references[v+x]}else l.triangleStart=v;l.triangleCount=y;break}};e.AsyncLoop.SyncAsyncForLoop(n.triangles.length,n.syncIterations,c,i,function(){return o>=a-s})},0)};e.AsyncLoop.Run(this.decimationIterations,function(e){o>=a-s?e.breakLoop():h(e.index,function(){e.executeNext()})},function(){setTimeout(function(){n.reconstructMesh(i),r()},0)})},t.prototype.initWithMesh=function(t,i,r){var s=this;this.vertices=[],this.triangles=[];var a=this._mesh.getVerticesData(e.VertexBuffer.PositionKind),h=this._mesh.getIndices(),c=this._mesh.subMeshes[t],l=function(e){if(r)for(var t=0;t>0,d,function(){var t=function(e){var t=c.indexStart/3+e,i=3*t,r=h[i+0],o=h[i+1],a=h[i+2],l=s.vertices[u[r-c.verticesStart]],d=s.vertices[u[o-c.verticesStart]],f=s.vertices[u[a-c.verticesStart]],p=new n([l,d,f]);p.originalOffset=i,s.triangles.push(p)};e.AsyncLoop.SyncAsyncForLoop(c.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;3>n;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;3>r;++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;io;++o)n.vertices[o].triangleCount=1;r.push(n)}var s=this._reconstructedMesh.getVerticesData(e.VertexBuffer.PositionKind)||[],a=this._reconstructedMesh.getVerticesData(e.VertexBuffer.NormalKind)||[],h=this._reconstructedMesh.getVerticesData(e.VertexBuffer.UVKind)||[],c=this._reconstructedMesh.getVerticesData(e.VertexBuffer.ColorKind)||[],l=this._mesh.getVerticesData(e.VertexBuffer.NormalKind),u=this._mesh.getVerticesData(e.VertexBuffer.UVKind),d=this._mesh.getVerticesData(e.VertexBuffer.ColorKind),f=0;for(i=0;ii&&(i=0),v.push(n.vertices[e].id+i+m)});this._reconstructedMesh.setIndices(v),this._reconstructedMesh.setVerticesData(e.VertexBuffer.PositionKind,s),this._reconstructedMesh.setVerticesData(e.VertexBuffer.NormalKind,a),h.length>0&&this._reconstructedMesh.setVerticesData(e.VertexBuffer.UVKind,h),c.length>0&&this._reconstructedMesh.setVerticesData(e.VertexBuffer.ColorKind,c);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,f,_,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(d,f).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;os;s++){for(var a=0,h=o.vertices[s];an;++n)o=r.vertices[n],o.triangleCount++;var s=0;for(t=0;tn;++n)o=r.vertices[n],h[o.triangleStart+o.triangleCount]=new a(n,t),o.triangleCount++;this.references=h,e&&this.identifyBorder()},t.prototype.vertexError=function(e,t){var i=t.x,r=t.y,n=t.z;return e.data[0]*i*i+2*e.data[1]*i*r+2*e.data[2]*i*n+2*e.data[3]*i+e.data[4]*r*r+2*e.data[5]*r*n+2*e.data[6]*r+e.data[7]*n*n+2*e.data[8]*n+e.data[9]},t.prototype.calculateError=function(t,i,r,n,o,s){var a=t.q.add(i.q),h=t.isBorder&&i.isBorder,c=0,l=a.det(0,1,2,1,4,5,2,5,7);if(0===l||h){var u=t.position.add(i.position).divide(new e.Vector3(2,2,2)),d=this.vertexError(a,t.position),f=this.vertexError(a,i.position),p=this.vertexError(a,u);c=Math.min(d,f,p),c===d?r&&r.copyFrom(t.position):c===f?r&&r.copyFrom(i.position):r&&r.copyFrom(u)}else r||(r=e.Vector3.Zero()),r.x=-1/l*a.det(1,2,3,4,5,6,5,7,8),r.y=1/l*a.det(0,2,3,1,5,6,2,7,8),r.z=-1/l*a.det(0,1,3,1,4,6,2,5,8),c=this.vertexError(a,r);return c},t}();e.QuadraticErrorSimplification=h}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=[],i=function(i,r){if(!t[i.id]){if(i instanceof e.Geometry.Primitives.Box)r.boxes.push(i.serialize());else if(i instanceof e.Geometry.Primitives.Sphere)r.spheres.push(i.serialize());else if(i instanceof e.Geometry.Primitives.Cylinder)r.cylinders.push(i.serialize());else if(i instanceof e.Geometry.Primitives.Torus)r.toruses.push(i.serialize());else if(i instanceof e.Geometry.Primitives.Ground)r.grounds.push(i.serialize());else if(i instanceof e.Geometry.Primitives.Plane)r.planes.push(i.serialize());else if(i instanceof e.Geometry.Primitives.TorusKnot)r.torusKnots.push(i.serialize());else{if(i instanceof e.Geometry.Primitives._Primitive)throw new Error("Unknown primitive type");r.vertexData.push(i.serializeVerticeData())}t[i.id]=!0}},r=function(t,r){var n={};n.name=t.name,n.id=t.id,e.Tags.HasTags(t)&&(n.tags=e.Tags.GetTags(t)),n.position=t.position.asArray(),t.rotationQuaternion?n.rotationQuaternion=t.rotationQuaternion.asArray():t.rotation&&(n.rotation=t.rotation.asArray()),n.scaling=t.scaling.asArray(),n.localMatrix=t.getPivotMatrix().asArray(),n.isEnabled=t.isEnabled(),n.isVisible=t.isVisible,n.infiniteDistance=t.infiniteDistance,n.pickable=t.isPickable,n.receiveShadows=t.receiveShadows,n.billboardMode=t.billboardMode,n.visibility=t.visibility,n.checkCollisions=t.checkCollisions,t.parent&&(n.parentId=t.parent.id);var o=t._geometry;if(o){var s=o.id;n.geometryId=s,t.getScene().getGeometryByID(s)||i(o,r.geometries),n.subMeshes=[];for(var a=0;at.EPSILON?u:l;p|=m,_.push(m)}switch(p){case l:(e.Vector3.Dot(this.normal,i.plane.normal)>0?r:o).push(i);break;case u:s.push(i);break;case d:a.push(i);break;case f:var g=[],v=[];for(h=0;h=3&&(P=new n(g,i.shared),P.plane&&s.push(P)),v.length>=3&&(P=new n(v,i.shared),P.plane&&a.push(P))}},t.EPSILON=1e-5,t}(),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(){var t=this.vertices.map(function(e){return e.clone()});return new e(t,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;eA;A++)for(var P=E[A].indexStart,M=E[A].indexCount+E[A].indexStart;M>P;P+=3){u=[];for(var S=0;3>S;S++){var C=new e.Vector3(x[3*v[P+S]],x[3*v[P+S]+1],x[3*v[P+S]+2]);h=new e.Vector2(b[2*v[P+S]],b[2*v[P+S]+1]);var I=new e.Vector3(y[3*v[P+S]],y[3*v[P+S]+1],y[3*v[P+S]+2]);c=e.Vector3.TransformCoordinates(I,d),a=e.Vector3.TransformNormal(C,d),s=new i(c,a,h),u.push(s)}l=new n(u,{subMeshId:A,meshId:t,materialIndex:E[A].materialIndex}),l.plane&&g.push(l)}var R=r.FromPolygons(g);return R.matrix=d,R.position=f,R.rotation=p,R.scaling=m,R.rotationQuaternion=_,t++,R},r.FromPolygons=function(e){var t=new r;return t.polygons=e,t},r.prototype.clone=function(){var e=new r;return e.polygons=this.polygons.map(function(e){return e.clone()}),e.copyTransformAttributes(this),e},r.prototype.toPolygons=function(){return this.polygons},r.prototype.union=function(e){var t=new o(this.clone().polygons),i=new o(e.clone().polygons);return t.clipTo(i),i.clipTo(t),i.invert(),i.clipTo(t),i.invert(),t.build(i.allPolygons()),r.FromPolygons(t.allPolygons()).copyTransformAttributes(this)},r.prototype.unionInPlace=function(e){var t=new o(this.polygons),i=new o(e.polygons);t.clipTo(i),i.clipTo(t),i.invert(),i.clipTo(t),i.invert(),t.build(i.allPolygons()),this.polygons=t.allPolygons()},r.prototype.subtract=function(e){var t=new o(this.clone().polygons),i=new o(e.clone().polygons);return t.invert(),t.clipTo(i),i.clipTo(t),i.invert(),i.clipTo(t),i.invert(),t.build(i.allPolygons()),t.invert(),r.FromPolygons(t.allPolygons()).copyTransformAttributes(this)},r.prototype.subtractInPlace=function(e){var t=new o(this.polygons),i=new o(e.polygons);t.invert(),t.clipTo(i),i.clipTo(t),i.invert(),i.clipTo(t),i.invert(),t.build(i.allPolygons()),t.invert(),this.polygons=t.allPolygons()},r.prototype.intersect=function(e){var t=new o(this.clone().polygons),i=new o(e.clone().polygons);return t.invert(),i.clipTo(t),i.invert(),t.clipTo(i),i.clipTo(t),t.build(i.allPolygons()),t.invert(),r.FromPolygons(t.allPolygons()).copyTransformAttributes(this)},r.prototype.intersectInPlace=function(e){var t=new o(this.polygons),i=new o(e.polygons);t.invert(),i.clipTo(t),i.invert(),t.clipTo(i),i.clipTo(t),t.build(i.allPolygons()),t.invert(),this.polygons=t.allPolygons()},r.prototype.inverse=function(){var e=this.clone();return e.inverseInPlace(),e},r.prototype.inverseInPlace=function(){this.polygons.map(function(e){e.flip()})},r.prototype.copyTransformAttributes=function(e){return this.matrix=e.matrix,this.position=e.position,this.rotation=e.rotation,this.scaling=e.scaling,this.rotationQuaternion=e.rotationQuaternion,this},r.prototype.buildMeshGeometry=function(t,i,r){var n=this.matrix.clone();n.invert();var o,s,a,h=new e.Mesh(t,i),c=[],l=[],u=[],d=[],f=e.Vector3.Zero(),p=e.Vector3.Zero(),_=e.Vector2.Zero(),m=this.polygons,g=[0,0,0],v={},y=0,x={};r&&m.sort(function(e,t){return e.shared.meshId===t.shared.meshId?e.shared.subMeshId-t.shared.subMeshId:e.shared.meshId-t.shared.meshId});for(var b=0,E=m.length;E>b;b++){o=m[b],x[o.shared.meshId]||(x[o.shared.meshId]={}),x[o.shared.meshId][o.shared.subMeshId]||(x[o.shared.meshId][o.shared.subMeshId]={indexStart:+(1/0),indexEnd:-(1/0),materialIndex:o.shared.materialIndex}),a=x[o.shared.meshId][o.shared.subMeshId];for(var A=2,T=o.vertices.length;T>A;A++){g[0]=0,g[1]=A-1,g[2]=A;for(var P=0;3>P;P++){f.copyFrom(o.vertices[g[P]].pos),p.copyFrom(o.vertices[g[P]].normal),_.copyFrom(o.vertices[g[P]].uv);var M=e.Vector3.TransformCoordinates(f,n),S=e.Vector3.TransformNormal(p,n);s=v[M.x+","+M.y+","+M.z],"undefined"!=typeof s&&u[3*s]===S.x&&u[3*s+1]===S.y&&u[3*s+2]===S.z&&d[2*s]===_.x&&d[2*s+1]===_.y||(c.push(M.x,M.y,M.z),d.push(_.x,_.y),u.push(p.x,p.y,p.z),s=v[M.x+","+M.y+","+M.z]=c.length/3-1),l.push(s),a.indexStart=Math.min(y,a.indexStart),a.indexEnd=Math.max(y,a.indexEnd),y++}}}if(h.setVerticesData(e.VertexBuffer.PositionKind,c),h.setVerticesData(e.VertexBuffer.NormalKind,u),h.setVerticesData(e.VertexBuffer.UVKind,d),h.setIndices(l),r){var C,I=0;h.subMeshes=new Array;for(var R in x){C=-1;for(var D in x[R])a=x[R][D],e.SubMesh.CreateFromIndices(a.materialIndex+I,a.indexStart,a.indexEnd-a.indexStart+1,h),C=Math.max(a.materialIndex,C);I+=++C}}return h},r.prototype.toMesh=function(e,t,i,r){var n=this.buildMeshGeometry(e,i,r);return n.material=t,n.position.copyFrom(this.position),n.rotation.copyFrom(this.rotation),this.rotationQuaternion&&(n.rotationQuaternion=this.rotationQuaternion.clone()),n.scaling.copyFrom(this.scaling),n.computeWorldMatrix(!0),n},r}();e.CSG=s}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t){function i(i,r,n,o){var s=this;t.call(this,i,"vrDistortionCorrection",["LensCenter","Scale","ScaleIn","HmdWarpParam"],null,o.postProcessScaleFactor,r,e.Texture.BILINEAR_SAMPLINGMODE,null,null),this._isRightEye=n,this._distortionFactors=o.distortionK,this._postProcessScaleFactor=o.postProcessScaleFactor,this._lensCenterOffset=o.lensCenterOffset,this.onSizeChanged=function(){s.aspectRatio=.5*s.width/s.height,s._scaleIn=new e.Vector2(2,2/s.aspectRatio),s._scaleFactor=new e.Vector2(.5*(1/s._postProcessScaleFactor),.5*(1/s._postProcessScaleFactor)*s.aspectRatio),s._lensCenter=new e.Vector2(s._isRightEye?.5-.5*s._lensCenterOffset:.5+.5*s._lensCenterOffset,.5)},this.onApply=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])}}return __extends(i,t),i}(e.PostProcess);e.VRDistortionCorrectionPostProcess=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){!function(e){e[e.X=0]="X",e[e.Y=1]="Y",e[e.Z=2]="Z"}(e.JoystickAxis||(e.JoystickAxis={}));var t=e.JoystickAxis,i=function(){function i(r){var n=this;r?this._leftJoystick=!0:this._leftJoystick=!1,this._joystickIndex=i._globalJoystickIndex,i._globalJoystickIndex++,this._axisTargetedByLeftAndRight=t.X,this._axisTargetedByUpAndDown=t.Y,this.reverseLeftRight=!1,this.reverseUpDown=!1,this._touches=new e.StringDictionary,this.deltaPosition=e.Vector3.Zero(),this._joystickSensibility=25,this._inversedSensibility=1/(this._joystickSensibility/1e3),this._rotationSpeed=25,this._inverseRotationSpeed=1/(this._rotationSpeed/1e3),this._rotateOnAxisRelativeToMesh=!1,this._onResize=function(e){i.vjCanvasWidth=window.innerWidth,i.vjCanvasHeight=window.innerHeight,i.vjCanvas.width=i.vjCanvasWidth,i.vjCanvas.height=i.vjCanvasHeight,i.halfWidth=i.vjCanvasWidth/2,i.halfHeight=i.vjCanvasHeight/2},i.vjCanvas||(window.addEventListener("resize",this._onResize,!1),i.vjCanvas=document.createElement("canvas"),i.vjCanvasWidth=window.innerWidth,i.vjCanvasHeight=window.innerHeight,i.vjCanvas.width=window.innerWidth,i.vjCanvas.height=window.innerHeight,i.vjCanvas.style.width="100%",i.vjCanvas.style.height="100%",i.vjCanvas.style.position="absolute",i.vjCanvas.style.backgroundColor="transparent",i.vjCanvas.style.top="0px",i.vjCanvas.style.left="0px",i.vjCanvas.style.zIndex="5",i.vjCanvas.style.msTouchAction="none",i.vjCanvas.setAttribute("touch-action","none"),i.vjCanvasContext=i.vjCanvas.getContext("2d"),i.vjCanvasContext.strokeStyle="#ffffff",i.vjCanvasContext.lineWidth=2,document.body.appendChild(i.vjCanvas)),i.halfWidth=i.vjCanvas.width/2,i.halfHeight=i.vjCanvas.height/2,this.pressed=!1,this._joystickColor="cyan",this._joystickPointerID=-1,this._joystickPointerPos=new e.Vector2(0,0),this._joystickPreviousPointerPos=new e.Vector2(0,0),this._joystickPointerStartPos=new e.Vector2(0,0),this._deltaJoystickVector=new e.Vector2(0,0),this._onPointerDownHandlerRef=function(e){n._onPointerDown(e)},this._onPointerMoveHandlerRef=function(e){n._onPointerMove(e)},this._onPointerOutHandlerRef=function(e){n._onPointerUp(e)},this._onPointerUpHandlerRef=function(e){n._onPointerUp(e)},i.vjCanvas.addEventListener("pointerdown",this._onPointerDownHandlerRef,!1),i.vjCanvas.addEventListener("pointermove",this._onPointerMoveHandlerRef,!1),i.vjCanvas.addEventListener("pointerup",this._onPointerUpHandlerRef,!1),i.vjCanvas.addEventListener("pointerout",this._onPointerUpHandlerRef,!1),i.vjCanvas.addEventListener("contextmenu",function(e){e.preventDefault()},!1),requestAnimationFrame(function(){n._drawVirtualJoystick()})}return i.prototype.setJoystickSensibility=function(e){this._joystickSensibility=e,this._inversedSensibility=1/(this._joystickSensibility/1e3)},i.prototype._onPointerDown=function(e){var t;e.preventDefault(),t=this._leftJoystick===!0?e.clientXi.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-63,this._joystickPointerStartPos.y-63,126,126),i.vjCanvasContext.clearRect(this._joystickPreviousPointerPos.x-41,this._joystickPreviousPointerPos.y-41,82,82),this._joystickPointerID=-1,this.pressed=!1;else{var t=this._touches.get(e.pointerId.toString());t&&i.vjCanvasContext.clearRect(t.prevX-43,t.prevY-43,86,86)}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){t.pointerId===e._joystickPointerID?(i.vjCanvasContext.clearRect(e._joystickPointerStartPos.x-63,e._joystickPointerStartPos.y-63,126,126),i.vjCanvasContext.clearRect(e._joystickPreviousPointerPos.x-41,e._joystickPreviousPointerPos.y-41,82,82),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(t.prevX-43,t.prevY-43,86,86),i.vjCanvasContext.beginPath(),i.vjCanvasContext.fillStyle="white",i.vjCanvasContext.beginPath(),i.vjCanvasContext.strokeStyle="red",i.vjCanvasContext.lineWidth=6,i.vjCanvasContext.arc(t.x,t.y,40,0,2*Math.PI,!0),i.vjCanvasContext.stroke(),i.vjCanvasContext.closePath(),t.prevX=t.x,t.prevY=t.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._globalJoystickIndex=0,i}();e.VirtualJoystick=i}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(e){function t(t,i,r){e.call(this,t,i,r),this.inputs.addVirtualJoystick()}return __extends(t,e),t}(e.FreeCamera);e.VirtualJoysticksCamera=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(e){function t(t,i,r,n,o,s){e.call(this,t,"anaglyph",null,["leftSampler"],i,r,n,o,s)}return __extends(t,e),t}(e.PostProcess);e.AnaglyphPostProcess=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(e){this._scene=e}return t.prototype.render=function(t,i,r){var n=this;void 0===r&&(r=!1);var o=this._scene,s=this._scene.getEngine(),a=null!==s.getCaps().instancedArrays&&null!==i.visibleInstances[t._id]&&void 0!==i.visibleInstances[t._id];if(this.isReady(t,a)){var h=t.getRenderingMesh(),c=t.getMaterial();if(s.enableEffect(this._effect),this._effect.setFloat("offset",r?0:h.outlineWidth),this._effect.setColor4("color",r?h.overlayColor:h.outlineColor,r?h.overlayAlpha:1),this._effect.setMatrix("viewProjection",o.getTransformMatrix()),h.useBones&&h.computeBonesUsingShaders&&this._effect.setMatrices("mBones",h.skeleton.getTransformMatrices(h)),h._bind(t,this._effect,e.Material.TriangleFillMode),c&&c.needAlphaTesting()){var l=c.getAlphaTestTexture();this._effect.setTexture("diffuseSampler",l),this._effect.setMatrix("diffuseMatrix",l.getTextureMatrix())}h._processRendering(t,this._effect,e.Material.TriangleFillMode,i,a,function(e,t){n._effect.setMatrix("world",t)})}},t.prototype.isReady=function(t,i){var r=[],n=[e.VertexBuffer.PositionKind,e.VertexBuffer.NormalKind],o=t.getMesh(),s=t.getMaterial();s&&s.needAlphaTesting()&&(r.push("#define ALPHATEST"),o.isVerticesDataPresent(e.VertexBuffer.UVKind)&&(n.push(e.VertexBuffer.UVKind),r.push("#define UV1")),o.isVerticesDataPresent(e.VertexBuffer.UV2Kind)&&(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 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 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 e(e,t){this.name=e,this.url=t,this.isCompleted=!1}return e.prototype.run=function(e,t,i){var r=this,n=new Image;n.onload=function(){r.image=n,r.isCompleted=!0,r.onSuccess&&r.onSuccess(r),t()},n.onerror=function(){r.onError&&r.onError(r),i()},n.src=this.url},e}();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 s(e){this._tasks=new Array,this._waitingTasksCount=0,this.useDefaultLoadingScreen=!0,this._scene=e}return s.prototype.addMeshTask=function(e,i,r,n){var o=new t(e,i,r,n);return this._tasks.push(o),o},s.prototype.addTextFileTask=function(e,t){var r=new i(e,t);return this._tasks.push(r),r},s.prototype.addBinaryFileTask=function(e,t){var i=new r(e,t);return this._tasks.push(i),i},s.prototype.addImageTask=function(e,t){var i=new n(e,t);return this._tasks.push(i),i},s.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},s.prototype._decreaseWaitingTasksCount=function(){this._waitingTasksCount--,0===this._waitingTasksCount&&(this.onFinish&&this.onFinish(this._tasks),this._scene.getEngine().hideLoadingUI())},s.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()})},s.prototype.reset=function(){return this._tasks=new Array,this},s.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;ei&&null===this._hmdDevice;)e[i]instanceof HMDVRDevice&&(this._hmdDevice=e[i]),i++;for(i=0;t>i&&null===this._sensorDevice;)e[i]instanceof PositionSensorVRDevice&&(!this._hmdDevice||e[i].hardwareUnitId===this._hmdDevice.hardwareUnitId)&&(this._sensorDevice=e[i]),i++;this._vrEnabled=!(!this._sensorDevice||!this._hmdDevice)},i.prototype._checkInputs=function(){this._vrEnabled&&(this._cacheState=this._sensorDevice.getState(),this._cacheQuaternion.copyFromFloats(this._cacheState.orientation.x,this._cacheState.orientation.y,this._cacheState.orientation.z,this._cacheState.orientation.w),this._cacheQuaternion.toEulerAnglesToRef(this._cacheRotation),this.rotation.x=-this._cacheRotation.x,this.rotation.y=-this._cacheRotation.y,this.rotation.z=this._cacheRotation.z),t.prototype._checkInputs.call(this)},i.prototype.attachControl=function(i,r){t.prototype.attachControl.call(this,i,r),r=e.Camera.ForceAttachControlToAlwaysPreventDefault?!1:r,navigator.getVRDevices?navigator.getVRDevices().then(this._getWebVRDevices):navigator.mozGetVRDevices&&navigator.mozGetVRDevices(this._getWebVRDevices)},i.prototype.detachControl=function(e){t.prototype.detachControl.call(this,e),this._vrEnabled=!1},i.prototype.getTypeName=function(){return"WebVRFreeCamera"},i}(e.FreeCamera);e.WebVRFreeCamera=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function e(e){void 0===e&&(e=0),this.priority=e,this.apply=function(e){return!0}}return e}();e.SceneOptimization=t;var i=function(e){function t(t,i){var r=this;void 0===t&&(t=0),void 0===i&&(i=1024),e.call(this,t),this.priority=t,this.maximumSize=i,this.apply=function(e){for(var t=!0,i=0;ir.maximumSize&&(n.scale(.5),t=!1)}}return t}}return __extends(t,e),t}(t);e.TextureOptimization=i;var r=function(e){function t(t,i){var r=this;void 0===t&&(t=0),void 0===i&&(i=2),e.call(this,t),this.priority=t,this.maximumScale=i,this._currentScale=1,this.apply=function(e){return r._currentScale++,e.getEngine().setHardwareScalingLevel(r._currentScale),r._currentScale>=r.maximumScale}}return __extends(t,e),t}(t);e.HardwareScalingOptimization=r;var n=function(e){function t(){e.apply(this,arguments),this.apply=function(e){return e.shadowsEnabled=!1,!0}}return __extends(t,e),t}(t);e.ShadowsOptimization=n;var o=function(e){function t(){e.apply(this,arguments),this.apply=function(e){return e.postProcessesEnabled=!1,!0}}return __extends(t,e),t}(t);e.PostProcessesOptimization=o;var s=function(e){function t(){e.apply(this,arguments),this.apply=function(e){return e.lensFlaresEnabled=!1,!0}}return __extends(t,e),t}(t);e.LensFlaresOptimization=s;var a=function(e){function t(){e.apply(this,arguments),this.apply=function(e){return e.particlesEnabled=!1,!0}}return __extends(t,e),t}(t);e.ParticlesOptimization=a;var h=function(e){function t(){e.apply(this,arguments),this.apply=function(e){return e.renderTargetsEnabled=!1,!0}}return __extends(t,e),t}(t);e.RenderTargetsOptimization=h;var c=function(t){function i(){var r=this;t.apply(this,arguments),this._canBeMerged=function(t){if(!(t instanceof e.Mesh))return!1;var i=t;return i.isVisible&&i.isEnabled()?i.instances.length>0?!1:i.skeleton||i.hasLODLevels?!1:!i.parent:!1},this.apply=function(t,n){for(var o=t.meshes.slice(0),s=o.length,a=0;s>a;a++){var h=new Array,c=o[a];if(r._canBeMerged(c)){h.push(c);for(var l=a+1;s>l;l++){var u=o[l];r._canBeMerged(u)&&u.material===c.material&&u.checkCollisions===c.checkCollisions&&(h.push(u),s--,o.splice(l,1),l--)}h.length<2||e.Mesh.MergeMeshes(h)}}return void 0!=n?n&&t.createOrUpdateSelectionOctree():i.UpdateSelectionTree&&t.createOrUpdateSelectionOctree(),!0}}return __extends(i,t),Object.defineProperty(i,"UpdateSelectionTree",{get:function(){return i._UpdateSelectionTree},set:function(e){i._UpdateSelectionTree=e},enumerable:!0,configurable:!0}),i._UpdateSelectionTree=!1,i}(t);e.MergeMeshesOptimization=c;var l=function(){function e(e,t){void 0===e&&(e=60),void 0===t&&(t=2e3),this.targetFrameRate=e,this.trackerDuration=t,this.optimizations=new Array}return e.LowDegradationAllowed=function(t){var r=new e(t),h=0;return r.optimizations.push(new c(h)),r.optimizations.push(new n(h)),r.optimizations.push(new s(h)),h++,r.optimizations.push(new o(h)),r.optimizations.push(new a(h)),h++,r.optimizations.push(new i(h,1024)), r},e.ModerateDegradationAllowed=function(t){var l=new e(t),u=0;return l.optimizations.push(new c(u)),l.optimizations.push(new n(u)),l.optimizations.push(new s(u)),u++,l.optimizations.push(new o(u)),l.optimizations.push(new a(u)),u++,l.optimizations.push(new i(u,512)),u++,l.optimizations.push(new h(u)),u++,l.optimizations.push(new r(u,2)),l},e.HighDegradationAllowed=function(t){var l=new e(t),u=0;return l.optimizations.push(new c(u)),l.optimizations.push(new n(u)),l.optimizations.push(new s(u)),u++,l.optimizations.push(new o(u)),l.optimizations.push(new a(u)),u++,l.optimizations.push(new i(u,256)),u++,l.optimizations.push(new h(u)),u++,l.optimizations.push(new r(u,4)),l},e}();e.SceneOptimizerOptions=l;var u=function(){function e(){}return e._CheckCurrentState=function(t,i,r,n,o){if(t.getEngine().getFps()>=i.targetFrameRate)return void(n&&n());for(var s=!0,a=!0,h=0;hi.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;n>h;h++)o.push(new e.Vector2(i+Math.cos(s)*t,r+Math.sin(s)*t)),s-=a;return o},t.Parse=function(t){var i,r=t.split(/[^-+eE\.\d]+/).map(parseFloat).filter(function(e){return!isNaN(e)}),n=[];for(i=0;i<(2147483646&r.length);i+=2)n.push(new e.Vector2(r[i],r[i+1]));return n},t.StartingAt=function(t,i){return e.Path2.StartingAt(t,i)},t}();e.Polygon=r;var n=function(){function t(t,r,n){if(this._points=new i,this._outlinepoints=new i,this._holes=[],!("poly2tri"in window))throw"PolygonMeshBuilder cannot be used because poly2tri is not referenced";this._name=t,this._scene=n;var o;o=r instanceof e.Path2?r.getPoints():r,this._swctx=new poly2tri.SweepContext(this._points.add(o)),this._outlinepoints.add(o)}return t.prototype.addHole=function(e){this._swctx.addHole(this._points.add(e));var t=new i;return t.add(e),this._holes.push(t),this},t.prototype.build=function(t,i){var r=this;void 0===t&&(t=!1);var n=new e.Mesh(this._name,this._scene),o=[],s=[],a=[],h=this._points.computeBounds();this._points.elements.forEach(function(e){o.push(0,1,0),s.push(e.x,0,e.y),a.push((e.x-h.min.x)/h.width,(e.y-h.min.y)/h.height)});var c=[];if(this._swctx.triangulate(),this._swctx.getTriangles().forEach(function(e){e.getPoints().forEach(function(e){c.push(e.index)})}),i>0){var l=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)});var u,d,f=0;this._swctx.getTriangles().forEach(function(e){e.getPoints().forEach(function(e){switch(f){case 0:u=e;break;case 1:d=e;break;case 2:c.push(e.index+l),c.push(d.index+l),c.push(u.index+l),f=-1}f++})}),this.addSide(s,o,a,c,h,this._outlinepoints,i,!1),this._holes.forEach(function(e){r.addSide(s,o,a,c,h,e,i,!0)})}return n.setVerticesData(e.VertexBuffer.PositionKind,s,t),n.setVerticesData(e.VertexBuffer.NormalKind,o,t),n.setVerticesData(e.VertexBuffer.UVKind,a,t),n.setIndices(c),n},t.prototype.addSide=function(t,i,r,n,o,s,a,h){for(var c=t.length/3,l=0,u=0;us.elements.length-1?s.elements[0]:s.elements[u+1],t.push(f.x,0,f.y),t.push(f.x,-a,f.y),t.push(d.x,0,d.y),t.push(d.x,-a,d.y);var p=new e.Vector3(f.x,0,f.y),_=new e.Vector3(d.x,0,d.y),m=_.subtract(p),g=new e.Vector3(0,1,0),v=e.Vector3.Cross(m,g);v=v.normalize(),r.push(l/o.width,0),r.push(l/o.width,1),l+=m.length(),r.push(l/o.width,0),r.push(l/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(c),n.push(c+2),n.push(c+1),n.push(c+1),n.push(c+2),n.push(c+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(c),n.push(c+1),n.push(c+2),n.push(c+1),n.push(c+3),n.push(c+2)),c+=4}},t}();e.PolygonMeshBuilder=n}(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;tl;l++)for(var u=0;2>u;u++)for(var d=0;2>d;d++){var f=t.add(c.multiplyByFloats(l,u,d)),p=t.add(c.multiplyByFloats(l+1,u+1,d+1)),_=new e.OctreeBlock(f,p,n,o+1,s,h);_.addEntries(r),a.blocks.push(_)}},t.CreationFuncForMeshes=function(e,t){!e.isBlocked&&e.getBoundingInfo().boundingBox.intersectsMinMax(t.minPoint,t.maxPoint)&&t.entries.push(e)},t.CreationFuncForSubMeshes=function(e,t){e.getBoundingInfo().boundingBox.intersectsMinMax(t.minPoint,t.maxPoint)&&t.entries.push(e)},t}();e.Octree=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(e,t,i,r,n,o){this.entries=new Array,this._boundingVectors=new Array,this._capacity=i,this._depth=r,this._maxDepth=n,this._creationFunc=o,this._minPoint=e,this._maxPoint=t,this._boundingVectors.push(e.clone()),this._boundingVectors.push(t.clone()),this._boundingVectors.push(e.clone()),this._boundingVectors[2].x=t.x,this._boundingVectors.push(e.clone()),this._boundingVectors[3].y=t.y,this._boundingVectors.push(e.clone()),this._boundingVectors[4].z=t.z,this._boundingVectors.push(t.clone()),this._boundingVectors[5].z=e.z,this._boundingVectors.push(t.clone()),this._boundingVectors[6].x=e.x,this._boundingVectors.push(t.clone()),this._boundingVectors[7].y=e.y}return Object.defineProperty(t.prototype,"capacity",{get:function(){return this._capacity},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"minPoint",{get:function(){return this._minPoint},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"maxPoint",{get:function(){return this._maxPoint},enumerable:!0,configurable:!0}),t.prototype.addEntry=function(e){if(this.blocks)for(var t=0;tthis.capacity&&this._depth0&&this._positionX>t.x&&this._positionXt.y&&this._positionYr},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.borderLimit&&(s=this.borderLimit);var a=1-s/this.borderLimit;if(0>a)return!1;a>1&&(a=1);var h=r.x+r.width/2,c=r.y+r.height/2,l=h-this._positionX,u=c-this._positionY;t.enableEffect(this._effect),t.setState(!1),t.setDepthBuffer(!1),t.setAlphaMode(e.Engine.ALPHA_ONEONE),t.bindBuffers(this._vertexBuffer,this._indexBuffer,this._vertexDeclaration,this._vertexStrideSize,this._effect);for(var d=0;d=2&&(this._leftStick={x:this.browserGamepad.axes[0],y:this.browserGamepad.axes[1]}),this.browserGamepad.axes.length>=4&&(this._rightStick={x:this.browserGamepad.axes[2],y:this.browserGamepad.axes[3]})}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[0],y:this.browserGamepad.axes[1]}),this._rightStick&&(this.rightStick={x:this.browserGamepad.axes[2],y:this.browserGamepad.axes[3]})},e}();e.Gamepad=r;var n=function(e){function t(t,i,r){e.call(this,t,i,r),this.id=t,this.index=i,this.gamepad=r,this._buttons=new Array(r.buttons.length)}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;t