@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.28 MB
JavaScript
function e(e,t,i,s){var r,n=arguments.length,a=n<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,s);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(a=(n<3?r(a):n>3?r(t,i,a):r(t,i))||a);return n>3&&a&&Object.defineProperty(t,i,a),a}"function"==typeof SuppressedError&&SuppressedError;const t={},i={};function s(e){const s=e.getClassName();if(t[s])return t[s];t[s]={};const r=t[s];let n=e,a=s;for(;a;){const e=i[a];for(const t in e)r[t]=e[t];let t,s=!1;do{if(t=Object.getPrototypeOf(n),!t.getClassName){s=!0;break}if(t.getClassName()!==a)break;n=t}while(t);if(s)break;a=t.getClassName(),n=t}return r}function r(e,t){return(s,r)=>{const n=function(e){const t=e.getClassName();return i[t]||(i[t]={}),i[t]}(s);n[r]||(n[r]={type:e,sourceName:t})}}function n(e,t=null){return function(e,t=null){return(i,s)=>{const r=t||"_"+s;Object.defineProperty(i,s,{get:function(){return this[r]},set:function(t){"function"==typeof this[r]?.equals&&this[r].equals(t)||this[r]!==t&&(this[r]=t,i[e].apply(this))},enumerable:!0,configurable:!0})}}(e,t)}function a(e){return r(0,e)}function o(e){return r(1,e)}function h(e){return r(2,e)}function l(e){return r(3,e)}function c(e){return r(4,e)}function u(e){return r(5,e)}function _(e){return r(6,e)}function d(e){return r(8,e)}function f(e){return r(9,e)}function p(e){return r(12,e)}function g(e,t,i,s){const r=i.value;i.value=(...i)=>{let n=r;if("undefined"!=typeof _native&&_native[t]){const e=_native[t];n=s?(...t)=>s(...t)?e(...t):r(...t):e}return e[t]=n,n(...i)}}g.filter=function(e){return(t,i,s)=>g(t,i,s,e)};const m="undefined"!=typeof WeakRef;class T{constructor(e,t=!1,i,s){this.initialize(e,t,i,s)}initialize(e,t=!1,i,s){return this.mask=e,this.skipNextObservers=t,this.target=i,this.currentTarget=s,this}}class E{constructor(e,t,i=null){this.callback=e,this.mask=t,this.scope=i,this._willBeUnregistered=!1,this.unregisterOnNextCall=!1,this._remove=null}remove(e=!1){this._remove&&this._remove(e)}}class A{static FromPromise(e,t){const i=new A;return e.then((e=>{i.notifyObservers(e)})).catch((e=>{if(!t)throw e;t.notifyObservers(e)})),i}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 T(0),e&&(this._onObserverAdded=e)}add(e,t=-1,i=!1,s=null,r=!1){if(!e)return null;const n=new E(e,t,s);n.unregisterOnNextCall=r,i?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=m?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 i=0;i<this._observers.length;i++){const s=this._observers[i];if(!s._willBeUnregistered&&(s.callback===e&&(!t||t===s.scope)))return this._deferUnregister(s),!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 i=this._observers.indexOf(e);return-1!==i&&(t&&this._numObserversMarkedAsDeleted--,this._observers.splice(i,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,i,s,r){if(this.notifyIfTriggered&&(this._hasNotified=!0,this._lastNotifiedValue=e),!this._observers.length)return!0;const n=this._eventState;n.mask=t,n.target=i,n.currentTarget=s,n.skipNextObservers=!1,n.lastReturnValue=e,n.userInfo=r;for(const i of this._observers)if(!i._willBeUnregistered&&(i.mask&t&&(i.unregisterOnNextCall&&this._deferUnregister(i),i.scope?n.lastReturnValue=i.callback.apply(i.scope,[e,n]):n.lastReturnValue=i.callback(e,n)),n.skipNextObservers))return!1;return!0}notifyObserver(e,t,i=-1){if(this.notifyIfTriggered&&(this._hasNotified=!0,this._lastNotifiedValue=t),e._willBeUnregistered)return;const s=this._eventState;s.mask=i,s.skipNextObservers=!1,e.unregisterOnNextCall&&this._deferUnregister(e),e.callback(t,s)}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 A;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}}const R=1/2.2,b=2.2,M=.001;function S(e,t){const i=[];for(let s=0;s<e;++s)i.push(t());return i}function y(e,t){return S(e,t)}const I=["push","splice","pop","shift","unshift"];function x(e,t){const i=I.map((i=>function(e,t,i){const s=e[t];if("function"!=typeof s)return null;const r=function(){const s=e.length,n=r.previous.apply(e,arguments);return i(t,s),n};return s.next=r,r.previous=s,e[t]=r,()=>{const i=r.previous;if(!i)return;const s=r.next;s?(i.next=s,s.previous=i):(i.next=void 0,e[t]=i),r.next=void 0,r.previous=void 0}}(e,i,t)));return()=>{for(const e of i)e?.()}}const C={};function v(e,t){C[e]=t}function P(e){return C[e]}class O{static SetMatrixPrecision(e){if(O.MatrixTrackPrecisionChange=!1,e&&!O.MatrixUse64Bits&&O.MatrixTrackedMatrices)for(let e=0;e<O.MatrixTrackedMatrices.length;++e){const t=O.MatrixTrackedMatrices[e],i=t._m;t._m=new Array(16);for(let e=0;e<16;++e)t._m[e]=i[e]}O.MatrixUse64Bits=e,O.MatrixCurrentType=O.MatrixUse64Bits?Array:Float32Array,O.MatrixTrackedMatrices=null}}O.MatrixUse64Bits=!1,O.MatrixTrackPrecisionChange=!0,O.MatrixCurrentType=Float32Array,O.MatrixTrackedMatrices=[];class D{static get LastCreatedEngine(){return 0===this.Instances.length?null:this.Instances[this.Instances.length-1]}static get LastCreatedScene(){return this._LastCreatedScene}}function L(e,t,i=1401298e-51){return Math.abs(e-t)<=i}function F(e,t){return e===t?e:Math.random()*(t-e)+e}function N(e,t,i){return e+(t-e)*i}function w(e,t,i,s,r){const n=r*r,a=r*n;return e*(2*a-3*n+1)+i*(-2*a+3*n)+t*(a-2*n+r)+s*(a-n)}function U(e,t=0,i=1){return Math.min(i,Math.max(t,e))}function B(e){return e-=2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI))}function k(e){const t=e.toString(16);return e<=15?("0"+t).toUpperCase():t.toUpperCase()}function G(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 V(e,t){return e-Math.floor(e/t)*t}function H(e,t){let i=V(t-e,360);return i>180&&(i-=360),i}function z(e,t,i){let s=0;return s=Math.abs(t-e)<=i?t:e+Math.sign(t-e)*i,s}function X(e,t){const i=e%t;return 0===i?t:X(t,i)}D.Instances=[],D.OnEnginesDisposedObservable=new A,D._LastCreatedScene=null,D.UseFallbackTexture=!0,D.FallbackTexture="";var W=Object.freeze({__proto__:null,Clamp:U,DeltaAngle:H,Denormalize:function(e,t,i){return e*(i-t)+t},ExtractAsInt:function(e){return parseInt(e.toString().replace(/\W/g,""))},Hermite:w,Hermite1stDerivative:function(e,t,i,s,r){const n=r*r;return 6*(n-r)*e+(3*n-4*r+1)*t+6*(-n+r)*i+(3*n-2*r)*s},HighestCommonFactor:X,ILog2:G,InverseLerp:function(e,t,i){let s=0;return s=e!=t?U((i-e)/(t-e)):0,s},Lerp:N,LerpAngle:function(e,t,i){let s=V(t-e,360);return s>180&&(s-=360),e+s*U(i)},MoveTowards:z,MoveTowardsAngle:function(e,t,i){const s=H(e,t);let r=0;return r=-i<s&&s<i?t:z(e,t=e+s,i),r},Normalize:function(e,t,i){return(e-t)/(i-t)},NormalizeRadians:B,OutsideRange:function(e,t,i,s=1401298e-51){return e<t-s||e>i+s},PercentToRange:function(e,t,i){return(i-t)*e+t},PingPong:function(e,t){const i=V(e,2*t);return t-Math.abs(i-t)},RandomRange:F,RangeToPercent:function(e,t,i){return(e-t)/(i-t)},Repeat:V,SmoothStep:function(e,t,i){let s=U(i);return s=-2*s*s*s+3*s*s,t*s+e*(1-s)},ToHex:k,WithinEpsilon:L});class Y{}Y._UpdateFlagSeed=0;const K=e=>parseInt(e.toString().replace(/\W/g,""));class j{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=K(this.x);return e=397*e^K(this.y),e}toArray(e,t=0){return e[t]=this.x,e[t+1]=this.y,this}fromArray(e,t=0){return j.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 j(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 j(this.x+e.x,this.y+e.y)}subtract(e){return new j(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 j(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 j(this.x*e,this.y*t)}divide(e){return new j(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 j(this.x-e,this.y-t)}subtractFromFloatsToRef(e,t,i){return i.x=this.x-e,i.y=this.y-t,i}negate(){return new j(-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 j(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&&L(this.x,e.x,t)&&L(this.y,e.y,t)}equalsToFloats(e,t){return this.x===e&&this.y===t}floor(){return new j(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 j(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 j)}rotateToRef(e,t){const i=Math.cos(e),s=Math.sin(e);return t.x=i*this.x-s*this.y,t.y=s*this.x+i*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 j;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 j(this.x,this.y)}dot(e){return this.x*e.x+this.y*e.y}static Zero(){return new j(0,0)}static One(){return new j(1,1)}static Random(e=0,t=1){return new j(F(e,t),F(e,t))}static RandomToRef(e=0,t=1,i){return i.copyFromFloats(F(e,t),F(e,t))}static get ZeroReadOnly(){return j._ZeroReadOnly}static FromArray(e,t=0){return new j(e[t],e[t+1])}static FromArrayToRef(e,t,i){return i.x=e[t],i.y=e[t+1],i}static FromFloatsToRef(e,t,i){return i.copyFromFloats(e,t),i}static CatmullRom(e,t,i,s,r){const n=r*r,a=r*n,o=.5*(2*t.x+(-e.x+i.x)*r+(2*e.x-5*t.x+4*i.x-s.x)*n+(-e.x+3*t.x-3*i.x+s.x)*a),h=.5*(2*t.y+(-e.y+i.y)*r+(2*e.y-5*t.y+4*i.y-s.y)*n+(-e.y+3*t.y-3*i.y+s.y)*a);return new j(o,h)}static ClampToRef(e,t,i,s){return s.x=U(e.x,t.x,i.x),s.y=U(e.y,t.y,i.y),s}static Clamp(e,t,i){const s=U(e.x,t.x,i.x),r=U(e.y,t.y,i.y);return new j(s,r)}static Hermite(e,t,i,s,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+i.x*h+t.x*l+s.x*c,_=e.y*o+i.y*h+t.y*l+s.y*c;return new j(u,_)}static Hermite1stDerivative(e,t,i,s,r){return this.Hermite1stDerivativeToRef(e,t,i,s,r,new j)}static Hermite1stDerivativeToRef(e,t,i,s,r,n){const a=r*r;return n.x=6*(a-r)*e.x+(3*a-4*r+1)*t.x+6*(-a+r)*i.x+(3*a-2*r)*s.x,n.y=6*(a-r)*e.y+(3*a-4*r+1)*t.y+6*(-a+r)*i.y+(3*a-2*r)*s.y,n}static Lerp(e,t,i){return j.LerpToRef(e,t,i,new j)}static LerpToRef(e,t,i,s){return s.x=e.x+(t.x-e.x)*i,s.y=e.y+(t.y-e.y)*i,s}static Dot(e,t){return e.x*t.x+e.y*t.y}static Normalize(e){return j.NormalizeToRef(e,new j)}static NormalizeToRef(e,t){return e.normalizeToRef(t),t}static Minimize(e,t){const i=e.x<t.x?e.x:t.x,s=e.y<t.y?e.y:t.y;return new j(i,s)}static Maximize(e,t){const i=e.x>t.x?e.x:t.x,s=e.y>t.y?e.y:t.y;return new j(i,s)}static Transform(e,t){return j.TransformToRef(e,t,new j)}static TransformToRef(e,t,i){const s=t.m,r=e.x*s[0]+e.y*s[4]+s[12],n=e.x*s[1]+e.y*s[5]+s[13];return i.x=r,i.y=n,i}static PointInTriangle(e,t,i,s){const r=.5*(-i.y*s.x+t.y*(-i.x+s.x)+t.x*(i.y-s.y)+i.x*s.y),n=r<0?-1:1,a=(t.y*s.x-t.x*s.y+(s.y-t.y)*e.x+(t.x-s.x)*e.y)*n,o=(t.x*i.y-t.y*i.x+(t.y-i.y)*e.x+(i.x-t.x)*e.y)*n;return a>0&&o>0&&a+o<2*r*n}static Distance(e,t){return Math.sqrt(j.DistanceSquared(e,t))}static DistanceSquared(e,t){const i=e.x-t.x,s=e.y-t.y;return i*i+s*s}static Center(e,t){return j.CenterToRef(e,t,new j)}static CenterToRef(e,t,i){return i.copyFromFloats((e.x+t.x)/2,(e.y+t.y)/2)}static DistanceOfPointFromSegment(e,t,i){const s=j.DistanceSquared(t,i);if(0===s)return j.Distance(e,t);const r=i.subtract(t),n=Math.max(0,Math.min(1,j.Dot(e.subtract(t),r)/s)),a=t.add(r.multiplyByFloats(n,n));return j.Distance(e,a)}}j._V8PerformanceHack=new j(.5,.5),j._ZeroReadOnly=j.Zero(),Object.defineProperties(j.prototype,{dimension:{value:[2]},rank:{value:1}});class Q{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,i=0){this._isDirty=!0,this._x=e,this._y=t,this._z=i}toString(){return`{X: ${this._x} Y: ${this._y} Z: ${this._z}}`}getClassName(){return"Vector3"}getHashCode(){let e=K(this._x);return e=397*e^K(this._y),e=397*e^K(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 Q.FromArrayToRef(e,t,this),this}toQuaternion(){return Z.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,i){return this._x+=e,this._y+=t,this._z+=i,this._isDirty=!0,this}add(e){return new Q(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 Q(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,i){return new Q(this._x-e,this._y-t,this._z-i)}subtractFromFloatsToRef(e,t,i,s){return s._x=this._x-e,s._y=this._y-t,s._z=this._z-i,s._isDirty=!0,s}negate(){return new Q(-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 Q(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 i=Math.acos(this._y/t);const s=Math.atan2(this._z,this._x);i>Math.PI/2?i-=Math.PI/2:i+=Math.PI/2;const r=t*Math.sin(i)*Math.cos(s),n=t*Math.cos(i),a=t*Math.sin(i)*Math.sin(s);return e.set(r,n,a),e}applyRotationQuaternionToRef(e,t){const i=this._x,s=this._y,r=this._z,n=e._x,a=e._y,o=e._z,h=e._w,l=2*(a*r-o*s),c=2*(o*i-n*r),u=2*(n*s-a*i);return t._x=i+h*l+a*u-o*c,t._y=s+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 Q)}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 Q)}projectOnPlaneToRef(e,t,i){const s=e.normal,r=e.d,n=$.Vector3[0];this.subtractToRef(t,n),n.normalize();const a=Q.Dot(n,s);if(Math.abs(a)<1e-10)i.setAll(1/0);else{const e=-(Q.Dot(t,s)+r)/a,o=n.scaleInPlace(e);t.addToRef(o,i)}return i}equals(e){return e&&this._x===e._x&&this._y===e._y&&this._z===e._z}equalsWithEpsilon(e,t=.001){return e&&L(this._x,e._x,t)&&L(this._y,e._y,t)&&L(this._z,e._z,t)}equalsToFloats(e,t,i){return this._x===e&&this._y===t&&this._z===i}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,i){return new Q(this._x*e,this._y*t,this._z*i)}divide(e){return new Q(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,i){return e<this._x&&(this.x=e),t<this._y&&(this.y=t),i<this._z&&(this.z=i),this}maximizeInPlaceFromFloats(e,t,i){return e>this._x&&(this.x=e),t>this._y&&(this.y=t),i>this._z&&(this.z=i),this}isNonUniformWithinEpsilon(e){const t=Math.abs(this._x),i=Math.abs(this._y);if(!L(t,i,e))return!0;const s=Math.abs(this._z);return!L(t,s,e)||!L(i,s,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 Q(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 Q(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=$.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($.Matrix[0]),Q.TransformCoordinatesToRef(this,$.Matrix[0],t),t}rotateByQuaternionAroundPointToRef(e,t,i){return this.subtractToRef(t,$.Vector3[0]),$.Vector3[0].rotateByQuaternionToRef(e,$.Vector3[0]),t.addToRef($.Vector3[0],i),i}cross(e){return Q.CrossToRef(this,e,new Q)}normalizeFromLength(e){return 0===e||1===e?this:this.scaleInPlace(1/e)}normalizeToNew(){return this.normalizeToRef(new Q)}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 Q(this._x,this._y,this._z)}copyFrom(e){return this.copyFromFloats(e._x,e._y,e._z)}copyFromFloats(e,t,i){return this._x=e,this._y=t,this._z=i,this._isDirty=!0,this}set(e,t,i){return this.copyFromFloats(e,t,i)}setAll(e){return this._x=this._y=this._z=e,this._isDirty=!0,this}static GetClipFactor(e,t,i,s){const r=Q.Dot(e,i);return(r-s)/(r-Q.Dot(t,i))}static GetAngleBetweenVectors(e,t,i){const s=e.normalizeToRef($.Vector3[1]),r=t.normalizeToRef($.Vector3[2]);let n=Q.Dot(s,r);n=U(n,-1,1);const a=Math.acos(n),o=$.Vector3[3];return Q.CrossToRef(s,r,o),Q.Dot(o,i)>0?isNaN(a)?0:a:isNaN(a)?-Math.PI:-Math.acos(n)}static GetAngleBetweenVectorsOnPlane(e,t,i){$.Vector3[0].copyFrom(e);const s=$.Vector3[0];$.Vector3[1].copyFrom(t);const r=$.Vector3[1];$.Vector3[2].copyFrom(i);const n=$.Vector3[2],a=$.Vector3[3],o=$.Vector3[4];s.normalize(),r.normalize(),n.normalize(),Q.CrossToRef(n,s,a),Q.CrossToRef(a,n,o);return B(Math.atan2(Q.Dot(r,a),Q.Dot(r,o)))}static PitchYawRollToMoveBetweenPointsToRef(e,t,i){const s=ee.Vector3[0];return t.subtractToRef(e,s),i._y=Math.atan2(s.x,s.z)||0,i._x=Math.atan2(Math.sqrt(s.x**2+s.z**2),s.y)||0,i._z=0,i._isDirty=!0,i}static PitchYawRollToMoveBetweenPoints(e,t){const i=Q.Zero();return Q.PitchYawRollToMoveBetweenPointsToRef(e,t,i)}static SlerpToRef(e,t,i,s){i=U(i,0,1);const r=$.Vector3[0],n=$.Vector3[1];r.copyFrom(e);const a=r.length();r.normalizeFromLength(a),n.copyFrom(t);const o=n.length();n.normalizeFromLength(o);const h=Q.Dot(r,n);let l,c;if(h<.999){const e=Math.acos(h),t=1/Math.sin(e);l=Math.sin((1-i)*e)*t,c=Math.sin(i*e)*t}else l=1-i,c=i;return r.scaleInPlace(l),n.scaleInPlace(c),s.copyFrom(r).addInPlace(n),s.scaleInPlace(N(a,o,i)),s}static SmoothToRef(e,t,i,s,r){return Q.SlerpToRef(e,t,0===s?1:i/s,r),r}static FromArray(e,t=0){return new Q(e[t],e[t+1],e[t+2])}static FromFloatArray(e,t){return Q.FromArray(e,t)}static FromArrayToRef(e,t,i){return i._x=e[t],i._y=e[t+1],i._z=e[t+2],i._isDirty=!0,i}static FromFloatArrayToRef(e,t,i){return Q.FromArrayToRef(e,t,i)}static FromFloatsToRef(e,t,i,s){return s.copyFromFloats(e,t,i),s}static Zero(){return new Q(0,0,0)}static One(){return new Q(1,1,1)}static Up(){return new Q(0,1,0)}static get UpReadOnly(){return Q._UpReadOnly}static get DownReadOnly(){return Q._DownReadOnly}static get RightReadOnly(){return Q._RightReadOnly}static get LeftReadOnly(){return Q._LeftReadOnly}static get LeftHandedForwardReadOnly(){return Q._LeftHandedForwardReadOnly}static get RightHandedForwardReadOnly(){return Q._RightHandedForwardReadOnly}static get LeftHandedBackwardReadOnly(){return Q._LeftHandedBackwardReadOnly}static get RightHandedBackwardReadOnly(){return Q._RightHandedBackwardReadOnly}static get ZeroReadOnly(){return Q._ZeroReadOnly}static get OneReadOnly(){return Q._OneReadOnly}static Down(){return new Q(0,-1,0)}static Forward(e=!1){return new Q(0,0,e?-1:1)}static Backward(e=!1){return new Q(0,0,e?1:-1)}static Right(){return new Q(1,0,0)}static Left(){return new Q(-1,0,0)}static Random(e=0,t=1){return new Q(F(e,t),F(e,t),F(e,t))}static RandomToRef(e=0,t=1,i){return i.copyFromFloats(F(e,t),F(e,t),F(e,t))}static TransformCoordinates(e,t){const i=Q.Zero();return Q.TransformCoordinatesToRef(e,t,i),i}static TransformCoordinatesToRef(e,t,i){return Q.TransformCoordinatesFromFloatsToRef(e._x,e._y,e._z,t,i),i}static TransformCoordinatesFromFloatsToRef(e,t,i,s,r){const n=s.m,a=e*n[0]+t*n[4]+i*n[8]+n[12],o=e*n[1]+t*n[5]+i*n[9]+n[13],h=e*n[2]+t*n[6]+i*n[10]+n[14],l=1/(e*n[3]+t*n[7]+i*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 i=Q.Zero();return Q.TransformNormalToRef(e,t,i),i}static TransformNormalToRef(e,t,i){return this.TransformNormalFromFloatsToRef(e._x,e._y,e._z,t,i),i}static TransformNormalFromFloatsToRef(e,t,i,s,r){const n=s.m;return r._x=e*n[0]+t*n[4]+i*n[8],r._y=e*n[1]+t*n[5]+i*n[9],r._z=e*n[2]+t*n[6]+i*n[10],r._isDirty=!0,r}static CatmullRom(e,t,i,s,r){const n=r*r,a=r*n,o=.5*(2*t._x+(-e._x+i._x)*r+(2*e._x-5*t._x+4*i._x-s._x)*n+(-e._x+3*t._x-3*i._x+s._x)*a),h=.5*(2*t._y+(-e._y+i._y)*r+(2*e._y-5*t._y+4*i._y-s._y)*n+(-e._y+3*t._y-3*i._y+s._y)*a),l=.5*(2*t._z+(-e._z+i._z)*r+(2*e._z-5*t._z+4*i._z-s._z)*n+(-e._z+3*t._z-3*i._z+s._z)*a);return new Q(o,h,l)}static Clamp(e,t,i){const s=new Q;return Q.ClampToRef(e,t,i,s),s}static ClampToRef(e,t,i,s){let r=e._x;r=r>i._x?i._x:r,r=r<t._x?t._x:r;let n=e._y;n=n>i._y?i._y:n,n=n<t._y?t._y:n;let a=e._z;return a=a>i._z?i._z:a,a=a<t._z?t._z:a,s.copyFromFloats(r,n,a),s}static CheckExtends(e,t,i){t.minimizeInPlace(e),i.maximizeInPlace(e)}static Hermite(e,t,i,s,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+i._x*h+t._x*l+s._x*c,_=e._y*o+i._y*h+t._y*l+s._y*c,d=e._z*o+i._z*h+t._z*l+s._z*c;return new Q(u,_,d)}static Hermite1stDerivative(e,t,i,s,r){const n=new Q;return this.Hermite1stDerivativeToRef(e,t,i,s,r,n),n}static Hermite1stDerivativeToRef(e,t,i,s,r,n){const a=r*r;return n._x=6*(a-r)*e._x+(3*a-4*r+1)*t._x+6*(-a+r)*i._x+(3*a-2*r)*s._x,n._y=6*(a-r)*e._y+(3*a-4*r+1)*t._y+6*(-a+r)*i._y+(3*a-2*r)*s._y,n._z=6*(a-r)*e._z+(3*a-4*r+1)*t._z+6*(-a+r)*i._z+(3*a-2*r)*s._z,n._isDirty=!0,n}static Lerp(e,t,i){const s=new Q(0,0,0);return Q.LerpToRef(e,t,i,s),s}static LerpToRef(e,t,i,s){return s._x=e._x+(t._x-e._x)*i,s._y=e._y+(t._y-e._y)*i,s._z=e._z+(t._z-e._z)*i,s._isDirty=!0,s}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 i=new Q;return Q.CrossToRef(e,t,i),i}static CrossToRef(e,t,i){const s=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 i.copyFromFloats(s,r,n),i}static Normalize(e){const t=Q.Zero();return Q.NormalizeToRef(e,t),t}static NormalizeToRef(e,t){return e.normalizeToRef(t),t}static Project(e,t,i,s){const r=new Q;return Q.ProjectToRef(e,t,i,s,r),r}static ProjectToRef(e,t,i,s,r){const n=s.width,a=s.height,o=s.x,h=s.y,l=$.Matrix[1],c=D.LastCreatedEngine?.isNDCHalfZRange,u=c?1:.5,_=c?0:.5;J.FromValuesToRef(n/2,0,0,0,0,-a/2,0,0,0,0,u,0,o+n/2,a/2+h,_,1,l);const d=$.Matrix[0];return t.multiplyToRef(i,d),d.multiplyToRef(l,d),Q.TransformCoordinatesToRef(e,d,r),r}static Reflect(e,t){return this.ReflectToRef(e,t,new Q)}static ReflectToRef(e,t,i){const s=ee.Vector3[0];return s.copyFrom(t).scaleInPlace(2*Q.Dot(e,t)),i.copyFrom(e).subtractInPlace(s)}static _UnprojectFromInvertedMatrixToRef(e,t,i){Q.TransformCoordinatesToRef(e,t,i);const s=t.m,r=e._x*s[3]+e._y*s[7]+e._z*s[11]+s[15];return L(r,1)&&i.scaleInPlace(1/r),i}static UnprojectFromTransform(e,t,i,s,r){return this.Unproject(e,t,i,s,r,J.IdentityReadOnly)}static Unproject(e,t,i,s,r,n){const a=new Q;return Q.UnprojectToRef(e,t,i,s,r,n,a),a}static UnprojectToRef(e,t,i,s,r,n,a){return Q.UnprojectFloatsToRef(e._x,e._y,e._z,t,i,s,r,n,a),a}static UnprojectFloatsToRef(e,t,i,s,r,n,a,o,h){const l=$.Matrix[0];n.multiplyToRef(a,l),l.multiplyToRef(o,l),l.invert();const c=$.Vector3[0];return c.x=e/s*2-1,c.y=-(t/r*2-1),D.LastCreatedEngine?.isNDCHalfZRange?c.z=i:c.z=2*i-1,Q._UnprojectFromInvertedMatrixToRef(c,l,h),h}static Minimize(e,t){const i=new Q;return i.copyFrom(e),i.minimizeInPlace(t),i}static Maximize(e,t){const i=new Q;return i.copyFrom(e),i.maximizeInPlace(t),i}static Distance(e,t){return Math.sqrt(Q.DistanceSquared(e,t))}static DistanceSquared(e,t){const i=e._x-t._x,s=e._y-t._y,r=e._z-t._z;return i*i+s*s+r*r}static ProjectOnTriangleToRef(e,t,i,s,r){const n=$.Vector3[0],a=$.Vector3[1],o=$.Vector3[2],h=$.Vector3[3],l=$.Vector3[4];i.subtractToRef(t,n),s.subtractToRef(t,a),s.subtractToRef(i,o);const c=n.length(),u=a.length(),_=o.length();if(c<M||u<M||_<M)return r.copyFrom(t),Q.Distance(e,t);e.subtractToRef(t,l),Q.CrossToRef(n,a,h);const d=h.length();if(d<M)return r.copyFrom(t),Q.Distance(e,t);h.normalizeFromLength(d);let f=l.length();if(f<M)return r.copyFrom(t),0;l.normalizeFromLength(f);const p=Q.Dot(h,l),g=$.Vector3[5],m=$.Vector3[6];g.copyFrom(h).scaleInPlace(-f*p),m.copyFrom(e).addInPlace(g);const T=$.Vector3[4],E=$.Vector3[5],A=$.Vector3[7],R=$.Vector3[8];T.copyFrom(n).scaleInPlace(1/c),R.copyFrom(a).scaleInPlace(1/u),T.addInPlace(R).scaleInPlace(-1),E.copyFrom(n).scaleInPlace(-1/c),R.copyFrom(o).scaleInPlace(1/_),E.addInPlace(R).scaleInPlace(-1),A.copyFrom(o).scaleInPlace(-1/_),R.copyFrom(a).scaleInPlace(-1/u),A.addInPlace(R).scaleInPlace(-1);const b=$.Vector3[9];let S;b.copyFrom(m).subtractInPlace(t),Q.CrossToRef(T,b,R),S=Q.Dot(R,h);const y=S;b.copyFrom(m).subtractInPlace(i),Q.CrossToRef(E,b,R),S=Q.Dot(R,h);const I=S;b.copyFrom(m).subtractInPlace(s),Q.CrossToRef(A,b,R),S=Q.Dot(R,h);const x=S,C=$.Vector3[10];let v,P;y>0&&I<0?(C.copyFrom(n),v=t,P=i):I>0&&x<0?(C.copyFrom(o),v=i,P=s):(C.copyFrom(a).scaleInPlace(-1),v=s,P=t);const O=$.Vector3[9],D=$.Vector3[4];v.subtractToRef(m,R),P.subtractToRef(m,O),Q.CrossToRef(R,O,D);if(!(Q.Dot(D,h)<0))return r.copyFrom(m),Math.abs(f*p);const L=$.Vector3[5];Q.CrossToRef(C,D,L),L.normalize();const F=$.Vector3[9];F.copyFrom(v).subtractInPlace(m);const N=F.length();if(N<M)return r.copyFrom(v),Q.Distance(e,v);F.normalizeFromLength(N);const w=Q.Dot(L,F),B=$.Vector3[7];B.copyFrom(m).addInPlace(L.scaleInPlace(N*w)),R.copyFrom(B).subtractInPlace(v),f=C.length(),C.normalizeFromLength(f);let k=Q.Dot(R,C)/Math.max(f,M);return k=U(k,0,1),B.copyFrom(v).addInPlace(C.scaleInPlace(k*f)),r.copyFrom(B),Q.Distance(e,B)}static Center(e,t){return Q.CenterToRef(e,t,Q.Zero())}static CenterToRef(e,t,i){return i.copyFromFloats((e._x+t._x)/2,(e._y+t._y)/2,(e._z+t._z)/2)}static RotationFromAxis(e,t,i){const s=new Q;return Q.RotationFromAxisToRef(e,t,i,s),s}static RotationFromAxisToRef(e,t,i,s){const r=$.Quaternion[0];return Z.RotationQuaternionFromAxisToRef(e,t,i,r),r.toEulerAnglesToRef(s),s}}Q._V8PerformanceHack=new Q(.5,.5,.5),Q._UpReadOnly=Q.Up(),Q._DownReadOnly=Q.Down(),Q._LeftHandedForwardReadOnly=Q.Forward(!1),Q._RightHandedForwardReadOnly=Q.Forward(!0),Q._LeftHandedBackwardReadOnly=Q.Backward(!1),Q._RightHandedBackwardReadOnly=Q.Backward(!0),Q._RightReadOnly=Q.Right(),Q._LeftReadOnly=Q.Left(),Q._ZeroReadOnly=Q.Zero(),Q._OneReadOnly=Q.One(),Object.defineProperties(Q.prototype,{dimension:{value:[3]},rank:{value:1}});class q{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,i=0,s=0){this._isDirty=!0,this._x=e,this._y=t,this._z=i,this._w=s}toString(){return`{X: ${this._x} Y: ${this._y} Z: ${this._z} W: ${this._w}}`}getClassName(){return"Vector4"}getHashCode(){let e=K(this._x);return e=397*e^K(this._y),e=397*e^K(this._z),e=397*e^K(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 q.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,i,s){return this.x+=e,this.y+=t,this.z+=i,this.w+=s,this}add(e){return new q(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 q(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,i,s){return new q(this._x-e,this._y-t,this._z-i,this._w-s)}subtractFromFloatsToRef(e,t,i,s,r){return r.x=this._x-e,r.y=this._y-t,r.z=this._z-i,r.w=this._w-s,r}negate(){return new q(-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 q(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&&L(this._x,e.x,t)&&L(this._y,e.y,t)&&L(this._z,e.z,t)&&L(this._w,e.w,t)}equalsToFloats(e,t,i,s){return this._x===e&&this._y===t&&this._z===i&&this._w===s}multiplyInPlace(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiply(e){return new q(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,i,s){return new q(this._x*e,this._y*t,this._z*i,this._w*s)}divide(e){return new q(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,i,s){return this.x=Math.min(e,this._x),this.y=Math.min(t,this._y),this.z=Math.min(i,this._z),this.w=Math.min(s,this._w),this}maximizeInPlaceFromFloats(e,t,i,s){return this.x=Math.max(e,this._x),this.y=Math.max(t,this._y),this.z=Math.max(i,this._z),this.w=Math.max(s,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 q(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 q(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*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}lengthSquared(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}normalize(){return this.normalizeFromLength(this.length())}normalizeFromLength(e){return 0===e||1===e?this:this.scaleInPlace(1/e)}normalizeToNew(){return this.normalizeToRef(new q)}normalizeToRef(e){const t=this.length();return 0===t||1===t?(e.x=this._x,e.y=this._y,e.z=this._z,e.w=this._w,e):this.scaleToRef(1/t,e)}toVector3(){return new Q(this._x,this._y,this._z)}clone(){return new q(this._x,this._y,this._z,this._w)}copyFrom(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w,this}copyFromFloats(e,t,i,s){return this.x=e,this.y=t,this.z=i,this.w=s,this}set(e,t,i,s){return this.copyFromFloats(e,t,i,s)}setAll(e){return this.x=this.y=this.z=this.w=e,this}dot(e){return this._x*e.x+this._y*e.y+this._z*e.z+this._w*e.w}static FromArray(e,t){return t||(t=0),new q(e[t],e[t+1],e[t+2],e[t+3])}static FromArrayToRef(e,t,i){return i.x=e[t],i.y=e[t+1],i.z=e[t+2],i.w=e[t+3],i}static FromFloatArrayToRef(e,t,i){return q.FromArrayToRef(e,t,i),i}static FromFloatsToRef(e,t,i,s,r){return r.x=e,r.y=t,r.z=i,r.w=s,r}static Zero(){return new q(0,0,0,0)}static One(){return new q(1,1,1,1)}static Random(e=0,t=1){return new q(F(e,t),F(e,t),F(e,t),F(e,t))}static RandomToRef(e=0,t=1,i){return i.x=F(e,t),i.y=F(e,t),i.z=F(e,t),i.w=F(e,t),i}static Clamp(e,t,i){return q.ClampToRef(e,t,i,new q)}static ClampToRef(e,t,i,s){return s.x=U(e.x,t.x,i.x),s.y=U(e.y,t.y,i.y),s.z=U(e.z,t.z,i.z),s.w=U(e.w,t.w,i.w),s}static CheckExtends(e,t,i){t.minimizeInPlace(e),i.maximizeInPlace(e)}static get ZeroReadOnly(){return q._ZeroReadOnly}static Normalize(e){return q.NormalizeToRef(e,new q)}static NormalizeToRef(e,t){return e.normalizeToRef(t),t}static Minimize(e,t){const i=new q;return i.copyFrom(e),i.minimizeInPlace(t),i}static Maximize(e,t){const i=new q;return i.copyFrom(e),i.maximizeInPlace(t),i}static Distance(e,t){return Math.sqrt(q.DistanceSquared(e,t))}static DistanceSquared(e,t){const i=e.x-t.x,s=e.y-t.y,r=e.z-t.z,n=e.w-t.w;return i*i+s*s+r*r+n*n}static Center(e,t){return q.CenterToRef(e,t,new q)}static CenterToRef(e,t,i){return i.x=(e.x+t.x)/2,i.y=(e.y+t.y)/2,i.z=(e.z+t.z)/2,i.w=(e.w+t.w)/2,i}static TransformCoordinates(e,t){return q.TransformCoordinatesToRef(e,t,new q)}static TransformCoordinatesToRef(e,t,i){return q.TransformCoordinatesFromFloatsToRef(e._x,e._y,e._z,t,i),i}static TransformCoordinatesFromFloatsToRef(e,t,i,s,r){const n=s.m,a=e*n[0]+t*n[4]+i*n[8]+n[12],o=e*n[1]+t*n[5]+i*n[9]+n[13],h=e*n[2]+t*n[6]+i*n[10]+n[14],l=e*n[3]+t*n[7]+i*n[11]+n[15];return r.x=a,r.y=o,r.z=h,r.w=l,r}static TransformNormal(e,t){return q.TransformNormalToRef(e,t,new q)}static TransformNormalToRef(e,t,i){const s=t.m,r=e.x*s[0]+e.y*s[4]+e.z*s[8],n=e.x*s[1]+e.y*s[5]+e.z*s[9],a=e.x*s[2]+e.y*s[6]+e.z*s[10];return i.x=r,i.y=n,i.z=a,i.w=e.w,i}static TransformNormalFromFloatsToRef(e,t,i,s,r,n){const a=r.m;return n.x=e*a[0]+t*a[4]+i*a[8],n.y=e*a[1]+t*a[5]+i*a[9],n.z=e*a[2]+t*a[6]+i*a[10],n.w=s,n}static FromVector3(e,t=0){return new q(e._x,e._y,e._z,t)}static Dot(e,t){return e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w}}q._V8PerformanceHack=new q(.5,.5,.5,.5),q._ZeroReadOnly=q.Zero(),Object.defineProperties(q.prototype,{dimension:{value:[4]},rank:{value:1}});class Z{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,i=0,s=1){this._isDirty=!0,this._x=e,this._y=t,this._z=i,this._w=s}toString(){return`{X: ${this._x} Y: ${this._y} Z: ${this._z} W: ${this._w}}`}getClassName(){return"Quaternion"}getHashCode(){let e=K(this._x);return e=397*e^K(this._y),e=397*e^K(this._z),e=397*e^K(this._w),e}asArray(){return[this._x,this._y,this._z,this._w]}toArray(e,t=0){return 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 Z.FromArrayToRef(e,t,this)}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&&L(this._x,e._x,t)&&L(this._y,e._y,t)&&L(this._z,e._z,t)&&L(this._w,e._w,t)}isApprox(e,t=.001){return e&&(L(this._x,e._x,t)&&L(this._y,e._y,t)&&L(this._z,e._z,t)&&L(this._w,e._w,t)||L(this._x,-e._x,t)&&L(this._y,-e._y,t)&&L(this._z,-e._z,t)&&L(this._w,-e._w,t))}clone(){return new Z(this._x,this._y,this._z,this._w)}copyFrom(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._w=e._w,this._isDirty=!0,this}copyFromFloats(e,t,i,s){return this._x=e,this._y=t,this._z=i,this._w=s,this._isDirty=!0,this}set(e,t,i,s){return this.copyFromFloats(e,t,i,s)}setAll(e){return this.copyFromFloats(e,e,e,e)}add(e){return new Z(this._x+e._x,this._y+e._y,this._z+e._z,this._w+e._w)}addInPlace(e){return this._x+=e._x,this._y+=e._y,this._z+=e._z,this._w+=e._w,this._isDirty=!0,this}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._isDirty=!0,t}addInPlaceFromFloats(e,t,i,s){return this._x+=e,this._y+=t,this._z+=i,this._w+=s,this._isDirty=!0,this}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._isDirty=!0,t}subtractFromFloats(e,t,i,s){return this.subtractFromFloatsToRef(e,t,i,s,new Z)}subtractFromFloatsToRef(e,t,i,s,r){return r._x=this._x-e,r._y=this._y-t,r._z=this._z-i,r._w=this._w-s,r._isDirty=!0,r}subtract(e){return new Z(this._x-e._x,this._y-e._y,this._z-e._z,this._w-e._w)}subtractInPlace(e){return this._x-=e._x,this._y-=e._y,this._z-=e._z,this._w-=e._w,this._isDirty=!0,this}scale(e){return new Z(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._isDirty=!0,t}scaleInPlace(e){return this._x*=e,this._y*=e,this._z*=e,this._w*=e,this._isDirty=!0,this}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._isDirty=!0,t}multiply(e){const t=new Z(0,0,0,1);return this.multiplyToRef(e,t),t}multiplyToRef(e,t){const i=this._x*e._w+this._y*e._z-this._z*e._y+this._w*e._x,s=-this._x*e._z+this._y*e._w+this._z*e._x+this._w*e._y,r=this._x*e._y-this._y*e._x+this._z*e._w+this._w*e._z,n=-this._x*e._x-this._y*e._y-this._z*e._z+this._w*e._w;return t.copyFromFloats(i,s,r,n),t}multiplyInPlace(e){return this.multiplyToRef(e,this)}multiplyByFloats(e,t,i,s){return this._x*=e,this._y*=t,this._z*=i,this._w*=s,this._isDirty=!0,this}divide(e){throw new ReferenceError("Can not divide a quaternion")}divideToRef(e,t){throw new ReferenceError("Can not divide a quaternion")}divideInPlace(e){throw new ReferenceError("Can not divide a quaternion")}minimizeInPlace(){throw new ReferenceError("Can not minimize a quaternion")}minimizeInPlaceFromFloats(){throw new ReferenceError("Can not minimize a quaternion")}maximizeInPlace(){throw new ReferenceError("Can not maximize a quaternion")}maximizeInPlaceFromFloats(){throw new ReferenceError("Can not maximize a quaternion")}negate(){return this.negateToRef(new Z)}negateInPlace(){return this._x=-this._x,this._y=-this._y,this._z=-this._z,this._w=-this._w,this._isDirty=!0,this}negateToRef(e){return e._x=-this._x,e._y=-this._y,e._z=-this._z,e._w=-this._w,e._isDirty=!0,e}equalsToFloats(e,t,i,s){return this._x===e&&this._y===t&&this._z===i&&this._w===s}floorToRef(e){throw new ReferenceError("Can not floor a quaternion")}floor(){throw new ReferenceError("Can not floor a quaternion")}fractToRef(e){throw new ReferenceError("Can not fract a quaternion")}fract(){throw new ReferenceError("Can not fract a quaternion")}conjugateToRef(e){return e.copyFromFloats(-this._x,-this._y,-this._z,this._w),e}conjugateInPlace(){return this._x*=-1,this._y*=-1,this._z*=-1,this._isDirty=!0,this}conjugate(){return new Z(-this._x,-this._y,-this._z,this._w)}invert(){const e=this.conjugate(),t=this.lengthSquared();return 0==t||1==t||e.scaleInPlace(1/t),e}invertInPlace(){this.conjugateInPlace();const e=this.lengthSquared();return 0==e||1==e||this.scaleInPlace(1/e),this}lengthSquared(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this.lengthSquared())}normalize(){return this.normalizeFromLength(this.length())}normalizeFromLength(e){return 0===e||1===e?this:this.scaleInPlace(1/e)}normalizeToNew(){const e=new Z(0,0,0,1);return this.normalizeToRef(e),e}normalizeToRef(e){const t=this.length();return 0===t||1===t?e.copyFromFloats(this._x,this._y,this._z,this._w):this.scaleToRef(1/t,e)}toEulerAngles(){const e=Q.Zero();return this.toEulerAnglesToRef(e),e}toEulerAnglesToRef(e){const t=this._z,i=this._x,s=this._y,r=this._w,n=s*t-i*r;if(n<-.4999999)e._y=2*Math.atan2(s,r),e._x=Math.PI/2,e._z=0,e._isDirty=!0;else if(n>.4999999)e._y=2*Math.atan2(s,r),e._x=-Math.PI/2,e._z=0,e._isDirty=!0;else{const a=r*r,o=t*t,h=i*i,l=s*s;e._z=Math.atan2(2*(i*s+t*r),-o-h+l+a),e._x=Math.asin(-2*n),e._y=Math.atan2(2*(t*i+s*r),o-h-l+a),e._isDirty=!0}return e}toAlphaBetaGammaToRef(e){const t=this._z,i=this._x,s=this._y,r=this._w,n=Math.sqrt(i*i+s*s),a=Math.sqrt(t*t+r*r),o=2*Math.atan2(n,a),h=2*Math.atan2(t,r),l=2*Math.atan2(s,i),c=(h+l)/2,u=(h-l)/2;return e.set(u,o,c),e}toRotationMatrix(e){return J.FromQuaternionToRef(this,e),e}fromRotationMatrix(e){return Z.FromRotationMatrixToRef(e,this),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}toAxisAngle(){const e=Q.Zero();return{axis:e,angle:this.toAxisAngleToRef(e)}}toAxisAngleToRef(e){let t=0;const i=Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z),s=this._w;return i>0?(t=2*Math.atan2(i,s),e.set(this._x/i,this._y/i,this._z/i)):(t=0,e.set(1,0,0)),t}static FromRotationMatrix(e){const t=new Z;return Z.FromRotationMatrixToRef(e,t),t}static FromRotationMatrixToRef(e,t){const i=e.m,s=i[0],r=i[4],n=i[8],a=i[1],o=i[5],h=i[9],l=i[2],c=i[6],u=i[10],_=s+o+u;let d;return _>0?(d=.5/Math.sqrt(_+1),t._w=.25/d,t._x=(c-h)*d,t._y=(n-l)*d,t._z=(a-r)*d,t._isDirty=!0):s>o&&s>u?(d=2*Math.sqrt(1+s-o-u),t._w=(c-h)/d,t._x=.25*d,t._y=(r+a)/d,t._z=(n+l)/d,t._isDirty=!0):o>u?(d=2*Math.sqrt(1+o-s-u),t._w=(n-l)/d,t._x=(r+a)/d,t._y=.25*d,t._z=(h+c)/d,t._isDirty=!0):(d=2*Math.sqrt(1+u-s-o),t._w=(a-r)/d,t._x=(n+l)/d,t._y=(h+c)/d,t._z=.25*d,t._isDirty=!0),t}static Dot(e,t){return e._x*t._x+e._y*t._y+e._z*t._z+e._w*t._w}static AreClose(e,t,i=.1){const s=Z.Dot(e,t);return 1-s*s<=i}static SmoothToRef(e,t,i,s,r){let n=0===s?1:i/s;return n=U(n,0,1),Z.SlerpToRef(e,t,n,r),r}static Zero(){return new Z(0,0,0,0)}static Inverse(e){return new Z(-e._x,-e._y,-e._z,e._w)}static InverseToRef(e,t){return t.set(-e._x,-e._y,-e._z,e._w),t}static Identity(){return new Z(0,0,0,1)}static IsIdentity(e){return e&&0===e._x&&0===e._y&&0===e._z&&1===e._w}static RotationAxis(e,t){return Z.RotationAxisToRef(e,t,new Z)}static RotationAxisToRef(e,t,i){i._w=Math.cos(t/2);const s=Math.sin(t/2)/e.length();return i._x=e._x*s,i._y=e._y*s,i._z=e._z*s,i._isDirty=!0,i}static FromArray(e,t){return t||(t=0),new Z(e[t],e[t+1],e[t+2],e[t+3])}static FromArrayToRef(e,t,i){return i._x=e[t],i._y=e[t+1],i._z=e[t+2],i._w=e[t+3],i._isDirty=!0,i}static FromFloatsToRef(e,t,i,s,r){return r.copyFromFloats(e,t,i,s),r}static FromEulerAngles(e,t,i){const s=new Z;return Z.RotationYawPitchRollToRef(t,e,i,s),s}static FromEulerAnglesToRef(e,t,i,s){return Z.RotationYawPitchRollToRef(t,e,i,s),s}static FromEulerVector(e){const t=new Z;return Z.RotationYawPitchRollToRef(e._y,e._x,e._z,t),t}static FromEulerVectorToRef(e,t){return Z.RotationYawPitchRollToRef(e._y,e._x,e._z,t),t}static FromUnitVectorsToRef(e,t,i,s=.001){const r=Q.Dot(e,t)+1;return r<s?Math.abs(e.x)>Math.abs(e.z)?i.set(-e.y,e.x,0,0):i.set(0,-e.z,e.y,0):(Q.CrossToRef(e,t,ee.Vector3[0]),i.set(ee.Vector3[0].x,ee.Vector3[0].y,ee.Vector3[0].z,r)),i.normalize()}static RotationYawPitchRoll(e,t,i){const s=new Z;return Z.RotationYawPitchRollToRef(e,t,i,s),s}static RotationYawPitchRollToRef(e,t,i,s){const r=.5*i,n=.5*t,a=.5*e,o=Math.sin(r),h=Math.cos(r),l=Math.sin(n),c=Math.cos(n),u=Math.sin(a),_=Math.cos(a);return s._x=_*l*h+u*c*o,s._y=u*c*h-_*l*o,s._z=_*c*o-u*l*h,s._w=_*c*h+u*l*o,s._isDirty=!0,s}static RotationAlphaBetaGamma(e,t,i){const s=new Z;return Z.RotationAlphaBetaGammaToRef(e,t,i,s),s}static RotationAlphaBetaGammaToRef(e,t,i,s){const r=.5*(i+e),n=.5*(i-e),a=.5*t;return s._x=Math.cos(n)*Math.sin(a),s._y=Math.sin(n)*Math.sin(a),s._z=Math.sin(r)*Math.cos(a),s._w=Math.cos(r)*Math.cos(a),s._isDirty=!0,s}static RotationQuaternionFromAxis(e,t,i){const s=new Z(0,0,0,0);return Z.RotationQuaternionFromAxisToRef(e,t,i,s),s}static RotationQuaternionFromAxisToRef(e,t,i,s){const r=$.Matrix[0];return e=e.normalizeToRef($.Vector3[0]),t=t.normalizeToRef($.Vector3[1]),i=i.normalizeToRef($.Vector3[2]),J.FromXYZAxesToRef(e,t,i,r),Z.FromRotationMatrixToRef(r,s),s}static FromLookDirectionLH(e,t){const i=new Z;return Z.FromLookDirectionLHToRef(e,t,i),i}static FromLookDirectionLHToRef(e,t,i){const s=$.Matrix[0];return J.LookDirectionLHToRef(e,t,s),Z.FromRotationMatrixToRef(s,i),i}static FromLookDirectionRH(e,t){const i=new Z;return Z.FromLookDirectionRHToRef(e,t,i),i}static FromLookDirectionRHToRef(e,t,i){const s=$.Matrix[0];return J.LookDirectionRHToRef(e,t,s),Z.FromRotationMatrixToRef(s,i)}static Slerp(e,t,i){const s=Z.Identity();return Z.SlerpToRef(e,t,i,s),s}static SlerpToRef(e,t,i,s){let r,n,a=e._x*t._x+e._y*t._y+e._z*t._z+e._w*t._w,o=!1;if(a<0&&(o=!0,a=-a),a>.999999)n=1-i,r=o?-i:i;else{const e=Math.acos(a),t=1/Math.sin(e);n=Math.sin((1-i)*e)*t,r=o?-Math.sin(i*e)*t:Math.sin(i*e)*t}return s._x=n*e._x+r*t._x,s._y=n*e._y+r*t._y,s._z=n*e._z+r*t._z,s._w=n*e._w+r*t._w,s._isDirty=!0,s}static Hermite(e,t,i,s,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+i._x*h+t._x*l+s._x*c,_=e._y*o+i._y*h+t._y*l+s._y*c,d=e._z*o+i._z*h+t._z*l+s._z*c,f=e._w*o+i._w*h+t._w*l+s._w*c;return new Z(u,_,d,f)}static Hermite1stDerivative(e,t,i,s,r){const n=new Z;return this.Hermite1stDerivativeToRef(e,t,i,s,r,n),n}static Hermite1stDerivativeToRef(e,t,i,s,r,n){const a=r*r;return n._x=6*(a-r)*e._x+(3*a-4*r+1)*t._x+6*(-a+r)*i._x+(3*a-2*r)*s._x,n._y=6*(a-r)*e._y+(3*a-4*r+1)*t._y+6*(-a+r)*i._y+(3*a-2*r)*s._y,n._z=6*(a-r)*e._z+(3*a-4*r+1)*t._z+6*(-a+r)*i._z+(3*a-2*r)*s._z,n._w=6*(a-r)*e._w+(3*a-4*r+1)*t._w+6*(-a+r)*i._w+(3*a-2*r)*s._w,n._isDirty=!0,n}static Normalize(e){const t=Z.Zero();return Z.NormalizeToRef(e,t),t}static NormalizeToRef(e,t){return e.normalizeToRef(t),t}static Clamp(e,t,i){const s=new Z;return Z.ClampToRef(e,t,i,s),s}static ClampToRef(e,t,i,s){return s.copyFromFloats(U(e.x,t.x,i.x),U(e.y,t.y,i.y),U(e.z,t.z,i.z),U(e.w,t.w,i.w))}static Random(e=0,t=1){return new Z(F(e,t),F(e,t),F(e,t),F(e,t))}static RandomToRef(e=0,t=1,i){return i.copyFromFloats(F(e,t),F(e,t),F(e,t),F(e,t))}static Minimize(){throw new ReferenceError("Quaternion.Minimize does not make sense")}static Maximize(){throw new ReferenceError("Quaternion.Maximize does not make sense")}static Distance(e,t){return Math.sqrt(Z.DistanceSquared(e,t))}static DistanceSquared(e,t){const i=e.x-t.x,s=e.y-t.y,r=e.z-t.z,n=e.w-t.w;return i*i+s*s+r*r+n*n}static Center(e,t){return Z.CenterToRef(e,t,Z.Zero())}static CenterToRef(e,t,i){return i.copyFromFloats((e.x+t.x)/2,(e.y+t.y)/2,(e.z+t.z)/2,(e.w+t.w)/2)}}Z._V8PerformanceHack=new Z(.5,.5,.5,.5),Object.defineProperties(Z.prototype,{dimension:{value:[4]},rank:{value:1}});class J{static get Use64Bits(){return O.MatrixUse64Bits}get m(){return this._m}markAsUpdated(){this.updateFlag=Y._UpdateFlagSeed++,this._isIdentity=!1,this._isIdentity3x2=!1,this._isIdentityDirty=!0,this._isIdentity3x2Dirty=!0}_updateIdentityStatus(e,t=!1,i=!1,s=!0){this._isIdentity=e,this._isIdentity3x2=e||i,this._isIdentityDirty=!this._isIdentity&&t,this._isIdentity3x2Dirty=!this._isIdentity3x2&&s}constructor(){this._isIdentity=!1,this._isIdentityDirty=!0,this._isIdentity3x2=!0,this._isIdentity3x2Dirty=!0,this.updateFlag=-1,O.MatrixTrackPrecisionChange&&O.MatrixTrackedMatrices.push(this),this._m=new O.MatrixCurrentType(16),this.markAsUpdated()}isIdentity(){if(this._isIdentityDirty){this._isIdentityDirty=!1;const e=this._m;this._isIdentity=1===e[0]&&0===e[1]&&0===e[2]&&0===e[3]&&0===e[4]&&1===e[5]&&0===e[6]&&0===e[7]&&0===e[8]&&0===e[9]&&1===e[10]&&0===e[