=t);r++)hr.CreateFromIndices(0,n,r===e-1?t-n:i,this),n+=i;this.synchronizeInstances()}},t.prototype.setVerticesData=function(e,t,i,n){if(void 0===i&&(i=!1),this._geometry)this._geometry.setVerticesData(e,t,i,n);else{var r=new $n;r.set(t,e);var o=this.getScene();new fr(fr.RandomId(),o,r,i,this)}return this},t.prototype.removeVerticesData=function(e){this._geometry&&this._geometry.removeVerticesData(e)},t.prototype.markVerticesDataAsUpdatable=function(e,t){void 0===t&&(t=!0);var i=this.getVertexBuffer(e);i&&i.isUpdatable()!==t&&this.setVerticesData(e,this.getVerticesData(e),t)},t.prototype.setVerticesBuffer=function(e,t){return void 0===t&&(t=!0),this._geometry||(this._geometry=fr.CreateGeometryForMesh(this)),this._geometry.setVerticesBuffer(e,null,t),this},t.prototype.updateVerticesData=function(e,t,i,n){return this._geometry?(n?(this.makeGeometryUnique(),this.updateVerticesData(e,t,i,!1)):this._geometry.updateVerticesData(e,t,i),this):this},t.prototype.updateMeshPositions=function(e,t){void 0===t&&(t=!0);var i=this.getVerticesData(wi.PositionKind);if(!i)return this;if(e(i),this.updateVerticesData(wi.PositionKind,i,!1,!1),t){var n=this.getIndices(),r=this.getVerticesData(wi.NormalKind);if(!r)return this;$n.ComputeNormals(i,n,r),this.updateVerticesData(wi.NormalKind,r,!1,!1)}return this},t.prototype.makeGeometryUnique=function(){if(!this._geometry)return this;if(1===this._geometry.meshes.length)return this;var e=this._geometry,t=this._geometry.copy(fr.RandomId());return e.releaseForMesh(this,!0),t.applyToMesh(this),this},t.prototype.setIndices=function(e,t,i){if(void 0===t&&(t=null),void 0===i&&(i=!1),this._geometry)this._geometry.setIndices(e,t,i);else{var n=new $n;n.indices=e;var r=this.getScene();new fr(fr.RandomId(),r,n,i,this)}return this},t.prototype.updateIndices=function(e,t,i){return void 0===i&&(i=!1),this._geometry?(this._geometry.updateIndices(e,t,i),this):this},t.prototype.toLeftHanded=function(){return this._geometry?(this._geometry.toLeftHanded(),this):this},t.prototype._bind=function(e,t,i){if(!this._geometry)return this;var n,r=this.getScene().getEngine();if(this.morphTargetManager&&this.morphTargetManager.isUsingTextureForTargets&&this.morphTargetManager._bind(t),this._unIndexed)n=null;else switch(i){case Ir.PointFillMode:n=null;break;case Ir.WireFrameFillMode:n=e._getLinesIndexBuffer(this.getIndices(),r);break;default:case Ir.TriangleFillMode:n=this._geometry.getIndexBuffer()}return!this._userInstancedBuffersStorage||this.hasThinInstances?this._geometry._bind(t,n):this._geometry._bind(t,n,this._userInstancedBuffersStorage.vertexBuffers,this._userInstancedBuffersStorage.vertexArrayObjects),this},t.prototype._draw=function(e,t,i){if(!this._geometry||!this._geometry.getVertexBuffers()||!this._unIndexed&&!this._geometry.getIndexBuffer())return this;this._internalMeshDataInfo._onBeforeDrawObservable&&this._internalMeshDataInfo._onBeforeDrawObservable.notifyObservers(this);var n=this.getScene().getEngine();return this._unIndexed||t==Ir.PointFillMode?n.drawArraysType(t,e.verticesStart,e.verticesCount,this.forcedInstanceCount||i):t==Ir.WireFrameFillMode?n.drawElementsType(t,0,e._linesIndexCount,this.forcedInstanceCount||i):n.drawElementsType(t,e.indexStart,e.indexCount,this.forcedInstanceCount||i),this},t.prototype.registerBeforeRender=function(e){return this.onBeforeRenderObservable.add(e),this},t.prototype.unregisterBeforeRender=function(e){return this.onBeforeRenderObservable.removeCallback(e),this},t.prototype.registerAfterRender=function(e){return this.onAfterRenderObservable.add(e),this},t.prototype.unregisterAfterRender=function(e){return this.onAfterRenderObservable.removeCallback(e),this},t.prototype._getInstancesRenderList=function(e,t){if(void 0===t&&(t=!1),this._instanceDataStorage.isFrozen){if(t)return this._instanceDataStorage.batchCacheReplacementModeInFrozenMode.hardwareInstancedRendering[e]=!1,this._instanceDataStorage.batchCacheReplacementModeInFrozenMode.renderSelf[e]=!0,this._instanceDataStorage.batchCacheReplacementModeInFrozenMode;if(this._instanceDataStorage.previousBatch)return this._instanceDataStorage.previousBatch}var i=this.getScene(),n=i._isInIntermediateRendering(),r=n?this._internalAbstractMeshDataInfo._onlyForInstancesIntermediate:this._internalAbstractMeshDataInfo._onlyForInstances,o=this._instanceDataStorage.batchCache;if(o.mustReturn=!1,o.renderSelf[e]=t||!r&&this.isEnabled()&&this.isVisible,o.visibleInstances[e]=null,this._instanceDataStorage.visibleInstances&&!t){var a=this._instanceDataStorage.visibleInstances,s=i.getRenderId(),l=n?a.intermediateDefaultRenderId:a.defaultRenderId;o.visibleInstances[e]=a[s],!o.visibleInstances[e]&&l&&(o.visibleInstances[e]=a[l])}return o.hardwareInstancedRendering[e]=!t&&this._instanceDataStorage.hardwareInstancedRendering&&null!==o.visibleInstances[e]&&void 0!==o.visibleInstances[e],this._instanceDataStorage.previousBatch=o,o},t.prototype._renderWithInstances=function(e,i,n,r,o){for(var a,s=n.visibleInstances[e._id],l=s?s.length:0,c=this._instanceDataStorage,u=c.instancesBufferSize,h=c.instancesBuffer,d=c.instancesPreviousBuffer,p=16*(l+1)*4;c.instancesBufferSizet._distanceToCamera?-1:e._distanceToCamerau&&n++,0!==f&&d++,h+=f,u=f}if(l[d]++,d>o&&(o=d),0===h)r++;else{var _=1/h,m=0;for(p=0;p.001&&a++}}var g=this.skeleton.bones.length,v=this.getVerticesData(wi.MatricesIndicesKind),y=this.getVerticesData(wi.MatricesIndicesExtraKind),b=0;for(c=0;c=g||T<0)&&b++}return{skinned:!0,valid:0===r&&0===a&&0===b,report:\"Number of Weights = \"+i/4+\"\\nMaximum influences = \"+o+\"\\nMissing Weights = \"+r+\"\\nNot Sorted = \"+n+\"\\nNot Normalized = \"+a+\"\\nWeightCounts = [\"+l+\"]\\nNumber of bones = \"+g+\"\\nBad Bone Indices = \"+b}},t.prototype._checkDelayState=function(){var e=this.getScene();return this._geometry?this._geometry.load(e):this.delayLoadState===a.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=a.DELAYLOADSTATE_LOADING,this._queueLoad(e)),this},t.prototype._queueLoad=function(e){var t=this;e.addPendingData(this);var i=-1!==this.delayLoadingFile.indexOf(\".babylonbinarymeshdata\");return mi.LoadFile(this.delayLoadingFile,(function(i){i instanceof ArrayBuffer?t._delayLoadingFunction(i,t):t._delayLoadingFunction(JSON.parse(i),t),t.instances.forEach((function(e){e.refreshBoundingInfo(),e._syncSubMeshes()})),t.delayLoadState=a.DELAYLOADSTATE_LOADED,e.removePendingData(t)}),(function(){}),e.offlineProvider,i),this},t.prototype.isInFrustum=function(t){return this.delayLoadState!==a.DELAYLOADSTATE_LOADING&&!!e.prototype.isInFrustum.call(this,t)&&(this._checkDelayState(),!0)},t.prototype.setMaterialById=function(e){var t,i=this.getScene().materials;for(t=i.length-1;t>-1;t--)if(i[t].id===e)return this.material=i[t],this;var n=this.getScene().multiMaterials;for(t=n.length-1;t>-1;t--)if(n[t].id===e)return this.material=n[t],this;return this},t.prototype.getAnimatables=function(){var e=new Array;return this.material&&e.push(this.material),this.skeleton&&e.push(this.skeleton),e},t.prototype.bakeTransformIntoVertices=function(e){if(!this.isVerticesDataPresent(wi.PositionKind))return this;var t=this.subMeshes.splice(0);this._resetPointsArrayCache();var i,n=this.getVerticesData(wi.PositionKind),r=new Array;for(i=0;i-1&&(r.morphTargetManager=i.getMorphTargetManagerById(e.morphTargetManagerId)),void 0!==e.skeletonId&&null!==e.skeletonId&&(r.skeleton=i.getLastSkeletonById(e.skeletonId),e.numBoneInfluencers&&(r.numBoneInfluencers=e.numBoneInfluencers)),e.animations){for(var o=0;o4,u=c?this.getVerticesData(wi.MatricesIndicesExtraKind):null,h=c?this.getVerticesData(wi.MatricesWeightsExtraKind):null,d=e.getTransformMatrices(this),p=x.Zero(),f=new M,_=new M,m=0,g=0;g0&&(M.FromFloat32ArrayToRefScaled(d,Math.floor(16*a[m+l]),v,_),f.addToSelf(_));if(c)for(l=0;l<4;l++)(v=h[m+l])>0&&(M.FromFloat32ArrayToRefScaled(d,Math.floor(16*u[m+l]),v,_),f.addToSelf(_));x.TransformCoordinatesFromFloatsToRef(i._sourcePositions[g],i._sourcePositions[g+1],i._sourcePositions[g+2],f,p),p.toArray(r,g),t&&(x.TransformNormalFromFloatsToRef(i._sourceNormals[g],i._sourceNormals[g+1],i._sourceNormals[g+2],f,p),p.toArray(o,g)),f.reset()}return this.updateVerticesData(wi.PositionKind,r),t&&this.updateVerticesData(wi.NormalKind,o),this},t.MinMax=function(e){var t=null,i=null;return e.forEach((function(e){var n=e.getBoundingInfo().boundingBox;t&&i?(t.minimizeInPlace(n.minimumWorld),i.maximizeInPlace(n.maximumWorld)):(t=n.minimumWorld,i=n.maximumWorld)})),t&&i?{min:t,max:i}:{min:x.Zero(),max:x.Zero()}},t.Center=function(e){var i=e instanceof Array?t.MinMax(e):e;return x.Center(i.min,i.max)},t.MergeMeshes=function(e,i,n,r,o,a){return void 0===i&&(i=!0),Qn(t._MergeMeshesCoroutine(e,i,n,r,o,a,!1))},t.MergeMeshesAsync=function(e,i,n,r,o,a){return void 0===i&&(i=!0),qn(t._MergeMeshesCoroutine(e,i,n,r,o,a,!0),Yn())},t._MergeMeshesCoroutine=function(e,i,n,r,o,a,s){var l,c,u,h,d,p,f,_,m,g,v,y,b,T,E,S,A,R,x,C,P,M,I,O,D,N;return void 0===i&&(i=!0),W(this,(function(L){switch(L.label){case 0:if(0===(e=e.filter(Boolean)).length)return[2,null];if(!n)for(c=0,l=0;l=65536)return Q.Warn(\"Cannot merge meshes because resulting mesh will have more than 65536 vertices. Please use allow32BitsIndices = true to use 32 bits indices\"),[2,null];for(a&&(o=!1),u=new Array,h=new Array,d=new Array,p=e[0].overrideMaterialSideOrientation,l=0;l-1&&t.animations.splice(o,1)}},r=0,o=e.animations;r0&&(_=!0,this._soundLoaded(i));break;case\"AudioBuffer\":this._audioBufferLoaded(i);break;case\"String\":f.push(i);case\"Array\":0===f.length&&(f=i);for(var m=function(e){var t=f[e];if(_=o&&o.skipCodecCheck||-1!==t.indexOf(\".mp3\",t.length-4)&&vr.audioEngine.isMP3supported||-1!==t.indexOf(\".ogg\",t.length-4)&&vr.audioEngine.isOGGsupported||-1!==t.indexOf(\".wav\",t.length-4)||-1!==t.indexOf(\".m4a\",t.length-4)||-1!==t.indexOf(\".mp4\",t.length-4)||-1!==t.indexOf(\"blob:\"))return g._streaming?(g._htmlAudioElement=new Audio(t),g._htmlAudioElement.controls=!1,g._htmlAudioElement.loop=g.loop,mi.SetCorsBehavior(t,g._htmlAudioElement),g._htmlAudioElement.preload=\"auto\",g._htmlAudioElement.addEventListener(\"canplaythrough\",(function(){d._isReadyToPlay=!0,d.autoplay&&d.play(0,d._offset,d._length),d._readyToPlayCallback&&d._readyToPlayCallback()})),document.body.appendChild(g._htmlAudioElement),g._htmlAudioElement.load()):g._scene._loadFile(t,(function(e){d._soundLoaded(e)}),void 0,!0,!0,(function(e){e&&Q.Error(\"XHR \"+e.status+\" error on: \"+t+\".\"),Q.Error(\"Sound creation aborted.\"),d._scene.mainSoundTrack.removeSound(d)})),\"break\"},g=this,v=0;v0&&(this._htmlAudioElement.currentTime=0)):this._streamingSource.disconnect(),this.isPlaying=!1;else if((null===(t=vr.audioEngine)||void 0===t?void 0:t.audioContext)&&this._soundSource){var n=e?vr.audioEngine.audioContext.currentTime+e:void 0;this._soundSource.stop(n),void 0===n?(this.isPlaying=!1,this._soundSource.onended=function(){}):this._soundSource.onended=function(){i.isPlaying=!1},this.isPaused||(this._startOffset=0)}},e.prototype.pause=function(){var e;this.isPlaying&&(this.isPaused=!0,this._streaming?(this._htmlAudioElement?this._htmlAudioElement.pause():this._streamingSource.disconnect(),this.isPlaying=!1):(null===(e=vr.audioEngine)||void 0===e?void 0:e.audioContext)&&(this.stop(0),this._startOffset+=vr.audioEngine.audioContext.currentTime-this._startTime))},e.prototype.setVolume=function(e,t){var i;(null===(i=vr.audioEngine)||void 0===i?void 0:i.canUseWebAudio)&&this._soundGain&&(t&&vr.audioEngine.audioContext?(this._soundGain.gain.cancelScheduledValues(vr.audioEngine.audioContext.currentTime),this._soundGain.gain.setValueAtTime(this._soundGain.gain.value,vr.audioEngine.audioContext.currentTime),this._soundGain.gain.linearRampToValueAtTime(e,vr.audioEngine.audioContext.currentTime+t)):this._soundGain.gain.value=e),this._volume=e},e.prototype.setPlaybackRate=function(e){this._playbackRate=e,this.isPlaying&&(this._streaming&&this._htmlAudioElement?this._htmlAudioElement.playbackRate=this._playbackRate:this._soundSource&&(this._soundSource.playbackRate.value=this._playbackRate))},e.prototype.getVolume=function(){return this._volume},e.prototype.attachToMesh=function(e){var t=this;this._connectedTransformNode&&this._registerFunc&&(this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc),this._registerFunc=null),this._connectedTransformNode=e,this._spatialSound||(this._spatialSound=!0,this._createSpatialParameters(),this.isPlaying&&this.loop&&(this.stop(),this.play(0,this._offset,this._length))),this._onRegisterAfterWorldMatrixUpdate(this._connectedTransformNode),this._registerFunc=function(e){return t._onRegisterAfterWorldMatrixUpdate(e)},this._connectedTransformNode.registerAfterWorldMatrixUpdate(this._registerFunc)},e.prototype.detachFromMesh=function(){this._connectedTransformNode&&this._registerFunc&&(this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc),this._registerFunc=null,this._connectedTransformNode=null)},e.prototype._onRegisterAfterWorldMatrixUpdate=function(e){var t;if(e.getBoundingInfo){var i=e.getBoundingInfo();this.setPosition(i.boundingSphere.centerWorld)}else this.setPosition(e.absolutePosition);(null===(t=vr.audioEngine)||void 0===t?void 0:t.canUseWebAudio)&&this._isDirectional&&this.isPlaying&&this._updateDirection()},e.prototype.clone=function(){var t=this;if(this._streaming)return null;var i=function(){t._isReadyToPlay?(r._audioBuffer=t.getAudioBuffer(),r._isReadyToPlay=!0,r.autoplay&&r.play(0,t._offset,t._length)):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 e(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},e.prototype.getAudioBuffer=function(){return this._audioBuffer},e.prototype.getSoundSource=function(){return this._soundSource},e.prototype.getSoundGain=function(){return this._soundGain},e.prototype.serialize=function(){var e={name:this.name,url:this.name,autoplay:this.autoplay,loop:this.loop,volume:this._volume,spatialSound:this._spatialSound,maxDistance:this.maxDistance,rolloffFactor:this.rolloffFactor,refDistance:this.refDistance,distanceModel:this.distanceModel,playbackRate:this._playbackRate,panningModel:this._panningModel,soundTrackId:this.soundTrackId,metadata:this.metadata};return this._spatialSound&&(this._connectedTransformNode&&(e.connectedMeshId=this._connectedTransformNode.id),e.position=this._position.asArray(),e.refDistance=this.refDistance,e.distanceModel=this.distanceModel,e.isDirectional=this._isDirectional,e.localDirectionToMesh=this._localDirection.asArray(),e.coneInnerAngle=this._coneInnerAngle,e.coneOuterAngle=this._coneOuterAngle,e.coneOuterGain=this._coneOuterGain),e},e.Parse=function(t,i,n,r){var o,a=t.name;o=t.url?n+t.url:n+a;var s,l={autoplay:t.autoplay,loop:t.loop,volume:t.volume,spatialSound:t.spatialSound,maxDistance:t.maxDistance,rolloffFactor:t.rolloffFactor,refDistance:t.refDistance,distanceModel:t.distanceModel,playbackRate:t.playbackRate};if(r){var c=function(){r._isReadyToPlay?(s._audioBuffer=r.getAudioBuffer(),s._isReadyToPlay=!0,s.autoplay&&s.play(0,s._offset,s._length)):window.setTimeout(c,300)};s=new e(a,new ArrayBuffer(0),i,null,l),c()}else s=new e(a,o,i,(function(){i.removePendingData(s)}),l),i.addPendingData(s);if(t.position){var u=x.FromArray(t.position);s.setPosition(u)}if(t.isDirectional&&(s.setDirectionalCone(t.coneInnerAngle||360,t.coneOuterAngle||360,t.coneOuterGain||0),t.localDirectionToMesh)){var h=x.FromArray(t.localDirectionToMesh);s.setLocalDirectionToMesh(h)}if(t.connectedMeshId){var d=i.getMeshById(t.connectedMeshId);d&&s.attachToMesh(d)}return t.metadata&&(s.metadata=t.metadata),s},e._SceneComponentInitialization=function(e){throw pe(\"AudioSceneComponent\")},e}(),Xr=function(){function e(e,t){void 0===t&&(t={}),this.id=-1,this._isInitialized=!1,(e=e||S.LastCreatedScene)&&(this._scene=e,this.soundCollection=new Array,this._options=t,!this._options.mainTrack&&this._scene.soundTracks&&(this._scene.soundTracks.push(this),this.id=this._scene.soundTracks.length-1))}return e.prototype._initializeSoundTrackAudioGraph=function(){var e;(null===(e=vr.audioEngine)||void 0===e?void 0:e.canUseWebAudio)&&vr.audioEngine.audioContext&&(this._outputAudioNode=vr.audioEngine.audioContext.createGain(),this._outputAudioNode.connect(vr.audioEngine.masterGain),this._options&&this._options.volume&&(this._outputAudioNode.gain.value=this._options.volume),this._isInitialized=!0)},e.prototype.dispose=function(){if(vr.audioEngine&&vr.audioEngine.canUseWebAudio){for(this._connectedAnalyser&&this._connectedAnalyser.stopDebugCanvas();this.soundCollection.length;)this.soundCollection[0].dispose();this._outputAudioNode&&this._outputAudioNode.disconnect(),this._outputAudioNode=null}},e.prototype.addSound=function(e){var t;this._isInitialized||this._initializeSoundTrackAudioGraph(),(null===(t=vr.audioEngine)||void 0===t?void 0:t.canUseWebAudio)&&this._outputAudioNode&&e.connectToSoundTrackAudioNode(this._outputAudioNode),e.soundTrackId&&(-1===e.soundTrackId?this._scene.mainSoundTrack.removeSound(e):this._scene.soundTracks&&this._scene.soundTracks[e.soundTrackId].removeSound(e)),this.soundCollection.push(e),e.soundTrackId=this.id},e.prototype.removeSound=function(e){var t=this.soundCollection.indexOf(e);-1!==t&&this.soundCollection.splice(t,1)},e.prototype.setVolume=function(e){var t;(null===(t=vr.audioEngine)||void 0===t?void 0:t.canUseWebAudio)&&this._outputAudioNode&&(this._outputAudioNode.gain.value=e)},e.prototype.switchPanningModelToHRTF=function(){var e;if(null===(e=vr.audioEngine)||void 0===e?void 0:e.canUseWebAudio)for(var t=0;t0?i.activeCameras[0]:i.activeCamera)?(this._cachedCameraPosition.equals(o.globalPosition)||(this._cachedCameraPosition.copyFrom(o.globalPosition),n.audioContext.listener.setPosition(o.globalPosition.x,o.globalPosition.y,o.globalPosition.z)),o.rigCameras&&o.rigCameras.length>0&&(o=o.rigCameras[0]),o.getViewMatrix().invertToRef(this._invertMatrixTemp),x.TransformNormalToRef(e._CameraDirection,this._invertMatrixTemp,this._cameraDirectionTemp),this._cameraDirectionTemp.normalize(),isNaN(this._cameraDirectionTemp.x)||isNaN(this._cameraDirectionTemp.y)||isNaN(this._cameraDirectionTemp.z)||this._cachedCameraDirection.equals(this._cameraDirectionTemp)||(this._cachedCameraDirection.copyFrom(this._cameraDirectionTemp),n.audioContext.listener.setOrientation(this._cameraDirectionTemp.x,this._cameraDirectionTemp.y,this._cameraDirectionTemp.z,0,1,0))):n.audioContext.listener.setPosition(0,0,0)}var a=void 0;for(a=0;a0?1/r:0,l=0;l=0&&this._scene.textures.splice(t,1),this._scene.onTextureRemovedObservable.notifyObservers(this),this._scene=null,this._parentContainer){var i=this._parentContainer.textures.indexOf(this);i>-1&&this._parentContainer.textures.splice(i,1),this._parentContainer=null}}this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.metadata=null,e.prototype.dispose.call(this)},t.prototype.serialize=function(){if(!this.name)return null;var e=Le.Serialize(this);return Le.AppendSerializedAnimations(this,e),e},t.WhenAllReady=function(e,t){var i=e.length;if(0!==i)for(var n=0;n=0;){var s=e[o];s<0?s=0:s>1&&(s=1),a[o]=255*s}e=a}var l=document.createElement(\"canvas\");l.width=n,l.height=r;var c=l.getContext(\"2d\");if(!c)return null;var u=c.createImageData(n,r);if(u.data.set(e),c.putImageData(u,0,0),i){var h=document.createElement(\"canvas\");h.width=n,h.height=r;var d=h.getContext(\"2d\");return d?(d.translate(0,r),d.scale(1,-1),d.drawImage(l,0,0),h.toDataURL(\"image/png\")):null}return l.toDataURL(\"image/png\")}function Jr(e,t,i){void 0===t&&(t=0),void 0===i&&(i=0);var n=e.getInternalTexture();if(!n)return null;var r=e._readPixelsSync(t,i);return r?Zr(r,e.getSize(),n.invertY):null}function $r(e,t,i){return void 0===t&&(t=0),void 0===i&&(i=0),z(this,void 0,void 0,(function(){var n,r;return W(this,(function(o){switch(o.label){case 0:return(n=e.getInternalTexture())?[4,e.readPixels(t,i)]:[2,null];case 1:return(r=o.sent())?[2,Zr(r,e.getSize(),n.invertY)]:[2,null]}}))}))}var eo={GenerateBase64StringFromPixelData:Zr,GenerateBase64StringFromTexture:Jr,GenerateBase64StringFromTextureAsync:$r},to=function(e){function t(i,n,r,o,s,l,c,h,d,p,f,_,m,g){void 0===s&&(s=t.TRILINEAR_SAMPLINGMODE),void 0===l&&(l=null),void 0===c&&(c=null),void 0===h&&(h=null),void 0===d&&(d=!1);var v,y,b,T,E,S,A,R,x,C,P=this;(P=e.call(this,n)||this).url=null,P.uOffset=0,P.vOffset=0,P.uScale=1,P.vScale=1,P.uAng=0,P.vAng=0,P.wAng=0,P.uRotationCenter=.5,P.vRotationCenter=.5,P.wRotationCenter=.5,P.homogeneousRotationInUVTransform=!1,P.inspectableCustomProperties=null,P._noMipmap=!1,P._invertY=!1,P._rowGenerationMatrix=null,P._cachedTextureMatrix=null,P._projectionModeMatrix=null,P._t0=null,P._t1=null,P._t2=null,P._cachedUOffset=-1,P._cachedVOffset=-1,P._cachedUScale=0,P._cachedVScale=0,P._cachedUAng=-1,P._cachedVAng=-1,P._cachedWAng=-1,P._cachedProjectionMatrixId=-1,P._cachedURotationCenter=-1,P._cachedVRotationCenter=-1,P._cachedWRotationCenter=-1,P._cachedHomogeneousRotationInUVTransform=!1,P._cachedCoordinatesMode=-1,P._buffer=null,P._deleteBuffer=!1,P._format=null,P._delayedOnLoad=null,P._delayedOnError=null,P.onLoadObservable=new u,P._isBlocking=!0,P.name=i||\"\",P.url=i;var M=!1,I=null;\"object\"==typeof r&&null!==r?(C=null!==(v=r.noMipmap)&&void 0!==v&&v,o=null!==(y=r.invertY)&&void 0!==y?y:!pr.UseOpenGLOrientationForUV,s=null!==(b=r.samplingMode)&&void 0!==b?b:t.TRILINEAR_SAMPLINGMODE,l=null!==(T=r.onLoad)&&void 0!==T?T:null,c=null!==(E=r.onError)&&void 0!==E?E:null,h=null!==(S=r.buffer)&&void 0!==S?S:null,d=null!==(A=r.deleteBuffer)&&void 0!==A&&A,p=r.format,f=r.mimeType,_=r.loaderOptions,m=r.creationFlags,M=null!==(R=r.useSRGBBuffer)&&void 0!==R&&R,I=null!==(x=r.internalTexture)&&void 0!==x?x:null):C=!!r,P._noMipmap=C,P._invertY=void 0===o?!pr.UseOpenGLOrientationForUV:o,P._initialSamplingMode=s,P._buffer=h,P._deleteBuffer=d,P._mimeType=f,P._loaderOptions=_,P._creationFlags=m,P._useSRGBBuffer=M,P._forcedExtension=g,p&&(P._format=p);var O=P.getScene(),D=P._getEngine();if(!D)return P;D.onBeforeTextureInitObservable.notifyObservers(P);var N=function(){P._texture&&(P._texture._invertVScale&&(P.vScale*=-1,P.vOffset+=1),null!==P._texture._cachedWrapU&&(P.wrapU=P._texture._cachedWrapU,P._texture._cachedWrapU=null),null!==P._texture._cachedWrapV&&(P.wrapV=P._texture._cachedWrapV,P._texture._cachedWrapV=null),null!==P._texture._cachedWrapR&&(P.wrapR=P._texture._cachedWrapR,P._texture._cachedWrapR=null)),P.onLoadObservable.hasObservers()&&P.onLoadObservable.notifyObservers(P),l&&l(),!P.isBlocking&&O&&O.resetCachedMaterial()},L=function(e,i){P._loadingError=!0,P._errorObject={message:e,exception:i},c&&c(e,i),t.OnTextureLoadErrorObservable.notifyObservers(P)};if(!P.url)return P._delayedOnLoad=N,P._delayedOnError=L,P;if(P._texture=null!=I?I:P._getFromCache(P.url,C,s,P._invertY,M),P._texture)if(P._texture.isReady)Kt.SetImmediate((function(){return N()}));else{var F=P._texture.onLoadedObservable.add(N);P._texture.onErrorObservable.add((function(e){var t;L(e.message,e.exception),null===(t=P._texture)||void 0===t||t.onLoadedObservable.remove(F)}))}else if(O&&O.useDelayedTextureLoading)P.delayLoadState=a.DELAYLOADSTATE_NOTLOADED,P._delayedOnLoad=N,P._delayedOnError=L;else{try{P._texture=D.createTexture(P.url,C,P._invertY,O,s,N,L,P._buffer,void 0,P._format,P._forcedExtension,f,_,m,M)}catch(e){throw L(\"error loading\",e),e}d&&(P._buffer=null)}return P}return V(t,e),Object.defineProperty(t.prototype,\"noMipmap\",{get:function(){return this._noMipmap},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"mimeType\",{get:function(){return this._mimeType},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"isBlocking\",{get:function(){return this._isBlocking},set:function(e){this._isBlocking=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"invertY\",{get:function(){return this._invertY},enumerable:!1,configurable:!0}),t.prototype.updateURL=function(e,t,i,n){void 0===t&&(t=null),this.url&&(this.releaseInternalTexture(),this.getScene().markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag)),this.name&&!this.name.startsWith(\"data:\")||(this.name=e),this.url=e,this._buffer=t,this._forcedExtension=n,this.delayLoadState=a.DELAYLOADSTATE_NOTLOADED,i&&(this._delayedOnLoad=i),this.delayLoad()},t.prototype.delayLoad=function(){if(this.delayLoadState===a.DELAYLOADSTATE_NOTLOADED){var e=this.getScene();e&&(this.delayLoadState=a.DELAYLOADSTATE_LOADED,this._texture=this._getFromCache(this.url,this._noMipmap,this.samplingMode,this._invertY,this._useSRGBBuffer),this._texture?this._delayedOnLoad&&(this._texture.isReady?Kt.SetImmediate(this._delayedOnLoad):this._texture.onLoadedObservable.add(this._delayedOnLoad)):(this._texture=e.getEngine().createTexture(this.url,this._noMipmap,this._invertY,e,this.samplingMode,this._delayedOnLoad,this._delayedOnError,this._buffer,null,this._format,this._forcedExtension,this._mimeType,this._loaderOptions,this._creationFlags,this._useSRGBBuffer),this._deleteBuffer&&(this._buffer=null)),this._delayedOnLoad=null,this._delayedOnError=null)}},t.prototype._prepareRowForTextureGeneration=function(e,t,i,n){e*=this._cachedUScale,t*=this._cachedVScale,e-=this.uRotationCenter*this._cachedUScale,t-=this.vRotationCenter*this._cachedVScale,i-=this.wRotationCenter,x.TransformCoordinatesFromFloatsToRef(e,t,i,this._rowGenerationMatrix,n),n.x+=this.uRotationCenter*this._cachedUScale+this._cachedUOffset,n.y+=this.vRotationCenter*this._cachedVScale+this._cachedVOffset,n.z+=this.wRotationCenter},t.prototype.checkTransformsAreIdentical=function(e){return null!==e&&this.uOffset===e.uOffset&&this.vOffset===e.vOffset&&this.uScale===e.uScale&&this.vScale===e.vScale&&this.uAng===e.uAng&&this.vAng===e.vAng&&this.wAng===e.wAng},t.prototype.getTextureMatrix=function(e){var t=this;if(void 0===e&&(e=1),this.uOffset===this._cachedUOffset&&this.vOffset===this._cachedVOffset&&this.uScale*e===this._cachedUScale&&this.vScale===this._cachedVScale&&this.uAng===this._cachedUAng&&this.vAng===this._cachedVAng&&this.wAng===this._cachedWAng&&this.uRotationCenter===this._cachedURotationCenter&&this.vRotationCenter===this._cachedVRotationCenter&&this.wRotationCenter===this._cachedWRotationCenter&&this.homogeneousRotationInUVTransform===this._cachedHomogeneousRotationInUVTransform)return this._cachedTextureMatrix;this._cachedUOffset=this.uOffset,this._cachedVOffset=this.vOffset,this._cachedUScale=this.uScale*e,this._cachedVScale=this.vScale,this._cachedUAng=this.uAng,this._cachedVAng=this.vAng,this._cachedWAng=this.wAng,this._cachedURotationCenter=this.uRotationCenter,this._cachedVRotationCenter=this.vRotationCenter,this._cachedWRotationCenter=this.wRotationCenter,this._cachedHomogeneousRotationInUVTransform=this.homogeneousRotationInUVTransform,this._cachedTextureMatrix&&this._rowGenerationMatrix||(this._cachedTextureMatrix=M.Zero(),this._rowGenerationMatrix=new M,this._t0=x.Zero(),this._t1=x.Zero(),this._t2=x.Zero()),M.RotationYawPitchRollToRef(this.vAng,this.uAng,this.wAng,this._rowGenerationMatrix),this.homogeneousRotationInUVTransform?(M.TranslationToRef(-this._cachedURotationCenter,-this._cachedVRotationCenter,-this._cachedWRotationCenter,O.Matrix[0]),M.TranslationToRef(this._cachedURotationCenter,this._cachedVRotationCenter,this._cachedWRotationCenter,O.Matrix[1]),M.ScalingToRef(this._cachedUScale,this._cachedVScale,0,O.Matrix[2]),M.TranslationToRef(this._cachedUOffset,this._cachedVOffset,0,O.Matrix[3]),O.Matrix[0].multiplyToRef(this._rowGenerationMatrix,this._cachedTextureMatrix),this._cachedTextureMatrix.multiplyToRef(O.Matrix[1],this._cachedTextureMatrix),this._cachedTextureMatrix.multiplyToRef(O.Matrix[2],this._cachedTextureMatrix),this._cachedTextureMatrix.multiplyToRef(O.Matrix[3],this._cachedTextureMatrix),this._cachedTextureMatrix.setRowFromFloats(2,this._cachedTextureMatrix.m[12],this._cachedTextureMatrix.m[13],this._cachedTextureMatrix.m[14],1)):(this._prepareRowForTextureGeneration(0,0,0,this._t0),this._prepareRowForTextureGeneration(1,0,0,this._t1),this._prepareRowForTextureGeneration(0,1,0,this._t2),this._t1.subtractInPlace(this._t0),this._t2.subtractInPlace(this._t0),M.FromValuesToRef(this._t1.x,this._t1.y,this._t1.z,0,this._t2.x,this._t2.y,this._t2.z,0,this._t0.x,this._t0.y,this._t0.z,0,0,0,0,1,this._cachedTextureMatrix));var i=this.getScene();return i?(this.optimizeUVAllocation&&i.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag,(function(e){return e.hasTexture(t)})),this._cachedTextureMatrix):this._cachedTextureMatrix},t.prototype.getReflectionTextureMatrix=function(){var e=this,i=this.getScene();if(!i)return this._cachedTextureMatrix;if(this.uOffset===this._cachedUOffset&&this.vOffset===this._cachedVOffset&&this.uScale===this._cachedUScale&&this.vScale===this._cachedVScale&&this.coordinatesMode===this._cachedCoordinatesMode){if(this.coordinatesMode!==t.PROJECTION_MODE)return this._cachedTextureMatrix;if(this._cachedProjectionMatrixId===i.getProjectionMatrix().updateFlag)return this._cachedTextureMatrix}this._cachedTextureMatrix||(this._cachedTextureMatrix=M.Zero()),this._projectionModeMatrix||(this._projectionModeMatrix=M.Zero());var n=this._cachedCoordinatesMode!==this.coordinatesMode;switch(this._cachedUOffset=this.uOffset,this._cachedVOffset=this.vOffset,this._cachedUScale=this.uScale,this._cachedVScale=this.vScale,this._cachedCoordinatesMode=this.coordinatesMode,this.coordinatesMode){case t.PLANAR_MODE:M.IdentityToRef(this._cachedTextureMatrix),this._cachedTextureMatrix[0]=this.uScale,this._cachedTextureMatrix[5]=this.vScale,this._cachedTextureMatrix[12]=this.uOffset,this._cachedTextureMatrix[13]=this.vOffset;break;case t.PROJECTION_MODE:M.FromValuesToRef(.5,0,0,0,0,-.5,0,0,0,0,0,0,.5,.5,1,1,this._projectionModeMatrix);var r=i.getProjectionMatrix();this._cachedProjectionMatrixId=r.updateFlag,r.multiplyToRef(this._projectionModeMatrix,this._cachedTextureMatrix);break;default:M.IdentityToRef(this._cachedTextureMatrix)}return n&&i.markAllMaterialsAsDirty(a.MATERIAL_TextureDirtyFlag,(function(t){return-1!==t.getActiveTextures().indexOf(e)})),this._cachedTextureMatrix},t.prototype.clone=function(){var e=this,i={noMipmap:this._noMipmap,invertY:this._invertY,samplingMode:this.samplingMode,onLoad:void 0,onError:void 0,buffer:this._texture?this._texture._buffer:void 0,deleteBuffer:this._deleteBuffer,format:this.textureFormat,mimeType:this.mimeType,loaderOptions:this._loaderOptions,creationFlags:this._creationFlags,useSRGBBuffer:this._useSRGBBuffer};return Le.Clone((function(){return new t(e._texture?e._texture.url:null,e.getScene(),i)}),this)},t.prototype.serialize=function(){var i=this.name;t.SerializeBuffers||this.name.startsWith(\"data:\")&&(this.name=\"\"),this.name.startsWith(\"data:\")&&this.url===this.name&&(this.url=\"\");var n=e.prototype.serialize.call(this);return n?((t.SerializeBuffers||t.ForceSerializeBuffers)&&(\"string\"==typeof this._buffer&&\"data:\"===this._buffer.substr(0,5)?(n.base64String=this._buffer,n.name=n.name.replace(\"data:\",\"\")):this.url&&this.url.startsWith(\"data:\")&&this._buffer instanceof Uint8Array?n.base64String=\"data:image/png;base64,\"+ht(this._buffer):(t.ForceSerializeBuffers||this.url&&this.url.startsWith(\"blob:\")||this._forceSerialize)&&(n.base64String=!this._engine||this._engine._features.supportSyncTextureRead?Jr(this):$r(this))),n.invertY=this._invertY,n.samplingMode=this.samplingMode,n._creationFlags=this._creationFlags,n._useSRGBBuffer=this._useSRGBBuffer,this.name=i,n):null},t.prototype.getClassName=function(){return\"Texture\"},t.prototype.dispose=function(){e.prototype.dispose.call(this),this.onLoadObservable.clear(),this._delayedOnLoad=null,this._delayedOnError=null},t.Parse=function(e,i,n){if(e.customType){var r=pi.Instantiate(e.customType).Parse(e,i,n);return e.samplingMode&&r.updateSamplingMode&&r._samplingMode&&r._samplingMode!==e.samplingMode&&r.updateSamplingMode(e.samplingMode),r}if(e.isCube&&!e.isRenderTarget)return t._CubeTextureParser(e,i,n);if(!e.name&&!e.isRenderTarget)return null;var o=function(t){if(t&&t._texture&&(t._texture._cachedWrapU=null,t._texture._cachedWrapV=null,t._texture._cachedWrapR=null),e.samplingMode){var i=e.samplingMode;t&&t.samplingMode!==i&&t.updateSamplingMode(i)}if(t&&e.animations)for(var n=0;n0?e.name:n+e.name,e.url&&(e.url.startsWith(\"data:\")||t.UseSerializedUrlIfAny)&&(f=e.url),l=new t(f,i,!c,e.invertY,e.samplingMode,(function(){o(l)}))}return l}),e,i);return a},t.CreateFromBase64String=function(e,i,n,r,o,s,l,c,u,h){return void 0===s&&(s=t.TRILINEAR_SAMPLINGMODE),void 0===l&&(l=null),void 0===c&&(c=null),void 0===u&&(u=a.TEXTUREFORMAT_RGBA),new t(\"data:\"+i,n,r,o,s,l,c,e,!1,u,void 0,void 0,h)},t.LoadFromDataString=function(e,i,n,r,o,s,l,c,u,h,d){return void 0===r&&(r=!1),void 0===s&&(s=!0),void 0===l&&(l=t.TRILINEAR_SAMPLINGMODE),void 0===c&&(c=null),void 0===u&&(u=null),void 0===h&&(h=a.TEXTUREFORMAT_RGBA),\"data:\"!==e.substr(0,5)&&(e=\"data:\"+e),new t(e,n,o,s,l,c,u,i,r,h,void 0,void 0,d)},t.SerializeBuffers=!0,t.ForceSerializeBuffers=!1,t.OnTextureLoadErrorObservable=new u,t._CubeTextureParser=function(e,t,i){throw pe(\"CubeTexture\")},t._CreateMirror=function(e,t,i,n){throw pe(\"MirrorTexture\")},t._CreateRenderTargetTexture=function(e,t,i,n,r){throw pe(\"RenderTargetTexture\")},t.NEAREST_SAMPLINGMODE=a.TEXTURE_NEAREST_SAMPLINGMODE,t.NEAREST_NEAREST_MIPLINEAR=a.TEXTURE_NEAREST_NEAREST_MIPLINEAR,t.BILINEAR_SAMPLINGMODE=a.TEXTURE_BILINEAR_SAMPLINGMODE,t.LINEAR_LINEAR_MIPNEAREST=a.TEXTURE_LINEAR_LINEAR_MIPNEAREST,t.TRILINEAR_SAMPLINGMODE=a.TEXTURE_TRILINEAR_SAMPLINGMODE,t.LINEAR_LINEAR_MIPLINEAR=a.TEXTURE_LINEAR_LINEAR_MIPLINEAR,t.NEAREST_NEAREST_MIPNEAREST=a.TEXTURE_NEAREST_NEAREST_MIPNEAREST,t.NEAREST_LINEAR_MIPNEAREST=a.TEXTURE_NEAREST_LINEAR_MIPNEAREST,t.NEAREST_LINEAR_MIPLINEAR=a.TEXTURE_NEAREST_LINEAR_MIPLINEAR,t.NEAREST_LINEAR=a.TEXTURE_NEAREST_LINEAR,t.NEAREST_NEAREST=a.TEXTURE_NEAREST_NEAREST,t.LINEAR_NEAREST_MIPNEAREST=a.TEXTURE_LINEAR_NEAREST_MIPNEAREST,t.LINEAR_NEAREST_MIPLINEAR=a.TEXTURE_LINEAR_NEAREST_MIPLINEAR,t.LINEAR_LINEAR=a.TEXTURE_LINEAR_LINEAR,t.LINEAR_NEAREST=a.TEXTURE_LINEAR_NEAREST,t.EXPLICIT_MODE=a.TEXTURE_EXPLICIT_MODE,t.SPHERICAL_MODE=a.TEXTURE_SPHERICAL_MODE,t.PLANAR_MODE=a.TEXTURE_PLANAR_MODE,t.CUBIC_MODE=a.TEXTURE_CUBIC_MODE,t.PROJECTION_MODE=a.TEXTURE_PROJECTION_MODE,t.SKYBOX_MODE=a.TEXTURE_SKYBOX_MODE,t.INVCUBIC_MODE=a.TEXTURE_INVCUBIC_MODE,t.EQUIRECTANGULAR_MODE=a.TEXTURE_EQUIRECTANGULAR_MODE,t.FIXED_EQUIRECTANGULAR_MODE=a.TEXTURE_FIXED_EQUIRECTANGULAR_MODE,t.FIXED_EQUIRECTANGULAR_MIRRORED_MODE=a.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE,t.CLAMP_ADDRESSMODE=a.TEXTURE_CLAMP_ADDRESSMODE,t.WRAP_ADDRESSMODE=a.TEXTURE_WRAP_ADDRESSMODE,t.MIRROR_ADDRESSMODE=a.TEXTURE_MIRROR_ADDRESSMODE,t.UseSerializedUrlIfAny=!1,G([be()],t.prototype,\"url\",void 0),G([be()],t.prototype,\"uOffset\",void 0),G([be()],t.prototype,\"vOffset\",void 0),G([be()],t.prototype,\"uScale\",void 0),G([be()],t.prototype,\"vScale\",void 0),G([be()],t.prototype,\"uAng\",void 0),G([be()],t.prototype,\"vAng\",void 0),G([be()],t.prototype,\"wAng\",void 0),G([be()],t.prototype,\"uRotationCenter\",void 0),G([be()],t.prototype,\"vRotationCenter\",void 0),G([be()],t.prototype,\"wRotationCenter\",void 0),G([be()],t.prototype,\"homogeneousRotationInUVTransform\",void 0),G([be()],t.prototype,\"isBlocking\",null),t}(qr);function io(e,t,i,n){var r,o=1;n===a.TEXTURETYPE_FLOAT?r=new Float32Array(t*i*4):n===a.TEXTURETYPE_HALF_FLOAT?(r=new Uint16Array(t*i*4),o=15360):r=n===a.TEXTURETYPE_UNSIGNED_INTEGER?new Uint32Array(t*i*4):new Uint8Array(t*i*4);for(var s=0;s>v,b=0;b<6;b++){var T=g[v][b];m&&(T=io(T,y,y,r)),f.texImage2D(b,v,h,y,y,0,u,a,T)}p._bindTextureDirectly(f.TEXTURE_CUBE_MAP,null)}else p.updateRawCubeTexture(_,o,n,r,d);_.isReady=!0,null==t||t.removePendingData(_),_.onLoadedObservable.notifyObservers(_),_.onLoadedObservable.clear(),c&&c()}}(e)}),void 0,null==t?void 0:t.offlineProvider,!0,(function(e,i){null==t||t.removePendingData(_),u&&e&&u(e.status+\" \"+e.statusText,i)})),_},Yt.prototype.createRawTexture2DArray=no(!1),Yt.prototype.createRawTexture3D=no(!0),Yt.prototype.updateRawTexture2DArray=ro(!1),Yt.prototype.updateRawTexture3D=ro(!0);var oo=function(e){function t(t,i,n,r,o,s,l,c,u,h,d){void 0===s&&(s=!0),void 0===l&&(l=!1),void 0===c&&(c=a.TEXTURE_TRILINEAR_SAMPLINGMODE),void 0===u&&(u=a.TEXTURETYPE_UNSIGNED_INT);var p=e.call(this,null,o,!s,l,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,h)||this;return p.format=r,p._engine?(p._engine._caps.textureFloatLinearFiltering||u!==a.TEXTURETYPE_FLOAT||(c=a.TEXTURE_NEAREST_SAMPLINGMODE),p._engine._caps.textureHalfFloatLinearFiltering||u!==a.TEXTURETYPE_HALF_FLOAT||(c=a.TEXTURE_NEAREST_SAMPLINGMODE),p._texture=p._engine.createRawTexture(t,i,n,r,s,l,c,null,u,null!=h?h:0,null!=d&&d),p.wrapU=to.CLAMP_ADDRESSMODE,p.wrapV=to.CLAMP_ADDRESSMODE,p):p}return V(t,e),t.prototype.update=function(e){this._getEngine().updateRawTexture(this._texture,e,this._texture.format,this._texture.invertY,null,this._texture.type,this._texture._useSRGBBuffer)},t.CreateLuminanceTexture=function(e,i,n,r,o,s,l){return void 0===o&&(o=!0),void 0===s&&(s=!1),void 0===l&&(l=a.TEXTURE_TRILINEAR_SAMPLINGMODE),new t(e,i,n,a.TEXTUREFORMAT_LUMINANCE,r,o,s,l)},t.CreateLuminanceAlphaTexture=function(e,i,n,r,o,s,l){return void 0===o&&(o=!0),void 0===s&&(s=!1),void 0===l&&(l=a.TEXTURE_TRILINEAR_SAMPLINGMODE),new t(e,i,n,a.TEXTUREFORMAT_LUMINANCE_ALPHA,r,o,s,l)},t.CreateAlphaTexture=function(e,i,n,r,o,s,l){return void 0===o&&(o=!0),void 0===s&&(s=!1),void 0===l&&(l=a.TEXTURE_TRILINEAR_SAMPLINGMODE),new t(e,i,n,a.TEXTUREFORMAT_ALPHA,r,o,s,l)},t.CreateRGBTexture=function(e,i,n,r,o,s,l,c,u,h){return void 0===o&&(o=!0),void 0===s&&(s=!1),void 0===l&&(l=a.TEXTURE_TRILINEAR_SAMPLINGMODE),void 0===c&&(c=a.TEXTURETYPE_UNSIGNED_INT),void 0===u&&(u=0),void 0===h&&(h=!1),new t(e,i,n,a.TEXTUREFORMAT_RGB,r,o,s,l,c,u,h)},t.CreateRGBATexture=function(e,i,n,r,o,s,l,c,u,h){return void 0===o&&(o=!0),void 0===s&&(s=!1),void 0===l&&(l=a.TEXTURE_TRILINEAR_SAMPLINGMODE),void 0===c&&(c=a.TEXTURETYPE_UNSIGNED_INT),void 0===u&&(u=0),void 0===h&&(h=!1),new t(e,i,n,a.TEXTUREFORMAT_RGBA,r,o,s,l,c,u,h)},t.CreateRGBAStorageTexture=function(e,i,n,r,o,s,l,c,u){return void 0===o&&(o=!0),void 0===s&&(s=!1),void 0===l&&(l=a.TEXTURE_TRILINEAR_SAMPLINGMODE),void 0===c&&(c=a.TEXTURETYPE_UNSIGNED_INT),void 0===u&&(u=!1),new t(e,i,n,a.TEXTUREFORMAT_RGBA,r,o,s,l,c,a.TEXTURE_CREATIONFLAG_STORAGE,u)},t.CreateRTexture=function(e,i,n,r,o,s,l,c){return void 0===o&&(o=!0),void 0===s&&(s=!1),void 0===l&&(l=to.TRILINEAR_SAMPLINGMODE),void 0===c&&(c=a.TEXTURETYPE_FLOAT),new t(e,i,n,a.TEXTUREFORMAT_R,r,o,s,l,c)},t.CreateRStorageTexture=function(e,i,n,r,o,s,l,c){return void 0===o&&(o=!0),void 0===s&&(s=!1),void 0===l&&(l=to.TRILINEAR_SAMPLINGMODE),void 0===c&&(c=a.TEXTURETYPE_FLOAT),new t(e,i,n,a.TEXTUREFORMAT_R,r,o,s,l,c,a.TEXTURE_CREATIONFLAG_STORAGE)},t}(to),ao=function(){function e(e,t){this._scene=e,this._mesh=t}return e.prototype.bakeVertexData=function(e){return z(this,void 0,void 0,(function(){var t,i,n,r,o,a,s,l;return W(this,(function(c){switch(c.label){case 0:if(!this._mesh.skeleton)throw new Error(\"No skeleton in this mesh.\");if(t=this._mesh.skeleton.bones.length,i=e.reduce((function(e,t){return e+t.to-t.from+1}),0),isNaN(i))throw new Error(\"Invalid animation ranges.\");n=0,r=new Float32Array(4*(t+1)*4*i),this._scene.stopAnimation(this._mesh),this._mesh.skeleton.returnToRest(),o=0,a=e,c.label=1;case 1:if(!(o0},enumerable:!1,configurable:!0}),e.prototype.init=function(){},e.prototype.attach=function(e){var t=this;this._attachedCamera=e;var i=this._attachedCamera.getScene();this._onPrePointerObservableObserver=i.onPrePointerObservable.add((function(e){e.type!==Hi.POINTERDOWN?e.type===Hi.POINTERUP&&(t._isPointerDown=!1):t._isPointerDown=!0})),this._onAfterCheckInputsObserver=e.onAfterCheckInputsObservable.add((function(){if(!t._reachTargetAlpha()){var e=it.Now,i=0;null!=t._lastFrameTime&&(i=e-t._lastFrameTime),t._lastFrameTime=e,t._applyUserInteraction();var n=e-t._lastInteractionTime-t._idleRotationWaitTime,r=Math.max(Math.min(n/t._idleRotationSpinupTime,1),0);t._cameraRotationSpeed=t._idleRotationSpeed*r,t._attachedCamera&&(t._attachedCamera.alpha-=t._cameraRotationSpeed*(i/1e3))}}))},e.prototype.detach=function(){if(this._attachedCamera){var e=this._attachedCamera.getScene();this._onPrePointerObservableObserver&&e.onPrePointerObservable.remove(this._onPrePointerObservableObserver),this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),this._attachedCamera=null}},e.prototype.resetLastInteractionTime=function(e){this._lastInteractionTime=null!=e?e:it.Now},e.prototype._reachTargetAlpha=function(){return!(!this._attachedCamera||!this.targetAlpha)&&Math.abs(this._attachedCamera.alpha-this.targetAlpha)<_},e.prototype._userIsZooming=function(){return!!this._attachedCamera&&0!==this._attachedCamera.inertialRadiusOffset},e.prototype._shouldAnimationStopForInteraction=function(){if(!this._attachedCamera)return!1;var e=!1;return this._lastFrameRadius===this._attachedCamera.radius&&0!==this._attachedCamera.inertialRadiusOffset&&(e=!0),this._lastFrameRadius=this._attachedCamera.radius,this._zoomStopsAnimation?e:this._userIsZooming()},e.prototype._applyUserInteraction=function(){this._userIsMoving()&&!this._shouldAnimationStopForInteraction()&&(this._lastInteractionTime=it.Now)},e.prototype._userIsMoving=function(){return!!this._attachedCamera&&(0!==this._attachedCamera.inertialAlphaOffset||0!==this._attachedCamera.inertialBetaOffset||0!==this._attachedCamera.inertialRadiusOffset||0!==this._attachedCamera.inertialPanningX||0!==this._attachedCamera.inertialPanningY||this._isPointerDown)},e}(),lo=function(){function e(){this.transitionDuration=450,this.lowerRadiusTransitionRange=2,this.upperRadiusTransitionRange=-2,this._autoTransitionRange=!1,this._radiusIsAnimating=!1,this._radiusBounceTransition=null,this._animatables=new Array}return Object.defineProperty(e.prototype,\"name\",{get:function(){return\"Bouncing\"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"autoTransitionRange\",{get:function(){return this._autoTransitionRange},set:function(e){var t=this;if(this._autoTransitionRange!==e){this._autoTransitionRange=e;var i=this._attachedCamera;i&&(e?this._onMeshTargetChangedObserver=i.onMeshTargetChangedObservable.add((function(e){if(e){e.computeWorldMatrix(!0);var i=e.getBoundingInfo().diagonalLength;t.lowerRadiusTransitionRange=.05*i,t.upperRadiusTransitionRange=.05*i}})):this._onMeshTargetChangedObserver&&i.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver))}},enumerable:!1,configurable:!0}),e.prototype.init=function(){},e.prototype.attach=function(e){var t=this;this._attachedCamera=e,this._onAfterCheckInputsObserver=e.onAfterCheckInputsObservable.add((function(){t._attachedCamera&&(t._isRadiusAtLimit(t._attachedCamera.lowerRadiusLimit)&&t._applyBoundRadiusAnimation(t.lowerRadiusTransitionRange),t._isRadiusAtLimit(t._attachedCamera.upperRadiusLimit)&&t._applyBoundRadiusAnimation(t.upperRadiusTransitionRange))}))},e.prototype.detach=function(){this._attachedCamera&&(this._onAfterCheckInputsObserver&&this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),this._onMeshTargetChangedObserver&&this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver),this._attachedCamera=null)},e.prototype._isRadiusAtLimit=function(e){return!!this._attachedCamera&&this._attachedCamera.radius===e&&!this._radiusIsAnimating},e.prototype._applyBoundRadiusAnimation=function(t){var i=this;if(this._attachedCamera){this._radiusBounceTransition||(e.EasingFunction.setEasingMode(e.EasingMode),this._radiusBounceTransition=ze.CreateAnimation(\"radius\",ze.ANIMATIONTYPE_FLOAT,60,e.EasingFunction)),this._cachedWheelPrecision=this._attachedCamera.wheelPrecision,this._attachedCamera.wheelPrecision=1/0,this._attachedCamera.inertialRadiusOffset=0,this.stopAllAnimations(),this._radiusIsAnimating=!0;var n=ze.TransitionTo(\"radius\",this._attachedCamera.radius+t,this._attachedCamera,this._attachedCamera.getScene(),60,this._radiusBounceTransition,this.transitionDuration,(function(){return i._clearAnimationLocks()}));n&&this._animatables.push(n)}},e.prototype._clearAnimationLocks=function(){this._radiusIsAnimating=!1,this._attachedCamera&&(this._attachedCamera.wheelPrecision=this._cachedWheelPrecision)},e.prototype.stopAllAnimations=function(){for(this._attachedCamera&&(this._attachedCamera.animations=[]);this._animatables.length;)this._animatables[0].onAnimationEnd=null,this._animatables[0].stop(),this._animatables.shift()},e.EasingFunction=new On(.3),e.EasingMode=Mn.EASINGMODE_EASEOUT,e}(),co=function(){function e(){this.onTargetFramingAnimationEndObservable=new u,this._mode=e.FitFrustumSidesMode,this._radiusScale=1,this._positionScale=.5,this._defaultElevation=.3,this._elevationReturnTime=1500,this._elevationReturnWaitTime=1e3,this._zoomStopsAnimation=!1,this._framingTime=1500,this.autoCorrectCameraLimitsAndSensibility=!0,this._isPointerDown=!1,this._lastInteractionTime=-1/0,this._animatables=new Array,this._betaIsAnimating=!1}return Object.defineProperty(e.prototype,\"name\",{get:function(){return\"Framing\"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"mode\",{get:function(){return this._mode},set:function(e){this._mode=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"radiusScale\",{get:function(){return this._radiusScale},set:function(e){this._radiusScale=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"positionScale\",{get:function(){return this._positionScale},set:function(e){this._positionScale=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"defaultElevation\",{get:function(){return this._defaultElevation},set:function(e){this._defaultElevation=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"elevationReturnTime\",{get:function(){return this._elevationReturnTime},set:function(e){this._elevationReturnTime=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"elevationReturnWaitTime\",{get:function(){return this._elevationReturnWaitTime},set:function(e){this._elevationReturnWaitTime=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"zoomStopsAnimation\",{get:function(){return this._zoomStopsAnimation},set:function(e){this._zoomStopsAnimation=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"framingTime\",{get:function(){return this._framingTime},set:function(e){this._framingTime=e},enumerable:!1,configurable:!0}),e.prototype.init=function(){},e.prototype.attach=function(t){var i=this;this._attachedCamera=t;var n=this._attachedCamera.getScene();e.EasingFunction.setEasingMode(e.EasingMode),this._onPrePointerObservableObserver=n.onPrePointerObservable.add((function(e){e.type!==Hi.POINTERDOWN?e.type===Hi.POINTERUP&&(i._isPointerDown=!1):i._isPointerDown=!0})),this._onMeshTargetChangedObserver=t.onMeshTargetChangedObservable.add((function(e){e&&i.zoomOnMesh(e,void 0,(function(){i.onTargetFramingAnimationEndObservable.notifyObservers()}))})),this._onAfterCheckInputsObserver=t.onAfterCheckInputsObservable.add((function(){i._applyUserInteraction(),i._maintainCameraAboveGround()}))},e.prototype.detach=function(){if(this._attachedCamera){var e=this._attachedCamera.getScene();this._onPrePointerObservableObserver&&e.onPrePointerObservable.remove(this._onPrePointerObservableObserver),this._onAfterCheckInputsObserver&&this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),this._onMeshTargetChangedObserver&&this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver),this._attachedCamera=null}},e.prototype.zoomOnMesh=function(e,t,i){void 0===t&&(t=!1),void 0===i&&(i=null),e.computeWorldMatrix(!0);var n=e.getBoundingInfo().boundingBox;this.zoomOnBoundingInfo(n.minimumWorld,n.maximumWorld,t,i)},e.prototype.zoomOnMeshHierarchy=function(e,t,i){void 0===t&&(t=!1),void 0===i&&(i=null),e.computeWorldMatrix(!0);var n=e.getHierarchyBoundingVectors(!0);this.zoomOnBoundingInfo(n.min,n.max,t,i)},e.prototype.zoomOnMeshesHierarchy=function(e,t,i){void 0===t&&(t=!1),void 0===i&&(i=null);for(var n=new x(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),r=new x(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),o=0;oc.upperRadiusLimit?c.upperRadiusLimit:l),l):0},e.prototype._maintainCameraAboveGround=function(){var t=this;if(!(this._elevationReturnTime<0)){var i=it.Now-this._lastInteractionTime,n=.5*Math.PI-this._defaultElevation,r=.5*Math.PI;if(this._attachedCamera&&!this._betaIsAnimating&&this._attachedCamera.beta>r&&i>=this._elevationReturnWaitTime){this._betaIsAnimating=!0,this.stopAllAnimations(),this._betaTransition||(this._betaTransition=ze.CreateAnimation(\"beta\",ze.ANIMATIONTYPE_FLOAT,60,e.EasingFunction));var o=ze.TransitionTo(\"beta\",n,this._attachedCamera,this._attachedCamera.getScene(),60,this._betaTransition,this._elevationReturnTime,(function(){t._clearAnimationLocks(),t.stopAllAnimations()}));o&&this._animatables.push(o)}}},e.prototype._getFrustumSlope=function(){var e=this._attachedCamera;if(!e)return R.Zero();var t=e.getScene().getEngine().getAspectRatio(e),i=Math.tan(e.fov/2);return new R(i*t,i)},e.prototype._clearAnimationLocks=function(){this._betaIsAnimating=!1},e.prototype._applyUserInteraction=function(){this.isUserIsMoving&&(this._lastInteractionTime=it.Now,this.stopAllAnimations(),this._clearAnimationLocks())},e.prototype.stopAllAnimations=function(){for(this._attachedCamera&&(this._attachedCamera.animations=[]);this._animatables.length;)this._animatables[0]&&(this._animatables[0].onAnimationEnd=null,this._animatables[0].stop()),this._animatables.shift()},Object.defineProperty(e.prototype,\"isUserIsMoving\",{get:function(){return!!this._attachedCamera&&(0!==this._attachedCamera.inertialAlphaOffset||0!==this._attachedCamera.inertialBetaOffset||0!==this._attachedCamera.inertialRadiusOffset||0!==this._attachedCamera.inertialPanningX||0!==this._attachedCamera.inertialPanningY||this._isPointerDown)},enumerable:!1,configurable:!0}),e.EasingFunction=new Fn,e.EasingMode=Mn.EASINGMODE_EASEINOUT,e.IgnoreBoundsSizeMode=0,e.FitFrustumSidesMode=1,e}(),uo=function(e,t,i,n){void 0===t&&(t=new x),void 0===i&&(i=0),void 0===n&&(n=!1),this.direction=e,this.rotatedDirection=t,this.diff=i,this.ignore=n},ho=function(){function e(e){this._ui=e,this.name=\"AttachToBoxBehavior\",this.distanceAwayFromFace=.15,this.distanceAwayFromBottomOfFace=.15,this._faceVectors=[new uo(x.Up()),new uo(x.Down()),new uo(x.Left()),new uo(x.Right()),new uo(x.Forward()),new uo(x.Forward().scaleInPlace(-1))],this._tmpMatrix=new M,this._tmpVector=new x,this._zeroVector=x.Zero(),this._lookAtTmpMatrix=new M}return e.prototype.init=function(){},e.prototype._closestFace=function(e){var t=this;return this._faceVectors.forEach((function(i){t._target.rotationQuaternion||(t._target.rotationQuaternion=P.RotationYawPitchRoll(t._target.rotation.y,t._target.rotation.x,t._target.rotation.z)),t._target.rotationQuaternion.toRotationMatrix(t._tmpMatrix),x.TransformCoordinatesToRef(i.direction,t._tmpMatrix,i.rotatedDirection),i.diff=x.GetAngleBetweenVectors(i.rotatedDirection,e,x.Cross(i.rotatedDirection,e))})),this._faceVectors.reduce((function(e,t){return e.ignore?t:t.ignore||e.diff1)return e._setAllVisibility(e._ownerNode,1),void(e._hoverValue=e.fadeInTime+e.delay);if(e._ownerNode.visibility<0&&(e._setAllVisibility(e._ownerNode,0),e._hoverValue<0))return void(e._hoverValue=0);setTimeout(e._update,e._millisecondsPerFrame)}}}return Object.defineProperty(e.prototype,\"name\",{get:function(){return\"FadeInOut\"},enumerable:!1,configurable:!0}),e.prototype.init=function(){},e.prototype.attach=function(e){this._ownerNode=e,this._setAllVisibility(this._ownerNode,0)},e.prototype.detach=function(){this._ownerNode=null},e.prototype.fadeIn=function(e){this._hovered=e,this._update()},e.prototype._setAllVisibility=function(e,t){var i=this;e.visibility=t,e.getChildMeshes().forEach((function(e){i._setAllVisibility(e,t)}))},e}(),fo=function(){function e(e,t,i){void 0===i&&(i=Number.MAX_VALUE),this.origin=e,this.direction=t,this.length=i}return e.prototype.clone=function(){return new e(this.origin.clone(),this.direction.clone(),this.length)},e.prototype.intersectsBoxMinMax=function(t,i,n){void 0===n&&(n=0);var r,o,a,s,l=e._TmpVector3[0].copyFromFloats(t.x-n,t.y-n,t.z-n),c=e._TmpVector3[1].copyFromFloats(i.x+n,i.y+n,i.z+n),u=0,h=Number.MAX_VALUE;if(Math.abs(this.direction.x)<1e-7){if(this.origin.xc.x)return!1}else if(r=1/this.direction.x,o=(l.x-this.origin.x)*r,(a=(c.x-this.origin.x)*r)==-1/0&&(a=1/0),o>a&&(s=o,o=a,a=s),(u=Math.max(o,u))>(h=Math.min(a,h)))return!1;if(Math.abs(this.direction.y)<1e-7){if(this.origin.yc.y)return!1}else if(r=1/this.direction.y,o=(l.y-this.origin.y)*r,(a=(c.y-this.origin.y)*r)==-1/0&&(a=1/0),o>a&&(s=o,o=a,a=s),(u=Math.max(o,u))>(h=Math.min(a,h)))return!1;if(Math.abs(this.direction.z)<1e-7){if(this.origin.zc.z)return!1}else if(r=1/this.direction.z,o=(l.z-this.origin.z)*r,(a=(c.z-this.origin.z)*r)==-1/0&&(a=1/0),o>a&&(s=o,o=a,a=s),(u=Math.max(o,u))>(h=Math.min(a,h)))return!1;return!0},e.prototype.intersectsBox=function(e,t){return void 0===t&&(t=0),this.intersectsBoxMinMax(e.minimum,e.maximum,t)},e.prototype.intersectsSphere=function(e,t){void 0===t&&(t=0);var i=e.center.x-this.origin.x,n=e.center.y-this.origin.y,r=e.center.z-this.origin.z,o=i*i+n*n+r*r,a=e.radius+t,s=a*a;if(o<=s)return!0;var l=i*this.direction.x+n*this.direction.y+r*this.direction.z;return!(l<0)&&o-l*l<=s},e.prototype.intersectsTriangle=function(t,i,n){var r=e._TmpVector3[0],o=e._TmpVector3[1],a=e._TmpVector3[2],s=e._TmpVector3[3],l=e._TmpVector3[4];i.subtractToRef(t,r),n.subtractToRef(t,o),x.CrossToRef(this.direction,o,a);var c=x.Dot(r,a);if(0===c)return null;var u=1/c;this.origin.subtractToRef(t,s);var h=x.Dot(s,a)*u;if(h<0||h>1)return null;x.CrossToRef(s,r,l);var d=x.Dot(this.direction,l)*u;if(d<0||h+d>1)return null;var p=x.Dot(o,l)*u;return p>this.length?null:new er(1-h-d,h,p)},e.prototype.intersectsPlane=function(e){var t,i=x.Dot(e.normal,this.direction);if(Math.abs(i)<9.99999997475243e-7)return null;var n=x.Dot(e.normal,this.origin);return(t=(-e.d-n)/i)<0?t<-9.99999997475243e-7?null:0:t},e.prototype.intersectsAxis=function(e,t){switch(void 0===t&&(t=0),e){case\"y\":return(i=(this.origin.y-t)/this.direction.y)>0?null:new x(this.origin.x+this.direction.x*-i,t,this.origin.z+this.direction.z*-i);case\"x\":return(i=(this.origin.x-t)/this.direction.x)>0?null:new x(t,this.origin.y+this.direction.y*-i,this.origin.z+this.direction.z*-i);case\"z\":var i;return(i=(this.origin.z-t)/this.direction.z)>0?null:new x(this.origin.x+this.direction.x*-i,this.origin.y+this.direction.y*-i,t);default:return null}},e.prototype.intersectsMesh=function(t,i){var n=O.Matrix[0];return t.getWorldMatrix().invertToRef(n),this._tmpRay?e.TransformToRef(this,n,this._tmpRay):this._tmpRay=e.Transform(this,n),t.intersects(this._tmpRay,i)},e.prototype.intersectsMeshes=function(e,t,i){i?i.length=0:i=[];for(var n=0;nt.distance?1:0},e.prototype.intersectionSegment=function(t,i,n){var r=this.origin,o=O.Vector3[0],a=O.Vector3[1],s=O.Vector3[2],l=O.Vector3[3];i.subtractToRef(t,o),this.direction.scaleToRef(e._Rayl,s),r.addToRef(s,a),t.subtractToRef(r,l);var c,u,h=x.Dot(o,o),d=x.Dot(o,s),p=x.Dot(s,s),f=x.Dot(o,l),_=x.Dot(s,l),m=h*p-d*d,g=m,v=m;mg&&(c=g,u=_+d,v=p)),u<0?(u=0,-f<0?c=0:-f>h?c=g:(c=-f,g=h)):u>v&&(u=v,-f+d<0?c=0:-f+d>h?c=g:(c=-f+d,g=h));var y=Math.abs(c)0&&b<=this.length&&S.lengthSquared()=e.distance?null:c:null},mn.prototype._internalPick=function(e,t,i,n,r){if(!Bi)return null;for(var o=null,a=0;a1)throw\"Multiple drag modes specified in dragBehavior options. Only one expected\"}return Object.defineProperty(e.prototype,\"currentDraggingPointerID\",{get:function(){return this.currentDraggingPointerId},set:function(e){this.currentDraggingPointerId=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"enabled\",{get:function(){return this._enabled},set:function(e){e!=this._enabled&&this.onEnabledObservable.notifyObservers(e),this._enabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"options\",{get:function(){return this._options},set:function(e){this._options=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"name\",{get:function(){return\"PointerDrag\"},enumerable:!1,configurable:!0}),e.prototype.init=function(){},e.prototype.attach=function(t,i){var n=this;this._scene=t.getScene(),t.isNearGrabbable=!0,this.attachedNode=t,e._PlaneScene||(this._debugMode?e._PlaneScene=this._scene:(e._PlaneScene=new mn(this._scene.getEngine(),{virtual:!0}),e._PlaneScene.detachControl(),this._scene.onDisposeObservable.addOnce((function(){e._PlaneScene.dispose(),e._PlaneScene=null})))),this._dragPlane=go(\"pointerDragPlane\",{size:this._debugMode?1:1e4,updatable:!1,sideOrientation:Ur.DOUBLESIDE},e._PlaneScene),this.lastDragPosition=new x(0,0,0);var r=i||function(e){return n.attachedNode==e||e.isDescendantOf(n.attachedNode)};this._pointerObserver=this._scene.onPointerObservable.add((function(t){if(n.enabled){if(t.type==Hi.POINTERDOWN)n.startAndReleaseDragOnPointerEvents&&!n.dragging&&t.pickInfo&&t.pickInfo.hit&&t.pickInfo.pickedMesh&&t.pickInfo.pickedPoint&&t.pickInfo.ray&&r(t.pickInfo.pickedMesh)&&-1===n._activeDragButton&&-1!==n.dragButtons.indexOf(t.event.button)&&(n._activeDragButton=t.event.button,n._startDrag(t.event.pointerId,t.pickInfo.ray,t.pickInfo.pickedPoint));else if(t.type==Hi.POINTERUP)n.startAndReleaseDragOnPointerEvents&&n.currentDraggingPointerId==t.event.pointerId&&n._activeDragButton===t.event.button&&(n.releaseDrag(),n._activeDragButton=-1);else if(t.type==Hi.POINTERMOVE){var i=t.event.pointerId;if(n.currentDraggingPointerId===e._AnyMouseId&&i!==e._AnyMouseId){var o=t.event;(\"mouse\"===o.pointerType||!n._scene.getEngine().hostInformation.isMobile&&o instanceof MouseEvent)&&(n._lastPointerRay[n.currentDraggingPointerId]&&(n._lastPointerRay[i]=n._lastPointerRay[n.currentDraggingPointerId],delete n._lastPointerRay[n.currentDraggingPointerId]),n.currentDraggingPointerId=i)}n._lastPointerRay[i]||(n._lastPointerRay[i]=new fo(new x,new x)),t.pickInfo&&t.pickInfo.ray&&(n._lastPointerRay[i].origin.copyFrom(t.pickInfo.ray.origin),n._lastPointerRay[i].direction.copyFrom(t.pickInfo.ray.direction),n.currentDraggingPointerId==i&&n.dragging&&n._moveDrag(t.pickInfo.ray))}}else n._attachedToElement&&(n.releaseDrag(),n._activeDragButton=-1)})),this._beforeRenderObserver=this._scene.onBeforeRenderObservable.add((function(){if(n._moving&&n.moveAttached){var e=!1;_o._RemoveAndStorePivotPoint(n.attachedNode),n._targetPosition.subtractToRef(n.attachedNode.absolutePosition,n._tmpVector),n._tmpVector.scaleInPlace(n.dragDeltaRatio),n.attachedNode.getAbsolutePosition().addToRef(n._tmpVector,n._tmpVector),n.validateDrag(n._tmpVector)&&(n.attachedNode.setAbsolutePosition(n._tmpVector),e=!0),_o._RestorePivotPoint(n.attachedNode),e&&n.attachedNode.computeWorldMatrix()}}))},e.prototype.releaseDrag=function(){if(this.dragging&&(this.dragging=!1,this.onDragEndObservable.notifyObservers({dragPlanePoint:this.lastDragPosition,pointerId:this.currentDraggingPointerId})),this.currentDraggingPointerId=-1,this._moving=!1,this.detachCameraControls&&this._attachedToElement&&this._scene.activeCamera&&!this._scene.activeCamera.leftCamera){if(\"ArcRotateCamera\"===this._scene.activeCamera.getClassName()){var e=this._scene.activeCamera;e.attachControl(!e.inputs||e.inputs.noPreventDefault,e._useCtrlForPanning,e._panningMouseButton)}else this._scene.activeCamera.attachControl(!this._scene.activeCamera.inputs||this._scene.activeCamera.inputs.noPreventDefault);this._attachedToElement=!1}},e.prototype.startDrag=function(t,i,n){void 0===t&&(t=e._AnyMouseId),this._startDrag(t,i,n);var r=this._lastPointerRay[t];t===e._AnyMouseId&&(r=this._lastPointerRay[Object.keys(this._lastPointerRay)[0]]),r&&this._moveDrag(r)},e.prototype._startDrag=function(e,t,i){if(this._scene.activeCamera&&!this.dragging&&this.attachedNode){_o._RemoveAndStorePivotPoint(this.attachedNode),t?(this._startDragRay.direction.copyFrom(t.direction),this._startDragRay.origin.copyFrom(t.origin)):(this._startDragRay.origin.copyFrom(this._scene.activeCamera.position),this.attachedNode.getWorldMatrix().getTranslationToRef(this._tmpVector),this._tmpVector.subtractToRef(this._scene.activeCamera.position,this._startDragRay.direction)),this._updateDragPlanePosition(this._startDragRay,i||this._tmpVector);var n=this._pickWithRayOnDragPlane(this._startDragRay);n&&(this.dragging=!0,this.currentDraggingPointerId=e,this.lastDragPosition.copyFrom(n),this.onDragStartObservable.notifyObservers({dragPlanePoint:n,pointerId:this.currentDraggingPointerId}),this._targetPosition.copyFrom(this.attachedNode.getAbsolutePosition()),this.detachCameraControls&&this._scene.activeCamera&&this._scene.activeCamera.inputs&&!this._scene.activeCamera.leftCamera&&(this._scene.activeCamera.inputs.attachedToElement?(this._scene.activeCamera.detachControl(),this._attachedToElement=!0):this._attachedToElement=!1)),_o._RestorePivotPoint(this.attachedNode)}},e.prototype._moveDrag=function(e){this._moving=!0;var t=this._pickWithRayOnDragPlane(e);if(t){_o._RemoveAndStorePivotPoint(this.attachedNode),this.updateDragPlane&&this._updateDragPlanePosition(e,t);var i=0;this._options.dragAxis?(this.useObjectOrientationForDragging?x.TransformCoordinatesToRef(this._options.dragAxis,this.attachedNode.getWorldMatrix().getRotationMatrix(),this._worldDragAxis):this._worldDragAxis.copyFrom(this._options.dragAxis),t.subtractToRef(this.lastDragPosition,this._tmpVector),i=x.Dot(this._tmpVector,this._worldDragAxis),this._worldDragAxis.scaleToRef(i,this._dragDelta)):(i=this._dragDelta.length(),t.subtractToRef(this.lastDragPosition,this._dragDelta)),this._targetPosition.addInPlace(this._dragDelta),this.onDragObservable.notifyObservers({dragDistance:i,delta:this._dragDelta,dragPlanePoint:t,dragPlaneNormal:this._dragPlane.forward,pointerId:this.currentDraggingPointerId}),this.lastDragPosition.copyFrom(t),_o._RestorePivotPoint(this.attachedNode)}},e.prototype._pickWithRayOnDragPlane=function(t){var i=this;if(!t)return null;var n=Math.acos(x.Dot(this._dragPlane.forward,t.direction));if(n>Math.PI/2&&(n=Math.PI-n),this.maxDragAngle>0&&n>this.maxDragAngle){if(this._useAlternatePickedPointAboveMaxDragAngle){this._tmpVector.copyFrom(t.direction),this.attachedNode.absolutePosition.subtractToRef(t.origin,this._alternatePickedPoint),this._alternatePickedPoint.normalize(),this._alternatePickedPoint.scaleInPlace(this._useAlternatePickedPointAboveMaxDragAngleDragSpeed*x.Dot(this._alternatePickedPoint,this._tmpVector)),this._tmpVector.addInPlace(this._alternatePickedPoint);var r=x.Dot(this._dragPlane.forward,this._tmpVector);return this._dragPlane.forward.scaleToRef(-r,this._alternatePickedPoint),this._alternatePickedPoint.addInPlace(this._tmpVector),this._alternatePickedPoint.addInPlace(this.attachedNode.absolutePosition),this._alternatePickedPoint}return null}var o=e._PlaneScene.pickWithRay(t,(function(e){return e==i._dragPlane}));return o&&o.hit&&o.pickedMesh&&o.pickedPoint?o.pickedPoint:null},e.prototype._updateDragPlanePosition=function(e,t){this._pointA.copyFrom(t),this._options.dragAxis?(this.useObjectOrientationForDragging?x.TransformCoordinatesToRef(this._options.dragAxis,this.attachedNode.getWorldMatrix().getRotationMatrix(),this._localAxis):this._localAxis.copyFrom(this._options.dragAxis),e.origin.subtractToRef(this._pointA,this._pointC),this._pointC.normalize(),Math.abs(x.Dot(this._localAxis,this._pointC))>.999?Math.abs(x.Dot(x.UpReadOnly,this._pointC))>.999?this._lookAt.copyFrom(x.Right()):this._lookAt.copyFrom(x.UpReadOnly):(x.CrossToRef(this._localAxis,this._pointC,this._lookAt),x.CrossToRef(this._localAxis,this._lookAt,this._lookAt),this._lookAt.normalize()),this._dragPlane.position.copyFrom(this._pointA),this._pointA.addToRef(this._lookAt,this._lookAt),this._dragPlane.lookAt(this._lookAt)):this._options.dragPlaneNormal?(this.useObjectOrientationForDragging?x.TransformCoordinatesToRef(this._options.dragPlaneNormal,this.attachedNode.getWorldMatrix().getRotationMatrix(),this._localAxis):this._localAxis.copyFrom(this._options.dragPlaneNormal),this._dragPlane.position.copyFrom(this._pointA),this._pointA.addToRef(this._localAxis,this._lookAt),this._dragPlane.lookAt(this._lookAt)):(this._dragPlane.position.copyFrom(this._pointA),this._dragPlane.lookAt(e.origin)),this._dragPlane.position.copyFrom(this.attachedNode.getAbsolutePosition()),this._dragPlane.computeWorldMatrix(!0)},e.prototype.detach=function(){this._lastPointerRay={},this.attachedNode&&(this.attachedNode.isNearGrabbable=!1),this._pointerObserver&&this._scene.onPointerObservable.remove(this._pointerObserver),this._beforeRenderObserver&&this._scene.onBeforeRenderObservable.remove(this._beforeRenderObserver),this._dragPlane&&this._dragPlane.dispose(),this.releaseDrag(),this._activeDragButton=-1},e._AnyMouseId=-2,e}(),To=function(){function e(){this._startDistance=0,this._initialScale=new x(0,0,0),this._targetScale=new x(0,0,0),this._sceneRenderObserver=null,this._dragBehaviorA=new bo({}),this._dragBehaviorA.moveAttached=!1,this._dragBehaviorB=new bo({}),this._dragBehaviorB.moveAttached=!1}return Object.defineProperty(e.prototype,\"name\",{get:function(){return\"MultiPointerScale\"},enumerable:!1,configurable:!0}),e.prototype.init=function(){},e.prototype._getCurrentDistance=function(){return this._dragBehaviorA.lastDragPosition.subtract(this._dragBehaviorB.lastDragPosition).length()},e.prototype.attach=function(e){var t=this;this._ownerNode=e,this._dragBehaviorA.onDragStartObservable.add((function(){t._dragBehaviorA.dragging&&t._dragBehaviorB.dragging&&(t._dragBehaviorA.currentDraggingPointerId==t._dragBehaviorB.currentDraggingPointerId?t._dragBehaviorA.releaseDrag():(t._initialScale.copyFrom(e.scaling),t._startDistance=t._getCurrentDistance()))})),this._dragBehaviorB.onDragStartObservable.add((function(){t._dragBehaviorA.dragging&&t._dragBehaviorB.dragging&&(t._dragBehaviorA.currentDraggingPointerId==t._dragBehaviorB.currentDraggingPointerId?t._dragBehaviorB.releaseDrag():(t._initialScale.copyFrom(e.scaling),t._startDistance=t._getCurrentDistance()))})),[this._dragBehaviorA,this._dragBehaviorB].forEach((function(e){e.onDragObservable.add((function(){if(t._dragBehaviorA.dragging&&t._dragBehaviorB.dragging){var e=t._getCurrentDistance()/t._startDistance;t._initialScale.scaleToRef(e,t._targetScale)}}))})),e.addBehavior(this._dragBehaviorA),e.addBehavior(this._dragBehaviorB),this._sceneRenderObserver=e.getScene().onBeforeRenderObservable.add((function(){if(t._dragBehaviorA.dragging&&t._dragBehaviorB.dragging){var i=t._targetScale.subtract(e.scaling).scaleInPlace(.1);i.length()>.01&&e.scaling.addInPlace(i)}}))},e.prototype.detach=function(){var e=this;this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver),[this._dragBehaviorA,this._dragBehaviorB].forEach((function(t){t.onDragStartObservable.clear(),t.onDragObservable.clear(),e._ownerNode.removeBehavior(t)}))},e}(),Eo=function(){function e(){this._attachedToElement=!1,this._virtualMeshesInfo={},this._tmpVector=new x,this._tmpQuaternion=new P,this._dragType={NONE:0,DRAG:1,DRAG_WITH_CONTROLLER:2,NEAR_DRAG:3},this._moving=!1,this._dragging=this._dragType.NONE,this.draggableMeshes=null,this.zDragFactor=3,this.currentDraggingPointerIds=[],this.detachCameraControls=!0,this.onDragStartObservable=new u,this.onDragObservable=new u,this.onDragEndObservable=new u,this.allowMultiPointer=!0}return Object.defineProperty(e.prototype,\"currentDraggingPointerId\",{get:function(){return void 0!==this.currentDraggingPointerIds[0]?this.currentDraggingPointerIds[0]:-1},set:function(e){this.currentDraggingPointerIds[0]=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"currentDraggingPointerID\",{get:function(){return this.currentDraggingPointerId},set:function(e){this.currentDraggingPointerId=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"name\",{get:function(){return\"BaseSixDofDrag\"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"isMoving\",{get:function(){return this._moving},enumerable:!1,configurable:!0}),e.prototype.init=function(){},Object.defineProperty(e.prototype,\"_pointerCamera\",{get:function(){return this._scene.cameraToUseForPointers?this._scene.cameraToUseForPointers:this._scene.activeCamera},enumerable:!1,configurable:!0}),e.prototype._createVirtualMeshInfo=function(){var t=new Sr(\"\",e._virtualScene);t.rotationQuaternion=new P;var i=new Sr(\"\",e._virtualScene);i.rotationQuaternion=new P;var n=new Sr(\"\",e._virtualScene);return n.rotationQuaternion=new P,{dragging:!1,moving:!1,dragMesh:t,originMesh:i,pivotMesh:n,startingPivotPosition:new x,startingPivotOrientation:new P,startingPosition:new x,startingOrientation:new P,lastOriginPosition:new x,lastDragPosition:new x}},e.prototype._resetVirtualMeshesPosition=function(){for(var e=0;eh&&(h=Math.min(.01-u,0)),c.scaleInPlace(h),c.addToRef(r.pivotMesh.absolutePosition,this._tmpVector),r.pivotMesh.setAbsolutePosition(this._tmpVector),c.addToRef(r.dragMesh.absolutePosition,this._tmpVector),r.dragMesh.setAbsolutePosition(this._tmpVector)}},e.prototype.attach=function(t){var i=this;this._ownerNode=t,this._scene=this._ownerNode.getScene(),e._virtualScene||(e._virtualScene=new mn(this._scene.getEngine(),{virtual:!0}),e._virtualScene.detachControl()),this._pointerObserver=this._scene.onPointerObservable.add((function(e){var t=e.event.pointerId;i._virtualMeshesInfo[t]||(i._virtualMeshesInfo[t]=i._createVirtualMeshInfo());var n,r=i._virtualMeshesInfo[t],o=\"xr-near\"===e.event.pointerType;if(e.type==Hi.POINTERDOWN){if(!r.dragging&&e.pickInfo&&e.pickInfo.hit&&e.pickInfo.pickedMesh&&e.pickInfo.pickedPoint&&e.pickInfo.ray&&(!o||e.pickInfo.aimTransform)&&(n=e.pickInfo.pickedMesh,i._ownerNode===n||n.isDescendantOf(i._ownerNode)&&(!i.draggableMeshes||-1!==i.draggableMeshes.indexOf(n)))){if(!i.allowMultiPointer&&i.currentDraggingPointerIds.length>0)return;!i._pointerCamera||i._pointerCamera.cameraRigMode!==xr.RIG_MODE_NONE||i._pointerCamera._isLeftCamera||i._pointerCamera._isRightCamera||e.pickInfo.ray.origin.copyFrom(i._pointerCamera.globalPosition),i._ownerNode.computeWorldMatrix(!0);var a=i._virtualMeshesInfo[t];o?(i._dragging=e.pickInfo.originMesh?i._dragType.NEAR_DRAG:i._dragType.DRAG_WITH_CONTROLLER,a.originMesh.position.copyFrom(e.pickInfo.aimTransform.position),i._dragging===i._dragType.NEAR_DRAG&&e.pickInfo.gripTransform?a.originMesh.rotationQuaternion.copyFrom(e.pickInfo.gripTransform.rotationQuaternion):a.originMesh.rotationQuaternion.copyFrom(e.pickInfo.aimTransform.rotationQuaternion)):(i._dragging=i._dragType.DRAG,a.originMesh.position.copyFrom(e.pickInfo.ray.origin)),a.lastOriginPosition.copyFrom(a.originMesh.position),a.dragMesh.position.copyFrom(e.pickInfo.pickedPoint),a.lastDragPosition.copyFrom(e.pickInfo.pickedPoint),a.pivotMesh.position.copyFrom(i._ownerNode.getAbsolutePivotPoint()),a.pivotMesh.rotationQuaternion.copyFrom(i._ownerNode.absoluteRotationQuaternion),a.startingPosition.copyFrom(a.dragMesh.position),a.startingPivotPosition.copyFrom(a.pivotMesh.position),a.startingOrientation.copyFrom(a.dragMesh.rotationQuaternion),a.startingPivotOrientation.copyFrom(a.pivotMesh.rotationQuaternion),o?(a.originMesh.addChild(a.dragMesh),a.originMesh.addChild(a.pivotMesh)):a.originMesh.lookAt(a.dragMesh.position),a.dragging=!0,-1===i.currentDraggingPointerIds.indexOf(t)&&i.currentDraggingPointerIds.push(t),i.detachCameraControls&&i._pointerCamera&&!i._pointerCamera.leftCamera&&(i._pointerCamera.inputs&&i._pointerCamera.inputs.attachedToElement?(i._pointerCamera.detachControl(),i._attachedToElement=!0):i._attachedToElement=!1),i._targetDragStart(a.pivotMesh.position,a.pivotMesh.rotationQuaternion,t),i.onDragStartObservable.notifyObservers({position:a.pivotMesh.position})}}else if(e.type==Hi.POINTERUP||e.type==Hi.POINTERDOUBLETAP){var s=i.currentDraggingPointerIds.indexOf(t);r.dragging=!1,-1!==s&&(i.currentDraggingPointerIds.splice(s,1),0===i.currentDraggingPointerIds.length&&(i._moving=!1,i._dragging=i._dragType.NONE,i.detachCameraControls&&i._attachedToElement&&i._pointerCamera&&!i._pointerCamera.leftCamera&&(i._pointerCamera.attachControl(!0),i._attachedToElement=!1)),r.originMesh.removeChild(r.dragMesh),r.originMesh.removeChild(r.pivotMesh),i._targetDragEnd(t),i.onDragEndObservable.notifyObservers({}))}else if(e.type==Hi.POINTERMOVE&&-1!==(s=i.currentDraggingPointerIds.indexOf(t))&&r.dragging&&e.pickInfo&&(e.pickInfo.ray||e.pickInfo.aimTransform)){var l=i.zDragFactor;(i.currentDraggingPointerIds.length>1||e.pickInfo.originMesh)&&(l=0),i._ownerNode.computeWorldMatrix(!0),o?i._pointerUpdateXR(e.pickInfo.aimTransform,e.pickInfo.gripTransform,t,l):i._pointerUpdate2D(e.pickInfo.ray,t,l),i._tmpQuaternion.copyFrom(r.startingPivotOrientation),i._tmpQuaternion.x=-i._tmpQuaternion.x,i._tmpQuaternion.y=-i._tmpQuaternion.y,i._tmpQuaternion.z=-i._tmpQuaternion.z,r.pivotMesh.absoluteRotationQuaternion.multiplyToRef(i._tmpQuaternion,i._tmpQuaternion),r.pivotMesh.absolutePosition.subtractToRef(r.startingPivotPosition,i._tmpVector),i.onDragObservable.notifyObservers({delta:i._tmpVector,position:r.pivotMesh.position,pickInfo:e.pickInfo}),i._targetDrag(i._tmpVector,i._tmpQuaternion,t),r.lastDragPosition.copyFrom(r.dragMesh.absolutePosition),i._moving=!0}}))},e.prototype._applyZOffset=function(e,t,i){e.position.z-=e.position.z<1?t*i:t*i*e.position.z,e.position.z<0&&(e.position.z=0)},e.prototype._targetDragStart=function(e,t,i){},e.prototype._targetDrag=function(e,t,i){},e.prototype._targetDragEnd=function(e){},e.prototype.detach=function(){for(var e in this._scene&&(this.detachCameraControls&&this._attachedToElement&&this._pointerCamera&&!this._pointerCamera.leftCamera&&(this._pointerCamera.attachControl(!0),this._attachedToElement=!1),this._scene.onPointerObservable.remove(this._pointerObserver)),this._virtualMeshesInfo)this._virtualMeshesInfo[e].originMesh.dispose(),this._virtualMeshesInfo[e].dragMesh.dispose();this.onDragEndObservable.clear(),this.onDragObservable.clear(),this.onDragStartObservable.clear()},e}(),So=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._sceneRenderObserver=null,t._targetPosition=new x(0,0,0),t._targetOrientation=new P,t._targetScaling=new x(1,1,1),t._startingPosition=new x(0,0,0),t._startingOrientation=new P,t._startingScaling=new x(1,1,1),t.onPositionChangedObservable=new u,t.dragDeltaRatio=.2,t.rotateDraggedObject=!0,t.rotateAroundYOnly=!1,t.rotateWithMotionController=!0,t.disableMovement=!1,t.faceCameraOnDragStart=!1,t}return V(t,e),Object.defineProperty(t.prototype,\"name\",{get:function(){return\"SixDofDrag\"},enumerable:!1,configurable:!0}),t.prototype.attach=function(t){var i=this;e.prototype.attach.call(this,t),t.isNearGrabbable=!0,this._virtualTransformNode=new yr(\"virtual_sixDof\",Eo._virtualScene),this._virtualTransformNode.rotationQuaternion=P.Identity(),this._sceneRenderObserver=t.getScene().onBeforeRenderObservable.add((function(){if(1===i.currentDraggingPointerIds.length&&i._moving&&!i.disableMovement){var e=t.parent;t.setParent(null),t.position.addInPlace(i._targetPosition.subtract(t.position).scale(i.dragDeltaRatio)),i.onPositionChangedObservable.notifyObservers({position:t.absolutePosition}),(!e||e.scaling&&!e.scaling.isNonUniformWithinEpsilon(.001))&&P.SlerpToRef(t.rotationQuaternion,i._targetOrientation,i.dragDeltaRatio,t.rotationQuaternion),t.setParent(e)}}))},t.prototype._getPositionOffsetAround=function(e,t,i){var n=O.Matrix[0],r=O.Matrix[1],o=O.Matrix[2],a=O.Matrix[3],s=O.Matrix[4];return M.TranslationToRef(e.x,e.y,e.z,n),M.TranslationToRef(-e.x,-e.y,-e.z,r),M.FromQuaternionToRef(i,o),M.ScalingToRef(t,t,t,a),r.multiplyToRef(o,s),s.multiplyToRef(a,s),s.multiplyToRef(n,s),s.getTranslation()},t.prototype._onePointerPositionUpdated=function(e,t){O.Vector3[0].setAll(0),this._dragging===this._dragType.DRAG?this.rotateDraggedObject&&(this.rotateAroundYOnly?P.RotationYawPitchRollToRef(t.toEulerAngles().y,0,0,O.Quaternion[0]):O.Quaternion[0].copyFrom(t),O.Quaternion[0].multiplyToRef(this._startingOrientation,this._targetOrientation)):(this._dragging===this._dragType.NEAR_DRAG||this._dragging===this._dragType.DRAG_WITH_CONTROLLER&&this.rotateWithMotionController)&&t.multiplyToRef(this._startingOrientation,this._targetOrientation),this._targetPosition.copyFrom(this._startingPosition).addInPlace(e)},t.prototype._twoPointersPositionUpdated=function(){var e=this._virtualMeshesInfo[this.currentDraggingPointerIds[0]].startingPosition,t=this._virtualMeshesInfo[this.currentDraggingPointerIds[1]].startingPosition,i=O.Vector3[0];e.addToRef(t,i),i.scaleInPlace(.5);var n=O.Vector3[1];t.subtractToRef(e,n);var r=this._virtualMeshesInfo[this.currentDraggingPointerIds[0]].dragMesh.absolutePosition,o=this._virtualMeshesInfo[this.currentDraggingPointerIds[1]].dragMesh.absolutePosition,a=O.Vector3[2];r.addToRef(o,a),a.scaleInPlace(.5);var s=O.Vector3[3];o.subtractToRef(r,s);var l=s.length()/n.length(),c=a.subtract(i),u=P.FromEulerAngles(0,x.GetAngleBetweenVectorsOnPlane(n.normalize(),s.normalize(),x.UpReadOnly),0),h=this._ownerNode.parent;this._ownerNode.setParent(null);var d=this._getPositionOffsetAround(i.subtract(this._virtualTransformNode.getAbsolutePivotPoint()),l,u);this._virtualTransformNode.rotationQuaternion.multiplyToRef(u,this._ownerNode.rotationQuaternion),this._virtualTransformNode.scaling.scaleToRef(l,this._ownerNode.scaling),this._virtualTransformNode.position.addToRef(c.addInPlace(d),this._ownerNode.position),this.onPositionChangedObservable.notifyObservers({position:this._ownerNode.position}),this._ownerNode.setParent(h)},t.prototype._targetDragStart=function(){var e=this.currentDraggingPointerIds.length,t=this._ownerNode.parent;this._ownerNode.rotationQuaternion||(this._ownerNode.rotationQuaternion=P.RotationYawPitchRoll(this._ownerNode.rotation.y,this._ownerNode.rotation.x,this._ownerNode.rotation.z));var i=this._ownerNode.getAbsolutePivotPoint();if(this._ownerNode.setParent(null),1===e){if(this._targetPosition.copyFrom(this._ownerNode.position),this._targetOrientation.copyFrom(this._ownerNode.rotationQuaternion),this._targetScaling.copyFrom(this._ownerNode.scaling),this.faceCameraOnDragStart&&this._scene.activeCamera){var n=O.Vector3[0];this._scene.activeCamera.position.subtractToRef(i,n),n.normalize();var r=O.Quaternion[0];this._scene.useRightHandedSystem?P.FromLookDirectionRHToRef(n,new x(0,1,0),r):P.FromLookDirectionLHToRef(n,new x(0,1,0),r),r.normalize(),P.RotationYawPitchRollToRef(r.toEulerAngles().y,0,0,O.Quaternion[0]),this._targetOrientation.copyFrom(O.Quaternion[0])}this._startingPosition.copyFrom(this._targetPosition),this._startingOrientation.copyFrom(this._targetOrientation),this._startingScaling.copyFrom(this._targetScaling)}else 2===e&&(this._virtualTransformNode.setPivotPoint(new x(0,0,0),_n.LOCAL),this._virtualTransformNode.position.copyFrom(this._ownerNode.position),this._virtualTransformNode.scaling.copyFrom(this._ownerNode.scaling),this._virtualTransformNode.rotationQuaternion.copyFrom(this._ownerNode.rotationQuaternion),this._virtualTransformNode.setPivotPoint(i,_n.WORLD),this._resetVirtualMeshesPosition());this._ownerNode.setParent(t)},t.prototype._targetDrag=function(e,t){1===this.currentDraggingPointerIds.length?this._onePointerPositionUpdated(e,t):2===this.currentDraggingPointerIds.length&&this._twoPointersPositionUpdated()},t.prototype._targetDragEnd=function(){if(1===this.currentDraggingPointerIds.length){this._resetVirtualMeshesPosition();var e=this.faceCameraOnDragStart;this.faceCameraOnDragStart=!1,this._targetDragStart(),this.faceCameraOnDragStart=e}},t.prototype.detach=function(){e.prototype.detach.call(this),this._ownerNode&&(this._ownerNode.isNearGrabbable=!1,this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver)),this._virtualTransformNode&&this._virtualTransformNode.dispose()},t}(Eo),Ao=function(){function e(){this._attachPointLocalOffset=new x,this._workingPosition=new x,this._workingQuaternion=new P,this._lastTick=-1,this._hit=!1,this.hitNormalOffset=.05,this.meshes=[],this.interpolatePose=!0,this.lerpTime=250,this.keepOrientationVertical=!0,this.enabled=!0,this.maxStickingDistance=.8}return Object.defineProperty(e.prototype,\"name\",{get:function(){return\"SurfaceMagnetism\"},enumerable:!1,configurable:!0}),e.prototype.init=function(){},e.prototype.attach=function(e,t){this._attachedMesh=e,this._scene=t||e.getScene(),this._attachedMesh.rotationQuaternion||(this._attachedMesh.rotationQuaternion=P.RotationYawPitchRoll(this._attachedMesh.rotation.y,this._attachedMesh.rotation.x,this._attachedMesh.rotation.z)),this.updateAttachPoint(),this._workingPosition.copyFrom(this._attachedMesh.position),this._workingQuaternion.copyFrom(this._attachedMesh.rotationQuaternion),this._addObservables()},e.prototype.detach=function(){this._attachedMesh=null,this._removeObservables()},e.prototype._getTargetPose=function(e){if(!this._attachedMesh)return null;if(e&&e.hit){var t=e.getNormal(!0,!0),i=e.pickedPoint;if(!t||!i)return null;t.normalize();var n=O.Vector3[0];return n.copyFrom(t),n.scaleInPlace(this.hitNormalOffset),n.addInPlace(i),this._attachedMesh.parent&&(O.Matrix[0].copyFrom(this._attachedMesh.parent.getWorldMatrix()).invert(),x.TransformNormalToRef(n,O.Matrix[0],n)),{position:n,quaternion:P.RotationYawPitchRoll(-Math.atan2(t.x,-t.z),this.keepOrientationVertical?0:Math.atan2(t.y,Math.sqrt(t.z*t.z+t.x*t.x)),0)}}return null},e.prototype.updateAttachPoint=function(){this._getAttachPointOffsetToRef(this._attachPointLocalOffset)},e.prototype.findAndUpdateTarget=function(e){if(this._hit=!1,!e.ray)return!1;var t=e.ray.intersectsMeshes(this.meshes)[0];if(this._attachedMesh&&t&&t.hit&&t.pickedMesh){var i=this._getTargetPose(t);i&&x.Distance(this._attachedMesh.position,i.position)c&&(P.RotationAxisToRef(n,-l+c,a),t.rotateByQuaternionToRef(a,t),o=!0)}var u=this._angleBetweenVectorAndPlane(t,n)*(this._scene.useRightHandedSystem?-1:1),h=this.maxViewHorizontalDegrees*Math.PI/180*.5;return u<-h?(P.RotationAxisToRef(r,-u-h,a),t.rotateByQuaternionToRef(a,t),o=!0):u>h&&(P.RotationAxisToRef(r,-u+h,a),t.rotateByQuaternionToRef(a,t),o=!0),o},e.prototype._orientationClamp=function(e,t){var i,n=this._tmpVectors[0];n.copyFrom(e).scaleInPlace(-1).normalize();var r=this._tmpVectors[1],o=this._tmpVectors[2];r.copyFromFloats(0,1,0),x.CrossToRef(n,r,o);var a=o.length();a<_||(o.normalizeFromLength(a),x.CrossToRef(o,n,r),(null===(i=this.attachedNode)||void 0===i?void 0:i.getScene().useRightHandedSystem)?P.FromLookDirectionRHToRef(n,r,t):P.FromLookDirectionLHToRef(n,r,t))},e.prototype._passedOrientationDeadzone=function(e,t){var i=this._tmpVectors[5];return i.copyFrom(e),i.normalize(),180*Math.abs(x.GetAngleBetweenVectorsOnPlane(t,i,x.UpReadOnly))/Math.PI>this.orientToCameraDeadzoneDegrees},e.prototype._updateLeashing=function(e){if(this.attachedNode&&this._enabled){var t=this.attachedNode.parent;this.attachedNode.setParent(null);var i=this.attachedNode.getWorldMatrix(),n=this._workingPosition,r=this._workingQuaternion,o=this.attachedNode.getPivotPoint(),a=this._tmpInvertView;a.copyFrom(e.getViewMatrix()),a.invert(),x.TransformCoordinatesToRef(o,i,n);var s=this._tmpPosition;s.copyFromFloats(0,0,0),x.TransformCoordinatesToRef(s,i,s),s.scaleInPlace(-1).subtractInPlace(o),n.subtractInPlace(e.globalPosition),this.ignoreCameraPitchAndRoll&&this._applyPitchOffset(a);var l=!1,c=this._tmpForward;c.copyFromFloats(0,0,this._scene.useRightHandedSystem?-1:1),x.TransformNormalToRef(c,a,c);var u=this._tmpNodeForward;if(u.copyFromFloats(0,0,this._scene.useRightHandedSystem?-1:1),x.TransformNormalToRef(u,i,u),this._recenterNextUpdate)n.copyFrom(c).scaleInPlace(this.defaultDistance);else if(this.ignoreAngleClamp){var h=n.length();n.copyFrom(c).scaleInPlace(h)}else l=this._angularClamp(a,n);var d=!1;this.ignoreDistanceClamp||(d=this._distanceClamp(n,l),this._applyVerticalClamp(n)),this.useFixedVerticalOffset&&(n.y=s.y-e.globalPosition.y+this.fixedVerticalOffset),(l||d||this._passedOrientationDeadzone(n,u)||this._recenterNextUpdate)&&this._orientationClamp(n,r),this._workingPosition.subtractInPlace(o),this._recenterNextUpdate=!1,this.attachedNode.setParent(t)}},e.prototype._updateTransformToGoal=function(e){if(this.attachedNode&&this.followedCamera&&this._enabled){this.attachedNode.rotationQuaternion||(this.attachedNode.rotationQuaternion=P.Identity());var t=this.attachedNode.parent;if(this.attachedNode.setParent(null),!this.interpolatePose)return this.attachedNode.position.copyFrom(this.followedCamera.globalPosition).addInPlace(this._workingPosition),void this.attachedNode.rotationQuaternion.copyFrom(this._workingQuaternion);var i=new x;i.copyFrom(this.attachedNode.position).subtractInPlace(this.followedCamera.globalPosition),x.SmoothToRef(i,this._workingPosition,e,this.lerpTime,i),i.addInPlace(this.followedCamera.globalPosition),this.attachedNode.position.copyFrom(i);var n=new P;n.copyFrom(this.attachedNode.rotationQuaternion),P.SmoothToRef(n,this._workingQuaternion,e,this.lerpTime,this.attachedNode.rotationQuaternion),this.attachedNode.setParent(t)}},e.prototype._addObservables=function(){var e=this;this._lastTick=Date.now(),this._onBeforeRender=this._scene.onBeforeRenderObservable.add((function(){if(e.followedCamera){var t=Date.now();e._updateLeashing(e.followedCamera),e._updateTransformToGoal(t-e._lastTick),e._lastTick=t}}))},e.prototype._removeObservables=function(){this._onBeforeRender&&this._scene.onBeforeRenderObservable.remove(this._onBeforeRender)},e}(),xo=function(){function e(){}return e.ANCHOR_SYSTEM=\"xr-anchor-system\",e.BACKGROUND_REMOVER=\"xr-background-remover\",e.HIT_TEST=\"xr-hit-test\",e.MESH_DETECTION=\"xr-mesh-detection\",e.PHYSICS_CONTROLLERS=\"xr-physics-controller\",e.PLANE_DETECTION=\"xr-plane-detection\",e.POINTER_SELECTION=\"xr-controller-pointer-selection\",e.TELEPORTATION=\"xr-controller-teleportation\",e.FEATURE_POINTS=\"xr-feature-points\",e.HAND_TRACKING=\"xr-hand-tracking\",e.IMAGE_TRACKING=\"xr-image-tracking\",e.NEAR_INTERACTION=\"xr-near-interaction\",e.DOM_OVERLAY=\"xr-dom-overlay\",e.MOVEMENT=\"xr-controller-movement\",e.LIGHT_ESTIMATION=\"xr-light-estimation\",e.EYE_TRACKING=\"xr-eye-tracking\",e.WALKING_LOCOMOTION=\"xr-walking-locomotion\",e.LAYERS=\"xr-layers\",e}(),Co=function(){function e(e){var t=this;this._xrSessionManager=e,this._features={},this._xrSessionManager.onXRSessionInit.add((function(){t.getEnabledFeatures().forEach((function(e){var i=t._features[e];!i.enabled||i.featureImplementation.attached||i.featureImplementation.disableAutoAttach||t.attachFeature(e)}))})),this._xrSessionManager.onXRSessionEnded.add((function(){t.getEnabledFeatures().forEach((function(e){var i=t._features[e];i.enabled&&i.featureImplementation.attached&&t.detachFeature(e)}))}))}return e.AddWebXRFeature=function(e,t,i,n){void 0===i&&(i=1),void 0===n&&(n=!1),this._AvailableFeatures[e]=this._AvailableFeatures[e]||{latest:i},i>this._AvailableFeatures[e].latest&&(this._AvailableFeatures[e].latest=i),n&&(this._AvailableFeatures[e].stable=i),this._AvailableFeatures[e][i]=t},e.ConstructFeature=function(e,t,i,n){void 0===t&&(t=1);var r=this._AvailableFeatures[e][t];if(!r)throw new Error(\"feature not found\");return r(i,n)},e.GetAvailableFeatures=function(){return Object.keys(this._AvailableFeatures)},e.GetAvailableVersions=function(e){return Object.keys(this._AvailableFeatures[e])},e.GetLatestVersionOfFeature=function(e){return this._AvailableFeatures[e]&&this._AvailableFeatures[e].latest||-1},e.GetStableVersionOfFeature=function(e){return this._AvailableFeatures[e]&&this._AvailableFeatures[e].stable||-1},e.prototype.attachFeature=function(e){var t=this._features[e];t&&t.enabled&&!t.featureImplementation.attached&&t.featureImplementation.attach()},e.prototype.detachFeature=function(e){var t=this._features[e];t&&t.featureImplementation.attached&&t.featureImplementation.detach()},e.prototype.disableFeature=function(e){var t=\"string\"==typeof e?e:e.Name,i=this._features[t];return!(!i||!i.enabled||(i.enabled=!1,this.detachFeature(t),i.featureImplementation.dispose(),delete this._features[t],0))},e.prototype.dispose=function(){var e=this;this.getEnabledFeatures().forEach((function(t){e.disableFeature(t)}))},e.prototype.enableFeature=function(t,i,n,r,o){var a=this;void 0===i&&(i=\"latest\"),void 0===n&&(n={}),void 0===r&&(r=!0),void 0===o&&(o=!0);var s=\"string\"==typeof t?t:t.Name,l=0;if(\"string\"==typeof i){if(!i)throw new Error(\"Error in provided version - \".concat(s,\" (\").concat(i,\")\"));if(-1===(l=\"stable\"===i?e.GetStableVersionOfFeature(s):\"latest\"===i?e.GetLatestVersionOfFeature(s):+i)||isNaN(l))throw new Error(\"feature not found - \".concat(s,\" (\").concat(i,\")\"))}else l=i;var c=e._ConflictingFeatures[s];if(void 0!==c&&-1!==this.getEnabledFeatures().indexOf(c))throw new Error(\"Feature \".concat(s,\" cannot be enabled while \").concat(c,\" is enabled.\"));var u=this._features[s],h=e.ConstructFeature(s,l,this._xrSessionManager,n);if(!h)throw new Error(\"feature not found - \".concat(s));u&&this.disableFeature(s);var d=h();if(d.dependsOn){var p=d.dependsOn.every((function(e){return!!a._features[e]}));if(!p)throw new Error(\"Dependant features missing. Make sure the following features are enabled - \".concat(d.dependsOn.join(\", \")))}if(d.isCompatible())return this._features[s]={featureImplementation:d,enabled:!0,version:l,required:o},r?this._xrSessionManager.session&&!this._features[s].featureImplementation.attached&&this.attachFeature(s):this._features[s].featureImplementation.disableAutoAttach=!0,this._features[s].featureImplementation;if(o)throw new Error(\"required feature not compatible\");return mi.Warn(\"Feature \".concat(s,\" not compatible with the current environment/browser and was not enabled.\")),d},e.prototype.getEnabledFeature=function(e){return this._features[e]&&this._features[e].featureImplementation},e.prototype.getEnabledFeatures=function(){return Object.keys(this._features)},e.prototype._extendXRSessionInitObject=function(e){return z(this,void 0,void 0,(function(){var t,i,n,r,o,a,s;return W(this,(function(l){switch(l.label){case 0:t=this.getEnabledFeatures(),i=0,n=t,l.label=1;case 1:return i100&&(this.soft=!0),this._physicsEngine=this._scene.getPhysicsEngine(),this._physicsEngine?(this.object.rotationQuaternion||(this.object.rotation?this.object.rotationQuaternion=P.RotationYawPitchRoll(this.object.rotation.y,this.object.rotation.x,this.object.rotation.z):this.object.rotationQuaternion=new P),this._options.mass=void 0===n.mass?0:n.mass,this._options.friction=void 0===n.friction?.2:n.friction,this._options.restitution=void 0===n.restitution?.2:n.restitution,this.soft&&(this._options.mass=this._options.mass>0?this._options.mass:1,this._options.pressure=void 0===n.pressure?200:n.pressure,this._options.stiffness=void 0===n.stiffness?1:n.stiffness,this._options.velocityIterations=void 0===n.velocityIterations?20:n.velocityIterations,this._options.positionIterations=void 0===n.positionIterations?20:n.positionIterations,this._options.fixedPoints=void 0===n.fixedPoints?0:n.fixedPoints,this._options.margin=void 0===n.margin?0:n.margin,this._options.damping=void 0===n.damping?0:n.damping,this._options.path=void 0===n.path?null:n.path,this._options.shape=void 0===n.shape?null:n.shape),this._joints=[],!this.object.parent||this._options.ignoreParent?this._init():this.object.parent.physicsImpostor&&Q.Warn(\"You must affect impostors to children before affecting impostor to parent.\")):Q.Error(\"Physics not enabled. Please use scene.enablePhysics(...) before creating impostors.\"))):Q.Error(\"No object was provided. A physics object is obligatory\")}return Object.defineProperty(e.prototype,\"isDisposed\",{get:function(){return this._isDisposed},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"mass\",{get:function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getBodyMass(this):0},set:function(e){this.setMass(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"friction\",{get:function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getBodyFriction(this):0},set:function(e){this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setBodyFriction(this,e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"restitution\",{get:function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getBodyRestitution(this):0},set:function(e){this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setBodyRestitution(this,e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"pressure\",{get:function(){if(!this._physicsEngine)return 0;var e=this._physicsEngine.getPhysicsPlugin();return e.setBodyPressure?e.getBodyPressure(this):0},set:function(e){if(this._physicsEngine){var t=this._physicsEngine.getPhysicsPlugin();t.setBodyPressure&&t.setBodyPressure(this,e)}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"stiffness\",{get:function(){if(!this._physicsEngine)return 0;var e=this._physicsEngine.getPhysicsPlugin();return e.getBodyStiffness?e.getBodyStiffness(this):0},set:function(e){if(this._physicsEngine){var t=this._physicsEngine.getPhysicsPlugin();t.setBodyStiffness&&t.setBodyStiffness(this,e)}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"velocityIterations\",{get:function(){if(!this._physicsEngine)return 0;var e=this._physicsEngine.getPhysicsPlugin();return e.getBodyVelocityIterations?e.getBodyVelocityIterations(this):0},set:function(e){if(this._physicsEngine){var t=this._physicsEngine.getPhysicsPlugin();t.setBodyVelocityIterations&&t.setBodyVelocityIterations(this,e)}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"positionIterations\",{get:function(){if(!this._physicsEngine)return 0;var e=this._physicsEngine.getPhysicsPlugin();return e.getBodyPositionIterations?e.getBodyPositionIterations(this):0},set:function(e){if(this._physicsEngine){var t=this._physicsEngine.getPhysicsPlugin();t.setBodyPositionIterations&&t.setBodyPositionIterations(this,e)}},enumerable:!1,configurable:!0}),e.prototype._init=function(){this._physicsEngine&&(this._physicsEngine.removeImpostor(this),this.physicsBody=null,this._parent=this._parent||this._getPhysicsParent(),this._isDisposed||this.parent&&!this._options.ignoreParent||this._physicsEngine.addImpostor(this))},e.prototype._getPhysicsParent=function(){return this.object.parent instanceof Sr?this.object.parent.physicsImpostor:null},e.prototype.isBodyInitRequired=function(){return this._bodyUpdateRequired||!this._physicsBody&&(!this._parent||!!this._options.ignoreParent)},e.prototype.setScalingUpdated=function(){this.forceUpdate()},e.prototype.forceUpdate=function(){this._init(),this.parent&&!this._options.ignoreParent&&this.parent.forceUpdate()},Object.defineProperty(e.prototype,\"physicsBody\",{get:function(){return this._parent&&!this._options.ignoreParent?this._parent.physicsBody:this._physicsBody},set:function(e){this._physicsBody&&this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().removePhysicsBody(this),this._physicsBody=e,this.resetUpdateFlags()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"parent\",{get:function(){return!this._options.ignoreParent&&this._parent?this._parent:null},set:function(e){this._parent=e},enumerable:!1,configurable:!0}),e.prototype.resetUpdateFlags=function(){this._bodyUpdateRequired=!1},e.prototype.getObjectExtents=function(){if(this.object.getBoundingInfo){var t=this.object.rotationQuaternion,i=this.object.scaling.clone();this.object.rotationQuaternion=e.IDENTITY_QUATERNION;var n=this.object.computeWorldMatrix&&this.object.computeWorldMatrix(!0);n&&n.decompose(i,void 0,void 0);var r=this.object.getBoundingInfo().boundingBox.extendSize.scale(2).multiplyInPlace(i);return r.x=Math.abs(r.x),r.y=Math.abs(r.y),r.z=Math.abs(r.z),this.object.rotationQuaternion=t,this.object.computeWorldMatrix&&this.object.computeWorldMatrix(!0),r}return e.DEFAULT_OBJECT_SIZE},e.prototype.getObjectCenter=function(){return this.object.getBoundingInfo?this.object.getBoundingInfo().boundingBox.centerWorld:this.object.position},e.prototype.getParam=function(e){return this._options[e]},e.prototype.setParam=function(e,t){this._options[e]=t,this._bodyUpdateRequired=!0},e.prototype.setMass=function(e){this.getParam(\"mass\")!==e&&this.setParam(\"mass\",e),this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setBodyMass(this,e)},e.prototype.getLinearVelocity=function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getLinearVelocity(this):x.Zero()},e.prototype.setLinearVelocity=function(e){this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setLinearVelocity(this,e)},e.prototype.getAngularVelocity=function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getAngularVelocity(this):x.Zero()},e.prototype.setAngularVelocity=function(e){this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setAngularVelocity(this,e)},e.prototype.executeNativeFunction=function(e){this._physicsEngine&&e(this._physicsEngine.getPhysicsPlugin().world,this.physicsBody)},e.prototype.registerBeforePhysicsStep=function(e){this._onBeforePhysicsStepCallbacks.push(e)},e.prototype.unregisterBeforePhysicsStep=function(e){var t=this._onBeforePhysicsStepCallbacks.indexOf(e);t>-1?this._onBeforePhysicsStepCallbacks.splice(t,1):Q.Warn(\"Function to remove was not found\")},e.prototype.registerAfterPhysicsStep=function(e){this._onAfterPhysicsStepCallbacks.push(e)},e.prototype.unregisterAfterPhysicsStep=function(e){var t=this._onAfterPhysicsStepCallbacks.indexOf(e);t>-1?this._onAfterPhysicsStepCallbacks.splice(t,1):Q.Warn(\"Function to remove was not found\")},e.prototype.registerOnPhysicsCollide=function(e,t){var i=e instanceof Array?e:[e];this._onPhysicsCollideCallbacks.push({callback:t,otherImpostors:i})},e.prototype.unregisterOnPhysicsCollide=function(e,t){var i=e instanceof Array?e:[e],n=-1;this._onPhysicsCollideCallbacks.some((function(e,r){if(e.callback===t&&e.otherImpostors.length===i.length){var o=e.otherImpostors.every((function(e){return i.indexOf(e)>-1}));return o&&(n=r),o}return!1}))?this._onPhysicsCollideCallbacks.splice(n,1):Q.Warn(\"Function to remove was not found\")},e.prototype.getParentsRotation=function(){var e=this.object.parent;for(this._tmpQuat.copyFromFloats(0,0,0,1);e;)e.rotationQuaternion?this._tmpQuat2.copyFrom(e.rotationQuaternion):P.RotationYawPitchRollToRef(e.rotation.y,e.rotation.x,e.rotation.z,this._tmpQuat2),this._tmpQuat.multiplyToRef(this._tmpQuat2,this._tmpQuat),e=e.parent;return this._tmpQuat},e.prototype.applyForce=function(e,t){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().applyForce(this,e,t),this},e.prototype.applyImpulse=function(e,t){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().applyImpulse(this,e,t),this},e.prototype.createJoint=function(e,t,i){var n=new Mo(t,i);return this.addJoint(e,n),this},e.prototype.addJoint=function(e,t){return this._joints.push({otherImpostor:e,joint:t}),this._physicsEngine&&this._physicsEngine.addJoint(this,e,t),this},e.prototype.addAnchor=function(e,t,i,n,r){if(!this._physicsEngine)return this;var o=this._physicsEngine.getPhysicsPlugin();return o.appendAnchor?(this._physicsEngine&&o.appendAnchor(this,e,t,i,n,r),this):this},e.prototype.addHook=function(e,t,i,n){if(!this._physicsEngine)return this;var r=this._physicsEngine.getPhysicsPlugin();return r.appendAnchor?(this._physicsEngine&&r.appendHook(this,e,t,i,n),this):this},e.prototype.sleep=function(){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().sleepBody(this),this},e.prototype.wakeUp=function(){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().wakeUpBody(this),this},e.prototype.clone=function(t){return t?new e(t,this.type,this._options,this._scene):null},e.prototype.dispose=function(){var e=this;this._physicsEngine&&(this._joints.forEach((function(t){e._physicsEngine&&e._physicsEngine.removeJoint(e,t.otherImpostor,t.joint)})),this._physicsEngine.removeImpostor(this),this.parent&&this.parent.forceUpdate(),this._isDisposed=!0)},e.prototype.setDeltaPosition=function(e){this._deltaPosition.copyFrom(e)},e.prototype.setDeltaRotation=function(e){this._deltaRotation||(this._deltaRotation=new P),this._deltaRotation.copyFrom(e),this._deltaRotationConjugated=this._deltaRotation.conjugate()},e.prototype.getBoxSizeToRef=function(e){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().getBoxSizeToRef(this,e),this},e.prototype.getRadius=function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getRadius(this):0},e.prototype.syncBoneWithImpostor=function(t,i,n,r,o){var a=e._TmpVecs[0],s=this.object;if(s.rotationQuaternion)if(o){var l=e._TmpQuat;s.rotationQuaternion.multiplyToRef(o,l),t.setRotationQuaternion(l,_n.WORLD,i)}else t.setRotationQuaternion(s.rotationQuaternion,_n.WORLD,i);a.x=0,a.y=0,a.z=0,n&&(a.x=n.x,a.y=n.y,a.z=n.z,t.getDirectionToRef(a,i,a),null==r&&(r=n.length()),a.x*=r,a.y*=r,a.z*=r),t.getParent()?(a.addInPlace(s.getAbsolutePosition()),t.setAbsolutePosition(a,i)):(i.setAbsolutePosition(s.getAbsolutePosition()),i.position.x-=a.x,i.position.y-=a.y,i.position.z-=a.z)},e.prototype.syncImpostorWithBone=function(t,i,n,r,o,a){var s=this.object;if(s.rotationQuaternion)if(o){var l=e._TmpQuat;t.getRotationQuaternionToRef(_n.WORLD,i,l),l.multiplyToRef(o,s.rotationQuaternion)}else t.getRotationQuaternionToRef(_n.WORLD,i,s.rotationQuaternion);var c=e._TmpVecs[0],u=e._TmpVecs[1];a||((a=e._TmpVecs[2]).x=0,a.y=1,a.z=0),t.getDirectionToRef(a,i,u),t.getAbsolutePositionToRef(i,c),null==r&&n&&(r=n.length()),null!=r&&(c.x+=u.x*r,c.y+=u.y*r,c.z+=u.z*r),s.setAbsolutePosition(c)},e.DEFAULT_OBJECT_SIZE=new x(1,1,1),e.IDENTITY_QUATERNION=P.Identity(),e._TmpVecs=m.BuildArray(3,x.Zero),e._TmpQuat=P.Identity(),e.NoImpostor=0,e.SphereImpostor=1,e.BoxImpostor=2,e.PlaneImpostor=3,e.MeshImpostor=4,e.CapsuleImpostor=6,e.CylinderImpostor=7,e.ParticleImpostor=8,e.HeightmapImpostor=9,e.ConvexHullImpostor=10,e.CustomImpostor=100,e.RopeImpostor=101,e.ClothImpostor=102,e.SoftbodyImpostor=103,e}();!function(e){e[e.Clean=0]=\"Clean\",e[e.Stop=1]=\"Stop\",e[e.Sync=2]=\"Sync\",e[e.NoSync=3]=\"NoSync\"}(Lo||(Lo={}));var wo,Bo,Uo=function(){function e(){}return Object.defineProperty(e,\"ForceFullSceneLoadingForIncremental\",{get:function(){return dr.ForceFullSceneLoadingForIncremental},set:function(e){dr.ForceFullSceneLoadingForIncremental=e},enumerable:!1,configurable:!0}),Object.defineProperty(e,\"ShowLoadingScreen\",{get:function(){return dr.ShowLoadingScreen},set:function(e){dr.ShowLoadingScreen=e},enumerable:!1,configurable:!0}),Object.defineProperty(e,\"loggingLevel\",{get:function(){return dr.loggingLevel},set:function(e){dr.loggingLevel=e},enumerable:!1,configurable:!0}),Object.defineProperty(e,\"CleanBoneMatrixWeights\",{get:function(){return dr.CleanBoneMatrixWeights},set:function(e){dr.CleanBoneMatrixWeights=e},enumerable:!1,configurable:!0}),e.GetDefaultPlugin=function(){return e._RegisteredPlugins[\".babylon\"]},e._GetPluginForExtension=function(t){return e._RegisteredPlugins[t]||(Q.Warn(\"Unable to find a plugin to load \"+t+\" files. Trying to use .babylon default plugin. To load from a specific filetype (eg. gltf) see: https://doc.babylonjs.com/how_to/load_from_any_file_type\"),e.GetDefaultPlugin())},e._GetPluginForDirectLoad=function(t){for(var i in e._RegisteredPlugins){var n=e._RegisteredPlugins[i].plugin;if(n.canDirectLoad&&n.canDirectLoad(t))return e._RegisteredPlugins[i]}return e.GetDefaultPlugin()},e._GetPluginForFilename=function(t){var i=t.indexOf(\"?\");-1!==i&&(t=t.substring(0,i));var n=t.lastIndexOf(\".\"),r=t.substring(n,t.length).toLowerCase();return e._GetPluginForExtension(r)},e._GetDirectLoad=function(e){return\"data:\"===e.substr(0,5)?e.substr(5):null},e._FormatErrorMessage=function(e,t,i){var n=\"Unable to load from \"+e.url;return t?n+=\": \".concat(t):i&&(n+=\": \".concat(i)),n},e._LoadData=function(t,i,n,r,o,a,s){var l,c=e._GetDirectLoad(t.url),u=s?e._GetPluginForExtension(s):c?e._GetPluginForDirectLoad(t.url):e._GetPluginForFilename(t.url);if(!(l=void 0!==u.plugin.createPlugin?u.plugin.createPlugin():u.plugin))throw\"The loader plugin corresponding to the file type you are trying to load has not been found. If using es6, please import the plugin you wish to use before.\";if(e.OnPluginActivatedObservable.notifyObservers(l),c&&(l.canDirectLoad&&l.canDirectLoad(t.url)||!si(t.url))){if(l.directLoad){var h=l.directLoad(i,c);h.then?h.then((function(e){n(l,e)})).catch((function(e){o(\"Error in directLoad of _loadData: \"+e,e)})):n(l,h)}else n(l,c);return l}var d=u.isBinary,p=function(e,t){i.isDisposed?o(\"Scene has been disposed\"):n(l,e,t)},f=null,_=!1,m=l.onDisposeObservable;m&&m.add((function(){_=!0,f&&(f.abort(),f=null),a()}));var g=function(){if(!_){var e=function(e,t){o(null==e?void 0:e.statusText,t)},n=t.file||t.url;f=l.loadFile?l.loadFile(i,n,p,r,d,e):i._loadFile(n,p,r,!0,d,e)}},v=i.getEngine(),y=v.enableOfflineSupport;if(y){for(var b=!1,T=0,E=i.disableOfflineSupportExceptionRules;T[0..\").concat(i.repeatKey,\"]\\r\\n\");var n=Ot.IncludesShadersStore[e]+\"\\r\\n\";if(this.sharedData.emitComments&&(n=t+\"\\r\\n\"+n),!i)return n;if(i.replaceStrings)for(var r=0;r[0..\").concat(i.repeatKey,\"]\\r\\n\"):this.functions[r]=\"#include<\".concat(e,\">\\r\\n\"),void(this.sharedData.emitComments&&(this.functions[r]=t+\"\\r\\n\"+this.functions[r]));if(this.functions[r]=Ot.IncludesShadersStore[e],this.sharedData.emitComments&&(this.functions[r]=t+\"\\r\\n\"+this.functions[r]),i.removeIfDef&&(this.functions[r]=this.functions[r].replace(/^\\s*?#ifdef.+$/gm,\"\"),this.functions[r]=this.functions[r].replace(/^\\s*?#endif.*$/gm,\"\"),this.functions[r]=this.functions[r].replace(/^\\s*?#else.*$/gm,\"\"),this.functions[r]=this.functions[r].replace(/^\\s*?#elif.*$/gm,\"\")),i.removeAttributes&&(this.functions[r]=this.functions[r].replace(/^\\s*?attribute.+$/gm,\"\")),i.removeUniforms&&(this.functions[r]=this.functions[r].replace(/^\\s*?uniform.+$/gm,\"\")),i.removeVaryings&&(this.functions[r]=this.functions[r].replace(/^\\s*?varying.+$/gm,\"\")),i.replaceStrings)for(var o=0;o0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"isDirectlyConnectedToVertexOutput\",{get:function(){if(!this.hasEndpoints)return!1;for(var e=0,t=this._endpoints;e=0)&&(t.isExposedOnFrame=!0,t.exposedPortPosition=this.exposedPortPosition),t},e.prototype.dispose=function(){this.onConnectionObservable.clear()},e}(),Xo=function(){function e(e,t,i,n){void 0===t&&(t=Bo.Vertex),void 0===i&&(i=!1),void 0===n&&(n=!1),this._isFinalMerger=!1,this._isInput=!1,this._name=\"\",this._isUnique=!1,this.inputsAreExclusive=!1,this._codeVariableName=\"\",this._inputs=new Array,this._outputs=new Array,this.comments=\"\",this.visibleInInspector=!1,this.visibleOnFrame=!1,this._target=t,this._originalTargetIsNeutral=t===Bo.Neutral,this._isFinalMerger=i,this._isInput=n,this._name=e,this.uniqueId=dn.UniqueId}return Object.defineProperty(e.prototype,\"name\",{get:function(){return this._name},set:function(e){this.validateBlockName(e)&&(this._name=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"isUnique\",{get:function(){return this._isUnique},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"isFinalMerger\",{get:function(){return this._isFinalMerger},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"isInput\",{get:function(){return this._isInput},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"buildId\",{get:function(){return this._buildId},set:function(e){this._buildId=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"target\",{get:function(){return this._target},set:function(e){0==(this._target&e)&&(this._target=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"inputs\",{get:function(){return this._inputs},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"outputs\",{get:function(){return this._outputs},enumerable:!1,configurable:!0}),e.prototype.getInputByName=function(e){var t=this._inputs.filter((function(t){return t.name===e}));return t.length?t[0]:null},e.prototype.getOutputByName=function(e){var t=this._outputs.filter((function(t){return t.name===e}));return t.length?t[0]:null},e.prototype.initialize=function(e){},e.prototype.bind=function(e,t,i,n){},e.prototype._declareOutput=function(e,t){return\"\".concat(t._getGLType(e.type),\" \").concat(e.associatedVariableName)},e.prototype._writeVariable=function(e){return e.connectedPoint?\"\".concat(e.associatedVariableName):\"0.\"},e.prototype._writeFloat=function(e){var t=e.toString();return-1===t.indexOf(\".\")&&(t+=\".0\"),\"\".concat(t)},e.prototype.getClassName=function(){return\"NodeMaterialBlock\"},e.prototype.registerInput=function(e,t,i,n,r){return void 0===i&&(i=!1),(r=null!=r?r:new Ho(e,this,Go.Input)).type=t,r.isOptional=i,n&&(r.target=n),this._inputs.push(r),this},e.prototype.registerOutput=function(e,t,i,n){return(n=null!=n?n:new Ho(e,this,Go.Output)).type=t,i&&(n.target=i),this._outputs.push(n),this},e.prototype.getFirstAvailableInput=function(e){void 0===e&&(e=null);for(var t=0,i=this._inputs;t=this._outputs.length?null:this._outputs[t+1]},e.prototype.isAnAncestorOf=function(e){for(var t=0,i=this._outputs;tthis._maxRank&&(this._maxRank=e),this._defines[e]=new Array),this._defines[e].push(t)},e.prototype.addCPUSkinningFallback=function(e,t){this._mesh=t,ethis._maxRank&&(this._maxRank=e)},Object.defineProperty(e.prototype,\"hasMoreFallbacks\",{get:function(){return this._currentRank<=this._maxRank},enumerable:!1,configurable:!0}),e.prototype.reduce=function(e,t){if(this._mesh&&this._mesh.computeBonesUsingShaders&&this._mesh.numBoneInfluencers>0){this._mesh.computeBonesUsingShaders=!1,e=e.replace(\"#define NUM_BONE_INFLUENCERS \"+this._mesh.numBoneInfluencers,\"#define NUM_BONE_INFLUENCERS 0\"),t._bonesComputationForcedToCPU=!0;for(var i=this._mesh.getScene(),n=0;n0&&(r.computeBonesUsingShaders=!1)}}else{var s=this._defines[this._currentRank];if(s)for(n=0;n0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"size\",{get:function(){return this.width},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"width\",{get:function(){return this._size.width||this._size},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"height\",{get:function(){return this._size.height||this._size},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"layers\",{get:function(){return this._size.layers||0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"texture\",{get:function(){var e,t;return null!==(t=null===(e=this._textures)||void 0===e?void 0:e[0])&&void 0!==t?t:null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"textures\",{get:function(){return this._textures},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"samples\",{get:function(){return this._samples},enumerable:!1,configurable:!0}),e.prototype.setSamples=function(e,t,i){if(void 0===t&&(t=!0),void 0===i&&(i=!1),this.samples===e&&!i)return e;var n=this._isMulti?this._engine.updateMultipleRenderTargetTextureSampleCount(this,e,t):this._engine.updateRenderTargetTextureSampleCount(this,e);return this._samples=e,n},e.prototype.setTextures=function(e){Array.isArray(e)?this._textures=e:this._textures=e?[e]:null},e.prototype.setTexture=function(e,t,i){void 0===t&&(t=0),void 0===i&&(i=!0),this._textures||(this._textures=[]),this._textures[t]&&i&&this._textures[t].dispose(),this._textures[t]=e},e.prototype.createDepthStencilTexture=function(e,t,i,n,r){var o;return void 0===e&&(e=0),void 0===t&&(t=!0),void 0===i&&(i=!1),void 0===n&&(n=1),void 0===r&&(r=a.TEXTUREFORMAT_DEPTH32_FLOAT),null===(o=this._depthStencilTexture)||void 0===o||o.dispose(),this._depthStencilTextureWithStencil=i,this._depthStencilTexture=this._engine.createDepthStencilTexture(this._size,{bilinearFiltering:t,comparisonFunction:e,generateStencil:i,isCube:this._isCube,samples:n,depthTextureFormat:r},this),this._depthStencilTexture},e.prototype._shareDepth=function(e){this._depthStencilTexture&&(e._depthStencilTexture&&e._depthStencilTexture.dispose(),e._depthStencilTexture=this._depthStencilTexture,this._depthStencilTexture.incrementReferences())},e.prototype._swapAndDie=function(e){this.texture&&this.texture._swapAndDie(e),this._textures=null,this.dispose(!0)},e.prototype._cloneRenderTargetWrapper=function(){var e,t,i,n,r,o,a=null;if(this._isMulti){var s=this.textures;if(s&&s.length>0){var l=!1,c=s.length,u=s[s.length-1]._source;u!==Rt.Depth&&u!==Rt.DepthStencil||(l=!0,c--);for(var h=[],d=[],p=0;p1&&e.setSamples(this.samples),e._swapRenderTargetWrapper(this),e.dispose()}},e.prototype.releaseTextures=function(){var e,t;if(this._textures)for(var i=0;null!==(t=i<(null===(e=this._textures)||void 0===e?void 0:e.length))&&void 0!==t&&t;++i)this._textures[i].dispose();this._textures=null},e.prototype.dispose=function(e){var t;void 0===e&&(e=!1),e||(null===(t=this._depthStencilTexture)||void 0===t||t.dispose(),this._depthStencilTexture=null,this.releaseTextures()),this._engine._releaseRenderTargetWrapper(this)},e}(),da=function(e){function t(t,i,n,r,o){var a=e.call(this,t,i,n,r)||this;return a._framebuffer=null,a._depthStencilBuffer=null,a._MSAAFramebuffer=null,a._colorTextureArray=null,a._depthStencilTextureArray=null,a._context=o,a}return V(t,e),t.prototype._cloneRenderTargetWrapper=function(){var t=null;return this._colorTextureArray&&this._depthStencilTextureArray?(t=this._engine.createMultiviewRenderTargetTexture(this.width,this.height)).texture.isReady=!0:t=e.prototype._cloneRenderTargetWrapper.call(this),t},t.prototype._swapRenderTargetWrapper=function(t){e.prototype._swapRenderTargetWrapper.call(this,t),t._framebuffer=this._framebuffer,t._depthStencilBuffer=this._depthStencilBuffer,t._MSAAFramebuffer=this._MSAAFramebuffer,t._colorTextureArray=this._colorTextureArray,t._depthStencilTextureArray=this._depthStencilTextureArray,this._framebuffer=this._depthStencilBuffer=this._MSAAFramebuffer=this._colorTextureArray=this._depthStencilTextureArray=null},t.prototype._shareDepth=function(t){e.prototype._shareDepth.call(this,t);var i=this._context,n=this._depthStencilBuffer,r=t._MSAAFramebuffer||t._framebuffer;t._depthStencilBuffer&&i.deleteRenderbuffer(t._depthStencilBuffer),t._depthStencilBuffer=this._depthStencilBuffer,this._engine._bindUnboundFramebuffer(r),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.RENDERBUFFER,n),this._engine._bindUnboundFramebuffer(null)},t.prototype._bindTextureRenderTarget=function(e,t,i,n){if(void 0===t&&(t=0),void 0===i&&(i=-1),void 0===n&&(n=0),e._hardwareTexture){var r=this._context,o=this._framebuffer,a=this._engine._currentFramebuffer;this._engine._bindUnboundFramebuffer(o);var s=r[this._engine.webGLVersion>1?\"COLOR_ATTACHMENT\"+t:\"COLOR_ATTACHMENT\"+t+\"_WEBGL\"],l=-1!==i?r.TEXTURE_CUBE_MAP_POSITIVE_X+i:r.TEXTURE_2D;r.framebufferTexture2D(r.FRAMEBUFFER,s,l,e._hardwareTexture.underlyingResource,n),this._engine._bindUnboundFramebuffer(a)}},t.prototype.setTexture=function(t,i,n){void 0===i&&(i=0),void 0===n&&(n=!0),e.prototype.setTexture.call(this,t,i,n),this._bindTextureRenderTarget(t,i)},t.prototype.dispose=function(t){void 0===t&&(t=!1);var i=this._context;t||(this._colorTextureArray&&(this._context.deleteTexture(this._colorTextureArray),this._colorTextureArray=null),this._depthStencilTextureArray&&(this._context.deleteTexture(this._depthStencilTextureArray),this._depthStencilTextureArray=null)),this._framebuffer&&(i.deleteFramebuffer(this._framebuffer),this._framebuffer=null),this._depthStencilBuffer&&(i.deleteRenderbuffer(this._depthStencilBuffer),this._depthStencilBuffer=null),this._MSAAFramebuffer&&(i.deleteFramebuffer(this._MSAAFramebuffer),this._MSAAFramebuffer=null),e.prototype.dispose.call(this,t)},t}(ha);Yt.prototype._createHardwareRenderTargetWrapper=function(e,t,i){var n=new da(e,t,i,this,this._gl);return this._renderTargetWrapperCache.push(n),n},Yt.prototype.createRenderTargetTexture=function(e,t){var i=this._createHardwareRenderTargetWrapper(!1,!1,e),n={};void 0!==t&&\"object\"==typeof t?(n.generateDepthBuffer=!!t.generateDepthBuffer,n.generateStencilBuffer=!!t.generateStencilBuffer,n.noColorTarget=!!t.noColorTarget):(n.generateDepthBuffer=!0,n.generateStencilBuffer=!1,n.noColorTarget=!1);var r=n.noColorTarget?null:this._createInternalTexture(e,t,!0,Rt.RenderTarget),o=e.width||e,a=e.height||e,s=this._currentFramebuffer,l=this._gl,c=l.createFramebuffer();return this._bindUnboundFramebuffer(c),i._depthStencilBuffer=this._setupFramebufferDepthAttachments(!!n.generateStencilBuffer,n.generateDepthBuffer,o,a),r&&!r.is2DArray&&l.framebufferTexture2D(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0,l.TEXTURE_2D,r._hardwareTexture.underlyingResource,0),this._bindUnboundFramebuffer(s),i._framebuffer=c,i._generateDepthBuffer=n.generateDepthBuffer,i._generateStencilBuffer=!!n.generateStencilBuffer,i.setTextures(r),i},Yt.prototype.createDepthStencilTexture=function(e,t,i){if(t.isCube){var n=e.width||e;return this._createDepthStencilCubeTexture(n,t,i)}return this._createDepthStencilTexture(e,t,i)},Yt.prototype._createDepthStencilTexture=function(e,t,i){var n=this._gl,r=e.layers||0,o=0!==r?n.TEXTURE_2D_ARRAY:n.TEXTURE_2D,s=new wt(this,Rt.DepthStencil);if(!this._caps.depthTextureExtension)return Q.Error(\"Depth texture is not supported by your browser or hardware.\"),s;var l=k({bilinearFiltering:!1,comparisonFunction:0,generateStencil:!1},t);if(this._bindTextureDirectly(o,s,!0),this._setupDepthStencilTexture(s,e,l.generateStencil,0!==l.comparisonFunction&&l.bilinearFiltering,l.comparisonFunction),void 0!==l.depthTextureFormat){if(l.depthTextureFormat!==a.TEXTUREFORMAT_DEPTH16&&l.depthTextureFormat!==a.TEXTUREFORMAT_DEPTH24&&l.depthTextureFormat!==a.TEXTUREFORMAT_DEPTH24UNORM_STENCIL8&&l.depthTextureFormat!==a.TEXTUREFORMAT_DEPTH24_STENCIL8&&l.depthTextureFormat!==a.TEXTUREFORMAT_DEPTH32_FLOAT&&l.depthTextureFormat!==a.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8)return Q.Error(\"Depth texture format is not supported.\"),s;s.format=l.depthTextureFormat}else s.format=l.generateStencil?a.TEXTUREFORMAT_DEPTH24_STENCIL8:a.TEXTUREFORMAT_DEPTH24;var c=s.format===a.TEXTUREFORMAT_DEPTH24UNORM_STENCIL8||s.format===a.TEXTUREFORMAT_DEPTH24_STENCIL8||s.format===a.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8;i._depthStencilTexture=s,i._depthStencilTextureWithStencil=c;var u=n.UNSIGNED_INT;s.format===a.TEXTUREFORMAT_DEPTH16?u=n.UNSIGNED_SHORT:s.format===a.TEXTUREFORMAT_DEPTH24UNORM_STENCIL8||s.format===a.TEXTUREFORMAT_DEPTH24_STENCIL8?u=n.UNSIGNED_INT_24_8:s.format===a.TEXTUREFORMAT_DEPTH32_FLOAT?u=n.FLOAT:s.format===a.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8&&(u=n.FLOAT_32_UNSIGNED_INT_24_8_REV);var h=c?n.DEPTH_STENCIL:n.DEPTH_COMPONENT,d=h;this.webGLVersion>1&&(s.format===a.TEXTUREFORMAT_DEPTH16?d=n.DEPTH_COMPONENT16:s.format===a.TEXTUREFORMAT_DEPTH24?d=n.DEPTH_COMPONENT24:s.format===a.TEXTUREFORMAT_DEPTH24UNORM_STENCIL8||s.format===a.TEXTUREFORMAT_DEPTH24_STENCIL8?d=n.DEPTH24_STENCIL8:s.format===a.TEXTUREFORMAT_DEPTH32_FLOAT?d=n.DEPTH_COMPONENT32F:s.format===a.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8&&(d=n.DEPTH32F_STENCIL8)),s.is2DArray?n.texImage3D(o,0,d,s.width,s.height,r,0,h,u,null):n.texImage2D(o,0,d,s.width,s.height,0,h,u,null),this._bindTextureDirectly(o,null),this._internalTexturesCache.push(s);var p=i;if(p._depthStencilBuffer){var f=this._currentFramebuffer;this._bindUnboundFramebuffer(p._framebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.RENDERBUFFER,null),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.RENDERBUFFER,null),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.STENCIL_ATTACHMENT,n.RENDERBUFFER,null),this._bindUnboundFramebuffer(f),n.deleteRenderbuffer(p._depthStencilBuffer),p._depthStencilBuffer=null}return s},Yt.prototype.updateRenderTargetTextureSampleCount=function(e,t){if(this.webGLVersion<2||!e||!e.texture)return 1;if(e.samples===t)return t;var i=this._gl;t=Math.min(t,this.getCaps().maxMSAASamples),e._depthStencilBuffer&&(i.deleteRenderbuffer(e._depthStencilBuffer),e._depthStencilBuffer=null),e._MSAAFramebuffer&&(i.deleteFramebuffer(e._MSAAFramebuffer),e._MSAAFramebuffer=null);var n=e.texture._hardwareTexture;if(n._MSAARenderBuffer&&(i.deleteRenderbuffer(n._MSAARenderBuffer),n._MSAARenderBuffer=null),t>1&&i.renderbufferStorageMultisample){var r=i.createFramebuffer();if(!r)throw new Error(\"Unable to create multi sampled framebuffer\");e._MSAAFramebuffer=r,this._bindUnboundFramebuffer(e._MSAAFramebuffer);var o=this._createRenderBuffer(e.texture.width,e.texture.height,t,-1,this._getRGBAMultiSampleBufferFormat(e.texture.type),i.COLOR_ATTACHMENT0,!1);if(!o)throw new Error(\"Unable to create multi sampled framebuffer\");n._MSAARenderBuffer=o}else this._bindUnboundFramebuffer(e._framebuffer);return e.texture.samples=t,e._depthStencilBuffer=this._setupFramebufferDepthAttachments(e._generateStencilBuffer,e._generateDepthBuffer,e.texture.width,e.texture.height,t),this._bindUnboundFramebuffer(null),t};var pa=function(){function e(e,t,i,n,r,o,s,l,c,h,d,p,f,_,m){void 0===s&&(s=a.TEXTURE_NEAREST_SAMPLINGMODE),void 0===h&&(h=null),void 0===d&&(d=a.TEXTURETYPE_UNSIGNED_INT),void 0===p&&(p=\"postprocess\"),void 0===_&&(_=!1),void 0===m&&(m=a.TEXTUREFORMAT_RGBA),this._parentContainer=null,this.width=-1,this.height=-1,this.nodeMaterialSource=null,this._outputTexture=null,this.autoClear=!0,this.alphaMode=a.ALPHA_DISABLE,this.animations=new Array,this.enablePixelPerfectMode=!1,this.forceFullscreenViewport=!0,this.scaleMode=a.SCALEMODE_FLOOR,this.alwaysForcePOT=!1,this._samples=1,this.adaptScaleToCurrentViewport=!1,this._reusable=!1,this._renderId=0,this.externalTextureSamplerBinding=!1,this._textures=new yi(2),this._textureCache=[],this._currentRenderTextureInd=0,this._scaleRatio=new R(1,1),this._texelSize=R.Zero(),this.onActivateObservable=new u,this.onSizeChangedObservable=new u,this.onApplyObservable=new u,this.onBeforeRenderObservable=new u,this.onAfterRenderObservable=new u,this.name=e,null!=o?(this._camera=o,this._scene=o.getScene(),o.attachPostProcess(this),this._engine=this._scene.getEngine(),this._scene.postProcesses.push(this),this.uniqueId=this._scene.getUniqueId()):l&&(this._engine=l,this._engine.postProcesses.push(this)),this._options=r,this.renderTargetSamplingMode=s||a.TEXTURE_NEAREST_SAMPLINGMODE,this._reusable=c||!1,this._textureType=d,this._textureFormat=m,this._samplers=n||[],this._samplers.push(\"textureSampler\"),this._fragmentUrl=t,this._vertexUrl=p,this._parameters=i||[],this._parameters.push(\"scale\"),this._indexParameters=f,this._drawWrapper=new Ht(this._engine),_||this.updateEffect(h)}return Object.defineProperty(e.prototype,\"samples\",{get:function(){return this._samples},set:function(e){var t=this;this._samples=Math.min(e,this._engine.getCaps().maxMSAASamples),this._textures.forEach((function(e){e.samples!==t._samples&&t._engine.updateRenderTargetTextureSampleCount(e,t._samples)}))},enumerable:!1,configurable:!0}),e.prototype.getEffectName=function(){return this._fragmentUrl},Object.defineProperty(e.prototype,\"onActivate\",{set:function(e){this._onActivateObserver&&this.onActivateObservable.remove(this._onActivateObserver),e&&(this._onActivateObserver=this.onActivateObservable.add(e))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"onSizeChanged\",{set:function(e){this._onSizeChangedObserver&&this.onSizeChangedObservable.remove(this._onSizeChangedObserver),this._onSizeChangedObserver=this.onSizeChangedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"onApply\",{set:function(e){this._onApplyObserver&&this.onApplyObservable.remove(this._onApplyObserver),this._onApplyObserver=this.onApplyObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"onBeforeRender\",{set:function(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"onAfterRender\",{set:function(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=this.onAfterRenderObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"inputTexture\",{get:function(){return this._textures.data[this._currentRenderTextureInd]},set:function(e){this._forcedOutputTexture=e},enumerable:!1,configurable:!0}),e.prototype.restoreDefaultInputTexture=function(){this._forcedOutputTexture&&(this._forcedOutputTexture=null,this.markTextureDirty())},e.prototype.getCamera=function(){return this._camera},Object.defineProperty(e.prototype,\"texelSize\",{get:function(){return this._shareOutputWithPostProcess?this._shareOutputWithPostProcess.texelSize:(this._forcedOutputTexture&&this._texelSize.copyFromFloats(1/this._forcedOutputTexture.width,1/this._forcedOutputTexture.height),this._texelSize)},enumerable:!1,configurable:!0}),e.prototype.getClassName=function(){return\"PostProcess\"},e.prototype.getEngine=function(){return this._engine},e.prototype.getEffect=function(){return this._drawWrapper.effect},e.prototype.shareOutputWith=function(e){return this._disposeTextures(),this._shareOutputWithPostProcess=e,this},e.prototype.useOwnOutput=function(){0==this._textures.length&&(this._textures=new yi(2)),this._shareOutputWithPostProcess=null},e.prototype.updateEffect=function(e,t,i,n,r,o,a,s){void 0===e&&(e=null),void 0===t&&(t=null),void 0===i&&(i=null),this._postProcessDefines=e,this._drawWrapper.effect=this._engine.createEffect({vertex:null!=a?a:this._vertexUrl,fragment:null!=s?s:this._fragmentUrl},[\"position\"],t||this._parameters,i||this._samplers,null!==e?e:\"\",void 0,r,o,n||this._indexParameters)},e.prototype.isReusable=function(){return this._reusable},e.prototype.markTextureDirty=function(){this.width=-1},e.prototype._createRenderTargetTexture=function(e,t,i){void 0===i&&(i=0);for(var n=0;n=0;t--)if(e-this._textureCache[t].lastUsedRenderId>100){for(var i=!1,n=0;n0&&this._textures.reset(),this.width=e,this.height=t;for(var o=null,a=0;a=0;e--)this._textureCache[e].texture.dispose();this._textureCache.length=0},e.prototype.setPrePassRenderer=function(e){return!!this._prePassEffectConfiguration&&(this._prePassEffectConfiguration=e.addEffectConfiguration(this._prePassEffectConfiguration),this._prePassEffectConfiguration.enabled=!0,!0)},e.prototype.dispose=function(e){var t;if(e=e||this._camera,this._disposeTextures(),this._scene&&-1!==(t=this._scene.postProcesses.indexOf(this))&&this._scene.postProcesses.splice(t,1),this._parentContainer){var i=this._parentContainer.postProcesses.indexOf(this);i>-1&&this._parentContainer.postProcesses.splice(i,1),this._parentContainer=null}if(-1!==(t=this._engine.postProcesses.indexOf(this))&&this._engine.postProcesses.splice(t,1),e){if(e.detachPostProcess(this),0===(t=e._postProcesses.indexOf(this))&&e._postProcesses.length>0){var n=this._camera._getFirstPostProcess();n&&n.markTextureDirty()}this.onActivateObservable.clear(),this.onAfterRenderObservable.clear(),this.onApplyObservable.clear(),this.onBeforeRenderObservable.clear(),this.onSizeChangedObservable.clear()}},e.prototype.serialize=function(){var e=Le.Serialize(this),t=this.getCamera()||this._scene&&this._scene.activeCamera;return e.customType=\"BABYLON.\"+this.getClassName(),e.cameraId=t?t.id:null,e.reusable=this._reusable,e.textureType=this._textureType,e.fragmentUrl=this._fragmentUrl,e.parameters=this._parameters,e.samplers=this._samplers,e.options=this._options,e.defines=this._postProcessDefines,e.textureFormat=this._textureFormat,e.vertexUrl=this._vertexUrl,e.indexParameters=this._indexParameters,e},e.prototype.clone=function(){var t=this.serialize();t._engine=this._engine,t.cameraId=null;var i=e.Parse(t,this._scene,\"\");return i?(i.onActivateObservable=this.onActivateObservable.clone(),i.onSizeChangedObservable=this.onSizeChangedObservable.clone(),i.onApplyObservable=this.onApplyObservable.clone(),i.onBeforeRenderObservable=this.onBeforeRenderObservable.clone(),i.onAfterRenderObservable=this.onAfterRenderObservable.clone(),i._prePassEffectConfiguration=this._prePassEffectConfiguration,i):null},e.Parse=function(e,t,i){var n=T(e.customType);if(!n||!n._Parse)return null;var r=t?t.getCameraById(e.cameraId):null;return n._Parse(e,r,t,i)},e._Parse=function(t,i,n,r){return Le.Parse((function(){return new e(t.name,t.fragmentUrl,t.parameters,t.samplers,t.options,i,t.renderTargetSamplingMode,t._engine,t.reusable,t.defines,t.textureType,t.vertexUrl,t.indexParameters,!1,t.textureFormat)}),t,n,r)},G([be()],e.prototype,\"uniqueId\",void 0),G([be()],e.prototype,\"name\",void 0),G([be()],e.prototype,\"width\",void 0),G([be()],e.prototype,\"height\",void 0),G([be()],e.prototype,\"renderTargetSamplingMode\",void 0),G([Pe()],e.prototype,\"clearColor\",void 0),G([be()],e.prototype,\"autoClear\",void 0),G([be()],e.prototype,\"alphaMode\",void 0),G([be()],e.prototype,\"alphaConstants\",void 0),G([be()],e.prototype,\"enablePixelPerfectMode\",void 0),G([be()],e.prototype,\"forceFullscreenViewport\",void 0),G([be()],e.prototype,\"scaleMode\",void 0),G([be()],e.prototype,\"alwaysForcePOT\",void 0),G([be(\"samples\")],e.prototype,\"_samples\",void 0),G([be()],e.prototype,\"adaptScaleToCurrentViewport\",void 0),e}();b(\"BABYLON.PostProcess\",pa);var fa=function(e){function t(t){var i=e.call(this,t,Bo.Neutral)||this;return i.xSwizzle=\"x\",i.ySwizzle=\"y\",i.zSwizzle=\"z\",i.wSwizzle=\"w\",i.registerInput(\"xyzw \",wo.Vector4,!0),i.registerInput(\"xyz \",wo.Vector3,!0),i.registerInput(\"xy \",wo.Vector2,!0),i.registerInput(\"zw \",wo.Vector2,!0),i.registerInput(\"x\",wo.Float,!0),i.registerInput(\"y\",wo.Float,!0),i.registerInput(\"z\",wo.Float,!0),i.registerInput(\"w\",wo.Float,!0),i.registerOutput(\"xyzw\",wo.Vector4),i.registerOutput(\"xyz\",wo.Vector3),i.registerOutput(\"xy\",wo.Vector2),i.registerOutput(\"zw\",wo.Vector2),i}return V(t,e),t.prototype.getClassName=function(){return\"VectorMergerBlock\"},Object.defineProperty(t.prototype,\"xyzwIn\",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"xyzIn\",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"xyIn\",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"zwIn\",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"x\",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"y\",{get:function(){return this._inputs[5]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"z\",{get:function(){return this._inputs[6]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"w\",{get:function(){return this._inputs[7]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"xyzw\",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"xyzOut\",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"xyOut\",{get:function(){return this._outputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"zwOut\",{get:function(){return this._outputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"xy\",{get:function(){return this.xyOut},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"xyz\",{get:function(){return this.xyzOut},enumerable:!1,configurable:!0}),t.prototype._inputRename=function(e){return\"xyzw \"===e?\"xyzwIn\":\"xyz \"===e?\"xyzIn\":\"xy \"===e?\"xyIn\":\"zw \"===e?\"zwIn\":e},t.prototype._buildSwizzle=function(e){return\".\"+(this.xSwizzle+this.ySwizzle+this.zSwizzle+this.wSwizzle).substr(0,e)},t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i=this.x,n=this.y,r=this.z,o=this.w,a=this.xyIn,s=this.zwIn,l=this.xyzIn,c=this.xyzwIn,u=this._outputs[0],h=this._outputs[1],d=this._outputs[2],p=this._outputs[3];return c.isConnected?(u.hasEndpoints&&(t.compilationString+=this._declareOutput(u,t)+\" = \".concat(c.associatedVariableName).concat(this._buildSwizzle(4),\";\\r\\n\")),h.hasEndpoints&&(t.compilationString+=this._declareOutput(h,t)+\" = \".concat(c.associatedVariableName).concat(this._buildSwizzle(3),\";\\r\\n\")),d.hasEndpoints&&(t.compilationString+=this._declareOutput(d,t)+\" = \".concat(c.associatedVariableName).concat(this._buildSwizzle(2),\";\\r\\n\"))):l.isConnected?(u.hasEndpoints&&(t.compilationString+=this._declareOutput(u,t)+\" = vec4(\".concat(l.associatedVariableName,\", \").concat(o.isConnected?this._writeVariable(o):\"0.0\",\")\").concat(this._buildSwizzle(4),\";\\r\\n\")),h.hasEndpoints&&(t.compilationString+=this._declareOutput(h,t)+\" = \".concat(l.associatedVariableName).concat(this._buildSwizzle(3),\";\\r\\n\")),d.hasEndpoints&&(t.compilationString+=this._declareOutput(d,t)+\" = \".concat(l.associatedVariableName).concat(this._buildSwizzle(2),\";\\r\\n\"))):a.isConnected?(u.hasEndpoints&&(s.isConnected?t.compilationString+=this._declareOutput(u,t)+\" = vec4(\".concat(a.associatedVariableName,\", \").concat(s.associatedVariableName,\")\").concat(this._buildSwizzle(4),\";\\r\\n\"):t.compilationString+=this._declareOutput(u,t)+\" = vec4(\".concat(a.associatedVariableName,\", \").concat(r.isConnected?this._writeVariable(r):\"0.0\",\", \").concat(o.isConnected?this._writeVariable(o):\"0.0\",\")\").concat(this._buildSwizzle(4),\";\\r\\n\")),h.hasEndpoints&&(t.compilationString+=this._declareOutput(h,t)+\" = vec3(\".concat(a.associatedVariableName,\", \").concat(r.isConnected?this._writeVariable(r):\"0.0\",\")\").concat(this._buildSwizzle(3),\";\\r\\n\")),d.hasEndpoints&&(t.compilationString+=this._declareOutput(d,t)+\" = \".concat(a.associatedVariableName).concat(this._buildSwizzle(2),\";\\r\\n\")),p.hasEndpoints&&(s.isConnected?t.compilationString+=this._declareOutput(p,t)+\" = \".concat(s.associatedVariableName).concat(this._buildSwizzle(2),\";\\r\\n\"):t.compilationString+=this._declareOutput(p,t)+\" = vec2(\".concat(r.isConnected?this._writeVariable(r):\"0.0\",\", \").concat(o.isConnected?this._writeVariable(o):\"0.0\",\")\").concat(this._buildSwizzle(2),\";\\r\\n\"))):(u.hasEndpoints&&(s.isConnected?t.compilationString+=this._declareOutput(u,t)+\" = vec4(\".concat(i.isConnected?this._writeVariable(i):\"0.0\",\", \").concat(n.isConnected?this._writeVariable(n):\"0.0\",\", \").concat(s.associatedVariableName,\")\").concat(this._buildSwizzle(4),\";\\r\\n\"):t.compilationString+=this._declareOutput(u,t)+\" = vec4(\".concat(i.isConnected?this._writeVariable(i):\"0.0\",\", \").concat(n.isConnected?this._writeVariable(n):\"0.0\",\", \").concat(r.isConnected?this._writeVariable(r):\"0.0\",\", \").concat(o.isConnected?this._writeVariable(o):\"0.0\",\")\").concat(this._buildSwizzle(4),\";\\r\\n\")),h.hasEndpoints&&(t.compilationString+=this._declareOutput(h,t)+\" = vec3(\".concat(i.isConnected?this._writeVariable(i):\"0.0\",\", \").concat(n.isConnected?this._writeVariable(n):\"0.0\",\", \").concat(r.isConnected?this._writeVariable(r):\"0.0\",\")\").concat(this._buildSwizzle(3),\";\\r\\n\")),d.hasEndpoints&&(t.compilationString+=this._declareOutput(d,t)+\" = vec2(\".concat(i.isConnected?this._writeVariable(i):\"0.0\",\", \").concat(n.isConnected?this._writeVariable(n):\"0.0\",\")\").concat(this._buildSwizzle(2),\";\\r\\n\")),p.hasEndpoints&&(s.isConnected?t.compilationString+=this._declareOutput(p,t)+\" = \".concat(s.associatedVariableName).concat(this._buildSwizzle(2),\";\\r\\n\"):t.compilationString+=this._declareOutput(p,t)+\" = vec2(\".concat(r.isConnected?this._writeVariable(r):\"0.0\",\", \").concat(o.isConnected?this._writeVariable(o):\"0.0\",\")\").concat(this._buildSwizzle(2),\";\\r\\n\"))),this},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.xSwizzle=this.xSwizzle,t.ySwizzle=this.ySwizzle,t.zSwizzle=this.zSwizzle,t.wSwizzle=this.wSwizzle,t},t.prototype._deserialize=function(t,i,n){var r,o,a,s;e.prototype._deserialize.call(this,t,i,n),this.xSwizzle=null!==(r=t.xSwizzle)&&void 0!==r?r:\"x\",this.ySwizzle=null!==(o=t.ySwizzle)&&void 0!==o?o:\"y\",this.zSwizzle=null!==(a=t.zSwizzle)&&void 0!==a?a:\"z\",this.wSwizzle=null!==(s=t.wSwizzle)&&void 0!==s?s:\"w\"},t.prototype._dumpPropertiesCode=function(){var t=e.prototype._dumpPropertiesCode.call(this);return t+=\"\".concat(this._codeVariableName,'.xSwizzle = \"').concat(this.xSwizzle,'\";\\r\\n'),t+=\"\".concat(this._codeVariableName,'.ySwizzle = \"').concat(this.ySwizzle,'\";\\r\\n'),(t+=\"\".concat(this._codeVariableName,'.zSwizzle = \"').concat(this.zSwizzle,'\";\\r\\n'))+\"\".concat(this._codeVariableName,'.wSwizzle = \"').concat(this.wSwizzle,'\";\\r\\n')},t}(Xo);b(\"BABYLON.VectorMergerBlock\",fa);var _a=function(e){function t(t){var i=e.call(this,t,Bo.Neutral)||this;return i.sourceRange=new R(-1,1),i.targetRange=new R(0,1),i.registerInput(\"input\",wo.AutoDetect),i.registerInput(\"sourceMin\",wo.Float,!0),i.registerInput(\"sourceMax\",wo.Float,!0),i.registerInput(\"targetMin\",wo.Float,!0),i.registerInput(\"targetMax\",wo.Float,!0),i.registerOutput(\"output\",wo.BasedOnInput),i._outputs[0]._typeConnectionSource=i._inputs[0],i}return V(t,e),t.prototype.getClassName=function(){return\"RemapBlock\"},Object.defineProperty(t.prototype,\"input\",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"sourceMin\",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"sourceMax\",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"targetMin\",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"targetMax\",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"output\",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i=this._outputs[0],n=this.sourceMin.isConnected?this.sourceMin.associatedVariableName:this._writeFloat(this.sourceRange.x),r=this.sourceMax.isConnected?this.sourceMax.associatedVariableName:this._writeFloat(this.sourceRange.y),o=this.targetMin.isConnected?this.targetMin.associatedVariableName:this._writeFloat(this.targetRange.x),a=this.targetMax.isConnected?this.targetMax.associatedVariableName:this._writeFloat(this.targetRange.y);return t.compilationString+=this._declareOutput(i,t)+\" = \".concat(o,\" + (\").concat(this._inputs[0].associatedVariableName,\" - \").concat(n,\") * (\").concat(a,\" - \").concat(o,\") / (\").concat(r,\" - \").concat(n,\");\\r\\n\"),this},t.prototype._dumpPropertiesCode=function(){return e.prototype._dumpPropertiesCode.call(this)+\"\".concat(this._codeVariableName,\".sourceRange = new BABYLON.Vector2(\").concat(this.sourceRange.x,\", \").concat(this.sourceRange.y,\");\\r\\n\")+\"\".concat(this._codeVariableName,\".targetRange = new BABYLON.Vector2(\").concat(this.targetRange.x,\", \").concat(this.targetRange.y,\");\\r\\n\")},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.sourceRange=this.sourceRange.asArray(),t.targetRange=this.targetRange.asArray(),t},t.prototype._deserialize=function(t,i,n){e.prototype._deserialize.call(this,t,i,n),this.sourceRange=R.FromArray(t.sourceRange),this.targetRange=R.FromArray(t.targetRange)},G([Qo(\"From\",Yo.Vector2)],t.prototype,\"sourceRange\",void 0),G([Qo(\"To\",Yo.Vector2)],t.prototype,\"targetRange\",void 0),t}(Xo);b(\"BABYLON.RemapBlock\",_a);var ma,ga=function(e){function t(t){var i=e.call(this,t,Bo.Neutral)||this;return i.registerInput(\"left\",wo.AutoDetect),i.registerInput(\"right\",wo.AutoDetect),i.registerOutput(\"output\",wo.BasedOnInput),i._outputs[0]._typeConnectionSource=i._inputs[0],i._linkConnectionTypes(0,1),i}return V(t,e),t.prototype.getClassName=function(){return\"MultiplyBlock\"},Object.defineProperty(t.prototype,\"left\",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"right\",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"output\",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i=this._outputs[0];return t.compilationString+=this._declareOutput(i,t)+\" = \".concat(this.left.associatedVariableName,\" * \").concat(this.right.associatedVariableName,\";\\r\\n\"),this},t}(Xo);b(\"BABYLON.MultiplyBlock\",ga),function(e){e[e.Material=0]=\"Material\",e[e.PostProcess=1]=\"PostProcess\",e[e.Particle=2]=\"Particle\",e[e.ProceduralTexture=3]=\"ProceduralTexture\"}(ma||(ma={}));var va=function(){function e(){this.direction1=new x(0,1,0),this.direction2=new x(0,1,0),this.minEmitBox=new x(-.5,-.5,-.5),this.maxEmitBox=new x(.5,.5,.5)}return e.prototype.startDirectionFunction=function(e,t,i,n){var r=h.RandomRange(this.direction1.x,this.direction2.x),o=h.RandomRange(this.direction1.y,this.direction2.y),a=h.RandomRange(this.direction1.z,this.direction2.z);if(n)return t.x=r,t.y=o,void(t.z=a);x.TransformNormalFromFloatsToRef(r,o,a,e,t)},e.prototype.startPositionFunction=function(e,t,i,n){var r=h.RandomRange(this.minEmitBox.x,this.maxEmitBox.x),o=h.RandomRange(this.minEmitBox.y,this.maxEmitBox.y),a=h.RandomRange(this.minEmitBox.z,this.maxEmitBox.z);if(n)return t.x=r,t.y=o,void(t.z=a);x.TransformCoordinatesFromFloatsToRef(r,o,a,e,t)},e.prototype.clone=function(){var t=new e;return se.DeepCopy(this,t),t},e.prototype.applyToShader=function(e){e.setVector3(\"direction1\",this.direction1),e.setVector3(\"direction2\",this.direction2),e.setVector3(\"minEmitBox\",this.minEmitBox),e.setVector3(\"maxEmitBox\",this.maxEmitBox)},e.prototype.buildUniformLayout=function(e){e.addUniform(\"direction1\",3),e.addUniform(\"direction2\",3),e.addUniform(\"minEmitBox\",3),e.addUniform(\"maxEmitBox\",3)},e.prototype.getEffectDefines=function(){return\"#define BOXEMITTER\"},e.prototype.getClassName=function(){return\"BoxParticleEmitter\"},e.prototype.serialize=function(){var e={};return e.type=this.getClassName(),e.direction1=this.direction1.asArray(),e.direction2=this.direction2.asArray(),e.minEmitBox=this.minEmitBox.asArray(),e.maxEmitBox=this.maxEmitBox.asArray(),e},e.prototype.parse=function(e){x.FromArrayToRef(e.direction1,0,this.direction1),x.FromArrayToRef(e.direction2,0,this.direction2),x.FromArrayToRef(e.minEmitBox,0,this.minEmitBox),x.FromArrayToRef(e.maxEmitBox,0,this.maxEmitBox)},e}(),ya=function(){function e(e,t,i){void 0===e&&(e=1),void 0===t&&(t=Math.PI),void 0===i&&(i=0),this.directionRandomizer=i,this.radiusRange=1,this.heightRange=1,this.emitFromSpawnPointOnly=!1,this.angle=t,this.radius=e}return Object.defineProperty(e.prototype,\"radius\",{get:function(){return this._radius},set:function(e){this._radius=e,this._buildHeight()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"angle\",{get:function(){return this._angle},set:function(e){this._angle=e,this._buildHeight()},enumerable:!1,configurable:!0}),e.prototype._buildHeight=function(){0!==this._angle?this._height=this._radius/Math.tan(this._angle/2):this._height=1},e.prototype.startDirectionFunction=function(e,t,i,n){n?O.Vector3[0].copyFrom(i._localPosition).normalize():i.position.subtractToRef(e.getTranslation(),O.Vector3[0]).normalize();var r=h.RandomRange(0,this.directionRandomizer),o=h.RandomRange(0,this.directionRandomizer),a=h.RandomRange(0,this.directionRandomizer);t.x=O.Vector3[0].x+r,t.y=O.Vector3[0].y+o,t.z=O.Vector3[0].z+a,t.normalize()},e.prototype.startPositionFunction=function(e,t,i,n){var r,o=h.RandomRange(0,2*Math.PI);r=this.emitFromSpawnPointOnly?1e-4:1-(r=h.RandomRange(0,this.heightRange))*r;var a=this._radius-h.RandomRange(0,this._radius*this.radiusRange),s=(a*=r)*Math.sin(o),l=a*Math.cos(o),c=r*this._height;if(n)return t.x=s,t.y=c,void(t.z=l);x.TransformCoordinatesFromFloatsToRef(s,c,l,e,t)},e.prototype.clone=function(){var t=new e(this._radius,this._angle,this.directionRandomizer);return se.DeepCopy(this,t),t},e.prototype.applyToShader=function(e){e.setFloat2(\"radius\",this._radius,this.radiusRange),e.setFloat(\"coneAngle\",this._angle),e.setFloat2(\"height\",this._height,this.heightRange),e.setFloat(\"directionRandomizer\",this.directionRandomizer)},e.prototype.buildUniformLayout=function(e){e.addUniform(\"radius\",2),e.addUniform(\"coneAngle\",1),e.addUniform(\"height\",2),e.addUniform(\"directionRandomizer\",1)},e.prototype.getEffectDefines=function(){var e=\"#define CONEEMITTER\";return this.emitFromSpawnPointOnly&&(e+=\"\\n#define CONEEMITTERSPAWNPOINT\"),e},e.prototype.getClassName=function(){return\"ConeParticleEmitter\"},e.prototype.serialize=function(){var e={};return e.type=this.getClassName(),e.radius=this._radius,e.angle=this._angle,e.directionRandomizer=this.directionRandomizer,e.radiusRange=this.radiusRange,e.heightRange=this.heightRange,e.emitFromSpawnPointOnly=this.emitFromSpawnPointOnly,e},e.prototype.parse=function(e){this.radius=e.radius,this.angle=e.angle,this.directionRandomizer=e.directionRandomizer,this.radiusRange=void 0!==e.radiusRange?e.radiusRange:1,this.heightRange=void 0!==e.radiusRange?e.heightRange:1,this.emitFromSpawnPointOnly=void 0!==e.emitFromSpawnPointOnly&&e.emitFromSpawnPointOnly},e}(),ba=function(){function e(e,t,i,n){void 0===e&&(e=1),void 0===t&&(t=1),void 0===i&&(i=1),void 0===n&&(n=0),this.radius=e,this.height=t,this.radiusRange=i,this.directionRandomizer=n,this._tempVector=x.Zero()}return e.prototype.startDirectionFunction=function(e,t,i,n,r){i.position.subtractToRef(e.getTranslation(),this._tempVector),this._tempVector.normalize(),x.TransformNormalToRef(this._tempVector,r,this._tempVector);var o=h.RandomRange(-this.directionRandomizer/2,this.directionRandomizer/2),a=Math.atan2(this._tempVector.x,this._tempVector.z);a+=h.RandomRange(-Math.PI/2,Math.PI/2)*this.directionRandomizer,this._tempVector.y=o,this._tempVector.x=Math.sin(a),this._tempVector.z=Math.cos(a),this._tempVector.normalize(),n?t.copyFrom(this._tempVector):x.TransformNormalFromFloatsToRef(this._tempVector.x,this._tempVector.y,this._tempVector.z,e,t)},e.prototype.startPositionFunction=function(e,t,i,n){var r=h.RandomRange(-this.height/2,this.height/2),o=h.RandomRange(0,2*Math.PI),a=h.RandomRange((1-this.radiusRange)*(1-this.radiusRange),1),s=Math.sqrt(a)*this.radius,l=s*Math.cos(o),c=s*Math.sin(o);n?t.copyFromFloats(l,r,c):x.TransformCoordinatesFromFloatsToRef(l,r,c,e,t)},e.prototype.clone=function(){var t=new e(this.radius,this.directionRandomizer);return se.DeepCopy(this,t),t},e.prototype.applyToShader=function(e){e.setFloat(\"radius\",this.radius),e.setFloat(\"height\",this.height),e.setFloat(\"radiusRange\",this.radiusRange),e.setFloat(\"directionRandomizer\",this.directionRandomizer)},e.prototype.buildUniformLayout=function(e){e.addUniform(\"radius\",1),e.addUniform(\"height\",1),e.addUniform(\"radiusRange\",1),e.addUniform(\"directionRandomizer\",1)},e.prototype.getEffectDefines=function(){return\"#define CYLINDEREMITTER\"},e.prototype.getClassName=function(){return\"CylinderParticleEmitter\"},e.prototype.serialize=function(){var e={};return e.type=this.getClassName(),e.radius=this.radius,e.height=this.height,e.radiusRange=this.radiusRange,e.directionRandomizer=this.directionRandomizer,e},e.prototype.parse=function(e){this.radius=e.radius,this.height=e.height,this.radiusRange=e.radiusRange,this.directionRandomizer=e.directionRandomizer},e}(),Ta=function(e){function t(t,i,n,r,o){void 0===t&&(t=1),void 0===i&&(i=1),void 0===n&&(n=1),void 0===r&&(r=new x(0,1,0)),void 0===o&&(o=new x(0,1,0));var a=e.call(this,t,i,n)||this;return a.direction1=r,a.direction2=o,a}return V(t,e),t.prototype.startDirectionFunction=function(e,t){var i=h.RandomRange(this.direction1.x,this.direction2.x),n=h.RandomRange(this.direction1.y,this.direction2.y),r=h.RandomRange(this.direction1.z,this.direction2.z);x.TransformNormalFromFloatsToRef(i,n,r,e,t)},t.prototype.clone=function(){var e=new t(this.radius,this.height,this.radiusRange,this.direction1,this.direction2);return se.DeepCopy(this,e),e},t.prototype.applyToShader=function(e){e.setFloat(\"radius\",this.radius),e.setFloat(\"height\",this.height),e.setFloat(\"radiusRange\",this.radiusRange),e.setVector3(\"direction1\",this.direction1),e.setVector3(\"direction2\",this.direction2)},t.prototype.buildUniformLayout=function(e){e.addUniform(\"radius\",1),e.addUniform(\"height\",1),e.addUniform(\"radiusRange\",1),e.addUniform(\"direction1\",3),e.addUniform(\"direction2\",3)},t.prototype.getEffectDefines=function(){return\"#define CYLINDEREMITTER\\n#define DIRECTEDCYLINDEREMITTER\"},t.prototype.getClassName=function(){return\"CylinderDirectedParticleEmitter\"},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.direction1=this.direction1.asArray(),t.direction2=this.direction2.asArray(),t},t.prototype.parse=function(t){e.prototype.parse.call(this,t),this.direction1.copyFrom(t.direction1),this.direction2.copyFrom(t.direction2)},t}(ba),Ea=function(){function e(e,t,i){void 0===e&&(e=1),void 0===t&&(t=1),void 0===i&&(i=0),this.radius=e,this.radiusRange=t,this.directionRandomizer=i}return e.prototype.startDirectionFunction=function(e,t,i,n){var r=i.position.subtract(e.getTranslation()).normalize(),o=h.RandomRange(0,this.directionRandomizer),a=h.RandomRange(0,this.directionRandomizer),s=h.RandomRange(0,this.directionRandomizer);r.x+=o,r.y+=a,r.z+=s,r.normalize(),n?t.copyFrom(r):x.TransformNormalFromFloatsToRef(r.x,r.y,r.z,e,t)},e.prototype.startPositionFunction=function(e,t,i,n){var r=this.radius-h.RandomRange(0,this.radius*this.radiusRange),o=h.RandomRange(0,1),a=h.RandomRange(0,2*Math.PI),s=Math.acos(2*o-1),l=r*Math.cos(a)*Math.sin(s),c=r*Math.cos(s),u=r*Math.sin(a)*Math.sin(s);n?t.copyFromFloats(l,Math.abs(c),u):x.TransformCoordinatesFromFloatsToRef(l,Math.abs(c),u,e,t)},e.prototype.clone=function(){var t=new e(this.radius,this.directionRandomizer);return se.DeepCopy(this,t),t},e.prototype.applyToShader=function(e){e.setFloat(\"radius\",this.radius),e.setFloat(\"radiusRange\",this.radiusRange),e.setFloat(\"directionRandomizer\",this.directionRandomizer)},e.prototype.buildUniformLayout=function(e){e.addUniform(\"radius\",1),e.addUniform(\"radiusRange\",1),e.addUniform(\"directionRandomizer\",1)},e.prototype.getEffectDefines=function(){return\"#define HEMISPHERICEMITTER\"},e.prototype.getClassName=function(){return\"HemisphericParticleEmitter\"},e.prototype.serialize=function(){var e={};return e.type=this.getClassName(),e.radius=this.radius,e.radiusRange=this.radiusRange,e.directionRandomizer=this.directionRandomizer,e},e.prototype.parse=function(e){this.radius=e.radius,this.radiusRange=e.radiusRange,this.directionRandomizer=e.directionRandomizer},e}(),Sa=function(){function e(){this.direction1=new x(0,1,0),this.direction2=new x(0,1,0)}return e.prototype.startDirectionFunction=function(e,t,i,n){var r=h.RandomRange(this.direction1.x,this.direction2.x),o=h.RandomRange(this.direction1.y,this.direction2.y),a=h.RandomRange(this.direction1.z,this.direction2.z);n?t.copyFromFloats(r,o,a):x.TransformNormalFromFloatsToRef(r,o,a,e,t)},e.prototype.startPositionFunction=function(e,t,i,n){n?t.copyFromFloats(0,0,0):x.TransformCoordinatesFromFloatsToRef(0,0,0,e,t)},e.prototype.clone=function(){var t=new e;return se.DeepCopy(this,t),t},e.prototype.applyToShader=function(e){e.setVector3(\"direction1\",this.direction1),e.setVector3(\"direction2\",this.direction2)},e.prototype.buildUniformLayout=function(e){e.addUniform(\"direction1\",3),e.addUniform(\"direction2\",3)},e.prototype.getEffectDefines=function(){return\"#define POINTEMITTER\"},e.prototype.getClassName=function(){return\"PointParticleEmitter\"},e.prototype.serialize=function(){var e={};return e.type=this.getClassName(),e.direction1=this.direction1.asArray(),e.direction2=this.direction2.asArray(),e},e.prototype.parse=function(e){x.FromArrayToRef(e.direction1,0,this.direction1),x.FromArrayToRef(e.direction2,0,this.direction2)},e}(),Aa=function(){function e(e,t,i){void 0===e&&(e=1),void 0===t&&(t=1),void 0===i&&(i=0),this.radius=e,this.radiusRange=t,this.directionRandomizer=i}return e.prototype.startDirectionFunction=function(e,t,i,n){var r=i.position.subtract(e.getTranslation()).normalize(),o=h.RandomRange(0,this.directionRandomizer),a=h.RandomRange(0,this.directionRandomizer),s=h.RandomRange(0,this.directionRandomizer);r.x+=o,r.y+=a,r.z+=s,r.normalize(),n?t.copyFrom(r):x.TransformNormalFromFloatsToRef(r.x,r.y,r.z,e,t)},e.prototype.startPositionFunction=function(e,t,i,n){var r=this.radius-h.RandomRange(0,this.radius*this.radiusRange),o=h.RandomRange(0,1),a=h.RandomRange(0,2*Math.PI),s=Math.acos(2*o-1),l=r*Math.cos(a)*Math.sin(s),c=r*Math.cos(s),u=r*Math.sin(a)*Math.sin(s);n?t.copyFromFloats(l,c,u):x.TransformCoordinatesFromFloatsToRef(l,c,u,e,t)},e.prototype.clone=function(){var t=new e(this.radius,this.directionRandomizer);return se.DeepCopy(this,t),t},e.prototype.applyToShader=function(e){e.setFloat(\"radius\",this.radius),e.setFloat(\"radiusRange\",this.radiusRange),e.setFloat(\"directionRandomizer\",this.directionRandomizer)},e.prototype.buildUniformLayout=function(e){e.addUniform(\"radius\",1),e.addUniform(\"radiusRange\",1),e.addUniform(\"directionRandomizer\",1)},e.prototype.getEffectDefines=function(){return\"#define SPHEREEMITTER\"},e.prototype.getClassName=function(){return\"SphereParticleEmitter\"},e.prototype.serialize=function(){var e={};return e.type=this.getClassName(),e.radius=this.radius,e.radiusRange=this.radiusRange,e.directionRandomizer=this.directionRandomizer,e},e.prototype.parse=function(e){this.radius=e.radius,this.radiusRange=e.radiusRange,this.directionRandomizer=e.directionRandomizer},e}(),Ra=function(e){function t(t,i,n){void 0===t&&(t=1),void 0===i&&(i=new x(0,1,0)),void 0===n&&(n=new x(0,1,0));var r=e.call(this,t)||this;return r.direction1=i,r.direction2=n,r}return V(t,e),t.prototype.startDirectionFunction=function(e,t){var i=h.RandomRange(this.direction1.x,this.direction2.x),n=h.RandomRange(this.direction1.y,this.direction2.y),r=h.RandomRange(this.direction1.z,this.direction2.z);x.TransformNormalFromFloatsToRef(i,n,r,e,t)},t.prototype.clone=function(){var e=new t(this.radius,this.direction1,this.direction2);return se.DeepCopy(this,e),e},t.prototype.applyToShader=function(e){e.setFloat(\"radius\",this.radius),e.setFloat(\"radiusRange\",this.radiusRange),e.setVector3(\"direction1\",this.direction1),e.setVector3(\"direction2\",this.direction2)},t.prototype.buildUniformLayout=function(e){e.addUniform(\"radius\",1),e.addUniform(\"radiusRange\",1),e.addUniform(\"direction1\",3),e.addUniform(\"direction2\",3)},t.prototype.getEffectDefines=function(){return\"#define SPHEREEMITTER\\n#define DIRECTEDSPHEREEMITTER\"},t.prototype.getClassName=function(){return\"SphereDirectedParticleEmitter\"},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.direction1=this.direction1.asArray(),t.direction2=this.direction2.asArray(),t},t.prototype.parse=function(t){e.prototype.parse.call(this,t),this.direction1.copyFrom(t.direction1),this.direction2.copyFrom(t.direction2)},t}(Aa),xa=function(){function e(){this.particlePositionGenerator=function(){},this.particleDestinationGenerator=function(){}}return e.prototype.startDirectionFunction=function(e,t,i,n){var r=O.Vector3[0];if(this.particleDestinationGenerator){this.particleDestinationGenerator(-1,i,r);var o=O.Vector3[1];r.subtractToRef(i.position,o),o.scaleToRef(1/i.lifeTime,r)}else r.set(0,0,0);n?t.copyFrom(r):x.TransformNormalToRef(r,e,t)},e.prototype.startPositionFunction=function(e,t,i,n){var r=O.Vector3[0];this.particlePositionGenerator?this.particlePositionGenerator(-1,i,r):r.set(0,0,0),n?t.copyFrom(r):x.TransformCoordinatesToRef(r,e,t)},e.prototype.clone=function(){var t=new e;return se.DeepCopy(this,t),t},e.prototype.applyToShader=function(e){},e.prototype.buildUniformLayout=function(e){},e.prototype.getEffectDefines=function(){return\"#define CUSTOMEMITTER\"},e.prototype.getClassName=function(){return\"CustomParticleEmitter\"},e.prototype.serialize=function(){var e={};return e.type=this.getClassName(),e},e.prototype.parse=function(e){},e}(),Ca=function(){function e(e){void 0===e&&(e=null),this._indices=null,this._positions=null,this._normals=null,this._storedNormal=x.Zero(),this._mesh=null,this.direction1=new x(0,1,0),this.direction2=new x(0,1,0),this.useMeshNormalsForDirection=!0,this.mesh=e}return Object.defineProperty(e.prototype,\"mesh\",{get:function(){return this._mesh},set:function(e){this._mesh!==e&&(this._mesh=e,e?(this._indices=e.getIndices(),this._positions=e.getVerticesData(wi.PositionKind),this._normals=e.getVerticesData(wi.NormalKind)):(this._indices=null,this._positions=null,this._normals=null))},enumerable:!1,configurable:!0}),e.prototype.startDirectionFunction=function(e,t,i,n){if(this.useMeshNormalsForDirection&&this._normals)x.TransformNormalToRef(this._storedNormal,e,t);else{var r=h.RandomRange(this.direction1.x,this.direction2.x),o=h.RandomRange(this.direction1.y,this.direction2.y),a=h.RandomRange(this.direction1.z,this.direction2.z);n?t.copyFromFloats(r,o,a):x.TransformNormalFromFloatsToRef(r,o,a,e,t)}},e.prototype.startPositionFunction=function(e,t,i,n){if(this._indices&&this._positions){var r=3*Math.random()*(this._indices.length/3)|0,o=Math.random(),a=Math.random()*(1-o),s=1-o-a,l=this._indices[r],c=this._indices[r+1],u=this._indices[r+2],h=O.Vector3[0],d=O.Vector3[1],p=O.Vector3[2],f=O.Vector3[3];x.FromArrayToRef(this._positions,3*l,h),x.FromArrayToRef(this._positions,3*c,d),x.FromArrayToRef(this._positions,3*u,p),f.x=o*h.x+a*d.x+s*p.x,f.y=o*h.y+a*d.y+s*p.y,f.z=o*h.z+a*d.z+s*p.z,n?t.copyFromFloats(f.x,f.y,f.z):x.TransformCoordinatesFromFloatsToRef(f.x,f.y,f.z,e,t),this.useMeshNormalsForDirection&&this._normals&&(x.FromArrayToRef(this._normals,3*l,h),x.FromArrayToRef(this._normals,3*c,d),x.FromArrayToRef(this._normals,3*u,p),this._storedNormal.x=o*h.x+a*d.x+s*p.x,this._storedNormal.y=o*h.y+a*d.y+s*p.y,this._storedNormal.z=o*h.z+a*d.z+s*p.z)}},e.prototype.clone=function(){var t=new e(this.mesh);return se.DeepCopy(this,t),t},e.prototype.applyToShader=function(e){e.setVector3(\"direction1\",this.direction1),e.setVector3(\"direction2\",this.direction2)},e.prototype.buildUniformLayout=function(e){e.addUniform(\"direction1\",3),e.addUniform(\"direction2\",3)},e.prototype.getEffectDefines=function(){return\"\"},e.prototype.getClassName=function(){return\"MeshParticleEmitter\"},e.prototype.serialize=function(){var e,t={};return t.type=this.getClassName(),t.direction1=this.direction1.asArray(),t.direction2=this.direction2.asArray(),t.meshId=null===(e=this.mesh)||void 0===e?void 0:e.id,t.useMeshNormalsForDirection=this.useMeshNormalsForDirection,t},e.prototype.parse=function(e,t){x.FromArrayToRef(e.direction1,0,this.direction1),x.FromArrayToRef(e.direction2,0,this.direction2),e.meshId&&t&&(this.mesh=t.getLastMeshById(e.meshId)),this.useMeshNormalsForDirection=e.useMeshNormalsForDirection},e}(),Pa=function(){function e(t){this.animations=[],this.renderingGroupId=0,this.emitter=x.Zero(),this.emitRate=10,this.manualEmitCount=-1,this.updateSpeed=.01,this.targetStopDuration=0,this.disposeOnStop=!1,this.minEmitPower=1,this.maxEmitPower=1,this.minLifeTime=1,this.maxLifeTime=1,this.minSize=1,this.maxSize=1,this.minScaleX=1,this.maxScaleX=1,this.minScaleY=1,this.maxScaleY=1,this.minInitialRotation=0,this.maxInitialRotation=0,this.minAngularSpeed=0,this.maxAngularSpeed=0,this.layerMask=268435455,this.customShader=null,this.preventAutoStart=!1,this._wasDispatched=!1,this._rootUrl=\"\",this.noiseStrength=new x(10,10,10),this.onAnimationEnd=null,this.blendMode=e.BLENDMODE_ONEONE,this.forceDepthWrite=!1,this.preWarmCycles=0,this.preWarmStepOffset=1,this.spriteCellChangeSpeed=1,this.startSpriteCellID=0,this.endSpriteCellID=0,this.spriteCellWidth=0,this.spriteCellHeight=0,this.spriteCellLoop=!0,this.spriteRandomStartCell=!1,this.translationPivot=new R(0,0),this.beginAnimationOnStart=!1,this.beginAnimationFrom=0,this.beginAnimationTo=60,this.beginAnimationLoop=!1,this.worldOffset=new x(0,0,0),this._useLogarithmicDepth=!1,this.gravity=x.Zero(),this._colorGradients=null,this._sizeGradients=null,this._lifeTimeGradients=null,this._angularSpeedGradients=null,this._velocityGradients=null,this._limitVelocityGradients=null,this._dragGradients=null,this._emitRateGradients=null,this._startSizeGradients=null,this._rampGradients=null,this._colorRemapGradients=null,this._alphaRemapGradients=null,this.startDelay=0,this.limitVelocityDamping=.4,this.color1=new L(1,1,1,1),this.color2=new L(1,1,1,1),this.colorDead=new L(0,0,0,1),this.textureMask=new L(1,1,1,1),this._isSubEmitter=!1,this._billboardMode=a.PARTICLES_BILLBOARDMODE_ALL,this._isBillboardBased=!0,this._imageProcessingConfigurationDefines=new Ai,this.id=t,this.name=t}return Object.defineProperty(e.prototype,\"noiseTexture\",{get:function(){return this._noiseTexture},set:function(e){this._noiseTexture!==e&&(this._noiseTexture=e,this._reset())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"isAnimationSheetEnabled\",{get:function(){return this._isAnimationSheetEnabled},set:function(e){this._isAnimationSheetEnabled!=e&&(this._isAnimationSheetEnabled=e,this._reset())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"useLogarithmicDepth\",{get:function(){return this._useLogarithmicDepth},set:function(e){this._useLogarithmicDepth=e&&this.getScene().getEngine().getCaps().fragmentDepthSupported},enumerable:!1,configurable:!0}),e.prototype.getScene=function(){return this._scene},e.prototype._hasTargetStopDurationDependantGradient=function(){return this._startSizeGradients&&this._startSizeGradients.length>0||this._emitRateGradients&&this._emitRateGradients.length>0||this._lifeTimeGradients&&this._lifeTimeGradients.length>0},e.prototype.getDragGradients=function(){return this._dragGradients},e.prototype.getLimitVelocityGradients=function(){return this._limitVelocityGradients},e.prototype.getColorGradients=function(){return this._colorGradients},e.prototype.getSizeGradients=function(){return this._sizeGradients},e.prototype.getColorRemapGradients=function(){return this._colorRemapGradients},e.prototype.getAlphaRemapGradients=function(){return this._alphaRemapGradients},e.prototype.getLifeTimeGradients=function(){return this._lifeTimeGradients},e.prototype.getAngularSpeedGradients=function(){return this._angularSpeedGradients},e.prototype.getVelocityGradients=function(){return this._velocityGradients},e.prototype.getStartSizeGradients=function(){return this._startSizeGradients},e.prototype.getEmitRateGradients=function(){return this._emitRateGradients},Object.defineProperty(e.prototype,\"direction1\",{get:function(){return this.particleEmitterType.direction1?this.particleEmitterType.direction1:x.Zero()},set:function(e){this.particleEmitterType.direction1&&(this.particleEmitterType.direction1=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"direction2\",{get:function(){return this.particleEmitterType.direction2?this.particleEmitterType.direction2:x.Zero()},set:function(e){this.particleEmitterType.direction2&&(this.particleEmitterType.direction2=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"minEmitBox\",{get:function(){return this.particleEmitterType.minEmitBox?this.particleEmitterType.minEmitBox:x.Zero()},set:function(e){this.particleEmitterType.minEmitBox&&(this.particleEmitterType.minEmitBox=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"maxEmitBox\",{get:function(){return this.particleEmitterType.maxEmitBox?this.particleEmitterType.maxEmitBox:x.Zero()},set:function(e){this.particleEmitterType.maxEmitBox&&(this.particleEmitterType.maxEmitBox=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"billboardMode\",{get:function(){return this._billboardMode},set:function(e){this._billboardMode!==e&&(this._billboardMode=e,this._reset())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"isBillboardBased\",{get:function(){return this._isBillboardBased},set:function(e){this._isBillboardBased!==e&&(this._isBillboardBased=e,this._reset())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"imageProcessingConfiguration\",{get:function(){return this._imageProcessingConfiguration},set:function(e){this._attachImageProcessingConfiguration(e)},enumerable:!1,configurable:!0}),e.prototype._attachImageProcessingConfiguration=function(e){e!==this._imageProcessingConfiguration&&(!e&&this._scene?this._imageProcessingConfiguration=this._scene.imageProcessingConfiguration:this._imageProcessingConfiguration=e)},e.prototype._reset=function(){},e.prototype._removeGradientAndTexture=function(e,t,i){if(!t)return this;for(var n=0,r=0,o=t;r0||0===n)&&(null===(i=T.getScene())||void 0===i||i.meshes.forEach((function(e){e._markSubMeshesAsLightDirty()})))},T.renderParticles=!0,T.renderSprites=!1,T.ignoreCameraViewport=!1,T.onBeforeBindObservable=new u,T.onAfterUnbindObservable=new u,T.onBeforeRenderObservable=new u,T.onAfterRenderObservable=new u,T.onClearObservable=new u,T.onResizeObservable=new u,T._cleared=!1,T.skipInitialClear=!1,T._currentRefreshId=-1,T._refreshRate=1,T._samples=1,T._canRescale=!0,T._renderTarget=null,T.boundingBoxPosition=x.Zero(),!(n=T.getScene()))return T;var E=T.getScene().getEngine();return T._coordinatesMode=to.PROJECTION_MODE,T.renderList=new Array,T.name=t,T.isRenderTarget=!0,T._initialSizeParameter=i,T._renderPassIds=[],T._isCubeData=l,T._processSizeParameter(i),T.renderPassId=T._renderPassIds[0],T._resizeObserver=E.onResizeObservable.add((function(){})),T._generateMipMaps=!!r,T._doNotChangeAspectRatio=o,T._renderingManager=new Gi(n),T._renderingManager._useSceneAutoClearSetup=!0,p||(T._renderTargetOptions={generateMipMaps:r,type:s,format:null!==(b=T._format)&&void 0!==b?b:void 0,samplingMode:T.samplingMode,generateDepthBuffer:h,generateStencilBuffer:d,samples:m,creationFlags:g,noColorTarget:v,useSRGBBuffer:y},T.samplingMode===to.NEAREST_SAMPLINGMODE&&(T.wrapU=to.CLAMP_ADDRESSMODE,T.wrapV=to.CLAMP_ADDRESSMODE),_||(l?(T._renderTarget=n.getEngine().createRenderTargetCubeTexture(T.getRenderSize(),T._renderTargetOptions),T.coordinatesMode=to.INVCUBIC_MODE,T._textureMatrix=M.Identity()):T._renderTarget=n.getEngine().createRenderTargetTexture(T._size,T._renderTargetOptions),T._texture=T._renderTarget.texture,void 0!==m&&(T.samples=m))),T}return V(t,e),Object.defineProperty(t.prototype,\"renderList\",{get:function(){return this._renderList},set:function(e){this._unObserveRenderList&&(this._unObserveRenderList(),this._unObserveRenderList=null),e&&(this._unObserveRenderList=v(e,this._renderListHasChanged)),this._renderList=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"postProcesses\",{get:function(){return this._postProcesses},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"_prePassEnabled\",{get:function(){return!!this._prePassRenderTarget&&this._prePassRenderTarget.enabled},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"onAfterUnbind\",{set:function(e){this._onAfterUnbindObserver&&this.onAfterUnbindObservable.remove(this._onAfterUnbindObserver),this._onAfterUnbindObserver=this.onAfterUnbindObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"onBeforeRender\",{set:function(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"onAfterRender\",{set:function(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=this.onAfterRenderObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"onClear\",{set:function(e){this._onClearObserver&&this.onClearObservable.remove(this._onClearObserver),this._onClearObserver=this.onClearObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"renderPassIds\",{get:function(){return this._renderPassIds},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"currentRefreshId\",{get:function(){return this._currentRefreshId},enumerable:!1,configurable:!0}),t.prototype.setMaterialForRendering=function(e,t){var i;i=Array.isArray(e)?e:[e];for(var n=0;n0&&(this._postProcesses[0].autoClear=!1))}},t.prototype._shouldRender=function(){return-1===this._currentRefreshId||this.refreshRate===this._currentRefreshId?(this._currentRefreshId=1,!0):(this._currentRefreshId++,!1)},t.prototype.getRenderSize=function(){return this.getRenderWidth()},t.prototype.getRenderWidth=function(){return this._size.width?this._size.width:this._size},t.prototype.getRenderHeight=function(){return this._size.width?this._size.height:this._size},t.prototype.getRenderLayers=function(){return this._size.layers||0},t.prototype.disableRescaling=function(){this._canRescale=!1},Object.defineProperty(t.prototype,\"canRescale\",{get:function(){return this._canRescale},enumerable:!1,configurable:!0}),t.prototype.scale=function(e){var t=Math.max(1,this.getRenderSize()*e);this.resize(t)},t.prototype.getReflectionTextureMatrix=function(){return this.isCube?this._textureMatrix:e.prototype.getReflectionTextureMatrix.call(this)},t.prototype.resize=function(e){var t,i=this.isCube;null===(t=this._renderTarget)||void 0===t||t.dispose(),this._renderTarget=null;var n=this.getScene();n&&(this._processSizeParameter(e),this._renderTarget=i?n.getEngine().createRenderTargetCubeTexture(this.getRenderSize(),this._renderTargetOptions):n.getEngine().createRenderTargetTexture(this._size,this._renderTargetOptions),this._texture=this._renderTarget.texture,void 0!==this._renderTargetOptions.samples&&(this.samples=this._renderTargetOptions.samples),this.onResizeObservable.hasObservers()&&this.onResizeObservable.notifyObservers(this))},t.prototype.render=function(e,t){void 0===e&&(e=!1),void 0===t&&(t=!1),this._render(e,t)},t.prototype.isReadyForRendering=function(){return this._render(!1,!1,!0)},t.prototype._render=function(e,t,i){var n;void 0===e&&(e=!1),void 0===t&&(t=!1),void 0===i&&(i=!1);var r=this.getScene();if(!r)return i;var o=r.getEngine();if(void 0!==this.useCameraPostProcesses&&(e=this.useCameraPostProcesses),this._waitingRenderList){this.renderList=[];for(var a=0;a1||this.activeCamera&&this.activeCamera!==r.activeCamera)&&r.setTransformMatrix(r.activeCamera.getViewMatrix(),r.activeCamera.getProjectionMatrix(!0)),o.setViewport(r.activeCamera.viewport)),r.resetCachedMaterial(),f},t.prototype._bestReflectionRenderTargetDimension=function(e,t){var i=e*t,n=vr.NearestPOT(i+16384/(128+i));return Math.min(vr.FloorPOT(e),n)},t.prototype._prepareRenderingManager=function(e,t,i,n){var r=this.getScene();if(r){this._renderingManager.reset();for(var o=r.getRenderId(),a=0;a=0&&this._renderingManager.dispatchParticles(p)}}},t.prototype._bindFrameBuffer=function(e,t){void 0===e&&(e=0),void 0===t&&(t=0);var i=this.getScene();if(i){var n=i.getEngine();this._renderTarget&&n.bindFramebuffer(this._renderTarget,this.isCube?e:void 0,void 0,void 0,this.ignoreCameraViewport,0,t)}},t.prototype._unbindFrameBuffer=function(e,t){var i=this;this._renderTarget&&e.unBindFramebuffer(this._renderTarget,this.isCube,(function(){i.onAfterRenderObservable.notifyObservers(t)}))},t.prototype._prepareFrame=function(e,t,i,n){this._postProcessManager?this._prePassEnabled||this._postProcessManager._prepareFrame(this._texture,this._postProcesses):n&&e.postProcessManager._prepareFrame(this._texture)||this._bindFrameBuffer(t,i)},t.prototype._renderToTarget=function(e,t,i,n,r){var o,s,l,c,u,h;void 0===n&&(n=0),void 0===r&&(r=null);var d=this.getScene();if(d){var p=d.getEngine();if(null===(o=p._debugPushGroup)||void 0===o||o.call(p,\"render to face #\".concat(e,\" layer #\").concat(n),1),this._prepareFrame(d,e,n,t),this.is2DArray?(p.currentRenderPassId=this._renderPassIds[n],this.onBeforeRenderObservable.notifyObservers(n)):(p.currentRenderPassId=this._renderPassIds[e],this.onBeforeRenderObservable.notifyObservers(e)),p.snapshotRendering&&p.snapshotRenderingMode===a.SNAPSHOTRENDERING_FAST)this.onClearObservable.hasObservers()?this.onClearObservable.notifyObservers(p):this.skipInitialClear||p.clear(this.clearColor||d.clearColor,!0,!0,!0);else{var f=null,_=this.renderList?this.renderList:d.getActiveMeshes().data,m=this.renderList?this.renderList.length:d.getActiveMeshes().length;this.getCustomRenderList&&(f=this.getCustomRenderList(this.is2DArray?n:e,_,m)),f?this._prepareRenderingManager(f,f.length,r,!1):(this._defaultRenderListPrepared||(this._prepareRenderingManager(_,m,r,!this.renderList),this._defaultRenderListPrepared=!0),f=_);for(var g=0,v=d._beforeRenderTargetClearStage;g=0&&i.customRenderTargets.splice(n,1);for(var r=0,o=i.cameras;r=0&&a.customRenderTargets.splice(n,1)}null===(t=this._renderTarget)||void 0===t||t.dispose(),this._renderTarget=null,this._texture=null,e.prototype.dispose.call(this)}},t.prototype._rebuild=function(){this.refreshRate===t.REFRESHRATE_RENDER_ONCE&&(this.refreshRate=t.REFRESHRATE_RENDER_ONCE),this._postProcessManager&&this._postProcessManager._rebuild()},t.prototype.freeRenderingGroups=function(){this._renderingManager&&this._renderingManager.freeRenderingGroups()},t.prototype.getViewCount=function(){return 1},t.REFRESHRATE_RENDER_ONCE=0,t.REFRESHRATE_RENDER_ONEVERYFRAME=1,t.REFRESHRATE_RENDER_ONEVERYTWOFRAMES=2,t}(to);to._CreateRenderTargetTexture=function(e,t,i,n,r){return new Ia(e,t,i,n)};var Oa=function(){function e(e){this.name=zi.NAME_PROCEDURALTEXTURE,this.scene=e,this.scene.proceduralTextures=new Array}return e.prototype.register=function(){this.scene._beforeClearStage.registerStep(zi.STEP_BEFORECLEAR_PROCEDURALTEXTURE,this,this._beforeClear)},e.prototype.rebuild=function(){},e.prototype.dispose=function(){},e.prototype._beforeClear=function(){if(this.scene.proceduralTexturesEnabled){mi.StartPerformanceCounter(\"Procedural textures\",this.scene.proceduralTextures.length>0);for(var e=0;e0)}},e}();It.ShadersStore.proceduralVertexShader=\"attribute vec2 position;\\nvarying vec2 vPosition;\\nvarying vec2 vUV;\\nconst vec2 madd=vec2(0.5,0.5);\\n#define CUSTOM_VERTEX_DEFINITIONS\\nvoid main(void) {\\n#define CUSTOM_VERTEX_MAIN_BEGIN\\nvPosition=position;\\nvUV=position*madd+madd;\\ngl_Position=vec4(position,0.0,1.0);\\n#define CUSTOM_VERTEX_MAIN_END\\n}\";var Da,Na=function(e){function t(t,i,n,r,o,s,l,c){void 0===o&&(o=null),void 0===s&&(s=!0),void 0===l&&(l=!1),void 0===c&&(c=a.TEXTURETYPE_UNSIGNED_INT);var h=e.call(this,null,r,!s)||this;h.isEnabled=!0,h.autoClear=!0,h.onGeneratedObservable=new u,h.onBeforeGenerationObservable=new u,h.nodeMaterialSource=null,h._textures={},h._currentRefreshId=-1,h._frameId=-1,h._refreshRate=1,h._vertexBuffers={},h._uniforms=new Array,h._samplers=new Array,h._floats={},h._ints={},h._floatsArrays={},h._colors3={},h._colors4={},h._vectors2={},h._vectors3={},h._matrices={},h._fallbackTextureUsed=!1,h._cachedDefines=null,h._contentUpdateId=-1,h._rtWrapper=null;var d=(r=h.getScene()||S.LastCreatedScene)._getComponent(zi.NAME_PROCEDURALTEXTURE);d||(d=new Oa(r),r._addComponent(d)),r.proceduralTextures.push(h),h._fullEngine=r.getEngine(),h.name=t,h.isRenderTarget=!0,h._size=i,h._textureType=c,h._generateMipMaps=s,h._drawWrapper=new Ht(h._fullEngine),h.setFragment(n),h._fallbackTexture=o;var p=h._createRtWrapper(l,i,s,c);h._texture=p.texture;var f=[];return f.push(1,1),f.push(-1,1),f.push(-1,-1),f.push(1,-1),h._vertexBuffers[wi.PositionKind]=new wi(h._fullEngine,f,wi.PositionKind,!1,!1,2),h._createIndexBuffer(),h}return V(t,e),t.prototype._createRtWrapper=function(e,t,i,n){return e?(this._rtWrapper=this._fullEngine.createRenderTargetCubeTexture(t,{generateMipMaps:i,generateDepthBuffer:!1,generateStencilBuffer:!1,type:n}),this.setFloat(\"face\",0)):this._rtWrapper=this._fullEngine.createRenderTargetTexture(t,{generateMipMaps:i,generateDepthBuffer:!1,generateStencilBuffer:!1,type:n}),this._rtWrapper},t.prototype.getEffect=function(){return this._drawWrapper.effect},t.prototype._setEffect=function(e){this._drawWrapper.effect=e},t.prototype.getContent=function(){var e=this;return this._contentData&&this._frameId===this._contentUpdateId||(this._contentData?this._contentData.then((function(t){e._contentData=e.readPixels(0,0,t),e._contentUpdateId=e._frameId})):(this._contentData=this.readPixels(0,0),this._contentUpdateId=this._frameId)),this._contentData},t.prototype._createIndexBuffer=function(){var e=this._fullEngine,t=[];t.push(0),t.push(1),t.push(2),t.push(0),t.push(2),t.push(3),this._indexBuffer=e.createIndexBuffer(t)},t.prototype._rebuild=function(){var e=this._vertexBuffers[wi.PositionKind];e&&e._rebuild(),this._createIndexBuffer(),this.refreshRate===Ia.REFRESHRATE_RENDER_ONCE&&(this.refreshRate=Ia.REFRESHRATE_RENDER_ONCE)},t.prototype.reset=function(){var e;null===(e=this._drawWrapper.effect)||void 0===e||e.dispose()},t.prototype._getDefines=function(){return\"\"},t.prototype.isReady=function(){var e,t=this,i=this._fullEngine;if(this.nodeMaterialSource)return this._drawWrapper.effect.isReady();if(!this._fragment)return!1;if(this._fallbackTextureUsed)return!0;if(!this._texture)return!1;var n=this._getDefines();return!(!this._drawWrapper.effect||n!==this._cachedDefines||!this._drawWrapper.effect.isReady())||(e=void 0!==this._fragment.fragmentElement?{vertex:\"procedural\",fragmentElement:this._fragment.fragmentElement}:{vertex:\"procedural\",fragment:this._fragment},this._cachedDefines!==n&&(this._cachedDefines=n,this._drawWrapper.effect=i.createEffect(e,[wi.PositionKind],this._uniforms,this._samplers,n,void 0,void 0,(function(){var e;null===(e=t._rtWrapper)||void 0===e||e.dispose(),t._rtWrapper=t._texture=null,t._fallbackTexture&&(t._texture=t._fallbackTexture._texture,t._texture&&t._texture.incrementReferences()),t._fallbackTextureUsed=!0}))),this._drawWrapper.effect.isReady())},t.prototype.resetRefreshCounter=function(){this._currentRefreshId=-1},t.prototype.setFragment=function(e){this._fragment=e},Object.defineProperty(t.prototype,\"refreshRate\",{get:function(){return this._refreshRate},set:function(e){this._refreshRate=e,this.resetRefreshCounter()},enumerable:!1,configurable:!0}),t.prototype._shouldRender=function(){return this.isEnabled&&this.isReady()&&this._texture?!this._fallbackTextureUsed&&(-1===this._currentRefreshId||this.refreshRate===this._currentRefreshId?(this._currentRefreshId=1,this._frameId++,!0):(this._currentRefreshId++,!1)):(this._texture&&(this._texture.isReady=!1),!1)},t.prototype.getRenderSize=function(){return this._size},t.prototype.resize=function(e,t){if(!this._fallbackTextureUsed&&this._rtWrapper&&this._texture){var i=this._texture.isCube;this._rtWrapper.dispose();var n=this._createRtWrapper(i,e,t,this._textureType);this._texture=n.texture,this._size=e,this._generateMipMaps=t}},t.prototype._checkUniform=function(e){-1===this._uniforms.indexOf(e)&&this._uniforms.push(e)},t.prototype.setTexture=function(e,t){return-1===this._samplers.indexOf(e)&&this._samplers.push(e),this._textures[e]=t,this},t.prototype.setFloat=function(e,t){return this._checkUniform(e),this._floats[e]=t,this},t.prototype.setInt=function(e,t){return this._checkUniform(e),this._ints[e]=t,this},t.prototype.setFloats=function(e,t){return this._checkUniform(e),this._floatsArrays[e]=t,this},t.prototype.setColor3=function(e,t){return this._checkUniform(e),this._colors3[e]=t,this},t.prototype.setColor4=function(e,t){return this._checkUniform(e),this._colors4[e]=t,this},t.prototype.setVector2=function(e,t){return this._checkUniform(e),this._vectors2[e]=t,this},t.prototype.setVector3=function(e,t){return this._checkUniform(e),this._vectors3[e]=t,this},t.prototype.setMatrix=function(e,t){return this._checkUniform(e),this._matrices[e]=t,this},t.prototype.render=function(e){var t,i,n=this.getScene();if(n){var r=this._fullEngine;if(r.enableEffect(this._drawWrapper),this.onBeforeGenerationObservable.notifyObservers(this),r.setState(!1),!this.nodeMaterialSource){for(var o in this._textures)this._drawWrapper.effect.setTexture(o,this._textures[o]);for(var a in this._ints)this._drawWrapper.effect.setInt(a,this._ints[a]);for(var s in this._floats)this._drawWrapper.effect.setFloat(s,this._floats[s]);for(var l in this._floatsArrays)this._drawWrapper.effect.setArray(l,this._floatsArrays[l]);for(var c in this._colors3)this._drawWrapper.effect.setColor3(c,this._colors3[c]);for(var u in this._colors4){var h=this._colors4[u];this._drawWrapper.effect.setFloat4(u,h.r,h.g,h.b,h.a)}for(var d in this._vectors2)this._drawWrapper.effect.setVector2(d,this._vectors2[d]);for(var p in this._vectors3)this._drawWrapper.effect.setVector3(p,this._vectors3[p]);for(var f in this._matrices)this._drawWrapper.effect.setMatrix(f,this._matrices[f])}if(this._texture&&this._rtWrapper){null===(t=r._debugPushGroup)||void 0===t||t.call(r,\"procedural texture generation for \".concat(this.name),1);var _=r.currentViewport;if(this.isCube)for(var m=0;m<6;m++)r.bindFramebuffer(this._rtWrapper,m,void 0,void 0,!0),r.bindBuffers(this._vertexBuffers,this._indexBuffer,this._drawWrapper.effect),this._drawWrapper.effect.setFloat(\"face\",m),this.autoClear&&r.clear(n.clearColor,!0,!1,!1),r.drawElementsType(Ir.TriangleFillMode,0,6);else r.bindFramebuffer(this._rtWrapper,0,void 0,void 0,!0),r.bindBuffers(this._vertexBuffers,this._indexBuffer,this._drawWrapper.effect),this.autoClear&&r.clear(n.clearColor,!0,!1,!1),r.drawElementsType(Ir.TriangleFillMode,0,6);r.unBindFramebuffer(this._rtWrapper,this.isCube),_&&r.setViewport(_),this.isCube&&r.generateMipMapsForCubemap(this._texture),null===(i=r._debugPopGroup)||void 0===i||i.call(r,1),this.onGenerated&&this.onGenerated(),this.onGeneratedObservable.notifyObservers(this)}}},t.prototype.clone=function(){var e=this.getSize(),i=new t(this.name,e.width,this._fragment,this.getScene(),this._fallbackTexture,this._generateMipMaps);return i.hasAlpha=this.hasAlpha,i.level=this.level,i.coordinatesMode=this.coordinatesMode,i},t.prototype.dispose=function(){var t=this.getScene();if(t){var i=t.proceduralTextures.indexOf(this);i>=0&&t.proceduralTextures.splice(i,1);var n=this._vertexBuffers[wi.PositionKind];n&&(n.dispose(),this._vertexBuffers[wi.PositionKind]=null),this._indexBuffer&&this._fullEngine._releaseBuffer(this._indexBuffer)&&(this._indexBuffer=null),this.onGeneratedObservable.clear(),this.onBeforeGenerationObservable.clear(),e.prototype.dispose.call(this)}},G([be()],t.prototype,\"isEnabled\",void 0),G([be()],t.prototype,\"autoClear\",void 0),G([be()],t.prototype,\"_generateMipMaps\",void 0),G([be()],t.prototype,\"_size\",void 0),G([be()],t.prototype,\"refreshRate\",null),t}(to);b(\"BABYLON.ProceduralTexture\",Na),function(e){e[e.Cos=0]=\"Cos\",e[e.Sin=1]=\"Sin\",e[e.Abs=2]=\"Abs\",e[e.Exp=3]=\"Exp\",e[e.Exp2=4]=\"Exp2\",e[e.Round=5]=\"Round\",e[e.Floor=6]=\"Floor\",e[e.Ceiling=7]=\"Ceiling\",e[e.Sqrt=8]=\"Sqrt\",e[e.Log=9]=\"Log\",e[e.Tan=10]=\"Tan\",e[e.ArcTan=11]=\"ArcTan\",e[e.ArcCos=12]=\"ArcCos\",e[e.ArcSin=13]=\"ArcSin\",e[e.Fract=14]=\"Fract\",e[e.Sign=15]=\"Sign\",e[e.Radians=16]=\"Radians\",e[e.Degrees=17]=\"Degrees\"}(Da||(Da={}));var La=function(e){function t(t){var i=e.call(this,t,Bo.Neutral)||this;return i.operation=Da.Cos,i.registerInput(\"input\",wo.AutoDetect),i.registerOutput(\"output\",wo.BasedOnInput),i._outputs[0]._typeConnectionSource=i._inputs[0],i}return V(t,e),t.prototype.getClassName=function(){return\"TrigonometryBlock\"},Object.defineProperty(t.prototype,\"input\",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"output\",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i=this._outputs[0],n=\"\";switch(this.operation){case Da.Cos:n=\"cos\";break;case Da.Sin:n=\"sin\";break;case Da.Abs:n=\"abs\";break;case Da.Exp:n=\"exp\";break;case Da.Exp2:n=\"exp2\";break;case Da.Round:n=\"round\";break;case Da.Floor:n=\"floor\";break;case Da.Ceiling:n=\"ceil\";break;case Da.Sqrt:n=\"sqrt\";break;case Da.Log:n=\"log\";break;case Da.Tan:n=\"tan\";break;case Da.ArcTan:n=\"atan\";break;case Da.ArcCos:n=\"acos\";break;case Da.ArcSin:n=\"asin\";break;case Da.Fract:n=\"fract\";break;case Da.Sign:n=\"sign\";break;case Da.Radians:n=\"radians\";break;case Da.Degrees:n=\"degrees\"}return t.compilationString+=this._declareOutput(i,t)+\" = \".concat(n,\"(\").concat(this.input.associatedVariableName,\");\\r\\n\"),this},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.operation=this.operation,t},t.prototype._deserialize=function(t,i,n){e.prototype._deserialize.call(this,t,i,n),this.operation=t.operation},t.prototype._dumpPropertiesCode=function(){return e.prototype._dumpPropertiesCode.call(this)+\"\".concat(this._codeVariableName,\".operation = BABYLON.TrigonometryBlockOperations.\").concat(Da[this.operation],\";\\r\\n\")},t}(Xo);b(\"BABYLON.TrigonometryBlock\",La);var Fa={effect:null,subMesh:null},wa=function(e){function t(){var t=e.call(this)||this;return t.NORMAL=!1,t.TANGENT=!1,t.UV1=!1,t.UV2=!1,t.UV3=!1,t.UV4=!1,t.UV5=!1,t.UV6=!1,t.NUM_BONE_INFLUENCERS=0,t.BonesPerMesh=0,t.BONETEXTURE=!1,t.MORPHTARGETS=!1,t.MORPHTARGETS_NORMAL=!1,t.MORPHTARGETS_TANGENT=!1,t.MORPHTARGETS_UV=!1,t.NUM_MORPH_INFLUENCERS=0,t.MORPHTARGETS_TEXTURE=!1,t.IMAGEPROCESSING=!1,t.VIGNETTE=!1,t.VIGNETTEBLENDMODEMULTIPLY=!1,t.VIGNETTEBLENDMODEOPAQUE=!1,t.TONEMAPPING=!1,t.TONEMAPPING_ACES=!1,t.CONTRAST=!1,t.EXPOSURE=!1,t.COLORCURVES=!1,t.COLORGRADING=!1,t.COLORGRADING3D=!1,t.SAMPLER3DGREENDEPTH=!1,t.SAMPLER3DBGRMAP=!1,t.DITHER=!1,t.IMAGEPROCESSINGPOSTPROCESS=!1,t.SKIPFINALCOLORCLAMP=!1,t.BUMPDIRECTUV=0,t.rebuild(),t}return V(t,e),t.prototype.setValue=function(e,t,i){void 0===i&&(i=!1),void 0===this[e]&&this._keys.push(e),i&&this[e]!==t&&this.markAsUnprocessed(),this[e]=t},t}(Ei),Ba=function(e){function t(i,n,r){void 0===r&&(r={});var o=e.call(this,i,n||S.LastCreatedScene)||this;return o._buildId=t._BuildIdGenerator++,o._buildWasSuccessful=!1,o._cachedWorldViewMatrix=new M,o._cachedWorldViewProjectionMatrix=new M,o._optimizers=new Array,o._animationFrame=-1,o.BJSNODEMATERIALEDITOR=o._getGlobalNodeMaterialEditor(),o.editorData=null,o.ignoreAlpha=!1,o.maxSimultaneousLights=4,o.onBuildObservable=new u,o._vertexOutputNodes=new Array,o._fragmentOutputNodes=new Array,o.attachedBlocks=new Array,o._mode=ma.Material,o.forceAlphaBlending=!1,o._options=k({emitComments:!1},r),o._attachImageProcessingConfiguration(null),o}return V(t,e),t.prototype._getGlobalNodeMaterialEditor=function(){return\"undefined\"!=typeof NODEEDITOR?NODEEDITOR:\"undefined\"!=typeof BABYLON&&void 0!==BABYLON.NodeEditor?BABYLON:void 0},Object.defineProperty(t.prototype,\"options\",{get:function(){return this._options},set:function(e){this._options=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"imageProcessingConfiguration\",{get:function(){return this._imageProcessingConfiguration},set:function(e){this._attachImageProcessingConfiguration(e),this._markAllSubMeshesAsTexturesDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"mode\",{get:function(){return this._mode},set:function(e){this._mode=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,\"buildId\",{get:function(){return this._buildId},set:function(e){this._buildId=e},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return\"NodeMaterial\"},t.prototype._attachImageProcessingConfiguration=function(e){var t=this;e!==this._imageProcessingConfiguration&&(this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),this._imageProcessingConfiguration=e||this.getScene().imageProcessingConfiguration,this._imageProcessingConfiguration&&(this._imageProcessingObserver=this._imageProcessingConfiguration.onUpdateParameters.add((function(){t._markAllSubMeshesAsImageProcessingDirty()}))))},t.prototype.getBlockByName=function(e){for(var t=null,i=0,n=this.attachedBlocks;i-1))return this._optimizers.push(e),this},t.prototype.unregisterOptimizer=function(e){var t=this._optimizers.indexOf(e);if(-1!==t)return this._optimizers.splice(t,1),this},t.prototype.addOutputNode=function(e){if(null===e.target)throw\"This node is not meant to be an output node. You may want to explicitly set its target value.\";return 0!=(e.target&Bo.Vertex)&&this._addVertexOutputNode(e),0!=(e.target&Bo.Fragment)&&this._addFragmentOutputNode(e),this},t.prototype.removeOutputNode=function(e){return null===e.target||(0!=(e.target&Bo.Vertex)&&this._removeVertexOutputNode(e),0!=(e.target&Bo.Fragment)&&this._removeFragmentOutputNode(e)),this},t.prototype._addVertexOutputNode=function(e){if(-1===this._vertexOutputNodes.indexOf(e))return e.target=Bo.Vertex,this._vertexOutputNodes.push(e),this},t.prototype._removeVertexOutputNode=function(e){var t=this._vertexOutputNodes.indexOf(e);if(-1!==t)return this._vertexOutputNodes.splice(t,1),this},t.prototype._addFragmentOutputNode=function(e){if(-1===this._fragmentOutputNodes.indexOf(e))return e.target=Bo.Fragment,this._fragmentOutputNodes.push(e),this},t.prototype._removeFragmentOutputNode=function(e){var t=this._fragmentOutputNodes.indexOf(e);if(-1!==t)return this._fragmentOutputNodes.splice(t,1),this},t.prototype.needAlphaBlending=function(){return!this.ignoreAlpha&&(this.forceAlphaBlending||this.alpha<1||this._sharedData&&this._sharedData.hints.needAlphaBlending)},t.prototype.needAlphaTesting=function(){return this._sharedData&&this._sharedData.hints.needAlphaTesting},t.prototype._initializeBlock=function(e,t,i,n){if(void 0===n&&(n=!0),e.initialize(t),n&&e.autoConfigure(this),e._preparationId=this._buildId,-1===this.attachedBlocks.indexOf(e)){if(e.isUnique)for(var r=e.getClassName(),o=0,a=this.attachedBlocks;o-1&&this.attachedBlocks.splice(t,1),e.isFinalMerger&&this.removeOutputNode(e)},t.prototype.build=function(e,i,n){void 0===e&&(e=!1),void 0===i&&(i=!0),void 0===n&&(n=!0),this._buildWasSuccessful=!1;var r=this.getScene().getEngine(),o=this._mode===ma.Particle;if(0===this._vertexOutputNodes.length&&!o)throw\"You must define at least one vertexOutputNode\";if(0===this._fragmentOutputNodes.length)throw\"You must define at least one fragmentOutputNode\";this._vertexCompilationState=new zo,this._vertexCompilationState.supportUniformBuffers=r.supportsUniformBuffers,this._vertexCompilationState.target=Bo.Vertex,this._fragmentCompilationState=new zo,this._fragmentCompilationState.supportUniformBuffers=r.supportsUniformBuffers,this._fragmentCompilationState.target=Bo.Fragment,this._sharedData=new Wo,this._sharedData.fragmentOutputNodes=this._fragmentOutputNodes,this._vertexCompilationState.sharedData=this._sharedData,this._fragmentCompilationState.sharedData=this._sharedData,this._sharedData.buildId=this._buildId,this._sharedData.emitComments=this._options.emitComments,this._sharedData.verbose=e,this._sharedData.scene=this.getScene(),this._sharedData.allowEmptyVertexProgram=o;for(var a=[],s=[],l=0,c=this._vertexOutputNodes;l0&&a.lengthSquared()-l2*this.palmUpStrictness-1&&(t=!0)}}this._node.setEnabled(t&&i)},e.prototype.detach=function(){this._scene.onBeforeRenderObservable.remove(this._sceneRenderObserver)},e.prototype.linkToXRExperience=function(e){try{this._eyeTracking=e.featuresManager.getEnabledFeature(xo.EYE_TRACKING)}catch(e){}try{this._handTracking=e.featuresManager.getEnabledFeature(xo.HAND_TRACKING)}catch(e){alert(\"Hand tracking must be enabled for the Hand Menu to work\")}},e}(),Ja=function(){function e(e,t,i){if(this.targetPosition=x.Zero(),this.poleTargetPosition=x.Zero(),this.poleTargetLocalOffset=x.Zero(),this.poleAngle=0,this.slerpAmount=1,this._bone1Quat=P.Identity(),this._bone1Mat=M.Identity(),this._bone2Ang=Math.PI,this._maxAngle=Math.PI,this._rightHandedSystem=!1,this._bendAxis=x.Right(),this._slerping=!1,this._adjustRoll=0,this._bone2=t,this._bone1=t.getParent(),this._bone1){this.mesh=e;var n=t.getPosition();if(t.getAbsoluteTransform().determinant()>0&&(this._rightHandedSystem=!0,this._bendAxis.x=0,this._bendAxis.y=0,this._bendAxis.z=-1,n.x>n.y&&n.x>n.z&&(this._adjustRoll=.5*Math.PI,this._bendAxis.z=1)),this._bone1.length){var r=this._bone1.getScale(),o=this._bone2.getScale();this._bone1Length=this._bone1.length*r.y*this.mesh.scaling.y,this._bone2Length=this._bone2.length*o.y*this.mesh.scaling.y}else if(this._bone1.children[0]){e.computeWorldMatrix(!0);var a=this._bone2.children[0].getAbsolutePosition(e),s=this._bone2.getAbsolutePosition(e),l=this._bone1.getAbsolutePosition(e);this._bone1Length=x.Distance(a,s),this._bone2Length=x.Distance(s,l)}this._bone1.getRotationMatrixToRef(_n.WORLD,e,this._bone1Mat),this.maxAngle=Math.PI,i&&(i.targetMesh&&(this.targetMesh=i.targetMesh,this.targetMesh.computeWorldMatrix(!0)),i.poleTargetMesh?(this.poleTargetMesh=i.poleTargetMesh,this.poleTargetMesh.computeWorldMatrix(!0)):i.poleTargetBone?this.poleTargetBone=i.poleTargetBone:this._bone1.getParent()&&(this.poleTargetBone=this._bone1.getParent()),i.poleTargetLocalOffset&&this.poleTargetLocalOffset.copyFrom(i.poleTargetLocalOffset),i.poleAngle&&(this.poleAngle=i.poleAngle),i.bendAxis&&this._bendAxis.copyFrom(i.bendAxis),i.maxAngle&&(this.maxAngle=i.maxAngle),i.slerpAmount&&(this.slerpAmount=i.slerpAmount))}}return Object.defineProperty(e.prototype,\"maxAngle\",{get:function(){return this._maxAngle},set:function(e){this._setMaxAngle(e)},enumerable:!1,configurable:!0}),e.prototype._setMaxAngle=function(e){e<0&&(e=0),(e>Math.PI||null==e)&&(e=Math.PI),this._maxAngle=e;var t=this._bone1Length,i=this._bone2Length;this._maxReach=Math.sqrt(t*t+i*i-2*t*i*Math.cos(e))},e.prototype.update=function(){var t=this._bone1;if(t){var i=this.targetPosition,n=this.poleTargetPosition,r=e._TmpMats[0],o=e._TmpMats[1];this.targetMesh&&i.copyFrom(this.targetMesh.getAbsolutePosition()),this.poleTargetBone?this.poleTargetBone.getAbsolutePositionFromLocalToRef(this.poleTargetLocalOffset,this.mesh,n):this.poleTargetMesh&&x.TransformCoordinatesToRef(this.poleTargetLocalOffset,this.poleTargetMesh.getWorldMatrix(),n);var a=e._TmpVecs[0],s=e._TmpVecs[1],l=e._TmpVecs[2],c=e._TmpVecs[3],u=e._TmpVecs[4],h=e._TmpQuat;t.getAbsolutePositionToRef(this.mesh,a),n.subtractToRef(a,u),0==u.x&&0==u.y&&0==u.z?u.y=1:u.normalize(),i.subtractToRef(a,c),c.normalize(),x.CrossToRef(c,u,s),s.normalize(),x.CrossToRef(c,s,l),l.normalize(),M.FromXYZAxesToRef(l,c,s,r);var d=this._bone1Length,p=this._bone2Length,f=x.Distance(a,i);this._maxReach>0&&(f=Math.min(this._maxReach,f));var _=(p*p+f*f-d*d)/(2*p*f),m=(f*f+d*d-p*p)/(2*f*d);_>1&&(_=1),m>1&&(m=1),_<-1&&(_=-1),m<-1&&(m=-1);var g=Math.acos(_),v=Math.acos(m),y=-g-v;if(this._rightHandedSystem)M.RotationYawPitchRollToRef(0,0,this._adjustRoll,o),o.multiplyToRef(r,r),M.RotationAxisToRef(this._bendAxis,v,o),o.multiplyToRef(r,r);else{var b=e._TmpVecs[5];b.copyFrom(this._bendAxis),b.x*=-1,M.RotationAxisToRef(b,-v,o),o.multiplyToRef(r,r)}this.poleAngle&&(M.RotationAxisToRef(c,this.poleAngle,o),r.multiplyToRef(o,r)),this._bone1&&(this.slerpAmount<1?(this._slerping||P.FromRotationMatrixToRef(this._bone1Mat,this._bone1Quat),P.FromRotationMatrixToRef(r,h),P.SlerpToRef(this._bone1Quat,h,this.slerpAmount,this._bone1Quat),y=this._bone2Ang*(1-this.slerpAmount)+y*this.slerpAmount,this._bone1.setRotationQuaternion(this._bone1Quat,_n.WORLD,this.mesh),this._slerping=!0):(this._bone1.setRotationMatrix(r,_n.WORLD,this.mesh),this._bone1Mat.copyFrom(r),this._slerping=!1),this._updateLinkedTransformRotation(this._bone1)),this._bone2.setAxisAngle(this._bendAxis,y,_n.LOCAL),this._updateLinkedTransformRotation(this._bone2),this._bone2Ang=y}},e.prototype._updateLinkedTransformRotation=function(e){e._linkedTransformNode&&(e._linkedTransformNode.rotationQuaternion||(e._linkedTransformNode.rotationQuaternion=new P),e.getRotationQuaternionToRef(_n.LOCAL,null,e._linkedTransformNode.rotationQuaternion))},e._TmpVecs=[x.Zero(),x.Zero(),x.Zero(),x.Zero(),x.Zero(),x.Zero()],e._TmpQuat=P.Identity(),e._TmpMats=[M.Identity(),M.Identity()],e}(),$a=function(){function e(e,t,i,n){if(this.upAxis=x.Up(),this.upAxisSpace=_n.LOCAL,this.adjustYaw=0,this.adjustPitch=0,this.adjustRoll=0,this.slerpAmount=1,this._boneQuat=P.Identity(),this._slerping=!1,this._firstFrameSkipped=!1,this._fowardAxis=x.Forward(),this.mesh=e,this.bone=t,this.target=i,n&&(n.adjustYaw&&(this.adjustYaw=n.adjustYaw),n.adjustPitch&&(this.adjustPitch=n.adjustPitch),n.adjustRoll&&(this.adjustRoll=n.adjustRoll),null!=n.maxYaw?this.maxYaw=n.maxYaw:this.maxYaw=Math.PI,null!=n.minYaw?this.minYaw=n.minYaw:this.minYaw=-Math.PI,null!=n.maxPitch?this.maxPitch=n.maxPitch:this.maxPitch=Math.PI,null!=n.minPitch?this.minPitch=n.minPitch:this.minPitch=-Math.PI,null!=n.slerpAmount&&(this.slerpAmount=n.slerpAmount),null!=n.upAxis&&(this.upAxis=n.upAxis),null!=n.upAxisSpace&&(this.upAxisSpace=n.upAxisSpace),null!=n.yawAxis||null!=n.pitchAxis)){var r=vn.Y,o=vn.X;null!=n.yawAxis&&(r=n.yawAxis.clone()).normalize(),null!=n.pitchAxis&&(o=n.pitchAxis.clone()).normalize();var a=x.Cross(o,r);this._transformYawPitch=M.Identity(),M.FromXYZAxesToRef(o,r,a,this._transformYawPitch),this._transformYawPitchInv=this._transformYawPitch.clone(),this._transformYawPitch.invert()}t.getParent()||this.upAxisSpace!=_n.BONE||(this.upAxisSpace=_n.LOCAL)}return Object.defineProperty(e.prototype,\"minYaw\",{get:function(){return this._minYaw},set:function(e){this._minYaw=e,this._minYawSin=Math.sin(e),this._minYawCos=Math.cos(e),null!=this._maxYaw&&(this._midYawConstraint=.5*this._getAngleDiff(this._minYaw,this._maxYaw)+this._minYaw,this._yawRange=this._maxYaw-this._minYaw)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"maxYaw\",{get:function(){return this._maxYaw},set:function(e){this._maxYaw=e,this._maxYawSin=Math.sin(e),this._maxYawCos=Math.cos(e),null!=this._minYaw&&(this._midYawConstraint=.5*this._getAngleDiff(this._minYaw,this._maxYaw)+this._minYaw,this._yawRange=this._maxYaw-this._minYaw)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"minPitch\",{get:function(){return this._minPitch},set:function(e){this._minPitch=e,this._minPitchTan=Math.tan(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"maxPitch\",{get:function(){return this._maxPitch},set:function(e){this._maxPitch=e,this._maxPitchTan=Math.tan(e)},enumerable:!1,configurable:!0}),e.prototype.update=function(){if(this.slerpAmount<1&&!this._firstFrameSkipped)this._firstFrameSkipped=!0;else{var t=this.bone,i=e._TmpVecs[0];t.getAbsolutePositionToRef(this.mesh,i);var n=this.target,r=e._TmpMats[0],o=e._TmpMats[1],a=this.mesh,s=t.getParent(),l=e._TmpVecs[1];l.copyFrom(this.upAxis),this.upAxisSpace==_n.BONE&&s?(this._transformYawPitch&&x.TransformCoordinatesToRef(l,this._transformYawPitchInv,l),s.getDirectionToRef(l,this.mesh,l)):this.upAxisSpace==_n.LOCAL&&(a.getDirectionToRef(l,l),1==a.scaling.x&&1==a.scaling.y&&1==a.scaling.z||l.normalize());var c=!1,u=!1;if(this._maxYaw==Math.PI&&this._minYaw==-Math.PI||(c=!0),this._maxPitch==Math.PI&&this._minPitch==-Math.PI||(u=!0),c||u){var h=e._TmpMats[2],d=e._TmpMats[3];if(this.upAxisSpace==_n.BONE&&1==l.y&&s)s.getRotationMatrixToRef(_n.WORLD,this.mesh,h);else if(this.upAxisSpace!=_n.LOCAL||1!=l.y||s){var p=e._TmpVecs[2];p.copyFrom(this._fowardAxis),this._transformYawPitch&&x.TransformCoordinatesToRef(p,this._transformYawPitchInv,p),s?s.getDirectionToRef(p,this.mesh,p):a.getDirectionToRef(p,p);var f=x.Cross(l,p);f.normalize(),p=x.Cross(f,l),M.FromXYZAxesToRef(f,l,p,h)}else h.copyFrom(a.getWorldMatrix());h.invertToRef(d);var _=null;if(u){var m=e._TmpVecs[3];n.subtractToRef(i,m),x.TransformCoordinatesToRef(m,d,m),_=Math.sqrt(m.x*m.x+m.z*m.z);var g=Math.atan2(m.y,_),v=g;g>this._maxPitch?(m.y=this._maxPitchTan*_,v=this._maxPitch):gthis._maxYaw||yMath.PI?this._isAngleBetween(y,this._maxYaw,this._midYawConstraint)?(m.z=this._maxYawCos*_,m.x=this._maxYawSin*_,b=this._maxYaw):this._isAngleBetween(y,this._midYawConstraint,this._minYaw)&&(m.z=this._minYawCos*_,m.x=this._minYawSin*_,b=this._minYaw):y>this._maxYaw?(m.z=this._maxYawCos*_,m.x=this._maxYawSin*_,b=this._maxYaw):yMath.PI){var T=e._TmpVecs[8];T.copyFrom(vn.Z),this._transformYawPitch&&x.TransformCoordinatesToRef(T,this._transformYawPitchInv,T);var E=e._TmpMats[4];this._boneQuat.toRotationMatrix(E),this.mesh.getWorldMatrix().multiplyToRef(E,E),x.TransformCoordinatesToRef(T,E,T),x.TransformCoordinatesToRef(T,d,T);var S=Math.atan2(T.x,T.z);if(this._getAngleBetween(S,y)>this._getAngleBetween(S,this._midYawConstraint)){null==_&&(_=Math.sqrt(m.x*m.x+m.z*m.z));var A=this._getAngleBetween(S,this._maxYaw);this._getAngleBetween(S,this._minYaw)Math.PI?i-=2*Math.PI:i<-Math.PI&&(i+=2*Math.PI),i},e.prototype._getAngleBetween=function(e,t){var i=0;return(i=(e=(e%=2*Math.PI)<0?e+2*Math.PI:e)<(t=(t%=2*Math.PI)<0?t+2*Math.PI:t)?t-e:e-t)>Math.PI&&(i=2*Math.PI-i),i},e.prototype._isAngleBetween=function(e,t,i){if(e=(e%=2*Math.PI)<0?e+2*Math.PI:e,(t=(t%=2*Math.PI)<0?t+2*Math.PI:t)<(i=(i%=2*Math.PI)<0?i+2*Math.PI:i)){if(e>t&&ei&&e0}return Object.defineProperty(e.prototype,\"useTextureToStoreBoneMatrices\",{get:function(){return this._useTextureToStoreBoneMatrices},set:function(e){this._useTextureToStoreBoneMatrices=e,this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"animationPropertiesOverride\",{get:function(){return this._animationPropertiesOverride?this._animationPropertiesOverride:this._scene.animationPropertiesOverride},set:function(e){this._animationPropertiesOverride=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"isUsingTextureForMatrices\",{get:function(){return this.useTextureToStoreBoneMatrices&&this._canUseTextureForBones},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,\"uniqueId\",{get:function(){return this._uniqueId},enumerable:!1,configurable:!0}),e.prototype.getClassName=function(){return\"Skeleton\"},e.prototype.getChildren=function(){return this.bones.filter((function(e){return!e.getParent()}))},e.prototype.getTransformMatrices=function(e){return this.needInitialSkinMatrix?(e._bonesTransformMatrices||this.prepare(),e._bonesTransformMatrices):(this._transformMatrices||this.prepare(),this._transformMatrices)},e.prototype.getTransformMatrixTexture=function(e){return this.needInitialSkinMatrix&&e._transformMatrixTexture?e._transformMatrixTexture:this._transformMatrixTexture},e.prototype.getScene=function(){return this._scene},e.prototype.toString=function(e){var t=\"Name: \".concat(this.name,\", nBones: \").concat(this.bones.length);if(t+=\", nAnimationRanges: \".concat(this._ranges?Object.keys(this._ranges).length:\"none\"),e){t+=\", Ranges: {\";var i=!0;for(var n in this._ranges)i&&(t+=\", \",i=!1),t+=n;t+=\"}\"}return t},e.prototype.getBoneIndexByName=function(e){for(var t=0,i=this.bones.length;t-1&&this._meshesWithPoseMatrix.splice(t,1)},e.prototype._computeTransformMatrices=function(e,t){this.onBeforeComputeObservable.notifyObservers(this);for(var i=0;i0)for(var e=0,t=this.bones;e-1&&this._parentContainer.skeletons.splice(e,1),this._parentContainer=null}this._transformMatrixTexture&&(this._transformMatrixTexture.dispose(),this._transformMatrixTexture=null)},e.prototype.serialize=function(){var e,t={};t.name=this.name,t.id=this.id,this.dimensionsAtRest&&(t.dimensionsAtRest=this.dimensionsAtRest.asArray()),t.bones=[],t.needInitialSkinMatrix=this.needInitialSkinMatrix;for(var i=0;i0&&(o.animation=n.animations[0].serialize()),t.ranges=[],this._ranges){var s=this._ranges[a];if(s){var l={};l.name=a,l.from=s.from,l.to=s.to,t.ranges.push(l)}}}return t},e.Parse=function(t,i){var n,r=new e(t.name,t.id,i);for(t.dimensionsAtRest&&(r.dimensionsAtRest=x.FromArray(t.dimensionsAtRest)),r.needInitialSkinMatrix=t.needInitialSkinMatrix,n=0;n-1&&(s=r.bones[o.parentBoneIndex]);var l=o.rest?M.FromArray(o.rest):null,c=new yn(o.name,r,s,M.FromArray(o.matrix),l,null,a);void 0!==o.id&&null!==o.id&&(c.id=o.id),o.length&&(c.length=o.length),o.metadata&&(c.metadata=o.metadata),o.animation&&c.animations.push(ze.Parse(o.animation)),void 0!==o.linkedTransformNodeId&&null!==o.linkedTransformNodeId&&(r._hasWaitingData=!0,c._waitingTransformNodeId=o.linkedTransformNodeId)}if(t.ranges)for(n=0;n0&&(e=this._meshesWithPoseMatrix[0].getPoseMatrix()),e},e.prototype.sortBones=function(){for(var e=new Array,t=new Array(this.bones.length),i=0;i=2&&(this._leftStick={x:this.browserGamepad.axes[this._leftStickAxisX],y:this.browserGamepad.axes[this._leftStickAxisY]}),this.browserGamepad.axes.length>=4&&(this._rightStick={x:this.browserGamepad.axes[this._rightStickAxisX],y:this.browserGamepad.axes[this._rightStickAxisY]})}return Object.defineProperty(e.prototype,\"isConnected\",{get:function(){return this._isConnected},enumerable:!1,configurable:!0}),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:!1,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:!1,configurable:!0}),e.prototype.update=function(){this._leftStick&&(this.leftStick={x:this.browserGamepad.axes[this._leftStickAxisX],y:this.browserGamepad.axes[this._leftStickAxisY]},this._invertLeftStickY&&(this.leftStick.y*=-1)),this._rightStick&&(this.rightStick={x:this.browserGamepad.axes[this._rightStickAxisX],y:this.browserGamepad.axes[this._rightStickAxisY]})},e.prototype.dispose=function(){},e.GAMEPAD=0,e.GENERIC=1,e.XBOX=2,e.POSE_ENABLED=3,e.DUALSHOCK=4,e}(),ls=function(e){function t(t,i,n){var r=e.call(this,t,i,n)||this;return r.onButtonDownObservable=new u,r.onButtonUpObservable=new u,r.type=ss.GENERIC,r._buttons=new Array(n.buttons.length),r}return V(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&&(1===e&&(this._onbuttondown&&this._onbuttondown(i),this.onButtonDownObservable.notifyObservers(i)),0===e&&(this._onbuttonup&&this._onbuttonup(i),this.onButtonUpObservable.notifyObservers(i))),e},t.prototype.update=function(){e.prototype.update.call(this);for(var t=0;t.005&&(e.inertialAlphaOffset+=i)}if(0!=t.y){var n=t.y/this.gamepadRotationSensibility*this._yAxisScale;0!=n&&Math.abs(n)>.005&&(e.inertialBetaOffset+=n)}}var r=this.gamepad.leftStick;if(r&&0!=r.y){var o=r.y/this.gamepadMoveSensibility;0!=o&&Math.abs(o)>.005&&(this.camera.inertialRadiusOffset-=o)}}},e.prototype.getClassName=function(){return\"ArcRotateCameraGamepadInput\"},e.prototype.getSimpleName=function(){return\"gamepad\"},G([be()],e.prototype,\"gamepadRotationSensibility\",void 0),G([be()],e.prototype,\"gamepadMoveSensibility\",void 0),e}();rs.ArcRotateCameraGamepadInput=cs;var us=function(){function e(){this.keysUp=[38],this.keysDown=[40],this.keysLeft=[37],this.keysRight=[39],this.keysReset=[220],this.panningSensibility=50,this.zoomingSensibility=25,this.useAltToZoom=!0,this.angularSpeed=.01,this._keys=new Array}return e.prototype.attachControl=function(e){var t=this;e=mi.BackCompatCameraNoPreventDefault(arguments),this._onCanvasBlurObserver||(this._scene=this.camera.getScene(),this._engine=this._scene.getEngine(),this._onCanvasBlurObserver=this._engine.onCanvasBlurObservable.add((function(){t._keys.length=0})),this._onKeyboardObserver=this._scene.onKeyboardObservable.add((function(i){var n,r=i.event;r.metaKey||(i.type===Ki.KEYDOWN?(t._ctrlPressed=r.ctrlKey,t._altPressed=r.altKey,(-1!==t.keysUp.indexOf(r.keyCode)||-1!==t.keysDown.indexOf(r.keyCode)||-1!==t.keysLeft.indexOf(r.keyCode)||-1!==t.keysRight.indexOf(r.keyCode)||-1!==t.keysReset.indexOf(r.keyCode))&&(-1===(n=t._keys.indexOf(r.keyCode))&&t._keys.push(r.keyCode),r.preventDefault&&(e||r.preventDefault()))):-1===t.keysUp.indexOf(r.keyCode)&&-1===t.keysDown.indexOf(r.keyCode)&&-1===t.keysLeft.indexOf(r.keyCode)&&-1===t.keysRight.indexOf(r.keyCode)&&-1===t.keysReset.indexOf(r.keyCode)||((n=t._keys.indexOf(r.keyCode))>=0&&t._keys.splice(n,1),r.preventDefault&&(e||r.preventDefault())))})))},e.prototype.detachControl=function(){this._scene&&(this._onKeyboardObserver&&this._scene.onKeyboardObservable.remove(this._onKeyboardObserver),this._onCanvasBlurObserver&&this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver),this._onKeyboardObserver=null,this._onCanvasBlurObserver=null),this._keys.length=0},e.prototype.checkInputs=function(){if(this._onKeyboardObserver)for(var e=this.camera,t=0;t0?i/(1+this.wheelDeltaPercentage):i*(1+this.wheelDeltaPercentage)},e.prototype.attachControl=function(e){var t=this;e=mi.BackCompatCameraNoPreventDefault(arguments),this._wheel=function(i){if(i.type===Hi.POINTERWHEEL){var n=i.event,r=0,o=n.deltaMode===Ji.DOM_DELTA_LINE?40:1,a=-n.deltaY*o;if(t.customComputeDeltaFromMouseWheel)r=t.customComputeDeltaFromMouseWheel(a,t,n);else if(t.wheelDeltaPercentage){if((r=t._computeDeltaFromMouseWheelLegacyEvent(a,t.camera.radius))>0){for(var s=t.camera.radius,l=t.camera.inertialRadiusOffset+r,c=0;c<20&&Math.abs(l)>.001;c++)s-=l,l*=t.camera.inertia;s=h.Clamp(s,0,Number.MAX_VALUE),r=t._computeDeltaFromMouseWheelLegacyEvent(a,s)}}else r=a/(40*t.wheelPrecision);r&&(t.zoomToMouseLocation&&t._hitPlane?t._zoomToMouse(r):t.camera.inertialRadiusOffset+=r),n.preventDefault&&(e||n.preventDefault())}},this._observer=this.camera.getScene().onPointerObservable.add(this._wheel,Hi.POINTERWHEEL),this.zoomToMouseLocation&&this._inertialPanning.setAll(0)},e.prototype.detachControl=function(){this._observer&&(this.camera.getScene().onPointerObservable.remove(this._observer),this._observer=null,this._wheel=null)},e.prototype.checkInputs=function(){if(this.zoomToMouseLocation){var e=this.camera;0+e.inertialAlphaOffset+e.inertialBetaOffset+e.inertialRadiusOffset&&(this._updateHitPlane(),e.target.addInPlace(this._inertialPanning),this._inertialPanning.scaleInPlace(e.inertia),this._zeroIfClose(this._inertialPanning))}},e.prototype.getClassName=function(){return\"ArcRotateCameraMouseWheelInput\"},e.prototype.getSimpleName=function(){return\"mousewheel\"},e.prototype._updateHitPlane=function(){var e=this.camera,t=e.target.subtract(e.position);this._hitPlane=un.FromPositionAndNormal(e.target,t)},e.prototype._getPosition=function(){var e,t=this.camera,i=t.getScene(),n=i.createPickingRay(i.pointerX,i.pointerY,M.Identity(),t,!1),r=0;return this._hitPlane&&(r=null!==(e=n.intersectsPlane(this._hitPlane))&&void 0!==e?e:0),n.origin.addInPlace(n.direction.scaleInPlace(r))},e.prototype._zoomToMouse=function(e){var t,i,n=this.camera,r=1-n.inertia;if(n.lowerRadiusLimit){var o=null!==(t=n.lowerRadiusLimit)&&void 0!==t?t:0;n.radius-(n.inertialRadiusOffset+e)/ra&&(e=(n.radius-a)*r-n.inertialRadiusOffset)}var s=e/r/n.radius,l=this._getPosition(),c=O.Vector3[6];l.subtractToRef(n.target,c),c.scaleInPlace(s),c.scaleInPlace(r),this._inertialPanning.addInPlace(c),n.inertialRadiusOffset+=e},e.prototype._zeroIfClose=function(e){Math.abs(e.x)<_&&(e.x=0),Math.abs(e.y)<_&&(e.y=0),Math.abs(e.z)<_&&(e.z=0)},G([be()],e.prototype,\"wheelPrecision\",void 0),G([be()],e.prototype,\"zoomToMouseLocation\",void 0),G([be()],e.prototype,\"wheelDeltaPercentage\",void 0),e}();rs.ArcRotateCameraMouseWheelInput=hs;var ds=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.buttons=[0,1,2],t.angularSensibilityX=1e3,t.angularSensibilityY=1e3,t.pinchPrecision=12,t.pinchDeltaPercentage=0,t.useNaturalPinchZoom=!1,t.pinchZoom=!0,t.panningSensibility=1e3,t.multiTouchPanning=!0,t.multiTouchPanAndZoom=!0,t.pinchInwards=!0,t._isPanClick=!1,t._twoFingerActivityCount=0,t._isPinching=!1,t}return V(t,e),t.prototype.getClassName=function(){return\"ArcRotateCameraPointersInput\"},t.prototype._computeMultiTouchPanning=function(e,t){if(0!==this.panningSensibility&&e&&t){var i=t.x-e.x,n=t.y-e.y;this.camera.inertialPanningX+=-i/this.panningSensibility,this.camera.inertialPanningY+=n/this.panningSensibility}},t.prototype._computePinchZoom=function(e,i){var n=this.camera.radius||t.MinimumRadiusForPinch;this.useNaturalPinchZoom?this.camera.radius=n*Math.sqrt(e)/Math.sqrt(i):this.pinchDeltaPercentage?this.camera.inertialRadiusOffset+=.001*(i-e)*n*this.pinchDeltaPercentage:this.camera.inertialRadiusOffset+=(i-e)/(this.pinchPrecision*(this.pinchInwards?1:-1)*(this.angularSensibilityX+this.angularSensibilityY)/2)},t.prototype.onTouch=function(e,t,i){0!==this.panningSensibility&&(this._ctrlKey&&this.camera._useCtrlForPanning||this._isPanClick)?(this.camera.inertialPanningX+=-t/this.panningSensibility,this.camera.inertialPanningY+=i/this.panningSensibility):(this.camera.inertialAlphaOffset-=t/this.angularSensibilityX,this.camera.inertialBetaOffset-=i/this.angularSensibilityY)},t.prototype.onDoubleTap=function(){this.camera.useInputToRestoreState&&this.camera.restoreState()},t.prototype.onMultiTouch=function(e,t,i,n,r,o){0===i&&null===r||0===n&&null===o||(this.multiTouchPanAndZoom?(this._computePinchZoom(i,n),this._computeMultiTouchPanning(r,o)):this.multiTouchPanning&&this.pinchZoom?(this._twoFingerActivityCount++,this._isPinching||this._twoFingerActivityCount<20&&Math.abs(Math.sqrt(n)-Math.sqrt(i))>this.camera.pinchToPanMaxDistance?(this._computePinchZoom(i,n),this._isPinching=!0):this._computeMultiTouchPanning(r,o)):this.multiTouchPanning?this._computeMultiTouchPanning(r,o):this.pinchZoom&&this._computePinchZoom(i,n))},t.prototype.onButtonDown=function(e){this._isPanClick=e.button===this.camera._panningMouseButton},t.prototype.onButtonUp=function(){this._twoFingerActivityCount=0,this._isPinching=!1},t.prototype.onLostFocus=function(){this._isPanClick=!1,this._twoFingerActivityCount=0,this._isPinching=!1},t.MinimumRadiusForPinch=.001,G([be()],t.prototype,\"buttons\",void 0),G([be()],t.prototype,\"angularSensibilityX\",void 0),G([be()],t.prototype,\"angularSensibilityY\",void 0),G([be()],t.prototype,\"pinchPrecision\",void 0),G([be()],t.prototype,\"pinchDeltaPercentage\",void 0),G([be()],t.prototype,\"useNaturalPinchZoom\",void 0),G([be()],t.prototype,\"pinchZoom\",void 0),G([be()],t.prototype,\"panningSensibility\",void 0),G([be()],t.prototype,\"multiTouchPanning\",void 0),G([be()],t.prototype,\"multiTouchPanAndZoom\",void 0),t}(ns);rs.ArcRotateCameraPointersInput=ds;var ps=function(e){function t(t){return e.call(this,t)||this}return V(t,e),t.prototype.addMouseWheel=function(){return this.add(new hs),this},t.prototype.addPointers=function(){return this.add(new ds),this},t.prototype.addKeyboard=function(){return this.add(new us),this},t}(os);ps.prototype.addVRDeviceOrientation=function(){return this.add(new fs),this};var fs=function(){function e(){this.alphaCorrection=1,this.gammaCorrection=1,this._alpha=0,this._gamma=0,this._dirty=!1,this._deviceOrientationHandler=this._onOrientationEvent.bind(this)}return e.prototype.attachControl=function(e){var t=this;e=mi.BackCompatCameraNoPreventDefault(arguments),this.camera.attachControl(e);var i=this.camera.getScene().getEngine().getHostWindow();i&&(\"undefined\"!=typeof DeviceOrientationEvent&&\"function\"==typeof DeviceOrientationEvent.requestPermission?DeviceOrientationEvent.requestPermission().then((function(e){\"granted\"===e?i.addEventListener(\"deviceorientation\",t._deviceOrientationHandler):mi.Warn(\"Permission not granted.\")})).catch((function(e){mi.Error(e)})):i.addEventListener(\"deviceorientation\",this._deviceOrientationHandler))},e.prototype._onOrientationEvent=function(e){null!==e.alpha&&(this._alpha=(0|+e.alpha)*this.alphaCorrection),null!==e.gamma&&(this._gamma=(0|+e.gamma)*this.gammaCorrection),this._dirty=!0},e.prototype.checkInputs=function(){this._dirty&&(this._dirty=!1,this._gamma<0&&(this._gamma=180+this._gamma),this.camera.alpha=-this._alpha/180*Math.PI%Math.PI*2,this.camera.beta=this._gamma/180*Math.PI)},e.prototype.detachControl=function(){window.removeEventListener(\"deviceorientation\",this._deviceOrientationHandler)},e.prototype.getClassName=function(){return\"ArcRotateCameraVRDeviceOrientationInput\"},e.prototype.getSimpleName=function(){return\"VRDeviceOrientation\"},e}();rs.ArcRotateCameraVRDeviceOrientationInput=fs;var _s=function(){function e(){this.keysForward=[87],this.keysBackward=[83],this.keysUp=[69],this.keysDown=[81],this.keysRight=[68],this.keysLeft=[65],this._keys=new Array}return e.prototype.attachControl=function(e){var t=this;e=mi.BackCompatCameraNoPreventDefault(arguments),this._onCanvasBlurObserver||(this._scene=this.camera.getScene(),this._engine=this._scene.getEngine(),this._onCanvasBlurObserver=this._engine.onCanvasBlurObservable.add((function(){t._keys.length=0})),this._onKeyboardObserver=this._scene.onKeyboardObservable.add((function(i){var n,r=i.event;i.type===Ki.KEYDOWN?-1===t.keysForward.indexOf(r.keyCode)&&-1===t.keysBackward.indexOf(r.keyCode)&&-1===t.keysUp.indexOf(r.keyCode)&&-1===t.keysDown.indexOf(r.keyCode)&&-1===t.keysLeft.indexOf(r.keyCode)&&-1===t.keysRight.indexOf(r.keyCode)||(-1===(n=t._keys.indexOf(r.keyCode))&&t._keys.push(r.keyCode),e||r.preventDefault()):-1===t.keysForward.indexOf(r.keyCode)&&-1===t.keysBackward.indexOf(r.keyCode)&&-1===t.keysUp.indexOf(r.keyCode)&&-1===t.keysDown.indexOf(r.keyCode)&&-1===t.keysLeft.indexOf(r.keyCode)&&-1===t.keysRight.indexOf(r.keyCode)||((n=t._keys.indexOf(r.keyCode))>=0&&t._keys.splice(n,1),e||r.preventDefault())})))},e.prototype.detachControl=function(){this._scene&&(this._onKeyboardObserver&&this._scene.onKeyboardObservable.remove(this._onKeyboardObserver),this._onCanvasBlurObserver&&this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver),this._onKeyboardObserver=null,this._onCanvasBlurObserver=null),this._keys.length=0},e.prototype.getClassName=function(){return\"FlyCameraKeyboardInput\"},e.prototype._onLostFocus=function(){this._keys.length=0},e.prototype.getSimpleName=function(){return\"keyboard\"},e.prototype.checkInputs=function(){if(this._onKeyboardObserver)for(var e=this.camera,t=0;t=0&&t._keys.splice(n,1),r.preventDefault&&(e||r.preventDefault())))})))},e.prototype.detachControl=function(){this._scene&&(this._onKeyboardObserver&&this._scene.onKeyboardObservable.remove(this._onKeyboardObserver),this._onCanvasBlurObserver&&this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver),this._onKeyboardObserver=null,this._onCanvasBlurObserver=null),this._keys.length=0},e.prototype.checkInputs=function(){var e=this;this._onKeyboardObserver&&this._keys.forEach((function(t){-1!==e.keysHeightOffsetIncr.indexOf(t)&&e._modifierHeightOffset()?e.camera.heightOffset+=e.heightSensibility:-1!==e.keysHeightOffsetDecr.indexOf(t)&&e._modifierHeightOffset()?e.camera.heightOffset-=e.heightSensibility:-1!==e.keysRotationOffsetIncr.indexOf(t)&&e._modifierRotationOffset()?(e.camera.rotationOffset+=e.rotationSensibility,e.camera.rotationOffset%=360):-1!==e.keysRotationOffsetDecr.indexOf(t)&&e._modifierRotationOffset()?(e.camera.rotationOffset-=e.rotationSensibility,e.camera.rotationOffset%=360):-1!==e.keysRadiusIncr.indexOf(t)&&e._modifierRadius()?e.camera.radius+=e.radiusSensibility:-1!==e.keysRadiusDecr.indexOf(t)&&e._modifierRadius()&&(e.camera.radius-=e.radiusSensibility)}))},e.prototype.getClassName=function(){return\"FollowCameraKeyboardMoveInput\"},e.prototype.getSimpleName=function(){return\"keyboard\"},e.prototype._modifierHeightOffset=function(){return this.keysHeightOffsetModifierAlt===this._altPressed&&this.keysHeightOffsetModifierCtrl===this._ctrlPressed&&this.keysHeightOffsetModifierShift===this._shiftPressed},e.prototype._modifierRotationOffset=function(){return this.keysRotationOffsetModifierAlt===this._altPressed&&this.keysRotationOffsetModifierCtrl===this._ctrlPressed&&this.keysRotationOffsetModifierShift===this._shiftPressed},e.prototype._modifierRadius=function(){return this.keysRadiusModifierAlt===this._altPressed&&this.keysRadiusModifierCtrl===this._ctrlPressed&&this.keysRadiusModifierShift===this._shiftPressed},G([be()],e.prototype,\"keysHeightOffsetIncr\",void 0),G([be()],e.prototype,\"keysHeightOffsetDecr\",void 0),G([be()],e.prototype,\"keysHeightOffsetModifierAlt\",void 0),G([be()],e.prototype,\"keysHeightOffsetModifierCtrl\",void 0),G([be()],e.prototype,\"keysHeightOffsetModifierShift\",void 0),G([be()],e.prototype,\"keysRotationOffsetIncr\",void 0),G([be()],e.prototype,\"keysRotationOffsetDecr\",void 0),G([be()],e.prototype,\"keysRotationOffsetModifierAlt\",void 0),G([be()],e.prototype,\"keysRotationOffsetModifierCtrl\",void 0),G([be()],e.prototype,\"keysRotationOffsetModifierShift\",void 0),G([be()],e.prototype,\"keysRadiusIncr\",void 0),G([be()],e.prototype,\"keysRadiusDecr\",void 0),G([be()],e.prototype,\"keysRadiusModifierAlt\",void 0),G([be()],e.prototype,\"keysRadiusModifierCtrl\",void 0),G([be()],e.prototype,\"keysRadiusModifierShift\",void 0),G([be()],e.prototype,\"heightSensibility\",void 0),G([be()],e.prototype,\"rotationSensibility\",void 0),G([be()],e.prototype,\"radiusSensibility\",void 0),e}();rs.FollowCameraKeyboardMoveInput=gs;var vs=function(){function e(){this.axisControlRadius=!0,this.axisControlHeight=!1,this.axisControlRotation=!1,this.wheelPrecision=3,this.wheelDeltaPercentage=0}return e.prototype.attachControl=function(e){var t=this;e=mi.BackCompatCameraNoPreventDefault(arguments),this._wheel=function(i){if(i.type===Hi.POINTERWHEEL){var n=i.event,r=0,o=Math.max(-1,Math.min(1,n.deltaY));t.wheelDeltaPercentage?(console.assert(t.axisControlRadius+t.axisControlHeight+t.axisControlRotation<=1,\"wheelDeltaPercentage only usable when mouse wheel controls ONE axis. Currently enabled: axisControlRadius: \"+t.axisControlRadius+\", axisControlHeightOffset: \"+t.axisControlHeight+\", axisControlRotationOffset: \"+t.axisControlRotation),t.axisControlRadius?r=.01*o*t.wheelDeltaPercentage*t.camera.radius:t.axisControlHeight?r=.01*o*t.wheelDeltaPercentage*t.camera.heightOffset:t.axisControlRotation&&(r=.01*o*t.wheelDeltaPercentage*t.camera.rotationOffset)):r=o*t.wheelPrecision,r&&(t.axisControlRadius?t.camera.radius+=r:t.axisControlHeight?t.camera.heightOffset-=r:t.axisControlRotation&&(t.camera.rotationOffset-=r)),n.preventDefault&&(e||n.preventDefault())}},this._observer=this.camera.getScene().onPointerObservable.add(this._wheel,Hi.POINTERWHEEL)},e.prototype.detachControl=function(){this._observer&&(this.camera.getScene().onPointerObservable.remove(this._observer),this._observer=null,this._wheel=null)},e.prototype.getClassName=function(){return\"ArcRotateCameraMouseWheelInput\"},e.prototype.getSimpleName=function(){return\"mousewheel\"},G([be()],e.prototype,\"axisControlRadius\",void 0),G([be()],e.prototype,\"axisControlHeight\",void 0),G([be()],e.prototype,\"axisControlRotation\",void 0),G([be()],e.prototype,\"wheelPrecision\",void 0),G([be()],e.prototype,\"wheelDeltaPercentage\",void 0),e}();rs.FollowCameraMouseWheelInput=vs;var ys=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.angularSensibilityX=1,t.angularSensibilityY=1,t.pinchPrecision=1e4,t.pinchDeltaPercentage=0,t.axisXControlRadius=!1,t.axisXControlHeight=!1,t.axisXControlRotation=!0,t.axisYControlRadius=!1,t.axisYControlHeight=!0,t.axisYControlRotation=!1,t.axisPinchControlRadius=!0,t.axisPinchControlHeight=!1,t.axisPinchControlRotation=!1,t.warningEnable=!0,t._warningCounter=0,t}return V(t,e),t.prototype.getClassName=function(){return\"FollowCameraPointersInput\"},t.prototype.onTouch=function(e,t,i){this._warning(),this.axisXControlRotation?this.camera.rotationOffset+=t/this.angularSensibilityX:this.axisYControlRotation&&(this.camera.rotationOffset+=i/this.angularSensibilityX),this.axisXControlHeight?this.camera.heightOffset+=t/this.angularSensibilityY:this.axisYControlHeight&&(this.camera.heightOffset+=i/this.angularSensibilityY),this.axisXControlRadius?this.camera.radius-=t/this.angularSensibilityY:this.axisYControlRadius&&(this.camera.radius-=i/this.angularSensibilityY)},t.prototype.onMultiTouch=function(e,t,i,n,r,o){if(!(0===i&&null===r||0===n&&null===o)){var a=(n-i)/(this.pinchPrecision*(this.angularSensibilityX+this.angularSensibilityY)/2);this.pinchDeltaPercentage?(a*=.01*this.pinchDeltaPercentage,this.axisPinchControlRotation&&(this.camera.rotationOffset+=a*this.camera.rotationOffset),this.axisPinchControlHeight&&(this.camera.heightOffset+=a*this.camera.heightOffset),this.axisPinchControlRadius&&(this.camera.radius-=a*this.camera.radius)):(this.axisPinchControlRotation&&(this.camera.rotationOffset+=a),this.axisPinchControlHeight&&(this.camera.heightOffset+=a),this.axisPinchControlRadius&&(this.camera.radius-=a))}},t.prototype._warning=function(){if(this.warningEnable&&this._warningCounter++%100==0){var e=\"It probably only makes sense to control ONE camera property with each pointer axis. Set 'warningEnable = false' if you are sure. Currently enabled: \";console.assert(this.axisXControlRotation+this.axisXControlHeight+this.axisXControlRadius<=1,e+\"axisXControlRotation: \"+this.axisXControlRotation+\", axisXControlHeight: \"+this.axisXControlHeight+\", axisXControlRadius: \"+this.axisXControlRadius),console.assert(this.axisYControlRotation+this.axisYControlHeight+this.axisYControlRadius<=1,e+\"axisYControlRotation: \"+this.axisYControlRotation+\", axisYControlHeight: \"+this.axisYControlHeight+\", axisYControlRadius: \"+this.axisYControlRadius),console.assert(this.axisPinchControlRotation+this.axisPinchControlHeight+this.axisPinchControlRadius<=1,e+\"axisPinchControlRotation: \"+this.axisPinchControlRotation+\", axisPinchControlHeight: \"+this.axisPinchControlHeight+\", axisPinchControlRadius: \"+this.axisPinchControlRadius)}},G([be()],t.prototype,\"angularSensibilityX\",void 0),G([be()],t.prototype,\"angularSensibilityY\",void 0),G([be()],t.prototype,\"pinchPrecision\",void 0),G([be()],t.prototype,\"pinchDeltaPercentage\",void 0),G([be()],t.prototype,\"axisXControlRadius\",void 0),G([be()],t.prototype,\"axisXControlHeight\",void 0),G([be()],t.prototype,\"axisXControlRotation\",void 0),G([be()],t.prototype,\"axisYControlRadius\",void 0),G([be()],t.prototype,\"axisYControlHeight\",void 0),G([be()],t.prototype,\"axisYControlRotation\",void 0),G([be()],t.prototype,\"axisPinchControlRadius\",void 0),G([be()],t.prototype,\"axisPinchControlHeight\",void 0),G([be()],t.prototype,\"axisPinchControlRotation\",void 0),t}(ns);rs.FollowCameraPointersInput=ys;var bs=function(){function e(){this.keysUp=[38],this.keysUpward=[33],this.keysDown=[40],this.keysDownward=[34],this.keysLeft=[37],this.keysRight=[39],this.rotationSpeed=.5,this.keysRotateLeft=[],this.keysRotateRight=[],this._keys=new Array}return e.prototype.attachControl=function(e){var t=this;e=mi.BackCompatCameraNoPreventDefault(arguments),this._onCanvasBlurObserver||(this._scene=this.camera.getScene(),this._engine=this._scene.getEngine(),this._onCanvasBlurObserver=this._engine.onCanvasBlurObservable.add((function(){t._keys.length=0})),this._onKeyboardObserver=this._scene.onKeyboardObservable.add((function(i){var n,r=i.event;r.metaKey||(i.type===Ki.KEYDOWN?-1===t.keysUp.indexOf(r.keyCode)&&-1===t.keysDown.indexOf(r.keyCode)&&-1===t.keysLeft.indexOf(r.keyCode)&&-1===t.keysRight.indexOf(r.keyCode)&&-1===t.keysUpward.indexOf(r.keyCode)&&-1===t.keysDownward.indexOf(r.keyCode)&&-1===t.keysRotateLeft.indexOf(r.keyCode)&&-1===t.keysRotateRight.indexOf(r.keyCode)||(-1===(n=t._keys.indexOf(r.keyCode))&&t._keys.push(r.keyCode),e||r.preventDefault()):-1===t.keysUp.indexOf(r.keyCode)&&-1===t.keysDown.indexOf(r.keyCode)&&-1===t.keysLeft.indexOf(r.keyCode)&&-1===t.keysRight.indexOf(r.keyCode)&&-1===t.keysUpward.indexOf(r.keyCode)&&-1===t.keysDownward.indexOf(r.keyCode)&&-1===t.keysRotateLeft.indexOf(r.keyCode)&&-1===t.keysRotateRight.indexOf(r.keyCode)||((n=t._keys.indexOf(r.keyCode))>=0&&t._keys.splice(n,1),e||r.preventDefault()))})))},e.prototype.detachControl=function(){this._scene&&(this._onKeyboardObserver&&this._scene.onKeyboardObservable.remove(this._onKeyboardObserver),this._onCanvasBlurObserver&&this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver),this._onKeyboardObserver=null,this._onCanvasBlurObserver=null),this._keys.length=0},e.prototype.checkInputs=function(){if(this._onKeyboardObserver)for(var e=this.camera,t=0;t1)e.cameraRotation.x=-this._offsetY/this.touchAngularSensibility;else{var t=e._computeLocalCameraSpeed(),i=new x(0,0,0!==this.touchMoveSensibility?t*this._offsetY/this.touchMoveSensibility:0);M.RotationYawPitchRollToRef(e.rotation.y,e.rotation.x,0,e._cameraRotationMatrix),e.cameraDirection.addInPlace(x.TransformCoordinates(i,e._cameraRotationMatrix))}}},e.prototype.getClassName=function(){return\"FreeCameraTouchInput\"},e.prototype.getSimpleName=function(){return\"touch\"},G([be()],e.prototype,\"touchAngularSensibility\",void 0),G([be()],e.prototype,\"touchMoveSensibility\",void 0),e}();rs.FreeCameraTouchInput=As;var Rs=function(e){function t(t){var i=e.call(this,t)||this;return i._mouseInput=null,i._mouseWheelInput=null,i}return V(t,e),t.prototype.addKeyboard=function(){return this.add(new bs),this},t.prototype.addMouse=function(e){return void 0===e&&(e=!0),this._mouseInput||(this._mouseInput=new Es(e),this.add(this._mouseInput)),this},t.prototype.removeMouse=function(){return this._mouseInput&&this.remove(this._mouseInput),this},t.prototype.addMouseWheel=function(){return this._mouseWheelInput||(this._mouseWheelInput=new Ss,this.add(this._mouseWheelInput)),this},t.prototype.removeMouseWheel=function(){return this._mouseWheelInput&&this.remove(this._mouseWheelInput),this},t.prototype.addTouch=function(){return this.add(new As),this},t.prototype.clear=function(){e.prototype.clear.call(this),this._mouseInput=null},t}(os);Rs.prototype.addDeviceOrientation=function(e){return this._deviceOrientationInput||(this._deviceOrientationInput=new xs,e&&(this._deviceOrientationInput.smoothFactor=e),this.add(this._deviceOrientationInput)),this};var xs=function(){function e(){var e=this;this._screenOrientationAngle=0,this._screenQuaternion=new P,this._alpha=0,this._beta=0,this._gamma=0,this.smoothFactor=0,this._onDeviceOrientationChangedObservable=new u,this._orientationChanged=function(){e._screenOrientationAngle=void 0!==window.orientation?+window.orientation:window.screen.orientation&&window.screen.orientation.angle?window.screen.orientation.angle:0,e._screenOrientationAngle=-mi.ToRadians(e._screenOrientationAngle/2),e._screenQuaternion.copyFromFloats(0,Math.sin(e._screenOrientationAngle),0,Math.cos(e._screenOrientationAngle))},this._deviceOrientation=function(t){e.smoothFactor?(e._alpha=null!==t.alpha?mi.SmoothAngleChange(e._alpha,t.alpha,e.smoothFactor):0,e._beta=null!==t.beta?mi.SmoothAngleChange(e._beta,t.beta,e.smoothFactor):0,e._gamma=null!==t.gamma?mi.SmoothAngleChange(e._gamma,t.gamma,e.smoothFactor):0):(e._alpha=null!==t.alpha?t.alpha:0,e._beta=null!==t.beta?t.beta:0,e._gamma=null!==t.gamma?t.gamma:0),null!==t.alpha&&e._onDeviceOrientationChangedObservable.notifyObservers()},this._constantTranform=new P(-Math.sqrt(.5),0,0,Math.sqrt(.5)),this._orientationChanged()}return e.WaitForOrientationChangeAsync=function(e){return new Promise((function(t,i){var n=!1,r=function(){window.removeEventListener(\"deviceorientation\",r),n=!0,t()};e&&setTimeout((function(){n||(window.removeEventListener(\"deviceorientation\",r),i(\"WaitForOrientationChangeAsync timed out\"))}),e),\"undefined\"!=typeof DeviceOrientationEvent&&\"function\"==typeof DeviceOrientationEvent.requestPermission?DeviceOrientationEvent.requestPermission().then((function(e){\"granted\"==e?window.addEventListener(\"deviceorientation\",r):mi.Warn(\"Permission not granted.\")})).catch((function(e){mi.Error(e)})):window.addEventListener(\"deviceorientation\",r)}))},Object.defineProperty(e.prototype,\"camera\",{get:function(){return this._camera},set:function(e){var t=this;this._camera=e,null==this._camera||this._camera.rotationQuaternion||(this._camera.rotationQuaternion=new P),this._camera&&this._camera.onDisposeObservable.add((function(){t._onDeviceOrientationChangedObservable.clear()}))},enumerable:!1,configurable:!0}),e.prototype.attachControl=function(){var e=this,t=this.camera.getScene().getEngine().getHostWindow();if(t){var i=function(){t.addEventListener(\"orientationchange\",e._orientationChanged),t.addEventListener(\"deviceorientation\",e._deviceOrientation),e._orientationChanged()};\"undefined\"!=typeof DeviceOrientationEvent&&\"function\"==typeof DeviceOrientationEvent.requestPermission?DeviceOrientationEvent.requestPermission().then((function(e){\"granted\"===e?i():mi.Warn(\"Permission not granted.\")})).catch((function(e){mi.Error(e)})):i()}},e.prototype.detachControl=function(){window.removeEventListener(\"orientationchange\",this._orientationChanged),window.removeEventListener(\"deviceorientation\",this._deviceOrientation),this._alpha=0},e.prototype.checkInputs=function(){this._alpha&&(P.RotationYawPitchRollToRef(mi.ToRadians(this._alpha),mi.ToRadians(this._beta),-mi.ToRadians(this._gamma),this.camera.rotationQuaternion),this._camera.rotationQuaternion.multiplyInPlace(this._screenQuaternion),this._camera.rotationQuaternion.multiplyInPlace(this._constantTranform),this._camera.rotationQuaternion.z*=-1,this._camera.rotationQuaternion.w*=-1)},e.prototype.getClassName=function(){return\"FreeCameraDeviceOrientationInput\"},e.prototype.getSimpleName=function(){return\"deviceOrientation\"},e}();rs.FreeCameraDeviceOrientationInput=xs;var Cs,Ps=function(){function e(){this.gamepadAngularSensibility=200,this.gamepadMoveSensibility=40,this.deadzoneDelta=.1,this._yAxisScale=1,this._cameraTransform=M.Identity(),this._deltaTransform=x.Zero(),this._vector3=x.Zero(),this._vector2=R.Zero()}return Object.defineProperty(e.prototype,\"invertYAxis\",{get:function(){return 1!==this._yAxisScale},set:function(e){this._yAxisScale=e?-1:1},enumerable:!1,configurable:!0}),e.prototype.attachControl=function(){var e=this,t=this.camera.getScene().gamepadManager;this._onGamepadConnectedObserver=t.onGamepadConnectedObservable.add((function(t){t.type!==ss.POSE_ENABLED&&(e.gamepad&&t.type!==ss.XBOX||(e.gamepad=t))})),this._onGamepadDisconnectedObserver=t.onGamepadDisconnectedObservable.add((function(t){e.gamepad===t&&(e.gamepad=null)})),this.gamepad=t.getGamepadByType(ss.XBOX),!this.gamepad&&t.gamepads.length&&(this.gamepad=t.gamepads[0])},e.prototype.detachControl=function(){this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver),this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver),this.gamepad=null},e.prototype.checkInputs=function(){if(this.gamepad&&this.gamepad.leftStick){var e=this.camera,t=this.gamepad.leftStick;0!==this.gamepadMoveSensibility&&(t.x=Math.abs(t.x)>this.deadzoneDelta?t.x/this.gamepadMoveSensibility:0,t.y=Math.abs(t.y)>this.deadzoneDelta?t.y/this.gamepadMoveSensibility:0);var i=this.gamepad.rightStick;i&&0!==this.gamepadAngularSensibility?(i.x=Math.abs(i.x)>this.deadzoneDelta?i.x/this.gamepadAngularSensibility:0,i.y=(Math.abs(i.y)>this.deadzoneDelta?i.y/this.gamepadAngularSensibility:0)*this._yAxisScale):i={x:0,y:0},e.rotationQuaternion?e.rotationQuaternion.toRotationMatrix(this._cameraTransform):M.RotationYawPitchRollToRef(e.rotation.y,e.rotation.x,0,this._cameraTransform);var n=50*e._computeLocalCameraSpeed();this._vector3.copyFromFloats(t.x*n,0,-t.y*n),x.TransformCoordinatesToRef(this._vector3,this._cameraTransform,this._deltaTransform),e.cameraDirection.addInPlace(this._deltaTransform),this._vector2.copyFromFloats(i.y,i.x),e.cameraRotation.addInPlace(this._vector2)}},e.prototype.getClassName=function(){return\"FreeCameraGamepadInput\"},e.prototype.getSimpleName=function(){return\"gamepad\"},G([be()],e.prototype,\"gamepadAngularSensibility\",void 0),G([be()],e.prototype,\"gamepadMoveSensibility\",void 0),e}();rs.FreeCameraGamepadInput=Ps,function(e){e[e.X=0]=\"X\",e[e.Y=1]=\"Y\",e[e.Z=2]=\"Z\"}(Cs||(Cs={}));var Ms=function(){function e(t,i){var n=this,r=k(k({},e._GetDefaultOptions()),i);if(this._leftJoystick=!!t,e._GlobalJoystickIndex++,this._axisTargetedByLeftAndRight=Cs.X,this._axisTargetedByUpAndDown=Cs.Y,this.reverseLeftRight=!1,this.reverseUpDown=!1,this._touches=new Ti,this.deltaPosition=x.Zero(),this._joystickSensibility=25,this._inversedSensibility=1/(this._joystickSensibility/1e3),this._onResize=function(){e._VJCanvasWidth=window.innerWidth,e._VJCanvasHeight=window.innerHeight,e.Canvas&&(e.Canvas.width=e._VJCanvasWidth,e.Canvas.height=e._VJCanvasHeight),e._HalfWidth=e._VJCanvasWidth/2},!e.Canvas){window.addEventListener(\"resize\",this._onResize,!1),e.Canvas=document.createElement(\"canvas\"),e._VJCanvasWidth=window.innerWidth,e._VJCanvasHeight=window.innerHeight,e.Canvas.width=window.innerWidth,e.Canvas.height=window.innerHeight,e.Canvas.style.width=\"100%\",e.Canvas.style.height=\"100%\",e.Canvas.style.position=\"absolute\",e.Canvas.style.backgroundColor=\"transparent\",e.Canvas.style.top=\"0px\",e.Canvas.style.left=\"0px\",e.Canvas.style.zIndex=\"5\",e.Canvas.style.touchAction=\"none\",e.Canvas.setAttribute(\"touch-action\",\"none\");var o=e.Canvas.getContext(\"2d\");if(!o)throw new Error(\"Unable to create canvas for virtual joystick\");e._VJCanvasContext=o,e._VJCanvasContext.strokeStyle=\"#ffffff\",e._VJCanvasContext.lineWidth=2,document.body.appendChild(e.Canvas)}e._HalfWidth=e.Canvas.width/2,this.pressed=!1,this.limitToContainer=r.limitToContainer,this._joystickColor=r.color,this.containerSize=r.containerSize,this.puckSize=r.puckSize,r.position&&this.setPosition(r.position.x,r.position.y),r.puckImage&&this.setPuckImage(r.puckImage),r.containerImage&&this.setContainerImage(r.containerImage),r.alwaysVisible&&e._AlwaysVisibleSticks++,this.alwaysVisible=r.alwaysVisible,this._joystickPointerId=-1,this._joystickPointerPos=new R(0,0),this._joystickPreviousPointerPos=new R(0,0),this._joystickPointerStartPos=new R(0,0),this._deltaJoystickVector=new R(0,0),this._onPointerDownHandlerRef=function(e){n._onPointerDown(e)},this._onPointerMoveHandlerRef=function(e){n._onPointerMove(e)},this._onPointerUpHandlerRef=function(e){n._onPointerUp(e)},e.Canvas.addEventListener(\"pointerdown\",this._onPointerDownHandlerRef,!1),e.Canvas.addEventListener(\"pointermove\",this._onPointerMoveHandlerRef,!1),e.Canvas.addEventListener(\"pointerup\",this._onPointerUpHandlerRef,!1),e.Canvas.addEventListener(\"pointerout\",this._onPointerUpHandlerRef,!1),e.Canvas.addEventListener(\"contextmenu\",(function(e){e.preventDefault()}),!1),requestAnimationFrame((function(){n._drawVirtualJoystick()}))}return e._GetDefaultOptions=function(){return{puckSize:40,containerSize:60,color:\"cyan\",puckImage:void 0,containerImage:void 0,position:void 0,alwaysVisible:!1,limitToContainer:!1}},e.prototype.setJoystickSensibility=function(e){this._joystickSensibility=e,this._inversedSensibility=1/(this._joystickSensibility/1e3)},e.prototype._onPointerDown=function(t){t.preventDefault(),(!0===this._leftJoystick?t.clientX