@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.
1 lines • 1.45 MB
JavaScript
"undefined"==typeof Symbol||Symbol.metadata||Object.defineProperty(Symbol,"metadata",{configurable:!0,writable:!0,value:Symbol("Symbol.metadata")});class e extends Error{}e._setPrototypeOf=Object.setPrototypeOf||((e,t)=>(e.__proto__=t,e));const t={MeshInvalidPositionsError:0,GLTFLoaderUnexpectedMagicError:2e3,SceneLoaderError:3e3,LoadFileError:4e3,RequestFileError:4001,ReadFileError:4002};class s extends e{constructor(t,i,r){super(t),this.errorCode=i,this.innerError=r,this.name="RuntimeError",e._setPrototypeOf(this,s.prototype)}}class i extends e{constructor(t="Operation aborted"){super(t),this.name="AbortError",e._setPrototypeOf(this,i.prototype)}}class r{get resolve(){return this._resolve}get reject(){return this._reject}constructor(){this.promise=new Promise((e,t)=>{this._resolve=e,this._reject=t})}}class n{constructor(){this._currentOperation=Promise.resolve()}lockAsync(e,t){t?.throwIfAborted();const s=t?()=>(t.throwIfAborted(),e()):e,i=this._currentOperation.then(s);return this._currentOperation=new Promise(e=>{i.then(()=>e(),e)}),i}static async LockAsync(e,t,s){if(s?.throwIfAborted(),0===t.length)return await e();const i=new r;let n=0;for(const r of t)r.lockAsync(async()=>(n++,n===t.length&&i.resolve(await e()),await i.promise),s).catch(e=>i.reject(e));return await i.promise}}class a{static _CheckLimit(e,t){let s=a._LogLimitOutputs[e];return s?s.current++:(s={limit:t,current:1},a._LogLimitOutputs[e]=s),s.current<=s.limit}static _GenerateLimitMessage(e,t=1){const s=a._LogLimitOutputs[e];if(!s||!a.MessageLimitReached)return;const i=this._Levels[t];s.current===s.limit&&a[i.name](a.MessageLimitReached.replace(/%LIMIT%/g,""+s.limit).replace(/%TYPE%/g,i.name??""))}static _AddLogEntry(e){a._LogCache=e+a._LogCache,a.OnNewCacheEntry&&a.OnNewCacheEntry(e)}static _FormatMessage(e){const t=e=>e<10?"0"+e:""+e,s=new Date;return"["+t(s.getHours())+":"+t(s.getMinutes())+":"+t(s.getSeconds())+"]: "+e}static _LogDisabled(e,t){}static _LogEnabled(e=1,t,s){const i=Array.isArray(t)?t[0]:t;if(void 0!==s&&!a._CheckLimit(i,s))return;const r=a._FormatMessage(i),n=this._Levels[e],o=Array.isArray(t)?t.slice(1):[];n.logFunc&&n.logFunc("BJS - "+r,...o);const h=`<div style='color:${n.color}'>${r}</div><br>`;a._AddLogEntry(h),a._GenerateLimitMessage(i,e)}static get LogCache(){return a._LogCache}static ClearLogCache(){a._LogCache="",a._LogLimitOutputs={},a.errorsCount=0}static set LogLevels(e){a.Log=a._LogDisabled,a.Warn=a._LogDisabled,a.Error=a._LogDisabled;const t=[a.MessageLogLevel,a.WarningLogLevel,a.ErrorLogLevel];for(const s of t)if((e&s)===s){const e=this._Levels[s];a[e.name]=a._LogEnabled.bind(a,s)}}}a.NoneLogLevel=0,a.MessageLogLevel=1,a.WarningLogLevel=2,a.ErrorLogLevel=4,a.AllLogLevel=7,a.MessageLimitReached="Too many %TYPE%s (%LIMIT%), no more %TYPE%s will be reported for this message.",a._LogCache="",a._LogLimitOutputs={},a._Levels=[{},{color:"white",logFunc:console.log,name:"Log"},{color:"orange",logFunc:console.warn,name:"Warn"},{},{color:"red",logFunc:console.error,name:"Error"}],a.errorsCount=0,a.Log=a._LogEnabled.bind(a,a.MessageLogLevel),a.Warn=a._LogEnabled.bind(a,a.WarningLogLevel),a.Error=a._LogEnabled.bind(a,a.ErrorLogLevel);const o="undefined"!=typeof WeakRef;class h{constructor(e,t=!1,s,i){this.initialize(e,t,s,i)}initialize(e,t=!1,s,i){return this.mask=e,this.skipNextObservers=t,this.target=s,this.currentTarget=i,this}}class l{constructor(e,t,s=null){this.callback=e,this.mask=t,this.scope=s,this._willBeUnregistered=!1,this.unregisterOnNextCall=!1,this._remove=null}remove(e=!1){this._remove&&this._remove(e)}}class c{static FromPromise(e,t){const s=new c;return e.then(e=>{s.notifyObservers(e)}).catch(e=>{if(!t)throw e;t.notifyObservers(e)}),s}get observers(){return this._observers}constructor(e,t=!1){this.notifyIfTriggered=t,this._observers=new Array,this._numObserversMarkedAsDeleted=0,this._hasNotified=!1,this._eventState=new h(0),e&&(this._onObserverAdded=e)}add(e,t=-1,s=!1,i=null,r=!1){if(!e)return null;const n=new l(e,t,i);n.unregisterOnNextCall=r,s?this._observers.unshift(n):this._observers.push(n),this._onObserverAdded&&this._onObserverAdded(n),this._hasNotified&&this.notifyIfTriggered&&void 0!==this._lastNotifiedValue&&this.notifyObserver(n,this._lastNotifiedValue);const a=o?new WeakRef(this):{deref:()=>this};return n._remove=(e=!1)=>{const t=a.deref();t&&(e?t.remove(n):t._remove(n))},n}addOnce(e){return this.add(e,void 0,void 0,void 0,!0)}remove(e){if(!e)return!1;e._remove=null;return-1!==this._observers.indexOf(e)&&(this._deferUnregister(e),!0)}removeCallback(e,t){for(let s=0;s<this._observers.length;s++){const i=this._observers[s];if(!i._willBeUnregistered&&(i.callback===e&&(!t||t===i.scope)))return this._deferUnregister(i),!0}return!1}_deferUnregister(e){e._willBeUnregistered||(this._numObserversMarkedAsDeleted++,e.unregisterOnNextCall=!1,e._willBeUnregistered=!0,setTimeout(()=>{this._remove(e)},0))}_remove(e,t=!0){if(!e)return!1;const s=this._observers.indexOf(e);return-1!==s&&(t&&this._numObserversMarkedAsDeleted--,this._observers.splice(s,1),!0)}makeObserverTopPriority(e){this._remove(e,!1),this._observers.unshift(e)}makeObserverBottomPriority(e){this._remove(e,!1),this._observers.push(e)}notifyObservers(e,t=-1,s,i,r){if(this.notifyIfTriggered&&(this._hasNotified=!0,this._lastNotifiedValue=e),!this._observers.length)return!0;const n=this._eventState;n.mask=t,n.target=s,n.currentTarget=i,n.skipNextObservers=!1,n.lastReturnValue=e,n.userInfo=r;for(const s of this._observers)if(!s._willBeUnregistered&&(s.mask&t&&(s.unregisterOnNextCall&&this._deferUnregister(s),s.scope?n.lastReturnValue=s.callback.apply(s.scope,[e,n]):n.lastReturnValue=s.callback(e,n)),n.skipNextObservers))return!1;return!0}notifyObserver(e,t,s=-1){if(this.notifyIfTriggered&&(this._hasNotified=!0,this._lastNotifiedValue=t),e._willBeUnregistered)return;const i=this._eventState;i.mask=s,i.skipNextObservers=!1,e.unregisterOnNextCall&&this._deferUnregister(e),e.callback(t,i)}hasObservers(){return this._observers.length-this._numObserversMarkedAsDeleted>0}clear(){for(;this._observers.length;){const e=this._observers.pop();e&&(e._remove=null)}this._onObserverAdded=null,this._numObserversMarkedAsDeleted=0,this.cleanLastNotifiedState()}cleanLastNotifiedState(){this._hasNotified=!1,this._lastNotifiedValue=void 0}clone(){const e=new c;return e._observers=this._observers.slice(0),e}hasSpecificMask(e=-1){for(const t of this._observers)if(t.mask&e||t.mask===e)return!0;return!1}}function u(...e){for(const t of e)t?.throwIfAborted()}function d(e){(async()=>{try{await e}catch(e){e instanceof i||a.Error(e)}})()}const _=["none","normal","high"],p=["none","standard","aces","neutral"];function f(e){return p.includes(e)}class g{constructor(){this.screenPosition=[NaN,NaN],this.worldPosition=[NaN,NaN,NaN],this.visibility=NaN}}const m={clearColor:[0,0,0,0],autoSuspendRendering:!0,environmentConfig:{intensity:1,blur:.3,rotation:0},environmentLighting:"auto",environmentSkybox:"none",cameraAutoOrbit:{enabled:!1,delay:2e3,speed:.05},animationAutoPlay:!1,animationSpeed:1,shadowConfig:{quality:"none"},postProcessing:{toneMapping:"neutral",contrast:1,exposure:1,ssao:"auto"},useRightHandedSystem:!1,useOpenPBR:!1},T=Math.PI/2,E=Math.PI/2.4;class R{constructor(){this.onEnvironmentChanged=new c,this.onEnvironmentConfigurationChanged=new c,this.onEnvironmentError=new c,this.onShadowsConfigurationChanged=new c,this.onPostProcessingChanged=new c,this.onModelChanged=new c,this.onModelError=new c,this.onLoadingProgressChanged=new c,this.onCameraAutoOrbitChanged=new c,this.onSelectedAnimationChanged=new c,this.onAnimationSpeedChanged=new c,this.onIsAnimationPlayingChanged=new c,this.onAnimationProgressChanged=new c,this.onSelectedMaterialVariantChanged=new c,this.onHotSpotsChanged=new c,this.onCamerasAsHotSpotsChanged=new c,this.onAfterRenderObservable=new c,this.onClearColorChanged=new c,this._loadOperations=new Set,this._isDisposed=!1,this._loadEnvironmentLightingLock=new n,this._loadEnvironmentLightingAbortController=null,this._loadEnvironmentSkyboxLock=new n,this._loadEnvironmentSkyboxAbortController=null,this._environmentIntensity=m.environmentConfig.intensity,this._environmentBlur=m.environmentConfig.blur,this._environmentRotation=m.environmentConfig.rotation,this._autoOrbitEnabled=m.cameraAutoOrbit.enabled,this._autoOrbitSpeed=m.cameraAutoOrbit.speed,this._autoOrbitDelay=m.cameraAutoOrbit.delay,this._clearColor={r:0,g:0,b:0,a:0},this._hotSpots={},this._loadModelLock=new n,this._loadModelAbortController=null,this._updateShadowsLock=new n,this._shadowsAbortController=null,this._shadowQuality=m.shadowConfig.quality}get loadingProgress(){if(this._loadOperations.size>0){let e=0;for(const t of this._loadOperations){if(null==t.progress)return!0;e+=t.progress}return e/this._loadOperations.size}return!1}_beginLoadOperation(){const e=this;let t=null;const s={get progress(){return t},set progress(s){t=s,e.onLoadingProgressChanged.notifyObservers()},dispose:()=>{e._loadOperations.delete(s),e.onLoadingProgressChanged.notifyObservers()}};return this._loadOperations.add(s),this.onLoadingProgressChanged.notifyObservers(),s}_throwIfDisposedOrAborted(...e){if(this._isDisposed)throw new Error("Viewer is disposed.");u(...e)}get _loadEnvironmentLightingAbortSignal(){return this._loadEnvironmentLightingAbortController?.signal}get _loadEnvironmentSkyboxAbortSignal(){return this._loadEnvironmentSkyboxAbortController?.signal}async loadEnvironment(e,t,s){return await this._updateEnvironment(e,t,s)}async resetEnvironment(e,t){return await this._updateEnvironment(void 0,e,t)}async _updateEnvironment(e,t,s){this._throwIfDisposedOrAborted(s);const r=!t||!!t.lighting,a=!t||!!t.skybox;if(!r&&!a)return;const o={...t,lighting:r,skybox:a},h=[],l=[];if(r){this._loadEnvironmentLightingAbortController?.abort(new i("New environment lighting is being loaded before previous environment lighting finished loading."));const e=this._loadEnvironmentLightingAbortController=new AbortController;h.push(this._loadEnvironmentLightingLock),l.push(e)}if(a){this._loadEnvironmentSkyboxAbortController?.abort(new i("New environment skybox is being loaded before previous environment skybox finished loading."));const e=this._loadEnvironmentSkyboxAbortController=new AbortController;h.push(this._loadEnvironmentSkyboxLock),l.push(e)}const c=new AbortController,d=()=>{l.every(e=>e.signal.aborted)&&c.abort(new i(l.map(e=>e.signal.reason).join(" | ")))};for(const e of l)e.signal.addEventListener("abort",d);try{await n.LockAsync(async()=>{u(s,c.signal),await this._loadEnvironmentImpl(e?.trim()??e,o,s,c.signal)},h)}finally{for(const e of l)e.signal.removeEventListener("abort",d)}}get environmentConfig(){return{intensity:this._environmentIntensity,blur:this._environmentBlur,rotation:this._environmentRotation}}set environmentConfig(e){void 0!==e.blur&&e.blur!==this._environmentBlur&&(this._environmentBlur=e.blur,this._applyEnvironmentBlur()),void 0!==e.intensity&&e.intensity!==this._environmentIntensity&&(this._environmentIntensity=e.intensity,this._applyEnvironmentIntensity()),void 0!==e.rotation&&e.rotation!==this._environmentRotation&&(this._environmentRotation=e.rotation,this._applyEnvironmentRotation()),this.onEnvironmentConfigurationChanged.notifyObservers()}get cameraAutoOrbit(){return{enabled:this._autoOrbitEnabled,speed:this._autoOrbitSpeed,delay:this._autoOrbitDelay}}set cameraAutoOrbit(e){let t=!1;void 0!==e.enabled&&e.enabled!==this._autoOrbitEnabled&&(this._autoOrbitEnabled=e.enabled,this._applyCameraAutoOrbitEnabled(),t=!0),void 0!==e.speed&&e.speed!==this._autoOrbitSpeed&&(this._autoOrbitSpeed=e.speed,this._applyCameraAutoOrbitSpeed(),t=!0),void 0!==e.delay&&e.delay!==this._autoOrbitDelay&&(this._autoOrbitDelay=e.delay,this._applyCameraAutoOrbitDelay(),t=!0),t&&this.onCameraAutoOrbitChanged.notifyObservers()}get clearColor(){return this._clearColor}set clearColor(e){this._clearColor.r=e.r,this._clearColor.g=e.g,this._clearColor.b=e.b,this._clearColor.a=e.a,this._applyClearColor(),this.onClearColorChanged.notifyObservers()}get hotSpots(){return this._hotSpots}set hotSpots(e){this._hotSpots=e,this.onHotSpotsChanged.notifyObservers()}get _loadModelAbortSignal(){return this._loadModelAbortController?.signal}async loadModel(e,t,s){return await this._updateModel(e,t,s)}async resetModel(e){return await this._updateModel(void 0,void 0,e)}async _updateModel(e,t,s){this._throwIfDisposedOrAborted(s),this._loadModelAbortController?.abort(new i("New model is being loaded before previous model finished loading."));const r=this._loadModelAbortController=new AbortController;await this._loadModelLock.lockAsync(async()=>{u(s,r.signal),await this._loadModelImpl(e,t,s,r.signal)}),r.signal.aborted||await this._afterLoadModel(e,t,s,r.signal)}async _afterLoadModel(e,t,s,i){}get _shadowsAbortSignal(){return this._shadowsAbortController?.signal}get shadowConfig(){return{quality:this._shadowQuality}}async updateShadows(e,t){if(void 0===e.quality||e.quality===this._shadowQuality)return;const s=this._shadowQuality;this._shadowQuality=e.quality;try{await this._updateShadows(this._shadowQuality,t)}catch(t){throw this._shadowQuality===e.quality&&(this._shadowQuality=s),t}this.onShadowsConfigurationChanged.notifyObservers()}async _updateShadows(e=this._shadowQuality,t){this._throwIfDisposedOrAborted(t),this._shadowsAbortController?.abort(new i("Shadows quality is being changed before previous shadows finished initializing."));const s=this._shadowsAbortController=new AbortController;await this._updateShadowsLock.lockAsync(async()=>{u(t,s.signal),await this._updateShadowsImpl(e,t,s.signal)})}dispose(){this._loadEnvironmentLightingAbortController?.abort(new i("The viewer is being disposed.")),this._loadEnvironmentLightingAbortController=null,this._loadEnvironmentSkyboxAbortController?.abort(new i("The viewer is being disposed.")),this._loadEnvironmentSkyboxAbortController=null,this._loadModelAbortController?.abort(new i("The viewer is being disposed.")),this._loadModelAbortController=null,this._shadowsAbortController?.abort(new i("The viewer is being disposed.")),this._shadowsAbortController=null,this.onEnvironmentChanged.clear(),this.onEnvironmentConfigurationChanged.clear(),this.onEnvironmentError.clear(),this.onShadowsConfigurationChanged.clear(),this.onPostProcessingChanged.clear(),this.onModelChanged.clear(),this.onModelError.clear(),this.onLoadingProgressChanged.clear(),this.onCameraAutoOrbitChanged.clear(),this.onSelectedAnimationChanged.clear(),this.onAnimationSpeedChanged.clear(),this.onIsAnimationPlayingChanged.clear(),this.onAnimationProgressChanged.clear(),this.onSelectedMaterialVariantChanged.clear(),this.onHotSpotsChanged.clear(),this.onCamerasAsHotSpotsChanged.clear(),this.onAfterRenderObservable.clear(),this.onClearColorChanged.clear(),this._isDisposed=!0}reset(...e){this._reset(!0,...e)}_reset(e,...t){const s=0===t.length;(s||t.includes("source"))&&this._resetModel(),(s||t.includes("environment"))&&this._resetEnvironment(),(s||t.includes("shadow"))&&this._resetShadows(),(s||t.includes("animation"))&&this._resetAnimation(),(s||t.includes("camera"))&&this._resetCamera(e),(s||t.includes("post-processing"))&&this._resetPostProcessing(),(s||t.includes("material-variant"))&&this._resetMaterialVariant()}_resetModel(){d(this._updateModel(this._options?.source))}_resetShadows(){d(this.updateShadows({quality:this._options?.shadowConfig?.quality??m.shadowConfig.quality}))}_resetMaterialVariant(){this.selectedMaterialVariant=this._options?.selectedMaterialVariant??null}}function b(e,t,s,i,r,n){function a(e){if(void 0!==e&&"function"!=typeof e)throw new TypeError("Function expected");return e}for(var o,h=i.kind,l="getter"===h?"get":"setter"===h?"set":"value",c=!t&&e?i.static?e:e.prototype:null,u=t||(c?Object.getOwnPropertyDescriptor(c,i.name):{}),d=!1,_=s.length-1;_>=0;_--){var p={};for(var f in i)p[f]="access"===f?{}:i[f];for(var f in i.access)p.access[f]=i.access[f];p.addInitializer=function(e){if(d)throw new TypeError("Cannot add initializers after decoration has completed");n.push(a(e||null))};var g=(0,s[_])("accessor"===h?{get:u.get,set:u.set}:u[l],p);if("accessor"===h){if(void 0===g)continue;if(null===g||"object"!=typeof g)throw new TypeError("Object expected");(o=a(g.get))&&(u.get=o),(o=a(g.set))&&(u.set=o),(o=a(g.init))&&r.unshift(o)}else(o=a(g))&&("field"===h?r.unshift(o):u[l]=o)}c&&Object.defineProperty(c,i.name,u),d=!0}function A(e,t,s){for(var i=arguments.length>2,r=0;r<t.length;r++)s=i?t[r].call(e,s):t[r].call(e);return i?s:void 0}function y(e,t,s){return"symbol"==typeof t&&(t=t.description?"[".concat(t.description,"]"):""),Object.defineProperty(e,"name",{configurable:!0,value:s?"".concat(s," ",t):t})}function M(e,t,s,i){if("a"===s&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?i:"a"===s?i.call(e):i?i.value:t.get(e)}function x(e,t,s,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,s):r?r.value=s:t.set(e,s),s}"function"==typeof SuppressedError&&SuppressedError;const S="__bjs_serializable__",v=new WeakMap;function I(e,t){return Object.prototype.hasOwnProperty.call(e,t)}const C=function(){let e=Symbol.metadata;return e||(e=Symbol("Symbol.metadata"),Object.defineProperty(Symbol,"metadata",{configurable:!0,writable:!0,value:e})),e}();function P(e){if(!e)throw new Error(`Decorator metadata is unavailable; the Symbol.metadata (${String(C)}) polyfill must run before decorated classes are evaluated.`);return I(e,S)||(e[S]={}),e[S]}function O(e){const t=function(e){return"function"==typeof e?e:e?.constructor}(e),s=t?t[C]:void 0;if(!s)return{};const i=v.get(s);if(i)return i;const r={},n=[];let a=s;for(;a;)n.push(a),a=Object.getPrototypeOf(a);for(const e of n)if(I(e,S)){const t=e[S];for(const e in t)r[e]=t[e]}return v.set(s,r),r}function D(e,t){return(s,i)=>{if(!i.metadata)return;const r=String(i.name),n=P(i.metadata);n[r]||(n[r]={type:e,sourceName:t})}}function w(e,t=null){return function(e,t=null){return(s,i)=>{const r=t||"_"+String(i.name);return{init(e){return void 0===e&&r in this||(this[r]=e),e},get(){return this[r]},set(t){"function"==typeof this[r]?.equals&&this[r].equals(t)||this[r]!==t&&(this[r]=t,this[e]())}}}}(e,t)}function L(e){return D(0,e)}function F(e){return D(1,e)}function N(e){return D(2,e)}function B(e){return D(3,e)}function U(e){return D(4,e)}function k(e){return D(5,e)}function G(e){return D(6,e)}function V(e){return D(8,e)}function H(e){return D(12,e)}function z(e,t,s){const i=String(t.name);let r=null;const n=function(...a){if(null===r){r=e,"undefined"!=typeof _native&&_native[i]&&(r=s(_native[i],e));const a=this&&(t.static?this:Object.getPrototypeOf(this));a?.[i]===n&&(a[i]=r)}return r.apply(this,a)};return n}function W(e,t){return z(e,t,e=>e)}function X(e,t=null){return(s,i)=>{const r=t||"_"+String(i.name);return{get(){return this[r]?.value},set(t){"function"==typeof this[r]?.value?.equals&&this[r].value.equals(t)||this[r].value!==t&&(this[r].value=t,this[e]())}}}}W.filter=function(e){return(t,s)=>z(t,s,(t,s)=>function(...i){return e(...i)?t(...i):s.apply(this,i)})};const K=1/2.2,Y=2.2;let j=.001;function q(e,t){const s=[];for(let i=0;i<e;++i)s.push(t());return s}function $(e,t){return q(e,t)}const Z=["push","splice","pop","shift","unshift"];function Q(e,t){const s=Z.map(s=>function(e,t,s){const i=e[t];if("function"!=typeof i)return null;const r=function(){const i=e.length,n=r.previous.apply(e,arguments);return s(t,i),n};return i.next=r,r.previous=i,e[t]=r,()=>{const s=r.previous;if(!s)return;const i=r.next;i?(s.next=i,i.previous=s):(s.next=void 0,e[t]=s),r.next=void 0,r.previous=void 0}}(e,s,t));return()=>{for(const e of s)e?.()}}class J{static SetMatrixPrecision(e){if(J.MatrixTrackPrecisionChange=!1,e&&!J.MatrixUse64Bits&&J.MatrixTrackedMatrices)for(let e=0;e<J.MatrixTrackedMatrices.length;++e){const t=J.MatrixTrackedMatrices[e],s=t._m;t._m=new Array(16);for(let e=0;e<16;++e)t._m[e]=s[e]}J.MatrixUse64Bits=e,J.MatrixCurrentType=J.MatrixUse64Bits?Array:Float32Array,J.MatrixTrackedMatrices=null}}J.MatrixUse64Bits=!1,J.MatrixTrackPrecisionChange=!0,J.MatrixCurrentType=Float32Array,J.MatrixTrackedMatrices=[];class ee{static get LastCreatedEngine(){return 0===this.Instances.length?null:this.Instances[this.Instances.length-1]}static get LastCreatedScene(){return this._LastCreatedScene}}function te(e,t,s=1401298e-51){return Math.abs(e-t)<=s}function se(e,t){return e===t?e:Math.random()*(t-e)+e}function ie(e,t,s){return e+(t-e)*s}function re(e,t,s,i,r){const n=r*r,a=r*n;return e*(2*a-3*n+1)+s*(-2*a+3*n)+t*(a-2*n+r)+i*(a-n)}function ne(e,t=0,s=1){return Math.min(s,Math.max(t,e))}function ae(e){return e-=2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI))}function oe(e){const t=e.toString(16);return e<=15?("0"+t).toUpperCase():t.toUpperCase()}function he(e){if(Math.log2)return Math.floor(Math.log2(e));if(e<0)return NaN;if(0===e)return-1/0;let t=0;if(e<1){for(;e<1;)t++,e*=2;t=-t}else if(e>1)for(;e>1;)t++,e=Math.floor(e/2);return t}function le(e,t){return e-Math.floor(e/t)*t}function ce(e,t){let s=le(t-e,360);return s>180&&(s-=360),s}function ue(e,t,s){let i;return i=Math.abs(t-e)<=s?t:e+Math.sign(t-e)*s,i}function de(e,t){const s=e%t;return 0===s?t:de(t,s)}ee.Instances=[],ee.OnEnginesDisposedObservable=new c,ee._LastCreatedScene=null,ee.UseFallbackTexture=!0,ee.FallbackTexture="";var _e=Object.freeze({__proto__:null,Clamp:ne,DeltaAngle:ce,Denormalize:function(e,t,s){return e*(s-t)+t},ExtractAsInt:function(e){return parseInt(e.toString().replace(/\W/g,""))},Hermite:re,Hermite1stDerivative:function(e,t,s,i,r){const n=r*r;return 6*(n-r)*e+(3*n-4*r+1)*t+6*(-n+r)*s+(3*n-2*r)*i},HighestCommonFactor:de,ILog2:he,InverseLerp:function(e,t,s){let i;return i=e!=t?ne((s-e)/(t-e)):0,i},Lerp:ie,LerpAngle:function(e,t,s){let i=le(t-e,360);return i>180&&(i-=360),e+i*ne(s)},MoveTowards:ue,MoveTowardsAngle:function(e,t,s){const i=ce(e,t);let r;return r=-s<i&&i<s?t:ue(e,t=e+i,s),r},Normalize:function(e,t,s){return(e-t)/(s-t)},NormalizeRadians:ae,OutsideRange:function(e,t,s,i=1401298e-51){return e<t-i||e>s+i},PercentToRange:function(e,t,s){return(s-t)*e+t},PingPong:function(e,t){const s=le(e,2*t);return t-Math.abs(s-t)},RandomRange:se,RangeToPercent:function(e,t,s){return(e-t)/(s-t)},Repeat:le,SmoothStep:function(e,t,s){let i=ne(s);return i=-2*i*i*i+3*i*i,t*i+e*(1-i)},ToHex:oe,WithinEpsilon:te});class pe{}function fe(e){e.updateFlag=pe._UpdateFlagSeed++}function ge(e,t,s,i=0){const r=e.asArray(),n=t.asArray(),a=r[0],o=r[1],h=r[2],l=r[3],c=r[4],u=r[5],d=r[6],_=r[7],p=r[8],f=r[9],g=r[10],m=r[11],T=r[12],E=r[13],R=r[14],b=r[15],A=n[0],y=n[1],M=n[2],x=n[3],S=n[4],v=n[5],I=n[6],C=n[7],P=n[8],O=n[9],D=n[10],w=n[11],L=n[12],F=n[13],N=n[14],B=n[15];s[i]=a*A+o*S+h*P+l*L,s[i+1]=a*y+o*v+h*O+l*F,s[i+2]=a*M+o*I+h*D+l*N,s[i+3]=a*x+o*C+h*w+l*B,s[i+4]=c*A+u*S+d*P+_*L,s[i+5]=c*y+u*v+d*O+_*F,s[i+6]=c*M+u*I+d*D+_*N,s[i+7]=c*x+u*C+d*w+_*B,s[i+8]=p*A+f*S+g*P+m*L,s[i+9]=p*y+f*v+g*O+m*F,s[i+10]=p*M+f*I+g*D+m*N,s[i+11]=p*x+f*C+g*w+m*B,s[i+12]=T*A+E*S+R*P+b*L,s[i+13]=T*y+E*v+R*O+b*F,s[i+14]=T*M+E*I+R*D+b*N,s[i+15]=T*x+E*C+R*w+b*B}function me(e,t,s,i=0){ge(e,t,s.asArray(),i),fe(s)}function Te(e,t){const s=Ee(e,t.asArray());return s&&fe(t),s}function Ee(e,t){const s=e.asArray(),i=s[0],r=s[1],n=s[2],a=s[3],o=s[4],h=s[5],l=s[6],c=s[7],u=s[8],d=s[9],_=s[10],p=s[11],f=s[12],g=s[13],m=s[14],T=s[15],E=_*T-m*p,R=d*T-g*p,b=d*m-g*_,A=u*T-f*p,y=u*m-_*f,M=u*g-f*d,x=+(h*E-l*R+c*b),S=-(o*E-l*A+c*y),v=+(o*R-h*A+c*M),I=-(o*b-h*y+l*M),C=i*x+r*S+n*v+a*I;if(0===C)return!1;const P=1/C,O=l*T-m*c,D=h*T-g*c,w=h*m-g*l,L=o*T-f*c,F=o*m-f*l,N=o*g-f*h,B=l*p-_*c,U=h*p-d*c,k=h*_-d*l,G=o*p-u*c,V=o*_-u*l,H=o*d-u*h,z=-(r*E-n*R+a*b),W=+(i*E-n*A+a*y),X=-(i*R-r*A+a*M),K=+(i*b-r*y+n*M),Y=+(r*O-n*D+a*w),j=-(i*O-n*L+a*F),q=+(i*D-r*L+a*N),$=-(i*w-r*F+n*N),Z=-(r*B-n*U+a*k),Q=+(i*B-n*G+a*V),J=-(i*U-r*G+a*H),ee=+(i*k-r*V+n*H);return t[0]=x*P,t[1]=z*P,t[2]=Y*P,t[3]=Z*P,t[4]=S*P,t[5]=W*P,t[6]=j*P,t[7]=Q*P,t[8]=v*P,t[9]=X*P,t[10]=q*P,t[11]=J*P,t[12]=I*P,t[13]=K*P,t[14]=$*P,t[15]=ee*P,!0}pe._UpdateFlagSeed=0;const Re={};function be(e,t){Re[e]=t}function Ae(e){return Re[e]}const ye=e=>parseInt(e.toString().replace(/\W/g,""));class Me{constructor(e=0,t=0){this.x=e,this.y=t}toString(){return`{X: ${this.x} Y: ${this.y}}`}getClassName(){return"Vector2"}getHashCode(){let e=ye(this.x);return e=397*e^ye(this.y),e}toArray(e,t=0){return e[t]=this.x,e[t+1]=this.y,this}fromArray(e,t=0){return Me.FromArrayToRef(e,t,this),this}asArray(){return[this.x,this.y]}copyFrom(e){return this.x=e.x,this.y=e.y,this}copyFromFloats(e,t){return this.x=e,this.y=t,this}set(e,t){return this.copyFromFloats(e,t)}setAll(e){return this.copyFromFloats(e,e)}add(e){return new Me(this.x+e.x,this.y+e.y)}addToRef(e,t){return t.x=this.x+e.x,t.y=this.y+e.y,t}addInPlace(e){return this.x+=e.x,this.y+=e.y,this}addInPlaceFromFloats(e,t){return this.x+=e,this.y+=t,this}addVector3(e){return new Me(this.x+e.x,this.y+e.y)}subtract(e){return new Me(this.x-e.x,this.y-e.y)}subtractToRef(e,t){return t.x=this.x-e.x,t.y=this.y-e.y,t}subtractInPlace(e){return this.x-=e.x,this.y-=e.y,this}multiplyInPlace(e){return this.x*=e.x,this.y*=e.y,this}multiply(e){return new Me(this.x*e.x,this.y*e.y)}multiplyToRef(e,t){return t.x=this.x*e.x,t.y=this.y*e.y,t}multiplyByFloats(e,t){return new Me(this.x*e,this.y*t)}divide(e){return new Me(this.x/e.x,this.y/e.y)}divideToRef(e,t){return t.x=this.x/e.x,t.y=this.y/e.y,t}divideInPlace(e){return this.x=this.x/e.x,this.y=this.y/e.y,this}minimizeInPlace(e){return this.minimizeInPlaceFromFloats(e.x,e.y)}maximizeInPlace(e){return this.maximizeInPlaceFromFloats(e.x,e.y)}minimizeInPlaceFromFloats(e,t){return this.x=Math.min(e,this.x),this.y=Math.min(t,this.y),this}maximizeInPlaceFromFloats(e,t){return this.x=Math.max(e,this.x),this.y=Math.max(t,this.y),this}subtractFromFloats(e,t){return new Me(this.x-e,this.y-t)}subtractFromFloatsToRef(e,t,s){return s.x=this.x-e,s.y=this.y-t,s}negate(){return new Me(-this.x,-this.y)}negateInPlace(){return this.x*=-1,this.y*=-1,this}negateToRef(e){return e.x=-this.x,e.y=-this.y,e}scaleInPlace(e){return this.x*=e,this.y*=e,this}scale(e){return new Me(this.x*e,this.y*e)}scaleToRef(e,t){return t.x=this.x*e,t.y=this.y*e,t}scaleAndAddToRef(e,t){return t.x+=this.x*e,t.y+=this.y*e,t}equals(e){return e&&this.x===e.x&&this.y===e.y}equalsWithEpsilon(e,t=.001){return e&&te(this.x,e.x,t)&&te(this.y,e.y,t)}equalsToFloats(e,t){return this.x===e&&this.y===t}floor(){return new Me(Math.floor(this.x),Math.floor(this.y))}floorToRef(e){return e.x=Math.floor(this.x),e.y=Math.floor(this.y),e}fract(){return new Me(this.x-Math.floor(this.x),this.y-Math.floor(this.y))}fractToRef(e){return e.x=this.x-Math.floor(this.x),e.y=this.y-Math.floor(this.y),e}rotate(e){return this.rotateToRef(e,new Me)}rotateToRef(e,t){const s=Math.cos(e),i=Math.sin(e);return t.x=s*this.x-i*this.y,t.y=i*this.x+s*this.y,t}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}lengthSquared(){return this.x*this.x+this.y*this.y}normalize(){return this.normalizeFromLength(this.length())}normalizeFromLength(e){return 0===e||1===e?this:this.scaleInPlace(1/e)}normalizeToNew(){const e=new Me;return this.normalizeToRef(e),e}normalizeToRef(e){const t=this.length();return 0===t&&(e.x=this.x,e.y=this.y),this.scaleToRef(1/t,e)}clone(){return new Me(this.x,this.y)}dot(e){return this.x*e.x+this.y*e.y}static Zero(){return new Me(0,0)}static One(){return new Me(1,1)}static Random(e=0,t=1){return new Me(se(e,t),se(e,t))}static RandomToRef(e=0,t=1,s){return s.copyFromFloats(se(e,t),se(e,t))}static get ZeroReadOnly(){return Me._ZeroReadOnly}static FromArray(e,t=0){return new Me(e[t],e[t+1])}static FromArrayToRef(e,t,s){return s.x=e[t],s.y=e[t+1],s}static FromFloatsToRef(e,t,s){return s.copyFromFloats(e,t),s}static CatmullRom(e,t,s,i,r){const n=r*r,a=r*n,o=.5*(2*t.x+(-e.x+s.x)*r+(2*e.x-5*t.x+4*s.x-i.x)*n+(-e.x+3*t.x-3*s.x+i.x)*a),h=.5*(2*t.y+(-e.y+s.y)*r+(2*e.y-5*t.y+4*s.y-i.y)*n+(-e.y+3*t.y-3*s.y+i.y)*a);return new Me(o,h)}static ClampToRef(e,t,s,i){return i.x=ne(e.x,t.x,s.x),i.y=ne(e.y,t.y,s.y),i}static Clamp(e,t,s){const i=ne(e.x,t.x,s.x),r=ne(e.y,t.y,s.y);return new Me(i,r)}static Hermite(e,t,s,i,r){const n=r*r,a=r*n,o=2*a-3*n+1,h=-2*a+3*n,l=a-2*n+r,c=a-n,u=e.x*o+s.x*h+t.x*l+i.x*c,d=e.y*o+s.y*h+t.y*l+i.y*c;return new Me(u,d)}static Hermite1stDerivative(e,t,s,i,r){return this.Hermite1stDerivativeToRef(e,t,s,i,r,new Me)}static Hermite1stDerivativeToRef(e,t,s,i,r,n){const a=r*r;return n.x=6*(a-r)*e.x+(3*a-4*r+1)*t.x+6*(-a+r)*s.x+(3*a-2*r)*i.x,n.y=6*(a-r)*e.y+(3*a-4*r+1)*t.y+6*(-a+r)*s.y+(3*a-2*r)*i.y,n}static Lerp(e,t,s){return Me.LerpToRef(e,t,s,new Me)}static LerpToRef(e,t,s,i){return i.x=e.x+(t.x-e.x)*s,i.y=e.y+(t.y-e.y)*s,i}static Dot(e,t){return e.x*t.x+e.y*t.y}static Normalize(e){return Me.NormalizeToRef(e,new Me)}static NormalizeToRef(e,t){return e.normalizeToRef(t),t}static Minimize(e,t){const s=e.x<t.x?e.x:t.x,i=e.y<t.y?e.y:t.y;return new Me(s,i)}static Maximize(e,t){const s=e.x>t.x?e.x:t.x,i=e.y>t.y?e.y:t.y;return new Me(s,i)}static Transform(e,t){return Me.TransformToRef(e,t,new Me)}static TransformToRef(e,t,s){const i=t.m,r=e.x*i[0]+e.y*i[4]+i[12],n=e.x*i[1]+e.y*i[5]+i[13];return s.x=r,s.y=n,s}static PointInTriangle(e,t,s,i){const r=.5*(-s.y*i.x+t.y*(-s.x+i.x)+t.x*(s.y-i.y)+s.x*i.y),n=r<0?-1:1,a=(t.y*i.x-t.x*i.y+(i.y-t.y)*e.x+(t.x-i.x)*e.y)*n,o=(t.x*s.y-t.y*s.x+(t.y-s.y)*e.x+(s.x-t.x)*e.y)*n;return a>0&&o>0&&a+o<2*r*n}static Distance(e,t){return Math.sqrt(Me.DistanceSquared(e,t))}static DistanceSquared(e,t){const s=e.x-t.x,i=e.y-t.y;return s*s+i*i}static Center(e,t){return Me.CenterToRef(e,t,new Me)}static CenterToRef(e,t,s){return s.copyFromFloats((e.x+t.x)/2,(e.y+t.y)/2)}static DistanceOfPointFromSegment(e,t,s){const i=Me.DistanceSquared(t,s);if(0===i)return Me.Distance(e,t);const r=s.subtract(t),n=Math.max(0,Math.min(1,Me.Dot(e.subtract(t),r)/i)),a=t.add(r.multiplyByFloats(n,n));return Me.Distance(e,a)}}Me._V8PerformanceHack=new Me(.5,.5),Me._ZeroReadOnly=Me.Zero();class xe{get x(){return this._x}set x(e){this._x=e,this._isDirty=!0}get y(){return this._y}set y(e){this._y=e,this._isDirty=!0}get z(){return this._z}set z(e){this._z=e,this._isDirty=!0}constructor(e=0,t=0,s=0){this._isDirty=!0,this._x=e,this._y=t,this._z=s}toString(){return`{X: ${this._x} Y: ${this._y} Z: ${this._z}}`}getClassName(){return"Vector3"}getHashCode(){let e=ye(this._x);return e=397*e^ye(this._y),e=397*e^ye(this._z),e}asArray(){return[this._x,this._y,this._z]}toArray(e,t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,this}fromArray(e,t=0){return xe.FromArrayToRef(e,t,this),this}toQuaternion(){return ve.RotationYawPitchRoll(this._y,this._x,this._z)}addInPlace(e){return this._x+=e._x,this._y+=e._y,this._z+=e._z,this._isDirty=!0,this}addInPlaceFromFloats(e,t,s){return this._x+=e,this._y+=t,this._z+=s,this._isDirty=!0,this}add(e){return new xe(this._x+e._x,this._y+e._y,this._z+e._z)}addToRef(e,t){return t._x=this._x+e._x,t._y=this._y+e._y,t._z=this._z+e._z,t._isDirty=!0,t}subtractInPlace(e){return this._x-=e._x,this._y-=e._y,this._z-=e._z,this._isDirty=!0,this}subtract(e){return new xe(this._x-e._x,this._y-e._y,this._z-e._z)}subtractToRef(e,t){return this.subtractFromFloatsToRef(e._x,e._y,e._z,t)}subtractFromFloats(e,t,s){return new xe(this._x-e,this._y-t,this._z-s)}subtractFromFloatsToRef(e,t,s,i){return i._x=this._x-e,i._y=this._y-t,i._z=this._z-s,i._isDirty=!0,i}negate(){return new xe(-this._x,-this._y,-this._z)}negateInPlace(){return this._x*=-1,this._y*=-1,this._z*=-1,this._isDirty=!0,this}negateToRef(e){return e._x=-1*this._x,e._y=-1*this._y,e._z=-1*this._z,e._isDirty=!0,e}scaleInPlace(e){return this._x*=e,this._y*=e,this._z*=e,this._isDirty=!0,this}scale(e){return new xe(this._x*e,this._y*e,this._z*e)}scaleToRef(e,t){return t._x=this._x*e,t._y=this._y*e,t._z=this._z*e,t._isDirty=!0,t}getNormalToRef(e){const t=this.length();let s=Math.acos(this._y/t);const i=Math.atan2(this._z,this._x);s>Math.PI/2?s-=Math.PI/2:s+=Math.PI/2;const r=t*Math.sin(s)*Math.cos(i),n=t*Math.cos(s),a=t*Math.sin(s)*Math.sin(i);return e.set(r,n,a),e}applyRotationQuaternionToRef(e,t){const s=this._x,i=this._y,r=this._z,n=e._x,a=e._y,o=e._z,h=e._w,l=2*(a*r-o*i),c=2*(o*s-n*r),u=2*(n*i-a*s);return t._x=s+h*l+a*u-o*c,t._y=i+h*c+o*l-n*u,t._z=r+h*u+n*c-a*l,t._isDirty=!0,t}applyRotationQuaternionInPlace(e){return this.applyRotationQuaternionToRef(e,this)}applyRotationQuaternion(e){return this.applyRotationQuaternionToRef(e,new xe)}scaleAndAddToRef(e,t){return t._x+=this._x*e,t._y+=this._y*e,t._z+=this._z*e,t._isDirty=!0,t}projectOnPlane(e,t){return this.projectOnPlaneToRef(e,t,new xe)}projectOnPlaneToRef(e,t,s){const i=e.normal,r=e.d,n=Ce.Vector3[0];this.subtractToRef(t,n),n.normalize();const a=xe.Dot(n,i);if(Math.abs(a)<1e-10)s.setAll(1/0);else{const e=-(xe.Dot(t,i)+r)/a,o=n.scaleInPlace(e);t.addToRef(o,s)}return s}equals(e){return e&&this._x===e._x&&this._y===e._y&&this._z===e._z}equalsWithEpsilon(e,t=.001){return e&&te(this._x,e._x,t)&&te(this._y,e._y,t)&&te(this._z,e._z,t)}equalsToFloats(e,t,s){return this._x===e&&this._y===t&&this._z===s}multiplyInPlace(e){return this._x*=e._x,this._y*=e._y,this._z*=e._z,this._isDirty=!0,this}multiply(e){return this.multiplyByFloats(e._x,e._y,e._z)}multiplyToRef(e,t){return t._x=this._x*e._x,t._y=this._y*e._y,t._z=this._z*e._z,t._isDirty=!0,t}multiplyByFloats(e,t,s){return new xe(this._x*e,this._y*t,this._z*s)}divide(e){return new xe(this._x/e._x,this._y/e._y,this._z/e._z)}divideToRef(e,t){return t._x=this._x/e._x,t._y=this._y/e._y,t._z=this._z/e._z,t._isDirty=!0,t}divideInPlace(e){return this._x=this._x/e._x,this._y=this._y/e._y,this._z=this._z/e._z,this._isDirty=!0,this}minimizeInPlace(e){return this.minimizeInPlaceFromFloats(e._x,e._y,e._z)}maximizeInPlace(e){return this.maximizeInPlaceFromFloats(e._x,e._y,e._z)}minimizeInPlaceFromFloats(e,t,s){return e<this._x&&(this.x=e),t<this._y&&(this.y=t),s<this._z&&(this.z=s),this}maximizeInPlaceFromFloats(e,t,s){return e>this._x&&(this.x=e),t>this._y&&(this.y=t),s>this._z&&(this.z=s),this}isNonUniformWithinEpsilon(e){const t=Math.abs(this._x),s=Math.abs(this._y);if(!te(t,s,e))return!0;const i=Math.abs(this._z);return!te(t,i,e)||!te(s,i,e)}get isNonUniform(){const e=Math.abs(this._x);if(e!==Math.abs(this._y))return!0;return e!==Math.abs(this._z)}floorToRef(e){return e._x=Math.floor(this._x),e._y=Math.floor(this._y),e._z=Math.floor(this._z),e._isDirty=!0,e}floor(){return new xe(Math.floor(this._x),Math.floor(this._y),Math.floor(this._z))}fractToRef(e){return e._x=this._x-Math.floor(this._x),e._y=this._y-Math.floor(this._y),e._z=this._z-Math.floor(this._z),e._isDirty=!0,e}fract(){return new xe(this._x-Math.floor(this._x),this._y-Math.floor(this._y),this._z-Math.floor(this._z))}length(){return Math.sqrt(this.lengthSquared())}lengthSquared(){return this._x*this._x+this._y*this._y+this._z*this._z}get hasAZeroComponent(){return this._x*this._y*this._z===0}normalize(){return this.normalizeFromLength(this.length())}reorderInPlace(e){if("xyz"===(e=e.toLowerCase()))return this;const t=Ce.Vector3[0].copyFrom(this);return this.x=t[e[0]],this.y=t[e[1]],this.z=t[e[2]],this}rotateByQuaternionToRef(e,t){return e.toRotationMatrix(Ce.Matrix[0]),xe.TransformCoordinatesToRef(this,Ce.Matrix[0],t),t}rotateByQuaternionAroundPointToRef(e,t,s){return this.subtractToRef(t,Ce.Vector3[0]),Ce.Vector3[0].rotateByQuaternionToRef(e,Ce.Vector3[0]),t.addToRef(Ce.Vector3[0],s),s}cross(e){return xe.CrossToRef(this,e,new xe)}normalizeFromLength(e){return 0===e||1===e?this:this.scaleInPlace(1/e)}normalizeToNew(){return this.normalizeToRef(new xe)}normalizeToRef(e){const t=this.length();return 0===t||1===t?(e._x=this._x,e._y=this._y,e._z=this._z,e._isDirty=!0,e):this.scaleToRef(1/t,e)}clone(){return new xe(this._x,this._y,this._z)}copyFrom(e){return this.copyFromFloats(e._x,e._y,e._z)}copyFromFloats(e,t,s){return this._x=e,this._y=t,this._z=s,this._isDirty=!0,this}set(e,t,s){return this.copyFromFloats(e,t,s)}setAll(e){return this._x=this._y=this._z=e,this._isDirty=!0,this}static GetClipFactor(e,t,s,i){const r=xe.Dot(e,s);return(r-i)/(r-xe.Dot(t,s))}static GetAngleBetweenVectors(e,t,s){const i=e.normalizeToRef(Ce.Vector3[1]),r=t.normalizeToRef(Ce.Vector3[2]);let n=xe.Dot(i,r);n=ne(n,-1,1);const a=Math.acos(n),o=Ce.Vector3[3];return xe.CrossToRef(i,r,o),xe.Dot(o,s)>0?isNaN(a)?0:a:isNaN(a)?-Math.PI:-Math.acos(n)}static GetAngleBetweenVectorsOnPlane(e,t,s){Ce.Vector3[0].copyFrom(e);const i=Ce.Vector3[0];Ce.Vector3[1].copyFrom(t);const r=Ce.Vector3[1];Ce.Vector3[2].copyFrom(s);const n=Ce.Vector3[2],a=Ce.Vector3[3],o=Ce.Vector3[4];i.normalize(),r.normalize(),n.normalize(),xe.CrossToRef(n,i,a),xe.CrossToRef(a,n,o);return ae(Math.atan2(xe.Dot(r,a),xe.Dot(r,o)))}static PitchYawRollToMoveBetweenPointsToRef(e,t,s){const i=Pe.Vector3[0];return t.subtractToRef(e,i),s._y=Math.atan2(i.x,i.z)||0,s._x=Math.atan2(Math.sqrt(i.x**2+i.z**2),i.y)||0,s._z=0,s._isDirty=!0,s}static PitchYawRollToMoveBetweenPoints(e,t){const s=xe.Zero();return xe.PitchYawRollToMoveBetweenPointsToRef(e,t,s)}static SlerpToRef(e,t,s,i){s=ne(s,0,1);const r=Ce.Vector3[0],n=Ce.Vector3[1];r.copyFrom(e);const a=r.length();r.normalizeFromLength(a),n.copyFrom(t);const o=n.length();n.normalizeFromLength(o);const h=xe.Dot(r,n);let l,c;if(h<.999){const e=Math.acos(h),t=1/Math.sin(e);l=Math.sin((1-s)*e)*t,c=Math.sin(s*e)*t}else l=1-s,c=s;return r.scaleInPlace(l),n.scaleInPlace(c),i.copyFrom(r).addInPlace(n),i.scaleInPlace(ie(a,o,s)),i}static SmoothToRef(e,t,s,i,r){return xe.SlerpToRef(e,t,0===i?1:s/i,r),r}static FromArray(e,t=0){return new xe(e[t],e[t+1],e[t+2])}static FromFloatArray(e,t){return xe.FromArray(e,t)}static FromArrayToRef(e,t,s){return s._x=e[t],s._y=e[t+1],s._z=e[t+2],s._isDirty=!0,s}static FromFloatArrayToRef(e,t,s){return xe.FromArrayToRef(e,t,s)}static FromFloatsToRef(e,t,s,i){return i.copyFromFloats(e,t,s),i}static Zero(){return new xe(0,0,0)}static One(){return new xe(1,1,1)}static Up(){return new xe(0,1,0)}static get UpReadOnly(){return xe._UpReadOnly}static get DownReadOnly(){return xe._DownReadOnly}static get RightReadOnly(){return xe._RightReadOnly}static get LeftReadOnly(){return xe._LeftReadOnly}static get LeftHandedForwardReadOnly(){return xe._LeftHandedForwardReadOnly}static get RightHandedForwardReadOnly(){return xe._RightHandedForwardReadOnly}static get LeftHandedBackwardReadOnly(){return xe._LeftHandedBackwardReadOnly}static get RightHandedBackwardReadOnly(){return xe._RightHandedBackwardReadOnly}static get ZeroReadOnly(){return xe._ZeroReadOnly}static get OneReadOnly(){return xe._OneReadOnly}static Down(){return new xe(0,-1,0)}static Forward(e=!1){return new xe(0,0,e?-1:1)}static Backward(e=!1){return new xe(0,0,e?1:-1)}static Right(){return new xe(1,0,0)}static Left(){return new xe(-1,0,0)}static Random(e=0,t=1){return new xe(se(e,t),se(e,t),se(e,t))}static RandomToRef(e=0,t=1,s){return s.copyFromFloats(se(e,t),se(e,t),se(e,t))}static TransformCoordinates(e,t){const s=xe.Zero();return xe.TransformCoordinatesToRef(e,t,s),s}static TransformCoordinatesToRef(e,t,s){return xe.TransformCoordinatesFromFloatsToRef(e._x,e._y,e._z,t,s),s}static TransformCoordinatesFromFloatsToRef(e,t,s,i,r){const n=i.m,a=e*n[0]+t*n[4]+s*n[8]+n[12],o=e*n[1]+t*n[5]+s*n[9]+n[13],h=e*n[2]+t*n[6]+s*n[10]+n[14],l=1/(e*n[3]+t*n[7]+s*n[11]+n[15]);return r._x=a*l,r._y=o*l,r._z=h*l,r._isDirty=!0,r}static TransformNormal(e,t){const s=xe.Zero();return xe.TransformNormalToRef(e,t,s),s}static TransformNormalToRef(e,t,s){return this.TransformNormalFromFloatsToRef(e._x,e._y,e._z,t,s),s}static TransformNormalFromFloatsToRef(e,t,s,i,r){const n=i.m;return r._x=e*n[0]+t*n[4]+s*n[8],r._y=e*n[1]+t*n[5]+s*n[9],r._z=e*n[2]+t*n[6]+s*n[10],r._isDirty=!0,r}static CatmullRom(e,t,s,i,r){const n=r*r,a=r*n,o=.5*(2*t._x+(-e._x+s._x)*r+(2*e._x-5*t._x+4*s._x-i._x)*n+(-e._x+3*t._x-3*s._x+i._x)*a),h=.5*(2*t._y+(-e._y+s._y)*r+(2*e._y-5*t._y+4*s._y-i._y)*n+(-e._y+3*t._y-3*s._y+i._y)*a),l=.5*(2*t._z+(-e._z+s._z)*r+(2*e._z-5*t._z+4*s._z-i._z)*n+(-e._z+3*t._z-3*s._z+i._z)*a);return new xe(o,h,l)}static Clamp(e,t,s){const i=new xe;return xe.ClampToRef(e,t,s,i),i}static ClampToRef(e,t,s,i){let r=e._x;r=r>s._x?s._x:r,r=r<t._x?t._x:r;let n=e._y;n=n>s._y?s._y:n,n=n<t._y?t._y:n;let a=e._z;return a=a>s._z?s._z:a,a=a<t._z?t._z:a,i.copyFromFloats(r,n,a),i}static CheckExtends(e,t,s){t.minimizeInPlace(e),s.maximizeInPlace(e)}static Hermite(e,t,s,i,r){const n=r*r,a=r*n,o=2*a-3*n+1,h=-2*a+3*n,l=a-2*n+r,c=a-n,u=e._x*o+s._x*h+t._x*l+i._x*c,d=e._y*o+s._y*h+t._y*l+i._y*c,_=e._z*o+s._z*h+t._z*l+i._z*c;return new xe(u,d,_)}static Hermite1stDerivative(e,t,s,i,r){const n=new xe;return this.Hermite1stDerivativeToRef(e,t,s,i,r,n),n}static Hermite1stDerivativeToRef(e,t,s,i,r,n){const a=r*r;return n._x=6*(a-r)*e._x+(3*a-4*r+1)*t._x+6*(-a+r)*s._x+(3*a-2*r)*i._x,n._y=6*(a-r)*e._y+(3*a-4*r+1)*t._y+6*(-a+r)*s._y+(3*a-2*r)*i._y,n._z=6*(a-r)*e._z+(3*a-4*r+1)*t._z+6*(-a+r)*s._z+(3*a-2*r)*i._z,n._isDirty=!0,n}static Lerp(e,t,s){const i=new xe(0,0,0);return xe.LerpToRef(e,t,s,i),i}static LerpToRef(e,t,s,i){return i._x=e._x+(t._x-e._x)*s,i._y=e._y+(t._y-e._y)*s,i._z=e._z+(t._z-e._z)*s,i._isDirty=!0,i}static Dot(e,t){return e._x*t._x+e._y*t._y+e._z*t._z}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z}static Cross(e,t){const s=new xe;return xe.CrossToRef(e,t,s),s}static CrossToRef(e,t,s){const i=e._y*t._z-e._z*t._y,r=e._z*t._x-e._x*t._z,n=e._x*t._y-e._y*t._x;return s.copyFromFloats(i,r,n),s}static Normalize(e){const t=xe.Zero();return xe.NormalizeToRef(e,t),t}static NormalizeToRef(e,t){return e.normalizeToRef(t),t}static Project(e,t,s,i){const r=new xe;return xe.ProjectToRef(e,t,s,i,r),r}static ProjectToRef(e,t,s,i,r){const n=i.width,a=i.height,o=i.x,h=i.y,l=Ce.Matrix[1],c=ee.LastCreatedEngine?.isNDCHalfZRange,u=c?1:.5,d=c?0:.5;Ie.FromValuesToRef(n/2,0,0,0,0,-a/2,0,0,0,0,u,0,o+n/2,a/2+h,d,1,l);const _=Ce.Matrix[0];return t.multiplyToRef(s,_),_.multiplyToRef(l,_),xe.TransformCoordinatesToRef(e,_,r),r}static Reflect(e,t){return this.ReflectToRef(e,t,new xe)}static ReflectToRef(e,t,s){const i=Pe.Vector3[0];return i.copyFrom(t).scaleInPlace(2*xe.Dot(e,t)),s.copyFrom(e).subtractInPlace(i)}static UnprojectFromTransform(e,t,s,i,r){return this.Unproject(e,t,s,i,r,Ie.IdentityReadOnly)}static Unproject(e,t,s,i,r,n){const a=new xe;return xe.UnprojectToRef(e,t,s,i,r,n,a),a}static UnprojectToRef(e,t,s,i,r,n,a){return xe.UnprojectFloatsToRef(e._x,e._y,e._z,t,s,i,r,n,a),a}static UnprojectFloatsToRef(e,t,s,i,r,n,a,o,h){const l=Ce.Matrix[0];n.multiplyToRef(a,l),l.multiplyToRef(o,l),l.invert();const c=Ce.Vector3[0];return c.x=e/i*2-1,c.y=-(t/r*2-1),ee.LastCreatedEngine?.isNDCHalfZRange?c.z=s:c.z=2*s-1,xe.TransformCoordinatesToRef(c,l,h),h}static Minimize(e,t){const s=new xe;return s.copyFrom(e),s.minimizeInPlace(t),s}static Maximize(e,t){const s=new xe;return s.copyFrom(e),s.maximizeInPlace(t),s}static Distance(e,t){return Math.sqrt(xe.DistanceSquared(e,t))}static DistanceSquared(e,t){const s=e._x-t._x,i=e._y-t._y,r=e._z-t._z;return s*s+i*i+r*r}static ProjectOnTriangleToRef(e,t,s,i,r){const n=Ce.Vector3[0],a=Ce.Vector3[1],o=Ce.Vector3[2],h=Ce.Vector3[3],l=Ce.Vector3[4];s.subtractToRef(t,n),i.subtractToRef(t,a),i.subtractToRef(s,o);const c=n.length(),u=a.length(),d=o.length();if(c<j||u<j||d<j)return r.copyFrom(t),xe.Distance(e,t);e.subtractToRef(t,l),xe.CrossToRef(n,a,h);const _=h.length();if(_<j)return r.copyFrom(t),xe.Distance(e,t);h.normalizeFromLength(_);let p=l.length();if(p<j)return r.copyFrom(t),0;l.normalizeFromLength(p);const f=xe.Dot(h,l),g=Ce.Vector3[5],m=Ce.Vector3[6];g.copyFrom(h).scaleInPlace(-p*f),m.copyFrom(e).addInPlace(g);const T=Ce.Vector3[4],E=Ce.Vector3[5],R=Ce.Vector3[7],b=Ce.Vector3[8];T.copyFrom(n).scaleInPlace(1/c),b.copyFrom(a).scaleInPlace(1/u),T.addInPlace(b).scaleInPlace(-1),E.copyFrom(n).scaleInPlace(-1/c),b.copyFrom(o).scaleInPlace(1/d),E.addInPlace(b).scaleInPlace(-1),R.copyFrom(o).scaleInPlace(-1/d),b.copyFrom(a).scaleInPlace(-1/u),R.addInPlace(b).scaleInPlace(-1);const A=Ce.Vector3[9];let y;A.copyFrom(m).subtractInPlace(t),xe.CrossToRef(T,A,b),y=xe.Dot(b,h);const M=y;A.copyFrom(m).subtractInPlace(s),xe.CrossToRef(E,A,b),y=xe.Dot(b,h);const x=y;A.copyFrom(m).subtractInPlace(i),xe.CrossToRef(R,A,b),y=xe.Dot(b,h);const S=y,v=Ce.Vector3[10];let I,C;M>0&&x<0?(v.copyFrom(n),I=t,C=s):x>0&&S<0?(v.copyFrom(o),I=s,C=i):(v.copyFrom(a).scaleInPlace(-1),I=i,C=t);const P=Ce.Vector3[9],O=Ce.Vector3[4];I.subtractToRef(m,b),C.subtractToRef(m,P),xe.CrossToRef(b,P,O);if(!(xe.Dot(O,h)<0))return r.copyFrom(m),Math.abs(p*f);const D=Ce.Vector3[5];xe.CrossToRef(v,O,D),D.normalize();const w=Ce.Vector3[9];w.copyFrom(I).subtractInPlace(m);const L=w.length();if(L<j)return r.copyFrom(I),xe.Distance(e,I);w.normalizeFromLength(L);const F=xe.Dot(D,w),N=Ce.Vector3[7];N.copyFrom(m).addInPlace(D.scaleInPlace(L*F)),b.copyFrom(N).subtractInPlace(I),p=v.length(),v.normalizeFromLength(p);let B=xe.Dot(b,v)/Math.max(p,j);return B=ne(B,0,1),N.copyFrom(I).addInPlace(v.scaleInPlace(B*p)),r.copyFrom(N),xe.Distance(e,N)}static Center(e,t){return xe.CenterToRef(e,t,xe.Zero())}static CenterToRef(e,t,s){return s.copyFromFloats((e._x+t._x)/2,(e._y+t._y)/2,(e._z+t._z)/2)}static RotationFromAxis(e,t,s){const i=new xe;return xe.RotationFromAxisToRef(e,t,s,i),i}static RotationFromAxisToRef(e,t,s,i){const r=Ce.Quaternion[0];return ve.RotationQuaternionFromAxisToRef(e,t,s,r),r.toEulerAnglesToRef(i),i}}xe._V8PerformanceHack=new xe(.5,.5,.5),xe._UpReadOnly=xe.Up(),xe._DownReadOnly=xe.Down(),xe._LeftHandedForwardReadOnly=xe.Forward(!1),xe._RightHandedForwardReadOnly=xe.Forward(!0),xe._LeftHandedBackwardReadOnly=xe.Backward(!1),xe._RightHandedBackwardReadOnly=xe.Backward(!0),xe._RightReadOnly=xe.Right(),xe._LeftReadOnly=xe.Left(),xe._ZeroReadOnly=xe.Zero(),xe._OneReadOnly=xe.One();class Se{get x(){return this._x}set x(e){this._x=e,this._isDirty=!0}get y(){return this._y}set y(e){this._y=e,this._isDirty=!0}get z(){return this._z}set z(e){this._z=e,this._isDirty=!0}get w(){return this._w}set w(e){this._w=e,this._isDirty=!0}constructor(e=0,t=0,s=0,i=0){this._isDirty=!0,this._x=e,this._y=t,this._z=s,this._w=i}toString(){return`{X: ${this._x} Y: ${this._y} Z: ${this._z} W: ${this._w}}`}getClassName(){return"Vector4"}getHashCode(){let e=ye(this._x);return e=397*e^ye(this._y),e=397*e^ye(this._z),e=397*e^ye(this._w),e}asArray(){return[this._x,this._y,this._z,this._w]}toArray(e,t){return void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,this}fromArray(e,t=0){return Se.FromArrayToRef(e,t,this),this}addInPlace(e){return this.x+=e._x,this.y+=e._y,this.z+=e._z,this.w+=e._w,this}addInPlaceFromFloats(e,t,s,i){return this.x+=e,this.y+=t,this.z+=s,this.w+=i,this}add(e){return new Se(this._x+e.x,this._y+e.y,this._z+e.z,this._w+e.w)}addToRef(e,t){return t.x=this._x+e.x,t.y=this._y+e.y,t.z=this._z+e.z,t.w=this._w+e.w,t}subtractInPlace(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subtract(e){return new Se(this._x-e.x,this._y-e.y,this._z-e.z,this._w-e.w)}subtractToRef(e,t){return t.x=this._x-e.x,t.y=this._y-e.y,t.z=this._z-e.z,t.w=this._w-e.w,t}subtractFromFloats(e,t,s,i){return new Se(this._x-e,this._y-t,this._z-s,this._w-i)}subtractFromFloatsToRef(e,t,s,i,r){return r.x=this._x-e,r.y=this._y-t,r.z=this._z-s,r.w=this._w-i,r}negate(){return new Se(-this._x,-this._y,-this._z,-this._w)}negateInPlace(){return this.x*=-1,this.y*=-1,this.z*=-1,this.w*=-1,this}negateToRef(e){return e.x=-this._x,e.y=-this._y,e.z=-this._z,e.w=-this._w,e}scaleInPlace(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}scale(e){return new Se(this._x*e,this._y*e,this._z*e,this._w*e)}scaleToRef(e,t){return t.x=this._x*e,t.y=this._y*e,t.z=this._z*e,t.w=this._w*e,t}scaleAndAddToRef(e,t){return t.x+=this._x*e,t.y+=this._y*e,t.z+=this._z*e,t.w+=this._w*e,t}equals(e){return e&&this._x===e.x&&this._y===e.y&&this._z===e.z&&this._w===e.w}equalsWithEpsilon(e,t=.001){return e&&te(this._x,e.x,t)&&te(this._y,e.y,t)&&te(this._z,e.z,t)&&te(this._w,e.w,t)}equalsToFloats(e,t,s,i){return this._x===e&&this._y===t&&this._z===s&&this._w===i}multiplyInPlace(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiply(e){return new Se(this._x*e.x,this._y*e.y,this._z*e.z,this._w*e.w)}multiplyToRef(e,t){return t.x=this._x*e.x,t.y=this._y*e.y,t.z=this._z*e.z,t.w=this._w*e.w,t}multiplyByFloats(e,t,s,i){return new Se(this._x*e,this._y*t,this._z*s,this._w*i)}divide(e){return new Se(this._x/e.x,this._y/e.y,this._z/e.z,this._w/e.w)}divideToRef(e,t){return t.x=this._x/e.x,t.y=this._y/e.y,t.z=this._z/e.z,t.w=this._w/e.w,t}divideInPlace(e){return this.divideToRef(e,this)}minimizeInPlace(e){return e.x<this._x&&(this.x=e.x),e.y<this._y&&(this.y=e.y),e.z<this._z&&(this.z=e.z),e.w<this._w&&(this.w=e.w),this}maximizeInPlace(e){return e.x>this._x&&(this.x=e.x),e.y>this._y&&(this.y=e.y),e.z>this._z&&(this.z=e.z),e.w>this._w&&(this.w=e.w),this}minimizeInPlaceFromFloats(e,t,s,i){return this.x=Math.min(e,this._x),this.y=Math.min(t,this._y),this.z=Math.min(s,this._z),this.w=Math.min(i,this._w),this}maximizeInPlaceFromFloats(e,t,s,i){return this.x=Math.max(e,this._x),this.y=Math.max(t,this._y),this.z=Math.max(s,this._z),this.w=Math.max(i,this._w),this}floorToRef(e){return e.x=Math.floor(this._x),e.y=Math.floor(this._y),e.z=Math.floor(this._z),e.w=Math.floor(this._w),e}floor(){return new Se(Math.floor(this._x),Math.floor(this._y),Math.floor(this._z),Math.floor(this._w))}fractToRef(e){return e.x=this._x-Math.floor(this._x),e.y=this._y-Math.floor(this._y),e.z=this._z-Math.floor(this._z),e.w=this._w-Math.floor(this._w),e}fract(){return new Se(this._x-Math.floor(this._x),this._y-Math.floor(this._y),this._z-Math.floor(this._z),this._w-Math.floor(this._w))}length(){return Math.sqrt(this._x*t