@babylonjs/viewer
Version:
The Babylon Viewer aims to simplify a specific but common Babylon.js use case: loading, viewing, and interacting with a 3D model.
3 lines (2 loc) • 43.2 kB
JavaScript
import{l as e,aY as t,cd as s,V as i,q as n,s as a,ce as o,O as r,by as h,cf as l,M as u,T as c,cg as d,aE as _,A as p,b3 as g,ch as m,r as v,a as y,o as f,G as w,a7 as k,m as b,C as R,Q as C,y as T}from"./index-BPURObVq.esm.min.js";let M=(()=>{var o;let r,h,l,u,c,d,_,p,g,m,v,y=[],f=[],w=[],k=[],b=[],R=[],C=[],T=[],M=[],x=[],P=[],S=[],I=[],A=[],O=[],D=[],U=[],V=[],E=[],N=[],L=[],Y=[];return o=class{constructor(){this.keysUp=e(this,y,[38]),this.keysUpward=(e(this,f),e(this,w,[33])),this.keysDown=(e(this,k),e(this,b,[40])),this.keysDownward=(e(this,R),e(this,C,[34])),this.keysLeft=(e(this,T),e(this,M,[37])),this.keysRight=(e(this,x),e(this,P,[39])),this.rotationSpeed=(e(this,S),e(this,I,.5)),this.keysRotateLeft=(e(this,A),e(this,O,[])),this.keysRotateRight=(e(this,D),e(this,U,[])),this.keysRotateUp=(e(this,V),e(this,E,[])),this.keysRotateDown=(e(this,N),e(this,L,[])),this._keys=(e(this,Y),new Array)}attachControl(e){e=t.BackCompatCameraNoPreventDefault(arguments),this._onCanvasBlurObserver||(this._scene=this.camera.getScene(),this._engine=this._scene.getEngine(),this._onCanvasBlurObserver=this._engine.onCanvasBlurObservable.add(()=>{this._keys.length=0}),this._onKeyboardObserver=this._scene.onKeyboardObservable.add(t=>{const i=t.event;if(!i.metaKey)if(t.type===s.KEYDOWN){if(-1!==this.keysUp.indexOf(i.keyCode)||-1!==this.keysDown.indexOf(i.keyCode)||-1!==this.keysLeft.indexOf(i.keyCode)||-1!==this.keysRight.indexOf(i.keyCode)||-1!==this.keysUpward.indexOf(i.keyCode)||-1!==this.keysDownward.indexOf(i.keyCode)||-1!==this.keysRotateLeft.indexOf(i.keyCode)||-1!==this.keysRotateRight.indexOf(i.keyCode)||-1!==this.keysRotateUp.indexOf(i.keyCode)||-1!==this.keysRotateDown.indexOf(i.keyCode)){-1===this._keys.indexOf(i.keyCode)&&this._keys.push(i.keyCode),e||i.preventDefault()}}else if(-1!==this.keysUp.indexOf(i.keyCode)||-1!==this.keysDown.indexOf(i.keyCode)||-1!==this.keysLeft.indexOf(i.keyCode)||-1!==this.keysRight.indexOf(i.keyCode)||-1!==this.keysUpward.indexOf(i.keyCode)||-1!==this.keysDownward.indexOf(i.keyCode)||-1!==this.keysRotateLeft.indexOf(i.keyCode)||-1!==this.keysRotateRight.indexOf(i.keyCode)||-1!==this.keysRotateUp.indexOf(i.keyCode)||-1!==this.keysRotateDown.indexOf(i.keyCode)){const t=this._keys.indexOf(i.keyCode);t>=0&&this._keys.splice(t,1),e||i.preventDefault()}}))}detachControl(){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}checkInputs(){if(this._onKeyboardObserver){const e=this.camera,t=e.movement.input,s=t.getEntry("keyboard","translate"),n=t.getEntry("keyboard","rotate"),a=n?.sensitivity??1,o=e._localDirection.copyFromFloats(0,0,0);for(let t=0;t<this._keys.length;t++){const s=this._keys[t];-1!==this.keysLeft.indexOf(s)?o.x-=1:-1!==this.keysUp.indexOf(s)?o.z+=1:-1!==this.keysRight.indexOf(s)?o.x+=1:-1!==this.keysDown.indexOf(s)?o.z-=1:-1!==this.keysUpward.indexOf(s)?o.y+=1:-1!==this.keysDownward.indexOf(s)?o.y-=1:-1!==this.keysRotateLeft.indexOf(s)?n&&(e.cameraRotation.y-=this._getLocalRotation()*a):-1!==this.keysRotateRight.indexOf(s)?n&&(e.cameraRotation.y+=this._getLocalRotation()*a):-1!==this.keysRotateUp.indexOf(s)?n&&(e.cameraRotation.x-=this._getLocalRotation()*a):-1!==this.keysRotateDown.indexOf(s)&&n&&(e.cameraRotation.x+=this._getLocalRotation()*a)}if(s&&(0!==o.x||0!==o.y||0!==o.z)){const t=e._computeLocalCameraSpeed()*(s.sensitivity??1);o.normalize().scaleInPlace(t),e.getScene().useRightHandedSystem&&(o.z*=-1),e.getViewMatrix().invertToRef(e._cameraTransformMatrix),i.TransformNormalToRef(o,e._cameraTransformMatrix,e._transformedDirection),e.cameraDirection.addInPlace(e._transformedDirection)}}}getClassName(){return"FreeCameraKeyboardMoveInput"}_onLostFocus(){this._keys.length=0}getSimpleName(){return"keyboard"}_getLocalRotation(){const e=this.camera._calculateHandednessMultiplier();return this.rotationSpeed*this._engine.getDeltaTime()/1e3*e}},(()=>{const e="function"==typeof Symbol&&Symbol.metadata?Object.create(null):void 0;r=[a()],h=[a()],l=[a()],u=[a()],c=[a()],d=[a()],_=[a()],p=[a()],g=[a()],m=[a()],v=[a()],n(null,null,r,{kind:"field",name:"keysUp",static:!1,private:!1,access:{has:e=>"keysUp"in e,get:e=>e.keysUp,set:(e,t)=>{e.keysUp=t}},metadata:e},y,f),n(null,null,h,{kind:"field",name:"keysUpward",static:!1,private:!1,access:{has:e=>"keysUpward"in e,get:e=>e.keysUpward,set:(e,t)=>{e.keysUpward=t}},metadata:e},w,k),n(null,null,l,{kind:"field",name:"keysDown",static:!1,private:!1,access:{has:e=>"keysDown"in e,get:e=>e.keysDown,set:(e,t)=>{e.keysDown=t}},metadata:e},b,R),n(null,null,u,{kind:"field",name:"keysDownward",static:!1,private:!1,access:{has:e=>"keysDownward"in e,get:e=>e.keysDownward,set:(e,t)=>{e.keysDownward=t}},metadata:e},C,T),n(null,null,c,{kind:"field",name:"keysLeft",static:!1,private:!1,access:{has:e=>"keysLeft"in e,get:e=>e.keysLeft,set:(e,t)=>{e.keysLeft=t}},metadata:e},M,x),n(null,null,d,{kind:"field",name:"keysRight",static:!1,private:!1,access:{has:e=>"keysRight"in e,get:e=>e.keysRight,set:(e,t)=>{e.keysRight=t}},metadata:e},P,S),n(null,null,_,{kind:"field",name:"rotationSpeed",static:!1,private:!1,access:{has:e=>"rotationSpeed"in e,get:e=>e.rotationSpeed,set:(e,t)=>{e.rotationSpeed=t}},metadata:e},I,A),n(null,null,p,{kind:"field",name:"keysRotateLeft",static:!1,private:!1,access:{has:e=>"keysRotateLeft"in e,get:e=>e.keysRotateLeft,set:(e,t)=>{e.keysRotateLeft=t}},metadata:e},O,D),n(null,null,g,{kind:"field",name:"keysRotateRight",static:!1,private:!1,access:{has:e=>"keysRotateRight"in e,get:e=>e.keysRotateRight,set:(e,t)=>{e.keysRotateRight=t}},metadata:e},U,V),n(null,null,m,{kind:"field",name:"keysRotateUp",static:!1,private:!1,access:{has:e=>"keysRotateUp"in e,get:e=>e.keysRotateUp,set:(e,t)=>{e.keysRotateUp=t}},metadata:e},E,N),n(null,null,v,{kind:"field",name:"keysRotateDown",static:!1,private:!1,access:{has:e=>"keysRotateDown"in e,get:e=>e.keysRotateDown,set:(e,t)=>{e.keysRotateDown=t}},metadata:e},L,Y),e&&Object.defineProperty(o,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:e})})(),o})();o.FreeCameraKeyboardMoveInput=M;let x=(()=>{var s;let i,o,l=[],u=[],c=[],d=[];return s=class{_applyPointerRotation(e,t){this._pointerConditions.button=this._currentActiveButton;const s=this.camera.movement.input.resolveInteraction("pointer",this._pointerConditions);if(!s||"rotate"!==s.interaction)return;const i=s.sensitivityX??s.sensitivity??1/this.angularSensibility,n=s.sensitivityY??s.sensitivity??1/this.angularSensibility;this.camera.cameraRotation.y+=e*i,this.camera.cameraRotation.x+=t*n}constructor(t=!0){this.touchEnabled=t,this.buttons=e(this,l,[0,1,2]),this.angularSensibility=(e(this,u),e(this,c,2e3)),this._pointerInput=e(this,d),this._previousPosition=null,this.onPointerMovedObservable=new r,this._allowCameraRotation=!0,this._currentActiveButton=-1,this._activePointerId=-1,this._pointerConditions={}}attachControl(e){e=t.BackCompatCameraNoPreventDefault(arguments);const s=this.camera.getEngine(),i=s.getInputElement();this._pointerInput||(this._pointerInput=t=>{const n=t.event,a="touch"===n.pointerType;if(!this.touchEnabled&&a)return;if(t.type!==h.POINTERMOVE&&-1===this.buttons.indexOf(n.button))return;const o=n.target;if(t.type===h.POINTERDOWN){if(a&&-1!==this._activePointerId||!a&&-1!==this._currentActiveButton)return;this._activePointerId=n.pointerId;try{o?.setPointerCapture(n.pointerId)}catch(e){}-1===this._currentActiveButton&&(this._currentActiveButton=n.button),this._previousPosition={x:n.clientX,y:n.clientY},e||(n.preventDefault(),i&&i.focus()),s.isPointerLock&&this._onMouseMove&&this._onMouseMove(t.event)}else if(t.type===h.POINTERUP){if(a&&this._activePointerId!==n.pointerId||!a&&this._currentActiveButton!==n.button)return;try{o?.releasePointerCapture(n.pointerId)}catch(e){}this._currentActiveButton=-1,this._previousPosition=null,e||n.preventDefault(),this._activePointerId=-1}else if(t.type===h.POINTERMOVE&&(this._activePointerId===n.pointerId||!a))if(s.isPointerLock&&this._onMouseMove)this._onMouseMove(t.event);else if(this._previousPosition){const t=this.camera._calculateHandednessMultiplier(),s=(n.clientX-this._previousPosition.x)*t,i=(n.clientY-this._previousPosition.y)*t;this._allowCameraRotation&&this._applyPointerRotation(s,i),this.onPointerMovedObservable.notifyObservers({offsetX:s,offsetY:i}),this._previousPosition={x:n.clientX,y:n.clientY},e||n.preventDefault()}}),this._onMouseMove=t=>{if(!s.isPointerLock)return;const i=this.camera._calculateHandednessMultiplier();this._applyPointerRotation(t.movementX*i,t.movementY*i),this._previousPosition=null,e||t.preventDefault()},this._observer=this.camera.getScene()._inputManager._addCameraPointerObserver(this._pointerInput,h.POINTERDOWN|h.POINTERUP|h.POINTERMOVE),i&&(this._contextMenuBind=e=>this.onContextMenu(e),i.addEventListener("contextmenu",this._contextMenuBind,!1))}onContextMenu(e){e.preventDefault()}detachControl(){if(this._observer){if(this.camera.getScene()._inputManager._removeCameraPointerObserver(this._observer),this._contextMenuBind){const e=this.camera.getEngine().getInputElement();e&&e.removeEventListener("contextmenu",this._contextMenuBind)}this.onPointerMovedObservable&&this.onPointerMovedObservable.clear(),this._observer=null,this._onMouseMove=null,this._previousPosition=null}this._activePointerId=-1,this._currentActiveButton=-1}getClassName(){return"FreeCameraMouseInput"}getSimpleName(){return"mouse"}},(()=>{const e="function"==typeof Symbol&&Symbol.metadata?Object.create(null):void 0;i=[a()],o=[a()],n(null,null,i,{kind:"field",name:"buttons",static:!1,private:!1,access:{has:e=>"buttons"in e,get:e=>e.buttons,set:(e,t)=>{e.buttons=t}},metadata:e},l,u),n(null,null,o,{kind:"field",name:"angularSensibility",static:!1,private:!1,access:{has:e=>"angularSensibility"in e,get:e=>e.angularSensibility,set:(e,t)=>{e.angularSensibility=t}},metadata:e},c,d),e&&Object.defineProperty(s,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:e})})(),s})();o.FreeCameraMouseInput=x;let P=(()=>{var s;let i,o,u,c=[],d=[],_=[],p=[],g=[],m=[];return s=class{constructor(){this.wheelPrecisionX=e(this,c,3),this.wheelPrecisionY=(e(this,d),e(this,_,3)),this.wheelPrecisionZ=(e(this,p),e(this,g,3)),this.onChangedObservable=(e(this,m),new r),this._wheelDeltaX=0,this._wheelDeltaY=0,this._wheelDeltaZ=0,this._ffMultiplier=12,this._normalize=120}attachControl(e){e=t.BackCompatCameraNoPreventDefault(arguments),this._wheel=t=>{if(t.type!==h.POINTERWHEEL)return;const s=t.event,i=s.deltaMode===l.DOM_DELTA_LINE?this._ffMultiplier:1;this._wheelDeltaX+=this.wheelPrecisionX*i*s.deltaX/this._normalize,this._wheelDeltaY-=this.wheelPrecisionY*i*s.deltaY/this._normalize,this._wheelDeltaZ+=this.wheelPrecisionZ*i*s.deltaZ/this._normalize,s.preventDefault&&(e||s.preventDefault())},this._observer=this.camera.getScene()._inputManager._addCameraPointerObserver(this._wheel,h.POINTERWHEEL)}detachControl(){this._observer&&(this.camera.getScene()._inputManager._removeCameraPointerObserver(this._observer),this._observer=null,this._wheel=null),this.onChangedObservable&&this.onChangedObservable.clear()}checkInputs(){this.onChangedObservable.notifyObservers({wheelDeltaX:this._wheelDeltaX,wheelDeltaY:this._wheelDeltaY,wheelDeltaZ:this._wheelDeltaZ}),this._wheelDeltaX=0,this._wheelDeltaY=0,this._wheelDeltaZ=0}getClassName(){return"BaseCameraMouseWheelInput"}getSimpleName(){return"mousewheel"}},(()=>{const e="function"==typeof Symbol&&Symbol.metadata?Object.create(null):void 0;i=[a()],o=[a()],u=[a()],n(null,null,i,{kind:"field",name:"wheelPrecisionX",static:!1,private:!1,access:{has:e=>"wheelPrecisionX"in e,get:e=>e.wheelPrecisionX,set:(e,t)=>{e.wheelPrecisionX=t}},metadata:e},c,d),n(null,null,o,{kind:"field",name:"wheelPrecisionY",static:!1,private:!1,access:{has:e=>"wheelPrecisionY"in e,get:e=>e.wheelPrecisionY,set:(e,t)=>{e.wheelPrecisionY=t}},metadata:e},_,p),n(null,null,u,{kind:"field",name:"wheelPrecisionZ",static:!1,private:!1,access:{has:e=>"wheelPrecisionZ"in e,get:e=>e.wheelPrecisionZ,set:(e,t)=>{e.wheelPrecisionZ=t}},metadata:e},g,m),e&&Object.defineProperty(s,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:e})})(),s})();var S;!function(e){e[e.MoveRelative=0]="MoveRelative",e[e.RotateRelative=1]="RotateRelative",e[e.MoveScene=2]="MoveScene"}(S||(S={}));let I=(()=>{var t;let s,o,r,h,l,c,d,_,p,g=P,m=[];return t=class extends g{constructor(){super(...arguments),this.camera=e(this,m),this._moveRelative=i.Zero(),this._rotateRelative=i.Zero(),this._moveScene=i.Zero(),this._wheelXAction=S.MoveRelative,this._wheelXActionCoordinate=0,this._wheelYAction=S.MoveRelative,this._wheelYActionCoordinate=2,this._wheelZAction=null,this._wheelZActionCoordinate=null}getClassName(){return"FreeCameraMouseWheelInput"}set wheelXMoveRelative(e){null===e&&this._wheelXAction!==S.MoveRelative||(this._wheelXAction=S.MoveRelative,this._wheelXActionCoordinate=e)}get wheelXMoveRelative(){return this._wheelXAction!==S.MoveRelative?null:this._wheelXActionCoordinate}set wheelYMoveRelative(e){null===e&&this._wheelYAction!==S.MoveRelative||(this._wheelYAction=S.MoveRelative,this._wheelYActionCoordinate=e)}get wheelYMoveRelative(){return this._wheelYAction!==S.MoveRelative?null:this._wheelYActionCoordinate}set wheelZMoveRelative(e){null===e&&this._wheelZAction!==S.MoveRelative||(this._wheelZAction=S.MoveRelative,this._wheelZActionCoordinate=e)}get wheelZMoveRelative(){return this._wheelZAction!==S.MoveRelative?null:this._wheelZActionCoordinate}set wheelXRotateRelative(e){null===e&&this._wheelXAction!==S.RotateRelative||(this._wheelXAction=S.RotateRelative,this._wheelXActionCoordinate=e)}get wheelXRotateRelative(){return this._wheelXAction!==S.RotateRelative?null:this._wheelXActionCoordinate}set wheelYRotateRelative(e){null===e&&this._wheelYAction!==S.RotateRelative||(this._wheelYAction=S.RotateRelative,this._wheelYActionCoordinate=e)}get wheelYRotateRelative(){return this._wheelYAction!==S.RotateRelative?null:this._wheelYActionCoordinate}set wheelZRotateRelative(e){null===e&&this._wheelZAction!==S.RotateRelative||(this._wheelZAction=S.RotateRelative,this._wheelZActionCoordinate=e)}get wheelZRotateRelative(){return this._wheelZAction!==S.RotateRelative?null:this._wheelZActionCoordinate}set wheelXMoveScene(e){null===e&&this._wheelXAction!==S.MoveScene||(this._wheelXAction=S.MoveScene,this._wheelXActionCoordinate=e)}get wheelXMoveScene(){return this._wheelXAction!==S.MoveScene?null:this._wheelXActionCoordinate}set wheelYMoveScene(e){null===e&&this._wheelYAction!==S.MoveScene||(this._wheelYAction=S.MoveScene,this._wheelYActionCoordinate=e)}get wheelYMoveScene(){return this._wheelYAction!==S.MoveScene?null:this._wheelYActionCoordinate}set wheelZMoveScene(e){null===e&&this._wheelZAction!==S.MoveScene||(this._wheelZAction=S.MoveScene,this._wheelZActionCoordinate=e)}get wheelZMoveScene(){return this._wheelZAction!==S.MoveScene?null:this._wheelZActionCoordinate}checkInputs(){if(0===this._wheelDeltaX&&0===this._wheelDeltaY&&0==this._wheelDeltaZ)return;this._moveRelative.setAll(0),this._rotateRelative.setAll(0),this._moveScene.setAll(0),this._updateCamera(),this.camera.getScene().useRightHandedSystem&&(this._moveRelative.z*=-1);const e=u.Zero();this.camera.getViewMatrix().invertToRef(e);const t=i.Zero();i.TransformNormalToRef(this._moveRelative,e,t),this.camera.cameraRotation.x+=this._rotateRelative.x/200,this.camera.cameraRotation.y+=this._rotateRelative.y/200,this.camera.cameraDirection.addInPlace(t),this.camera.cameraDirection.addInPlace(this._moveScene),super.checkInputs()}_updateCamera(){this._updateCameraProperty(this._wheelDeltaX,this._wheelXAction,this._wheelXActionCoordinate),this._updateCameraProperty(this._wheelDeltaY,this._wheelYAction,this._wheelYActionCoordinate),this._updateCameraProperty(this._wheelDeltaZ,this._wheelZAction,this._wheelZActionCoordinate)}_updateCameraProperty(e,t,s){if(0===e)return;if(null===t||null===s)return;let i=null;switch(t){case S.MoveRelative:i=this._moveRelative;break;case S.RotateRelative:i=this._rotateRelative;break;case S.MoveScene:i=this._moveScene}switch(s){case 0:i.set(e,0,0);break;case 1:i.set(0,e,0);break;case 2:i.set(0,0,e)}}},(()=>{const e="function"==typeof Symbol&&Symbol.metadata?Object.create(g[Symbol.metadata]??null):void 0;s=[a()],o=[a()],r=[a()],h=[a()],l=[a()],c=[a()],d=[a()],_=[a()],p=[a()],n(t,null,s,{kind:"setter",name:"wheelXMoveRelative",static:!1,private:!1,access:{has:e=>"wheelXMoveRelative"in e,set:(e,t)=>{e.wheelXMoveRelative=t}},metadata:e},null,m),n(t,null,o,{kind:"setter",name:"wheelYMoveRelative",static:!1,private:!1,access:{has:e=>"wheelYMoveRelative"in e,set:(e,t)=>{e.wheelYMoveRelative=t}},metadata:e},null,m),n(t,null,r,{kind:"setter",name:"wheelZMoveRelative",static:!1,private:!1,access:{has:e=>"wheelZMoveRelative"in e,set:(e,t)=>{e.wheelZMoveRelative=t}},metadata:e},null,m),n(t,null,h,{kind:"setter",name:"wheelXRotateRelative",static:!1,private:!1,access:{has:e=>"wheelXRotateRelative"in e,set:(e,t)=>{e.wheelXRotateRelative=t}},metadata:e},null,m),n(t,null,l,{kind:"setter",name:"wheelYRotateRelative",static:!1,private:!1,access:{has:e=>"wheelYRotateRelative"in e,set:(e,t)=>{e.wheelYRotateRelative=t}},metadata:e},null,m),n(t,null,c,{kind:"setter",name:"wheelZRotateRelative",static:!1,private:!1,access:{has:e=>"wheelZRotateRelative"in e,set:(e,t)=>{e.wheelZRotateRelative=t}},metadata:e},null,m),n(t,null,d,{kind:"setter",name:"wheelXMoveScene",static:!1,private:!1,access:{has:e=>"wheelXMoveScene"in e,set:(e,t)=>{e.wheelXMoveScene=t}},metadata:e},null,m),n(t,null,_,{kind:"setter",name:"wheelYMoveScene",static:!1,private:!1,access:{has:e=>"wheelYMoveScene"in e,set:(e,t)=>{e.wheelYMoveScene=t}},metadata:e},null,m),n(t,null,p,{kind:"setter",name:"wheelZMoveScene",static:!1,private:!1,access:{has:e=>"wheelZMoveScene"in e,set:(e,t)=>{e.wheelZMoveScene=t}},metadata:e},null,m),e&&Object.defineProperty(t,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:e})})(),t})();o.FreeCameraMouseWheelInput=I;let A=(()=>{var s;let o,r,l=[],d=[],_=[],p=[];return s=class{constructor(s=!1){this.allowMouse=s,this.touchAngularSensibility=e(this,l,2e5),this.touchMoveSensibility=(e(this,d),e(this,_,250)),this.singleFingerRotate=(e(this,p),!1),this._offsetX=null,this._offsetY=null,this._pointerPressed=new Array,this._isSafari=t.IsSafari()}attachControl(e){e=t.BackCompatCameraNoPreventDefault(arguments);let s=null;if(void 0===this._pointerInput&&(this._onLostFocus=()=>{this._offsetX=null,this._offsetY=null},this._pointerInput=t=>{const i=t.event,n="mouse"===i.pointerType||this._isSafari&&void 0===i.pointerType;if(this.allowMouse||!n)if(t.type===h.POINTERDOWN){if(e||i.preventDefault(),this._pointerPressed.push(i.pointerId),1!==this._pointerPressed.length)return;s={x:i.clientX,y:i.clientY}}else if(t.type===h.POINTERUP){e||i.preventDefault();const t=this._pointerPressed.indexOf(i.pointerId);if(-1===t)return;if(this._pointerPressed.splice(t,1),0!=t)return;s=null,this._offsetX=null,this._offsetY=null}else if(t.type===h.POINTERMOVE){if(e||i.preventDefault(),!s)return;if(0!=this._pointerPressed.indexOf(i.pointerId))return;this._offsetX=i.clientX-s.x,this._offsetY=-(i.clientY-s.y)}}),this._observer=this.camera.getScene()._inputManager._addCameraPointerObserver(this._pointerInput,h.POINTERDOWN|h.POINTERUP|h.POINTERMOVE),this._onLostFocus){const e=this.camera.getEngine().getInputElement();e&&e.addEventListener("blur",this._onLostFocus)}}detachControl(){if(this._pointerInput){if(this._observer&&(this.camera.getScene()._inputManager._removeCameraPointerObserver(this._observer),this._observer=null),this._onLostFocus){const e=this.camera.getEngine().getInputElement();e&&e.removeEventListener("blur",this._onLostFocus),this._onLostFocus=null}this._pointerPressed.length=0,this._offsetX=null,this._offsetY=null}}checkInputs(){if(null===this._offsetX||null===this._offsetY)return;if(0===this._offsetX&&0===this._offsetY)return;const e=this.camera,t=e.movement.input,s=t.getEntry("touch","rotate"),n=t.getEntry("touch","translate"),a=e._calculateHandednessMultiplier(),o=this.singleFingerRotate&&1===this._pointerPressed.length||!this.singleFingerRotate&&this._pointerPressed.length>1;if(s){const t=s.sensitivity??1/this.touchAngularSensibility;e.cameraRotation.y=this._offsetX*a*t,o&&(e.cameraRotation.x=-this._offsetY*a*t)}if(!o&&n){const t=e._computeLocalCameraSpeed(),s=n.sensitivity??(0!==this.touchMoveSensibility?1/this.touchMoveSensibility:0),a=c.Vector3[0];a.copyFromFloats(0,0,t*this._offsetY*s),u.RotationYawPitchRollToRef(e.rotation.y,e.rotation.x,0,e._cameraRotationMatrix),i.TransformCoordinatesToRef(a,e._cameraRotationMatrix,a),e.cameraDirection.addInPlace(a)}}getClassName(){return"FreeCameraTouchInput"}getSimpleName(){return"touch"}},(()=>{const e="function"==typeof Symbol&&Symbol.metadata?Object.create(null):void 0;o=[a()],r=[a()],n(null,null,o,{kind:"field",name:"touchAngularSensibility",static:!1,private:!1,access:{has:e=>"touchAngularSensibility"in e,get:e=>e.touchAngularSensibility,set:(e,t)=>{e.touchAngularSensibility=t}},metadata:e},l,d),n(null,null,r,{kind:"field",name:"touchMoveSensibility",static:!1,private:!1,access:{has:e=>"touchMoveSensibility"in e,get:e=>e.touchMoveSensibility,set:(e,t)=>{e.touchMoveSensibility=t}},metadata:e},_,p),e&&Object.defineProperty(s,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:e})})(),s})();o.FreeCameraTouchInput=A;class O extends d{constructor(e){super(e),this._mouseInput=null,this._mouseWheelInput=null}addKeyboard(){return this.add(new M),this}addMouse(e=!0){return this._mouseInput||(this._mouseInput=new x(e),this.add(this._mouseInput)),this}removeMouse(){return this._mouseInput&&this.remove(this._mouseInput),this}addMouseWheel(){return this._mouseWheelInput||(this._mouseWheelInput=new I,this.add(this._mouseWheelInput)),this}removeMouseWheel(){return this._mouseWheelInput&&this.remove(this._mouseWheelInput),this}addTouch(){return this.add(new A),this}clear(){super.clear(),this._mouseInput=null}}O.prototype.addDeviceOrientation??=_("FreeCameraInputsManager","addDeviceOrientation"),O.prototype.addVirtualJoystick??=_("FreeCameraInputsManager","addVirtualJoystick"),O.prototype.addGamepad??=_("FreeCameraInputsManager","addGamepad");let D=(()=>{var s;let o,r,h,l,u=m,c=[],d=[],_=[],y=[],f=[],w=[],k=[],b=[];return s=class extends u{get angularSensibility(){const e=this.inputs.attached.mouse;return e?e.angularSensibility:0}set angularSensibility(e){const t=this.inputs.attached.mouse;t&&(t.angularSensibility=e)}get keysUp(){const e=this.inputs.attached.keyboard;return e?e.keysUp:[]}set keysUp(e){const t=this.inputs.attached.keyboard;t&&(t.keysUp=e)}get keysUpward(){const e=this.inputs.attached.keyboard;return e?e.keysUpward:[]}set keysUpward(e){const t=this.inputs.attached.keyboard;t&&(t.keysUpward=e)}get keysDown(){const e=this.inputs.attached.keyboard;return e?e.keysDown:[]}set keysDown(e){const t=this.inputs.attached.keyboard;t&&(t.keysDown=e)}get keysDownward(){const e=this.inputs.attached.keyboard;return e?e.keysDownward:[]}set keysDownward(e){const t=this.inputs.attached.keyboard;t&&(t.keysDownward=e)}get keysLeft(){const e=this.inputs.attached.keyboard;return e?e.keysLeft:[]}set keysLeft(e){const t=this.inputs.attached.keyboard;t&&(t.keysLeft=e)}get keysRight(){const e=this.inputs.attached.keyboard;return e?e.keysRight:[]}set keysRight(e){const t=this.inputs.attached.keyboard;t&&(t.keysRight=e)}get keysRotateLeft(){const e=this.inputs.attached.keyboard;return e?e.keysRotateLeft:[]}set keysRotateLeft(e){const t=this.inputs.attached.keyboard;t&&(t.keysRotateLeft=e)}get keysRotateRight(){const e=this.inputs.attached.keyboard;return e?e.keysRotateRight:[]}set keysRotateRight(e){const t=this.inputs.attached.keyboard;t&&(t.keysRotateRight=e)}get keysRotateUp(){const e=this.inputs.attached.keyboard;return e?e.keysRotateUp:[]}set keysRotateUp(e){const t=this.inputs.attached.keyboard;t&&(t.keysRotateUp=e)}get keysRotateDown(){const e=this.inputs.attached.keyboard;return e?e.keysRotateDown:[]}set keysRotateDown(e){const t=this.inputs.attached.keyboard;t&&(t.keysRotateDown=e)}constructor(t,s,n,a=!0){super(t,s,n,a),this.ellipsoid=e(this,c,new i(.5,1,.5)),this.ellipsoidOffset=(e(this,d),e(this,_,new i(0,0,0))),this.checkCollisions=(e(this,y),e(this,f,!1)),this.applyGravity=(e(this,w),e(this,k,!1)),this.inputs=e(this,b),this._needMoveForGravity=!1,this._oldPosition=i.Zero(),this._diffPosition=i.Zero(),this._newPosition=i.Zero(),this._collisionMask=-1,this._onCollisionPositionChange=(e,t,s=null)=>{this._newPosition.copyFrom(t),this._newPosition.subtractToRef(this._oldPosition,this._diffPosition),this._diffPosition.length()>p.CollisionsEpsilon&&(this.position.addToRef(this._diffPosition,this._deferredPositionUpdate),this._deferOnly?this._deferredUpdated=!0:this.position.copyFrom(this._deferredPositionUpdate),this.onCollide&&s&&this.onCollide(s))},this.inputs=new O(this),this.inputs.addKeyboard().addMouse()}attachControl(e,s){s=t.BackCompatCameraNoPreventDefault(arguments),this.inputs.attachElement(s)}detachControl(){this.inputs.detachElement(),this.cameraDirection=new i(0,0,0),this.cameraRotation=new g(0,0)}get collisionMask(){return this._collisionMask}set collisionMask(e){this._collisionMask=isNaN(e)?-1:e}_collideWithWorld(e){let t;t=this.parent?i.TransformCoordinates(this.position,this.parent.getWorldMatrix()):this.position,t.subtractFromFloatsToRef(0,this.ellipsoid.y,0,this._oldPosition),this._oldPosition.addInPlace(this.ellipsoidOffset);const s=this.getScene().collisionCoordinator;this._collider||(this._collider=s.createCollider()),this._collider._radius=this.ellipsoid,this._collider.collisionMask=this._collisionMask;let n=e;this.applyGravity&&(n=e.add(this.getScene().gravity)),s.getNewPosition(this._oldPosition,n,this._collider,3,null,this._onCollisionPositionChange,this.uniqueId)}_checkInputs(){this._localDirection||(this._localDirection=i.Zero(),this._transformedDirection=i.Zero()),this.inputs.checkInputs(),super._checkInputs()}set needMoveForGravity(e){this._needMoveForGravity=e}get needMoveForGravity(){return this._needMoveForGravity}_decideIfNeedsToMove(){return this._needMoveForGravity||Math.abs(this.cameraDirection.x)>0||Math.abs(this.cameraDirection.y)>0||Math.abs(this.cameraDirection.z)>0}_updatePosition(){this.checkCollisions&&this.getScene().collisionsEnabled?this._collideWithWorld(this.cameraDirection):super._updatePosition()}dispose(){this.inputs.clear(),super.dispose()}getClassName(){return"FreeCamera"}},(()=>{const e="function"==typeof Symbol&&Symbol.metadata?Object.create(u[Symbol.metadata]??null):void 0;o=[v()],r=[v()],h=[a()],l=[a()],n(null,null,o,{kind:"field",name:"ellipsoid",static:!1,private:!1,access:{has:e=>"ellipsoid"in e,get:e=>e.ellipsoid,set:(e,t)=>{e.ellipsoid=t}},metadata:e},c,d),n(null,null,r,{kind:"field",name:"ellipsoidOffset",static:!1,private:!1,access:{has:e=>"ellipsoidOffset"in e,get:e=>e.ellipsoidOffset,set:(e,t)=>{e.ellipsoidOffset=t}},metadata:e},_,y),n(null,null,h,{kind:"field",name:"checkCollisions",static:!1,private:!1,access:{has:e=>"checkCollisions"in e,get:e=>e.checkCollisions,set:(e,t)=>{e.checkCollisions=t}},metadata:e},f,w),n(null,null,l,{kind:"field",name:"applyGravity",static:!1,private:!1,access:{has:e=>"applyGravity"in e,get:e=>e.applyGravity,set:(e,t)=>{e.applyGravity=t}},metadata:e},k,b),e&&Object.defineProperty(s,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:e})})(),s})(),U=(()=>{var t;let s,i,o=[],h=[],l=[],u=[];return t=class{get influence(){return this._influence}set influence(e){if(this._influence===e)return;const t=this._influence;this._influence=e,this.onInfluenceChanged.hasObservers()&&this.onInfluenceChanged.notifyObservers(0===t||0===e)}get animationPropertiesOverride(){return!this._animationPropertiesOverride&&this._scene?this._scene.animationPropertiesOverride:this._animationPropertiesOverride}set animationPropertiesOverride(e){this._animationPropertiesOverride=e}constructor(t,s=0,i=null,n=null){this.name=t,this.animations=[],this._positions=null,this._normals=null,this._tangents=null,this._uvs=null,this._uv2s=null,this._colors=null,this._uniqueId=0,this.onInfluenceChanged=new r,this._onDataLayoutChanged=new r,this.id=e(this,o,void 0),this.morphTargetManager=(e(this,h),e(this,l,null)),this._animationPropertiesOverride=(e(this,u),null),this.id=t,this.morphTargetManager=n,this._scene=i||y.LastCreatedScene,this.influence=s,this._scene&&(this._uniqueId=this._scene.getUniqueId())}get uniqueId(){return this._uniqueId}get hasPositions(){return!!this._positions}get hasNormals(){return!!this._normals}get hasTangents(){return!!this._tangents}get hasUVs(){return!!this._uvs}get hasUV2s(){return!!this._uv2s}get hasColors(){return!!this._colors}get vertexCount(){return this._positions?this._positions.length/3:this._normals?this._normals.length/3:this._tangents?this._tangents.length/3:this._uvs?this._uvs.length/2:this._uv2s?this._uv2s.length/2:this._colors?this._colors.length/4:0}setPositions(e){const t=this.hasPositions;this._positions=e,t!==this.hasPositions&&this._onDataLayoutChanged.notifyObservers(void 0)}getPositions(){return this._positions}setNormals(e){const t=this.hasNormals;this._normals=e,t!==this.hasNormals&&this._onDataLayoutChanged.notifyObservers(void 0)}getNormals(){return this._normals}setTangents(e){const t=this.hasTangents;this._tangents=e,t!==this.hasTangents&&this._onDataLayoutChanged.notifyObservers(void 0)}getTangents(){return this._tangents}setUVs(e){const t=this.hasUVs;this._uvs=e,t!==this.hasUVs&&this._onDataLayoutChanged.notifyObservers(void 0)}getUVs(){return this._uvs}setUV2s(e){const t=this.hasUV2s;this._uv2s=e,t!==this.hasUV2s&&this._onDataLayoutChanged.notifyObservers(void 0)}getUV2s(){return this._uv2s}setColors(e){const t=this.hasColors;this._colors=e,t!==this.hasColors&&this._onDataLayoutChanged.notifyObservers(void 0)}getColors(){return this._colors}clone(){const e=f.Clone(()=>new t(this.name,this.influence,this._scene,this.morphTargetManager),this);return e._positions=this._positions,e._normals=this._normals,e._tangents=this._tangents,e._uvs=this._uvs,e._uv2s=this._uv2s,e._colors=this._colors,e}serialize(){const e={};return e.name=this.name,e.influence=this.influence,null!=this.id&&(e.id=this.id),e.uniqueId=this.uniqueId,e.positions=Array.prototype.slice.call(this.getPositions()),this.hasNormals&&(e.normals=Array.prototype.slice.call(this.getNormals())),this.hasTangents&&(e.tangents=Array.prototype.slice.call(this.getTangents())),this.hasUVs&&(e.uvs=Array.prototype.slice.call(this.getUVs())),this.hasUV2s&&(e.uv2s=Array.prototype.slice.call(this.getUV2s())),this.hasColors&&(e.colors=Array.prototype.slice.call(this.getColors())),f.AppendSerializedAnimations(this,e),e}getClassName(){return"MorphTarget"}static Parse(e,s,i=null){const n=new t(e.name,e.influence,s,i);if(n.setPositions(e.positions),null!=e.id&&(n.id=e.id),e.normals&&n.setNormals(e.normals),e.tangents&&n.setTangents(e.tangents),e.uvs&&n.setUVs(e.uvs),e.uv2s&&n.setUV2s(e.uv2s),e.colors&&n.setColors(e.colors),e.animations){for(let t=0;t<e.animations.length;t++){const s=e.animations[t],i=w("BABYLON.Animation");i&&n.animations.push(i.Parse(s))}e.autoAnimate&&s&&s.beginAnimation(n,e.autoAnimateFrom,e.autoAnimateTo,e.autoAnimateLoop,e.autoAnimateSpeed||1)}return n}static FromMesh(e,s,i){s||(s=e.name);const n=new t(s,i,e.getScene(),e.morphTargetManager);return n.setPositions(e.getVerticesData(k.PositionKind)),e.isVerticesDataPresent(k.NormalKind)&&n.setNormals(e.getVerticesData(k.NormalKind)),e.isVerticesDataPresent(k.TangentKind)&&n.setTangents(e.getVerticesData(k.TangentKind)),e.isVerticesDataPresent(k.UVKind)&&n.setUVs(e.getVerticesData(k.UVKind)),e.isVerticesDataPresent(k.UV2Kind)&&n.setUV2s(e.getVerticesData(k.UV2Kind)),e.isVerticesDataPresent(k.ColorKind)&&n.setColors(e.getVerticesData(k.ColorKind)),n}},(()=>{const e="function"==typeof Symbol&&Symbol.metadata?Object.create(null):void 0;s=[a()],i=[a()],n(null,null,s,{kind:"field",name:"id",static:!1,private:!1,access:{has:e=>"id"in e,get:e=>e.id,set:(e,t)=>{e.id=t}},metadata:e},o,h),n(null,null,i,{kind:"field",name:"morphTargetManager",static:!1,private:!1,access:{has:e=>"morphTargetManager"in e,get:e=>e.morphTargetManager,set:(e,t)=>{e.morphTargetManager=t}},metadata:e},l,u),e&&Object.defineProperty(t,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:e})})(),t})();class V extends b{get depth(){return this._depth}constructor(e,t,s,i,n,a,o=!0,r=!1,h=b.TRILINEAR_SAMPLINGMODE,l=R.TEXTURETYPE_UNSIGNED_BYTE,u,c){super(null,a,!o,r),this.format=n,this._texture=a.getEngine().createRawTexture2DArray(e,t,s,i,n,o,r,h,null,l,u??0,c),this._depth=i,this.is2DArray=!0}update(e){this.updateMipLevel(e,0)}updateMipLevel(e,t){this._texture&&this._getEngine().updateRawTexture2DArray(this._texture,e,this._texture.format,this._texture.invertY,null,this._texture.type,t)}static CreateRGBATexture(e,t,s,i,n,a=!0,o=!1,r=R.TEXTURE_TRILINEAR_SAMPLINGMODE,h=R.TEXTURETYPE_UNSIGNED_BYTE){return new V(e,t,s,i,R.TEXTUREFORMAT_RGBA,n,a,o,r,h)}}class E{set areUpdatesFrozen(e){e?this._blockCounter++:(this._blockCounter--,this._blockCounter<=0&&(this._blockCounter=0,this._syncActiveTargets(this._forceUpdateWhenUnfrozen),this._forceUpdateWhenUnfrozen=!1))}get areUpdatesFrozen(){return this._blockCounter>0}constructor(e=null,t){if(this.meshName=t,this._targets=new Array,this._targetInfluenceChangedObservers=new Array,this._targetDataLayoutChangedObservers=new Array,this._activeTargets=new C(16),this._supportsPositions=!1,this._supportsNormals=!1,this._supportsTangents=!1,this._supportsUVs=!1,this._supportsUV2s=!1,this._supportsColors=!1,this._vertexCount=0,this._uniqueId=0,this._tempInfluences=new Array,this._canUseTextureForTargets=!1,this._blockCounter=0,this._mustSynchronize=!0,this._forceUpdateWhenUnfrozen=!1,this._textureVertexStride=0,this._textureWidth=0,this._textureHeight=1,this._parentContainer=null,this.optimizeInfluencers=!0,this.enablePositionMorphing=!0,this.enableNormalMorphing=!0,this.enableTangentMorphing=!0,this.enableUVMorphing=!0,this.enableUV2Morphing=!0,this.enableColorMorphing=!0,this._numMaxInfluencers=0,this._useTextureToStoreTargets=!0,this.metadata=null,this._influencesAreDirty=!1,this._needUpdateInfluences=!1,e||(e=y.LastCreatedScene),this._scene=e,this._scene){this._scene.addMorphTargetManager(this),this._uniqueId=this._scene.getUniqueId();const e=this._scene.getEngine().getCaps();this._canUseTextureForTargets=e.canUseGLVertexID&&e.textureFloat&&e.maxVertexTextureImageUnits>0&&e.texture2DArrayMaxLayerCount>1}}get numMaxInfluencers(){return E.ConstantTargetCountForTextureMode>0&&this.isUsingTextureForTargets?E.ConstantTargetCountForTextureMode:this._numMaxInfluencers}set numMaxInfluencers(e){this._numMaxInfluencers!==e&&(this._numMaxInfluencers=e,this._mustSynchronize=!0,this._syncActiveTargets())}get uniqueId(){return this._uniqueId}get vertexCount(){return this._vertexCount}get supportsPositions(){return this._supportsPositions&&this.enablePositionMorphing}get supportsNormals(){return this._supportsNormals&&this.enableNormalMorphing}get supportsTangents(){return this._supportsTangents&&this.enableTangentMorphing}get supportsUVs(){return this._supportsUVs&&this.enableUVMorphing}get supportsUV2s(){return this._supportsUV2s&&this.enableUV2Morphing}get supportsColors(){return this._supportsColors&&this.enableColorMorphing}get hasPositions(){return this._supportsPositions}get hasNormals(){return this._supportsNormals}get hasTangents(){return this._supportsTangents}get hasUVs(){return this._supportsUVs}get hasUV2s(){return this._supportsUV2s}get hasColors(){return this._supportsColors}get numTargets(){return this._targets.length}get numInfluencers(){return this._influencesAreDirty&&this._syncActiveTargets(),this._activeTargets.length}get influences(){return this._influencesAreDirty&&this._syncActiveTargets(),this._influences}get useTextureToStoreTargets(){return this._useTextureToStoreTargets}set useTextureToStoreTargets(e){this._useTextureToStoreTargets!==e&&(this._useTextureToStoreTargets=e,this._mustSynchronize=!0,this._syncActiveTargets())}get isUsingTextureForTargets(){return E.EnableTextureStorage&&this.useTextureToStoreTargets&&this._canUseTextureForTargets&&!this._scene?.getEngine().getCaps().disableMorphTargetTexture}getActiveTarget(e){return this._influencesAreDirty&&this._syncActiveTargets(),this._activeTargets.data[e]}getTarget(e){return this._targets[e]}getTargetByName(e){for(const t of this._targets)if(t.name===e)return t;return null}addTarget(e){this._targets.push(e),this._targetInfluenceChangedObservers.push(e.onInfluenceChanged.add(e=>{this.areUpdatesFrozen&&e&&(this._forceUpdateWhenUnfrozen=!0),this._influencesAreDirty=!0,this._needUpdateInfluences=this._needUpdateInfluences||e})),this._targetDataLayoutChangedObservers.push(e._onDataLayoutChanged.add(()=>{this._mustSynchronize=!0,this._syncActiveTargets()})),this._mustSynchronize=!0,this._syncActiveTargets()}removeTarget(e){const t=this._targets.indexOf(e);t>=0&&(this._targets.splice(t,1),e.onInfluenceChanged.remove(this._targetInfluenceChangedObservers.splice(t,1)[0]),e._onDataLayoutChanged.remove(this._targetDataLayoutChangedObservers.splice(t,1)[0]),this._mustSynchronize=!0,this._syncActiveTargets()),this._scene&&this._scene.stopAnimation(e)}_bind(e){this._influencesAreDirty&&this._syncActiveTargets(),e.setFloat3("morphTargetTextureInfo",this._textureVertexStride,this._textureWidth,this._textureHeight),e.setFloatArray("morphTargetTextureIndices",this._morphTargetTextureIndices),e.setTexture("morphTargets",this._targetStoreTexture),e.setFloat("morphTargetCount",this.numInfluencers)}clone(){const e=new E(this._scene);e.areUpdatesFrozen=!0;for(const t of this._targets)e.addTarget(t.clone());return e.areUpdatesFrozen=!1,e.enablePositionMorphing=this.enablePositionMorphing,e.enableNormalMorphing=this.enableNormalMorphing,e.enableTangentMorphing=this.enableTangentMorphing,e.enableUVMorphing=this.enableUVMorphing,e.enableUV2Morphing=this.enableUV2Morphing,e.enableColorMorphing=this.enableColorMorphing,e.metadata=this.metadata,e}serialize(){const e={};e.id=this.uniqueId,e.meshName=this.meshName,e.targets=[];for(const t of this._targets)e.targets.push(t.serialize());return this.metadata&&(e.metadata=this.metadata),e}_syncActiveTargets(e=!1){if(this.areUpdatesFrozen)return;e=e||this._needUpdateInfluences,this._needUpdateInfluences=!1,this._influencesAreDirty=!1;const t=!!this._targetStoreTexture,s=this.isUsingTextureForTargets;(this._mustSynchronize||t!==s)&&(this._mustSynchronize=!1,this.synchronize());let i=0;this._activeTargets.reset(),this._morphTargetTextureIndices&&this._morphTargetTextureIndices.length===this._targets.length||(this._morphTargetTextureIndices=new Float32Array(this._targets.length));let n=-1;for(const e of this._targets)if(n++,0!==e.influence||!this.optimizeInfluencers){if(this._activeTargets.length>=E.MaxActiveMorphTargetsInVertexAttributeMode&&!this.isUsingTextureForTargets)break;this._activeTargets.push(e),this._morphTargetTextureIndices[i]=n,this._tempInfluences[i++]=e.influence}this._morphTargetTextureIndices.length!==i&&(this._morphTargetTextureIndices=this._morphTargetTextureIndices.slice(0,i)),this._influences&&this._influences.length===i||(this._influences=new Float32Array(i));for(let e=0;e<i;e++)this._influences[e]=this._tempInfluences[e];if(e&&this._scene)for(const e of this._scene.meshes)e.morphTargetManager===this&&(s?e._markSubMeshesAsAttributesDirty():e._syncGeometryWithMorphTargetManager())}synchronize(){if(!this._scene||this.areUpdatesFrozen)return;const e=this._scene.getEngine();this._supportsPositions=!0,this._supportsNormals=!0,this._supportsTangents=!0,this._supportsUVs=!0,this._supportsUV2s=!0,this._supportsColors=!0,this._vertexCount=0,this._targetStoreTexture?.dispose(),this._targetStoreTexture=null,this.isUsingTextureForTargets&&this._targets.length>e.getCaps().texture2DArrayMaxLayerCount&&(this.useTextureToStoreTargets=!1);for(const e of this._targets){this._supportsPositions=this._supportsPositions&&e.hasPositions,this._supportsNormals=this._supportsNormals&&e.hasNormals,this._supportsTangents=this._supportsTangents&&e.hasTangents,this._supportsUVs=this._supportsUVs&&e.hasUVs,this._supportsUV2s=this._supportsUV2s&&e.hasUV2s,this._supportsColors=this._supportsColors&&e.hasColors;const t=e.vertexCount;if(0===this._vertexCount)this._vertexCount=t;else if(this._vertexCount!==t)return void T.Error(`Incompatible target. Targets must all have the same vertices count. Current vertex count: ${this._vertexCount}, vertex count for target "${e.name}": ${t}`)}if(this.isUsingTextureForTargets){this._textureVertexStride=0,this._supportsPositions&&this._textureVertexStride++,this._supportsNormals&&this._textureVertexStride++,this._supportsTangents&&this._textureVertexStride++,this._supportsUVs&&this._textureVertexStride++,this._supportsUV2s&&this._textureVertexStride++,this._supportsColors&&this._textureVertexStride++,this._textureWidth=this._vertexCount*this._textureVertexStride||1,this._textureHeight=1;const t=e.getCaps().maxTextureSize;this._textureWidth>t&&(this._textureHeight=Math.ceil(this._textureWidth/t),this._textureWidth=t);const s=this._targets.length,i=new Float32Array(s*this._textureWidth*this._textureHeight*4);let n;for(let e=0;e<s;e++){const t=this._targets[e],s=t.getPositions(),a=t.getNormals(),o=t.getUVs(),r=t.getTangents(),h=t.getUV2s(),l=t.getColors();n=e*this._textureWidth*this._textureHeight*4;for(let e=0;e<this._vertexCount;e++)this._supportsPositions&&s&&(i[n]=s[3*e],i[n+1]=s[3*e+1],i[n+2]=s[3*e+2],n+=4),this._supportsNormals&&a&&(i[n]=a[3*e],i[n+1]=a[3*e+1],i[n+2]=a[3*e+2],n+=4),this._supportsUVs&&o&&(i[n]=o[2*e],i[n+1]=o[2*e+1],n+=4),this._supportsTangents&&r&&(i[n]=r[3*e],i[n+1]=r[3*e+1],i[n+2]=r[3*e+2],n+=4),this._supportsUV2s&&h&&(i[n]=h[2*e],i[n+1]=h[2*e+1],n+=4),this._supportsColors&&l&&(i[n]=l[4*e],i[n+1]=l[4*e+1],i[n+2]=l[4*e+2],i[n+3]=l[4*e+3],n+=4)}this._targetStoreTexture=V.CreateRGBATexture(i,this._textureWidth,this._textureHeight,s,this._scene,!1,!1,R.TEXTURE_NEAREST_SAMPLINGMODE,R.TEXTURETYPE_FLOAT),this._targetStoreTexture.name=`Morph texture_${this.uniqueId}`}for(const e of this._scene.meshes)e.morphTargetManager===this&&e._syncGeometryWithMorphTargetManager()}dispose(){if(this._targetStoreTexture&&this._targetStoreTexture.dispose(),this._targetStoreTexture=null,this.metadata=null,this._scene){if(this._scene.removeMorphTargetManager(this),this._parentContainer){const e=this._parentContainer.morphTargetManagers.indexOf(this);e>-1&&this._parentContainer.morphTargetManagers.splice(e,1),this._parentContainer=null}for(const e of this._targets)this._scene.stopAnimation(e)}}static Parse(e,t){const s=new E(t);for(const i of e.targets)s.addTarget(U.Parse(i,t,s));return e.metadata&&(s.metadata=e.metadata),s}}E.EnableTextureStorage=!0,E.MaxActiveMorphTargetsInVertexAttributeMode=8,E.ConstantTargetCountForTextureMode=0;export{D as F,E as M,U as a};
//# sourceMappingURL=morphTargetManager-CdEb1BHc.esm.min.js.map