diff --git a/docs/static/pmx_converter/257.bundle.js b/docs/static/pmx_converter/257.bundle.js deleted file mode 100644 index 74f5221..0000000 --- a/docs/static/pmx_converter/257.bundle.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunkbabylon_mmd=self.webpackChunkbabylon_mmd||[]).push([[257],{8257:(e,n,b)=>{function u(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}b.d(n,{N:()=>u})}}]); \ No newline at end of file diff --git a/docs/static/pmx_converter/833.bundle.js b/docs/static/pmx_converter/833.bundle.js deleted file mode 100644 index 7abf02b..0000000 --- a/docs/static/pmx_converter/833.bundle.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunkbabylon_mmd=self.webpackChunkbabylon_mmd||[]).push([[833],{7540:(e,t,s)=>{s.d(t,{X5:()=>b});var i=s(9923),r=s(6041),n=s(4867),a=s(6552),o=s(6227),h=s(4870),l=s(521),c=s(2366),u=s(6877);const d=Object.freeze(new i.PT(0,0,0,0)),_=Object.freeze(i.Pq.Zero()),f=Object.freeze(i.I9.Zero()),p=Object.freeze(l.o.Zero()),g=Object.freeze(r.v9.Black()),m=Object.freeze(new r.ov(0,0,0,0)),T={key:0,repeatCount:0,loopMode:2};class b{static _PrepareAnimation(e,t,s,n,a,o,h,c){let u;if(!isNaN(parseFloat(a))&&isFinite(a)?u=b.ANIMATIONTYPE_FLOAT:a instanceof i.PT?u=b.ANIMATIONTYPE_QUATERNION:a instanceof i.Pq?u=b.ANIMATIONTYPE_VECTOR3:a instanceof i.I9?u=b.ANIMATIONTYPE_VECTOR2:a instanceof r.v9?u=b.ANIMATIONTYPE_COLOR3:a instanceof r.ov?u=b.ANIMATIONTYPE_COLOR4:a instanceof l.o&&(u=b.ANIMATIONTYPE_SIZE),null==u)return null;const d=new b(e,t,s,u,h),_=[{frame:0,value:a},{frame:n,value:o}];return d.setKeys(_),void 0!==c&&d.setEasingFunction(c),d}static CreateAnimation(e,t,s,i){const r=new b(e+"Animation",e,s,t,b.ANIMATIONLOOPMODE_CONSTANT);return r.setEasingFunction(i),r}static CreateAndStartAnimation(e,t,s,i,r,n,a,o,h,l,c){const u=b._PrepareAnimation(e,s,i,r,n,a,o,h);return u?(t.getScene&&(c=t.getScene()),c?c.beginDirectAnimation(t,[u],0,r,1===u.loopMode,1,l):null):null}static CreateAndStartHierarchyAnimation(e,t,s,i,r,n,a,o,h,l,c){const u=b._PrepareAnimation(e,i,r,n,a,o,h,l);return u?t.getScene().beginDirectHierarchyAnimation(t,s,[u],0,n,1===u.loopMode,1,c):null}static CreateMergeAndStartAnimation(e,t,s,i,r,n,a,o,h,l){const c=b._PrepareAnimation(e,s,i,r,n,a,o,h);return c?(t.animations.push(c),t.getScene().beginAnimation(t,0,r,1===c.loopMode,1,l)):null}static MakeAnimationAdditive(e,t,s,r=!1,n){let a;a="object"==typeof t?t:{referenceFrame:t??0,range:s,cloneOriginalAnimation:r,clonedAnimationName:n};let o=e;if(a.cloneOriginalAnimation&&(o=e.clone(),o.name=a.clonedAnimationName||o.name),!o._keys.length)return o;const h=a.referenceFrame&&a.referenceFrame>=0?a.referenceFrame:0;let l=0;const c=o._keys[0];let u=o._keys.length-1;const d=o._keys[u],_={referenceValue:c.value,referencePosition:i.AA.Vector3[0],referenceQuaternion:i.AA.Quaternion[0],referenceScaling:i.AA.Vector3[1],keyPosition:i.AA.Vector3[2],keyQuaternion:i.AA.Quaternion[1],keyScaling:i.AA.Vector3[3]};let f=c.frame,p=d.frame;if(a.range){const e=o.getRange(a.range);e&&(f=e.from,p=e.to)}else f=a.fromFrame??f,p=a.toFrame??p;if(f!==c.frame&&(l=o.createKeyForFrame(f)),p!==d.frame&&(u=o.createKeyForFrame(p)),1===o._keys.length){const e=o._getKeyValue(o._keys[0]);_.referenceValue=e.clone?e.clone():e}else if(h<=c.frame){const e=o._getKeyValue(c.value);_.referenceValue=e.clone?e.clone():e}else if(h>=d.frame){const e=o._getKeyValue(d.value);_.referenceValue=e.clone?e.clone():e}else{T.key=0;const e=o._interpolate(h,T);_.referenceValue=e.clone?e.clone():e}o.dataType===b.ANIMATIONTYPE_QUATERNION?_.referenceValue.normalize().conjugateInPlace():o.dataType===b.ANIMATIONTYPE_MATRIX&&(_.referenceValue.decompose(_.referenceScaling,_.referenceQuaternion,_.referencePosition),_.referenceQuaternion.normalize().conjugateInPlace());let g=Number.MAX_VALUE;const m=a.clipKeys?[]:null;for(let e=l;e<=u;e++){let t=o._keys[e];if((m||a.cloneOriginalAnimation)&&(t={frame:t.frame,value:t.value.clone?t.value.clone():t.value,inTangent:t.inTangent,outTangent:t.outTangent,interpolation:t.interpolation,lockedTangent:t.lockedTangent},m&&(g===Number.MAX_VALUE&&(g=t.frame),t.frame-=g,m.push(t))),!e||o.dataType===b.ANIMATIONTYPE_FLOAT||t.value!==c.value)switch(o.dataType){case b.ANIMATIONTYPE_MATRIX:t.value.decompose(_.keyScaling,_.keyQuaternion,_.keyPosition),_.keyPosition.subtractInPlace(_.referencePosition),_.keyScaling.divideInPlace(_.referenceScaling),_.referenceQuaternion.multiplyToRef(_.keyQuaternion,_.keyQuaternion),i.uq.ComposeToRef(_.keyScaling,_.keyQuaternion,_.keyPosition,t.value);break;case b.ANIMATIONTYPE_QUATERNION:_.referenceValue.multiplyToRef(t.value,t.value);break;case b.ANIMATIONTYPE_VECTOR2:case b.ANIMATIONTYPE_VECTOR3:case b.ANIMATIONTYPE_COLOR3:case b.ANIMATIONTYPE_COLOR4:t.value.subtractToRef(_.referenceValue,t.value);break;case b.ANIMATIONTYPE_SIZE:t.value.width-=_.referenceValue.width,t.value.height-=_.referenceValue.height;break;default:t.value-=_.referenceValue}}return m&&o.setKeys(m,!0),o}static TransitionTo(e,t,s,i,r,n,a,o=null){if(a<=0)return s[e]=t,o&&o(),null;const h=r*(a/1e3);n.setKeys([{frame:0,value:s[e].clone?s[e].clone():s[e]},{frame:h,value:t}]),s.animations||(s.animations=[]),s.animations.push(n);const l=i.beginAnimation(s,0,h,!1);return l.onAnimationEnd=o,l}get runtimeAnimations(){return this._runtimeAnimations}get hasRunningRuntimeAnimations(){for(const e of this._runtimeAnimations)if(!e.isStopped())return!0;return!1}constructor(e,t,s,i,r,n){this.name=e,this.targetProperty=t,this.framePerSecond=s,this.dataType=i,this.loopMode=r,this.enableBlending=n,this._easingFunction=null,this._runtimeAnimations=new Array,this._events=new Array,this.blendingSpeed=.01,this._ranges={},this.targetPropertyPath=t.split("."),this.dataType=i,this.loopMode=void 0===r?b.ANIMATIONLOOPMODE_CYCLE:r,this.uniqueId=b._UniqueIdGenerator++}toString(e){let t="Name: "+this.name+", property: "+this.targetProperty;if(t+=", datatype: "+["Float","Vector3","Quaternion","Matrix","Color3","Vector2"][this.dataType],t+=", nKeys: "+(this._keys?this._keys.length:"none"),t+=", nRanges: "+(this._ranges?Object.keys(this._ranges).length:"none"),e){t+=", Ranges: {";let e=!0;for(const s in this._ranges)e&&(t+=", ",e=!1),t+=s;t+="}"}return t}addEvent(e){this._events.push(e),this._events.sort(((e,t)=>e.frame-t.frame))}removeEvents(e){for(let t=0;t=0;s--)this._keys[s].frame>=e&&this._keys[s].frame<=t&&this._keys.splice(s,1)}this._ranges[e]=null}}getRange(e){return this._ranges[e]}getKeys(){return this._keys}getHighestFrame(){let e=0;for(let t=0,s=this._keys.length;t0)return t.highLimitValue.clone?t.highLimitValue.clone():t.highLimitValue;const i=this._keys,r=i.length;let n=t.key;for(;n>=0&&e=i[n+1].frame;)++n;if(t.key=n,n<0)return s?void 0:this._getKeyValue(i[0].value);if(n+1>r-1)return s?void 0:this._getKeyValue(i[r-1].value);const a=i[n],o=i[n+1];if(s&&(e===a.frame||e===o.frame))return;const h=this._getKeyValue(a.value),l=this._getKeyValue(o.value);if(1===a.interpolation)return o.frame>e?h:l;const c=void 0!==a.outTangent&&void 0!==o.inTangent,u=o.frame-a.frame;let T=(e-a.frame)/u;const E=a.easingFunction||this.getEasingFunction();switch(null!==E&&(T=E.ease(T)),this.dataType){case b.ANIMATIONTYPE_FLOAT:{const e=c?this.floatInterpolateFunctionWithTangents(h,a.outTangent*u,l,o.inTangent*u,T):this.floatInterpolateFunction(h,l,T);switch(t.loopMode){case b.ANIMATIONLOOPMODE_CYCLE:case b.ANIMATIONLOOPMODE_CONSTANT:case b.ANIMATIONLOOPMODE_YOYO:return e;case b.ANIMATIONLOOPMODE_RELATIVE:case b.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return(t.offsetValue??0)*t.repeatCount+e}break}case b.ANIMATIONTYPE_QUATERNION:{const e=c?this.quaternionInterpolateFunctionWithTangents(h,a.outTangent.scale(u),l,o.inTangent.scale(u),T):this.quaternionInterpolateFunction(h,l,T);switch(t.loopMode){case b.ANIMATIONLOOPMODE_CYCLE:case b.ANIMATIONLOOPMODE_CONSTANT:case b.ANIMATIONLOOPMODE_YOYO:return e;case b.ANIMATIONLOOPMODE_RELATIVE:case b.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return e.addInPlace((t.offsetValue||d).scale(t.repeatCount))}return e}case b.ANIMATIONTYPE_VECTOR3:{const e=c?this.vector3InterpolateFunctionWithTangents(h,a.outTangent.scale(u),l,o.inTangent.scale(u),T):this.vector3InterpolateFunction(h,l,T);switch(t.loopMode){case b.ANIMATIONLOOPMODE_CYCLE:case b.ANIMATIONLOOPMODE_CONSTANT:case b.ANIMATIONLOOPMODE_YOYO:return e;case b.ANIMATIONLOOPMODE_RELATIVE:case b.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return e.add((t.offsetValue||_).scale(t.repeatCount))}break}case b.ANIMATIONTYPE_VECTOR2:{const e=c?this.vector2InterpolateFunctionWithTangents(h,a.outTangent.scale(u),l,o.inTangent.scale(u),T):this.vector2InterpolateFunction(h,l,T);switch(t.loopMode){case b.ANIMATIONLOOPMODE_CYCLE:case b.ANIMATIONLOOPMODE_CONSTANT:case b.ANIMATIONLOOPMODE_YOYO:return e;case b.ANIMATIONLOOPMODE_RELATIVE:case b.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return e.add((t.offsetValue||f).scale(t.repeatCount))}break}case b.ANIMATIONTYPE_SIZE:switch(t.loopMode){case b.ANIMATIONLOOPMODE_CYCLE:case b.ANIMATIONLOOPMODE_CONSTANT:case b.ANIMATIONLOOPMODE_YOYO:return this.sizeInterpolateFunction(h,l,T);case b.ANIMATIONLOOPMODE_RELATIVE:case b.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return this.sizeInterpolateFunction(h,l,T).add((t.offsetValue||p).scale(t.repeatCount))}break;case b.ANIMATIONTYPE_COLOR3:{const e=c?this.color3InterpolateFunctionWithTangents(h,a.outTangent.scale(u),l,o.inTangent.scale(u),T):this.color3InterpolateFunction(h,l,T);switch(t.loopMode){case b.ANIMATIONLOOPMODE_CYCLE:case b.ANIMATIONLOOPMODE_CONSTANT:case b.ANIMATIONLOOPMODE_YOYO:return e;case b.ANIMATIONLOOPMODE_RELATIVE:case b.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return e.add((t.offsetValue||g).scale(t.repeatCount))}break}case b.ANIMATIONTYPE_COLOR4:{const e=c?this.color4InterpolateFunctionWithTangents(h,a.outTangent.scale(u),l,o.inTangent.scale(u),T):this.color4InterpolateFunction(h,l,T);switch(t.loopMode){case b.ANIMATIONLOOPMODE_CYCLE:case b.ANIMATIONLOOPMODE_CONSTANT:case b.ANIMATIONLOOPMODE_YOYO:return e;case b.ANIMATIONLOOPMODE_RELATIVE:case b.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return e.add((t.offsetValue||m).scale(t.repeatCount))}break}case b.ANIMATIONTYPE_MATRIX:switch(t.loopMode){case b.ANIMATIONLOOPMODE_CYCLE:case b.ANIMATIONLOOPMODE_CONSTANT:case b.ANIMATIONLOOPMODE_YOYO:return b.AllowMatricesInterpolation?this.matrixInterpolateFunction(h,l,T,t.workValue):h;case b.ANIMATIONLOOPMODE_RELATIVE:case b.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return h}}return 0}matrixInterpolateFunction(e,t,s,r){return b.AllowMatrixDecomposeForInterpolation?r?(i.uq.DecomposeLerpToRef(e,t,s,r),r):i.uq.DecomposeLerp(e,t,s):r?(i.uq.LerpToRef(e,t,s,r),r):i.uq.Lerp(e,t,s)}clone(){const e=new b(this.name,this.targetPropertyPath.join("."),this.framePerSecond,this.dataType,this.loopMode);if(e.enableBlending=this.enableBlending,e.blendingSpeed=this.blendingSpeed,this._keys&&e.setKeys(this._keys),this._ranges){e._ranges={};for(const t in this._ranges){const s=this._ranges[t];s&&(e._ranges[t]=s.clone())}}return e}setKeys(e,t=!1){this._keys=t?e:e.slice(0)}createKeyForFrame(e){T.key=0;const t=this._interpolate(e,T,!0);if(!t)return this._keys[T.key].frame===e?T.key:T.key+1;const s={frame:e,value:t.clone?t.clone():t};return this._keys.splice(T.key+1,0,s),T.key+1}serialize(){const e={};e.name=this.name,e.property=this.targetProperty,e.framePerSecond=this.framePerSecond,e.dataType=this.dataType,e.loopBehavior=this.loopMode,e.enableBlending=this.enableBlending,e.blendingSpeed=this.blendingSpeed;const t=this.dataType;e.keys=[];const s=this.getKeys();for(let i=0;i=2&&(h=t.values[1]),t.values.length>=3&&(l=t.values[2]),t.values.length>=4&&(c=t.values[3]);break;case b.ANIMATIONTYPE_QUATERNION:if(a=i.PT.FromArray(t.values),t.values.length>=8){const e=i.PT.FromArray(t.values.slice(4,8));e.equals(i.PT.Zero())||(h=e)}if(t.values.length>=12){const e=i.PT.FromArray(t.values.slice(8,12));e.equals(i.PT.Zero())||(l=e)}t.values.length>=13&&(c=t.values[12]);break;case b.ANIMATIONTYPE_MATRIX:a=i.uq.FromArray(t.values),t.values.length>=17&&(c=t.values[16]);break;case b.ANIMATIONTYPE_COLOR3:a=r.v9.FromArray(t.values),t.values[3]&&(h=r.v9.FromArray(t.values[3])),t.values[4]&&(l=r.v9.FromArray(t.values[4])),t.values[5]&&(c=t.values[5]);break;case b.ANIMATIONTYPE_COLOR4:a=r.ov.FromArray(t.values),t.values[4]&&(h=r.ov.FromArray(t.values[4])),t.values[5]&&(l=r.ov.FromArray(t.values[5])),t.values[6]&&(c=r.ov.FromArray(t.values[6]));break;case b.ANIMATIONTYPE_VECTOR3:default:a=i.Pq.FromArray(t.values),t.values[3]&&(h=i.Pq.FromArray(t.values[3])),t.values[4]&&(l=i.Pq.FromArray(t.values[4])),t.values[5]&&(c=t.values[5])}const u={};u.frame=t.frame,u.value=a,null!=h&&(u.inTangent=h),null!=l&&(u.outTangent=l),null!=c&&(u.interpolation=c),n.push(u)}if(t.setKeys(n),e.ranges)for(o=0;o{const r=new c.u;r.addEventListener("readystatechange",(()=>{if(4==r.readyState)if(200==r.status){let t=JSON.parse(r.responseText);if(t.animations&&(t=t.animations),t.length){const e=[];for(const s of t)e.push(this.Parse(s));s(e)}else{const i=this.Parse(t);e&&(i.name=e),s(i)}}else i("Unable to load the animation")})),r.open("GET",t),r.send()}))}static ParseFromSnippetAsync(e){return new Promise(((t,s)=>{const i=new c.u;i.addEventListener("readystatechange",(()=>{if(4==i.readyState)if(200==i.status){const s=JSON.parse(JSON.parse(i.responseText).jsonPayload);if(s.animations){const i=JSON.parse(s.animations),r=[];for(const t of i.animations){const s=this.Parse(t);s.snippetId=e,r.push(s)}t(r)}else{const i=JSON.parse(s.animation),r=this.Parse(i);r.snippetId=e,t(r)}}else s("Unable to load the snippet "+e)})),i.open("GET",this.SnippetUrl+"/"+e.replace(/#/g,"/")),i.send()}))}}b._UniqueIdGenerator=0,b.AllowMatricesInterpolation=!1,b.AllowMatrixDecomposeForInterpolation=!0,b.SnippetUrl="https://snippet.babylonjs.com",b.ANIMATIONTYPE_FLOAT=0,b.ANIMATIONTYPE_VECTOR3=1,b.ANIMATIONTYPE_QUATERNION=2,b.ANIMATIONTYPE_MATRIX=3,b.ANIMATIONTYPE_COLOR3=4,b.ANIMATIONTYPE_COLOR4=7,b.ANIMATIONTYPE_VECTOR2=5,b.ANIMATIONTYPE_SIZE=6,b.ANIMATIONLOOPMODE_RELATIVE=0,b.ANIMATIONLOOPMODE_CYCLE=1,b.ANIMATIONLOOPMODE_CONSTANT=2,b.ANIMATIONLOOPMODE_YOYO=4,b.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT=5,b.CreateFromSnippetAsync=b.ParseFromSnippetAsync,(0,a.Y5)("BABYLON.Animation",b),h.b._AnimationRangeFactory=(e,t,s)=>new o.K(e,t,s)},6227:(e,t,s)=>{s.d(t,{K:()=>i});class i{constructor(e,t,s){this.name=e,this.from=t,this.to=s}clone(){return new i(this.name,this.from,this.to)}}},6504:(e,t,s)=>{s.d(t,{$:()=>a});var i=s(9923),r=s(7309),n=s(4870);class a extends n.b{get _matrix(){return this._compose(),this._localMatrix}set _matrix(e){(e.updateFlag!==this._localMatrix.updateFlag||this._needToCompose)&&(this._needToCompose=!1,this._localMatrix.copyFrom(e),this._markAsDirtyAndDecompose())}constructor(e,t,s=null,r=null,n=null,a=null,o=null){super(e,t.getScene(),!1),this.name=e,this.children=[],this.animations=[],this._index=null,this._scalingDeterminant=1,this._needToDecompose=!0,this._needToCompose=!1,this._linkedTransformNode=null,this._waitingTransformNodeId=null,this._skeleton=t,this._localMatrix=r?.clone()??i.uq.Identity(),this._restMatrix=n??this._localMatrix.clone(),this._bindMatrix=a??this._localMatrix.clone(),this._index=o,this._absoluteMatrix=new i.uq,this._absoluteBindMatrix=new i.uq,this._absoluteInverseBindMatrix=new i.uq,this._finalMatrix=new i.uq,t.bones.push(this),this.setParent(s,!1),this._updateAbsoluteBindMatrices()}getClassName(){return"Bone"}getSkeleton(){return this._skeleton}get parent(){return this._parentNode}getParent(){return this.parent}getChildren(){return this.children}getIndex(){return null===this._index?this.getSkeleton().bones.indexOf(this):this._index}set parent(e){this.setParent(e)}setParent(e,t=!0){if(this.parent!==e){if(this.parent){const e=this.parent.children.indexOf(this);-1!==e&&this.parent.children.splice(e,1)}this._parentNode=e,this.parent&&this.parent.children.push(this),t&&this._updateAbsoluteBindMatrices(),this.markAsDirty()}}getLocalMatrix(){return this._compose(),this._localMatrix}getBindMatrix(){return this._bindMatrix}getBaseMatrix(){return this.getBindMatrix()}getRestMatrix(){return this._restMatrix}getRestPose(){return this.getRestMatrix()}setRestMatrix(e){this._restMatrix.copyFrom(e)}setRestPose(e){this.setRestMatrix(e)}getBindPose(){return this.getBindMatrix()}setBindMatrix(e){this.updateMatrix(e)}setBindPose(e){this.setBindMatrix(e)}getFinalMatrix(){return this._finalMatrix}getWorldMatrix(){return this.getFinalMatrix()}returnToRest(){if(this._linkedTransformNode){const e=i.AA.Vector3[0],t=i.AA.Quaternion[0],s=i.AA.Vector3[1];this.getRestMatrix().decompose(e,t,s),this._linkedTransformNode.position.copyFrom(s),this._linkedTransformNode.rotationQuaternion=this._linkedTransformNode.rotationQuaternion??i.PT.Identity(),this._linkedTransformNode.rotationQuaternion.copyFrom(t),this._linkedTransformNode.scaling.copyFrom(e)}else this._matrix=this._restMatrix}getAbsoluteInverseBindMatrix(){return this._absoluteInverseBindMatrix}getInvertedAbsoluteTransform(){return this.getAbsoluteInverseBindMatrix()}getAbsoluteMatrix(){return this._absoluteMatrix}getAbsoluteTransform(){return this._absoluteMatrix}linkTransformNode(e){this._linkedTransformNode&&this._skeleton._numBonesWithLinkedTransformNode--,this._linkedTransformNode=e,this._linkedTransformNode&&this._skeleton._numBonesWithLinkedTransformNode++}getTransformNode(){return this._linkedTransformNode}get position(){return this._decompose(),this._localPosition}set position(e){this._decompose(),this._localPosition.copyFrom(e),this._markAsDirtyAndCompose()}get rotation(){return this.getRotation()}set rotation(e){this.setRotation(e)}get rotationQuaternion(){return this._decompose(),this._localRotation}set rotationQuaternion(e){this.setRotationQuaternion(e)}get scaling(){return this.getScale()}set scaling(e){this.setScale(e)}get animationPropertiesOverride(){return this._skeleton.animationPropertiesOverride}_decompose(){this._needToDecompose&&(this._needToDecompose=!1,this._localScaling||(this._localScaling=i.Pq.Zero(),this._localRotation=i.PT.Zero(),this._localPosition=i.Pq.Zero()),this._localMatrix.decompose(this._localScaling,this._localRotation,this._localPosition))}_compose(){this._needToCompose&&(this._localScaling?(this._needToCompose=!1,i.uq.ComposeToRef(this._localScaling,this._localRotation,this._localPosition,this._localMatrix)):this._needToCompose=!1)}updateMatrix(e,t=!0,s=!0){this._bindMatrix.copyFrom(e),t&&this._updateAbsoluteBindMatrices(),s?this._matrix=e:this.markAsDirty()}_updateAbsoluteBindMatrices(e,t=!0){if(e||(e=this._bindMatrix),this.parent?e.multiplyToRef(this.parent._absoluteBindMatrix,this._absoluteBindMatrix):this._absoluteBindMatrix.copyFrom(e),this._absoluteBindMatrix.invertToRef(this._absoluteInverseBindMatrix),t)for(let e=0;e{s.d(t,{E:()=>_});var i=s(6504),r=s(9848),n=s(9923),a=s(2781);class o extends a.g{constructor(e,t,s,i,r,n=!0,o=!1,h=3,l=0,c,u){super(null,r,!n,o,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,c),this.format=i,this._engine&&(this._engine._caps.textureFloatLinearFiltering||1!==l||(h=1),this._engine._caps.textureHalfFloatLinearFiltering||2!==l||(h=1),this._texture=this._engine.createRawTexture(e,t,s,i,n,o,h,null,l,c??0,u??!1),this.wrapU=a.g.CLAMP_ADDRESSMODE,this.wrapV=a.g.CLAMP_ADDRESSMODE)}update(e){this._getEngine().updateRawTexture(this._texture,e,this._texture.format,this._texture.invertY,null,this._texture.type,this._texture._useSRGBBuffer)}clone(){if(!this._texture)return super.clone();const e=new o(null,this.getSize().width,this.getSize().height,this.format,this.getScene(),this._texture.generateMipMaps,this._invertY,this.samplingMode,this._texture.type,this._texture._creationFlags,this._useSRGBBuffer);return e._texture=this._texture,this._texture.incrementReferences(),e}static CreateLuminanceTexture(e,t,s,i,r=!0,n=!1,a=3){return new o(e,t,s,1,i,r,n,a)}static CreateLuminanceAlphaTexture(e,t,s,i,r=!0,n=!1,a=3){return new o(e,t,s,2,i,r,n,a)}static CreateAlphaTexture(e,t,s,i,r=!0,n=!1,a=3){return new o(e,t,s,0,i,r,n,a)}static CreateRGBTexture(e,t,s,i,r=!0,n=!1,a=3,h=0,l=0,c=!1){return new o(e,t,s,4,i,r,n,a,h,l,c)}static CreateRGBATexture(e,t,s,i,r=!0,n=!1,a=3,h=0,l=0,c=!1){return new o(e,t,s,5,i,r,n,a,h,l,c)}static CreateRGBAStorageTexture(e,t,s,i,r=!0,n=!1,a=3,h=0,l=!1){return new o(e,t,s,5,i,r,n,a,h,1,l)}static CreateRTexture(e,t,s,i,r=!0,n=!1,h=a.g.TRILINEAR_SAMPLINGMODE,l=1){return new o(e,t,s,6,i,r,n,h,l)}static CreateRStorageTexture(e,t,s,i,r=!0,n=!1,h=a.g.TRILINEAR_SAMPLINGMODE,l=1){return new o(e,t,s,6,i,r,n,h,l,1)}}var h=s(7540),l=s(6227),c=s(6315),u=s(1137),d=s(4609);class _{get useTextureToStoreBoneMatrices(){return this._useTextureToStoreBoneMatrices}set useTextureToStoreBoneMatrices(e){this._useTextureToStoreBoneMatrices=e,this._markAsDirty()}get animationPropertiesOverride(){return this._animationPropertiesOverride?this._animationPropertiesOverride:this._scene.animationPropertiesOverride}set animationPropertiesOverride(e){this._animationPropertiesOverride=e}get isUsingTextureForMatrices(){return this.useTextureToStoreBoneMatrices&&this._canUseTextureForBones}get uniqueId(){return this._uniqueId}constructor(e,t,s){this.name=e,this.id=t,this.bones=[],this.needInitialSkinMatrix=!1,this._isDirty=!0,this._meshesWithPoseMatrix=new Array,this._identity=n.uq.Identity(),this._currentRenderId=-1,this._ranges={},this._absoluteTransformIsDirty=!0,this._canUseTextureForBones=!1,this._uniqueId=0,this._numBonesWithLinkedTransformNode=0,this._hasWaitingData=null,this._parentContainer=null,this.doNotSerialize=!1,this._useTextureToStoreBoneMatrices=!0,this._animationPropertiesOverride=null,this.onBeforeComputeObservable=new r.cP,this.bones=[],this._scene=s||c.q.LastCreatedScene,this._uniqueId=this._scene.getUniqueId(),this._scene.addSkeleton(this),this._isDirty=!0;const i=this._scene.getEngine().getCaps();this._canUseTextureForBones=i.textureFloat&&i.maxVertexTextureImageUnits>0}getClassName(){return"Skeleton"}getChildren(){return this.bones.filter((e=>!e.getParent()))}getTransformMatrices(e){if(this.needInitialSkinMatrix){if(!e)throw new Error("getTransformMatrices: When using the needInitialSkinMatrix flag, a mesh must be provided");return e._bonesTransformMatrices||this.prepare(!0),e._bonesTransformMatrices}return this._transformMatrices&&!this._isDirty||this.prepare(!this._transformMatrices),this._transformMatrices}getTransformMatrixTexture(e){return this.needInitialSkinMatrix&&e._transformMatrixTexture?e._transformMatrixTexture:this._transformMatrixTexture}getScene(){return this._scene}toString(e){let t=`Name: ${this.name}, nBones: ${this.bones.length}`;if(t+=`, nAnimationRanges: ${this._ranges?Object.keys(this._ranges).length:"none"}`,e){t+=", Ranges: {";let e=!0;for(const s in this._ranges)e&&(t+=", ",e=!1),t+=s;t+="}"}return t}getBoneIndexByName(e){for(let t=0,s=this.bones.length;t-1&&this._meshesWithPoseMatrix.splice(t,1)}_computeTransformMatrices(e,t){this.onBeforeComputeObservable.notifyObservers(this);for(let s=0;s0)for(const e of this.bones)if(e._linkedTransformNode){const t=e._linkedTransformNode;e.position=t.position,t.rotationQuaternion?e.rotationQuaternion=t.rotationQuaternion:e.rotation=t.rotation,e.scaling=t.scaling}if(this.needInitialSkinMatrix)for(const e of this._meshesWithPoseMatrix){const t=e.getPoseMatrix();let s=this._isDirty;if(e._bonesTransformMatrices&&e._bonesTransformMatrices.length===16*(this.bones.length+1)||(e._bonesTransformMatrices=new Float32Array(16*(this.bones.length+1)),s=!0),s){if(this._synchronizedWithMesh!==e){this._synchronizedWithMesh=e;for(const e of this.bones)e.getParent()||(e.getBindMatrix().multiplyToRef(t,n.AA.Matrix[1]),e._updateAbsoluteBindMatrices(n.AA.Matrix[1]));if(this.isUsingTextureForMatrices){const t=4*(this.bones.length+1);e._transformMatrixTexture&&e._transformMatrixTexture.getSize().width===t||(e._transformMatrixTexture&&e._transformMatrixTexture.dispose(),e._transformMatrixTexture=o.CreateRGBATexture(e._bonesTransformMatrices,4*(this.bones.length+1),1,this._scene,!1,!1,1,1))}}this._computeTransformMatrices(e._bonesTransformMatrices,t),this.isUsingTextureForMatrices&&e._transformMatrixTexture&&e._transformMatrixTexture.update(e._bonesTransformMatrices)}}else{if(!this._isDirty)return;this._transformMatrices&&this._transformMatrices.length===16*(this.bones.length+1)||(this._transformMatrices=new Float32Array(16*(this.bones.length+1)),this.isUsingTextureForMatrices&&(this._transformMatrixTexture&&this._transformMatrixTexture.dispose(),this._transformMatrixTexture=o.CreateRGBATexture(this._transformMatrices,4*(this.bones.length+1),1,this._scene,!1,!1,1,1))),this._computeTransformMatrices(this._transformMatrices,null),this.isUsingTextureForMatrices&&this._transformMatrixTexture&&this._transformMatrixTexture.update(this._transformMatrices)}this._isDirty=!1}getAnimatables(){if(!this._animatables||this._animatables.length!==this.bones.length){this._animatables=[];for(let e=0;e{t.animations.forEach((t=>{t.enableBlending=!0,t.blendingSpeed=e}))}))}dispose(){if(this._meshesWithPoseMatrix.length=0,this.getScene().stopAnimation(this),this.getScene().removeSkeleton(this),this._parentContainer){const e=this._parentContainer.skeletons.indexOf(this);e>-1&&this._parentContainer.skeletons.splice(e,1),this._parentContainer=null}this._transformMatrixTexture&&(this._transformMatrixTexture.dispose(),this._transformMatrixTexture=null)}serialize(){const e={};e.name=this.name,e.id=this.id,this.dimensionsAtRest&&(e.dimensionsAtRest=this.dimensionsAtRest.asArray()),e.bones=[],e.needInitialSkinMatrix=this.needInitialSkinMatrix;for(let t=0;t0&&(r.animation=s.animations[0].serialize()),e.ranges=[];for(const t in this._ranges){const s=this._ranges[t];if(!s)continue;const i={};i.name=t,i.from=s.from,i.to=s.to,e.ranges.push(i)}}return e}static Parse(e,t){const s=new _(e.name,e.id,t);let r;for(e.dimensionsAtRest&&(s.dimensionsAtRest=n.Pq.FromArray(e.dimensionsAtRest)),s.needInitialSkinMatrix=e.needInitialSkinMatrix,r=0;r-1&&(o=s.bones[t.parentBoneIndex]);const l=t.rest?n.uq.FromArray(t.rest):null,c=new i.$(t.name,s,o,n.uq.FromArray(t.matrix),l,null,a);void 0!==t.id&&null!==t.id&&(c.id=t.id),t.length&&(c.length=t.length),t.metadata&&(c.metadata=t.metadata),t.animation&&c.animations.push(h.X5.Parse(t.animation)),void 0!==t.linkedTransformNodeId&&null!==t.linkedTransformNodeId&&(s._hasWaitingData=!0,c._waitingTransformNodeId=t.linkedTransformNodeId)}if(e.ranges)for(r=0;r0&&(e=this._meshesWithPoseMatrix[0].getPoseMatrix()),e}sortBones(){const e=[],t=new Array(this.bones.length);for(let s=0;s{e.setCurrentPoseAsRest()}))}}},5616:(e,t,s)=>{s.d(t,{R:()=>a,h:()=>n});var i=s(1504),r=s(1137);class n{get isDisposed(){return this._isDisposed}constructor(e,t,s,r=0,n=!1,a=!1,o=!1,h,l){this._isAlreadyOwned=!1,this._isDisposed=!1,e&&e.getScene?this._engine=e.getScene().getEngine():this._engine=e,this._updatable=s,this._instanced=a,this._divisor=h||1,this._label=l,t instanceof i.n?(this._data=null,this._buffer=t):(this._data=t,this._buffer=null),this.byteStride=o?r:r*Float32Array.BYTES_PER_ELEMENT,n||this.create()}createVertexBuffer(e,t,s,i,r,n=!1,o){const h=n?t:t*Float32Array.BYTES_PER_ELEMENT,l=i?n?i:i*Float32Array.BYTES_PER_ELEMENT:this.byteStride;return new a(this._engine,this,e,this._updatable,!0,l,void 0===r?this._instanced:r,h,s,void 0,void 0,!0,this._divisor||o)}isUpdatable(){return this._updatable}getData(){return this._data}getBuffer(){return this._buffer}getStrideSize(){return this.byteStride/Float32Array.BYTES_PER_ELEMENT}create(e=null){!e&&this._buffer||(e=e||this._data)&&(this._buffer?this._updatable&&(this._engine.updateDynamicVertexBuffer(this._buffer,e),this._data=e):this._updatable?(this._buffer=this._engine.createDynamicVertexBuffer(e,this._label),this._data=e):this._buffer=this._engine.createVertexBuffer(e,void 0,this._label))}_rebuild(){if(this._data)this._buffer=null,this.create(this._data);else{if(!this._buffer)return;if(this._buffer.capacity>0)return void(this._updatable?this._buffer=this._engine.createDynamicVertexBuffer(this._buffer.capacity,this._label):this._buffer=this._engine.createVertexBuffer(this._buffer.capacity,void 0,this._label));r.V.Warn(`Missing data for buffer "${this._label}" ${this._buffer?"(uniqueId: "+this._buffer.uniqueId+")":""}. Buffer reconstruction failed.`),this._buffer=null}}update(e){this.create(e)}updateDirectly(e,t,s,i=!1){this._buffer&&this._updatable&&(this._engine.updateDynamicVertexBuffer(this._buffer,e,i?t:t*Float32Array.BYTES_PER_ELEMENT,s?s*this.byteStride:void 0),this._data=0===t&&void 0===s?e:null)}_increaseReferences(){this._buffer&&(this._isAlreadyOwned?this._buffer.references++:this._isAlreadyOwned=!0)}dispose(){this._buffer&&this._engine._releaseBuffer(this._buffer)&&(this._isDisposed=!0,this._data=null,this._buffer=null)}}class a{get isDisposed(){return this._isDisposed}get instanceDivisor(){return this._instanceDivisor}set instanceDivisor(e){const t=0!=e;this._instanceDivisor=e,t!==this._instanced&&(this._instanced=t,this._computeHashCode())}get _maxVerticesCount(){const e=this.getData();return e?Array.isArray(e)?e.length/(this.byteStride/4)-this.byteOffset/4:(e.byteLength-this.byteOffset)/this.byteStride:0}constructor(e,t,s,i,r,o,h,l,c,u,d=!1,_=!1,f=1,p=!1){this._isDisposed=!1;let g=!1;if(this.engine=e,"object"==typeof i&&null!==i?(g=i.updatable??!1,r=i.postponeInternalCreation,o=i.stride,h=i.instanced,l=i.offset,c=i.size,u=i.type,d=i.normalized??!1,_=i.useBytes??!1,f=i.divisor??1,p=i.takeBufferOwnership??!1,this._label=i.label):g=!!i,t instanceof n?(this._buffer=t,this._ownsBuffer=p):(this._buffer=new n(e,t,g,o,r,h,_,f,this._label),this._ownsBuffer=!0),this.uniqueId=a._Counter++,this._kind=s,void 0===u){const e=this.getData();this.type=e?a.GetDataType(e):a.FLOAT}else this.type=u;const m=a.GetTypeByteLength(this.type);_?(this._size=c||(o?o/m:a.DeduceStride(s)),this.byteStride=o||this._buffer.byteStride||this._size*m,this.byteOffset=l||0):(this._size=c||o||a.DeduceStride(s),this.byteStride=o?o*m:this._buffer.byteStride||this._size*m,this.byteOffset=(l||0)*m),this.normalized=d,this._instanced=void 0!==h&&h,this._instanceDivisor=h?f:0,this._alignBuffer(),this._computeHashCode()}_computeHashCode(){this.hashCode=(this.type-5120<<0)+((this.normalized?1:0)<<3)+(this._size<<4)+((this._instanced?1:0)<<6)+(this.byteStride<<12)}_rebuild(){this._buffer?._rebuild()}getKind(){return this._kind}isUpdatable(){return this._buffer.isUpdatable()}getData(){return this._buffer.getData()}getFloatData(e,t){const s=this.getData();return s?a.GetFloatData(s,this._size,this.type,this.byteOffset,this.byteStride,this.normalized,e,t):null}getBuffer(){return this._buffer.getBuffer()}getWrapperBuffer(){return this._buffer}getStrideSize(){return this.byteStride/a.GetTypeByteLength(this.type)}getOffset(){return this.byteOffset/a.GetTypeByteLength(this.type)}getSize(e=!1){return e?this._size*a.GetTypeByteLength(this.type):this._size}getIsInstanced(){return this._instanced}getInstanceDivisor(){return this._instanceDivisor}create(e){this._buffer.create(e),this._alignBuffer()}update(e){this._buffer.update(e),this._alignBuffer()}updateDirectly(e,t,s=!1){this._buffer.updateDirectly(e,t,void 0,s),this._alignBuffer()}dispose(){this._ownsBuffer&&this._buffer.dispose(),this._isDisposed=!0}forEach(e,t){a.ForEach(this._buffer.getData(),this.byteOffset,this.byteStride,this._size,this.type,e,this.normalized,t)}_alignBuffer(){}static DeduceStride(e){switch(e){case a.UVKind:case a.UV2Kind:case a.UV3Kind:case a.UV4Kind:case a.UV5Kind:case a.UV6Kind:return 2;case a.NormalKind:case a.PositionKind:return 3;case a.ColorKind:case a.ColorInstanceKind:case a.MatricesIndicesKind:case a.MatricesIndicesExtraKind:case a.MatricesWeightsKind:case a.MatricesWeightsExtraKind:case a.TangentKind:return 4;default:throw new Error("Invalid kind '"+e+"'")}}static GetDataType(e){return e instanceof Int8Array?a.BYTE:e instanceof Uint8Array?a.UNSIGNED_BYTE:e instanceof Int16Array?a.SHORT:e instanceof Uint16Array?a.UNSIGNED_SHORT:e instanceof Int32Array?a.INT:e instanceof Uint32Array?a.UNSIGNED_INT:a.FLOAT}static GetTypeByteLength(e){switch(e){case a.BYTE:case a.UNSIGNED_BYTE:return 1;case a.SHORT:case a.UNSIGNED_SHORT:return 2;case a.INT:case a.UNSIGNED_INT:case a.FLOAT:return 4;default:throw new Error(`Invalid type '${e}'`)}}static ForEach(e,t,s,i,r,n,o,h){if(e instanceof Array){let r=t/4;const a=s/4;for(let t=0;tr[t]=e)),r}if(!(e instanceof Array||e instanceof Float32Array)||0!==i||e.length!==u){if(e instanceof Array){const t=i/4;return e.slice(t,t+u)}if(e instanceof ArrayBuffer)return new Float32Array(e,i,u);{const t=e.byteOffset+i;if(0!=(3&t)&&(r.V.Warn("Float array must be aligned to 4-bytes border"),l=!0),l){const s=new Uint8Array(u*Float32Array.BYTES_PER_ELEMENT),i=new Uint8Array(e.buffer,t,s.length);return s.set(i),new Float32Array(s.buffer)}return new Float32Array(e.buffer,t,u)}}return l?e.slice():e}}a._Counter=0,a.BYTE=5120,a.UNSIGNED_BYTE=5121,a.SHORT=5122,a.UNSIGNED_SHORT=5123,a.INT=5124,a.UNSIGNED_INT=5125,a.FLOAT=5126,a.PositionKind="position",a.NormalKind="normal",a.TangentKind="tangent",a.UVKind="uv",a.UV2Kind="uv2",a.UV3Kind="uv3",a.UV4Kind="uv4",a.UV5Kind="uv5",a.UV6Kind="uv6",a.ColorKind="color",a.ColorInstanceKind="instanceColor",a.MatricesIndicesKind="matricesIndices",a.MatricesWeightsKind="matricesWeights",a.MatricesIndicesExtraKind="matricesIndicesExtra",a.MatricesWeightsExtraKind="matricesWeightsExtra"},1504:(e,t,s)=>{s.d(t,{n:()=>i});class i{get underlyingResource(){return null}constructor(){this.references=0,this.capacity=0,this.is32Bits=!1,this.uniqueId=i._Counter++}}i._Counter=0},9057:(e,t,s)=>{s.d(t,{L:()=>L});var i=s(5524),r=s(9259),n=s(9848),a=s(9923),o=s(4867),h=s(4870),l=s(5530),c=s(6240),u=s(6237),d=s(5559);class _{constructor(){this._zoomStopsAnimation=!1,this._idleRotationSpeed=.05,this._idleRotationWaitTime=2e3,this._idleRotationSpinupTime=2e3,this.targetAlpha=null,this._isPointerDown=!1,this._lastFrameTime=null,this._lastInteractionTime=-1/0,this._cameraRotationSpeed=0,this._lastFrameRadius=0}get name(){return"AutoRotation"}set zoomStopsAnimation(e){this._zoomStopsAnimation=e}get zoomStopsAnimation(){return this._zoomStopsAnimation}set idleRotationSpeed(e){this._idleRotationSpeed=e}get idleRotationSpeed(){return this._idleRotationSpeed}set idleRotationWaitTime(e){this._idleRotationWaitTime=e}get idleRotationWaitTime(){return this._idleRotationWaitTime}set idleRotationSpinupTime(e){this._idleRotationSpinupTime=e}get idleRotationSpinupTime(){return this._idleRotationSpinupTime}get rotationInProgress(){return Math.abs(this._cameraRotationSpeed)>0}init(){}attach(e){this._attachedCamera=e;const t=this._attachedCamera.getScene();this._onPrePointerObservableObserver=t.onPrePointerObservable.add((e=>{e.type!==c.Zp.POINTERDOWN?e.type===c.Zp.POINTERUP&&(this._isPointerDown=!1):this._isPointerDown=!0})),this._onAfterCheckInputsObserver=e.onAfterCheckInputsObservable.add((()=>{if(this._reachTargetAlpha())return;const e=u.j.Now;let t=0;null!=this._lastFrameTime&&(t=e-this._lastFrameTime),this._lastFrameTime=e,this._applyUserInteraction();const s=e-this._lastInteractionTime-this._idleRotationWaitTime,i=Math.max(Math.min(s/this._idleRotationSpinupTime,1),0);this._cameraRotationSpeed=this._idleRotationSpeed*i,this._attachedCamera&&(this._attachedCamera.alpha-=this._cameraRotationSpeed*(t/1e3))}))}detach(){if(!this._attachedCamera)return;const e=this._attachedCamera.getScene();this._onPrePointerObservableObserver&&e.onPrePointerObservable.remove(this._onPrePointerObservableObserver),this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),this._attachedCamera=null,this._lastFrameTime=null}resetLastInteractionTime(e){this._lastInteractionTime=e??u.j.Now}_reachTargetAlpha(){return!(!this._attachedCamera||!this.targetAlpha)&&Math.abs(this._attachedCamera.alpha-this.targetAlpha)=.5?.5*(1-this.easeInCore(2*(1-e)))+.5:.5*this.easeInCore(2*e)}}f.EASINGMODE_EASEIN=0,f.EASINGMODE_EASEOUT=1,f.EASINGMODE_EASEINOUT=2;var p=s(7540);class g{constructor(){this.transitionDuration=450,this.lowerRadiusTransitionRange=2,this.upperRadiusTransitionRange=-2,this._autoTransitionRange=!1,this._radiusIsAnimating=!1,this._radiusBounceTransition=null,this._animatables=new Array}get name(){return"Bouncing"}get autoTransitionRange(){return this._autoTransitionRange}set autoTransitionRange(e){if(this._autoTransitionRange===e)return;this._autoTransitionRange=e;const t=this._attachedCamera;t&&(e?this._onMeshTargetChangedObserver=t.onMeshTargetChangedObservable.add((e=>{if(e&&(e.computeWorldMatrix(!0),e.getBoundingInfo)){const t=e.getBoundingInfo().diagonalLength;this.lowerRadiusTransitionRange=.05*t,this.upperRadiusTransitionRange=.05*t}})):this._onMeshTargetChangedObserver&&t.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver))}init(){}attach(e){this._attachedCamera=e,this._onAfterCheckInputsObserver=e.onAfterCheckInputsObservable.add((()=>{this._attachedCamera&&(this._isRadiusAtLimit(this._attachedCamera.lowerRadiusLimit)&&this._applyBoundRadiusAnimation(this.lowerRadiusTransitionRange),this._isRadiusAtLimit(this._attachedCamera.upperRadiusLimit)&&this._applyBoundRadiusAnimation(this.upperRadiusTransitionRange))}))}detach(){this._attachedCamera&&(this._onAfterCheckInputsObserver&&this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),this._onMeshTargetChangedObserver&&this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver),this._attachedCamera=null)}_isRadiusAtLimit(e){return!!this._attachedCamera&&this._attachedCamera.radius===e&&!this._radiusIsAnimating}_applyBoundRadiusAnimation(e){if(!this._attachedCamera)return;this._radiusBounceTransition||(g.EasingFunction.setEasingMode(g.EasingMode),this._radiusBounceTransition=p.X5.CreateAnimation("radius",p.X5.ANIMATIONTYPE_FLOAT,60,g.EasingFunction)),this._cachedWheelPrecision=this._attachedCamera.wheelPrecision,this._attachedCamera.wheelPrecision=1/0,this._attachedCamera.inertialRadiusOffset=0,this.stopAllAnimations(),this._radiusIsAnimating=!0;const t=p.X5.TransitionTo("radius",this._attachedCamera.radius+e,this._attachedCamera,this._attachedCamera.getScene(),60,this._radiusBounceTransition,this.transitionDuration,(()=>this._clearAnimationLocks()));t&&this._animatables.push(t)}_clearAnimationLocks(){this._radiusIsAnimating=!1,this._attachedCamera&&(this._attachedCamera.wheelPrecision=this._cachedWheelPrecision)}stopAllAnimations(){for(this._attachedCamera&&(this._attachedCamera.animations=[]);this._animatables.length;)this._animatables[0].onAnimationEnd=null,this._animatables[0].stop(),this._animatables.shift()}}g.EasingFunction=new class extends f{constructor(e=1){super(),this.amplitude=e}easeInCore(e){const t=Math.max(0,this.amplitude);return Math.pow(e,3)-e*t*Math.sin(3.141592653589793*e)}}(.3),g.EasingMode=f.EASINGMODE_EASEOUT;class m{constructor(){this.onTargetFramingAnimationEndObservable=new n.cP,this._mode=m.FitFrustumSidesMode,this._radiusScale=1,this._positionScale=.5,this._defaultElevation=.3,this._elevationReturnTime=1500,this._elevationReturnWaitTime=1e3,this._zoomStopsAnimation=!1,this._framingTime=1500,this.autoCorrectCameraLimitsAndSensibility=!0,this._isPointerDown=!1,this._lastInteractionTime=-1/0,this._animatables=new Array,this._betaIsAnimating=!1}get name(){return"Framing"}set mode(e){this._mode=e}get mode(){return this._mode}set radiusScale(e){this._radiusScale=e}get radiusScale(){return this._radiusScale}set positionScale(e){this._positionScale=e}get positionScale(){return this._positionScale}set defaultElevation(e){this._defaultElevation=e}get defaultElevation(){return this._defaultElevation}set elevationReturnTime(e){this._elevationReturnTime=e}get elevationReturnTime(){return this._elevationReturnTime}set elevationReturnWaitTime(e){this._elevationReturnWaitTime=e}get elevationReturnWaitTime(){return this._elevationReturnWaitTime}set zoomStopsAnimation(e){this._zoomStopsAnimation=e}get zoomStopsAnimation(){return this._zoomStopsAnimation}set framingTime(e){this._framingTime=e}get framingTime(){return this._framingTime}init(){}attach(e){this._attachedCamera=e;const t=this._attachedCamera.getScene();m.EasingFunction.setEasingMode(m.EasingMode),this._onPrePointerObservableObserver=t.onPrePointerObservable.add((e=>{e.type!==c.Zp.POINTERDOWN?e.type===c.Zp.POINTERUP&&(this._isPointerDown=!1):this._isPointerDown=!0})),this._onMeshTargetChangedObserver=e.onMeshTargetChangedObservable.add((e=>{e&&e.getBoundingInfo&&this.zoomOnMesh(e,void 0,(()=>{this.onTargetFramingAnimationEndObservable.notifyObservers()}))})),this._onAfterCheckInputsObserver=e.onAfterCheckInputsObservable.add((()=>{this._applyUserInteraction(),this._maintainCameraAboveGround()}))}detach(){if(!this._attachedCamera)return;const e=this._attachedCamera.getScene();this._onPrePointerObservableObserver&&e.onPrePointerObservable.remove(this._onPrePointerObservableObserver),this._onAfterCheckInputsObserver&&this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),this._onMeshTargetChangedObserver&&this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver),this._attachedCamera=null}zoomOnMesh(e,t=!1,s=null){e.computeWorldMatrix(!0);const i=e.getBoundingInfo().boundingBox;this.zoomOnBoundingInfo(i.minimumWorld,i.maximumWorld,t,s)}zoomOnMeshHierarchy(e,t=!1,s=null){e.computeWorldMatrix(!0);const i=e.getHierarchyBoundingVectors(!0);this.zoomOnBoundingInfo(i.min,i.max,t,s)}zoomOnMeshesHierarchy(e,t=!1,s=null){const i=new a.Pq(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),r=new a.Pq(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);for(let t=0;t{this.stopAllAnimations(),i&&i(),this._attachedCamera&&this._attachedCamera.useInputToRestoreState&&this._attachedCamera.storeState()})),l&&this._animatables.push(l),!0}_calculateLowerRadiusFromModelBoundingSphere(e,t){const s=this._attachedCamera;if(!s)return 0;let i=s._calculateLowerRadiusFromModelBoundingSphere(e,t,this._radiusScale);return s.lowerRadiusLimit&&this._mode===m.IgnoreBoundsSizeMode&&(i=is.upperRadiusLimit?s.upperRadiusLimit:i),i}_maintainCameraAboveGround(){if(this._elevationReturnTime<0)return;const e=u.j.Now-this._lastInteractionTime,t=.5*Math.PI-this._defaultElevation,s=.5*Math.PI;if(this._attachedCamera&&!this._betaIsAnimating&&this._attachedCamera.beta>s&&e>=this._elevationReturnWaitTime){this._betaIsAnimating=!0,this.stopAllAnimations(),this._betaTransition||(this._betaTransition=p.X5.CreateAnimation("beta",p.X5.ANIMATIONTYPE_FLOAT,60,m.EasingFunction));const e=p.X5.TransitionTo("beta",t,this._attachedCamera,this._attachedCamera.getScene(),60,this._betaTransition,this._elevationReturnTime,(()=>{this._clearAnimationLocks(),this.stopAllAnimations()}));e&&this._animatables.push(e)}}_clearAnimationLocks(){this._betaIsAnimating=!1}_applyUserInteraction(){this.isUserIsMoving&&(this._lastInteractionTime=u.j.Now,this.stopAllAnimations(),this._clearAnimationLocks())}stopAllAnimations(){for(this._attachedCamera&&(this._attachedCamera.animations=[]);this._animatables.length;)this._animatables[0]&&(this._animatables[0].onAnimationEnd=null,this._animatables[0].stop()),this._animatables.shift()}get isUserIsMoving(){return!!this._attachedCamera&&(0!==this._attachedCamera.inertialAlphaOffset||0!==this._attachedCamera.inertialBetaOffset||0!==this._attachedCamera.inertialRadiusOffset||0!==this._attachedCamera.inertialPanningX||0!==this._attachedCamera.inertialPanningY||this._isPointerDown)}}m.EasingFunction=new class extends f{constructor(e=2){super(),this.exponent=e}easeInCore(e){return this.exponent<=0?e:(Math.exp(this.exponent*e)-1)/(Math.exp(this.exponent)-1)}},m.EasingMode=f.EASINGMODE_EASEINOUT,m.IgnoreBoundsSizeMode=0,m.FitFrustumSidesMode=1;var T=s(388),b=s(8733);h.b.AddNodeConstructor("TargetCamera",((e,t)=>()=>new E(e,a.Pq.Zero(),t)));class E extends T.i{constructor(e,t,s,i=!0){super(e,t,s,i),this._tmpUpVector=a.Pq.Zero(),this._tmpTargetVector=a.Pq.Zero(),this.cameraDirection=new a.Pq(0,0,0),this.cameraRotation=new a.I9(0,0),this.ignoreParentScaling=!1,this.updateUpVectorFromRotation=!1,this._tmpQuaternion=new a.PT,this.rotation=new a.Pq(0,0,0),this.speed=2,this.noRotationConstraint=!1,this.invertRotation=!1,this.inverseRotationSpeed=.2,this.lockedTarget=null,this._currentTarget=a.Pq.Zero(),this._initialFocalDistance=1,this._viewMatrix=a.uq.Zero(),this._camMatrix=a.uq.Zero(),this._cameraTransformMatrix=a.uq.Zero(),this._cameraRotationMatrix=a.uq.Zero(),this._referencePoint=new a.Pq(0,0,1),this._transformedReferencePoint=a.Pq.Zero(),this._deferredPositionUpdate=new a.Pq,this._deferredRotationQuaternionUpdate=new a.PT,this._deferredRotationUpdate=new a.Pq,this._deferredUpdated=!1,this._deferOnly=!1,this._defaultUp=a.Pq.Up(),this._cachedRotationZ=0,this._cachedQuaternionRotationZ=0}getFrontPosition(e){this.getWorldMatrix();const t=this.getTarget().subtract(this.position);return t.normalize(),t.scaleInPlace(e),this.globalPosition.add(t)}_getLockedTargetPosition(){if(!this.lockedTarget)return null;if(this.lockedTarget.absolutePosition){const e=this.lockedTarget;e.computeWorldMatrix().getTranslationToRef(e.absolutePosition)}return this.lockedTarget.absolutePosition||this.lockedTarget}storeState(){return this._storedPosition=this.position.clone(),this._storedRotation=this.rotation.clone(),this.rotationQuaternion&&(this._storedRotationQuaternion=this.rotationQuaternion.clone()),super.storeState()}_restoreStateValues(){return!!super._restoreStateValues()&&(this.position=this._storedPosition.clone(),this.rotation=this._storedRotation.clone(),this.rotationQuaternion&&(this.rotationQuaternion=this._storedRotationQuaternion.clone()),this.cameraDirection.copyFromFloats(0,0,0),this.cameraRotation.copyFromFloats(0,0),!0)}_initCache(){super._initCache(),this._cache.lockedTarget=new a.Pq(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.rotation=new a.Pq(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.rotationQuaternion=new a.PT(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)}_updateCache(e){e||super._updateCache();const t=this._getLockedTargetPosition();t?this._cache.lockedTarget?this._cache.lockedTarget.copyFrom(t):this._cache.lockedTarget=t.clone():this._cache.lockedTarget=null,this._cache.rotation.copyFrom(this.rotation),this.rotationQuaternion&&this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion)}_isSynchronizedViewMatrix(){if(!super._isSynchronizedViewMatrix())return!1;const e=this._getLockedTargetPosition();return(this._cache.lockedTarget?this._cache.lockedTarget.equals(e):!e)&&(this.rotationQuaternion?this.rotationQuaternion.equals(this._cache.rotationQuaternion):this._cache.rotation.equals(this.rotation))}_computeLocalCameraSpeed(){const e=this.getEngine();return this.speed*Math.sqrt(e.getDeltaTime()/(100*e.getFps()))}setTarget(e){this.upVector.normalize(),this._initialFocalDistance=e.subtract(this.position).length(),this.position.z===e.z&&(this.position.z+=d.bH),this._referencePoint.normalize().scaleInPlace(this._initialFocalDistance),a.uq.LookAtLHToRef(this.position,e,this._defaultUp,this._camMatrix),this._camMatrix.invert(),this.rotation.x=Math.atan(this._camMatrix.m[6]/this._camMatrix.m[10]);const t=e.subtract(this.position);t.x>=0?this.rotation.y=-Math.atan(t.z/t.x)+Math.PI/2:this.rotation.y=-Math.atan(t.z/t.x)-Math.PI/2,this.rotation.z=0,isNaN(this.rotation.x)&&(this.rotation.x=0),isNaN(this.rotation.y)&&(this.rotation.y=0),isNaN(this.rotation.z)&&(this.rotation.z=0),this.rotationQuaternion&&a.PT.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this.rotationQuaternion)}get target(){return this.getTarget()}set target(e){this.setTarget(e)}getTarget(){return this._currentTarget}_decideIfNeedsToMove(){return Math.abs(this.cameraDirection.x)>0||Math.abs(this.cameraDirection.y)>0||Math.abs(this.cameraDirection.z)>0}_updatePosition(){if(this.parent)return this.parent.getWorldMatrix().invertToRef(a.AA.Matrix[0]),a.Pq.TransformNormalToRef(this.cameraDirection,a.AA.Matrix[0],a.AA.Vector3[0]),this._deferredPositionUpdate.addInPlace(a.AA.Vector3[0]),void(this._deferOnly?this._deferredUpdated=!0:this.position.copyFrom(this._deferredPositionUpdate));this._deferredPositionUpdate.addInPlace(this.cameraDirection),this._deferOnly?this._deferredUpdated=!0:this.position.copyFrom(this._deferredPositionUpdate)}_checkInputs(){const e=this.invertRotation?-this.inverseRotationSpeed:1,t=this._decideIfNeedsToMove(),s=this.cameraRotation.x||this.cameraRotation.y;if(this._deferredUpdated=!1,this._deferredRotationUpdate.copyFrom(this.rotation),this._deferredPositionUpdate.copyFrom(this.position),this.rotationQuaternion&&this._deferredRotationQuaternionUpdate.copyFrom(this.rotationQuaternion),t&&this._updatePosition(),s){if(this.rotationQuaternion&&this.rotationQuaternion.toEulerAnglesToRef(this._deferredRotationUpdate),this._deferredRotationUpdate.x+=this.cameraRotation.x*e,this._deferredRotationUpdate.y+=this.cameraRotation.y*e,!this.noRotationConstraint){const e=1.570796;this._deferredRotationUpdate.x>e&&(this._deferredRotationUpdate.x=e),this._deferredRotationUpdate.x<-e&&(this._deferredRotationUpdate.x=-e)}this._deferOnly?this._deferredUpdated=!0:this.rotation.copyFrom(this._deferredRotationUpdate),this.rotationQuaternion&&this._deferredRotationUpdate.lengthSquared()&&(a.PT.RotationYawPitchRollToRef(this._deferredRotationUpdate.y,this._deferredRotationUpdate.x,this._deferredRotationUpdate.z,this._deferredRotationQuaternionUpdate),this._deferOnly?this._deferredUpdated=!0:this.rotationQuaternion.copyFrom(this._deferredRotationQuaternionUpdate))}t&&(Math.abs(this.cameraDirection.x){}}add(e){const t=e.getSimpleName();this.attached[t]?x.V.Warn("camera input of type "+t+" already exists on camera"):(this.attached[t]=e,e.camera=this.camera,e.checkInputs&&(this.checkInputs=this._addCheckInputs(e.checkInputs.bind(e))),this.attachedToElement&&e.attachControl(this.noPreventDefault))}remove(e){for(const t in this.attached){const s=this.attached[t];if(s===e)return s.detachControl(),s.camera=null,delete this.attached[t],void this.rebuildInputCheck()}}removeByType(e){for(const t in this.attached){const s=this.attached[t];s.getClassName()===e&&(s.detachControl(),s.camera=null,delete this.attached[t],this.rebuildInputCheck())}}_addCheckInputs(e){const t=this.checkInputs;return()=>{t(),e()}}attachInput(e){this.attachedToElement&&e.attachControl(this.noPreventDefault)}attachElement(e=!1){if(!this.attachedToElement){e=!T.i.ForceAttachControlToAlwaysPreventDefault&&e,this.attachedToElement=!0,this.noPreventDefault=e;for(const t in this.attached)this.attached[t].attachControl(e)}}detachElement(e=!1){for(const t in this.attached)this.attached[t].detachControl(),e&&(this.attached[t].camera=null);this.attachedToElement=!1}rebuildInputCheck(){this.checkInputs=()=>{};for(const e in this.attached){const t=this.attached[e];t.checkInputs&&(this.checkInputs=this._addCheckInputs(t.checkInputs.bind(t)))}}clear(){this.attachedToElement&&this.detachElement(!0),this.attached={},this.attachedToElement=!1,this.checkInputs=()=>{}}serialize(e){const t={};for(const e in this.attached){const s=this.attached[e],i=A.p.Serialize(s);t[s.getClassName()]=i}e.inputsmgr=t}parse(e){const t=e.inputsmgr;if(t){this.clear();for(const e in t){const s=R[e];if(s){const i=t[e],r=A.p.Parse((()=>new s),i,null);this.add(r)}}}else for(const t in this.attached){const s=R[this.attached[t].getClassName()];if(s){const i=A.p.Parse((()=>new s),e,null);this.remove(this.attached[t]),this.add(i)}}}}var y=s(998);class P{constructor(){this._currentActiveButton=-1,this.buttons=[0,1,2]}attachControl(e){e=y.S0.BackCompatCameraNoPreventDefault(arguments);const t=this.camera.getEngine(),s=t.getInputElement();let i=0,r=null;this._pointA=null,this._pointB=null,this._altKey=!1,this._ctrlKey=!1,this._metaKey=!1,this._shiftKey=!1,this._buttonsPressed=0,this._pointerInput=n=>{const a=n.event,o="touch"===a.pointerType;if(n.type!==c.Zp.POINTERMOVE&&-1===this.buttons.indexOf(a.button))return;const h=a.target;if(this._altKey=a.altKey,this._ctrlKey=a.ctrlKey,this._metaKey=a.metaKey,this._shiftKey=a.shiftKey,this._buttonsPressed=a.buttons,t.isPointerLock){const e=a.movementX,t=a.movementY;this.onTouch(null,e,t),this._pointA=null,this._pointB=null}else{if(n.type!==c.Zp.POINTERDOWN&&n.type!==c.Zp.POINTERDOUBLETAP&&o&&this._pointA?.pointerId!==a.pointerId&&this._pointB?.pointerId!==a.pointerId)return;if(n.type!==c.Zp.POINTERDOWN||-1!==this._currentActiveButton&&!o)if(n.type===c.Zp.POINTERDOUBLETAP)this.onDoubleTap(a.pointerType);else if(n.type!==c.Zp.POINTERUP||this._currentActiveButton!==a.button&&!o){if(n.type===c.Zp.POINTERMOVE)if(e||a.preventDefault(),this._pointA&&null===this._pointB){const e=a.clientX-this._pointA.x,t=a.clientY-this._pointA.y;this._pointA.x=a.clientX,this._pointA.y=a.clientY,this.onTouch(this._pointA,e,t)}else if(this._pointA&&this._pointB){const e=this._pointA.pointerId===a.pointerId?this._pointA:this._pointB;e.x=a.clientX,e.y=a.clientY;const t=this._pointA.x-this._pointB.x,s=this._pointA.y-this._pointB.y,o=t*t+s*s,h={x:(this._pointA.x+this._pointB.x)/2,y:(this._pointA.y+this._pointB.y)/2,pointerId:a.pointerId,type:n.type};this.onMultiTouch(this._pointA,this._pointB,i,o,r,h),r=h,i=o}}else{try{h?.releasePointerCapture(a.pointerId)}catch(e){}o||(this._pointB=null),t._badOS?this._pointA=this._pointB=null:this._pointB&&this._pointA&&this._pointA.pointerId==a.pointerId?(this._pointA=this._pointB,this._pointB=null):this._pointA&&this._pointB&&this._pointB.pointerId==a.pointerId?this._pointB=null:this._pointA=this._pointB=null,(0!==i||r)&&(this.onMultiTouch(this._pointA,this._pointB,i,0,r,null),i=0,r=null),this._currentActiveButton=-1,this.onButtonUp(a),e||a.preventDefault()}else{try{h?.setPointerCapture(a.pointerId)}catch(e){}if(null===this._pointA)this._pointA={x:a.clientX,y:a.clientY,pointerId:a.pointerId,type:a.pointerType};else{if(null!==this._pointB)return;this._pointB={x:a.clientX,y:a.clientY,pointerId:a.pointerId,type:a.pointerType}}-1!==this._currentActiveButton||o||(this._currentActiveButton=a.button),this.onButtonDown(a),e||(a.preventDefault(),s&&s.focus())}}},this._observer=this.camera.getScene()._inputManager._addCameraPointerObserver(this._pointerInput,c.Zp.POINTERDOWN|c.Zp.POINTERUP|c.Zp.POINTERMOVE|c.Zp.POINTERDOUBLETAP),this._onLostFocus=()=>{this._pointA=this._pointB=null,i=0,r=null,this.onLostFocus()},this._contextMenuBind=e=>this.onContextMenu(e),s&&s.addEventListener("contextmenu",this._contextMenuBind,!1);const n=this.camera.getScene().getEngine().getHostWindow();n&&y.S0.RegisterTopRootEvents(n,[{name:"blur",handler:this._onLostFocus}])}detachControl(){if(this._onLostFocus){const e=this.camera.getScene().getEngine().getHostWindow();e&&y.S0.UnregisterTopRootEvents(e,[{name:"blur",handler:this._onLostFocus}])}if(this._observer){if(this.camera.getScene()._inputManager._removeCameraPointerObserver(this._observer),this._observer=null,this._contextMenuBind){const e=this.camera.getScene().getEngine().getInputElement();e&&e.removeEventListener("contextmenu",this._contextMenuBind)}this._onLostFocus=null}this._altKey=!1,this._ctrlKey=!1,this._metaKey=!1,this._shiftKey=!1,this._buttonsPressed=0,this._currentActiveButton=-1}getClassName(){return"BaseCameraPointersInput"}getSimpleName(){return"pointers"}onDoubleTap(e){}onTouch(e,t,s){}onMultiTouch(e,t,s,i,r,n){}onContextMenu(e){e.preventDefault()}onButtonDown(e){}onButtonUp(e){}onLostFocus(){}}(0,i.Cg)([(0,r.lK)()],P.prototype,"buttons",void 0);class v extends P{constructor(){super(...arguments),this.buttons=[0,1,2],this.angularSensibilityX=1e3,this.angularSensibilityY=1e3,this.pinchPrecision=12,this.pinchDeltaPercentage=0,this.useNaturalPinchZoom=!1,this.pinchZoom=!0,this.panningSensibility=1e3,this.multiTouchPanning=!0,this.multiTouchPanAndZoom=!0,this.pinchInwards=!0,this._isPanClick=!1,this._twoFingerActivityCount=0,this._isPinching=!1}getClassName(){return"ArcRotateCameraPointersInput"}_computeMultiTouchPanning(e,t){if(0!==this.panningSensibility&&e&&t){const s=t.x-e.x,i=t.y-e.y;this.camera.inertialPanningX+=-s/this.panningSensibility,this.camera.inertialPanningY+=i/this.panningSensibility}}_computePinchZoom(e,t){const s=this.camera.radius||v.MinimumRadiusForPinch;this.useNaturalPinchZoom?this.camera.radius=s*Math.sqrt(e)/Math.sqrt(t):this.pinchDeltaPercentage?this.camera.inertialRadiusOffset+=.001*(t-e)*s*this.pinchDeltaPercentage:this.camera.inertialRadiusOffset+=(t-e)/(this.pinchPrecision*(this.pinchInwards?1:-1)*(this.angularSensibilityX+this.angularSensibilityY)/2)}onTouch(e,t,s){0!==this.panningSensibility&&(this._ctrlKey&&this.camera._useCtrlForPanning||this._isPanClick)?(this.camera.inertialPanningX+=-t/this.panningSensibility,this.camera.inertialPanningY+=s/this.panningSensibility):(this.camera.inertialAlphaOffset-=t/this.angularSensibilityX,this.camera.inertialBetaOffset-=s/this.angularSensibilityY)}onDoubleTap(){this.camera.useInputToRestoreState&&this.camera.restoreState()}onMultiTouch(e,t,s,i,r,n){0===s&&null===r||0===i&&null===n||(this.multiTouchPanAndZoom?(this._computePinchZoom(s,i),this._computeMultiTouchPanning(r,n)):this.multiTouchPanning&&this.pinchZoom?(this._twoFingerActivityCount++,this._isPinching||this._twoFingerActivityCount<20&&Math.abs(Math.sqrt(i)-Math.sqrt(s))>this.camera.pinchToPanMaxDistance?(this._computePinchZoom(s,i),this._isPinching=!0):this._computeMultiTouchPanning(r,n)):this.multiTouchPanning?this._computeMultiTouchPanning(r,n):this.pinchZoom&&this._computePinchZoom(s,i))}onButtonDown(e){this._isPanClick=e.button===this.camera._panningMouseButton}onButtonUp(e){this._twoFingerActivityCount=0,this._isPinching=!1}onLostFocus(){this._isPanClick=!1,this._twoFingerActivityCount=0,this._isPinching=!1}}v.MinimumRadiusForPinch=.001,(0,i.Cg)([(0,r.lK)()],v.prototype,"buttons",void 0),(0,i.Cg)([(0,r.lK)()],v.prototype,"angularSensibilityX",void 0),(0,i.Cg)([(0,r.lK)()],v.prototype,"angularSensibilityY",void 0),(0,i.Cg)([(0,r.lK)()],v.prototype,"pinchPrecision",void 0),(0,i.Cg)([(0,r.lK)()],v.prototype,"pinchDeltaPercentage",void 0),(0,i.Cg)([(0,r.lK)()],v.prototype,"useNaturalPinchZoom",void 0),(0,i.Cg)([(0,r.lK)()],v.prototype,"pinchZoom",void 0),(0,i.Cg)([(0,r.lK)()],v.prototype,"panningSensibility",void 0),(0,i.Cg)([(0,r.lK)()],v.prototype,"multiTouchPanning",void 0),(0,i.Cg)([(0,r.lK)()],v.prototype,"multiTouchPanAndZoom",void 0),R.ArcRotateCameraPointersInput=v;var C=s(4146);class S{constructor(){this.keysUp=[38],this.keysDown=[40],this.keysLeft=[37],this.keysRight=[39],this.keysReset=[220],this.panningSensibility=50,this.zoomingSensibility=25,this.useAltToZoom=!0,this.angularSpeed=.01,this._keys=new Array}attachControl(e){e=y.S0.BackCompatCameraNoPreventDefault(arguments),this._onCanvasBlurObserver||(this._scene=this.camera.getScene(),this._engine=this._scene.getEngine(),this._onCanvasBlurObserver=this._engine.onCanvasBlurObservable.add((()=>{this._keys.length=0})),this._onKeyboardObserver=this._scene.onKeyboardObservable.add((t=>{const s=t.event;if(!s.metaKey)if(t.type===C.TB.KEYDOWN)this._ctrlPressed=s.ctrlKey,this._altPressed=s.altKey,(-1!==this.keysUp.indexOf(s.keyCode)||-1!==this.keysDown.indexOf(s.keyCode)||-1!==this.keysLeft.indexOf(s.keyCode)||-1!==this.keysRight.indexOf(s.keyCode)||-1!==this.keysReset.indexOf(s.keyCode))&&(-1===this._keys.indexOf(s.keyCode)&&this._keys.push(s.keyCode),s.preventDefault&&(e||s.preventDefault()));else if(-1!==this.keysUp.indexOf(s.keyCode)||-1!==this.keysDown.indexOf(s.keyCode)||-1!==this.keysLeft.indexOf(s.keyCode)||-1!==this.keysRight.indexOf(s.keyCode)||-1!==this.keysReset.indexOf(s.keyCode)){const t=this._keys.indexOf(s.keyCode);t>=0&&this._keys.splice(t,1),s.preventDefault&&(e||s.preventDefault())}})))}detachControl(){this._scene&&(this._onKeyboardObserver&&this._scene.onKeyboardObservable.remove(this._onKeyboardObserver),this._onCanvasBlurObserver&&this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver),this._onKeyboardObserver=null,this._onCanvasBlurObserver=null),this._keys.length=0}checkInputs(){if(this._onKeyboardObserver){const e=this.camera;for(let t=0;t0?i/(1+this.wheelDeltaPercentage):i*(1+this.wheelDeltaPercentage),s}attachControl(e){e=y.S0.BackCompatCameraNoPreventDefault(arguments),this._wheel=t=>{if(t.type!==c.Zp.POINTERWHEEL)return;const s=t.event;let i=0;const r=s.deltaMode===D.s.DOM_DELTA_LINE?40:1,n=-s.deltaY*r;if(this.customComputeDeltaFromMouseWheel)i=this.customComputeDeltaFromMouseWheel(n,this,s);else if(this.wheelDeltaPercentage){if(i=this._computeDeltaFromMouseWheelLegacyEvent(n,this.camera.radius),i>0){let e=this.camera.radius,t=this.camera.inertialRadiusOffset+i;for(let s=0;s<20&&Math.abs(t)>.001;s++)e-=t,t*=this.camera.inertia;e=(0,o.OQ)(e,0,Number.MAX_VALUE),i=this._computeDeltaFromMouseWheelLegacyEvent(n,e)}}else i=n/(40*this.wheelPrecision);i&&(this.zoomToMouseLocation?(this._hitPlane||this._updateHitPlane(),this._zoomToMouse(i)):this.camera.inertialRadiusOffset+=i),s.preventDefault&&(e||s.preventDefault())},this._observer=this.camera.getScene()._inputManager._addCameraPointerObserver(this._wheel,c.Zp.POINTERWHEEL),this.zoomToMouseLocation&&this._inertialPanning.setAll(0)}detachControl(){this._observer&&(this.camera.getScene()._inputManager._removeCameraPointerObserver(this._observer),this._observer=null,this._wheel=null)}checkInputs(){if(!this.zoomToMouseLocation)return;const e=this.camera;0+e.inertialAlphaOffset+e.inertialBetaOffset+e.inertialRadiusOffset&&(this._updateHitPlane(),e.target.addInPlace(this._inertialPanning),this._inertialPanning.scaleInPlace(e.inertia),this._zeroIfClose(this._inertialPanning))}getClassName(){return"ArcRotateCameraMouseWheelInput"}getSimpleName(){return"mousewheel"}_updateHitPlane(){const e=this.camera,t=e.target.subtract(e.position);this._hitPlane=I.Z.FromPositionAndNormal(e.target,t)}_getPosition(){const e=this.camera,t=e.getScene(),s=t.createPickingRay(t.pointerX,t.pointerY,a.uq.Identity(),e,!1);0===e.targetScreenOffset.x&&0===e.targetScreenOffset.y||(this._viewOffset.set(e.targetScreenOffset.x,e.targetScreenOffset.y,0),e.getViewMatrix().invertToRef(e._cameraTransformMatrix),this._globalOffset=a.Pq.TransformNormal(this._viewOffset,e._cameraTransformMatrix),s.origin.addInPlace(this._globalOffset));let i=0;return this._hitPlane&&(i=s.intersectsPlane(this._hitPlane)??0),s.origin.addInPlace(s.direction.scaleInPlace(i))}_zoomToMouse(e){const t=this.camera,s=1-t.inertia;if(t.lowerRadiusLimit){const i=t.lowerRadiusLimit??0;t.radius-(t.inertialRadiusOffset+e)/si&&(e=(t.radius-i)*s-t.inertialRadiusOffset)}const i=e/s/t.radius,r=this._getPosition(),n=a.AA.Vector3[6];r.subtractToRef(t.target,n),n.scaleInPlace(i),n.scaleInPlace(s),this._inertialPanning.addInPlace(n),t.inertialRadiusOffset+=e}_zeroIfClose(e){Math.abs(e.x)()=>new L(e,0,0,1,a.Pq.Zero(),t)));class L extends E{get target(){return this._target}set target(e){this.setTarget(e)}get targetHost(){return this._targetHost}set targetHost(e){e&&this.setTarget(e)}getTarget(){return this.target}get position(){return this._position}set position(e){this.setPosition(e)}set upVector(e){this._upToYMatrix||(this._yToUpMatrix=new a.uq,this._upToYMatrix=new a.uq,this._upVector=a.Pq.Zero()),e.normalize(),this._upVector.copyFrom(e),this.setMatUp()}get upVector(){return this._upVector}setMatUp(){a.uq.RotationAlignToRef(a.Pq.UpReadOnly,this._upVector,this._yToUpMatrix),a.uq.RotationAlignToRef(this._upVector,a.Pq.UpReadOnly,this._upToYMatrix)}get angularSensibilityX(){const e=this.inputs.attached.pointers;return e?e.angularSensibilityX:0}set angularSensibilityX(e){const t=this.inputs.attached.pointers;t&&(t.angularSensibilityX=e)}get angularSensibilityY(){const e=this.inputs.attached.pointers;return e?e.angularSensibilityY:0}set angularSensibilityY(e){const t=this.inputs.attached.pointers;t&&(t.angularSensibilityY=e)}get pinchPrecision(){const e=this.inputs.attached.pointers;return e?e.pinchPrecision:0}set pinchPrecision(e){const t=this.inputs.attached.pointers;t&&(t.pinchPrecision=e)}get pinchDeltaPercentage(){const e=this.inputs.attached.pointers;return e?e.pinchDeltaPercentage:0}set pinchDeltaPercentage(e){const t=this.inputs.attached.pointers;t&&(t.pinchDeltaPercentage=e)}get useNaturalPinchZoom(){const e=this.inputs.attached.pointers;return!!e&&e.useNaturalPinchZoom}set useNaturalPinchZoom(e){const t=this.inputs.attached.pointers;t&&(t.useNaturalPinchZoom=e)}get panningSensibility(){const e=this.inputs.attached.pointers;return e?e.panningSensibility:0}set panningSensibility(e){const t=this.inputs.attached.pointers;t&&(t.panningSensibility=e)}get keysUp(){const e=this.inputs.attached.keyboard;return e?e.keysUp:[]}set keysUp(e){const t=this.inputs.attached.keyboard;t&&(t.keysUp=e)}get keysDown(){const e=this.inputs.attached.keyboard;return e?e.keysDown:[]}set keysDown(e){const t=this.inputs.attached.keyboard;t&&(t.keysDown=e)}get keysLeft(){const e=this.inputs.attached.keyboard;return e?e.keysLeft:[]}set keysLeft(e){const t=this.inputs.attached.keyboard;t&&(t.keysLeft=e)}get keysRight(){const e=this.inputs.attached.keyboard;return e?e.keysRight:[]}set keysRight(e){const t=this.inputs.attached.keyboard;t&&(t.keysRight=e)}get wheelPrecision(){const e=this.inputs.attached.mousewheel;return e?e.wheelPrecision:0}set wheelPrecision(e){const t=this.inputs.attached.mousewheel;t&&(t.wheelPrecision=e)}get zoomToMouseLocation(){const e=this.inputs.attached.mousewheel;return!!e&&e.zoomToMouseLocation}set zoomToMouseLocation(e){const t=this.inputs.attached.mousewheel;t&&(t.zoomToMouseLocation=e)}get wheelDeltaPercentage(){const e=this.inputs.attached.mousewheel;return e?e.wheelDeltaPercentage:0}set wheelDeltaPercentage(e){const t=this.inputs.attached.mousewheel;t&&(t.wheelDeltaPercentage=e)}get bouncingBehavior(){return this._bouncingBehavior}get useBouncingBehavior(){return null!=this._bouncingBehavior}set useBouncingBehavior(e){e!==this.useBouncingBehavior&&(e?(this._bouncingBehavior=new g,this.addBehavior(this._bouncingBehavior)):this._bouncingBehavior&&(this.removeBehavior(this._bouncingBehavior),this._bouncingBehavior=null))}get framingBehavior(){return this._framingBehavior}get useFramingBehavior(){return null!=this._framingBehavior}set useFramingBehavior(e){e!==this.useFramingBehavior&&(e?(this._framingBehavior=new m,this.addBehavior(this._framingBehavior)):this._framingBehavior&&(this.removeBehavior(this._framingBehavior),this._framingBehavior=null))}get autoRotationBehavior(){return this._autoRotationBehavior}get useAutoRotationBehavior(){return null!=this._autoRotationBehavior}set useAutoRotationBehavior(e){e!==this.useAutoRotationBehavior&&(e?(this._autoRotationBehavior=new _,this.addBehavior(this._autoRotationBehavior)):this._autoRotationBehavior&&(this.removeBehavior(this._autoRotationBehavior),this._autoRotationBehavior=null))}constructor(e,t,s,i,r,o,h=!0){super(e,a.Pq.Zero(),o,h),this.inertialAlphaOffset=0,this.inertialBetaOffset=0,this.inertialRadiusOffset=0,this.lowerAlphaLimit=null,this.upperAlphaLimit=null,this.lowerBetaLimit=.01,this.upperBetaLimit=Math.PI-.01,this.lowerRadiusLimit=null,this.upperRadiusLimit=null,this.inertialPanningX=0,this.inertialPanningY=0,this.pinchToPanMaxDistance=20,this.panningDistanceLimit=null,this.panningOriginTarget=a.Pq.Zero(),this.panningInertia=.9,this.zoomOnFactor=1,this.targetScreenOffset=a.I9.Zero(),this.allowUpsideDown=!0,this.useInputToRestoreState=!0,this.restoreStateInterpolationFactor=0,this._viewMatrix=new a.uq,this.panningAxis=new a.Pq(1,1,0),this._transformedDirection=new a.Pq,this.mapPanning=!1,this._progressiveRestore=!1,this.onMeshTargetChangedObservable=new n.cP,this.checkCollisions=!1,this.collisionRadius=new a.Pq(.5,.5,.5),this._previousPosition=a.Pq.Zero(),this._collisionVelocity=a.Pq.Zero(),this._newPosition=a.Pq.Zero(),this._computationVector=a.Pq.Zero(),this._onCollisionPositionChange=(e,t,s=null)=>{s?(this.setPosition(t),this.onCollide&&this.onCollide(s)):this._previousPosition.copyFrom(this._position);const i=Math.cos(this.alpha),r=Math.sin(this.alpha),n=Math.cos(this.beta);let a=Math.sin(this.beta);0===a&&(a=1e-4);const o=this._getTargetPosition();this._computationVector.copyFromFloats(this.radius*i*a,this.radius*n,this.radius*r*a),o.addToRef(this._computationVector,this._newPosition),this._position.copyFrom(this._newPosition);let h=this.upVector;this.allowUpsideDown&&this.beta<0&&(h=h.clone(),h=h.negate()),this._computeViewMatrix(this._position,o,h),this._viewMatrix.addAtIndex(12,this.targetScreenOffset.x),this._viewMatrix.addAtIndex(13,this.targetScreenOffset.y),this._collisionTriggered=!1},this._target=a.Pq.Zero(),r&&this.setTarget(r),this.alpha=t,this.beta=s,this.radius=i,this.getViewMatrix(),this.inputs=new F(this),this.inputs.addKeyboard().addMouseWheel().addPointers()}_initCache(){super._initCache(),this._cache._target=new a.Pq(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.alpha=void 0,this._cache.beta=void 0,this._cache.radius=void 0,this._cache.targetScreenOffset=a.I9.Zero()}_updateCache(e){e||super._updateCache(),this._cache._target.copyFrom(this._getTargetPosition()),this._cache.alpha=this.alpha,this._cache.beta=this.beta,this._cache.radius=this.radius,this._cache.targetScreenOffset.copyFrom(this.targetScreenOffset)}_getTargetPosition(){if(this._targetHost&&this._targetHost.getAbsolutePosition){const e=this._targetHost.getAbsolutePosition();this._targetBoundingCenter?e.addToRef(this._targetBoundingCenter,this._target):this._target.copyFrom(e)}return this._getLockedTargetPosition()||this._target}storeState(){return this._storedAlpha=this._goalAlpha=this.alpha,this._storedBeta=this._goalBeta=this.beta,this._storedRadius=this._goalRadius=this.radius,this._storedTarget=this._goalTarget=this._getTargetPosition().clone(),this._storedTargetScreenOffset=this._goalTargetScreenOffset=this.targetScreenOffset.clone(),super.storeState()}_restoreStateValues(){return this.hasStateStored()&&this.restoreStateInterpolationFactor>d.bH&&this.restoreStateInterpolationFactor<1?(this.interpolateTo(this._storedAlpha,this._storedBeta,this._storedRadius,this._storedTarget,this._storedTargetScreenOffset),!0):!!super._restoreStateValues()&&(this.setTarget(this._storedTarget.clone()),this.alpha=this._storedAlpha,this.beta=this._storedBeta,this.radius=this._storedRadius,this.targetScreenOffset=this._storedTargetScreenOffset.clone(),this.inertialAlphaOffset=0,this.inertialBetaOffset=0,this.inertialRadiusOffset=0,this.inertialPanningX=0,this.inertialPanningY=0,!0)}interpolateTo(e=this.alpha,t=this.beta,s=this.radius,i=this.target,r=this.targetScreenOffset){this._progressiveRestore=!0,this.inertialAlphaOffset=0,this.inertialBetaOffset=0,this.inertialRadiusOffset=0,this.inertialPanningX=0,this.inertialPanningY=0,e=(0,o.OQ)(e,this.lowerAlphaLimit??-1/0,this.upperAlphaLimit??1/0),t=(0,o.OQ)(t,this.lowerBetaLimit??-1/0,this.upperBetaLimit??1/0),s=(0,o.OQ)(s,this.lowerRadiusLimit??-1/0,this.upperRadiusLimit??1/0),this._goalAlpha=e,this._goalBeta=t,this._goalRadius=s,this._goalTarget=i,this._goalTargetScreenOffset=r}_isSynchronizedViewMatrix(){return!!super._isSynchronizedViewMatrix()&&this._cache._target.equals(this._getTargetPosition())&&this._cache.alpha===this.alpha&&this._cache.beta===this.beta&&this._cache.radius===this.radius&&this._cache.targetScreenOffset.equals(this.targetScreenOffset)}attachControl(e,t,s=!0,i=2){const r=arguments;t=y.S0.BackCompatCameraNoPreventDefault(r),this._useCtrlForPanning=s,this._panningMouseButton=i,"boolean"==typeof r[0]&&(r.length>1&&(this._useCtrlForPanning=r[1]),r.length>2&&(this._panningMouseButton=r[2])),this.inputs.attachElement(t),this._reset=()=>{this.inertialAlphaOffset=0,this.inertialBetaOffset=0,this.inertialRadiusOffset=0,this.inertialPanningX=0,this.inertialPanningY=0}}detachControl(){this.inputs.detachElement(),this._reset&&this._reset()}_checkInputs(){if(!this._collisionTriggered){if(this.inputs.checkInputs(),this._progressiveRestore){const e=this._scene.getEngine().getDeltaTime()/1e3,t=1-Math.pow(2,-e/this.restoreStateInterpolationFactor);this.setTarget(a.Pq.Lerp(this.getTarget(),this._goalTarget,t)),a.PT.RotationAlphaBetaGammaToRef(this._goalAlpha,this._goalBeta,0,a.AA.Quaternion[0]),a.PT.RotationAlphaBetaGammaToRef(this.alpha,this.beta,0,a.AA.Quaternion[1]),a.PT.SlerpToRef(a.AA.Quaternion[1],a.AA.Quaternion[0],t,a.AA.Quaternion[2]),a.AA.Quaternion[2].normalize(),a.AA.Quaternion[2].toAlphaBetaGammaToRef(a.AA.Vector3[0]),this.alpha=a.AA.Vector3[0].x,this.beta=a.AA.Vector3[0].y,this.radius+=(this._goalRadius-this.radius)*t,a.I9.LerpToRef(this.targetScreenOffset,this._goalTargetScreenOffset,t,this.targetScreenOffset),(a.Pq.DistanceSquared(this.getTarget(),this._goalTarget)Math.PI&&(this.beta=this.beta-2*Math.PI):this.betathis.upperBetaLimit&&(this.beta=this.upperBetaLimit),null!==this.lowerAlphaLimit&&this.alphathis.upperAlphaLimit&&(this.alpha=this.upperAlphaLimit),null!==this.lowerRadiusLimit&&this.radiusthis.upperRadiusLimit&&(this.radius=this.upperRadiusLimit,this.inertialRadiusOffset=0)}rebuildAnglesAndRadius(){this._position.subtractToRef(this._getTargetPosition(),this._computationVector),0===this._upVector.x&&1===this._upVector.y&&0===this._upVector.z||a.Pq.TransformCoordinatesToRef(this._computationVector,this._upToYMatrix,this._computationVector),this.radius=this._computationVector.length(),0===this.radius&&(this.radius=1e-4);const e=this.alpha;0===this._computationVector.x&&0===this._computationVector.z?this.alpha=Math.PI/2:this.alpha=Math.acos(this._computationVector.x/Math.sqrt(Math.pow(this._computationVector.x,2)+Math.pow(this._computationVector.z,2))),this._computationVector.z<0&&(this.alpha=2*Math.PI-this.alpha);const t=Math.round((e-this.alpha)/(2*Math.PI));this.alpha+=2*t*Math.PI,this.beta=Math.acos(this._computationVector.y/this.radius),this._checkLimits()}setPosition(e){this._position.equals(e)||(this._position.copyFrom(e),this.rebuildAnglesAndRadius())}setTarget(e,t=!1,s=!1,i=!1){if(i=this.overrideCloneAlphaBetaRadius??i,e.computeWorldMatrix)t&&e.getBoundingInfo?this._targetBoundingCenter=e.getBoundingInfo().boundingBox.centerWorld.clone():this._targetBoundingCenter=null,e.computeWorldMatrix(),this._targetHost=e,this._target=this._getTargetPosition(),this.onMeshTargetChangedObservable.notifyObservers(this._targetHost);else{const t=e,i=this._getTargetPosition();if(i&&!s&&i.equals(t))return;this._targetHost=null,this._target=t,this._targetBoundingCenter=null,this.onMeshTargetChangedObservable.notifyObservers(null)}i||this.rebuildAnglesAndRadius()}_getViewMatrix(){const e=Math.cos(this.alpha),t=Math.sin(this.alpha),s=Math.cos(this.beta);let i=Math.sin(this.beta);0===i&&(i=1e-4),0===this.radius&&(this.radius=1e-4);const r=this._getTargetPosition();if(this._computationVector.copyFromFloats(this.radius*e*i,this.radius*s,this.radius*t*i),0===this._upVector.x&&1===this._upVector.y&&0===this._upVector.z||a.Pq.TransformCoordinatesToRef(this._computationVector,this._yToUpMatrix,this._computationVector),r.addToRef(this._computationVector,this._newPosition),this.getScene().collisionsEnabled&&this.checkCollisions){const e=this.getScene().collisionCoordinator;this._collider||(this._collider=e.createCollider()),this._collider._radius=this.collisionRadius,this._newPosition.subtractToRef(this._position,this._collisionVelocity),this._collisionTriggered=!0,e.getNewPosition(this._position,this._collisionVelocity,this._collider,3,null,this._onCollisionPositionChange,this.uniqueId)}else{this._position.copyFrom(this._newPosition);let e=this.upVector;this.allowUpsideDown&&i<0&&(e=e.negate()),this._computeViewMatrix(this._position,r,e),this._viewMatrix.addAtIndex(12,this.targetScreenOffset.x),this._viewMatrix.addAtIndex(13,this.targetScreenOffset.y)}return this._currentTarget=r,this._viewMatrix}zoomOn(e,t=!1){e=e||this.getScene().meshes;const s=l.e.MinMax(e);let i=this._calculateLowerRadiusFromModelBoundingSphere(s.min,s.max);i=Math.max(Math.min(i,this.upperRadiusLimit||Number.MAX_VALUE),this.lowerRadiusLimit||0),this.radius=i*this.zoomOnFactor,this.focusOn({min:s.min,max:s.max,distance:i},t)}focusOn(e,t=!1){let s,i;if(void 0===e.min){const t=e||this.getScene().meshes;s=l.e.MinMax(t),i=a.Pq.Distance(s.min,s.max)}else s=e,i=e.distance;this._target=l.e.Center(s),t||(this.maxZ=2*i)}createRigCamera(e,t){let s=0;switch(this.cameraRigMode){case T.i.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case T.i.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case T.i.RIG_MODE_STEREOSCOPIC_OVERUNDER:case T.i.RIG_MODE_STEREOSCOPIC_INTERLACED:case T.i.RIG_MODE_VR:s=this._cameraRigParams.stereoHalfAngle*(0===t?1:-1);break;case T.i.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:s=this._cameraRigParams.stereoHalfAngle*(0===t?-1:1)}const i=new L(e,this.alpha+s,this.beta,this.radius,this._target,this.getScene());return i._cameraRigParams={},i.isRigCamera=!0,i.rigParent=this,i.upVector=this.upVector,i.mode=this.mode,i.orthoLeft=this.orthoLeft,i.orthoRight=this.orthoRight,i.orthoBottom=this.orthoBottom,i.orthoTop=this.orthoTop,i}_updateRigCameras(){const e=this._rigCameras[0],t=this._rigCameras[1];switch(e.beta=t.beta=this.beta,this.cameraRigMode){case T.i.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case T.i.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case T.i.RIG_MODE_STEREOSCOPIC_OVERUNDER:case T.i.RIG_MODE_STEREOSCOPIC_INTERLACED:case T.i.RIG_MODE_VR:e.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle,t.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle;break;case T.i.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:e.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle,t.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle}super._updateRigCameras()}_calculateLowerRadiusFromModelBoundingSphere(e,t,s=1){const i=a.Pq.Distance(e,t),r=this.getScene().getEngine().getAspectRatio(this),n=Math.tan(this.fov/2),o=n*r,h=.5*i*s,l=h*Math.sqrt(1+1/(o*o)),c=h*Math.sqrt(1+1/(n*n));return Math.max(l,c)}dispose(){this.inputs.clear(),super.dispose()}getClassName(){return"ArcRotateCamera"}}(0,i.Cg)([(0,r.lK)()],L.prototype,"alpha",void 0),(0,i.Cg)([(0,r.lK)()],L.prototype,"beta",void 0),(0,i.Cg)([(0,r.lK)()],L.prototype,"radius",void 0),(0,i.Cg)([(0,r.lK)()],L.prototype,"overrideCloneAlphaBetaRadius",void 0),(0,i.Cg)([(0,r.P_)("target")],L.prototype,"_target",void 0),(0,i.Cg)([(0,r.xG)("targetHost")],L.prototype,"_targetHost",void 0),(0,i.Cg)([(0,r.lK)()],L.prototype,"inertialAlphaOffset",void 0),(0,i.Cg)([(0,r.lK)()],L.prototype,"inertialBetaOffset",void 0),(0,i.Cg)([(0,r.lK)()],L.prototype,"inertialRadiusOffset",void 0),(0,i.Cg)([(0,r.lK)()],L.prototype,"lowerAlphaLimit",void 0),(0,i.Cg)([(0,r.lK)()],L.prototype,"upperAlphaLimit",void 0),(0,i.Cg)([(0,r.lK)()],L.prototype,"lowerBetaLimit",void 0),(0,i.Cg)([(0,r.lK)()],L.prototype,"upperBetaLimit",void 0),(0,i.Cg)([(0,r.lK)()],L.prototype,"lowerRadiusLimit",void 0),(0,i.Cg)([(0,r.lK)()],L.prototype,"upperRadiusLimit",void 0),(0,i.Cg)([(0,r.lK)()],L.prototype,"inertialPanningX",void 0),(0,i.Cg)([(0,r.lK)()],L.prototype,"inertialPanningY",void 0),(0,i.Cg)([(0,r.lK)()],L.prototype,"pinchToPanMaxDistance",void 0),(0,i.Cg)([(0,r.lK)()],L.prototype,"panningDistanceLimit",void 0),(0,i.Cg)([(0,r.P_)()],L.prototype,"panningOriginTarget",void 0),(0,i.Cg)([(0,r.lK)()],L.prototype,"panningInertia",void 0),(0,i.Cg)([(0,r.lK)()],L.prototype,"zoomToMouseLocation",null),(0,i.Cg)([(0,r.lK)()],L.prototype,"zoomOnFactor",void 0),(0,i.Cg)([(0,r.WM)()],L.prototype,"targetScreenOffset",void 0),(0,i.Cg)([(0,r.lK)()],L.prototype,"allowUpsideDown",void 0),(0,i.Cg)([(0,r.lK)()],L.prototype,"useInputToRestoreState",void 0),(0,i.Cg)([(0,r.lK)()],L.prototype,"restoreStateInterpolationFactor",void 0),(0,w.Y5)("BABYLON.ArcRotateCamera",L)},388:(e,t,s)=>{s.d(t,{i:()=>g});var i=s(5524),r=s(9259),n=s(7931),a=s(998),o=s(9848),h=s(9923),l=s(4870),c=s(1137),u=s(6552),d=s(5503),_=s(4494),f=s(2572),p=s(6877);class g extends l.b{get position(){return this._position}set position(e){this._position=e}set upVector(e){this._upVector=e}get upVector(){return this._upVector}get screenArea(){let e=0,t=0;if(this.mode===g.PERSPECTIVE_CAMERA)this.fovMode===g.FOVMODE_VERTICAL_FIXED?(t=2*this.minZ*Math.tan(this.fov/2),e=this.getEngine().getAspectRatio(this)*t):(e=2*this.minZ*Math.tan(this.fov/2),t=e/this.getEngine().getAspectRatio(this));else{const s=this.getEngine().getRenderWidth()/2,i=this.getEngine().getRenderHeight()/2;e=(this.orthoRight??s)-(this.orthoLeft??-s),t=(this.orthoTop??i)-(this.orthoBottom??-i)}return e*t}set orthoLeft(e){this._orthoLeft=e;for(const t of this._rigCameras)t.orthoLeft=e}get orthoLeft(){return this._orthoLeft}set orthoRight(e){this._orthoRight=e;for(const t of this._rigCameras)t.orthoRight=e}get orthoRight(){return this._orthoRight}set orthoBottom(e){this._orthoBottom=e;for(const t of this._rigCameras)t.orthoBottom=e}get orthoBottom(){return this._orthoBottom}set orthoTop(e){this._orthoTop=e;for(const t of this._rigCameras)t.orthoTop=e}get orthoTop(){return this._orthoTop}set mode(e){this._mode=e;for(const t of this._rigCameras)t.mode=e}get mode(){return this._mode}get hasMoved(){return this._hasMoved}constructor(e,t,s,i=!0){super(e,s,!1),this._position=h.Pq.Zero(),this._upVector=h.Pq.Up(),this.oblique=null,this._orthoLeft=null,this._orthoRight=null,this._orthoBottom=null,this._orthoTop=null,this.fov=.8,this.projectionPlaneTilt=0,this.minZ=1,this.maxZ=1e4,this.inertia=.9,this._mode=g.PERSPECTIVE_CAMERA,this.isIntermediate=!1,this.viewport=new _.L(0,0,1,1),this.layerMask=268435455,this.fovMode=g.FOVMODE_VERTICAL_FIXED,this.cameraRigMode=g.RIG_MODE_NONE,this.customRenderTargets=[],this.outputRenderTarget=null,this.onViewMatrixChangedObservable=new o.cP,this.onProjectionMatrixChangedObservable=new o.cP,this.onAfterCheckInputsObservable=new o.cP,this.onRestoreStateObservable=new o.cP,this.isRigCamera=!1,this._hasMoved=!1,this._rigCameras=new Array,this._skipRendering=!1,this._projectionMatrix=new h.uq,this._postProcesses=new Array,this._activeMeshes=new n.L(256),this._globalPosition=h.Pq.Zero(),this._computedViewMatrix=h.uq.Identity(),this._doNotComputeProjectionMatrix=!1,this._transformMatrix=h.uq.Zero(),this._refreshFrustumPlanes=!0,this._absoluteRotation=h.PT.Identity(),this._isCamera=!0,this._isLeftCamera=!1,this._isRightCamera=!1,this.getScene().addCamera(this),i&&!this.getScene().activeCamera&&(this.getScene().activeCamera=this),this.position=t,this.renderPassId=this.getScene().getEngine().createRenderPassId(`Camera ${e}`)}storeState(){return this._stateStored=!0,this._storedFov=this.fov,this}hasStateStored(){return!!this._stateStored}_restoreStateValues(){return!!this._stateStored&&(this.fov=this._storedFov,!0)}restoreState(){return!!this._restoreStateValues()&&(this.onRestoreStateObservable.notifyObservers(this),!0)}getClassName(){return"Camera"}toString(e){let t="Name: "+this.name;if(t+=", type: "+this.getClassName(),this.animations)for(let s=0;s-1?(c.V.Error("You're trying to reuse a post process not defined as reusable."),0):(null==t||t<0?this._postProcesses.push(e):null===this._postProcesses[t]?this._postProcesses[t]=e:this._postProcesses.splice(t,0,e),this._cascadePostProcessesToRigCams(),this._scene.prePassRenderer&&this._scene.prePassRenderer.markAsDirty(),this._postProcesses.indexOf(e))}detachPostProcess(e){const t=this._postProcesses.indexOf(e);-1!==t&&(this._postProcesses[t]=null),this._scene.prePassRenderer&&this._scene.prePassRenderer.markAsDirty(),this._cascadePostProcessesToRigCams()}getWorldMatrix(){return this._isSynchronizedViewMatrix()||this.getViewMatrix(),this._worldMatrix}_getViewMatrix(){return h.uq.Identity()}getViewMatrix(e){return!e&&this._isSynchronizedViewMatrix()||(this._hasMoved=!0,this.updateCache(),this._computedViewMatrix=this._getViewMatrix(),this._currentRenderId=this.getScene().getRenderId(),this._childUpdateId++,this._refreshFrustumPlanes=!0,this._cameraRigParams&&this._cameraRigParams.vrPreViewMatrix&&this._computedViewMatrix.multiplyToRef(this._cameraRigParams.vrPreViewMatrix,this._computedViewMatrix),this.parent&&this.parent.onViewMatrixChangedObservable&&this.parent.onViewMatrixChangedObservable.notifyObservers(this.parent),this.onViewMatrixChangedObservable.notifyObservers(this),this._computedViewMatrix.invertToRef(this._worldMatrix)),this._computedViewMatrix}freezeProjectionMatrix(e){this._doNotComputeProjectionMatrix=!0,void 0!==e&&(this._projectionMatrix=e)}unfreezeProjectionMatrix(){this._doNotComputeProjectionMatrix=!1}getProjectionMatrix(e){if(this._doNotComputeProjectionMatrix||!e&&this._isSynchronizedProjectionMatrix())return this._projectionMatrix;this._cache.mode=this.mode,this._cache.minZ=this.minZ,this._cache.maxZ=this.maxZ,this._refreshFrustumPlanes=!0;const t=this.getEngine(),s=this.getScene(),i=t.useReverseDepthBuffer;if(this.mode===g.PERSPECTIVE_CAMERA){let e;this._cache.fov=this.fov,this._cache.fovMode=this.fovMode,this._cache.aspectRatio=t.getAspectRatio(this),this._cache.projectionPlaneTilt=this.projectionPlaneTilt,this.minZ<=0&&(this.minZ=.1),e=s.useRightHandedSystem?h.uq.PerspectiveFovRHToRef:h.uq.PerspectiveFovLHToRef,e(this.fov,t.getAspectRatio(this),i?this.maxZ:this.minZ,i?this.minZ:this.maxZ,this._projectionMatrix,this.fovMode===g.FOVMODE_VERTICAL_FIXED,t.isNDCHalfZRange,this.projectionPlaneTilt,i)}else{const e=t.getRenderWidth()/2,r=t.getRenderHeight()/2;s.useRightHandedSystem?this.oblique?h.uq.ObliqueOffCenterRHToRef(this.orthoLeft??-e,this.orthoRight??e,this.orthoBottom??-r,this.orthoTop??r,i?this.maxZ:this.minZ,i?this.minZ:this.maxZ,this.oblique.length,this.oblique.angle,this._computeObliqueDistance(this.oblique.offset),this._projectionMatrix,t.isNDCHalfZRange):h.uq.OrthoOffCenterRHToRef(this.orthoLeft??-e,this.orthoRight??e,this.orthoBottom??-r,this.orthoTop??r,i?this.maxZ:this.minZ,i?this.minZ:this.maxZ,this._projectionMatrix,t.isNDCHalfZRange):this.oblique?h.uq.ObliqueOffCenterLHToRef(this.orthoLeft??-e,this.orthoRight??e,this.orthoBottom??-r,this.orthoTop??r,i?this.maxZ:this.minZ,i?this.minZ:this.maxZ,this.oblique.length,this.oblique.angle,this._computeObliqueDistance(this.oblique.offset),this._projectionMatrix,t.isNDCHalfZRange):h.uq.OrthoOffCenterLHToRef(this.orthoLeft??-e,this.orthoRight??e,this.orthoBottom??-r,this.orthoTop??r,i?this.maxZ:this.minZ,i?this.minZ:this.maxZ,this._projectionMatrix,t.isNDCHalfZRange),this._cache.orthoLeft=this.orthoLeft,this._cache.orthoRight=this.orthoRight,this._cache.orthoBottom=this.orthoBottom,this._cache.orthoTop=this.orthoTop,this._cache.obliqueAngle=this.oblique?.angle,this._cache.obliqueLength=this.oblique?.length,this._cache.obliqueOffset=this.oblique?.offset,this._cache.renderWidth=t.getRenderWidth(),this._cache.renderHeight=t.getRenderHeight()}return this.onProjectionMatrixChangedObservable.notifyObservers(this),this._projectionMatrix}getTransformationMatrix(){return this._computedViewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix),this._transformMatrix}_computeObliqueDistance(e){return(this.radius||(this.target?h.Pq.Distance(this.position,this.target):this.position.length()))+e}_updateFrustumPlanes(){this._refreshFrustumPlanes&&(this.getTransformationMatrix(),this._frustumPlanes?f.P.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=f.P.GetPlanes(this._transformMatrix),this._refreshFrustumPlanes=!1)}isInFrustum(e,t=!1){if(this._updateFrustumPlanes(),t&&this.rigCameras.length>0){let t=!1;return this.rigCameras.forEach((s=>{s._updateFrustumPlanes(),t=t||e.isInFrustum(s._frustumPlanes)})),t}return e.isInFrustum(this._frustumPlanes)}isCompletelyInFrustum(e){return this._updateFrustumPlanes(),e.isCompletelyInFrustum(this._frustumPlanes)}getForwardRay(e=100,t,s){throw(0,d.n)("Ray")}getForwardRayToRef(e,t=100,s,i){throw(0,d.n)("Ray")}dispose(e,t=!1){for(this.onViewMatrixChangedObservable.clear(),this.onProjectionMatrixChangedObservable.clear(),this.onAfterCheckInputsObservable.clear(),this.onRestoreStateObservable.clear(),this.inputs&&this.inputs.clear(),this.getScene().stopAnimation(this),this.getScene().removeCamera(this);this._rigCameras.length>0;){const e=this._rigCameras.pop();e&&e.dispose()}if(this._parentContainer){const e=this._parentContainer.cameras.indexOf(this);e>-1&&this._parentContainer.cameras.splice(e,1),this._parentContainer=null}if(this._rigPostProcess)this._rigPostProcess.dispose(this),this._rigPostProcess=null,this._postProcesses.length=0;else if(this.cameraRigMode!==g.RIG_MODE_NONE)this._rigPostProcess=null,this._postProcesses.length=0;else{let e=this._postProcesses.length;for(;--e>=0;){const t=this._postProcesses[e];t&&t.dispose(this)}}let s=this.customRenderTargets.length;for(;--s>=0;)this.customRenderTargets[s].dispose();this.customRenderTargets.length=0,this._activeMeshes.dispose(),this.getScene().getEngine().releaseRenderPassId(this.renderPassId),super.dispose(e,t)}get isLeftCamera(){return this._isLeftCamera}get isRightCamera(){return this._isRightCamera}get leftCamera(){return this._rigCameras.length<1?null:this._rigCameras[0]}get rightCamera(){return this._rigCameras.length<2?null:this._rigCameras[1]}getLeftTarget(){return this._rigCameras.length<1?null:this._rigCameras[0].getTarget()}getRightTarget(){return this._rigCameras.length<2?null:this._rigCameras[1].getTarget()}setCameraRigMode(e,t){if(this.cameraRigMode!==e){for(;this._rigCameras.length>0;){const e=this._rigCameras.pop();e&&e.dispose()}if(this.cameraRigMode=e,this._cameraRigParams={},this._cameraRigParams.interaxialDistance=t.interaxialDistance||.0637,this._cameraRigParams.stereoHalfAngle=a.S0.ToRadians(this._cameraRigParams.interaxialDistance/.0637),this.cameraRigMode!==g.RIG_MODE_NONE){const e=this.createRigCamera(this.name+"_L",0);e&&(e._isLeftCamera=!0);const t=this.createRigCamera(this.name+"_R",1);t&&(t._isRightCamera=!0),e&&t&&(this._rigCameras.push(e),this._rigCameras.push(t))}this._setRigMode(t),this._cascadePostProcessesToRigCams(),this.update()}}_setRigMode(e){}_getVRProjectionMatrix(){return h.uq.PerspectiveFovLHToRef(this._cameraRigParams.vrMetrics.aspectRatioFov,this._cameraRigParams.vrMetrics.aspectRatio,this.minZ,this.maxZ,this._cameraRigParams.vrWorkMatrix,!0,this.getEngine().isNDCHalfZRange),this._cameraRigParams.vrWorkMatrix.multiplyToRef(this._cameraRigParams.vrHMatrix,this._projectionMatrix),this._projectionMatrix}setCameraRigParameter(e,t){this._cameraRigParams||(this._cameraRigParams={}),this._cameraRigParams[e]=t,"interaxialDistance"===e&&(this._cameraRigParams.stereoHalfAngle=a.S0.ToRadians(t/.0637))}createRigCamera(e,t){return null}_updateRigCameras(){for(let e=0;eg._CreateDefaultParsedCamera(t,s))}computeWorldMatrix(){return this.getWorldMatrix()}static Parse(e,t){const s=e.type,i=g.GetConstructorFromName(s,e.name,t,e.interaxial_distance,e.isStereoscopicSideBySide),r=p.p.Parse(i,e,t);if(void 0!==e.parentId&&(r._waitingParentId=e.parentId),void 0!==e.parentInstanceIndex&&(r._waitingParentInstanceIndex=e.parentInstanceIndex),r.inputs&&(r.inputs.parse(e),r._setupInputs()),e.upVector&&(r.upVector=h.Pq.FromArray(e.upVector)),r.setPosition&&(r.position.copyFromFloats(0,0,0),r.setPosition(h.Pq.FromArray(e.position))),e.target&&r.setTarget&&r.setTarget(h.Pq.FromArray(e.target)),e.cameraRigMode){const t=e.interaxial_distance?{interaxialDistance:e.interaxial_distance}:{};r.setCameraRigMode(e.cameraRigMode,t)}if(e.animations){for(let t=0;t{throw(0,d.n)("UniversalCamera")},g.PERSPECTIVE_CAMERA=0,g.ORTHOGRAPHIC_CAMERA=1,g.FOVMODE_VERTICAL_FIXED=0,g.FOVMODE_HORIZONTAL_FIXED=1,g.RIG_MODE_NONE=0,g.RIG_MODE_STEREOSCOPIC_ANAGLYPH=10,g.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL=11,g.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED=12,g.RIG_MODE_STEREOSCOPIC_OVERUNDER=13,g.RIG_MODE_STEREOSCOPIC_INTERLACED=14,g.RIG_MODE_VR=20,g.RIG_MODE_CUSTOM=22,g.ForceAttachControlToAlwaysPreventDefault=!1,(0,i.Cg)([(0,r.P_)("position")],g.prototype,"_position",void 0),(0,i.Cg)([(0,r.P_)("upVector")],g.prototype,"_upVector",void 0),(0,i.Cg)([(0,r.lK)()],g.prototype,"orthoLeft",null),(0,i.Cg)([(0,r.lK)()],g.prototype,"orthoRight",null),(0,i.Cg)([(0,r.lK)()],g.prototype,"orthoBottom",null),(0,i.Cg)([(0,r.lK)()],g.prototype,"orthoTop",null),(0,i.Cg)([(0,r.lK)()],g.prototype,"fov",void 0),(0,i.Cg)([(0,r.lK)()],g.prototype,"projectionPlaneTilt",void 0),(0,i.Cg)([(0,r.lK)()],g.prototype,"minZ",void 0),(0,i.Cg)([(0,r.lK)()],g.prototype,"maxZ",void 0),(0,i.Cg)([(0,r.lK)()],g.prototype,"inertia",void 0),(0,i.Cg)([(0,r.lK)()],g.prototype,"mode",null),(0,i.Cg)([(0,r.lK)()],g.prototype,"layerMask",void 0),(0,i.Cg)([(0,r.lK)()],g.prototype,"fovMode",void 0),(0,i.Cg)([(0,r.lK)()],g.prototype,"cameraRigMode",void 0),(0,i.Cg)([(0,r.lK)()],g.prototype,"interaxialDistance",void 0),(0,i.Cg)([(0,r.lK)()],g.prototype,"isStereoscopicSideBySide",void 0)},311:(e,t,s)=>{s.d(t,{G:()=>n});var i=s(9923),r=s(5616);class n{constructor(){this.hit=!1,this.distance=0,this.pickedPoint=null,this.pickedMesh=null,this.bu=0,this.bv=0,this.faceId=-1,this.subMeshFaceId=-1,this.subMeshId=0,this.pickedSprite=null,this.thinInstanceIndex=-1,this.ray=null,this.originMesh=null,this.aimTransform=null,this.gripTransform=null}getNormal(e=!1,t=!0){if(!this.pickedMesh||t&&!this.pickedMesh.isVerticesDataPresent(r.R.NormalKind))return null;let s,n=this.pickedMesh.getIndices();0===n?.length&&(n=null);const a=i.AA.Vector3[0],o=i.AA.Vector3[1],h=i.AA.Vector3[2];if(t){const e=this.pickedMesh.getVerticesData(r.R.NormalKind);let t=n?i.Pq.FromArrayToRef(e,3*n[3*this.faceId],a):a.copyFromFloats(e[3*this.faceId*3],e[3*this.faceId*3+1],e[3*this.faceId*3+2]),l=n?i.Pq.FromArrayToRef(e,3*n[3*this.faceId+1],o):o.copyFromFloats(e[3*(3*this.faceId+1)],e[3*(3*this.faceId+1)+1],e[3*(3*this.faceId+1)+2]),c=n?i.Pq.FromArrayToRef(e,3*n[3*this.faceId+2],h):h.copyFromFloats(e[3*(3*this.faceId+2)],e[3*(3*this.faceId+2)+1],e[3*(3*this.faceId+2)+2]);t=t.scale(this.bu),l=l.scale(this.bv),c=c.scale(1-this.bu-this.bv),s=new i.Pq(t.x+l.x+c.x,t.y+l.y+c.y,t.z+l.z+c.z)}else{const e=this.pickedMesh.getVerticesData(r.R.PositionKind),t=n?i.Pq.FromArrayToRef(e,3*n[3*this.faceId],a):a.copyFromFloats(e[3*this.faceId*3],e[3*this.faceId*3+1],e[3*this.faceId*3+2]),l=n?i.Pq.FromArrayToRef(e,3*n[3*this.faceId+1],o):o.copyFromFloats(e[3*(3*this.faceId+1)],e[3*(3*this.faceId+1)+1],e[3*(3*this.faceId+1)+2]),c=n?i.Pq.FromArrayToRef(e,3*n[3*this.faceId+2],h):h.copyFromFloats(e[3*(3*this.faceId+2)],e[3*(3*this.faceId+2)+1],e[3*(3*this.faceId+2)+2]),u=t.subtract(l),d=c.subtract(l);s=i.Pq.Cross(u,d)}const l=(e,t)=>{let s=e.getWorldMatrix();e.nonUniformScaling&&(i.AA.Matrix[0].copyFrom(s),s=i.AA.Matrix[0],s.setTranslationFromFloats(0,0,0),s.invert(),s.transposeToRef(i.AA.Matrix[1]),s=i.AA.Matrix[1]),i.Pq.TransformNormalToRef(t,s,t)};if(e&&l(this.pickedMesh,s),this.ray){const t=i.AA.Vector3[0].copyFrom(s);e||l(this.pickedMesh,t),i.Pq.Dot(t,this.ray.direction)>0&&s.negateInPlace()}return s.normalize(),s}getTextureCoordinates(e=r.R.UVKind){if(!this.pickedMesh||!this.pickedMesh.isVerticesDataPresent(e))return null;const t=this.pickedMesh.getIndices();if(!t)return null;const s=this.pickedMesh.getVerticesData(e);if(!s)return null;let n=i.I9.FromArray(s,2*t[3*this.faceId]),a=i.I9.FromArray(s,2*t[3*this.faceId+1]),o=i.I9.FromArray(s,2*t[3*this.faceId+2]);return n=n.scale(this.bu),a=a.scale(this.bv),o=o.scale(1-this.bu-this.bv),new i.I9(n.x+a.x+o.x,n.y+a.y+o.y)}}},1313:(e,t,s)=>{s.d(t,{rX:()=>i});let i=!1},2564:(e,t,s)=>{s.d(t,{j:()=>d});var i=s(7309),r=s(9923),n=s(5559);class a{constructor(e,t,s){this.vectors=(0,i.mI)(8,r.Pq.Zero),this.center=r.Pq.Zero(),this.centerWorld=r.Pq.Zero(),this.extendSize=r.Pq.Zero(),this.extendSizeWorld=r.Pq.Zero(),this.directions=(0,i.mI)(3,r.Pq.Zero),this.vectorsWorld=(0,i.mI)(8,r.Pq.Zero),this.minimumWorld=r.Pq.Zero(),this.maximumWorld=r.Pq.Zero(),this.minimum=r.Pq.Zero(),this.maximum=r.Pq.Zero(),this._drawWrapperFront=null,this._drawWrapperBack=null,this.reConstruct(e,t,s)}reConstruct(e,t,s){const i=e.x,n=e.y,a=e.z,o=t.x,h=t.y,l=t.z,c=this.vectors;this.minimum.copyFromFloats(i,n,a),this.maximum.copyFromFloats(o,h,l),c[0].copyFromFloats(i,n,a),c[1].copyFromFloats(o,h,l),c[2].copyFromFloats(o,n,a),c[3].copyFromFloats(i,h,a),c[4].copyFromFloats(i,n,l),c[5].copyFromFloats(o,h,a),c[6].copyFromFloats(i,h,l),c[7].copyFromFloats(o,n,l),t.addToRef(e,this.center).scaleInPlace(.5),t.subtractToRef(e,this.extendSize).scaleInPlace(.5),this._worldMatrix=s||r.uq.IdentityReadOnly,this._update(this._worldMatrix)}scale(e){const t=a._TmpVector3,s=this.maximum.subtractToRef(this.minimum,t[0]),i=s.length();s.normalizeFromLength(i);const r=i*e,n=s.scaleInPlace(.5*r),o=this.center.subtractToRef(n,t[1]),h=this.center.addToRef(n,t[2]);return this.reConstruct(o,h,this._worldMatrix),this}getWorldMatrix(){return this._worldMatrix}_update(e){const t=this.minimumWorld,s=this.maximumWorld,i=this.directions,n=this.vectorsWorld,a=this.vectors;if(e.isIdentity()){t.copyFrom(this.minimum),s.copyFrom(this.maximum);for(let e=0;e<8;++e)n[e].copyFrom(a[e]);this.extendSizeWorld.copyFrom(this.extendSize),this.centerWorld.copyFrom(this.center)}else{t.setAll(Number.MAX_VALUE),s.setAll(-Number.MAX_VALUE);for(let i=0;i<8;++i){const o=n[i];r.Pq.TransformCoordinatesToRef(a[i],e,o),t.minimizeInPlace(o),s.maximizeInPlace(o)}s.subtractToRef(t,this.extendSizeWorld).scaleInPlace(.5),s.addToRef(t,this.centerWorld).scaleInPlace(.5)}r.Pq.FromArrayToRef(e.m,0,i[0]),r.Pq.FromArrayToRef(e.m,4,i[1]),r.Pq.FromArrayToRef(e.m,8,i[2]),this._worldMatrix=e}isInFrustum(e){return a.IsInFrustum(this.vectorsWorld,e)}isCompletelyInFrustum(e){return a.IsCompletelyInFrustum(this.vectorsWorld,e)}intersectsPoint(e){const t=this.minimumWorld,s=this.maximumWorld,i=t.x,r=t.y,a=t.z,o=s.x,h=s.y,l=s.z,c=e.x,u=e.y,d=e.z,_=-n.bH;return!(o-c<_||_>c-i||h-u<_||_>u-r||l-d<_||_>d-a)}intersectsSphere(e){return a.IntersectsSphere(this.minimumWorld,this.maximumWorld,e.centerWorld,e.radiusWorld)}intersectsMinMax(e,t){const s=this.minimumWorld,i=this.maximumWorld,r=s.x,n=s.y,a=s.z,o=i.x,h=i.y,l=i.z,c=e.x,u=e.y,d=e.z,_=t.x,f=t.y,p=t.z;return!(o_||hf||lp)}dispose(){this._drawWrapperFront?.dispose(),this._drawWrapperBack?.dispose()}static Intersects(e,t){return e.intersectsMinMax(t.minimumWorld,t.maximumWorld)}static IntersectsSphere(e,t,s,i){const n=a._TmpVector3[0];return r.Pq.ClampToRef(s,e,t,n),r.Pq.DistanceSquared(s,n)<=i*i}static IsCompletelyInFrustum(e,t){for(let s=0;s<6;++s){const i=t[s];for(let t=0;t<8;++t)if(i.dotCoordinate(e[t])<0)return!1}return!0}static IsInFrustum(e,t){for(let s=0;s<6;++s){let i=!0;const r=t[s];for(let t=0;t<8;++t)if(r.dotCoordinate(e[t])>=0){i=!1;break}if(i)return!1}return!0}}a._TmpVector3=(0,i.mI)(3,r.Pq.Zero);class o{constructor(e,t,s){this.center=r.Pq.Zero(),this.centerWorld=r.Pq.Zero(),this.minimum=r.Pq.Zero(),this.maximum=r.Pq.Zero(),this.reConstruct(e,t,s)}reConstruct(e,t,s){this.minimum.copyFrom(e),this.maximum.copyFrom(t);const i=r.Pq.Distance(e,t);t.addToRef(e,this.center).scaleInPlace(.5),this.radius=.5*i,this._update(s||r.uq.IdentityReadOnly)}scale(e){const t=this.radius*e,s=o._TmpVector3,i=s[0].setAll(t),r=this.center.subtractToRef(i,s[1]),n=this.center.addToRef(i,s[2]);return this.reConstruct(r,n,this._worldMatrix),this}getWorldMatrix(){return this._worldMatrix}_update(e){if(e.isIdentity())this.centerWorld.copyFrom(this.center),this.radiusWorld=this.radius;else{r.Pq.TransformCoordinatesToRef(this.center,e,this.centerWorld);const t=o._TmpVector3[0];r.Pq.TransformNormalFromFloatsToRef(1,1,1,e,t),this.radiusWorld=Math.max(Math.abs(t.x),Math.abs(t.y),Math.abs(t.z))*this.radius}}isInFrustum(e){const t=this.centerWorld,s=this.radiusWorld;for(let i=0;i<6;i++)if(e[i].dotCoordinate(t)<=-s)return!1;return!0}isCenterInFrustum(e){const t=this.centerWorld;for(let s=0;s<6;s++)if(e[s].dotCoordinate(t)<0)return!1;return!0}intersectsPoint(e){const t=r.Pq.DistanceSquared(this.centerWorld,e);return!(this.radiusWorld*this.radiusWorld{const i=r.Pq.Dot(t.centerWorld,e),n=Math.abs(r.Pq.Dot(t.directions[0],e))*t.extendSize.x+Math.abs(r.Pq.Dot(t.directions[1],e))*t.extendSize.y+Math.abs(r.Pq.Dot(t.directions[2],e))*t.extendSize.z;s.min=i-n,s.max=i+n},u=(e,t,s)=>(c(e,t,h),c(e,s,l),!(h.min>l.max||l.min>h.max));class d{constructor(e,t,s){this._isLocked=!1,this.boundingBox=new a(e,t,s),this.boundingSphere=new o(e,t,s)}reConstruct(e,t,s){this.boundingBox.reConstruct(e,t,s),this.boundingSphere.reConstruct(e,t,s)}get minimum(){return this.boundingBox.minimum}get maximum(){return this.boundingBox.maximum}get isLocked(){return this._isLocked}set isLocked(e){this._isLocked=e}update(e){this._isLocked||(this.boundingBox._update(e),this.boundingSphere._update(e))}centerOn(e,t){const s=d._TmpVector3[0].copyFrom(e).subtractInPlace(t),i=d._TmpVector3[1].copyFrom(e).addInPlace(t);return this.boundingBox.reConstruct(s,i,this.boundingBox.getWorldMatrix()),this.boundingSphere.reConstruct(s,i,this.boundingBox.getWorldMatrix()),this}encapsulate(e){const t=r.Pq.Minimize(this.minimum,e),s=r.Pq.Maximize(this.maximum,e);return this.reConstruct(t,s,this.boundingBox.getWorldMatrix()),this}encapsulateBoundingInfo(e){const t=r.AA.Matrix[0];this.boundingBox.getWorldMatrix().invertToRef(t);const s=r.AA.Vector3[0];return r.Pq.TransformCoordinatesToRef(e.boundingBox.minimumWorld,t,s),this.encapsulate(s),r.Pq.TransformCoordinatesToRef(e.boundingBox.maximumWorld,t,s),this.encapsulate(s),this}scale(e){return this.boundingBox.scale(e),this.boundingSphere.scale(e),this}isInFrustum(e,t=0){return!(2!==t&&3!==t||!this.boundingSphere.isCenterInFrustum(e))||!!this.boundingSphere.isInFrustum(e)&&(!(1!==t&&3!==t)||this.boundingBox.isInFrustum(e))}get diagonalLength(){const e=this.boundingBox;return e.maximumWorld.subtractToRef(e.minimumWorld,d._TmpVector3[0]).length()}isCompletelyInFrustum(e){return this.boundingBox.isCompletelyInFrustum(e)}_checkCollision(e){return e._canDoCollision(this.boundingSphere.centerWorld,this.boundingSphere.radiusWorld,this.boundingBox.minimumWorld,this.boundingBox.maximumWorld)}intersectsPoint(e){return!!this.boundingSphere.centerWorld&&!!this.boundingSphere.intersectsPoint(e)&&!!this.boundingBox.intersectsPoint(e)}intersects(e,t){if(!o.Intersects(this.boundingSphere,e.boundingSphere))return!1;if(!a.Intersects(this.boundingBox,e.boundingBox))return!1;if(!t)return!0;const s=this.boundingBox,i=e.boundingBox;return!!(u(s.directions[0],s,i)&&u(s.directions[1],s,i)&&u(s.directions[2],s,i)&&u(i.directions[0],s,i)&&u(i.directions[1],s,i)&&u(i.directions[2],s,i)&&u(r.Pq.Cross(s.directions[0],i.directions[0]),s,i)&&u(r.Pq.Cross(s.directions[0],i.directions[1]),s,i)&&u(r.Pq.Cross(s.directions[0],i.directions[2]),s,i)&&u(r.Pq.Cross(s.directions[1],i.directions[0]),s,i)&&u(r.Pq.Cross(s.directions[1],i.directions[1]),s,i)&&u(r.Pq.Cross(s.directions[1],i.directions[2]),s,i)&&u(r.Pq.Cross(s.directions[2],i.directions[0]),s,i)&&u(r.Pq.Cross(s.directions[2],i.directions[1]),s,i)&&u(r.Pq.Cross(s.directions[2],i.directions[2]),s,i))}}d._TmpVector3=(0,i.mI)(2,r.Pq.Zero)},9125:(e,t,s)=>{s.d(t,{nO:()=>M,pB:()=>A,M0:()=>R,Iq:()=>S,J:()=>I});class i{constructor(){this.children=[]}isValid(e){return!0}process(e,t){let s="";if(this.line){let i=this.line;const r=t.processor;if(r){r.lineProcessor&&(i=r.lineProcessor(i,t.isFragment,t.processingContext));const s=t.processor?.attributeKeywordName??"attribute",n=t.isFragment&&t.processor?.varyingFragmentKeywordName?t.processor?.varyingFragmentKeywordName:!t.isFragment&&t.processor?.varyingVertexKeywordName?t.processor?.varyingVertexKeywordName:"varying";!t.isFragment&&r.attributeProcessor&&this.line.startsWith(s)?i=r.attributeProcessor(this.line,e,t.processingContext):r.varyingProcessor&&(r.varyingCheck?.(this.line,t.isFragment)||!r.varyingCheck&&this.line.startsWith(n))?i=r.varyingProcessor(this.line,t.isFragment,e,t.processingContext):r.uniformProcessor&&r.uniformRegexp&&r.uniformRegexp.test(this.line)?t.lookForClosingBracketForUniformBuffer||(i=r.uniformProcessor(this.line,t.isFragment,e,t.processingContext)):r.uniformBufferProcessor&&r.uniformBufferRegexp&&r.uniformBufferRegexp.test(this.line)?t.lookForClosingBracketForUniformBuffer||(i=r.uniformBufferProcessor(this.line,t.isFragment,t.processingContext),t.lookForClosingBracketForUniformBuffer=!0):r.textureProcessor&&r.textureRegexp&&r.textureRegexp.test(this.line)?i=r.textureProcessor(this.line,t.isFragment,e,t.processingContext):(r.uniformProcessor||r.uniformBufferProcessor)&&this.line.startsWith("uniform")&&!t.lookForClosingBracketForUniformBuffer&&(/uniform\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s+(\S+)\s*;/.test(this.line)?r.uniformProcessor&&(i=r.uniformProcessor(this.line,t.isFragment,e,t.processingContext)):r.uniformBufferProcessor&&(i=r.uniformBufferProcessor(this.line,t.isFragment,t.processingContext),t.lookForClosingBracketForUniformBuffer=!0)),t.lookForClosingBracketForUniformBuffer&&-1!==this.line.indexOf("}")&&(t.lookForClosingBracketForUniformBuffer=!1,r.endOfUniformBufferProcessor&&(i=r.endOfUniformBufferProcessor(this.line,t.isFragment,t.processingContext)))}s+=i+"\n"}return this.children.forEach((i=>{s+=i.process(e,t)})),this.additionalDefineKey&&(e[this.additionalDefineKey]=this.additionalDefineValue||"true"),s}}class r{constructor(){this._lines=[]}get currentLine(){return this._lines[this.lineIndex]}get canRead(){return this.lineIndex1&&this._lines.push(e);else{const e=t.split(";");for(let t=0;t{c=c.trim(),""!==c&&(s.push(c),c="")},n=e=>{io._Stack[i],h=()=>-1===i?"!!INVALID EXPRESSION!!":o._Stack[i--];let l=0,c="";for(;l1){for(r();-1!==i&&o._OperatorPriority[a()]>=o._OperatorPriority[u];)s.push(h());n(u),l++}else c+=t;l++}for(r();-1!==i;)"("===a()?h():s.push(h());return o._InfixToPostfixCache.size>=o.InfixToPostfixCacheLimitSize&&o.ClearCache(),o._InfixToPostfixCache.set(e,{result:s,accessTime:Date.now()}),s}static ClearCache(){const e=Array.from(o._InfixToPostfixCache.entries()).sort(((e,t)=>e[1].accessTime-t[1].accessTime));for(let t=0;t":s=i>r;break;case"<":s=i=":s=i>=r;break;case"==":s=i===r;break;case"!=":s=i!==r}return s}}var d=s(5503),_=s(6741);const f=/defined\s*?\((.+?)\)/g,p=/defined\s*?\[(.+?)\]/g,g=/#include\s?<(.+)>(\((.*)\))*(\[(.*)\])*/g,m=/__decl__/,T=/light\{X\}.(\w*)/g,b=/\{X\}/g,E=[],x=/(#ifdef)|(#else)|(#elif)|(#endif)|(#ifndef)|(#if)/;function A(e){e.processor&&e.processor.initializeShaders&&e.processor.initializeShaders(e.processingContext)}function R(e,t,s,n){t.processor?.preProcessShaderCode&&(e=t.processor.preProcessShaderCode(e,t.isFragment)),S(e,t,(e=>{t.processCodeAfterIncludes&&(e=t.processCodeAfterIncludes(t.isFragment?"fragment":"vertex",e,t.defines));const a=function(e,t,s){let n=function(e,t){if(t.processor?.noPrecision)return e;const s=t.shouldUseHighPrecisionShader;return-1===e.indexOf("precision highp float")?e=s?"precision highp float;\n"+e:"precision mediump float;\n"+e:s||(e=e.replace("precision highp float","precision mediump float")),e}(e,t);if(!t.processor)return n;if(0===t.processor.shaderLanguage&&-1!==n.indexOf("#version 3")&&(n=n.replace("#version 300 es",""),!t.processor.parseGLES3))return n;const a=t.defines,o=function(e,t){const s=e.defines,i={};for(const e of s){const t=e.replace("#define","").replace(";","").trim().split(" ");i[t[0]]=t.length>1?t[1]:""}return 0===e.processor?.shaderLanguage&&(i.GL_ES="true"),i.__VERSION__=e.version,i[e.platformName]="true",(0,_.xt)(i,t?.isNDCHalfZRange,t?.useReverseDepthBuffer,t?.useExactSrgbConversions),i}(t,s);return t.processor.preProcessor&&(n=t.processor.preProcessor(n,a,o,t.isFragment,t.processingContext)),n=function(e,t,s){const n=new i,a=new r;return a.lineIndex=-1,a.lines=e.split("\n"),C(a,n),n.process(t,s)}(n,o,t),t.processor.postProcessor&&(n=t.processor.postProcessor(n,a,t.isFragment,t.processingContext,s?{drawBuffersExtensionDisabled:!s.getCaps().drawBuffersExtension}:{})),s?._features.needShaderCodeInlining&&(n=s.inlineShaderCode(n)),n}(e,t,n);s(a,e)}))}function M(e,t,s){return s.processor&&s.processor.finalizeShaders?s.processor.finalizeShaders(e,t,s.processingContext):{vertexCode:e,fragmentCode:t}}function y(e){const t=/defined\((.+)\)/.exec(e);if(t&&t.length)return new h(t[1].trim(),"!"===e[0]);const s=["==","!=",">=","<=","<",">"];let i="",r=0;for(i of s)if(r=e.indexOf(i),r>-1)break;if(-1===r)return new h(e);const n=e.substring(0,r).trim(),a=e.substring(r+i.length).trim();return new u(n,i,a)}function P(e,t){const s=new a,i=e.substring(0,t);let r=e.substring(t);return r=r.substring(0,(r.indexOf("//")+1||r.length+1)-1).trim(),s.testExpression="#ifdef"===i?new h(r):"#ifndef"===i?new h(r,!0):function(e){e=e.replace(f,"defined[$1]");const t=o.infixToPostfix(e),s=[];for(const e of t)if("||"!==e&&"&&"!==e)s.push(e);else if(s.length>=2){let t=s[s.length-1],i=s[s.length-2];s.length-=2;const r="&&"==e?new c:new l;"string"==typeof t&&(t=t.replace(p,"defined($1)")),"string"==typeof i&&(i=i.replace(p,"defined($1)")),r.leftOperand="string"==typeof i?y(i):i,r.rightOperand="string"==typeof t?y(t):t,s.push(r)}let i=s[s.length-1];return"string"==typeof i&&(i=i.replace(p,"defined($1)")),"string"==typeof i?y(i):i}(r),s}function v(e,t,s){let r=e.currentLine;for(;C(e,s);){r=e.currentLine;const n=r.substring(0,5).toLowerCase();if("#else"===n){const s=new i;return t.children.push(s),void C(e,s)}if("#elif"===n){const e=P(r,5);t.children.push(e),s=e}}}function C(e,t){for(;e.canRead;){e.lineIndex++;const s=e.currentLine;if(s.indexOf("#")>=0){const i=x.exec(s);if(i&&i.length){switch(i[0]){case"#ifdef":{const i=new n;t.children.push(i);const r=P(s,6);i.children.push(r),v(e,i,r);break}case"#else":case"#elif":return!0;case"#endif":return!1;case"#ifndef":{const i=new n;t.children.push(i);const r=P(s,7);i.children.push(r),v(e,i,r);break}case"#if":{const i=new n,r=P(s,3);t.children.push(i),i.children.push(r),v(e,i,r);break}}continue}}const r=new i;if(r.line=s,t.children.push(r),"#"===s[0]&&"d"===s[1]){const e=s.replace(";","").split(" ");r.additionalDefineKey=e[1],3===e.length&&(r.additionalDefineValue=e[2])}}return!1}function S(e,t,s){let i;for(E.length=0;null!==(i=g.exec(e));)E.push(i);let r=String(e),n=[e],a=!1;for(const e of E){let i=e[1];if(-1!==i.indexOf("__decl__")&&(i=i.replace(m,""),t.supportsUniformBuffers&&(i=i.replace("Vertex","Ubo").replace("Fragment","Ubo")),i+="Declaration"),!t.includesShadersStore[i]){const e=t.shadersRepository+"ShadersInclude/"+i+".fx";return void I.loadFile(e,(e=>{t.includesShadersStore[i]=e,S(n.join(""),t,s)}))}{let s=t.includesShadersStore[i];if(e[2]){const t=e[3].split(",");for(let e=0;et+"{X}"))),s+=a.replace(b,e.toString())+"\n"}else t.supportsUniformBuffers||(s=s.replace(T,((e,t)=>t+"{X}"))),s=s.replace(b,i)}const r=[];for(const t of n){const i=t.split(e[0]);for(let e=0;e=0||s.indexOf("#include <")>=0}}E.length=0,r=n.join(""),a?S(r.toString(),t,s):s(r)}const I={loadFile:(e,t,s,i,r,n)=>{throw(0,d.n)("FileTools")}}},7716:(e,t,s)=>{s.d(t,{d:()=>i});class i{get underlyingResource(){return this._webGLTexture}constructor(e=null,t){if(this._MSAARenderBuffers=null,this._context=t,!e&&!(e=t.createTexture()))throw new Error("Unable to create webGL texture");this.set(e)}setUsage(){}set(e){this._webGLTexture=e}reset(){this._webGLTexture=null,this._MSAARenderBuffers=null}addMSAARenderBuffer(e){this._MSAARenderBuffers||(this._MSAARenderBuffers=[]),this._MSAARenderBuffers.push(e)}releaseMSAARenderBuffers(){if(this._MSAARenderBuffers){for(const e of this._MSAARenderBuffers)this._context.deleteRenderbuffer(e);this._MSAARenderBuffers=null}}getMSAARenderBuffer(e=0){return this._MSAARenderBuffers?.[e]??null}release(){this.releaseMSAARenderBuffers(),this._webGLTexture&&this._context.deleteTexture(this._webGLTexture),this.reset()}}},6741:(e,t,s)=>{s.d(t,{W0:()=>a,iL:()=>n,kZ:()=>h,sg:()=>r,xt:()=>o});var i=s(5503);s(8790);const r={};function n(e,t,s=""){return s+(t?t+"\n":"")+e}function a(e,t,s,n,a,o,h){const l=h||r.loadFile;if(l)return l(e,t,s,n,a,o);throw(0,i.n)("FileTools")}function o(e,t,s,i){if(e)return t?e.IS_NDC_HALF_ZRANGE="":delete e.IS_NDC_HALF_ZRANGE,s?e.USE_REVERSE_DEPTHBUFFER="":delete e.USE_REVERSE_DEPTHBUFFER,void(i?e.USE_EXACT_SRGB_CONVERSIONS="":delete e.USE_EXACT_SRGB_CONVERSIONS);{let e="";return t&&(e+="#define IS_NDC_HALF_ZRANGE"),s&&(e&&(e+="\n"),e+="#define USE_REVERSE_DEPTHBUFFER"),i&&(e&&(e+="\n"),e+="#define USE_EXACT_SRGB_CONVERSIONS"),e}}function h(e,t,s=!1,i){switch(e){case 3:{const e=(ArrayBuffer,new Int8Array(t));return i&&e.set(new Int8Array(i)),e}case 0:{const e=(ArrayBuffer,new Uint8Array(t));return i&&e.set(new Uint8Array(i)),e}case 4:{const e=t instanceof ArrayBuffer?new Int16Array(t):new Int16Array(s?t/2:t);return i&&e.set(new Int16Array(i)),e}case 5:case 8:case 9:case 10:case 2:{const e=t instanceof ArrayBuffer?new Uint16Array(t):new Uint16Array(s?t/2:t);return i&&e.set(new Uint16Array(i)),e}case 6:{const e=t instanceof ArrayBuffer?new Int32Array(t):new Int32Array(s?t/4:t);return i&&e.set(new Int32Array(i)),e}case 7:case 11:case 12:case 13:case 14:case 15:{const e=t instanceof ArrayBuffer?new Uint32Array(t):new Uint32Array(s?t/4:t);return i&&e.set(new Uint32Array(i)),e}case 1:{const e=t instanceof ArrayBuffer?new Float32Array(t):new Float32Array(s?t/4:t);return i&&e.set(new Float32Array(i)),e}}const r=(ArrayBuffer,new Uint8Array(t));return i&&r.set(new Uint8Array(i)),r}},6326:(e,t,s)=>{s.d(t,{$:()=>b});var i=s(6315),r=s(1137),n=s(4420),a=s(215),o=s(6237);class h{constructor(e=!0){this._isDepthTestDirty=!1,this._isDepthMaskDirty=!1,this._isDepthFuncDirty=!1,this._isCullFaceDirty=!1,this._isCullDirty=!1,this._isZOffsetDirty=!1,this._isFrontFaceDirty=!1,e&&this.reset()}get isDirty(){return this._isDepthFuncDirty||this._isDepthTestDirty||this._isDepthMaskDirty||this._isCullFaceDirty||this._isCullDirty||this._isZOffsetDirty||this._isFrontFaceDirty}get zOffset(){return this._zOffset}set zOffset(e){this._zOffset!==e&&(this._zOffset=e,this._isZOffsetDirty=!0)}get zOffsetUnits(){return this._zOffsetUnits}set zOffsetUnits(e){this._zOffsetUnits!==e&&(this._zOffsetUnits=e,this._isZOffsetDirty=!0)}get cullFace(){return this._cullFace}set cullFace(e){this._cullFace!==e&&(this._cullFace=e,this._isCullFaceDirty=!0)}get cull(){return this._cull}set cull(e){this._cull!==e&&(this._cull=e,this._isCullDirty=!0)}get depthFunc(){return this._depthFunc}set depthFunc(e){this._depthFunc!==e&&(this._depthFunc=e,this._isDepthFuncDirty=!0)}get depthMask(){return this._depthMask}set depthMask(e){this._depthMask!==e&&(this._depthMask=e,this._isDepthMaskDirty=!0)}get depthTest(){return this._depthTest}set depthTest(e){this._depthTest!==e&&(this._depthTest=e,this._isDepthTestDirty=!0)}get frontFace(){return this._frontFace}set frontFace(e){this._frontFace!==e&&(this._frontFace=e,this._isFrontFaceDirty=!0)}reset(){this._depthMask=!0,this._depthTest=!0,this._depthFunc=null,this._cullFace=null,this._cull=null,this._zOffset=0,this._zOffsetUnits=0,this._frontFace=null,this._isDepthTestDirty=!0,this._isDepthMaskDirty=!0,this._isDepthFuncDirty=!1,this._isCullFaceDirty=!1,this._isCullDirty=!1,this._isZOffsetDirty=!0,this._isFrontFaceDirty=!1}apply(e){this.isDirty&&(this._isCullDirty&&(this.cull?e.enable(e.CULL_FACE):e.disable(e.CULL_FACE),this._isCullDirty=!1),this._isCullFaceDirty&&(e.cullFace(this.cullFace),this._isCullFaceDirty=!1),this._isDepthMaskDirty&&(e.depthMask(this.depthMask),this._isDepthMaskDirty=!1),this._isDepthTestDirty&&(this.depthTest?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST),this._isDepthTestDirty=!1),this._isDepthFuncDirty&&(e.depthFunc(this.depthFunc),this._isDepthFuncDirty=!1),this._isZOffsetDirty&&(this.zOffset||this.zOffsetUnits?(e.enable(e.POLYGON_OFFSET_FILL),e.polygonOffset(this.zOffset,this.zOffsetUnits)):e.disable(e.POLYGON_OFFSET_FILL),this._isZOffsetDirty=!1),this._isFrontFaceDirty&&(e.frontFace(this.frontFace),this._isFrontFaceDirty=!1))}}class l{get isDirty(){return this._isStencilTestDirty||this._isStencilMaskDirty||this._isStencilFuncDirty||this._isStencilOpDirty}get func(){return this._func}set func(e){this._func!==e&&(this._func=e,this._isStencilFuncDirty=!0)}get funcRef(){return this._funcRef}set funcRef(e){this._funcRef!==e&&(this._funcRef=e,this._isStencilFuncDirty=!0)}get funcMask(){return this._funcMask}set funcMask(e){this._funcMask!==e&&(this._funcMask=e,this._isStencilFuncDirty=!0)}get opStencilFail(){return this._opStencilFail}set opStencilFail(e){this._opStencilFail!==e&&(this._opStencilFail=e,this._isStencilOpDirty=!0)}get opDepthFail(){return this._opDepthFail}set opDepthFail(e){this._opDepthFail!==e&&(this._opDepthFail=e,this._isStencilOpDirty=!0)}get opStencilDepthPass(){return this._opStencilDepthPass}set opStencilDepthPass(e){this._opStencilDepthPass!==e&&(this._opStencilDepthPass=e,this._isStencilOpDirty=!0)}get mask(){return this._mask}set mask(e){this._mask!==e&&(this._mask=e,this._isStencilMaskDirty=!0)}get enabled(){return this._enabled}set enabled(e){this._enabled!==e&&(this._enabled=e,this._isStencilTestDirty=!0)}constructor(e=!0){this._isStencilTestDirty=!1,this._isStencilMaskDirty=!1,this._isStencilFuncDirty=!1,this._isStencilOpDirty=!1,this.useStencilGlobalOnly=!1,e&&this.reset()}reset(){this.stencilMaterial=void 0,this.stencilGlobal?.reset(),this._isStencilTestDirty=!0,this._isStencilMaskDirty=!0,this._isStencilFuncDirty=!0,this._isStencilOpDirty=!0}apply(e){if(!e)return;const t=!this.useStencilGlobalOnly&&!!this.stencilMaterial?.enabled;this.enabled=t?this.stencilMaterial.enabled:this.stencilGlobal.enabled,this.func=t?this.stencilMaterial.func:this.stencilGlobal.func,this.funcRef=t?this.stencilMaterial.funcRef:this.stencilGlobal.funcRef,this.funcMask=t?this.stencilMaterial.funcMask:this.stencilGlobal.funcMask,this.opStencilFail=t?this.stencilMaterial.opStencilFail:this.stencilGlobal.opStencilFail,this.opDepthFail=t?this.stencilMaterial.opDepthFail:this.stencilGlobal.opDepthFail,this.opStencilDepthPass=t?this.stencilMaterial.opStencilDepthPass:this.stencilGlobal.opStencilDepthPass,this.mask=t?this.stencilMaterial.mask:this.stencilGlobal.mask,this.isDirty&&(this._isStencilTestDirty&&(this.enabled?e.enable(e.STENCIL_TEST):e.disable(e.STENCIL_TEST),this._isStencilTestDirty=!1),this._isStencilMaskDirty&&(e.stencilMask(this.mask),this._isStencilMaskDirty=!1),this._isStencilFuncDirty&&(e.stencilFunc(this.func,this.funcRef,this.funcMask),this._isStencilFuncDirty=!1),this._isStencilOpDirty&&(e.stencilOp(this.opStencilFail,this.opDepthFail,this.opStencilDepthPass),this._isStencilOpDirty=!1))}}class c{constructor(){this.reset()}reset(){this.enabled=!1,this.mask=255,this.func=c.ALWAYS,this.funcRef=1,this.funcMask=255,this.opStencilFail=c.KEEP,this.opDepthFail=c.KEEP,this.opStencilDepthPass=c.REPLACE}get stencilFunc(){return this.func}set stencilFunc(e){this.func=e}get stencilFuncRef(){return this.funcRef}set stencilFuncRef(e){this.funcRef=e}get stencilFuncMask(){return this.funcMask}set stencilFuncMask(e){this.funcMask=e}get stencilOpStencilFail(){return this.opStencilFail}set stencilOpStencilFail(e){this.opStencilFail=e}get stencilOpDepthFail(){return this.opDepthFail}set stencilOpDepthFail(e){this.opDepthFail=e}get stencilOpStencilDepthPass(){return this.opStencilDepthPass}set stencilOpStencilDepthPass(e){this.opStencilDepthPass=e}get stencilMask(){return this.mask}set stencilMask(e){this.mask=e}get stencilTest(){return this.enabled}set stencilTest(e){this.enabled=e}}c.ALWAYS=519,c.KEEP=7680,c.REPLACE=7681;class u{constructor(){this._blendFunctionParameters=new Array(4),this._blendEquationParameters=new Array(2),this._blendConstants=new Array(4),this._isBlendConstantsDirty=!1,this._alphaBlend=!1,this._isAlphaBlendDirty=!1,this._isBlendFunctionParametersDirty=!1,this._isBlendEquationParametersDirty=!1,this.reset()}get isDirty(){return this._isAlphaBlendDirty||this._isBlendFunctionParametersDirty||this._isBlendEquationParametersDirty}get alphaBlend(){return this._alphaBlend}set alphaBlend(e){this._alphaBlend!==e&&(this._alphaBlend=e,this._isAlphaBlendDirty=!0)}setAlphaBlendConstants(e,t,s,i){this._blendConstants[0]===e&&this._blendConstants[1]===t&&this._blendConstants[2]===s&&this._blendConstants[3]===i||(this._blendConstants[0]=e,this._blendConstants[1]=t,this._blendConstants[2]=s,this._blendConstants[3]=i,this._isBlendConstantsDirty=!0)}setAlphaBlendFunctionParameters(e,t,s,i){this._blendFunctionParameters[0]===e&&this._blendFunctionParameters[1]===t&&this._blendFunctionParameters[2]===s&&this._blendFunctionParameters[3]===i||(this._blendFunctionParameters[0]=e,this._blendFunctionParameters[1]=t,this._blendFunctionParameters[2]=s,this._blendFunctionParameters[3]=i,this._isBlendFunctionParametersDirty=!0)}setAlphaEquationParameters(e,t){this._blendEquationParameters[0]===e&&this._blendEquationParameters[1]===t||(this._blendEquationParameters[0]=e,this._blendEquationParameters[1]=t,this._isBlendEquationParametersDirty=!0)}reset(){this._alphaBlend=!1,this._blendFunctionParameters[0]=null,this._blendFunctionParameters[1]=null,this._blendFunctionParameters[2]=null,this._blendFunctionParameters[3]=null,this._blendEquationParameters[0]=null,this._blendEquationParameters[1]=null,this._blendConstants[0]=null,this._blendConstants[1]=null,this._blendConstants[2]=null,this._blendConstants[3]=null,this._isAlphaBlendDirty=!0,this._isBlendFunctionParametersDirty=!1,this._isBlendEquationParametersDirty=!1,this._isBlendConstantsDirty=!1}apply(e){this.isDirty&&(this._isAlphaBlendDirty&&(this._alphaBlend?e.enable(e.BLEND):e.disable(e.BLEND),this._isAlphaBlendDirty=!1),this._isBlendFunctionParametersDirty&&(e.blendFuncSeparate(this._blendFunctionParameters[0],this._blendFunctionParameters[1],this._blendFunctionParameters[2],this._blendFunctionParameters[3]),this._isBlendFunctionParametersDirty=!1),this._isBlendEquationParametersDirty&&(e.blendEquationSeparate(this._blendEquationParameters[0],this._blendEquationParameters[1]),this._isBlendEquationParametersDirty=!1),this._isBlendConstantsDirty&&(e.blendColor(this._blendConstants[0],this._blendConstants[1],this._blendConstants[2],this._blendConstants[3]),this._isBlendConstantsDirty=!1))}}var d=s(5503),_=s(854),f=s(8790),p=s(9848),g=s(6741),m=s(8454);function T(e,t){if((0,f.BA)()){const{requestAnimationFrame:s}=t||window;if("function"==typeof s)return s(e)}else if("function"==typeof requestAnimationFrame)return requestAnimationFrame(e);return setTimeout(e,16)}class b{get frameId(){return this._frameId}get isWebGPU(){return this._isWebGPU}_getShaderProcessor(e){return this._shaderProcessor}get shaderPlatformName(){return this._shaderPlatformName}_clearEmptyResources(){this._emptyTexture=null,this._emptyCubeTexture=null,this._emptyTexture3D=null,this._emptyTexture2DArray=null}get useReverseDepthBuffer(){return this._useReverseDepthBuffer}set useReverseDepthBuffer(e){e!==this._useReverseDepthBuffer&&(this._useReverseDepthBuffer=e,this._depthCullingState.depthFunc=e?518:515)}setColorWrite(e){e!==this._colorWrite&&(this._colorWriteChanged=!0,this._colorWrite=e)}getColorWrite(){return this._colorWrite}get depthCullingState(){return this._depthCullingState}get alphaState(){return this._alphaState}get stencilState(){return this._stencilState}get stencilStateComposer(){return this._stencilStateComposer}_getGlobalDefines(e){if(e)return this.isNDCHalfZRange?e.IS_NDC_HALF_ZRANGE="":delete e.IS_NDC_HALF_ZRANGE,this.useReverseDepthBuffer?e.USE_REVERSE_DEPTHBUFFER="":delete e.USE_REVERSE_DEPTHBUFFER,void(this.useExactSrgbConversions?e.USE_EXACT_SRGB_CONVERSIONS="":delete e.USE_EXACT_SRGB_CONVERSIONS);{let e="";return this.isNDCHalfZRange&&(e+="#define IS_NDC_HALF_ZRANGE"),this.useReverseDepthBuffer&&(e&&(e+="\n"),e+="#define USE_REVERSE_DEPTHBUFFER"),this.useExactSrgbConversions&&(e&&(e+="\n"),e+="#define USE_EXACT_SRGB_CONVERSIONS"),e}}_rebuildInternalTextures(){const e=this._internalTexturesCache.slice();for(const t of e)t._rebuild()}_rebuildRenderTargetWrappers(){const e=this._renderTargetWrapperCache.slice();for(const t of e)t._rebuild()}_rebuildEffects(){for(const e in this._compiledEffects){const t=this._compiledEffects[e];t._pipelineContext=null,t._prepareEffect()}n.M.ResetCache()}_rebuildGraphicsResources(){this.wipeCaches(!0),this._rebuildEffects(),this._rebuildComputeEffects?.(),this._rebuildBuffers(),this._rebuildInternalTextures(),this._rebuildTextures(),this._rebuildRenderTargetWrappers(),this.wipeCaches(!0)}_flagContextRestored(){r.V.Warn(this.name+" context successfully restored."),this.onContextRestoredObservable.notifyObservers(this),this._contextWasLost=!1}_restoreEngineAfterContextLost(e){setTimeout((async()=>{this._clearEmptyResources();const t=this._depthCullingState.depthTest,s=this._depthCullingState.depthFunc,i=this._depthCullingState.depthMask,r=this._stencilState.stencilTest;await e(),this._rebuildGraphicsResources(),this._depthCullingState.depthTest=t,this._depthCullingState.depthFunc=s,this._depthCullingState.depthMask=i,this._stencilState.stencilTest=r,this._flagContextRestored()}),0)}get isDisposed(){return this._isDisposed}get snapshotRendering(){return!1}set snapshotRendering(e){}get snapshotRenderingMode(){return 0}set snapshotRenderingMode(e){}getClassName(){return"AbstractEngine"}get emptyTexture(){return this._emptyTexture||(this._emptyTexture=this.createRawTexture(new Uint8Array(4),1,1,5,!1,!1,1)),this._emptyTexture}get emptyTexture3D(){return this._emptyTexture3D||(this._emptyTexture3D=this.createRawTexture3D(new Uint8Array(4),1,1,1,5,!1,!1,1)),this._emptyTexture3D}get emptyTexture2DArray(){return this._emptyTexture2DArray||(this._emptyTexture2DArray=this.createRawTexture2DArray(new Uint8Array(4),1,1,1,5,!1,!1,1)),this._emptyTexture2DArray}get emptyCubeTexture(){if(!this._emptyCubeTexture){const e=new Uint8Array(4),t=[e,e,e,e,e,e];this._emptyCubeTexture=this.createRawCubeTexture(t,1,5,0,!1,!1,1)}return this._emptyCubeTexture}get activeRenderLoops(){return this._activeRenderLoops}stopRenderLoop(e){if(!e)return this._activeRenderLoops.length=0,void this._cancelFrame();const t=this._activeRenderLoops.indexOf(e);t>=0&&(this._activeRenderLoops.splice(t,1),0==this._activeRenderLoops.length&&this._cancelFrame())}_cancelFrame(){if(0!==this._frameHandler){const e=this._frameHandler;if(this._frameHandler=0,(0,f.BA)()){const{cancelAnimationFrame:t}=this.getHostWindow()||window;if("function"==typeof t)return t(e)}else if("function"==typeof cancelAnimationFrame)return cancelAnimationFrame(e);return clearTimeout(e)}}beginFrame(){this.onBeginFrameObservable.notifyObservers(this)}endFrame(){this._frameId++,this.onEndFrameObservable.notifyObservers(this)}_renderLoop(){if(this._frameHandler=0,!this._contextWasLost){let e=!0;(this._isDisposed||!this.renderEvenInBackground&&this._windowIsBackground)&&(e=!1),e&&(this.beginFrame(),this._renderViews()||this._renderFrame(),this.endFrame())}this._activeRenderLoops.length>0&&0===this._frameHandler&&(this._frameHandler=this._queueNewFrame(this._boundRenderFunction,this.getHostWindow()))}_renderFrame(){for(let e=0;e-1?e.substring(P).toLowerCase():"");v.indexOf("?")>-1&&(v=v.split("?")[0]);const C=(0,m.gT)(v,g);n&&n.addPendingData(M),M.url=e,M.generateMipMaps=!t,M.samplingMode=a,M.invertY=s,M._useSRGBBuffer=this._getUseSRGBBuffer(!!E,t),this._doNotHandleContextLost||(M._buffer=u);let S=null;o&&!d&&(S=M.onLoadedObservable.add(o)),d||this._internalTexturesCache.push(M);const I=(s,d)=>{n&&n.removePendingData(M),e===y?(S&&M.onLoadedObservable.remove(S),i.q.UseFallbackTexture&&e!==i.q.FallbackTexture&&this._createTextureBase(i.q.FallbackTexture,t,M.invertY,n,a,null,h,l,c,u,M),s=(s||"Unknown error")+(i.q.UseFallbackTexture?" - Fallback texture was used":""),M.onErrorObservable.notifyObservers({message:s,exception:d}),h&&h(s,d)):(r.V.Warn(`Failed to load ${e}, falling back to ${y}`),this._createTextureBase(y,t,M.invertY,n,a,o,h,l,c,u,M,f,p,g,T,E))};if(C){const t=async e=>{(await C).loadData(e,M,((e,t,s,i,r,o)=>{o?I("TextureLoader failed to load data"):l(M,v,n,{width:e,height:t},M.invertY,!s,i,(()=>(r(),!1)),a)}),T)};u?u instanceof ArrayBuffer?t(new Uint8Array(u)):ArrayBuffer.isView(u)?t(u):h&&h("Unable to load: only ArrayBuffer or ArrayBufferView is supported",null):this._loadFile(e,(e=>t(new Uint8Array(e))),void 0,n?n.offlineProvider:void 0,!0,((e,t)=>{I("Unable to load "+(e&&e.responseURL,t))}))}else{const s=e=>{A&&!this._doNotHandleContextLost&&(M._buffer=e),l(M,v,n,e,M.invertY,t,!1,c,a)};!x||R?u&&("string"==typeof u.decoding||u.close)?s(u):b._FileToolsLoadImage(e||"",s,I,n?n.offlineProvider:null,g,M.invertY&&this._features.needsInvertingBitmap?{imageOrientation:"flipY"}:void 0):"string"==typeof u||u instanceof ArrayBuffer||ArrayBuffer.isView(u)||u instanceof Blob?b._FileToolsLoadImage(u,s,I,n?n.offlineProvider:null,g,M.invertY&&this._features.needsInvertingBitmap?{imageOrientation:"flipY"}:void 0):u&&s(u)}return M}_rebuildBuffers(){for(const e of this._uniformBuffers)e._rebuildAfterContextLost()}get _shouldUseHighPrecisionShader(){return!(!this._caps.highPrecisionShaderSupported||!this._highPrecisionShadersAllowed)}getHostDocument(){return this._renderingCanvas&&this._renderingCanvas.ownerDocument?this._renderingCanvas.ownerDocument:(0,f.Nf)()?document:null}getLoadedTexturesCache(){return this._internalTexturesCache}clearInternalTexturesCache(){this._internalTexturesCache.length=0}getCaps(){return this._caps}resetTextureCache(){for(const e in this._boundTexturesCache)Object.prototype.hasOwnProperty.call(this._boundTexturesCache,e)&&(this._boundTexturesCache[e]=null);this._currentTextureChannel=-1}get name(){return this._name}set name(e){this._name=e}static get NpmPackage(){return"babylonjs@7.35.1"}static get Version(){return"7.35.1"}getRenderingCanvas(){return this._renderingCanvas}getAudioContext(){return this._audioContext}getAudioDestination(){return this._audioDestination}setHardwareScalingLevel(e){this._hardwareScalingLevel=e,this.resize()}getHardwareScalingLevel(){return this._hardwareScalingLevel}get doNotHandleContextLost(){return this._doNotHandleContextLost}set doNotHandleContextLost(e){this._doNotHandleContextLost=e}get isStencilEnable(){return this._isStencilEnable}getCreationOptions(){return this._creationOptions}constructor(e,t,s){this._colorWrite=!0,this._colorWriteChanged=!0,this._depthCullingState=new h,this._stencilStateComposer=new l,this._stencilState=new c,this._alphaState=new u,this._alphaMode=1,this._alphaEquation=0,this._activeRequests=[],this._badOS=!1,this._badDesktopOS=!1,this._compatibilityMode=!0,this._internalTexturesCache=new Array,this._currentRenderTarget=null,this._boundTexturesCache={},this._activeChannel=0,this._currentTextureChannel=-1,this._viewportCached={x:0,y:0,z:0,w:0},this._isWebGPU=!1,this.onCanvasBlurObservable=new p.cP,this.onCanvasFocusObservable=new p.cP,this.onNewSceneAddedObservable=new p.cP,this.onResizeObservable=new p.cP,this.onCanvasPointerOutObservable=new p.cP,this.disablePerformanceMonitorInBackground=!1,this.disableVertexArrayObjects=!1,this._frameId=0,this.hostInformation={isMobile:!1},this.isFullscreen=!1,this.enableOfflineSupport=!1,this.disableManifestCheck=!1,this.disableContextMenu=!0,this.currentRenderPassId=0,this.isPointerLock=!1,this.postProcesses=[],this.canvasTabIndex=1,this._contextWasLost=!1,this._useReverseDepthBuffer=!1,this.isNDCHalfZRange=!1,this.hasOriginBottomLeft=!0,this._renderTargetWrapperCache=new Array,this._compiledEffects={},this._isDisposed=!1,this.scenes=[],this._virtualScenes=new Array,this.onBeforeTextureInitObservable=new p.cP,this.renderEvenInBackground=!0,this.preventCacheWipeBetweenFrames=!1,this._frameHandler=0,this._activeRenderLoops=new Array,this._windowIsBackground=!1,this._boundRenderFunction=()=>this._renderLoop(),this.onBeforeShaderCompilationObservable=new p.cP,this.onAfterShaderCompilationObservable=new p.cP,this.onBeginFrameObservable=new p.cP,this.onEndFrameObservable=new p.cP,this._transformTextureUrl=null,this._uniformBuffers=new Array,this._storageBuffers=new Array,this._highPrecisionShadersAllowed=!0,this.onContextLostObservable=new p.cP,this.onContextRestoredObservable=new p.cP,this._name="",this.premultipliedAlpha=!0,this.adaptToDeviceRatio=!1,this._lastDevicePixelRatio=1,this._doNotHandleContextLost=!1,this.cullBackFaces=null,this._renderPassNames=["main"],this._fps=60,this._deltaTime=0,this._deterministicLockstep=!1,this._lockstepMaxSteps=4,this._timeStep=1/60,this.onDisposeObservable=new p.cP,i.q.Instances.push(this),this.startTime=o.j.Now,this._stencilStateComposer.stencilGlobal=this._stencilState,a.I.SetMatrixPrecision(!!t.useHighPrecisionMatrix),(0,f.XD)()&&navigator.userAgent&&(this._badOS=/iPad/i.test(navigator.userAgent)||/iPhone/i.test(navigator.userAgent),this._badDesktopOS=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)),this.adaptToDeviceRatio=s??!1,t.antialias=e??t.antialias,t.deterministicLockstep=t.deterministicLockstep??!1,t.lockstepMaxSteps=t.lockstepMaxSteps??4,t.timeStep=t.timeStep??1/60,t.audioEngine=t.audioEngine??!0,t.stencil=t.stencil??!0,this._audioContext=t.audioEngineOptions?.audioContext??null,this._audioDestination=t.audioEngineOptions?.audioDestination??null,this.premultipliedAlpha=t.premultipliedAlpha??!0,this._doNotHandleContextLost=!!t.doNotHandleContextLost,this._isStencilEnable=!!t.stencil,this.useExactSrgbConversions=t.useExactSrgbConversions??!1;const r=(0,f.BA)()&&window.devicePixelRatio||1,n=t.limitDeviceRatio||r;s=s||t.adaptToDeviceRatio||!1,this._hardwareScalingLevel=s?1/Math.min(n,r):1,this._lastDevicePixelRatio=r,this._creationOptions=t}resize(e=!1){let t,s;if(this.adaptToDeviceRatio){const e=(0,f.BA)()&&window.devicePixelRatio||1,t=this._lastDevicePixelRatio/e;this._lastDevicePixelRatio=e,this._hardwareScalingLevel*=t}if((0,f.BA)()&&(0,f.Nf)())if(this._renderingCanvas){const e=this._renderingCanvas.getBoundingClientRect?this._renderingCanvas.getBoundingClientRect():{width:this._renderingCanvas.width*this._hardwareScalingLevel,height:this._renderingCanvas.height*this._hardwareScalingLevel};t=this._renderingCanvas.clientWidth||e.width||this._renderingCanvas.width||100,s=this._renderingCanvas.clientHeight||e.height||this._renderingCanvas.height||100}else t=window.innerWidth,s=window.innerHeight;else t=this._renderingCanvas?this._renderingCanvas.width:100,s=this._renderingCanvas?this._renderingCanvas.height:100;this.setSize(t/this._hardwareScalingLevel,s/this._hardwareScalingLevel,e)}setSize(e,t,s=!1){if(!this._renderingCanvas)return!1;if(e|=0,t|=0,!s&&this._renderingCanvas.width===e&&this._renderingCanvas.height===t)return!1;if(this._renderingCanvas.width=e,this._renderingCanvas.height=t,this.scenes){for(let e=0;e{const e=navigator.userAgent;this.hostInformation.isMobile=-1!==e.indexOf("Mobile")||-1!==e.indexOf("Mac")&&(0,f.Nf)()&&"ontouchend"in document},this._checkForMobile(),(0,f.BA)()&&window.addEventListener("resize",this._checkForMobile))}createVideoElement(e){return document.createElement("video")}_reportDrawCall(e=1){this._drawCalls?.addCount(e,!1)}getFps(){return this._fps}getDeltaTime(){return this._deltaTime}isDeterministicLockStep(){return this._deterministicLockstep}getLockstepMaxSteps(){return this._lockstepMaxSteps}getTimeStep(){return 1e3*this._timeStep}_createImageBitmapFromSource(e,t){throw new Error("createImageBitmapFromSource is not implemented")}createImageBitmap(e,t){return createImageBitmap(e,t)}resizeImageBitmap(e,t,s){throw new Error("resizeImageBitmap is not implemented")}getFontOffset(e){throw new Error("getFontOffset is not implemented")}static _CreateCanvas(e,t){if("undefined"==typeof document)return new OffscreenCanvas(e,t);const s=document.createElement("canvas");return s.width=e,s.height=t,s}createCanvas(e,t){return b._CreateCanvas(e,t)}static _FileToolsLoadImage(e,t,s,i,r,n){throw(0,d.n)("FileTools")}_loadFile(e,t,s,i,r,n){const a=(0,g.W0)(e,t,s,i,r,n);return this._activeRequests.push(a),a.onCompleteObservable.add((()=>{const e=this._activeRequests.indexOf(a);-1!==e&&this._activeRequests.splice(e,1)})),a}static _FileToolsLoadFile(e,t,s,i,r,n){if(g.sg.loadFile)return g.sg.loadFile(e,t,s,i,r,n);throw(0,d.n)("FileTools")}dispose(){for(this.releaseEffects(),this._isDisposed=!0,this.stopRenderLoop(),this._emptyTexture&&(this._releaseTexture(this._emptyTexture),this._emptyTexture=null),this._emptyCubeTexture&&(this._releaseTexture(this._emptyCubeTexture),this._emptyCubeTexture=null),this._renderingCanvas=null,this.onBeforeTextureInitObservable&&this.onBeforeTextureInitObservable.clear();this.postProcesses.length;)this.postProcesses[0].dispose();for(;this.scenes.length;)this.scenes[0].dispose();for(;this._virtualScenes.length;)this._virtualScenes[0].dispose();this.releaseComputeEffects?.(),n.M.ResetCache();for(const e of this._activeRequests)e.abort();this._boundRenderFunction=null,this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onResizeObservable.clear(),this.onCanvasBlurObservable.clear(),this.onCanvasFocusObservable.clear(),this.onCanvasPointerOutObservable.clear(),this.onNewSceneAddedObservable.clear(),(0,f.BA)()&&window.removeEventListener("resize",this._checkForMobile);const e=i.q.Instances.indexOf(this);e>=0&&i.q.Instances.splice(e,1),i.q.Instances.length||(i.q.OnEnginesDisposedObservable.notifyObservers(this),i.q.OnEnginesDisposedObservable.clear()),this.onBeginFrameObservable.clear(),this.onEndFrameObservable.clear()}static DefaultLoadingScreenFactory(e){throw(0,d.n)("LoadingScreen")}static MarkAllMaterialsAsDirty(e,t){for(let s=0;s{s.d(t,{Y:()=>i});class i{}i.AUTOSAMPLERSUFFIX="Sampler",i.DISABLEUA="#define DISABLE_UNIFORMITY_ANALYSIS",i.ALPHA_DISABLE=0,i.ALPHA_ADD=1,i.ALPHA_COMBINE=2,i.ALPHA_SUBTRACT=3,i.ALPHA_MULTIPLY=4,i.ALPHA_MAXIMIZED=5,i.ALPHA_ONEONE=6,i.ALPHA_PREMULTIPLIED=7,i.ALPHA_PREMULTIPLIED_PORTERDUFF=8,i.ALPHA_INTERPOLATE=9,i.ALPHA_SCREENMODE=10,i.ALPHA_ONEONE_ONEONE=11,i.ALPHA_ALPHATOCOLOR=12,i.ALPHA_REVERSEONEMINUS=13,i.ALPHA_SRC_DSTONEMINUSSRCALPHA=14,i.ALPHA_ONEONE_ONEZERO=15,i.ALPHA_EXCLUSION=16,i.ALPHA_LAYER_ACCUMULATE=17,i.ALPHA_EQUATION_ADD=0,i.ALPHA_EQUATION_SUBSTRACT=1,i.ALPHA_EQUATION_REVERSE_SUBTRACT=2,i.ALPHA_EQUATION_MAX=3,i.ALPHA_EQUATION_MIN=4,i.ALPHA_EQUATION_DARKEN=5,i.DELAYLOADSTATE_NONE=0,i.DELAYLOADSTATE_LOADED=1,i.DELAYLOADSTATE_LOADING=2,i.DELAYLOADSTATE_NOTLOADED=4,i.NEVER=512,i.ALWAYS=519,i.LESS=513,i.EQUAL=514,i.LEQUAL=515,i.GREATER=516,i.GEQUAL=518,i.NOTEQUAL=517,i.KEEP=7680,i.ZERO=0,i.REPLACE=7681,i.INCR=7682,i.DECR=7683,i.INVERT=5386,i.INCR_WRAP=34055,i.DECR_WRAP=34056,i.TEXTURE_CLAMP_ADDRESSMODE=0,i.TEXTURE_WRAP_ADDRESSMODE=1,i.TEXTURE_MIRROR_ADDRESSMODE=2,i.TEXTURE_CREATIONFLAG_STORAGE=1,i.TEXTUREFORMAT_ALPHA=0,i.TEXTUREFORMAT_LUMINANCE=1,i.TEXTUREFORMAT_LUMINANCE_ALPHA=2,i.TEXTUREFORMAT_RGB=4,i.TEXTUREFORMAT_RGBA=5,i.TEXTUREFORMAT_RED=6,i.TEXTUREFORMAT_R=6,i.TEXTUREFORMAT_RG=7,i.TEXTUREFORMAT_RED_INTEGER=8,i.TEXTUREFORMAT_R_INTEGER=8,i.TEXTUREFORMAT_RG_INTEGER=9,i.TEXTUREFORMAT_RGB_INTEGER=10,i.TEXTUREFORMAT_RGBA_INTEGER=11,i.TEXTUREFORMAT_BGRA=12,i.TEXTUREFORMAT_DEPTH24_STENCIL8=13,i.TEXTUREFORMAT_DEPTH32_FLOAT=14,i.TEXTUREFORMAT_DEPTH16=15,i.TEXTUREFORMAT_DEPTH24=16,i.TEXTUREFORMAT_DEPTH24UNORM_STENCIL8=17,i.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8=18,i.TEXTUREFORMAT_STENCIL8=19,i.TEXTUREFORMAT_UNDEFINED=4294967295,i.TEXTUREFORMAT_COMPRESSED_RGBA_BPTC_UNORM=36492,i.TEXTUREFORMAT_COMPRESSED_SRGB_ALPHA_BPTC_UNORM=36493,i.TEXTUREFORMAT_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT=36495,i.TEXTUREFORMAT_COMPRESSED_RGB_BPTC_SIGNED_FLOAT=36494,i.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5=33779,i.TEXTUREFORMAT_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919,i.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT3=33778,i.TEXTUREFORMAT_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918,i.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT1=33777,i.TEXTUREFORMAT_COMPRESSED_RGB_S3TC_DXT1=33776,i.TEXTUREFORMAT_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917,i.TEXTUREFORMAT_COMPRESSED_SRGB_S3TC_DXT1_EXT=35916,i.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_4x4=37808,i.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840,i.TEXTUREFORMAT_COMPRESSED_RGB_ETC1_WEBGL=36196,i.TEXTUREFORMAT_COMPRESSED_RGB8_ETC2=37492,i.TEXTUREFORMAT_COMPRESSED_SRGB8_ETC2=37493,i.TEXTUREFORMAT_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494,i.TEXTUREFORMAT_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495,i.TEXTUREFORMAT_COMPRESSED_RGBA8_ETC2_EAC=37496,i.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37497,i.TEXTURETYPE_UNSIGNED_BYTE=0,i.TEXTURETYPE_UNSIGNED_INT=0,i.TEXTURETYPE_FLOAT=1,i.TEXTURETYPE_HALF_FLOAT=2,i.TEXTURETYPE_BYTE=3,i.TEXTURETYPE_SHORT=4,i.TEXTURETYPE_UNSIGNED_SHORT=5,i.TEXTURETYPE_INT=6,i.TEXTURETYPE_UNSIGNED_INTEGER=7,i.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4=8,i.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1=9,i.TEXTURETYPE_UNSIGNED_SHORT_5_6_5=10,i.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV=11,i.TEXTURETYPE_UNSIGNED_INT_24_8=12,i.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV=13,i.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV=14,i.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV=15,i.TEXTURETYPE_UNDEFINED=16,i.TEXTURE_2D=3553,i.TEXTURE_2D_ARRAY=35866,i.TEXTURE_CUBE_MAP=34067,i.TEXTURE_CUBE_MAP_ARRAY=3735928559,i.TEXTURE_3D=32879,i.TEXTURE_NEAREST_SAMPLINGMODE=1,i.TEXTURE_NEAREST_NEAREST=1,i.TEXTURE_BILINEAR_SAMPLINGMODE=2,i.TEXTURE_LINEAR_LINEAR=2,i.TEXTURE_TRILINEAR_SAMPLINGMODE=3,i.TEXTURE_LINEAR_LINEAR_MIPLINEAR=3,i.TEXTURE_NEAREST_NEAREST_MIPNEAREST=4,i.TEXTURE_NEAREST_LINEAR_MIPNEAREST=5,i.TEXTURE_NEAREST_LINEAR_MIPLINEAR=6,i.TEXTURE_NEAREST_LINEAR=7,i.TEXTURE_NEAREST_NEAREST_MIPLINEAR=8,i.TEXTURE_LINEAR_NEAREST_MIPNEAREST=9,i.TEXTURE_LINEAR_NEAREST_MIPLINEAR=10,i.TEXTURE_LINEAR_LINEAR_MIPNEAREST=11,i.TEXTURE_LINEAR_NEAREST=12,i.TEXTURE_EXPLICIT_MODE=0,i.TEXTURE_SPHERICAL_MODE=1,i.TEXTURE_PLANAR_MODE=2,i.TEXTURE_CUBIC_MODE=3,i.TEXTURE_PROJECTION_MODE=4,i.TEXTURE_SKYBOX_MODE=5,i.TEXTURE_INVCUBIC_MODE=6,i.TEXTURE_EQUIRECTANGULAR_MODE=7,i.TEXTURE_FIXED_EQUIRECTANGULAR_MODE=8,i.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE=9,i.TEXTURE_FILTERING_QUALITY_OFFLINE=4096,i.TEXTURE_FILTERING_QUALITY_HIGH=64,i.TEXTURE_FILTERING_QUALITY_MEDIUM=16,i.TEXTURE_FILTERING_QUALITY_LOW=8,i.SCALEMODE_FLOOR=1,i.SCALEMODE_NEAREST=2,i.SCALEMODE_CEILING=3,i.MATERIAL_TextureDirtyFlag=1,i.MATERIAL_LightDirtyFlag=2,i.MATERIAL_FresnelDirtyFlag=4,i.MATERIAL_AttributesDirtyFlag=8,i.MATERIAL_MiscDirtyFlag=16,i.MATERIAL_PrePassDirtyFlag=32,i.MATERIAL_AllDirtyFlag=63,i.MATERIAL_TriangleFillMode=0,i.MATERIAL_WireFrameFillMode=1,i.MATERIAL_PointFillMode=2,i.MATERIAL_PointListDrawMode=3,i.MATERIAL_LineListDrawMode=4,i.MATERIAL_LineLoopDrawMode=5,i.MATERIAL_LineStripDrawMode=6,i.MATERIAL_TriangleStripDrawMode=7,i.MATERIAL_TriangleFanDrawMode=8,i.MATERIAL_ClockWiseSideOrientation=0,i.MATERIAL_CounterClockWiseSideOrientation=1,i.ACTION_NothingTrigger=0,i.ACTION_OnPickTrigger=1,i.ACTION_OnLeftPickTrigger=2,i.ACTION_OnRightPickTrigger=3,i.ACTION_OnCenterPickTrigger=4,i.ACTION_OnPickDownTrigger=5,i.ACTION_OnDoublePickTrigger=6,i.ACTION_OnPickUpTrigger=7,i.ACTION_OnPickOutTrigger=16,i.ACTION_OnLongPressTrigger=8,i.ACTION_OnPointerOverTrigger=9,i.ACTION_OnPointerOutTrigger=10,i.ACTION_OnEveryFrameTrigger=11,i.ACTION_OnIntersectionEnterTrigger=12,i.ACTION_OnIntersectionExitTrigger=13,i.ACTION_OnKeyDownTrigger=14,i.ACTION_OnKeyUpTrigger=15,i.PARTICLES_BILLBOARDMODE_Y=2,i.PARTICLES_BILLBOARDMODE_ALL=7,i.PARTICLES_BILLBOARDMODE_STRETCHED=8,i.PARTICLES_BILLBOARDMODE_STRETCHED_LOCAL=9,i.MESHES_CULLINGSTRATEGY_STANDARD=0,i.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY=1,i.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION=2,i.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY=3,i.SCENELOADER_NO_LOGGING=0,i.SCENELOADER_MINIMAL_LOGGING=1,i.SCENELOADER_SUMMARY_LOGGING=2,i.SCENELOADER_DETAILED_LOGGING=3,i.PREPASS_IRRADIANCE_TEXTURE_TYPE=0,i.PREPASS_POSITION_TEXTURE_TYPE=1,i.PREPASS_VELOCITY_TEXTURE_TYPE=2,i.PREPASS_REFLECTIVITY_TEXTURE_TYPE=3,i.PREPASS_COLOR_TEXTURE_TYPE=4,i.PREPASS_DEPTH_TEXTURE_TYPE=5,i.PREPASS_NORMAL_TEXTURE_TYPE=6,i.PREPASS_ALBEDO_SQRT_TEXTURE_TYPE=7,i.PREPASS_WORLD_NORMAL_TEXTURE_TYPE=8,i.PREPASS_LOCAL_POSITION_TEXTURE_TYPE=9,i.PREPASS_SCREENSPACE_DEPTH_TEXTURE_TYPE=10,i.PREPASS_VELOCITY_LINEAR_TEXTURE_TYPE=11,i.PREPASS_ALBEDO_TEXTURE_TYPE=12,i.BUFFER_CREATIONFLAG_READ=1,i.BUFFER_CREATIONFLAG_WRITE=2,i.BUFFER_CREATIONFLAG_READWRITE=3,i.BUFFER_CREATIONFLAG_UNIFORM=4,i.BUFFER_CREATIONFLAG_VERTEX=8,i.BUFFER_CREATIONFLAG_INDEX=16,i.BUFFER_CREATIONFLAG_STORAGE=32,i.BUFFER_CREATIONFLAG_INDIRECT=64,i.RENDERPASS_MAIN=0,i.INPUT_ALT_KEY=18,i.INPUT_CTRL_KEY=17,i.INPUT_META_KEY1=91,i.INPUT_META_KEY2=92,i.INPUT_META_KEY3=93,i.INPUT_SHIFT_KEY=16,i.SNAPSHOTRENDERING_STANDARD=0,i.SNAPSHOTRENDERING_FAST=1,i.PERSPECTIVE_CAMERA=0,i.ORTHOGRAPHIC_CAMERA=1,i.FOVMODE_VERTICAL_FIXED=0,i.FOVMODE_HORIZONTAL_FIXED=1,i.RIG_MODE_NONE=0,i.RIG_MODE_STEREOSCOPIC_ANAGLYPH=10,i.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL=11,i.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED=12,i.RIG_MODE_STEREOSCOPIC_OVERUNDER=13,i.RIG_MODE_STEREOSCOPIC_INTERLACED=14,i.RIG_MODE_VR=20,i.RIG_MODE_CUSTOM=22,i.MAX_SUPPORTED_UV_SETS=6,i.GL_ALPHA_EQUATION_ADD=32774,i.GL_ALPHA_EQUATION_MIN=32775,i.GL_ALPHA_EQUATION_MAX=32776,i.GL_ALPHA_EQUATION_SUBTRACT=32778,i.GL_ALPHA_EQUATION_REVERSE_SUBTRACT=32779,i.GL_ALPHA_FUNCTION_SRC=768,i.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_COLOR=769,i.GL_ALPHA_FUNCTION_SRC_ALPHA=770,i.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA=771,i.GL_ALPHA_FUNCTION_DST_ALPHA=772,i.GL_ALPHA_FUNCTION_ONE_MINUS_DST_ALPHA=773,i.GL_ALPHA_FUNCTION_DST_COLOR=774,i.GL_ALPHA_FUNCTION_ONE_MINUS_DST_COLOR=775,i.GL_ALPHA_FUNCTION_SRC_ALPHA_SATURATED=776,i.GL_ALPHA_FUNCTION_CONSTANT_COLOR=32769,i.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_COLOR=32770,i.GL_ALPHA_FUNCTION_CONSTANT_ALPHA=32771,i.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_ALPHA=32772,i.GL_ALPHA_FUNCTION_SRC1_COLOR=35065,i.GL_ALPHA_FUNCTION_ONE_MINUS_SRC1_COLOR=35066,i.GL_ALPHA_FUNCTION_SRC1_ALPHA=34185,i.GL_ALPHA_FUNCTION_ONE_MINUS_SRC1_ALPHA=35067,i.SnippetUrl="https://snippet.babylonjs.com",i.FOGMODE_NONE=0,i.FOGMODE_EXP=1,i.FOGMODE_EXP2=2,i.FOGMODE_LINEAR=3,i.BYTE=5120,i.UNSIGNED_BYTE=5121,i.SHORT=5122,i.UNSIGNED_SHORT=5123,i.INT=5124,i.UNSIGNED_INT=5125,i.FLOAT=5126,i.PositionKind="position",i.NormalKind="normal",i.TangentKind="tangent",i.UVKind="uv",i.UV2Kind="uv2",i.UV3Kind="uv3",i.UV4Kind="uv4",i.UV5Kind="uv5",i.UV6Kind="uv6",i.ColorKind="color",i.ColorInstanceKind="instanceColor",i.MatricesIndicesKind="matricesIndices",i.MatricesWeightsKind="matricesWeights",i.MatricesIndicesExtraKind="matricesIndicesExtra",i.MatricesWeightsExtraKind="matricesWeightsExtra"},3720:(e,t,s)=>{s.d(t,{N:()=>C});var i=s(854),r=s(6315),n=s(6321),a=s(6237);class o{constructor(e=30){this._enabled=!0,this._rollingFrameTime=new h(e)}sampleFrame(e=a.j.Now){if(this._enabled){if(null!=this._lastFrameTimeMs){const t=e-this._lastFrameTimeMs;this._rollingFrameTime.add(t)}this._lastFrameTimeMs=e}}get averageFrameTime(){return this._rollingFrameTime.average}get averageFrameTimeVariance(){return this._rollingFrameTime.variance}get instantaneousFrameTime(){return this._rollingFrameTime.history(0)}get averageFPS(){return 1e3/this._rollingFrameTime.average}get instantaneousFPS(){const e=this._rollingFrameTime.history(0);return 0===e?0:1e3/e}get isSaturated(){return this._rollingFrameTime.isSaturated()}enable(){this._enabled=!0}disable(){this._enabled=!1,this._lastFrameTimeMs=null}get isEnabled(){return this._enabled}reset(){this._lastFrameTimeMs=null,this._rollingFrameTime.reset()}}class h{constructor(e){this._samples=new Array(e),this.reset()}add(e){let t;if(this.isSaturated()){const e=this._samples[this._pos];t=e-this.average,this.average-=t/(this._sampleCount-1),this._m2-=t*(e-this.average)}else this._sampleCount++;t=e-this.average,this.average+=t/this._sampleCount,this._m2+=t*(e-this.average),this.variance=this._m2/(this._sampleCount-1),this._samples[this._pos]=e,this._pos++,this._pos%=this._samples.length}history(e){if(e>=this._sampleCount||e>=this._samples.length)return 0;const t=this._wrapPosition(this._pos-1);return this._samples[this._wrapPosition(t-e)]}isSaturated(){return this._sampleCount>=this._samples.length}reset(){this.average=0,this.variance=0,this._sampleCount=0,this._pos=0,this._m2=0}_wrapPosition(e){const t=this._samples.length;return(e%t+t)%t}}var l=s(4329),c=s(1137),u=s(7716);n.ThinEngine.prototype.setAlphaMode=function(e,t=!1){if(this._alphaMode!==e){switch(e){case 0:this._alphaState.alphaBlend=!1;break;case 7:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE_MINUS_SRC_ALPHA,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case 8:case 14:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE_MINUS_SRC_ALPHA,this._gl.ONE,this._gl.ONE_MINUS_SRC_ALPHA),this._alphaState.alphaBlend=!0;break;case 2:this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA,this._gl.ONE_MINUS_SRC_ALPHA,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case 6:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE,this._gl.ZERO,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case 1:this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA,this._gl.ONE,this._gl.ZERO,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case 3:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ZERO,this._gl.ONE_MINUS_SRC_COLOR,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case 4:this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_COLOR,this._gl.ZERO,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case 5:this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA,this._gl.ONE_MINUS_SRC_COLOR,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case 9:this._alphaState.setAlphaBlendFunctionParameters(this._gl.CONSTANT_COLOR,this._gl.ONE_MINUS_CONSTANT_COLOR,this._gl.CONSTANT_ALPHA,this._gl.ONE_MINUS_CONSTANT_ALPHA),this._alphaState.alphaBlend=!0;break;case 10:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE_MINUS_SRC_COLOR,this._gl.ONE,this._gl.ONE_MINUS_SRC_ALPHA),this._alphaState.alphaBlend=!0;break;case 11:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case 12:this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_ALPHA,this._gl.ONE,this._gl.ZERO,this._gl.ZERO),this._alphaState.alphaBlend=!0;break;case 13:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE_MINUS_DST_COLOR,this._gl.ONE_MINUS_SRC_COLOR,this._gl.ONE_MINUS_DST_ALPHA,this._gl.ONE_MINUS_SRC_ALPHA),this._alphaState.alphaBlend=!0;break;case 15:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE,this._gl.ONE,this._gl.ZERO),this._alphaState.alphaBlend=!0;break;case 16:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE_MINUS_DST_COLOR,this._gl.ONE_MINUS_SRC_COLOR,this._gl.ZERO,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case 17:this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA,this._gl.ONE_MINUS_SRC_ALPHA,this._gl.ONE,this._gl.ONE_MINUS_SRC_ALPHA),this._alphaState.alphaBlend=!0}t||(this.depthCullingState.depthMask=0===e),this._alphaMode=e}else if(!t){const t=0===e;this.depthCullingState.depthMask!==t&&(this.depthCullingState.depthMask=t)}};var d=s(1597);function _(e,t,s,i){let r,n=1;1===i?r=new Float32Array(t*s*4):2===i?(r=new Uint16Array(t*s*4),n=15360):r=7===i?new Uint32Array(t*s*4):new Uint8Array(t*s*4);for(let i=0;i{const s=f.width,n=a(e);if(n){if(o){const e=this._getWebGLTextureType(r);let t=this._getInternalFormat(i);const a=this._getRGBABufferInternalSizedFormat(r);let h=!1;t===d.RGB&&(t=d.RGBA,h=!0),this._bindTextureDirectly(d.TEXTURE_CUBE_MAP,f,!0),this._unpackFlipY(!1);const l=o(n);for(let i=0;i>i;for(let s=0;s<6;s++){let o=l[i][s];h&&(o=_(o,n,n,r)),d.texImage2D(s,i,a,n,n,0,t,e,o)}}this._bindTextureDirectly(d.TEXTURE_CUBE_MAP,null)}else this.updateRawCubeTexture(f,n,i,r,u);f.isReady=!0,t?.removePendingData(f),f.onLoadedObservable.notifyObservers(f),f.onLoadedObservable.clear(),h&&h()}};return this._loadFile(e,(e=>{p(e)}),void 0,t?.offlineProvider,!0,((e,s)=>{t?.removePendingData(f),l&&e&&l(e.status+" "+e.statusText,s)})),f},n.ThinEngine.prototype.createRawTexture2DArray=f(!1),n.ThinEngine.prototype.createRawTexture3D=f(!0),n.ThinEngine.prototype.updateRawTexture2DArray=p(!1),n.ThinEngine.prototype.updateRawTexture3D=p(!0);var g=s(6741);n.ThinEngine.prototype._readTexturePixelsSync=function(e,t,s,i=-1,r=0,n=null,a=!0,o=!1,h=0,l=0){const c=this._gl;if(!c)throw new Error("Engine does not have gl rendering context.");if(!this._dummyFramebuffer){const e=c.createFramebuffer();if(!e)throw new Error("Unable to create dummy framebuffer");this._dummyFramebuffer=e}c.bindFramebuffer(c.FRAMEBUFFER,this._dummyFramebuffer),i>-1?c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0,c.TEXTURE_CUBE_MAP_POSITIVE_X+i,e._hardwareTexture?.underlyingResource,r):c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0,c.TEXTURE_2D,e._hardwareTexture?.underlyingResource,r);let u=void 0!==e.type?this._getWebGLTextureType(e.type):c.UNSIGNED_BYTE;return o?n||(n=(0,g.kZ)(e.type,4*t*s)):u===c.UNSIGNED_BYTE?(n||(n=new Uint8Array(4*t*s)),u=c.UNSIGNED_BYTE):(n||(n=new Float32Array(4*t*s)),u=c.FLOAT),a&&this.flushFramebuffer(),c.readPixels(h,l,t,s,c.RGBA,u,n),c.bindFramebuffer(c.FRAMEBUFFER,this._currentFramebuffer),n},n.ThinEngine.prototype._readTexturePixels=function(e,t,s,i=-1,r=0,n=null,a=!0,o=!1,h=0,l=0){return Promise.resolve(this._readTexturePixelsSync(e,t,s,i,r,n,a,o,h,l))},n.ThinEngine.prototype.updateDynamicIndexBuffer=function(e,t,s=0){let i;this._currentBoundBuffer[this._gl.ELEMENT_ARRAY_BUFFER]=null,this.bindIndexBuffer(e),i=e.is32Bits?t instanceof Uint32Array?t:new Uint32Array(t):t instanceof Uint16Array?t:new Uint16Array(t),this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER,i,this._gl.DYNAMIC_DRAW),this._resetIndexBufferBinding()},n.ThinEngine.prototype.updateDynamicVertexBuffer=function(e,t,s,i){this.bindArrayBuffer(e),void 0===s&&(s=0);const r=t.byteLength||t.length;void 0===i||i>=r&&0===s?t instanceof Array?this._gl.bufferSubData(this._gl.ARRAY_BUFFER,s,new Float32Array(t)):this._gl.bufferSubData(this._gl.ARRAY_BUFFER,s,t):t instanceof Array?this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,new Float32Array(t).subarray(s,s+i)):(t=t instanceof ArrayBuffer?new Uint8Array(t,s,i):new Uint8Array(t.buffer,t.byteOffset+s,i),this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,t)),this._resetVertexBufferBinding()},n.ThinEngine.prototype._createDepthStencilCubeTexture=function(e,t){const s=new i.h(this,12);if(s.isCube=!0,1===this.webGLVersion)return c.V.Error("Depth cube texture is not supported by WebGL 1."),s;const r={bilinearFiltering:!1,comparisonFunction:0,generateStencil:!1,...t},n=this._gl;this._bindTextureDirectly(n.TEXTURE_CUBE_MAP,s,!0),this._setupDepthStencilTexture(s,e,r.bilinearFiltering,r.comparisonFunction);for(let t=0;t<6;t++)r.generateStencil?n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,n.DEPTH24_STENCIL8,e,e,0,n.DEPTH_STENCIL,n.UNSIGNED_INT_24_8,null):n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,n.DEPTH_COMPONENT24,e,e,0,n.DEPTH_COMPONENT,n.UNSIGNED_INT,null);return this._bindTextureDirectly(n.TEXTURE_CUBE_MAP,null),this._internalTexturesCache.push(s),s},n.ThinEngine.prototype._setCubeMapTextureParams=function(e,t,s){const i=this._gl;i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_MIN_FILTER,t?i.LINEAR_MIPMAP_LINEAR:i.LINEAR),i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),e.samplingMode=t?3:2,t&&this.getCaps().textureMaxLevel&&void 0!==s&&s>0&&(i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_MAX_LEVEL,s),e._maxLodLevel=s),this._bindTextureDirectly(i.TEXTURE_CUBE_MAP,null)},n.ThinEngine.prototype.createCubeTexture=function(e,t,s,i,r=null,n=null,a,o=null,h=!1,l=0,u=0,_=null,f,p=!1,g=null){const m=this._gl;return this.createCubeTextureBase(e,t,s,!!i,r,n,a,o,h,l,u,_,(e=>this._bindTextureDirectly(m.TEXTURE_CUBE_MAP,e,!0)),((e,t)=>{const s=this.needPOTTextures?(0,d.R)(t[0].width,this._caps.maxCubemapTextureSize):t[0].width,n=s,o=[m.TEXTURE_CUBE_MAP_POSITIVE_X,m.TEXTURE_CUBE_MAP_POSITIVE_Y,m.TEXTURE_CUBE_MAP_POSITIVE_Z,m.TEXTURE_CUBE_MAP_NEGATIVE_X,m.TEXTURE_CUBE_MAP_NEGATIVE_Y,m.TEXTURE_CUBE_MAP_NEGATIVE_Z];this._bindTextureDirectly(m.TEXTURE_CUBE_MAP,e,!0),this._unpackFlipY(!1);const h=a?this._getInternalFormat(a,e._useSRGBBuffer):e._useSRGBBuffer?this._glSRGBExtensionValues.SRGB8_ALPHA8:m.RGBA;let l=a?this._getInternalFormat(a):m.RGBA;e._useSRGBBuffer&&1===this.webGLVersion&&(l=h);for(let e=0;e0}get is3D(){return this.depth>0}get size(){return this.width}get width(){return this._size.width||this._size}get height(){return this._size.height||this._size}get layers(){return this._size.layers||0}get depth(){return this._size.depth||0}get texture(){return this._textures?.[0]??null}get textures(){return this._textures}get faceIndices(){return this._faceIndices}get layerIndices(){return this._layerIndices}getBaseArrayLayer(e){if(!this._textures)return-1;const t=this._textures[e],s=this._layerIndices?.[e]??0,i=this._faceIndices?.[e]??0;return t.isCube?6*s+i:t.is3D?0:s}get samples(){return this._samples}setSamples(e,t=!0,s=!1){if(this.samples===e&&!s)return e;const i=this._isMulti?this._engine.updateMultipleRenderTargetTextureSampleCount(this,e,t):this._engine.updateRenderTargetTextureSampleCount(this,e);return this._samples=e,i}constructor(e,t,s,i,r){this._textures=null,this._faceIndices=null,this._layerIndices=null,this._samples=1,this._attachments=null,this._generateStencilBuffer=!1,this._generateDepthBuffer=!1,this._depthStencilTextureWithStencil=!1,this._isMulti=e,this._isCube=t,this._size=s,this._engine=i,this._depthStencilTexture=null,this.label=r}setTextures(e){Array.isArray(e)?this._textures=e:this._textures=e?[e]:null}setTexture(e,t=0,s=!0){this._textures||(this._textures=[]),this._textures[t]!==e&&(this._textures[t]&&s&&this._textures[t].dispose(),this._textures[t]=e)}setLayerAndFaceIndices(e,t){this._layerIndices=e,this._faceIndices=t}setLayerAndFaceIndex(e=0,t,s){this._layerIndices||(this._layerIndices=[]),this._faceIndices||(this._faceIndices=[]),void 0!==t&&t>=0&&(this._layerIndices[e]=t),void 0!==s&&s>=0&&(this._faceIndices[e]=s)}createDepthStencilTexture(e=0,t=!0,s=!1,i=1,r=14,n){return this._depthStencilTexture?.dispose(),this._depthStencilTextureWithStencil=s,this._depthStencilTextureLabel=n,this._depthStencilTexture=this._engine.createDepthStencilTexture(this._size,{bilinearFiltering:t,comparisonFunction:e,generateStencil:s,isCube:this._isCube,samples:i,depthTextureFormat:r,label:n},this),this._depthStencilTexture}_shareDepth(e){this.shareDepth(e)}shareDepth(e){this._depthStencilTexture&&(e._depthStencilTexture&&e._depthStencilTexture.dispose(),e._depthStencilTexture=this._depthStencilTexture,e._depthStencilTextureWithStencil=this._depthStencilTextureWithStencil,this._depthStencilTexture.incrementReferences())}_swapAndDie(e){this.texture&&this.texture._swapAndDie(e),this._textures=null,this.dispose(!0)}_cloneRenderTargetWrapper(){let e=null;if(this._isMulti){const t=this.textures;if(t&&t.length>0){let s=!1,i=t.length,r=-1;const n=t[t.length-1]._source;14!==n&&12!==n||(s=!0,r=t[t.length-1].format,i--);const a=[],o=[],h=[],l=[],c=[],u=[],d=[],_={};for(let e=0;e1&&e.setSamples(this.samples),e._swapRenderTargetWrapper(this),e.dispose()}}releaseTextures(){if(this._textures)for(let e=0;e1){const r=this._context,n=r["COLOR_ATTACHMENT"+t];e.is2DArray||e.is3D?(s=s??this.layerIndices?.[t]??0,r.framebufferTextureLayer(r.FRAMEBUFFER,n,e._hardwareTexture.underlyingResource,i,s)):e.isCube?(s=s??this.faceIndices?.[t]??0,r.framebufferTexture2D(r.FRAMEBUFFER,n,r.TEXTURE_CUBE_MAP_POSITIVE_X+s,e._hardwareTexture.underlyingResource,i)):r.framebufferTexture2D(r.FRAMEBUFFER,n,r.TEXTURE_2D,e._hardwareTexture.underlyingResource,i)}else{const r=this._context,n=r["COLOR_ATTACHMENT"+t+"_WEBGL"],a=void 0!==s?r.TEXTURE_CUBE_MAP_POSITIVE_X+s:r.TEXTURE_2D;r.framebufferTexture2D(r.FRAMEBUFFER,n,a,e._hardwareTexture.underlyingResource,i)}n._bindUnboundFramebuffer(a)}setTexture(e,t=0,s=!0){super.setTexture(e,t,s),this._bindTextureRenderTarget(e,t)}setLayerAndFaceIndices(e,t){if(super.setLayerAndFaceIndices(e,t),!this.textures||!this.layerIndices||!this.faceIndices)return;const s=this._attachments?.length??this.textures.length;for(let e=0;e1){const e=i._hardwareTexture.getMSAARenderBuffer(0);s._MSAAFramebuffer=_.createFramebuffer(),this._bindUnboundFramebuffer(s._MSAAFramebuffer),_.framebufferRenderbuffer(_.FRAMEBUFFER,_.COLOR_ATTACHMENT0,_.RENDERBUFFER,e),this._bindUnboundFramebuffer(null)}}else this.updateRenderTargetTextureSampleCount(s,h);return s},n.ThinEngine.prototype._createDepthStencilTexture=function(e,t,s){const r=this._gl,n=e.layers||0,a=e.depth||0;let o=r.TEXTURE_2D;0!==n?o=r.TEXTURE_2D_ARRAY:0!==a&&(o=r.TEXTURE_3D);const h=new i.h(this,12);if(h.label=t.label,!this._caps.depthTextureExtension)return c.V.Error("Depth texture is not supported by your browser or hardware."),h;const l={bilinearFiltering:!1,comparisonFunction:0,generateStencil:!1,...t};if(this._bindTextureDirectly(o,h,!0),this._setupDepthStencilTexture(h,e,0!==l.comparisonFunction&&l.bilinearFiltering,l.comparisonFunction,l.samples),void 0!==l.depthTextureFormat){if(15!==l.depthTextureFormat&&16!==l.depthTextureFormat&&17!==l.depthTextureFormat&&13!==l.depthTextureFormat&&14!==l.depthTextureFormat&&18!==l.depthTextureFormat)return c.V.Error(`Depth texture ${l.depthTextureFormat} format is not supported.`),h;h.format=l.depthTextureFormat}else h.format=l.generateStencil?13:16;const u=17===h.format||13===h.format||18===h.format;let d=r.UNSIGNED_INT;15===h.format?d=r.UNSIGNED_SHORT:17===h.format||13===h.format?d=r.UNSIGNED_INT_24_8:14===h.format?d=r.FLOAT:18===h.format&&(d=r.FLOAT_32_UNSIGNED_INT_24_8_REV);const _=u?r.DEPTH_STENCIL:r.DEPTH_COMPONENT,f=this._getInternalFormatFromDepthTextureFormat(h.format,!0,u);return h.is2DArray?r.texImage3D(o,0,f,h.width,h.height,n,0,_,d,null):h.is3D?r.texImage3D(o,0,f,h.width,h.height,a,0,_,d,null):r.texImage2D(o,0,f,h.width,h.height,0,_,d,null),this._bindTextureDirectly(o,null),this._internalTexturesCache.push(h),s._depthStencilBuffer&&(r.deleteRenderbuffer(s._depthStencilBuffer),s._depthStencilBuffer=null),this._bindUnboundFramebuffer(s._MSAAFramebuffer??s._framebuffer),s._generateStencilBuffer=u,s._depthStencilTextureWithStencil=u,s._depthStencilBuffer=this._setupFramebufferDepthAttachments(s._generateStencilBuffer,s._generateDepthBuffer,s.width,s.height,s.samples,h.format),this._bindUnboundFramebuffer(null),h},n.ThinEngine.prototype.updateRenderTargetTextureSampleCount=function(e,t){if(this.webGLVersion<2||!e)return 1;if(e.samples===t)return t;const s=this._gl;t=Math.min(t,this.getCaps().maxMSAASamples),e._depthStencilBuffer&&(s.deleteRenderbuffer(e._depthStencilBuffer),e._depthStencilBuffer=null),e._MSAAFramebuffer&&(s.deleteFramebuffer(e._MSAAFramebuffer),e._MSAAFramebuffer=null);const i=e.texture?._hardwareTexture;if(i?.releaseMSAARenderBuffers(),e.texture&&t>1&&"function"==typeof s.renderbufferStorageMultisample){const r=s.createFramebuffer();if(!r)throw new Error("Unable to create multi sampled framebuffer");e._MSAAFramebuffer=r,this._bindUnboundFramebuffer(e._MSAAFramebuffer);const n=this._createRenderBuffer(e.texture.width,e.texture.height,t,-1,this._getRGBABufferInternalSizedFormat(e.texture.type,e.texture.format,e.texture._useSRGBBuffer),s.COLOR_ATTACHMENT0,!1);if(!n)throw new Error("Unable to create multi sampled framebuffer");i?.addMSAARenderBuffer(n)}this._bindUnboundFramebuffer(e._MSAAFramebuffer??e._framebuffer),e.texture&&(e.texture.samples=t),e._samples=t;const r=e._depthStencilTexture?e._depthStencilTexture.format:void 0;return e._depthStencilBuffer=this._setupFramebufferDepthAttachments(e._generateStencilBuffer,e._generateDepthBuffer,e.width,e.height,t,r),this._bindUnboundFramebuffer(null),t},n.ThinEngine.prototype._setupDepthStencilTexture=function(e,t,s,i,r=1){const n=t.width??t,a=t.height??t,o=t.layers||0,h=t.depth||0;e.baseWidth=n,e.baseHeight=a,e.width=n,e.height=a,e.is2DArray=o>0,e.depth=o||h,e.isReady=!0,e.samples=r,e.generateMipMaps=!1,e.samplingMode=s?2:1,e.type=0,e._comparisonFunction=i;const l=this._gl,c=this._getTextureTarget(e),u=this._getSamplingParameters(e.samplingMode,!1);l.texParameteri(c,l.TEXTURE_MAG_FILTER,u.mag),l.texParameteri(c,l.TEXTURE_MIN_FILTER,u.min),l.texParameteri(c,l.TEXTURE_WRAP_S,l.CLAMP_TO_EDGE),l.texParameteri(c,l.TEXTURE_WRAP_T,l.CLAMP_TO_EDGE),this.webGLVersion>1&&(0===i?(l.texParameteri(c,l.TEXTURE_COMPARE_FUNC,515),l.texParameteri(c,l.TEXTURE_COMPARE_MODE,l.NONE)):(l.texParameteri(c,l.TEXTURE_COMPARE_FUNC,i),l.texParameteri(c,l.TEXTURE_COMPARE_MODE,l.COMPARE_REF_TO_TEXTURE)))},n.ThinEngine.prototype.setDepthStencilTexture=function(e,t,s,i){void 0!==e&&(t&&(this._boundUniforms[e]=t),s&&s.depthStencilTexture?this._setTexture(e,s,!1,!0,i):this._setTexture(e,null,void 0,void 0,i))},n.ThinEngine.prototype.createRenderTargetCubeTexture=function(e,t){const s=this._createHardwareRenderTargetWrapper(!1,!0,e),r={generateMipMaps:!0,generateDepthBuffer:!0,generateStencilBuffer:!1,type:0,samplingMode:3,format:5,...t};r.generateStencilBuffer=r.generateDepthBuffer&&r.generateStencilBuffer,(1!==r.type||this._caps.textureFloatLinearFiltering)&&(2!==r.type||this._caps.textureHalfFloatLinearFiltering)||(r.samplingMode=1);const n=this._gl,a=new i.h(this,5);this._bindTextureDirectly(n.TEXTURE_CUBE_MAP,a,!0);const o=this._getSamplingParameters(r.samplingMode,r.generateMipMaps);1!==r.type||this._caps.textureFloat||(r.type=0,c.V.Warn("Float textures are not supported. Cube render target forced to TEXTURETYPE_UNESIGNED_BYTE type")),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_MAG_FILTER,o.mag),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_MIN_FILTER,o.min),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE);for(let t=0;t<6;t++)n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,this._getRGBABufferInternalSizedFormat(r.type,r.format),e,e,0,this._getInternalFormat(r.format),this._getWebGLTextureType(r.type),null);const h=n.createFramebuffer();return this._bindUnboundFramebuffer(h),s._depthStencilBuffer=this._setupFramebufferDepthAttachments(r.generateStencilBuffer,r.generateDepthBuffer,e,e),r.generateMipMaps&&n.generateMipmap(n.TEXTURE_CUBE_MAP),this._bindTextureDirectly(n.TEXTURE_CUBE_MAP,null),this._bindUnboundFramebuffer(null),s._framebuffer=h,s._generateDepthBuffer=r.generateDepthBuffer,s._generateStencilBuffer=r.generateStencilBuffer,a.width=e,a.height=e,a.isReady=!0,a.isCube=!0,a.samples=1,a.generateMipMaps=r.generateMipMaps,a.samplingMode=r.samplingMode,a.type=r.type,a.format=r.format,this._internalTexturesCache.push(a),s.setTextures(a),s};var E=s(4640),x=s(2667),A=s(3537);n.ThinEngine.prototype.createPrefilteredCubeTexture=function(e,t,s,r,n=null,a=null,o,h=null,l=!0){return this.createCubeTexture(e,t,null,!1,(e=>{if(!e)return void(n&&n(null));const a=e.texture;if(l?e.info.sphericalPolynomial&&(a._sphericalPolynomial=e.info.sphericalPolynomial):a._sphericalPolynomial=new E.Q,a._source=9,this.getCaps().textureLOD)return void(n&&n(a));const o=this._gl,h=e.width;if(!h)return;const u=[];for(let n=0;n<3;n++){const l=1-n/2,d=r,_=Math.log2(h)*s+r,f=d+(_-d)*l,p=Math.round(Math.min(Math.max(f,0),_)),g=new i.h(this,2);if(g.type=a.type,g.format=a.format,g.width=Math.pow(2,Math.max(Math.log2(h)-p,0)),g.height=g.width,g.isCube=!0,g._cachedWrapU=0,g._cachedWrapV=0,this._bindTextureDirectly(o.TEXTURE_CUBE_MAP,g,!0),g.samplingMode=2,o.texParameteri(o.TEXTURE_CUBE_MAP,o.TEXTURE_MAG_FILTER,o.LINEAR),o.texParameteri(o.TEXTURE_CUBE_MAP,o.TEXTURE_MIN_FILTER,o.LINEAR),o.texParameteri(o.TEXTURE_CUBE_MAP,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_CUBE_MAP,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),e.isDDS){const t=e.info,s=e.data;this._unpackFlipY(t.isCompressed),A.D.UploadDDSLevels(this,g,s,t,!0,6,p)}else c.V.Warn("DDS is the only prefiltered cube map supported so far.");this._bindTextureDirectly(o.TEXTURE_CUBE_MAP,null);const m=new x.t(t);m._isCube=!0,m._texture=g,g.isReady=!0,u.push(m)}a._lodTextureHigh=u[2],a._lodTextureMid=u[1],a._lodTextureLow=u[0],n&&n(a)}),a,o,h,l,s,r)},n.ThinEngine.prototype.createUniformBuffer=function(e,t){const s=this._gl.createBuffer();if(!s)throw new Error("Unable to create uniform buffer");const i=new l.A(s);return this.bindUniformBuffer(i),e instanceof Float32Array?this._gl.bufferData(this._gl.UNIFORM_BUFFER,e,this._gl.STATIC_DRAW):this._gl.bufferData(this._gl.UNIFORM_BUFFER,new Float32Array(e),this._gl.STATIC_DRAW),this.bindUniformBuffer(null),i.references=1,i},n.ThinEngine.prototype.createDynamicUniformBuffer=function(e,t){const s=this._gl.createBuffer();if(!s)throw new Error("Unable to create dynamic uniform buffer");const i=new l.A(s);return this.bindUniformBuffer(i),e instanceof Float32Array?this._gl.bufferData(this._gl.UNIFORM_BUFFER,e,this._gl.DYNAMIC_DRAW):this._gl.bufferData(this._gl.UNIFORM_BUFFER,new Float32Array(e),this._gl.DYNAMIC_DRAW),this.bindUniformBuffer(null),i.references=1,i},n.ThinEngine.prototype.updateUniformBuffer=function(e,t,s,i){this.bindUniformBuffer(e),void 0===s&&(s=0),void 0===i?t instanceof Float32Array?this._gl.bufferSubData(this._gl.UNIFORM_BUFFER,s,t):this._gl.bufferSubData(this._gl.UNIFORM_BUFFER,s,new Float32Array(t)):t instanceof Float32Array?this._gl.bufferSubData(this._gl.UNIFORM_BUFFER,0,t.subarray(s,s+i)):this._gl.bufferSubData(this._gl.UNIFORM_BUFFER,0,new Float32Array(t).subarray(s,s+i)),this.bindUniformBuffer(null)},n.ThinEngine.prototype.bindUniformBuffer=function(e){this._gl.bindBuffer(this._gl.UNIFORM_BUFFER,e?e.underlyingResource:null)},n.ThinEngine.prototype.bindUniformBufferBase=function(e,t,s){this._gl.bindBufferBase(this._gl.UNIFORM_BUFFER,t,e?e.underlyingResource:null)},n.ThinEngine.prototype.bindUniformBlock=function(e,t,s){const i=e.program,r=this._gl.getUniformBlockIndex(i,t);4294967295!==r&&this._gl.uniformBlockBinding(i,r,s)};var R=s(8790);function M(e){if(e.requestPointerLock){const t=e.requestPointerLock();t instanceof Promise?t.then((()=>{e.focus()})).catch((()=>{})):e.focus()}}b.$.prototype.displayLoadingUI=function(){if(!(0,R.BA)())return;const e=this.loadingScreen;e&&e.displayLoadingUI()},b.$.prototype.hideLoadingUI=function(){if(!(0,R.BA)())return;const e=this._loadingScreen;e&&e.hideLoadingUI()},Object.defineProperty(b.$.prototype,"loadingScreen",{get:function(){return!this._loadingScreen&&this._renderingCanvas&&(this._loadingScreen=b.$.DefaultLoadingScreenFactory(this._renderingCanvas)),this._loadingScreen},set:function(e){this._loadingScreen=e},enumerable:!0,configurable:!0}),Object.defineProperty(b.$.prototype,"loadingUIText",{set:function(e){this.loadingScreen.loadingUIText=e},enumerable:!0,configurable:!0}),Object.defineProperty(b.$.prototype,"loadingUIBackgroundColor",{set:function(e){this.loadingScreen.loadingUIBackgroundColor=e},enumerable:!0,configurable:!0}),b.$.prototype.getInputElement=function(){return this._renderingCanvas},b.$.prototype.getRenderingCanvasClientRect=function(){return this._renderingCanvas?this._renderingCanvas.getBoundingClientRect():null},b.$.prototype.getInputElementClientRect=function(){return this._renderingCanvas?this.getInputElement().getBoundingClientRect():null},b.$.prototype.getAspectRatio=function(e,t=!1){const s=e.viewport;return this.getRenderWidth(t)*s.width/(this.getRenderHeight(t)*s.height)},b.$.prototype.getScreenAspectRatio=function(){return this.getRenderWidth(!0)/this.getRenderHeight(!0)},b.$.prototype._verifyPointerLock=function(){this._onPointerLockChange?.()},b.$.prototype.setAlphaEquation=function(e){if(this._alphaEquation!==e){switch(e){case 0:this._alphaState.setAlphaEquationParameters(32774,32774);break;case 1:this._alphaState.setAlphaEquationParameters(32778,32778);break;case 2:this._alphaState.setAlphaEquationParameters(32779,32779);break;case 3:this._alphaState.setAlphaEquationParameters(32776,32776);break;case 4:this._alphaState.setAlphaEquationParameters(32775,32775);break;case 5:this._alphaState.setAlphaEquationParameters(32775,32774)}this._alphaEquation=e}},b.$.prototype.getInputElement=function(){return this._renderingCanvas},b.$.prototype.getDepthFunction=function(){return this._depthCullingState.depthFunc},b.$.prototype.setDepthFunction=function(e){this._depthCullingState.depthFunc=e},b.$.prototype.setDepthFunctionToGreater=function(){this.setDepthFunction(516)},b.$.prototype.setDepthFunctionToGreaterOrEqual=function(){this.setDepthFunction(518)},b.$.prototype.setDepthFunctionToLess=function(){this.setDepthFunction(513)},b.$.prototype.setDepthFunctionToLessOrEqual=function(){this.setDepthFunction(515)},b.$.prototype.getDepthWrite=function(){return this._depthCullingState.depthMask},b.$.prototype.setDepthWrite=function(e){this._depthCullingState.depthMask=e},b.$.prototype.getStencilBuffer=function(){return this._stencilState.stencilTest},b.$.prototype.setStencilBuffer=function(e){this._stencilState.stencilTest=e},b.$.prototype.getStencilMask=function(){return this._stencilState.stencilMask},b.$.prototype.setStencilMask=function(e){this._stencilState.stencilMask=e},b.$.prototype.getStencilFunction=function(){return this._stencilState.stencilFunc},b.$.prototype.getStencilFunctionReference=function(){return this._stencilState.stencilFuncRef},b.$.prototype.getStencilFunctionMask=function(){return this._stencilState.stencilFuncMask},b.$.prototype.setStencilFunction=function(e){this._stencilState.stencilFunc=e},b.$.prototype.setStencilFunctionReference=function(e){this._stencilState.stencilFuncRef=e},b.$.prototype.setStencilFunctionMask=function(e){this._stencilState.stencilFuncMask=e},b.$.prototype.getStencilOperationFail=function(){return this._stencilState.stencilOpStencilFail},b.$.prototype.getStencilOperationDepthFail=function(){return this._stencilState.stencilOpDepthFail},b.$.prototype.getStencilOperationPass=function(){return this._stencilState.stencilOpStencilDepthPass},b.$.prototype.setStencilOperationFail=function(e){this._stencilState.stencilOpStencilFail=e},b.$.prototype.setStencilOperationDepthFail=function(e){this._stencilState.stencilOpDepthFail=e},b.$.prototype.setStencilOperationPass=function(e){this._stencilState.stencilOpStencilDepthPass=e},b.$.prototype.cacheStencilState=function(){this._cachedStencilBuffer=this.getStencilBuffer(),this._cachedStencilFunction=this.getStencilFunction(),this._cachedStencilMask=this.getStencilMask(),this._cachedStencilOperationPass=this.getStencilOperationPass(),this._cachedStencilOperationFail=this.getStencilOperationFail(),this._cachedStencilOperationDepthFail=this.getStencilOperationDepthFail(),this._cachedStencilReference=this.getStencilFunctionReference()},b.$.prototype.restoreStencilState=function(){this.setStencilFunction(this._cachedStencilFunction),this.setStencilMask(this._cachedStencilMask),this.setStencilBuffer(this._cachedStencilBuffer),this.setStencilOperationPass(this._cachedStencilOperationPass),this.setStencilOperationFail(this._cachedStencilOperationFail),this.setStencilOperationDepthFail(this._cachedStencilOperationDepthFail),this.setStencilFunctionReference(this._cachedStencilReference)},b.$.prototype.setAlphaConstants=function(e,t,s,i){this._alphaState.setAlphaBlendConstants(e,t,s,i)},b.$.prototype.getAlphaMode=function(){return this._alphaMode},b.$.prototype.getAlphaEquation=function(){return this._alphaEquation},b.$.prototype.getRenderPassNames=function(){return this._renderPassNames},b.$.prototype.getCurrentRenderPassName=function(){return this._renderPassNames[this.currentRenderPassId]},b.$.prototype.createRenderPassId=function(e){const t=++b.$._RenderPassIdCounter;return this._renderPassNames[t]=e??"NONAME",t},b.$.prototype.releaseRenderPassId=function(e){this._renderPassNames[e]=void 0;for(let t=0;tnew v(e,t,s);class v{get audioContext(){return this._audioContextInitialized||this._initializeAudioContext(),this._audioContext}constructor(e=null,t=null,s=null){if(this._audioContext=null,this._audioContextInitialized=!1,this._muteButton=null,this._audioDestination=null,this.canUseWebAudio=!1,this.WarnedWebAudioUnsupported=!1,this.isMP3supported=!1,this.isOGGsupported=!1,this.unlocked=!1,this.useCustomUnlockedButton=!1,this.onAudioUnlockedObservable=new P.cP,this.onAudioLockedObservable=new P.cP,this._tryToRun=!1,this._onResize=()=>{this._moveButtonToTopLeft()},!(0,R.BA)())return;void 0!==window.AudioContext&&(this.canUseWebAudio=!0);const i=document.createElement("audio");this._hostElement=e,this._audioContext=t,this._audioDestination=s;try{i&&i.canPlayType&&(i.canPlayType('audio/mpeg; codecs="mp3"').replace(/^no$/,"")||i.canPlayType("audio/mp3").replace(/^no$/,""))&&(this.isMP3supported=!0)}catch(e){}try{i&&i.canPlayType&&i.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,"")&&(this.isOGGsupported=!0)}catch(e){}}lock(){this._triggerSuspendedState()}unlock(){if("running"===this._audioContext?.state)return this._hideMuteButton(),void(this.unlocked||(this.unlocked=!0,this.onAudioUnlockedObservable.notifyObservers(this)));this._tryToRun?this._audioContext?.suspend().then((()=>{this._tryToRun=!1,this._triggerRunningState()})):this._triggerRunningState()}_resumeAudioContextOnStateChange(){this._audioContext?.addEventListener("statechange",(()=>{this.unlocked&&"running"!==this._audioContext?.state&&this._resumeAudioContext()}),{once:!0,passive:!0,signal:AbortSignal.timeout(3e3)})}_resumeAudioContext(){return this._audioContext?.resume?this._audioContext.resume():Promise.resolve()}_initializeAudioContext(){try{this.canUseWebAudio&&(this._audioContext||(this._audioContext=new AudioContext),this.masterGain=this._audioContext.createGain(),this.masterGain.gain.value=1,this._audioDestination||(this._audioDestination=this._audioContext.destination),this.masterGain.connect(this._audioDestination),this._audioContextInitialized=!0,"running"===this._audioContext.state&&this._triggerRunningState())}catch(e){this.canUseWebAudio=!1,c.V.Error("Web Audio: "+e.message)}}_triggerRunningState(){this._tryToRun||(this._tryToRun=!0,this._resumeAudioContext().then((()=>{this._tryToRun=!1,this._muteButton&&this._hideMuteButton(),this.unlocked=!0,this.onAudioUnlockedObservable.notifyObservers(this)})).catch((()=>{this._tryToRun=!1,this.unlocked=!1})))}_triggerSuspendedState(){this.unlocked=!1,this.onAudioLockedObservable.notifyObservers(this),this._displayMuteButton()}_displayMuteButton(){if(this.useCustomUnlockedButton||this._muteButton)return;this._muteButton=document.createElement("BUTTON"),this._muteButton.className="babylonUnmuteIcon",this._muteButton.id="babylonUnmuteIconBtn",this._muteButton.title="Unmute";const e=".babylonUnmuteIcon { position: absolute; left: 20px; top: 20px; height: 40px; width: 60px; background-color: rgba(51,51,51,0.7); background-image: url("+(window.SVGSVGElement?"data:image/svg+xml;charset=UTF-8,%3Csvg%20version%3D%221.1%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2239%22%20height%3D%2232%22%20viewBox%3D%220%200%2039%2032%22%3E%3Cpath%20fill%3D%22white%22%20d%3D%22M9.625%2018.938l-0.031%200.016h-4.953q-0.016%200-0.031-0.016v-12.453q0-0.016%200.031-0.016h4.953q0.031%200%200.031%200.016v12.453zM12.125%207.688l8.719-8.703v27.453l-8.719-8.719-0.016-0.047v-9.938zM23.359%207.875l1.406-1.406%204.219%204.203%204.203-4.203%201.422%201.406-4.219%204.219%204.219%204.203-1.484%201.359-4.141-4.156-4.219%204.219-1.406-1.422%204.219-4.203z%22%3E%3C%2Fpath%3E%3C%2Fsvg%3E":"https://cdn.babylonjs.com/Assets/audio.png")+"); background-size: 80%; background-repeat:no-repeat; background-position: center; background-position-y: 4px; border: none; outline: none; transition: transform 0.125s ease-out; cursor: pointer; z-index: 9999; } .babylonUnmuteIcon:hover { transform: scale(1.05) } .babylonUnmuteIcon:active { background-color: rgba(51,51,51,1) }",t=document.createElement("style");t.appendChild(document.createTextNode(e)),document.getElementsByTagName("head")[0].appendChild(t),document.body.appendChild(this._muteButton),this._moveButtonToTopLeft(),this._muteButton.addEventListener("touchend",(()=>{this._triggerRunningState()}),!0),this._muteButton.addEventListener("click",(()=>{this.unlock()}),!0),window.addEventListener("resize",this._onResize)}_moveButtonToTopLeft(){this._hostElement&&this._muteButton&&(this._muteButton.style.top=this._hostElement.offsetTop+20+"px",this._muteButton.style.left=this._hostElement.offsetLeft+20+"px")}_hideMuteButton(){this._muteButton&&(document.body.removeChild(this._muteButton),this._muteButton=null)}dispose(){this.canUseWebAudio&&this._audioContextInitialized&&(this._connectedAnalyser&&this._audioContext&&(this._connectedAnalyser.stopDebugCanvas(),this._connectedAnalyser.dispose(),this.masterGain.disconnect(),this.masterGain.connect(this._audioContext.destination),this._connectedAnalyser=null),this.masterGain.gain.value=1),this.WarnedWebAudioUnsupported=!1,this._hideMuteButton(),window.removeEventListener("resize",this._onResize),this.onAudioUnlockedObservable.clear(),this.onAudioLockedObservable.clear()}getGlobalVolume(){return this.canUseWebAudio&&this._audioContextInitialized?this.masterGain.gain.value:-1}setGlobalVolume(e){this.canUseWebAudio&&this._audioContextInitialized&&(this.masterGain.gain.value=e)}connectToAnalyser(e){this._connectedAnalyser&&this._connectedAnalyser.stopDebugCanvas(),this.canUseWebAudio&&this._audioContextInitialized&&this._audioContext&&(this._connectedAnalyser=e,this.masterGain.disconnect(),this._connectedAnalyser.connectAudioNodes(this.masterGain,this._audioContext.destination))}}class C extends n.ThinEngine{static get NpmPackage(){return b.$.NpmPackage}static get Version(){return b.$.Version}static get Instances(){return r.q.Instances}static get LastCreatedEngine(){return r.q.LastCreatedEngine}static get LastCreatedScene(){return r.q.LastCreatedScene}static DefaultLoadingScreenFactory(e){return b.$.DefaultLoadingScreenFactory(e)}get _supportsHardwareTextureRescaling(){return!!C._RescalePostProcessFactory}_measureFps(){this._performanceMonitor.sampleFrame(),this._fps=this._performanceMonitor.averageFPS,this._deltaTime=this._performanceMonitor.instantaneousFrameTime||0}get performanceMonitor(){return this._performanceMonitor}constructor(e,t,s,i=!1){if(super(e,t,s,i),this.customAnimationFrameRequester=null,this._performanceMonitor=new o,this._drawCalls=new y.A,e&&(this._features.supportRenderPasses=!0,s=this._creationOptions,e.getContext)){const t=e;this._sharedInit(t)}}_initGLContext(){super._initGLContext(),this._rescalePostProcess=null}_sharedInit(e){super._sharedInit(e),function(e,t,s){e._onCanvasFocus=()=>{e.onCanvasFocusObservable.notifyObservers(e)},e._onCanvasBlur=()=>{e.onCanvasBlurObservable.notifyObservers(e)},e._onCanvasContextMenu=t=>{e.disableContextMenu&&t.preventDefault()},t.addEventListener("focus",e._onCanvasFocus),t.addEventListener("blur",e._onCanvasBlur),t.addEventListener("contextmenu",e._onCanvasContextMenu),e._onBlur=()=>{e.disablePerformanceMonitorInBackground&&e.performanceMonitor.disable(),e._windowIsBackground=!0},e._onFocus=()=>{e.disablePerformanceMonitorInBackground&&e.performanceMonitor.enable(),e._windowIsBackground=!1},e._onCanvasPointerOut=s=>{document.elementFromPoint(s.clientX,s.clientY)!==t&&e.onCanvasPointerOutObservable.notifyObservers(s)};const i=e.getHostWindow();i&&"function"==typeof i.addEventListener&&(i.addEventListener("blur",e._onBlur),i.addEventListener("focus",e._onFocus)),t.addEventListener("pointerout",e._onCanvasPointerOut),s.doNotHandleTouchAction||function(e){e&&e.setAttribute&&(e.setAttribute("touch-action","none"),e.style.touchAction="none",e.style.webkitTapHighlightColor="transparent")}(t),!b.$.audioEngine&&s.audioEngine&&b.$.AudioEngineFactory&&(b.$.audioEngine=b.$.AudioEngineFactory(e.getRenderingCanvas(),e.getAudioContext(),e.getAudioDestination())),(0,R.Nf)()&&(e._onFullscreenChange=()=>{e.isFullscreen=!!document.fullscreenElement,e.isFullscreen&&e._pointerLockRequested&&t&&M(t)},document.addEventListener("fullscreenchange",e._onFullscreenChange,!1),document.addEventListener("webkitfullscreenchange",e._onFullscreenChange,!1),e._onPointerLockChange=()=>{e.isPointerLock=document.pointerLockElement===t},document.addEventListener("pointerlockchange",e._onPointerLockChange,!1),document.addEventListener("webkitpointerlockchange",e._onPointerLockChange,!1)),e.enableOfflineSupport=void 0!==b.$.OfflineProviderFactory,e._deterministicLockstep=!!s.deterministicLockstep,e._lockstepMaxSteps=s.lockstepMaxSteps||0,e._timeStep=s.timeStep||1/60}(this,e,this._creationOptions)}resizeImageBitmap(e,t,s){return function(e,t,s,i){const r=e.createCanvas(s,i).getContext("2d");if(!r)throw new Error("Unable to get 2d context for resizeImageBitmap");return r.drawImage(t,0,0),r.getImageData(0,0,s,i).data}(this,e,t,s)}_createImageBitmapFromSource(e,t){return function(e,t,s){return new Promise(((i,r)=>{const n=new Image;n.onload=()=>{n.decode().then((()=>{e.createImageBitmap(n,s).then((e=>{i(e)}))}))},n.onerror=()=>{r(`Error loading image ${n.src}`)},n.src=t}))}(this,e,t)}switchFullscreen(e){this.isFullscreen?this.exitFullscreen():this.enterFullscreen(e)}enterFullscreen(e){this.isFullscreen||(this._pointerLockRequested=e,this._renderingCanvas&&function(e){const t=e.requestFullscreen||e.webkitRequestFullscreen;t&&t.call(e)}(this._renderingCanvas))}exitFullscreen(){this.isFullscreen&&function(){const e=document;document.exitFullscreen?document.exitFullscreen():e.webkitCancelFullScreen&&e.webkitCancelFullScreen()}()}setDitheringState(e){e?this._gl.enable(this._gl.DITHER):this._gl.disable(this._gl.DITHER)}setRasterizerState(e){e?this._gl.disable(this._gl.RASTERIZER_DISCARD):this._gl.enable(this._gl.RASTERIZER_DISCARD)}setDirectViewport(e,t,s,i){const r=this._cachedViewport;return this._cachedViewport=null,this._viewport(e,t,s,i),r}scissorClear(e,t,s,i,r){this.enableScissor(e,t,s,i),this.clear(r,!0,!0,!0),this.disableScissor()}enableScissor(e,t,s,i){const r=this._gl;r.enable(r.SCISSOR_TEST),r.scissor(e,t,s,i)}disableScissor(){const e=this._gl;e.disable(e.SCISSOR_TEST)}_loadFileAsync(e,t,s){return new Promise(((i,r)=>{this._loadFile(e,(e=>{i(e)}),void 0,t,s,((e,t)=>{r(t)}))}))}getVertexShaderSource(e){const t=this._gl.getAttachedShaders(e);return t?this._gl.getShaderSource(t[0]):null}getFragmentShaderSource(e){const t=this._gl.getAttachedShaders(e);return t?this._gl.getShaderSource(t[1]):null}set framebufferDimensionsObject(e){this._framebufferDimensionsObject=e,this._framebufferDimensionsObject&&this.onResizeObservable.notifyObservers(this)}_rebuildBuffers(){for(const e of this.scenes)e.resetCachedMaterial(),e._rebuildGeometries();for(const e of this._virtualScenes)e.resetCachedMaterial(),e._rebuildGeometries();super._rebuildBuffers()}getFontOffset(e){return function(e){const t=document.createElement("span");t.textContent="Hg",t.style.font=e;const s=document.createElement("div");s.style.display="inline-block",s.style.width="1px",s.style.height="0px",s.style.verticalAlign="bottom";const i=document.createElement("div");i.style.whiteSpace="nowrap",i.appendChild(t),i.appendChild(s),document.body.appendChild(i);let r=0,n=0;try{n=s.getBoundingClientRect().top-t.getBoundingClientRect().top,s.style.verticalAlign="baseline",r=s.getBoundingClientRect().top-t.getBoundingClientRect().top}finally{document.body.removeChild(i)}return{ascent:r,height:n,descent:n-r}}(e)}_cancelFrame(){if(this.customAnimationFrameRequester){if(0!==this._frameHandler){this._frameHandler=0;const{cancelAnimationFrame:e}=this.customAnimationFrameRequester;e&&e(this.customAnimationFrameRequester.requestID)}}else super._cancelFrame()}_renderLoop(){if(this._frameHandler=0,!this._contextWasLost){let e=!0;(this.isDisposed||!this.renderEvenInBackground&&this._windowIsBackground)&&(e=!1),e&&(this.beginFrame(),this._renderViews()||this._renderFrame(),this.endFrame())}this._activeRenderLoops.length>0&&0===this._frameHandler&&(this.customAnimationFrameRequester?(this.customAnimationFrameRequester.requestID=this._queueNewFrame(this.customAnimationFrameRequester.renderFunction||this._boundRenderFunction,this.customAnimationFrameRequester),this._frameHandler=this.customAnimationFrameRequester.requestID):this._frameHandler=this._queueNewFrame(this._boundRenderFunction,this.getHostWindow()))}enterPointerlock(){this._renderingCanvas&&M(this._renderingCanvas)}exitPointerlock(){document.exitPointerLock&&document.exitPointerLock()}beginFrame(){this._measureFps(),super.beginFrame()}_deletePipelineContext(e){const t=e;t&&t.program&&t.transformFeedback&&(this.deleteTransformFeedback(t.transformFeedback),t.transformFeedback=null),super._deletePipelineContext(e)}createShaderProgram(e,t,s,i,r,n=null){r=r||this._gl,this.onBeforeShaderCompilationObservable.notifyObservers(this);const a=super.createShaderProgram(e,t,s,i,r,n);return this.onAfterShaderCompilationObservable.notifyObservers(this),a}_createShaderProgram(e,t,s,i,r=null){const n=i.createProgram();if(e.program=n,!n)throw new Error("Unable to create program");if(i.attachShader(n,t),i.attachShader(n,s),this.webGLVersion>1&&r){const t=this.createTransformFeedback();this.bindTransformFeedback(t),this.setTranformFeedbackVaryings(n,r),e.transformFeedback=t}return i.linkProgram(n),this.webGLVersion>1&&r&&this.bindTransformFeedback(null),e.context=i,e.vertexShader=t,e.fragmentShader=s,e.isParallelCompiled||this._finalizePipelineContext(e),n}_releaseTexture(e){super._releaseTexture(e)}_releaseRenderTargetWrapper(e){super._releaseRenderTargetWrapper(e),this.scenes.forEach((t=>{t.postProcesses.forEach((t=>{t._outputTexture===e&&(t._outputTexture=null)})),t.cameras.forEach((t=>{t._postProcesses.forEach((t=>{t&&t._outputTexture===e&&(t._outputTexture=null)}))}))}))}_rescaleTexture(e,t,s,i,r){this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MAG_FILTER,this._gl.LINEAR),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MIN_FILTER,this._gl.LINEAR),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_S,this._gl.CLAMP_TO_EDGE),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_T,this._gl.CLAMP_TO_EDGE);const n=this.createRenderTargetTexture({width:t.width,height:t.height},{generateMipMaps:!1,type:0,samplingMode:2,generateDepthBuffer:!1,generateStencilBuffer:!1});if(!this._rescalePostProcess&&C._RescalePostProcessFactory&&(this._rescalePostProcess=C._RescalePostProcessFactory(this)),this._rescalePostProcess){this._rescalePostProcess.externalTextureSamplerBinding=!0;const a=()=>{this._rescalePostProcess.onApply=function(t){t._bindTexture("textureSampler",e)};let a=s;a||(a=this.scenes[this.scenes.length-1]),a.postProcessManager.directRender([this._rescalePostProcess],n,!0),this._bindTextureDirectly(this._gl.TEXTURE_2D,t,!0),this._gl.copyTexImage2D(this._gl.TEXTURE_2D,0,i,0,0,t.width,t.height,0),this.unBindFramebuffer(n),n.dispose(),r&&r()},o=this._rescalePostProcess.getEffect();o?o.executeWhenCompiled(a):this._rescalePostProcess.onEffectCreatedObservable.addOnce((e=>{e.executeWhenCompiled(a)}))}}wrapWebGLTexture(e,t=!1,s=3,r=0,n=0){const a=new u.d(e,this._gl),o=new i.h(this,0,!0);return o._hardwareTexture=a,o.baseWidth=r,o.baseHeight=n,o.width=r,o.height=n,o.isReady=!0,o.useMipMaps=t,this.updateTextureSamplingMode(s,o),o}_uploadImageToTexture(e,t,s=0,i=0){const r=this._gl,n=this._getWebGLTextureType(e.type),a=this._getInternalFormat(e.format),o=this._getRGBABufferInternalSizedFormat(e.type,a),h=e.isCube?r.TEXTURE_CUBE_MAP:r.TEXTURE_2D;this._bindTextureDirectly(h,e,!0),this._unpackFlipY(e.invertY);let l=r.TEXTURE_2D;e.isCube&&(l=r.TEXTURE_CUBE_MAP_POSITIVE_X+s),r.texImage2D(l,i,o,a,n,t),this._bindTextureDirectly(h,null,!0)}updateTextureComparisonFunction(e,t){if(1===this.webGLVersion)return void c.V.Error("WebGL 1 does not support texture comparison.");const s=this._gl;e.isCube?(this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,e,!0),0===t?(s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_COMPARE_FUNC,515),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_COMPARE_MODE,s.NONE)):(s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_COMPARE_FUNC,t),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_COMPARE_MODE,s.COMPARE_REF_TO_TEXTURE)),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null)):(this._bindTextureDirectly(this._gl.TEXTURE_2D,e,!0),0===t?(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_COMPARE_FUNC,515),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_COMPARE_MODE,s.NONE)):(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_COMPARE_FUNC,t),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_COMPARE_MODE,s.COMPARE_REF_TO_TEXTURE)),this._bindTextureDirectly(this._gl.TEXTURE_2D,null)),e._comparisonFunction=t}createInstancesBuffer(e){const t=this._gl.createBuffer();if(!t)throw new Error("Unable to create instance buffer");const s=new l.A(t);return s.capacity=e,this.bindArrayBuffer(s),this._gl.bufferData(this._gl.ARRAY_BUFFER,e,this._gl.DYNAMIC_DRAW),s.references=1,s}deleteInstancesBuffer(e){this._gl.deleteBuffer(e)}_clientWaitAsync(e,t=0,s=10){const i=this._gl;return new Promise(((r,n)=>{const a=()=>{const o=i.clientWaitSync(e,t,0);o!=i.WAIT_FAILED?o!=i.TIMEOUT_EXPIRED?r():setTimeout(a,s):n()};a()}))}_readPixelsAsync(e,t,s,i,r,n,a){if(this._webGLVersion<2)throw new Error("_readPixelsAsync only work on WebGL2+");const o=this._gl,h=o.createBuffer();o.bindBuffer(o.PIXEL_PACK_BUFFER,h),o.bufferData(o.PIXEL_PACK_BUFFER,a.byteLength,o.STREAM_READ),o.readPixels(e,t,s,i,r,n,0),o.bindBuffer(o.PIXEL_PACK_BUFFER,null);const l=o.fenceSync(o.SYNC_GPU_COMMANDS_COMPLETE,0);return l?(o.flush(),this._clientWaitAsync(l,0,10).then((()=>(o.deleteSync(l),o.bindBuffer(o.PIXEL_PACK_BUFFER,h),o.getBufferSubData(o.PIXEL_PACK_BUFFER,0,a),o.bindBuffer(o.PIXEL_PACK_BUFFER,null),o.deleteBuffer(h),a)))):null}dispose(){this.hideLoadingUI(),this._rescalePostProcess&&this._rescalePostProcess.dispose(),function(e,t){1===r.q.Instances.length&&b.$.audioEngine&&(b.$.audioEngine.dispose(),b.$.audioEngine=null);const s=e.getHostWindow();s&&"function"==typeof s.removeEventListener&&(s.removeEventListener("blur",e._onBlur),s.removeEventListener("focus",e._onFocus)),t&&(t.removeEventListener("focus",e._onCanvasFocus),t.removeEventListener("blur",e._onCanvasBlur),t.removeEventListener("pointerout",e._onCanvasPointerOut),t.removeEventListener("contextmenu",e._onCanvasContextMenu)),(0,R.Nf)()&&(document.removeEventListener("fullscreenchange",e._onFullscreenChange),document.removeEventListener("mozfullscreenchange",e._onFullscreenChange),document.removeEventListener("webkitfullscreenchange",e._onFullscreenChange),document.removeEventListener("msfullscreenchange",e._onFullscreenChange),document.removeEventListener("pointerlockchange",e._onPointerLockChange),document.removeEventListener("mspointerlockchange",e._onPointerLockChange),document.removeEventListener("mozpointerlockchange",e._onPointerLockChange),document.removeEventListener("webkitpointerlockchange",e._onPointerLockChange))}(this,this._renderingCanvas),super.dispose()}}C.ALPHA_DISABLE=0,C.ALPHA_ADD=1,C.ALPHA_COMBINE=2,C.ALPHA_SUBTRACT=3,C.ALPHA_MULTIPLY=4,C.ALPHA_MAXIMIZED=5,C.ALPHA_ONEONE=6,C.ALPHA_PREMULTIPLIED=7,C.ALPHA_PREMULTIPLIED_PORTERDUFF=8,C.ALPHA_INTERPOLATE=9,C.ALPHA_SCREENMODE=10,C.DELAYLOADSTATE_NONE=0,C.DELAYLOADSTATE_LOADED=1,C.DELAYLOADSTATE_LOADING=2,C.DELAYLOADSTATE_NOTLOADED=4,C.NEVER=512,C.ALWAYS=519,C.LESS=513,C.EQUAL=514,C.LEQUAL=515,C.GREATER=516,C.GEQUAL=518,C.NOTEQUAL=517,C.KEEP=7680,C.REPLACE=7681,C.INCR=7682,C.DECR=7683,C.INVERT=5386,C.INCR_WRAP=34055,C.DECR_WRAP=34056,C.TEXTURE_CLAMP_ADDRESSMODE=0,C.TEXTURE_WRAP_ADDRESSMODE=1,C.TEXTURE_MIRROR_ADDRESSMODE=2,C.TEXTUREFORMAT_ALPHA=0,C.TEXTUREFORMAT_LUMINANCE=1,C.TEXTUREFORMAT_LUMINANCE_ALPHA=2,C.TEXTUREFORMAT_RGB=4,C.TEXTUREFORMAT_RGBA=5,C.TEXTUREFORMAT_RED=6,C.TEXTUREFORMAT_R=6,C.TEXTUREFORMAT_RG=7,C.TEXTUREFORMAT_RED_INTEGER=8,C.TEXTUREFORMAT_R_INTEGER=8,C.TEXTUREFORMAT_RG_INTEGER=9,C.TEXTUREFORMAT_RGB_INTEGER=10,C.TEXTUREFORMAT_RGBA_INTEGER=11,C.TEXTURETYPE_UNSIGNED_BYTE=0,C.TEXTURETYPE_UNSIGNED_INT=0,C.TEXTURETYPE_FLOAT=1,C.TEXTURETYPE_HALF_FLOAT=2,C.TEXTURETYPE_BYTE=3,C.TEXTURETYPE_SHORT=4,C.TEXTURETYPE_UNSIGNED_SHORT=5,C.TEXTURETYPE_INT=6,C.TEXTURETYPE_UNSIGNED_INTEGER=7,C.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4=8,C.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1=9,C.TEXTURETYPE_UNSIGNED_SHORT_5_6_5=10,C.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV=11,C.TEXTURETYPE_UNSIGNED_INT_24_8=12,C.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV=13,C.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV=14,C.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV=15,C.TEXTURE_NEAREST_SAMPLINGMODE=1,C.TEXTURE_BILINEAR_SAMPLINGMODE=2,C.TEXTURE_TRILINEAR_SAMPLINGMODE=3,C.TEXTURE_NEAREST_NEAREST_MIPLINEAR=8,C.TEXTURE_LINEAR_LINEAR_MIPNEAREST=11,C.TEXTURE_LINEAR_LINEAR_MIPLINEAR=3,C.TEXTURE_NEAREST_NEAREST_MIPNEAREST=4,C.TEXTURE_NEAREST_LINEAR_MIPNEAREST=5,C.TEXTURE_NEAREST_LINEAR_MIPLINEAR=6,C.TEXTURE_NEAREST_LINEAR=7,C.TEXTURE_NEAREST_NEAREST=1,C.TEXTURE_LINEAR_NEAREST_MIPNEAREST=9,C.TEXTURE_LINEAR_NEAREST_MIPLINEAR=10,C.TEXTURE_LINEAR_LINEAR=2,C.TEXTURE_LINEAR_NEAREST=12,C.TEXTURE_EXPLICIT_MODE=0,C.TEXTURE_SPHERICAL_MODE=1,C.TEXTURE_PLANAR_MODE=2,C.TEXTURE_CUBIC_MODE=3,C.TEXTURE_PROJECTION_MODE=4,C.TEXTURE_SKYBOX_MODE=5,C.TEXTURE_INVCUBIC_MODE=6,C.TEXTURE_EQUIRECTANGULAR_MODE=7,C.TEXTURE_FIXED_EQUIRECTANGULAR_MODE=8,C.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE=9,C.SCALEMODE_FLOOR=1,C.SCALEMODE_NEAREST=2,C.SCALEMODE_CEILING=3},6315:(e,t,s)=>{s.d(t,{q:()=>r});var i=s(9848);class r{static get LastCreatedEngine(){return 0===this.Instances.length?null:this.Instances[this.Instances.length-1]}static get LastCreatedScene(){return this._LastCreatedScene}}r.Instances=[],r.OnEnginesDisposedObservable=new i.cP,r._LastCreatedScene=null,r.UseFallbackTexture=!0,r.FallbackTexture=""},215:(e,t,s)=>{s.d(t,{I:()=>i});class i{static SetMatrixPrecision(e){if(i.MatrixTrackPrecisionChange=!1,e&&!i.MatrixUse64Bits&&i.MatrixTrackedMatrices)for(let e=0;e{s.d(t,{l:()=>i});class i{static GetShadersRepository(e=0){return 0===e?i.ShadersRepository:i.ShadersRepositoryWGSL}static GetShadersStore(e=0){return 0===e?i.ShadersStore:i.ShadersStoreWGSL}static GetIncludesShadersStore(e=0){return 0===e?i.IncludesShadersStore:i.IncludesShadersStoreWGSL}}i.ShadersRepository="src/Shaders/",i.ShadersStore={},i.IncludesShadersStore={},i.ShadersRepositoryWGSL="src/ShadersWGSL/",i.ShadersStoreWGSL={},i.IncludesShadersStoreWGSL={}},5852:(e,t,s)=>{s.d(t,{tI:()=>d,bS:()=>T,tg:()=>_,YM:()=>f,C5:()=>m,GX:()=>u,kf:()=>l,EX:()=>c,Cm:()=>h,N5:()=>o});class i{constructor(){this._valueCache={},this.vertexCompilationError=null,this.fragmentCompilationError=null,this.programLinkError=null,this.programValidationError=null,this._isDisposed=!1}get isAsync(){return this.isParallelCompiled}get isReady(){return!!this.program&&(!this.isParallelCompiled||this.engine._isRenderingStateCompiled(this))}_handlesSpectorRebuildCallback(e){e&&this.program&&e(this.program)}setEngine(e){this.engine=e}_fillEffectInformation(e,t,s,i,r,n,a,o){const h=this.engine;if(h.supportsUniformBuffers)for(const s in t)e.bindUniformBlock(s,t[s]);let l;for(this.engine.getUniforms(this,s).forEach(((e,t)=>{i[s[t]]=e})),this._uniforms=i,l=0;l{n[e]=t}));for(const e of h.getAttributes(this,a))o.push(e)}dispose(){this._uniforms={},this._isDisposed=!0}_cacheMatrix(e,t){const s=this._valueCache[e],i=t.updateFlag;return(void 0===s||s!==i)&&(this._valueCache[e]=i,!0)}_cacheFloat2(e,t,s){let i=this._valueCache[e];if(!i||2!==i.length)return i=[t,s],this._valueCache[e]=i,!0;let r=!1;return i[0]!==t&&(i[0]=t,r=!0),i[1]!==s&&(i[1]=s,r=!0),r}_cacheFloat3(e,t,s,i){let r=this._valueCache[e];if(!r||3!==r.length)return r=[t,s,i],this._valueCache[e]=r,!0;let n=!1;return r[0]!==t&&(r[0]=t,n=!0),r[1]!==s&&(r[1]=s,n=!0),r[2]!==i&&(r[2]=i,n=!0),n}_cacheFloat4(e,t,s,i,r){let n=this._valueCache[e];if(!n||4!==n.length)return n=[t,s,i,r],this._valueCache[e]=n,!0;let a=!1;return n[0]!==t&&(n[0]=t,a=!0),n[1]!==s&&(n[1]=s,a=!0),n[2]!==i&&(n[2]=i,a=!0),n[3]!==r&&(n[3]=r,a=!0),a}setInt(e,t){const s=this._valueCache[e];void 0!==s&&s===t||this.engine.setInt(this._uniforms[e],t)&&(this._valueCache[e]=t)}setInt2(e,t,s){this._cacheFloat2(e,t,s)&&(this.engine.setInt2(this._uniforms[e],t,s)||(this._valueCache[e]=null))}setInt3(e,t,s,i){this._cacheFloat3(e,t,s,i)&&(this.engine.setInt3(this._uniforms[e],t,s,i)||(this._valueCache[e]=null))}setInt4(e,t,s,i,r){this._cacheFloat4(e,t,s,i,r)&&(this.engine.setInt4(this._uniforms[e],t,s,i,r)||(this._valueCache[e]=null))}setIntArray(e,t){this._valueCache[e]=null,this.engine.setIntArray(this._uniforms[e],t)}setIntArray2(e,t){this._valueCache[e]=null,this.engine.setIntArray2(this._uniforms[e],t)}setIntArray3(e,t){this._valueCache[e]=null,this.engine.setIntArray3(this._uniforms[e],t)}setIntArray4(e,t){this._valueCache[e]=null,this.engine.setIntArray4(this._uniforms[e],t)}setUInt(e,t){const s=this._valueCache[e];void 0!==s&&s===t||this.engine.setUInt(this._uniforms[e],t)&&(this._valueCache[e]=t)}setUInt2(e,t,s){this._cacheFloat2(e,t,s)&&(this.engine.setUInt2(this._uniforms[e],t,s)||(this._valueCache[e]=null))}setUInt3(e,t,s,i){this._cacheFloat3(e,t,s,i)&&(this.engine.setUInt3(this._uniforms[e],t,s,i)||(this._valueCache[e]=null))}setUInt4(e,t,s,i,r){this._cacheFloat4(e,t,s,i,r)&&(this.engine.setUInt4(this._uniforms[e],t,s,i,r)||(this._valueCache[e]=null))}setUIntArray(e,t){this._valueCache[e]=null,this.engine.setUIntArray(this._uniforms[e],t)}setUIntArray2(e,t){this._valueCache[e]=null,this.engine.setUIntArray2(this._uniforms[e],t)}setUIntArray3(e,t){this._valueCache[e]=null,this.engine.setUIntArray3(this._uniforms[e],t)}setUIntArray4(e,t){this._valueCache[e]=null,this.engine.setUIntArray4(this._uniforms[e],t)}setArray(e,t){this._valueCache[e]=null,this.engine.setArray(this._uniforms[e],t)}setArray2(e,t){this._valueCache[e]=null,this.engine.setArray2(this._uniforms[e],t)}setArray3(e,t){this._valueCache[e]=null,this.engine.setArray3(this._uniforms[e],t)}setArray4(e,t){this._valueCache[e]=null,this.engine.setArray4(this._uniforms[e],t)}setMatrices(e,t){t&&(this._valueCache[e]=null,this.engine.setMatrices(this._uniforms[e],t))}setMatrix(e,t){this._cacheMatrix(e,t)&&(this.engine.setMatrices(this._uniforms[e],t.asArray())||(this._valueCache[e]=null))}setMatrix3x3(e,t){this._valueCache[e]=null,this.engine.setMatrix3x3(this._uniforms[e],t)}setMatrix2x2(e,t){this._valueCache[e]=null,this.engine.setMatrix2x2(this._uniforms[e],t)}setFloat(e,t){const s=this._valueCache[e];void 0!==s&&s===t||this.engine.setFloat(this._uniforms[e],t)&&(this._valueCache[e]=t)}setVector2(e,t){this._cacheFloat2(e,t.x,t.y)&&(this.engine.setFloat2(this._uniforms[e],t.x,t.y)||(this._valueCache[e]=null))}setFloat2(e,t,s){this._cacheFloat2(e,t,s)&&(this.engine.setFloat2(this._uniforms[e],t,s)||(this._valueCache[e]=null))}setVector3(e,t){this._cacheFloat3(e,t.x,t.y,t.z)&&(this.engine.setFloat3(this._uniforms[e],t.x,t.y,t.z)||(this._valueCache[e]=null))}setFloat3(e,t,s,i){this._cacheFloat3(e,t,s,i)&&(this.engine.setFloat3(this._uniforms[e],t,s,i)||(this._valueCache[e]=null))}setVector4(e,t){this._cacheFloat4(e,t.x,t.y,t.z,t.w)&&(this.engine.setFloat4(this._uniforms[e],t.x,t.y,t.z,t.w)||(this._valueCache[e]=null))}setQuaternion(e,t){this._cacheFloat4(e,t.x,t.y,t.z,t.w)&&(this.engine.setFloat4(this._uniforms[e],t.x,t.y,t.z,t.w)||(this._valueCache[e]=null))}setFloat4(e,t,s,i,r){this._cacheFloat4(e,t,s,i,r)&&(this.engine.setFloat4(this._uniforms[e],t,s,i,r)||(this._valueCache[e]=null))}setColor3(e,t){this._cacheFloat3(e,t.r,t.g,t.b)&&(this.engine.setFloat3(this._uniforms[e],t.r,t.g,t.b)||(this._valueCache[e]=null))}setColor4(e,t,s){this._cacheFloat4(e,t.r,t.g,t.b,s)&&(this.engine.setFloat4(this._uniforms[e],t.r,t.g,t.b,s)||(this._valueCache[e]=null))}setDirectColor4(e,t){this._cacheFloat4(e,t.r,t.g,t.b,t.a)&&(this.engine.setFloat4(this._uniforms[e],t.r,t.g,t.b,t.a)||(this._valueCache[e]=null))}_getVertexShaderCode(){return this.vertexShader?this.engine._getShaderSource(this.vertexShader):null}_getFragmentShaderCode(){return this.fragmentShader?this.engine._getShaderSource(this.fragmentShader):null}}var r=s(6741);const n=new WeakMap,a={_webGLVersion:2,cachedPipelines:{}};function o(e){let t=n.get(e);if(!t){if(!e)return a;t={_webGLVersion:e.TEXTURE_BINDING_3D?2:1,_context:e,cachedPipelines:{}},n.set(e,t)}return t}function h(e){n.delete(e)}function l(e,t,s,i,r,n){const a=o(i);return n||(n=a._createShaderProgramInjection??d),n(e,g(t,"vertex",i,a._contextWasLost),g(s,"fragment",i,a._contextWasLost),i,r,a.validateShaderPrograms)}function c(e,t,s,i,r,n=null,a){const h=o(r);a||(a=h._createShaderProgramInjection??d);const l=h._webGLVersion>1?"#version 300 es\n#define WEBGL2 \n":"";return a(e,p(t,"vertex",i,l,r,h._contextWasLost),p(s,"fragment",i,l,r,h._contextWasLost),r,n,h.validateShaderPrograms)}function u(e,t){const s=new i,r=o(e);return r.parallelShaderCompile&&(s.isParallelCompiled=!0),s.context=r._context,s}function d(e,t,s,i,r=null,n){const a=i.createProgram();if(e.program=a,!a)throw new Error("Unable to create program");return i.attachShader(a,t),i.attachShader(a,s),i.linkProgram(a),e.context=i,e.vertexShader=t,e.fragmentShader=s,e.isParallelCompiled||_(e,i,n),a}function _(e,t,s){const i=e.context,r=e.vertexShader,n=e.fragmentShader,a=e.program;if(!i.getProgramParameter(a,i.LINK_STATUS)){if(!t.getShaderParameter(r,t.COMPILE_STATUS)){const s=t.getShaderInfoLog(r);if(s)throw e.vertexCompilationError=s,new Error("VERTEX SHADER "+s)}if(!t.getShaderParameter(n,t.COMPILE_STATUS)){const s=t.getShaderInfoLog(n);if(s)throw e.fragmentCompilationError=s,new Error("FRAGMENT SHADER "+s)}const s=i.getProgramInfoLog(a);if(s)throw e.programLinkError=s,new Error(s)}if(s&&(i.validateProgram(a),!i.getProgramParameter(a,i.VALIDATE_STATUS))){const t=i.getProgramInfoLog(a);if(t)throw e.programValidationError=t,new Error(t)}i.deleteShader(r),i.deleteShader(n),e.vertexShader=void 0,e.fragmentShader=void 0,e.onCompiled&&(e.onCompiled(),e.onCompiled=void 0)}function f(e,t,s,i,r,n,a,h,u,d="",_,f,p){const g=o(e.context);f||(f=g.createRawShaderProgramInjection??l),p||(p=g.createShaderProgramInjection??c);const m=e;m.program=i?f(m,t,s,m.context,u):p(m,t,s,h,m.context,u),m.program.__SPECTOR_rebuildProgram=a,_()}function p(e,t,s,i,n,a){return g((0,r.iL)(e,s,i),t,n,a)}function g(e,t,s,i){const r=s.createShader("vertex"===t?s.VERTEX_SHADER:s.FRAGMENT_SHADER);if(!r){let e=s.NO_ERROR,r=s.NO_ERROR;for(;(r=s.getError())!==s.NO_ERROR;)e=r;throw new Error(`Something went wrong while creating a gl ${t} shader object. gl error=${e}, gl isContextLost=${s.isContextLost()}, _contextWasLost=${i}`)}return s.shaderSource(r,e),s.compileShader(r),r}function m(e,t){t.useProgram(e)}function T(e,t){const s=e;if(!s.isParallelCompiled)return void t(e);const i=s.onCompiled;s.onCompiled=()=>{i?.(),t(e)}}},6321:(e,t,s)=>{s.r(t),s.d(t,{ThinEngine:()=>T});var i=s(5852),r=s(1137),n=s(8790);class a{constructor(){this.shaderLanguage=0}postProcessor(e,t,s,i,r){if(r.drawBuffersExtensionDisabled){const t=/#extension.+GL_EXT_draw_buffers.+(enable|require)/g;e=e.replace(t,"")}return e}}const o=/(flat\s)?\s*varying\s*.*/;class h{constructor(){this.shaderLanguage=0}attributeProcessor(e){return e.replace("attribute","in")}varyingCheck(e,t){return o.test(e)}varyingProcessor(e,t){return e.replace("varying",t?"in":"out")}postProcessor(e,t,s){const i=-1!==e.search(/#extension.+GL_EXT_draw_buffers.+require/);if(e=(e=e.replace(/#extension.+(GL_OVR_multiview2|GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth|GL_EXT_draw_buffers).+(enable|require)/g,"")).replace(/texture2D\s*\(/g,"texture("),s){const t=-1!==e.search(/layout *\(location *= *0\) *out/g);e=(e=(e=(e=(e=(e=(e=e.replace(/texture2DLodEXT\s*\(/g,"textureLod(")).replace(/textureCubeLodEXT\s*\(/g,"textureLod(")).replace(/textureCube\s*\(/g,"texture(")).replace(/gl_FragDepthEXT/g,"gl_FragDepth")).replace(/gl_FragColor/g,"glFragColor")).replace(/gl_FragData/g,"glFragData")).replace(/void\s+?main\s*\(/g,(i||t?"":"layout(location = 0) out vec4 glFragColor;\n")+"void main(")}else if(-1!==t.indexOf("#define MULTIVIEW"))return"#extension GL_OVR_multiview2 : require\nlayout (num_views = 2) in;\n"+e;return e}}var l=s(4329),c=s(1597),u=s(6326),d=s(7716),_=s(854),f=s(4420),p=s(6741),g=s(7647);class m{}class T extends u.${get name(){return this._name}set name(e){this._name=e}get version(){return this._webGLVersion}static get ShadersRepository(){return f.M.ShadersRepository}static set ShadersRepository(e){f.M.ShadersRepository=e}get supportsUniformBuffers(){return this.webGLVersion>1&&!this.disableUniformBuffers}get needPOTTextures(){return this._webGLVersion<2||this.forcePOTTextures}get _supportsHardwareTextureRescaling(){return!1}set framebufferDimensionsObject(e){this._framebufferDimensionsObject=e}snapshotRenderingReset(){this.snapshotRendering=!1}constructor(e,t,s,n){if(s=s||{},super(t??s.antialias,s,n),this._name="WebGL",this.forcePOTTextures=!1,this.validateShaderPrograms=!1,this.disableUniformBuffers=!1,this._webGLVersion=1,this._vertexAttribArraysEnabled=[],this._uintIndicesCurrentlySet=!1,this._currentBoundBuffer=new Array,this._currentFramebuffer=null,this._dummyFramebuffer=null,this._currentBufferPointers=new Array,this._currentInstanceLocations=new Array,this._currentInstanceBuffers=new Array,this._vaoRecordInProgress=!1,this._mustWipeVertexAttributes=!1,this._nextFreeTextureSlots=new Array,this._maxSimultaneousTextures=0,this._maxMSAASamplesOverride=null,this._unpackFlipYCached=null,this.enableUnpackFlipYCached=!0,this._boundUniforms={},!e)return;let o=null;if(e.getContext){if(o=e,this._renderingCanvas=o,void 0===s.preserveDrawingBuffer&&(s.preserveDrawingBuffer=!1),void 0===s.xrCompatible&&(s.xrCompatible=!1),navigator&&navigator.userAgent){this._setupMobileChecks();const e=navigator.userAgent;for(const t of T.ExceptionList){const i=t.key,r=t.targets;if(new RegExp(i).test(e)){if(t.capture&&t.captureConstraint){const s=t.capture,i=t.captureConstraint,r=new RegExp(s).exec(e);if(r&&r.length>0&&parseInt(r[r.length-1])>=i)continue}for(const e of r)switch(e){case"uniformBuffer":this.disableUniformBuffers=!0;break;case"vao":this.disableVertexArrayObjects=!0;break;case"antialias":s.antialias=!1;break;case"maxMSAASamples":this._maxMSAASamplesOverride=1}}}}if(this._doNotHandleContextLost||(this._onContextLost=e=>{e.preventDefault(),this._contextWasLost=!0,r.V.Warn("WebGL context lost."),this.onContextLostObservable.notifyObservers(this)},this._onContextRestored=()=>{this._restoreEngineAfterContextLost((()=>this._initGLContext()))},o.addEventListener("webglcontextlost",this._onContextLost,!1),o.addEventListener("webglcontextrestored",this._onContextRestored,!1),s.powerPreference=s.powerPreference||"high-performance"),this._badDesktopOS&&(s.xrCompatible=!1),!s.disableWebGL2Support)try{this._gl=o.getContext("webgl2",s)||o.getContext("experimental-webgl2",s),this._gl&&(this._webGLVersion=2,this._shaderPlatformName="WEBGL2",this._gl.deleteQuery||(this._webGLVersion=1,this._shaderPlatformName="WEBGL1"))}catch(e){}if(!this._gl){if(!o)throw new Error("The provided canvas is null or undefined.");try{this._gl=o.getContext("webgl",s)||o.getContext("experimental-webgl",s)}catch(e){throw new Error("WebGL not supported")}}if(!this._gl)throw new Error("WebGL not supported")}else{this._gl=e,this._renderingCanvas=this._gl.canvas,this._gl.renderbufferStorageMultisample?(this._webGLVersion=2,this._shaderPlatformName="WEBGL2"):this._shaderPlatformName="WEBGL1";const t=this._gl.getContextAttributes();t&&(s.stencil=t.stencil)}this._gl.pixelStorei(this._gl.UNPACK_COLORSPACE_CONVERSION_WEBGL,this._gl.NONE),void 0!==s.useHighPrecisionFloats&&(this._highPrecisionShadersAllowed=s.useHighPrecisionFloats),this.resize(),this._initGLContext(),this._initFeatures();for(let e=0;e1?new h:new a;const l=`Babylon.js v${T.Version}`;r.V.Log(l+` - ${this.description}`),this._renderingCanvas&&this._renderingCanvas.setAttribute&&this._renderingCanvas.setAttribute("data-engine",l);const c=(0,i.N5)(this._gl);c.validateShaderPrograms=this.validateShaderPrograms,c.parallelShaderCompile=this._caps.parallelShaderCompile}_clearEmptyResources(){this._dummyFramebuffer=null,super._clearEmptyResources()}_getShaderProcessingContext(e){return null}areAllEffectsReady(){for(const e in this._compiledEffects)if(!this._compiledEffects[e].isReady())return!1;return!0}_initGLContext(){this._caps={maxTexturesImageUnits:this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS),maxCombinedTexturesImageUnits:this._gl.getParameter(this._gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS),maxVertexTextureImageUnits:this._gl.getParameter(this._gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS),maxTextureSize:this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE),maxSamples:this._webGLVersion>1?this._gl.getParameter(this._gl.MAX_SAMPLES):1,maxCubemapTextureSize:this._gl.getParameter(this._gl.MAX_CUBE_MAP_TEXTURE_SIZE),maxRenderTextureSize:this._gl.getParameter(this._gl.MAX_RENDERBUFFER_SIZE),maxVertexAttribs:this._gl.getParameter(this._gl.MAX_VERTEX_ATTRIBS),maxVaryingVectors:this._gl.getParameter(this._gl.MAX_VARYING_VECTORS),maxFragmentUniformVectors:this._gl.getParameter(this._gl.MAX_FRAGMENT_UNIFORM_VECTORS),maxVertexUniformVectors:this._gl.getParameter(this._gl.MAX_VERTEX_UNIFORM_VECTORS),parallelShaderCompile:this._gl.getExtension("KHR_parallel_shader_compile")||void 0,standardDerivatives:this._webGLVersion>1||null!==this._gl.getExtension("OES_standard_derivatives"),maxAnisotropy:1,astc:this._gl.getExtension("WEBGL_compressed_texture_astc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_astc"),bptc:this._gl.getExtension("EXT_texture_compression_bptc")||this._gl.getExtension("WEBKIT_EXT_texture_compression_bptc"),s3tc:this._gl.getExtension("WEBGL_compressed_texture_s3tc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc"),s3tc_srgb:this._gl.getExtension("WEBGL_compressed_texture_s3tc_srgb")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc_srgb"),pvrtc:this._gl.getExtension("WEBGL_compressed_texture_pvrtc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),etc1:this._gl.getExtension("WEBGL_compressed_texture_etc1")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_etc1"),etc2:this._gl.getExtension("WEBGL_compressed_texture_etc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_etc")||this._gl.getExtension("WEBGL_compressed_texture_es3_0"),textureAnisotropicFilterExtension:this._gl.getExtension("EXT_texture_filter_anisotropic")||this._gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic")||this._gl.getExtension("MOZ_EXT_texture_filter_anisotropic"),uintIndices:this._webGLVersion>1||null!==this._gl.getExtension("OES_element_index_uint"),fragmentDepthSupported:this._webGLVersion>1||null!==this._gl.getExtension("EXT_frag_depth"),highPrecisionShaderSupported:!1,timerQuery:this._gl.getExtension("EXT_disjoint_timer_query_webgl2")||this._gl.getExtension("EXT_disjoint_timer_query"),supportOcclusionQuery:this._webGLVersion>1,canUseTimestampForTimerQuery:!1,drawBuffersExtension:!1,maxMSAASamples:1,colorBufferFloat:!!(this._webGLVersion>1&&this._gl.getExtension("EXT_color_buffer_float")),supportFloatTexturesResolve:!1,rg11b10ufColorRenderable:!1,colorBufferHalfFloat:!!(this._webGLVersion>1&&this._gl.getExtension("EXT_color_buffer_half_float")),textureFloat:!!(this._webGLVersion>1||this._gl.getExtension("OES_texture_float")),textureHalfFloat:!!(this._webGLVersion>1||this._gl.getExtension("OES_texture_half_float")),textureHalfFloatRender:!1,textureFloatLinearFiltering:!1,textureFloatRender:!1,textureHalfFloatLinearFiltering:!1,vertexArrayObject:!1,instancedArrays:!1,textureLOD:!!(this._webGLVersion>1||this._gl.getExtension("EXT_shader_texture_lod")),texelFetch:1!==this._webGLVersion,blendMinMax:!1,multiview:this._gl.getExtension("OVR_multiview2"),oculusMultiview:this._gl.getExtension("OCULUS_multiview"),depthTextureExtension:!1,canUseGLInstanceID:this._webGLVersion>1,canUseGLVertexID:this._webGLVersion>1,supportComputeShaders:!1,supportSRGBBuffers:!1,supportTransformFeedbacks:this._webGLVersion>1,textureMaxLevel:this._webGLVersion>1,texture2DArrayMaxLayerCount:this._webGLVersion>1?this._gl.getParameter(this._gl.MAX_ARRAY_TEXTURE_LAYERS):128,disableMorphTargetTexture:!1},this._caps.supportFloatTexturesResolve=this._caps.colorBufferFloat,this._caps.rg11b10ufColorRenderable=this._caps.colorBufferFloat,this._glVersion=this._gl.getParameter(this._gl.VERSION);const e=this._gl.getExtension("WEBGL_debug_renderer_info");if(null!=e&&(this._glRenderer=this._gl.getParameter(e.UNMASKED_RENDERER_WEBGL),this._glVendor=this._gl.getParameter(e.UNMASKED_VENDOR_WEBGL)),this._glVendor||(this._glVendor=this._gl.getParameter(this._gl.VENDOR)||"Unknown vendor"),this._glRenderer||(this._glRenderer=this._gl.getParameter(this._gl.RENDERER)||"Unknown renderer"),36193!==this._gl.HALF_FLOAT_OES&&(this._gl.HALF_FLOAT_OES=36193),34842!==this._gl.RGBA16F&&(this._gl.RGBA16F=34842),34836!==this._gl.RGBA32F&&(this._gl.RGBA32F=34836),35056!==this._gl.DEPTH24_STENCIL8&&(this._gl.DEPTH24_STENCIL8=35056),this._caps.timerQuery&&(1===this._webGLVersion&&(this._gl.getQuery=this._caps.timerQuery.getQueryEXT.bind(this._caps.timerQuery)),this._caps.canUseTimestampForTimerQuery=(this._gl.getQuery(this._caps.timerQuery.TIMESTAMP_EXT,this._caps.timerQuery.QUERY_COUNTER_BITS_EXT)??0)>0),this._caps.maxAnisotropy=this._caps.textureAnisotropicFilterExtension?this._gl.getParameter(this._caps.textureAnisotropicFilterExtension.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0,this._caps.textureFloatLinearFiltering=!(!this._caps.textureFloat||!this._gl.getExtension("OES_texture_float_linear")),this._caps.textureFloatRender=!(!this._caps.textureFloat||!this._canRenderToFloatFramebuffer()),this._caps.textureHalfFloatLinearFiltering=!!(this._webGLVersion>1||this._caps.textureHalfFloat&&this._gl.getExtension("OES_texture_half_float_linear")),this._caps.astc&&(this._gl.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=this._caps.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR),this._caps.bptc&&(this._gl.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=this._caps.bptc.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT),this._caps.s3tc_srgb&&(this._gl.COMPRESSED_SRGB_S3TC_DXT1_EXT=this._caps.s3tc_srgb.COMPRESSED_SRGB_S3TC_DXT1_EXT,this._gl.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=this._caps.s3tc_srgb.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,this._gl.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=this._caps.s3tc_srgb.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT),this._caps.etc2&&(this._gl.COMPRESSED_SRGB8_ETC2=this._caps.etc2.COMPRESSED_SRGB8_ETC2,this._gl.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=this._caps.etc2.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC),this._webGLVersion>1&&5131!==this._gl.HALF_FLOAT_OES&&(this._gl.HALF_FLOAT_OES=5131),this._caps.textureHalfFloatRender=this._caps.textureHalfFloat&&this._canRenderToHalfFloatFramebuffer(),this._webGLVersion>1)this._caps.drawBuffersExtension=!0,this._caps.maxMSAASamples=null!==this._maxMSAASamplesOverride?this._maxMSAASamplesOverride:this._gl.getParameter(this._gl.MAX_SAMPLES),this._caps.maxDrawBuffers=this._gl.getParameter(this._gl.MAX_DRAW_BUFFERS);else{const e=this._gl.getExtension("WEBGL_draw_buffers");if(null!==e){this._caps.drawBuffersExtension=!0,this._gl.drawBuffers=e.drawBuffersWEBGL.bind(e),this._caps.maxDrawBuffers=this._gl.getParameter(e.MAX_DRAW_BUFFERS_WEBGL),this._gl.DRAW_FRAMEBUFFER=this._gl.FRAMEBUFFER;for(let t=0;t<16;t++)this._gl["COLOR_ATTACHMENT"+t+"_WEBGL"]=e["COLOR_ATTACHMENT"+t+"_WEBGL"]}}if(this._webGLVersion>1)this._caps.depthTextureExtension=!0;else{const e=this._gl.getExtension("WEBGL_depth_texture");null!=e&&(this._caps.depthTextureExtension=!0,this._gl.UNSIGNED_INT_24_8=e.UNSIGNED_INT_24_8_WEBGL)}if(this.disableVertexArrayObjects)this._caps.vertexArrayObject=!1;else if(this._webGLVersion>1)this._caps.vertexArrayObject=!0;else{const e=this._gl.getExtension("OES_vertex_array_object");null!=e&&(this._caps.vertexArrayObject=!0,this._gl.createVertexArray=e.createVertexArrayOES.bind(e),this._gl.bindVertexArray=e.bindVertexArrayOES.bind(e),this._gl.deleteVertexArray=e.deleteVertexArrayOES.bind(e))}if(this._webGLVersion>1)this._caps.instancedArrays=!0;else{const e=this._gl.getExtension("ANGLE_instanced_arrays");null!=e?(this._caps.instancedArrays=!0,this._gl.drawArraysInstanced=e.drawArraysInstancedANGLE.bind(e),this._gl.drawElementsInstanced=e.drawElementsInstancedANGLE.bind(e),this._gl.vertexAttribDivisor=e.vertexAttribDivisorANGLE.bind(e)):this._caps.instancedArrays=!1}if(this._gl.getShaderPrecisionFormat){const e=this._gl.getShaderPrecisionFormat(this._gl.VERTEX_SHADER,this._gl.HIGH_FLOAT),t=this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER,this._gl.HIGH_FLOAT);e&&t&&(this._caps.highPrecisionShaderSupported=0!==e.precision&&0!==t.precision)}if(this._webGLVersion>1)this._caps.blendMinMax=!0;else{const e=this._gl.getExtension("EXT_blend_minmax");null!=e&&(this._caps.blendMinMax=!0,this._gl.MAX=e.MAX_EXT,this._gl.MIN=e.MIN_EXT)}if(!this._caps.supportSRGBBuffers){if(this._webGLVersion>1)this._caps.supportSRGBBuffers=!0,this._glSRGBExtensionValues={SRGB:WebGL2RenderingContext.SRGB,SRGB8:WebGL2RenderingContext.SRGB8,SRGB8_ALPHA8:WebGL2RenderingContext.SRGB8_ALPHA8};else{const e=this._gl.getExtension("EXT_sRGB");null!=e&&(this._caps.supportSRGBBuffers=!0,this._glSRGBExtensionValues={SRGB:e.SRGB_EXT,SRGB8:e.SRGB_ALPHA_EXT,SRGB8_ALPHA8:e.SRGB_ALPHA_EXT})}if(this._creationOptions){const e=this._creationOptions.forceSRGBBufferSupportState;void 0!==e&&(this._caps.supportSRGBBuffers=this._caps.supportSRGBBuffers&&e)}}this._depthCullingState.depthTest=!0,this._depthCullingState.depthFunc=this._gl.LEQUAL,this._depthCullingState.depthMask=!0,this._maxSimultaneousTextures=this._caps.maxCombinedTexturesImageUnits;for(let e=0;e=65535)return new Uint32Array(e);return new Uint16Array(e)}return new Uint16Array(e)}bindArrayBuffer(e){this._vaoRecordInProgress||this._unbindVertexArrayObject(),this._bindBuffer(e,this._gl.ARRAY_BUFFER)}bindUniformBlock(e,t,s){const i=e.program,r=this._gl.getUniformBlockIndex(i,t);this._gl.uniformBlockBinding(i,r,s)}bindIndexBuffer(e){this._vaoRecordInProgress||this._unbindVertexArrayObject(),this._bindBuffer(e,this._gl.ELEMENT_ARRAY_BUFFER)}_bindBuffer(e,t){(this._vaoRecordInProgress||this._currentBoundBuffer[t]!==e)&&(this._gl.bindBuffer(t,e?e.underlyingResource:null),this._currentBoundBuffer[t]=e)}updateArrayBuffer(e){this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,e)}_vertexAttribPointer(e,t,s,i,r,n,a){const o=this._currentBufferPointers[t];if(!o)return;let h=!1;o.active?(o.buffer!==e&&(o.buffer=e,h=!0),o.size!==s&&(o.size=s,h=!0),o.type!==i&&(o.type=i,h=!0),o.normalized!==r&&(o.normalized=r,h=!0),o.stride!==n&&(o.stride=n,h=!0),o.offset!==a&&(o.offset=a,h=!0)):(h=!0,o.active=!0,o.index=t,o.size=s,o.type=i,o.normalized=r,o.stride=n,o.offset=a,o.buffer=e),(h||this._vaoRecordInProgress)&&(this.bindArrayBuffer(e),i===this._gl.UNSIGNED_INT||i===this._gl.INT?this._gl.vertexAttribIPointer(t,s,i,n,a):this._gl.vertexAttribPointer(t,s,i,r,n,a))}_bindIndexBufferWithCache(e){null!=e&&this._cachedIndexBuffer!==e&&(this._cachedIndexBuffer=e,this.bindIndexBuffer(e),this._uintIndicesCurrentlySet=e.is32Bits)}_bindVertexBuffersAttributes(e,t,s){const i=t.getAttributesNames();this._vaoRecordInProgress||this._unbindVertexArrayObject(),this.unbindAllAttributes();for(let r=0;r=0){const t=i[r];let a=null;if(s&&(a=s[t]),a||(a=e[t]),!a)continue;this._gl.enableVertexAttribArray(n),this._vaoRecordInProgress||(this._vertexAttribArraysEnabled[n]=!0);const o=a.getBuffer();o&&(this._vertexAttribPointer(o,n,a.getSize(),a.type,a.normalized,a.byteStride,a.byteOffset),a.getIsInstanced()&&(this._gl.vertexAttribDivisor(n,a.getInstanceDivisor()),this._vaoRecordInProgress||(this._currentInstanceLocations.push(n),this._currentInstanceBuffers.push(o))))}}}recordVertexArrayObject(e,t,s,i){const r=this._gl.createVertexArray();if(!r)throw new Error("Unable to create VAO");return this._vaoRecordInProgress=!0,this._gl.bindVertexArray(r),this._mustWipeVertexAttributes=!0,this._bindVertexBuffersAttributes(e,s,i),this.bindIndexBuffer(t),this._vaoRecordInProgress=!1,this._gl.bindVertexArray(null),r}bindVertexArrayObject(e,t){this._cachedVertexArrayObject!==e&&(this._cachedVertexArrayObject=e,this._gl.bindVertexArray(e),this._cachedVertexBuffers=null,this._cachedIndexBuffer=null,this._uintIndicesCurrentlySet=null!=t&&t.is32Bits,this._mustWipeVertexAttributes=!0)}bindBuffersDirectly(e,t,s,i,r){if(this._cachedVertexBuffers!==e||this._cachedEffectForVertexBuffers!==r){this._cachedVertexBuffers=e,this._cachedEffectForVertexBuffers=r;const t=r.getAttributesCount();this._unbindVertexArrayObject(),this.unbindAllAttributes();let n=0;for(let a=0;a=0&&(this._gl.enableVertexAttribArray(t),this._vertexAttribArraysEnabled[t]=!0,this._vertexAttribPointer(e,t,s[a],this._gl.FLOAT,!1,i,n)),n+=4*s[a]}}this._bindIndexBufferWithCache(t)}_unbindVertexArrayObject(){this._cachedVertexArrayObject&&(this._cachedVertexArrayObject=null,this._gl.bindVertexArray(null))}bindBuffers(e,t,s,i){this._cachedVertexBuffers===e&&this._cachedEffectForVertexBuffers===s||(this._cachedVertexBuffers=e,this._cachedEffectForVertexBuffers=s,this._bindVertexBuffersAttributes(e,s,i)),this._bindIndexBufferWithCache(t)}unbindInstanceAttributes(){let e;for(let t=0,s=this._currentInstanceLocations.length;t1||this.isWebGPU)),(1!==o||this._caps.textureFloatLinearFiltering)&&(2!==o||this._caps.textureHalfFloatLinearFiltering)||(h=1),1!==o||this._caps.textureFloat||(o=0,r.V.Warn("Float textures are not supported. Type forced to TEXTURETYPE_UNSIGNED_BYTE"));const d=this._gl,f=new _.h(this,i),p=e.width||e,g=e.height||e,m=e.depth||0,T=e.layers||0,b=this._getSamplingParameters(h,a),E=0!==T?d.TEXTURE_2D_ARRAY:0!==m?d.TEXTURE_3D:d.TEXTURE_2D,x=this._getRGBABufferInternalSizedFormat(o,l,c),A=this._getInternalFormat(l),R=this._getWebGLTextureType(o);return this._bindTextureDirectly(E,f),0!==T?(f.is2DArray=!0,d.texImage3D(E,0,x,p,g,T,0,A,R,null)):0!==m?(f.is3D=!0,d.texImage3D(E,0,x,p,g,m,0,A,R,null)):d.texImage2D(E,0,x,p,g,0,A,R,null),d.texParameteri(E,d.TEXTURE_MAG_FILTER,b.mag),d.texParameteri(E,d.TEXTURE_MIN_FILTER,b.min),d.texParameteri(E,d.TEXTURE_WRAP_S,d.CLAMP_TO_EDGE),d.texParameteri(E,d.TEXTURE_WRAP_T,d.CLAMP_TO_EDGE),a&&this._gl.generateMipmap(E),this._bindTextureDirectly(E,null),f._useSRGBBuffer=c,f.baseWidth=p,f.baseHeight=g,f.width=p,f.height=g,f.depth=T,f.isReady=!0,f.samples=u,f.generateMipMaps=a,f.samplingMode=h,f.type=o,f.format=l,f.label=n,this._internalTexturesCache.push(f),f}_getUseSRGBBuffer(e,t){return e&&this._caps.supportSRGBBuffers&&(this.webGLVersion>1||t)}createTexture(e,t,s,i,r=3,n=null,a=null,o=null,h=null,l=null,c=null,u,d,f,p){return this._createTextureBase(e,t,s,i,r,n,a,((...e)=>this._prepareWebGLTexture(...e,l)),((e,t,s,r,n,a)=>{const o=this._gl,h=s.width===e&&s.height===t;n._creationFlags=f??0;const l=this._getTexImageParametersForCreateTexture(n.format,n._useSRGBBuffer);if(h)return o.texImage2D(o.TEXTURE_2D,0,l.internalFormat,l.format,l.type,s),!1;const c=this._caps.maxTextureSize;if(s.width>c||s.height>c||!this._supportsHardwareTextureRescaling)return this._prepareWorkingCanvas(),!(!this._workingCanvas||!this._workingContext||(this._workingCanvas.width=e,this._workingCanvas.height=t,this._workingContext.drawImage(s,0,0,s.width,s.height,0,0,e,t),o.texImage2D(o.TEXTURE_2D,0,l.internalFormat,l.format,l.type,this._workingCanvas),n.width=e,n.height=t,1));{const e=new _.h(this,2);this._bindTextureDirectly(o.TEXTURE_2D,e,!0),o.texImage2D(o.TEXTURE_2D,0,l.internalFormat,l.format,l.type,s),this._rescaleTexture(e,n,i,l.format,(()=>{this._releaseTexture(e),this._bindTextureDirectly(o.TEXTURE_2D,n,!0),a()}))}return!0}),o,h,l,c,u,d,p)}_getTexImageParametersForCreateTexture(e,t){let s,i;return 1===this.webGLVersion?(s=this._getInternalFormat(e,t),i=s):(s=this._getInternalFormat(e,!1),i=this._getRGBABufferInternalSizedFormat(0,e,t)),{internalFormat:i,format:s,type:this._gl.UNSIGNED_BYTE}}_rescaleTexture(e,t,s,i,r){}_unpackFlipY(e){this._unpackFlipYCached!==e&&(this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL,e?1:0),this.enableUnpackFlipYCached&&(this._unpackFlipYCached=e))}_getUnpackAlignement(){return this._gl.getParameter(this._gl.UNPACK_ALIGNMENT)}_getTextureTarget(e){return e.isCube?this._gl.TEXTURE_CUBE_MAP:e.is3D?this._gl.TEXTURE_3D:e.is2DArray||e.isMultiview?this._gl.TEXTURE_2D_ARRAY:this._gl.TEXTURE_2D}updateTextureSamplingMode(e,t,s=!1){const i=this._getTextureTarget(t),r=this._getSamplingParameters(e,t.useMipMaps||s);this._setTextureParameterInteger(i,this._gl.TEXTURE_MAG_FILTER,r.mag,t),this._setTextureParameterInteger(i,this._gl.TEXTURE_MIN_FILTER,r.min),s&&(t.generateMipMaps=!0,this._gl.generateMipmap(i)),this._bindTextureDirectly(i,null),t.samplingMode=e}updateTextureDimensions(e,t,s,i=1){}updateTextureWrappingMode(e,t,s=null,i=null){const r=this._getTextureTarget(e);null!==t&&(this._setTextureParameterInteger(r,this._gl.TEXTURE_WRAP_S,this._getTextureWrapMode(t),e),e._cachedWrapU=t),null!==s&&(this._setTextureParameterInteger(r,this._gl.TEXTURE_WRAP_T,this._getTextureWrapMode(s),e),e._cachedWrapV=s),(e.is2DArray||e.is3D)&&null!==i&&(this._setTextureParameterInteger(r,this._gl.TEXTURE_WRAP_R,this._getTextureWrapMode(i),e),e._cachedWrapR=i),this._bindTextureDirectly(r,null)}_uploadCompressedDataToTextureDirectly(e,t,s,i,r,n=0,a=0){const o=this._gl;let h=o.TEXTURE_2D;if(e.isCube&&(h=o.TEXTURE_CUBE_MAP_POSITIVE_X+n),e._useSRGBBuffer)switch(t){case 37492:case 36196:this._caps.etc2?t=o.COMPRESSED_SRGB8_ETC2:e._useSRGBBuffer=!1;break;case 37496:this._caps.etc2?t=o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:e._useSRGBBuffer=!1;break;case 36492:t=o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT;break;case 37808:t=o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR;break;case 33776:this._caps.s3tc_srgb?t=o.COMPRESSED_SRGB_S3TC_DXT1_EXT:e._useSRGBBuffer=!1;break;case 33777:this._caps.s3tc_srgb?t=o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:e._useSRGBBuffer=!1;break;case 33779:this._caps.s3tc_srgb?t=o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:e._useSRGBBuffer=!1;break;default:e._useSRGBBuffer=!1}this._gl.compressedTexImage2D(h,a,t,s,i,0,r)}_uploadDataToTextureDirectly(e,t,s=0,i=0,r,n=!1){const a=this._gl,o=this._getWebGLTextureType(e.type),h=this._getInternalFormat(e.format),l=void 0===r?this._getRGBABufferInternalSizedFormat(e.type,e.format,e._useSRGBBuffer):this._getInternalFormat(r,e._useSRGBBuffer);this._unpackFlipY(e.invertY);let c=a.TEXTURE_2D;e.isCube&&(c=a.TEXTURE_CUBE_MAP_POSITIVE_X+s);const u=Math.round(Math.log(e.width)*Math.LOG2E),d=Math.round(Math.log(e.height)*Math.LOG2E),_=n?e.width:Math.pow(2,Math.max(u-i,0)),f=n?e.height:Math.pow(2,Math.max(d-i,0));a.texImage2D(c,i,l,_,f,0,h,o,t)}updateTextureData(e,t,s,i,r,n,a=0,o=0,h=!1){const l=this._gl,c=this._getWebGLTextureType(e.type),u=this._getInternalFormat(e.format);this._unpackFlipY(e.invertY);let d=l.TEXTURE_2D,_=l.TEXTURE_2D;e.isCube&&(_=l.TEXTURE_CUBE_MAP_POSITIVE_X+a,d=l.TEXTURE_CUBE_MAP),this._bindTextureDirectly(d,e,!0),l.texSubImage2D(_,o,s,i,r,n,u,c,t),h&&this._gl.generateMipmap(_),this._bindTextureDirectly(d,null)}_uploadArrayBufferViewToTexture(e,t,s=0,i=0){const r=this._gl,n=e.isCube?r.TEXTURE_CUBE_MAP:r.TEXTURE_2D;this._bindTextureDirectly(n,e,!0),this._uploadDataToTextureDirectly(e,t,s,i),this._bindTextureDirectly(n,null,!0)}_prepareWebGLTextureContinuation(e,t,s,i,r){const n=this._gl;if(!n)return;const a=this._getSamplingParameters(r,!s);n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,a.mag),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,a.min),s||i||n.generateMipmap(n.TEXTURE_2D),this._bindTextureDirectly(n.TEXTURE_2D,null),t&&t.removePendingData(e),e.onLoadedObservable.notifyObservers(e),e.onLoadedObservable.clear()}_prepareWebGLTexture(e,t,s,i,r,n,a,o,h,l){const u=this.getCaps().maxTextureSize,d=Math.min(u,this.needPOTTextures?(0,c.R)(i.width,u):i.width),_=Math.min(u,this.needPOTTextures?(0,c.R)(i.height,u):i.height),f=this._gl;f&&(e._hardwareTexture?(this._bindTextureDirectly(f.TEXTURE_2D,e,!0),this._unpackFlipY(void 0===r||!!r),e.baseWidth=i.width,e.baseHeight=i.height,e.width=d,e.height=_,e.isReady=!0,e.type=-1!==e.type?e.type:0,e.format=-1!==e.format?e.format:l??(".jpg"!==t||e._useSRGBBuffer?5:4),o(d,_,i,t,e,(()=>{this._prepareWebGLTextureContinuation(e,s,n,a,h)}))||this._prepareWebGLTextureContinuation(e,s,n,a,h)):s&&s.removePendingData(e))}_getInternalFormatFromDepthTextureFormat(e,t,s){const i=this._gl;if(!t)return i.STENCIL_INDEX8;let r=s?i.DEPTH_STENCIL:i.DEPTH_COMPONENT;return this.webGLVersion>1?15===e?r=i.DEPTH_COMPONENT16:16===e?r=i.DEPTH_COMPONENT24:17===e||13===e?r=s?i.DEPTH24_STENCIL8:i.DEPTH_COMPONENT24:14===e?r=i.DEPTH_COMPONENT32F:18===e&&(r=s?i.DEPTH32F_STENCIL8:i.DEPTH_COMPONENT32F):r=i.DEPTH_COMPONENT16,r}_setupFramebufferDepthAttachments(e,t,s,i,r=1,n){const a=this._gl;n=n??(e?13:14);const o=this._getInternalFormatFromDepthTextureFormat(n,t,e);return e&&t?this._createRenderBuffer(s,i,r,a.DEPTH_STENCIL,o,a.DEPTH_STENCIL_ATTACHMENT):t?this._createRenderBuffer(s,i,r,o,o,a.DEPTH_ATTACHMENT):e?this._createRenderBuffer(s,i,r,o,o,a.STENCIL_ATTACHMENT):null}_createRenderBuffer(e,t,s,i,r,n,a=!0){const o=this._gl.createRenderbuffer();return this._updateRenderBuffer(o,e,t,s,i,r,n,a)}_updateRenderBuffer(e,t,s,i,r,n,a,o=!0){const h=this._gl;return h.bindRenderbuffer(h.RENDERBUFFER,e),i>1&&h.renderbufferStorageMultisample?h.renderbufferStorageMultisample(h.RENDERBUFFER,i,n,t,s):h.renderbufferStorage(h.RENDERBUFFER,r,t,s),h.framebufferRenderbuffer(h.FRAMEBUFFER,a,h.RENDERBUFFER,e),o&&h.bindRenderbuffer(h.RENDERBUFFER,null),e}_releaseTexture(e){this._deleteTexture(e._hardwareTexture),this.unbindAllTextures();const t=this._internalTexturesCache.indexOf(e);-1!==t&&this._internalTexturesCache.splice(t,1),e._lodTextureHigh&&e._lodTextureHigh.dispose(),e._lodTextureMid&&e._lodTextureMid.dispose(),e._lodTextureLow&&e._lodTextureLow.dispose(),e._irradianceTexture&&e._irradianceTexture.dispose()}_deleteTexture(e){e?.release()}_setProgram(e){this._currentProgram!==e&&((0,i.C5)(e,this._gl),this._currentProgram=e)}bindSamplers(e){const t=e.getPipelineContext();this._setProgram(t.program);const s=e.getSamplers();for(let t=0;t-1;if(s&&a&&(this._activeChannel=t._associatedChannel),this._boundTexturesCache[this._activeChannel]!==t||i){if(this._activateCurrentTexture(),t&&t.isMultiview)throw r.V.Error(["_bindTextureDirectly called with a multiview texture!",e,t]),"_bindTextureDirectly called with a multiview texture!";this._gl.bindTexture(e,t?._hardwareTexture?.underlyingResource??null),this._boundTexturesCache[this._activeChannel]=t,t&&(t._associatedChannel=this._activeChannel)}else s&&(n=!0,this._activateCurrentTexture());return a&&!s&&this._bindSamplerUniformToChannel(t._associatedChannel,this._activeChannel),n}_bindTexture(e,t,s){if(void 0===e)return;t&&(t._associatedChannel=e),this._activeChannel=e;const i=t?this._getTextureTarget(t):this._gl.TEXTURE_2D;this._bindTextureDirectly(i,t)}unbindAllTextures(){for(let e=0;e1&&(this._bindTextureDirectly(this._gl.TEXTURE_3D,null),this._bindTextureDirectly(this._gl.TEXTURE_2D_ARRAY,null))}setTexture(e,t,s,i){void 0!==e&&(t&&(this._boundUniforms[e]=t),this._setTexture(e,s))}_bindSamplerUniformToChannel(e,t){const s=this._boundUniforms[e];s&&s._currentState!==t&&(this._gl.uniform1i(s,t),s._currentState=t)}_getTextureWrapMode(e){switch(e){case 1:return this._gl.REPEAT;case 0:return this._gl.CLAMP_TO_EDGE;case 2:return this._gl.MIRRORED_REPEAT}return this._gl.REPEAT}_setTexture(e,t,s=!1,i=!1,r=""){if(!t)return null!=this._boundTexturesCache[e]&&(this._activeChannel=e,this._bindTextureDirectly(this._gl.TEXTURE_2D,null),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null),this.webGLVersion>1&&(this._bindTextureDirectly(this._gl.TEXTURE_3D,null),this._bindTextureDirectly(this._gl.TEXTURE_2D_ARRAY,null))),!1;if(t.video){this._activeChannel=e;const s=t.getInternalTexture();s&&(s._associatedChannel=e),t.update()}else if(4===t.delayLoadState)return t.delayLoad(),!1;let n;n=i?t.depthStencilTexture:t.isReady()?t.getInternalTexture():t.isCube?this.emptyCubeTexture:t.is3D?this.emptyTexture3D:t.is2DArray?this.emptyTexture2DArray:this.emptyTexture,!s&&n&&(n._associatedChannel=e);let a=!0;this._boundTexturesCache[e]===n&&(s||this._bindSamplerUniformToChannel(n._associatedChannel,e),a=!1),this._activeChannel=e;const o=this._getTextureTarget(n);if(a&&this._bindTextureDirectly(o,n,s),n&&!n.isMultiview){if(n.isCube&&n._cachedCoordinatesMode!==t.coordinatesMode){n._cachedCoordinatesMode=t.coordinatesMode;const e=3!==t.coordinatesMode&&5!==t.coordinatesMode?1:0;t.wrapU=e,t.wrapV=e}n._cachedWrapU!==t.wrapU&&(n._cachedWrapU=t.wrapU,this._setTextureParameterInteger(o,this._gl.TEXTURE_WRAP_S,this._getTextureWrapMode(t.wrapU),n)),n._cachedWrapV!==t.wrapV&&(n._cachedWrapV=t.wrapV,this._setTextureParameterInteger(o,this._gl.TEXTURE_WRAP_T,this._getTextureWrapMode(t.wrapV),n)),n.is3D&&n._cachedWrapR!==t.wrapR&&(n._cachedWrapR=t.wrapR,this._setTextureParameterInteger(o,this._gl.TEXTURE_WRAP_R,this._getTextureWrapMode(t.wrapR),n)),this._setAnisotropicLevel(o,n,t.anisotropicFilteringLevel)}return!0}setTextureArray(e,t,s,i){if(void 0!==e&&t){this._textureUnits&&this._textureUnits.length===s.length||(this._textureUnits=new Int32Array(s.length));for(let t=0;t=this._caps.maxVertexAttribs||!this._vertexAttribArraysEnabled[e]||this.disableAttributeByIndex(e)}releaseEffects(){const e=Object.keys(this._compiledEffects);for(const t of e)this._compiledEffects[t].dispose();this._compiledEffects={}}dispose(){(0,n.BA)()&&this._renderingCanvas&&(this._doNotHandleContextLost||(this._renderingCanvas.removeEventListener("webglcontextlost",this._onContextLost),this._renderingCanvas.removeEventListener("webglcontextrestored",this._onContextRestored))),super.dispose(),this._dummyFramebuffer&&this._gl.deleteFramebuffer(this._dummyFramebuffer),this.unbindAllAttributes(),this._boundUniforms={},this._workingCanvas=null,this._workingContext=null,this._currentBufferPointers.length=0,this._currentProgram=null,this._creationOptions.loseContextOnDispose&&this._gl.getExtension("WEBGL_lose_context")?.loseContext(),(0,i.Cm)(this._gl)}attachContextLostEvent(e){this._renderingCanvas&&this._renderingCanvas.addEventListener("webglcontextlost",e,!1)}attachContextRestoredEvent(e){this._renderingCanvas&&this._renderingCanvas.addEventListener("webglcontextrestored",e,!1)}getError(){return this._gl.getError()}_canRenderToFloatFramebuffer(){return this._webGLVersion>1?this._caps.colorBufferFloat:this._canRenderToFramebuffer(1)}_canRenderToHalfFloatFramebuffer(){return this._webGLVersion>1?this._caps.colorBufferFloat:this._canRenderToFramebuffer(2)}_canRenderToFramebuffer(e){const t=this._gl;for(;t.getError()!==t.NO_ERROR;);let s=!0;const i=t.createTexture();t.bindTexture(t.TEXTURE_2D,i),t.texImage2D(t.TEXTURE_2D,0,this._getRGBABufferInternalSizedFormat(e),1,1,0,t.RGBA,this._getWebGLTextureType(e),null),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST);const r=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,r),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,i,0);const n=t.checkFramebufferStatus(t.FRAMEBUFFER);if(s=s&&n===t.FRAMEBUFFER_COMPLETE,s=s&&t.getError()===t.NO_ERROR,s&&(t.clear(t.COLOR_BUFFER_BIT),s=s&&t.getError()===t.NO_ERROR),s){t.bindFramebuffer(t.FRAMEBUFFER,null);const e=t.RGBA,i=t.UNSIGNED_BYTE,r=new Uint8Array(4);t.readPixels(0,0,1,1,e,i,r),s=s&&t.getError()===t.NO_ERROR}for(t.deleteTexture(i),t.deleteFramebuffer(r),t.bindFramebuffer(t.FRAMEBUFFER,null);!s&&t.getError()!==t.NO_ERROR;);return s}_getWebGLTextureType(e){if(1===this._webGLVersion){switch(e){case 1:return this._gl.FLOAT;case 2:return this._gl.HALF_FLOAT_OES;case 0:return this._gl.UNSIGNED_BYTE;case 8:return this._gl.UNSIGNED_SHORT_4_4_4_4;case 9:return this._gl.UNSIGNED_SHORT_5_5_5_1;case 10:return this._gl.UNSIGNED_SHORT_5_6_5}return this._gl.UNSIGNED_BYTE}switch(e){case 3:return this._gl.BYTE;case 0:return this._gl.UNSIGNED_BYTE;case 4:return this._gl.SHORT;case 5:return this._gl.UNSIGNED_SHORT;case 6:return this._gl.INT;case 7:return this._gl.UNSIGNED_INT;case 1:return this._gl.FLOAT;case 2:return this._gl.HALF_FLOAT;case 8:return this._gl.UNSIGNED_SHORT_4_4_4_4;case 9:return this._gl.UNSIGNED_SHORT_5_5_5_1;case 10:return this._gl.UNSIGNED_SHORT_5_6_5;case 11:return this._gl.UNSIGNED_INT_2_10_10_10_REV;case 12:return this._gl.UNSIGNED_INT_24_8;case 13:return this._gl.UNSIGNED_INT_10F_11F_11F_REV;case 14:return this._gl.UNSIGNED_INT_5_9_9_9_REV;case 15:return this._gl.FLOAT_32_UNSIGNED_INT_24_8_REV}return this._gl.UNSIGNED_BYTE}_getInternalFormat(e,t=!1){let s=t?this._glSRGBExtensionValues.SRGB8_ALPHA8:this._gl.RGBA;switch(e){case 0:s=this._gl.ALPHA;break;case 1:s=this._gl.LUMINANCE;break;case 2:s=this._gl.LUMINANCE_ALPHA;break;case 6:s=this._gl.RED;break;case 7:s=this._gl.RG;break;case 4:s=t?this._glSRGBExtensionValues.SRGB:this._gl.RGB;break;case 5:s=t?this._glSRGBExtensionValues.SRGB8_ALPHA8:this._gl.RGBA}if(this._webGLVersion>1)switch(e){case 8:s=this._gl.RED_INTEGER;break;case 9:s=this._gl.RG_INTEGER;break;case 10:s=this._gl.RGB_INTEGER;break;case 11:s=this._gl.RGBA_INTEGER}return s}_getRGBABufferInternalSizedFormat(e,t,s=!1){if(1===this._webGLVersion){if(void 0!==t)switch(t){case 0:return this._gl.ALPHA;case 1:return this._gl.LUMINANCE;case 2:return this._gl.LUMINANCE_ALPHA;case 4:return s?this._glSRGBExtensionValues.SRGB:this._gl.RGB}return this._gl.RGBA}switch(e){case 3:switch(t){case 6:return this._gl.R8_SNORM;case 7:return this._gl.RG8_SNORM;case 4:return this._gl.RGB8_SNORM;case 8:return this._gl.R8I;case 9:return this._gl.RG8I;case 10:return this._gl.RGB8I;case 11:return this._gl.RGBA8I;default:return this._gl.RGBA8_SNORM}case 0:switch(t){case 6:return this._gl.R8;case 7:return this._gl.RG8;case 4:return s?this._glSRGBExtensionValues.SRGB8:this._gl.RGB8;case 5:return s?this._glSRGBExtensionValues.SRGB8_ALPHA8:this._gl.RGBA8;case 8:return this._gl.R8UI;case 9:return this._gl.RG8UI;case 10:return this._gl.RGB8UI;case 11:return this._gl.RGBA8UI;case 0:return this._gl.ALPHA;case 1:return this._gl.LUMINANCE;case 2:return this._gl.LUMINANCE_ALPHA;default:return this._gl.RGBA8}case 4:switch(t){case 8:return this._gl.R16I;case 9:return this._gl.RG16I;case 10:return this._gl.RGB16I;default:return this._gl.RGBA16I}case 5:switch(t){case 8:return this._gl.R16UI;case 9:return this._gl.RG16UI;case 10:return this._gl.RGB16UI;default:return this._gl.RGBA16UI}case 6:switch(t){case 8:return this._gl.R32I;case 9:return this._gl.RG32I;case 10:return this._gl.RGB32I;default:return this._gl.RGBA32I}case 7:switch(t){case 8:return this._gl.R32UI;case 9:return this._gl.RG32UI;case 10:return this._gl.RGB32UI;default:return this._gl.RGBA32UI}case 1:switch(t){case 6:return this._gl.R32F;case 7:return this._gl.RG32F;case 4:return this._gl.RGB32F;default:return this._gl.RGBA32F}case 2:switch(t){case 6:return this._gl.R16F;case 7:return this._gl.RG16F;case 4:return this._gl.RGB16F;default:return this._gl.RGBA16F}case 10:return this._gl.RGB565;case 13:return this._gl.R11F_G11F_B10F;case 14:return this._gl.RGB9_E5;case 8:return this._gl.RGBA4;case 9:return this._gl.RGB5_A1;case 11:switch(t){case 5:default:return this._gl.RGB10_A2;case 11:return this._gl.RGB10_A2UI}}return s?this._glSRGBExtensionValues.SRGB8_ALPHA8:this._gl.RGBA8}readPixels(e,t,s,i,r=!0,n=!0){const a=r?4:3,o=r?this._gl.RGBA:this._gl.RGB,h=new Uint8Array(i*s*a);return n&&this.flushFramebuffer(),this._gl.readPixels(e,t,s,i,o,this._gl.UNSIGNED_BYTE,h),Promise.resolve(h)}static get IsSupportedAsync(){return Promise.resolve(this.isSupported())}static get IsSupported(){return this.isSupported()}static isSupported(){if(null!==this._HasMajorPerformanceCaveat)return!this._HasMajorPerformanceCaveat;if(null===this._IsSupported)try{const e=u.$._CreateCanvas(1,1),t=e.getContext("webgl")||e.getContext("experimental-webgl");this._IsSupported=null!=t&&!!window.WebGLRenderingContext}catch(e){this._IsSupported=!1}return this._IsSupported}static get HasMajorPerformanceCaveat(){if(null===this._HasMajorPerformanceCaveat)try{const e=u.$._CreateCanvas(1,1),t=e.getContext("webgl",{failIfMajorPerformanceCaveat:!0})||e.getContext("experimental-webgl",{failIfMajorPerformanceCaveat:!0});this._HasMajorPerformanceCaveat=!t}catch(e){this._HasMajorPerformanceCaveat=!1}return this._HasMajorPerformanceCaveat}}T._TempClearColorUint32=new Uint32Array(4),T._TempClearColorInt32=new Int32Array(4),T.ExceptionList=[{key:"Chrome/63.0",capture:"63\\.0\\.3239\\.(\\d+)",captureConstraint:108,targets:["uniformBuffer"]},{key:"Firefox/58",capture:null,captureConstraint:null,targets:["uniformBuffer"]},{key:"Firefox/59",capture:null,captureConstraint:null,targets:["uniformBuffer"]},{key:"Chrome/72.+?Mobile",capture:null,captureConstraint:null,targets:["vao"]},{key:"Chrome/73.+?Mobile",capture:null,captureConstraint:null,targets:["vao"]},{key:"Chrome/74.+?Mobile",capture:null,captureConstraint:null,targets:["vao"]},{key:"Mac OS.+Chrome/71",capture:null,captureConstraint:null,targets:["vao"]},{key:"Mac OS.+Chrome/72",capture:null,captureConstraint:null,targets:["vao"]},{key:"Mac OS.+Chrome",capture:null,captureConstraint:null,targets:["uniformBuffer"]},{key:"Chrome/12\\d\\..+?Mobile",capture:null,captureConstraint:null,targets:["uniformBuffer"]},{key:".*AppleWebKit.*(15.4).*Safari",capture:null,captureConstraint:null,targets:["antialias","maxMSAASamples"]},{key:".*(15.4).*AppleWebKit.*Safari",capture:null,captureConstraint:null,targets:["antialias","maxMSAASamples"]}],T._ConcatenateShader=p.iL,T._IsSupported=null,T._HasMajorPerformanceCaveat=null},8123:(e,t,s)=>{var i;s.d(t,{s:()=>r}),function(e){e[e.PointerMove=0]="PointerMove",e[e.PointerDown=1]="PointerDown",e[e.PointerUp=2]="PointerUp"}(i||(i={}));class r{}r.DOM_DELTA_PIXEL=0,r.DOM_DELTA_LINE=1,r.DOM_DELTA_PAGE=2},4146:(e,t,s)=>{s.d(t,{Bu:()=>n,TB:()=>i,W0:()=>r});class i{}i.KEYDOWN=1,i.KEYUP=2;class r{constructor(e,t){this.type=e,this.event=t}}class n extends r{get skipOnPointerObservable(){return this.skipOnKeyboardObservable}set skipOnPointerObservable(e){this.skipOnKeyboardObservable=e}constructor(e,t){super(e,t),this.type=e,this.event=t,this.skipOnKeyboardObservable=!1}}},6240:(e,t,s)=>{s.d(t,{Zp:()=>r,mx:()=>o,tT:()=>a});var i=s(9923);class r{}r.POINTERDOWN=1,r.POINTERUP=2,r.POINTERMOVE=4,r.POINTERWHEEL=8,r.POINTERPICK=16,r.POINTERTAP=32,r.POINTERDOUBLETAP=64;class n{constructor(e,t){this.type=e,this.event=t}}class a extends n{constructor(e,t,s,r){super(e,t),this.ray=null,this.originalPickingInfo=null,this.skipOnPointerObservable=!1,this.localPosition=new i.I9(s,r)}}class o extends n{get pickInfo(){return this._pickInfo||this._generatePickInfo(),this._pickInfo}constructor(e,t,s,i=null){super(e,t),this._pickInfo=s,this._inputManager=i}_generatePickInfo(){this._inputManager&&(this._pickInfo=this._inputManager._pickMove(this.event),this._inputManager._setRayOnPointerInfo(this._pickInfo,this.event),this._inputManager=null)}}},8595:(e,t,s)=>{s.d(t,{o:()=>T});var i=s(9923),r=s(6041),n=s(5616),a=s(4704),o=s(2781),h=s(6882),l=s(7891),c=s(6532),u=s(9848),d=s(5503),_=s(2565),f=s(3099),p=s(5476),g=s(492),m=s(467);class T{get bias(){return this._bias}set bias(e){this._bias=e}get normalBias(){return this._normalBias}set normalBias(e){this._normalBias=e}get blurBoxOffset(){return this._blurBoxOffset}set blurBoxOffset(e){this._blurBoxOffset!==e&&(this._blurBoxOffset=e,this._disposeBlurPostProcesses())}get blurScale(){return this._blurScale}set blurScale(e){this._blurScale!==e&&(this._blurScale=e,this._disposeBlurPostProcesses())}get blurKernel(){return this._blurKernel}set blurKernel(e){this._blurKernel!==e&&(this._blurKernel=e,this._disposeBlurPostProcesses())}get useKernelBlur(){return this._useKernelBlur}set useKernelBlur(e){this._useKernelBlur!==e&&(this._useKernelBlur=e,this._disposeBlurPostProcesses())}get depthScale(){return void 0!==this._depthScale?this._depthScale:this._light.getDepthScale()}set depthScale(e){this._depthScale=e}_validateFilter(e){return e}get filter(){return this._filter}set filter(e){if(e=this._validateFilter(e),this._light.needCube()){if(e===T.FILTER_BLUREXPONENTIALSHADOWMAP)return void(this.useExponentialShadowMap=!0);if(e===T.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP)return void(this.useCloseExponentialShadowMap=!0);if(e===T.FILTER_PCF||e===T.FILTER_PCSS)return void(this.usePoissonSampling=!0)}e!==T.FILTER_PCF&&e!==T.FILTER_PCSS||this._scene.getEngine()._features.supportShadowSamplers?this._filter!==e&&(this._filter=e,this._disposeBlurPostProcesses(),this._applyFilterValues(),this._light._markMeshesAsLightDirty()):this.usePoissonSampling=!0}get usePoissonSampling(){return this.filter===T.FILTER_POISSONSAMPLING}set usePoissonSampling(e){const t=this._validateFilter(T.FILTER_POISSONSAMPLING);(e||this.filter===T.FILTER_POISSONSAMPLING)&&(this.filter=e?t:T.FILTER_NONE)}get useExponentialShadowMap(){return this.filter===T.FILTER_EXPONENTIALSHADOWMAP}set useExponentialShadowMap(e){const t=this._validateFilter(T.FILTER_EXPONENTIALSHADOWMAP);(e||this.filter===T.FILTER_EXPONENTIALSHADOWMAP)&&(this.filter=e?t:T.FILTER_NONE)}get useBlurExponentialShadowMap(){return this.filter===T.FILTER_BLUREXPONENTIALSHADOWMAP}set useBlurExponentialShadowMap(e){const t=this._validateFilter(T.FILTER_BLUREXPONENTIALSHADOWMAP);(e||this.filter===T.FILTER_BLUREXPONENTIALSHADOWMAP)&&(this.filter=e?t:T.FILTER_NONE)}get useCloseExponentialShadowMap(){return this.filter===T.FILTER_CLOSEEXPONENTIALSHADOWMAP}set useCloseExponentialShadowMap(e){const t=this._validateFilter(T.FILTER_CLOSEEXPONENTIALSHADOWMAP);(e||this.filter===T.FILTER_CLOSEEXPONENTIALSHADOWMAP)&&(this.filter=e?t:T.FILTER_NONE)}get useBlurCloseExponentialShadowMap(){return this.filter===T.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP}set useBlurCloseExponentialShadowMap(e){const t=this._validateFilter(T.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP);(e||this.filter===T.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP)&&(this.filter=e?t:T.FILTER_NONE)}get usePercentageCloserFiltering(){return this.filter===T.FILTER_PCF}set usePercentageCloserFiltering(e){const t=this._validateFilter(T.FILTER_PCF);(e||this.filter===T.FILTER_PCF)&&(this.filter=e?t:T.FILTER_NONE)}get filteringQuality(){return this._filteringQuality}set filteringQuality(e){this._filteringQuality!==e&&(this._filteringQuality=e,this._disposeBlurPostProcesses(),this._applyFilterValues(),this._light._markMeshesAsLightDirty())}get useContactHardeningShadow(){return this.filter===T.FILTER_PCSS}set useContactHardeningShadow(e){const t=this._validateFilter(T.FILTER_PCSS);(e||this.filter===T.FILTER_PCSS)&&(this.filter=e?t:T.FILTER_NONE)}get contactHardeningLightSizeUVRatio(){return this._contactHardeningLightSizeUVRatio}set contactHardeningLightSizeUVRatio(e){this._contactHardeningLightSizeUVRatio=e}get darkness(){return this._darkness}set darkness(e){this.setDarkness(e)}getDarkness(){return this._darkness}setDarkness(e){return this._darkness=e>=1?1:e<=0?0:e,this}get transparencyShadow(){return this._transparencyShadow}set transparencyShadow(e){this.setTransparencyShadow(e)}setTransparencyShadow(e){return this._transparencyShadow=e,this}getShadowMap(){return this._shadowMap}getShadowMapForRendering(){return this._shadowMap2?this._shadowMap2:this._shadowMap}getClassName(){return T.CLASSNAME}addShadowCaster(e,t=!0){if(!this._shadowMap)return this;if(this._shadowMap.renderList||(this._shadowMap.renderList=[]),-1===this._shadowMap.renderList.indexOf(e)&&this._shadowMap.renderList.push(e),t)for(const t of e.getChildMeshes())-1===this._shadowMap.renderList.indexOf(t)&&this._shadowMap.renderList.push(t);return this}removeShadowCaster(e,t=!0){if(!this._shadowMap||!this._shadowMap.renderList)return this;const s=this._shadowMap.renderList.indexOf(e);if(-1!==s&&this._shadowMap.renderList.splice(s,1),t)for(const t of e.getChildren())this.removeShadowCaster(t);return this}getLight(){return this._light}get shaderLanguage(){return this._shaderLanguage}_getCamera(){return this._camera??this._scene.activeCamera}get mapSize(){return this._mapSize}set mapSize(e){this._mapSize=e,this._light._markMeshesAsLightDirty(),this.recreateShadowMap()}constructor(e,t,s,r,n,a=!1){this.onBeforeShadowMapRenderObservable=new u.cP,this.onAfterShadowMapRenderObservable=new u.cP,this.onBeforeShadowMapRenderMeshObservable=new u.cP,this.onAfterShadowMapRenderMeshObservable=new u.cP,this._bias=5e-5,this._normalBias=0,this._blurBoxOffset=1,this._blurScale=2,this._blurKernel=1,this._useKernelBlur=!1,this._filter=T.FILTER_NONE,this._filteringQuality=T.QUALITY_HIGH,this._contactHardeningLightSizeUVRatio=.1,this._darkness=0,this._transparencyShadow=!1,this.enableSoftTransparentShadow=!1,this.useOpacityTextureForTransparentShadow=!1,this.frustumEdgeFalloff=0,this._shaderLanguage=0,this.forceBackFacesOnly=!1,this._lightDirection=i.Pq.Zero(),this._viewMatrix=i.uq.Zero(),this._projectionMatrix=i.uq.Zero(),this._transformMatrix=i.uq.Zero(),this._cachedPosition=new i.Pq(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cachedDirection=new i.Pq(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._currentFaceIndex=0,this._currentFaceIndexCache=0,this._defaultTextureMatrix=i.uq.Identity(),this._shadersLoaded=!1,this._mapSize=e,this._light=t,this._scene=t.getScene(),this._camera=r??null,this._useRedTextureType=!!n,this._initShaderSourceAsync(a);let o=t._shadowGenerators;o||(o=t._shadowGenerators=new Map),o.set(this._camera,this),this.id=t.id,this._useUBO=this._scene.getEngine().supportsUniformBuffers,this._useUBO&&(this._sceneUBOs=[],this._sceneUBOs.push(this._scene.createSceneUniformBuffer(`Scene for Shadow Generator (light "${this._light.name}")`))),T._SceneComponentInitialization(this._scene);const h=this._scene.getEngine().getCaps();s?h.textureFloatRender&&h.textureFloatLinearFiltering?this._textureType=1:h.textureHalfFloatRender&&h.textureHalfFloatLinearFiltering?this._textureType=2:this._textureType=0:h.textureHalfFloatRender&&h.textureHalfFloatLinearFiltering?this._textureType=2:h.textureFloatRender&&h.textureFloatLinearFiltering?this._textureType=1:this._textureType=0,this._initializeGenerator(),this._applyFilterValues()}_initializeGenerator(){this._light._markMeshesAsLightDirty(),this._initializeShadowMap()}_createTargetRenderTexture(){const e=this._scene.getEngine();e._features.supportDepthStencilTexture?(this._shadowMap=new h.$(this._light.name+"_shadowMap",this._mapSize,this._scene,!1,!0,this._textureType,this._light.needCube(),void 0,!1,!1,void 0,this._useRedTextureType?6:5),this._shadowMap.createDepthStencilTexture(e.useReverseDepthBuffer?516:513,!0,void 0,void 0,void 0,`DepthStencilForShadowGenerator-${this._light.name}`)):this._shadowMap=new h.$(this._light.name+"_shadowMap",this._mapSize,this._scene,!1,!0,this._textureType,this._light.needCube()),this._shadowMap.noPrePassRenderer=!0}_initializeShadowMap(){if(this._createTargetRenderTexture(),null===this._shadowMap)return;this._shadowMap.wrapU=o.g.CLAMP_ADDRESSMODE,this._shadowMap.wrapV=o.g.CLAMP_ADDRESSMODE,this._shadowMap.anisotropicFilteringLevel=1,this._shadowMap.updateSamplingMode(o.g.BILINEAR_SAMPLINGMODE),this._shadowMap.renderParticles=!1,this._shadowMap.ignoreCameraViewport=!0,this._storedUniqueId&&(this._shadowMap.uniqueId=this._storedUniqueId),this._shadowMap.customRenderFunction=(e,t,s,i)=>this._renderForShadowMap(e,t,s,i),this._shadowMap.customIsReadyFunction=()=>!0;const e=this._scene.getEngine();this._shadowMap.onBeforeBindObservable.add((()=>{this._currentSceneUBO=this._scene.getSceneUniformBuffer(),e._debugPushGroup?.(`shadow map generation for pass id ${e.currentRenderPassId}`,1)})),this._shadowMap.onBeforeRenderObservable.add((t=>{this._sceneUBOs&&this._scene.setSceneUniformBuffer(this._sceneUBOs[0]),this._currentFaceIndex=t,this._filter===T.FILTER_PCF&&e.setColorWrite(!1),this.getTransformMatrix(),this._scene.setTransformMatrix(this._viewMatrix,this._projectionMatrix),this._useUBO&&(this._scene.getSceneUniformBuffer().unbindEffect(),this._scene.finalizeSceneUbo())})),this._shadowMap.onAfterUnbindObservable.add((()=>{if(this._sceneUBOs&&this._scene.setSceneUniformBuffer(this._currentSceneUBO),this._scene.updateTransformMatrix(),this._filter===T.FILTER_PCF&&e.setColorWrite(!0),!this.useBlurExponentialShadowMap&&!this.useBlurCloseExponentialShadowMap)return void e._debugPopGroup?.(1);const t=this.getShadowMapForRendering();t&&(this._scene.postProcessManager.directRender(this._blurPostProcesses,t.renderTarget,!0),e.unBindFramebuffer(t.renderTarget,!0)),e._debugPopGroup?.(1)}));const t=new r.ov(0,0,0,0),s=new r.ov(1,1,1,1);this._shadowMap.onClearObservable.add((e=>{this._filter===T.FILTER_PCF?e.clear(s,!1,!0,!1):this.useExponentialShadowMap||this.useBlurExponentialShadowMap?e.clear(t,!0,!0,!1):e.clear(s,!0,!0,!1)})),this._shadowMap.onResizeObservable.add((e=>{this._storedUniqueId=this._shadowMap.uniqueId,this._mapSize=e.getRenderSize(),this._light._markMeshesAsLightDirty(),this.recreateShadowMap()}));for(let e=f.m.MIN_RENDERINGGROUPS;e{e.setTexture("textureSampler",this._shadowMap)})),this._kernelBlurYPostprocess=new c.j(this._light.name+"KernelBlurY",new i.I9(0,1),this.blurKernel,1,null,o.g.BILINEAR_SAMPLINGMODE,e,!1,this._textureType),this._kernelBlurXPostprocess.autoClear=!1,this._kernelBlurYPostprocess.autoClear=!1,0===this._textureType&&(this._kernelBlurXPostprocess.packedFloat=!0,this._kernelBlurYPostprocess.packedFloat=!0),this._blurPostProcesses=[this._kernelBlurXPostprocess,this._kernelBlurYPostprocess]):(this._boxBlurPostprocess=new l.w(this._light.name+"DepthBoxBlur","depthBoxBlur",["screenSize","boxOffset"],[],1,null,o.g.BILINEAR_SAMPLINGMODE,e,!1,"#define OFFSET "+this._blurBoxOffset,this._textureType,void 0,void 0,void 0,void 0,this._shaderLanguage),this._boxBlurPostprocess.externalTextureSamplerBinding=!0,this._boxBlurPostprocess.onApplyObservable.add((e=>{e.setFloat2("screenSize",t,t),e.setTexture("textureSampler",this._shadowMap)})),this._boxBlurPostprocess.autoClear=!1,this._blurPostProcesses=[this._boxBlurPostprocess])}_renderForShadowMap(e,t,s,i){let r;if(i.length)for(r=0;r{i===s||e?(i.getMeshUniformBuffer().bindToEffect(c,"Mesh"),i.transferToEffect(e?t:f)):(s.getMeshUniformBuffer().bindToEffect(c,"Mesh"),s.transferToEffect(t))})),this.forceBackFacesOnly&&n.setState(!0,0,!1,!1,o.cullBackFaces),this.onAfterShadowMapRenderObservable.notifyObservers(c),this.onAfterShadowMapRenderMeshObservable.notifyObservers(s)}else this._shadowMap&&this._shadowMap.resetRefreshCounter()}_applyFilterValues(){this._shadowMap&&(this.filter===T.FILTER_NONE||this.filter===T.FILTER_PCSS?this._shadowMap.updateSamplingMode(o.g.NEAREST_SAMPLINGMODE):this._shadowMap.updateSamplingMode(o.g.BILINEAR_SAMPLINGMODE))}forceCompilation(e,t){const s={useInstances:!1,...t},i=this.getShadowMap();if(!i)return void(e&&e(this));const r=i.renderList;if(!r)return void(e&&e(this));const n=[];for(const e of r)n.push(...e.subMeshes);if(0===n.length)return void(e&&e(this));let a=0;const o=()=>{if(this._scene&&this._scene.getEngine()){for(;this.isReady(n[a],s.useInstances,n[a].getMaterial()?.needAlphaBlendingForMesh(n[a].getMesh())??!1);)if(a++,a>=n.length)return void(e&&e(this));setTimeout(o,16)}};o()}forceCompilationAsync(e){return new Promise((t=>{this.forceCompilation((()=>{t()}),e)}))}_isReadyCustomDefines(e,t,s){}_prepareShadowDefines(e,t,s,i){s.push("#define SM_LIGHTTYPE_"+this._light.getClassName().toUpperCase()),s.push("#define SM_FLOAT "+(0!==this._textureType?"1":"0")),s.push("#define SM_ESM "+(this.useExponentialShadowMap||this.useBlurExponentialShadowMap?"1":"0")),s.push("#define SM_DEPTHTEXTURE "+(this.usePercentageCloserFiltering||this.useContactHardeningShadow?"1":"0"));const r=e.getMesh();return s.push("#define SM_NORMALBIAS "+(this.normalBias&&r.isVerticesDataPresent(n.R.NormalKind)?"1":"0")),s.push("#define SM_DIRECTIONINLIGHTDATA "+(this.getLight().getTypeID()===a.v.LIGHTTYPEID_DIRECTIONALLIGHT?"1":"0")),s.push("#define SM_USEDISTANCE "+(this._light.needCube()?"1":"0")),s.push("#define SM_SOFTTRANSPARENTSHADOW "+(this.enableSoftTransparentShadow&&i?"1":"0")),this._isReadyCustomDefines(s,e,t),s}isReady(e,t,s){if(!this._shadersLoaded)return!1;const i=e.getMaterial(),r=i?.shadowDepthWrapper;if(this._opacityTexture=null,!i)return!1;const a=[];if(this._prepareShadowDefines(e,t,a,s),r){if(!r.isReadyForSubMesh(e,a,this,t,this._scene.getEngine().currentRenderPassId))return!1}else{const s=e._getDrawWrapper(void 0,!0);let r=s.effect,o=s.defines;const h=[n.R.PositionKind],l=e.getMesh();this.normalBias&&l.isVerticesDataPresent(n.R.NormalKind)&&(h.push(n.R.NormalKind),a.push("#define NORMAL"),l.nonUniformScaling&&a.push("#define NONUNIFORMSCALING"));const c=i.needAlphaTesting();if((c||i.needAlphaBlending())&&(this.useOpacityTextureForTransparentShadow?this._opacityTexture=i.opacityTexture:this._opacityTexture=i.getAlphaTestTexture(),this._opacityTexture)){if(!this._opacityTexture.isReady())return!1;const e=i.alphaCutOff??T.DEFAULT_ALPHA_CUTOFF;a.push("#define ALPHATEXTURE"),c&&a.push(`#define ALPHATESTVALUE ${e}${e%1==0?".":""}`),l.isVerticesDataPresent(n.R.UVKind)&&(h.push(n.R.UVKind),a.push("#define UV1")),l.isVerticesDataPresent(n.R.UV2Kind)&&1===this._opacityTexture.coordinatesIndex&&(h.push(n.R.UV2Kind),a.push("#define UV2"))}const u=new _.J;if(l.useBones&&l.computeBonesUsingShaders&&l.skeleton){h.push(n.R.MatricesIndicesKind),h.push(n.R.MatricesWeightsKind),l.numBoneInfluencers>4&&(h.push(n.R.MatricesIndicesExtraKind),h.push(n.R.MatricesWeightsExtraKind));const e=l.skeleton;a.push("#define NUM_BONE_INFLUENCERS "+l.numBoneInfluencers),l.numBoneInfluencers>0&&u.addCPUSkinningFallback(0,l),e.isUsingTextureForMatrices?a.push("#define BONETEXTURE"):a.push("#define BonesPerMesh "+(e.bones.length+1))}else a.push("#define NUM_BONE_INFLUENCERS 0");const d=l.morphTargetManager;let f=0;if(d&&(f=d.numMaxInfluencers||d.numInfluencers,f>0&&(a.push("#define MORPHTARGETS"),a.push("#define NUM_MORPH_INFLUENCERS "+f),d.isUsingTextureForTargets&&a.push("#define MORPHTARGETS_TEXTURE"),(0,m.MF)(h,l,f))),(0,g.tv)(i,this._scene,a),t&&(a.push("#define INSTANCES"),(0,m.te)(h),e.getRenderingMesh().hasThinInstances&&a.push("#define THIN_INSTANCES")),this.customShaderOptions&&this.customShaderOptions.defines)for(const e of this.customShaderOptions.defines)-1===a.indexOf(e)&&a.push(e);const p=l.bakedVertexAnimationManager;p&&p.isEnabled&&(a.push("#define BAKED_VERTEX_ANIMATION_TEXTURE"),t&&h.push("bakedVertexAnimationSettingsInstanced"));const b=a.join("\n");if(o!==b){o=b;let e="shadowMap";const t=["world","mBones","viewProjection","diffuseMatrix","lightDataSM","depthValuesSM","biasAndScaleSM","morphTargetInfluences","morphTargetCount","boneTextureWidth","softTransparentShadowSM","morphTargetTextureInfo","morphTargetTextureIndices","bakedVertexAnimationSettings","bakedVertexAnimationTextureSizeInverted","bakedVertexAnimationTime","bakedVertexAnimationTexture"],i=["diffuseSampler","boneSampler","morphTargets","bakedVertexAnimationTexture"],n=["Scene","Mesh"];if((0,g.TV)(t),this.customShaderOptions){if(e=this.customShaderOptions.shaderName,this.customShaderOptions.attributes)for(const e of this.customShaderOptions.attributes)-1===h.indexOf(e)&&h.push(e);if(this.customShaderOptions.uniforms)for(const e of this.customShaderOptions.uniforms)-1===t.indexOf(e)&&t.push(e);if(this.customShaderOptions.samplers)for(const e of this.customShaderOptions.samplers)-1===i.indexOf(e)&&i.push(e)}const a=this._scene.getEngine();r=a.createEffect(e,{attributes:h,uniformsNames:t,uniformBuffersNames:n,samplers:i,defines:b,fallbacks:u,onCompiled:null,onError:null,indexParameters:{maxSimultaneousMorphTargets:f},shaderLanguage:this._shaderLanguage},a),s.setEffect(r,o)}if(!r.isReady())return!1}return(this.useBlurExponentialShadowMap||this.useBlurCloseExponentialShadowMap)&&(this._blurPostProcesses&&this._blurPostProcesses.length||this._initializeBlurRTTAndPostProcesses()),!(this._kernelBlurXPostprocess&&!this._kernelBlurXPostprocess.isReady()||this._kernelBlurYPostprocess&&!this._kernelBlurYPostprocess.isReady()||this._boxBlurPostprocess&&!this._boxBlurPostprocess.isReady())}prepareDefines(e,t){const s=this._scene,i=this._light;s.shadowsEnabled&&i.shadowEnabled&&(e["SHADOW"+t]=!0,this.useContactHardeningShadow?(e["SHADOWPCSS"+t]=!0,this._filteringQuality===T.QUALITY_LOW?e["SHADOWLOWQUALITY"+t]=!0:this._filteringQuality===T.QUALITY_MEDIUM&&(e["SHADOWMEDIUMQUALITY"+t]=!0)):this.usePercentageCloserFiltering?(e["SHADOWPCF"+t]=!0,this._filteringQuality===T.QUALITY_LOW?e["SHADOWLOWQUALITY"+t]=!0:this._filteringQuality===T.QUALITY_MEDIUM&&(e["SHADOWMEDIUMQUALITY"+t]=!0)):this.usePoissonSampling?e["SHADOWPOISSON"+t]=!0:this.useExponentialShadowMap||this.useBlurExponentialShadowMap?e["SHADOWESM"+t]=!0:(this.useCloseExponentialShadowMap||this.useBlurCloseExponentialShadowMap)&&(e["SHADOWCLOSEESM"+t]=!0),i.needCube()&&(e["SHADOWCUBE"+t]=!0))}bindShadowLight(e,t){const s=this._light;if(!this._scene.shadowsEnabled||!s.shadowEnabled)return;const i=this._getCamera();if(!i)return;const r=this.getShadowMap();if(!r)return;s.needCube()||t.setMatrix("lightMatrix"+e,this.getTransformMatrix());const n=this.getShadowMapForRendering();this._filter===T.FILTER_PCF?(t.setDepthStencilTexture("shadowTexture"+e,n),s._uniformBuffer.updateFloat4("shadowsInfo",this.getDarkness(),r.getSize().width,1/r.getSize().width,this.frustumEdgeFalloff,e)):this._filter===T.FILTER_PCSS?(t.setDepthStencilTexture("shadowTexture"+e,n),t.setTexture("depthTexture"+e,n),s._uniformBuffer.updateFloat4("shadowsInfo",this.getDarkness(),1/r.getSize().width,this._contactHardeningLightSizeUVRatio*r.getSize().width,this.frustumEdgeFalloff,e)):(t.setTexture("shadowTexture"+e,n),s._uniformBuffer.updateFloat4("shadowsInfo",this.getDarkness(),this.blurScale/r.getSize().width,this.depthScale,this.frustumEdgeFalloff,e)),s._uniformBuffer.updateFloat2("depthValues",this.getLight().getDepthMinZ(i),this.getLight().getDepthMinZ(i)+this.getLight().getDepthMaxZ(i),e)}get viewMatrix(){return this._viewMatrix}get projectionMatrix(){return this._projectionMatrix}getTransformMatrix(){const e=this._scene;if(this._currentRenderId===e.getRenderId()&&this._currentFaceIndexCache===this._currentFaceIndex)return this._transformMatrix;this._currentRenderId=e.getRenderId(),this._currentFaceIndexCache=this._currentFaceIndex;let t=this._light.position;if(this._light.computeTransformedInformation()&&(t=this._light.transformedPosition),i.Pq.NormalizeToRef(this._light.getShadowDirection(this._currentFaceIndex),this._lightDirection),1===Math.abs(i.Pq.Dot(this._lightDirection,i.Pq.Up()))&&(this._lightDirection.z=1e-13),this._light.needProjectionMatrixCompute()||!this._cachedPosition||!this._cachedDirection||!t.equals(this._cachedPosition)||!this._lightDirection.equals(this._cachedDirection)){this._cachedPosition.copyFrom(t),this._cachedDirection.copyFrom(this._lightDirection),i.uq.LookAtLHToRef(t,t.add(this._lightDirection),i.Pq.Up(),this._viewMatrix);const e=this.getShadowMap();if(e){const t=e.renderList;t&&this._light.setShadowProjectionMatrix(this._projectionMatrix,this._viewMatrix,t)}this._viewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix)}return this._transformMatrix}recreateShadowMap(){const e=this._shadowMap;if(!e)return;const t=e.renderList;if(this._disposeRTTandPostProcesses(),this._initializeGenerator(),this.filter=this._filter,this._applyFilterValues(),t){this._shadowMap.renderList||(this._shadowMap.renderList=[]);for(const e of t)this._shadowMap.renderList.push(e)}else this._shadowMap.renderList=null}_disposeBlurPostProcesses(){this._shadowMap2&&(this._shadowMap2.dispose(),this._shadowMap2=null),this._boxBlurPostprocess&&(this._boxBlurPostprocess.dispose(),this._boxBlurPostprocess=null),this._kernelBlurXPostprocess&&(this._kernelBlurXPostprocess.dispose(),this._kernelBlurXPostprocess=null),this._kernelBlurYPostprocess&&(this._kernelBlurYPostprocess.dispose(),this._kernelBlurYPostprocess=null),this._blurPostProcesses=[]}_disposeRTTandPostProcesses(){this._shadowMap&&(this._shadowMap.dispose(),this._shadowMap=null),this._disposeBlurPostProcesses()}_disposeSceneUBOs(){if(this._sceneUBOs){for(const e of this._sceneUBOs)e.dispose();this._sceneUBOs=[]}}dispose(){if(this._disposeRTTandPostProcesses(),this._disposeSceneUBOs(),this._light){if(this._light._shadowGenerators){const e=this._light._shadowGenerators.entries();for(let t=e.next();!0!==t.done;t=e.next()){const[e,s]=t.value;s===this&&this._light._shadowGenerators.delete(e)}0===this._light._shadowGenerators.size&&(this._light._shadowGenerators=null)}this._light._markMeshesAsLightDirty()}this.onBeforeShadowMapRenderMeshObservable.clear(),this.onBeforeShadowMapRenderObservable.clear(),this.onAfterShadowMapRenderMeshObservable.clear(),this.onAfterShadowMapRenderObservable.clear()}serialize(){const e={},t=this.getShadowMap();if(!t)return e;if(e.className=this.getClassName(),e.lightId=this._light.id,e.cameraId=this._camera?.id,e.id=this.id,e.mapSize=t.getRenderSize(),e.forceBackFacesOnly=this.forceBackFacesOnly,e.darkness=this.getDarkness(),e.transparencyShadow=this._transparencyShadow,e.frustumEdgeFalloff=this.frustumEdgeFalloff,e.bias=this.bias,e.normalBias=this.normalBias,e.usePercentageCloserFiltering=this.usePercentageCloserFiltering,e.useContactHardeningShadow=this.useContactHardeningShadow,e.contactHardeningLightSizeUVRatio=this.contactHardeningLightSizeUVRatio,e.filteringQuality=this.filteringQuality,e.useExponentialShadowMap=this.useExponentialShadowMap,e.useBlurExponentialShadowMap=this.useBlurExponentialShadowMap,e.useCloseExponentialShadowMap=this.useBlurExponentialShadowMap,e.useBlurCloseExponentialShadowMap=this.useBlurExponentialShadowMap,e.usePoissonSampling=this.usePoissonSampling,e.depthScale=this.depthScale,e.blurBoxOffset=this.blurBoxOffset,e.blurKernel=this.blurKernel,e.blurScale=this.blurScale,e.useKernelBlur=this.useKernelBlur,e.renderList=[],t.renderList)for(let s=0;s{throw(0,d.n)("ShadowGeneratorSceneComponent")}},9400:(e,t,s)=>{var i=s(8595),r=s(9923),n=s(6882),a=s(5503),o=s(2564),h=s(6041),l=s(5616),c=s(2781),u=s(388),d=(s(8852),s(9977),s(492)),_=s(467),f=s(2565);class p{get shaderLanguage(){return this._shaderLanguage}setMaterialForRendering(e,t){this._depthMap.setMaterialForRendering(e,t)}constructor(e,t=1,s=null,i=!1,r=c.g.TRILINEAR_SAMPLINGMODE,a=!1,o){this._shaderLanguage=0,this.enabled=!0,this.forceDepthWriteTransparentMeshes=!1,this.useOnlyInActiveCamera=!1,this.reverseCulling=!1,this._shadersLoaded=!1,this._scene=e,this._storeNonLinearDepth=i,this._storeCameraSpaceZ=a,this.isPacked=0===t,this.isPacked?this.clearColor=new h.ov(1,1,1,1):this.clearColor=new h.ov(a?1e8:1,0,0,1),this._initShaderSourceAsync(),p._SceneComponentInitialization(this._scene);const l=e.getEngine();this._camera=s,r!==c.g.NEAREST_SAMPLINGMODE&&(1!==t||l._caps.textureFloatLinearFiltering||(r=c.g.NEAREST_SAMPLINGMODE),2!==t||l._caps.textureHalfFloatLinearFiltering||(r=c.g.NEAREST_SAMPLINGMODE));const f=this.isPacked||!l._features.supportExtendedTextureFormats?5:6;this._depthMap=new n.$(o??"DepthRenderer",{width:l.getRenderWidth(),height:l.getRenderHeight()},this._scene,!1,!0,t,!1,r,void 0,void 0,void 0,f),this._depthMap.wrapU=c.g.CLAMP_ADDRESSMODE,this._depthMap.wrapV=c.g.CLAMP_ADDRESSMODE,this._depthMap.refreshRate=1,this._depthMap.renderParticles=!1,this._depthMap.renderList=null,this._depthMap.noPrePassRenderer=!0,this._depthMap.activeCamera=this._camera,this._depthMap.ignoreCameraViewport=!0,this._depthMap.useCameraPostProcesses=!1,this._depthMap.onClearObservable.add((e=>{e.clear(this.clearColor,!0,!0,!0)})),this._depthMap.onBeforeBindObservable.add((()=>{l._debugPushGroup?.("depth renderer",1)})),this._depthMap.onAfterUnbindObservable.add((()=>{l._debugPopGroup?.(1)})),this._depthMap.customIsReadyFunction=(e,t,s)=>{if((s||0===t)&&e.subMeshes)for(let t=0;t{const t=e.getRenderingMesh(),s=e.getEffectiveMesh(),i=this._scene,r=i.getEngine(),n=e.getMaterial();if(s._internalAbstractMeshDataInfo._isActiveIntermediate=!1,!n||s.infiniteDistance||n.disableDepthWrite||0===e.verticesCount||e._renderId===i.getRenderId())return;const a=s._getWorldMatrixDeterminant()<0;let o=n._getEffectiveOrientation(t);a&&(o=0===o?1:0);const h=0===o;r.setState(n.backFaceCulling,0,!1,h,this.reverseCulling?!n.cullBackFaces:n.cullBackFaces);const l=t._getInstancesRenderList(e._id,!!e.getReplacementMesh());if(l.mustReturn)return;const c=r.getCaps().instancedArrays&&(null!==l.visibleInstances[e._id]&&void 0!==l.visibleInstances[e._id]||t.hasThinInstances),f=this._camera||i.activeCamera;if(this.isReady(e,c)&&f){e._renderId=i.getRenderId();const a=s._internalAbstractMeshDataInfo._materialForRenderPass?.[r.currentRenderPassId];let o=e._getDrawWrapper();!o&&a&&(o=a._getDrawWrapper());const h=f.mode===u.i.ORTHOGRAPHIC_CAMERA;if(!o)return;const p=o.effect;let g,m;if(r.enableEffect(o),c||t._bind(e,p,n.fillMode),a?a.bindForSubMesh(s.getWorldMatrix(),s,e):(p.setMatrix("viewProjection",i.getTransformMatrix()),p.setMatrix("world",s.getWorldMatrix()),this._storeCameraSpaceZ&&p.setMatrix("view",i.getViewMatrix())),h?(g=!r.useReverseDepthBuffer&&r.isNDCHalfZRange?0:1,m=r.useReverseDepthBuffer&&r.isNDCHalfZRange?0:1):(g=r.useReverseDepthBuffer&&r.isNDCHalfZRange?f.minZ:r.isNDCHalfZRange?0:f.minZ,m=r.useReverseDepthBuffer&&r.isNDCHalfZRange?0:f.maxZ),p.setFloat2("depthValues",g,g+m),!a){if(n.needAlphaTesting()){const e=n.getAlphaTestTexture();e&&(p.setTexture("diffuseSampler",e),p.setMatrix("diffuseMatrix",e.getTextureMatrix()))}(0,_.f$)(t,p),(0,d.gS)(p,n,i),(0,_.nR)(t,p),t.morphTargetManager&&t.morphTargetManager.isUsingTextureForTargets&&t.morphTargetManager._bind(p);const s=e.getMesh().bakedVertexAnimationManager;s&&s.isEnabled&&s.bind(p,c),n.pointsCloud&&p.setFloat("pointSize",n.pointSize)}t._processRendering(s,e,p,n.fillMode,l,c,((e,t)=>p.setMatrix("world",t)))}};this._depthMap.customRenderFunction=(e,t,s,i)=>{let r;if(i.length)for(r=0;r4&&(h.push(l.R.MatricesIndicesExtraKind),h.push(l.R.MatricesWeightsExtraKind)),o.push("#define NUM_BONE_INFLUENCERS "+i.numBoneInfluencers),i.numBoneInfluencers>0&&c.addCPUSkinningFallback(0,i);const e=i.skeleton;e.isUsingTextureForMatrices?o.push("#define BONETEXTURE"):o.push("#define BonesPerMesh "+(e.bones.length+1))}else o.push("#define NUM_BONE_INFLUENCERS 0");const u=i.morphTargetManager;let p=0;u&&(p=u.numMaxInfluencers||u.numInfluencers,p>0&&(o.push("#define MORPHTARGETS"),o.push("#define NUM_MORPH_INFLUENCERS "+p),u.isUsingTextureForTargets&&o.push("#define MORPHTARGETS_TEXTURE"),(0,_.MF)(h,i,p))),a.pointsCloud&&o.push("#define POINTSIZE"),t&&(o.push("#define INSTANCES"),(0,_.te)(h),e.getRenderingMesh().hasThinInstances&&o.push("#define THIN_INSTANCES"));const g=i.bakedVertexAnimationManager;g&&g.isEnabled&&(o.push("#define BAKED_VERTEX_ANIMATION_TEXTURE"),t&&h.push("bakedVertexAnimationSettingsInstanced")),this._storeNonLinearDepth&&o.push("#define NONLINEARDEPTH"),this._storeCameraSpaceZ&&o.push("#define STORE_CAMERASPACE_Z"),this.isPacked&&o.push("#define PACKED"),(0,d.tv)(a,r,o);const m=e._getDrawWrapper(void 0,!0),T=m.defines,b=o.join("\n");if(T!==b){const e=["world","mBones","boneTextureWidth","pointSize","viewProjection","view","diffuseMatrix","depthValues","morphTargetInfluences","morphTargetCount","morphTargetTextureInfo","morphTargetTextureIndices","bakedVertexAnimationSettings","bakedVertexAnimationTextureSizeInverted","bakedVertexAnimationTime","bakedVertexAnimationTexture"],t=["diffuseSampler","morphTargets","boneSampler","bakedVertexAnimationTexture"];(0,d.TV)(e),m.setEffect(s.createEffect("depth",{attributes:h,uniformsNames:e,uniformBuffersNames:[],samplers:t,defines:b,fallbacks:c,onCompiled:null,onError:null,indexParameters:{maxSimultaneousMorphTargets:p},shaderLanguage:this._shaderLanguage},s))}return m.effect.isReady()}getDepthMap(){return this._depthMap}dispose(){const e=[];for(const t in this._scene._depthRenderer)this._scene._depthRenderer[t]===this&&e.push(t);if(e.length>0){this._depthMap.dispose();for(const t of e)delete this._scene._depthRenderer[t]}}}p.ForceGLSL=!1,p._SceneComponentInitialization=e=>{throw(0,a.n)("DepthRendererSceneComponent")};var g=s(9848),m=s(7891),T=s(6096);s(9610).l.ShadersStore.minmaxReduxPixelShader="varying vec2 vUV;uniform sampler2D textureSampler;\n#if defined(INITIAL)\nuniform sampler2D sourceTexture;uniform vec2 texSize;void main(void)\n{ivec2 coord=ivec2(vUV*(texSize-1.0));float f1=texelFetch(sourceTexture,coord,0).r;float f2=texelFetch(sourceTexture,coord+ivec2(1,0),0).r;float f3=texelFetch(sourceTexture,coord+ivec2(1,1),0).r;float f4=texelFetch(sourceTexture,coord+ivec2(0,1),0).r;float minz=min(min(min(f1,f2),f3),f4);\n#ifdef DEPTH_REDUX\nfloat maxz=max(max(max(sign(1.0-f1)*f1,sign(1.0-f2)*f2),sign(1.0-f3)*f3),sign(1.0-f4)*f4);\n#else\nfloat maxz=max(max(max(f1,f2),f3),f4);\n#endif\nglFragColor=vec4(minz,maxz,0.,0.);}\n#elif defined(MAIN)\nuniform vec2 texSize;void main(void)\n{ivec2 coord=ivec2(vUV*(texSize-1.0));vec2 f1=texelFetch(textureSampler,coord,0).rg;vec2 f2=texelFetch(textureSampler,coord+ivec2(1,0),0).rg;vec2 f3=texelFetch(textureSampler,coord+ivec2(1,1),0).rg;vec2 f4=texelFetch(textureSampler,coord+ivec2(0,1),0).rg;float minz=min(min(min(f1.x,f2.x),f3.x),f4.x);float maxz=max(max(max(f1.y,f2.y),f3.y),f4.y);glFragColor=vec4(minz,maxz,0.,0.);}\n#elif defined(ONEBEFORELAST)\nuniform ivec2 texSize;void main(void)\n{ivec2 coord=ivec2(vUV*vec2(texSize-1));vec2 f1=texelFetch(textureSampler,coord % texSize,0).rg;vec2 f2=texelFetch(textureSampler,(coord+ivec2(1,0)) % texSize,0).rg;vec2 f3=texelFetch(textureSampler,(coord+ivec2(1,1)) % texSize,0).rg;vec2 f4=texelFetch(textureSampler,(coord+ivec2(0,1)) % texSize,0).rg;float minz=min(f1.x,f2.x);float maxz=max(f1.y,f2.y);glFragColor=vec4(minz,maxz,0.,0.);}\n#elif defined(LAST)\nvoid main(void)\n{glFragColor=vec4(0.);if (true) { \ndiscard;}}\n#endif\n";class b{constructor(e){this.onAfterReductionPerformed=new g.cP,this._forceFullscreenViewport=!0,this._activated=!1,this._camera=e,this._postProcessManager=new T.X(e.getScene()),this._onContextRestoredObserver=e.getEngine().onContextRestoredObservable.add((()=>{this._postProcessManager._rebuild()}))}get sourceTexture(){return this._sourceTexture}setSourceTexture(e,t,s=2,i=!0){if(e===this._sourceTexture)return;this.dispose(!1),this._sourceTexture=e,this._reductionSteps=[],this._forceFullscreenViewport=i;const r=this._camera.getScene(),n=new m.w("Initial reduction phase","minmaxRedux",["texSize"],["sourceTexture"],1,null,1,r.getEngine(),!1,"#define INITIAL"+(t?"\n#define DEPTH_REDUX":""),s,void 0,void 0,void 0,7);n.autoClear=!1,n.forceFullscreenViewport=i;let a=this._sourceTexture.getRenderWidth(),o=this._sourceTexture.getRenderHeight();n.onApply=((e,t)=>s=>{s.setTexture("sourceTexture",this._sourceTexture),s.setFloat2("texSize",e,t)})(a,o),this._reductionSteps.push(n);let h=1;for(;a>1||o>1;){a=Math.max(Math.round(a/2),1),o=Math.max(Math.round(o/2),1);const e=new m.w("Reduction phase "+h,"minmaxRedux",["texSize"],null,{width:a,height:o},null,1,r.getEngine(),!1,"#define "+(1==a&&1==o?"LAST":1==a||1==o?"ONEBEFORELAST":"MAIN"),s,void 0,void 0,void 0,7);if(e.autoClear=!1,e.forceFullscreenViewport=i,e.onApply=((e,t)=>s=>{1==e||1==t?s.setInt2("texSize",e,t):s.setFloat2("texSize",e,t)})(a,o),this._reductionSteps.push(e),h++,1==a&&1==o){const t=(e,t,s)=>{const i=new Float32Array(4*e*t),n={min:0,max:0};return()=>{r.getEngine()._readTexturePixels(s.inputTexture.texture,e,t,-1,0,i,!1),n.min=i[0],n.max=i[1],this.onAfterReductionPerformed.notifyObservers(n)}};e.onAfterRenderObservable.add(t(a,o,e))}}}get refreshRate(){return this._sourceTexture?this._sourceTexture.refreshRate:-1}set refreshRate(e){this._sourceTexture&&(this._sourceTexture.refreshRate=e)}get activated(){return this._activated}activate(){!this._onAfterUnbindObserver&&this._sourceTexture&&(this._onAfterUnbindObserver=this._sourceTexture.onAfterUnbindObservable.add((()=>{const e=this._camera.getScene().getEngine();e._debugPushGroup?.("min max reduction",1),this._reductionSteps[0].activate(this._camera),this._postProcessManager.directRender(this._reductionSteps,this._reductionSteps[0].inputTexture,this._forceFullscreenViewport),e.unBindFramebuffer(this._reductionSteps[0].inputTexture,!1),e._debugPopGroup?.(1)})),this._activated=!0)}deactivate(){this._onAfterUnbindObserver&&this._sourceTexture&&(this._sourceTexture.onAfterUnbindObservable.remove(this._onAfterUnbindObserver),this._onAfterUnbindObserver=null,this._activated=!1)}dispose(e=!0){if(e&&(this.onAfterReductionPerformed.clear(),this._onContextRestoredObserver&&(this._camera.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver),this._onContextRestoredObserver=null)),this.deactivate(),this._reductionSteps){for(let e=0;ethis._computeShadowCastersBoundingInfo()))),this._freezeShadowCastersBoundingInfo=e,e&&this._computeShadowCastersBoundingInfo()}_computeShadowCastersBoundingInfo(){if(this._scbiMin.copyFromFloats(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._scbiMax.copyFromFloats(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),this._shadowMap&&this._shadowMap.renderList){const e=this._shadowMap.renderList;for(let t=0;tt&&(e=0,t=1),e<0&&(e=0),t>1&&(t=1),this._minDistance=e,this._maxDistance=t,this._breaksAreDirty=!0)}get minDistance(){return this._minDistance}get maxDistance(){return this._maxDistance}getClassName(){return C.CLASSNAME}getCascadeMinExtents(e){return e>=0&&e=0&&et.maxZ&&0!==t.maxZ||(this._shadowMaxZ=e,this._light._markMeshesAsLightDirty(),this._breaksAreDirty=!0):this._shadowMaxZ=e}get debug(){return this._debug}set debug(e){this._debug=e,this._light._markMeshesAsLightDirty()}get depthClamp(){return this._depthClamp}set depthClamp(e){this._depthClamp=e}get cascadeBlendPercentage(){return this._cascadeBlendPercentage}set cascadeBlendPercentage(e){this._cascadeBlendPercentage=e,this._light._markMeshesAsLightDirty()}get lambda(){return this._lambda}set lambda(e){const t=Math.min(Math.max(e,0),1);this._lambda!=t&&(this._lambda=t,this._breaksAreDirty=!0)}getCascadeViewMatrix(e){return e>=0&&e=0&&e=0&&e{let t=e.min,s=e.max;t>=s&&(t=0,s=1),t==this._minDistance&&s==this._maxDistance||this.setMinMaxDistance(t,s)})),this._depthReducer.setDepthRenderer(this._depthRenderer)),this._depthReducer.activate()}}get autoCalcDepthBoundsRefreshRate(){return this._depthReducer?.depthRenderer?.getDepthMap().refreshRate??-1}set autoCalcDepthBoundsRefreshRate(e){this._depthReducer?.depthRenderer&&(this._depthReducer.depthRenderer.getDepthMap().refreshRate=e)}splitFrustum(){this._breaksAreDirty=!0}_splitFrustum(){const e=this._getCamera();if(!e)return;const t=e.minZ,s=e.maxZ||this._shadowMaxZ,i=s-t,r=this._minDistance,n=t+r*i,a=t+(this._shadowMaxZ=t?Math.min((this._shadowMaxZ-t)/(s-t),this._maxDistance):this._maxDistance)*i,o=a-n,h=a/n;for(let e=0;e{this._sceneUBOs&&this._scene.setSceneUniformBuffer(this._sceneUBOs[t]),this._currentLayer=t,this._filter===i.o.FILTER_PCF&&e.setColorWrite(!1),this._scene.setTransformMatrix(this.getCascadeViewMatrix(t),this.getCascadeProjectionMatrix(t)),this._useUBO&&(this._scene.getSceneUniformBuffer().unbindEffect(),this._scene.finalizeSceneUbo())})),this._shadowMap.onBeforeBindObservable.add((()=>{this._currentSceneUBO=this._scene.getSceneUniformBuffer(),e._debugPushGroup?.(`cascaded shadow map generation for pass id ${e.currentRenderPassId}`,1),this._breaksAreDirty&&this._splitFrustum(),this._computeMatrices()})),this._splitFrustum()}_bindCustomEffectForRenderSubMeshForShadowMap(e,t){t.setMatrix("viewProjection",this.getCascadeTransformMatrix(this._currentLayer))}_isReadyCustomDefines(e){e.push("#define SM_DEPTHCLAMP "+(this._depthClamp&&this._filter!==i.o.FILTER_PCSS?"1":"0"))}prepareDefines(e,t){super.prepareDefines(e,t);const s=this._scene,i=this._light;if(!s.shadowsEnabled||!i.shadowEnabled)return;e["SHADOWCSM"+t]=!0,e["SHADOWCSMDEBUG"+t]=this.debug,e["SHADOWCSMNUM_CASCADES"+t]=this.numCascades,e["SHADOWCSM_RIGHTHANDED"+t]=s.useRightHandedSystem;const r=this._getCamera();r&&this._shadowMaxZ<=(r.maxZ||this._shadowMaxZ)&&(e["SHADOWCSMUSESHADOWMAXZ"+t]=!0),0===this.cascadeBlendPercentage&&(e["SHADOWCSMNOBLEND"+t]=!0)}bindShadowLight(e,t){const s=this._light;if(!this._scene.shadowsEnabled||!s.shadowEnabled)return;const r=this._getCamera();if(!r)return;const n=this.getShadowMap();if(!n)return;const a=n.getSize().width;if(t.setMatrices("lightMatrix"+e,this._transformMatricesAsArray),t.setArray("viewFrustumZ"+e,this._viewSpaceFrustumsZ),t.setFloat("cascadeBlendFactor"+e,0===this.cascadeBlendPercentage?1e4:1/this.cascadeBlendPercentage),t.setArray("frustumLengths"+e,this._frustumLengths),this._filter===i.o.FILTER_PCF)t.setDepthStencilTexture("shadowTexture"+e,n),s._uniformBuffer.updateFloat4("shadowsInfo",this.getDarkness(),a,1/a,this.frustumEdgeFalloff,e);else if(this._filter===i.o.FILTER_PCSS){for(let e=0;enew C(e,t,void 0,s)));return void 0!==e.numCascades&&(s.numCascades=e.numCascades),void 0!==e.debug&&(s.debug=e.debug),void 0!==e.stabilizeCascades&&(s.stabilizeCascades=e.stabilizeCascades),void 0!==e.lambda&&(s.lambda=e.lambda),void 0!==e.cascadeBlendPercentage&&(s.cascadeBlendPercentage=e.cascadeBlendPercentage),void 0!==e.depthClamp&&(s.depthClamp=e.depthClamp),void 0!==e.autoCalcDepthBounds&&(s.autoCalcDepthBounds=e.autoCalcDepthBounds),void 0!==e.shadowMaxZ&&(s.shadowMaxZ=e.shadowMaxZ),void 0!==e.penumbraDarkness&&(s.penumbraDarkness=e.penumbraDarkness),void 0!==e.freezeShadowCastersBoundingInfo&&(s.freezeShadowCastersBoundingInfo=e.freezeShadowCastersBoundingInfo),void 0!==e.minDistance&&void 0!==e.maxDistance&&s.setMinMaxDistance(e.minDistance,e.maxDistance),s}}C._FrustumCornersNDCSpace=[new r.Pq(-1,1,-1),new r.Pq(1,1,-1),new r.Pq(1,-1,-1),new r.Pq(-1,-1,-1),new r.Pq(-1,1,1),new r.Pq(1,1,1),new r.Pq(1,-1,1),new r.Pq(-1,-1,1)],C.CLASSNAME="CascadedShadowGenerator",C.DEFAULT_CASCADES_COUNT=4,C.MIN_CASCADES_COUNT=2,C.MAX_CASCADES_COUNT=4,C._SceneComponentInitialization=e=>{throw(0,a.n)("ShadowGeneratorSceneComponent")};var S=s(6945);(0,s(3084).ji)(S.v.NAME_SHADOWGENERATOR,((e,t)=>{if(void 0!==e.shadowGenerators&&null!==e.shadowGenerators)for(let s=0,r=e.shadowGenerators.length;s{let t=e._getComponent(S.v.NAME_SHADOWGENERATOR);t||(t=new I(e),e._addComponent(t))}},5581:(e,t,s)=>{s.d(t,{Z:()=>u});var i=s(5524),r=s(9259),n=s(9923),a=s(4870),o=s(4704),h=s(8733);class l extends o.v{constructor(){super(...arguments),this._needProjectionMatrixCompute=!0,this._viewMatrix=n.uq.Identity(),this._projectionMatrix=n.uq.Identity()}_setPosition(e){this._position=e}get position(){return this._position}set position(e){this._setPosition(e)}_setDirection(e){this._direction=e}get direction(){return this._direction}set direction(e){this._setDirection(e)}get shadowMinZ(){return this._shadowMinZ}set shadowMinZ(e){this._shadowMinZ=e,this.forceProjectionMatrixCompute()}get shadowMaxZ(){return this._shadowMaxZ}set shadowMaxZ(e){this._shadowMaxZ=e,this.forceProjectionMatrixCompute()}computeTransformedInformation(){return!(!this.parent||!this.parent.getWorldMatrix||(this.transformedPosition||(this.transformedPosition=n.Pq.Zero()),n.Pq.TransformCoordinatesToRef(this.position,this.parent.getWorldMatrix(),this.transformedPosition),this.direction&&(this.transformedDirection||(this.transformedDirection=n.Pq.Zero()),n.Pq.TransformNormalToRef(this.direction,this.parent.getWorldMatrix(),this.transformedDirection)),0))}getDepthScale(){return 50}getShadowDirection(e){return this.transformedDirection?this.transformedDirection:this.direction}getAbsolutePosition(){return this.transformedPosition?this.transformedPosition:this.position}setDirectionToTarget(e){return this.direction=n.Pq.Normalize(e.subtract(this.position)),this.direction}getRotation(){this.direction.normalize();const e=n.Pq.Cross(this.direction,h._0.Y),t=n.Pq.Cross(e,this.direction);return n.Pq.RotationFromAxis(e,t,this.direction)}needCube(){return!1}needProjectionMatrixCompute(){return this._needProjectionMatrixCompute}forceProjectionMatrixCompute(){this._needProjectionMatrixCompute=!0}_initCache(){super._initCache(),this._cache.position=n.Pq.Zero()}_isSynchronized(){return!!this._cache.position.equals(this.position)}computeWorldMatrix(e){return!e&&this.isSynchronized()?(this._currentRenderId=this.getScene().getRenderId(),this._worldMatrix):(this._updateCache(),this._cache.position.copyFrom(this.position),this._worldMatrix||(this._worldMatrix=n.uq.Identity()),n.uq.TranslationToRef(this.position.x,this.position.y,this.position.z,this._worldMatrix),this.parent&&this.parent.getWorldMatrix&&(this._worldMatrix.multiplyToRef(this.parent.getWorldMatrix(),this._worldMatrix),this._markSyncedWithParent()),this._worldMatrixDeterminantIsDirty=!0,this._worldMatrix)}getDepthMinZ(e){return void 0!==this.shadowMinZ?this.shadowMinZ:e.minZ}getDepthMaxZ(e){return void 0!==this.shadowMaxZ?this.shadowMaxZ:e.maxZ}setShadowProjectionMatrix(e,t,s){return this.customProjectionMatrixBuilder?this.customProjectionMatrixBuilder(t,s,e):this._setDefaultShadowProjectionMatrix(e,t,s),this}_syncParentEnabledState(){super._syncParentEnabledState(),this.parent&&this.parent.getWorldMatrix||(this.transformedPosition=null,this.transformedDirection=null)}getViewMatrix(e){const t=n.AA.Vector3[0];let s=this.position;this.computeTransformedInformation()&&(s=this.transformedPosition),n.Pq.NormalizeToRef(this.getShadowDirection(e),t),1===Math.abs(n.Pq.Dot(t,n.Pq.Up()))&&(t.z=1e-13);const i=n.AA.Vector3[1];return s.addToRef(t,i),n.uq.LookAtLHToRef(s,i,n.Pq.Up(),this._viewMatrix),this._viewMatrix}getProjectionMatrix(e,t){return this.setShadowProjectionMatrix(this._projectionMatrix,e??this._viewMatrix,t??[]),this._projectionMatrix}}(0,i.Cg)([(0,r.P_)()],l.prototype,"position",null),(0,i.Cg)([(0,r.P_)()],l.prototype,"direction",null),(0,i.Cg)([(0,r.lK)()],l.prototype,"shadowMinZ",null),(0,i.Cg)([(0,r.lK)()],l.prototype,"shadowMaxZ",null);var c=s(6552);a.b.AddNodeConstructor("Light_Type_1",((e,t)=>()=>new u(e,n.Pq.Zero(),t)));class u extends l{get shadowFrustumSize(){return this._shadowFrustumSize}set shadowFrustumSize(e){this._shadowFrustumSize=e,this.forceProjectionMatrixCompute()}get shadowOrthoScale(){return this._shadowOrthoScale}set shadowOrthoScale(e){this._shadowOrthoScale=e,this.forceProjectionMatrixCompute()}get orthoLeft(){return this._orthoLeft}set orthoLeft(e){this._orthoLeft=e}get orthoRight(){return this._orthoRight}set orthoRight(e){this._orthoRight=e}get orthoTop(){return this._orthoTop}set orthoTop(e){this._orthoTop=e}get orthoBottom(){return this._orthoBottom}set orthoBottom(e){this._orthoBottom=e}constructor(e,t,s){super(e,s),this._shadowFrustumSize=0,this._shadowOrthoScale=.1,this.autoUpdateExtends=!0,this.autoCalcShadowZBounds=!1,this._orthoLeft=Number.MAX_VALUE,this._orthoRight=Number.MIN_VALUE,this._orthoTop=Number.MIN_VALUE,this._orthoBottom=Number.MAX_VALUE,this.position=t.scale(-1),this.direction=t}getClassName(){return"DirectionalLight"}getTypeID(){return o.v.LIGHTTYPEID_DIRECTIONALLIGHT}_setDefaultShadowProjectionMatrix(e,t,s){this.shadowFrustumSize>0?this._setDefaultFixedFrustumShadowProjectionMatrix(e):this._setDefaultAutoExtendShadowProjectionMatrix(e,t,s)}_setDefaultFixedFrustumShadowProjectionMatrix(e){const t=this.getScene().activeCamera;t&&n.uq.OrthoLHToRef(this.shadowFrustumSize,this.shadowFrustumSize,void 0!==this.shadowMinZ?this.shadowMinZ:t.minZ,void 0!==this.shadowMaxZ?this.shadowMaxZ:t.maxZ,e,this.getScene().getEngine().isNDCHalfZRange)}_setDefaultAutoExtendShadowProjectionMatrix(e,t,s){const i=this.getScene().activeCamera;if(!i)return;if(this.autoUpdateExtends||this._orthoLeft===Number.MAX_VALUE){const e=n.Pq.Zero();this._orthoLeft=Number.MAX_VALUE,this._orthoRight=-Number.MAX_VALUE,this._orthoTop=-Number.MAX_VALUE,this._orthoBottom=Number.MAX_VALUE;let i=Number.MAX_VALUE,r=-Number.MAX_VALUE;for(let a=0;athis._orthoRight&&(this._orthoRight=e.x),e.y>this._orthoTop&&(this._orthoTop=e.y),this.autoCalcShadowZBounds&&(e.zr&&(r=e.z))}this.autoCalcShadowZBounds&&(this._shadowMinZ=i,this._shadowMaxZ=r)}const r=this._orthoRight-this._orthoLeft,a=this._orthoTop-this._orthoBottom,o=void 0!==this.shadowMinZ?this.shadowMinZ:i.minZ,h=void 0!==this.shadowMaxZ?this.shadowMaxZ:i.maxZ,l=this.getScene().getEngine().useReverseDepthBuffer;n.uq.OrthoOffCenterLHToRef(this._orthoLeft-r*this.shadowOrthoScale,this._orthoRight+r*this.shadowOrthoScale,this._orthoBottom-a*this.shadowOrthoScale,this._orthoTop+a*this.shadowOrthoScale,l?h:o,l?o:h,e,this.getScene().getEngine().isNDCHalfZRange)}_buildUniformLayout(){this._uniformBuffer.addUniform("vLightData",4),this._uniformBuffer.addUniform("vLightDiffuse",4),this._uniformBuffer.addUniform("vLightSpecular",4),this._uniformBuffer.addUniform("shadowsInfo",3),this._uniformBuffer.addUniform("depthValues",2),this._uniformBuffer.create()}transferToEffect(e,t){return this.computeTransformedInformation()?(this._uniformBuffer.updateFloat4("vLightData",this.transformedDirection.x,this.transformedDirection.y,this.transformedDirection.z,1,t),this):(this._uniformBuffer.updateFloat4("vLightData",this.direction.x,this.direction.y,this.direction.z,1,t),this)}transferToNodeMaterialEffect(e,t){return this.computeTransformedInformation()?(e.setFloat3(t,this.transformedDirection.x,this.transformedDirection.y,this.transformedDirection.z),this):(e.setFloat3(t,this.direction.x,this.direction.y,this.direction.z),this)}getDepthMinZ(e){const t=this._scene.getEngine();return!t.useReverseDepthBuffer&&t.isNDCHalfZRange?0:1}getDepthMaxZ(e){const t=this._scene.getEngine();return t.useReverseDepthBuffer&&t.isNDCHalfZRange?0:1}prepareLightSpecificDefines(e,t){e["DIRLIGHT"+t]=!0}}(0,i.Cg)([(0,r.lK)()],u.prototype,"shadowFrustumSize",null),(0,i.Cg)([(0,r.lK)()],u.prototype,"shadowOrthoScale",null),(0,i.Cg)([(0,r.lK)()],u.prototype,"autoUpdateExtends",void 0),(0,i.Cg)([(0,r.lK)()],u.prototype,"autoCalcShadowZBounds",void 0),(0,i.Cg)([(0,r.lK)("orthoLeft")],u.prototype,"_orthoLeft",void 0),(0,i.Cg)([(0,r.lK)("orthoRight")],u.prototype,"_orthoRight",void 0),(0,i.Cg)([(0,r.lK)("orthoTop")],u.prototype,"_orthoTop",void 0),(0,i.Cg)([(0,r.lK)("orthoBottom")],u.prototype,"_orthoBottom",void 0),(0,c.Y5)("BABYLON.DirectionalLight",u)},1513:(e,t,s)=>{s.d(t,{g:()=>c});var i=s(5524),r=s(9259),n=s(9923),a=s(6041),o=s(4870),h=s(4704),l=s(6552);o.b.AddNodeConstructor("Light_Type_3",((e,t)=>()=>new c(e,n.Pq.Zero(),t)));class c extends h.v{constructor(e,t,s){super(e,s),this.groundColor=new a.v9(0,0,0),this.direction=t||n.Pq.Up()}_buildUniformLayout(){this._uniformBuffer.addUniform("vLightData",4),this._uniformBuffer.addUniform("vLightDiffuse",4),this._uniformBuffer.addUniform("vLightSpecular",4),this._uniformBuffer.addUniform("vLightGround",3),this._uniformBuffer.addUniform("shadowsInfo",3),this._uniformBuffer.addUniform("depthValues",2),this._uniformBuffer.create()}getClassName(){return"HemisphericLight"}setDirectionToTarget(e){return this.direction=n.Pq.Normalize(e.subtract(n.Pq.Zero())),this.direction}getShadowGenerator(){return null}transferToEffect(e,t){const s=n.Pq.Normalize(this.direction);return this._uniformBuffer.updateFloat4("vLightData",s.x,s.y,s.z,0,t),this._uniformBuffer.updateColor3("vLightGround",this.groundColor.scale(this.intensity),t),this}transferToNodeMaterialEffect(e,t){const s=n.Pq.Normalize(this.direction);return e.setFloat3(t,s.x,s.y,s.z),this}computeWorldMatrix(){return this._worldMatrix||(this._worldMatrix=n.uq.Identity()),this._worldMatrix}getTypeID(){return h.v.LIGHTTYPEID_HEMISPHERICLIGHT}prepareLightSpecificDefines(e,t){e["HEMILIGHT"+t]=!0}}(0,i.Cg)([(0,r.jT)()],c.prototype,"groundColor",void 0),(0,i.Cg)([(0,r.P_)()],c.prototype,"direction",void 0),(0,l.Y5)("BABYLON.HemisphericLight",c)},4704:(e,t,s)=>{s.d(t,{v:()=>d});var i=s(5524),r=s(9259),n=s(9923),a=s(6041),o=s(4870),h=s(935),l=s(6552),c=s(5515),u=s(6877);class d extends o.b{get range(){return this._range}set range(e){this._range=e,this._inverseSquaredRange=1/(this.range*this.range)}get intensityMode(){return this._intensityMode}set intensityMode(e){this._intensityMode=e,this._computePhotometricScale()}get radius(){return this._radius}set radius(e){this._radius=e,this._computePhotometricScale()}get shadowEnabled(){return this._shadowEnabled}set shadowEnabled(e){this._shadowEnabled!==e&&(this._shadowEnabled=e,this._markMeshesAsLightDirty())}get includedOnlyMeshes(){return this._includedOnlyMeshes}set includedOnlyMeshes(e){this._includedOnlyMeshes=e,this._hookArrayForIncludedOnly(e)}get excludedMeshes(){return this._excludedMeshes}set excludedMeshes(e){this._excludedMeshes=e,this._hookArrayForExcluded(e)}get excludeWithLayerMask(){return this._excludeWithLayerMask}set excludeWithLayerMask(e){this._excludeWithLayerMask=e,this._resyncMeshes()}get includeOnlyWithLayerMask(){return this._includeOnlyWithLayerMask}set includeOnlyWithLayerMask(e){this._includeOnlyWithLayerMask=e,this._resyncMeshes()}get lightmapMode(){return this._lightmapMode}set lightmapMode(e){this._lightmapMode!==e&&(this._lightmapMode=e,this._markMeshesAsLightDirty())}getViewMatrix(e){return null}getProjectionMatrix(e,t){return null}constructor(e,t){super(e,t,!1),this.diffuse=new a.v9(1,1,1),this.specular=new a.v9(1,1,1),this.falloffType=d.FALLOFF_DEFAULT,this.intensity=1,this._range=Number.MAX_VALUE,this._inverseSquaredRange=0,this._photometricScale=1,this._intensityMode=d.INTENSITYMODE_AUTOMATIC,this._radius=1e-5,this.renderPriority=0,this._shadowEnabled=!0,this._excludeWithLayerMask=0,this._includeOnlyWithLayerMask=0,this._lightmapMode=0,this._shadowGenerators=null,this._excludedMeshesIds=new Array,this._includedOnlyMeshesIds=new Array,this._isLight=!0,this.getScene().addLight(this),this._uniformBuffer=new h.D(this.getScene().getEngine(),void 0,void 0,e),this._buildUniformLayout(),this.includedOnlyMeshes=[],this.excludedMeshes=[],this._resyncMeshes()}transferTexturesToEffect(e,t){return this}_bindLight(e,t,s,i,r=!0){const n=e.toString();let o=!1;if(this._uniformBuffer.bindToEffect(s,"Light"+n),this._renderId!==t.getRenderId()||this._lastUseSpecular!==i||!this._uniformBuffer.useUbo){this._renderId=t.getRenderId(),this._lastUseSpecular=i;const e=this.getScaledIntensity();this.transferToEffect(s,n),this.diffuse.scaleToRef(e,a.IG.Color3[0]),this._uniformBuffer.updateColor4("vLightDiffuse",a.IG.Color3[0],this.range,n),i&&(this.specular.scaleToRef(e,a.IG.Color3[1]),this._uniformBuffer.updateColor4("vLightSpecular",a.IG.Color3[1],this.radius,n)),o=!0}if(this.transferTexturesToEffect(s,n),t.shadowsEnabled&&this.shadowEnabled&&r){const e=this.getShadowGenerator(t.activeCamera)??this.getShadowGenerator();e&&(e.bindShadowLight(n,s),o=!0)}o?this._uniformBuffer.update():this._uniformBuffer.bindUniformBuffer()}getClassName(){return"Light"}toString(e){let t="Name: "+this.name;if(t+=", type: "+["Point","Directional","Spot","Hemispheric"][this.getTypeID()],this.animations)for(let s=0;s0&&-1===this.includedOnlyMeshes.indexOf(e)||this.excludedMeshes&&this.excludedMeshes.length>0&&-1!==this.excludedMeshes.indexOf(e)||0!==this.includeOnlyWithLayerMask&&0==(this.includeOnlyWithLayerMask&e.layerMask)||0!==this.excludeWithLayerMask&&this.excludeWithLayerMask&e.layerMask))}dispose(e,t=!1){if(this._shadowGenerators){const e=this._shadowGenerators.values();for(let t=e.next();!0!==t.done;t=e.next())t.value.dispose();this._shadowGenerators=null}if(this.getScene().stopAnimation(this),this._parentContainer){const e=this._parentContainer.lights.indexOf(this);e>-1&&this._parentContainer.lights.splice(e,1),this._parentContainer=null}for(const e of this.getScene().meshes)e._removeLightSource(this,!0);this._uniformBuffer.dispose(),this.getScene().removeLight(this),super.dispose(e,t)}getTypeID(){return 0}getScaledIntensity(){return this._photometricScale*this.intensity}clone(e,t=null){const s=d.GetConstructorFromName(this.getTypeID(),e,this.getScene());if(!s)return null;const i=u.p.Clone(s,this);return e&&(i.name=e),t&&(i.parent=t),i.setEnabled(this.isEnabled()),this.onClonedObservable.notifyObservers(i),i}serialize(){const e=u.p.Serialize(this);return e.uniqueId=this.uniqueId,e.type=this.getTypeID(),this.parent&&this.parent._serializeAsParent(e),this.excludedMeshes.length>0&&(e.excludedMeshesIds=[],this.excludedMeshes.forEach((t=>{e.excludedMeshesIds.push(t.id)}))),this.includedOnlyMeshes.length>0&&(e.includedOnlyMeshesIds=[],this.includedOnlyMeshes.forEach((t=>{e.includedOnlyMeshesIds.push(t.id)}))),u.p.AppendSerializedAnimations(this,e),e.ranges=this.serializeAnimationRanges(),e.isEnabled=this.isEnabled(),e}static GetConstructorFromName(e,t,s){return o.b.Construct("Light_Type_"+e,t,s)||null}static Parse(e,t){const s=d.GetConstructorFromName(e.type,e.name,t);if(!s)return null;const i=u.p.Parse(s,e,t);if(e.excludedMeshesIds&&(i._excludedMeshesIds=e.excludedMeshesIds),e.includedOnlyMeshesIds&&(i._includedOnlyMeshesIds=e.includedOnlyMeshesIds),void 0!==e.parentId&&(i._waitingParentId=e.parentId),void 0!==e.parentInstanceIndex&&(i._waitingParentInstanceIndex=e.parentInstanceIndex),void 0!==e.falloffType&&(i.falloffType=e.falloffType),void 0!==e.lightmapMode&&(i.lightmapMode=e.lightmapMode),e.animations){for(let t=0;t{const i=t.apply(e,s);for(const e of s)e._resyncLightSource(this);return i};const s=e.splice;e.splice=(t,i)=>{const r=s.apply(e,[t,i]);for(const e of r)e._resyncLightSource(this);return r};for(const t of e)t._resyncLightSource(this)}_hookArrayForIncludedOnly(e){const t=e.push;e.push=(...s)=>{const i=t.apply(e,s);return this._resyncMeshes(),i};const s=e.splice;e.splice=(t,i)=>{const r=s.apply(e,[t,i]);return this._resyncMeshes(),r},this._resyncMeshes()}_resyncMeshes(){for(const e of this.getScene().meshes)e._resyncLightSource(this)}_markMeshesAsLightDirty(){for(const e of this.getScene().meshes)-1!==e.lightSources.indexOf(this)&&e._markSubMeshesAsLightDirty()}_computePhotometricScale(){this._photometricScale=this._getPhotometricScale(),this.getScene().resetCachedMaterial()}_getPhotometricScale(){let e=0;const t=this.getTypeID();let s=this.intensityMode;switch(s===d.INTENSITYMODE_AUTOMATIC&&(s=t===d.LIGHTTYPEID_DIRECTIONALLIGHT?d.INTENSITYMODE_ILLUMINANCE:d.INTENSITYMODE_LUMINOUSINTENSITY),t){case d.LIGHTTYPEID_POINTLIGHT:case d.LIGHTTYPEID_SPOTLIGHT:switch(s){case d.INTENSITYMODE_LUMINOUSPOWER:e=1/(4*Math.PI);break;case d.INTENSITYMODE_LUMINOUSINTENSITY:e=1;break;case d.INTENSITYMODE_LUMINANCE:e=this.radius*this.radius}break;case d.LIGHTTYPEID_DIRECTIONALLIGHT:switch(s){case d.INTENSITYMODE_ILLUMINANCE:e=1;break;case d.INTENSITYMODE_LUMINANCE:{let t=this.radius;t=Math.max(t,.001),e=2*Math.PI*(1-Math.cos(t));break}}break;case d.LIGHTTYPEID_HEMISPHERICLIGHT:e=1}return e}_reorderLightsInScene(){const e=this.getScene();0!=this._renderPriority&&(e.requireLightSorting=!0),this.getScene().sortLightsByPriority()}}d.FALLOFF_DEFAULT=c.c.FALLOFF_DEFAULT,d.FALLOFF_PHYSICAL=c.c.FALLOFF_PHYSICAL,d.FALLOFF_GLTF=c.c.FALLOFF_GLTF,d.FALLOFF_STANDARD=c.c.FALLOFF_STANDARD,d.LIGHTMAP_DEFAULT=c.c.LIGHTMAP_DEFAULT,d.LIGHTMAP_SPECULAR=c.c.LIGHTMAP_SPECULAR,d.LIGHTMAP_SHADOWSONLY=c.c.LIGHTMAP_SHADOWSONLY,d.INTENSITYMODE_AUTOMATIC=c.c.INTENSITYMODE_AUTOMATIC,d.INTENSITYMODE_LUMINOUSPOWER=c.c.INTENSITYMODE_LUMINOUSPOWER,d.INTENSITYMODE_LUMINOUSINTENSITY=c.c.INTENSITYMODE_LUMINOUSINTENSITY,d.INTENSITYMODE_ILLUMINANCE=c.c.INTENSITYMODE_ILLUMINANCE,d.INTENSITYMODE_LUMINANCE=c.c.INTENSITYMODE_LUMINANCE,d.LIGHTTYPEID_POINTLIGHT=c.c.LIGHTTYPEID_POINTLIGHT,d.LIGHTTYPEID_DIRECTIONALLIGHT=c.c.LIGHTTYPEID_DIRECTIONALLIGHT,d.LIGHTTYPEID_SPOTLIGHT=c.c.LIGHTTYPEID_SPOTLIGHT,d.LIGHTTYPEID_HEMISPHERICLIGHT=c.c.LIGHTTYPEID_HEMISPHERICLIGHT,(0,i.Cg)([(0,r.jT)()],d.prototype,"diffuse",void 0),(0,i.Cg)([(0,r.jT)()],d.prototype,"specular",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"falloffType",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"intensity",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"range",null),(0,i.Cg)([(0,r.lK)()],d.prototype,"intensityMode",null),(0,i.Cg)([(0,r.lK)()],d.prototype,"radius",null),(0,i.Cg)([(0,r.lK)()],d.prototype,"_renderPriority",void 0),(0,i.Cg)([(0,r.$z)("_reorderLightsInScene")],d.prototype,"renderPriority",void 0),(0,i.Cg)([(0,r.lK)("shadowEnabled")],d.prototype,"_shadowEnabled",void 0),(0,i.Cg)([(0,r.lK)("excludeWithLayerMask")],d.prototype,"_excludeWithLayerMask",void 0),(0,i.Cg)([(0,r.lK)("includeOnlyWithLayerMask")],d.prototype,"_includeOnlyWithLayerMask",void 0),(0,i.Cg)([(0,r.lK)("lightmapMode")],d.prototype,"_lightmapMode",void 0)},5515:(e,t,s)=>{s.d(t,{c:()=>i});class i{static CompareLightsPriority(e,t){return e.shadowEnabled!==t.shadowEnabled?(t.shadowEnabled?1:0)-(e.shadowEnabled?1:0):t.renderPriority-e.renderPriority}}i.FALLOFF_DEFAULT=0,i.FALLOFF_PHYSICAL=1,i.FALLOFF_GLTF=2,i.FALLOFF_STANDARD=3,i.LIGHTMAP_DEFAULT=0,i.LIGHTMAP_SPECULAR=1,i.LIGHTMAP_SHADOWSONLY=2,i.INTENSITYMODE_AUTOMATIC=0,i.INTENSITYMODE_LUMINOUSPOWER=1,i.INTENSITYMODE_LUMINOUSINTENSITY=2,i.INTENSITYMODE_ILLUMINANCE=3,i.INTENSITYMODE_LUMINANCE=4,i.LIGHTTYPEID_POINTLIGHT=0,i.LIGHTTYPEID_DIRECTIONALLIGHT=1,i.LIGHTTYPEID_SPOTLIGHT=2,i.LIGHTTYPEID_HEMISPHERICLIGHT=3},3084:(e,t,s)=>{s.d(t,{ji:()=>r});const i={};function r(e,t){i[e]=t}},9679:(e,t,s)=>{var i=s(6326);class r{constructor(e,t="",s="black"){this._renderingCanvas=e,this._loadingText=t,this._loadingDivBackgroundColor=s,this._resizeLoadingUI=()=>{const e=this._renderingCanvas.getBoundingClientRect(),t=window.getComputedStyle(this._renderingCanvas).position;this._loadingDiv&&(this._loadingDiv.style.position="fixed"===t?"fixed":"absolute",this._loadingDiv.style.left=e.left+"px",this._loadingDiv.style.top=e.top+"px",this._loadingDiv.style.width=e.width+"px",this._loadingDiv.style.height=e.height+"px")}}displayLoadingUI(){if(this._loadingDiv)return;this._loadingDiv=document.createElement("div"),this._loadingDiv.id="babylonjsLoadingDiv",this._loadingDiv.style.opacity="0",this._loadingDiv.style.transition="opacity 1.5s ease",this._loadingDiv.style.pointerEvents="none",this._loadingDiv.style.display="grid",this._loadingDiv.style.gridTemplateRows="100%",this._loadingDiv.style.gridTemplateColumns="100%",this._loadingDiv.style.justifyItems="center",this._loadingDiv.style.alignItems="center",this._loadingTextDiv=document.createElement("div"),this._loadingTextDiv.style.position="absolute",this._loadingTextDiv.style.left="0",this._loadingTextDiv.style.top="50%",this._loadingTextDiv.style.marginTop="80px",this._loadingTextDiv.style.width="100%",this._loadingTextDiv.style.height="20px",this._loadingTextDiv.style.fontFamily="Arial",this._loadingTextDiv.style.fontSize="14px",this._loadingTextDiv.style.color="white",this._loadingTextDiv.style.textAlign="center",this._loadingTextDiv.style.zIndex="1",this._loadingTextDiv.innerHTML="Loading",this._loadingDiv.appendChild(this._loadingTextDiv),this._loadingTextDiv.innerHTML=this._loadingText,this._style=document.createElement("style"),this._style.type="text/css",this._style.innerHTML="@-webkit-keyframes spin1 { 0% { -webkit-transform: rotate(0deg);}\n 100% { -webkit-transform: rotate(360deg);}\n } @keyframes spin1 { 0% { transform: rotate(0deg);}\n 100% { transform: rotate(360deg);}\n }",document.getElementsByTagName("head")[0].appendChild(this._style);const e=!!window.SVGSVGElement,t=new Image;r.DefaultLogoUrl?t.src=r.DefaultLogoUrl:t.src=e?"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxODAuMTcgMjA4LjA0Ij48ZGVmcz48c3R5bGU+LmNscy0xe2ZpbGw6I2ZmZjt9LmNscy0ye2ZpbGw6I2UwNjg0Yjt9LmNscy0ze2ZpbGw6I2JiNDY0Yjt9LmNscy00e2ZpbGw6I2UwZGVkODt9LmNscy01e2ZpbGw6I2Q1ZDJjYTt9PC9zdHlsZT48L2RlZnM+PHRpdGxlPkJhYnlsb25Mb2dvPC90aXRsZT48ZyBpZD0iTGF5ZXJfMiIgZGF0YS1uYW1lPSJMYXllciAyIj48ZyBpZD0iUGFnZV9FbGVtZW50cyIgZGF0YS1uYW1lPSJQYWdlIEVsZW1lbnRzIj48cGF0aCBjbGFzcz0iY2xzLTEiIGQ9Ik05MC4wOSwwLDAsNTJWMTU2bDkwLjA5LDUyLDkwLjA4LTUyVjUyWiIvPjxwb2x5Z29uIGNsYXNzPSJjbHMtMiIgcG9pbnRzPSIxODAuMTcgNTIuMDEgMTUxLjk3IDM1LjczIDEyNC44NSA1MS4zOSAxNTMuMDUgNjcuNjcgMTgwLjE3IDUyLjAxIi8+PHBvbHlnb24gY2xhc3M9ImNscy0yIiBwb2ludHM9IjI3LjEyIDY3LjY3IDExNy4yMSAxNS42NiA5MC4wOCAwIDAgNTIuMDEgMjcuMTIgNjcuNjciLz48cG9seWdvbiBjbGFzcz0iY2xzLTIiIHBvaW50cz0iNjEuODkgMTIwLjMgOTAuMDggMTM2LjU4IDExOC4yOCAxMjAuMyA5MC4wOCAxMDQuMDIgNjEuODkgMTIwLjMiLz48cG9seWdvbiBjbGFzcz0iY2xzLTMiIHBvaW50cz0iMTUzLjA1IDY3LjY3IDE1My4wNSAxNDAuMzcgOTAuMDggMTc2LjcyIDI3LjEyIDE0MC4zNyAyNy4xMiA2Ny42NyAwIDUyLjAxIDAgMTU2LjAzIDkwLjA4IDIwOC4wNCAxODAuMTcgMTU2LjAzIDE4MC4xNyA1Mi4wMSAxNTMuMDUgNjcuNjciLz48cG9seWdvbiBjbGFzcz0iY2xzLTMiIHBvaW50cz0iOTAuMDggNzEuNDYgNjEuODkgODcuNzQgNjEuODkgMTIwLjMgOTAuMDggMTA0LjAyIDExOC4yOCAxMjAuMyAxMTguMjggODcuNzQgOTAuMDggNzEuNDYiLz48cG9seWdvbiBjbGFzcz0iY2xzLTQiIHBvaW50cz0iMTUzLjA1IDY3LjY3IDExOC4yOCA4Ny43NCAxMTguMjggMTIwLjMgOTAuMDggMTM2LjU4IDkwLjA4IDE3Ni43MiAxNTMuMDUgMTQwLjM3IDE1My4wNSA2Ny42NyIvPjxwb2x5Z29uIGNsYXNzPSJjbHMtNSIgcG9pbnRzPSIyNy4xMiA2Ny42NyA2MS44OSA4Ny43NCA2MS44OSAxMjAuMyA5MC4wOCAxMzYuNTggOTAuMDggMTc2LjcyIDI3LjEyIDE0MC4zNyAyNy4xMiA2Ny42NyIvPjwvZz48L2c+PC9zdmc+":"https://cdn.babylonjs.com/Assets/babylonLogo.png",t.style.width="150px",t.style.gridColumn="1",t.style.gridRow="1",t.style.top="50%",t.style.left="50%",t.style.transform="translate(-50%, -50%)",t.style.position="absolute";const s=document.createElement("div");s.style.width="300px",s.style.gridColumn="1",s.style.gridRow="1",s.style.top="50%",s.style.left="50%",s.style.transform="translate(-50%, -50%)",s.style.position="absolute";const i=new Image;if(r.DefaultSpinnerUrl?i.src=r.DefaultSpinnerUrl:i.src=e?"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzOTIgMzkyIj48ZGVmcz48c3R5bGU+LmNscy0xe2ZpbGw6I2UwNjg0Yjt9LmNscy0ye2ZpbGw6bm9uZTt9PC9zdHlsZT48L2RlZnM+PHRpdGxlPlNwaW5uZXJJY29uPC90aXRsZT48ZyBpZD0iTGF5ZXJfMiIgZGF0YS1uYW1lPSJMYXllciAyIj48ZyBpZD0iU3Bpbm5lciI+PHBhdGggY2xhc3M9ImNscy0xIiBkPSJNNDAuMjEsMTI2LjQzYzMuNy03LjMxLDcuNjctMTQuNDQsMTItMjEuMzJsMy4zNi01LjEsMy41Mi01YzEuMjMtMS42MywyLjQxLTMuMjksMy42NS00LjkxczIuNTMtMy4yMSwzLjgyLTQuNzlBMTg1LjIsMTg1LjIsMCwwLDEsODMuNCw2Ny40M2EyMDgsMjA4LDAsMCwxLDE5LTE1LjY2YzMuMzUtMi40MSw2Ljc0LTQuNzgsMTAuMjUtN3M3LjExLTQuMjgsMTAuNzUtNi4zMmM3LjI5LTQsMTQuNzMtOCwyMi41My0xMS40OSwzLjktMS43Miw3Ljg4LTMuMywxMi00LjY0YTEwNC4yMiwxMDQuMjIsMCwwLDEsMTIuNDQtMy4yMyw2Mi40NCw2Mi40NCwwLDAsMSwxMi43OC0xLjM5QTI1LjkyLDI1LjkyLDAsMCwxLDE5NiwyMS40NGE2LjU1LDYuNTUsMCwwLDEsMi4wNSw5LDYuNjYsNi42NiwwLDAsMS0xLjY0LDEuNzhsLS40MS4yOWEyMi4wNywyMi4wNywwLDAsMS01Ljc4LDMsMzAuNDIsMzAuNDIsMCwwLDEtNS42NywxLjYyLDM3LjgyLDM3LjgyLDAsMCwxLTUuNjkuNzFjLTEsMC0xLjkuMTgtMi44NS4yNmwtMi44NS4yNHEtNS43Mi41MS0xMS40OCwxLjFjLTMuODQuNC03LjcxLjgyLTExLjU4LDEuNGExMTIuMzQsMTEyLjM0LDAsMCwwLTIyLjk0LDUuNjFjLTMuNzIsMS4zNS03LjM0LDMtMTAuOTQsNC42NHMtNy4xNCwzLjUxLTEwLjYsNS41MUExNTEuNiwxNTEuNiwwLDAsMCw2OC41Niw4N0M2Ny4yMyw4OC40OCw2Niw5MCw2NC42NCw5MS41NnMtMi41MSwzLjE1LTMuNzUsNC43M2wtMy41NCw0LjljLTEuMTMsMS42Ni0yLjIzLDMuMzUtMy4zMyw1YTEyNywxMjcsMCwwLDAtMTAuOTMsMjEuNDksMS41OCwxLjU4LDAsMSwxLTMtMS4xNVM0MC4xOSwxMjYuNDcsNDAuMjEsMTI2LjQzWiIvPjxyZWN0IGNsYXNzPSJjbHMtMiIgd2lkdGg9IjM5MiIgaGVpZ2h0PSIzOTIiLz48L2c+PC9nPjwvc3ZnPg==":"https://cdn.babylonjs.com/Assets/loadingIcon.png",i.style.animation="spin1 0.75s infinite linear",i.style.transformOrigin="50% 50%",!e){const e={w:16,h:18.5},s={w:30,h:30};t.style.width=`${e.w}vh`,t.style.height=`${e.h}vh`,t.style.left=`calc(50% - ${e.w/2}vh)`,t.style.top=`calc(50% - ${e.h/2}vh)`,i.style.width=`${s.w}vh`,i.style.height=`${s.h}vh`,i.style.left=`calc(50% - ${s.w/2}vh)`,i.style.top=`calc(50% - ${s.h/2}vh)`}s.appendChild(i),this._loadingDiv.appendChild(t),this._loadingDiv.appendChild(s),this._resizeLoadingUI(),window.addEventListener("resize",this._resizeLoadingUI),this._loadingDiv.style.backgroundColor=this._loadingDivBackgroundColor,document.body.appendChild(this._loadingDiv),this._loadingDiv.style.opacity="1"}hideLoadingUI(){this._loadingDiv&&(this._loadingDiv.style.opacity="0",this._loadingDiv.addEventListener("transitionend",(()=>{this._loadingTextDiv&&(this._loadingTextDiv.remove(),this._loadingTextDiv=null),this._loadingDiv&&(this._loadingDiv.remove(),this._loadingDiv=null),this._style&&(this._style.remove(),this._style=null),window.removeEventListener("resize",this._resizeLoadingUI)})))}set loadingUIText(e){this._loadingText=e,this._loadingTextDiv&&(this._loadingTextDiv.innerHTML=this._loadingText)}get loadingUIText(){return this._loadingText}get loadingUIBackgroundColor(){return this._loadingDivBackgroundColor}set loadingUIBackgroundColor(e){this._loadingDivBackgroundColor=e,this._loadingDiv&&(this._loadingDiv.style.backgroundColor=this._loadingDivBackgroundColor)}}r.DefaultLogoUrl="",r.DefaultSpinnerUrl="",i.$.DefaultLoadingScreenFactory=e=>new r(e)},5909:(e,t,s)=>{s.d(t,{kS:()=>C,cH:()=>R});var i,r=s(998),n=s(9848),a=s(554),o=s(6315),h=s(1137),l=s(7597),c=s(655),u=s(8563),d=s(8688),_=s(6326),f=s(2366);!function(e){e[e.Clean=0]="Clean",e[e.Stop=1]="Stop",e[e.Sync=2]="Sync",e[e.NoSync=3]="NoSync"}(i||(i={}));const p=new n.cP,g={};let m=!1;function T(){return g[".babylon"]}function b(e,t){return g[e]||(h.V.Warn("Unable to find a plugin to load "+e+" files. Trying to use .babylon default plugin. To load from a specific filetype (eg. gltf) see: https://doc.babylonjs.com/features/featuresDeepDive/importers/loadingFileTypes"),t?T():void 0)}function E(e,t,s){let i="Unable to load from "+(e.rawData?"binary data":e.url);return t?i+=`: ${t}`:s&&(i+=`: ${s}`),i}async function x(e,t,s,i,r,n,a,o,h){const l="data:"===(u=e.url).substring(0,5)?u.substring(5):null;var u;if(e.rawData&&!a)throw"When using ArrayBufferView to load data the file extension must be provided.";const d=l||a?"":function(e){const t=e.indexOf("?");-1!==t&&(e=e.substring(0,t));const s=e.lastIndexOf(".");return e.substring(s,e.length).toLowerCase()}(e.url);let m=a?b(a,!0):l?function(e){for(const t in g){const s=g[t].plugin;if(s.canDirectLoad&&s.canDirectLoad(e))return g[t]}return T()}(e.url):b(d,!1);if(!m&&d){if(e.url&&!e.url.startsWith("blob:")){const t=await function(e,t){const s=t.method||"GET";return new Promise(((i,r)=>{const n=new f.u;n.addEventListener("readystatechange",(()=>{if(4==n.readyState)if(200==n.status){const e={};if(t.responseHeaders)for(const s of t.responseHeaders)e[s]=n.getResponseHeader(s)||"";i({response:n.response,headerValues:e})}else r(`Unable to fetch data from ${e}. Error code: ${n.status}`)})),n.open(s,e),n.send()}))}(e.url,{method:"HEAD",responseHeaders:["Content-Type"]}),s=t.headerValues?t.headerValues["Content-Type"]:"";s&&(m=function(e){for(const t in g){const s=g[t];if(s.mimeType===e)return s}}(s))}m||(m=T())}if(!m)throw new Error(`No plugin or fallback for ${a??e.url}`);if(!1===h?.[m.plugin.name]?.enabled)throw new Error(`The '${m.plugin.name}' plugin is disabled via the loader options passed to the loading operation.`);if(e.rawData&&!m.isBinary)throw"Loading from ArrayBufferView can not be used with plugins that don't support binary loading.";return(e=>{if(m.plugin.createPlugin){const t=m.plugin.createPlugin(h??{});return t instanceof Promise?(t.then(e).catch((e=>{r("Error instantiating plugin.",e)})),null):(e(t),t)}return e(m.plugin),m.plugin})((h=>{if(!h)throw`The loader plugin corresponding to the '${a}' file type has not been found. If using es6, please import the plugin you wish to use before.`;if(p.notifyObservers(h),l&&(h.canDirectLoad&&h.canDirectLoad(e.url)||!(0,c.f2)(e.url))){if(h.directLoad){const e=h.directLoad(t,l);e instanceof Promise?e.then((e=>{s(h,e)})).catch((e=>{r("Error in directLoad of _loadData: "+e,e)})):s(h,e)}else s(h,l);return}const u=m.isBinary,d=(e,i)=>{t.isDisposed?r("Scene has been disposed"):s(h,e,i)};let f=null,g=!1;h.onDisposeObservable?.add((()=>{g=!0,f&&(f.abort(),f=null),n()}));const T=()=>{if(g)return;const s=(e,t)=>{r(e?.statusText,t)};if(!h.loadFile&&e.rawData)throw"Plugin does not support loading ArrayBufferView.";f=h.loadFile?h.loadFile(t,e.rawData||e.file||e.url,e.rootUrl,d,i,u,s,o):t._loadFile(e.file||e.url,d,i,!0,u,s)},b=t.getEngine();let E=b.enableOfflineSupport;if(E){let s=!1;for(const i of t.disableOfflineSupportExceptionRules)if(i.test(e.url)){s=!0;break}E=!s}E&&_.$.OfflineProviderFactory?t.offlineProvider=_.$.OfflineProviderFactory(e.url,T,b.disableManifestCheck):T()}))}function A(e,t){let s,i,n=null,a=null;if(t)if(t.name)s=`file:${t.name}`,i=t.name,n=t;else if(ArrayBuffer.isView(t))s="",i=(0,d.z)(),a=t;else if(t.startsWith("data:"))s=t,i="";else if(e){const n=t;if("/"===n.substring(0,1))return r.S0.Error("Wrong sceneFilename parameter"),null;s=e+n,i=n}else s=t,i=r.S0.GetFilename(t),e=r.S0.GetFolderPath(t);else s=e,i=r.S0.GetFilename(e),e=r.S0.GetFolderPath(e);return{url:s,rootUrl:e,name:i,file:n,rawData:a}}function R(e){if("string"==typeof e.extensions){const t=e.extensions;g[t.toLowerCase()]={plugin:e,isBinary:!1}}else{const t=e.extensions;Object.keys(t).forEach((s=>{g[s.toLowerCase()]={plugin:e,isBinary:t[s].isBinary,mimeType:t[s].mimeType}}))}}async function M(e,t,s="",i=o.q.LastCreatedScene,r=null,n=null,a=null,l=null,c="",d={}){if(!i)return h.V.Error("No scene available to import mesh to"),null;const _=A(t,s);if(!_)return null;const f={};i.addPendingData(f);const p=()=>{i.removePendingData(f)},g=(e,t)=>{const s=E(_,e,t);a?a(i,s,new u.bu(s,u.tG.SceneLoaderError,t)):h.V.Error(s),p()},m=n?e=>{try{n(e)}catch(e){g("Error in onProgress callback: "+e,e)}}:void 0,T=(e,t,s,n,a,o,h,l)=>{if(i.importedMeshesFiles.push(_.url),r)try{r(e,t,s,n,a,o,h,l)}catch(e){g("Error in onSuccess callback: "+e,e)}i.removePendingData(f)};return await x(_,i,((t,s,r)=>{if(t.rewriteRootURL&&(_.rootUrl=t.rewriteRootURL(_.rootUrl,r)),t.importMesh){const r=[],n=[],a=[];if(!t.importMesh(e,i,s,_.rootUrl,r,n,a,g))return;i.loadingPluginName=t.name,T(r,n,a,[],[],[],[],[])}else t.importMeshAsync(e,i,s,_.rootUrl,m,_.name).then((e=>{i.loadingPluginName=t.name,T(e.meshes,e.particleSystems,e.skeletons,e.animationGroups,e.transformNodes,e.geometries,e.lights,e.spriteManagers)})).catch((e=>{g(e.message,e)}))}),m,g,p,l,c,d)}function y(e,t="",s=o.q.LastCreatedEngine,i=null,n=null,h=null,l=null,c="",u={}){s?P(e,t,new a.Z(s),i,n,h,l,c,u):r.S0.Error("No engine available")}async function P(e,t="",s=o.q.LastCreatedScene,i=null,r=null,n=null,a=null,c="",d={}){if(!s)return h.V.Error("No scene available to append to"),null;const _=A(e,t);if(!_)return null;const f={};s.addPendingData(f);const p=()=>{s.removePendingData(f)};l.B.ShowLoadingScreen&&!m&&(m=!0,s.getEngine().displayLoadingUI(),s.executeWhenReady((()=>{s.getEngine().hideLoadingUI(),m=!1})));const g=(e,t)=>{const i=E(_,e,t);n?n(s,i,new u.bu(i,u.tG.SceneLoaderError,t)):h.V.Error(i),p()},T=r?e=>{try{r(e)}catch(e){g("Error in onProgress callback",e)}}:void 0,b=()=>{if(i)try{i(s)}catch(e){g("Error in onSuccess callback",e)}s.removePendingData(f)};return await x(_,s,((e,t)=>{if(e.load){if(!e.load(s,t,_.rootUrl,g))return;s.loadingPluginName=e.name,b()}else e.loadAsync(s,t,_.rootUrl,T,_.name).then((()=>{s.loadingPluginName=e.name,b()})).catch((e=>{g(e.message,e)}))}),T,g,p,a,c,d)}async function v(e,t="",s=o.q.LastCreatedScene,i=null,r=null,n=null,a=null,l="",c={}){if(!s)return h.V.Error("No scene available to load asset container to"),null;const d=A(e,t);if(!d)return null;const _={};s.addPendingData(_);const f=()=>{s.removePendingData(_)},p=(e,t)=>{const i=E(d,e,t);n?n(s,i,new u.bu(i,u.tG.SceneLoaderError,t)):h.V.Error(i),f()},g=r?e=>{try{r(e)}catch(e){p("Error in onProgress callback",e)}}:void 0,m=e=>{if(i)try{i(e)}catch(e){p("Error in onSuccess callback",e)}s.removePendingData(_)};return await x(d,s,((e,t)=>{if(e.loadAssetContainer){const i=e.loadAssetContainer(s,t,d.rootUrl,p);if(!i)return;i.populateRootNodes(),s.loadingPluginName=e.name,m(i)}else e.loadAssetContainerAsync?e.loadAssetContainerAsync(s,t,d.rootUrl,g,d.name).then((t=>{t.populateRootNodes(),s.loadingPluginName=e.name,m(t)})).catch((e=>{p(e.message,e)})):p("LoadAssetContainer is not supported by this plugin. Plugin did not provide a loadAssetContainer or loadAssetContainerAsync method.")}),g,p,f,a,l,c)}function C(e,t,s){const{rootUrl:i="",onProgress:r,pluginExtension:n,name:a,pluginOptions:o}=s??{};return S(i,e,t,r,n,a,o)}function S(e,t,s,i,r,n,a){return new Promise(((o,h)=>{v(e,t,s,(e=>{o(e)}),i,((e,t,s)=>{h(s||new Error(t))}),r,n,a)}))}function I(e,t="",s=o.q.LastCreatedScene,i=!0,r=0,n=null,a=null,l=null,c=null,u=null,d="",_={}){if(!s)return void h.V.Error("No scene available to load animations to");if(i){for(const e of s.animatables)e.reset();s.stopAllAnimations(),s.animationGroups.slice().forEach((e=>{e.dispose()})),s.getNodes().forEach((e=>{e.animations&&(e.animations=[])}))}else switch(r){case 0:s.animationGroups.slice().forEach((e=>{e.dispose()}));break;case 1:s.animationGroups.forEach((e=>{e.stop()}));break;case 2:s.animationGroups.forEach((e=>{e.reset(),e.restart()}));break;case 3:break;default:return void h.V.Error("Unknown animation group loading mode value '"+r+"'")}const f=s.animatables.length;v(e,t,s,(e=>{e.mergeAnimationsTo(s,s.animatables.slice(f),n),e.dispose(),s.onAnimationFileImportedObservable.notifyObservers(s),a&&a(s)}),l,c,u,d,_)}class D{static get ForceFullSceneLoadingForIncremental(){return l.B.ForceFullSceneLoadingForIncremental}static set ForceFullSceneLoadingForIncremental(e){l.B.ForceFullSceneLoadingForIncremental=e}static get ShowLoadingScreen(){return l.B.ShowLoadingScreen}static set ShowLoadingScreen(e){l.B.ShowLoadingScreen=e}static get loggingLevel(){return l.B.loggingLevel}static set loggingLevel(e){l.B.loggingLevel=e}static get CleanBoneMatrixWeights(){return l.B.CleanBoneMatrixWeights}static set CleanBoneMatrixWeights(e){l.B.CleanBoneMatrixWeights=e}static GetDefaultPlugin(){return T()}static GetPluginForExtension(e){return b(e,!0)?.plugin}static IsPluginForExtensionAvailable(e){return function(e){return!!g[e]}(e)}static RegisterPlugin(e){R(e)}static ImportMesh(e,t,s,i,r,n,a,o,h){M(e,t,s,i,r,n,a,o,h)}static ImportMeshAsync(e,t,s,i,r,n,a){return function(e,t,s,i,r,n,a,o){return new Promise(((o,h)=>{M(e,t,s,i,((e,t,s,i,r,n,a,h)=>{o({meshes:e,particleSystems:t,skeletons:s,animationGroups:i,transformNodes:r,geometries:n,lights:a,spriteManagers:h})}),r,((e,t,s)=>{h(s||new Error(t))}),n,a,undefined)}))}(e,t,s,i,r,n,a)}static Load(e,t,s,i,r,n,a,o){y(e,t,s,i,r,n,a,o)}static LoadAsync(e,t,s,i,r,n){return function(e,t,s,i,r,n,a){return new Promise(((o,h)=>{y(e,t,s,(e=>{o(e)}),i,((e,t,s)=>{h(s||new Error(t))}),r,n,a)}))}(e,t,s,i,r,n)}static Append(e,t,s,i,r,n,a,o){P(e,t,s,i,r,n,a,o)}static AppendAsync(e,t,s,i,r,n){return function(e,t,s,i,r,n,a){return new Promise(((o,h)=>{P(e,t,s,(e=>{o(e)}),i,((e,t,s)=>{h(s||new Error(t))}),r,n,a)}))}(e,t,s,i,r,n)}static LoadAssetContainer(e,t,s,i,r,n,a,o){v(e,t,s,i,r,n,a,o)}static LoadAssetContainerAsync(e,t,s,i,r,n){return S(e,t,s,i,r,n)}static ImportAnimations(e,t,s,i,r,n,a,o,h,l,c){I(e,t,s,i,r,n,a,o,h,l,c)}static ImportAnimationsAsync(e,t,s,i,r,n,a,o,h,l,c){return function(e,t,s,i,r,n,a,o,h,l){return new Promise(((c,u)=>{I(e,t,s,i,r,n,(e=>{c(e)}),a,((e,t,s)=>{u(s||new Error(t))}),o,h,l)}))}(e,t,s,i,r,n,o,l,c)}}D.NO_LOGGING=0,D.MINIMAL_LOGGING=1,D.SUMMARY_LOGGING=2,D.DETAILED_LOGGING=3,D.OnPluginActivatedObservable=p},7597:(e,t,s)=>{s.d(t,{B:()=>i});class i{static get ForceFullSceneLoadingForIncremental(){return i._ForceFullSceneLoadingForIncremental}static set ForceFullSceneLoadingForIncremental(e){i._ForceFullSceneLoadingForIncremental=e}static get ShowLoadingScreen(){return i._ShowLoadingScreen}static set ShowLoadingScreen(e){i._ShowLoadingScreen=e}static get loggingLevel(){return i._LoggingLevel}static set loggingLevel(e){i._LoggingLevel=e}static get CleanBoneMatrixWeights(){return i._CleanBoneMatrixWeights}static set CleanBoneMatrixWeights(e){i._CleanBoneMatrixWeights=e}}i._ForceFullSceneLoadingForIncremental=!1,i._ShowLoadingScreen=!0,i._CleanBoneMatrixWeights=!1,i._LoggingLevel=0},994:(e,t,s)=>{s.r(t),s.d(t,{_DDSTextureLoader:()=>n});var i=s(4640),r=s(3537);class n{constructor(){this.supportCascades=!0}loadCubeData(e,t,s,n){const a=t.getEngine();let o,h=!1,l=1e3;if(Array.isArray(e))for(let s=0;s1)&&t.generateMipMaps,a._unpackFlipY(o.isCompressed),r.D.UploadDDSLevels(a,t,i,o,h,6,-1,s),o.isFourCC||1!==o.mipmapCount?l=o.mipmapCount-1:a.generateMipMapsForCubemap(t)}else{const n=e;o=r.D.GetDDSInfo(n),t.width=o.width,t.height=o.height,s&&(o.sphericalPolynomial=new i.Q),h=(o.isRGB||o.isLuminance||o.mipmapCount>1)&&t.generateMipMaps,a._unpackFlipY(o.isCompressed),r.D.UploadDDSLevels(a,t,n,o,h,6),o.isFourCC||1!==o.mipmapCount?l=o.mipmapCount-1:a.generateMipMapsForCubemap(t,!1)}a._setCubeMapTextureParams(t,h,l),t.isReady=!0,t.onLoadedObservable.notifyObservers(t),t.onLoadedObservable.clear(),n&&n({isDDS:!0,width:t.width,info:o,data:e,texture:t})}loadData(e,t,s){const i=r.D.GetDDSInfo(e),n=(i.isRGB||i.isLuminance||i.mipmapCount>1)&&t.generateMipMaps&&Math.max(i.width,i.height)>>i.mipmapCount-1==1;s(i.width,i.height,n,i.isFourCC,(()=>{r.D.UploadDDSLevels(t.getEngine(),t,e,i,n,1)}))}}},8454:(e,t,s)=>{s.d(t,{gT:()=>a});var i=s(1137);const r=new Map;function n(e,t){(function(e){return r.delete(e)})(e)&&i.V.Warn(`Extension with the name '${name}' already exists`),r.set(e,t)}function a(e,t){"image/ktx"!==t&&"image/ktx2"!==t||(e=".ktx"),r.has(e)||(e.endsWith(".dds")&&n(".dds",(()=>Promise.resolve().then(s.bind(s,994)).then((e=>new e._DDSTextureLoader)))),e.endsWith(".basis")&&n(".basis",(()=>s.e(692).then(s.bind(s,6692)).then((e=>new e._BasisTextureLoader)))),e.endsWith(".env")&&n(".env",(()=>s.e(834).then(s.bind(s,5834)).then((e=>new e._ENVTextureLoader)))),e.endsWith(".hdr")&&n(".hdr",(()=>s.e(608).then(s.bind(s,5608)).then((e=>new e._HDRTextureLoader)))),(e.endsWith(".ktx")||e.endsWith(".ktx2"))&&(n(".ktx",(()=>s.e(788).then(s.bind(s,788)).then((e=>new e._KTXTextureLoader)))),n(".ktx2",(()=>s.e(788).then(s.bind(s,788)).then((e=>new e._KTXTextureLoader))))),e.endsWith(".tga")&&n(".tga",(()=>Promise.resolve().then(s.bind(s,1318)).then((e=>new e._TGATextureLoader)))),e.endsWith(".exr")&&n(".exr",(()=>s.e(685).then(s.bind(s,8685)).then((e=>new e._ExrTextureLoader)))));const i=r.get(e);return i?Promise.resolve(i(t)):null}},1318:(e,t,s)=>{s.r(t),s.d(t,{_TGATextureLoader:()=>o});var i=s(1137);function r(e){let t=0;return{id_length:e[t++],colormap_type:e[t++],image_type:e[t++],colormap_index:e[t++]|e[t++]<<8,colormap_length:e[t++]|e[t++]<<8,colormap_size:e[t++],origin:[e[t++]|e[t++]<<8,e[t++]|e[t++]<<8],width:e[t++]|e[t++]<<8,height:e[t++]|e[t++]<<8,pixel_size:e[t++],flags:e[t++]}}function n(e,t){if(t.length<19)return void i.V.Error("Unable to load TGA file - Not enough data to contain header");let s=18;const n=r(t);if(n.id_length+s>t.length)return void i.V.Error("Unable to load TGA file - Not enough data");s+=n.id_length;let o,h=!1,l=!1,c=!1;switch(n.image_type){case 9:h=!0;case 1:l=!0;break;case 10:h=!0;case 2:break;case 11:h=!0;case 3:c=!0}const u=n.pixel_size>>3,d=n.width*n.height*u;let _,f,p,g,m,T,b;if(l&&(_=t.subarray(s,s+=n.colormap_length*(n.colormap_size>>3))),h){let e,i,r;o=new Uint8Array(d);let n=0;const a=new Uint8Array(u);for(;s>4){default:case 2:f=0,g=1,b=n.width,p=0,m=1,T=n.height;break;case 0:f=0,g=1,b=n.width,p=n.height-1,m=-1,T=-1;break;case 3:f=n.width-1,g=-1,b=-1,p=0,m=1,T=n.height;break;case 1:f=n.width-1,g=-1,b=-1,p=n.height-1,m=-1,T=-1}const E="_getImageData"+(c?"Grey":"")+n.pixel_size+"bits",x=a[E](n,_,o,p,m,T,f,g,b);e.getEngine()._uploadDataToTextureDirectly(e,x)}const a={GetTGAHeader:r,UploadContent:n,_getImageData8bits:function(e,t,s,i,r,n,a,o,h){const l=s,c=t,u=e.width,d=e.height;let _,f,p,g=0;const m=new Uint8Array(u*d*4);for(p=i;p!==n;p+=r)for(f=a;f!==h;f+=o,g++)_=l[g],m[4*(f+u*p)+3]=255,m[4*(f+u*p)+2]=c[3*_+0],m[4*(f+u*p)+1]=c[3*_+1],m[4*(f+u*p)+0]=c[3*_+2];return m},_getImageData16bits:function(e,t,s,i,r,n,a,o,h){const l=s,c=e.width,u=e.height;let d,_,f,p=0;const g=new Uint8Array(c*u*4);for(f=i;f!==n;f+=r)for(_=a;_!==h;_+=o,p+=2){d=l[p+0]+(l[p+1]<<8);const e=255*((31744&d)>>10)/31|0,t=255*((992&d)>>5)/31|0,s=255*(31&d)/31|0;g[4*(_+c*f)+0]=e,g[4*(_+c*f)+1]=t,g[4*(_+c*f)+2]=s,g[4*(_+c*f)+3]=32768&d?0:255}return g},_getImageData24bits:function(e,t,s,i,r,n,a,o,h){const l=s,c=e.width,u=e.height;let d,_,f=0;const p=new Uint8Array(c*u*4);for(_=i;_!==n;_+=r)for(d=a;d!==h;d+=o,f+=3)p[4*(d+c*_)+3]=255,p[4*(d+c*_)+2]=l[f+0],p[4*(d+c*_)+1]=l[f+1],p[4*(d+c*_)+0]=l[f+2];return p},_getImageData32bits:function(e,t,s,i,r,n,a,o,h){const l=s,c=e.width,u=e.height;let d,_,f=0;const p=new Uint8Array(c*u*4);for(_=i;_!==n;_+=r)for(d=a;d!==h;d+=o,f+=4)p[4*(d+c*_)+2]=l[f+0],p[4*(d+c*_)+1]=l[f+1],p[4*(d+c*_)+0]=l[f+2],p[4*(d+c*_)+3]=l[f+3];return p},_getImageDataGrey8bits:function(e,t,s,i,r,n,a,o,h){const l=s,c=e.width,u=e.height;let d,_,f,p=0;const g=new Uint8Array(c*u*4);for(f=i;f!==n;f+=r)for(_=a;_!==h;_+=o,p++)d=l[p],g[4*(_+c*f)+0]=d,g[4*(_+c*f)+1]=d,g[4*(_+c*f)+2]=d,g[4*(_+c*f)+3]=255;return g},_getImageDataGrey16bits:function(e,t,s,i,r,n,a,o,h){const l=s,c=e.width,u=e.height;let d,_,f=0;const p=new Uint8Array(c*u*4);for(_=i;_!==n;_+=r)for(d=a;d!==h;d+=o,f+=2)p[4*(d+c*_)+0]=l[f+0],p[4*(d+c*_)+1]=l[f+0],p[4*(d+c*_)+2]=l[f+0],p[4*(d+c*_)+3]=l[f+1];return p}};class o{constructor(){this.supportCascades=!1}loadCubeData(){throw".env not supported in Cube."}loadData(e,t,s){const i=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),a=r(i);s(a.width,a.height,t.generateMipMaps,!1,(()=>{n(t,i)}))}}},2667:(e,t,s)=>{s.d(t,{t:()=>d});var i=s(5524),r=s(9259),n=s(9848),a=s(9923),o=s(6315),h=s(8688),l=(s(655),s(521));class c{get wrapU(){return this._wrapU}set wrapU(e){this._wrapU=e}get wrapV(){return this._wrapV}set wrapV(e){this._wrapV=e}get coordinatesMode(){return 0}get isCube(){return!!this._texture&&this._texture.isCube}set isCube(e){this._texture&&(this._texture.isCube=e)}get is3D(){return!!this._texture&&this._texture.is3D}set is3D(e){this._texture&&(this._texture.is3D=e)}get is2DArray(){return!!this._texture&&this._texture.is2DArray}set is2DArray(e){this._texture&&(this._texture.is2DArray=e)}getClassName(){return"ThinTexture"}static _IsRenderTargetWrapper(e){return void 0!==e?.shareDepth}constructor(e){this._wrapU=1,this._wrapV=1,this.wrapR=1,this.anisotropicFilteringLevel=4,this.delayLoadState=0,this._texture=null,this._engine=null,this._cachedSize=l.o.Zero(),this._cachedBaseSize=l.o.Zero(),this._initialSamplingMode=2,this._texture=c._IsRenderTargetWrapper(e)?e.texture:e,this._texture&&(this._engine=this._texture.getEngine())}isReady(){return 4===this.delayLoadState?(this.delayLoad(),!1):!!this._texture&&this._texture.isReady}delayLoad(){}getInternalTexture(){return this._texture}getSize(){if(this._texture){if(this._texture.width)return this._cachedSize.width=this._texture.width,this._cachedSize.height=this._texture.height,this._cachedSize;if(this._texture._size)return this._cachedSize.width=this._texture._size,this._cachedSize.height=this._texture._size,this._cachedSize}return this._cachedSize}getBaseSize(){return this.isReady()&&this._texture?this._texture._size?(this._cachedBaseSize.width=this._texture._size,this._cachedBaseSize.height=this._texture._size,this._cachedBaseSize):(this._cachedBaseSize.width=this._texture.baseWidth,this._cachedBaseSize.height=this._texture.baseHeight,this._cachedBaseSize):(this._cachedBaseSize.width=0,this._cachedBaseSize.height=0,this._cachedBaseSize)}get samplingMode(){return this._texture?this._texture.samplingMode:this._initialSamplingMode}updateSamplingMode(e){this._texture&&this._engine&&this._engine.updateTextureSamplingMode(e,this._texture)}releaseInternalTexture(){this._texture&&(this._texture.dispose(),this._texture=null)}dispose(){this._texture&&(this.releaseInternalTexture(),this._engine=null)}}var u=s(6877);class d extends c{set hasAlpha(e){this._hasAlpha!==e&&(this._hasAlpha=e,this._scene&&this._scene.markAllMaterialsAsDirty(1,(e=>e.hasTexture(this))))}get hasAlpha(){return this._hasAlpha}set getAlphaFromRGB(e){this._getAlphaFromRGB!==e&&(this._getAlphaFromRGB=e,this._scene&&this._scene.markAllMaterialsAsDirty(1,(e=>e.hasTexture(this))))}get getAlphaFromRGB(){return this._getAlphaFromRGB}set coordinatesIndex(e){this._coordinatesIndex!==e&&(this._coordinatesIndex=e,this._scene&&this._scene.markAllMaterialsAsDirty(1,(e=>e.hasTexture(this))))}get coordinatesIndex(){return this._coordinatesIndex}set coordinatesMode(e){this._coordinatesMode!==e&&(this._coordinatesMode=e,this._scene&&this._scene.markAllMaterialsAsDirty(1,(e=>e.hasTexture(this))))}get coordinatesMode(){return this._coordinatesMode}get wrapU(){return this._wrapU}set wrapU(e){this._wrapU=e}get wrapV(){return this._wrapV}set wrapV(e){this._wrapV=e}get isCube(){return this._texture?this._texture.isCube:this._isCube}set isCube(e){this._texture?this._texture.isCube=e:this._isCube=e}get is3D(){return!!this._texture&&this._texture.is3D}set is3D(e){this._texture&&(this._texture.is3D=e)}get is2DArray(){return!!this._texture&&this._texture.is2DArray}set is2DArray(e){this._texture&&(this._texture.is2DArray=e)}get gammaSpace(){return this._texture?(null===this._texture._gammaSpace&&(this._texture._gammaSpace=this._gammaSpace),this._texture._gammaSpace&&!this._texture._useSRGBBuffer):this._gammaSpace}set gammaSpace(e){if(this._texture){if(this._texture._gammaSpace===e)return;this._texture._gammaSpace=e}else{if(this._gammaSpace===e)return;this._gammaSpace=e}this.getScene()?.markAllMaterialsAsDirty(1,(e=>e.hasTexture(this)))}get isRGBD(){return null!=this._texture&&this._texture._isRGBD}set isRGBD(e){e!==this.isRGBD&&(this._texture&&(this._texture._isRGBD=e),this.getScene()?.markAllMaterialsAsDirty(1,(e=>e.hasTexture(this))))}get noMipmap(){return!1}get lodGenerationOffset(){return this._texture?this._texture._lodGenerationOffset:0}set lodGenerationOffset(e){this._texture&&(this._texture._lodGenerationOffset=e)}get lodGenerationScale(){return this._texture?this._texture._lodGenerationScale:0}set lodGenerationScale(e){this._texture&&(this._texture._lodGenerationScale=e)}get linearSpecularLOD(){return!!this._texture&&this._texture._linearSpecularLOD}set linearSpecularLOD(e){this._texture&&(this._texture._linearSpecularLOD=e)}get irradianceTexture(){return this._texture?this._texture._irradianceTexture:null}set irradianceTexture(e){this._texture&&(this._texture._irradianceTexture=e)}get uid(){return this._uid||(this._uid=(0,h.z)()),this._uid}toString(){return this.name}getClassName(){return"BaseTexture"}set onDispose(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)}get isBlocking(){return!0}get loadingError(){return this._loadingError}get errorObject(){return this._errorObject}constructor(e,t=null){super(null),this.metadata=null,this.reservedDataStore=null,this._hasAlpha=!1,this._getAlphaFromRGB=!1,this.level=1,this._coordinatesIndex=0,this.optimizeUVAllocation=!0,this._coordinatesMode=0,this.wrapR=1,this.anisotropicFilteringLevel=d.DEFAULT_ANISOTROPIC_FILTERING_LEVEL,this._isCube=!1,this._gammaSpace=!0,this.invertZ=!1,this.lodLevelInAlpha=!1,this.isRenderTarget=!1,this._prefiltered=!1,this._forceSerialize=!1,this.animations=[],this.onDisposeObservable=new n.cP,this._onDisposeObserver=null,this._scene=null,this._uid=null,this._parentContainer=null,this._loadingError=!1,e?d._IsScene(e)?this._scene=e:this._engine=e:this._scene=o.q.LastCreatedScene,this._scene&&(this.uniqueId=this._scene.getUniqueId(),this._scene.addTexture(this),this._engine=this._scene.getEngine()),this._texture=t,this._uid=null}getScene(){return this._scene}_getEngine(){return this._engine}getTextureMatrix(){return a.uq.IdentityReadOnly}getReflectionTextureMatrix(){return a.uq.IdentityReadOnly}getRefractionTextureMatrix(){return this.getReflectionTextureMatrix()}isReadyOrNotBlocking(){return!this.isBlocking||this.isReady()||this.loadingError}scale(e){}get canRescale(){return!1}_getFromCache(e,t,s,i,r,n){const a=this._getEngine();if(!a)return null;const o=a._getUseSRGBBuffer(!!r,t),h=a.getLoadedTexturesCache();for(let a=0;a=0&&this._scene.textures.splice(e,1),this._scene.onTextureRemovedObservable.notifyObservers(this),this._scene=null,this._parentContainer){const e=this._parentContainer.textures.indexOf(this);e>-1&&this._parentContainer.textures.splice(e,1),this._parentContainer=null}}this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.metadata=null,super.dispose()}serialize(e=!1){if(!this.name&&!e)return null;const t=u.p.Serialize(this);return u.p.AppendSerializedAnimations(this,t),t}static WhenAllReady(e,t){let s=e.length;if(0!==s)for(let i=0;i{0==--s&&t()})):0==--s&&t()}}else t()}static _IsScene(e){return"Scene"===e.getClassName()}}d.DEFAULT_ANISOTROPIC_FILTERING_LEVEL=4,(0,i.Cg)([(0,r.lK)()],d.prototype,"uniqueId",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"name",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"displayName",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"metadata",void 0),(0,i.Cg)([(0,r.lK)("hasAlpha")],d.prototype,"_hasAlpha",void 0),(0,i.Cg)([(0,r.lK)("getAlphaFromRGB")],d.prototype,"_getAlphaFromRGB",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"level",void 0),(0,i.Cg)([(0,r.lK)("coordinatesIndex")],d.prototype,"_coordinatesIndex",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"optimizeUVAllocation",void 0),(0,i.Cg)([(0,r.lK)("coordinatesMode")],d.prototype,"_coordinatesMode",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"wrapU",null),(0,i.Cg)([(0,r.lK)()],d.prototype,"wrapV",null),(0,i.Cg)([(0,r.lK)()],d.prototype,"wrapR",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"anisotropicFilteringLevel",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"isCube",null),(0,i.Cg)([(0,r.lK)()],d.prototype,"is3D",null),(0,i.Cg)([(0,r.lK)()],d.prototype,"is2DArray",null),(0,i.Cg)([(0,r.lK)()],d.prototype,"gammaSpace",null),(0,i.Cg)([(0,r.lK)()],d.prototype,"invertZ",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"lodLevelInAlpha",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"lodGenerationOffset",null),(0,i.Cg)([(0,r.lK)()],d.prototype,"lodGenerationScale",null),(0,i.Cg)([(0,r.lK)()],d.prototype,"linearSpecularLOD",null),(0,i.Cg)([(0,r.uM)()],d.prototype,"irradianceTexture",null),(0,i.Cg)([(0,r.lK)()],d.prototype,"isRenderTarget",void 0)},854:(e,t,s)=>{s.d(t,{h:()=>a});var i,r=s(9848);class n{get wrapU(){return this._cachedWrapU}set wrapU(e){this._cachedWrapU=e}get wrapV(){return this._cachedWrapV}set wrapV(e){this._cachedWrapV=e}get wrapR(){return this._cachedWrapR}set wrapR(e){this._cachedWrapR=e}get anisotropicFilteringLevel(){return this._cachedAnisotropicFilteringLevel}set anisotropicFilteringLevel(e){this._cachedAnisotropicFilteringLevel=e}get comparisonFunction(){return this._comparisonFunction}set comparisonFunction(e){this._comparisonFunction=e}get useMipMaps(){return this._useMipMaps}set useMipMaps(e){this._useMipMaps=e}constructor(){this.samplingMode=-1,this._useMipMaps=!0,this._cachedWrapU=null,this._cachedWrapV=null,this._cachedWrapR=null,this._cachedAnisotropicFilteringLevel=null,this._comparisonFunction=0}setParameters(e=1,t=1,s=1,i=1,r=2,n=0){return this._cachedWrapU=e,this._cachedWrapV=t,this._cachedWrapR=s,this._cachedAnisotropicFilteringLevel=i,this.samplingMode=r,this._comparisonFunction=n,this}compareSampler(e){return this._cachedWrapU===e._cachedWrapU&&this._cachedWrapV===e._cachedWrapV&&this._cachedWrapR===e._cachedWrapR&&this._cachedAnisotropicFilteringLevel===e._cachedAnisotropicFilteringLevel&&this.samplingMode===e.samplingMode&&this._comparisonFunction===e._comparisonFunction&&this._useMipMaps===e._useMipMaps}}!function(e){e[e.Unknown=0]="Unknown",e[e.Url=1]="Url",e[e.Temp=2]="Temp",e[e.Raw=3]="Raw",e[e.Dynamic=4]="Dynamic",e[e.RenderTarget=5]="RenderTarget",e[e.MultiRenderTarget=6]="MultiRenderTarget",e[e.Cube=7]="Cube",e[e.CubeRaw=8]="CubeRaw",e[e.CubePrefiltered=9]="CubePrefiltered",e[e.Raw3D=10]="Raw3D",e[e.Raw2DArray=11]="Raw2DArray",e[e.DepthStencil=12]="DepthStencil",e[e.CubeRawRGBD=13]="CubeRawRGBD",e[e.Depth=14]="Depth"}(i||(i={}));class a extends n{get useMipMaps(){return this.generateMipMaps}set useMipMaps(e){this.generateMipMaps=e}get uniqueId(){return this._uniqueId}_setUniqueId(e){this._uniqueId=e}getEngine(){return this._engine}get source(){return this._source}constructor(e,t,s=!1){super(),this.isReady=!1,this.isCube=!1,this.is3D=!1,this.is2DArray=!1,this.isMultiview=!1,this.url="",this.generateMipMaps=!1,this.samples=0,this.type=-1,this.format=-1,this.onLoadedObservable=new r.cP,this.onErrorObservable=new r.cP,this.onRebuildCallback=null,this.width=0,this.height=0,this.depth=0,this.baseWidth=0,this.baseHeight=0,this.baseDepth=0,this.invertY=!1,this._invertVScale=!1,this._associatedChannel=-1,this._source=0,this._buffer=null,this._bufferView=null,this._bufferViewArray=null,this._bufferViewArrayArray=null,this._size=0,this._extension="",this._files=null,this._workingCanvas=null,this._workingContext=null,this._cachedCoordinatesMode=null,this._isDisabled=!1,this._compression=null,this._sphericalPolynomial=null,this._sphericalPolynomialPromise=null,this._sphericalPolynomialComputed=!1,this._lodGenerationScale=0,this._lodGenerationOffset=0,this._useSRGBBuffer=!1,this._creationFlags=0,this._lodTextureHigh=null,this._lodTextureMid=null,this._lodTextureLow=null,this._isRGBD=!1,this._linearSpecularLOD=!1,this._irradianceTexture=null,this._hardwareTexture=null,this._maxLodLevel=null,this._references=1,this._gammaSpace=null,this._premulAlpha=!1,this._dynamicTextureSource=null,this._engine=e,this._source=t,this._uniqueId=a._Counter++,s||(this._hardwareTexture=e._createHardwareTexture())}incrementReferences(){this._references++}updateSize(e,t,s=1){this._engine.updateTextureDimensions(this,e,t,s),this.width=e,this.height=t,this.depth=s,this.baseWidth=e,this.baseHeight=t,this.baseDepth=s,this._size=e*t*s}_rebuild(){if(this.isReady=!1,this._cachedCoordinatesMode=null,this._cachedWrapU=null,this._cachedWrapV=null,this._cachedWrapR=null,this._cachedAnisotropicFilteringLevel=null,this.onRebuildCallback){const e=this.onRebuildCallback(this),t=t=>{t._swapAndDie(this,!1),this.isReady=e.isReady};return void(e.isAsync?e.proxy.then(t):t(e.proxy))}let e;switch(this.source){case 2:case 12:case 14:break;case 1:return void(e=this._engine.createTexture(this._originalUrl??this.url,!this.generateMipMaps,this.invertY,null,this.samplingMode,(e=>{e._swapAndDie(this,!1),this.isReady=!0}),null,this._buffer,void 0,this.format,this._extension,void 0,void 0,void 0,this._useSRGBBuffer));case 3:e=this._engine.createRawTexture(this._bufferView,this.baseWidth,this.baseHeight,this.format,this.generateMipMaps,this.invertY,this.samplingMode,this._compression,this.type,this._creationFlags,this._useSRGBBuffer),e._swapAndDie(this,!1),this.isReady=!0;break;case 10:e=this._engine.createRawTexture3D(this._bufferView,this.baseWidth,this.baseHeight,this.baseDepth,this.format,this.generateMipMaps,this.invertY,this.samplingMode,this._compression,this.type),e._swapAndDie(this,!1),this.isReady=!0;break;case 11:e=this._engine.createRawTexture2DArray(this._bufferView,this.baseWidth,this.baseHeight,this.baseDepth,this.format,this.generateMipMaps,this.invertY,this.samplingMode,this._compression,this.type),e._swapAndDie(this,!1),this.isReady=!0;break;case 4:e=this._engine.createDynamicTexture(this.baseWidth,this.baseHeight,this.generateMipMaps,this.samplingMode),e._swapAndDie(this,!1),this._dynamicTextureSource&&this._engine.updateDynamicTexture(this,this._dynamicTextureSource,this.invertY,this._premulAlpha,this.format,!0);break;case 7:return void(e=this._engine.createCubeTexture(this.url,null,this._files,!this.generateMipMaps,(()=>{e._swapAndDie(this,!1),this.isReady=!0}),null,this.format,this._extension,!1,0,0,null,void 0,this._useSRGBBuffer,ArrayBuffer.isView(this._buffer)?this._buffer:null));case 8:e=this._engine.createRawCubeTexture(this._bufferViewArray,this.width,this._originalFormat??this.format,this.type,this.generateMipMaps,this.invertY,this.samplingMode,this._compression),e._swapAndDie(this,!1),this.isReady=!0;break;case 13:return;case 9:return e=this._engine.createPrefilteredCubeTexture(this.url,null,this._lodGenerationScale,this._lodGenerationOffset,(e=>{e&&e._swapAndDie(this,!1),this.isReady=!0}),null,this.format,this._extension),void(e._sphericalPolynomial=this._sphericalPolynomial)}}_swapAndDie(e,t=!0){this._hardwareTexture?.setUsage(e._source,this.generateMipMaps,this.is2DArray,this.isCube,this.is3D,this.width,this.height,this.depth),e._hardwareTexture=this._hardwareTexture,t&&(e._isRGBD=this._isRGBD),this._lodTextureHigh&&(e._lodTextureHigh&&e._lodTextureHigh.dispose(),e._lodTextureHigh=this._lodTextureHigh),this._lodTextureMid&&(e._lodTextureMid&&e._lodTextureMid.dispose(),e._lodTextureMid=this._lodTextureMid),this._lodTextureLow&&(e._lodTextureLow&&e._lodTextureLow.dispose(),e._lodTextureLow=this._lodTextureLow),this._irradianceTexture&&(e._irradianceTexture&&e._irradianceTexture.dispose(),e._irradianceTexture=this._irradianceTexture);const s=this._engine.getLoadedTexturesCache();let i=s.indexOf(this);-1!==i&&s.splice(i,1),i=s.indexOf(e),-1===i&&s.push(e)}dispose(){this._references--,this.onLoadedObservable.clear(),this.onErrorObservable.clear(),0===this._references&&(this._engine._releaseTexture(this),this._hardwareTexture=null,this._dynamicTextureSource=null)}}a._Counter=0},6882:(e,t,s)=>{s.d(t,{$:()=>_});var i=s(9848),r=s(9923),n=s(2781),a=s(6096),o=s(1597),h=s(4420),l=s(1137),c=s(3099),u=s(7309);class d{get renderList(){return this._renderList}set renderList(e){this._renderList!==e&&(this._unObserveRenderList&&(this._unObserveRenderList(),this._unObserveRenderList=null),e&&(this._unObserveRenderList=(0,u.lL)(e,this._renderListHasChanged)),this._renderList=e)}get renderPassIds(){return this._renderPassIds}get currentRefreshId(){return this._currentRefreshId}setMaterialForRendering(e,t){let s;s=Array.isArray(e)?e:[e];for(let e=0;e{const s=this._renderList?this._renderList.length:0;(0===t&&s>0||0===s)&&this._scene.meshes.forEach((e=>{e._markSubMeshesAsLightDirty()}))},this.particleSystemList=null,this.getCustomRenderList=null,this.renderParticles=!0,this.renderSprites=!1,this.forceLayerMaskCheck=!1,this.onBeforeRenderObservable=new i.cP,this.onAfterRenderObservable=new i.cP,this.onBeforeRenderingManagerRenderObservable=new i.cP,this.onAfterRenderingManagerRenderObservable=new i.cP,this.onFastPathRenderObservable=new i.cP,this._currentRefreshId=-1,this._refreshRate=1,this._currentSceneCamera=null,this.name=e,this._scene=t,this.renderList=[],this._renderPassIds=[],this.options={numPasses:1,doNotChangeAspectRatio:!0,...s},this._createRenderPassId(),this.renderPassId=this._renderPassIds[0],this._renderingManager=new c.m(t),this._renderingManager._useSceneAutoClearSetup=!0}_releaseRenderPassId(){const e=this._scene.getEngine();for(let t=0;t1&&(e.incrementRenderId(),e.resetCachedMaterial())}const n=this.particleSystemList||e.particleSystems;for(const e of n)e.isReady()||(i=!1);return t.currentRenderPassId=s,i}_prepareRenderingManager(e,t,s){const i=this._scene,r=i.activeCamera;this._renderingManager.reset();const n=i.getRenderId();for(let a=0;a{for(const e of this._scene._beforeRenderTargetClearStage)e.action(this,this._currentFaceIndex,this._currentLayer);this.onClearObservable.hasObservers()?this.onClearObservable.notifyObservers(M):this.skipInitialClear||M.clear(this.clearColor||this._scene.clearColor,!0,!0,!0),this._doNotChangeAspectRatio||this._scene.updateTransformMatrix(!0);for(const e of this._scene._beforeRenderTargetDrawStage)e.action(this,this._currentFaceIndex,this._currentLayer)})),this._objectRenderer.onAfterRenderingManagerRenderObservable.add((()=>{for(const e of this._scene._afterRenderTargetDrawStage)e.action(this,this._currentFaceIndex,this._currentLayer);const e=this._texture?.generateMipMaps??!1;this._texture&&(this._texture.generateMipMaps=!1),this._postProcessManager?this._postProcessManager._finalizeFrame(!1,this._renderTarget??void 0,this._currentFaceIndex,this._postProcesses,this.ignoreCameraViewport):this._currentUseCameraPostProcess&&this._scene.postProcessManager._finalizeFrame(!1,this._renderTarget??void 0,this._currentFaceIndex);for(const e of this._scene._afterRenderTargetPostProcessStage)e.action(this,this._currentFaceIndex,this._currentLayer);this._texture&&(this._texture.generateMipMaps=e),this._doNotChangeAspectRatio||this._scene.updateTransformMatrix(!0),this._currentDumpForDebug&&(this._dumpTools?this._dumpTools.DumpFramebuffer(this.getRenderWidth(),this.getRenderHeight(),M):l.V.Error("dumpTools module is still being loaded. To speed up the process import dump tools directly in your project"))})),this._objectRenderer.onFastPathRenderObservable.add((()=>{this.onClearObservable.hasObservers()?this.onClearObservable.notifyObservers(M):this.skipInitialClear||M.clear(this.clearColor||this._scene.clearColor,!0,!0,!0)})),this._resizeObserver=M.onResizeObservable.add((()=>{})),this._generateMipMaps=!!a,this._doNotChangeAspectRatio=o,p||(this._renderTargetOptions={generateMipMaps:a,type:h,format:this._format??void 0,samplingMode:this.samplingMode,generateDepthBuffer:_,generateStencilBuffer:f,samples:T,creationFlags:b,noColorAttachment:E,useSRGBBuffer:x,colorAttachment:A,label:this.name},this.samplingMode===n.g.NEAREST_SAMPLINGMODE&&(this.wrapU=n.g.CLAMP_ADDRESSMODE,this.wrapV=n.g.CLAMP_ADDRESSMODE),m||(c?(this._renderTarget=s.getEngine().createRenderTargetCubeTexture(this.getRenderSize(),this._renderTargetOptions),this.coordinatesMode=n.g.INVCUBIC_MODE,this._textureMatrix=r.uq.Identity()):this._renderTarget=s.getEngine().createRenderTargetTexture(this._size,this._renderTargetOptions),this._texture=this._renderTarget.texture,void 0!==T&&(this.samples=T)))}createDepthStencilTexture(e=0,t=!0,s=!1,i=1,r=14,n){this._renderTarget?.createDepthStencilTexture(e,t,s,i,r,n)}_processSizeParameter(e){if(e.ratio){this._sizeRatio=e.ratio;const t=this._getEngine();this._size={width:this._bestReflectionRenderTargetDimension(t.getRenderWidth(),this._sizeRatio),height:this._bestReflectionRenderTargetDimension(t.getRenderHeight(),this._sizeRatio)}}else this._size=e}get samples(){return this._renderTarget?.samples??this._samples}set samples(e){this._renderTarget&&(this._samples=this._renderTarget.setSamples(e))}addPostProcess(e){if(!this._postProcessManager){const e=this.getScene();if(!e)return;this._postProcessManager=new a.X(e),this._postProcesses=new Array}this._postProcesses.push(e),this._postProcesses[0].autoClear=!1}clearPostProcesses(e=!1){if(this._postProcesses){if(e)for(const e of this._postProcesses)e.dispose();this._postProcesses=[]}}removePostProcess(e){if(!this._postProcesses)return;const t=this._postProcesses.indexOf(e);-1!==t&&(this._postProcesses.splice(t,1),this._postProcesses.length>0&&(this._postProcesses[0].autoClear=!1))}resetRefreshCounter(){this._objectRenderer.resetRefreshCounter()}get refreshRate(){return this._objectRenderer.refreshRate}set refreshRate(e){this._objectRenderer.refreshRate=e}_shouldRender(){return this._objectRenderer.shouldRender()}getRenderSize(){return this.getRenderWidth()}getRenderWidth(){return this._size.width?this._size.width:this._size}getRenderHeight(){return this._size.width?this._size.height:this._size}getRenderLayers(){const e=this._size.layers;if(e)return e;return this._size.depth||0}disableRescaling(){this._canRescale=!1}get canRescale(){return this._canRescale}scale(e){const t=Math.max(1,this.getRenderSize()*e);this.resize(t)}getReflectionTextureMatrix(){return this.isCube?this._textureMatrix:super.getReflectionTextureMatrix()}resize(e){const t=this.isCube;this._renderTarget?.dispose(),this._renderTarget=null;const s=this.getScene();s&&(this._processSizeParameter(e),this._renderTarget=t?s.getEngine().createRenderTargetCubeTexture(this.getRenderSize(),this._renderTargetOptions):s.getEngine().createRenderTargetTexture(this._size,this._renderTargetOptions),this._texture=this._renderTarget.texture,void 0!==this._renderTargetOptions.samples&&(this.samples=this._renderTargetOptions.samples),this.onResizeObservable.hasObservers()&&this.onResizeObservable.notifyObservers(this))}render(e=!1,t=!1){this._render(e,t)}isReadyForRendering(){this._dumpToolsLoading||(this._dumpToolsLoading=!0,s.e(928).then(s.bind(s,9928)).then((e=>this._dumpTools=e))),this._objectRenderer.prepareRenderList(),this.onBeforeBindObservable.notifyObservers(this),this._objectRenderer.initRender(this.getRenderWidth(),this.getRenderHeight());const e=this._objectRenderer._checkReadiness();return this.onAfterUnbindObservable.notifyObservers(this),this._objectRenderer.finishRender(),e}_render(e=!1,t=!1){const s=this.getScene();if(s){if(void 0!==this.useCameraPostProcesses&&(e=this.useCameraPostProcesses),this._objectRenderer.prepareRenderList(),this.onBeforeBindObservable.notifyObservers(this),this._objectRenderer.initRender(this.getRenderWidth(),this.getRenderHeight()),!this.is2DArray&&!this.is3D||this.isMulti)if(this.isCube&&!this.isMulti)for(let i=0;i<6;i++)this._renderToTarget(i,e,t),s.incrementRenderId(),s.resetCachedMaterial();else this._renderToTarget(0,e,t);else for(let i=0;i{this.onAfterRenderObservable.notifyObservers(t)}))}_prepareFrame(e,t,s,i){this._postProcessManager?this._prePassEnabled||this._postProcessManager._prepareFrame(this._texture,this._postProcesses):i&&e.postProcessManager._prepareFrame(this._texture)||this._bindFrameBuffer(t,s)}_renderToTarget(e,t,s,i=0){const r=this.getScene();if(!r)return;const n=r.getEngine();this._currentFaceIndex=e,this._currentLayer=i,this._currentUseCameraPostProcess=t,this._currentDumpForDebug=s,this._prepareFrame(r,e,i,t),n._debugPushGroup?.(`render to face #${e} layer #${i}`,2),this._objectRenderer.render(e+i,!0),n._debugPopGroup?.(2),this._unbindFrameBuffer(n,e),this._texture&&this.isCube&&5===e&&n.generateMipMapsForCubemap(this._texture,!0)}setRenderingOrder(e,t=null,s=null,i=null){this._objectRenderer.setRenderingOrder(e,t,s,i)}setRenderingAutoClearDepthStencil(e,t){this._objectRenderer.setRenderingAutoClearDepthStencil(e,t)}clone(){const e=this.getSize(),t=new _(this.name,e,this.getScene(),this._renderTargetOptions.generateMipMaps,this._doNotChangeAspectRatio,this._renderTargetOptions.type,this.isCube,this._renderTargetOptions.samplingMode,this._renderTargetOptions.generateDepthBuffer,this._renderTargetOptions.generateStencilBuffer,void 0,this._renderTargetOptions.format,void 0,this._renderTargetOptions.samples);return t.hasAlpha=this.hasAlpha,t.level=this.level,t.coordinatesMode=this.coordinatesMode,this.renderList&&(t.renderList=this.renderList.slice(0)),t}serialize(){if(!this.name)return null;const e=super.serialize();if(e.renderTargetSize=this.getRenderSize(),e.renderList=[],this.renderList)for(let t=0;t=0&&e.customRenderTargets.splice(t,1);for(const s of e.cameras)t=s.customRenderTargets.indexOf(this),t>=0&&s.customRenderTargets.splice(t,1);this._renderTarget?.dispose(),this._renderTarget=null,this._texture=null,super.dispose()}_rebuild(){this._objectRenderer._rebuild(),this._postProcessManager&&this._postProcessManager._rebuild()}freeRenderingGroups(){this._objectRenderer.freeRenderingGroups()}getViewCount(){return 1}}_.REFRESHRATE_RENDER_ONCE=d.REFRESHRATE_RENDER_ONCE,_.REFRESHRATE_RENDER_ONEVERYFRAME=d.REFRESHRATE_RENDER_ONEVERYFRAME,_.REFRESHRATE_RENDER_ONEVERYTWOFRAMES=d.REFRESHRATE_RENDER_ONEVERYTWOFRAMES,n.g._CreateRenderTargetTexture=(e,t,s,i,r)=>new _(e,t,s,i)},2781:(e,t,s)=>{s.d(t,{g:()=>m});var i=s(5524),r=s(9259),n=s(9848),a=s(9923),o=s(2667),h=s(6552),l=s(5503),c=s(2940),u=s(9337),d=s(4100),_=s(6181);function f(e,t,s=!1){const i=t.width,r=t.height;if(e instanceof Float32Array){let t=e.byteLength/e.BYTES_PER_ELEMENT;const s=new Uint8Array(t);for(;--t>=0;){let i=e[t];i<0?i=0:i>1&&(i=1),s[t]=255*i}e=s}const n=document.createElement("canvas");n.width=i,n.height=r;const a=n.getContext("2d");if(!a)return null;const o=a.createImageData(i,r);if(o.data.set(e),a.putImageData(o,0,0),s){const e=document.createElement("canvas");e.width=i,e.height=r;const t=e.getContext("2d");return t?(t.translate(0,r),t.scale(1,-1),t.drawImage(n,0,0),e.toDataURL("image/png")):null}return n.toDataURL("image/png")}var p=s(1313),g=s(6877);class m extends o.t{static _CreateVideoTexture(e,t,s,i=!1,r=!1,n=m.TRILINEAR_SAMPLINGMODE,a={},o,h=5){throw(0,l.n)("VideoTexture")}get noMipmap(){return this._noMipmap}get mimeType(){return this._mimeType}set isBlocking(e){this._isBlocking=e}get isBlocking(){return this._isBlocking}get invertY(){return this._invertY}constructor(e,t,s,i,r=m.TRILINEAR_SAMPLINGMODE,a=null,o=null,h=null,l=!1,u,d,_,f,g){let T;super(t),this.url=null,this.uOffset=0,this.vOffset=0,this.uScale=1,this.vScale=1,this.uAng=0,this.vAng=0,this.wAng=0,this.uRotationCenter=.5,this.vRotationCenter=.5,this.wRotationCenter=.5,this.homogeneousRotationInUVTransform=!1,this.inspectableCustomProperties=null,this._noMipmap=!1,this._invertY=!1,this._rowGenerationMatrix=null,this._cachedTextureMatrix=null,this._projectionModeMatrix=null,this._t0=null,this._t1=null,this._t2=null,this._cachedUOffset=-1,this._cachedVOffset=-1,this._cachedUScale=0,this._cachedVScale=0,this._cachedUAng=-1,this._cachedVAng=-1,this._cachedWAng=-1,this._cachedReflectionProjectionMatrixId=-1,this._cachedURotationCenter=-1,this._cachedVRotationCenter=-1,this._cachedWRotationCenter=-1,this._cachedHomogeneousRotationInUVTransform=!1,this._cachedIdentity3x2=!0,this._cachedReflectionTextureMatrix=null,this._cachedReflectionUOffset=-1,this._cachedReflectionVOffset=-1,this._cachedReflectionUScale=0,this._cachedReflectionVScale=0,this._cachedReflectionCoordinatesMode=-1,this._buffer=null,this._deleteBuffer=!1,this._format=null,this._delayedOnLoad=null,this._delayedOnError=null,this.onLoadObservable=new n.cP,this._isBlocking=!0,this.name=e||"",this.url=e;let b=!1,E=null,x=!0;"object"==typeof s&&null!==s?(T=s.noMipmap??!1,i=s.invertY??!p.rX,r=s.samplingMode??m.TRILINEAR_SAMPLINGMODE,a=s.onLoad??null,o=s.onError??null,h=s.buffer??null,l=s.deleteBuffer??!1,u=s.format,d=s.mimeType,_=s.loaderOptions,f=s.creationFlags,b=s.useSRGBBuffer??!1,E=s.internalTexture??null,x=s.gammaSpace??x,g=s.forcedExtension??g):T=!!s,this._gammaSpace=x,this._noMipmap=T,this._invertY=void 0===i?!p.rX:i,this._initialSamplingMode=r,this._buffer=h,this._deleteBuffer=l,this._mimeType=d,this._loaderOptions=_,this._creationFlags=f,this._useSRGBBuffer=b,this._forcedExtension=g,u&&(this._format=u);const A=this.getScene(),R=this._getEngine();if(!R)return;R.onBeforeTextureInitObservable.notifyObservers(this);const M=()=>{this._texture&&(this._texture._invertVScale&&(this.vScale*=-1,this.vOffset+=1),null!==this._texture._cachedWrapU&&(this.wrapU=this._texture._cachedWrapU,this._texture._cachedWrapU=null),null!==this._texture._cachedWrapV&&(this.wrapV=this._texture._cachedWrapV,this._texture._cachedWrapV=null),null!==this._texture._cachedWrapR&&(this.wrapR=this._texture._cachedWrapR,this._texture._cachedWrapR=null)),this.onLoadObservable.hasObservers()&&this.onLoadObservable.notifyObservers(this),a&&a(),!this.isBlocking&&A&&A.resetCachedMaterial()},y=(e,t)=>{this._loadingError=!0,this._errorObject={message:e,exception:t},o&&o(e,t),m.OnTextureLoadErrorObservable.notifyObservers(this)};if(!this.url&&!E)return this._delayedOnLoad=M,void(this._delayedOnError=y);if(this._texture=E??this._getFromCache(this.url,T,r,this._invertY,b,this.isCube),this._texture)if(this._texture.isReady)c._.SetImmediate((()=>M()));else{const e=this._texture.onLoadedObservable.add(M);this._texture.onErrorObservable.add((t=>{y(t.message,t.exception),this._texture?.onLoadedObservable.remove(e)}))}else if(A&&A.useDelayedTextureLoading)this.delayLoadState=4,this._delayedOnLoad=M,this._delayedOnError=y;else{try{this._texture=R.createTexture(this.url,T,this._invertY,A,r,M,y,this._buffer,void 0,this._format,this._forcedExtension,d,_,f,b)}catch(e){throw y("error loading",e),e}l&&(this._buffer=null)}}updateURL(e,t=null,s,i){this.url&&(this.releaseInternalTexture(),this.getScene().markAllMaterialsAsDirty(1,(e=>e.hasTexture(this)))),this.name&&!this.name.startsWith("data:")||(this.name=e),this.url=e,this._buffer=t,this._forcedExtension=i,this.delayLoadState=4,s&&(this._delayedOnLoad=s),this.delayLoad()}delayLoad(){if(4!==this.delayLoadState)return;const e=this.getScene();e&&(this.delayLoadState=1,this._texture=this._getFromCache(this.url,this._noMipmap,this.samplingMode,this._invertY,this._useSRGBBuffer,this.isCube),this._texture?this._delayedOnLoad&&(this._texture.isReady?c._.SetImmediate(this._delayedOnLoad):this._texture.onLoadedObservable.add(this._delayedOnLoad)):(this._texture=e.getEngine().createTexture(this.url,this._noMipmap,this._invertY,e,this.samplingMode,this._delayedOnLoad,this._delayedOnError,this._buffer,null,this._format,this._forcedExtension,this._mimeType,this._loaderOptions,this._creationFlags,this._useSRGBBuffer),this._deleteBuffer&&(this._buffer=null)),this._delayedOnLoad=null,this._delayedOnError=null)}_prepareRowForTextureGeneration(e,t,s,i){e*=this._cachedUScale,t*=this._cachedVScale,e-=this.uRotationCenter*this._cachedUScale,t-=this.vRotationCenter*this._cachedVScale,s-=this.wRotationCenter,a.Pq.TransformCoordinatesFromFloatsToRef(e,t,s,this._rowGenerationMatrix,i),i.x+=this.uRotationCenter*this._cachedUScale+this._cachedUOffset,i.y+=this.vRotationCenter*this._cachedVScale+this._cachedVOffset,i.z+=this.wRotationCenter}getTextureMatrix(e=1){if(this.uOffset===this._cachedUOffset&&this.vOffset===this._cachedVOffset&&this.uScale*e===this._cachedUScale&&this.vScale===this._cachedVScale&&this.uAng===this._cachedUAng&&this.vAng===this._cachedVAng&&this.wAng===this._cachedWAng&&this.uRotationCenter===this._cachedURotationCenter&&this.vRotationCenter===this._cachedVRotationCenter&&this.wRotationCenter===this._cachedWRotationCenter&&this.homogeneousRotationInUVTransform===this._cachedHomogeneousRotationInUVTransform)return this._cachedTextureMatrix;this._cachedUOffset=this.uOffset,this._cachedVOffset=this.vOffset,this._cachedUScale=this.uScale*e,this._cachedVScale=this.vScale,this._cachedUAng=this.uAng,this._cachedVAng=this.vAng,this._cachedWAng=this.wAng,this._cachedURotationCenter=this.uRotationCenter,this._cachedVRotationCenter=this.vRotationCenter,this._cachedWRotationCenter=this.wRotationCenter,this._cachedHomogeneousRotationInUVTransform=this.homogeneousRotationInUVTransform,this._cachedTextureMatrix&&this._rowGenerationMatrix||(this._cachedTextureMatrix=a.uq.Zero(),this._rowGenerationMatrix=new a.uq,this._t0=a.Pq.Zero(),this._t1=a.Pq.Zero(),this._t2=a.Pq.Zero()),a.uq.RotationYawPitchRollToRef(this.vAng,this.uAng,this.wAng,this._rowGenerationMatrix),this.homogeneousRotationInUVTransform?(a.uq.TranslationToRef(-this._cachedURotationCenter,-this._cachedVRotationCenter,-this._cachedWRotationCenter,a.AA.Matrix[0]),a.uq.TranslationToRef(this._cachedURotationCenter,this._cachedVRotationCenter,this._cachedWRotationCenter,a.AA.Matrix[1]),a.uq.ScalingToRef(this._cachedUScale,this._cachedVScale,0,a.AA.Matrix[2]),a.uq.TranslationToRef(this._cachedUOffset,this._cachedVOffset,0,a.AA.Matrix[3]),a.AA.Matrix[0].multiplyToRef(this._rowGenerationMatrix,this._cachedTextureMatrix),this._cachedTextureMatrix.multiplyToRef(a.AA.Matrix[1],this._cachedTextureMatrix),this._cachedTextureMatrix.multiplyToRef(a.AA.Matrix[2],this._cachedTextureMatrix),this._cachedTextureMatrix.multiplyToRef(a.AA.Matrix[3],this._cachedTextureMatrix),this._cachedTextureMatrix.setRowFromFloats(2,this._cachedTextureMatrix.m[12],this._cachedTextureMatrix.m[13],this._cachedTextureMatrix.m[14],1)):(this._prepareRowForTextureGeneration(0,0,0,this._t0),this._prepareRowForTextureGeneration(1,0,0,this._t1),this._prepareRowForTextureGeneration(0,1,0,this._t2),this._t1.subtractInPlace(this._t0),this._t2.subtractInPlace(this._t0),a.uq.FromValuesToRef(this._t1.x,this._t1.y,this._t1.z,0,this._t2.x,this._t2.y,this._t2.z,0,this._t0.x,this._t0.y,this._t0.z,0,0,0,0,1,this._cachedTextureMatrix));const t=this.getScene();if(!t)return this._cachedTextureMatrix;const s=this._cachedIdentity3x2;return this._cachedIdentity3x2=this._cachedTextureMatrix.isIdentityAs3x2(),this.optimizeUVAllocation&&s!==this._cachedIdentity3x2&&t.markAllMaterialsAsDirty(1,(e=>e.hasTexture(this))),this._cachedTextureMatrix}getReflectionTextureMatrix(){const e=this.getScene();if(!e)return this._cachedReflectionTextureMatrix;if(this.uOffset===this._cachedReflectionUOffset&&this.vOffset===this._cachedReflectionVOffset&&this.uScale===this._cachedReflectionUScale&&this.vScale===this._cachedReflectionVScale&&this.coordinatesMode===this._cachedReflectionCoordinatesMode){if(this.coordinatesMode!==m.PROJECTION_MODE)return this._cachedReflectionTextureMatrix;if(this._cachedReflectionProjectionMatrixId===e.getProjectionMatrix().updateFlag)return this._cachedReflectionTextureMatrix}this._cachedReflectionTextureMatrix||(this._cachedReflectionTextureMatrix=a.uq.Zero()),this._projectionModeMatrix||(this._projectionModeMatrix=a.uq.Zero());const t=this._cachedReflectionCoordinatesMode!==this.coordinatesMode;switch(this._cachedReflectionUOffset=this.uOffset,this._cachedReflectionVOffset=this.vOffset,this._cachedReflectionUScale=this.uScale,this._cachedReflectionVScale=this.vScale,this._cachedReflectionCoordinatesMode=this.coordinatesMode,this.coordinatesMode){case m.PLANAR_MODE:a.uq.IdentityToRef(this._cachedReflectionTextureMatrix),this._cachedReflectionTextureMatrix[0]=this.uScale,this._cachedReflectionTextureMatrix[5]=this.vScale,this._cachedReflectionTextureMatrix[12]=this.uOffset,this._cachedReflectionTextureMatrix[13]=this.vOffset;break;case m.PROJECTION_MODE:{a.uq.FromValuesToRef(.5,0,0,0,0,-.5,0,0,0,0,0,0,.5,.5,1,1,this._projectionModeMatrix);const t=e.getProjectionMatrix();this._cachedReflectionProjectionMatrixId=t.updateFlag,t.multiplyToRef(this._projectionModeMatrix,this._cachedReflectionTextureMatrix);break}default:a.uq.IdentityToRef(this._cachedReflectionTextureMatrix)}return t&&e.markAllMaterialsAsDirty(1,(e=>e.hasTexture(this))),this._cachedReflectionTextureMatrix}clone(){const e={noMipmap:this._noMipmap,invertY:this._invertY,samplingMode:this.samplingMode,onLoad:void 0,onError:void 0,buffer:this._texture?this._texture._buffer:void 0,deleteBuffer:this._deleteBuffer,format:this.textureFormat,mimeType:this.mimeType,loaderOptions:this._loaderOptions,creationFlags:this._creationFlags,useSRGBBuffer:this._useSRGBBuffer};return g.p.Clone((()=>new m(this._texture?this._texture.url:null,this.getScene(),e)),this)}serialize(){const e=this.name;m.SerializeBuffers||this.name.startsWith("data:")&&(this.name=""),this.name.startsWith("data:")&&this.url===this.name&&(this.url="");const t=super.serialize(m._SerializeInternalTextureUniqueId);return t?((m.SerializeBuffers||m.ForceSerializeBuffers)&&("string"==typeof this._buffer&&"data:"===this._buffer.substring(0,5)?(t.base64String=this._buffer,t.name=t.name.replace("data:","")):this.url&&this.url.startsWith("data:")&&this._buffer instanceof Uint8Array?t.base64String="data:image/png;base64,"+(0,_.EL)(this._buffer):(m.ForceSerializeBuffers||this.url&&this.url.startsWith("blob:")||this._forceSerialize)&&(t.base64String=!this._engine||this._engine._features.supportSyncTextureRead?function(e,t=0,s=0){const i=e.getInternalTexture();if(!i)return null;const r=e._readPixelsSync(t,s);return r?f(r,e.getSize(),i.invertY):null}(this):async function(e,t=0,s=0){const i=e.getInternalTexture();if(!i)return null;const r=await e.readPixels(t,s);return r?f(r,e.getSize(),i.invertY):null}(this))),t.invertY=this._invertY,t.samplingMode=this.samplingMode,t._creationFlags=this._creationFlags,t._useSRGBBuffer=this._useSRGBBuffer,m._SerializeInternalTextureUniqueId&&(t.internalTextureUniqueId=this._texture?.uniqueId),t.internalTextureLabel=this._texture?.label,t.noMipmap=this._noMipmap,this.name=e,t):null}getClassName(){return"Texture"}dispose(){super.dispose(),this.onLoadObservable.clear(),this._delayedOnLoad=null,this._delayedOnError=null,this._buffer=null}static Parse(e,t,s){if(e.customType){const i=u.n.Instantiate(e.customType).Parse(e,t,s);return e.samplingMode&&i.updateSamplingMode&&i._samplingMode&&i._samplingMode!==e.samplingMode&&i.updateSamplingMode(e.samplingMode),i}if(e.isCube&&!e.isRenderTarget)return m._CubeTextureParser(e,t,s);const i=void 0!==e.internalTextureUniqueId;if(!e.name&&!e.isRenderTarget&&!i)return null;let r;if(i){const s=t.getEngine().getLoadedTexturesCache();for(const t of s)if(t.uniqueId===e.internalTextureUniqueId){r=t;break}}const n=t=>{if(t&&t._texture&&(t._texture._cachedWrapU=null,t._texture._cachedWrapV=null,t._texture._cachedWrapR=null),e.samplingMode){const s=e.samplingMode;t&&t.samplingMode!==s&&t.updateSamplingMode(s)}if(t&&e.animations)for(let s=0;s{let i=!0;if(e.noMipmap&&(i=!1),e.mirrorPlane){const s=m._CreateMirror(e.name,e.renderTargetSize,t,i);return s._waitingRenderList=e.renderList,s.mirrorPlane=d.Z.FromArray(e.mirrorPlane),n(s),s}if(e.isRenderTarget){let s=null;if(e.isCube){if(t.reflectionProbes)for(let s=0;s{n(a)}),e._creationFlags??0,e._useSRGBBuffer??!1),a.name=e.name;else{let o;o=e.name&&(e.name.indexOf("://")>0||e.name.startsWith("data:"))?e.name:s+e.name,e.url&&(e.url.startsWith("data:")||m.UseSerializedUrlIfAny)&&(o=e.url);const h={noMipmap:!i,invertY:e.invertY,samplingMode:e.samplingMode,onLoad:()=>{n(a)},internalTexture:r};a=new m(o,t,h)}return a}}),e,t)}static CreateFromBase64String(e,t,s,i,r,n=m.TRILINEAR_SAMPLINGMODE,a=null,o=null,h=5,l,c){return new m("data:"+t,s,i,r,n,a,o,e,!1,h,void 0,void 0,l,c)}static LoadFromDataString(e,t,s,i=!1,r,n=!0,a=m.TRILINEAR_SAMPLINGMODE,o=null,h=null,l=5,c,u){return"data:"!==e.substring(0,5)&&(e="data:"+e),new m(e,s,r,n,a,o,h,t,i,l,void 0,void 0,c,u)}}m.SerializeBuffers=!0,m.ForceSerializeBuffers=!1,m.OnTextureLoadErrorObservable=new n.cP,m._SerializeInternalTextureUniqueId=!1,m._CubeTextureParser=(e,t,s)=>{throw(0,l.n)("CubeTexture")},m._CreateMirror=(e,t,s,i)=>{throw(0,l.n)("MirrorTexture")},m._CreateRenderTargetTexture=(e,t,s,i,r)=>{throw(0,l.n)("RenderTargetTexture")},m.NEAREST_SAMPLINGMODE=1,m.NEAREST_NEAREST_MIPLINEAR=8,m.BILINEAR_SAMPLINGMODE=2,m.LINEAR_LINEAR_MIPNEAREST=11,m.TRILINEAR_SAMPLINGMODE=3,m.LINEAR_LINEAR_MIPLINEAR=3,m.NEAREST_NEAREST_MIPNEAREST=4,m.NEAREST_LINEAR_MIPNEAREST=5,m.NEAREST_LINEAR_MIPLINEAR=6,m.NEAREST_LINEAR=7,m.NEAREST_NEAREST=1,m.LINEAR_NEAREST_MIPNEAREST=9,m.LINEAR_NEAREST_MIPLINEAR=10,m.LINEAR_LINEAR=2,m.LINEAR_NEAREST=12,m.EXPLICIT_MODE=0,m.SPHERICAL_MODE=1,m.PLANAR_MODE=2,m.CUBIC_MODE=3,m.PROJECTION_MODE=4,m.SKYBOX_MODE=5,m.INVCUBIC_MODE=6,m.EQUIRECTANGULAR_MODE=7,m.FIXED_EQUIRECTANGULAR_MODE=8,m.FIXED_EQUIRECTANGULAR_MIRRORED_MODE=9,m.CLAMP_ADDRESSMODE=0,m.WRAP_ADDRESSMODE=1,m.MIRROR_ADDRESSMODE=2,m.UseSerializedUrlIfAny=!1,(0,i.Cg)([(0,r.lK)()],m.prototype,"url",void 0),(0,i.Cg)([(0,r.lK)()],m.prototype,"uOffset",void 0),(0,i.Cg)([(0,r.lK)()],m.prototype,"vOffset",void 0),(0,i.Cg)([(0,r.lK)()],m.prototype,"uScale",void 0),(0,i.Cg)([(0,r.lK)()],m.prototype,"vScale",void 0),(0,i.Cg)([(0,r.lK)()],m.prototype,"uAng",void 0),(0,i.Cg)([(0,r.lK)()],m.prototype,"vAng",void 0),(0,i.Cg)([(0,r.lK)()],m.prototype,"wAng",void 0),(0,i.Cg)([(0,r.lK)()],m.prototype,"uRotationCenter",void 0),(0,i.Cg)([(0,r.lK)()],m.prototype,"vRotationCenter",void 0),(0,i.Cg)([(0,r.lK)()],m.prototype,"wRotationCenter",void 0),(0,i.Cg)([(0,r.lK)()],m.prototype,"homogeneousRotationInUVTransform",void 0),(0,i.Cg)([(0,r.lK)()],m.prototype,"isBlocking",null),(0,h.Y5)("BABYLON.Texture",m),g.p._TextureParser=m.Parse},492:(e,t,s)=>{function i(e){-1===e.indexOf("vClipPlane")&&e.push("vClipPlane"),-1===e.indexOf("vClipPlane2")&&e.push("vClipPlane2"),-1===e.indexOf("vClipPlane3")&&e.push("vClipPlane3"),-1===e.indexOf("vClipPlane4")&&e.push("vClipPlane4"),-1===e.indexOf("vClipPlane5")&&e.push("vClipPlane5"),-1===e.indexOf("vClipPlane6")&&e.push("vClipPlane6")}function r(e,t,s){const i=!!(e.clipPlane??t.clipPlane),r=!!(e.clipPlane2??t.clipPlane2),n=!!(e.clipPlane3??t.clipPlane3),a=!!(e.clipPlane4??t.clipPlane4),o=!!(e.clipPlane5??t.clipPlane5),h=!!(e.clipPlane6??t.clipPlane6);i&&s.push("#define CLIPPLANE"),r&&s.push("#define CLIPPLANE2"),n&&s.push("#define CLIPPLANE3"),a&&s.push("#define CLIPPLANE4"),o&&s.push("#define CLIPPLANE5"),h&&s.push("#define CLIPPLANE6")}function n(e,t,s){let i=!1;const r=!!(e.clipPlane??t.clipPlane),n=!!(e.clipPlane2??t.clipPlane2),a=!!(e.clipPlane3??t.clipPlane3),o=!!(e.clipPlane4??t.clipPlane4),h=!!(e.clipPlane5??t.clipPlane5),l=!!(e.clipPlane6??t.clipPlane6);return s.CLIPPLANE!==r&&(s.CLIPPLANE=r,i=!0),s.CLIPPLANE2!==n&&(s.CLIPPLANE2=n,i=!0),s.CLIPPLANE3!==a&&(s.CLIPPLANE3=a,i=!0),s.CLIPPLANE4!==o&&(s.CLIPPLANE4=o,i=!0),s.CLIPPLANE5!==h&&(s.CLIPPLANE5=h,i=!0),s.CLIPPLANE6!==l&&(s.CLIPPLANE6=l,i=!0),i}function a(e,t,s){let i=t.clipPlane??s.clipPlane;o(e,"vClipPlane",i),i=t.clipPlane2??s.clipPlane2,o(e,"vClipPlane2",i),i=t.clipPlane3??s.clipPlane3,o(e,"vClipPlane3",i),i=t.clipPlane4??s.clipPlane4,o(e,"vClipPlane4",i),i=t.clipPlane5??s.clipPlane5,o(e,"vClipPlane5",i),i=t.clipPlane6??s.clipPlane6,o(e,"vClipPlane6",i)}function o(e,t,s){s&&e.setFloat4(t,s.normal.x,s.normal.y,s.normal.z,s.d)}s.d(t,{Eq:()=>n,TV:()=>i,gS:()=>a,tv:()=>r})},5476:(e,t,s)=>{s.d(t,{E:()=>i});class i{static GetEffect(e){return void 0===e.getPipelineContext?e.effect:e}constructor(e,t=!0){this._wasPreviouslyReady=!1,this._forceRebindOnNextCall=!0,this._wasPreviouslyUsingInstances=null,this.effect=null,this.defines=null,this.drawContext=e.createDrawContext(),t&&(this.materialContext=e.createMaterialContext())}setEffect(e,t,s=!0){this.effect=e,void 0!==t&&(this.defines=t),s&&this.drawContext?.reset()}dispose(){this.drawContext?.dispose()}}},7647:(e,t,s)=>{s.d(t,{b4:()=>l,bu:()=>u,mO:()=>c,uR:()=>_});var i=s(8790),r=s(5852),n=s(9610),a=s(1137),o=s(9125),h=s(6741);function l(e,t){return(0,r.N5)(t).cachedPipelines[e]}function c(e){const t=e._name,s=e.context;if(t&&s){const e=(0,r.N5)(s),i=e.cachedPipelines[t];i?.dispose(),delete e.cachedPipelines[t]}}function u(e,t,s,r,n,a,h){let l,c;const u=(0,i.BA)()?a?.getHostDocument():null;l="string"==typeof t?t:t.vertexSource?"source:"+t.vertexSource:t.vertexElement?u?.getElementById(t.vertexElement)||t.vertexElement:t.vertex||t,c="string"==typeof t?t:t.fragmentSource?"source:"+t.fragmentSource:t.fragmentElement?u?.getElementById(t.fragmentElement)||t.fragmentElement:t.fragment||t;const _=[void 0,void 0],f=()=>{if(_[0]&&_[1]){e.isFragment=!0;const[i,l]=_;(0,o.M0)(l,e,((a,l)=>{h&&(h._fragmentSourceCodeBeforeMigration=l),s&&(a=s("fragment",a));const c=(0,o.nO)(i,a,e);e=null;const u=function(e,t,s,i){return s?{vertexSourceCode:(1===i?"//":"")+"#define SHADER_NAME vertex:"+(s.vertexElement||s.vertex||s.spectorName||s)+"\n"+e,fragmentSourceCode:(1===i?"//":"")+"#define SHADER_NAME fragment:"+(s.fragmentElement||s.fragment||s.spectorName||s)+"\n"+t}:{vertexSourceCode:e,fragmentSourceCode:t}}(c.vertexCode,c.fragmentCode,t,n);r?.(u.vertexSourceCode,u.fragmentSourceCode)}),a)}};d(l,"Vertex","",(t=>{(0,o.pB)(e),(0,o.M0)(t,e,((e,i)=>{h&&(h._rawVertexSourceCode=t,h._vertexSourceCodeBeforeMigration=i),s&&(e=s("vertex",e)),_[0]=e,f()}),a)}),n),d(c,"Fragment","Pixel",(e=>{h&&(h._rawFragmentSourceCode=e),_[1]=e,f()}),n)}function d(e,t,s,r,a,o){if("undefined"!=typeof HTMLElement&&e instanceof HTMLElement)return void r((0,i.Zl)(e));if("source:"===e.substring(0,7))return void r(e.substring(7));if("base64:"===e.substring(0,7))return void r(window.atob(e.substring(7)));const l=n.l.GetShadersStore(a);if(l[e+t+"Shader"])return void r(l[e+t+"Shader"]);if(s&&l[e+s+"Shader"])return void r(l[e+s+"Shader"]);let c;if(c="."===e[0]||"/"===e[0]||e.indexOf("http")>-1?e:n.l.GetShadersRepository(a)+e,!(o=o||h.W0))throw new Error("loadFileInjection is not defined");o(c+"."+t.toLowerCase()+".fx",r)}const _=(e,t,s,i)=>{try{const n=e.existingPipelineContext||t(e.shaderProcessingContext);return n._name=e.name,e.name&&e.context&&((0,r.N5)(e.context).cachedPipelines[e.name]=n),s(n,e.vertex,e.fragment,!!e.createAsRaw,"","",e.rebuildRebind,e.defines,e.transformFeedbackVaryings,"",(()=>{i(n,(()=>{e.onRenderingStateCompiled?.(n)}))})),n}catch(e){throw a.V.Error("Error compiling effect"),e}}},4420:(e,t,s)=>{s.d(t,{M:()=>o});var i=s(9848),r=s(1137),n=s(9610),a=s(7647);class o{static get ShadersRepository(){return n.l.ShadersRepository}static set ShadersRepository(e){n.l.ShadersRepository=e}get onBindObservable(){return this._onBindObservable||(this._onBindObservable=new i.cP),this._onBindObservable}get shaderLanguage(){return this._shaderLanguage}constructor(e,t,s,r=null,n,h=null,l=null,c=null,u=null,d,_="",f=0,p){this.defines="",this.onCompiled=null,this.onError=null,this.onBind=null,this.uniqueId=0,this.onCompileObservable=new i.cP,this.onErrorObservable=new i.cP,this._onBindObservable=null,this._isDisposed=!1,this._refCount=1,this._bonesComputationForcedToCPU=!1,this._uniformBuffersNames={},this._multiTarget=!1,this._samplers={},this._isReady=!1,this._compilationError="",this._allFallbacksProcessed=!1,this._uniforms={},this._key="",this._fallbacks=null,this._vertexSourceCodeOverride="",this._fragmentSourceCodeOverride="",this._transformFeedbackVaryings=null,this._pipelineContext=null,this._vertexSourceCode="",this._fragmentSourceCode="",this._vertexSourceCodeBeforeMigration="",this._fragmentSourceCodeBeforeMigration="",this._rawVertexSourceCode="",this._rawFragmentSourceCode="",this._processCodeAfterIncludes=void 0,this._processFinalCode=null,this.name=e,this._key=_;const g=this._key.replace(/\r/g,"").replace(/\n/g,"|");let m;if(t.attributes){const e=t;if(this._engine=s,this._attributesNames=e.attributes,this._uniformsNames=e.uniformsNames.concat(e.samplers),this._samplerList=e.samplers.slice(),this.defines=e.defines,this.onError=e.onError,this.onCompiled=e.onCompiled,this._fallbacks=e.fallbacks,this._indexParameters=e.indexParameters,this._transformFeedbackVaryings=e.transformFeedbackVaryings||null,this._multiTarget=!!e.multiTarget,this._shaderLanguage=e.shaderLanguage??0,e.uniformBuffersNames){this._uniformBuffersNamesList=e.uniformBuffersNames.slice();for(let t=0;t{this._vertexSourceCode=e,this._fragmentSourceCode=s,this._prepareEffect(t)}),this._shaderLanguage,this._engine,this)}get key(){return this._key}isReady(){try{return this._isReadyInternal()}catch{return!1}}_isReadyInternal(){return!!this._engine.isDisposed||!!this._isReady||!!this._pipelineContext&&this._pipelineContext.isReady}getEngine(){return this._engine}getPipelineContext(){return this._pipelineContext}getAttributesNames(){return this._attributesNames}getAttributeLocation(e){return this._attributes[e]}getAttributeLocationByName(e){return this._attributeLocationByName[e]}getAttributesCount(){return this._attributes.length}getUniformIndex(e){return this._uniformsNames.indexOf(e)}getUniform(e){return this._uniforms[e]}getSamplers(){return this._samplerList}getUniformNames(){return this._uniformsNames}getUniformBuffersNames(){return this._uniformBuffersNamesList}getIndexParameters(){return this._indexParameters}getCompilationError(){return this._compilationError}allFallbacksProcessed(){return this._allFallbacksProcessed}executeWhenCompiled(e){this.isReady()?e(this):(this.onCompileObservable.add((t=>{e(t)})),this._pipelineContext&&!this._pipelineContext.isAsync||setTimeout((()=>{this._checkIsReady(null)}),16))}_checkIsReady(e){try{if(this._isReadyInternal())return}catch(t){return void this._processCompilationErrors(t,e)}this._isDisposed||setTimeout((()=>{this._checkIsReady(e)}),16)}get vertexSourceCode(){return this._vertexSourceCodeOverride&&this._fragmentSourceCodeOverride?this._vertexSourceCodeOverride:this._pipelineContext?._getVertexShaderCode()??this._vertexSourceCode}get fragmentSourceCode(){return this._vertexSourceCodeOverride&&this._fragmentSourceCodeOverride?this._fragmentSourceCodeOverride:this._pipelineContext?._getFragmentShaderCode()??this._fragmentSourceCode}get vertexSourceCodeBeforeMigration(){return this._vertexSourceCodeBeforeMigration}get fragmentSourceCodeBeforeMigration(){return this._fragmentSourceCodeBeforeMigration}get rawVertexSourceCode(){return this._rawVertexSourceCode}get rawFragmentSourceCode(){return this._rawFragmentSourceCode}getPipelineGenerationOptions(){return{platformName:this._engine.shaderPlatformName,shaderLanguage:this._shaderLanguage,shaderNameOrContent:this.name,key:this._key,defines:this.defines.split("\n"),addGlobalDefines:!1,extendedProcessingOptions:{indexParameters:this._indexParameters,isNDCHalfZRange:this._engine.isNDCHalfZRange,useReverseDepthBuffer:this._engine.useReverseDepthBuffer,supportsUniformBuffers:this._engine.supportsUniformBuffers},extendedCreatePipelineOptions:{transformFeedbackVaryings:this._transformFeedbackVaryings,createAsRaw:!(!this._vertexSourceCodeOverride||!this._fragmentSourceCodeOverride)}}}_rebuildProgram(e,t,s,i){this._isReady=!1,this._vertexSourceCodeOverride=e,this._fragmentSourceCodeOverride=t,this.onError=(e,t)=>{i&&i(t)},this.onCompiled=()=>{const e=this.getEngine().scenes;if(e)for(let t=0;tthis._rebuildProgram(e,t,s,i),defines:i,transformFeedbackVaryings:this._transformFeedbackVaryings,name:this._key.replace(/\r/g,"").replace(/\n/g,"|"),createAsRaw:s,parallelShaderCompile:o._caps.parallelShaderCompile,shaderProcessingContext:this._processingContext,onRenderingStateCompiled:s=>{t&&!e&&this._engine._deletePipelineContext(t),s&&this._onRenderingStateCompiled(s)}},this._engine.createPipelineContext.bind(this._engine),this._engine._preparePipelineContext.bind(this._engine),this._engine._executeWhenRenderingStateIsCompiled.bind(this._engine)),this._pipelineContext.isAsync&&this._checkIsReady(t)}catch(e){this._processCompilationErrors(e,t)}}_getShaderCodeAndErrorLine(e,t,s){const i=s?/FRAGMENT SHADER ERROR: 0:(\d+?):/:/VERTEX SHADER ERROR: 0:(\d+?):/;let r=null;if(t&&e){const n=t.match(i);if(n&&2===n.length){const t=parseInt(n[1]),i=e.split("\n",-1);i.length>=t&&(r=`Offending line [${t}] in ${s?"fragment":"vertex"} code: ${i[t-1]}`)}}return[e,r]}_processCompilationErrors(e,t=null){this._compilationError=e.message;const s=this._attributesNames,i=this._fallbacks;if(r.V.Error("Unable to compile effect:"),r.V.Error("Uniforms: "+this._uniformsNames.map((function(e){return" "+e}))),r.V.Error("Attributes: "+s.map((function(e){return" "+e}))),r.V.Error("Defines:\n"+this.defines),o.LogShaderCodeOnCompilationError){let e=null,t=null,s=null;this._pipelineContext?._getVertexShaderCode()&&([s,e]=this._getShaderCodeAndErrorLine(this._pipelineContext._getVertexShaderCode(),this._compilationError,!1),s&&(r.V.Error("Vertex code:"),r.V.Error(s))),this._pipelineContext?._getFragmentShaderCode()&&([s,t]=this._getShaderCodeAndErrorLine(this._pipelineContext?._getFragmentShaderCode(),this._compilationError,!0),s&&(r.V.Error("Fragment code:"),r.V.Error(s))),e&&r.V.Error(e),t&&r.V.Error(t)}r.V.Error("Error: "+this._compilationError);const n=()=>{this.onError&&this.onError(this,this._compilationError),this.onErrorObservable.notifyObservers(this)};t&&(this._pipelineContext=t,this._isReady=!0,n()),i?(this._pipelineContext=null,i.hasMoreFallbacks?(this._allFallbacksProcessed=!1,r.V.Error("Trying next fallback."),this.defines=i.reduce(this.defines,this),this._prepareEffect()):(this._allFallbacksProcessed=!0,n(),this.onErrorObservable.clear(),this._fallbacks&&this._fallbacks.unBindMesh())):(this._allFallbacksProcessed=!0,t||n())}get isSupported(){return""===this._compilationError}_bindTexture(e,t){this._engine._bindTexture(this._samplers[e],t,e)}setTexture(e,t){this._engine.setTexture(this._samplers[e],this._uniforms[e],t,e)}setTextureArray(e,t){const s=e+"Ex";if(-1===this._samplerList.indexOf(s+"0")){const i=this._samplerList.indexOf(e);for(let e=1;e0||(this._pipelineContext&&(0,a.mO)(this._pipelineContext),this._engine._releaseEffect(this),this.clearCodeCache(),this._isDisposed=!0)}static RegisterShader(e,t,s,i=0){t&&(n.l.GetShadersStore(i)[`${e}PixelShader`]=t),s&&(n.l.GetShadersStore(i)[`${e}VertexShader`]=s)}static ResetCache(){o._BaseCache={}}}o.LogShaderCodeOnCompilationError=!0,o.AutomaticallyClearCodeCache=!1,o._UniqueIdSeed=0,o._BaseCache={},o.ShadersStore=n.l.ShadersStore,o.IncludesShadersStore=n.l.IncludesShadersStore},2565:(e,t,s)=>{s.d(t,{J:()=>i});class i{constructor(){this._defines={},this._currentRank=32,this._maxRank=-1,this._mesh=null}unBindMesh(){this._mesh=null}addFallback(e,t){this._defines[e]||(ethis._maxRank&&(this._maxRank=e),this._defines[e]=new Array),this._defines[e].push(t)}addCPUSkinningFallback(e,t){this._mesh=t,ethis._maxRank&&(this._maxRank=e)}get hasMoreFallbacks(){return this._currentRank<=this._maxRank}reduce(e,t){if(this._mesh&&this._mesh.computeBonesUsingShaders&&this._mesh.numBoneInfluencers>0){this._mesh.computeBonesUsingShaders=!1,e=e.replace("#define NUM_BONE_INFLUENCERS "+this._mesh.numBoneInfluencers,"#define NUM_BONE_INFLUENCERS 0"),t._bonesComputationForcedToCPU=!0;const s=this._mesh.getScene();for(let e=0;e0&&(i.computeBonesUsingShaders=!1)}}else{const t=this._defines[this._currentRank];if(t)for(let s=0;s{s.d(t,{$:()=>c,J:()=>l});var i=s(5616),r=s(4494),n=s(9848),a=s(4420),o=s(5476);s(6612);const h={positions:[1,1,-1,1,-1,-1,1,-1],indices:[0,1,2,0,2,3]};class l{constructor(e,t=h){this._fullscreenViewport=new r.L(0,0,1,1);const s=t.positions??h.positions,n=t.indices??h.indices;this.engine=e,this._vertexBuffers={[i.R.PositionKind]:new i.R(e,s,i.R.PositionKind,!1,!1,2)},this._indexBuffer=e.createIndexBuffer(n),this._onContextRestoredObserver=e.onContextRestoredObservable.add((()=>{this._indexBuffer=e.createIndexBuffer(n);for(const e in this._vertexBuffers)this._vertexBuffers[e]._rebuild()}))}setViewport(e=this._fullscreenViewport){this.engine.setViewport(e)}bindBuffers(e){this.engine.bindBuffers(this._vertexBuffers,this._indexBuffer,e)}applyEffectWrapper(e){this.engine.setState(!0),this.engine.depthCullingState.depthTest=!1,this.engine.stencilState.stencilTest=!1,this.engine.enableEffect(e.drawWrapper),this.bindBuffers(e.effect),e.onApplyObservable.notifyObservers({})}saveStates(){this._savedStateDepthTest=this.engine.depthCullingState.depthTest,this._savedStateStencilTest=this.engine.stencilState.stencilTest}restoreStates(){this.engine.depthCullingState.depthTest=this._savedStateDepthTest,this.engine.stencilState.stencilTest=this._savedStateStencilTest}draw(){this.engine.drawElementsType(0,0,6)}_isRenderTargetTexture(e){return void 0!==e.renderTarget}render(e,t=null){if(!e.effect.isReady())return;this.saveStates(),this.setViewport();const s=null===t?null:this._isRenderTargetTexture(t)?t.renderTarget:t;s&&this.engine.bindFramebuffer(s),this.applyEffectWrapper(e),this.draw(),s&&this.engine.unBindFramebuffer(s),this.restoreStates()}dispose(){const e=this._vertexBuffers[i.R.PositionKind];e&&(e.dispose(),delete this._vertexBuffers[i.R.PositionKind]),this._indexBuffer&&this.engine._releaseBuffer(this._indexBuffer),this._onContextRestoredObserver&&(this.engine.onContextRestoredObservable.remove(this._onContextRestoredObserver),this._onContextRestoredObserver=null)}}class c{static RegisterShaderCodeProcessing(e,t){t?c._CustomShaderCodeProcessing[e??""]=t:delete c._CustomShaderCodeProcessing[e??""]}static _GetShaderCodeProcessing(e){return c._CustomShaderCodeProcessing[e]??c._CustomShaderCodeProcessing[""]}get name(){return this.options.name}set name(e){this.options.name=e}isReady(){return this._drawWrapper.effect?.isReady()??!1}get drawWrapper(){return this._drawWrapper}get effect(){return this._drawWrapper.effect}set effect(e){this._drawWrapper.effect=e}constructor(e){this.alphaMode=0,this.onEffectCreatedObservable=new n.cP(void 0,!0),this.onApplyObservable=new n.cP,this._shadersLoaded=!1,this._webGPUReady=!1,this._importPromises=[],this.options={...e,name:e.name||"effectWrapper",engine:e.engine,uniforms:e.uniforms||e.uniformNames||[],uniformNames:void 0,samplers:e.samplers||e.samplerNames||[],samplerNames:void 0,attributeNames:e.attributeNames||["position"],uniformBuffers:e.uniformBuffers||[],defines:e.defines||"",useShaderStore:e.useShaderStore||!1,vertexUrl:e.vertexUrl||e.vertexShader||"postprocess",vertexShader:void 0,fragmentShader:e.fragmentShader||"pass",indexParameters:e.indexParameters,blockCompilation:e.blockCompilation||!1,shaderLanguage:e.shaderLanguage||0,onCompiled:e.onCompiled||void 0,extraInitializations:e.extraInitializations||void 0,extraInitializationsAsync:e.extraInitializationsAsync||void 0,useAsPostProcess:e.useAsPostProcess??!1},this.options.uniformNames=this.options.uniforms,this.options.samplerNames=this.options.samplers,this.options.vertexShader=this.options.vertexUrl,this.options.useAsPostProcess&&(-1===this.options.samplers.indexOf("textureSampler")&&this.options.samplers.push("textureSampler"),-1===this.options.uniforms.indexOf("scale")&&this.options.uniforms.push("scale")),e.vertexUrl||e.vertexShader?this._shaderPath={vertexSource:this.options.vertexShader}:(this.options.useAsPostProcess||(this.options.uniforms.push("scale"),this.onApplyObservable.add((()=>{this.effect.setFloat2("scale",1,1)}))),this._shaderPath={vertex:this.options.vertexShader}),this._shaderPath.fragmentSource=this.options.fragmentShader,this._shaderPath.spectorName=this.options.name,this.options.useShaderStore&&(this._shaderPath.fragment=this._shaderPath.fragmentSource,this._shaderPath.vertex||(this._shaderPath.vertex=this._shaderPath.vertexSource),delete this._shaderPath.fragmentSource,delete this._shaderPath.vertexSource),this.onApplyObservable.add((()=>{this.bind()})),this.options.useShaderStore||(this._onContextRestoredObserver=this.options.engine.onContextRestoredObservable.add((()=>{this.effect._pipelineContext=null,this.effect._prepareEffect()}))),this._drawWrapper=new o.E(this.options.engine),this._webGPUReady=1===this.options.shaderLanguage;const t=Array.isArray(this.options.defines)?this.options.defines.join("\n"):this.options.defines;this._postConstructor(this.options.blockCompilation,t,this.options.extraInitializations)}_gatherImports(e=!1,t){this.options.useAsPostProcess&&(e&&this._webGPUReady?t.push(Promise.all([s.e(126).then(s.bind(s,2083))])):t.push(Promise.all([Promise.resolve().then(s.bind(s,6612))])))}_postConstructor(e,t=null,s,i){this._importPromises.length=0,i&&this._importPromises.push(...i);const r=this.options.engine.isWebGPU&&!c.ForceGLSL;this._gatherImports(r,this._importPromises),void 0!==s&&s(r,this._importPromises),r&&this._webGPUReady&&(this.options.shaderLanguage=1),e||this.updateEffect(t)}updateEffect(e=null,t=null,s=null,i,r,n,o,h){const l=c._GetShaderCodeProcessing(this.name);if(l?.defineCustomBindings){const i=t?.slice()??[];i.push(...this.options.uniforms);const r=s?.slice()??[];r.push(...this.options.samplers),e=l.defineCustomBindings(this.name,e,i,r),t=i,s=r}this.options.defines=e||"";const u=this._shadersLoaded||0===this._importPromises.length?void 0:async()=>{await Promise.all(this._importPromises),this._shadersLoaded=!0};let d;d=this.options.extraInitializationsAsync?async()=>{u?.(),await this.options.extraInitializationsAsync}:u,this.options.useShaderStore?this._drawWrapper.effect=this.options.engine.createEffect({vertex:o??this._shaderPath.vertex,fragment:h??this._shaderPath.fragment},{attributes:this.options.attributeNames,uniformsNames:t||this.options.uniforms,uniformBuffersNames:this.options.uniformBuffers,samplers:s||this.options.samplers,defines:null!==e?e:"",fallbacks:null,onCompiled:r??this.options.onCompiled,onError:n??null,indexParameters:i||this.options.indexParameters,processCodeAfterIncludes:l?.processCodeAfterIncludes?(e,t)=>l.processCodeAfterIncludes(this.name,e,t):null,processFinalCode:l?.processFinalCode?(e,t)=>l.processFinalCode(this.name,e,t):null,shaderLanguage:this.options.shaderLanguage,extraInitializationsAsync:d},this.options.engine):this._drawWrapper.effect=new a.M(this._shaderPath,this.options.attributeNames,t||this.options.uniforms,s||this.options.samplerNames,this.options.engine,e,void 0,r||this.options.onCompiled,void 0,void 0,void 0,this.options.shaderLanguage,d),this.onEffectCreatedObservable.notifyObservers(this._drawWrapper.effect)}bind(){this.options.useAsPostProcess&&(this.options.engine.setAlphaMode(this.alphaMode),this.drawWrapper.effect.setFloat2("scale",1,1)),c._GetShaderCodeProcessing(this.name)?.bindCustomBindings?.(this.name,this._drawWrapper.effect)}dispose(e=!1){this._onContextRestoredObserver&&(this.effect.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver),this._onContextRestoredObserver=null),this.onEffectCreatedObservable.clear(),this.effect.dispose()}}c.ForceGLSL=!1,c._CustomShaderCodeProcessing={}},1088:(e,t,s)=>{s.d(t,{p:()=>d});var i=s(5524),r=s(9259),n=s(9848),a=s(6041),o=s(6877);function h(e){e.push("vCameraColorCurveNeutral","vCameraColorCurvePositive","vCameraColorCurveNegative")}class l{constructor(){this._dirty=!0,this._tempColor=new a.ov(0,0,0,0),this._globalCurve=new a.ov(0,0,0,0),this._highlightsCurve=new a.ov(0,0,0,0),this._midtonesCurve=new a.ov(0,0,0,0),this._shadowsCurve=new a.ov(0,0,0,0),this._positiveCurve=new a.ov(0,0,0,0),this._negativeCurve=new a.ov(0,0,0,0),this._globalHue=30,this._globalDensity=0,this._globalSaturation=0,this._globalExposure=0,this._highlightsHue=30,this._highlightsDensity=0,this._highlightsSaturation=0,this._highlightsExposure=0,this._midtonesHue=30,this._midtonesDensity=0,this._midtonesSaturation=0,this._midtonesExposure=0,this._shadowsHue=30,this._shadowsDensity=0,this._shadowsSaturation=0,this._shadowsExposure=0}get globalHue(){return this._globalHue}set globalHue(e){this._globalHue=e,this._dirty=!0}get globalDensity(){return this._globalDensity}set globalDensity(e){this._globalDensity=e,this._dirty=!0}get globalSaturation(){return this._globalSaturation}set globalSaturation(e){this._globalSaturation=e,this._dirty=!0}get globalExposure(){return this._globalExposure}set globalExposure(e){this._globalExposure=e,this._dirty=!0}get highlightsHue(){return this._highlightsHue}set highlightsHue(e){this._highlightsHue=e,this._dirty=!0}get highlightsDensity(){return this._highlightsDensity}set highlightsDensity(e){this._highlightsDensity=e,this._dirty=!0}get highlightsSaturation(){return this._highlightsSaturation}set highlightsSaturation(e){this._highlightsSaturation=e,this._dirty=!0}get highlightsExposure(){return this._highlightsExposure}set highlightsExposure(e){this._highlightsExposure=e,this._dirty=!0}get midtonesHue(){return this._midtonesHue}set midtonesHue(e){this._midtonesHue=e,this._dirty=!0}get midtonesDensity(){return this._midtonesDensity}set midtonesDensity(e){this._midtonesDensity=e,this._dirty=!0}get midtonesSaturation(){return this._midtonesSaturation}set midtonesSaturation(e){this._midtonesSaturation=e,this._dirty=!0}get midtonesExposure(){return this._midtonesExposure}set midtonesExposure(e){this._midtonesExposure=e,this._dirty=!0}get shadowsHue(){return this._shadowsHue}set shadowsHue(e){this._shadowsHue=e,this._dirty=!0}get shadowsDensity(){return this._shadowsDensity}set shadowsDensity(e){this._shadowsDensity=e,this._dirty=!0}get shadowsSaturation(){return this._shadowsSaturation}set shadowsSaturation(e){this._shadowsSaturation=e,this._dirty=!0}get shadowsExposure(){return this._shadowsExposure}set shadowsExposure(e){this._shadowsExposure=e,this._dirty=!0}getClassName(){return"ColorCurves"}static Bind(e,t,s="vCameraColorCurvePositive",i="vCameraColorCurveNeutral",r="vCameraColorCurveNegative"){e._dirty&&(e._dirty=!1,e._getColorGradingDataToRef(e._globalHue,e._globalDensity,e._globalSaturation,e._globalExposure,e._globalCurve),e._getColorGradingDataToRef(e._highlightsHue,e._highlightsDensity,e._highlightsSaturation,e._highlightsExposure,e._tempColor),e._tempColor.multiplyToRef(e._globalCurve,e._highlightsCurve),e._getColorGradingDataToRef(e._midtonesHue,e._midtonesDensity,e._midtonesSaturation,e._midtonesExposure,e._tempColor),e._tempColor.multiplyToRef(e._globalCurve,e._midtonesCurve),e._getColorGradingDataToRef(e._shadowsHue,e._shadowsDensity,e._shadowsSaturation,e._shadowsExposure,e._tempColor),e._tempColor.multiplyToRef(e._globalCurve,e._shadowsCurve),e._highlightsCurve.subtractToRef(e._midtonesCurve,e._positiveCurve),e._midtonesCurve.subtractToRef(e._shadowsCurve,e._negativeCurve)),t&&(t.setFloat4(s,e._positiveCurve.r,e._positiveCurve.g,e._positiveCurve.b,e._positiveCurve.a),t.setFloat4(i,e._midtonesCurve.r,e._midtonesCurve.g,e._midtonesCurve.b,e._midtonesCurve.a),t.setFloat4(r,e._negativeCurve.r,e._negativeCurve.g,e._negativeCurve.b,e._negativeCurve.a))}_getColorGradingDataToRef(e,t,s,i,r){null!=e&&(e=l._Clamp(e,0,360),t=l._Clamp(t,-100,100),s=l._Clamp(s,-100,100),i=l._Clamp(i,-100,100),t=l._ApplyColorGradingSliderNonlinear(t),t*=.5,i=l._ApplyColorGradingSliderNonlinear(i),t<0&&(t*=-1,e=(e+180)%360),l._FromHSBToRef(e,t,50+.25*i,r),r.scaleToRef(2,r),r.a=1+.01*s)}static _ApplyColorGradingSliderNonlinear(e){e/=100;let t=Math.abs(e);return t=Math.pow(t,2),e<0&&(t*=-1),t*=100,t}static _FromHSBToRef(e,t,s,i){let r=l._Clamp(e,0,360);const n=l._Clamp(t/100,0,1),a=l._Clamp(s/100,0,1);if(0===n)i.r=a,i.g=a,i.b=a;else{r/=60;const e=Math.floor(r),t=r-e,s=a*(1-n),o=a*(1-n*t),h=a*(1-n*(1-t));switch(e){case 0:i.r=a,i.g=h,i.b=s;break;case 1:i.r=o,i.g=a,i.b=s;break;case 2:i.r=s,i.g=a,i.b=h;break;case 3:i.r=s,i.g=o,i.b=a;break;case 4:i.r=h,i.g=s,i.b=a;break;default:i.r=a,i.g=s,i.b=o}}i.a=1}static _Clamp(e,t,s){return Math.min(Math.max(e,t),s)}clone(){return o.p.Clone((()=>new l),this)}serialize(){return o.p.Serialize(this)}static Parse(e){return o.p.Parse((()=>new l),e,null,null)}}l.PrepareUniforms=h,(0,i.Cg)([(0,r.lK)()],l.prototype,"_globalHue",void 0),(0,i.Cg)([(0,r.lK)()],l.prototype,"_globalDensity",void 0),(0,i.Cg)([(0,r.lK)()],l.prototype,"_globalSaturation",void 0),(0,i.Cg)([(0,r.lK)()],l.prototype,"_globalExposure",void 0),(0,i.Cg)([(0,r.lK)()],l.prototype,"_highlightsHue",void 0),(0,i.Cg)([(0,r.lK)()],l.prototype,"_highlightsDensity",void 0),(0,i.Cg)([(0,r.lK)()],l.prototype,"_highlightsSaturation",void 0),(0,i.Cg)([(0,r.lK)()],l.prototype,"_highlightsExposure",void 0),(0,i.Cg)([(0,r.lK)()],l.prototype,"_midtonesHue",void 0),(0,i.Cg)([(0,r.lK)()],l.prototype,"_midtonesDensity",void 0),(0,i.Cg)([(0,r.lK)()],l.prototype,"_midtonesSaturation",void 0),(0,i.Cg)([(0,r.lK)()],l.prototype,"_midtonesExposure",void 0),o.p._ColorCurvesParser=l.Parse;var c=s(1597),u=s(6552);class d{constructor(){this.colorCurves=new l,this._colorCurvesEnabled=!1,this._colorGradingEnabled=!1,this._colorGradingWithGreenDepth=!0,this._colorGradingBGR=!0,this._exposure=1,this._toneMappingEnabled=!1,this._toneMappingType=d.TONEMAPPING_STANDARD,this._contrast=1,this.vignetteStretch=0,this.vignetteCenterX=0,this.vignetteCenterY=0,this.vignetteWeight=1.5,this.vignetteColor=new a.ov(0,0,0,0),this.vignetteCameraFov=.5,this._vignetteBlendMode=d.VIGNETTEMODE_MULTIPLY,this._vignetteEnabled=!1,this._ditheringEnabled=!1,this._ditheringIntensity=1/255,this._skipFinalColorClamp=!1,this._applyByPostProcess=!1,this._isEnabled=!0,this.onUpdateParameters=new n.cP}get colorCurvesEnabled(){return this._colorCurvesEnabled}set colorCurvesEnabled(e){this._colorCurvesEnabled!==e&&(this._colorCurvesEnabled=e,this._updateParameters())}get colorGradingTexture(){return this._colorGradingTexture}set colorGradingTexture(e){this._colorGradingTexture!==e&&(this._colorGradingTexture=e,this._updateParameters())}get colorGradingEnabled(){return this._colorGradingEnabled}set colorGradingEnabled(e){this._colorGradingEnabled!==e&&(this._colorGradingEnabled=e,this._updateParameters())}get colorGradingWithGreenDepth(){return this._colorGradingWithGreenDepth}set colorGradingWithGreenDepth(e){this._colorGradingWithGreenDepth!==e&&(this._colorGradingWithGreenDepth=e,this._updateParameters())}get colorGradingBGR(){return this._colorGradingBGR}set colorGradingBGR(e){this._colorGradingBGR!==e&&(this._colorGradingBGR=e,this._updateParameters())}get exposure(){return this._exposure}set exposure(e){this._exposure!==e&&(this._exposure=e,this._updateParameters())}get toneMappingEnabled(){return this._toneMappingEnabled}set toneMappingEnabled(e){this._toneMappingEnabled!==e&&(this._toneMappingEnabled=e,this._updateParameters())}get toneMappingType(){return this._toneMappingType}set toneMappingType(e){this._toneMappingType!==e&&(this._toneMappingType=e,this._updateParameters())}get contrast(){return this._contrast}set contrast(e){this._contrast!==e&&(this._contrast=e,this._updateParameters())}get vignetteCentreY(){return this.vignetteCenterY}set vignetteCentreY(e){this.vignetteCenterY=e}get vignetteCentreX(){return this.vignetteCenterX}set vignetteCentreX(e){this.vignetteCenterX=e}get vignetteBlendMode(){return this._vignetteBlendMode}set vignetteBlendMode(e){this._vignetteBlendMode!==e&&(this._vignetteBlendMode=e,this._updateParameters())}get vignetteEnabled(){return this._vignetteEnabled}set vignetteEnabled(e){this._vignetteEnabled!==e&&(this._vignetteEnabled=e,this._updateParameters())}get ditheringEnabled(){return this._ditheringEnabled}set ditheringEnabled(e){this._ditheringEnabled!==e&&(this._ditheringEnabled=e,this._updateParameters())}get ditheringIntensity(){return this._ditheringIntensity}set ditheringIntensity(e){this._ditheringIntensity!==e&&(this._ditheringIntensity=e,this._updateParameters())}get skipFinalColorClamp(){return this._skipFinalColorClamp}set skipFinalColorClamp(e){this._skipFinalColorClamp!==e&&(this._skipFinalColorClamp=e,this._updateParameters())}get applyByPostProcess(){return this._applyByPostProcess}set applyByPostProcess(e){this._applyByPostProcess!==e&&(this._applyByPostProcess=e,this._updateParameters())}get isEnabled(){return this._isEnabled}set isEnabled(e){this._isEnabled!==e&&(this._isEnabled=e,this._updateParameters())}_updateParameters(){this.onUpdateParameters.notifyObservers(this)}getClassName(){return"ImageProcessingConfiguration"}prepareDefines(e,t=!1){if(t!==this.applyByPostProcess||!this._isEnabled)return e.VIGNETTE=!1,e.TONEMAPPING=0,e.CONTRAST=!1,e.EXPOSURE=!1,e.COLORCURVES=!1,e.COLORGRADING=!1,e.COLORGRADING3D=!1,e.DITHER=!1,e.IMAGEPROCESSING=!1,e.SKIPFINALCOLORCLAMP=this.skipFinalColorClamp,void(e.IMAGEPROCESSINGPOSTPROCESS=this.applyByPostProcess&&this._isEnabled);if(e.VIGNETTE=this.vignetteEnabled,e.VIGNETTEBLENDMODEMULTIPLY=this.vignetteBlendMode===d._VIGNETTEMODE_MULTIPLY,e.VIGNETTEBLENDMODEOPAQUE=!e.VIGNETTEBLENDMODEMULTIPLY,this._toneMappingEnabled)switch(this._toneMappingType){case d.TONEMAPPING_KHR_PBR_NEUTRAL:e.TONEMAPPING=3;break;case d.TONEMAPPING_ACES:e.TONEMAPPING=2;break;default:e.TONEMAPPING=1}else e.TONEMAPPING=0;e.CONTRAST=1!==this.contrast,e.EXPOSURE=1!==this.exposure,e.COLORCURVES=this.colorCurvesEnabled&&!!this.colorCurves,e.COLORGRADING=this.colorGradingEnabled&&!!this.colorGradingTexture,e.COLORGRADING?e.COLORGRADING3D=this.colorGradingTexture.is3D:e.COLORGRADING3D=!1,e.SAMPLER3DGREENDEPTH=this.colorGradingWithGreenDepth,e.SAMPLER3DBGRMAP=this.colorGradingBGR,e.DITHER=this._ditheringEnabled,e.IMAGEPROCESSINGPOSTPROCESS=this.applyByPostProcess,e.SKIPFINALCOLORCLAMP=this.skipFinalColorClamp,e.IMAGEPROCESSING=e.VIGNETTE||!!e.TONEMAPPING||e.CONTRAST||e.EXPOSURE||e.COLORCURVES||e.COLORGRADING||e.DITHER}isReady(){return!this.colorGradingEnabled||!this.colorGradingTexture||this.colorGradingTexture.isReady()}bind(e,t){if(this._colorCurvesEnabled&&this.colorCurves&&l.Bind(this.colorCurves,e),this._vignetteEnabled||this._ditheringEnabled){const s=1/e.getEngine().getRenderWidth(),i=1/e.getEngine().getRenderHeight();if(e.setFloat2("vInverseScreenSize",s,i),this._ditheringEnabled&&e.setFloat("ditherIntensity",.5*this._ditheringIntensity),this._vignetteEnabled){const r=null!=t?t:i/s;let n=Math.tan(.5*this.vignetteCameraFov),a=n*r;const o=Math.sqrt(a*n);a=(0,c.zF)(a,o,this.vignetteStretch),n=(0,c.zF)(n,o,this.vignetteStretch),e.setFloat4("vignetteSettings1",a,n,-a*this.vignetteCenterX,-n*this.vignetteCenterY);const h=-2*this.vignetteWeight;e.setFloat4("vignetteSettings2",this.vignetteColor.r,this.vignetteColor.g,this.vignetteColor.b,h)}}if(e.setFloat("exposureLinear",this.exposure),e.setFloat("contrast",this.contrast),this.colorGradingTexture){e.setTexture("txColorTransform",this.colorGradingTexture);const t=this.colorGradingTexture.getSize().height;e.setFloat4("colorTransformSettings",(t-1)/t,.5/t,t,this.colorGradingTexture.level)}}clone(){return o.p.Clone((()=>new d),this)}serialize(){return o.p.Serialize(this)}static Parse(e){const t=o.p.Parse((()=>new d),e,null,null);return void 0!==e.vignetteCentreX&&(t.vignetteCenterX=e.vignetteCentreX),void 0!==e.vignetteCentreY&&(t.vignetteCenterY=e.vignetteCentreY),t}static get VIGNETTEMODE_MULTIPLY(){return this._VIGNETTEMODE_MULTIPLY}static get VIGNETTEMODE_OPAQUE(){return this._VIGNETTEMODE_OPAQUE}}d.TONEMAPPING_STANDARD=0,d.TONEMAPPING_ACES=1,d.TONEMAPPING_KHR_PBR_NEUTRAL=2,d.PrepareUniforms=function(e,t){t.EXPOSURE&&e.push("exposureLinear"),t.CONTRAST&&e.push("contrast"),t.COLORGRADING&&e.push("colorTransformSettings"),(t.VIGNETTE||t.DITHER)&&e.push("vInverseScreenSize"),t.VIGNETTE&&(e.push("vignetteSettings1"),e.push("vignetteSettings2")),t.COLORCURVES&&h(e),t.DITHER&&e.push("ditherIntensity")},d.PrepareSamplers=function(e,t){t.COLORGRADING&&e.push("txColorTransform")},d._VIGNETTEMODE_MULTIPLY=0,d._VIGNETTEMODE_OPAQUE=1,(0,i.Cg)([(0,r.wL)()],d.prototype,"colorCurves",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"_colorCurvesEnabled",void 0),(0,i.Cg)([(0,r.uM)("colorGradingTexture")],d.prototype,"_colorGradingTexture",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"_colorGradingEnabled",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"_colorGradingWithGreenDepth",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"_colorGradingBGR",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"_exposure",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"_toneMappingEnabled",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"_toneMappingType",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"_contrast",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"vignetteStretch",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"vignetteCenterX",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"vignetteCenterY",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"vignetteWeight",void 0),(0,i.Cg)([(0,r.qK)()],d.prototype,"vignetteColor",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"vignetteCameraFov",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"_vignetteBlendMode",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"_vignetteEnabled",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"_ditheringEnabled",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"_ditheringIntensity",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"_skipFinalColorClamp",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"_applyByPostProcess",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"_isEnabled",void 0),o.p._ImageProcessingConfigurationParser=d.Parse,(0,u.Y5)("BABYLON.ImageProcessingConfiguration",d)},8986:(e,t,s)=>{s.d(t,{i:()=>g});var i=s(5524),r=s(9259),n=s(998),a=s(9848),o=s(6315),h=s(1846),l=s(935),c=s(1137),u=s(4100),d=s(5476),_=s(6877);class f{constructor(){this.reset()}reset(){this.enabled=!1,this.mask=255,this.func=519,this.funcRef=1,this.funcMask=255,this.opStencilFail=7680,this.opDepthFail=7680,this.opStencilDepthPass=7681}get func(){return this._func}set func(e){this._func=e}get funcRef(){return this._funcRef}set funcRef(e){this._funcRef=e}get funcMask(){return this._funcMask}set funcMask(e){this._funcMask=e}get opStencilFail(){return this._opStencilFail}set opStencilFail(e){this._opStencilFail=e}get opDepthFail(){return this._opDepthFail}set opDepthFail(e){this._opDepthFail=e}get opStencilDepthPass(){return this._opStencilDepthPass}set opStencilDepthPass(e){this._opStencilDepthPass=e}get mask(){return this._mask}set mask(e){this._mask=e}get enabled(){return this._enabled}set enabled(e){this._enabled=e}getClassName(){return"MaterialStencilState"}copyTo(e){_.p.Clone((()=>e),this)}serialize(){return _.p.Serialize(this)}parse(e,t,s){_.p.Parse((()=>this),e,t,s)}}(0,i.Cg)([(0,r.lK)()],f.prototype,"func",null),(0,i.Cg)([(0,r.lK)()],f.prototype,"funcRef",null),(0,i.Cg)([(0,r.lK)()],f.prototype,"funcMask",null),(0,i.Cg)([(0,r.lK)()],f.prototype,"opStencilFail",null),(0,i.Cg)([(0,r.lK)()],f.prototype,"opDepthFail",null),(0,i.Cg)([(0,r.lK)()],f.prototype,"opStencilDepthPass",null),(0,i.Cg)([(0,r.lK)()],f.prototype,"mask",null),(0,i.Cg)([(0,r.lK)()],f.prototype,"enabled",null);var p=s(467);class g{get shaderLanguage(){return this._shaderLanguage}get canRenderToMRT(){return!1}set alpha(e){if(this._alpha===e)return;const t=this._alpha;this._alpha=e,1!==t&&1!==e||this.markAsDirty(g.MiscDirtyFlag+g.PrePassDirtyFlag)}get alpha(){return this._alpha}set backFaceCulling(e){this._backFaceCulling!==e&&(this._backFaceCulling=e,this.markAsDirty(g.TextureDirtyFlag))}get backFaceCulling(){return this._backFaceCulling}set cullBackFaces(e){this._cullBackFaces!==e&&(this._cullBackFaces=e,this.markAsDirty(g.TextureDirtyFlag))}get cullBackFaces(){return this._cullBackFaces}get blockDirtyMechanism(){return this._blockDirtyMechanism}set blockDirtyMechanism(e){this._blockDirtyMechanism!==e&&(this._blockDirtyMechanism=e,e||this.markDirty())}atomicMaterialsUpdate(e){this.blockDirtyMechanism=!0;try{e(this)}finally{this.blockDirtyMechanism=!1}}get hasRenderTargetTextures(){return this._eventInfo.hasRenderTargetTextures=!1,this._callbackPluginEventHasRenderTargetTextures(this._eventInfo),this._eventInfo.hasRenderTargetTextures}set onDispose(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)}get onBindObservable(){return this._onBindObservable||(this._onBindObservable=new a.cP),this._onBindObservable}set onBind(e){this._onBindObserver&&this.onBindObservable.remove(this._onBindObserver),this._onBindObserver=this.onBindObservable.add(e)}get onUnBindObservable(){return this._onUnBindObservable||(this._onUnBindObservable=new a.cP),this._onUnBindObservable}get onEffectCreatedObservable(){return this._onEffectCreatedObservable||(this._onEffectCreatedObservable=new a.cP),this._onEffectCreatedObservable}set alphaMode(e){this._alphaMode!==e&&(this._alphaMode=e,this.markAsDirty(g.TextureDirtyFlag))}get alphaMode(){return this._alphaMode}set needDepthPrePass(e){this._needDepthPrePass!==e&&(this._needDepthPrePass=e,this._needDepthPrePass&&(this.checkReadyOnEveryCall=!0))}get needDepthPrePass(){return this._needDepthPrePass}get isPrePassCapable(){return!1}set fogEnabled(e){this._fogEnabled!==e&&(this._fogEnabled=e,this.markAsDirty(g.MiscDirtyFlag))}get fogEnabled(){return this._fogEnabled}get wireframe(){switch(this._fillMode){case g.WireFrameFillMode:case g.LineListDrawMode:case g.LineLoopDrawMode:case g.LineStripDrawMode:return!0}return this._scene.forceWireframe}set wireframe(e){this.fillMode=e?g.WireFrameFillMode:g.TriangleFillMode}get pointsCloud(){switch(this._fillMode){case g.PointFillMode:case g.PointListDrawMode:return!0}return this._scene.forcePointsCloud}set pointsCloud(e){this.fillMode=e?g.PointFillMode:g.TriangleFillMode}get fillMode(){return this._fillMode}set fillMode(e){this._fillMode!==e&&(this._fillMode=e,this.markAsDirty(g.MiscDirtyFlag))}get useLogarithmicDepth(){return this._useLogarithmicDepth}set useLogarithmicDepth(e){const t=this.getScene().getEngine().getCaps().fragmentDepthSupported;e&&!t&&c.V.Warn("Logarithmic depth has been requested for a material on a device that doesn't support it."),this._useLogarithmicDepth=e&&t,this._markAllSubMeshesAsMiscDirty()}_getDrawWrapper(){return this._drawWrapper}_setDrawWrapper(e){this._drawWrapper=e}constructor(e,t,s,i=!1){this.shadowDepthWrapper=null,this.allowShaderHotSwapping=!0,this._shaderLanguage=0,this._forceGLSL=!1,this.metadata=null,this.reservedDataStore=null,this.checkReadyOnEveryCall=!1,this.checkReadyOnlyOnce=!1,this.state="",this._alpha=1,this._backFaceCulling=!0,this._cullBackFaces=!0,this._blockDirtyMechanism=!1,this.sideOrientation=null,this.onCompiled=null,this.onError=null,this.getRenderTargetTextures=null,this.doNotSerialize=!1,this._storeEffectOnSubMeshes=!1,this.animations=null,this.onDisposeObservable=new a.cP,this._onDisposeObserver=null,this._onUnBindObservable=null,this._onBindObserver=null,this._alphaMode=2,this._needDepthPrePass=!1,this.disableDepthWrite=!1,this.disableColorWrite=!1,this.forceDepthWrite=!1,this.depthFunction=0,this.separateCullingPass=!1,this._fogEnabled=!0,this.pointSize=1,this.zOffset=0,this.zOffsetUnits=0,this.stencil=new f,this._useUBO=!1,this._fillMode=g.TriangleFillMode,this._cachedDepthWriteState=!1,this._cachedColorWriteState=!1,this._cachedDepthFunctionState=0,this._indexInSceneMaterialArray=-1,this.meshMap=null,this._parentContainer=null,this._uniformBufferLayoutBuilt=!1,this._eventInfo={},this._callbackPluginEventGeneric=()=>{},this._callbackPluginEventIsReadyForSubMesh=()=>{},this._callbackPluginEventPrepareDefines=()=>{},this._callbackPluginEventPrepareDefinesBeforeAttributes=()=>{},this._callbackPluginEventHardBindForSubMesh=()=>{},this._callbackPluginEventBindForSubMesh=()=>{},this._callbackPluginEventHasRenderTargetTextures=()=>{},this._callbackPluginEventFillRenderTargetTextures=()=>{},this._forceAlphaTest=!1,this._transparencyMode=null,this.name=e;const r=t||o.q.LastCreatedScene;r&&(this._scene=r,this._dirtyCallbacks={},this._forceGLSL=i,this._dirtyCallbacks[1]=this._markAllSubMeshesAsTexturesDirty.bind(this),this._dirtyCallbacks[2]=this._markAllSubMeshesAsLightsDirty.bind(this),this._dirtyCallbacks[4]=this._markAllSubMeshesAsFresnelDirty.bind(this),this._dirtyCallbacks[8]=this._markAllSubMeshesAsAttributesDirty.bind(this),this._dirtyCallbacks[16]=this._markAllSubMeshesAsMiscDirty.bind(this),this._dirtyCallbacks[32]=this._markAllSubMeshesAsPrePassDirty.bind(this),this._dirtyCallbacks[63]=this._markAllSubMeshesAsAllDirty.bind(this),this.id=e||n.S0.RandomId(),this.uniqueId=this._scene.getUniqueId(),this._materialContext=this._scene.getEngine().createMaterialContext(),this._drawWrapper=new d.E(this._scene.getEngine(),!1),this._drawWrapper.materialContext=this._materialContext,this._uniformBuffer=new l.D(this._scene.getEngine(),void 0,void 0,e),this._useUBO=this.getScene().getEngine().supportsUniformBuffers,this._createUniformBuffer(),s||this._scene.addMaterial(this),this._scene.useMaterialMeshMap&&(this.meshMap={}),g.OnEventObservable.notifyObservers(this,1))}_createUniformBuffer(){const e=this.getScene().getEngine();this._uniformBuffer?.dispose(),e.isWebGPU&&!this._forceGLSL?(this._uniformBuffer=new l.D(e,void 0,void 0,this.name,!0),this._shaderLanguage=1):this._uniformBuffer=new l.D(this._scene.getEngine(),void 0,void 0,this.name),this._uniformBufferLayoutBuilt=!1}toString(e){return"Name: "+this.name}getClassName(){return"Material"}get _isMaterial(){return!0}get isFrozen(){return this.checkReadyOnlyOnce}freeze(){this.markDirty(),this.checkReadyOnlyOnce=!0}unfreeze(){this.markDirty(),this.checkReadyOnlyOnce=!1}isReady(e,t){return!0}isReadyForSubMesh(e,t,s){const i=t.materialDefines;return!!i&&(this._eventInfo.isReadyForSubMesh=!0,this._eventInfo.defines=i,this._callbackPluginEventIsReadyForSubMesh(this._eventInfo),this._eventInfo.isReadyForSubMesh)}getEffect(){return this._drawWrapper.effect}getScene(){return this._scene}_getEffectiveOrientation(e){return null!==this.sideOrientation?this.sideOrientation:e.sideOrientation}get transparencyMode(){return this._transparencyMode}set transparencyMode(e){this._transparencyMode!==e&&(this._transparencyMode=e,this._forceAlphaTest=e===g.MATERIAL_ALPHATESTANDBLEND,this._markAllSubMeshesAsTexturesAndMiscDirty())}get _disableAlphaBlending(){return this._transparencyMode===g.MATERIAL_OPAQUE||this._transparencyMode===g.MATERIAL_ALPHATEST}needAlphaBlending(){return!this._disableAlphaBlending&&this.alpha<1}needAlphaBlendingForMesh(e){return e.visibility<1||!this._disableAlphaBlending&&(e.hasVertexAlpha||this.needAlphaBlending())}needAlphaTesting(){return!!this._forceAlphaTest}_shouldTurnAlphaTestOn(e){return!this.needAlphaBlendingForMesh(e)&&this.needAlphaTesting()}getAlphaTestTexture(){return null}markDirty(e=!1){const t=this.getScene().meshes;for(const s of t)if(s.subMeshes)for(const t of s.subMeshes)if(t.getMaterial()===this)for(const s of t._drawWrappers)s&&this._materialContext===s.materialContext&&(s._wasPreviouslyReady=!1,s._wasPreviouslyUsingInstances=null,s._forceRebindOnNextCall=e);e&&this.markAsDirty(g.AllDirtyFlag)}_preBind(e,t=null){const s=this._scene.getEngine(),i=(null==t?this.sideOrientation:t)===g.ClockWiseSideOrientation;return s.enableEffect(e||this._getDrawWrapper()),s.setState(this.backFaceCulling,this.zOffset,!1,i,this._scene._mirroredCameraPosition?!this.cullBackFaces:this.cullBackFaces,this.stencil,this.zOffsetUnits),i}bind(e,t){}buildUniformLayout(){const e=this._uniformBuffer;this._eventInfo.ubo=e,this._callbackPluginEventGeneric(8,this._eventInfo),e.create(),this._uniformBufferLayoutBuilt=!0}bindForSubMesh(e,t,s){const i=s._drawWrapper;this._eventInfo.subMesh=s,this._callbackPluginEventBindForSubMesh(this._eventInfo),i._forceRebindOnNextCall=!1}bindOnlyWorldMatrix(e){}bindView(e){this._useUBO?this._needToBindSceneUbo=!0:e.setMatrix("view",this.getScene().getViewMatrix())}bindViewProjection(e){this._useUBO?this._needToBindSceneUbo=!0:(e.setMatrix("viewProjection",this.getScene().getTransformMatrix()),e.setMatrix("projection",this.getScene().getProjectionMatrix()))}bindEyePosition(e,t){this._useUBO?this._needToBindSceneUbo=!0:this._scene.bindEyePosition(e,t)}_afterBind(e,t=null,s){if(this._scene._cachedMaterial=this,this._needToBindSceneUbo&&t&&(this._needToBindSceneUbo=!1,(0,p._8)(t,this.getScene().getSceneUniformBuffer()),this._scene.finalizeSceneUbo()),this._scene._cachedVisibility=e?e.visibility:1,this._onBindObservable&&e&&this._onBindObservable.notifyObservers(e),this.disableDepthWrite){const e=this._scene.getEngine();this._cachedDepthWriteState=e.getDepthWrite(),e.setDepthWrite(!1)}if(this.disableColorWrite){const e=this._scene.getEngine();this._cachedColorWriteState=e.getColorWrite(),e.setColorWrite(!1)}if(0!==this.depthFunction){const e=this._scene.getEngine();this._cachedDepthFunctionState=e.getDepthFunction()||0,e.setDepthFunction(this.depthFunction)}}unbind(){this._onUnBindObservable&&this._onUnBindObservable.notifyObservers(this),0!==this.depthFunction&&this._scene.getEngine().setDepthFunction(this._cachedDepthFunctionState),this.disableDepthWrite&&this._scene.getEngine().setDepthWrite(this._cachedDepthWriteState),this.disableColorWrite&&this._scene.getEngine().setColorWrite(this._cachedColorWriteState)}getAnimatables(){return this._eventInfo.animatables=[],this._callbackPluginEventGeneric(256,this._eventInfo),this._eventInfo.animatables}getActiveTextures(){return this._eventInfo.activeTextures=[],this._callbackPluginEventGeneric(512,this._eventInfo),this._eventInfo.activeTextures}hasTexture(e){return this._eventInfo.hasTexture=!1,this._eventInfo.texture=e,this._callbackPluginEventGeneric(1024,this._eventInfo),this._eventInfo.hasTexture}clone(e){return null}_clonePlugins(e,t){const s={};if(this._serializePlugins(s),g._ParsePlugins(s,e,this._scene,t),this.pluginManager)for(const t of this.pluginManager._plugins){const s=e.pluginManager.getPlugin(t.name);s&&t.copyTo(s)}}getBindedMeshes(){if(this.meshMap){const e=[];for(const t in this.meshMap){const s=this.meshMap[t];s&&e.push(s)}return e}return this._scene.meshes.filter((e=>e.material===this))}forceCompilation(e,t,s,i){const r={clipPlane:!1,useInstances:!1,...s},n=this.getScene(),a=this.allowShaderHotSwapping;this.allowShaderHotSwapping=!1;const o=()=>{if(!this._scene||!this._scene.getEngine())return;const s=n.clipPlane;if(r.clipPlane&&(n.clipPlane=new u.Z(0,0,0,1)),this._storeEffectOnSubMeshes){let s=!0,n=null;if(e.subMeshes){const t=new h.K(0,0,0,0,0,e,void 0,!1,!1);t.materialDefines&&(t.materialDefines._renderId=-1),this.isReadyForSubMesh(e,t,r.useInstances)||(t.effect&&t.effect.getCompilationError()&&t.effect.allFallbacksProcessed()?n=t.effect.getCompilationError():(s=!1,setTimeout(o,16)))}s&&(this.allowShaderHotSwapping=a,n&&i&&i(n),t&&t(this))}else this.isReady()?(this.allowShaderHotSwapping=a,t&&t(this)):setTimeout(o,16);r.clipPlane&&(n.clipPlane=s)};o()}forceCompilationAsync(e,t){return new Promise(((s,i)=>{this.forceCompilation(e,(()=>{s()}),t,(e=>{i(e)}))}))}markAsDirty(e){this.getScene().blockMaterialDirtyMechanism||this._blockDirtyMechanism||(g._DirtyCallbackArray.length=0,e&g.TextureDirtyFlag&&g._DirtyCallbackArray.push(g._TextureDirtyCallBack),e&g.LightDirtyFlag&&g._DirtyCallbackArray.push(g._LightsDirtyCallBack),e&g.FresnelDirtyFlag&&g._DirtyCallbackArray.push(g._FresnelDirtyCallBack),e&g.AttributesDirtyFlag&&g._DirtyCallbackArray.push(g._AttributeDirtyCallBack),e&g.MiscDirtyFlag&&g._DirtyCallbackArray.push(g._MiscDirtyCallBack),e&g.PrePassDirtyFlag&&g._DirtyCallbackArray.push(g._PrePassDirtyCallBack),g._DirtyCallbackArray.length&&this._markAllSubMeshesAsDirty(g._RunDirtyCallBacks),this.getScene().resetCachedMaterial())}resetDrawCache(){const e=this.getScene().meshes;for(const t of e)if(t.subMeshes)for(const e of t.subMeshes)e.getMaterial()===this&&e.resetDrawCache()}_markAllSubMeshesAsDirty(e){if(this.getScene().blockMaterialDirtyMechanism||this._blockDirtyMechanism)return;const t=this.getScene().meshes;for(const s of t)if(s.subMeshes)for(const t of s.subMeshes)if(t.getMaterial(!1)===this)for(const s of t._drawWrappers)s&&s.defines&&s.defines.markAllAsDirty&&this._materialContext===s.materialContext&&e(s.defines)}_markScenePrePassDirty(){if(this.getScene().blockMaterialDirtyMechanism||this._blockDirtyMechanism)return;const e=this.getScene().enablePrePassRenderer();e&&e.markAsDirty()}_markAllSubMeshesAsAllDirty(){this._markAllSubMeshesAsDirty(g._AllDirtyCallBack)}_markAllSubMeshesAsImageProcessingDirty(){this._markAllSubMeshesAsDirty(g._ImageProcessingDirtyCallBack)}_markAllSubMeshesAsTexturesDirty(){this._markAllSubMeshesAsDirty(g._TextureDirtyCallBack)}_markAllSubMeshesAsFresnelDirty(){this._markAllSubMeshesAsDirty(g._FresnelDirtyCallBack)}_markAllSubMeshesAsFresnelAndMiscDirty(){this._markAllSubMeshesAsDirty(g._FresnelAndMiscDirtyCallBack)}_markAllSubMeshesAsLightsDirty(){this._markAllSubMeshesAsDirty(g._LightsDirtyCallBack)}_markAllSubMeshesAsAttributesDirty(){this._markAllSubMeshesAsDirty(g._AttributeDirtyCallBack)}_markAllSubMeshesAsMiscDirty(){this._markAllSubMeshesAsDirty(g._MiscDirtyCallBack)}_markAllSubMeshesAsPrePassDirty(){this._markAllSubMeshesAsDirty(g._MiscDirtyCallBack)}_markAllSubMeshesAsTexturesAndMiscDirty(){this._markAllSubMeshesAsDirty(g._TextureAndMiscDirtyCallBack)}_checkScenePerformancePriority(){if(0!==this._scene.performancePriority){this.checkReadyOnlyOnce=!0;const e=this._scene.onScenePerformancePriorityChangedObservable.addOnce((()=>{this.checkReadyOnlyOnce=!1}));this.onDisposeObservable.add((()=>{this._scene.onScenePerformancePriorityChangedObservable.remove(e)}))}}setPrePassRenderer(e){return!1}dispose(e,t,s){const i=this.getScene();if(i.stopAnimation(this),i.freeProcessedMaterials(),i.removeMaterial(this),this._eventInfo.forceDisposeTextures=t,this._callbackPluginEventGeneric(2,this._eventInfo),this._parentContainer){const e=this._parentContainer.materials.indexOf(this);e>-1&&this._parentContainer.materials.splice(e,1),this._parentContainer=null}if(!0!==s)if(this.meshMap)for(const t in this.meshMap){const s=this.meshMap[t];s&&(s.material=null,this.releaseVertexArrayObject(s,e))}else{const t=i.meshes;for(const s of t)s.material!==this||s.sourceMesh||(s.material=null,this.releaseVertexArrayObject(s,e))}this._uniformBuffer.dispose(),e&&this._drawWrapper.effect&&(this._storeEffectOnSubMeshes||this._drawWrapper.effect.dispose(),this._drawWrapper.effect=null),this.metadata=null,this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this._onBindObservable&&this._onBindObservable.clear(),this._onUnBindObservable&&this._onUnBindObservable.clear(),this._onEffectCreatedObservable&&this._onEffectCreatedObservable.clear(),this._eventInfo&&(this._eventInfo={})}releaseVertexArrayObject(e,t){const s=e.geometry;if(s)if(this._storeEffectOnSubMeshes){if(e.subMeshes)for(const i of e.subMeshes)s._releaseVertexArrayObject(i.effect),t&&i.effect&&i.effect.dispose()}else s._releaseVertexArrayObject(this._drawWrapper.effect)}serialize(){const e=_.p.Serialize(this);return e.stencil=this.stencil.serialize(),e.uniqueId=this.uniqueId,this._serializePlugins(e),e}_serializePlugins(e){if(e.plugins={},this.pluginManager)for(const t of this.pluginManager._plugins)e.plugins[t.getClassName()]=t.serialize()}static Parse(e,t,s){if(e.customType){if("BABYLON.PBRMaterial"===e.customType&&e.overloadedAlbedo&&(e.customType="BABYLON.LegacyPBRMaterial",!BABYLON.LegacyPBRMaterial))return c.V.Error("Your scene is trying to load a legacy version of the PBRMaterial, please, include it from the materials library."),null}else e.customType="BABYLON.StandardMaterial";const i=n.S0.Instantiate(e.customType).Parse(e,t,s);return i._loadedUniqueId=e.uniqueId,i}static _ParsePlugins(e,t,s,i){if(e.plugins)for(const r in e.plugins){const a=e.plugins[r];let o=t.pluginManager?.getPlugin(a.name);if(!o){const e=n.S0.Instantiate("BABYLON."+r);e&&(o=new e(t))}o?.parse(a,s,i)}}}g.TriangleFillMode=0,g.WireFrameFillMode=1,g.PointFillMode=2,g.PointListDrawMode=3,g.LineListDrawMode=4,g.LineLoopDrawMode=5,g.LineStripDrawMode=6,g.TriangleStripDrawMode=7,g.TriangleFanDrawMode=8,g.ClockWiseSideOrientation=0,g.CounterClockWiseSideOrientation=1,g.TextureDirtyFlag=1,g.LightDirtyFlag=2,g.FresnelDirtyFlag=4,g.AttributesDirtyFlag=8,g.MiscDirtyFlag=16,g.PrePassDirtyFlag=32,g.AllDirtyFlag=63,g.MATERIAL_OPAQUE=0,g.MATERIAL_ALPHATEST=1,g.MATERIAL_ALPHABLEND=2,g.MATERIAL_ALPHATESTANDBLEND=3,g.MATERIAL_NORMALBLENDMETHOD_WHITEOUT=0,g.MATERIAL_NORMALBLENDMETHOD_RNM=1,g.OnEventObservable=new a.cP,g._AllDirtyCallBack=e=>e.markAllAsDirty(),g._ImageProcessingDirtyCallBack=e=>e.markAsImageProcessingDirty(),g._TextureDirtyCallBack=e=>e.markAsTexturesDirty(),g._FresnelDirtyCallBack=e=>e.markAsFresnelDirty(),g._MiscDirtyCallBack=e=>e.markAsMiscDirty(),g._PrePassDirtyCallBack=e=>e.markAsPrePassDirty(),g._LightsDirtyCallBack=e=>e.markAsLightDirty(),g._AttributeDirtyCallBack=e=>e.markAsAttributesDirty(),g._FresnelAndMiscDirtyCallBack=e=>{g._FresnelDirtyCallBack(e),g._MiscDirtyCallBack(e)},g._TextureAndMiscDirtyCallBack=e=>{g._TextureDirtyCallBack(e),g._MiscDirtyCallBack(e)},g._DirtyCallbackArray=[],g._RunDirtyCallBacks=e=>{for(const t of g._DirtyCallbackArray)t(e)},(0,i.Cg)([(0,r.lK)()],g.prototype,"id",void 0),(0,i.Cg)([(0,r.lK)()],g.prototype,"uniqueId",void 0),(0,i.Cg)([(0,r.lK)()],g.prototype,"name",void 0),(0,i.Cg)([(0,r.lK)()],g.prototype,"metadata",void 0),(0,i.Cg)([(0,r.lK)()],g.prototype,"checkReadyOnEveryCall",void 0),(0,i.Cg)([(0,r.lK)()],g.prototype,"checkReadyOnlyOnce",void 0),(0,i.Cg)([(0,r.lK)()],g.prototype,"state",void 0),(0,i.Cg)([(0,r.lK)("alpha")],g.prototype,"_alpha",void 0),(0,i.Cg)([(0,r.lK)("backFaceCulling")],g.prototype,"_backFaceCulling",void 0),(0,i.Cg)([(0,r.lK)("cullBackFaces")],g.prototype,"_cullBackFaces",void 0),(0,i.Cg)([(0,r.lK)()],g.prototype,"sideOrientation",void 0),(0,i.Cg)([(0,r.lK)("alphaMode")],g.prototype,"_alphaMode",void 0),(0,i.Cg)([(0,r.lK)()],g.prototype,"_needDepthPrePass",void 0),(0,i.Cg)([(0,r.lK)()],g.prototype,"disableDepthWrite",void 0),(0,i.Cg)([(0,r.lK)()],g.prototype,"disableColorWrite",void 0),(0,i.Cg)([(0,r.lK)()],g.prototype,"forceDepthWrite",void 0),(0,i.Cg)([(0,r.lK)()],g.prototype,"depthFunction",void 0),(0,i.Cg)([(0,r.lK)()],g.prototype,"separateCullingPass",void 0),(0,i.Cg)([(0,r.lK)("fogEnabled")],g.prototype,"_fogEnabled",void 0),(0,i.Cg)([(0,r.lK)()],g.prototype,"pointSize",void 0),(0,i.Cg)([(0,r.lK)()],g.prototype,"zOffset",void 0),(0,i.Cg)([(0,r.lK)()],g.prototype,"zOffsetUnits",void 0),(0,i.Cg)([(0,r.lK)()],g.prototype,"pointsCloud",null),(0,i.Cg)([(0,r.lK)()],g.prototype,"fillMode",null),(0,i.Cg)([(0,r.lK)()],g.prototype,"useLogarithmicDepth",null),(0,i.Cg)([(0,r.lK)()],g.prototype,"transparencyMode",null)},9526:(e,t,s)=>{s.d(t,{M:()=>i});class i{constructor(e){if(this._keys=[],this._isDirty=!0,this._areLightsDirty=!0,this._areLightsDisposed=!1,this._areAttributesDirty=!0,this._areTexturesDirty=!0,this._areFresnelDirty=!0,this._areMiscDirty=!0,this._arePrePassDirty=!0,this._areImageProcessingDirty=!0,this._normals=!1,this._uvs=!1,this._needNormals=!1,this._needUVs=!1,this._externalProperties=e,e)for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&this._setDefaultValue(t)}get isDirty(){return this._isDirty}markAsProcessed(){this._isDirty=!1,this._areAttributesDirty=!1,this._areTexturesDirty=!1,this._areFresnelDirty=!1,this._areLightsDirty=!1,this._areLightsDisposed=!1,this._areMiscDirty=!1,this._arePrePassDirty=!1,this._areImageProcessingDirty=!1}markAsUnprocessed(){this._isDirty=!0}markAllAsDirty(){this._areTexturesDirty=!0,this._areAttributesDirty=!0,this._areLightsDirty=!0,this._areFresnelDirty=!0,this._areMiscDirty=!0,this._arePrePassDirty=!1,this._areImageProcessingDirty=!0,this._isDirty=!0}markAsImageProcessingDirty(){this._areImageProcessingDirty=!0,this._isDirty=!0}markAsLightDirty(e=!1){this._areLightsDirty=!0,this._areLightsDisposed=this._areLightsDisposed||e,this._isDirty=!0}markAsAttributesDirty(){this._areAttributesDirty=!0,this._isDirty=!0}markAsTexturesDirty(){this._areTexturesDirty=!0,this._isDirty=!0}markAsFresnelDirty(){this._areFresnelDirty=!0,this._isDirty=!0}markAsMiscDirty(){this._areMiscDirty=!0,this._isDirty=!0}markAsPrePassDirty(){this._arePrePassDirty=!0,this._isDirty=!0}rebuild(){this._keys.length=0;for(const e of Object.keys(this))"_"!==e[0]&&this._keys.push(e);if(this._externalProperties)for(const e in this._externalProperties)-1===this._keys.indexOf(e)&&this._keys.push(e)}isEqual(e){if(this._keys.length!==e._keys.length)return!1;for(let t=0;tthis._setDefaultValue(e)))}_setDefaultValue(e){const t=this._externalProperties?.[e]?.type??typeof this[e],s=this._externalProperties?.[e]?.default;switch(t){case"number":this[e]=s??0;break;case"string":this[e]=s??"";break;default:this[e]=s??!1}}toString(){let e="";for(let t=0;t{s.d(t,{Bb:()=>L,DL:()=>c,ER:()=>M,IF:()=>_,J2:()=>b,MF:()=>d,N4:()=>F,Nc:()=>O,OR:()=>S,RL:()=>A,VO:()=>D,YT:()=>m,Yy:()=>u,_8:()=>g,az:()=>v,c4:()=>y,f$:()=>E,fm:()=>P,mA:()=>T,nR:()=>p,ni:()=>R,qB:()=>I,te:()=>f});var i=s(1137),r=s(6041),n=s(6315),a=s(5515),o=s(492);const h=r.v9.Black(),l={NUM_MORPH_INFLUENCERS:0};function c(e,t,s){if(!e||e.LOGARITHMICDEPTH||e.indexOf&&e.indexOf("LOGARITHMICDEPTH")>=0){const e=s.activeCamera;1===e.mode&&i.V.Error("Logarithmic depth is not compatible with orthographic cameras!",20),t.setFloat("logarithmicDepthConstant",2/(Math.log(e.maxZ+1)/Math.LN2))}}function u(e,t,s,i=!1){s&&e.fogEnabled&&(!t||t.applyFog)&&0!==e.fogMode&&(s.setFloat4("vFogInfos",e.fogMode,e.fogStart,e.fogEnd,e.fogDensity),i?(e.fogColor.toLinearSpaceToRef(h,e.getEngine().useExactSrgbConversions),s.setColor3("vFogColor",h)):s.setColor3("vFogColor",e.fogColor))}function d(e,t,s){l.NUM_MORPH_INFLUENCERS=s,_(e,t,l)}function _(e,t,s){const r=s.NUM_MORPH_INFLUENCERS;if(r>0&&n.q.LastCreatedEngine){const a=n.q.LastCreatedEngine.getCaps().maxVertexAttribs,o=t.morphTargetManager;if(o?.isUsingTextureForTargets)return;const h=o&&o.supportsNormals&&s.NORMAL,l=o&&o.supportsTangents&&s.TANGENT,c=o&&o.supportsUVs&&s.UV1;for(let s=0;sa&&i.V.Error("Cannot add more vertex attributes for mesh "+t.name)}}function f(e,t=!1){e.push("world0"),e.push("world1"),e.push("world2"),e.push("world3"),t&&(e.push("previousWorld0"),e.push("previousWorld1"),e.push("previousWorld2"),e.push("previousWorld3"))}function p(e,t){const s=e.morphTargetManager;e&&s&&t.setFloatArray("morphTargetInfluences",s.influences)}function g(e,t){t.bindToEffect(e,"Scene")}function m(e,t,s){t._needUVs=!0,t[s]=!0,e.optimizeUVAllocation&&e.getTextureMatrix().isIdentityAs3x2()?(t[s+"DIRECTUV"]=e.coordinatesIndex+1,t["MAINUV"+(e.coordinatesIndex+1)]=!0):t[s+"DIRECTUV"]=0}function T(e,t,s){const i=e.getTextureMatrix();t.updateMatrix(s+"Matrix",i)}function b(e,t,s){s.BAKED_VERTEX_ANIMATION_TEXTURE&&s.INSTANCES&&e.push("bakedVertexAnimationSettingsInstanced")}function E(e,t,s){var i;if(t&&e&&(e.computeBonesUsingShaders&&t._bonesComputationForcedToCPU&&(e.computeBonesUsingShaders=!1),e.useBones&&e.computeBonesUsingShaders&&e.skeleton)){const r=e.skeleton;if(r.isUsingTextureForMatrices&&t.getUniformIndex("boneTextureWidth")>-1){const s=r.getTransformMatrixTexture(e);t.setTexture("boneSampler",s),t.setFloat("boneTextureWidth",4*(r.bones.length+1))}else{const n=r.getTransformMatrices(e);n&&(t.setMatrices("mBones",n),s&&e.getScene().prePassRenderer&&e.getScene().prePassRenderer.getIndex(2)&&(s.previousBones[e.uniqueId]||(s.previousBones[e.uniqueId]=n.slice()),t.setMatrices("mPreviousBones",s.previousBones[e.uniqueId]),i=n,s.previousBones[e.uniqueId].set(i)))}}}function x(e,t,s,i,r,n=!0){e._bindLight(t,s,i,r,n)}function A(e,t,s,i,r=4){const n=Math.min(t.lightSources.length,r);for(let r=0;r0&&(i.addCPUSkinningFallback(0,t),e.push("matricesIndices"),e.push("matricesWeights"),s.NUM_BONE_INFLUENCERS>4&&(e.push("matricesIndicesExtra"),e.push("matricesWeightsExtra")))}function M(e,t){(t.INSTANCES||t.THIN_INSTANCES)&&f(e,!!t.PREPASS_VELOCITY),t.INSTANCESCOLOR&&e.push("instanceColor")}function y(e,t,s=4,i=0){let r=0;for(let n=0;n0&&(r=i+n,t.addFallback(r,"LIGHT"+n)),e.SHADOWS||(e["SHADOW"+n]&&t.addFallback(i,"SHADOW"+n),e["SHADOWPCF"+n]&&t.addFallback(i,"SHADOWPCF"+n),e["SHADOWPCSS"+n]&&t.addFallback(i,"SHADOWPCSS"+n),e["SHADOWPOISSON"+n]&&t.addFallback(i,"SHADOWPOISSON"+n),e["SHADOWESM"+n]&&t.addFallback(i,"SHADOWESM"+n),e["SHADOWCLOSEESM"+n]&&t.addFallback(i,"SHADOWCLOSEESM"+n));return r++}function P(e,t,s,i,r,n,a,o=!1){a._areMiscDirty&&(a.LOGARITHMICDEPTH=s,a.POINTSIZE=i,a.FOG=r&&function(e,t){return t.fogEnabled&&e.applyFog&&0!==t.fogMode}(e,t),a.NONUNIFORMSCALING=e.nonUniformScaling,a.ALPHATEST=n,a.DECAL_AFTER_DETAIL=o)}function v(e,t,s,i,r=4,n=!1){if(!s._areLightsDirty)return s._needNormals;let a=0;const o={needNormals:s._needNormals,needRebuild:!1,lightmapMode:!1,shadowEnabled:!1,specularEnabled:!1};if(e.lightsEnabled&&!n)for(const n of t.lightSources)if(C(e,t,n,a,s,i,o),a++,a===r)break;s.SPECULARTERM=o.specularEnabled,s.SHADOWS=o.shadowEnabled;for(let e=a;e0&&(o.shadowEnabled=!0,t.prepareDefines(r,i))}}s.lightmapMode!=a.c.LIGHTMAP_DEFAULT?(o.lightmapMode=!0,r["LIGHTMAPEXCLUDED"+i]=!0,r["LIGHTMAPNOSPECULAR"+i]=s.lightmapMode==a.c.LIGHTMAP_SHADOWSONLY):(r["LIGHTMAPEXCLUDED"+i]=!1,r["LIGHTMAPNOSPECULAR"+i]=!1)}function S(e,t,s,i,r,n=null,a=!1){let h=function(e,t){let s=!1;if(e.activeCamera){const i=t.CAMERA_ORTHOGRAPHIC?1:0,r=t.CAMERA_PERSPECTIVE?1:0,n=1===e.activeCamera.mode?1:0,a=0===e.activeCamera.mode?1:0;(i^n||r^a)&&(t.CAMERA_ORTHOGRAPHIC=1===n,t.CAMERA_PERSPECTIVE=1===a,s=!0)}return s}(e,i);!1!==n&&(h=(0,o.Eq)(s,e,i)),i.DEPTHPREPASS!==!t.getColorWrite()&&(i.DEPTHPREPASS=!i.DEPTHPREPASS,h=!0),i.INSTANCES!==r&&(i.INSTANCES=r,h=!0),i.THIN_INSTANCES!==a&&(i.THIN_INSTANCES=a,h=!0),h&&i.markAsUnprocessed()}function I(e,t,s,i,r=!1,n=!0,a=!0){if(!t._areAttributesDirty&&t._needNormals===t._normals&&t._needUVs===t._uvs)return!1;t._normals=t._needNormals,t._uvs=t._needUVs,t.NORMAL=t._needNormals&&e.isVerticesDataPresent("normal"),t._needNormals&&e.isVerticesDataPresent("tangent")&&(t.TANGENT=!0);for(let s=1;s<=6;++s)t["UV"+s]=!!t._needUVs&&e.isVerticesDataPresent(`uv${1===s?"":s}`);if(s){const s=e.useVertexColors&&e.isVerticesDataPresent("color");t.VERTEXCOLOR=s,t.VERTEXALPHA=e.hasVertexAlpha&&s&&n}return e.isVerticesDataPresent("instanceColor")&&(e.hasInstances||e.hasThinInstances)&&(t.INSTANCESCOLOR=!0),i&&function(e,t){if(e.useBones&&e.computeBonesUsingShaders&&e.skeleton){t.NUM_BONE_INFLUENCERS=e.numBoneInfluencers;const s=void 0!==t.BONETEXTURE;if(e.skeleton.isUsingTextureForMatrices&&s)t.BONETEXTURE=!0;else{t.BonesPerMesh=e.skeleton.bones.length+1,t.BONETEXTURE=!s&&void 0;const i=e.getScene().prePassRenderer;if(i&&i.enabled){const s=-1===i.excludedSkinnedMesh.indexOf(e);t.BONES_VELOCITY_ENABLED=s}}}else t.NUM_BONE_INFLUENCERS=0,t.BonesPerMesh=0,void 0!==t.BONETEXTURE&&(t.BONETEXTURE=!1)}(e,t),r&&function(e,t){const s=e.morphTargetManager;s?(t.MORPHTARGETS_UV=s.supportsUVs&&t.UV1,t.MORPHTARGETS_TANGENT=s.supportsTangents&&t.TANGENT,t.MORPHTARGETS_NORMAL=s.supportsNormals&&t.NORMAL,t.NUM_MORPH_INFLUENCERS=s.numMaxInfluencers||s.numInfluencers,t.MORPHTARGETS=t.NUM_MORPH_INFLUENCERS>0,t.MORPHTARGETS_TEXTURE=s.isUsingTextureForTargets):(t.MORPHTARGETS_UV=!1,t.MORPHTARGETS_TANGENT=!1,t.MORPHTARGETS_NORMAL=!1,t.MORPHTARGETS=!1,t.NUM_MORPH_INFLUENCERS=0)}(e,t),a&&function(e,t){const s=e.bakedVertexAnimationManager;t.BAKED_VERTEX_ANIMATION_TEXTURE=!(!s||!s.isEnabled)}(e,t),!0}function D(e,t){if(e.activeCamera){const s=t.MULTIVIEW;t.MULTIVIEW=null!==e.activeCamera.outputRenderTarget&&e.activeCamera.outputRenderTarget.getViewCount()>1,t.MULTIVIEW!=s&&t.markAsUnprocessed()}}function O(e,t,s){const i=t.ORDER_INDEPENDENT_TRANSPARENCY,r=t.ORDER_INDEPENDENT_TRANSPARENCY_16BITS;t.ORDER_INDEPENDENT_TRANSPARENCY=e.useOrderIndependentTransparency&&s,t.ORDER_INDEPENDENT_TRANSPARENCY_16BITS=!e.getEngine().getCaps().textureFloatLinearFiltering,i===t.ORDER_INDEPENDENT_TRANSPARENCY&&r===t.ORDER_INDEPENDENT_TRANSPARENCY_16BITS||t.markAsUnprocessed()}function F(e,t,s){const i=t.PREPASS;if(!t._arePrePassDirty)return;const r=[{type:1,define:"PREPASS_POSITION",index:"PREPASS_POSITION_INDEX"},{type:9,define:"PREPASS_LOCAL_POSITION",index:"PREPASS_LOCAL_POSITION_INDEX"},{type:2,define:"PREPASS_VELOCITY",index:"PREPASS_VELOCITY_INDEX"},{type:11,define:"PREPASS_VELOCITY_LINEAR",index:"PREPASS_VELOCITY_LINEAR_INDEX"},{type:3,define:"PREPASS_REFLECTIVITY",index:"PREPASS_REFLECTIVITY_INDEX"},{type:0,define:"PREPASS_IRRADIANCE",index:"PREPASS_IRRADIANCE_INDEX"},{type:7,define:"PREPASS_ALBEDO_SQRT",index:"PREPASS_ALBEDO_SQRT_INDEX"},{type:5,define:"PREPASS_DEPTH",index:"PREPASS_DEPTH_INDEX"},{type:10,define:"PREPASS_SCREENSPACE_DEPTH",index:"PREPASS_SCREENSPACE_DEPTH_INDEX"},{type:6,define:"PREPASS_NORMAL",index:"PREPASS_NORMAL_INDEX"},{type:8,define:"PREPASS_WORLD_NORMAL",index:"PREPASS_WORLD_NORMAL_INDEX"}];if(e.prePassRenderer&&e.prePassRenderer.enabled&&s){t.PREPASS=!0,t.SCENE_MRT_COUNT=e.prePassRenderer.mrtCount,t.PREPASS_NORMAL_WORLDSPACE=e.prePassRenderer.generateNormalsInWorldSpace,t.PREPASS_COLOR=!0,t.PREPASS_COLOR_INDEX=0;for(let s=0;s{s.d(t,{y:()=>g});var i=s(5524),r=s(9259),n=s(8986),a=s(6315),o=s(9125),h=s(9610);const l=new RegExp("^([gimus]+)!");class c{constructor(e){this._plugins=[],this._activePlugins=[],this._activePluginsForExtraEvents=[],this._material=e,this._scene=e.getScene(),this._engine=this._scene.getEngine()}_addPlugin(e){for(let t=0;tthis._handlePluginEvent(e,t),this._plugins.push(e),this._plugins.sort(((e,t)=>e.priority-t.priority)),this._codeInjectionPoints={};const s={};s[c._MaterialPluginClassToMainDefine[t]]={type:"boolean",default:!0};for(const e of this._plugins)e.collectDefines(s),this._collectPointNames("vertex",e.getCustomCode("vertex",this._material.shaderLanguage)),this._collectPointNames("fragment",e.getCustomCode("fragment",this._material.shaderLanguage));return this._defineNamesFromPlugins=s,!0}_activatePlugin(e){-1===this._activePlugins.indexOf(e)&&(this._activePlugins.push(e),this._activePlugins.sort(((e,t)=>e.priority-t.priority)),this._material._callbackPluginEventIsReadyForSubMesh=this._handlePluginEventIsReadyForSubMesh.bind(this),this._material._callbackPluginEventPrepareDefinesBeforeAttributes=this._handlePluginEventPrepareDefinesBeforeAttributes.bind(this),this._material._callbackPluginEventPrepareDefines=this._handlePluginEventPrepareDefines.bind(this),this._material._callbackPluginEventBindForSubMesh=this._handlePluginEventBindForSubMesh.bind(this),e.registerForExtraEvents&&(this._activePluginsForExtraEvents.push(e),this._activePluginsForExtraEvents.sort(((e,t)=>e.priority-t.priority)),this._material._callbackPluginEventHasRenderTargetTextures=this._handlePluginEventHasRenderTargetTextures.bind(this),this._material._callbackPluginEventFillRenderTargetTextures=this._handlePluginEventFillRenderTargetTextures.bind(this),this._material._callbackPluginEventHardBindForSubMesh=this._handlePluginEventHardBindForSubMesh.bind(this)))}getPlugin(e){for(let t=0;t0&&e.uniforms.push(...this._uniformList),this._samplerList.length>0&&e.samplers.push(...this._samplerList),this._uboList.length>0&&e.uniformBuffersNames.push(...this._uboList),e.customCode=this._injectCustomCode(e,e.customCode);break}case 8:{const e=t;this._uboDeclaration="",this._vertexDeclaration="",this._fragmentDeclaration="",this._uniformList=[],this._samplerList=[],this._uboList=[];const s=1===this._material.shaderLanguage;for(const t of this._plugins){const i=t.getUniforms(this._material.shaderLanguage);if(i){if(i.ubo)for(const t of i.ubo){if(t.size&&t.type){const i=t.arraySize??0;if(e.ubo.addUniform(t.name,t.size,i),s){let e;switch(t.type){case"mat4":e="mat4x4f";break;case"float":e="f32";break;default:e=`${t.type}f`}this._uboDeclaration+=`uniform ${t.name}: ${e}${i>0?`[${i}]`:""};\n`}else this._uboDeclaration+=`${t.type} ${t.name}${i>0?`[${i}]`:""};\n`}this._uniformList.push(t.name)}i.vertex&&(this._vertexDeclaration+=i.vertex+"\n"),i.fragment&&(this._fragmentDeclaration+=i.fragment+"\n")}t.getSamplers(this._samplerList),t.getUniformBuffersNames(this._uboList)}break}}}_collectPointNames(e,t){if(t)for(const s in t)this._codeInjectionPoints[e]||(this._codeInjectionPoints[e]={}),this._codeInjectionPoints[e][s]=!0}_injectCustomCode(e,t){return(s,i)=>{t&&(i=t(s,i)),this._uboDeclaration&&(i=i.replace("#define ADDITIONAL_UBO_DECLARATION",this._uboDeclaration)),this._vertexDeclaration&&(i=i.replace("#define ADDITIONAL_VERTEX_DECLARATION",this._vertexDeclaration)),this._fragmentDeclaration&&(i=i.replace("#define ADDITIONAL_FRAGMENT_DECLARATION",this._fragmentDeclaration));const r=this._codeInjectionPoints?.[s];if(!r)return i;let n=null;for(let t in r){let r="";for(const i of this._activePlugins){let a=i.getCustomCode(s,this._material.shaderLanguage)?.[t];if(a){if(i.resolveIncludes){if(null===n){const t=0;n={defines:[],indexParameters:e.indexParameters,isFragment:!1,shouldUseHighPrecisionShader:this._engine._shouldUseHighPrecisionShader,processor:void 0,supportsUniformBuffers:this._engine.supportsUniformBuffers,shadersRepository:h.l.GetShadersRepository(t),includesShadersStore:h.l.GetIncludesShadersStore(t),version:void 0,platformName:this._engine.shaderPlatformName,processingContext:void 0,isNDCHalfZRange:this._engine.isNDCHalfZRange,useReverseDepthBuffer:this._engine.useReverseDepthBuffer,processCodeAfterIncludes:void 0}}n.isFragment="fragment"===s,(0,o.Iq)(a,n,(e=>a=e))}r+=a+"\n"}}if(r.length>0)if("!"===t.charAt(0)){t=t.substring(1);let e="g";if("!"===t.charAt(0))e="",t=t.substring(1);else{const s=l.exec(t);s&&s.length>=2&&(e=s[1],t=t.substring(e.length+1))}e.indexOf("g")<0&&(e+="g");const s=i,n=new RegExp(t,e);let a=n.exec(s);for(;null!==a;){let e=r;for(let t=0;t{u.length=0,d=!1,n.i.OnEventObservable.remove(_),_=null}));const u=[];let d=!1,_=null;var f=s(6877),p=s(6552);class g{isCompatible(e){return 0===e}_enable(e){e&&this._pluginManager._activatePlugin(this)}constructor(e,t,s,i,r=!0,n=!1,a=!1){this.priority=500,this.resolveIncludes=!1,this.registerForExtraEvents=!1,this._material=e,this.name=t,this.priority=s,this.resolveIncludes=a,e.pluginManager||(e.pluginManager=new c(e),e.onDisposeObservable.add((()=>{e.pluginManager=void 0}))),this._pluginDefineNames=i,this._pluginManager=e.pluginManager,r&&this._pluginManager._addPlugin(this),n&&this._enable(!0),this.markAllDefinesAsDirty=e._dirtyCallbacks[63]}getClassName(){return"MaterialPluginBase"}isReadyForSubMesh(e,t,s,i){return!0}hardBindForSubMesh(e,t,s,i){}bindForSubMesh(e,t,s,i){}dispose(e){}getCustomCode(e,t=0){return null}collectDefines(e){if(this._pluginDefineNames)for(const t of Object.keys(this._pluginDefineNames)){if("_"===t[0])continue;const s=typeof this._pluginDefineNames[t];e[t]={type:"number"===s?"number":"string"===s?"string":"boolean"===s?"boolean":"object",default:this._pluginDefineNames[t]}}}prepareDefinesBeforeAttributes(e,t,s){}prepareDefines(e,t,s){}hasTexture(e){return!1}hasRenderTargetTextures(){return!1}fillRenderTargetTextures(e){}getActiveTextures(e){}getAnimatables(e){}addFallbacks(e,t,s){return s}getSamplers(e){}getAttributes(e,t,s){}getUniformBuffersNames(e){}getUniforms(e=0){return{}}copyTo(e){f.p.Clone((()=>e),this)}serialize(){return f.p.Serialize(this)}parse(e,t,s){f.p.Parse((()=>this),e,t,s)}}(0,i.Cg)([(0,r.lK)()],g.prototype,"name",void 0),(0,i.Cg)([(0,r.lK)()],g.prototype,"priority",void 0),(0,i.Cg)([(0,r.lK)()],g.prototype,"resolveIncludes",void 0),(0,i.Cg)([(0,r.lK)()],g.prototype,"registerForExtraEvents",void 0),(0,p.Y5)("BABYLON.MaterialPluginBase",g)},1644:(e,t,s)=>{s.d(t,{E:()=>n});var i=s(9923),r=s(8986);class n extends r.i{constructor(e,t,s=!0,r=!1){super(e,t,void 0,r),this._normalMatrix=new i.uq,this._storeEffectOnSubMeshes=s}getEffect(){return this._storeEffectOnSubMeshes?this._activeEffect:super.getEffect()}isReady(e,t){return!!e&&(!this._storeEffectOnSubMeshes||!e.subMeshes||0===e.subMeshes.length||this.isReadyForSubMesh(e,e.subMeshes[0],t))}_isReadyForSubMesh(e){const t=e.materialDefines;return!(this.checkReadyOnEveryCall||!e.effect||!t||t._renderId!==this.getScene().getRenderId())}bindOnlyWorldMatrix(e){this._activeEffect.setMatrix("world",e)}bindOnlyNormalMatrix(e){this._activeEffect.setMatrix("normalMatrix",e)}bind(e,t){t&&this.bindForSubMesh(e,t,t.subMeshes[0])}_afterBind(e,t=null,s){super._afterBind(e,t,s),this.getScene()._cachedEffect=t,s?s._drawWrapper._forceRebindOnNextCall=!1:this._drawWrapper._forceRebindOnNextCall=!1}_mustRebind(e,t,s,i=1){return s._drawWrapper._forceRebindOnNextCall||e.isCachedMaterialInvalid(this,t,i)}dispose(e,t,s){this._activeEffect=void 0,super.dispose(e,t,s)}}},5662:(e,t,s)=>{var i;s.d(t,{w:()=>i}),function(e){e[e.GLSL=0]="GLSL",e[e.WGSL=1]="WGSL"}(i||(i={}))},917:(e,t,s)=>{s.d(t,{B:()=>m});var i=s(6877),r=s(554),n=s(9923),a=s(5616),o=s(2781),h=s(6552),l=s(6041),c=s(2565),u=s(2366),d=s(1644),_=s(6315),f=s(492),p=s(467);const g={effect:null,subMesh:null};class m extends d.E{constructor(e,t,s,i={},r=!0){super(e,t,r),this._textures={},this._textureArrays={},this._externalTextures={},this._floats={},this._ints={},this._uints={},this._floatsArrays={},this._colors3={},this._colors3Arrays={},this._colors4={},this._colors4Arrays={},this._vectors2={},this._vectors3={},this._vectors4={},this._quaternions={},this._quaternionsArrays={},this._matrices={},this._matrixArrays={},this._matrices3x3={},this._matrices2x2={},this._vectors2Arrays={},this._vectors3Arrays={},this._vectors4Arrays={},this._uniformBuffers={},this._textureSamplers={},this._storageBuffers={},this._cachedWorldViewMatrix=new n.uq,this._cachedWorldViewProjectionMatrix=new n.uq,this._multiview=!1,this._materialHelperNeedsPreviousMatrices=!1,this._shaderPath=s,this._options={needAlphaBlending:!1,needAlphaTesting:!1,attributes:["position","normal","uv"],uniforms:["worldViewProjection"],uniformBuffers:[],samplers:[],externalTextures:[],samplerObjects:[],storageBuffers:[],defines:[],useClipPlane:!1,...i}}get shaderPath(){return this._shaderPath}set shaderPath(e){this._shaderPath=e}get options(){return this._options}get isMultiview(){return this._multiview}getClassName(){return"ShaderMaterial"}needAlphaBlending(){return this.alpha<1||this._options.needAlphaBlending}needAlphaTesting(){return this._options.needAlphaTesting}_checkUniform(e){-1===this._options.uniforms.indexOf(e)&&this._options.uniforms.push(e)}setTexture(e,t){return-1===this._options.samplers.indexOf(e)&&this._options.samplers.push(e),this._textures[e]=t,this}removeTexture(e){delete this._textures[e]}setTextureArray(e,t){return-1===this._options.samplers.indexOf(e)&&this._options.samplers.push(e),this._checkUniform(e),this._textureArrays[e]=t,this}setExternalTexture(e,t){return-1===this._options.externalTextures.indexOf(e)&&this._options.externalTextures.push(e),this._externalTextures[e]=t,this}setFloat(e,t){return this._checkUniform(e),this._floats[e]=t,this}setInt(e,t){return this._checkUniform(e),this._ints[e]=t,this}setUInt(e,t){return this._checkUniform(e),this._uints[e]=t,this}setFloats(e,t){return this._checkUniform(e),this._floatsArrays[e]=t,this}setColor3(e,t){return this._checkUniform(e),this._colors3[e]=t,this}setColor3Array(e,t){return this._checkUniform(e),this._colors3Arrays[e]=t.reduce(((e,t)=>(t.toArray(e,e.length),e)),[]),this}setColor4(e,t){return this._checkUniform(e),this._colors4[e]=t,this}setColor4Array(e,t){return this._checkUniform(e),this._colors4Arrays[e]=t.reduce(((e,t)=>(t.toArray(e,e.length),e)),[]),this}setVector2(e,t){return this._checkUniform(e),this._vectors2[e]=t,this}setVector3(e,t){return this._checkUniform(e),this._vectors3[e]=t,this}setVector4(e,t){return this._checkUniform(e),this._vectors4[e]=t,this}setQuaternion(e,t){return this._checkUniform(e),this._quaternions[e]=t,this}setQuaternionArray(e,t){return this._checkUniform(e),this._quaternionsArrays[e]=t.reduce(((e,t)=>(t.toArray(e,e.length),e)),[]),this}setMatrix(e,t){return this._checkUniform(e),this._matrices[e]=t,this}setMatrices(e,t){this._checkUniform(e);const s=new Float32Array(16*t.length);for(let e=0;et===e||t.startsWith(s)));return i>=0&&this.options.defines.splice(i,1),("boolean"!=typeof t||t)&&this.options.defines.push(s+t),this}isReadyForSubMesh(e,t,s){return this.isReady(e,s,t)}isReady(e,t,s){const i=s&&this._storeEffectOnSubMeshes;if(this.isFrozen){const e=i?s._drawWrapper:this._drawWrapper;if(e.effect&&e._wasPreviouslyReady&&e._wasPreviouslyUsingInstances===t)return!0}const n=this.getScene(),o=n.getEngine(),h=[],l=[],u=new c.J;let d=this._shaderPath,_=this._options.uniforms,m=this._options.uniformBuffers,T=this._options.samplers;o.getCaps().multiview&&n.activeCamera&&n.activeCamera.outputRenderTarget&&n.activeCamera.outputRenderTarget.getViewCount()>1&&(this._multiview=!0,h.push("#define MULTIVIEW"),-1!==_.indexOf("viewProjection")&&-1===_.indexOf("viewProjectionR")&&_.push("viewProjectionR"));for(let e=0;e4&&(l.push(a.R.MatricesIndicesExtraKind),l.push(a.R.MatricesWeightsExtraKind));const t=e.skeleton;h.push("#define NUM_BONE_INFLUENCERS "+e.numBoneInfluencers),u.addCPUSkinningFallback(0,e),t.isUsingTextureForMatrices?(h.push("#define BONETEXTURE"),-1===_.indexOf("boneTextureWidth")&&_.push("boneTextureWidth"),-1===this._options.samplers.indexOf("boneSampler")&&this._options.samplers.push("boneSampler")):(h.push("#define BonesPerMesh "+(t.bones.length+1)),-1===_.indexOf("mBones")&&_.push("mBones"))}else h.push("#define NUM_BONE_INFLUENCERS 0");let b=0;const E=e?e.morphTargetManager:null;if(E){const e=E.supportsUVs&&-1!==h.indexOf("#define UV1"),t=E.supportsTangents&&-1!==h.indexOf("#define TANGENT"),s=E.supportsNormals&&-1!==h.indexOf("#define NORMAL");b=E.numMaxInfluencers||E.numInfluencers,e&&h.push("#define MORPHTARGETS_UV"),t&&h.push("#define MORPHTARGETS_TANGENT"),s&&h.push("#define MORPHTARGETS_NORMAL"),b>0&&h.push("#define MORPHTARGETS"),E.isUsingTextureForTargets&&(h.push("#define MORPHTARGETS_TEXTURE"),-1===_.indexOf("morphTargetTextureIndices")&&_.push("morphTargetTextureIndices"),-1===this._options.samplers.indexOf("morphTargets")&&this._options.samplers.push("morphTargets")),h.push("#define NUM_MORPH_INFLUENCERS "+b);for(let i=0;i0&&(_=_.slice(),_.push("morphTargetInfluences"),_.push("morphTargetCount"),_.push("morphTargetTextureInfo"),_.push("morphTargetTextureIndices"))}else h.push("#define NUM_MORPH_INFLUENCERS 0");if(e){const t=e.bakedVertexAnimationManager;t&&t.isEnabled&&(h.push("#define BAKED_VERTEX_ANIMATION_TEXTURE"),-1===_.indexOf("bakedVertexAnimationSettings")&&_.push("bakedVertexAnimationSettings"),-1===_.indexOf("bakedVertexAnimationTextureSizeInverted")&&_.push("bakedVertexAnimationTextureSizeInverted"),-1===_.indexOf("bakedVertexAnimationTime")&&_.push("bakedVertexAnimationTime"),-1===this._options.samplers.indexOf("bakedVertexAnimationTexture")&&this._options.samplers.push("bakedVertexAnimationTexture")),(0,p.J2)(l,e,h)}for(const e in this._textures)if(!this._textures[e].isReady())return!1;e&&this._shouldTurnAlphaTestOn(e)&&h.push("#define ALPHATEST"),!1!==this._options.useClipPlane&&((0,f.TV)(_),(0,f.tv)(this,n,h)),n.fogEnabled&&e?.applyFog&&n.fogMode!==r.Z.FOGMODE_NONE&&(h.push("#define FOG"),-1===_.indexOf("view")&&_.push("view"),-1===_.indexOf("vFogInfos")&&_.push("vFogInfos"),-1===_.indexOf("vFogColor")&&_.push("vFogColor")),this._useLogarithmicDepth&&(h.push("#define LOGARITHMICDEPTH"),-1===_.indexOf("logarithmicDepthConstant")&&_.push("logarithmicDepthConstant")),this.customShaderNameResolve&&(_=_.slice(),m=m.slice(),T=T.slice(),d=this.customShaderNameResolve(this.name,_,m,T,h,l));const x=i?s._getDrawWrapper(void 0,!0):this._drawWrapper,A=x?.effect??null,R=x?.defines??null,M=h.join("\n");let y=A;return R!==M&&(y=o.createEffect(d,{attributes:l,uniformsNames:_,uniformBuffersNames:m,samplers:T,defines:M,fallbacks:u,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousMorphTargets:b},shaderLanguage:this._options.shaderLanguage,extraInitializationsAsync:this._options.extraInitializationsAsync},o),i?s.setEffect(y,M,this._materialContext):x&&x.setEffect(y,M),this._onEffectCreatedObservable&&(g.effect=y,g.subMesh=s??e?.subMeshes[0]??null,this._onEffectCreatedObservable.notifyObservers(g))),x._wasPreviouslyUsingInstances=!!t,!(!y?.isReady()??1)&&(A!==y&&n.resetCachedMaterial(),x._wasPreviouslyReady=!0,!0)}bindOnlyWorldMatrix(e,t){const s=this.getScene(),i=t??this.getEffect();i&&(-1!==this._options.uniforms.indexOf("world")&&i.setMatrix("world",e),-1!==this._options.uniforms.indexOf("worldView")&&(e.multiplyToRef(s.getViewMatrix(),this._cachedWorldViewMatrix),i.setMatrix("worldView",this._cachedWorldViewMatrix)),-1!==this._options.uniforms.indexOf("worldViewProjection")&&(e.multiplyToRef(s.getTransformMatrix(),this._cachedWorldViewProjectionMatrix),i.setMatrix("worldViewProjection",this._cachedWorldViewProjectionMatrix)),-1!==this._options.uniforms.indexOf("view")&&i.setMatrix("view",s.getViewMatrix()))}bindForSubMesh(e,t,s){this.bind(e,t,s._drawWrapperOverride?.effect,s)}bind(e,t,s,i){const r=i&&this._storeEffectOnSubMeshes,n=s??(r?i.effect:this.getEffect());if(!n)return;const a=this.getScene();this._activeEffect=n,this.bindOnlyWorldMatrix(e,s);const o=this._options.uniformBuffers;let h=!1;if(n&&o&&o.length>0&&a.getEngine().supportsUniformBuffers)for(let s=0;s0&&(0,p.nR)(t,n);const s=t.bakedVertexAnimationManager;if(s&&s.isEnabled){const e=r?i._drawWrapper:this._drawWrapper;t.bakedVertexAnimationManager?.bind(n,!!e._wasPreviouslyUsingInstances)}}this._afterBind(t,n,i)}getActiveTextures(){const e=super.getActiveTextures();for(const t in this._textures)e.push(this._textures[t]);for(const t in this._textureArrays){const s=this._textureArrays[t];for(let t=0;tnew m(e,this.getScene(),this._shaderPath,this._options,this._storeEffectOnSubMeshes)),this);t.name=e,t.id=e,"object"==typeof t._shaderPath&&(t._shaderPath={...t._shaderPath}),this._options={...this._options},Object.keys(this._options).forEach((e=>{const t=this._options[e];Array.isArray(t)&&(this._options[e]=t.slice(0))})),this.stencil.copyTo(t.stencil);for(const e in this._textures)t.setTexture(e,this._textures[e]);for(const e in this._textureArrays)t.setTextureArray(e,this._textureArrays[e]);for(const e in this._externalTextures)t.setExternalTexture(e,this._externalTextures[e]);for(const e in this._ints)t.setInt(e,this._ints[e]);for(const e in this._uints)t.setUInt(e,this._uints[e]);for(const e in this._floats)t.setFloat(e,this._floats[e]);for(const e in this._floatsArrays)t.setFloats(e,this._floatsArrays[e]);for(const e in this._colors3)t.setColor3(e,this._colors3[e]);for(const e in this._colors3Arrays)t._colors3Arrays[e]=this._colors3Arrays[e];for(const e in this._colors4)t.setColor4(e,this._colors4[e]);for(const e in this._colors4Arrays)t._colors4Arrays[e]=this._colors4Arrays[e];for(const e in this._vectors2)t.setVector2(e,this._vectors2[e]);for(const e in this._vectors3)t.setVector3(e,this._vectors3[e]);for(const e in this._vectors4)t.setVector4(e,this._vectors4[e]);for(const e in this._quaternions)t.setQuaternion(e,this._quaternions[e]);for(const e in this._quaternionsArrays)t._quaternionsArrays[e]=this._quaternionsArrays[e];for(const e in this._matrices)t.setMatrix(e,this._matrices[e]);for(const e in this._matrixArrays)t._matrixArrays[e]=this._matrixArrays[e].slice();for(const e in this._matrices3x3)t.setMatrix3x3(e,this._matrices3x3[e]);for(const e in this._matrices2x2)t.setMatrix2x2(e,this._matrices2x2[e]);for(const e in this._vectors2Arrays)t.setArray2(e,this._vectors2Arrays[e]);for(const e in this._vectors3Arrays)t.setArray3(e,this._vectors3Arrays[e]);for(const e in this._vectors4Arrays)t.setArray4(e,this._vectors4Arrays[e]);for(const e in this._uniformBuffers)t.setUniformBuffer(e,this._uniformBuffers[e]);for(const e in this._textureSamplers)t.setTextureSampler(e,this._textureSamplers[e]);for(const e in this._storageBuffers)t.setStorageBuffer(e,this._storageBuffers[e]);return t}dispose(e,t,s){if(t){let e;for(e in this._textures)this._textures[e].dispose();for(e in this._textureArrays){const t=this._textureArrays[e];for(let e=0;enew m(e.name,t,e.shaderPath,e.options,e.storeEffectOnSubMeshes)),e,t,s);let a;for(a in e.stencil&&r.stencil.parse(e.stencil,t,s),e.textures)r.setTexture(a,o.g.Parse(e.textures[a],t,s));for(a in e.textureArrays){const i=e.textureArrays[a],n=[];for(let e=0;e(s%3==0?e.push([t]):e[e.length-1].push(t),e)),[]).map((e=>l.v9.FromArray(e)));r.setColor3Array(a,t)}for(a in e.colors4)r.setColor4(a,l.ov.FromArray(e.colors4[a]));for(a in e.colors4Arrays){const t=e.colors4Arrays[a].reduce(((e,t,s)=>(s%4==0?e.push([t]):e[e.length-1].push(t),e)),[]).map((e=>l.ov.FromArray(e)));r.setColor4Array(a,t)}for(a in e.vectors2)r.setVector2(a,n.I9.FromArray(e.vectors2[a]));for(a in e.vectors3)r.setVector3(a,n.Pq.FromArray(e.vectors3[a]));for(a in e.vectors4)r.setVector4(a,n.IU.FromArray(e.vectors4[a]));for(a in e.quaternions)r.setQuaternion(a,n.PT.FromArray(e.quaternions[a]));for(a in e.matrices)r.setMatrix(a,n.uq.FromArray(e.matrices[a]));for(a in e.matrixArray)r._matrixArrays[a]=new Float32Array(e.matrixArray[a]);for(a in e.matrices3x3)r.setMatrix3x3(a,e.matrices3x3[a]);for(a in e.matrices2x2)r.setMatrix2x2(a,e.matrices2x2[a]);for(a in e.vectors2Arrays)r.setArray2(a,e.vectors2Arrays[a]);for(a in e.vectors3Arrays)r.setArray3(a,e.vectors3Arrays[a]);for(a in e.vectors4Arrays)r.setArray4(a,e.vectors4Arrays[a]);for(a in e.quaternionsArrays)r.setArray4(a,e.quaternionsArrays[a]);return r}static ParseFromFileAsync(e,t,s,i=""){return new Promise(((r,n)=>{const a=new u.u;a.addEventListener("readystatechange",(()=>{if(4==a.readyState)if(200==a.status){const t=JSON.parse(a.responseText),n=this.Parse(t,s||_.q.LastCreatedScene,i);e&&(n.name=e),r(n)}else n("Unable to load the ShaderMaterial")})),a.open("GET",t),a.send()}))}static ParseFromSnippetAsync(e,t,s=""){return new Promise(((i,r)=>{const n=new u.u;n.addEventListener("readystatechange",(()=>{if(4==n.readyState)if(200==n.status){const r=JSON.parse(JSON.parse(n.responseText).jsonPayload),a=JSON.parse(r.shaderMaterial),o=this.Parse(a,t||_.q.LastCreatedScene,s);o.snippetId=e,i(o)}else r("Unable to load the snippet "+e)})),n.open("GET",this.SnippetUrl+"/"+e.replace(/#/g,"/")),n.send()}))}}m.SnippetUrl="https://snippet.babylonjs.com",m.CreateFromSnippetAsync=m.ParseFromSnippetAsync,(0,h.Y5)("BABYLON.ShaderMaterial",m)},2673:(e,t,s)=>{s.d(t,{F:()=>I});var i=s(5524),r=s(9259),n=s(7931),a=s(554),o=s(9923),h=s(6041),l=s(5616);class c{constructor(){this.previousWorldMatrices={},this.previousBones={}}static AddUniforms(e){e.push("previousWorld","previousViewProjection","mPreviousBones")}static AddSamplers(e){}bindForSubMesh(e,t,s,i,r){if(t.prePassRenderer&&t.prePassRenderer.enabled&&t.prePassRenderer.currentRTisSceneRT&&(-1!==t.prePassRenderer.getIndex(2)||-1!==t.prePassRenderer.getIndex(11))){this.previousWorldMatrices[s.uniqueId]||(this.previousWorldMatrices[s.uniqueId]=i.clone()),this.previousViewProjection||(this.previousViewProjection=t.getTransformMatrix().clone(),this.currentViewProjection=t.getTransformMatrix().clone());const r=t.getEngine();this.currentViewProjection.updateFlag!==t.getTransformMatrix().updateFlag?(this._lastUpdateFrameId=r.frameId,this.previousViewProjection.copyFrom(this.currentViewProjection),this.currentViewProjection.copyFrom(t.getTransformMatrix())):this._lastUpdateFrameId!==r.frameId&&(this._lastUpdateFrameId=r.frameId,this.previousViewProjection.copyFrom(this.currentViewProjection)),e.setMatrix("previousWorld",this.previousWorldMatrices[s.uniqueId]),e.setMatrix("previousViewProjection",this.previousViewProjection),this.previousWorldMatrices[s.uniqueId]=i.clone()}}}var u=s(1088),d=s(8986),_=s(9526),f=s(1644),p=s(2781),g=s(6552),m=s(6326);class T{static get DiffuseTextureEnabled(){return this._DiffuseTextureEnabled}static set DiffuseTextureEnabled(e){this._DiffuseTextureEnabled!==e&&(this._DiffuseTextureEnabled=e,m.$.MarkAllMaterialsAsDirty(1))}static get DetailTextureEnabled(){return this._DetailTextureEnabled}static set DetailTextureEnabled(e){this._DetailTextureEnabled!==e&&(this._DetailTextureEnabled=e,m.$.MarkAllMaterialsAsDirty(1))}static get DecalMapEnabled(){return this._DecalMapEnabled}static set DecalMapEnabled(e){this._DecalMapEnabled!==e&&(this._DecalMapEnabled=e,m.$.MarkAllMaterialsAsDirty(1))}static get AmbientTextureEnabled(){return this._AmbientTextureEnabled}static set AmbientTextureEnabled(e){this._AmbientTextureEnabled!==e&&(this._AmbientTextureEnabled=e,m.$.MarkAllMaterialsAsDirty(1))}static get OpacityTextureEnabled(){return this._OpacityTextureEnabled}static set OpacityTextureEnabled(e){this._OpacityTextureEnabled!==e&&(this._OpacityTextureEnabled=e,m.$.MarkAllMaterialsAsDirty(1))}static get ReflectionTextureEnabled(){return this._ReflectionTextureEnabled}static set ReflectionTextureEnabled(e){this._ReflectionTextureEnabled!==e&&(this._ReflectionTextureEnabled=e,m.$.MarkAllMaterialsAsDirty(1))}static get EmissiveTextureEnabled(){return this._EmissiveTextureEnabled}static set EmissiveTextureEnabled(e){this._EmissiveTextureEnabled!==e&&(this._EmissiveTextureEnabled=e,m.$.MarkAllMaterialsAsDirty(1))}static get SpecularTextureEnabled(){return this._SpecularTextureEnabled}static set SpecularTextureEnabled(e){this._SpecularTextureEnabled!==e&&(this._SpecularTextureEnabled=e,m.$.MarkAllMaterialsAsDirty(1))}static get BumpTextureEnabled(){return this._BumpTextureEnabled}static set BumpTextureEnabled(e){this._BumpTextureEnabled!==e&&(this._BumpTextureEnabled=e,m.$.MarkAllMaterialsAsDirty(1))}static get LightmapTextureEnabled(){return this._LightmapTextureEnabled}static set LightmapTextureEnabled(e){this._LightmapTextureEnabled!==e&&(this._LightmapTextureEnabled=e,m.$.MarkAllMaterialsAsDirty(1))}static get RefractionTextureEnabled(){return this._RefractionTextureEnabled}static set RefractionTextureEnabled(e){this._RefractionTextureEnabled!==e&&(this._RefractionTextureEnabled=e,m.$.MarkAllMaterialsAsDirty(1))}static get ColorGradingTextureEnabled(){return this._ColorGradingTextureEnabled}static set ColorGradingTextureEnabled(e){this._ColorGradingTextureEnabled!==e&&(this._ColorGradingTextureEnabled=e,m.$.MarkAllMaterialsAsDirty(1))}static get FresnelEnabled(){return this._FresnelEnabled}static set FresnelEnabled(e){this._FresnelEnabled!==e&&(this._FresnelEnabled=e,m.$.MarkAllMaterialsAsDirty(4))}static get ClearCoatTextureEnabled(){return this._ClearCoatTextureEnabled}static set ClearCoatTextureEnabled(e){this._ClearCoatTextureEnabled!==e&&(this._ClearCoatTextureEnabled=e,m.$.MarkAllMaterialsAsDirty(1))}static get ClearCoatBumpTextureEnabled(){return this._ClearCoatBumpTextureEnabled}static set ClearCoatBumpTextureEnabled(e){this._ClearCoatBumpTextureEnabled!==e&&(this._ClearCoatBumpTextureEnabled=e,m.$.MarkAllMaterialsAsDirty(1))}static get ClearCoatTintTextureEnabled(){return this._ClearCoatTintTextureEnabled}static set ClearCoatTintTextureEnabled(e){this._ClearCoatTintTextureEnabled!==e&&(this._ClearCoatTintTextureEnabled=e,m.$.MarkAllMaterialsAsDirty(1))}static get SheenTextureEnabled(){return this._SheenTextureEnabled}static set SheenTextureEnabled(e){this._SheenTextureEnabled!==e&&(this._SheenTextureEnabled=e,m.$.MarkAllMaterialsAsDirty(1))}static get AnisotropicTextureEnabled(){return this._AnisotropicTextureEnabled}static set AnisotropicTextureEnabled(e){this._AnisotropicTextureEnabled!==e&&(this._AnisotropicTextureEnabled=e,m.$.MarkAllMaterialsAsDirty(1))}static get ThicknessTextureEnabled(){return this._ThicknessTextureEnabled}static set ThicknessTextureEnabled(e){this._ThicknessTextureEnabled!==e&&(this._ThicknessTextureEnabled=e,m.$.MarkAllMaterialsAsDirty(1))}static get RefractionIntensityTextureEnabled(){return this._ThicknessTextureEnabled}static set RefractionIntensityTextureEnabled(e){this._RefractionIntensityTextureEnabled!==e&&(this._RefractionIntensityTextureEnabled=e,m.$.MarkAllMaterialsAsDirty(1))}static get TranslucencyIntensityTextureEnabled(){return this._TranslucencyIntensityTextureEnabled}static set TranslucencyIntensityTextureEnabled(e){this._TranslucencyIntensityTextureEnabled!==e&&(this._TranslucencyIntensityTextureEnabled=e,m.$.MarkAllMaterialsAsDirty(1))}static get TranslucencyColorTextureEnabled(){return this._TranslucencyColorTextureEnabled}static set TranslucencyColorTextureEnabled(e){this._TranslucencyColorTextureEnabled!==e&&(this._TranslucencyColorTextureEnabled=e,m.$.MarkAllMaterialsAsDirty(1))}static get IridescenceTextureEnabled(){return this._IridescenceTextureEnabled}static set IridescenceTextureEnabled(e){this._IridescenceTextureEnabled!==e&&(this._IridescenceTextureEnabled=e,m.$.MarkAllMaterialsAsDirty(1))}}T._DiffuseTextureEnabled=!0,T._DetailTextureEnabled=!0,T._DecalMapEnabled=!0,T._AmbientTextureEnabled=!0,T._OpacityTextureEnabled=!0,T._ReflectionTextureEnabled=!0,T._EmissiveTextureEnabled=!0,T._SpecularTextureEnabled=!0,T._BumpTextureEnabled=!0,T._LightmapTextureEnabled=!0,T._RefractionTextureEnabled=!0,T._ColorGradingTextureEnabled=!0,T._FresnelEnabled=!0,T._ClearCoatTextureEnabled=!0,T._ClearCoatBumpTextureEnabled=!0,T._ClearCoatTintTextureEnabled=!0,T._SheenTextureEnabled=!0,T._AnisotropicTextureEnabled=!0,T._ThicknessTextureEnabled=!0,T._RefractionIntensityTextureEnabled=!0,T._TranslucencyIntensityTextureEnabled=!0,T._TranslucencyColorTextureEnabled=!0,T._IridescenceTextureEnabled=!0;var b=s(2565),E=s(2277),x=s(467);class A extends _.M{constructor(){super(...arguments),this.DETAIL=!1,this.DETAILDIRECTUV=0,this.DETAIL_NORMALBLENDMETHOD=0}}class R extends E.y{_markAllSubMeshesAsTexturesDirty(){this._enable(this._isEnabled),this._internalMarkAllSubMeshesAsTexturesDirty()}isCompatible(){return!0}constructor(e,t=!0){super(e,"DetailMap",140,new A,t),this._texture=null,this.diffuseBlendLevel=1,this.roughnessBlendLevel=1,this.bumpLevel=1,this._normalBlendMethod=d.i.MATERIAL_NORMALBLENDMETHOD_WHITEOUT,this._isEnabled=!1,this.isEnabled=!1,this._internalMarkAllSubMeshesAsTexturesDirty=e._dirtyCallbacks[1]}isReadyForSubMesh(e,t,s){return!this._isEnabled||!(e._areTexturesDirty&&t.texturesEnabled&&s.getCaps().standardDerivatives&&this._texture&&T.DetailTextureEnabled&&!this._texture.isReady())}prepareDefines(e,t){if(this._isEnabled){e.DETAIL_NORMALBLENDMETHOD=this._normalBlendMethod;const s=t.getEngine();e._areTexturesDirty&&(s.getCaps().standardDerivatives&&this._texture&&T.DetailTextureEnabled&&this._isEnabled?((0,x.YT)(this._texture,e,"DETAIL"),e.DETAIL_NORMALBLENDMETHOD=this._normalBlendMethod):e.DETAIL=!1)}else e.DETAIL=!1}bindForSubMesh(e,t){if(!this._isEnabled)return;const s=this._material.isFrozen;e.useUbo&&s&&e.isSync||this._texture&&T.DetailTextureEnabled&&(e.updateFloat4("vDetailInfos",this._texture.coordinatesIndex,this.diffuseBlendLevel,this.bumpLevel,this.roughnessBlendLevel),(0,x.mA)(this._texture,e,"detail")),t.texturesEnabled&&this._texture&&T.DetailTextureEnabled&&e.setTexture("detailSampler",this._texture)}hasTexture(e){return this._texture===e}getActiveTextures(e){this._texture&&e.push(this._texture)}getAnimatables(e){this._texture&&this._texture.animations&&this._texture.animations.length>0&&e.push(this._texture)}dispose(e){e&&this._texture?.dispose()}getClassName(){return"DetailMapConfiguration"}getSamplers(e){e.push("detailSampler")}getUniforms(){return{ubo:[{name:"vDetailInfos",size:4,type:"vec4"},{name:"detailMatrix",size:16,type:"mat4"}]}}}(0,i.Cg)([(0,r.uM)("detailTexture"),(0,r.$z)("_markAllSubMeshesAsTexturesDirty")],R.prototype,"texture",void 0),(0,i.Cg)([(0,r.lK)()],R.prototype,"diffuseBlendLevel",void 0),(0,i.Cg)([(0,r.lK)()],R.prototype,"roughnessBlendLevel",void 0),(0,i.Cg)([(0,r.lK)()],R.prototype,"bumpLevel",void 0),(0,i.Cg)([(0,r.lK)(),(0,r.$z)("_markAllSubMeshesAsTexturesDirty")],R.prototype,"normalBlendMethod",void 0),(0,i.Cg)([(0,r.lK)(),(0,r.$z)("_markAllSubMeshesAsTexturesDirty")],R.prototype,"isEnabled",void 0);var M,y=s(492),P=s(6877);!function(e){e[e.Zero=0]="Zero",e[e.One=1]="One",e[e.MaxViewZ=2]="MaxViewZ"}(M||(M={}));class v{static CreateConfiguration(e){return v._Configurations[e]={defines:{},previousWorldMatrices:{},previousViewProjection:o.uq.Zero(),currentViewProjection:o.uq.Zero(),previousBones:{},lastUpdateFrameId:-1,excludedSkinnedMesh:[]},v._Configurations[e]}static DeleteConfiguration(e){delete v._Configurations[e]}static GetConfiguration(e){return v._Configurations[e]}static AddUniformsAndSamplers(e,t){e.push("previousWorld","previousViewProjection","mPreviousBones")}static MarkAsDirty(e,t){for(const s of t)if(s.subMeshes)for(const t of s.subMeshes)t._removeDrawWrapper(e)}static PrepareDefines(e,t,s){if(!s._arePrePassDirty)return;const i=v._Configurations[e];if(!i)return;s.PREPASS=!0,s.PREPASS_COLOR=!1,s.PREPASS_COLOR_INDEX=-1;let r=0;for(let e=0;e{this._markAllSubMeshesAsImageProcessingDirty()}))))}get isPrePassCapable(){return!this.disableDepthWrite}get cameraColorCurvesEnabled(){return this.imageProcessingConfiguration.colorCurvesEnabled}set cameraColorCurvesEnabled(e){this.imageProcessingConfiguration.colorCurvesEnabled=e}get cameraColorGradingEnabled(){return this.imageProcessingConfiguration.colorGradingEnabled}set cameraColorGradingEnabled(e){this.imageProcessingConfiguration.colorGradingEnabled=e}get cameraToneMappingEnabled(){return this._imageProcessingConfiguration.toneMappingEnabled}set cameraToneMappingEnabled(e){this._imageProcessingConfiguration.toneMappingEnabled=e}get cameraExposure(){return this._imageProcessingConfiguration.exposure}set cameraExposure(e){this._imageProcessingConfiguration.exposure=e}get cameraContrast(){return this._imageProcessingConfiguration.contrast}set cameraContrast(e){this._imageProcessingConfiguration.contrast=e}get cameraColorGradingTexture(){return this._imageProcessingConfiguration.colorGradingTexture}set cameraColorGradingTexture(e){this._imageProcessingConfiguration.colorGradingTexture=e}get cameraColorCurves(){return this._imageProcessingConfiguration.colorCurves}set cameraColorCurves(e){this._imageProcessingConfiguration.colorCurves=e}get canRenderToMRT(){return!0}constructor(e,t,s=!1){super(e,t,void 0,s||I.ForceGLSL),this._diffuseTexture=null,this._ambientTexture=null,this._opacityTexture=null,this._reflectionTexture=null,this._emissiveTexture=null,this._specularTexture=null,this._bumpTexture=null,this._lightmapTexture=null,this._refractionTexture=null,this.ambientColor=new h.v9(0,0,0),this.diffuseColor=new h.v9(1,1,1),this.specularColor=new h.v9(1,1,1),this.emissiveColor=new h.v9(0,0,0),this.specularPower=64,this._useAlphaFromDiffuseTexture=!1,this._useEmissiveAsIllumination=!1,this._linkEmissiveWithDiffuse=!1,this._useSpecularOverAlpha=!1,this._useReflectionOverAlpha=!1,this._disableLighting=!1,this._useObjectSpaceNormalMap=!1,this._useParallax=!1,this._useParallaxOcclusion=!1,this.parallaxScaleBias=.05,this._roughness=0,this.indexOfRefraction=.98,this.invertRefractionY=!0,this.alphaCutOff=.4,this._useLightmapAsShadowmap=!1,this._useReflectionFresnelFromSpecular=!1,this._useGlossinessFromSpecularMapAlpha=!1,this._maxSimultaneousLights=4,this._invertNormalMapX=!1,this._invertNormalMapY=!1,this._twoSidedLighting=!1,this._applyDecalMapAfterDetailMap=!1,this._shadersLoaded=!1,this._renderTargets=new n.L(16),this._worldViewProjectionMatrix=o.uq.Zero(),this._globalAmbientColor=new h.v9(0,0,0),this._cacheHasRenderTargetTextures=!1,this.detailMap=new R(this),this._attachImageProcessingConfiguration(null),this.prePassConfiguration=new c,this.getRenderTargetTextures=()=>(this._renderTargets.reset(),I.ReflectionTextureEnabled&&this._reflectionTexture&&this._reflectionTexture.isRenderTarget&&this._renderTargets.push(this._reflectionTexture),I.RefractionTextureEnabled&&this._refractionTexture&&this._refractionTexture.isRenderTarget&&this._renderTargets.push(this._refractionTexture),this._eventInfo.renderTargets=this._renderTargets,this._callbackPluginEventFillRenderTargetTextures(this._eventInfo),this._renderTargets)}get hasRenderTargetTextures(){return!!(I.ReflectionTextureEnabled&&this._reflectionTexture&&this._reflectionTexture.isRenderTarget)||!!(I.RefractionTextureEnabled&&this._refractionTexture&&this._refractionTexture.isRenderTarget)||this._cacheHasRenderTargetTextures}getClassName(){return"StandardMaterial"}needAlphaBlending(){return!this._disableAlphaBlending&&(this.alpha<1||null!=this._opacityTexture||this._shouldUseAlphaFromDiffuseTexture()||this._opacityFresnelParameters&&this._opacityFresnelParameters.isEnabled)}needAlphaTesting(){return!!this._forceAlphaTest||this._hasAlphaChannel()&&(null==this._transparencyMode||this._transparencyMode===d.i.MATERIAL_ALPHATEST)}_shouldUseAlphaFromDiffuseTexture(){return null!=this._diffuseTexture&&this._diffuseTexture.hasAlpha&&this._useAlphaFromDiffuseTexture&&this._transparencyMode!==d.i.MATERIAL_OPAQUE}_hasAlphaChannel(){return null!=this._diffuseTexture&&this._diffuseTexture.hasAlpha||null!=this._opacityTexture}getAlphaTestTexture(){return this._diffuseTexture}isReadyForSubMesh(e,t,i=!1){this._uniformBufferLayoutBuilt||this.buildUniformLayout();const r=t._drawWrapper;if(r.effect&&this.isFrozen&&r._wasPreviouslyReady&&r._wasPreviouslyUsingInstances===i)return!0;t.materialDefines||(this._callbackPluginEventGeneric(4,this._eventInfo),t.materialDefines=new S(this._eventInfo.defineNames));const n=this.getScene(),a=t.materialDefines;if(this._isReadyForSubMesh(t))return!0;const o=n.getEngine();a._needNormals=(0,x.az)(n,e,a,!0,this._maxSimultaneousLights,this._disableLighting),(0,x.VO)(n,a);const h=this.needAlphaBlendingForMesh(e)&&this.getScene().useOrderIndependentTransparency;if((0,x.N4)(n,a,this.canRenderToMRT&&!h),(0,x.Nc)(n,a,h),v.PrepareDefines(o.currentRenderPassId,e,a),a._areTexturesDirty){this._eventInfo.hasRenderTargetTextures=!1,this._callbackPluginEventHasRenderTargetTextures(this._eventInfo),this._cacheHasRenderTargetTextures=this._eventInfo.hasRenderTargetTextures,a._needUVs=!1;for(let e=1;e<=6;++e)a["MAINUV"+e]=!1;if(n.texturesEnabled){if(a.DIFFUSEDIRECTUV=0,a.BUMPDIRECTUV=0,a.AMBIENTDIRECTUV=0,a.OPACITYDIRECTUV=0,a.EMISSIVEDIRECTUV=0,a.SPECULARDIRECTUV=0,a.LIGHTMAPDIRECTUV=0,this._diffuseTexture&&I.DiffuseTextureEnabled){if(!this._diffuseTexture.isReadyOrNotBlocking())return!1;(0,x.YT)(this._diffuseTexture,a,"DIFFUSE")}else a.DIFFUSE=!1;if(this._ambientTexture&&I.AmbientTextureEnabled){if(!this._ambientTexture.isReadyOrNotBlocking())return!1;(0,x.YT)(this._ambientTexture,a,"AMBIENT")}else a.AMBIENT=!1;if(this._opacityTexture&&I.OpacityTextureEnabled){if(!this._opacityTexture.isReadyOrNotBlocking())return!1;(0,x.YT)(this._opacityTexture,a,"OPACITY"),a.OPACITYRGB=this._opacityTexture.getAlphaFromRGB}else a.OPACITY=!1;if(this._reflectionTexture&&I.ReflectionTextureEnabled){if(!this._reflectionTexture.isReadyOrNotBlocking())return!1;switch(a._needNormals=!0,a.REFLECTION=!0,a.ROUGHNESS=this._roughness>0,a.REFLECTIONOVERALPHA=this._useReflectionOverAlpha,a.INVERTCUBICMAP=this._reflectionTexture.coordinatesMode===p.g.INVCUBIC_MODE,a.REFLECTIONMAP_3D=this._reflectionTexture.isCube,a.REFLECTIONMAP_OPPOSITEZ=a.REFLECTIONMAP_3D&&this.getScene().useRightHandedSystem?!this._reflectionTexture.invertZ:this._reflectionTexture.invertZ,a.RGBDREFLECTION=this._reflectionTexture.isRGBD,this._reflectionTexture.coordinatesMode){case p.g.EXPLICIT_MODE:a.setReflectionMode("REFLECTIONMAP_EXPLICIT");break;case p.g.PLANAR_MODE:a.setReflectionMode("REFLECTIONMAP_PLANAR");break;case p.g.PROJECTION_MODE:a.setReflectionMode("REFLECTIONMAP_PROJECTION");break;case p.g.SKYBOX_MODE:a.setReflectionMode("REFLECTIONMAP_SKYBOX");break;case p.g.SPHERICAL_MODE:a.setReflectionMode("REFLECTIONMAP_SPHERICAL");break;case p.g.EQUIRECTANGULAR_MODE:a.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR");break;case p.g.FIXED_EQUIRECTANGULAR_MODE:a.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR_FIXED");break;case p.g.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:a.setReflectionMode("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED");break;case p.g.CUBIC_MODE:case p.g.INVCUBIC_MODE:default:a.setReflectionMode("REFLECTIONMAP_CUBIC")}a.USE_LOCAL_REFLECTIONMAP_CUBIC=!!this._reflectionTexture.boundingBoxSize}else a.REFLECTION=!1,a.REFLECTIONMAP_OPPOSITEZ=!1;if(this._emissiveTexture&&I.EmissiveTextureEnabled){if(!this._emissiveTexture.isReadyOrNotBlocking())return!1;(0,x.YT)(this._emissiveTexture,a,"EMISSIVE")}else a.EMISSIVE=!1;if(this._lightmapTexture&&I.LightmapTextureEnabled){if(!this._lightmapTexture.isReadyOrNotBlocking())return!1;(0,x.YT)(this._lightmapTexture,a,"LIGHTMAP"),a.USELIGHTMAPASSHADOWMAP=this._useLightmapAsShadowmap,a.RGBDLIGHTMAP=this._lightmapTexture.isRGBD}else a.LIGHTMAP=!1;if(this._specularTexture&&I.SpecularTextureEnabled){if(!this._specularTexture.isReadyOrNotBlocking())return!1;(0,x.YT)(this._specularTexture,a,"SPECULAR"),a.GLOSSINESS=this._useGlossinessFromSpecularMapAlpha}else a.SPECULAR=!1;if(n.getEngine().getCaps().standardDerivatives&&this._bumpTexture&&I.BumpTextureEnabled){if(!this._bumpTexture.isReady())return!1;(0,x.YT)(this._bumpTexture,a,"BUMP"),a.PARALLAX=this._useParallax,a.PARALLAX_RHS=n.useRightHandedSystem,a.PARALLAXOCCLUSION=this._useParallaxOcclusion,a.OBJECTSPACE_NORMALMAP=this._useObjectSpaceNormalMap}else a.BUMP=!1,a.PARALLAX=!1,a.PARALLAX_RHS=!1,a.PARALLAXOCCLUSION=!1;if(this._refractionTexture&&I.RefractionTextureEnabled){if(!this._refractionTexture.isReadyOrNotBlocking())return!1;a._needUVs=!0,a.REFRACTION=!0,a.REFRACTIONMAP_3D=this._refractionTexture.isCube,a.RGBDREFRACTION=this._refractionTexture.isRGBD,a.USE_LOCAL_REFRACTIONMAP_CUBIC=!!this._refractionTexture.boundingBoxSize}else a.REFRACTION=!1;a.TWOSIDEDLIGHTING=!this._backFaceCulling&&this._twoSidedLighting}else a.DIFFUSE=!1,a.AMBIENT=!1,a.OPACITY=!1,a.REFLECTION=!1,a.EMISSIVE=!1,a.LIGHTMAP=!1,a.BUMP=!1,a.REFRACTION=!1;a.ALPHAFROMDIFFUSE=this._shouldUseAlphaFromDiffuseTexture(),a.EMISSIVEASILLUMINATION=this._useEmissiveAsIllumination,a.LINKEMISSIVEWITHDIFFUSE=this._linkEmissiveWithDiffuse,a.SPECULAROVERALPHA=this._useSpecularOverAlpha,a.PREMULTIPLYALPHA=7===this.alphaMode||8===this.alphaMode,a.ALPHATEST_AFTERALLALPHACOMPUTATIONS=null!==this.transparencyMode,a.ALPHABLEND=null===this.transparencyMode||this.needAlphaBlendingForMesh(e)}if(this._eventInfo.isReadyForSubMesh=!0,this._eventInfo.defines=a,this._eventInfo.subMesh=t,this._callbackPluginEventIsReadyForSubMesh(this._eventInfo),!this._eventInfo.isReadyForSubMesh)return!1;if(a._areImageProcessingDirty&&this._imageProcessingConfiguration){if(!this._imageProcessingConfiguration.isReady())return!1;this._imageProcessingConfiguration.prepareDefines(a),a.IS_REFLECTION_LINEAR=null!=this.reflectionTexture&&!this.reflectionTexture.gammaSpace,a.IS_REFRACTION_LINEAR=null!=this.refractionTexture&&!this.refractionTexture.gammaSpace}a._areFresnelDirty&&(I.FresnelEnabled?(this._diffuseFresnelParameters||this._opacityFresnelParameters||this._emissiveFresnelParameters||this._refractionFresnelParameters||this._reflectionFresnelParameters)&&(a.DIFFUSEFRESNEL=this._diffuseFresnelParameters&&this._diffuseFresnelParameters.isEnabled,a.OPACITYFRESNEL=this._opacityFresnelParameters&&this._opacityFresnelParameters.isEnabled,a.REFLECTIONFRESNEL=this._reflectionFresnelParameters&&this._reflectionFresnelParameters.isEnabled,a.REFLECTIONFRESNELFROMSPECULAR=this._useReflectionFresnelFromSpecular,a.REFRACTIONFRESNEL=this._refractionFresnelParameters&&this._refractionFresnelParameters.isEnabled,a.EMISSIVEFRESNEL=this._emissiveFresnelParameters&&this._emissiveFresnelParameters.isEnabled,a._needNormals=!0,a.FRESNEL=!0):a.FRESNEL=!1),(0,x.fm)(e,n,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e)||this._forceAlphaTest,a,this._applyDecalMapAfterDetailMap),(0,x.OR)(n,o,this,a,i,null,t.getRenderingMesh().hasThinInstances),this._eventInfo.defines=a,this._eventInfo.mesh=e,this._callbackPluginEventPrepareDefinesBeforeAttributes(this._eventInfo),(0,x.qB)(e,a,!0,!0,!0),this._callbackPluginEventPrepareDefines(this._eventInfo);let d=!1;if(a.isDirty){const i=a._areLightsDisposed;a.markAsProcessed();const r=new b.J;a.REFLECTION&&r.addFallback(0,"REFLECTION"),a.SPECULAR&&r.addFallback(0,"SPECULAR"),a.BUMP&&r.addFallback(0,"BUMP"),a.PARALLAX&&r.addFallback(1,"PARALLAX"),a.PARALLAX_RHS&&r.addFallback(1,"PARALLAX_RHS"),a.PARALLAXOCCLUSION&&r.addFallback(0,"PARALLAXOCCLUSION"),a.SPECULAROVERALPHA&&r.addFallback(0,"SPECULAROVERALPHA"),a.FOG&&r.addFallback(1,"FOG"),a.POINTSIZE&&r.addFallback(0,"POINTSIZE"),a.LOGARITHMICDEPTH&&r.addFallback(0,"LOGARITHMICDEPTH"),(0,x.c4)(a,r,this._maxSimultaneousLights),a.SPECULARTERM&&r.addFallback(0,"SPECULARTERM"),a.DIFFUSEFRESNEL&&r.addFallback(1,"DIFFUSEFRESNEL"),a.OPACITYFRESNEL&&r.addFallback(2,"OPACITYFRESNEL"),a.REFLECTIONFRESNEL&&r.addFallback(3,"REFLECTIONFRESNEL"),a.EMISSIVEFRESNEL&&r.addFallback(4,"EMISSIVEFRESNEL"),a.FRESNEL&&r.addFallback(4,"FRESNEL"),a.MULTIVIEW&&r.addFallback(0,"MULTIVIEW");const h=[l.R.PositionKind];a.NORMAL&&h.push(l.R.NormalKind),a.TANGENT&&h.push(l.R.TangentKind);for(let e=1;e<=6;++e)a["UV"+e]&&h.push(`uv${1===e?"":e}`);a.VERTEXCOLOR&&h.push(l.R.ColorKind),(0,x.ni)(h,e,a,r),(0,x.ER)(h,a),(0,x.IF)(h,e,a),(0,x.J2)(h,e,a);let _="default";const f=["world","view","viewProjection","vEyePosition","vLightsType","vAmbientColor","vDiffuseColor","vSpecularColor","vEmissiveColor","visibility","vFogInfos","vFogColor","pointSize","vDiffuseInfos","vAmbientInfos","vOpacityInfos","vReflectionInfos","vEmissiveInfos","vSpecularInfos","vBumpInfos","vLightmapInfos","vRefractionInfos","mBones","diffuseMatrix","ambientMatrix","opacityMatrix","reflectionMatrix","emissiveMatrix","specularMatrix","bumpMatrix","normalMatrix","lightmapMatrix","refractionMatrix","diffuseLeftColor","diffuseRightColor","opacityParts","reflectionLeftColor","reflectionRightColor","emissiveLeftColor","emissiveRightColor","refractionLeftColor","refractionRightColor","vReflectionPosition","vReflectionSize","vRefractionPosition","vRefractionSize","logarithmicDepthConstant","vTangentSpaceParams","alphaCutOff","boneTextureWidth","morphTargetTextureInfo","morphTargetTextureIndices"],p=["diffuseSampler","ambientSampler","opacitySampler","reflectionCubeSampler","reflection2DSampler","emissiveSampler","specularSampler","bumpSampler","lightmapSampler","refractionCubeSampler","refraction2DSampler","boneSampler","morphTargets","oitDepthSampler","oitFrontColorSampler"],g=["Material","Scene","Mesh"],m={maxSimultaneousLights:this._maxSimultaneousLights,maxSimultaneousMorphTargets:a.NUM_MORPH_INFLUENCERS};this._eventInfo.fallbacks=r,this._eventInfo.fallbackRank=0,this._eventInfo.defines=a,this._eventInfo.uniforms=f,this._eventInfo.attributes=h,this._eventInfo.samplers=p,this._eventInfo.uniformBuffersNames=g,this._eventInfo.customCode=void 0,this._eventInfo.mesh=e,this._eventInfo.indexParameters=m,this._callbackPluginEventGeneric(128,this._eventInfo),v.AddUniformsAndSamplers(f,p),c.AddUniforms(f),c.AddSamplers(p),u.p&&(u.p.PrepareUniforms(f,a),u.p.PrepareSamplers(p,a)),(0,x.Bb)({uniformsNames:f,uniformBuffersNames:g,samplers:p,defines:a,maxSimultaneousLights:this._maxSimultaneousLights}),(0,y.TV)(f);const T={};this.customShaderNameResolve&&(_=this.customShaderNameResolve(_,f,g,p,a,h,T));const E=a.toString(),A=t.effect;let R=n.getEngine().createEffect(_,{attributes:h,uniformsNames:f,uniformBuffersNames:g,samplers:p,defines:E,fallbacks:r,onCompiled:this.onCompiled,onError:this.onError,indexParameters:m,processFinalCode:T.processFinalCode,processCodeAfterIncludes:this._eventInfo.customCode,multiTarget:a.PREPASS,shaderLanguage:this._shaderLanguage,extraInitializationsAsync:this._shadersLoaded?void 0:async()=>{1===this._shaderLanguage?await Promise.all([s.e(126).then(s.bind(s,6234)),s.e(126).then(s.bind(s,2727))]):await Promise.all([s.e(71).then(s.bind(s,5735)),s.e(71).then(s.bind(s,9041))]),this._shadersLoaded=!0}},o);if(this._eventInfo.customCode=void 0,R)if(this._onEffectCreatedObservable&&(C.effect=R,C.subMesh=t,this._onEffectCreatedObservable.notifyObservers(C)),this.allowShaderHotSwapping&&A&&!R.isReady()){if(R=A,a.markAsUnprocessed(),d=this.isFrozen,i)return a._areLightsDisposed=!0,!1}else n.resetCachedMaterial(),t.setEffect(R,a,this._materialContext)}return!(!t.effect||!t.effect.isReady()||(a._renderId=n.getRenderId(),r._wasPreviouslyReady=!d,r._wasPreviouslyUsingInstances=i,this._checkScenePerformancePriority(),0))}buildUniformLayout(){const e=this._uniformBuffer;e.addUniform("diffuseLeftColor",4),e.addUniform("diffuseRightColor",4),e.addUniform("opacityParts",4),e.addUniform("reflectionLeftColor",4),e.addUniform("reflectionRightColor",4),e.addUniform("refractionLeftColor",4),e.addUniform("refractionRightColor",4),e.addUniform("emissiveLeftColor",4),e.addUniform("emissiveRightColor",4),e.addUniform("vDiffuseInfos",2),e.addUniform("vAmbientInfos",2),e.addUniform("vOpacityInfos",2),e.addUniform("vReflectionInfos",2),e.addUniform("vReflectionPosition",3),e.addUniform("vReflectionSize",3),e.addUniform("vEmissiveInfos",2),e.addUniform("vLightmapInfos",2),e.addUniform("vSpecularInfos",2),e.addUniform("vBumpInfos",3),e.addUniform("diffuseMatrix",16),e.addUniform("ambientMatrix",16),e.addUniform("opacityMatrix",16),e.addUniform("reflectionMatrix",16),e.addUniform("emissiveMatrix",16),e.addUniform("lightmapMatrix",16),e.addUniform("specularMatrix",16),e.addUniform("bumpMatrix",16),e.addUniform("vTangentSpaceParams",2),e.addUniform("pointSize",1),e.addUniform("alphaCutOff",1),e.addUniform("refractionMatrix",16),e.addUniform("vRefractionInfos",4),e.addUniform("vRefractionPosition",3),e.addUniform("vRefractionSize",3),e.addUniform("vSpecularColor",4),e.addUniform("vEmissiveColor",3),e.addUniform("vDiffuseColor",4),e.addUniform("vAmbientColor",3),super.buildUniformLayout()}bindForSubMesh(e,t,s){const i=this.getScene(),r=s.materialDefines;if(!r)return;const n=s.effect;if(!n)return;this._activeEffect=n,t.getMeshUniformBuffer().bindToEffect(n,"Mesh"),t.transferToEffect(e),this._uniformBuffer.bindToEffect(n,"Material"),this.prePassConfiguration.bindForSubMesh(this._activeEffect,i,t,e,this.isFrozen),v.Bind(i.getEngine().currentRenderPassId,this._activeEffect,t,e),this._eventInfo.subMesh=s,this._callbackPluginEventHardBindForSubMesh(this._eventInfo),r.OBJECTSPACE_NORMALMAP&&(e.toNormalMatrix(this._normalMatrix),this.bindOnlyNormalMatrix(this._normalMatrix));const o=this._mustRebind(i,n,s,t.visibility);(0,x.f$)(t,n);const l=this._uniformBuffer;if(o){if(this.bindViewProjection(n),!l.useUbo||!this.isFrozen||!l.isSync||s._drawWrapper._forceRebindOnNextCall){if(I.FresnelEnabled&&r.FRESNEL&&(this.diffuseFresnelParameters&&this.diffuseFresnelParameters.isEnabled&&(l.updateColor4("diffuseLeftColor",this.diffuseFresnelParameters.leftColor,this.diffuseFresnelParameters.power),l.updateColor4("diffuseRightColor",this.diffuseFresnelParameters.rightColor,this.diffuseFresnelParameters.bias)),this.opacityFresnelParameters&&this.opacityFresnelParameters.isEnabled&&l.updateColor4("opacityParts",new h.v9(this.opacityFresnelParameters.leftColor.toLuminance(),this.opacityFresnelParameters.rightColor.toLuminance(),this.opacityFresnelParameters.bias),this.opacityFresnelParameters.power),this.reflectionFresnelParameters&&this.reflectionFresnelParameters.isEnabled&&(l.updateColor4("reflectionLeftColor",this.reflectionFresnelParameters.leftColor,this.reflectionFresnelParameters.power),l.updateColor4("reflectionRightColor",this.reflectionFresnelParameters.rightColor,this.reflectionFresnelParameters.bias)),this.refractionFresnelParameters&&this.refractionFresnelParameters.isEnabled&&(l.updateColor4("refractionLeftColor",this.refractionFresnelParameters.leftColor,this.refractionFresnelParameters.power),l.updateColor4("refractionRightColor",this.refractionFresnelParameters.rightColor,this.refractionFresnelParameters.bias)),this.emissiveFresnelParameters&&this.emissiveFresnelParameters.isEnabled&&(l.updateColor4("emissiveLeftColor",this.emissiveFresnelParameters.leftColor,this.emissiveFresnelParameters.power),l.updateColor4("emissiveRightColor",this.emissiveFresnelParameters.rightColor,this.emissiveFresnelParameters.bias))),i.texturesEnabled){if(this._diffuseTexture&&I.DiffuseTextureEnabled&&(l.updateFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),(0,x.mA)(this._diffuseTexture,l,"diffuse")),this._ambientTexture&&I.AmbientTextureEnabled&&(l.updateFloat2("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level),(0,x.mA)(this._ambientTexture,l,"ambient")),this._opacityTexture&&I.OpacityTextureEnabled&&(l.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),(0,x.mA)(this._opacityTexture,l,"opacity")),this._hasAlphaChannel()&&l.updateFloat("alphaCutOff",this.alphaCutOff),this._reflectionTexture&&I.ReflectionTextureEnabled&&(l.updateFloat2("vReflectionInfos",this._reflectionTexture.level,this.roughness),l.updateMatrix("reflectionMatrix",this._reflectionTexture.getReflectionTextureMatrix()),this._reflectionTexture.boundingBoxSize)){const e=this._reflectionTexture;l.updateVector3("vReflectionPosition",e.boundingBoxPosition),l.updateVector3("vReflectionSize",e.boundingBoxSize)}if(this._emissiveTexture&&I.EmissiveTextureEnabled&&(l.updateFloat2("vEmissiveInfos",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),(0,x.mA)(this._emissiveTexture,l,"emissive")),this._lightmapTexture&&I.LightmapTextureEnabled&&(l.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),(0,x.mA)(this._lightmapTexture,l,"lightmap")),this._specularTexture&&I.SpecularTextureEnabled&&(l.updateFloat2("vSpecularInfos",this._specularTexture.coordinatesIndex,this._specularTexture.level),(0,x.mA)(this._specularTexture,l,"specular")),this._bumpTexture&&i.getEngine().getCaps().standardDerivatives&&I.BumpTextureEnabled&&(l.updateFloat3("vBumpInfos",this._bumpTexture.coordinatesIndex,1/this._bumpTexture.level,this.parallaxScaleBias),(0,x.mA)(this._bumpTexture,l,"bump"),i._mirroredCameraPosition?l.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?1:-1,this._invertNormalMapY?1:-1):l.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?-1:1,this._invertNormalMapY?-1:1)),this._refractionTexture&&I.RefractionTextureEnabled){let e=1;if(this._refractionTexture.isCube||(l.updateMatrix("refractionMatrix",this._refractionTexture.getReflectionTextureMatrix()),this._refractionTexture.depth&&(e=this._refractionTexture.depth)),l.updateFloat4("vRefractionInfos",this._refractionTexture.level,this.indexOfRefraction,e,this.invertRefractionY?-1:1),this._refractionTexture.boundingBoxSize){const e=this._refractionTexture;l.updateVector3("vRefractionPosition",e.boundingBoxPosition),l.updateVector3("vRefractionSize",e.boundingBoxSize)}}}this.pointsCloud&&l.updateFloat("pointSize",this.pointSize),l.updateColor4("vSpecularColor",this.specularColor,this.specularPower),l.updateColor3("vEmissiveColor",I.EmissiveTextureEnabled?this.emissiveColor:h.v9.BlackReadOnly),l.updateColor4("vDiffuseColor",this.diffuseColor,this.alpha),i.ambientColor.multiplyToRef(this.ambientColor,this._globalAmbientColor),l.updateColor3("vAmbientColor",this._globalAmbientColor)}i.texturesEnabled&&(this._diffuseTexture&&I.DiffuseTextureEnabled&&n.setTexture("diffuseSampler",this._diffuseTexture),this._ambientTexture&&I.AmbientTextureEnabled&&n.setTexture("ambientSampler",this._ambientTexture),this._opacityTexture&&I.OpacityTextureEnabled&&n.setTexture("opacitySampler",this._opacityTexture),this._reflectionTexture&&I.ReflectionTextureEnabled&&(this._reflectionTexture.isCube?n.setTexture("reflectionCubeSampler",this._reflectionTexture):n.setTexture("reflection2DSampler",this._reflectionTexture)),this._emissiveTexture&&I.EmissiveTextureEnabled&&n.setTexture("emissiveSampler",this._emissiveTexture),this._lightmapTexture&&I.LightmapTextureEnabled&&n.setTexture("lightmapSampler",this._lightmapTexture),this._specularTexture&&I.SpecularTextureEnabled&&n.setTexture("specularSampler",this._specularTexture),this._bumpTexture&&i.getEngine().getCaps().standardDerivatives&&I.BumpTextureEnabled&&n.setTexture("bumpSampler",this._bumpTexture),this._refractionTexture&&I.RefractionTextureEnabled&&(this._refractionTexture.isCube?n.setTexture("refractionCubeSampler",this._refractionTexture):n.setTexture("refraction2DSampler",this._refractionTexture))),this.getScene().useOrderIndependentTransparency&&this.needAlphaBlendingForMesh(t)&&this.getScene().depthPeelingRenderer.bind(n),this._eventInfo.subMesh=s,this._callbackPluginEventBindForSubMesh(this._eventInfo),(0,y.gS)(n,this,i),this.bindEyePosition(n)}else i.getEngine()._features.needToAlwaysBindUniformBuffers&&(this._needToBindSceneUbo=!0);!o&&this.isFrozen||(i.lightsEnabled&&!this._disableLighting&&(0,x.RL)(i,t,n,r,this._maxSimultaneousLights),(i.fogEnabled&&t.applyFog&&i.fogMode!==a.Z.FOGMODE_NONE||this._reflectionTexture||this._refractionTexture||t.receiveShadows||r.PREPASS)&&this.bindView(n),(0,x.Yy)(i,t,n),r.NUM_MORPH_INFLUENCERS&&(0,x.nR)(t,n),r.BAKED_VERTEX_ANIMATION_TEXTURE&&t.bakedVertexAnimationManager?.bind(n,r.INSTANCES),this.useLogarithmicDepth&&(0,x.DL)(r,n,i),this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.applyByPostProcess&&this._imageProcessingConfiguration.bind(this._activeEffect)),this._afterBind(t,this._activeEffect,s),l.update()}getAnimatables(){const e=super.getAnimatables();return this._diffuseTexture&&this._diffuseTexture.animations&&this._diffuseTexture.animations.length>0&&e.push(this._diffuseTexture),this._ambientTexture&&this._ambientTexture.animations&&this._ambientTexture.animations.length>0&&e.push(this._ambientTexture),this._opacityTexture&&this._opacityTexture.animations&&this._opacityTexture.animations.length>0&&e.push(this._opacityTexture),this._reflectionTexture&&this._reflectionTexture.animations&&this._reflectionTexture.animations.length>0&&e.push(this._reflectionTexture),this._emissiveTexture&&this._emissiveTexture.animations&&this._emissiveTexture.animations.length>0&&e.push(this._emissiveTexture),this._specularTexture&&this._specularTexture.animations&&this._specularTexture.animations.length>0&&e.push(this._specularTexture),this._bumpTexture&&this._bumpTexture.animations&&this._bumpTexture.animations.length>0&&e.push(this._bumpTexture),this._lightmapTexture&&this._lightmapTexture.animations&&this._lightmapTexture.animations.length>0&&e.push(this._lightmapTexture),this._refractionTexture&&this._refractionTexture.animations&&this._refractionTexture.animations.length>0&&e.push(this._refractionTexture),e}getActiveTextures(){const e=super.getActiveTextures();return this._diffuseTexture&&e.push(this._diffuseTexture),this._ambientTexture&&e.push(this._ambientTexture),this._opacityTexture&&e.push(this._opacityTexture),this._reflectionTexture&&e.push(this._reflectionTexture),this._emissiveTexture&&e.push(this._emissiveTexture),this._specularTexture&&e.push(this._specularTexture),this._bumpTexture&&e.push(this._bumpTexture),this._lightmapTexture&&e.push(this._lightmapTexture),this._refractionTexture&&e.push(this._refractionTexture),e}hasTexture(e){return!!super.hasTexture(e)||this._diffuseTexture===e||this._ambientTexture===e||this._opacityTexture===e||this._reflectionTexture===e||this._emissiveTexture===e||this._specularTexture===e||this._bumpTexture===e||this._lightmapTexture===e||this._refractionTexture===e}dispose(e,t){t&&(this._diffuseTexture?.dispose(),this._ambientTexture?.dispose(),this._opacityTexture?.dispose(),this._reflectionTexture?.dispose(),this._emissiveTexture?.dispose(),this._specularTexture?.dispose(),this._bumpTexture?.dispose(),this._lightmapTexture?.dispose(),this._refractionTexture?.dispose()),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),super.dispose(e,t)}clone(e,t=!0,s=""){const i=P.p.Clone((()=>new I(e,this.getScene())),this,{cloneTexturesOnlyOnce:t});return i.name=e,i.id=e,this.stencil.copyTo(i.stencil),this._clonePlugins(i,s),i}static Parse(e,t,s){const i=P.p.Parse((()=>new I(e.name,t)),e,t,s);return e.stencil&&i.stencil.parse(e.stencil,t,s),d.i._ParsePlugins(e,i,t,s),i}static get DiffuseTextureEnabled(){return T.DiffuseTextureEnabled}static set DiffuseTextureEnabled(e){T.DiffuseTextureEnabled=e}static get DetailTextureEnabled(){return T.DetailTextureEnabled}static set DetailTextureEnabled(e){T.DetailTextureEnabled=e}static get AmbientTextureEnabled(){return T.AmbientTextureEnabled}static set AmbientTextureEnabled(e){T.AmbientTextureEnabled=e}static get OpacityTextureEnabled(){return T.OpacityTextureEnabled}static set OpacityTextureEnabled(e){T.OpacityTextureEnabled=e}static get ReflectionTextureEnabled(){return T.ReflectionTextureEnabled}static set ReflectionTextureEnabled(e){T.ReflectionTextureEnabled=e}static get EmissiveTextureEnabled(){return T.EmissiveTextureEnabled}static set EmissiveTextureEnabled(e){T.EmissiveTextureEnabled=e}static get SpecularTextureEnabled(){return T.SpecularTextureEnabled}static set SpecularTextureEnabled(e){T.SpecularTextureEnabled=e}static get BumpTextureEnabled(){return T.BumpTextureEnabled}static set BumpTextureEnabled(e){T.BumpTextureEnabled=e}static get LightmapTextureEnabled(){return T.LightmapTextureEnabled}static set LightmapTextureEnabled(e){T.LightmapTextureEnabled=e}static get RefractionTextureEnabled(){return T.RefractionTextureEnabled}static set RefractionTextureEnabled(e){T.RefractionTextureEnabled=e}static get ColorGradingTextureEnabled(){return T.ColorGradingTextureEnabled}static set ColorGradingTextureEnabled(e){T.ColorGradingTextureEnabled=e}static get FresnelEnabled(){return T.FresnelEnabled}static set FresnelEnabled(e){T.FresnelEnabled=e}}I.ForceGLSL=!1,(0,i.Cg)([(0,r.uM)("diffuseTexture")],I.prototype,"_diffuseTexture",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsTexturesAndMiscDirty")],I.prototype,"diffuseTexture",void 0),(0,i.Cg)([(0,r.uM)("ambientTexture")],I.prototype,"_ambientTexture",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsTexturesDirty")],I.prototype,"ambientTexture",void 0),(0,i.Cg)([(0,r.uM)("opacityTexture")],I.prototype,"_opacityTexture",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsTexturesAndMiscDirty")],I.prototype,"opacityTexture",void 0),(0,i.Cg)([(0,r.uM)("reflectionTexture")],I.prototype,"_reflectionTexture",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsTexturesDirty")],I.prototype,"reflectionTexture",void 0),(0,i.Cg)([(0,r.uM)("emissiveTexture")],I.prototype,"_emissiveTexture",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsTexturesDirty")],I.prototype,"emissiveTexture",void 0),(0,i.Cg)([(0,r.uM)("specularTexture")],I.prototype,"_specularTexture",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsTexturesDirty")],I.prototype,"specularTexture",void 0),(0,i.Cg)([(0,r.uM)("bumpTexture")],I.prototype,"_bumpTexture",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsTexturesDirty")],I.prototype,"bumpTexture",void 0),(0,i.Cg)([(0,r.uM)("lightmapTexture")],I.prototype,"_lightmapTexture",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsTexturesDirty")],I.prototype,"lightmapTexture",void 0),(0,i.Cg)([(0,r.uM)("refractionTexture")],I.prototype,"_refractionTexture",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsTexturesDirty")],I.prototype,"refractionTexture",void 0),(0,i.Cg)([(0,r.jT)("ambient")],I.prototype,"ambientColor",void 0),(0,i.Cg)([(0,r.jT)("diffuse")],I.prototype,"diffuseColor",void 0),(0,i.Cg)([(0,r.jT)("specular")],I.prototype,"specularColor",void 0),(0,i.Cg)([(0,r.jT)("emissive")],I.prototype,"emissiveColor",void 0),(0,i.Cg)([(0,r.lK)()],I.prototype,"specularPower",void 0),(0,i.Cg)([(0,r.lK)("useAlphaFromDiffuseTexture")],I.prototype,"_useAlphaFromDiffuseTexture",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsTexturesAndMiscDirty")],I.prototype,"useAlphaFromDiffuseTexture",void 0),(0,i.Cg)([(0,r.lK)("useEmissiveAsIllumination")],I.prototype,"_useEmissiveAsIllumination",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsTexturesDirty")],I.prototype,"useEmissiveAsIllumination",void 0),(0,i.Cg)([(0,r.lK)("linkEmissiveWithDiffuse")],I.prototype,"_linkEmissiveWithDiffuse",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsTexturesDirty")],I.prototype,"linkEmissiveWithDiffuse",void 0),(0,i.Cg)([(0,r.lK)("useSpecularOverAlpha")],I.prototype,"_useSpecularOverAlpha",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsTexturesDirty")],I.prototype,"useSpecularOverAlpha",void 0),(0,i.Cg)([(0,r.lK)("useReflectionOverAlpha")],I.prototype,"_useReflectionOverAlpha",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsTexturesDirty")],I.prototype,"useReflectionOverAlpha",void 0),(0,i.Cg)([(0,r.lK)("disableLighting")],I.prototype,"_disableLighting",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsLightsDirty")],I.prototype,"disableLighting",void 0),(0,i.Cg)([(0,r.lK)("useObjectSpaceNormalMap")],I.prototype,"_useObjectSpaceNormalMap",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsTexturesDirty")],I.prototype,"useObjectSpaceNormalMap",void 0),(0,i.Cg)([(0,r.lK)("useParallax")],I.prototype,"_useParallax",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsTexturesDirty")],I.prototype,"useParallax",void 0),(0,i.Cg)([(0,r.lK)("useParallaxOcclusion")],I.prototype,"_useParallaxOcclusion",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsTexturesDirty")],I.prototype,"useParallaxOcclusion",void 0),(0,i.Cg)([(0,r.lK)()],I.prototype,"parallaxScaleBias",void 0),(0,i.Cg)([(0,r.lK)("roughness")],I.prototype,"_roughness",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsTexturesDirty")],I.prototype,"roughness",void 0),(0,i.Cg)([(0,r.lK)()],I.prototype,"indexOfRefraction",void 0),(0,i.Cg)([(0,r.lK)()],I.prototype,"invertRefractionY",void 0),(0,i.Cg)([(0,r.lK)()],I.prototype,"alphaCutOff",void 0),(0,i.Cg)([(0,r.lK)("useLightmapAsShadowmap")],I.prototype,"_useLightmapAsShadowmap",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsTexturesDirty")],I.prototype,"useLightmapAsShadowmap",void 0),(0,i.Cg)([(0,r.Y9)("diffuseFresnelParameters")],I.prototype,"_diffuseFresnelParameters",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsFresnelDirty")],I.prototype,"diffuseFresnelParameters",void 0),(0,i.Cg)([(0,r.Y9)("opacityFresnelParameters")],I.prototype,"_opacityFresnelParameters",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsFresnelAndMiscDirty")],I.prototype,"opacityFresnelParameters",void 0),(0,i.Cg)([(0,r.Y9)("reflectionFresnelParameters")],I.prototype,"_reflectionFresnelParameters",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsFresnelDirty")],I.prototype,"reflectionFresnelParameters",void 0),(0,i.Cg)([(0,r.Y9)("refractionFresnelParameters")],I.prototype,"_refractionFresnelParameters",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsFresnelDirty")],I.prototype,"refractionFresnelParameters",void 0),(0,i.Cg)([(0,r.Y9)("emissiveFresnelParameters")],I.prototype,"_emissiveFresnelParameters",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsFresnelDirty")],I.prototype,"emissiveFresnelParameters",void 0),(0,i.Cg)([(0,r.lK)("useReflectionFresnelFromSpecular")],I.prototype,"_useReflectionFresnelFromSpecular",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsFresnelDirty")],I.prototype,"useReflectionFresnelFromSpecular",void 0),(0,i.Cg)([(0,r.lK)("useGlossinessFromSpecularMapAlpha")],I.prototype,"_useGlossinessFromSpecularMapAlpha",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsTexturesDirty")],I.prototype,"useGlossinessFromSpecularMapAlpha",void 0),(0,i.Cg)([(0,r.lK)("maxSimultaneousLights")],I.prototype,"_maxSimultaneousLights",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsLightsDirty")],I.prototype,"maxSimultaneousLights",void 0),(0,i.Cg)([(0,r.lK)("invertNormalMapX")],I.prototype,"_invertNormalMapX",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsTexturesDirty")],I.prototype,"invertNormalMapX",void 0),(0,i.Cg)([(0,r.lK)("invertNormalMapY")],I.prototype,"_invertNormalMapY",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsTexturesDirty")],I.prototype,"invertNormalMapY",void 0),(0,i.Cg)([(0,r.lK)("twoSidedLighting")],I.prototype,"_twoSidedLighting",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsTexturesDirty")],I.prototype,"twoSidedLighting",void 0),(0,i.Cg)([(0,r.lK)("applyDecalMapAfterDetailMap")],I.prototype,"_applyDecalMapAfterDetailMap",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsMiscDirty")],I.prototype,"applyDecalMapAfterDetailMap",void 0),(0,g.Y5)("BABYLON.StandardMaterial",I),a.Z.DefaultMaterialFactory=e=>new I("default material",e)},935:(e,t,s)=>{s.d(t,{D:()=>n});var i=s(1137),r=s(998);class n{constructor(e,t,s,i,r=!1){this._valueCache={},this._engine=e,this._noUBO=!e.supportsUniformBuffers||r,this._dynamic=s,this._name=i??"no-name",this._data=t||[],this._uniformLocations={},this._uniformSizes={},this._uniformArraySizes={},this._uniformLocationPointer=0,this._needSync=!1,this._engine._features.trackUbosInFrame&&(this._buffers=[],this._bufferIndex=-1,this._createBufferOnWrite=!1,this._currentFrameId=0),this._noUBO?(this.updateMatrix3x3=this._updateMatrix3x3ForEffect,this.updateMatrix2x2=this._updateMatrix2x2ForEffect,this.updateFloat=this._updateFloatForEffect,this.updateFloat2=this._updateFloat2ForEffect,this.updateFloat3=this._updateFloat3ForEffect,this.updateFloat4=this._updateFloat4ForEffect,this.updateFloatArray=this._updateFloatArrayForEffect,this.updateArray=this._updateArrayForEffect,this.updateIntArray=this._updateIntArrayForEffect,this.updateUIntArray=this._updateUIntArrayForEffect,this.updateMatrix=this._updateMatrixForEffect,this.updateMatrices=this._updateMatricesForEffect,this.updateVector3=this._updateVector3ForEffect,this.updateVector4=this._updateVector4ForEffect,this.updateColor3=this._updateColor3ForEffect,this.updateColor4=this._updateColor4ForEffect,this.updateDirectColor4=this._updateDirectColor4ForEffect,this.updateInt=this._updateIntForEffect,this.updateInt2=this._updateInt2ForEffect,this.updateInt3=this._updateInt3ForEffect,this.updateInt4=this._updateInt4ForEffect,this.updateUInt=this._updateUIntForEffect,this.updateUInt2=this._updateUInt2ForEffect,this.updateUInt3=this._updateUInt3ForEffect,this.updateUInt4=this._updateUInt4ForEffect):(this._engine._uniformBuffers.push(this),this.updateMatrix3x3=this._updateMatrix3x3ForUniform,this.updateMatrix2x2=this._updateMatrix2x2ForUniform,this.updateFloat=this._updateFloatForUniform,this.updateFloat2=this._updateFloat2ForUniform,this.updateFloat3=this._updateFloat3ForUniform,this.updateFloat4=this._updateFloat4ForUniform,this.updateFloatArray=this._updateFloatArrayForUniform,this.updateArray=this._updateArrayForUniform,this.updateIntArray=this._updateIntArrayForUniform,this.updateUIntArray=this._updateUIntArrayForUniform,this.updateMatrix=this._updateMatrixForUniform,this.updateMatrices=this._updateMatricesForUniform,this.updateVector3=this._updateVector3ForUniform,this.updateVector4=this._updateVector4ForUniform,this.updateColor3=this._updateColor3ForUniform,this.updateColor4=this._updateColor4ForUniform,this.updateDirectColor4=this._updateDirectColor4ForUniform,this.updateInt=this._updateIntForUniform,this.updateInt2=this._updateInt2ForUniform,this.updateInt3=this._updateInt3ForUniform,this.updateInt4=this._updateInt4ForUniform,this.updateUInt=this._updateUIntForUniform,this.updateUInt2=this._updateUInt2ForUniform,this.updateUInt3=this._updateUInt3ForUniform,this.updateUInt4=this._updateUInt4ForUniform)}get useUbo(){return!this._noUBO}get isSync(){return!this._needSync}isDynamic(){return void 0!==this._dynamic}getData(){return this._bufferData}getBuffer(){return this._buffer}_fillAlignment(e){let t;if(t=e<=2?e:4,this._uniformLocationPointer%t!=0){const e=this._uniformLocationPointer;this._uniformLocationPointer+=t-this._uniformLocationPointer%t;const s=this._uniformLocationPointer-e;for(let e=0;e0){if(t instanceof Array)throw"addUniform should not be use with Array in UBO: "+e;this._fillAlignment(4),this._uniformArraySizes[e]={strideSize:t,arraySize:s},16==t?t*=s:t=t*s+(4-t)*s,i=[];for(let e=0;e1&&this._buffers[this._bufferIndex][1]){if(this._buffersEqual(this._bufferData,this._buffers[this._bufferIndex][1]))return this._needSync=!1,void(this._createBufferOnWrite=this._engine._features.trackUbosInFrame);this._copyBuffer(this._bufferData,this._buffers[this._bufferIndex][1])}this._engine.updateUniformBuffer(this._buffer,this._bufferData),this._engine._features._collectUbosUpdatedInFrame&&(n._UpdatedUbosInFrame[this._name]||(n._UpdatedUbosInFrame[this._name]=0),n._UpdatedUbosInFrame[this._name]++),this._needSync=!1,this._createBufferOnWrite=this._engine._features.trackUbosInFrame}else this._createBufferOnWrite=this._engine._features.trackUbosInFrame;else this.create()}_createNewBuffer(){this._bufferIndex+10?(this._needSync=0!==this._bufferIndex,this._bufferIndex=0,this._buffer=this._buffers[this._bufferIndex][0]):this._bufferIndex=-1)}updateUniform(e,t,s){this._checkNewFrame();let r=this._uniformLocations[e];if(void 0===r){if(this._buffer)return void i.V.Error("Cannot add an uniform after UBO has been created. uniformName="+e);this.addUniform(e,s),r=this._uniformLocations[e]}if(this._buffer||this.create(),this._dynamic)for(let e=0;e{s.d(t,{_0:()=>a});var i,r,n=s(9923);!function(e){e[e.LOCAL=0]="LOCAL",e[e.WORLD=1]="WORLD",e[e.BONE=2]="BONE"}(i||(i={}));class a{}a.X=new n.Pq(1,0,0),a.Y=new n.Pq(0,1,0),a.Z=new n.Pq(0,0,1),function(e){e[e.X=0]="X",e[e.Y=1]="Y",e[e.Z=2]="Z"}(r||(r={}))},6041:(e,t,s)=>{s.d(t,{IG:()=>_,ov:()=>d,v9:()=>u});var i=s(7309),r=s(6552),n=s(5559),a=s(4867);function o(e){return Math.pow(e,n.tk)}function h(e){return e<=.04045?.0773993808*e:Math.pow(.947867299*(e+.055),2.4)}function l(e){return Math.pow(e,n.rv)}function c(e){return e<=.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}class u{constructor(e=0,t=0,s=0){this.r=e,this.g=t,this.b=s}toString(){return"{R: "+this.r+" G:"+this.g+" B:"+this.b+"}"}getClassName(){return"Color3"}getHashCode(){let e=255*this.r|0;return e=397*e^(255*this.g|0),e=397*e^(255*this.b|0),e}toArray(e,t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,this}fromArray(e,t=0){return u.FromArrayToRef(e,t,this),this}toColor4(e=1){return new d(this.r,this.g,this.b,e)}asArray(){return[this.r,this.g,this.b]}toLuminance(){return.3*this.r+.59*this.g+.11*this.b}multiply(e){return new u(this.r*e.r,this.g*e.g,this.b*e.b)}multiplyToRef(e,t){return t.r=this.r*e.r,t.g=this.g*e.g,t.b=this.b*e.b,t}multiplyInPlace(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyByFloats(e,t,s){return new u(this.r*e,this.g*t,this.b*s)}divide(e){throw new ReferenceError("Can not divide a color")}divideToRef(e,t){throw new ReferenceError("Can not divide a color")}divideInPlace(e){throw new ReferenceError("Can not divide a color")}minimizeInPlace(e){return this.minimizeInPlaceFromFloats(e.r,e.g,e.b)}maximizeInPlace(e){return this.maximizeInPlaceFromFloats(e.r,e.g,e.b)}minimizeInPlaceFromFloats(e,t,s){return this.r=Math.min(e,this.r),this.g=Math.min(t,this.g),this.b=Math.min(s,this.b),this}maximizeInPlaceFromFloats(e,t,s){return this.r=Math.max(e,this.r),this.g=Math.max(t,this.g),this.b=Math.max(s,this.b),this}floorToRef(e){throw new ReferenceError("Can not floor a color")}floor(){throw new ReferenceError("Can not floor a color")}fractToRef(e){throw new ReferenceError("Can not fract a color")}fract(){throw new ReferenceError("Can not fract a color")}equals(e){return e&&this.r===e.r&&this.g===e.g&&this.b===e.b}equalsFloats(e,t,s){return this.equalsToFloats(e,t,s)}equalsToFloats(e,t,s){return this.r===e&&this.g===t&&this.b===s}equalsWithEpsilon(e,t=n.bH){return(0,a.Mj)(this.r,e.r,t)&&(0,a.Mj)(this.g,e.g,t)&&(0,a.Mj)(this.b,e.b,t)}negate(){throw new ReferenceError("Can not negate a color")}negateInPlace(){throw new ReferenceError("Can not negate a color")}negateToRef(e){throw new ReferenceError("Can not negate a color")}scale(e){return new u(this.r*e,this.g*e,this.b*e)}scaleInPlace(e){return this.r*=e,this.g*=e,this.b*=e,this}scaleToRef(e,t){return t.r=this.r*e,t.g=this.g*e,t.b=this.b*e,t}scaleAndAddToRef(e,t){return t.r+=this.r*e,t.g+=this.g*e,t.b+=this.b*e,t}clampToRef(e=0,t=1,s){return s.r=(0,a.OQ)(this.r,e,t),s.g=(0,a.OQ)(this.g,e,t),s.b=(0,a.OQ)(this.b,e,t),s}add(e){return new u(this.r+e.r,this.g+e.g,this.b+e.b)}addInPlace(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addInPlaceFromFloats(e,t,s){return this.r+=e,this.g+=t,this.b+=s,this}addToRef(e,t){return t.r=this.r+e.r,t.g=this.g+e.g,t.b=this.b+e.b,t}subtract(e){return new u(this.r-e.r,this.g-e.g,this.b-e.b)}subtractToRef(e,t){return t.r=this.r-e.r,t.g=this.g-e.g,t.b=this.b-e.b,t}subtractInPlace(e){return this.r-=e.r,this.g-=e.g,this.b-=e.b,this}subtractFromFloats(e,t,s){return new u(this.r-e,this.g-t,this.b-s)}subtractFromFloatsToRef(e,t,s,i){return i.r=this.r-e,i.g=this.g-t,i.b=this.b-s,i}clone(){return new u(this.r,this.g,this.b)}copyFrom(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copyFromFloats(e,t,s){return this.r=e,this.g=t,this.b=s,this}set(e,t,s){return this.copyFromFloats(e,t,s)}setAll(e){return this.r=this.g=this.b=e,this}toHexString(){const e=Math.round(255*this.r),t=Math.round(255*this.g),s=Math.round(255*this.b);return"#"+(0,a.Db)(e)+(0,a.Db)(t)+(0,a.Db)(s)}fromHexString(e){return"#"!==e.substring(0,1)||7!==e.length||(this.r=parseInt(e.substring(1,3),16)/255,this.g=parseInt(e.substring(3,5),16)/255,this.b=parseInt(e.substring(5,7),16)/255),this}toHSV(){return this.toHSVToRef(new u)}toHSVToRef(e){const t=this.r,s=this.g,i=this.b,r=Math.max(t,s,i),n=Math.min(t,s,i);let a=0,o=0;const h=r,l=r-n;return 0!==r&&(o=l/r),r!=n&&(r==t?(a=(s-i)/l,s=0&&n<=1?(o=r,h=a):n>=1&&n<=2?(o=a,h=r):n>=2&&n<=3?(h=r,l=a):n>=3&&n<=4?(h=a,l=r):n>=4&&n<=5?(o=a,l=r):n>=5&&n<=6&&(o=r,l=a);const c=s-r;return i.r=o+c,i.g=h+c,i.b=l+c,i}static FromHSV(e,t,s){const i=new u(0,0,0);return u.HSVtoRGBToRef(e,t,s,i),i}static FromHexString(e){return new u(0,0,0).fromHexString(e)}static FromArray(e,t=0){return new u(e[t],e[t+1],e[t+2])}static FromArrayToRef(e,t=0,s){s.r=e[t],s.g=e[t+1],s.b=e[t+2]}static FromInts(e,t,s){return new u(e/255,t/255,s/255)}static Lerp(e,t,s){const i=new u(0,0,0);return u.LerpToRef(e,t,s,i),i}static LerpToRef(e,t,s,i){i.r=e.r+(t.r-e.r)*s,i.g=e.g+(t.g-e.g)*s,i.b=e.b+(t.b-e.b)*s}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,d=e.r*o+s.r*h+t.r*l+i.r*c,_=e.g*o+s.g*h+t.g*l+i.g*c,f=e.b*o+s.b*h+t.b*l+i.b*c;return new u(d,_,f)}static Hermite1stDerivative(e,t,s,i,r){const n=u.Black();return this.Hermite1stDerivativeToRef(e,t,s,i,r,n),n}static Hermite1stDerivativeToRef(e,t,s,i,r,n){const a=r*r;n.r=6*(a-r)*e.r+(3*a-4*r+1)*t.r+6*(-a+r)*s.r+(3*a-2*r)*i.r,n.g=6*(a-r)*e.g+(3*a-4*r+1)*t.g+6*(-a+r)*s.g+(3*a-2*r)*i.g,n.b=6*(a-r)*e.b+(3*a-4*r+1)*t.b+6*(-a+r)*s.b+(3*a-2*r)*i.b}static Red(){return new u(1,0,0)}static Green(){return new u(0,1,0)}static Blue(){return new u(0,0,1)}static Black(){return new u(0,0,0)}static get BlackReadOnly(){return u._BlackReadOnly}static White(){return new u(1,1,1)}static Purple(){return new u(.5,0,.5)}static Magenta(){return new u(1,0,1)}static Yellow(){return new u(1,1,0)}static Gray(){return new u(.5,.5,.5)}static Teal(){return new u(0,1,1)}static Random(){return new u(Math.random(),Math.random(),Math.random())}}u._BlackReadOnly=u.Black(),Object.defineProperties(u.prototype,{dimension:{value:[3]},rank:{value:1}});class d{constructor(e=0,t=0,s=0,i=1){this.r=e,this.g=t,this.b=s,this.a=i}asArray(){return[this.r,this.g,this.b,this.a]}toArray(e,t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e[t+3]=this.a,this}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this.a=e[t+3],this}equals(e){return e&&this.r===e.r&&this.g===e.g&&this.b===e.b&&this.a===e.a}add(e){return new d(this.r+e.r,this.g+e.g,this.b+e.b,this.a+e.a)}addToRef(e,t){return t.r=this.r+e.r,t.g=this.g+e.g,t.b=this.b+e.b,t.a=this.a+e.a,t}addInPlace(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this.a+=e.a,this}addInPlaceFromFloats(e,t,s,i){return this.r+=e,this.g+=t,this.b+=s,this.a+=i,this}subtract(e){return new d(this.r-e.r,this.g-e.g,this.b-e.b,this.a-e.a)}subtractToRef(e,t){return t.r=this.r-e.r,t.g=this.g-e.g,t.b=this.b-e.b,t.a=this.a-e.a,t}subtractInPlace(e){return this.r-=e.r,this.g-=e.g,this.b-=e.b,this.a-=e.a,this}subtractFromFloats(e,t,s,i){return new d(this.r-e,this.g-t,this.b-s,this.a-i)}subtractFromFloatsToRef(e,t,s,i,r){return r.r=this.r-e,r.g=this.g-t,r.b=this.b-s,r.a=this.a-i,r}scale(e){return new d(this.r*e,this.g*e,this.b*e,this.a*e)}scaleInPlace(e){return this.r*=e,this.g*=e,this.b*=e,this.a*=e,this}scaleToRef(e,t){return t.r=this.r*e,t.g=this.g*e,t.b=this.b*e,t.a=this.a*e,t}scaleAndAddToRef(e,t){return t.r+=this.r*e,t.g+=this.g*e,t.b+=this.b*e,t.a+=this.a*e,t}clampToRef(e=0,t=1,s){return s.r=(0,a.OQ)(this.r,e,t),s.g=(0,a.OQ)(this.g,e,t),s.b=(0,a.OQ)(this.b,e,t),s.a=(0,a.OQ)(this.a,e,t),s}multiply(e){return new d(this.r*e.r,this.g*e.g,this.b*e.b,this.a*e.a)}multiplyToRef(e,t){return t.r=this.r*e.r,t.g=this.g*e.g,t.b=this.b*e.b,t.a=this.a*e.a,t}multiplyInPlace(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this.a*=e.a,this}multiplyByFloats(e,t,s,i){return new d(this.r*e,this.g*t,this.b*s,this.a*i)}divide(e){throw new ReferenceError("Can not divide a color")}divideToRef(e,t){throw new ReferenceError("Can not divide a color")}divideInPlace(e){throw new ReferenceError("Can not divide a color")}minimizeInPlace(e){return this.r=Math.min(this.r,e.r),this.g=Math.min(this.g,e.g),this.b=Math.min(this.b,e.b),this.a=Math.min(this.a,e.a),this}maximizeInPlace(e){return this.r=Math.max(this.r,e.r),this.g=Math.max(this.g,e.g),this.b=Math.max(this.b,e.b),this.a=Math.max(this.a,e.a),this}minimizeInPlaceFromFloats(e,t,s,i){return this.r=Math.min(e,this.r),this.g=Math.min(t,this.g),this.b=Math.min(s,this.b),this.a=Math.min(i,this.a),this}maximizeInPlaceFromFloats(e,t,s,i){return this.r=Math.max(e,this.r),this.g=Math.max(t,this.g),this.b=Math.max(s,this.b),this.a=Math.max(i,this.a),this}floorToRef(e){throw new ReferenceError("Can not floor a color")}floor(){throw new ReferenceError("Can not floor a color")}fractToRef(e){throw new ReferenceError("Can not fract a color")}fract(){throw new ReferenceError("Can not fract a color")}negate(){throw new ReferenceError("Can not negate a color")}negateInPlace(){throw new ReferenceError("Can not negate a color")}negateToRef(e){throw new ReferenceError("Can not negate a color")}equalsWithEpsilon(e,t=n.bH){return(0,a.Mj)(this.r,e.r,t)&&(0,a.Mj)(this.g,e.g,t)&&(0,a.Mj)(this.b,e.b,t)&&(0,a.Mj)(this.a,e.a,t)}equalsToFloats(e,t,s,i){return this.r===e&&this.g===t&&this.b===s&&this.a===i}toString(){return"{R: "+this.r+" G:"+this.g+" B:"+this.b+" A:"+this.a+"}"}getClassName(){return"Color4"}getHashCode(){let e=255*this.r|0;return e=397*e^(255*this.g|0),e=397*e^(255*this.b|0),e=397*e^(255*this.a|0),e}clone(){return(new d).copyFrom(this)}copyFrom(e){return this.r=e.r,this.g=e.g,this.b=e.b,this.a=e.a,this}copyFromFloats(e,t,s,i){return this.r=e,this.g=t,this.b=s,this.a=i,this}set(e,t,s,i){return this.copyFromFloats(e,t,s,i)}setAll(e){return this.r=this.g=this.b=this.a=e,this}toHexString(e=!1){const t=Math.round(255*this.r),s=Math.round(255*this.g),i=Math.round(255*this.b);if(e)return"#"+(0,a.Db)(t)+(0,a.Db)(s)+(0,a.Db)(i);const r=Math.round(255*this.a);return"#"+(0,a.Db)(t)+(0,a.Db)(s)+(0,a.Db)(i)+(0,a.Db)(r)}fromHexString(e){return"#"!==e.substring(0,1)||9!==e.length&&7!==e.length||(this.r=parseInt(e.substring(1,3),16)/255,this.g=parseInt(e.substring(3,5),16)/255,this.b=parseInt(e.substring(5,7),16)/255,9===e.length&&(this.a=parseInt(e.substring(7,9),16)/255)),this}toLinearSpace(e=!1){const t=new d;return this.toLinearSpaceToRef(t,e),t}toLinearSpaceToRef(e,t=!1){return t?(e.r=h(this.r),e.g=h(this.g),e.b=h(this.b)):(e.r=o(this.r),e.g=o(this.g),e.b=o(this.b)),e.a=this.a,this}toGammaSpace(e=!1){const t=new d;return this.toGammaSpaceToRef(t,e),t}toGammaSpaceToRef(e,t=!1){return t?(e.r=c(this.r),e.g=c(this.g),e.b=c(this.b)):(e.r=l(this.r),e.g=l(this.g),e.b=l(this.b)),e.a=this.a,this}static FromHexString(e){return"#"!==e.substring(0,1)||9!==e.length&&7!==e.length?new d(0,0,0,0):new d(0,0,0,1).fromHexString(e)}static Lerp(e,t,s){return d.LerpToRef(e,t,s,new d)}static LerpToRef(e,t,s,i){return i.r=e.r+(t.r-e.r)*s,i.g=e.g+(t.g-e.g)*s,i.b=e.b+(t.b-e.b)*s,i.a=e.a+(t.a-e.a)*s,i}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.r*o+s.r*h+t.r*l+i.r*c,_=e.g*o+s.g*h+t.g*l+i.g*c,f=e.b*o+s.b*h+t.b*l+i.b*c,p=e.a*o+s.a*h+t.a*l+i.a*c;return new d(u,_,f,p)}static Hermite1stDerivative(e,t,s,i,r){const n=new d;return this.Hermite1stDerivativeToRef(e,t,s,i,r,n),n}static Hermite1stDerivativeToRef(e,t,s,i,r,n){const a=r*r;n.r=6*(a-r)*e.r+(3*a-4*r+1)*t.r+6*(-a+r)*s.r+(3*a-2*r)*i.r,n.g=6*(a-r)*e.g+(3*a-4*r+1)*t.g+6*(-a+r)*s.g+(3*a-2*r)*i.g,n.b=6*(a-r)*e.b+(3*a-4*r+1)*t.b+6*(-a+r)*s.b+(3*a-2*r)*i.b,n.a=6*(a-r)*e.a+(3*a-4*r+1)*t.a+6*(-a+r)*s.a+(3*a-2*r)*i.a}static FromColor3(e,t=1){return new d(e.r,e.g,e.b,t)}static FromArray(e,t=0){return new d(e[t],e[t+1],e[t+2],e[t+3])}static FromArrayToRef(e,t=0,s){s.r=e[t],s.g=e[t+1],s.b=e[t+2],s.a=e[t+3]}static FromInts(e,t,s,i){return new d(e/255,t/255,s/255,i/255)}static CheckColors4(e,t){if(e.length===3*t){const t=[];for(let s=0;snew d(0,0,0,0))),(0,r.Y5)("BABYLON.Color3",u),(0,r.Y5)("BABYLON.Color4",d)},5559:(e,t,s)=>{s.d(t,{bH:()=>n,rv:()=>i,tk:()=>r});const i=1/2.2,r=2.2,n=(Math.sqrt(5),.001)},2572:(e,t,s)=>{s.d(t,{P:()=>r});var i=s(4100);class r{static GetPlanes(e){const t=[];for(let e=0;e<6;e++)t.push(new i.Z(0,0,0,0));return r.GetPlanesToRef(e,t),t}static GetNearPlaneToRef(e,t){const s=e.m;t.normal.x=s[3]+s[2],t.normal.y=s[7]+s[6],t.normal.z=s[11]+s[10],t.d=s[15]+s[14],t.normalize()}static GetFarPlaneToRef(e,t){const s=e.m;t.normal.x=s[3]-s[2],t.normal.y=s[7]-s[6],t.normal.z=s[11]-s[10],t.d=s[15]-s[14],t.normalize()}static GetLeftPlaneToRef(e,t){const s=e.m;t.normal.x=s[3]+s[0],t.normal.y=s[7]+s[4],t.normal.z=s[11]+s[8],t.d=s[15]+s[12],t.normalize()}static GetRightPlaneToRef(e,t){const s=e.m;t.normal.x=s[3]-s[0],t.normal.y=s[7]-s[4],t.normal.z=s[11]-s[8],t.d=s[15]-s[12],t.normalize()}static GetTopPlaneToRef(e,t){const s=e.m;t.normal.x=s[3]-s[1],t.normal.y=s[7]-s[5],t.normal.z=s[11]-s[9],t.d=s[15]-s[13],t.normalize()}static GetBottomPlaneToRef(e,t){const s=e.m;t.normal.x=s[3]+s[1],t.normal.y=s[7]+s[5],t.normal.z=s[11]+s[9],t.d=s[15]+s[13],t.normalize()}static GetPlanesToRef(e,t){r.GetNearPlaneToRef(e,t[0]),r.GetFarPlaneToRef(e,t[1]),r.GetLeftPlaneToRef(e,t[2]),r.GetRightPlaneToRef(e,t[3]),r.GetTopPlaneToRef(e,t[4]),r.GetBottomPlaneToRef(e,t[5])}static IsPointInFrustum(e,t){for(let s=0;s<6;s++)if(t[s].dotCoordinate(e)<0)return!1;return!0}}},1139:(e,t,s)=>{s.d(t,{b8:()=>h,cD:()=>o});var i=s(5524),r=s(9923),n=s(9259);class a{static extractMinAndMaxIndexed(e,t,s,i,r,n){for(let a=s;a!Array.isArray(e)&&!Array.isArray(t)))],a,"extractMinAndMaxIndexed",null),(0,i.Cg)([n.Cx.filter(((...[e])=>!Array.isArray(e)))],a,"extractMinAndMax",null)},1903:(e,t,s)=>{var i;s.d(t,{vr:()=>r}),s(4867),s(9923),s(5559),function(e){e[e.CW=0]="CW",e[e.CCW=1]="CCW"}(i||(i={}));class r{static Interpolate(e,t,s,i,r){const n=1-3*i+3*t,a=3*i-6*t,o=3*t;let h=e;for(let t=0;t<5;t++){const t=h*h;h-=1/(3*n*t+2*a*h+o)*(n*(t*h)+a*t+o*h-e),h=Math.min(1,Math.max(0,h))}return 3*Math.pow(1-h,2)*h*s+3*(1-h)*Math.pow(h,2)*r+Math.pow(h,3)}}},4100:(e,t,s)=>{s.d(t,{Z:()=>r});var i=s(9923);class r{constructor(e,t,s,r){this.normal=new i.Pq(e,t,s),this.d=r}asArray(){return[this.normal.x,this.normal.y,this.normal.z,this.d]}clone(){return new r(this.normal.x,this.normal.y,this.normal.z,this.d)}getClassName(){return"Plane"}getHashCode(){let e=this.normal.getHashCode();return e=397*e^(0|this.d),e}normalize(){const e=Math.sqrt(this.normal.x*this.normal.x+this.normal.y*this.normal.y+this.normal.z*this.normal.z);let t=0;return 0!==e&&(t=1/e),this.normal.x*=t,this.normal.y*=t,this.normal.z*=t,this.d*=t,this}transform(e){const t=r._TmpMatrix;e.invertToRef(t);const s=t.m,i=this.normal.x,n=this.normal.y,a=this.normal.z,o=this.d,h=i*s[0]+n*s[1]+a*s[2]+o*s[3],l=i*s[4]+n*s[5]+a*s[6]+o*s[7],c=i*s[8]+n*s[9]+a*s[10]+o*s[11],u=i*s[12]+n*s[13]+a*s[14]+o*s[15];return new r(h,l,c,u)}dotCoordinate(e){return this.normal.x*e.x+this.normal.y*e.y+this.normal.z*e.z+this.d}copyFromPoints(e,t,s){const i=t.x-e.x,r=t.y-e.y,n=t.z-e.z,a=s.x-e.x,o=s.y-e.y,h=s.z-e.z,l=r*h-n*o,c=n*a-i*h,u=i*o-r*a,d=Math.sqrt(l*l+c*c+u*u);let _;return _=0!==d?1/d:0,this.normal.x=l*_,this.normal.y=c*_,this.normal.z=u*_,this.d=-(this.normal.x*e.x+this.normal.y*e.y+this.normal.z*e.z),this}isFrontFacingTo(e,t){return i.Pq.Dot(this.normal,e)<=t}signedDistanceTo(e){return i.Pq.Dot(e,this.normal)+this.d}static FromArray(e){return new r(e[0],e[1],e[2],e[3])}static FromPoints(e,t,s){const i=new r(0,0,0,0);return i.copyFromPoints(e,t,s),i}static FromPositionAndNormal(e,t){const s=new r(0,0,0,0);return this.FromPositionAndNormalToRef(e,t,s)}static FromPositionAndNormalToRef(e,t,s){return s.normal.copyFrom(t),s.normal.normalize(),s.d=-e.dot(s.normal),s}static SignedDistanceToPlaneFromPositionAndNormal(e,t,s){const r=-(t.x*e.x+t.y*e.y+t.z*e.z);return i.Pq.Dot(s,t)+r}}r._TmpMatrix=i.uq.Identity()},4867:(e,t,s)=>{function i(e,t,s=1401298e-51){return Math.abs(e-t)<=s}function r(e,t){return e===t?e:Math.random()*(t-e)+e}function n(e,t,s){return e+(t-e)*s}function a(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 o(e,t=0,s=1){return Math.min(s,Math.max(t,e))}function h(e){return e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI))}function l(e){const t=e.toString(16);return e<=15?("0"+t).toUpperCase():t.toUpperCase()}function c(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}s.d(t,{C0:()=>c,Db:()=>l,Mj:()=>i,OQ:()=>o,VD:()=>r,cP:()=>n,ed:()=>h,t:()=>a})},521:(e,t,s)=>{s.d(t,{o:()=>i});class i{constructor(e,t){this.width=e,this.height=t}toString(){return`{W: ${this.width}, H: ${this.height}}`}getClassName(){return"Size"}getHashCode(){let e=0|this.width;return e=397*e^(0|this.height),e}copyFrom(e){this.width=e.width,this.height=e.height}copyFromFloats(e,t){return this.width=e,this.height=t,this}set(e,t){return this.copyFromFloats(e,t)}multiplyByFloats(e,t){return new i(this.width*e,this.height*t)}clone(){return new i(this.width,this.height)}equals(e){return!!e&&this.width===e.width&&this.height===e.height}get surface(){return this.width*this.height}static Zero(){return new i(0,0)}add(e){return new i(this.width+e.width,this.height+e.height)}subtract(e){return new i(this.width-e.width,this.height-e.height)}scale(e){return new i(this.width*e,this.height*e)}static Lerp(e,t,s){const r=e.width+(t.width-e.width)*s,n=e.height+(t.height-e.height)*s;return new i(r,n)}}},9923:(e,t,s)=>{s.d(t,{AA:()=>g,I9:()=>c,IU:()=>d,PT:()=>_,Pq:()=>u,uq:()=>f});var i=s(5559),r=s(7309),n=s(6552),a=s(215),o=s(6315),h=s(4867);const l=e=>parseInt(e.toString().replace(/\W/g,""));class c{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=l(this.x);return e=397*e^l(this.y),e}toArray(e,t=0){return e[t]=this.x,e[t+1]=this.y,this}fromArray(e,t=0){return c.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 c(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 c(this.x+e.x,this.y+e.y)}subtract(e){return new c(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 c(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 c(this.x*e,this.y*t)}divide(e){return new c(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 c(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 c(-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 c(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=i.bH){return e&&(0,h.Mj)(this.x,e.x,t)&&(0,h.Mj)(this.y,e.y,t)}equalsToFloats(e,t){return this.x===e&&this.y===t}floor(){return new c(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 c(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}rotateToRef(e,t){const s=Math.cos(e),i=Math.sin(e),r=s*this.x-i*this.y,n=i*this.x+s*this.y;return t.x=r,t.y=n,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 c;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 c(this.x,this.y)}dot(e){return this.x*e.x+this.y*e.y}static Zero(){return new c(0,0)}static One(){return new c(1,1)}static Random(e=0,t=1){return new c((0,h.VD)(e,t),(0,h.VD)(e,t))}static RandomToRef(e=0,t=1,s){return s.copyFromFloats((0,h.VD)(e,t),(0,h.VD)(e,t))}static get ZeroReadOnly(){return c._ZeroReadOnly}static FromArray(e,t=0){return new c(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 c(o,h)}static ClampToRef(e,t,s,i){return i.x=(0,h.OQ)(e.x,t.x,s.x),i.y=(0,h.OQ)(e.y,t.y,s.y),i}static Clamp(e,t,s){const i=(0,h.OQ)(e.x,t.x,s.x),r=(0,h.OQ)(e.y,t.y,s.y);return new c(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,u=a-n,d=e.x*o+s.x*h+t.x*l+i.x*u,_=e.y*o+s.y*h+t.y*l+i.y*u;return new c(d,_)}static Hermite1stDerivative(e,t,s,i,r){return this.Hermite1stDerivativeToRef(e,t,s,i,r,new c)}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 c.LerpToRef(e,t,s,new c)}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 c.NormalizeToRef(e,new c)}static NormalizeToRef(e,t){return e.normalizeToRef(t),t}static Minimize(e,t){const s=e.xt.x?e.x:t.x,i=e.y>t.y?e.y:t.y;return new c(s,i)}static Transform(e,t){return c.TransformToRef(e,t,new c)}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(c.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 c.CenterToRef(e,t,new c)}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=c.DistanceSquared(t,s);if(0===i)return c.Distance(e,t);const r=s.subtract(t),n=Math.max(0,Math.min(1,c.Dot(e.subtract(t),r)/i)),a=t.add(r.multiplyByFloats(n,n));return c.Distance(e,a)}}c._ZeroReadOnly=c.Zero(),Object.defineProperties(c.prototype,{dimension:{value:[2]},rank:{value:1}});class u{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=l(this._x);return e=397*e^l(this._y),e=397*e^l(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 u.FromArrayToRef(e,t,this),this}toQuaternion(){return _.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 u(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 u(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 u(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 u(-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 u(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 u)}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 u)}projectOnPlaneToRef(e,t,s){const i=e.normal,r=e.d,n=p.Vector3[0];this.subtractToRef(t,n),n.normalize();const a=u.Dot(n,i);if(Math.abs(a)<1e-10)s.setAll(1/0);else{const e=-(u.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=i.bH){return e&&(0,h.Mj)(this._x,e._x,t)&&(0,h.Mj)(this._y,e._y,t)&&(0,h.Mj)(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 u(this._x*e,this._y*t,this._z*s)}divide(e){return new u(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 ethis._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(!(0,h.Mj)(t,s,e))return!0;const i=Math.abs(this._z);return!(0,h.Mj)(t,i,e)||!(0,h.Mj)(s,i,e)}get isNonUniform(){const e=Math.abs(this._x);return e!==Math.abs(this._y)||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 u(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 u(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=p.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(p.Matrix[0]),u.TransformCoordinatesToRef(this,p.Matrix[0],t),t}rotateByQuaternionAroundPointToRef(e,t,s){return this.subtractToRef(t,p.Vector3[0]),p.Vector3[0].rotateByQuaternionToRef(e,p.Vector3[0]),t.addToRef(p.Vector3[0],s),s}cross(e){return u.CrossToRef(this,e,new u)}normalizeFromLength(e){return 0===e||1===e?this:this.scaleInPlace(1/e)}normalizeToNew(){return this.normalizeToRef(new u)}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 u(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=u.Dot(e,s);return(r-i)/(r-u.Dot(t,s))}static GetAngleBetweenVectors(e,t,s){const i=e.normalizeToRef(p.Vector3[1]),r=t.normalizeToRef(p.Vector3[2]);let n=u.Dot(i,r);n=(0,h.OQ)(n,-1,1);const a=Math.acos(n),o=p.Vector3[3];return u.CrossToRef(i,r,o),u.Dot(o,s)>0?isNaN(a)?0:a:isNaN(a)?-Math.PI:-Math.acos(n)}static GetAngleBetweenVectorsOnPlane(e,t,s){p.Vector3[0].copyFrom(e);const i=p.Vector3[0];p.Vector3[1].copyFrom(t);const r=p.Vector3[1];p.Vector3[2].copyFrom(s);const n=p.Vector3[2],a=p.Vector3[3],o=p.Vector3[4];i.normalize(),r.normalize(),n.normalize(),u.CrossToRef(n,i,a),u.CrossToRef(a,n,o);const l=Math.atan2(u.Dot(r,a),u.Dot(r,o));return(0,h.ed)(l)}static PitchYawRollToMoveBetweenPointsToRef(e,t,s){const i=g.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=u.Zero();return u.PitchYawRollToMoveBetweenPointsToRef(e,t,s)}static SlerpToRef(e,t,s,r){s=(0,h.OQ)(s,0,1);const n=p.Vector3[0],a=p.Vector3[1];n.copyFrom(e);const o=n.length();n.normalizeFromLength(o),a.copyFrom(t);const l=a.length();a.normalizeFromLength(l);const c=u.Dot(n,a);let d,_;if(c<1-i.bH){const e=Math.acos(c),t=1/Math.sin(e);d=Math.sin((1-s)*e)*t,_=Math.sin(s*e)*t}else d=1-s,_=s;return n.scaleInPlace(d),a.scaleInPlace(_),r.copyFrom(n).addInPlace(a),r.scaleInPlace((0,h.cP)(o,l,s)),r}static SmoothToRef(e,t,s,i,r){return u.SlerpToRef(e,t,0===i?1:s/i,r),r}static FromArray(e,t=0){return new u(e[t],e[t+1],e[t+2])}static FromFloatArray(e,t){return u.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 u.FromArrayToRef(e,t,s)}static FromFloatsToRef(e,t,s,i){return i.copyFromFloats(e,t,s),i}static Zero(){return new u(0,0,0)}static One(){return new u(1,1,1)}static Up(){return new u(0,1,0)}static get UpReadOnly(){return u._UpReadOnly}static get DownReadOnly(){return u._DownReadOnly}static get RightReadOnly(){return u._RightReadOnly}static get LeftReadOnly(){return u._LeftReadOnly}static get LeftHandedForwardReadOnly(){return u._LeftHandedForwardReadOnly}static get RightHandedForwardReadOnly(){return u._RightHandedForwardReadOnly}static get LeftHandedBackwardReadOnly(){return u._LeftHandedBackwardReadOnly}static get RightHandedBackwardReadOnly(){return u._RightHandedBackwardReadOnly}static get ZeroReadOnly(){return u._ZeroReadOnly}static get OneReadOnly(){return u._OneReadOnly}static Down(){return new u(0,-1,0)}static Forward(e=!1){return new u(0,0,e?-1:1)}static Backward(e=!1){return new u(0,0,e?1:-1)}static Right(){return new u(1,0,0)}static Left(){return new u(-1,0,0)}static Random(e=0,t=1){return new u((0,h.VD)(e,t),(0,h.VD)(e,t),(0,h.VD)(e,t))}static RandomToRef(e=0,t=1,s){return s.copyFromFloats((0,h.VD)(e,t),(0,h.VD)(e,t),(0,h.VD)(e,t))}static TransformCoordinates(e,t){const s=u.Zero();return u.TransformCoordinatesToRef(e,t,s),s}static TransformCoordinatesToRef(e,t,s){return u.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=u.Zero();return u.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 u(o,h,l)}static Clamp(e,t,s){const i=new u;return u.ClampToRef(e,t,s,i),i}static ClampToRef(e,t,s,i){let r=e._x;r=r>s._x?s._x:r,r=rs._y?s._y:n,n=ns._z?s._z:a,a=a0&&S<0?(D.copyFrom(a),O=t,F=s):S>0&&I<0?(D.copyFrom(l),O=s,F=r):(D.copyFrom(o).scaleInPlace(-1),O=r,F=t);const w=p.Vector3[9],L=p.Vector3[4];if(O.subtractToRef(x,y),F.subtractToRef(x,w),u.CrossToRef(y,w,L),!(u.Dot(L,c)<0))return n.copyFrom(x),Math.abs(T*b);const B=p.Vector3[5];u.CrossToRef(D,L,B),B.normalize();const N=p.Vector3[9];N.copyFrom(O).subtractInPlace(x);const U=N.length();if(Uthis.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 d(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 d(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 d)}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 u(this.x,this.y,this.z)}clone(){return new d(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,s,i){return this.x=e,this.y=t,this.z=s,this.w=i,this}set(e,t,s,i){return this.copyFromFloats(e,t,s,i)}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 d(e[t],e[t+1],e[t+2],e[t+3])}static FromArrayToRef(e,t,s){return s.x=e[t],s.y=e[t+1],s.z=e[t+2],s.w=e[t+3],s}static FromFloatArrayToRef(e,t,s){return d.FromArrayToRef(e,t,s),s}static FromFloatsToRef(e,t,s,i,r){return r.x=e,r.y=t,r.z=s,r.w=i,r}static Zero(){return new d(0,0,0,0)}static One(){return new d(1,1,1,1)}static Random(e=0,t=1){return new d((0,h.VD)(e,t),(0,h.VD)(e,t),(0,h.VD)(e,t),(0,h.VD)(e,t))}static RandomToRef(e=0,t=1,s){return s.x=(0,h.VD)(e,t),s.y=(0,h.VD)(e,t),s.z=(0,h.VD)(e,t),s.w=(0,h.VD)(e,t),s}static Clamp(e,t,s){return d.ClampToRef(e,t,s,new d)}static ClampToRef(e,t,s,i){return i.x=(0,h.OQ)(e.x,t.x,s.x),i.y=(0,h.OQ)(e.y,t.y,s.y),i.z=(0,h.OQ)(e.z,t.z,s.z),i.w=(0,h.OQ)(e.w,t.w,s.w),i}static CheckExtends(e,t,s){t.minimizeInPlace(e),s.maximizeInPlace(e)}static get ZeroReadOnly(){return d._ZeroReadOnly}static Normalize(e){return d.NormalizeToRef(e,new d)}static NormalizeToRef(e,t){return e.normalizeToRef(t),t}static Minimize(e,t){const s=new d;return s.copyFrom(e),s.minimizeInPlace(t),s}static Maximize(e,t){const s=new d;return s.copyFrom(e),s.maximizeInPlace(t),s}static Distance(e,t){return Math.sqrt(d.DistanceSquared(e,t))}static DistanceSquared(e,t){const s=e.x-t.x,i=e.y-t.y,r=e.z-t.z,n=e.w-t.w;return s*s+i*i+r*r+n*n}static Center(e,t){return d.CenterToRef(e,t,new d)}static CenterToRef(e,t,s){return s.x=(e.x+t.x)/2,s.y=(e.y+t.y)/2,s.z=(e.z+t.z)/2,s.w=(e.w+t.w)/2,s}static TransformCoordinates(e,t){return d.TransformCoordinatesToRef(e,t,new d)}static TransformCoordinatesToRef(e,t,s){return d.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=e*n[3]+t*n[7]+s*n[11]+n[15];return r.x=a,r.y=o,r.z=h,r.w=l,r}static TransformNormal(e,t){return d.TransformNormalToRef(e,t,new d)}static TransformNormalToRef(e,t,s){const i=t.m,r=e.x*i[0]+e.y*i[4]+e.z*i[8],n=e.x*i[1]+e.y*i[5]+e.z*i[9],a=e.x*i[2]+e.y*i[6]+e.z*i[10];return s.x=r,s.y=n,s.z=a,s.w=e.w,s}static TransformNormalFromFloatsToRef(e,t,s,i,r,n){const a=r.m;return n.x=e*a[0]+t*a[4]+s*a[8],n.y=e*a[1]+t*a[5]+s*a[9],n.z=e*a[2]+t*a[6]+s*a[10],n.w=i,n}static FromVector3(e,t=0){return new d(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}}d._ZeroReadOnly=d.Zero(),Object.defineProperties(d.prototype,{dimension:{value:[4]},rank:{value:1}});class _{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=1){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"Quaternion"}getHashCode(){let e=l(this._x);return e=397*e^l(this._y),e=397*e^l(this._z),e=397*e^l(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 _.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=i.bH){return e&&(0,h.Mj)(this._x,e._x,t)&&(0,h.Mj)(this._y,e._y,t)&&(0,h.Mj)(this._z,e._z,t)&&(0,h.Mj)(this._w,e._w,t)}clone(){return new _(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,s,i){return this._x=e,this._y=t,this._z=s,this._w=i,this._isDirty=!0,this}set(e,t,s,i){return this.copyFromFloats(e,t,s,i)}setAll(e){return this.copyFromFloats(e,e,e,e)}add(e){return new _(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,s,i){return this._x+=e,this._y+=t,this._z+=s,this._w+=i,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,s,i){return this.subtractFromFloatsToRef(e,t,s,i,new _)}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._isDirty=!0,r}subtract(e){return new _(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 _(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 _(0,0,0,1);return this.multiplyToRef(e,t),t}multiplyToRef(e,t){const s=this._x*e._w+this._y*e._z-this._z*e._y+this._w*e._x,i=-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(s,i,r,n),t}multiplyInPlace(e){return this.multiplyToRef(e,this)}multiplyByFloats(e,t,s,i){return this._x*=e,this._y*=t,this._z*=s,this._w*=i,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 _)}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,s,i){return this._x===e&&this._y===t&&this._z===s&&this._w===i}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 _(-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 _(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=u.Zero();return this.toEulerAnglesToRef(e),e}toEulerAnglesToRef(e){const t=this._z,s=this._x,i=this._y,r=this._w,n=i*t-s*r,a=.4999999;if(n<-a)e._y=2*Math.atan2(i,r),e._x=Math.PI/2,e._z=0,e._isDirty=!0;else if(n>a)e._y=2*Math.atan2(i,r),e._x=-Math.PI/2,e._z=0,e._isDirty=!0;else{const a=r*r,o=t*t,h=s*s,l=i*i;e._z=Math.atan2(2*(s*i+t*r),-o-h+l+a),e._x=Math.asin(-2*n),e._y=Math.atan2(2*(t*s+i*r),o-h-l+a),e._isDirty=!0}return e}toAlphaBetaGammaToRef(e){const t=this._z,s=this._x,i=this._y,r=this._w,n=Math.sqrt(s*s+i*i),a=Math.sqrt(t*t+r*r),o=2*Math.atan2(n,a),h=2*Math.atan2(t,r),l=2*Math.atan2(i,s),c=(h+l)/2,u=(h-l)/2;return e.set(u,o,c),e}toRotationMatrix(e){return f.FromQuaternionToRef(this,e),e}fromRotationMatrix(e){return _.FromRotationMatrixToRef(e,this),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}static FromRotationMatrix(e){const t=new _;return _.FromRotationMatrixToRef(e,t),t}static FromRotationMatrixToRef(e,t){const s=e.m,i=s[0],r=s[4],n=s[8],a=s[1],o=s[5],h=s[9],l=s[2],c=s[6],u=s[10],d=i+o+u;let _;return d>0?(_=.5/Math.sqrt(d+1),t._w=.25/_,t._x=(c-h)*_,t._y=(n-l)*_,t._z=(a-r)*_,t._isDirty=!0):i>o&&i>u?(_=2*Math.sqrt(1+i-o-u),t._w=(c-h)/_,t._x=.25*_,t._y=(r+a)/_,t._z=(n+l)/_,t._isDirty=!0):o>u?(_=2*Math.sqrt(1+o-i-u),t._w=(n-l)/_,t._x=(r+a)/_,t._y=.25*_,t._z=(h+c)/_,t._isDirty=!0):(_=2*Math.sqrt(1+u-i-o),t._w=(a-r)/_,t._x=(n+l)/_,t._y=(h+c)/_,t._z=.25*_,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,s=.1){const i=_.Dot(e,t);return 1-i*i<=s}static SmoothToRef(e,t,s,i,r){let n=0===i?1:s/i;return n=(0,h.OQ)(n,0,1),_.SlerpToRef(e,t,n,r),r}static Zero(){return new _(0,0,0,0)}static Inverse(e){return new _(-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 _(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 _.RotationAxisToRef(e,t,new _)}static RotationAxisToRef(e,t,s){s._w=Math.cos(t/2);const i=Math.sin(t/2)/e.length();return s._x=e._x*i,s._y=e._y*i,s._z=e._z*i,s._isDirty=!0,s}static FromArray(e,t){return t||(t=0),new _(e[t],e[t+1],e[t+2],e[t+3])}static FromArrayToRef(e,t,s){return s._x=e[t],s._y=e[t+1],s._z=e[t+2],s._w=e[t+3],s._isDirty=!0,s}static FromFloatsToRef(e,t,s,i,r){return r.copyFromFloats(e,t,s,i),r}static FromEulerAngles(e,t,s){const i=new _;return _.RotationYawPitchRollToRef(t,e,s,i),i}static FromEulerAnglesToRef(e,t,s,i){return _.RotationYawPitchRollToRef(t,e,s,i),i}static FromEulerVector(e){const t=new _;return _.RotationYawPitchRollToRef(e._y,e._x,e._z,t),t}static FromEulerVectorToRef(e,t){return _.RotationYawPitchRollToRef(e._y,e._x,e._z,t),t}static FromUnitVectorsToRef(e,t,s,r=i.bH){const n=u.Dot(e,t)+1;return nMath.abs(e.z)?s.set(-e.y,e.x,0,0):s.set(0,-e.z,e.y,0):(u.CrossToRef(e,t,g.Vector3[0]),s.set(g.Vector3[0].x,g.Vector3[0].y,g.Vector3[0].z,n)),s.normalize()}static RotationYawPitchRoll(e,t,s){const i=new _;return _.RotationYawPitchRollToRef(e,t,s,i),i}static RotationYawPitchRollToRef(e,t,s,i){const r=.5*s,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),d=Math.cos(a);return i._x=d*l*h+u*c*o,i._y=u*c*h-d*l*o,i._z=d*c*o-u*l*h,i._w=d*c*h+u*l*o,i._isDirty=!0,i}static RotationAlphaBetaGamma(e,t,s){const i=new _;return _.RotationAlphaBetaGammaToRef(e,t,s,i),i}static RotationAlphaBetaGammaToRef(e,t,s,i){const r=.5*(s+e),n=.5*(s-e),a=.5*t;return i._x=Math.cos(n)*Math.sin(a),i._y=Math.sin(n)*Math.sin(a),i._z=Math.sin(r)*Math.cos(a),i._w=Math.cos(r)*Math.cos(a),i._isDirty=!0,i}static RotationQuaternionFromAxis(e,t,s){const i=new _(0,0,0,0);return _.RotationQuaternionFromAxisToRef(e,t,s,i),i}static RotationQuaternionFromAxisToRef(e,t,s,i){const r=p.Matrix[0];return e=e.normalizeToRef(p.Vector3[0]),t=t.normalizeToRef(p.Vector3[1]),s=s.normalizeToRef(p.Vector3[2]),f.FromXYZAxesToRef(e,t,s,r),_.FromRotationMatrixToRef(r,i),i}static FromLookDirectionLH(e,t){const s=new _;return _.FromLookDirectionLHToRef(e,t,s),s}static FromLookDirectionLHToRef(e,t,s){const i=p.Matrix[0];return f.LookDirectionLHToRef(e,t,i),_.FromRotationMatrixToRef(i,s),s}static FromLookDirectionRH(e,t){const s=new _;return _.FromLookDirectionRHToRef(e,t,s),s}static FromLookDirectionRHToRef(e,t,s){const i=p.Matrix[0];return f.LookDirectionRHToRef(e,t,i),_.FromRotationMatrixToRef(i,s)}static Slerp(e,t,s){const i=_.Identity();return _.SlerpToRef(e,t,s,i),i}static SlerpToRef(e,t,s,i){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-s,r=o?-s:s;else{const e=Math.acos(a),t=1/Math.sin(e);n=Math.sin((1-s)*e)*t,r=o?-Math.sin(s*e)*t:Math.sin(s*e)*t}return i._x=n*e._x+r*t._x,i._y=n*e._y+r*t._y,i._z=n*e._z+r*t._z,i._w=n*e._w+r*t._w,i._isDirty=!0,i}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,f=e._z*o+s._z*h+t._z*l+i._z*c,p=e._w*o+s._w*h+t._w*l+i._w*c;return new _(u,d,f,p)}static Hermite1stDerivative(e,t,s,i,r){const n=new _;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._w=6*(a-r)*e._w+(3*a-4*r+1)*t._w+6*(-a+r)*s._w+(3*a-2*r)*i._w,n._isDirty=!0,n}static Normalize(e){const t=_.Zero();return _.NormalizeToRef(e,t),t}static NormalizeToRef(e,t){return e.normalizeToRef(t),t}static Clamp(e,t,s){const i=new _;return _.ClampToRef(e,t,s,i),i}static ClampToRef(e,t,s,i){return i.copyFromFloats((0,h.OQ)(e.x,t.x,s.x),(0,h.OQ)(e.y,t.y,s.y),(0,h.OQ)(e.z,t.z,s.z),(0,h.OQ)(e.w,t.w,s.w))}static Random(e=0,t=1){return new _((0,h.VD)(e,t),(0,h.VD)(e,t),(0,h.VD)(e,t),(0,h.VD)(e,t))}static RandomToRef(e=0,t=1,s){return s.copyFromFloats((0,h.VD)(e,t),(0,h.VD)(e,t),(0,h.VD)(e,t),(0,h.VD)(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(_.DistanceSquared(e,t))}static DistanceSquared(e,t){const s=e.x-t.x,i=e.y-t.y,r=e.z-t.z,n=e.w-t.w;return s*s+i*i+r*r+n*n}static Center(e,t){return _.CenterToRef(e,t,_.Zero())}static CenterToRef(e,t,s){return s.copyFromFloats((e.x+t.x)/2,(e.y+t.y)/2,(e.z+t.z)/2,(e.w+t.w)/2)}}Object.defineProperties(_.prototype,{dimension:{value:[4]},rank:{value:1}});class f{static get Use64Bits(){return a.I.MatrixUse64Bits}get m(){return this._m}markAsUpdated(){this.updateFlag=f._UpdateFlagSeed++,this._isIdentity=!1,this._isIdentity3x2=!1,this._isIdentityDirty=!0,this._isIdentity3x2Dirty=!0}_updateIdentityStatus(e,t=!1,s=!1,i=!0){this._isIdentity=e,this._isIdentity3x2=e||s,this._isIdentityDirty=!this._isIdentity&&t,this._isIdentity3x2Dirty=!this._isIdentity3x2&&i}constructor(){this._isIdentity=!1,this._isIdentityDirty=!0,this._isIdentity3x2=!0,this._isIdentity3x2Dirty=!0,this.updateFlag=-1,a.I.MatrixTrackPrecisionChange&&a.I.MatrixTrackedMatrices.push(this),this._m=new a.I.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[11]&&0===e[12]&&0===e[13]&&0===e[14]&&1===e[15]}return this._isIdentity}isIdentityAs3x2(){return this._isIdentity3x2Dirty&&(this._isIdentity3x2Dirty=!1,1!==this._m[0]||1!==this._m[5]||1!==this._m[15]||0!==this._m[1]||0!==this._m[2]||0!==this._m[3]||0!==this._m[4]||0!==this._m[6]||0!==this._m[7]||0!==this._m[8]||0!==this._m[9]||0!==this._m[10]||0!==this._m[11]||0!==this._m[12]||0!==this._m[13]||0!==this._m[14]?this._isIdentity3x2=!1:this._isIdentity3x2=!0),this._isIdentity3x2}determinant(){if(!0===this._isIdentity)return 1;const e=this._m,t=e[0],s=e[1],i=e[2],r=e[3],n=e[4],a=e[5],o=e[6],h=e[7],l=e[8],c=e[9],u=e[10],d=e[11],_=e[12],f=e[13],p=e[14],g=e[15],m=u*g-p*d,T=c*g-f*d,b=c*p-f*u,E=l*g-_*d,x=l*p-u*_,A=l*f-_*c;return t*+(a*m-o*T+h*b)+s*-(n*m-o*E+h*x)+i*+(n*T-a*E+h*A)+r*-(n*b-a*x+o*A)}toString(){return`{${this.m[0]}, ${this.m[1]}, ${this.m[2]}, ${this.m[3]}\n${this.m[4]}, ${this.m[5]}, ${this.m[6]}, ${this.m[7]}\n${this.m[8]}, ${this.m[9]}, ${this.m[10]}, ${this.m[11]}\n${this.m[12]}, ${this.m[13]}, ${this.m[14]}, ${this.m[15]}}`}toArray(e=null,t=0){if(!e)return this._m;const s=this._m;for(let i=0;i<16;i++)e[t+i]=s[i];return this}asArray(){return this._m}fromArray(e,t=0){return f.FromArrayToRef(e,t,this)}copyFromFloats(...e){return f.FromArrayToRef(e,0,this)}set(...e){const t=this._m;for(let s=0;s<16;s++)t[s]=e[s];return this.markAsUpdated(),this}setAll(e){const t=this._m;for(let s=0;s<16;s++)t[s]=e;return this.markAsUpdated(),this}invert(){return this.invertToRef(this),this}reset(){return f.FromValuesToRef(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,this),this._updateIdentityStatus(!1),this}add(e){const t=new f;return this.addToRef(e,t),t}addToRef(e,t){const s=this._m,i=t._m,r=e.m;for(let e=0;e<16;e++)i[e]=s[e]+r[e];return t.markAsUpdated(),t}addToSelf(e){const t=this._m,s=e.m;return t[0]+=s[0],t[1]+=s[1],t[2]+=s[2],t[3]+=s[3],t[4]+=s[4],t[5]+=s[5],t[6]+=s[6],t[7]+=s[7],t[8]+=s[8],t[9]+=s[9],t[10]+=s[10],t[11]+=s[11],t[12]+=s[12],t[13]+=s[13],t[14]+=s[14],t[15]+=s[15],this.markAsUpdated(),this}addInPlace(e){const t=this._m,s=e.m;for(let e=0;e<16;e++)t[e]+=s[e];return this.markAsUpdated(),this}addInPlaceFromFloats(...e){const t=this._m;for(let s=0;s<16;s++)t[s]+=e[s];return this.markAsUpdated(),this}subtract(e){const t=this._m,s=e.m;for(let e=0;e<16;e++)t[e]-=s[e];return this.markAsUpdated(),this}subtractToRef(e,t){const s=this._m,i=e.m,r=t._m;for(let e=0;e<16;e++)r[e]=s[e]-i[e];return t.markAsUpdated(),t}subtractInPlace(e){const t=this._m,s=e.m;for(let e=0;e<16;e++)t[e]-=s[e];return this.markAsUpdated(),this}subtractFromFloats(...e){return this.subtractFromFloatsToRef(...e,new f)}subtractFromFloatsToRef(...e){const t=e.pop(),s=this._m,i=t._m,r=e;for(let e=0;e<16;e++)i[e]=s[e]-r[e];return t.markAsUpdated(),t}invertToRef(e){if(!0===this._isIdentity)return f.IdentityToRef(e),e;const t=this._m,s=t[0],i=t[1],r=t[2],n=t[3],a=t[4],o=t[5],h=t[6],l=t[7],c=t[8],u=t[9],d=t[10],_=t[11],p=t[12],g=t[13],m=t[14],T=t[15],b=d*T-m*_,E=u*T-g*_,x=u*m-g*d,A=c*T-p*_,R=c*m-d*p,M=c*g-p*u,y=+(o*b-h*E+l*x),P=-(a*b-h*A+l*R),v=+(a*E-o*A+l*M),C=-(a*x-o*R+h*M),S=s*y+i*P+r*v+n*C;if(0===S)return e.copyFrom(this),e;const I=1/S,D=h*T-m*l,O=o*T-g*l,F=o*m-g*h,w=a*T-p*l,L=a*m-p*h,B=a*g-p*o,N=h*_-d*l,U=o*_-u*l,k=o*d-u*h,V=a*_-c*l,G=a*d-c*h,z=a*u-c*o,W=-(i*b-r*E+n*x),H=+(s*b-r*A+n*R),K=-(s*E-i*A+n*M),q=+(s*x-i*R+r*M),X=+(i*D-r*O+n*F),Y=-(s*D-r*w+n*L),j=+(s*O-i*w+n*B),Z=-(s*F-i*L+r*B),Q=-(i*N-r*U+n*k),$=+(s*N-r*V+n*G),J=-(s*U-i*V+n*z),ee=+(s*k-i*G+r*z);return f.FromValuesToRef(y*I,W*I,X*I,Q*I,P*I,H*I,Y*I,$*I,v*I,K*I,j*I,J*I,C*I,q*I,Z*I,ee*I,e),e}addAtIndex(e,t){return this._m[e]+=t,this.markAsUpdated(),this}multiplyAtIndex(e,t){return this._m[e]*=t,this.markAsUpdated(),this}setTranslationFromFloats(e,t,s){return this._m[12]=e,this._m[13]=t,this._m[14]=s,this.markAsUpdated(),this}addTranslationFromFloats(e,t,s){return this._m[12]+=e,this._m[13]+=t,this._m[14]+=s,this.markAsUpdated(),this}setTranslation(e){return this.setTranslationFromFloats(e._x,e._y,e._z)}getTranslation(){return new u(this._m[12],this._m[13],this._m[14])}getTranslationToRef(e){return e.x=this._m[12],e.y=this._m[13],e.z=this._m[14],e}removeRotationAndScaling(){const e=this.m;return f.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,e[12],e[13],e[14],e[15],this),this._updateIdentityStatus(0===e[12]&&0===e[13]&&0===e[14]&&1===e[15]),this}copyFrom(e){e.copyToArray(this._m);const t=e;return this.updateFlag=t.updateFlag,this._updateIdentityStatus(t._isIdentity,t._isIdentityDirty,t._isIdentity3x2,t._isIdentity3x2Dirty),this}copyToArray(e,t=0){const s=this._m;return e[t]=s[0],e[t+1]=s[1],e[t+2]=s[2],e[t+3]=s[3],e[t+4]=s[4],e[t+5]=s[5],e[t+6]=s[6],e[t+7]=s[7],e[t+8]=s[8],e[t+9]=s[9],e[t+10]=s[10],e[t+11]=s[11],e[t+12]=s[12],e[t+13]=s[13],e[t+14]=s[14],e[t+15]=s[15],this}multiply(e){const t=new f;return this.multiplyToRef(e,t),t}multiplyInPlace(e){const t=this._m,s=e.m;for(let e=0;e<16;e++)t[e]*=s[e];return this.markAsUpdated(),this}multiplyByFloats(...e){const t=this._m;for(let s=0;s<16;s++)t[s]*=e[s];return this.markAsUpdated(),this}multiplyByFloatsToRef(...e){const t=e.pop(),s=this._m,i=t._m,r=e;for(let e=0;e<16;e++)i[e]=s[e]*r[e];return t.markAsUpdated(),t}multiplyToRef(e,t){return this._isIdentity?(t.copyFrom(e),t):e._isIdentity?(t.copyFrom(this),t):(this.multiplyToArray(e,t._m,0),t.markAsUpdated(),t)}multiplyToArray(e,t,s){const i=this._m,r=e.m,n=i[0],a=i[1],o=i[2],h=i[3],l=i[4],c=i[5],u=i[6],d=i[7],_=i[8],f=i[9],p=i[10],g=i[11],m=i[12],T=i[13],b=i[14],E=i[15],x=r[0],A=r[1],R=r[2],M=r[3],y=r[4],P=r[5],v=r[6],C=r[7],S=r[8],I=r[9],D=r[10],O=r[11],F=r[12],w=r[13],L=r[14],B=r[15];return t[s]=n*x+a*y+o*S+h*F,t[s+1]=n*A+a*P+o*I+h*w,t[s+2]=n*R+a*v+o*D+h*L,t[s+3]=n*M+a*C+o*O+h*B,t[s+4]=l*x+c*y+u*S+d*F,t[s+5]=l*A+c*P+u*I+d*w,t[s+6]=l*R+c*v+u*D+d*L,t[s+7]=l*M+c*C+u*O+d*B,t[s+8]=_*x+f*y+p*S+g*F,t[s+9]=_*A+f*P+p*I+g*w,t[s+10]=_*R+f*v+p*D+g*L,t[s+11]=_*M+f*C+p*O+g*B,t[s+12]=m*x+T*y+b*S+E*F,t[s+13]=m*A+T*P+b*I+E*w,t[s+14]=m*R+T*v+b*D+E*L,t[s+15]=m*M+T*C+b*O+E*B,this}divide(e){return this.divideToRef(e,new f)}divideToRef(e,t){const s=this._m,i=e.m,r=t._m;for(let e=0;e<16;e++)r[e]=s[e]/i[e];return t.markAsUpdated(),t}divideInPlace(e){const t=this._m,s=e.m;for(let e=0;e<16;e++)t[e]/=s[e];return this.markAsUpdated(),this}minimizeInPlace(e){const t=this._m,s=e.m;for(let e=0;e<16;e++)t[e]=Math.min(t[e],s[e]);return this.markAsUpdated(),this}minimizeInPlaceFromFloats(...e){const t=this._m;for(let s=0;s<16;s++)t[s]=Math.min(t[s],e[s]);return this.markAsUpdated(),this}maximizeInPlace(e){const t=this._m,s=e.m;for(let e=0;e<16;e++)t[e]=Math.min(t[e],s[e]);return this.markAsUpdated(),this}maximizeInPlaceFromFloats(...e){const t=this._m;for(let s=0;s<16;s++)t[s]=Math.min(t[s],e[s]);return this.markAsUpdated(),this}negate(){return this.negateToRef(new f)}negateInPlace(){const e=this._m;for(let t=0;t<16;t++)e[t]=-e[t];return this.markAsUpdated(),this}negateToRef(e){const t=this._m,s=e._m;for(let e=0;e<16;e++)s[e]=-t[e];return e.markAsUpdated(),e}equals(e){const t=e;if(!t)return!1;if((this._isIdentity||t._isIdentity)&&!this._isIdentityDirty&&!t._isIdentityDirty)return this._isIdentity&&t._isIdentity;const s=this.m,i=t.m;return s[0]===i[0]&&s[1]===i[1]&&s[2]===i[2]&&s[3]===i[3]&&s[4]===i[4]&&s[5]===i[5]&&s[6]===i[6]&&s[7]===i[7]&&s[8]===i[8]&&s[9]===i[9]&&s[10]===i[10]&&s[11]===i[11]&&s[12]===i[12]&&s[13]===i[13]&&s[14]===i[14]&&s[15]===i[15]}equalsWithEpsilon(e,t=0){const s=this._m,i=e.m;for(let e=0;e<16;e++)if(!(0,h.Mj)(s[e],i[e],t))return!1;return!0}equalsToFloats(...e){const t=this._m;for(let s=0;s<16;s++)if(t[s]!=e[s])return!1;return!0}floor(){return this.floorToRef(new f)}floorToRef(e){const t=this._m,s=e._m;for(let e=0;e<16;e++)s[e]=Math.floor(t[e]);return e.markAsUpdated(),e}fract(){return this.fractToRef(new f)}fractToRef(e){const t=this._m,s=e._m;for(let e=0;e<16;e++)s[e]=t[e]-Math.floor(t[e]);return e.markAsUpdated(),e}clone(){const e=new f;return e.copyFrom(this),e}getClassName(){return"Matrix"}getHashCode(){let e=l(this._m[0]);for(let t=1;t<16;t++)e=397*e^l(this._m[t]);return e}decomposeToTransformNode(e){return e.rotationQuaternion=e.rotationQuaternion||new _,this.decompose(e.scaling,e.rotationQuaternion,e.position)}decompose(e,t,s,i,r=!0){if(this._isIdentity)return s&&s.setAll(0),e&&e.setAll(1),t&&t.copyFromFloats(0,0,0,1),!0;const n=this._m;if(s&&s.copyFromFloats(n[12],n[13],n[14]),(e=e||p.Vector3[0]).x=Math.sqrt(n[0]*n[0]+n[1]*n[1]+n[2]*n[2]),e.y=Math.sqrt(n[4]*n[4]+n[5]*n[5]+n[6]*n[6]),e.z=Math.sqrt(n[8]*n[8]+n[9]*n[9]+n[10]*n[10]),i){const t=(r?i.absoluteScaling.x:i.scaling.x)<0?-1:1,s=(r?i.absoluteScaling.y:i.scaling.y)<0?-1:1,n=(r?i.absoluteScaling.z:i.scaling.z)<0?-1:1;e.x*=t,e.y*=s,e.z*=n}else this.determinant()<=0&&(e.y*=-1);if(0===e._x||0===e._y||0===e._z)return t&&t.copyFromFloats(0,0,0,1),!1;if(t){const s=1/e._x,i=1/e._y,r=1/e._z;f.FromValuesToRef(n[0]*s,n[1]*s,n[2]*s,0,n[4]*i,n[5]*i,n[6]*i,0,n[8]*r,n[9]*r,n[10]*r,0,0,0,0,1,p.Matrix[0]),_.FromRotationMatrixToRef(p.Matrix[0],t)}return!0}getRow(e){if(e<0||e>3)return null;const t=4*e;return new d(this._m[t+0],this._m[t+1],this._m[t+2],this._m[t+3])}getRowToRef(e,t){if(e>=0&&e<=3){const s=4*e;t.x=this._m[s+0],t.y=this._m[s+1],t.z=this._m[s+2],t.w=this._m[s+3]}return t}setRow(e,t){return this.setRowFromFloats(e,t.x,t.y,t.z,t.w)}transpose(){const e=new f;return f.TransposeToRef(this,e),e}transposeToRef(e){return f.TransposeToRef(this,e),e}setRowFromFloats(e,t,s,i,r){if(e<0||e>3)return this;const n=4*e;return this._m[n+0]=t,this._m[n+1]=s,this._m[n+2]=i,this._m[n+3]=r,this.markAsUpdated(),this}scale(e){const t=new f;return this.scaleToRef(e,t),t}scaleToRef(e,t){for(let s=0;s<16;s++)t._m[s]=this._m[s]*e;return t.markAsUpdated(),t}scaleAndAddToRef(e,t){for(let s=0;s<16;s++)t._m[s]+=this._m[s]*e;return t.markAsUpdated(),t}scaleInPlace(e){const t=this._m;for(let s=0;s<16;s++)t[s]*=e;return this.markAsUpdated(),this}toNormalMatrix(e){const t=p.Matrix[0];this.invertToRef(t),t.transposeToRef(e);const s=e._m;return f.FromValuesToRef(s[0],s[1],s[2],0,s[4],s[5],s[6],0,s[8],s[9],s[10],0,0,0,0,1,e),e}getRotationMatrix(){const e=new f;return this.getRotationMatrixToRef(e),e}getRotationMatrixToRef(e){const t=p.Vector3[0];if(!this.decompose(t))return f.IdentityToRef(e),e;const s=this._m,i=1/t._x,r=1/t._y,n=1/t._z;return f.FromValuesToRef(s[0]*i,s[1]*i,s[2]*i,0,s[4]*r,s[5]*r,s[6]*r,0,s[8]*n,s[9]*n,s[10]*n,0,0,0,0,1,e),e}toggleModelMatrixHandInPlace(){const e=this._m;return e[2]*=-1,e[6]*=-1,e[8]*=-1,e[9]*=-1,e[14]*=-1,this.markAsUpdated(),this}toggleProjectionMatrixHandInPlace(){const e=this._m;return e[8]*=-1,e[9]*=-1,e[10]*=-1,e[11]*=-1,this.markAsUpdated(),this}static FromArray(e,t=0){const s=new f;return f.FromArrayToRef(e,t,s),s}static FromArrayToRef(e,t,s){for(let i=0;i<16;i++)s._m[i]=e[i+t];return s.markAsUpdated(),s}static FromFloat32ArrayToRefScaled(e,t,s,i){return i._m[0]=e[0+t]*s,i._m[1]=e[1+t]*s,i._m[2]=e[2+t]*s,i._m[3]=e[3+t]*s,i._m[4]=e[4+t]*s,i._m[5]=e[5+t]*s,i._m[6]=e[6+t]*s,i._m[7]=e[7+t]*s,i._m[8]=e[8+t]*s,i._m[9]=e[9+t]*s,i._m[10]=e[10+t]*s,i._m[11]=e[11+t]*s,i._m[12]=e[12+t]*s,i._m[13]=e[13+t]*s,i._m[14]=e[14+t]*s,i._m[15]=e[15+t]*s,i.markAsUpdated(),i}static get IdentityReadOnly(){return f._IdentityReadOnly}static FromValuesToRef(e,t,s,i,r,n,a,o,h,l,c,u,d,_,f,p,g){const m=g._m;m[0]=e,m[1]=t,m[2]=s,m[3]=i,m[4]=r,m[5]=n,m[6]=a,m[7]=o,m[8]=h,m[9]=l,m[10]=c,m[11]=u,m[12]=d,m[13]=_,m[14]=f,m[15]=p,g.markAsUpdated()}static FromValues(e,t,s,i,r,n,a,o,h,l,c,u,d,_,p,g){const m=new f,T=m._m;return T[0]=e,T[1]=t,T[2]=s,T[3]=i,T[4]=r,T[5]=n,T[6]=a,T[7]=o,T[8]=h,T[9]=l,T[10]=c,T[11]=u,T[12]=d,T[13]=_,T[14]=p,T[15]=g,m.markAsUpdated(),m}static Compose(e,t,s){const i=new f;return f.ComposeToRef(e,t,s,i),i}static ComposeToRef(e,t,s,i){const r=i._m,n=t._x,a=t._y,o=t._z,h=t._w,l=n+n,c=a+a,u=o+o,d=n*l,_=n*c,f=n*u,p=a*c,g=a*u,m=o*u,T=h*l,b=h*c,E=h*u,x=e._x,A=e._y,R=e._z;return r[0]=(1-(p+m))*x,r[1]=(_+E)*x,r[2]=(f-b)*x,r[3]=0,r[4]=(_-E)*A,r[5]=(1-(d+m))*A,r[6]=(g+T)*A,r[7]=0,r[8]=(f+b)*R,r[9]=(g-T)*R,r[10]=(1-(d+p))*R,r[11]=0,r[12]=s._x,r[13]=s._y,r[14]=s._z,r[15]=1,i.markAsUpdated(),i}static Identity(){const e=f.FromValues(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return e._updateIdentityStatus(!0),e}static IdentityToRef(e){return f.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,e),e._updateIdentityStatus(!0),e}static Zero(){const e=f.FromValues(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);return e._updateIdentityStatus(!1),e}static RotationX(e){const t=new f;return f.RotationXToRef(e,t),t}static Invert(e){const t=new f;return e.invertToRef(t),t}static RotationXToRef(e,t){const s=Math.sin(e),i=Math.cos(e);return f.FromValuesToRef(1,0,0,0,0,i,s,0,0,-s,i,0,0,0,0,1,t),t._updateIdentityStatus(1===i&&0===s),t}static RotationY(e){const t=new f;return f.RotationYToRef(e,t),t}static RotationYToRef(e,t){const s=Math.sin(e),i=Math.cos(e);return f.FromValuesToRef(i,0,-s,0,0,1,0,0,s,0,i,0,0,0,0,1,t),t._updateIdentityStatus(1===i&&0===s),t}static RotationZ(e){const t=new f;return f.RotationZToRef(e,t),t}static RotationZToRef(e,t){const s=Math.sin(e),i=Math.cos(e);return f.FromValuesToRef(i,s,0,0,-s,i,0,0,0,0,1,0,0,0,0,1,t),t._updateIdentityStatus(1===i&&0===s),t}static RotationAxis(e,t){const s=new f;return f.RotationAxisToRef(e,t,s),s}static RotationAxisToRef(e,t,s){const i=Math.sin(-t),r=Math.cos(-t),n=1-r;e=e.normalizeToRef(p.Vector3[0]);const a=s._m;return a[0]=e._x*e._x*n+r,a[1]=e._x*e._y*n-e._z*i,a[2]=e._x*e._z*n+e._y*i,a[3]=0,a[4]=e._y*e._x*n+e._z*i,a[5]=e._y*e._y*n+r,a[6]=e._y*e._z*n-e._x*i,a[7]=0,a[8]=e._z*e._x*n-e._y*i,a[9]=e._z*e._y*n+e._x*i,a[10]=e._z*e._z*n+r,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,s.markAsUpdated(),s}static RotationAlignToRef(e,t,s,r=!1){const n=u.Dot(t,e),a=s._m;if(n<-1+i.bH)a[0]=-1,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=r?1:-1,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=r?-1:1,a[11]=0;else{const s=u.Cross(t,e),i=1/(1+n);a[0]=s._x*s._x*i+n,a[1]=s._y*s._x*i-s._z,a[2]=s._z*s._x*i+s._y,a[3]=0,a[4]=s._x*s._y*i+s._z,a[5]=s._y*s._y*i+n,a[6]=s._z*s._y*i-s._x,a[7]=0,a[8]=s._x*s._z*i-s._y,a[9]=s._y*s._z*i+s._x,a[10]=s._z*s._z*i+n,a[11]=0}return a[12]=0,a[13]=0,a[14]=0,a[15]=1,s.markAsUpdated(),s}static RotationYawPitchRoll(e,t,s){const i=new f;return f.RotationYawPitchRollToRef(e,t,s,i),i}static RotationYawPitchRollToRef(e,t,s,i){return _.RotationYawPitchRollToRef(e,t,s,p.Quaternion[0]),p.Quaternion[0].toRotationMatrix(i),i}static Scaling(e,t,s){const i=new f;return f.ScalingToRef(e,t,s,i),i}static ScalingToRef(e,t,s,i){return f.FromValuesToRef(e,0,0,0,0,t,0,0,0,0,s,0,0,0,0,1,i),i._updateIdentityStatus(1===e&&1===t&&1===s),i}static Translation(e,t,s){const i=new f;return f.TranslationToRef(e,t,s,i),i}static TranslationToRef(e,t,s,i){return f.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,e,t,s,1,i),i._updateIdentityStatus(0===e&&0===t&&0===s),i}static Lerp(e,t,s){const i=new f;return f.LerpToRef(e,t,s,i),i}static LerpToRef(e,t,s,i){const r=i._m,n=e.m,a=t.m;for(let e=0;e<16;e++)r[e]=n[e]*(1-s)+a[e]*s;return i.markAsUpdated(),i}static DecomposeLerp(e,t,s){const i=new f;return f.DecomposeLerpToRef(e,t,s,i),i}static DecomposeLerpToRef(e,t,s,i){const r=p.Vector3[0],n=p.Quaternion[0],a=p.Vector3[1];e.decompose(r,n,a);const o=p.Vector3[2],h=p.Quaternion[1],l=p.Vector3[3];t.decompose(o,h,l);const c=p.Vector3[4];u.LerpToRef(r,o,s,c);const d=p.Quaternion[2];_.SlerpToRef(n,h,s,d);const g=p.Vector3[5];return u.LerpToRef(a,l,s,g),f.ComposeToRef(c,d,g,i),i}static LookAtLH(e,t,s){const i=new f;return f.LookAtLHToRef(e,t,s,i),i}static LookAtLHToRef(e,t,s,i){const r=p.Vector3[0],n=p.Vector3[1],a=p.Vector3[2];t.subtractToRef(e,a),a.normalize(),u.CrossToRef(s,a,r);const o=r.lengthSquared();0===o?r.x=1:r.normalizeFromLength(Math.sqrt(o)),u.CrossToRef(a,r,n),n.normalize();const h=-u.Dot(r,e),l=-u.Dot(n,e),c=-u.Dot(a,e);return f.FromValuesToRef(r._x,n._x,a._x,0,r._y,n._y,a._y,0,r._z,n._z,a._z,0,h,l,c,1,i),i}static LookAtRH(e,t,s){const i=new f;return f.LookAtRHToRef(e,t,s,i),i}static LookAtRHToRef(e,t,s,i){const r=p.Vector3[0],n=p.Vector3[1],a=p.Vector3[2];e.subtractToRef(t,a),a.normalize(),u.CrossToRef(s,a,r);const o=r.lengthSquared();0===o?r.x=1:r.normalizeFromLength(Math.sqrt(o)),u.CrossToRef(a,r,n),n.normalize();const h=-u.Dot(r,e),l=-u.Dot(n,e),c=-u.Dot(a,e);return f.FromValuesToRef(r._x,n._x,a._x,0,r._y,n._y,a._y,0,r._z,n._z,a._z,0,h,l,c,1,i),i}static LookDirectionLH(e,t){const s=new f;return f.LookDirectionLHToRef(e,t,s),s}static LookDirectionLHToRef(e,t,s){const i=p.Vector3[0];i.copyFrom(e),i.scaleInPlace(-1);const r=p.Vector3[1];return u.CrossToRef(t,i,r),f.FromValuesToRef(r._x,r._y,r._z,0,t._x,t._y,t._z,0,i._x,i._y,i._z,0,0,0,0,1,s),s}static LookDirectionRH(e,t){const s=new f;return f.LookDirectionRHToRef(e,t,s),s}static LookDirectionRHToRef(e,t,s){const i=p.Vector3[2];return u.CrossToRef(t,e,i),f.FromValuesToRef(i._x,i._y,i._z,0,t._x,t._y,t._z,0,e._x,e._y,e._z,0,0,0,0,1,s),s}static OrthoLH(e,t,s,i,r){const n=new f;return f.OrthoLHToRef(e,t,s,i,n,r),n}static OrthoLHToRef(e,t,s,i,r,n){const a=2/e,o=2/t,h=2/(i-s),l=-(i+s)/(i-s);return f.FromValuesToRef(a,0,0,0,0,o,0,0,0,0,h,0,0,0,l,1,r),n&&r.multiplyToRef(m,r),r._updateIdentityStatus(1===a&&1===o&&1===h&&0===l),r}static OrthoOffCenterLH(e,t,s,i,r,n,a){const o=new f;return f.OrthoOffCenterLHToRef(e,t,s,i,r,n,o,a),o}static OrthoOffCenterLHToRef(e,t,s,i,r,n,a,o){const h=2/(t-e),l=2/(i-s),c=2/(n-r),u=-(n+r)/(n-r),d=(e+t)/(e-t),_=(i+s)/(s-i);return f.FromValuesToRef(h,0,0,0,0,l,0,0,0,0,c,0,d,_,u,1,a),o&&a.multiplyToRef(m,a),a.markAsUpdated(),a}static ObliqueOffCenterLHToRef(e,t,s,i,r,n,a,o,h,l,c){const u=-a*Math.cos(o),d=-a*Math.sin(o);return f.TranslationToRef(0,0,-h,p.Matrix[1]),f.FromValuesToRef(1,0,0,0,0,1,0,0,u,d,1,0,0,0,0,1,p.Matrix[0]),p.Matrix[1].multiplyToRef(p.Matrix[0],p.Matrix[0]),f.TranslationToRef(0,0,h,p.Matrix[1]),p.Matrix[0].multiplyToRef(p.Matrix[1],p.Matrix[0]),f.OrthoOffCenterLHToRef(e,t,s,i,r,n,l,c),p.Matrix[0].multiplyToRef(l,l),l}static OrthoOffCenterRH(e,t,s,i,r,n,a){const o=new f;return f.OrthoOffCenterRHToRef(e,t,s,i,r,n,o,a),o}static OrthoOffCenterRHToRef(e,t,s,i,r,n,a,o){return f.OrthoOffCenterLHToRef(e,t,s,i,r,n,a,o),a._m[10]*=-1,a}static ObliqueOffCenterRHToRef(e,t,s,i,r,n,a,o,h,l,c){const u=a*Math.cos(o),d=a*Math.sin(o);return f.TranslationToRef(0,0,h,p.Matrix[1]),f.FromValuesToRef(1,0,0,0,0,1,0,0,u,d,1,0,0,0,0,1,p.Matrix[0]),p.Matrix[1].multiplyToRef(p.Matrix[0],p.Matrix[0]),f.TranslationToRef(0,0,-h,p.Matrix[1]),p.Matrix[0].multiplyToRef(p.Matrix[1],p.Matrix[0]),f.OrthoOffCenterRHToRef(e,t,s,i,r,n,l,c),p.Matrix[0].multiplyToRef(l,l),l}static PerspectiveLH(e,t,s,i,r,n=0){const a=new f,o=2*s/e,h=2*s/t,l=(i+s)/(i-s),c=-2*i*s/(i-s),u=Math.tan(n);return f.FromValuesToRef(o,0,0,0,0,h,0,u,0,0,l,1,0,0,c,0,a),r&&a.multiplyToRef(m,a),a._updateIdentityStatus(!1),a}static PerspectiveFovLH(e,t,s,i,r,n=0,a=!1){const o=new f;return f.PerspectiveFovLHToRef(e,t,s,i,o,!0,r,n,a),o}static PerspectiveFovLHToRef(e,t,s,i,r,n=!0,a,o=0,h=!1){const l=s,c=i,u=1/Math.tan(.5*e),d=n?u/t:u,_=n?u:u*t,p=h&&0===l?-1:0!==c?(c+l)/(c-l):1,g=h&&0===l?2*c:0!==c?-2*c*l/(c-l):-2*l,T=Math.tan(o);return f.FromValuesToRef(d,0,0,0,0,_,0,T,0,0,p,1,0,0,g,0,r),a&&r.multiplyToRef(m,r),r._updateIdentityStatus(!1),r}static PerspectiveFovReverseLHToRef(e,t,s,i,r,n=!0,a,o=0){const h=1/Math.tan(.5*e),l=n?h/t:h,c=n?h:h*t,u=Math.tan(o);return f.FromValuesToRef(l,0,0,0,0,c,0,u,0,0,-s,1,0,0,1,0,r),a&&r.multiplyToRef(m,r),r._updateIdentityStatus(!1),r}static PerspectiveFovRH(e,t,s,i,r,n=0,a=!1){const o=new f;return f.PerspectiveFovRHToRef(e,t,s,i,o,!0,r,n,a),o}static PerspectiveFovRHToRef(e,t,s,i,r,n=!0,a,o=0,h=!1){const l=s,c=i,u=1/Math.tan(.5*e),d=n?u/t:u,_=n?u:u*t,p=h&&0===l?1:0!==c?-(c+l)/(c-l):-1,g=h&&0===l?2*c:0!==c?-2*c*l/(c-l):-2*l,T=Math.tan(o);return f.FromValuesToRef(d,0,0,0,0,_,0,T,0,0,p,-1,0,0,g,0,r),a&&r.multiplyToRef(m,r),r._updateIdentityStatus(!1),r}static PerspectiveFovReverseRHToRef(e,t,s,i,r,n=!0,a,o=0){const h=1/Math.tan(.5*e),l=n?h/t:h,c=n?h:h*t,u=Math.tan(o);return f.FromValuesToRef(l,0,0,0,0,c,0,u,0,0,-s,-1,0,0,-1,0,r),a&&r.multiplyToRef(m,r),r._updateIdentityStatus(!1),r}static GetFinalMatrix(e,t,s,i,r,n){const a=e.width,o=e.height,h=e.x,l=e.y,c=f.FromValues(a/2,0,0,0,0,-o/2,0,0,0,0,n-r,0,h+a/2,o/2+l,r,1),u=new f;return t.multiplyToRef(s,u),u.multiplyToRef(i,u),u.multiplyToRef(c,u)}static GetAsMatrix2x2(e){const t=e.m,s=[t[0],t[1],t[4],t[5]];return a.I.MatrixUse64Bits?s:new Float32Array(s)}static GetAsMatrix3x3(e){const t=e.m,s=[t[0],t[1],t[2],t[4],t[5],t[6],t[8],t[9],t[10]];return a.I.MatrixUse64Bits?s:new Float32Array(s)}static Transpose(e){const t=new f;return f.TransposeToRef(e,t),t}static TransposeToRef(e,t){const s=e.m,i=s[0],r=s[4],n=s[8],a=s[12],o=s[1],h=s[5],l=s[9],c=s[13],u=s[2],d=s[6],_=s[10],f=s[14],p=s[3],g=s[7],m=s[11],T=s[15],b=t._m;return b[0]=i,b[1]=r,b[2]=n,b[3]=a,b[4]=o,b[5]=h,b[6]=l,b[7]=c,b[8]=u,b[9]=d,b[10]=_,b[11]=f,b[12]=p,b[13]=g,b[14]=m,b[15]=T,t.markAsUpdated(),t._updateIdentityStatus(e._isIdentity,e._isIdentityDirty),t}static Reflection(e){const t=new f;return f.ReflectionToRef(e,t),t}static ReflectionToRef(e,t){e.normalize();const s=e.normal.x,i=e.normal.y,r=e.normal.z,n=-2*s,a=-2*i,o=-2*r;return f.FromValuesToRef(n*s+1,a*s,o*s,0,n*i,a*i+1,o*i,0,n*r,a*r,o*r+1,0,n*e.d,a*e.d,o*e.d,1,t),t}static FromXYZAxesToRef(e,t,s,i){return f.FromValuesToRef(e._x,e._y,e._z,0,t._x,t._y,t._z,0,s._x,s._y,s._z,0,0,0,0,1,i),i}static FromQuaternionToRef(e,t){const s=e._x*e._x,i=e._y*e._y,r=e._z*e._z,n=e._x*e._y,a=e._z*e._w,o=e._z*e._x,h=e._y*e._w,l=e._y*e._z,c=e._x*e._w;return t._m[0]=1-2*(i+r),t._m[1]=2*(n+a),t._m[2]=2*(o-h),t._m[3]=0,t._m[4]=2*(n-a),t._m[5]=1-2*(r+s),t._m[6]=2*(l+c),t._m[7]=0,t._m[8]=2*(o+h),t._m[9]=2*(l-c),t._m[10]=1-2*(i+s),t._m[11]=0,t._m[12]=0,t._m[13]=0,t._m[14]=0,t._m[15]=1,t.markAsUpdated(),t}}f._UpdateFlagSeed=0,f._IdentityReadOnly=f.Identity(),Object.defineProperties(f.prototype,{dimension:{value:[4,4]},rank:{value:2}});class p{}p.Vector3=(0,r.ln)(11,u.Zero),p.Matrix=(0,r.ln)(2,f.Identity),p.Quaternion=(0,r.ln)(3,_.Zero);class g{}g.Vector2=(0,r.ln)(3,c.Zero),g.Vector3=(0,r.ln)(13,u.Zero),g.Vector4=(0,r.ln)(3,d.Zero),g.Quaternion=(0,r.ln)(3,_.Zero),g.Matrix=(0,r.ln)(8,f.Identity),(0,n.Y5)("BABYLON.Vector2",c),(0,n.Y5)("BABYLON.Vector3",u),(0,n.Y5)("BABYLON.Vector4",d),(0,n.Y5)("BABYLON.Matrix",f);const m=f.FromValues(1,0,0,0,0,1,0,0,0,0,.5,0,0,0,.5,1)},4494:(e,t,s)=>{s.d(t,{L:()=>i});class i{constructor(e,t,s,i){this.x=e,this.y=t,this.width=s,this.height=i}toGlobal(e,t){return new i(this.x*e,this.y*t,this.width*e,this.height*t)}toGlobalToRef(e,t,s){return s.x=this.x*e,s.y=this.y*t,s.width=this.width*e,s.height=this.height*t,this}clone(){return new i(this.x,this.y,this.width,this.height)}}},4640:(e,t,s)=>{s.d(t,{O:()=>h,Q:()=>l});var i=s(9923);s(8733),s(6041),s(5559),s(2572),s(1903),s(4100),s(521),s(4494);const r=[Math.sqrt(1/(4*Math.PI)),-Math.sqrt(3/(4*Math.PI)),Math.sqrt(3/(4*Math.PI)),-Math.sqrt(3/(4*Math.PI)),Math.sqrt(15/(4*Math.PI)),-Math.sqrt(15/(4*Math.PI)),Math.sqrt(5/(16*Math.PI)),-Math.sqrt(15/(4*Math.PI)),Math.sqrt(15/(16*Math.PI))],n=[()=>1,e=>e.y,e=>e.z,e=>e.x,e=>e.x*e.y,e=>e.y*e.z,e=>3*e.z*e.z-1,e=>e.x*e.z,e=>e.x*e.x-e.y*e.y],a=(e,t)=>r[e]*n[e](t),o=[Math.PI,2*Math.PI/3,2*Math.PI/3,2*Math.PI/3,Math.PI/4,Math.PI/4,Math.PI/4,Math.PI/4,Math.PI/4];class h{constructor(){this.preScaled=!1,this.l00=i.Pq.Zero(),this.l1_1=i.Pq.Zero(),this.l10=i.Pq.Zero(),this.l11=i.Pq.Zero(),this.l2_2=i.Pq.Zero(),this.l2_1=i.Pq.Zero(),this.l20=i.Pq.Zero(),this.l21=i.Pq.Zero(),this.l22=i.Pq.Zero()}addLight(e,t,s){i.AA.Vector3[0].set(t.r,t.g,t.b);const r=i.AA.Vector3[0],n=i.AA.Vector3[1];r.scaleToRef(s,n),n.scaleToRef(a(0,e),i.AA.Vector3[2]),this.l00.addInPlace(i.AA.Vector3[2]),n.scaleToRef(a(1,e),i.AA.Vector3[2]),this.l1_1.addInPlace(i.AA.Vector3[2]),n.scaleToRef(a(2,e),i.AA.Vector3[2]),this.l10.addInPlace(i.AA.Vector3[2]),n.scaleToRef(a(3,e),i.AA.Vector3[2]),this.l11.addInPlace(i.AA.Vector3[2]),n.scaleToRef(a(4,e),i.AA.Vector3[2]),this.l2_2.addInPlace(i.AA.Vector3[2]),n.scaleToRef(a(5,e),i.AA.Vector3[2]),this.l2_1.addInPlace(i.AA.Vector3[2]),n.scaleToRef(a(6,e),i.AA.Vector3[2]),this.l20.addInPlace(i.AA.Vector3[2]),n.scaleToRef(a(7,e),i.AA.Vector3[2]),this.l21.addInPlace(i.AA.Vector3[2]),n.scaleToRef(a(8,e),i.AA.Vector3[2]),this.l22.addInPlace(i.AA.Vector3[2])}scaleInPlace(e){this.l00.scaleInPlace(e),this.l1_1.scaleInPlace(e),this.l10.scaleInPlace(e),this.l11.scaleInPlace(e),this.l2_2.scaleInPlace(e),this.l2_1.scaleInPlace(e),this.l20.scaleInPlace(e),this.l21.scaleInPlace(e),this.l22.scaleInPlace(e)}convertIncidentRadianceToIrradiance(){this.l00.scaleInPlace(o[0]),this.l1_1.scaleInPlace(o[1]),this.l10.scaleInPlace(o[2]),this.l11.scaleInPlace(o[3]),this.l2_2.scaleInPlace(o[4]),this.l2_1.scaleInPlace(o[5]),this.l20.scaleInPlace(o[6]),this.l21.scaleInPlace(o[7]),this.l22.scaleInPlace(o[8])}convertIrradianceToLambertianRadiance(){this.scaleInPlace(1/Math.PI)}preScaleForRendering(){this.preScaled=!0,this.l00.scaleInPlace(r[0]),this.l1_1.scaleInPlace(r[1]),this.l10.scaleInPlace(r[2]),this.l11.scaleInPlace(r[3]),this.l2_2.scaleInPlace(r[4]),this.l2_1.scaleInPlace(r[5]),this.l20.scaleInPlace(r[6]),this.l21.scaleInPlace(r[7]),this.l22.scaleInPlace(r[8])}updateFromArray(e){return i.Pq.FromArrayToRef(e[0],0,this.l00),i.Pq.FromArrayToRef(e[1],0,this.l1_1),i.Pq.FromArrayToRef(e[2],0,this.l10),i.Pq.FromArrayToRef(e[3],0,this.l11),i.Pq.FromArrayToRef(e[4],0,this.l2_2),i.Pq.FromArrayToRef(e[5],0,this.l2_1),i.Pq.FromArrayToRef(e[6],0,this.l20),i.Pq.FromArrayToRef(e[7],0,this.l21),i.Pq.FromArrayToRef(e[8],0,this.l22),this}updateFromFloatsArray(e){return i.Pq.FromFloatsToRef(e[0],e[1],e[2],this.l00),i.Pq.FromFloatsToRef(e[3],e[4],e[5],this.l1_1),i.Pq.FromFloatsToRef(e[6],e[7],e[8],this.l10),i.Pq.FromFloatsToRef(e[9],e[10],e[11],this.l11),i.Pq.FromFloatsToRef(e[12],e[13],e[14],this.l2_2),i.Pq.FromFloatsToRef(e[15],e[16],e[17],this.l2_1),i.Pq.FromFloatsToRef(e[18],e[19],e[20],this.l20),i.Pq.FromFloatsToRef(e[21],e[22],e[23],this.l21),i.Pq.FromFloatsToRef(e[24],e[25],e[26],this.l22),this}static FromArray(e){return(new h).updateFromArray(e)}static FromPolynomial(e){const t=new h;return t.l00=e.xx.scale(.376127).add(e.yy.scale(.376127)).add(e.zz.scale(.376126)),t.l1_1=e.y.scale(.977204),t.l10=e.z.scale(.977204),t.l11=e.x.scale(.977204),t.l2_2=e.xy.scale(1.16538),t.l2_1=e.yz.scale(1.16538),t.l20=e.zz.scale(1.34567).subtract(e.xx.scale(.672834)).subtract(e.yy.scale(.672834)),t.l21=e.zx.scale(1.16538),t.l22=e.xx.scale(1.16538).subtract(e.yy.scale(1.16538)),t.l1_1.scaleInPlace(-1),t.l11.scaleInPlace(-1),t.l2_1.scaleInPlace(-1),t.l21.scaleInPlace(-1),t.scaleInPlace(Math.PI),t}}class l{constructor(){this.x=i.Pq.Zero(),this.y=i.Pq.Zero(),this.z=i.Pq.Zero(),this.xx=i.Pq.Zero(),this.yy=i.Pq.Zero(),this.zz=i.Pq.Zero(),this.xy=i.Pq.Zero(),this.yz=i.Pq.Zero(),this.zx=i.Pq.Zero()}get preScaledHarmonics(){return this._harmonics||(this._harmonics=h.FromPolynomial(this)),this._harmonics.preScaled||this._harmonics.preScaleForRendering(),this._harmonics}addAmbient(e){i.AA.Vector3[0].copyFromFloats(e.r,e.g,e.b);const t=i.AA.Vector3[0];this.xx.addInPlace(t),this.yy.addInPlace(t),this.zz.addInPlace(t)}scaleInPlace(e){this.x.scaleInPlace(e),this.y.scaleInPlace(e),this.z.scaleInPlace(e),this.xx.scaleInPlace(e),this.yy.scaleInPlace(e),this.zz.scaleInPlace(e),this.yz.scaleInPlace(e),this.zx.scaleInPlace(e),this.xy.scaleInPlace(e)}updateFromHarmonics(e){return this._harmonics=e,this.x.copyFrom(e.l11),this.x.scaleInPlace(1.02333).scaleInPlace(-1),this.y.copyFrom(e.l1_1),this.y.scaleInPlace(1.02333).scaleInPlace(-1),this.z.copyFrom(e.l10),this.z.scaleInPlace(1.02333),this.xx.copyFrom(e.l00),i.AA.Vector3[0].copyFrom(e.l20).scaleInPlace(.247708),i.AA.Vector3[1].copyFrom(e.l22).scaleInPlace(.429043),this.xx.scaleInPlace(.886277).subtractInPlace(i.AA.Vector3[0]).addInPlace(i.AA.Vector3[1]),this.yy.copyFrom(e.l00),this.yy.scaleInPlace(.886277).subtractInPlace(i.AA.Vector3[0]).subtractInPlace(i.AA.Vector3[1]),this.zz.copyFrom(e.l00),i.AA.Vector3[0].copyFrom(e.l20).scaleInPlace(.495417),this.zz.scaleInPlace(.886277).addInPlace(i.AA.Vector3[0]),this.yz.copyFrom(e.l2_1),this.yz.scaleInPlace(.858086).scaleInPlace(-1),this.zx.copyFrom(e.l21),this.zx.scaleInPlace(.858086).scaleInPlace(-1),this.xy.copyFrom(e.l2_2),this.xy.scaleInPlace(.858086),this.scaleInPlace(1/Math.PI),this}static FromHarmonics(e){return(new l).updateFromHarmonics(e)}static FromArray(e){const t=new l;return i.Pq.FromArrayToRef(e[0],0,t.x),i.Pq.FromArrayToRef(e[1],0,t.y),i.Pq.FromArrayToRef(e[2],0,t.z),i.Pq.FromArrayToRef(e[3],0,t.xx),i.Pq.FromArrayToRef(e[4],0,t.yy),i.Pq.FromArrayToRef(e[5],0,t.zz),i.Pq.FromArrayToRef(e[6],0,t.yz),i.Pq.FromArrayToRef(e[7],0,t.zx),i.Pq.FromArrayToRef(e[8],0,t.xy),t}}},8529:(e,t,s)=>{s.d(t,{km:()=>g});var i=s(9923),r=s(6041),n=s(5530),a=s(6803),o=s(5616);n.e._GroundMeshParser=(e,t)=>h.Parse(e,t);class h extends n.e{constructor(e,t){super(e,t),this.generateOctree=!1}getClassName(){return"GroundMesh"}get subdivisions(){return Math.min(this._subdivisionsX,this._subdivisionsY)}get subdivisionsX(){return this._subdivisionsX}get subdivisionsY(){return this._subdivisionsY}optimize(e,t=32){this._subdivisionsX=e,this._subdivisionsY=e,this.subdivide(e);this.createOrUpdateSubmeshesOctree&&this.createOrUpdateSubmeshesOctree(t)}getHeightAtCoordinates(e,t){const s=this.getWorldMatrix(),r=i.AA.Matrix[5];s.invertToRef(r);const n=i.AA.Vector3[8];if(i.Pq.TransformCoordinatesFromFloatsToRef(e,0,t,r,n),e=n.x,t=n.z,e=this._maxX||t<=this._minZ||t>this._maxZ)return this.position.y;this._heightQuads&&0!=this._heightQuads.length||(this._initHeightQuads(),this._computeHeightQuads());const a=this._getFacetAt(e,t),o=-(a.x*e+a.z*t+a.w)/a.y;return i.Pq.TransformCoordinatesFromFloatsToRef(0,o,0,s,n),n.y}getNormalAtCoordinates(e,t){const s=new i.Pq(0,1,0);return this.getNormalAtCoordinatesToRef(e,t,s),s}getNormalAtCoordinatesToRef(e,t,s){const r=this.getWorldMatrix(),n=i.AA.Matrix[5];r.invertToRef(n);const a=i.AA.Vector3[8];if(i.Pq.TransformCoordinatesFromFloatsToRef(e,0,t,n,a),e=a.x,t=a.z,ethis._maxX||tthis._maxZ)return this;this._heightQuads&&0!=this._heightQuads.length||(this._initHeightQuads(),this._computeHeightQuads());const o=this._getFacetAt(e,t);return i.Pq.TransformNormalFromFloatsToRef(o.x,o.y,o.z,r,s),this}updateCoordinateHeights(){return this._heightQuads&&0!=this._heightQuads.length||this._initHeightQuads(),this._computeHeightQuads(),this}_getFacetAt(e,t){const s=Math.floor((e+this._maxX)*this._subdivisionsX/this._width),i=Math.floor(-(t+this._maxZ)*this._subdivisionsY/this._height+this._subdivisionsY),r=this._heightQuads[i*this._subdivisionsX+s];let n;return n=te.maxHeight){_=!0;const t=e.maxHeight;e.maxHeight=e.minHeight,e.minHeight=t}for(h=0;h<=e.subdivisions;h++)for(l=0;l<=e.subdivisions;l++){const t=new i.Pq(l*e.width/e.subdivisions-e.width/2,0,(e.subdivisions-h)*e.height/e.subdivisions-e.height/2),r=4*(((t.x+e.width/2)/e.width*(e.bufferWidth-1)|0)+((1-(t.z+e.height/2)/e.height)*(e.bufferHeight-1)|0)*e.bufferWidth);let a=e.buffer[r]/255,f=e.buffer[r+1]/255,p=e.buffer[r+2]/255;const g=e.buffer[r+3]/255;_&&(a=1-a,f=1-f,p=1-p);const m=a*c.r+f*c.g+p*c.b;t.y=g>=d?e.minHeight+(e.maxHeight-e.minHeight)*m:e.minHeight-u.bH,e.heightBuffer&&(e.heightBuffer[h*(e.subdivisions+1)+l]=t.y),s.push(t.x,t.y,t.z),n.push(0,0,0),o.push(l/e.subdivisions,1-h/e.subdivisions)}for(h=0;h=e.minHeight,c=s[3*r+1]>=e.minHeight,u=s[3*n+1]>=e.minHeight;o&&c&&u&&(t.push(i),t.push(r),t.push(n)),s[3*a+1]>=e.minHeight&&o&&u&&(t.push(a),t.push(i),t.push(n))}a.P.ComputeNormals(s,t,n);const f=new a.P;return f.indices=t,f.positions=s,f.normals=n,f.uvs=o,f}function g(e,t={},s){const i=new h(e,s);return i._setReady(!1),i._subdivisionsX=t.subdivisionsX||t.subdivisions||1,i._subdivisionsY=t.subdivisionsY||t.subdivisions||1,i._width=t.width||1,i._height=t.height||1,i._maxX=i._width/2,i._maxZ=i._height/2,i._minX=-i._maxX,i._minZ=-i._maxZ,_(t).applyToMesh(i,t.updatable),i._setReady(!0),i}a.P.CreateGround=_,a.P.CreateTiledGround=f,a.P.CreateGroundFromHeightMap=p,n.e.CreateGround=(e,t,s,i,r,n)=>g(e,{width:t,height:s,subdivisions:i,updatable:n},r),n.e.CreateTiledGround=(e,t,s,i,r,a,o,h,l)=>function(e,t,s=null){const i=new n.e(e,s);return f(t).applyToMesh(i,t.updatable),i}(e,{xmin:t,zmin:s,xmax:i,zmax:r,subdivisions:a,precision:o,updatable:l},h),n.e.CreateGroundFromHeightMap=(e,t,s,i,n,a,o,u,d,_,f)=>function(e,t,s={},i=null){const n=s.width||10,a=s.height||10,o=s.subdivisions||1,u=s.minHeight||0,d=s.maxHeight||1,_=s.colorFilter||new r.v9(.3,.59,.11),f=s.alphaFilter||0,g=s.updatable,m=s.onReady;i=i||c.q.LastCreatedScene;const T=new h(e,i);let b;T._subdivisionsX=o,T._subdivisionsY=o,T._width=n,T._height=a,T._maxX=T._width/2,T._maxZ=T._height/2,T._minX=-T._maxX,T._minZ=-T._maxZ,T._setReady(!1),s.passHeightBufferInCallback&&(b=new Float32Array((o+1)*(o+1)));const E=(e,t,s)=>{p({width:n,height:a,subdivisions:o,minHeight:u,maxHeight:d,colorFilter:_,buffer:e,bufferWidth:t,bufferHeight:s,alphaFilter:f,heightBuffer:b}).applyToMesh(T,g),m&&m(T,b),T._setReady(!0)};if("string"==typeof t){const e=e=>{const t=e.width,s=e.height;if(i.isDisposed)return;const r=i?.getEngine().resizeImageBitmap(e,t,s);E(r,t,s)};l.S0.LoadImage(t,e,s.onError?s.onError:()=>{},i.offlineProvider)}else E(t.data,t.width,t.height);return T}(e,t,{width:s,height:i,subdivisions:n,minHeight:a,maxHeight:o,updatable:d,onReady:_,alphaFilter:f},u)},4329:(e,t,s)=>{s.d(t,{A:()=>r});var i=s(1504);class r extends i.n{constructor(e){super(),this._buffer=e}get underlyingResource(){return this._buffer}}},861:(e,t,s)=>{s.d(t,{u:()=>R});var i=s(5524),r=s(9848),n=s(9923),a=s(5616),o=s(6803),h=s(7328),l=s(311),c=s(2564),u=s(935);class d{constructor(){this._checkCollisions=!1,this._collisionMask=-1,this._collisionGroup=-1,this._surroundingMeshes=null,this._collider=null,this._oldPositionForCollisions=new n.Pq(0,0,0),this._diffPositionForCollisions=new n.Pq(0,0,0),this._collisionResponse=!0}}var _=s(5503),f=s(1139),p=s(6041),g=s(5559),m=s(8733),T=s(6552),b=s(9259),E=s(6326);class x{constructor(){this.facetNb=0,this.partitioningSubdivisions=10,this.partitioningBBoxRatio=1.01,this.facetDataEnabled=!1,this.facetParameters={},this.bbSize=n.Pq.Zero(),this.subDiv={max:1,X:1,Y:1,Z:1},this.facetDepthSort=!1,this.facetDepthSortEnabled=!1}}class A{constructor(){this._hasVertexAlpha=!1,this._useVertexColors=!0,this._numBoneInfluencers=4,this._applyFog=!0,this._receiveShadows=!1,this._facetData=new x,this._visibility=1,this._skeleton=null,this._layerMask=268435455,this._computeBonesUsingShaders=!0,this._isActive=!1,this._onlyForInstances=!1,this._isActiveIntermediate=!1,this._onlyForInstancesIntermediate=!1,this._actAsRegularMesh=!1,this._currentLOD=null,this._currentLODIsUpToDate=!1,this._collisionRetryCount=3,this._morphTargetManager=null,this._renderingGroupId=0,this._bakedVertexAnimationManager=null,this._material=null,this._positions=null,this._pointerOverDisableMeshTesting=!1,this._meshCollisionData=new d,this._enableDistantPicking=!1,this._rawBoundingInfo=null,this._sideOrientationHint=!1,this._inheritVisibility=!1}}class R extends h.V{static get BILLBOARDMODE_NONE(){return h.V.BILLBOARDMODE_NONE}static get BILLBOARDMODE_X(){return h.V.BILLBOARDMODE_X}static get BILLBOARDMODE_Y(){return h.V.BILLBOARDMODE_Y}static get BILLBOARDMODE_Z(){return h.V.BILLBOARDMODE_Z}static get BILLBOARDMODE_ALL(){return h.V.BILLBOARDMODE_ALL}static get BILLBOARDMODE_USE_POSITION(){return h.V.BILLBOARDMODE_USE_POSITION}get facetNb(){return this._internalAbstractMeshDataInfo._facetData.facetNb}get partitioningSubdivisions(){return this._internalAbstractMeshDataInfo._facetData.partitioningSubdivisions}set partitioningSubdivisions(e){this._internalAbstractMeshDataInfo._facetData.partitioningSubdivisions=e}get partitioningBBoxRatio(){return this._internalAbstractMeshDataInfo._facetData.partitioningBBoxRatio}set partitioningBBoxRatio(e){this._internalAbstractMeshDataInfo._facetData.partitioningBBoxRatio=e}get mustDepthSortFacets(){return this._internalAbstractMeshDataInfo._facetData.facetDepthSort}set mustDepthSortFacets(e){this._internalAbstractMeshDataInfo._facetData.facetDepthSort=e}get facetDepthSortFrom(){return this._internalAbstractMeshDataInfo._facetData.facetDepthSortFrom}set facetDepthSortFrom(e){this._internalAbstractMeshDataInfo._facetData.facetDepthSortFrom=e}get collisionRetryCount(){return this._internalAbstractMeshDataInfo._collisionRetryCount}set collisionRetryCount(e){this._internalAbstractMeshDataInfo._collisionRetryCount=e}get isFacetDataEnabled(){return this._internalAbstractMeshDataInfo._facetData.facetDataEnabled}get morphTargetManager(){return this._internalAbstractMeshDataInfo._morphTargetManager}set morphTargetManager(e){this._internalAbstractMeshDataInfo._morphTargetManager!==e&&(this._internalAbstractMeshDataInfo._morphTargetManager=e,this._syncGeometryWithMorphTargetManager())}get bakedVertexAnimationManager(){return this._internalAbstractMeshDataInfo._bakedVertexAnimationManager}set bakedVertexAnimationManager(e){this._internalAbstractMeshDataInfo._bakedVertexAnimationManager!==e&&(this._internalAbstractMeshDataInfo._bakedVertexAnimationManager=e,this._markSubMeshesAsAttributesDirty())}_syncGeometryWithMorphTargetManager(){}_updateNonUniformScalingState(e){return!!super._updateNonUniformScalingState(e)&&(this._markSubMeshesAsMiscDirty(),!0)}get rawBoundingInfo(){return this._internalAbstractMeshDataInfo._rawBoundingInfo}set rawBoundingInfo(e){this._internalAbstractMeshDataInfo._rawBoundingInfo=e}set onCollide(e){this._internalAbstractMeshDataInfo._meshCollisionData._onCollideObserver&&this.onCollideObservable.remove(this._internalAbstractMeshDataInfo._meshCollisionData._onCollideObserver),this._internalAbstractMeshDataInfo._meshCollisionData._onCollideObserver=this.onCollideObservable.add(e)}set onCollisionPositionChange(e){this._internalAbstractMeshDataInfo._meshCollisionData._onCollisionPositionChangeObserver&&this.onCollisionPositionChangeObservable.remove(this._internalAbstractMeshDataInfo._meshCollisionData._onCollisionPositionChangeObserver),this._internalAbstractMeshDataInfo._meshCollisionData._onCollisionPositionChangeObserver=this.onCollisionPositionChangeObservable.add(e)}get visibility(){return this._internalAbstractMeshDataInfo._visibility}set visibility(e){if(this._internalAbstractMeshDataInfo._visibility===e)return;const t=this._internalAbstractMeshDataInfo._visibility;this._internalAbstractMeshDataInfo._visibility=e,(1===t&&1!==e||1!==t&&1===e)&&this._markSubMeshesAsDirty((e=>{e.markAsMiscDirty(),e.markAsPrePassDirty()}))}get inheritVisibility(){return this._internalAbstractMeshDataInfo._inheritVisibility}set inheritVisibility(e){this._internalAbstractMeshDataInfo._inheritVisibility=e}get isVisible(){if(!this._isVisible||!this.inheritVisibility||!this._parentNode)return this._isVisible;if(this._isVisible){let e=this._parentNode;for(;e;){const t=e.isVisible;if(void 0!==t)return t;e=e.parent}}return this._isVisible}set isVisible(e){this._isVisible=e}get pointerOverDisableMeshTesting(){return this._internalAbstractMeshDataInfo._pointerOverDisableMeshTesting}set pointerOverDisableMeshTesting(e){this._internalAbstractMeshDataInfo._pointerOverDisableMeshTesting=e}get renderingGroupId(){return this._internalAbstractMeshDataInfo._renderingGroupId}set renderingGroupId(e){this._internalAbstractMeshDataInfo._renderingGroupId=e}get material(){return this._internalAbstractMeshDataInfo._material}set material(e){this._setMaterial(e)}_setMaterial(e){this._internalAbstractMeshDataInfo._material!==e&&(this._internalAbstractMeshDataInfo._material&&this._internalAbstractMeshDataInfo._material.meshMap&&(this._internalAbstractMeshDataInfo._material.meshMap[this.uniqueId]=void 0),this._internalAbstractMeshDataInfo._material=e,e&&e.meshMap&&(e.meshMap[this.uniqueId]=this),this.onMaterialChangedObservable.hasObservers()&&this.onMaterialChangedObservable.notifyObservers(this),this.subMeshes&&(this.resetDrawCache(),this._unBindEffect()))}getMaterialForRenderPass(e){return this._internalAbstractMeshDataInfo._materialForRenderPass?.[e]}setMaterialForRenderPass(e,t){this.resetDrawCache(e),this._internalAbstractMeshDataInfo._materialForRenderPass||(this._internalAbstractMeshDataInfo._materialForRenderPass=[]),this._internalAbstractMeshDataInfo._materialForRenderPass[e]=t}get receiveShadows(){return this._internalAbstractMeshDataInfo._receiveShadows}set receiveShadows(e){this._internalAbstractMeshDataInfo._receiveShadows!==e&&(this._internalAbstractMeshDataInfo._receiveShadows=e,this._markSubMeshesAsLightDirty())}get hasVertexAlpha(){return this._internalAbstractMeshDataInfo._hasVertexAlpha}set hasVertexAlpha(e){this._internalAbstractMeshDataInfo._hasVertexAlpha!==e&&(this._internalAbstractMeshDataInfo._hasVertexAlpha=e,this._markSubMeshesAsAttributesDirty(),this._markSubMeshesAsMiscDirty())}get useVertexColors(){return this._internalAbstractMeshDataInfo._useVertexColors}set useVertexColors(e){this._internalAbstractMeshDataInfo._useVertexColors!==e&&(this._internalAbstractMeshDataInfo._useVertexColors=e,this._markSubMeshesAsAttributesDirty())}get computeBonesUsingShaders(){return this._internalAbstractMeshDataInfo._computeBonesUsingShaders}set computeBonesUsingShaders(e){this._internalAbstractMeshDataInfo._computeBonesUsingShaders!==e&&(this._internalAbstractMeshDataInfo._computeBonesUsingShaders=e,this._markSubMeshesAsAttributesDirty())}get numBoneInfluencers(){return this._internalAbstractMeshDataInfo._numBoneInfluencers}set numBoneInfluencers(e){this._internalAbstractMeshDataInfo._numBoneInfluencers!==e&&(this._internalAbstractMeshDataInfo._numBoneInfluencers=e,this._markSubMeshesAsAttributesDirty())}get applyFog(){return this._internalAbstractMeshDataInfo._applyFog}set applyFog(e){this._internalAbstractMeshDataInfo._applyFog!==e&&(this._internalAbstractMeshDataInfo._applyFog=e,this._markSubMeshesAsMiscDirty())}get enableDistantPicking(){return this._internalAbstractMeshDataInfo._enableDistantPicking}set enableDistantPicking(e){this._internalAbstractMeshDataInfo._enableDistantPicking=e}get layerMask(){return this._internalAbstractMeshDataInfo._layerMask}set layerMask(e){e!==this._internalAbstractMeshDataInfo._layerMask&&(this._internalAbstractMeshDataInfo._layerMask=e,this._resyncLightSources())}get collisionMask(){return this._internalAbstractMeshDataInfo._meshCollisionData._collisionMask}set collisionMask(e){this._internalAbstractMeshDataInfo._meshCollisionData._collisionMask=isNaN(e)?-1:e}get collisionResponse(){return this._internalAbstractMeshDataInfo._meshCollisionData._collisionResponse}set collisionResponse(e){this._internalAbstractMeshDataInfo._meshCollisionData._collisionResponse=e}get collisionGroup(){return this._internalAbstractMeshDataInfo._meshCollisionData._collisionGroup}set collisionGroup(e){this._internalAbstractMeshDataInfo._meshCollisionData._collisionGroup=isNaN(e)?-1:e}get surroundingMeshes(){return this._internalAbstractMeshDataInfo._meshCollisionData._surroundingMeshes}set surroundingMeshes(e){this._internalAbstractMeshDataInfo._meshCollisionData._surroundingMeshes=e}get lightSources(){return this._lightSources}set skeleton(e){const t=this._internalAbstractMeshDataInfo._skeleton;t&&t.needInitialSkinMatrix&&t._unregisterMeshWithPoseMatrix(this),e&&e.needInitialSkinMatrix&&e._registerMeshWithPoseMatrix(this),this._internalAbstractMeshDataInfo._skeleton=e,this._internalAbstractMeshDataInfo._skeleton||(this._bonesTransformMatrices=null),this._markSubMeshesAsAttributesDirty()}get skeleton(){return this._internalAbstractMeshDataInfo._skeleton}constructor(e,t=null){switch(super(e,t,!1),this._internalAbstractMeshDataInfo=new A,this._waitingMaterialId=null,this._waitingMorphTargetManagerId=null,this.cullingStrategy=R.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY,this.onCollideObservable=new r.cP,this.onCollisionPositionChangeObservable=new r.cP,this.onMaterialChangedObservable=new r.cP,this.definedFacingForward=!0,this._occlusionQuery=null,this._renderingGroup=null,this.alphaIndex=Number.MAX_VALUE,this._isVisible=!0,this.isPickable=!0,this.isNearPickable=!1,this.isNearGrabbable=!1,this.showSubMeshesBoundingBox=!1,this.isBlocker=!1,this.enablePointerMoveEvents=!1,this.outlineColor=p.v9.Red(),this.outlineWidth=.02,this.overlayColor=p.v9.Red(),this.overlayAlpha=.5,this.useOctreeForRenderingSelection=!0,this.useOctreeForPicking=!0,this.useOctreeForCollisions=!0,this.alwaysSelectAsActiveMesh=!1,this.doNotSyncBoundingInfo=!1,this.actionManager=null,this.ellipsoid=new n.Pq(.5,1,.5),this.ellipsoidOffset=new n.Pq(0,0,0),this.edgesWidth=1,this.edgesColor=new p.ov(1,0,0,1),this._edgesRenderer=null,this._masterMesh=null,this._boundingInfo=null,this._boundingInfoIsDirty=!0,this._renderId=0,this._intersectionsInProgress=new Array,this._unIndexed=!1,this._lightSources=new Array,this._waitingData={lods:null,actions:null,freezeWorldMatrix:null},this._bonesTransformMatrices=null,this._transformMatrixTexture=null,this.onRebuildObservable=new r.cP,this._onCollisionPositionChange=(e,t,s=null)=>{t.subtractToRef(this._internalAbstractMeshDataInfo._meshCollisionData._oldPositionForCollisions,this._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions),this._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions.length()>E.$.CollisionsEpsilon&&this.position.addInPlace(this._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions),s&&this.onCollideObservable.notifyObservers(s),this.onCollisionPositionChangeObservable.notifyObservers(this.position)},(t=this.getScene()).addMesh(this),this._resyncLightSources(),this._uniformBuffer=new u.D(this.getScene().getEngine(),void 0,void 0,e,!this.getScene().getEngine().isWebGPU),this._buildUniformLayout(),t.performancePriority){case 2:this.doNotSyncBoundingInfo=!0;case 1:this.alwaysSelectAsActiveMesh=!0,this.isPickable=!1}}_buildUniformLayout(){this._uniformBuffer.addUniform("world",16),this._uniformBuffer.addUniform("visibility",1),this._uniformBuffer.create()}transferToEffect(e){const t=this._uniformBuffer;t.updateMatrix("world",e),t.updateFloat("visibility",this._internalAbstractMeshDataInfo._visibility),t.update()}getMeshUniformBuffer(){return this._uniformBuffer}getClassName(){return"AbstractMesh"}toString(e){let t="Name: "+this.name+", isInstance: "+("InstancedMesh"!==this.getClassName()?"YES":"NO");t+=", # of submeshes: "+(this.subMeshes?this.subMeshes.length:0);const s=this._internalAbstractMeshDataInfo._skeleton;return s&&(t+=", skeleton: "+s.name),e&&(t+=", billboard mode: "+["NONE","X","Y",null,"Z",null,null,"ALL"][this.billboardMode],t+=", freeze wrld mat: "+(this._isWorldMatrixFrozen||this._waitingData.freezeWorldMatrix?"YES":"NO")),t}_getEffectiveParent(){return this._masterMesh&&this.billboardMode!==h.V.BILLBOARDMODE_NONE?this._masterMesh:super._getEffectiveParent()}_getActionManagerForTrigger(e,t=!0){if(this.actionManager&&(t||this.actionManager.isRecursive)){if(!e)return this.actionManager;if(this.actionManager.hasSpecificTrigger(e))return this.actionManager}return this.parent?this.parent._getActionManagerForTrigger(e,!1):null}_rebuild(e=!1){if(this.onRebuildObservable.notifyObservers(this),null!==this._occlusionQuery&&(this._occlusionQuery=null),this.subMeshes){for(const e of this.subMeshes)e._rebuild();this.resetDrawCache()}}_resyncLightSources(){this._lightSources.length=0;for(const e of this.getScene().lights)e.isEnabled()&&e.canAffectMesh(this)&&this._lightSources.push(e);this._markSubMeshesAsLightDirty()}_resyncLightSource(e){const t=e.isEnabled()&&e.canAffectMesh(this),s=this._lightSources.indexOf(e);let i=!1;if(-1===s){if(!t)return;this._lightSources.push(e)}else{if(t)return;i=!0,this._lightSources.splice(s,1)}this._markSubMeshesAsLightDirty(i)}_unBindEffect(){for(const e of this.subMeshes)e.setEffect(null)}_removeLightSource(e,t){const s=this._lightSources.indexOf(e);-1!==s&&(this._lightSources.splice(s,1),this._markSubMeshesAsLightDirty(t))}_markSubMeshesAsDirty(e){if(this.subMeshes)for(const t of this.subMeshes)for(let s=0;st.markAsLightDirty(e)))}_markSubMeshesAsAttributesDirty(){this._markSubMeshesAsDirty((e=>e.markAsAttributesDirty()))}_markSubMeshesAsMiscDirty(){this._markSubMeshesAsDirty((e=>e.markAsMiscDirty()))}markAsDirty(e){return this._currentRenderId=Number.MAX_VALUE,super.markAsDirty(e),this._isDirty=!0,this}resetDrawCache(e){if(this.subMeshes)for(const t of this.subMeshes)t.resetDrawCache(e)}get isBlocked(){return!1}getLOD(e){return this}getTotalVertices(){return 0}getTotalIndices(){return 0}getIndices(){return null}getVerticesData(e){return null}setVerticesData(e,t,s,i){return this}updateVerticesData(e,t,s,i){return this}setIndices(e,t){return this}isVerticesDataPresent(e){return!1}getBoundingInfo(){return this._masterMesh?this._masterMesh.getBoundingInfo():(this._boundingInfoIsDirty&&(this._boundingInfoIsDirty=!1,this._updateBoundingInfo()),this._boundingInfo)}getRawBoundingInfo(){return this.rawBoundingInfo??this.getBoundingInfo()}setBoundingInfo(e){return this._boundingInfo=e,this}get hasBoundingInfo(){return null!==this._boundingInfo}buildBoundingInfo(e,t,s){return this._boundingInfo=new c.j(e,t,s),this._boundingInfo}normalizeToUnitCube(e=!0,t=!1,s){return super.normalizeToUnitCube(e,t,s)}get useBones(){return this.skeleton&&this.getScene().skeletonsEnabled&&this.isVerticesDataPresent(a.R.MatricesIndicesKind)&&this.isVerticesDataPresent(a.R.MatricesWeightsKind)}_preActivate(){}_preActivateForIntermediateRendering(e){}_activate(e,t){return this._renderId=e,!0}_postActivate(){}_freeze(){}_unFreeze(){}getWorldMatrix(){return this._masterMesh&&this.billboardMode===h.V.BILLBOARDMODE_NONE?this._masterMesh.getWorldMatrix():super.getWorldMatrix()}_getWorldMatrixDeterminant(){return this._masterMesh?this._masterMesh._getWorldMatrixDeterminant():super._getWorldMatrixDeterminant()}get isAnInstance(){return!1}get hasInstances(){return!1}get hasThinInstances(){return!1}movePOV(e,t,s){return this.position.addInPlace(this.calcMovePOV(e,t,s)),this}calcMovePOV(e,t,s){const i=new n.uq;(this.rotationQuaternion?this.rotationQuaternion:n.PT.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z)).toRotationMatrix(i);const r=n.Pq.Zero(),a=this.definedFacingForward?-1:1;return n.Pq.TransformCoordinatesFromFloatsToRef(e*a,t,s*a,i,r),r}rotatePOV(e,t,s){return this.rotation.addInPlace(this.calcRotatePOV(e,t,s)),this}calcRotatePOV(e,t,s){const i=this.definedFacingForward?1:-1;return new n.Pq(e*i,t,s*i)}_refreshBoundingInfo(e,t){if(e){const s=(0,f.b8)(e,0,this.getTotalVertices(),t);this._boundingInfo?this._boundingInfo.reConstruct(s.minimum,s.maximum):this._boundingInfo=new c.j(s.minimum,s.maximum)}if(this.subMeshes)for(let t=0;t0&&(n.uq.FromFloat32ArrayToRefScaled(s,Math.floor(16*i[a+_]),f,u),c.addToSelf(u));if(o&&h)for(_=0;_<4;_++)f=h[a+_],f>0&&(n.uq.FromFloat32ArrayToRefScaled(s,Math.floor(16*o[a+_]),f,u),c.addToSelf(u));d(e[t],e[t+1],e[t+2],c,l),l.toArray(e,t)}}(e,t,s,i,r,o,h)}_getData(e,t,s=a.R.PositionKind){const i=e.cache,r=e=>{if(i){const t=i._vertexData||(i._vertexData={});return t[e]||this.copyVerticesData(e,t),t[e]}return this.getVerticesData(e)};if(t||(t=r(s)),!t)return null;if(i?(i._outputData?i._outputData.set(t):i._outputData=new Float32Array(t),t=i._outputData):(e.applyMorph&&this.morphTargetManager||e.applySkeleton&&this.skeleton)&&(t=t.slice()),e.applyMorph&&this.morphTargetManager&&function(e,t,s){let i=null;switch(t){case a.R.PositionKind:i=e=>e.getPositions();break;case a.R.NormalKind:i=e=>e.getNormals();break;case a.R.TangentKind:i=e=>e.getTangents();break;case a.R.UVKind:i=e=>e.getUVs();break;default:return}for(let t=0;t4,o=n?r(a.R.MatricesIndicesExtraKind):null,h=n?r(a.R.MatricesWeightsExtraKind):null,l=this.skeleton.getTransformMatrices(this);R._ApplySkeleton(t,s,l,e,i,o,h)}}if(!1!==e.updatePositionsArray&&s===a.R.PositionKind){const e=this._internalAbstractMeshDataInfo._positions||[],s=e.length;if(e.length=t.length/3,s1||!i.IsGlobal)&&i.updateBoundingInfo(e)}return this}_afterComputeWorldMatrix(){this.doNotSyncBoundingInfo||(this._boundingInfoIsDirty=!0)}isInFrustum(e){return this.getBoundingInfo().isInFrustum(e,this.cullingStrategy)}isCompletelyInFrustum(e){return this.getBoundingInfo().isCompletelyInFrustum(e)}intersectsMesh(e,t=!1,s){const i=this.getBoundingInfo(),r=e.getBoundingInfo();if(i.intersects(r,t))return!0;if(s)for(const s of this.getChildMeshes())if(s.intersectsMesh(e,t,!0))return!0;return!1}intersectsPoint(e){return this.getBoundingInfo().intersectsPoint(e)}get checkCollisions(){return this._internalAbstractMeshDataInfo._meshCollisionData._checkCollisions}set checkCollisions(e){this._internalAbstractMeshDataInfo._meshCollisionData._checkCollisions=e}get collider(){return this._internalAbstractMeshDataInfo._meshCollisionData._collider}moveWithCollisions(e){this.getAbsolutePosition().addToRef(this.ellipsoidOffset,this._internalAbstractMeshDataInfo._meshCollisionData._oldPositionForCollisions);const t=this.getScene().collisionCoordinator;return this._internalAbstractMeshDataInfo._meshCollisionData._collider||(this._internalAbstractMeshDataInfo._meshCollisionData._collider=t.createCollider()),this._internalAbstractMeshDataInfo._meshCollisionData._collider._radius=this.ellipsoid,t.getNewPosition(this._internalAbstractMeshDataInfo._meshCollisionData._oldPositionForCollisions,e,this._internalAbstractMeshDataInfo._meshCollisionData._collider,this.collisionRetryCount,this,this._onCollisionPositionChange,this.uniqueId),this}_collideForSubMesh(e,t,s){if(this._generatePointsArray(),!this._positions)return this;if(!e._lastColliderWorldVertices||!e._lastColliderTransformMatrix.equals(t)){e._lastColliderTransformMatrix=t.clone(),e._lastColliderWorldVertices=[],e._trianglePlanes=[];const s=e.verticesStart,i=e.verticesStart+e.verticesCount;for(let r=s;r1&&!n._checkCollision(e)||this._collideForSubMesh(n,t,e)}return this}_shouldConvertRHS(){return!1}_checkCollision(e){if(!this.getBoundingInfo()._checkCollision(e))return this;const t=n.AA.Matrix[0],s=n.AA.Matrix[1];return n.uq.ScalingToRef(1/e._radius.x,1/e._radius.y,1/e._radius.z,t),this.worldMatrixFromCache.multiplyToRef(t,s),this._processCollisionsForSubMeshes(e,s),this}_generatePointsArray(){return!1}intersects(e,t,s,i=!1,r,a=!1){const o=new l.G,h=this.getClassName(),c="InstancedLinesMesh"===h||"LinesMesh"===h||"GreasedLineMesh"===h?this.intersectionThreshold:0,u=this.getBoundingInfo();if(!this.subMeshes)return o;if(!(a||e.intersectsSphere(u.boundingSphere,c)&&e.intersectsBox(u.boundingBox,c)))return o;if(i)return o.hit=!a,o.pickedMesh=a?null:this,o.distance=a?0:n.Pq.Distance(e.origin,u.boundingSphere.center),o.subMeshId=0,o;if(!this._generatePointsArray())return o;let d=null;const _=this._scene.getIntersectingSubMeshCandidates(this,e),f=_.length;let p=!1;for(let e=0;e1&&!a&&!r.canIntersects(e))continue;const n=r.intersects(e,this._positions,this.getIndices(),t,s);if(n&&(t||!d||n.distancee!==this&&e.actionManager===this.actionManager))&&this.actionManager.dispose(),this.actionManager=null),this._internalAbstractMeshDataInfo._skeleton=null,this._transformMatrixTexture&&(this._transformMatrixTexture.dispose(),this._transformMatrixTexture=null),s=0;s{let t=e.includedOnlyMeshes.indexOf(this);-1!==t&&e.includedOnlyMeshes.splice(t,1),t=e.excludedMeshes.indexOf(this),-1!==t&&e.excludedMeshes.splice(t,1);const s=e.getShadowGenerators();if(s){const e=s.values();for(let s=e.next();!0!==s.done;s=e.next()){const e=s.value.getShadowMap();e&&e.renderList&&(t=e.renderList.indexOf(this),-1!==t&&e.renderList.splice(t,1))}}})),"InstancedMesh"===this.getClassName()&&"InstancedLinesMesh"===this.getClassName()||this.releaseSubMeshes();const r=i.getEngine();if(null!==this._occlusionQuery&&(this.isOcclusionQueryInProgress=!1,r.deleteQuery(this._occlusionQuery),this._occlusionQuery=null),r.wipeCaches(),i.removeMesh(this),this._parentContainer){const e=this._parentContainer.meshes.indexOf(this);e>-1&&this._parentContainer.meshes.splice(e,1),this._parentContainer=null}if(t&&this.material&&("MultiMaterial"===this.material.getClassName()?this.material.dispose(!1,!0,!0):this.material.dispose(!1,!0)),!e)for(s=0;s65535){t=!0;break}e.depthSortedIndices=t?new Uint32Array(s):new Uint16Array(s)}if(e.facetDepthSortFunction=function(e,t){return t.sqDistance-e.sqDistance},!e.facetDepthSortFrom){const t=this.getScene().activeCamera;e.facetDepthSortFrom=t?t.position:n.Pq.Zero()}e.depthSortedFacets=[];for(let t=0;tg.bH?r.maximum.x-r.minimum.x:g.bH,e.bbSize.y=r.maximum.y-r.minimum.y>g.bH?r.maximum.y-r.minimum.y:g.bH,e.bbSize.z=r.maximum.z-r.minimum.z>g.bH?r.maximum.z-r.minimum.z:g.bH;let h=e.bbSize.x>e.bbSize.y?e.bbSize.x:e.bbSize.y;if(h=h>e.bbSize.z?h:e.bbSize.z,e.subDiv.max=e.partitioningSubdivisions,e.subDiv.X=Math.floor(e.subDiv.max*e.bbSize.x/h),e.subDiv.Y=Math.floor(e.subDiv.max*e.bbSize.y/h),e.subDiv.Z=Math.floor(e.subDiv.max*e.bbSize.z/h),e.subDiv.X=e.subDiv.X<1?1:e.subDiv.X,e.subDiv.Y=e.subDiv.Y<1?1:e.subDiv.Y,e.subDiv.Z=e.subDiv.Z<1?1:e.subDiv.Z,e.facetParameters.facetNormals=this.getFacetLocalNormals(),e.facetParameters.facetPositions=this.getFacetLocalPositions(),e.facetParameters.facetPartitioning=this.getFacetLocalPartitioning(),e.facetParameters.bInfo=r,e.facetParameters.bbSize=e.bbSize,e.facetParameters.subDiv=e.subDiv,e.facetParameters.ratio=this.partitioningBBoxRatio,e.facetParameters.depthSort=e.facetDepthSort,e.facetDepthSort&&e.facetDepthSortEnabled&&(this.computeWorldMatrix(!0),this._worldMatrix.invertToRef(e.invertedMatrix),n.Pq.TransformCoordinatesToRef(e.facetDepthSortFrom,e.invertedMatrix,e.facetDepthSortOrigin),e.facetParameters.distanceTo=e.facetDepthSortOrigin),e.facetParameters.depthSortedFacets=e.depthSortedFacets,i&&o.P.ComputeNormals(t,s,i,e.facetParameters),e.facetDepthSort&&e.facetDepthSortEnabled){e.depthSortedFacets.sort(e.facetDepthSortFunction);const t=e.depthSortedIndices.length/3|0;for(let i=0;ir.subDiv.max||a<0||a>r.subDiv.max||o<0||o>r.subDiv.max?null:r.facetPartitioning[n+r.subDiv.max*a+r.subDiv.max*r.subDiv.max*o]}getClosestFacetAtCoordinates(e,t,s,i,r=!1,a=!0){const o=this.getWorldMatrix(),h=n.AA.Matrix[5];o.invertToRef(h);const l=n.AA.Vector3[8];n.Pq.TransformCoordinatesFromFloatsToRef(e,t,s,h,l);const c=this.getClosestFacetAtLocalCoordinates(l.x,l.y,l.z,i,r,a);return i&&n.Pq.TransformCoordinatesFromFloatsToRef(i.x,i.y,i.z,o,i),c}getClosestFacetAtLocalCoordinates(e,t,s,i,r=!1,n=!0){let a=null,o=0,h=0,l=0,c=0,u=0,d=0,_=0,f=0;const p=this.getFacetLocalPositions(),g=this.getFacetLocalNormals(),m=this.getFacetsAtLocalCoordinates(e,t,s);if(!m)return null;let T,b,E,x=Number.MAX_VALUE,A=x;for(let R=0;R=0||r&&!n&&c<=0)&&(c=b.x*E.x+b.y*E.y+b.z*E.z,u=-(b.x*e+b.y*t+b.z*s-c)/(b.x*b.x+b.y*b.y+b.z*b.z),d=e+b.x*u,_=t+b.y*u,f=s+b.z*u,o=d-e,h=_-t,l=f-s,A=o*o+h*h+l*l,Ae.emitter===this))}}R.OCCLUSION_TYPE_NONE=0,R.OCCLUSION_TYPE_OPTIMISTIC=1,R.OCCLUSION_TYPE_STRICT=2,R.OCCLUSION_ALGORITHM_TYPE_ACCURATE=0,R.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE=1,R.CULLINGSTRATEGY_STANDARD=0,R.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY=1,R.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION=2,R.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY=3,(0,i.Cg)([b.Cx.filter(((...[e,t,s,i,r])=>!(Array.isArray(e)||Array.isArray(t)||Array.isArray(s)||Array.isArray(i)||Array.isArray(r))))],R,"_ApplySkeleton",null),(0,T.Y5)("BABYLON.AbstractMesh",R)},1359:(e,t,s)=>{s.d(t,{V:()=>g});var i=s(9923),r=s(6041),n=s(6803),a=s(5616),o=s(1846),h=s(7597),l=s(2564),c=s(998),u=s(7503),d=s(1139),_=s(6315),f=s(1313),p=s(1137);class g{get boundingBias(){return this._boundingBias}set boundingBias(e){this._boundingBias?this._boundingBias.copyFrom(e):this._boundingBias=e.clone(),this._updateBoundingInfo(!0,null)}static CreateGeometryForMesh(e){const t=new g(g.RandomId(),e.getScene());return t.applyToMesh(e),t}get meshes(){return this._meshes}constructor(e,t,s,i=!1,r=null){this.delayLoadState=0,this._totalVertices=0,this._isDisposed=!1,this._indexBufferIsUpdatable=!1,this._positionsCache=[],this._parentContainer=null,this.useBoundingInfoFromGeometry=!1,this._scene=t||_.q.LastCreatedScene,this._scene&&(this.id=e,this.uniqueId=this._scene.getUniqueId(),this._engine=this._scene.getEngine(),this._meshes=[],this._vertexBuffers={},this._indices=[],this._updatable=i,s?this.setAllVerticesData(s,i):this._totalVertices=0,this._engine.getCaps().vertexArrayObject&&(this._vertexArrayObjects={}),r&&(this.applyToMesh(r),r.computeWorldMatrix(!0)))}get extend(){return this._extend}getScene(){return this._scene}getEngine(){return this._engine}isReady(){return 1===this.delayLoadState||0===this.delayLoadState}get doNotSerialize(){for(let e=0;e{e._rebuild()}))}setAllVerticesData(e,t){e.applyToGeometry(this,t),this._notifyUpdate()}setVerticesData(e,t,s=!1,i){s&&Array.isArray(t)&&(t=new Float32Array(t));const r=new a.R(this._engine,t,e,{updatable:s,postponeInternalCreation:0===this._meshes.length,stride:i,label:"Geometry_"+this.id+"_"+e});this.setVerticesBuffer(r)}removeVerticesData(e){this._vertexBuffers[e]&&(this._vertexBuffers[e].dispose(),delete this._vertexBuffers[e]),this._vertexArrayObjects&&this._disposeVertexArrayObjects()}setVerticesBuffer(e,t=null,s=!0){const r=e.getKind();this._vertexBuffers[r]&&s&&this._vertexBuffers[r].dispose(),e._buffer&&e._buffer._increaseReferences(),this._vertexBuffers[r]=e;const n=this._meshes,o=n.length;if(r===a.R.PositionKind){this._totalVertices=t??e._maxVerticesCount,this._updateExtend(e.getFloatData(this._totalVertices)),this._resetPointsArrayCache();const s=this._extend&&this._extend.minimum||new i.Pq(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),r=this._extend&&this._extend.maximum||new i.Pq(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE);for(let e=0;eh[t]=e))}(i,s.getSize(),s.type,s.byteOffset,s.byteStride,s.normalized,this._totalVertices,t[e])}isVertexBufferUpdatable(e){const t=this._vertexBuffers[e];return!!t&&t.isUpdatable()}getVertexBuffer(e){return this.isReady()?this._vertexBuffers[e]:null}getVertexBuffers(){return this.isReady()?this._vertexBuffers:null}isVerticesDataPresent(e){return this._vertexBuffers?void 0!==this._vertexBuffers[e]:!!this._delayInfo&&-1!==this._delayInfo.indexOf(e)}getVerticesDataKinds(){const e=[];let t;if(!this._vertexBuffers&&this._delayInfo)for(t in this._delayInfo)e.push(t);else for(t in this._vertexBuffers)e.push(t);return e}updateIndices(e,t,s=!1){if(this._indexBuffer)if(this._indexBufferIsUpdatable){const i=e.length!==this._indices.length;if(s||(this._indices=e.slice()),this._engine.updateDynamicIndexBuffer(this._indexBuffer,e,t),i)for(const e of this._meshes)e._createGlobalSubMesh(!0)}else this.setIndices(e,null,!0)}setIndexBuffer(e,t,s){this._indices=[],this._indexBufferIsUpdatable=!1,this._indexBuffer=e,this._totalVertices=t,this._totalIndices=s,e.is32Bits||(e.is32Bits=this._totalIndices>65535);for(const e of this._meshes)e._createGlobalSubMesh(!0),e.synchronizeInstances();this._notifyUpdate()}setIndices(e,t=null,s=!1,i=!1){this._indexBuffer&&this._engine._releaseBuffer(this._indexBuffer),this._indices=e,this._indexBufferIsUpdatable=s,0!==this._meshes.length&&this._indices&&(this._indexBuffer=this._engine.createIndexBuffer(this._indices,s,"Geometry_"+this.id+"_IndexBuffer")),null!=t&&(this._totalVertices=t);for(const e of this._meshes)e._createGlobalSubMesh(!i),e.synchronizeInstances();this._notifyUpdate()}getTotalIndices(){return this.isReady()?void 0!==this._totalIndices?this._totalIndices:this._indices.length:0}getIndices(e,t){if(!this.isReady())return null;const s=this._indices;return t||e&&1!==this._meshes.length?s.slice():s}getIndexBuffer(){return this.isReady()?this._indexBuffer:null}_releaseVertexArrayObject(e=null){e&&this._vertexArrayObjects&&this._vertexArrayObjects[e.key]&&(this._engine.releaseVertexArrayObject(this._vertexArrayObjects[e.key]),delete this._vertexArrayObjects[e.key])}releaseForMesh(e,t){const s=this._meshes,i=s.indexOf(e);-1!==i&&(s.splice(i,1),this._vertexArrayObjects&&e._invalidateInstanceVertexArrayObject(),e._geometry=null,0===s.length&&t&&this.dispose())}applyToMesh(e){if(e._geometry===this)return;const t=e._geometry;t&&t.releaseForMesh(e),this._vertexArrayObjects&&e._invalidateInstanceVertexArrayObject();const s=this._meshes;e._geometry=this,e._internalAbstractMeshDataInfo._positions=null,this._scene.pushGeometry(this),s.push(e),this.isReady()?this._applyToMesh(e):this._boundingInfo&&e.setBoundingInfo(this._boundingInfo)}_updateExtend(e=null){if(this.useBoundingInfoFromGeometry&&this._boundingInfo)this._extend={minimum:this._boundingInfo.minimum.clone(),maximum:this._boundingInfo.maximum.clone()};else{if(!e&&!(e=this.getVerticesData(a.R.PositionKind)))return;this._extend=(0,d.b8)(e,0,this._totalVertices,this.boundingBias,3)}}_applyToMesh(e){const t=this._meshes.length;for(const s in this._vertexBuffers)1===t&&this._vertexBuffers[s].create(),s===a.R.PositionKind&&(this._extend||this._updateExtend(),e.buildBoundingInfo(this._extend.minimum,this._extend.maximum),e._createGlobalSubMesh(e.isUnIndexed),e._updateBoundingInfo());1===t&&this._indices&&this._indices.length>0&&(this._indexBuffer=this._engine.createIndexBuffer(this._indices,this._updatable,"Geometry_"+this.id+"_IndexBuffer")),e._syncGeometryWithMorphTargetManager(),e.synchronizeInstances()}_notifyUpdate(e){this.onGeometryUpdated&&this.onGeometryUpdated(this,e),this._vertexArrayObjects&&this._disposeVertexArrayObjects();for(const e of this._meshes)e._markSubMeshesAsAttributesDirty()}load(e,t){2!==this.delayLoadState&&(this.isReady()?t&&t():(this.delayLoadState=2,this._queueLoad(e,t)))}_queueLoad(e,t){this.delayLoadingFile&&(e.addPendingData(this),e._loadFile(this.delayLoadingFile,(s=>{if(!this._delayLoadingFunction)return;this._delayLoadingFunction(JSON.parse(s),this),this.delayLoadState=1,this._delayInfo=[],e.removePendingData(this);const i=this._meshes,r=i.length;for(let e=0;e0){for(let t=0;t0){for(let e=0;e0){for(let e=0;e-1&&this._parentContainer.geometries.splice(e,1),this._parentContainer=null}this._isDisposed=!0}copy(e){const t=new n.P;t.indices=[];const s=this.getIndices();if(s)for(let e=0;e0){const i=new Float32Array(e,s.positionsAttrDesc.offset,s.positionsAttrDesc.count);t.setVerticesData(a.R.PositionKind,i,!1)}if(s.normalsAttrDesc&&s.normalsAttrDesc.count>0){const i=new Float32Array(e,s.normalsAttrDesc.offset,s.normalsAttrDesc.count);t.setVerticesData(a.R.NormalKind,i,!1)}if(s.tangetsAttrDesc&&s.tangetsAttrDesc.count>0){const i=new Float32Array(e,s.tangetsAttrDesc.offset,s.tangetsAttrDesc.count);t.setVerticesData(a.R.TangentKind,i,!1)}if(s.uvsAttrDesc&&s.uvsAttrDesc.count>0){const i=new Float32Array(e,s.uvsAttrDesc.offset,s.uvsAttrDesc.count);if(f.rX)for(let e=1;e0){const i=new Float32Array(e,s.uvs2AttrDesc.offset,s.uvs2AttrDesc.count);if(f.rX)for(let e=1;e0){const i=new Float32Array(e,s.uvs3AttrDesc.offset,s.uvs3AttrDesc.count);if(f.rX)for(let e=1;e0){const i=new Float32Array(e,s.uvs4AttrDesc.offset,s.uvs4AttrDesc.count);if(f.rX)for(let e=1;e0){const i=new Float32Array(e,s.uvs5AttrDesc.offset,s.uvs5AttrDesc.count);if(f.rX)for(let e=1;e0){const i=new Float32Array(e,s.uvs6AttrDesc.offset,s.uvs6AttrDesc.count);if(f.rX)for(let e=1;e0){const i=new Float32Array(e,s.colorsAttrDesc.offset,s.colorsAttrDesc.count);t.setVerticesData(a.R.ColorKind,i,!1,s.colorsAttrDesc.stride)}if(s.matricesIndicesAttrDesc&&s.matricesIndicesAttrDesc.count>0){const i=new Int32Array(e,s.matricesIndicesAttrDesc.offset,s.matricesIndicesAttrDesc.count),r=[];for(let e=0;e>8),r.push((16711680&t)>>16),r.push(t>>24&255)}t.setVerticesData(a.R.MatricesIndicesKind,r,!1)}if(s.matricesIndicesExtraAttrDesc&&s.matricesIndicesExtraAttrDesc.count>0){const i=new Int32Array(e,s.matricesIndicesExtraAttrDesc.offset,s.matricesIndicesExtraAttrDesc.count),r=[];for(let e=0;e>8),r.push((16711680&t)>>16),r.push(t>>24&255)}t.setVerticesData(a.R.MatricesIndicesExtraKind,r,!1)}if(s.matricesWeightsAttrDesc&&s.matricesWeightsAttrDesc.count>0){const i=new Float32Array(e,s.matricesWeightsAttrDesc.offset,s.matricesWeightsAttrDesc.count);t.setVerticesData(a.R.MatricesWeightsKind,i,!1)}if(s.indicesAttrDesc&&s.indicesAttrDesc.count>0){const i=new Int32Array(e,s.indicesAttrDesc.offset,s.indicesAttrDesc.count);t.setIndices(i,null)}if(s.subMeshesAttrDesc&&s.subMeshesAttrDesc.count>0){const i=new Int32Array(e,s.subMeshesAttrDesc.offset,5*s.subMeshesAttrDesc.count);t.subMeshes=[];for(let e=0;e>8),s.push((16711680&i)>>16),s.push(i>>24&255)}t.setVerticesData(a.R.MatricesIndicesKind,s,e.matricesIndices._updatable)}if(e.matricesIndicesExtra)if(e.matricesIndicesExtra._isExpanded)delete e.matricesIndices._isExpanded,t.setVerticesData(a.R.MatricesIndicesExtraKind,e.matricesIndicesExtra,e.matricesIndicesExtra._updatable);else{const s=[];for(let t=0;t>8),s.push((16711680&i)>>16),s.push(i>>24&255)}t.setVerticesData(a.R.MatricesIndicesExtraKind,s,e.matricesIndicesExtra._updatable)}e.matricesWeights&&(g._CleanMatricesWeights(e,t),t.setVerticesData(a.R.MatricesWeightsKind,e.matricesWeights,e.matricesWeights._updatable)),e.matricesWeightsExtra&&t.setVerticesData(a.R.MatricesWeightsExtraKind,e.matricesWeightsExtra,e.matricesWeights._updatable),t.setIndices(e.indices,null)}if(e.subMeshes){t.subMeshes=[];for(let s=0;s-1))return;{const s=t.getScene().getLastSkeletonById(e.skeletonId);if(!s)return;i=s.bones.length}const r=t.getVerticesData(a.R.MatricesIndicesKind),n=t.getVerticesData(a.R.MatricesIndicesExtraKind),o=e.matricesWeights,l=e.matricesWeightsExtra,c=e.numBoneInfluencer,u=o.length;for(let e=0;ec-1)&&(a=c-1),t>s){const s=1/t;for(let t=0;t<4;t++)o[e+t]*=s;if(l)for(let t=0;t<4;t++)l[e+t]*=s}else a>=4?(l[e+a-4]=1-t,n[e+a-4]=i):(o[e+a]=1-t,r[e+a]=i)}t.setVerticesData(a.R.MatricesIndicesKind,r),e.matricesWeightsExtra&&t.setVerticesData(a.R.MatricesIndicesExtraKind,n)}static Parse(e,t,s){const r=new g(e.id,t,void 0,e.updatable);return r._loadedUniqueId=e.uniqueId,u.Y&&u.Y.AddTagsTo(r,e.tags),e.delayLoadingFile?(r.delayLoadState=4,r.delayLoadingFile=s+e.delayLoadingFile,r._boundingInfo=new l.j(i.Pq.FromArray(e.boundingBoxMinimum),i.Pq.FromArray(e.boundingBoxMaximum)),r._delayInfo=[],e.hasUVs&&r._delayInfo.push(a.R.UVKind),e.hasUVs2&&r._delayInfo.push(a.R.UV2Kind),e.hasUVs3&&r._delayInfo.push(a.R.UV3Kind),e.hasUVs4&&r._delayInfo.push(a.R.UV4Kind),e.hasUVs5&&r._delayInfo.push(a.R.UV5Kind),e.hasUVs6&&r._delayInfo.push(a.R.UV6Kind),e.hasColors&&r._delayInfo.push(a.R.ColorKind),e.hasMatricesIndices&&r._delayInfo.push(a.R.MatricesIndicesKind),e.hasMatricesWeights&&r._delayInfo.push(a.R.MatricesWeightsKind),r._delayLoadingFunction=n.P.ImportVertexData):n.P.ImportVertexData(e,r),t.pushGeometry(r,!0),r}}},5530:(e,t,s)=>{s.d(t,{e:()=>I});var i=s(9848),r=s(998),n=s(4609),a=s(7503),o=s(163),h=s(388),l=s(9923),c=s(6041),u=s(4870),d=s(5616),_=s(6803),f=s(1359),p=s(861),g=s(1846),m=s(8986),T=s(6552);class b extends m.i{get subMaterials(){return this._subMaterials}set subMaterials(e){this._subMaterials=e,this._hookArray(e)}getChildren(){return this.subMaterials}constructor(e,t){super(e,t,!0),this._waitingSubMaterialsUniqueIds=[],this.getScene().addMultiMaterial(this),this.subMaterials=[],this._storeEffectOnSubMeshes=!0}_hookArray(e){const t=e.push;e.push=(...s)=>{const i=t.apply(e,s);return this._markAllSubMeshesAsTexturesDirty(),i};const s=e.splice;e.splice=(t,i)=>{const r=s.apply(e,[t,i]);return this._markAllSubMeshesAsTexturesDirty(),r}}getSubMaterial(e){return e<0||e>=this.subMaterials.length?this.getScene().defaultMaterial:this.subMaterials[e]}getActiveTextures(){return super.getActiveTextures().concat(...this.subMaterials.map((e=>e?e.getActiveTextures():[])))}hasTexture(e){if(super.hasTexture(e))return!0;for(let t=0;t=0&&i.multiMaterials.splice(r,1),super.dispose(e,t)}static ParseMultiMaterial(e,t){const s=new b(e.name,t);return s.id=e.id,s._loadedUniqueId=e.uniqueId,a.Y&&a.Y.AddTagsTo(s,e.tags),e.materialsUniqueIds?s._waitingSubMaterialsUniqueIds=e.materialsUniqueIds:e.materials.forEach((e=>s.subMaterials.push(t.getLastMaterialById(e)))),s}}(0,T.Y5)("BABYLON.MultiMaterial",b);var E=s(7597),x=s(6877),A=s(1137),R=s(5503),M=s(6945);class y{constructor(e,t){this.distanceOrScreenCoverage=e,this.mesh=t}}class P{constructor(){this.visibleInstances={},this.batchCache=new v,this.batchCacheReplacementModeInFrozenMode=new v,this.instancesBufferSize=2048}}class v{constructor(){this.mustReturn=!1,this.visibleInstances=new Array,this.renderSelf=[],this.hardwareInstancedRendering=[]}}class C{constructor(){this.instancesCount=0,this.matrixBuffer=null,this.previousMatrixBuffer=null,this.matrixBufferSize=512,this.matrixData=null,this.boundingVectors=[],this.worldMatrices=null}}class S{constructor(){this._areNormalsFrozen=!1,this._source=null,this.meshMap=null,this._preActivateId=-1,this._LODLevels=new Array,this._useLODScreenCoverage=!1,this._effectiveMaterial=null,this._forcedInstanceCount=0,this._overrideRenderingFillMode=null}}class I extends p.u{static _GetDefaultSideOrientation(e){return e||I.FRONTSIDE}get useLODScreenCoverage(){return this._internalMeshDataInfo._useLODScreenCoverage}set useLODScreenCoverage(e){this._internalMeshDataInfo._useLODScreenCoverage=e,this._sortLODLevels()}get computeBonesUsingShaders(){return this._internalAbstractMeshDataInfo._computeBonesUsingShaders}set computeBonesUsingShaders(e){this._internalAbstractMeshDataInfo._computeBonesUsingShaders!==e&&(e&&this._internalMeshDataInfo._sourcePositions&&(this.setVerticesData(d.R.PositionKind,this._internalMeshDataInfo._sourcePositions,!0),this._internalMeshDataInfo._sourceNormals&&this.setVerticesData(d.R.NormalKind,this._internalMeshDataInfo._sourceNormals,!0),this._internalMeshDataInfo._sourcePositions=null,this._internalMeshDataInfo._sourceNormals=null),this._internalAbstractMeshDataInfo._computeBonesUsingShaders=e,this._markSubMeshesAsAttributesDirty())}get onBeforeRenderObservable(){return this._internalMeshDataInfo._onBeforeRenderObservable||(this._internalMeshDataInfo._onBeforeRenderObservable=new i.cP),this._internalMeshDataInfo._onBeforeRenderObservable}get onBeforeBindObservable(){return this._internalMeshDataInfo._onBeforeBindObservable||(this._internalMeshDataInfo._onBeforeBindObservable=new i.cP),this._internalMeshDataInfo._onBeforeBindObservable}get onAfterRenderObservable(){return this._internalMeshDataInfo._onAfterRenderObservable||(this._internalMeshDataInfo._onAfterRenderObservable=new i.cP),this._internalMeshDataInfo._onAfterRenderObservable}get onBetweenPassObservable(){return this._internalMeshDataInfo._onBetweenPassObservable||(this._internalMeshDataInfo._onBetweenPassObservable=new i.cP),this._internalMeshDataInfo._onBetweenPassObservable}get onBeforeDrawObservable(){return this._internalMeshDataInfo._onBeforeDrawObservable||(this._internalMeshDataInfo._onBeforeDrawObservable=new i.cP),this._internalMeshDataInfo._onBeforeDrawObservable}set onBeforeDraw(e){this._onBeforeDrawObserver&&this.onBeforeDrawObservable.remove(this._onBeforeDrawObserver),this._onBeforeDrawObserver=this.onBeforeDrawObservable.add(e)}get hasInstances(){return this.instances.length>0}get hasThinInstances(){return(this.forcedInstanceCount||this._thinInstanceDataStorage.instancesCount||0)>0}get forcedInstanceCount(){return this._internalMeshDataInfo._forcedInstanceCount}set forcedInstanceCount(e){this._internalMeshDataInfo._forcedInstanceCount=e}get sideOrientation(){return this._internalMeshDataInfo._sideOrientation}set sideOrientation(e){this._internalMeshDataInfo._sideOrientation=e,this._internalAbstractMeshDataInfo._sideOrientationHint=this._scene.useRightHandedSystem&&1===e||!this._scene.useRightHandedSystem&&0===e}get overrideMaterialSideOrientation(){return this.sideOrientation}set overrideMaterialSideOrientation(e){this.sideOrientation=e,this.material&&(this.material.sideOrientation=null)}get overrideRenderingFillMode(){return this._internalMeshDataInfo._overrideRenderingFillMode}set overrideRenderingFillMode(e){this._internalMeshDataInfo._overrideRenderingFillMode=e}get material(){return this._internalAbstractMeshDataInfo._material}set material(e){e&&(this.material&&null===this.material.sideOrientation||this._internalAbstractMeshDataInfo._sideOrientationHint)&&(e.sideOrientation=null),this._setMaterial(e)}get source(){return this._internalMeshDataInfo._source}get cloneMeshMap(){return this._internalMeshDataInfo.meshMap}get isUnIndexed(){return this._unIndexed}set isUnIndexed(e){this._unIndexed!==e&&(this._unIndexed=e,this._markSubMeshesAsAttributesDirty())}get worldMatrixInstancedBuffer(){return this._instanceDataStorage.instancesData}get previousWorldMatrixInstancedBuffer(){return this._instanceDataStorage.instancesPreviousData}get manualUpdateOfWorldMatrixInstancedBuffer(){return this._instanceDataStorage.manualUpdate}set manualUpdateOfWorldMatrixInstancedBuffer(e){this._instanceDataStorage.manualUpdate=e}get manualUpdateOfPreviousWorldMatrixInstancedBuffer(){return this._instanceDataStorage.previousManualUpdate}set manualUpdateOfPreviousWorldMatrixInstancedBuffer(e){this._instanceDataStorage.previousManualUpdate=e}get forceWorldMatrixInstancedBufferUpdate(){return this._instanceDataStorage.forceMatrixUpdates}set forceWorldMatrixInstancedBufferUpdate(e){this._instanceDataStorage.forceMatrixUpdates=e}_copySource(e,t,s=!0){const i=this.getScene();if(e._geometry&&e._geometry.applyToMesh(this),n.r.DeepCopy(e,this,["name","material","skeleton","instances","parent","uniqueId","source","metadata","morphTargetManager","hasInstances","worldMatrixInstancedBuffer","previousWorldMatrixInstancedBuffer","hasLODLevels","geometry","isBlocked","areNormalsFrozen","facetNb","isFacetDataEnabled","lightSources","useBones","isAnInstance","collider","edgesRenderer","forward","up","right","absolutePosition","absoluteScaling","absoluteRotationQuaternion","isWorldMatrixFrozen","nonUniformScaling","behaviors","worldMatrixFromCache","hasThinInstances","cloneMeshMap","hasBoundingInfo","physicsBody","physicsImpostor"],["_poseMatrix"]),this._internalMeshDataInfo._source=e,i.useClonedMeshMap&&(e._internalMeshDataInfo.meshMap||(e._internalMeshDataInfo.meshMap={}),e._internalMeshDataInfo.meshMap[this.uniqueId]=this),this._originalBuilderSideOrientation=e._originalBuilderSideOrientation,this._creationDataStorage=e._creationDataStorage,e._ranges){const t=e._ranges;for(const e in t)Object.prototype.hasOwnProperty.call(t,e)&&t[e]&&this.createAnimationRange(e,t[e].from,t[e].to)}if(e.metadata&&e.metadata.clone?this.metadata=e.metadata.clone():this.metadata=e.metadata,this._internalMetadata=e._internalMetadata,a.Y&&a.Y.HasTags(e)&&a.Y.AddTagsTo(this,a.Y.GetTags(e,!0)),this.setEnabled(e.isEnabled(!1)),this.parent=e.parent,this.setPivotMatrix(e.getPivotMatrix(),this._postMultiplyPivotMatrix),this.id=this.name+"."+e.id,this.material=e.material,!t){const t=e.getDescendants(!0);for(let e=0;e{e&&s&&(this._uniformBuffer?this.transferToEffect(t):s.bindOnlyWorldMatrix(t))},r&&this._copySource(r,n,a),null!==s&&(this.parent=s),this._instanceDataStorage.hardwareInstancedRendering=this.getEngine().getCaps().instancedArrays,this._internalMeshDataInfo._onMeshReadyObserverAdded=e=>{e.unregisterOnNextCall=!0,this.isReady(!0)?this.onMeshReadyObservable.notifyObservers(this):this._internalMeshDataInfo._checkReadinessObserver||(this._internalMeshDataInfo._checkReadinessObserver=this._scene.onBeforeRenderObservable.add((()=>{this.isReady(!0)&&(this._scene.onBeforeRenderObservable.remove(this._internalMeshDataInfo._checkReadinessObserver),this._internalMeshDataInfo._checkReadinessObserver=null,this.onMeshReadyObservable.notifyObservers(this))})))},this.onMeshReadyObservable=new i.cP(this._internalMeshDataInfo._onMeshReadyObserverAdded),r&&r.onClonedObservable.notifyObservers(this)}instantiateHierarchy(e=null,t,s){const i=0===this.getTotalVertices()||t&&t.doNotInstantiate&&(!0===t.doNotInstantiate||t.doNotInstantiate(this))?this.clone("Clone of "+(this.name||this.id),e||this.parent,!0):this.createInstance("instance of "+(this.name||this.id));i.parent=e||this.parent,i.position=this.position.clone(),i.scaling=this.scaling.clone(),this.rotationQuaternion?i.rotationQuaternion=this.rotationQuaternion.clone():i.rotation=this.rotation.clone(),s&&s(this,i);for(const e of this.getChildTransformNodes(!0))"InstancedMesh"===e.getClassName()&&"Mesh"===i.getClassName()&&e.sourceMesh===this?e.instantiateHierarchy(i,{doNotInstantiate:t&&t.doNotInstantiate||!1,newSourcedMesh:i},s):e.instantiateHierarchy(i,t,s);return i}getClassName(){return"Mesh"}get _isMesh(){return!0}toString(e){let t=super.toString(e);if(t+=", n vertices: "+this.getTotalVertices(),t+=", parent: "+(this._waitingParentId?this._waitingParentId:this.parent?this.parent.name:"NONE"),this.animations)for(let s=0;s0}getLODLevels(){return this._internalMeshDataInfo._LODLevels}_sortLODLevels(){const e=this._internalMeshDataInfo._useLODScreenCoverage?-1:1;this._internalMeshDataInfo._LODLevels.sort(((t,s)=>t.distanceOrScreenCoverages.distanceOrScreenCoverage?-e:0))}addLODLevel(e,t){if(t&&t._masterMesh)return A.V.Warn("You cannot use a mesh as LOD level twice"),this;const s=new y(e,t);return this._internalMeshDataInfo._LODLevels.push(s),t&&(t._masterMesh=this),this._sortLODLevels(),this}getLODLevelAtDistance(e){const t=this._internalMeshDataInfo;for(let s=0;sa*n)return this.onLODLevelSelection&&this.onLODLevelSelection(n,this,this),this;for(let e=0;e0||this.hasThinInstances);this.computeWorldMatrix();const n=this.material||i.defaultMaterial;if(n)if(n._storeEffectOnSubMeshes)for(const e of this.subMeshes){const t=e.getMaterial();if(t)if(t._storeEffectOnSubMeshes){if(!t.isReadyForSubMesh(this,e,r))return!1}else if(!t.isReady(this,r))return!1}else if(!n.isReady(this,r))return!1;const a=s.currentRenderPassId;for(const e of this.lightSources){const t=e.getShadowGenerators();if(!t)continue;const i=t.values();for(let e=i.next();!0!==e.done;e=i.next()){const t=e.value;if(t&&(!t.getShadowMap()?.renderList||t.getShadowMap()?.renderList&&-1!==t.getShadowMap()?.renderList?.indexOf(this))){const e=t.getShadowMap().renderPassIds??[s.currentRenderPassId];for(let i=0;i0){const s=this.getIndices();if(!s)return null;const i=s.length;let r=!1;if(e)r=!0;else for(const e of this.subMeshes){if(e.indexStart+e.indexCount>i){r=!0;break}if(e.verticesStart+e.verticesCount>t){r=!0;break}}if(!r)return this.subMeshes[0]}return this.releaseSubMeshes(),new g.K(0,0,t,0,this.getTotalIndices(),this)}subdivide(e){if(e<1)return;const t=this.getTotalIndices();let s=t/e|0,i=0;for(;s%3!=0;)s++;this.releaseSubMeshes();for(let r=0;r=t);r++)g.K.CreateFromIndices(0,i,r===e-1?t-i:s,this,void 0,!1),i+=s;this.refreshBoundingInfo(),this.synchronizeInstances()}setVerticesData(e,t,s=!1,i){if(this._geometry)this._geometry.setVerticesData(e,t,s,i);else{const i=new _.P;i.set(t,e);const r=this.getScene();new f.V(f.V.RandomId(),r,i,s,this)}return this}removeVerticesData(e){this._geometry&&this._geometry.removeVerticesData(e)}markVerticesDataAsUpdatable(e,t=!0){const s=this.getVertexBuffer(e);s&&s.isUpdatable()!==t&&this.setVerticesData(e,this.getVerticesData(e),t)}setVerticesBuffer(e,t=!0){return this._geometry||(this._geometry=f.V.CreateGeometryForMesh(this)),this._geometry.setVerticesBuffer(e,null,t),this}updateVerticesData(e,t,s,i){return this._geometry?(i?(this.makeGeometryUnique(),this.updateVerticesData(e,t,s,!1)):this._geometry.updateVerticesData(e,t,s),this):this}updateMeshPositions(e,t=!0){const s=this.getVerticesData(d.R.PositionKind);if(!s)return this;if(e(s),this.updateVerticesData(d.R.PositionKind,s,!1,!1),t){const e=this.getIndices(),t=this.getVerticesData(d.R.NormalKind);if(!t)return this;_.P.ComputeNormals(s,e,t),this.updateVerticesData(d.R.NormalKind,t,!1,!1)}return this}makeGeometryUnique(){if(!this._geometry)return this;if(1===this._geometry.meshes.length)return this;const e=this._geometry,t=this._geometry.copy(f.V.RandomId());return e.releaseForMesh(this,!0),t.applyToMesh(this),this}setIndexBuffer(e,t,s){let i=this._geometry;i||(i=new f.V(f.V.RandomId(),this.getScene(),void 0,void 0,this)),i.setIndexBuffer(e,t,s)}setIndices(e,t=null,s=!1,i=!1){if(this._geometry)this._geometry.setIndices(e,t,s,i);else{const t=new _.P;t.indices=e;const i=this.getScene();new f.V(f.V.RandomId(),i,t,s,this)}return this}updateIndices(e,t,s=!1){return this._geometry?(this._geometry.updateIndices(e,t,s),this):this}toLeftHanded(){return this._geometry?(this._geometry.toLeftHanded(),this):this}_bind(e,t,s,i=!0){if(!this._geometry)return this;const r=this.getScene().getEngine();let n;if(this._unIndexed)n=this._getRenderingFillMode(s)===m.i.WireFrameFillMode?e._getLinesIndexBuffer(this.getIndices(),r):null;else switch(this._getRenderingFillMode(s)){case m.i.PointFillMode:n=null;break;case m.i.WireFrameFillMode:n=e._getLinesIndexBuffer(this.getIndices(),r);break;default:case m.i.TriangleFillMode:n=this._geometry.getIndexBuffer()}return this._bindDirect(t,n,i)}_bindDirect(e,t,s=!0){return this._geometry?(this.morphTargetManager&&this.morphTargetManager.isUsingTextureForTargets&&this.morphTargetManager._bind(e),s&&this._userInstancedBuffersStorage&&!this.hasThinInstances?this._geometry._bind(e,t,this._userInstancedBuffersStorage.vertexBuffers,this._userInstancedBuffersStorage.vertexArrayObjects):this._geometry._bind(e,t),this):this}_draw(e,t,s){if(!this._geometry||!this._geometry.getVertexBuffers()||!this._unIndexed&&!this._geometry.getIndexBuffer())return this;this._internalMeshDataInfo._onBeforeDrawObservable&&this._internalMeshDataInfo._onBeforeDrawObservable.notifyObservers(this);const i=this.getScene().getEngine();return this._unIndexed&&t!==m.i.WireFrameFillMode||t==m.i.PointFillMode?i.drawArraysType(t,e.verticesStart,e.verticesCount,this.forcedInstanceCount||s):t==m.i.WireFrameFillMode?i.drawElementsType(t,0,e._linesIndexCount,this.forcedInstanceCount||s):i.drawElementsType(t,e.indexStart,e.indexCount,this.forcedInstanceCount||s),this}registerBeforeRender(e){return this.onBeforeRenderObservable.add(e),this}unregisterBeforeRender(e){return this.onBeforeRenderObservable.removeCallback(e),this}registerAfterRender(e){return this.onAfterRenderObservable.add(e),this}unregisterAfterRender(e){return this.onAfterRenderObservable.removeCallback(e),this}_getInstancesRenderList(e,t=!1){if(this._instanceDataStorage.isFrozen){if(t)return this._instanceDataStorage.batchCacheReplacementModeInFrozenMode.hardwareInstancedRendering[e]=!1,this._instanceDataStorage.batchCacheReplacementModeInFrozenMode.renderSelf[e]=!0,this._instanceDataStorage.batchCacheReplacementModeInFrozenMode;if(this._instanceDataStorage.previousBatch)return this._instanceDataStorage.previousBatch}const s=this.getScene(),i=s._isInIntermediateRendering(),r=i?this._internalAbstractMeshDataInfo._onlyForInstancesIntermediate:this._internalAbstractMeshDataInfo._onlyForInstances,n=this._instanceDataStorage.batchCache;if(n.mustReturn=!1,n.renderSelf[e]=t||!r&&this.isEnabled()&&this.isVisible,n.visibleInstances[e]=null,this._instanceDataStorage.visibleInstances&&!t){const t=this._instanceDataStorage.visibleInstances,r=s.getRenderId(),a=i?t.intermediateDefaultRenderId:t.defaultRenderId;n.visibleInstances[e]=t[r],!n.visibleInstances[e]&&a&&(n.visibleInstances[e]=t[a])}return n.hardwareInstancedRendering[e]=!t&&this._instanceDataStorage.hardwareInstancedRendering&&null!==n.visibleInstances[e]&&void 0!==n.visibleInstances[e],this._instanceDataStorage.previousBatch=n,n}_renderWithInstances(e,t,s,i,r){const n=s.visibleInstances[e._id],a=n?n.length:0,o=this._instanceDataStorage,h=o.instancesBufferSize;let c=o.instancesBuffer,u=o.instancesPreviousBuffer;const _=16*(a+1)*4;for(;o.instancesBufferSize<_;)o.instancesBufferSize*=2;o.instancesData&&h==o.instancesBufferSize||(o.instancesData=new Float32Array(o.instancesBufferSize/4)),(this._scene.needsPreviousWorldMatrices&&!o.instancesPreviousData||h!=o.instancesBufferSize)&&(o.instancesPreviousData=new Float32Array(o.instancesBufferSize/4));let f=0,p=0;const g=s.renderSelf[e._id],m=!c||h!==o.instancesBufferSize||this._scene.needsPreviousWorldMatrices&&!o.instancesPreviousBuffer;if(this._instanceDataStorage.manualUpdate||o.isFrozen&&!m)p=(g?1:0)+a;else{const t=this.getWorldMatrix();if(g&&(this._scene.needsPreviousWorldMatrices&&(o.masterMeshPreviousWorldMatrix?(o.masterMeshPreviousWorldMatrix.copyToArray(o.instancesPreviousData,f),o.masterMeshPreviousWorldMatrix.copyFrom(t)):(o.masterMeshPreviousWorldMatrix=t.clone(),o.masterMeshPreviousWorldMatrix.copyToArray(o.instancesPreviousData,f))),t.copyToArray(o.instancesData,f),f+=16,p++),n){if(I.INSTANCEDMESH_SORT_TRANSPARENT&&this._scene.activeCamera&&e.getMaterial()?.needAlphaBlendingForMesh(e.getRenderingMesh())){const e=this._scene.activeCamera.globalPosition;for(let t=0;te._distanceToCamera>t._distanceToCamera?-1:e._distanceToCamera1&&i.activeCamera===i.activeCameras[0]||r<=1)&&this._checkOcclusionQuery()&&!this._occlusionDataStorage.forceRenderingWhenOccluded)return this;const n=this._getInstancesRenderList(e._id,!!s);if(n.mustReturn)return this;if(!this._geometry||!this._geometry.getVertexBuffers()||!this._unIndexed&&!this._geometry.getIndexBuffer())return this;const a=i.getEngine();let o=0,h=null;this.ignoreCameraMaxZ&&i.activeCamera&&!i._isInIntermediateRendering()&&(o=i.activeCamera.maxZ,h=i.activeCamera,i.activeCamera.maxZ=0,i.updateTransformMatrix(!0)),this._internalMeshDataInfo._onBeforeRenderObservable&&this._internalMeshDataInfo._onBeforeRenderObservable.notifyObservers(this);const l=e.getRenderingMesh(),c=n.hardwareInstancedRendering[e._id]||l.hasThinInstances||!!this._userInstancedBuffersStorage&&!e.getMesh()._internalAbstractMeshDataInfo._actAsRegularMesh,u=this._instanceDataStorage,d=e.getMaterial();if(!d)return h&&(h.maxZ=o,i.updateTransformMatrix(!0)),this;if(u.isFrozen&&this._internalMeshDataInfo._effectiveMaterial&&this._internalMeshDataInfo._effectiveMaterial===d){if(d._storeEffectOnSubMeshes&&!e._drawWrapper?._wasPreviouslyReady||!d._storeEffectOnSubMeshes&&!d._getDrawWrapper()._wasPreviouslyReady)return h&&(h.maxZ=o,i.updateTransformMatrix(!0)),this}else{if(d._storeEffectOnSubMeshes){if(!d.isReadyForSubMesh(this,e,c))return h&&(h.maxZ=o,i.updateTransformMatrix(!0)),this}else if(!d.isReady(this,c))return h&&(h.maxZ=o,i.updateTransformMatrix(!0)),this;this._internalMeshDataInfo._effectiveMaterial=d}let _;t&&a.setAlphaMode(this._internalMeshDataInfo._effectiveMaterial.alphaMode),_=this._internalMeshDataInfo._effectiveMaterial._storeEffectOnSubMeshes?e._drawWrapper:this._internalMeshDataInfo._effectiveMaterial._getDrawWrapper();const f=_?.effect??null;for(const t of i._beforeRenderingMeshStage)t.action(this,e,n,f);if(!_||!f)return h&&(h.maxZ=o,i.updateTransformMatrix(!0)),this;const p=s||this;let g;if(u.isFrozen||!this._internalMeshDataInfo._effectiveMaterial.backFaceCulling&&null===this._internalMeshDataInfo._effectiveMaterial.sideOrientation&&!this._internalMeshDataInfo._effectiveMaterial.twoSidedLighting)g=u.sideOrientation;else{const e=p._getWorldMatrixDeterminant();g=this._internalMeshDataInfo._effectiveMaterial._getEffectiveOrientation(this),e<0&&(g=g===m.i.ClockWiseSideOrientation?m.i.CounterClockWiseSideOrientation:m.i.ClockWiseSideOrientation),u.sideOrientation=g}const T=this._internalMeshDataInfo._effectiveMaterial._preBind(_,g);this._internalMeshDataInfo._effectiveMaterial.forceDepthWrite&&a.setDepthWrite(!0);const b=this._internalMeshDataInfo._effectiveMaterial,E=b.fillMode;this._internalMeshDataInfo._onBeforeBindObservable&&this._internalMeshDataInfo._onBeforeBindObservable.notifyObservers(this),c||this._bind(e,f,E,!1);const x=p.getWorldMatrix();b._storeEffectOnSubMeshes?b.bindForSubMesh(x,this,e):b.bind(x,this),!b.backFaceCulling&&b.separateCullingPass&&(a.setState(!0,b.zOffset,!1,!T,b.cullBackFaces,b.stencil,b.zOffsetUnits),this._processRendering(this,e,f,E,n,c,this._onBeforeDraw,this._internalMeshDataInfo._effectiveMaterial),a.setState(!0,b.zOffset,!1,T,b.cullBackFaces,b.stencil,b.zOffsetUnits),this._internalMeshDataInfo._onBetweenPassObservable&&this._internalMeshDataInfo._onBetweenPassObservable.notifyObservers(e)),this._processRendering(this,e,f,E,n,c,this._onBeforeDraw,this._internalMeshDataInfo._effectiveMaterial),this._internalMeshDataInfo._effectiveMaterial.unbind();for(const t of i._afterRenderingMeshStage)t.action(this,e,n,f);return this._internalMeshDataInfo._onAfterRenderObservable&&this._internalMeshDataInfo._onAfterRenderObservable.notifyObservers(this),h&&(h.maxZ=o,i.updateTransformMatrix(!0)),2!==i.performancePriority||u.isFrozen||this._freeze(),this}cleanMatrixWeights(){this.isVerticesDataPresent(d.R.MatricesWeightsKind)&&(this.isVerticesDataPresent(d.R.MatricesWeightsExtraKind)?this._normalizeSkinWeightsAndExtra():this._normalizeSkinFourWeights())}_normalizeSkinFourWeights(){const e=this.getVerticesData(d.R.MatricesWeightsKind),t=e.length;for(let s=0;ss&&i++,0!==n&&u++,c+=n,s=n}if(h[u]++,u>n&&(n=u),0===c)r++;else{const s=1/c;let i=0;for(let r=0;r.001&&a++}}const l=this.skeleton.bones.length,c=this.getVerticesData(d.R.MatricesIndicesKind),u=this.getVerticesData(d.R.MatricesIndicesExtraKind);let _=0;for(let e=0;e=l||s<0)&&_++}return{skinned:!0,valid:0===r&&0===a&&0===_,report:"Number of Weights = "+s/4+"\nMaximum influences = "+n+"\nMissing Weights = "+r+"\nNot Sorted = "+i+"\nNot Normalized = "+a+"\nWeightCounts = ["+h+"]\nNumber of bones = "+l+"\nBad Bone Indices = "+_}}_checkDelayState(){const e=this.getScene();return this._geometry?this._geometry.load(e):4===this.delayLoadState&&(this.delayLoadState=2,this._queueLoad(e)),this}_queueLoad(e){e.addPendingData(this);const t=-1!==this.delayLoadingFile.indexOf(".babylonbinarymeshdata");return r.S0.LoadFile(this.delayLoadingFile,(t=>{t instanceof ArrayBuffer?this._delayLoadingFunction(t,this):this._delayLoadingFunction(JSON.parse(t),this),this.instances.forEach((e=>{e.refreshBoundingInfo(),e._syncSubMeshes()})),this.delayLoadState=1,e.removePendingData(this)}),(()=>{}),e.offlineProvider,t),this}isInFrustum(e){return 2!==this.delayLoadState&&!!super.isInFrustum(e)&&(this._checkDelayState(),!0)}setMaterialById(e){const t=this.getScene().materials;let s;for(s=t.length-1;s>-1;s--)if(t[s].id===e)return this.material=t[s],this;const i=this.getScene().multiMaterials;for(s=i.length-1;s>-1;s--)if(i[s].id===e)return this.material=i[s],this;return this}getAnimatables(){const e=[];return this.material&&e.push(this.material),this.skeleton&&e.push(this.skeleton),e}bakeTransformIntoVertices(e){if(!this.isVerticesDataPresent(d.R.PositionKind))return this;const t=this.subMeshes.splice(0);this._resetPointsArrayCache();let s=this.getVerticesData(d.R.PositionKind);const i=l.Pq.Zero();let r;for(r=0;r{const r=e.width,h=e.height,l=this.getEngine().createCanvas(r,h).getContext("2d");l.drawImage(e,0,0);const c=l.getImageData(0,0,r,h).data;this.applyDisplacementMapFromBuffer(c,r,h,t,s,n,a,o),i&&i(this)}),h||(()=>{}),l.offlineProvider),this}applyDisplacementMapFromBuffer(e,t,s,i,r,n,a,o=!1){if(!this.isVerticesDataPresent(d.R.PositionKind)||!this.isVerticesDataPresent(d.R.NormalKind)||!this.isVerticesDataPresent(d.R.UVKind))return A.V.Warn("Cannot call applyDisplacementMap: Given mesh is not complete. Position, Normal or UV are missing"),this;const h=this.getVerticesData(d.R.PositionKind,!0,!0),c=this.getVerticesData(d.R.NormalKind),u=this.getVerticesData(d.R.UVKind);let f=l.Pq.Zero();const p=l.Pq.Zero(),g=l.I9.Zero();n=n||l.I9.Zero(),a=a||new l.I9(1,1);for(let o=0;o!this.getVertexBuffer(e)?.getIsInstanced())),s=this.getIndices(),i={},r=(e,t)=>{const i=new Float32Array(s.length*t);let r=0;for(let n=0;n{const t=i.length-1-e,s=i[t];for(let e=0;e{for(let e=0;e-1&&(i._waitingMorphTargetManagerId=e.morphTargetManagerId),void 0!==e.skeletonId&&null!==e.skeletonId&&(i.skeleton=t.getLastSkeletonById(e.skeletonId),e.numBoneInfluencers&&(i.numBoneInfluencers=e.numBoneInfluencers)),e.animations){for(let t=0;t4,h=o?this.getVerticesData(d.R.MatricesIndicesExtraKind):null,c=o?this.getVerticesData(d.R.MatricesWeightsExtraKind):null,u=e.getTransformMatrices(this),_=l.Pq.Zero(),f=new l.uq,p=new l.uq;let g,m=0;for(let e=0;e0&&(l.uq.FromFloat32ArrayToRefScaled(u,Math.floor(16*n[m+g]),d,p),f.addToSelf(p));if(o)for(g=0;g<4;g++)d=c[m+g],d>0&&(l.uq.FromFloat32ArrayToRefScaled(u,Math.floor(16*h[m+g]),d,p),f.addToSelf(p));l.Pq.TransformCoordinatesFromFloatsToRef(s._sourcePositions[e],s._sourcePositions[e+1],s._sourcePositions[e+2],f,_),_.toArray(i,e),t&&(l.Pq.TransformNormalFromFloatsToRef(s._sourceNormals[e],s._sourceNormals[e+1],s._sourceNormals[e+2],f,_),_.toArray(r,e)),f.reset()}return this.updateVerticesData(d.R.PositionKind,i),t&&this.updateVerticesData(d.R.NormalKind,r),this}static MinMax(e){let t=null,s=null;return e.forEach((function(e){const i=e.getBoundingInfo().boundingBox;t&&s?(t.minimizeInPlace(i.minimumWorld),s.maximizeInPlace(i.maximumWorld)):(t=i.minimumWorld,s=i.maximumWorld)})),t&&s?{min:t,max:s}:{min:l.Pq.Zero(),max:l.Pq.Zero()}}static Center(e){const t=e instanceof Array?I.MinMax(e):e;return l.Pq.Center(t.min,t.max)}static MergeMeshes(e,t=!0,s,i,r,n){return(0,o.V1)(I._MergeMeshesCoroutine(e,t,s,i,r,n,!1))}static MergeMeshesAsync(e,t=!0,s,i,r,n){return(0,o.kj)(I._MergeMeshesCoroutine(e,t,s,i,r,n,!0),(0,o.VP)())}static*_MergeMeshesCoroutine(e,t=!0,s,i,r,n,a){if(0===(e=e.filter(Boolean)).length)return null;let o;if(!s){let t=0;for(o=0;o=65536)return A.V.Warn("Cannot merge meshes because resulting mesh will have more than 65536 vertices. Please use allow32BitsIndices = true to use 32 bits indices"),null}n&&(r=!1);const h=new Array,l=new Array,c=new Array,u=e[0].sideOrientation;for(o=0;o{const t=e.computeWorldMatrix(!0);return{vertexData:_.P.ExtractFromMesh(e,!1,!1),transform:t}},{vertexData:p,transform:m}=f(d);a&&(yield);const T=new Array(e.length-1);for(let t=1;t{throw(0,R.n)("GroundMesh")},I._GoldbergMeshParser=(e,t)=>{throw(0,R.n)("GoldbergMesh")},I._LinesMeshParser=(e,t)=>{throw(0,R.n)("LinesMesh")},I._GreasedLineMeshParser=(e,t)=>{throw(0,R.n)("GreasedLineMesh")},I._GreasedLineRibbonMeshParser=(e,t)=>{throw(0,R.n)("GreasedLineRibbonMesh")},I._TrailMeshParser=(e,t)=>{throw(0,R.n)("TrailMesh")},(0,T.Y5)("BABYLON.Mesh",I)},6803:(e,t,s)=>{s.d(t,{P:()=>f});var i=s(5524),r=s(9923),n=s(5616),a=s(5503),o=s(6041),h=s(1137),l=s(9259),c=s(163),u=s(8563),d=s(1846);class _{}class f{constructor(){this.uniqueId=0,this.metadata={},this._applyTo=(0,c.Aj)(this._applyToCoroutine.bind(this)),this.uniqueId=f._UniqueIDGenerator,f._UniqueIDGenerator++}set(e,t){switch(e.length||h.V.Warn(`Setting vertex data kind '${t}' with an empty array`),t){case n.R.PositionKind:this.positions=e;break;case n.R.NormalKind:this.normals=e;break;case n.R.TangentKind:this.tangents=e;break;case n.R.UVKind:this.uvs=e;break;case n.R.UV2Kind:this.uvs2=e;break;case n.R.UV3Kind:this.uvs3=e;break;case n.R.UV4Kind:this.uvs4=e;break;case n.R.UV5Kind:this.uvs5=e;break;case n.R.UV6Kind:this.uvs6=e;break;case n.R.ColorKind:this.colors=e;break;case n.R.MatricesIndicesKind:this.matricesIndices=e;break;case n.R.MatricesWeightsKind:this.matricesWeights=e;break;case n.R.MatricesIndicesExtraKind:this.matricesIndicesExtra=e;break;case n.R.MatricesWeightsExtraKind:this.matricesWeightsExtra=e}}applyToMesh(e,t){return this._applyTo(e,t,!1),this}applyToGeometry(e,t){return this._applyTo(e,t,!1),this}updateMesh(e){return this._update(e),this}updateGeometry(e){return this._update(e),this}*_applyToCoroutine(e,t=!1,s){if(this.positions&&(e.setVerticesData(n.R.PositionKind,this.positions,t),s&&(yield)),this.normals&&(e.setVerticesData(n.R.NormalKind,this.normals,t),s&&(yield)),this.tangents&&(e.setVerticesData(n.R.TangentKind,this.tangents,t),s&&(yield)),this.uvs&&(e.setVerticesData(n.R.UVKind,this.uvs,t),s&&(yield)),this.uvs2&&(e.setVerticesData(n.R.UV2Kind,this.uvs2,t),s&&(yield)),this.uvs3&&(e.setVerticesData(n.R.UV3Kind,this.uvs3,t),s&&(yield)),this.uvs4&&(e.setVerticesData(n.R.UV4Kind,this.uvs4,t),s&&(yield)),this.uvs5&&(e.setVerticesData(n.R.UV5Kind,this.uvs5,t),s&&(yield)),this.uvs6&&(e.setVerticesData(n.R.UV6Kind,this.uvs6,t),s&&(yield)),this.colors&&(e.setVerticesData(n.R.ColorKind,this.colors,t),this.hasVertexAlpha&&void 0!==e.hasVertexAlpha&&(e.hasVertexAlpha=!0),s&&(yield)),this.matricesIndices&&(e.setVerticesData(n.R.MatricesIndicesKind,this.matricesIndices,t),s&&(yield)),this.matricesWeights&&(e.setVerticesData(n.R.MatricesWeightsKind,this.matricesWeights,t),s&&(yield)),this.matricesIndicesExtra&&(e.setVerticesData(n.R.MatricesIndicesExtraKind,this.matricesIndicesExtra,t),s&&(yield)),this.matricesWeightsExtra&&(e.setVerticesData(n.R.MatricesWeightsExtraKind,this.matricesWeightsExtra,t),s&&(yield)),this.indices?(e.setIndices(this.indices,null,t),s&&(yield)):e.setIndices([],null),e.subMeshes&&this.materialInfos&&this.materialInfos.length>1){const t=e;t.subMeshes=[];for(const e of this.materialInfos)new d.K(e.materialIndex,e.verticesStart,e.verticesCount,e.indexStart,e.indexCount,t)}return this}_update(e,t,s){return this.positions&&e.updateVerticesData(n.R.PositionKind,this.positions,t,s),this.normals&&e.updateVerticesData(n.R.NormalKind,this.normals,t,s),this.tangents&&e.updateVerticesData(n.R.TangentKind,this.tangents,t,s),this.uvs&&e.updateVerticesData(n.R.UVKind,this.uvs,t,s),this.uvs2&&e.updateVerticesData(n.R.UV2Kind,this.uvs2,t,s),this.uvs3&&e.updateVerticesData(n.R.UV3Kind,this.uvs3,t,s),this.uvs4&&e.updateVerticesData(n.R.UV4Kind,this.uvs4,t,s),this.uvs5&&e.updateVerticesData(n.R.UV5Kind,this.uvs5,t,s),this.uvs6&&e.updateVerticesData(n.R.UV6Kind,this.uvs6,t,s),this.colors&&e.updateVerticesData(n.R.ColorKind,this.colors,t,s),this.matricesIndices&&e.updateVerticesData(n.R.MatricesIndicesKind,this.matricesIndices,t,s),this.matricesWeights&&e.updateVerticesData(n.R.MatricesWeightsKind,this.matricesWeights,t,s),this.matricesIndicesExtra&&e.updateVerticesData(n.R.MatricesIndicesExtraKind,this.matricesIndicesExtra,t,s),this.matricesWeightsExtra&&e.updateVerticesData(n.R.MatricesWeightsExtraKind,this.matricesWeightsExtra,t,s),this.indices&&e.setIndices(this.indices,null),this}static _TransformVector3Coordinates(e,t,s=0,i=e.length){const n=r.AA.Vector3[0],a=r.AA.Vector3[1];for(let o=s;o({vertexData:e}))):[{vertexData:e}];return(0,c.V1)(this._mergeCoroutine(void 0,n,t,!1,s,i,r))}*_mergeCoroutine(e,t,s=!1,i,r,a=!1,o=!1){this._validate();let h=t.map((e=>e.vertexData)),l=this;if(o)for(const e of h)e&&(e._validate(),!this.normals&&e.normals&&(this.normals=new Float32Array(this.positions.length)),!this.tangents&&e.tangents&&(this.tangents=new Float32Array(this.positions.length/3*4)),!this.uvs&&e.uvs&&(this.uvs=new Float32Array(this.positions.length/3*2)),!this.uvs2&&e.uvs2&&(this.uvs2=new Float32Array(this.positions.length/3*2)),!this.uvs3&&e.uvs3&&(this.uvs3=new Float32Array(this.positions.length/3*2)),!this.uvs4&&e.uvs4&&(this.uvs4=new Float32Array(this.positions.length/3*2)),!this.uvs5&&e.uvs5&&(this.uvs5=new Float32Array(this.positions.length/3*2)),!this.uvs6&&e.uvs6&&(this.uvs6=new Float32Array(this.positions.length/3*2)),!this.colors&&e.colors&&(this.colors=new Float32Array(this.positions.length/3*4),this.colors.fill(1)),!this.matricesIndices&&e.matricesIndices&&(this.matricesIndices=new Float32Array(this.positions.length/3*4)),!this.matricesWeights&&e.matricesWeights&&(this.matricesWeights=new Float32Array(this.positions.length/3*4)),!this.matricesIndicesExtra&&e.matricesIndicesExtra&&(this.matricesIndicesExtra=new Float32Array(this.positions.length/3*4)),!this.matricesWeightsExtra&&e.matricesWeightsExtra&&(this.matricesWeightsExtra=new Float32Array(this.positions.length/3*4)));for(const e of h)if(e)if(o)this.normals&&!e.normals&&(e.normals=new Float32Array(e.positions.length)),this.tangents&&!e.tangents&&(e.tangents=new Float32Array(e.positions.length/3*4)),this.uvs&&!e.uvs&&(e.uvs=new Float32Array(e.positions.length/3*2)),this.uvs2&&!e.uvs2&&(e.uvs2=new Float32Array(e.positions.length/3*2)),this.uvs3&&!e.uvs3&&(e.uvs3=new Float32Array(e.positions.length/3*2)),this.uvs4&&!e.uvs4&&(e.uvs4=new Float32Array(e.positions.length/3*2)),this.uvs5&&!e.uvs5&&(e.uvs5=new Float32Array(e.positions.length/3*2)),this.uvs6&&!e.uvs6&&(e.uvs6=new Float32Array(e.positions.length/3*2)),this.colors&&!e.colors&&(e.colors=new Float32Array(e.positions.length/3*4),e.colors.fill(1)),this.matricesIndices&&!e.matricesIndices&&(e.matricesIndices=new Float32Array(e.positions.length/3*4)),this.matricesWeights&&!e.matricesWeights&&(e.matricesWeights=new Float32Array(e.positions.length/3*4)),this.matricesIndicesExtra&&!e.matricesIndicesExtra&&(e.matricesIndicesExtra=new Float32Array(e.positions.length/3*4)),this.matricesWeightsExtra&&!e.matricesWeightsExtra&&(e.matricesWeightsExtra=new Float32Array(e.positions.length/3*4));else if(e._validate(),!this.normals!=!e.normals||!this.tangents!=!e.tangents||!this.uvs!=!e.uvs||!this.uvs2!=!e.uvs2||!this.uvs3!=!e.uvs3||!this.uvs4!=!e.uvs4||!this.uvs5!=!e.uvs5||!this.uvs6!=!e.uvs6||!this.colors!=!e.colors||!this.matricesIndices!=!e.matricesIndices||!this.matricesWeights!=!e.matricesWeights||!this.matricesIndicesExtra!=!e.matricesIndicesExtra||!this.matricesWeightsExtra!=!e.matricesWeightsExtra)throw new Error("Cannot merge vertex data that do not have the same set of attributes");if(a){let s=0,i=0,r=0;const n=[];let a=null;const o=[];for(const t of this.splitBasedOnMaterialID())o.push({vertexData:t,transform:e});for(const e of t)if(e.vertexData)for(const t of e.vertexData.splitBasedOnMaterialID())o.push({vertexData:t,transform:e.transform});o.sort(((e,t)=>{const s=e.vertexData.materialInfos?e.vertexData.materialInfos[0].materialIndex:0,i=t.vertexData.materialInfos?t.vertexData.materialInfos[0].materialIndex:0;return s>i?1:s===i?0:-1}));for(const e of o){const t=e.vertexData;if(s=t.materialInfos?t.materialInfos[0].materialIndex:0,a&&a.materialIndex===s)a.indexCount+=t.indices.length,a.verticesCount+=t.positions.length/3;else{const e=new _;e.materialIndex=s,e.indexStart=i,e.indexCount=t.indices.length,e.verticesStart=r,e.verticesCount=t.positions.length/3,n.push(e),a=e}i+=t.indices.length,r+=t.positions.length/3}const c=o.splice(0,1)[0];l=c.vertexData,e=c.transform,h=o.map((e=>e.vertexData)),t=o,this.materialInfos=n}const c=h.reduce(((e,t)=>e+(t.indices?.length??0)),l.indices?.length??0);let u=r||h.some((e=>e.indices===l.indices))?l.indices?.slice():l.indices;if(c>0){let r=u?.length??0;if(u||(u=new Array(c)),u.length!==c){if(Array.isArray(u))u.length=c;else{const e=s||u instanceof Uint32Array?new Uint32Array(c):new Uint16Array(c);e.set(u),u=e}e&&e.determinant()<0&&f._FlipFaces(u,0,r)}let n=l.positions?l.positions.length/3:0;for(const{vertexData:e,transform:s}of t)if(e.indices){for(let t=0;t[e.vertexData.positions,e.transform]))),i&&(yield),l.normals&&(this.normals=f._MergeElement(n.R.NormalKind,l.normals,e,t.map((e=>[e.vertexData.normals,e.transform]))),i&&(yield)),l.tangents&&(this.tangents=f._MergeElement(n.R.TangentKind,l.tangents,e,t.map((e=>[e.vertexData.tangents,e.transform]))),i&&(yield)),l.uvs&&(this.uvs=f._MergeElement(n.R.UVKind,l.uvs,e,t.map((e=>[e.vertexData.uvs,e.transform]))),i&&(yield)),l.uvs2&&(this.uvs2=f._MergeElement(n.R.UV2Kind,l.uvs2,e,t.map((e=>[e.vertexData.uvs2,e.transform]))),i&&(yield)),l.uvs3&&(this.uvs3=f._MergeElement(n.R.UV3Kind,l.uvs3,e,t.map((e=>[e.vertexData.uvs3,e.transform]))),i&&(yield)),l.uvs4&&(this.uvs4=f._MergeElement(n.R.UV4Kind,l.uvs4,e,t.map((e=>[e.vertexData.uvs4,e.transform]))),i&&(yield)),l.uvs5&&(this.uvs5=f._MergeElement(n.R.UV5Kind,l.uvs5,e,t.map((e=>[e.vertexData.uvs5,e.transform]))),i&&(yield)),l.uvs6&&(this.uvs6=f._MergeElement(n.R.UV6Kind,l.uvs6,e,t.map((e=>[e.vertexData.uvs6,e.transform]))),i&&(yield)),l.colors&&(this.colors=f._MergeElement(n.R.ColorKind,l.colors,e,t.map((e=>[e.vertexData.colors,e.transform]))),(void 0!==l.hasVertexAlpha||t.some((e=>void 0!==e.vertexData.hasVertexAlpha)))&&(this.hasVertexAlpha=l.hasVertexAlpha||t.some((e=>e.vertexData.hasVertexAlpha))),i&&(yield)),l.matricesIndices&&(this.matricesIndices=f._MergeElement(n.R.MatricesIndicesKind,l.matricesIndices,e,t.map((e=>[e.vertexData.matricesIndices,e.transform]))),i&&(yield)),l.matricesWeights&&(this.matricesWeights=f._MergeElement(n.R.MatricesWeightsKind,l.matricesWeights,e,t.map((e=>[e.vertexData.matricesWeights,e.transform]))),i&&(yield)),l.matricesIndicesExtra&&(this.matricesIndicesExtra=f._MergeElement(n.R.MatricesIndicesExtraKind,l.matricesIndicesExtra,e,t.map((e=>[e.vertexData.matricesIndicesExtra,e.transform]))),i&&(yield)),l.matricesWeightsExtra&&(this.matricesWeightsExtra=f._MergeElement(n.R.MatricesWeightsExtraKind,l.matricesWeightsExtra,e,t.map((e=>[e.vertexData.matricesWeightsExtra,e.transform])))),this}static _MergeElement(e,t,s,i){const r=i.filter((e=>null!==e[0]&&void 0!==e[0]));if(!t&&0==r.length)return t;if(!t)return this._MergeElement(e,r[0][0],r[0][1],r.slice(1));const a=r.reduce(((e,t)=>e+t[0].length),t.length),o=e===n.R.PositionKind?f._TransformVector3Coordinates:e===n.R.NormalKind?f._TransformVector3Normals:e===n.R.TangentKind?f._TransformVector4Normals:()=>{};if(t instanceof Float32Array){const e=new Float32Array(a);e.set(t),s&&o(e,s,0,t.length);let i=t.length;for(const[t,s]of r)e.set(t,i),s&&o(e,s,i,t.length),i+=t.length;return e}{const e=new Array(a);for(let s=0;s{const s=n.R.DeduceStride(e);if(t.length%s!=0)throw new Error("The "+e+"s array count must be a multiple of "+s);return t.length/s},t=e(n.R.PositionKind,this.positions),s=(s,i)=>{const r=e(s,i);if(r!==t)throw new Error("The "+s+"s element count ("+r+") does not match the positions count ("+t+")")};this.normals&&s(n.R.NormalKind,this.normals),this.tangents&&s(n.R.TangentKind,this.tangents),this.uvs&&s(n.R.UVKind,this.uvs),this.uvs2&&s(n.R.UV2Kind,this.uvs2),this.uvs3&&s(n.R.UV3Kind,this.uvs3),this.uvs4&&s(n.R.UV4Kind,this.uvs4),this.uvs5&&s(n.R.UV5Kind,this.uvs5),this.uvs6&&s(n.R.UV6Kind,this.uvs6),this.colors&&s(n.R.ColorKind,this.colors),this.matricesIndices&&s(n.R.MatricesIndicesKind,this.matricesIndices),this.matricesWeights&&s(n.R.MatricesWeightsKind,this.matricesWeights),this.matricesIndicesExtra&&s(n.R.MatricesIndicesExtraKind,this.matricesIndicesExtra),this.matricesWeightsExtra&&s(n.R.MatricesWeightsExtraKind,this.matricesWeightsExtra)}clone(){const e=this.serialize();return f.Parse(e)}serialize(){const e={};if(this.positions&&(e.positions=Array.from(this.positions)),this.normals&&(e.normals=Array.from(this.normals)),this.tangents&&(e.tangents=Array.from(this.tangents)),this.uvs&&(e.uvs=Array.from(this.uvs)),this.uvs2&&(e.uvs2=Array.from(this.uvs2)),this.uvs3&&(e.uvs3=Array.from(this.uvs3)),this.uvs4&&(e.uvs4=Array.from(this.uvs4)),this.uvs5&&(e.uvs5=Array.from(this.uvs5)),this.uvs6&&(e.uvs6=Array.from(this.uvs6)),this.colors&&(e.colors=Array.from(this.colors),e.hasVertexAlpha=this.hasVertexAlpha),this.matricesIndices&&(e.matricesIndices=Array.from(this.matricesIndices),e.matricesIndices._isExpanded=!0),this.matricesWeights&&(e.matricesWeights=Array.from(this.matricesWeights)),this.matricesIndicesExtra&&(e.matricesIndicesExtra=Array.from(this.matricesIndicesExtra),e.matricesIndicesExtra._isExpanded=!0),this.matricesWeightsExtra&&(e.matricesWeightsExtra=Array.from(this.matricesWeightsExtra)),e.indices=Array.from(this.indices),this.materialInfos){e.materialInfos=[];for(const t of this.materialInfos){const s={indexStart:t.indexStart,indexCount:t.indexCount,materialIndex:t.materialIndex,verticesStart:t.verticesStart,verticesCount:t.verticesCount};e.materialInfos.push(s)}}return e}static ExtractFromMesh(e,t,s){return f._ExtractFrom(e,t,s)}static ExtractFromGeometry(e,t,s){return f._ExtractFrom(e,t,s)}static _ExtractFrom(e,t,s){const i=new f;if(e.isVerticesDataPresent(n.R.PositionKind)&&(i.positions=e.getVerticesData(n.R.PositionKind,t,s)),e.isVerticesDataPresent(n.R.NormalKind)&&(i.normals=e.getVerticesData(n.R.NormalKind,t,s)),e.isVerticesDataPresent(n.R.TangentKind)&&(i.tangents=e.getVerticesData(n.R.TangentKind,t,s)),e.isVerticesDataPresent(n.R.UVKind)&&(i.uvs=e.getVerticesData(n.R.UVKind,t,s)),e.isVerticesDataPresent(n.R.UV2Kind)&&(i.uvs2=e.getVerticesData(n.R.UV2Kind,t,s)),e.isVerticesDataPresent(n.R.UV3Kind)&&(i.uvs3=e.getVerticesData(n.R.UV3Kind,t,s)),e.isVerticesDataPresent(n.R.UV4Kind)&&(i.uvs4=e.getVerticesData(n.R.UV4Kind,t,s)),e.isVerticesDataPresent(n.R.UV5Kind)&&(i.uvs5=e.getVerticesData(n.R.UV5Kind,t,s)),e.isVerticesDataPresent(n.R.UV6Kind)&&(i.uvs6=e.getVerticesData(n.R.UV6Kind,t,s)),e.isVerticesDataPresent(n.R.ColorKind)){const r=e.geometry||e,a=r.getVertexBuffer(n.R.ColorKind),o=r.getVerticesData(n.R.ColorKind,t,s);if(3===a.getSize()){const e=new Float32Array(4*o.length/3);for(let t=0,s=0;t!Array.isArray(e)))],f,"_TransformVector3Coordinates",null),(0,i.Cg)([l.Cx.filter(((...[e])=>!Array.isArray(e)))],f,"_TransformVector3Normals",null),(0,i.Cg)([l.Cx.filter(((...[e])=>!Array.isArray(e)))],f,"_TransformVector4Normals",null),(0,i.Cg)([l.Cx.filter(((...[e])=>!Array.isArray(e)))],f,"_FlipFaces",null)},1846:(e,t,s)=>{s.d(t,{K:()=>h});var i=s(5616);class r{constructor(e,t,s){this.bu=e,this.bv=t,this.distance=s,this.faceId=0,this.subMeshId=0}}var n=s(2564),a=s(1139),o=s(5476);class h{get materialDefines(){return this._mainDrawWrapperOverride?this._mainDrawWrapperOverride.defines:this._getDrawWrapper()?.defines}set materialDefines(e){(this._mainDrawWrapperOverride??this._getDrawWrapper(void 0,!0)).defines=e}_getDrawWrapper(e,t=!1){e=e??this._engine.currentRenderPassId;let s=this._drawWrappers[e];return!s&&t&&(this._drawWrappers[e]=s=new o.E(this._mesh.getScene().getEngine())),s}_removeDrawWrapper(e,t=!0){t&&this._drawWrappers[e]?.dispose(),this._drawWrappers[e]=void 0}get effect(){return this._mainDrawWrapperOverride?this._mainDrawWrapperOverride.effect:this._getDrawWrapper()?.effect??null}get _drawWrapper(){return this._mainDrawWrapperOverride??this._getDrawWrapper(void 0,!0)}get _drawWrapperOverride(){return this._mainDrawWrapperOverride}_setMainDrawWrapperOverride(e){this._mainDrawWrapperOverride=e}setEffect(e,t=null,s,i=!0){const r=this._drawWrapper;r.setEffect(e,t,i),void 0!==s&&(r.materialContext=s),e||(r.defines=null,r.materialContext=void 0)}resetDrawCache(e){if(this._drawWrappers){if(void 0!==e)return void this._removeDrawWrapper(e);for(const e of this._drawWrappers)e?.dispose()}this._drawWrappers=[]}static AddToMesh(e,t,s,i,r,n,a,o=!0){return new h(e,t,s,i,r,n,a,o)}constructor(e,t,s,i,r,n,a,o=!0,h=!0){this.materialIndex=e,this.verticesStart=t,this.verticesCount=s,this.indexStart=i,this.indexCount=r,this._mainDrawWrapperOverride=null,this._linesIndexCount=0,this._linesIndexBuffer=null,this._lastColliderWorldVertices=null,this._lastColliderTransformMatrix=null,this._wasDispatched=!1,this._renderId=0,this._alphaIndex=0,this._distanceToCamera=0,this._currentMaterial=null,this._mesh=n,this._renderingMesh=a||n,h&&n.subMeshes.push(this),this._engine=this._mesh.getScene().getEngine(),this.resetDrawCache(),this._trianglePlanes=[],this._id=n.subMeshes.length-1,o&&(this.refreshBoundingInfo(),n.computeWorldMatrix(!0))}get IsGlobal(){return 0===this.verticesStart&&this.verticesCount===this._mesh.getTotalVertices()&&0===this.indexStart&&this.indexCount===this._mesh.getTotalIndices()}getBoundingInfo(){return this.IsGlobal||this._mesh.hasThinInstances?this._mesh.getBoundingInfo():this._boundingInfo}setBoundingInfo(e){return this._boundingInfo=e,this}getMesh(){return this._mesh}getRenderingMesh(){return this._renderingMesh}getReplacementMesh(){return this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh?this._mesh:null}getEffectiveMesh(){return(this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh?this._mesh:null)||this._renderingMesh}getMaterial(e=!0){const t=this._renderingMesh.getMaterialForRenderPass(this._engine.currentRenderPassId)??this._renderingMesh.material;if(!t)return e?this._mesh.getScene().defaultMaterial:null;if(this._isMultiMaterial(t)){const e=t.getSubMaterial(this.materialIndex);return this._currentMaterial!==e&&(this._currentMaterial=e,this.resetDrawCache()),e}return t}_isMultiMaterial(e){return void 0!==e.getSubMaterial}refreshBoundingInfo(e=null){if(this._lastColliderWorldVertices=null,this.IsGlobal||!this._renderingMesh||!this._renderingMesh.geometry)return this;if(e||(e=this._renderingMesh.getVerticesData(i.R.PositionKind)),!e)return this._boundingInfo=this._mesh.getBoundingInfo(),this;const t=this._renderingMesh.getIndices();let s;if(0===this.indexStart&&this.indexCount===t.length){const e=this._renderingMesh.getBoundingInfo();s={minimum:e.minimum.clone(),maximum:e.maximum.clone()}}else s=(0,a.cD)(e,t,this.indexStart,this.indexCount,this._renderingMesh.geometry.boundingBias);return this._boundingInfo?this._boundingInfo.reConstruct(s.minimum,s.maximum):this._boundingInfo=new n.j(s.minimum,s.maximum),this}_checkCollision(e){return this.getBoundingInfo()._checkCollision(e)}updateBoundingInfo(e){let t=this.getBoundingInfo();return t||(this.refreshBoundingInfo(),t=this.getBoundingInfo()),t&&t.update(e),this}isInFrustum(e){const t=this.getBoundingInfo();return!!t&&t.isInFrustum(e,this._mesh.cullingStrategy)}isCompletelyInFrustum(e){const t=this.getBoundingInfo();return!!t&&t.isCompletelyInFrustum(e)}render(e){return this._renderingMesh.render(this,e,this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh?this._mesh:void 0),this}_getLinesIndexBuffer(e,t){if(!this._linesIndexBuffer){const s=[];for(let t=this.indexStart;to&&(o=t)}return new h(e,a,o-a+1,t,s,i,r,n)}}},7328:(e,t,s)=>{s.d(t,{V:()=>u});var i=s(5524),r=s(9259),n=s(6877),a=s(9848),o=s(9923),h=s(4870),l=s(6552);const c=o.uq.Compose(o.Pq.One(),o.PT.FromEulerAngles(0,Math.PI,0),o.Pq.Zero());class u extends h.b{get billboardMode(){return this._billboardMode}set billboardMode(e){this._billboardMode!==e&&(this._billboardMode=e,this._cache.useBillboardPosition=0!=(this._billboardMode&u.BILLBOARDMODE_USE_POSITION),this._computeUseBillboardPath())}get preserveParentRotationForBillboard(){return this._preserveParentRotationForBillboard}set preserveParentRotationForBillboard(e){e!==this._preserveParentRotationForBillboard&&(this._preserveParentRotationForBillboard=e,this._computeUseBillboardPath())}_computeUseBillboardPath(){this._cache.useBillboardPath=this._billboardMode!==u.BILLBOARDMODE_NONE&&!this.preserveParentRotationForBillboard}get infiniteDistance(){return this._infiniteDistance}set infiniteDistance(e){this._infiniteDistance!==e&&(this._infiniteDistance=e)}constructor(e,t=null,s=!0){super(e,t,!1),this._forward=new o.Pq(0,0,1),this._up=new o.Pq(0,1,0),this._right=new o.Pq(1,0,0),this._position=o.Pq.Zero(),this._rotation=o.Pq.Zero(),this._rotationQuaternion=null,this._scaling=o.Pq.One(),this._transformToBoneReferal=null,this._isAbsoluteSynced=!1,this._billboardMode=u.BILLBOARDMODE_NONE,this._preserveParentRotationForBillboard=!1,this.scalingDeterminant=1,this._infiniteDistance=!1,this.ignoreNonUniformScaling=!1,this.reIntegrateRotationIntoRotationQuaternion=!1,this._poseMatrix=null,this._localMatrix=o.uq.Zero(),this._usePivotMatrix=!1,this._absolutePosition=o.Pq.Zero(),this._absoluteScaling=o.Pq.Zero(),this._absoluteRotationQuaternion=o.PT.Identity(),this._pivotMatrix=o.uq.Identity(),this._postMultiplyPivotMatrix=!1,this._isWorldMatrixFrozen=!1,this._indexInSceneTransformNodesArray=-1,this.onAfterWorldMatrixUpdateObservable=new a.cP,this._nonUniformScaling=!1,s&&this.getScene().addTransformNode(this)}getClassName(){return"TransformNode"}get position(){return this._position}set position(e){this._position=e,this._markAsDirtyInternal()}isUsingPivotMatrix(){return this._usePivotMatrix}isUsingPostMultiplyPivotMatrix(){return this._postMultiplyPivotMatrix}get rotation(){return this._rotation}set rotation(e){this._rotation=e,this._rotationQuaternion=null,this._markAsDirtyInternal()}get scaling(){return this._scaling}set scaling(e){this._scaling=e,this._markAsDirtyInternal()}get rotationQuaternion(){return this._rotationQuaternion}set rotationQuaternion(e){this._rotationQuaternion=e,e&&this._rotation.setAll(0),this._markAsDirtyInternal()}_markAsDirtyInternal(){this._isDirty||(this._isDirty=!0,this.customMarkAsDirty&&this.customMarkAsDirty())}get forward(){return o.Pq.TransformNormalFromFloatsToRef(0,0,this.getScene().useRightHandedSystem?-1:1,this.getWorldMatrix(),this._forward),this._forward.normalize()}get up(){return o.Pq.TransformNormalFromFloatsToRef(0,1,0,this.getWorldMatrix(),this._up),this._up.normalize()}get right(){return o.Pq.TransformNormalFromFloatsToRef(this.getScene().useRightHandedSystem?-1:1,0,0,this.getWorldMatrix(),this._right),this._right.normalize()}updatePoseMatrix(e){return this._poseMatrix?(this._poseMatrix.copyFrom(e),this):(this._poseMatrix=e.clone(),this)}getPoseMatrix(){return this._poseMatrix||(this._poseMatrix=o.uq.Identity()),this._poseMatrix}_isSynchronized(){const e=this._cache;return!(this._billboardMode!==e.billboardMode||this._billboardMode!==u.BILLBOARDMODE_NONE||e.pivotMatrixUpdated||this._infiniteDistance||this._position._isDirty||this._scaling._isDirty||this._rotationQuaternion&&this._rotationQuaternion._isDirty||this._rotation._isDirty)}_initCache(){super._initCache();const e=this._cache;e.localMatrixUpdated=!1,e.billboardMode=-1,e.infiniteDistance=!1,e.useBillboardPosition=!1,e.useBillboardPath=!1}get absolutePosition(){return this.getAbsolutePosition()}get absoluteScaling(){return this._syncAbsoluteScalingAndRotation(),this._absoluteScaling}get absoluteRotationQuaternion(){return this._syncAbsoluteScalingAndRotation(),this._absoluteRotationQuaternion}setPreTransformMatrix(e){return this.setPivotMatrix(e,!1)}setPivotMatrix(e,t=!0){return this._pivotMatrix.copyFrom(e),this._usePivotMatrix=!this._pivotMatrix.isIdentity(),this._cache.pivotMatrixUpdated=!0,this._postMultiplyPivotMatrix=t,this._postMultiplyPivotMatrix&&(this._pivotMatrixInverse?this._pivotMatrix.invertToRef(this._pivotMatrixInverse):this._pivotMatrixInverse=o.uq.Invert(this._pivotMatrix)),this}getPivotMatrix(){return this._pivotMatrix}instantiateHierarchy(e=null,t,s){const i=this.clone("Clone of "+(this.name||this.id),e||this.parent,!0);i&&s&&s(this,i);for(const e of this.getChildTransformNodes(!0))e.instantiateHierarchy(i,t,s);return i}freezeWorldMatrix(e=null,t=!1){return e?t?(this._rotation.setAll(0),this._rotationQuaternion=this._rotationQuaternion||o.PT.Identity(),e.decompose(this._scaling,this._rotationQuaternion,this._position),this.computeWorldMatrix(!0)):(this._worldMatrix=e,this._absolutePosition.copyFromFloats(this._worldMatrix.m[12],this._worldMatrix.m[13],this._worldMatrix.m[14]),this._afterComputeWorldMatrix()):(this._isWorldMatrixFrozen=!1,this.computeWorldMatrix(!0)),this._isDirty=!1,this._isWorldMatrixFrozen=!0,this}unfreezeWorldMatrix(){return this._isWorldMatrixFrozen=!1,this.computeWorldMatrix(!0),this}get isWorldMatrixFrozen(){return this._isWorldMatrixFrozen}getAbsolutePosition(){return this.computeWorldMatrix(),this._absolutePosition}setAbsolutePosition(e){if(!e)return this;let t,s,i;if(void 0===e.x){if(arguments.length<3)return this;t=arguments[0],s=arguments[1],i=arguments[2]}else t=e.x,s=e.y,i=e.z;if(this.parent){const e=o.AA.Matrix[0];this.parent.getWorldMatrix().invertToRef(e),o.Pq.TransformCoordinatesFromFloatsToRef(t,s,i,e,this.position)}else this.position.x=t,this.position.y=s,this.position.z=i;return this._absolutePosition.copyFrom(e),this}setPositionWithLocalVector(e){return this.computeWorldMatrix(),this.position=o.Pq.TransformNormal(e,this._localMatrix),this}getPositionExpressedInLocalSpace(){this.computeWorldMatrix();const e=o.AA.Matrix[0];return this._localMatrix.invertToRef(e),o.Pq.TransformNormal(this.position,e)}locallyTranslate(e){return this.computeWorldMatrix(!0),this.position=o.Pq.TransformCoordinates(e,this._localMatrix),this}lookAt(e,t=0,s=0,i=0,r=0){const n=u._LookAtVectorCache,a=0===r?this.position:this.getAbsolutePosition();if(e.subtractToRef(a,n),this.setDirection(n,t,s,i),1===r&&this.parent)if(this.rotationQuaternion){const e=o.AA.Matrix[0];this.rotationQuaternion.toRotationMatrix(e);const t=o.AA.Matrix[1];this.parent.getWorldMatrix().getRotationMatrixToRef(t),t.invert(),e.multiplyToRef(t,e),this.rotationQuaternion.fromRotationMatrix(e)}else{const e=o.AA.Quaternion[0];o.PT.FromEulerVectorToRef(this.rotation,e);const t=o.AA.Matrix[0];e.toRotationMatrix(t);const s=o.AA.Matrix[1];this.parent.getWorldMatrix().getRotationMatrixToRef(s),s.invert(),t.multiplyToRef(s,t),e.fromRotationMatrix(t),e.toEulerAnglesToRef(this.rotation)}return this}getDirection(e){const t=o.Pq.Zero();return this.getDirectionToRef(e,t),t}getDirectionToRef(e,t){return o.Pq.TransformNormalToRef(e,this.getWorldMatrix(),t),this}setDirection(e,t=0,s=0,i=0){const r=-Math.atan2(e.z,e.x)+Math.PI/2,n=Math.sqrt(e.x*e.x+e.z*e.z),a=-Math.atan2(e.y,n);return this.rotationQuaternion?o.PT.RotationYawPitchRollToRef(r+t,a+s,i,this.rotationQuaternion):(this.rotation.x=a+s,this.rotation.y=r+t,this.rotation.z=i),this}setPivotPoint(e,t=0){0==this.getScene().getRenderId()&&this.computeWorldMatrix(!0);const s=this.getWorldMatrix();if(1==t){const t=o.AA.Matrix[0];s.invertToRef(t),e=o.Pq.TransformCoordinates(e,t)}return this.setPivotMatrix(o.uq.Translation(-e.x,-e.y,-e.z),!0)}getPivotPoint(){const e=o.Pq.Zero();return this.getPivotPointToRef(e),e}getPivotPointToRef(e){return e.x=-this._pivotMatrix.m[12],e.y=-this._pivotMatrix.m[13],e.z=-this._pivotMatrix.m[14],this}getAbsolutePivotPoint(){const e=o.Pq.Zero();return this.getAbsolutePivotPointToRef(e),e}getAbsolutePivotPointToRef(e){return this.getPivotPointToRef(e),o.Pq.TransformCoordinatesToRef(e,this.getWorldMatrix(),e),this}markAsDirty(e){if(this._isDirty)return this;if(this._children)for(const t of this._children)t.markAsDirty(e);return super.markAsDirty(e)}setParent(e,t=!1,s=!1){if(!e&&!this.parent)return this;const i=o.AA.Quaternion[0],r=o.AA.Vector3[0],n=o.AA.Vector3[1],a=o.AA.Matrix[1];o.uq.IdentityToRef(a);const h=o.AA.Matrix[0];this.computeWorldMatrix(!0);let l=this.rotationQuaternion;return l||(l=u._TmpRotation,o.PT.RotationYawPitchRollToRef(this._rotation.y,this._rotation.x,this._rotation.z,l)),o.uq.ComposeToRef(this.scaling,l,this.position,h),this.parent&&h.multiplyToRef(this.parent.computeWorldMatrix(!0),h),e&&(e.computeWorldMatrix(!0).invertToRef(a),h.multiplyToRef(a,h)),h.decompose(n,i,r,t?this:void 0),this.rotationQuaternion?this.rotationQuaternion.copyFrom(i):i.toEulerAnglesToRef(this.rotation),this.scaling.copyFrom(n),this.position.copyFrom(r),this.parent=e,s&&this.setPivotMatrix(o.uq.Identity()),this}addChild(e,t=!1){return e.setParent(this,t),this}removeChild(e,t=!1){return e.setParent(null,t),this}get nonUniformScaling(){return this._nonUniformScaling}_updateNonUniformScalingState(e){return this._nonUniformScaling!==e&&(this._nonUniformScaling=e,!0)}attachToBone(e,t){return this._currentParentWhenAttachingToBone=this.parent,this._transformToBoneReferal=t,this.parent=e,e.getSkeleton().prepare(!0),e.getFinalMatrix().determinant()<0&&(this.scalingDeterminant*=-1),this}detachFromBone(e=!1){return this.parent?(this.parent.getWorldMatrix().determinant()<0&&(this.scalingDeterminant*=-1),this._transformToBoneReferal=null,this.parent=e?this._currentParentWhenAttachingToBone:null,this):(e&&(this.parent=this._currentParentWhenAttachingToBone),this)}rotate(e,t,s){let i;if(e.normalize(),this.rotationQuaternion||(this.rotationQuaternion=this.rotation.toQuaternion(),this.rotation.setAll(0)),s&&0!==s){if(this.parent){const s=this.parent.getWorldMatrix(),i=o.AA.Matrix[0];s.invertToRef(i),e=o.Pq.TransformNormal(e,i),s.determinant()<0&&(t*=-1)}i=o.PT.RotationAxisToRef(e,t,u._RotationAxisCache),i.multiplyToRef(this.rotationQuaternion,this.rotationQuaternion)}else i=o.PT.RotationAxisToRef(e,t,u._RotationAxisCache),this.rotationQuaternion.multiplyToRef(i,this.rotationQuaternion);return this}rotateAround(e,t,s){t.normalize(),this.rotationQuaternion||(this.rotationQuaternion=o.PT.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z),this.rotation.setAll(0));const i=o.AA.Vector3[0],r=o.AA.Vector3[1],n=o.AA.Vector3[2],a=o.AA.Quaternion[0],h=o.AA.Matrix[0],l=o.AA.Matrix[1],c=o.AA.Matrix[2],u=o.AA.Matrix[3];return e.subtractToRef(this.position,i),o.uq.TranslationToRef(i.x,i.y,i.z,h),o.uq.TranslationToRef(-i.x,-i.y,-i.z,l),o.uq.RotationAxisToRef(t,s,c),l.multiplyToRef(c,u),u.multiplyToRef(h,u),u.decompose(r,a,n),this.position.addInPlace(n),a.multiplyToRef(this.rotationQuaternion,this.rotationQuaternion),this}translate(e,t,s){const i=e.scale(t);if(s&&0!==s)this.setAbsolutePosition(this.getAbsolutePosition().add(i));else{const e=this.getPositionExpressedInLocalSpace().add(i);this.setPositionWithLocalVector(e)}return this}addRotation(e,t,s){let i;this.rotationQuaternion?i=this.rotationQuaternion:(i=o.AA.Quaternion[1],o.PT.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,i));const r=o.AA.Quaternion[0];return o.PT.RotationYawPitchRollToRef(t,e,s,r),i.multiplyInPlace(r),this.rotationQuaternion||i.toEulerAnglesToRef(this.rotation),this}_getEffectiveParent(){return this.parent}isWorldMatrixCameraDependent(){return this._infiniteDistance&&!this.parent||this._billboardMode!==u.BILLBOARDMODE_NONE&&!this.preserveParentRotationForBillboard}computeWorldMatrix(e=!1,t=null){if(this._isWorldMatrixFrozen&&!this._isDirty)return this._worldMatrix;const s=this.getScene().getRenderId();if(!this._isDirty&&!e&&(this._currentRenderId===s||this.isSynchronized()))return this._currentRenderId=s,this._worldMatrix;t=t||this.getScene().activeCamera,this._updateCache();const i=this._cache;i.pivotMatrixUpdated=!1,i.billboardMode=this.billboardMode,i.infiniteDistance=this.infiniteDistance,i.parent=this._parentNode,this._currentRenderId=s,this._childUpdateId+=1,this._isDirty=!1,this._position._isDirty=!1,this._rotation._isDirty=!1,this._scaling._isDirty=!1;const r=this._getEffectiveParent(),n=u._TmpScaling;let a,h=this._position;if(this._infiniteDistance&&!this.parent&&t){const e=t.getWorldMatrix(),s=new o.Pq(e.m[12],e.m[13],e.m[14]);h=u._TmpTranslation,h.copyFromFloats(this._position.x+s.x,this._position.y+s.y,this._position.z+s.z)}if(n.copyFromFloats(this._scaling.x*this.scalingDeterminant,this._scaling.y*this.scalingDeterminant,this._scaling.z*this.scalingDeterminant),this._rotationQuaternion?(this._rotationQuaternion._isDirty=!1,a=this._rotationQuaternion,this.reIntegrateRotationIntoRotationQuaternion&&this.rotation.lengthSquared()&&(this._rotationQuaternion.multiplyInPlace(o.PT.RotationYawPitchRoll(this._rotation.y,this._rotation.x,this._rotation.z)),this._rotation.copyFromFloats(0,0,0))):(a=u._TmpRotation,o.PT.RotationYawPitchRollToRef(this._rotation.y,this._rotation.x,this._rotation.z,a)),this._usePivotMatrix){const e=o.AA.Matrix[1];o.uq.ScalingToRef(n.x,n.y,n.z,e);const t=o.AA.Matrix[0];a.toRotationMatrix(t),this._pivotMatrix.multiplyToRef(e,o.AA.Matrix[4]),o.AA.Matrix[4].multiplyToRef(t,this._localMatrix),this._postMultiplyPivotMatrix&&this._localMatrix.multiplyToRef(this._pivotMatrixInverse,this._localMatrix),this._localMatrix.addTranslationFromFloats(h.x,h.y,h.z)}else o.uq.ComposeToRef(n,a,h,this._localMatrix);if(r&&r.getWorldMatrix){if(e&&r.computeWorldMatrix(e),i.useBillboardPath){if(this._transformToBoneReferal){const e=this.parent;e.getSkeleton().prepare(),e.getFinalMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(),o.AA.Matrix[7])}else o.AA.Matrix[7].copyFrom(r.getWorldMatrix());const e=o.AA.Vector3[5],t=o.AA.Vector3[6],s=o.AA.Quaternion[0];o.AA.Matrix[7].decompose(t,s,e),o.uq.ScalingToRef(t.x,t.y,t.z,o.AA.Matrix[7]),o.AA.Matrix[7].setTranslation(e),u.BillboardUseParentOrientation&&(this._position.applyRotationQuaternionToRef(s,e),this._localMatrix.setTranslation(e)),this._localMatrix.multiplyToRef(o.AA.Matrix[7],this._worldMatrix)}else if(this._transformToBoneReferal){const e=this.parent;e.getSkeleton().prepare(),this._localMatrix.multiplyToRef(e.getFinalMatrix(),o.AA.Matrix[6]),o.AA.Matrix[6].multiplyToRef(this._transformToBoneReferal.getWorldMatrix(),this._worldMatrix)}else this._localMatrix.multiplyToRef(r.getWorldMatrix(),this._worldMatrix);this._markSyncedWithParent()}else this._worldMatrix.copyFrom(this._localMatrix);if(i.useBillboardPath&&t&&this.billboardMode&&!i.useBillboardPosition){const e=o.AA.Vector3[0];if(this._worldMatrix.getTranslationToRef(e),o.AA.Matrix[1].copyFrom(t.getViewMatrix()),this._scene.useRightHandedSystem&&o.AA.Matrix[1].multiplyToRef(c,o.AA.Matrix[1]),o.AA.Matrix[1].setTranslationFromFloats(0,0,0),o.AA.Matrix[1].invertToRef(o.AA.Matrix[0]),(this.billboardMode&u.BILLBOARDMODE_ALL)!==u.BILLBOARDMODE_ALL){o.AA.Matrix[0].decompose(void 0,o.AA.Quaternion[0],void 0);const e=o.AA.Vector3[1];o.AA.Quaternion[0].toEulerAnglesToRef(e),(this.billboardMode&u.BILLBOARDMODE_X)!==u.BILLBOARDMODE_X&&(e.x=0),(this.billboardMode&u.BILLBOARDMODE_Y)!==u.BILLBOARDMODE_Y&&(e.y=0),(this.billboardMode&u.BILLBOARDMODE_Z)!==u.BILLBOARDMODE_Z&&(e.z=0),o.uq.RotationYawPitchRollToRef(e.y,e.x,e.z,o.AA.Matrix[0])}this._worldMatrix.setTranslationFromFloats(0,0,0),this._worldMatrix.multiplyToRef(o.AA.Matrix[0],this._worldMatrix),this._worldMatrix.setTranslation(o.AA.Vector3[0])}else if(i.useBillboardPath&&t&&i.useBillboardPosition){const e=o.AA.Vector3[0];this._worldMatrix.getTranslationToRef(e);const s=t.globalPosition;this._worldMatrix.invertToRef(o.AA.Matrix[1]);const i=o.AA.Vector3[1];o.Pq.TransformCoordinatesToRef(s,o.AA.Matrix[1],i),i.normalize();const r=-Math.atan2(i.z,i.x)+Math.PI/2,n=Math.sqrt(i.x*i.x+i.z*i.z),a=-Math.atan2(i.y,n);if(o.PT.RotationYawPitchRollToRef(r,a,0,o.AA.Quaternion[0]),(this.billboardMode&u.BILLBOARDMODE_ALL)!==u.BILLBOARDMODE_ALL){const e=o.AA.Vector3[1];o.AA.Quaternion[0].toEulerAnglesToRef(e),(this.billboardMode&u.BILLBOARDMODE_X)!==u.BILLBOARDMODE_X&&(e.x=0),(this.billboardMode&u.BILLBOARDMODE_Y)!==u.BILLBOARDMODE_Y&&(e.y=0),(this.billboardMode&u.BILLBOARDMODE_Z)!==u.BILLBOARDMODE_Z&&(e.z=0),o.uq.RotationYawPitchRollToRef(e.y,e.x,e.z,o.AA.Matrix[0])}else o.uq.FromQuaternionToRef(o.AA.Quaternion[0],o.AA.Matrix[0]);this._worldMatrix.setTranslationFromFloats(0,0,0),this._worldMatrix.multiplyToRef(o.AA.Matrix[0],this._worldMatrix),this._worldMatrix.setTranslation(o.AA.Vector3[0])}return this.ignoreNonUniformScaling?this._updateNonUniformScalingState(!1):this._scaling.isNonUniformWithinEpsilon(1e-6)?this._updateNonUniformScalingState(!0):r&&r._nonUniformScaling?this._updateNonUniformScalingState(r._nonUniformScaling):this._updateNonUniformScalingState(!1),this._afterComputeWorldMatrix(),this._absolutePosition.copyFromFloats(this._worldMatrix.m[12],this._worldMatrix.m[13],this._worldMatrix.m[14]),this._isAbsoluteSynced=!1,this.onAfterWorldMatrixUpdateObservable.notifyObservers(this),this._poseMatrix||(this._poseMatrix=o.uq.Invert(this._worldMatrix)),this._worldMatrixDeterminantIsDirty=!0,this._worldMatrix}resetLocalMatrix(e=!0){if(this.computeWorldMatrix(),e){const e=this.getChildren();for(let t=0;tnew u(e,this.getScene())),this);if(i.name=e,i.id=e,t&&(i.parent=t),!s){const t=this.getDescendants(!0);for(let s=0;snew u(e.name,t)),e,t,s);if(e.localMatrix?i.setPreTransformMatrix(o.uq.FromArray(e.localMatrix)):e.pivotMatrix&&i.setPivotMatrix(o.uq.FromArray(e.pivotMatrix)),i.setEnabled(e.isEnabled),i._waitingParsedUniqueId=e.uniqueId,void 0!==e.parentId&&(i._waitingParentId=e.parentId),void 0!==e.parentInstanceIndex&&(i._waitingParentInstanceIndex=e.parentInstanceIndex),e.animations){for(let t=0;t(!t||t(e))&&e instanceof u)),s}dispose(e,t=!1){if(this.getScene().stopAnimation(this),this.getScene().removeTransformNode(this),this._parentContainer){const e=this._parentContainer.transformNodes.indexOf(this);e>-1&&this._parentContainer.transformNodes.splice(e,1),this._parentContainer=null}if(this.onAfterWorldMatrixUpdateObservable.clear(),e){const e=this.getChildTransformNodes(!0);for(const t of e)t.parent=null,t.computeWorldMatrix(!0)}super.dispose(e,t)}normalizeToUnitCube(e=!0,t=!1,s){let i=null,r=null;t&&(this.rotationQuaternion?(r=this.rotationQuaternion.clone(),this.rotationQuaternion.copyFromFloats(0,0,0,1)):this.rotation&&(i=this.rotation.clone(),this.rotation.copyFromFloats(0,0,0)));const n=this.getHierarchyBoundingVectors(e,s),a=n.max.subtract(n.min),o=Math.max(a.x,a.y,a.z);if(0===o)return this;const h=1/o;return this.scaling.scaleInPlace(h),t&&(this.rotationQuaternion&&r?this.rotationQuaternion.copyFrom(r):this.rotation&&i&&this.rotation.copyFrom(i)),this}_syncAbsoluteScalingAndRotation(){this._isAbsoluteSynced||(this._worldMatrix.decompose(this._absoluteScaling,this._absoluteRotationQuaternion),this._isAbsoluteSynced=!0)}}u.BILLBOARDMODE_NONE=0,u.BILLBOARDMODE_X=1,u.BILLBOARDMODE_Y=2,u.BILLBOARDMODE_Z=4,u.BILLBOARDMODE_ALL=7,u.BILLBOARDMODE_USE_POSITION=128,u.BillboardUseParentOrientation=!1,u._TmpRotation=o.PT.Zero(),u._TmpScaling=o.Pq.Zero(),u._TmpTranslation=o.Pq.Zero(),u._LookAtVectorCache=new o.Pq(0,0,0),u._RotationAxisCache=new o.PT,(0,i.Cg)([(0,r.P_)("position")],u.prototype,"_position",void 0),(0,i.Cg)([(0,r.P_)("rotation")],u.prototype,"_rotation",void 0),(0,i.Cg)([(0,r.bR)("rotationQuaternion")],u.prototype,"_rotationQuaternion",void 0),(0,i.Cg)([(0,r.P_)("scaling")],u.prototype,"_scaling",void 0),(0,i.Cg)([(0,r.lK)("billboardMode")],u.prototype,"_billboardMode",void 0),(0,i.Cg)([(0,r.lK)()],u.prototype,"scalingDeterminant",void 0),(0,i.Cg)([(0,r.lK)("infiniteDistance")],u.prototype,"_infiniteDistance",void 0),(0,i.Cg)([(0,r.lK)()],u.prototype,"ignoreNonUniformScaling",void 0),(0,i.Cg)([(0,r.lK)()],u.prototype,"reIntegrateRotationIntoRotationQuaternion",void 0)},6755:(e,t,s)=>{s.d(t,{d:()=>l});var i=s(9923),r=s(4867),n=s(4640),a=s(5559),o=s(6041);class h{constructor(e,t,s,i){this.name=e,this.worldAxisForNormal=t,this.worldAxisForFileX=s,this.worldAxisForFileY=i}}class l{static ConvertCubeMapTextureToSphericalPolynomial(e){if(!e.isCube)return null;e.getScene()?.getEngine().flushFramebuffer();const t=e.getSize().width,s=e.readPixels(0,void 0,void 0,!1),i=e.readPixels(1,void 0,void 0,!1);let r,n;e.isRenderTarget?(r=e.readPixels(3,void 0,void 0,!1),n=e.readPixels(2,void 0,void 0,!1)):(r=e.readPixels(2,void 0,void 0,!1),n=e.readPixels(3,void 0,void 0,!1));const a=e.readPixels(4,void 0,void 0,!1),o=e.readPixels(5,void 0,void 0,!1),h=e.gammaSpace;let l=0;return 1!=e.textureType&&2!=e.textureType||(l=1),new Promise((e=>{Promise.all([i,s,r,n,a,o]).then((([s,i,r,n,a,o])=>{const c={size:t,right:i,left:s,up:r,down:n,front:a,back:o,format:5,type:l,gammaSpace:h};e(this.ConvertCubeMapToSphericalPolynomial(c))}))}))}static _AreaElement(e,t){return Math.atan2(e*t,Math.sqrt(e*e+t*t+1))}static ConvertCubeMapToSphericalPolynomial(e){const t=new n.O;let s=0;const i=2/e.size,h=i,l=.5*i,c=l-1;for(let n=0;n<6;n++){const u=this._FileFaces[n],d=e[u.name];let _=c;const f=5===e.format?4:3;for(let n=0;nE){const t=E/e;m*=t,T*=t,b*=t}}else m=(0,r.OQ)(m,0,E),T=(0,r.OQ)(T,0,E),b=(0,r.OQ)(b,0,E);const x=new o.v9(m,T,b);t.addLight(c,x,g),s+=g,p+=i}_+=h}}const u=4*Math.PI*6/6/s;return t.scaleInPlace(u),t.convertIncidentRadianceToIrradiance(),t.convertIrradianceToLambertianRadiance(),n.Q.FromHarmonics(t)}}l._FileFaces=[new h("right",new i.Pq(1,0,0),new i.Pq(0,0,-1),new i.Pq(0,-1,0)),new h("left",new i.Pq(-1,0,0),new i.Pq(0,0,1),new i.Pq(0,-1,0)),new h("up",new i.Pq(0,1,0),new i.Pq(1,0,0),new i.Pq(0,0,1)),new h("down",new i.Pq(0,-1,0),new i.Pq(1,0,0),new i.Pq(0,0,-1)),new h("front",new i.Pq(0,0,1),new i.Pq(1,0,0),new i.Pq(0,-1,0)),new h("back",new i.Pq(0,0,-1),new i.Pq(-1,0,0),new i.Pq(0,-1,0))],l.MAX_HDRI_VALUE=4096,l.PRESERVE_CLAMPED_COLORS=!1},7309:(e,t,s)=>{function i(e,t){const s=[];for(let i=0;ia,ln:()=>r,mI:()=>i});const n=["push","splice","pop","shift","unshift"];function a(e,t){const s=n.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()=>{s.forEach((e=>{e?.()}))}}},163:(e,t,s)=>{function i(e,t,s){try{const i=e.next();i.done?t(i):i.value?i.value.then((()=>{i.value=void 0,t(i)}),s):t(i)}catch(e){s(e)}}function r(e=25){let t;return(s,r,n)=>{const a=performance.now();void 0===t||a-t>e?(t=a,setTimeout((()=>{i(s,r,n)}),0)):i(s,r,n)}}function n(e,t,s,i,r){const n=()=>{let a;const o=e=>{e.done?s(e.value):void 0===a?a=!0:n()};do{a=void 0,r&&r.aborted?i(new Error("Aborted")):t(e,o,i),void 0===a&&(a=!1)}while(a)};n()}function a(e,t){let s;return n(e,i,(e=>s=e),(e=>{throw e}),t),s}function o(e,t,s){return new Promise(((i,r)=>{n(e,t,i,r,s)}))}function h(e,t){return(...s)=>a(e(...s),t)}s.d(t,{Aj:()=>h,V1:()=>a,VP:()=>r,kj:()=>o})},3537:(e,t,s)=>{s.d(t,{D:()=>b});var i=s(4867),r=s(1137),n=s(6755),a=s(1947),o=s(854),h=s(655),l=s(8688),c=s(6326),u=s(8454);c.$.prototype._partialLoadFile=function(e,t,s,i,r=null){this._loadFile(e,(e=>{s[t]=e,s._internalCount++,6===s._internalCount&&i(s)}),void 0,void 0,!0,((e,t)=>{r&&e&&r(e.status+" "+e.statusText,t)}))},c.$.prototype._cascadeLoadFiles=function(e,t,s,i=null){const r=[];r._internalCount=0;for(let e=0;e<6;e++)this._partialLoadFile(s[e],e,r,t,i)},c.$.prototype._cascadeLoadImgs=function(e,t,s,i,r=null,n){const a=[];a._internalCount=0;for(let o=0;o<6;o++)this._partialLoadImg(i[o],o,a,e,t,s,r,n)},c.$.prototype._partialLoadImg=function(e,t,s,i,r,n,a=null,o){const c=(0,l.z)();(0,h.W$)(e,(e=>{s[t]=e,s._internalCount++,i&&i.removePendingData(c),6===s._internalCount&&n&&n(r,s)}),((e,t)=>{i&&i.removePendingData(c),a&&a(e,t)}),i?i.offlineProvider:null,o),i&&i.addPendingData(c)},c.$.prototype.createCubeTextureBase=function(e,t,s,i,n=null,a=null,h,l=null,c=!1,d=0,_=0,f=null,p=null,g=null,m=!1,T=null){const b=f||new o.h(this,7);b.isCube=!0,b.url=e,b.generateMipMaps=!i,b._lodGenerationScale=d,b._lodGenerationOffset=_,b._useSRGBBuffer=!!m&&this._caps.supportSRGBBuffers&&(this.version>1||this.isWebGPU||!!i),b!==f&&(b.label=e.substring(0,60)),this._doNotHandleContextLost||(b._extension=l,b._files=s,b._buffer=T);const E=e;this._transformTextureUrl&&!f&&(e=this._transformTextureUrl(e));const x=e.split("?")[0],A=x.lastIndexOf("."),R=l||(A>-1?x.substring(A).toLowerCase():""),M=(0,u.gT)(R),y=(o,u)=>{e===E?a&&o&&a(o.status+" "+o.statusText,u):(r.V.Warn(`Failed to load ${e}, falling back to the ${E}`),this.createCubeTextureBase(E,t,s,!!i,n,a,h,l,c,d,_,b,p,g,m,T))};if(M)M.then((i=>{const o=e=>{p&&p(b,e),i.loadCubeData(e,b,c,n,a)};T?o(T):s&&6===s.length?i.supportCascades?this._cascadeLoadFiles(t,(e=>o(e.map((e=>new Uint8Array(e))))),s,a):a?a("Textures type does not support cascades."):r.V.Warn("Texture loader does not support cascades."):this._loadFile(e,(e=>o(new Uint8Array(e))),void 0,void 0,!0,y)}));else{if(!s||0===s.length)throw new Error("Cannot load cubemap because files were not defined, or the correct loader was not found.");this._cascadeLoadImgs(t,b,((e,t)=>{g&&g(e,t)}),s,a)}return this._internalTexturesCache.push(b),b};const d=131072,_=131072;function f(e){return e.charCodeAt(0)+(e.charCodeAt(1)<<8)+(e.charCodeAt(2)<<16)+(e.charCodeAt(3)<<24)}const p=f("DXT1"),g=f("DXT3"),m=f("DXT5"),T=f("DX10");class b{static GetDDSInfo(e){const t=new Int32Array(e.buffer,e.byteOffset,31),s=new Int32Array(e.buffer,e.byteOffset,35);let i=1;t[2]&d&&(i=Math.max(1,t[7]));const r=t[21],n=r===T?s[32]:0;let a=0;switch(r){case 113:a=2;break;case 116:a=1;break;case T:if(10===n){a=2;break}if(2===n){a=1;break}}return{width:t[4],height:t[3],mipmapCount:i,isFourCC:4==(4&t[20]),isRGB:64==(64&t[20]),isLuminance:(t[20]&_)===_,isCube:512==(512&t[28]),isCompressed:r===p||r===g||r===m,dxgiFormat:n,textureType:a}}static _GetHalfFloatAsFloatRGBAArrayBuffer(e,t,s,i,r,n){const o=new Float32Array(i),h=new Uint16Array(r,s);let l=0;for(let s=0;s>8)}static _GetRGBArrayBuffer(e,t,s,i,r,n,a,o){const h=new Uint8Array(i),l=new Uint8Array(r,s);let c=0;for(let s=0;s>8&255,O>>16&255,O>>24&255))])}var O;const F=b._ExtractLongWordOrder(f[23]),w=b._ExtractLongWordOrder(f[24]),L=b._ExtractLongWordOrder(f[25]),B=b._ExtractLongWordOrder(f[26]);D&&(C=e._getRGBABufferInternalSizedFormat(i.textureType)),y=1,f[2]&d&&!1!==a&&(y=Math.max(1,f[7]));const N=l||0,U=e.getCaps();for(let r=N;r0?i.sphericalPolynomial=n.d.ConvertCubeMapToSphericalPolynomial({size:f[4],right:u[0],left:u[1],up:u[2],down:u[3],front:u[4],back:u[5],format:5,type:1,gammaSpace:!1}):i.sphericalPolynomial=void 0}}b.StoreLODInAlphaChannel=!1},6080:(e,t,s)=>{s.d(t,{B:()=>n,K:()=>a});const i={},r={};function n(e){const t=e.getClassName();return r[t]||(r[t]={}),r[t]}function a(e){const t=e.getClassName();if(i[t])return i[t];i[t]={};const s=i[t];let n=e,a=t;for(;a;){const e=r[a];for(const t in e)s[t]=e[t];let t,i=!1;do{if(t=Object.getPrototypeOf(n),!t.getClassName){i=!0;break}if(t.getClassName()!==a)break;n=t}while(t);if(i)break;a=t.getClassName(),n=t}return s}},9259:(e,t,s)=>{s.d(t,{$z:()=>n,Cx:()=>m,P_:()=>u,WM:()=>c,Y9:()=>l,bR:()=>p,fW:()=>g,jT:()=>h,lK:()=>a,qK:()=>f,uM:()=>o,wL:()=>_,xG:()=>d});var i=s(6080);function r(e,t){return(s,r)=>{const n=(0,i.B)(s);n[r]||(n[r]={type:e,sourceName:t})}}function n(e,t=null){return function(e,t=null){return(s,i)=>{const r=t||"_"+i;Object.defineProperty(s,i,{get:function(){return this[r]},set:function(t){"function"==typeof this.equals&&this.equals(t)||this[r]!==t&&(this[r]=t,s[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 d(e){return r(6,e)}function _(e){return r(7,e)}function f(e){return r(8,e)}function p(e){return r(10,e)}function g(e){return r(11,e)}function m(e,t,s,i){const r=s.value;s.value=(...s)=>{let n=r;if("undefined"!=typeof _native&&_native[t]){const e=_native[t];n=i?(...t)=>i(...t)?e(...t):r(...t):e}return e[t]=n,n(...s)}}m.filter=function(e){return(t,s,i)=>m(t,s,i,e)}},6877:(e,t,s)=>{s.d(t,{p:()=>l});var i=s(5503),r=s(7503),n=s(6041),a=s(9923),o=s(6080);const h=function(e,t,s,i={}){const n=e();r.Y&&r.Y.HasTags(t)&&r.Y.AddTagsTo(n,r.Y.GetTags(t,!0));const a=(0,o.K)(n),h={};for(const e in a){const r=a[e],o=t[e],c=r.type;if(null!=o&&("uniqueId"!==e||l.AllowLoadingUniqueId))switch(c){case 0:case 6:case 11:n[e]=o;break;case 1:i.cloneTexturesOnlyOnce&&h[o.uniqueId]?n[e]=h[o.uniqueId]:(n[e]=s||o.isRenderTarget?o:o.clone(),h[o.uniqueId]=n[e]);break;case 2:case 3:case 4:case 5:case 7:case 10:case 12:n[e]=s?o:o.clone()}}return n};class l{static AppendSerializedAnimations(e,t){if(e.animations){t.animations=[];for(let s=0;s{throw(0,i.n)("ImageProcessingConfiguration")},l._FresnelParametersParser=e=>{throw(0,i.n)("FresnelParameters")},l._ColorCurvesParser=e=>{throw(0,i.n)("ColorCurves")},l._TextureParser=(e,t,s)=>{throw(0,i.n)("Texture")}},4609:(e,t,s)=>{s.d(t,{r:()=>n});var i=s(1137);const r=(e,t,s)=>e?e.getClassName&&"Mesh"===e.getClassName()?null:!e.getClassName||"SubMesh"!==e.getClassName()&&"PhysicsBody"!==e.getClassName()?e.clone?e.clone():Array.isArray(e)?e.slice():s&&"object"==typeof e?{...e}:null:e.clone(t):null;class n{static DeepCopy(e,t,s,n,a=!1){const o=function(e){const t=[];do{Object.getOwnPropertyNames(e).forEach((function(e){-1===t.indexOf(e)&&t.push(e)}))}while(e=Object.getPrototypeOf(e));return t}(e);for(const h of o){if("_"===h[0]&&(!n||-1===n.indexOf(h)))continue;if(h.endsWith("Observable"))continue;if(s&&-1!==s.indexOf(h))continue;const o=e[h],l=typeof o;if("function"!==l)try{if("object"===l)if(o instanceof Uint8Array)t[h]=Uint8Array.from(o);else if(o instanceof Array){if(t[h]=[],o.length>0)if("object"==typeof o[0])for(let e=0;e{s.d(t,{n:()=>r});const i={};function r(e,t=!1){if(!t||!i[e])return i[e]=!0,`${e} needs to be imported before as it contains a side-effect required by your code.`}},8790:(e,t,s)=>{function i(){return"undefined"!=typeof window}function r(){return"undefined"!=typeof navigator}function n(){return"undefined"!=typeof document}function a(e){let t="",s=e.firstChild;for(;s;)3===s.nodeType&&(t+=s.textContent),s=s.nextSibling;return t}s.d(t,{BA:()=>i,Nf:()=>n,XD:()=>r,Zl:()=>a})},8563:(e,t,s)=>{s.d(t,{Cf:()=>i,bu:()=>n,tG:()=>r});class i extends Error{}i._setPrototypeOf=Object.setPrototypeOf||((e,t)=>(e.__proto__=t,e));const r={MeshInvalidPositionsError:0,UnsupportedTextureError:1e3,GLTFLoaderUnexpectedMagicError:2e3,SceneLoaderError:3e3,LoadFileError:4e3,RequestFileError:4001,ReadFileError:4002};class n extends i{constructor(e,t,s){super(e),this.errorCode=t,this.innerError=s,this.name="RuntimeError",i._setPrototypeOf(this,n.prototype)}}},655:(e,t,s)=>{s.d(t,{rz:()=>S,eC:()=>b,f2:()=>v,zU:()=>M,W$:()=>A,NJ:()=>R,sh:()=>y,M1:()=>E});var i=s(2366),r=s(8790),n=s(9848);class a{}a.FilesToLoad={};var o=s(8563),h=s(6181),l=s(9125),c=s(6315),u=s(1137),d=s(2940),_=s(6741),f=s(6326);const p=new RegExp(/^data:([^,]+\/[^,]+)?;base64,/i);class g extends o.bu{constructor(e,t){super(e,o.tG.LoadFileError),this.name="LoadFileError",o.Cf._setPrototypeOf(this,g.prototype),t instanceof i.u?this.request=t:this.file=t}}class m extends o.bu{constructor(e,t){super(e,o.tG.RequestFileError),this.request=t,this.name="RequestFileError",o.Cf._setPrototypeOf(this,m.prototype)}}class T extends o.bu{constructor(e,t){super(e,o.tG.ReadFileError),this.file=t,this.name="ReadFileError",o.Cf._setPrototypeOf(this,T.prototype)}}const b={DefaultRetryStrategy:class{static ExponentialBackoff(e=3,t=500){return(s,i,r)=>0!==i.status||r>=e||-1!==s.indexOf("file:")?-1:Math.pow(2,r)*t}}.ExponentialBackoff(),BaseUrl:"",CorsBehavior:"anonymous",PreprocessUrl:e=>e,ScriptBaseUrl:"",ScriptPreprocessUrl:e=>e,CleanUrl:e=>e.replace(/#/gm,"%23")},E=(e,t)=>{if((!e||0!==e.indexOf("data:"))&&b.CorsBehavior)if("string"==typeof b.CorsBehavior||b.CorsBehavior instanceof String)t.crossOrigin=b.CorsBehavior;else{const s=b.CorsBehavior(e);s&&(t.crossOrigin=s)}},x={getRequiredSize:null},A=(e,t,s,r,n="",o)=>{const l=c.q.LastCreatedEngine;if("undefined"==typeof HTMLImageElement&&!l?._features.forceBitmapOverHTMLImageElement)return s("LoadImage is only supported in web or BabylonNative environments."),null;let u,d=!1;e instanceof ArrayBuffer||ArrayBuffer.isView(e)?"undefined"!=typeof Blob&&"undefined"!=typeof URL?(u=URL.createObjectURL(new Blob([e],{type:n})),d=!0):u=`data:${n};base64,`+(0,h.EL)(e):e instanceof Blob?(u=URL.createObjectURL(e),d=!0):(u=b.CleanUrl(e),u=b.PreprocessUrl(u));const _=t=>{if(s){const i=u||e.toString();s(`Error while trying to load image: ${0===i.indexOf("http")||i.length<=128?i:i.slice(0,128)+"..."}`,t)}};if(l?._features.forceBitmapOverHTMLImageElement)return M(u,(i=>{l.createImageBitmap(new Blob([i],{type:n}),{premultiplyAlpha:"none",...o}).then((e=>{t(e),d&&URL.revokeObjectURL(u)})).catch((t=>{s&&s("Error while trying to load image: "+e,t)}))}),void 0,r||void 0,!0,((e,t)=>{_(t)})),null;const f=new Image;if(x.getRequiredSize){const t=x.getRequiredSize(e);t.width&&(f.width=t.width),t.height&&(f.height=t.height)}E(u,f);const p=[],g=()=>{p.forEach((e=>{e.target.removeEventListener(e.name,e.handler)})),p.length=0};p.push({target:f,name:"load",handler:()=>{g(),t(f),d&&f.src&&URL.revokeObjectURL(f.src)}}),p.push({target:f,name:"error",handler:e=>{g(),_(e),d&&f.src&&URL.revokeObjectURL(f.src)}}),p.push({target:document,name:"securitypolicyviolation",handler:e=>{if(e.blockedURI!==f.src||"report"===e.disposition)return;g();const t=new Error(`CSP violation of policy ${e.effectiveDirective} ${e.blockedURI}. Current policy is ${e.originalPolicy}`);c.q.UseFallbackTexture=!1,_(t),d&&f.src&&URL.revokeObjectURL(f.src),f.src=""}}),p.forEach((e=>{e.target.addEventListener(e.name,e.handler)}));const m="blob:"===u.substring(0,5),T="data:"===u.substring(0,5),A=()=>{m||T||!i.u.IsCustomRequestAvailable?f.src=u:M(u,((e,t,s)=>{const i=new Blob([e],{type:!n&&s?s:n}),r=URL.createObjectURL(i);d=!0,f.src=r}),void 0,r||void 0,!0,((e,t)=>{_(t)}))};if(!m&&!T&&r&&r.enableTexturesOffline)r.open((()=>{r&&r.loadImage(u,f)}),A);else{if(-1!==u.indexOf("file:")){const e=decodeURIComponent(u.substring(5).toLowerCase());if(a.FilesToLoad[e]&&"undefined"!=typeof URL){try{let t;try{t=URL.createObjectURL(a.FilesToLoad[e])}catch(s){t=URL.createObjectURL(a.FilesToLoad[e])}f.src=t,d=!0}catch(e){f.src=""}return f}}A()}return f},R=(e,t,s,i,r)=>{const a=new FileReader,o={onCompleteObservable:new n.cP,abort:()=>a.abort()};return a.onloadend=()=>o.onCompleteObservable.notifyObservers(o),r&&(a.onerror=()=>{r(new T(`Unable to read ${e.name}`,e))}),a.onload=e=>{t(e.target.result)},s&&(a.onprogress=s),i?a.readAsArrayBuffer(e):a.readAsText(e),o},M=(e,t,s,i,r,o,h)=>{if(e.name)return R(e,t,s,r,o?e=>{o(void 0,e)}:void 0);const l=e;if(-1!==l.indexOf("file:")){let e=decodeURIComponent(l.substring(5).toLowerCase());0===e.indexOf("./")&&(e=e.substring(2));const i=a.FilesToLoad[e];if(i)return R(i,t,s,r,o?e=>o(void 0,new g(e.message,e.file)):void 0)}const{match:c,type:_}=C(l);if(c){const e={onCompleteObservable:new n.cP,abort:()=>()=>{}};try{const e=r?S(l):I(l);t(e,void 0,_)}catch(e){o?o(void 0,e):u.V.Error(e.message||"Failed to parse the Data URL")}return d._.SetImmediate((()=>{e.onCompleteObservable.notifyObservers(e)})),e}return y(l,((e,s)=>{t(e,s?.responseURL,s?.getResponseHeader("content-type"))}),s,i,r,o?e=>{o(e.request,new g(e.message,e.request))}:void 0,h)},y=(e,t,s,a,o,h,l)=>{e=b.CleanUrl(e),e=b.PreprocessUrl(e);const c=b.BaseUrl+e;let d=!1;const _={onCompleteObservable:new n.cP,abort:()=>d=!0},f=()=>{let e,n=new i.u,a=null;const f=()=>{n&&(s&&n.removeEventListener("progress",s),e&&n.removeEventListener("readystatechange",e),n.removeEventListener("loadend",p))};let p=()=>{f(),_.onCompleteObservable.notifyObservers(_),_.onCompleteObservable.clear(),s=void 0,e=null,p=null,h=void 0,l=void 0,t=void 0};_.abort=()=>{d=!0,p&&p(),n&&n.readyState!==(XMLHttpRequest.DONE||4)&&n.abort(),null!==a&&(clearTimeout(a),a=null),n=null};const g=e=>{const t=e.message||"Unknown error";h&&n?h(new m(t,n)):u.V.Error(t)},T=u=>{if(n){if(n.open("GET",c),l)try{l(n)}catch(e){return void g(e)}o&&(n.responseType="arraybuffer"),s&&n.addEventListener("progress",s),p&&n.addEventListener("loadend",p),e=()=>{if(!d&&n&&n.readyState===(XMLHttpRequest.DONE||4)){if(e&&n.removeEventListener("readystatechange",e),n.status>=200&&n.status<300||0===n.status&&(!(0,r.BA)()||P())){try{t&&t(o?n.response:n.responseText,n)}catch(e){g(e)}return}const s=b.DefaultRetryStrategy;if(s){const e=s(c,n,u);if(-1!==e)return f(),n=new i.u,void(a=setTimeout((()=>T(u+1)),e))}const l=new m("Error status: "+n.status+" "+n.statusText+" - Unable to load "+c,n);h&&h(l)}},n.addEventListener("readystatechange",e),n.send()}};T(0)};if(a&&a.enableSceneOffline){const i=e=>{e&&e.status>400?h&&h(e):f()},r=()=>{a&&a.loadFile(b.BaseUrl+e,(e=>{!d&&t&&t(e),_.onCompleteObservable.notifyObservers(_)}),s?e=>{!d&&s&&s(e)}:void 0,i,o)};a.open(r,i)}else f();return _},P=()=>"undefined"!=typeof location&&"file:"===location.protocol,v=e=>p.test(e),C=e=>{const t=p.exec(e);return null===t||0===t.length?{match:!1,type:""}:{match:!0,type:t[0].replace("data:","").replace("base64,","")}};function S(e){return(0,h.yS)(e.split(",")[1])}const I=e=>(0,h.AV)(e.split(",")[1]);let D;f.$._FileToolsLoadImage=A,_.sg.loadFile=M,l.J.loadFile=M,((e,t,s,i,r,n,a,o,h,l)=>{D={DecodeBase64UrlToBinary:e,DecodeBase64UrlToString:t,DefaultRetryStrategy:s.DefaultRetryStrategy,BaseUrl:s.BaseUrl,CorsBehavior:s.CorsBehavior,PreprocessUrl:s.PreprocessUrl,IsBase64DataUrl:i,IsFileURL:r,LoadFile:n,LoadImage:a,ReadFile:o,RequestFile:h,SetCorsBehavior:l},Object.defineProperty(D,"DefaultRetryStrategy",{get:function(){return s.DefaultRetryStrategy},set:function(e){s.DefaultRetryStrategy=e}}),Object.defineProperty(D,"BaseUrl",{get:function(){return s.BaseUrl},set:function(e){s.BaseUrl=e}}),Object.defineProperty(D,"PreprocessUrl",{get:function(){return s.PreprocessUrl},set:function(e){s.PreprocessUrl=e}}),Object.defineProperty(D,"CorsBehavior",{get:function(){return s.CorsBehavior},set:function(e){s.CorsBehavior=e}})})(S,I,b,v,P,M,A,R,y,E)},8688:(e,t,s)=>{function i(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))}s.d(t,{z:()=>i})},9337:(e,t,s)=>{s.d(t,{n:()=>n});var i=s(1137),r=s(6552);class n{static Instantiate(e){if(this.RegisteredExternalClasses&&this.RegisteredExternalClasses[e])return this.RegisteredExternalClasses[e];const t=(0,r.n9)(e);if(t)return t;i.V.Warn(e+" not found, you may have missed an import.");const s=e.split(".");let n=window||this;for(let e=0,t=s.length;e{s.d(t,{V:()=>i});class i{static _CheckLimit(e,t){let s=i._LogLimitOutputs[e];return s?s.current++:(s={limit:t,current:1},i._LogLimitOutputs[e]=s),s.current<=s.limit}static _GenerateLimitMessage(e,t=1){const s=i._LogLimitOutputs[e];if(!s||!i.MessageLimitReached)return;const r=this._Levels[t];s.current===s.limit&&i[r.name](i.MessageLimitReached.replace(/%LIMIT%/g,""+s.limit).replace(/%TYPE%/g,r.name??""))}static _AddLogEntry(e){i._LogCache=e+i._LogCache,i.OnNewCacheEntry&&i.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 r=Array.isArray(t)?t[0]:t;if(void 0!==s&&!i._CheckLimit(r,s))return;const n=i._FormatMessage(r),a=this._Levels[e],o=Array.isArray(t)?t.slice(1):[];a.logFunc&&a.logFunc("BJS - "+n,...o);const h=`
${n}

`;i._AddLogEntry(h),i._GenerateLimitMessage(r,e)}static get LogCache(){return i._LogCache}static ClearLogCache(){i._LogCache="",i._LogLimitOutputs={},i.errorsCount=0}static set LogLevels(e){i.Log=i._LogDisabled,i.Warn=i._LogDisabled,i.Error=i._LogDisabled,[i.MessageLogLevel,i.WarningLogLevel,i.ErrorLogLevel].forEach((t=>{if((e&t)===t){const e=this._Levels[t];i[e.name]=i._LogEnabled.bind(i,t)}}))}}i.NoneLogLevel=0,i.MessageLogLevel=1,i.WarningLogLevel=2,i.ErrorLogLevel=4,i.AllLogLevel=7,i.MessageLimitReached="Too many %TYPE%s (%LIMIT%), no more %TYPE%s will be reported for this message.",i._LogCache="",i._LogLimitOutputs={},i._Levels=[{},{color:"white",logFunc:console.log,name:"Log"},{color:"orange",logFunc:console.warn,name:"Warn"},{},{color:"red",logFunc:console.error,name:"Error"}],i.errorsCount=0,i.Log=i._LogEnabled.bind(i,i.MessageLogLevel),i.Warn=i._LogEnabled.bind(i,i.WarningLogLevel),i.Error=i._LogEnabled.bind(i,i.ErrorLogLevel)},9848:(e,t,s)=>{s.d(t,{cP:()=>n});class i{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 r{constructor(e,t,s=null){this.callback=e,this.mask=t,this.scope=s,this._willBeUnregistered=!1,this.unregisterOnNextCall=!1,this._remove=null}remove(){this._remove&&this._remove()}}class n{static FromPromise(e,t){const s=new n;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 i(0),e&&(this._onObserverAdded=e)}add(e,t=-1,s=!1,i=null,n=!1){if(!e)return null;const a=new r(e,t,i);return a.unregisterOnNextCall=n,s?this._observers.unshift(a):this._observers.push(a),this._onObserverAdded&&this._onObserverAdded(a),this._hasNotified&&this.notifyIfTriggered&&void 0!==this._lastNotifiedValue&&this.notifyObserver(a,this._lastNotifiedValue),a._remove=()=>{this.remove(a)},a}addOnce(e){return this.add(e,void 0,void 0,void 0,!0)}remove(e){return!!e&&(e._remove=null,-1!==this._observers.indexOf(e)&&(this._deferUnregister(e),!0))}removeCallback(e,t){for(let s=0;s{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 n;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}}},4296:(e,t,s)=>{s.d(t,{A:()=>r});var i=s(6237);class r{get min(){return this._min}get max(){return this._max}get average(){return this._average}get lastSecAverage(){return this._lastSecAverage}get current(){return this._current}get total(){return this._totalAccumulated}get count(){return this._totalValueCount}constructor(){this._startMonitoringTime=0,this._min=0,this._max=0,this._average=0,this._lastSecAverage=0,this._current=0,this._totalValueCount=0,this._totalAccumulated=0,this._lastSecAccumulated=0,this._lastSecTime=0,this._lastSecValueCount=0}fetchNewFrame(){this._totalValueCount++,this._current=0,this._lastSecValueCount++}addCount(e,t){r.Enabled&&(this._current+=e,t&&this._fetchResult())}beginMonitoring(){r.Enabled&&(this._startMonitoringTime=i.j.Now)}endMonitoring(e=!0){if(!r.Enabled)return;e&&this.fetchNewFrame();const t=i.j.Now;this._current=t-this._startMonitoringTime,e&&this._fetchResult()}endFrame(){this._fetchResult()}_fetchResult(){this._totalAccumulated+=this._current,this._lastSecAccumulated+=this._current,this._min=Math.min(this._min,this._current),this._max=Math.max(this._max,this._current),this._average=this._totalAccumulated/this._totalValueCount;const e=i.j.Now;e-this._lastSecTime>1e3&&(this._lastSecAverage=this._lastSecAccumulated/this._lastSecValueCount,this._lastSecTime=e,this._lastSecAccumulated=0,this._lastSecValueCount=0)}}r.Enabled=!0},6237:(e,t,s)=>{s.d(t,{j:()=>r});var i=s(8790);class r{static get Now(){return(0,i.BA)()&&window.performance&&window.performance.now?window.performance.now():Date.now()}}},7931:(e,t,s)=>{s.d(t,{L:()=>i,b:()=>r});class i{constructor(e){this.length=0,this.data=new Array(e),this._id=i._GlobalId++}push(e){this.data[this.length++]=e,this.length>this.data.length&&(this.data.length*=2)}forEach(e){for(let t=0;tthis.data.length&&(this.data.length=2*(this.length+e.length));for(let t=0;t=this.length?-1:t}contains(e){return-1!==this.indexOf(e)}}i._GlobalId=0;class r extends i{constructor(){super(...arguments),this._duplicateId=0}push(e){super.push(e),e.__smartArrayFlags||(e.__smartArrayFlags={}),e.__smartArrayFlags[this._id]=this._duplicateId}pushNoDuplicate(e){return!(e.__smartArrayFlags&&e.__smartArrayFlags[this._id]===this._duplicateId||(this.push(e),0))}reset(){super.reset(),this._duplicateId++}concatWithNoDuplicate(e){if(0!==e.length){this.length+e.length>this.data.length&&(this.data.length=2*(this.length+e.length));for(let t=0;t{s.d(t,{AV:()=>r,EL:()=>i,yS:()=>n});const i=e=>{const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";let s,i,r,n,a,o,h,l="",c=0;const u=ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e);for(;c>2,a=(3&s)<<4|i>>4,o=(15&i)<<2|r>>6,h=63&r,isNaN(i)?o=h=64:isNaN(r)&&(h=64),l+=t.charAt(n)+t.charAt(a)+t.charAt(o)+t.charAt(h);return l},r=e=>atob(e),n=e=>{const t=r(e),s=t.length,i=new Uint8Array(new ArrayBuffer(s));for(let e=0;e{s.d(t,{Y:()=>r});class i{static Eval(e,t){return"true"===(e=e.match(/\([^()]*\)/g)?e.replace(/\([^()]*\)/g,(e=>(e=e.slice(1,e.length-1),i._HandleParenthesisContent(e,t)))):i._HandleParenthesisContent(e,t))||"false"!==e&&i.Eval(e,t)}static _HandleParenthesisContent(e,t){let s;t=t||(e=>"true"===e);const r=e.split("||");for(const e in r)if(Object.prototype.hasOwnProperty.call(r,e)){let n=i._SimplifyNegation(r[e].trim());const a=n.split("&&");if(a.length>1)for(let e=0;e(e=e.replace(/[\s]/g,(()=>""))).length%2?"!":""))).trim())?e="false":"!false"===e&&(e="true"),e}}class r{static EnableFor(e){e._tags=e._tags||{},e.hasTags=()=>r.HasTags(e),e.addTags=t=>r.AddTagsTo(e,t),e.removeTags=t=>r.RemoveTagsFrom(e,t),e.matchesTagsQuery=t=>r.MatchesQuery(e,t)}static DisableFor(e){delete e._tags,delete e.hasTags,delete e.addTags,delete e.removeTags,delete e.matchesTagsQuery}static HasTags(e){if(!e._tags)return!1;const t=e._tags;for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!0;return!1}static GetTags(e,t=!0){if(!e._tags)return null;if(t){const t=[];for(const s in e._tags)Object.prototype.hasOwnProperty.call(e._tags,s)&&!0===e._tags[s]&&t.push(s);return t.join(" ")}return e._tags}static AddTagsTo(e,t){t&&"string"==typeof t&&t.split(" ").forEach((function(t){r._AddTagTo(e,t)}))}static _AddTagTo(e,t){""!==(t=t.trim())&&"true"!==t&&"false"!==t&&(t.match(/[\s]/)||t.match(/^([!]|([|]|[&]){2})/)||(r.EnableFor(e),e._tags[t]=!0))}static RemoveTagsFrom(e,t){if(!r.HasTags(e))return;const s=t.split(" ");for(const t in s)r._RemoveTagFrom(e,s[t])}static _RemoveTagFrom(e,t){delete e._tags[t]}static MatchesQuery(e,t){return void 0===t||(""===t?r.HasTags(e):i.Eval(t,(t=>r.HasTags(e)&&e._tags[t])))}}},1947:(e,t,s)=>{s.d(t,{Qs:()=>h,SX:()=>d,LZ:()=>u}),s(2781),s(6882);var i=s(7891),r=s(6326),n=s(6552),a=s(6877);class o extends i.w{getClassName(){return"PassPostProcess"}constructor(e,t,s=null,i,r,n,a=0,o=!1){super(e,"pass",null,null,t,s,i,r,n,void 0,a,void 0,null,o)}_gatherImports(e,t){e?(this._webGPUReady=!0,t.push(Promise.all([s.e(126).then(s.bind(s,9965))]))):t.push(Promise.all([s.e(71).then(s.bind(s,9820))])),super._gatherImports(e,t)}static _Parse(e,t,s,i){return a.p.Parse((()=>new o(e.name,e.options,t,e.renderTargetSamplingMode,e._engine,e.reusable)),e,s,i)}}function h(e,t,s,r,n,a,o,h){const l=t.getEngine();return t.isReady=!1,n=n??t.samplingMode,r=r??t.type,a=a??t.format,o=o??t.width,h=h??t.height,-1===r&&(r=0),new Promise((c=>{const u=new i.w("postprocess",e,null,null,1,null,n,l,!1,void 0,r,void 0,null,!1,a);u.externalTextureSamplerBinding=!0;const d=l.createRenderTargetTexture({width:o,height:h},{generateDepthBuffer:!1,generateMipMaps:!1,generateStencilBuffer:!1,samplingMode:n,type:r,format:a});u.onEffectCreatedObservable.addOnce((e=>{e.executeWhenCompiled((()=>{u.onApply=e=>{e._bindTexture("textureSampler",t),e.setFloat2("scale",1,1)},s.postProcessManager.directRender([u],d,!0),l.restoreDefaultFramebuffer(),l._releaseTexture(t),u&&u.dispose(),d._swapAndDie(t),t.type=r,t.format=5,t.isReady=!0,c(t)}))}))}))}let l,c;function u(e){l||(l=new Float32Array(1),c=new Int32Array(l.buffer)),l[0]=e;const t=c[0];let s=t>>16&32768,i=t>>12&2047;const r=t>>23&255;return r<103?s:r>142?(s|=31744,s|=(255==r?0:1)&&8388607&t,s):r<113?(i|=2048,s|=(i>>114-r)+(i>>113-r&1),s):(s|=r-112<<10|i>>1,s+=1&i,s)}function d(e){const t=(32768&e)>>15,s=(31744&e)>>10,i=1023&e;return 0===s?(t?-1:1)*Math.pow(2,-14)*(i/Math.pow(2,10)):31==s?i?NaN:1/0*(t?-1:1):(t?-1:1)*Math.pow(2,s-15)*(1+i/Math.pow(2,10))}(0,n.Y5)("BABYLON.PassPostProcess",o),i.w,r.$._RescalePostProcessFactory=e=>new o("rescale",1,null,2,e,!1,0)},2940:(e,t,s)=>{s.d(t,{_:()=>r});var i=s(8790);class r{static SetImmediate(e){(0,i.BA)()&&window.setImmediate?window.setImmediate(e):setTimeout(e,1)}}},1597:(e,t,s)=>{function i(e){let t=1;do{t*=2}while(te-s?s:t}function a(e){return e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,++e}function o(e){return e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,(e|=e>>16)-(e>>1)}function h(e,t,s=2){let i;switch(s){case 1:i=o(e);break;case 2:i=n(e);break;default:i=a(e)}return Math.min(i,t)}s.d(t,{C4:()=>o,L8:()=>i,OG:()=>n,R:()=>h,zF:()=>r})},998:(e,t,s)=>{s.d(t,{LV:()=>m,S0:()=>g});var i=s(9848),r=s(8790),n=s(1137),a=s(4609),o=s(6237),h=s(5503),l=s(2366),c=s(6315),u=s(655),d=s(2940),_=s(9337),f=s(8688),p=s(1597);class g{static get BaseUrl(){return u.eC.BaseUrl}static set BaseUrl(e){u.eC.BaseUrl=e}static get CleanUrl(){return u.eC.CleanUrl}static set CleanUrl(e){u.eC.CleanUrl=e}static IsAbsoluteUrl(e){return 0===e.indexOf("//")||-1!==e.indexOf("://")&&-1!==e.indexOf(".")&&-1!==e.indexOf("/")&&!(e.indexOf(":")>e.indexOf("/"))&&(e.indexOf("://"){(0,u.zU)(e,(e=>{s(e)}),void 0,void 0,t,((e,t)=>{i(t)}))}))}static GetBabylonScriptURL(e,t){if(!e)return"";if(g.ScriptBaseUrl&&e.startsWith(g._DefaultCdnUrl)){const t="/"===g.ScriptBaseUrl[g.ScriptBaseUrl.length-1]?g.ScriptBaseUrl.substring(0,g.ScriptBaseUrl.length-1):g.ScriptBaseUrl;e=e.replace(g._DefaultCdnUrl,t)}return e=g.ScriptPreprocessUrl(e),t&&(e=g.GetAbsoluteUrl(e)),e}static LoadBabylonScript(e,t,s,i){e=g.GetBabylonScriptURL(e),g.LoadScript(e,t,s)}static LoadBabylonScriptAsync(e){return e=g.GetBabylonScriptURL(e),g.LoadScriptAsync(e)}static LoadScript(e,t,s,i,n=!1){if("function"==typeof importScripts){try{importScripts(e),t&&t()}catch(t){s?.(`Unable to load script '${e}' in worker`,t)}return}if(!(0,r.BA)())return void s?.(`Cannot load script '${e}' outside of a window or a worker`);const a=document.getElementsByTagName("head")[0],o=document.createElement("script");n?(o.setAttribute("type","module"),o.innerText=e):(o.setAttribute("type","text/javascript"),o.setAttribute("src",e)),i&&(o.id=i),o.onload=()=>{t&&t()},o.onerror=t=>{s&&s(`Unable to load script '${e}'`,t)},a.appendChild(o)}static LoadScriptAsync(e,t){return new Promise(((s,i)=>{this.LoadScript(e,(()=>{s()}),((e,t)=>{i(t||new Error(e))}),t)}))}static ReadFileAsDataURL(e,t,s){const r=new FileReader,n={onCompleteObservable:new i.cP,abort:()=>r.abort()};return r.onloadend=()=>{n.onCompleteObservable.notifyObservers(n)},r.onload=e=>{t(e.target.result)},r.onprogress=s,r.readAsDataURL(e),n}static ReadFile(e,t,s,i,r){return(0,u.NJ)(e,t,s,i,r)}static FileAsURL(e){const t=new Blob([e]);return window.URL.createObjectURL(t)}static Format(e,t=2){return e.toFixed(t)}static DeepCopy(e,t,s,i){a.r.DeepCopy(e,t,s,i)}static IsEmpty(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}static RegisterTopRootEvents(e,t){for(let s=0;s{const i=atob(this.toDataURL(t,s).split(",")[1]),r=i.length,n=new Uint8Array(r);for(let e=0;et(e))):e.toBlob((function(e){t(e)}),s,i)}static DownloadBlob(e,t){if("download"in document.createElement("a")){if(!t){const e=new Date;t="screenshot_"+(e.getFullYear()+"-"+(e.getMonth()+1)).slice(2)+"-"+e.getDate()+"_"+e.getHours()+"-"+("0"+e.getMinutes()).slice(-2)+".png"}g.Download(e,t)}else if(e&&"undefined"!=typeof URL){const t=URL.createObjectURL(e),s=window.open("");if(!s)return;const i=s.document.createElement("img");i.onload=function(){URL.revokeObjectURL(t)},i.src=t,s.document.body.appendChild(i)}}static EncodeScreenshotCanvasData(e,t,s="image/png",i,r){if("string"!=typeof i&&t){if(t){if(g._IsOffScreenCanvas(e))return void e.convertToBlob({type:s,quality:r}).then((e=>{const s=new FileReader;s.readAsDataURL(e),s.onloadend=()=>{const e=s.result;t(e)}}));const i=e.toDataURL(s,r);t(i)}}else this.ToBlob(e,(function(e){e&&g.DownloadBlob(e,i),t&&t("")}),s,r)}static Download(e,t){if("undefined"==typeof URL)return;const s=window.URL.createObjectURL(e),i=document.createElement("a");document.body.appendChild(i),i.style.display="none",i.href=s,i.download=t,i.addEventListener("click",(()=>{i.parentElement&&i.parentElement.removeChild(i)})),i.click(),window.URL.revokeObjectURL(s)}static BackCompatCameraNoPreventDefault(e){return"boolean"==typeof e[0]?e[0]:"boolean"==typeof e[1]&&e[1]}static CreateScreenshot(e,t,s,i,r="image/png",n=!1,a){throw(0,h.n)("ScreenshotTools")}static CreateScreenshotAsync(e,t,s,i="image/png",r){throw(0,h.n)("ScreenshotTools")}static CreateScreenshotUsingRenderTarget(e,t,s,i,r="image/png",n=1,a=!1,o,l=!1,c=!1,u=!0,d,_){throw(0,h.n)("ScreenshotTools")}static CreateScreenshotUsingRenderTargetAsync(e,t,s,i="image/png",r=1,n=!1,a,o=!1,l=!1,c=!0,u,d){throw(0,h.n)("ScreenshotTools")}static RandomId(){return(0,f.z)()}static IsBase64(e){return(0,u.f2)(e)}static DecodeBase64(e){return(0,u.rz)(e)}static get errorsCount(){return n.V.errorsCount}static Log(e){n.V.Log(e)}static Warn(e){n.V.Warn(e)}static Error(e){n.V.Error(e)}static get LogCache(){return n.V.LogCache}static ClearLogCache(){n.V.ClearLogCache()}static set LogLevels(e){n.V.LogLevels=e}static set PerformanceLogLevel(e){return(e&g.PerformanceUserMarkLogLevel)===g.PerformanceUserMarkLogLevel?(g.StartPerformanceCounter=g._StartUserMark,void(g.EndPerformanceCounter=g._EndUserMark)):(e&g.PerformanceConsoleLogLevel)===g.PerformanceConsoleLogLevel?(g.StartPerformanceCounter=g._StartPerformanceConsole,void(g.EndPerformanceCounter=g._EndPerformanceConsole)):(g.StartPerformanceCounter=g._StartPerformanceCounterDisabled,void(g.EndPerformanceCounter=g._EndPerformanceCounterDisabled))}static _StartPerformanceCounterDisabled(e,t){}static _EndPerformanceCounterDisabled(e,t){}static _StartUserMark(e,t=!0){if(!g._Performance){if(!(0,r.BA)())return;g._Performance=window.performance}t&&g._Performance.mark&&g._Performance.mark(e+"-Begin")}static _EndUserMark(e,t=!0){t&&g._Performance.mark&&(g._Performance.mark(e+"-End"),g._Performance.measure(e,e+"-Begin",e+"-End"))}static _StartPerformanceConsole(e,t=!0){t&&(g._StartUserMark(e,t),console.time&&console.time(e))}static _EndPerformanceConsole(e,t=!0){t&&(g._EndUserMark(e,t),console.timeEnd(e))}static get Now(){return o.j.Now}static GetClassName(e,t=!1){let s=null;return!t&&e.getClassName?s=e.getClassName():(e instanceof Object&&(s=(t?e:Object.getPrototypeOf(e)).constructor.__bjsclassName__),s||(s=typeof e)),s}static First(e,t){for(const s of e)if(t(s))return s;return null}static getFullClassName(e,t=!1){let s=null,i=null;if(!t&&e.getClassName)s=e.getClassName();else{if(e instanceof Object){const r=t?e:Object.getPrototypeOf(e);s=r.constructor.__bjsclassName__,i=r.constructor.__bjsmoduleName__}s||(s=typeof e)}return s?(null!=i?i+".":"")+s:null}static DelayAsync(e){return new Promise((t=>{setTimeout((()=>{t()}),e)}))}static IsSafari(){return!!(0,r.XD)()&&/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}}g.UseCustomRequestHeaders=!1,g.CustomRequestHeaders=l.u.CustomRequestHeaders,g.GetDOMTextContent=r.Zl,g._DefaultCdnUrl="https://cdn.babylonjs.com",g.GetAbsoluteUrl="object"==typeof document?e=>{const t=document.createElement("a");return t.href=e,t.href}:"function"==typeof URL&&"object"==typeof location?e=>new URL(e,location.origin).href:()=>{throw new Error("Unable to get absolute URL. Override BABYLON.Tools.GetAbsoluteUrl to a custom implementation for the current context.")},g.NoneLogLevel=n.V.NoneLogLevel,g.MessageLogLevel=n.V.MessageLogLevel,g.WarningLogLevel=n.V.WarningLogLevel,g.ErrorLogLevel=n.V.ErrorLogLevel,g.AllLogLevel=n.V.AllLogLevel,g.IsWindowObjectExist=r.BA,g.PerformanceNoneLogLevel=0,g.PerformanceUserMarkLogLevel=1,g.PerformanceConsoleLogLevel=2,g.StartPerformanceCounter=g._StartPerformanceCounterDisabled,g.EndPerformanceCounter=g._EndPerformanceCounterDisabled;class m{constructor(e,t,s,i=0){this.iterations=e,this.index=i-1,this._done=!1,this._fn=t,this._successCallback=s}executeNext(){this._done||(this.index+1{r&&r()?i.breakLoop():setTimeout((()=>{for(let n=0;n=e)break;if(s(a),r&&r()){i.breakLoop();break}}i.executeNext()}),n)}),i)}}g.Mix=p.zF,g.IsExponentOfTwo=p.L8,c.q.FallbackTexture="data:image/jpg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/4QBmRXhpZgAATU0AKgAAAAgABAEaAAUAAAABAAAAPgEbAAUAAAABAAAARgEoAAMAAAABAAIAAAExAAIAAAAQAAAATgAAAAAAAABgAAAAAQAAAGAAAAABcGFpbnQubmV0IDQuMC41AP/bAEMABAIDAwMCBAMDAwQEBAQFCQYFBQUFCwgIBgkNCw0NDQsMDA4QFBEODxMPDAwSGBITFRYXFxcOERkbGRYaFBYXFv/bAEMBBAQEBQUFCgYGChYPDA8WFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFv/AABEIAQABAAMBIgACEQEDEQH/xAAfAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgv/xAC1EAACAQMDAgQDBQUEBAAAAX0BAgMABBEFEiExQQYTUWEHInEUMoGRoQgjQrHBFVLR8CQzYnKCCQoWFxgZGiUmJygpKjQ1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4eLj5OXm5+jp6vHy8/T19vf4+fr/xAAfAQADAQEBAQEBAQEBAAAAAAAAAQIDBAUGBwgJCgv/xAC1EQACAQIEBAMEBwUEBAABAncAAQIDEQQFITEGEkFRB2FxEyIygQgUQpGhscEJIzNS8BVictEKFiQ04SXxFxgZGiYnKCkqNTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqCg4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2dri4+Tl5ufo6ery8/T19vf4+fr/2gAMAwEAAhEDEQA/APH6KKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FCiiigD6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++gooooA+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gUKKKKAPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76CiiigD5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BQooooA+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/voKKKKAPl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FCiiigD6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++gooooA+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gUKKKKAPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76CiiigD5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BQooooA+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/voKKKKAPl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FCiiigD6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++gooooA+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gUKKKKAPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76P//Z"},6552:(e,t,s)=>{s.d(t,{Y5:()=>r,n9:()=>n});const i={};function r(e,t){i[e]=t}function n(e){return i[e]}},2366:(e,t,s)=>{s.d(t,{u:()=>i});class i{constructor(){this._xhr="undefined"!=typeof _native&&_native.XMLHttpRequest?new _native.XMLHttpRequest:new XMLHttpRequest,this._requestURL=""}static get IsCustomRequestAvailable(){return Object.keys(i.CustomRequestHeaders).length>0||i.CustomRequestModifiers.length>0}get requestURL(){return this._requestURL}_injectCustomRequestHeaders(){if(!this._shouldSkipRequestModifications(this._requestURL))for(const e in i.CustomRequestHeaders){const t=i.CustomRequestHeaders[e];t&&this._xhr.setRequestHeader(e,t)}}_shouldSkipRequestModifications(e){return i.SkipRequestModificationForBabylonCDN&&(e.includes("preview.babylonjs.com")||e.includes("cdn.babylonjs.com"))}get onprogress(){return this._xhr.onprogress}set onprogress(e){this._xhr.onprogress=e}get readyState(){return this._xhr.readyState}get status(){return this._xhr.status}get statusText(){return this._xhr.statusText}get response(){return this._xhr.response}get responseURL(){return this._xhr.responseURL}get responseText(){return this._xhr.responseText}get responseType(){return this._xhr.responseType}set responseType(e){this._xhr.responseType=e}get timeout(){return this._xhr.timeout}set timeout(e){this._xhr.timeout=e}addEventListener(e,t,s){this._xhr.addEventListener(e,t,s)}removeEventListener(e,t,s){this._xhr.removeEventListener(e,t,s)}abort(){this._xhr.abort()}send(e){i.CustomRequestHeaders&&this._injectCustomRequestHeaders(),this._xhr.send(e)}open(e,t){for(const e of i.CustomRequestModifiers){if(this._shouldSkipRequestModifications(t))return;e(this._xhr,t)}t=(t=t.replace("file:http:","http:")).replace("file:https:","https:"),this._requestURL=t,this._xhr.open(e,t,!0)}setRequestHeader(e,t){this._xhr.setRequestHeader(e,t)}getResponseHeader(e){return this._xhr.getResponseHeader(e)}}i.CustomRequestHeaders={},i.CustomRequestModifiers=new Array,i.SkipRequestModificationForBabylonCDN=!0},706:(e,t,s)=>{s.d(t,{M:()=>c});var i=s(5524),r=s(9848),n=s(6315),a=s(5616),o=s(9259),h=s(6877),l=s(6552);class c{get influence(){return this._influence}set influence(e){if(this._influence===e)return;const t=this._influence;this._influence=e,this.onInfluenceChanged.hasObservers()&&this.onInfluenceChanged.notifyObservers(0===t||0===e)}get animationPropertiesOverride(){return!this._animationPropertiesOverride&&this._scene?this._scene.animationPropertiesOverride:this._animationPropertiesOverride}set animationPropertiesOverride(e){this._animationPropertiesOverride=e}constructor(e,t=0,s=null){this.name=e,this.animations=[],this._positions=null,this._normals=null,this._tangents=null,this._uvs=null,this._uniqueId=0,this.onInfluenceChanged=new r.cP,this._onDataLayoutChanged=new r.cP,this._animationPropertiesOverride=null,this.id=e,this._scene=s||n.q.LastCreatedScene,this.influence=t,this._scene&&(this._uniqueId=this._scene.getUniqueId())}get uniqueId(){return this._uniqueId}get hasPositions(){return!!this._positions}get hasNormals(){return!!this._normals}get hasTangents(){return!!this._tangents}get hasUVs(){return!!this._uvs}setPositions(e){const t=this.hasPositions;this._positions=e,t!==this.hasPositions&&this._onDataLayoutChanged.notifyObservers(void 0)}getPositions(){return this._positions}setNormals(e){const t=this.hasNormals;this._normals=e,t!==this.hasNormals&&this._onDataLayoutChanged.notifyObservers(void 0)}getNormals(){return this._normals}setTangents(e){const t=this.hasTangents;this._tangents=e,t!==this.hasTangents&&this._onDataLayoutChanged.notifyObservers(void 0)}getTangents(){return this._tangents}setUVs(e){const t=this.hasUVs;this._uvs=e,t!==this.hasUVs&&this._onDataLayoutChanged.notifyObservers(void 0)}getUVs(){return this._uvs}clone(){const e=h.p.Clone((()=>new c(this.name,this.influence,this._scene)),this);return e._positions=this._positions,e._normals=this._normals,e._tangents=this._tangents,e._uvs=this._uvs,e}serialize(){const e={};return e.name=this.name,e.influence=this.influence,e.positions=Array.prototype.slice.call(this.getPositions()),null!=this.id&&(e.id=this.id),this.hasNormals&&(e.normals=Array.prototype.slice.call(this.getNormals())),this.hasTangents&&(e.tangents=Array.prototype.slice.call(this.getTangents())),this.hasUVs&&(e.uvs=Array.prototype.slice.call(this.getUVs())),h.p.AppendSerializedAnimations(this,e),e}getClassName(){return"MorphTarget"}static Parse(e,t){const s=new c(e.name,e.influence);if(s.setPositions(e.positions),null!=e.id&&(s.id=e.id),e.normals&&s.setNormals(e.normals),e.tangents&&s.setTangents(e.tangents),e.uvs&&s.setUVs(e.uvs),e.animations){for(let t=0;t{s.d(t,{j:()=>l});var i=s(7931),r=s(1137),n=s(6315),a=s(706),o=s(2781);class h extends o.g{get depth(){return this._depth}constructor(e,t,s,i,r,n,a=!0,h=!1,l=o.g.TRILINEAR_SAMPLINGMODE,c=0,u){super(null,n,!a,h),this.format=r,this._texture=n.getEngine().createRawTexture2DArray(e,t,s,i,r,a,h,l,null,c,u),this._depth=i,this.is2DArray=!0}update(e){this._texture&&this._getEngine().updateRawTexture2DArray(this._texture,e,this._texture.format,this._texture.invertY,null,this._texture.type)}static CreateRGBATexture(e,t,s,i,r,n=!0,a=!1,o=3,l=0){return new h(e,t,s,i,5,r,n,a,o,l)}}class l{set areUpdatesFrozen(e){e?this._blockCounter++:(this._blockCounter--,this._blockCounter<=0&&(this._blockCounter=0,this._syncActiveTargets(!0)))}get areUpdatesFrozen(){return this._blockCounter>0}constructor(e=null){if(this._targets=new Array,this._targetInfluenceChangedObservers=new Array,this._targetDataLayoutChangedObservers=new Array,this._activeTargets=new i.L(16),this._supportsNormals=!1,this._supportsTangents=!1,this._supportsUVs=!1,this._vertexCount=0,this._uniqueId=0,this._tempInfluences=new Array,this._canUseTextureForTargets=!1,this._blockCounter=0,this._textureVertexStride=0,this._textureWidth=0,this._textureHeight=1,this._parentContainer=null,this.optimizeInfluencers=!0,this.enableNormalMorphing=!0,this.enableTangentMorphing=!0,this.enableUVMorphing=!0,this._numMaxInfluencers=0,this._useTextureToStoreTargets=!0,e||(e=n.q.LastCreatedScene),this._scene=e,this._scene){this._scene.addMorphTargetManager(this),this._uniqueId=this._scene.getUniqueId();const e=this._scene.getEngine().getCaps();this._canUseTextureForTargets=e.canUseGLVertexID&&e.textureFloat&&e.maxVertexTextureImageUnits>0&&e.texture2DArrayMaxLayerCount>1}}get numMaxInfluencers(){return this._numMaxInfluencers}set numMaxInfluencers(e){this._numMaxInfluencers!==e&&(this._numMaxInfluencers=e,this._syncActiveTargets(!0))}get uniqueId(){return this._uniqueId}get vertexCount(){return this._vertexCount}get supportsNormals(){return this._supportsNormals&&this.enableNormalMorphing}get supportsTangents(){return this._supportsTangents&&this.enableTangentMorphing}get supportsUVs(){return this._supportsUVs&&this.enableUVMorphing}get numTargets(){return this._targets.length}get numInfluencers(){return this._activeTargets.length}get influences(){return this._influences}get useTextureToStoreTargets(){return this._useTextureToStoreTargets}set useTextureToStoreTargets(e){this._useTextureToStoreTargets=e}get isUsingTextureForTargets(){return l.EnableTextureStorage&&this.useTextureToStoreTargets&&this._canUseTextureForTargets&&!this._scene?.getEngine().getCaps().disableMorphTargetTexture}getActiveTarget(e){return this._activeTargets.data[e]}getTarget(e){return this._targets[e]}getTargetByName(e){for(const t of this._targets)if(t.name===e)return t;return null}addTarget(e){this._targets.push(e),this._targetInfluenceChangedObservers.push(e.onInfluenceChanged.add((e=>{this._syncActiveTargets(e)}))),this._targetDataLayoutChangedObservers.push(e._onDataLayoutChanged.add((()=>{this._syncActiveTargets(!0)}))),this._syncActiveTargets(!0)}removeTarget(e){const t=this._targets.indexOf(e);t>=0&&(this._targets.splice(t,1),e.onInfluenceChanged.remove(this._targetInfluenceChangedObservers.splice(t,1)[0]),e._onDataLayoutChanged.remove(this._targetDataLayoutChangedObservers.splice(t,1)[0]),this._syncActiveTargets(!0)),this._scene&&this._scene.stopAnimation(e)}_bind(e){e.setFloat3("morphTargetTextureInfo",this._textureVertexStride,this._textureWidth,this._textureHeight),e.setFloatArray("morphTargetTextureIndices",this._morphTargetTextureIndices),e.setTexture("morphTargets",this._targetStoreTexture),e.setInt("morphTargetCount",this.numInfluencers)}clone(){const e=new l(this._scene);for(const t of this._targets)e.addTarget(t.clone());return e.enableNormalMorphing=this.enableNormalMorphing,e.enableTangentMorphing=this.enableTangentMorphing,e.enableUVMorphing=this.enableUVMorphing,e}serialize(){const e={};e.id=this.uniqueId,e.targets=[];for(const t of this._targets)e.targets.push(t.serialize());return e}_syncActiveTargets(e){if(this.areUpdatesFrozen)return;let t=0;this._activeTargets.reset(),this._supportsNormals=!0,this._supportsTangents=!0,this._supportsUVs=!0,this._vertexCount=0,this._scene&&this._targets.length>this._scene.getEngine().getCaps().texture2DArrayMaxLayerCount&&(this.useTextureToStoreTargets=!1),this._morphTargetTextureIndices&&this._morphTargetTextureIndices.length===this._targets.length||(this._morphTargetTextureIndices=new Float32Array(this._targets.length));let s=-1;for(const e of this._targets){if(s++,0===e.influence&&this.optimizeInfluencers)continue;if(this._activeTargets.length>=l.MaxActiveMorphTargetsInVertexAttributeMode&&!this.isUsingTextureForTargets)break;this._activeTargets.push(e),this._morphTargetTextureIndices[t]=s,this._tempInfluences[t++]=e.influence,this._supportsNormals=this._supportsNormals&&e.hasNormals,this._supportsTangents=this._supportsTangents&&e.hasTangents,this._supportsUVs=this._supportsUVs&&e.hasUVs;const i=e.getPositions();if(i){const e=i.length/3;if(0===this._vertexCount)this._vertexCount=e;else if(this._vertexCount!==e)return void r.V.Error("Incompatible target. Targets must all have the same vertices count.")}}this._morphTargetTextureIndices.length!==t&&(this._morphTargetTextureIndices=this._morphTargetTextureIndices.slice(0,t)),this._influences&&this._influences.length===t||(this._influences=new Float32Array(t));for(let e=0;e0)){this._textureVertexStride=1,this._supportsNormals&&this._textureVertexStride++,this._supportsTangents&&this._textureVertexStride++,this._supportsUVs&&this._textureVertexStride++,this._textureWidth=this._vertexCount*this._textureVertexStride||1,this._textureHeight=1;const e=this._scene.getEngine().getCaps().maxTextureSize;this._textureWidth>e&&(this._textureHeight=Math.ceil(this._textureWidth/e),this._textureWidth=e);let t=!0;if(this._targetStoreTexture){const e=this._targetStoreTexture.getSize();e.width===this._textureWidth&&e.height===this._textureHeight&&this._targetStoreTexture.depth===this._targets.length&&(t=!1)}if(t){this._targetStoreTexture&&this._targetStoreTexture.dispose();const e=this._targets.length,t=new Float32Array(e*this._textureWidth*this._textureHeight*4);let s=0;for(let i=0;i-1&&this._parentContainer.morphTargetManagers.splice(e,1),this._parentContainer=null}for(const e of this._targets)this._scene.stopAnimation(e)}}static Parse(e,t){const s=new l(t);for(const i of e.targets)s.addTarget(a.M.Parse(i,t));return s}}l.EnableTextureStorage=!0,l.MaxActiveMorphTargetsInVertexAttributeMode=8},3770:(e,t,s)=>{s.d(t,{e:()=>ae});var i=s(5524),r=s(9259),n=s(6877),a=s(9848),o=s(1137),h=s(2781),l=s(554),c=s(9923),u=s(5616),d=s(6882),_=s(8986),f=s(6532),p=s(998),g=s(6041),m=s(6315),T=s(5503),b=s(2565),E=s(5476),x=s(492),A=s(467),R=s(1597);class M{get camera(){return this._effectLayerOptions.camera}get renderingGroupId(){return this._effectLayerOptions.renderingGroupId}set renderingGroupId(e){this._effectLayerOptions.renderingGroupId=e}get mainTexture(){return this._mainTexture}get shaderLanguage(){return this._shaderLanguage}setMaterialForRendering(e,t){if(this._mainTexture.setMaterialForRendering(e,t),Array.isArray(e))for(let s=0;s{if((s||0===t)&&e.subMeshes)for(let t=0;t{let r;this.onBeforeRenderMainTextureObservable.notifyObservers(this);const n=this._scene.getEngine();if(i.length){for(n.setColorWrite(!1),r=0;r{e.clear(this.neutralColor,!0,!0,!0)})),this._scene.getBoundingBoxRenderer){const e=this._scene.getBoundingBoxRenderer().enabled;this._mainTexture.onBeforeBindObservable.add((()=>{this._scene.getBoundingBoxRenderer().enabled=!this.disableBoundingBoxesFromEffectLayer&&e})),this._mainTexture.onAfterUnbindObservable.add((()=>{this._scene.getBoundingBoxRenderer().enabled=e}))}}_addCustomEffectDefines(e){}_isReady(e,t,s){const i=this._scene.getEngine(),r=e.getMesh(),n=r._internalAbstractMeshDataInfo._materialForRenderPass?.[i.currentRenderPassId];if(n)return n.isReadyForSubMesh(r,e,t);const a=e.getMaterial();if(!a)return!1;if(this._useMeshMaterial(e.getRenderingMesh()))return a.isReadyForSubMesh(e.getMesh(),e,t);const o=[],h=[u.R.PositionKind];let l=!1,c=!1;if(a){const e=a.needAlphaTesting(),t=a.getAlphaTestTexture(),s=t&&t.hasAlpha&&(a.useAlphaFromDiffuseTexture||a._useAlphaFromAlbedoTexture);t&&(e||s)&&(o.push("#define DIFFUSE"),r.isVerticesDataPresent(u.R.UV2Kind)&&1===t.coordinatesIndex?(o.push("#define DIFFUSEUV2"),c=!0):r.isVerticesDataPresent(u.R.UVKind)&&(o.push("#define DIFFUSEUV1"),l=!0),e&&(o.push("#define ALPHATEST"),o.push("#define ALPHATESTVALUE 0.4")),t.gammaSpace||o.push("#define DIFFUSE_ISLINEAR"));const i=a.opacityTexture;i&&(o.push("#define OPACITY"),r.isVerticesDataPresent(u.R.UV2Kind)&&1===i.coordinatesIndex?(o.push("#define OPACITYUV2"),c=!0):r.isVerticesDataPresent(u.R.UVKind)&&(o.push("#define OPACITYUV1"),l=!0))}s&&(o.push("#define EMISSIVE"),r.isVerticesDataPresent(u.R.UV2Kind)&&1===s.coordinatesIndex?(o.push("#define EMISSIVEUV2"),c=!0):r.isVerticesDataPresent(u.R.UVKind)&&(o.push("#define EMISSIVEUV1"),l=!0),s.gammaSpace||o.push("#define EMISSIVE_ISLINEAR")),r.useVertexColors&&r.isVerticesDataPresent(u.R.ColorKind)&&r.hasVertexAlpha&&a.transparencyMode!==_.i.MATERIAL_OPAQUE&&(h.push(u.R.ColorKind),o.push("#define VERTEXALPHA")),l&&(h.push(u.R.UVKind),o.push("#define UV1")),c&&(h.push(u.R.UV2Kind),o.push("#define UV2"));const d=new b.J;if(r.useBones&&r.computeBonesUsingShaders){h.push(u.R.MatricesIndicesKind),h.push(u.R.MatricesWeightsKind),r.numBoneInfluencers>4&&(h.push(u.R.MatricesIndicesExtraKind),h.push(u.R.MatricesWeightsExtraKind)),o.push("#define NUM_BONE_INFLUENCERS "+r.numBoneInfluencers);const e=r.skeleton;e&&e.isUsingTextureForMatrices?o.push("#define BONETEXTURE"):o.push("#define BonesPerMesh "+(e?e.bones.length+1:0)),r.numBoneInfluencers>0&&d.addCPUSkinningFallback(0,r)}else o.push("#define NUM_BONE_INFLUENCERS 0");const f=r.morphTargetManager;let p=0;f&&(p=f.numMaxInfluencers||f.numInfluencers,p>0&&(o.push("#define MORPHTARGETS"),o.push("#define NUM_MORPH_INFLUENCERS "+p),f.isUsingTextureForTargets&&o.push("#define MORPHTARGETS_TEXTURE"),(0,A.MF)(h,r,p))),t&&(o.push("#define INSTANCES"),(0,A.te)(h),e.getRenderingMesh().hasThinInstances&&o.push("#define THIN_INSTANCES")),(0,x.tv)(a,this._scene,o),this._addCustomEffectDefines(o);const g=e._getDrawWrapper(void 0,!0),m=g.defines,T=o.join("\n");if(m!==T){const e=["world","mBones","viewProjection","glowColor","morphTargetInfluences","morphTargetCount","boneTextureWidth","diffuseMatrix","emissiveMatrix","opacityMatrix","opacityIntensity","morphTargetTextureInfo","morphTargetTextureIndices","glowIntensity"];(0,x.TV)(e),g.setEffect(this._engine.createEffect("glowMapGeneration",h,e,["diffuseSampler","emissiveSampler","opacitySampler","boneSampler","morphTargets"],T,d,void 0,void 0,{maxSimultaneousMorphTargets:p},this._shaderLanguage,this._shadersLoaded?void 0:async()=>{await this._importShadersAsync(),this._shadersLoaded=!0}),T)}const E=g.effect.isReady();return this._arePostProcessAndMergeReady()&&E}async _importShadersAsync(){1===this._shaderLanguage?await Promise.all([s.e(126).then(s.bind(s,8267)),s.e(126).then(s.bind(s,9073))]):await Promise.all([s.e(71).then(s.bind(s,136)),s.e(71).then(s.bind(s,3234))])}_arePostProcessAndMergeReady(){let e=!0;for(let t=0;tl.setMatrix("world",t)))}else this._mainTexture.resetRefreshCounter();this.onAfterRenderMeshToEffect.notifyObservers(i)}_useMeshMaterial(e){return!1}_rebuild(){const e=this._vertexBuffers[u.R.PositionKind];e&&e._rebuild(),this._generateIndexBuffer()}_disposeTextureAndPostProcesses(){this._mainTexture.dispose();for(let e=0;e-1&&this._scene.effectLayers.splice(t,1),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onBeforeRenderMainTextureObservable.clear(),this.onBeforeComposeObservable.clear(),this.onBeforeRenderMeshToEffect.clear(),this.onAfterRenderMeshToEffect.clear(),this.onAfterComposeObservable.clear(),this.onSizeChangedObservable.clear()}getClassName(){return"EffectLayer"}static Parse(e,t,s){return p.S0.Instantiate(e.customType).Parse(e,t,s)}}M.ForceGLSL=!1,M._SceneComponentInitialization=e=>{throw(0,T.n)("EffectLayerSceneComponent")},(0,i.Cg)([(0,r.lK)()],M.prototype,"name",void 0),(0,i.Cg)([(0,r.qK)()],M.prototype,"neutralColor",void 0),(0,i.Cg)([(0,r.lK)()],M.prototype,"isEnabled",void 0),(0,i.Cg)([(0,r.fW)()],M.prototype,"camera",null),(0,i.Cg)([(0,r.lK)()],M.prototype,"renderingGroupId",null),(0,i.Cg)([(0,r.lK)()],M.prototype,"disableBoundingBoxesFromEffectLayer",void 0);var y=s(6552),P=s(388),v=s(6945);(0,s(3084).ji)(v.v.NAME_EFFECTLAYER,((e,t,s,i)=>{if(e.effectLayers){s.effectLayers||(s.effectLayers=[]);for(let r=0;r{this.scene.addEffectLayer(e)}))}removeFromContainer(e,t){e.effectLayers&&e.effectLayers.forEach((e=>{this.scene.removeEffectLayer(e),t&&e.dispose()}))}dispose(){const e=this.scene.effectLayers;for(;e.length;)e[0].dispose()}_isReadyForMesh(e,t){const s=this._engine.currentRenderPassId,i=this.scene.effectLayers;for(const r of i){if(!r.hasMesh(e))continue;const i=r._mainTexture;this._engine.currentRenderPassId=i.renderPassId;for(const i of e.subMeshes)if(!r.isReady(i,t))return this._engine.currentRenderPassId=s,!1}return this._engine.currentRenderPassId=s,!0}_renderMainTexture(e){this._renderEffects=!1,this._needStencil=!1;let t=!1;const s=this.scene.effectLayers;if(s&&s.length>0){this._previousStencilState=this._engine.getStencilBuffer();for(const i of s)if(i.shouldRender()&&(!i.camera||i.camera.cameraRigMode===P.i.RIG_MODE_NONE&&e===i.camera||i.camera.cameraRigMode!==P.i.RIG_MODE_NONE&&i.camera._rigCameras.indexOf(e)>-1)){this._renderEffects=!0,this._needStencil=this._needStencil||i.needStencil();const e=i._mainTexture;e._shouldRender()&&(this.scene.incrementRenderId(),e.render(!1,!1),t=!0)}this.scene.incrementRenderId()}return t}_setStencil(){this._needStencil&&this._engine.setStencilBuffer(!0)}_setStencilBack(){this._needStencil&&this._engine.setStencilBuffer(this._previousStencilState)}_draw(e){if(this._renderEffects){this._engine.setDepthBuffer(!1);const t=this.scene.effectLayers;for(let s=0;s{let t=e._getComponent(v.v.NAME_EFFECTLAYER);t||(t=new C(e),e._addComponent(t))},l.Z.prototype.getGlowLayerByName=function(e){for(let t=0;t{await this._importShadersAsync(),this._shadersLoaded=!0})}_createTextureAndPostProcesses(){let e=this._mainTextureDesiredSize.width,t=this._mainTextureDesiredSize.height;e=this._engine.needPOTTextures?(0,R.R)(e,this._maxSize):e,t=this._engine.needPOTTextures?(0,R.R)(t,this._maxSize):t;let s=0;s=this._engine.getCaps().textureHalfFloatRender?2:0,this._blurTexture1=new d.$("GlowLayerBlurRTT",{width:e,height:t},this._scene,!1,!0,s),this._blurTexture1.wrapU=h.g.CLAMP_ADDRESSMODE,this._blurTexture1.wrapV=h.g.CLAMP_ADDRESSMODE,this._blurTexture1.updateSamplingMode(h.g.BILINEAR_SAMPLINGMODE),this._blurTexture1.renderParticles=!1,this._blurTexture1.ignoreCameraViewport=!0;const i=Math.floor(e/2),r=Math.floor(t/2);this._blurTexture2=new d.$("GlowLayerBlurRTT2",{width:i,height:r},this._scene,!1,!0,s),this._blurTexture2.wrapU=h.g.CLAMP_ADDRESSMODE,this._blurTexture2.wrapV=h.g.CLAMP_ADDRESSMODE,this._blurTexture2.updateSamplingMode(h.g.BILINEAR_SAMPLINGMODE),this._blurTexture2.renderParticles=!1,this._blurTexture2.ignoreCameraViewport=!0,this._textures=[this._blurTexture1,this._blurTexture2];const n=this._getEffectiveBlurKernelSize();this._horizontalBlurPostprocess1=new f.j("GlowLayerHBP1",new c.I9(1,0),n,{width:e,height:t},null,h.g.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,s),this._horizontalBlurPostprocess1.width=e,this._horizontalBlurPostprocess1.height=t,this._horizontalBlurPostprocess1.externalTextureSamplerBinding=!0,this._horizontalBlurPostprocess1.onApplyObservable.add((e=>{e.setTexture("textureSampler",this._mainTexture)})),this._verticalBlurPostprocess1=new f.j("GlowLayerVBP1",new c.I9(0,1),n,{width:e,height:t},null,h.g.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,s),this._horizontalBlurPostprocess2=new f.j("GlowLayerHBP2",new c.I9(1,0),n,{width:i,height:r},null,h.g.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,s),this._horizontalBlurPostprocess2.width=i,this._horizontalBlurPostprocess2.height=r,this._horizontalBlurPostprocess2.externalTextureSamplerBinding=!0,this._horizontalBlurPostprocess2.onApplyObservable.add((e=>{e.setTexture("textureSampler",this._blurTexture1)})),this._verticalBlurPostprocess2=new f.j("GlowLayerVBP2",new c.I9(0,1),n,{width:i,height:r},null,h.g.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,s),this._postProcesses=[this._horizontalBlurPostprocess1,this._verticalBlurPostprocess1,this._horizontalBlurPostprocess2,this._verticalBlurPostprocess2],this._postProcesses1=[this._horizontalBlurPostprocess1,this._verticalBlurPostprocess1],this._postProcesses2=[this._horizontalBlurPostprocess2,this._verticalBlurPostprocess2],this._mainTexture.samples=this._options.mainTextureSamples,this._mainTexture.onAfterUnbindObservable.add((()=>{const e=this._blurTexture1.renderTarget;if(e){this._scene.postProcessManager.directRender(this._postProcesses1,e,!0);const t=this._blurTexture2.renderTarget;t&&this._scene.postProcessManager.directRender(this._postProcesses2,t,!0),this._engine.unBindFramebuffer(t??e,!0)}})),this._postProcesses.map((e=>{e.autoClear=!1}))}_getEffectiveBlurKernelSize(){return this._options.blurKernelSize/2}isReady(e,t){const s=e.getMaterial(),i=e.getRenderingMesh();if(!s||!i)return!1;const r=s.emissiveTexture;return super._isReady(e,t,r)}needStencil(){return!1}_canRenderMesh(e,t){return!0}_internalRender(e){e.setTexture("textureSampler",this._blurTexture1),e.setTexture("textureSampler2",this._blurTexture2),e.setFloat("offset",this._intensity);const t=this._engine,s=t.getStencilBuffer();t.setStencilBuffer(!1),t.drawElementsType(_.i.TriangleFillMode,0,6),t.setStencilBuffer(s)}_setEmissiveTextureAndColor(e,t,s){let i=1;this.customEmissiveTextureSelector?this._emissiveTextureAndColor.texture=this.customEmissiveTextureSelector(e,t,s):s?(this._emissiveTextureAndColor.texture=s.emissiveTexture,this._emissiveTextureAndColor.texture&&(i=this._emissiveTextureAndColor.texture.level)):this._emissiveTextureAndColor.texture=null,this.customEmissiveColorSelector?this.customEmissiveColorSelector(e,t,s,this._emissiveTextureAndColor.color):s.emissiveColor?(i*=s.emissiveIntensity??1,this._emissiveTextureAndColor.color.set(s.emissiveColor.r*i,s.emissiveColor.g*i,s.emissiveColor.b*i,s.alpha)):this._emissiveTextureAndColor.color.set(this.neutralColor.r,this.neutralColor.g,this.neutralColor.b,this.neutralColor.a)}_shouldRenderMesh(e){return this.hasMesh(e)}_addCustomEffectDefines(e){e.push("#define GLOW")}addExcludedMesh(e){-1===this._excludedMeshes.indexOf(e.uniqueId)&&this._excludedMeshes.push(e.uniqueId)}removeExcludedMesh(e){const t=this._excludedMeshes.indexOf(e.uniqueId);-1!==t&&this._excludedMeshes.splice(t,1)}addIncludedOnlyMesh(e){-1===this._includedOnlyMeshes.indexOf(e.uniqueId)&&this._includedOnlyMeshes.push(e.uniqueId)}removeIncludedOnlyMesh(e){const t=this._includedOnlyMeshes.indexOf(e.uniqueId);-1!==t&&this._includedOnlyMeshes.splice(t,1)}hasMesh(e){return!!super.hasMesh(e)&&(this._includedOnlyMeshes.length?-1!==this._includedOnlyMeshes.indexOf(e.uniqueId):!this._excludedMeshes.length||-1===this._excludedMeshes.indexOf(e.uniqueId))}_useMeshMaterial(e){return 0!=this._meshesUsingTheirOwnMaterials.length&&this._meshesUsingTheirOwnMaterials.indexOf(e.uniqueId)>-1}referenceMeshToUseItsOwnMaterial(e){e.resetDrawCache(this._mainTexture.renderPassId),this._meshesUsingTheirOwnMaterials.push(e.uniqueId),e.onDisposeObservable.add((()=>{this._disposeMesh(e)}))}unReferenceMeshFromUsingItsOwnMaterial(e){let t=this._meshesUsingTheirOwnMaterials.indexOf(e.uniqueId);for(;t>=0;)this._meshesUsingTheirOwnMaterials.splice(t,1),t=this._meshesUsingTheirOwnMaterials.indexOf(e.uniqueId);e.resetDrawCache(this._mainTexture.renderPassId)}_disposeMesh(e){this.removeIncludedOnlyMesh(e),this.removeExcludedMesh(e)}getClassName(){return"GlowLayer"}serialize(){const e=n.p.Serialize(this);let t;if(e.customType="BABYLON.GlowLayer",e.includedMeshes=[],this._includedOnlyMeshes.length)for(t=0;tnew S(e.name,t,e.options)),e,t,s);let r;for(r=0;r{e.setFloat2("screenSize",this.width,this.height),e.setFloat2("sharpnessAmounts",this.edgeAmount,this.colorAmount)}}_gatherImports(e,t){e?(this._webGPUReady=!0,t.push(Promise.all([s.e(126).then(s.bind(s,5381))]))):t.push(Promise.all([Promise.resolve().then(s.bind(s,8438))])),super._gatherImports(e,t)}static _Parse(e,t,s,i){return n.p.Parse((()=>new D(e.name,e.options,t,e.renderTargetSamplingMode,s.getEngine(),e.textureType,e.reusable)),e,s,i)}}(0,i.Cg)([(0,r.lK)()],D.prototype,"colorAmount",void 0),(0,i.Cg)([(0,r.lK)()],D.prototype,"edgeAmount",void 0),(0,y.Y5)("BABYLON.SharpenPostProcess",D);var O=s(1088);class F extends I.w{get imageProcessingConfiguration(){return this._imageProcessingConfiguration}set imageProcessingConfiguration(e){e.applyByPostProcess=!0,this._attachImageProcessingConfiguration(e)}_attachImageProcessingConfiguration(e,t=!1){if(e!==this._imageProcessingConfiguration){if(this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),e)this._imageProcessingConfiguration=e;else{let e=null;const t=this.getEngine(),s=this.getCamera();if(s)e=s.getScene();else if(t&&t.scenes){const s=t.scenes;e=s[s.length-1]}else e=m.q.LastCreatedScene;this._imageProcessingConfiguration=e?e.imageProcessingConfiguration:new O.p}this._imageProcessingConfiguration&&(this._imageProcessingObserver=this._imageProcessingConfiguration.onUpdateParameters.add((()=>{this._updateParameters()}))),t||this._updateParameters()}}get isSupported(){const e=this.getEffect();return!e||e.isSupported}get colorCurves(){return this.imageProcessingConfiguration.colorCurves}set colorCurves(e){this.imageProcessingConfiguration.colorCurves=e}get colorCurvesEnabled(){return this.imageProcessingConfiguration.colorCurvesEnabled}set colorCurvesEnabled(e){this.imageProcessingConfiguration.colorCurvesEnabled=e}get colorGradingTexture(){return this.imageProcessingConfiguration.colorGradingTexture}set colorGradingTexture(e){this.imageProcessingConfiguration.colorGradingTexture=e}get colorGradingEnabled(){return this.imageProcessingConfiguration.colorGradingEnabled}set colorGradingEnabled(e){this.imageProcessingConfiguration.colorGradingEnabled=e}get exposure(){return this.imageProcessingConfiguration.exposure}set exposure(e){this.imageProcessingConfiguration.exposure=e}get toneMappingEnabled(){return this._imageProcessingConfiguration.toneMappingEnabled}set toneMappingEnabled(e){this._imageProcessingConfiguration.toneMappingEnabled=e}get toneMappingType(){return this._imageProcessingConfiguration.toneMappingType}set toneMappingType(e){this._imageProcessingConfiguration.toneMappingType=e}get contrast(){return this.imageProcessingConfiguration.contrast}set contrast(e){this.imageProcessingConfiguration.contrast=e}get vignetteStretch(){return this.imageProcessingConfiguration.vignetteStretch}set vignetteStretch(e){this.imageProcessingConfiguration.vignetteStretch=e}get vignetteCentreX(){return this.imageProcessingConfiguration.vignetteCenterX}set vignetteCentreX(e){this.imageProcessingConfiguration.vignetteCenterX=e}get vignetteCentreY(){return this.imageProcessingConfiguration.vignetteCenterY}set vignetteCentreY(e){this.imageProcessingConfiguration.vignetteCenterY=e}get vignetteCenterY(){return this.imageProcessingConfiguration.vignetteCenterY}set vignetteCenterY(e){this.imageProcessingConfiguration.vignetteCenterY=e}get vignetteCenterX(){return this.imageProcessingConfiguration.vignetteCenterX}set vignetteCenterX(e){this.imageProcessingConfiguration.vignetteCenterX=e}get vignetteWeight(){return this.imageProcessingConfiguration.vignetteWeight}set vignetteWeight(e){this.imageProcessingConfiguration.vignetteWeight=e}get vignetteColor(){return this.imageProcessingConfiguration.vignetteColor}set vignetteColor(e){this.imageProcessingConfiguration.vignetteColor=e}get vignetteCameraFov(){return this.imageProcessingConfiguration.vignetteCameraFov}set vignetteCameraFov(e){this.imageProcessingConfiguration.vignetteCameraFov=e}get vignetteBlendMode(){return this.imageProcessingConfiguration.vignetteBlendMode}set vignetteBlendMode(e){this.imageProcessingConfiguration.vignetteBlendMode=e}get vignetteEnabled(){return this.imageProcessingConfiguration.vignetteEnabled}set vignetteEnabled(e){this.imageProcessingConfiguration.vignetteEnabled=e}get ditheringIntensity(){return this.imageProcessingConfiguration.ditheringIntensity}set ditheringIntensity(e){this.imageProcessingConfiguration.ditheringIntensity=e}get ditheringEnabled(){return this.imageProcessingConfiguration.ditheringEnabled}set ditheringEnabled(e){this.imageProcessingConfiguration.ditheringEnabled=e}get fromLinearSpace(){return this._fromLinearSpace}set fromLinearSpace(e){this._fromLinearSpace!==e&&(this._fromLinearSpace=e,this._updateParameters())}constructor(e,t,s=null,i,r,n,a=0,o){super(e,"imageProcessing",[],[],t,s,i,r,n,null,a,"postprocess",null,!0),this._fromLinearSpace=!0,this._defines={IMAGEPROCESSING:!1,VIGNETTE:!1,VIGNETTEBLENDMODEMULTIPLY:!1,VIGNETTEBLENDMODEOPAQUE:!1,TONEMAPPING:0,CONTRAST:!1,COLORCURVES:!1,COLORGRADING:!1,COLORGRADING3D:!1,FROMLINEARSPACE:!1,SAMPLER3DGREENDEPTH:!1,SAMPLER3DBGRMAP:!1,DITHER:!1,IMAGEPROCESSINGPOSTPROCESS:!1,EXPOSURE:!1,SKIPFINALCOLORCLAMP:!1},o?(o.applyByPostProcess=!0,this._attachImageProcessingConfiguration(o,!0),this._updateParameters()):(this._attachImageProcessingConfiguration(null,!0),this.imageProcessingConfiguration.applyByPostProcess=!0),this.onApply=e=>{this.imageProcessingConfiguration.bind(e,this.aspectRatio)}}_gatherImports(e,t){e?(this._webGPUReady=!0,t.push(s.e(126).then(s.bind(s,7614)))):t.push(s.e(71).then(s.bind(s,3153))),super._gatherImports(e,t)}getClassName(){return"ImageProcessingPostProcess"}_updateParameters(){this._defines.FROMLINEARSPACE=this._fromLinearSpace,this.imageProcessingConfiguration.prepareDefines(this._defines,!0);let e="";for(const t in this._defines){const s=this._defines[t];switch(typeof s){case"number":case"string":e+=`#define ${t} ${s};\n`;break;default:s&&(e+=`#define ${t};\n`)}}const t=["textureSampler"],s=["scale"];O.p&&(O.p.PrepareSamplers(t,this._defines),O.p.PrepareUniforms(s,this._defines)),this.updateEffect(e,s,t)}dispose(e){super.dispose(e),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),this._imageProcessingConfiguration&&(this.imageProcessingConfiguration.applyByPostProcess=!1)}}(0,i.Cg)([(0,r.lK)()],F.prototype,"_fromLinearSpace",void 0);class w extends I.w{getClassName(){return"ChromaticAberrationPostProcess"}constructor(e,t,s,i,r,n,a,o,h=0,l=!1){super(e,"chromaticAberration",["chromatic_aberration","screen_width","screen_height","direction","radialIntensity","centerPosition"],[],i,r,n,a,o,null,h,void 0,null,l),this.aberrationAmount=30,this.radialIntensity=0,this.direction=new c.I9(.707,.707),this.centerPosition=new c.I9(.5,.5),this.screenWidth=t,this.screenHeight=s,this.onApplyObservable.add((e=>{e.setFloat("chromatic_aberration",this.aberrationAmount),e.setFloat("screen_width",t),e.setFloat("screen_height",s),e.setFloat("radialIntensity",this.radialIntensity),e.setFloat2("direction",this.direction.x,this.direction.y),e.setFloat2("centerPosition",this.centerPosition.x,this.centerPosition.y)}))}_gatherImports(e,t){e?(this._webGPUReady=!0,t.push(Promise.all([s.e(126).then(s.bind(s,9619))]))):t.push(Promise.all([s.e(71).then(s.bind(s,2048))])),super._gatherImports(e,t)}static _Parse(e,t,s,i){return n.p.Parse((()=>new w(e.name,e.screenWidth,e.screenHeight,e.options,t,e.renderTargetSamplingMode,s.getEngine(),e.reusable,e.textureType,!1)),e,s,i)}}(0,i.Cg)([(0,r.lK)()],w.prototype,"aberrationAmount",void 0),(0,i.Cg)([(0,r.lK)()],w.prototype,"radialIntensity",void 0),(0,i.Cg)([(0,r.lK)()],w.prototype,"direction",void 0),(0,i.Cg)([(0,r.lK)()],w.prototype,"centerPosition",void 0),(0,i.Cg)([(0,r.lK)()],w.prototype,"screenWidth",void 0),(0,i.Cg)([(0,r.lK)()],w.prototype,"screenHeight",void 0),(0,y.Y5)("BABYLON.ChromaticAberrationPostProcess",w);class L extends I.w{getClassName(){return"GrainPostProcess"}constructor(e,t,s,i,r,n,a=0,o=!1){super(e,"grain",["intensity","animatedSeed"],[],t,s,i,r,n,null,a,void 0,null,o),this.intensity=30,this.animated=!1,this.onApplyObservable.add((e=>{e.setFloat("intensity",this.intensity),e.setFloat("animatedSeed",this.animated?Math.random()+1:1)}))}_gatherImports(e,t){e?(this._webGPUReady=!0,t.push(Promise.all([s.e(126).then(s.bind(s,8625))]))):t.push(Promise.all([s.e(71).then(s.bind(s,890))])),super._gatherImports(e,t)}static _Parse(e,t,s,i){return n.p.Parse((()=>new L(e.name,e.options,t,e.renderTargetSamplingMode,s.getEngine(),e.reusable)),e,s,i)}}(0,i.Cg)([(0,r.lK)()],L.prototype,"intensity",void 0),(0,i.Cg)([(0,r.lK)()],L.prototype,"animated",void 0),(0,y.Y5)("BABYLON.GrainPostProcess",L);class B extends I.w{getClassName(){return"FxaaPostProcess"}constructor(e,t,s=null,i,r,n,a=0){super(e,"fxaa",["texelSize"],null,t,s,i||h.g.BILINEAR_SAMPLINGMODE,r,n,null,a,"fxaa",void 0,!0);const o=this._getDefines();this.updateEffect(o),this.onApplyObservable.add((e=>{const t=this.texelSize;e.setFloat2("texelSize",t.x,t.y)}))}_gatherImports(e,t){e?(this._webGPUReady=!0,t.push(Promise.all([s.e(126).then(s.bind(s,2578)),s.e(126).then(s.bind(s,3208))]))):t.push(Promise.all([s.e(71).then(s.bind(s,5499)),s.e(71).then(s.bind(s,9669))])),super._gatherImports(e,t)}_getDefines(){const e=this.getEngine();return e&&e.extractDriverInfo().toLowerCase().indexOf("mali")>-1?"#define MALI 1\n":null}static _Parse(e,t,s,i){return n.p.Parse((()=>new B(e.name,e.options,t,e.renderTargetSamplingMode,s.getEngine(),e.reusable)),e,s,i)}}(0,y.Y5)("BABYLON.FxaaPostProcess",B);class N{get name(){return this._name}get cameras(){return this._cameras}get engine(){return this._engine}constructor(e,t){this._engine=e,this._name=t,this._renderEffects={},this._renderEffectsForIsolatedPass=new Array,this._cameras=[]}getClassName(){return"PostProcessRenderPipeline"}get isSupported(){for(const e in this._renderEffects)if(Object.prototype.hasOwnProperty.call(this._renderEffects,e)&&!this._renderEffects[e].isSupported)return!1;return!0}addEffect(e){this._renderEffects[e._name]=e}_rebuild(){}_enableEffect(e,t){const s=this._renderEffects[e];s&&s._enable(p.S0.MakeArray(t||this._cameras))}_disableEffect(e,t){const s=this._renderEffects[e];s&&s._disable(p.S0.MakeArray(t||this._cameras))}_attachCameras(e,t){const s=p.S0.MakeArray(e||this._cameras);if(!s)return;const i=[];let r;for(r=0;r0){const s=this._renderEffects[t[0]].getPostProcesses();s&&(s[0].samples=e)}return!0}_adaptPostProcessesToViewPort(){const e=Object.keys(this._renderEffects);for(const t of e){const e=this._renderEffects[t].getPostProcesses();if(e)for(const t of e)t.adaptScaleToCurrentViewport=!0}}setPrePassRenderer(e){return!1}dispose(){}}(0,i.Cg)([(0,r.lK)()],N.prototype,"_name",void 0);class U{constructor(e,t,s,i){this._name=t,this._singleInstance=i||!0,this._getPostProcesses=s,this._cameras={},this._indicesForCamera={},this._postProcesses={}}get isSupported(){for(const e in this._postProcesses)if(Object.prototype.hasOwnProperty.call(this._postProcesses,e)){const t=this._postProcesses[e];for(let e=0;e{const t=i.attachPostProcess(e);this._indicesForCamera[r].push(t)})),this._cameras[r]||(this._cameras[r]=i)}}_detachCameras(e){const t=p.S0.MakeArray(e||this._cameras);if(t)for(let e=0;e{s.detachPostProcess(e)})),this._cameras[i]&&(this._cameras[i]=null),delete this._indicesForCamera[i]}}_enable(e){const t=p.S0.MakeArray(e||this._cameras);if(t)for(let e=0;e{s.detachPostProcess(e)}))}}getPostProcesses(e){return this._singleInstance?this._postProcesses[0]:e?this._postProcesses[e.name]:null}}var k=s(4255),V=s(3720);class G extends k.${_gatherImports(e,t){e?(this._webGPUReady=!0,t.push(s.e(126).then(s.bind(s,2217)))):t.push(s.e(71).then(s.bind(s,7694)))}constructor(e,t=null,s){super({...s,name:e,engine:t||V.N.LastCreatedEngine,useShaderStore:!0,useAsPostProcess:!0,fragmentShader:G.FragmentUrl,uniforms:G.Uniforms,samplers:G.Samplers,defines:s?.depthNotNormalized?G.DefinesDepthNotNormalized:void 0}),this.lensSize=50,this.fStop=1.4,this.focusDistance=2e3,this.focalLength=50}bind(){super.bind();const e=this.options,t=this._drawWrapper.effect;e.depthNotNormalized||t.setFloat2("cameraMinMaxZ",this.camera.minZ,this.camera.maxZ-this.camera.minZ);const s=this.lensSize/this.fStop*this.focalLength/(this.focusDistance-this.focalLength);t.setFloat("focusDistance",this.focusDistance),t.setFloat("cocPrecalculation",s)}}G.FragmentUrl="circleOfConfusion",G.Uniforms=["cameraMinMaxZ","focusDistance","cocPrecalculation"],G.Samplers=["depthSampler"],G.DefinesDepthNotNormalized="#define COC_DEPTH_NOT_NORMALIZED";class z extends I.w{get lensSize(){return this._effectWrapper.lensSize}set lensSize(e){this._effectWrapper.lensSize=e}get fStop(){return this._effectWrapper.fStop}set fStop(e){this._effectWrapper.fStop=e}get focusDistance(){return this._effectWrapper.focusDistance}set focusDistance(e){this._effectWrapper.focusDistance=e}get focalLength(){return this._effectWrapper.focalLength}set focalLength(e){this._effectWrapper.focalLength=e}getClassName(){return"CircleOfConfusionPostProcess"}constructor(e,t,s,i,r,n,a,h=0,l=!1){const c={uniforms:G.Uniforms,samplers:G.Samplers,defines:"object"==typeof s&&s.depthNotNormalized?G.DefinesDepthNotNormalized:void 0,size:"number"==typeof s?s:void 0,camera:i,samplingMode:r,engine:n,reusable:a,textureType:h,blockCompilation:l,...s};super(e,G.FragmentUrl,{effectWrapper:"number"!=typeof s&&s.effectWrapper?void 0:new G(e,n,c),...c}),this._depthTexture=null,this._depthTexture=t,this.onApplyObservable.add((e=>{this._depthTexture?(e.setTexture("depthSampler",this._depthTexture),this._effectWrapper.camera=this._depthTexture.activeCamera):o.V.Warn("No depth texture set on CircleOfConfusionPostProcess")}))}set depthTexture(e){this._depthTexture=e}}(0,i.Cg)([(0,r.lK)()],z.prototype,"lensSize",null),(0,i.Cg)([(0,r.lK)()],z.prototype,"fStop",null),(0,i.Cg)([(0,r.lK)()],z.prototype,"focusDistance",null),(0,i.Cg)([(0,r.lK)()],z.prototype,"focalLength",null),(0,y.Y5)("BABYLON.CircleOfConfusionPostProcess",z);class W extends f.j{getClassName(){return"DepthOfFieldBlurPostProcess"}constructor(e,t,s,i,r,n,a,o=null,l=h.g.BILINEAR_SAMPLINGMODE,c,u,d=0,_=!1,f=5){super(e,s,i,{camera:n,engine:c,reusable:u,textureType:d,defines:"#define DOF 1\n",blockCompilation:_,textureFormat:f,...r,samplingMode:2}),this.externalTextureSamplerBinding=!!o,this.onApplyObservable.add((e=>{null!=o&&e.setTextureFromPostProcess("textureSampler",o),e.setTextureFromPostProcessOutput("circleOfConfusionSampler",a)}))}}(0,y.Y5)("BABYLON.DepthOfFieldBlurPostProcess",W);class H extends k.${_gatherImports(e,t){e?(this._webGPUReady=!0,t.push(s.e(126).then(s.bind(s,9480)))):t.push(s.e(71).then(s.bind(s,9411)))}constructor(e,t=null,s){super({...s,name:e,engine:t||V.N.LastCreatedEngine,useShaderStore:!0,useAsPostProcess:!0,fragmentShader:H.FragmentUrl,samplers:H.Samplers})}}H.FragmentUrl="depthOfFieldMerge",H.Samplers=["circleOfConfusionSampler","blurStep0","blurStep1","blurStep2"];class K extends I.w{getClassName(){return"DepthOfFieldMergePostProcess"}constructor(e,t,s,i,r,n,a,o,h,l=0,c=!1){const u="number"==typeof r?c:!!r.blockCompilation,d={samplers:H.Samplers,size:"number"==typeof r?r:void 0,camera:n,samplingMode:a,engine:o,reusable:h,textureType:l,...r,blockCompilation:!0};super(e,H.FragmentUrl,{effectWrapper:"number"!=typeof r&&r.effectWrapper?void 0:new H(e,o,d),...d}),this._blurSteps=i,this.externalTextureSamplerBinding=!0,this.onApplyObservable.add((e=>{e.setTextureFromPostProcess("textureSampler",t),e.setTextureFromPostProcessOutput("circleOfConfusionSampler",s),i.forEach(((t,s)=>{e.setTextureFromPostProcessOutput("blurStep"+(i.length-s-1),t)}))})),u||this.updateEffect()}updateEffect(e=null,t=null,s=null,i,r,n){e||(e="",e+="#define BLUR_LEVEL "+(this._blurSteps.length-1)+"\n"),super.updateEffect(e,t,s,i,r,n)}}var q,X,Y=s(2309);!function(e){e[e.Low=0]="Low",e[e.Medium=1]="Medium",e[e.High=2]="High"}(q||(q={}));class j{set focalLength(e){this._circleOfConfusion.focalLength=e}get focalLength(){return this._circleOfConfusion.focalLength}set fStop(e){this._circleOfConfusion.fStop=e}get fStop(){return this._circleOfConfusion.fStop}set focusDistance(e){this._circleOfConfusion.focusDistance=e}get focusDistance(){return this._circleOfConfusion.focusDistance}set lensSize(e){this._circleOfConfusion.lensSize=e}get lensSize(){return this._circleOfConfusion.lensSize}constructor(e,t,s=0,i=!1,r=!1){this._depthOfFieldBlurX=[],this._depthOfFieldBlurY=[],this._circleOfConfusion=new G(e,t,{depthNotNormalized:i,blockCompilation:r}),this.blurLevel=s;let n=1,a=15;switch(s){case 2:n=3,a=51;break;case 1:n=2,a=31;break;default:a=15,n=1}const o=a/Math.pow(2,n-1);let h=1;for(let s=0;sthis._effects),!0),this._effects=[],this._thinDepthOfFieldEffect=new j("Depth of Field",a,s,!1,r);const o=a.isWebGPU||a.version>1?6:5;this._circleOfConfusion=new z("circleOfConfusion",t,{size:1,samplingMode:h.g.BILINEAR_SAMPLINGMODE,engine:a,textureType:i,blockCompilation:r,depthNotNormalized:n,effectWrapper:this._thinDepthOfFieldEffect._circleOfConfusion},null),this._depthOfFieldBlurY=[],this._depthOfFieldBlurX=[];const l=this._thinDepthOfFieldEffect._depthOfFieldBlurX.length;for(let e=0;e{this.externalTextureSamplerBinding=!!this._inputPostProcess,this._inputPostProcess&&e.setTextureFromPostProcess("textureSampler",this._inputPostProcess)}))}}(0,i.Cg)([(0,r.lK)()],J.prototype,"threshold",null),(0,y.Y5)("BABYLON.ExtractHighlightsPostProcess",J);class ee extends k.${_gatherImports(e,t){e?(this._webGPUReady=!0,t.push(s.e(126).then(s.bind(s,6645)))):t.push(s.e(71).then(s.bind(s,9336)))}constructor(e,t=null,s){super({...s,name:e,engine:t||V.N.LastCreatedEngine,useShaderStore:!0,useAsPostProcess:!0,fragmentShader:ee.FragmentUrl,uniforms:ee.Uniforms,samplers:ee.Samplers}),this.weight=1}bind(){super.bind(),this._drawWrapper.effect.setFloat("bloomWeight",this.weight)}}ee.FragmentUrl="bloomMerge",ee.Uniforms=["bloomWeight"],ee.Samplers=["bloomBlur"];class te extends I.w{get weight(){return this._effectWrapper.weight}set weight(e){this._effectWrapper.weight=e}getClassName(){return"BloomMergePostProcess"}constructor(e,t,s,i,r,n=null,a,o,h,l=0,c=!1){const u="number"==typeof r?c:!!r.blockCompilation,d={uniforms:ee.Uniforms,samplers:ee.Samplers,size:"number"==typeof r?r:void 0,camera:n,samplingMode:a,engine:o,reusable:h,textureType:l,...r,blockCompilation:!0};super(e,ee.FragmentUrl,{effectWrapper:"number"!=typeof r&&r.effectWrapper?void 0:new ee(e,o,d),...d}),this.weight=i,this.externalTextureSamplerBinding=!0,this.onApplyObservable.add((e=>{e.setTextureFromPostProcess("textureSampler",t),e.setTextureFromPostProcessOutput("bloomBlur",s)})),u||this.updateEffect()}}(0,i.Cg)([(0,r.lK)()],te.prototype,"weight",null),(0,y.Y5)("BABYLON.BloomMergePostProcess",te);class se{get threshold(){return this._downscale.threshold}set threshold(e){this._downscale.threshold=e}get weight(){return this._merge.weight}set weight(e){this._merge.weight=e}get kernel(){return this._blurX.kernel/this.scale}set kernel(e){this._blurX.kernel=e*this.scale,this._blurY.kernel=e*this.scale}constructor(e,t,s,i=!1){this.scale=s,this._downscale=new $(e+"_downscale",t,{blockCompilation:i}),this._blurX=new Y.q(e+"_blurX",t,new c.I9(1,0),10,{blockCompilation:i}),this._blurY=new Y.q(e+"_blurY",t,new c.I9(0,1),10,{blockCompilation:i}),this._merge=new ee(e+"_merge",t,{blockCompilation:i})}isReady(){return this._downscale.isReady()&&this._blurX.isReady()&&this._blurY.isReady()&&this._merge.isReady()}}class ie extends U{get threshold(){return this._thinBloomEffect.threshold}set threshold(e){this._thinBloomEffect.threshold=e}get weight(){return this._thinBloomEffect.weight}set weight(e){this._thinBloomEffect.weight=e}get kernel(){return this._thinBloomEffect.kernel}set kernel(e){this._thinBloomEffect.kernel=e}get bloomScale(){return this._thinBloomEffect.scale}constructor(e,t,s,i,r=0,n=!1){const a=e._renderForCamera?e.getEngine():e;super(a,"bloom",(()=>this._effects),!0),this._effects=[],this._thinBloomEffect=new se("bloom",a,t,n),this._downscale=new J("highlights",{size:1,samplingMode:h.g.BILINEAR_SAMPLINGMODE,engine:a,textureType:r,blockCompilation:n,effectWrapper:this._thinBloomEffect._downscale}),this._blurX=new f.j("horizontal blur",this._thinBloomEffect._blurX.direction,this._thinBloomEffect._blurX.kernel,{size:t,samplingMode:h.g.BILINEAR_SAMPLINGMODE,engine:a,textureType:r,blockCompilation:n,effectWrapper:this._thinBloomEffect._blurX}),this._blurX.alwaysForcePOT=!0,this._blurX.autoClear=!1,this._blurY=new f.j("vertical blur",this._thinBloomEffect._blurY.direction,this._thinBloomEffect._blurY.kernel,{size:t,samplingMode:h.g.BILINEAR_SAMPLINGMODE,engine:a,textureType:r,blockCompilation:n,effectWrapper:this._thinBloomEffect._blurY}),this._blurY.alwaysForcePOT=!0,this._blurY.autoClear=!1,this.kernel=i,this._effects=[this._downscale,this._blurX,this._blurY],this._merge=new te("bloomMerge",this._downscale,this._blurY,s,{size:t,samplingMode:h.g.BILINEAR_SAMPLINGMODE,engine:a,textureType:r,blockCompilation:n,effectWrapper:this._thinBloomEffect._merge}),this._merge.autoClear=!1,this._effects.push(this._merge)}disposeEffects(e){for(let t=0;tthis.sharpen),!0),this.depthOfField=new Z(this._scene,null,this._depthOfFieldBlurLevel,this._defaultPipelineTextureType,!0),this._hardwareScaleLevel=o.getHardwareScalingLevel(),this._resizeObserver=o.onResizeObservable.add((()=>{this._hardwareScaleLevel=o.getHardwareScalingLevel(),this.bloomKernel=this._bloomKernel})),this.bloom=new ie(this._scene,this._bloomScale,this._bloomWeight,this.bloomKernel/this._hardwareScaleLevel,this._defaultPipelineTextureType,!0),this.chromaticAberration=new w("ChromaticAberration",o.getRenderWidth(),o.getRenderHeight(),1,null,h.g.BILINEAR_SAMPLINGMODE,o,!1,this._defaultPipelineTextureType,!0),this._chromaticAberrationEffect=new U(o,this.ChromaticAberrationPostProcessId,(()=>this.chromaticAberration),!0),this.grain=new L("Grain",1,null,h.g.BILINEAR_SAMPLINGMODE,o,!1,this._defaultPipelineTextureType,!0),this._grainEffect=new U(o,this.GrainPostProcessId,(()=>this.grain),!0);let l=!0;this._imageProcessingConfigurationObserver=this._scene.imageProcessingConfiguration.onUpdateParameters.add((()=>{this.bloom._downscale._exposure=this._scene.imageProcessingConfiguration.exposure,this.imageProcessingEnabled!==this._scene.imageProcessingConfiguration.isEnabled&&(this._imageProcessingEnabled=this._scene.imageProcessingConfiguration.isEnabled,l?p.S0.SetImmediate((()=>{this._buildPipeline()})):this._buildPipeline())})),this._buildPipeline(),l=!1}getClassName(){return"DefaultRenderingPipeline"}prepare(){const e=this._buildAllowed;this._buildAllowed=!0,this._buildPipeline(),this._buildAllowed=e}_setAutoClearAndTextureSharing(e,t=!1){this._hasCleared?e.autoClear=!1:(e.autoClear=!0,this._scene.autoClear=!1,this._hasCleared=!0),t||(this._prevPrevPostProcess?e.shareOutputWith(this._prevPrevPostProcess):e.useOwnOutput(),this._prevPostProcess&&(this._prevPrevPostProcess=this._prevPostProcess),this._prevPostProcess=e)}_buildPipeline(){if(!this._buildAllowed)return;this._scene.autoClear=!0;const e=this._scene.getEngine();if(this._disposePostProcesses(),null!==this._cameras&&(this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._cameras),this._cameras=this._camerasToBeAttached.slice()),this._reset(),this._prevPostProcess=null,this._prevPrevPostProcess=null,this._hasCleared=!1,this.depthOfFieldEnabled){if(this._cameras.length>1){for(const e of this._cameras)this._scene.enableDepthRenderer(e).useOnlyInActiveCamera=!0;this._depthOfFieldSceneObserver=this._scene.onAfterRenderTargetsRenderObservable.add((e=>{this._cameras.indexOf(e.activeCamera)>-1&&(this.depthOfField.depthTexture=e.enableDepthRenderer(e.activeCamera).getDepthMap())}))}else{this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);const e=this._scene.enableDepthRenderer(this._cameras[0]);this.depthOfField.depthTexture=e.getDepthMap()}this.depthOfField._isReady()||this.depthOfField._updateEffects(),this.addEffect(this.depthOfField),this._setAutoClearAndTextureSharing(this.depthOfField._effects[0],!0)}else this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);this.bloomEnabled&&(this.bloom._isReady()||this.bloom._updateEffects(),this.addEffect(this.bloom),this._setAutoClearAndTextureSharing(this.bloom._effects[0],!0)),this._imageProcessingEnabled&&(this.imageProcessing=new F("imageProcessing",1,null,h.g.BILINEAR_SAMPLINGMODE,e,!1,this._defaultPipelineTextureType,this.scene.imageProcessingConfiguration),this._hdr?(this.addEffect(new U(e,this.ImageProcessingPostProcessId,(()=>this.imageProcessing),!0)),this._setAutoClearAndTextureSharing(this.imageProcessing)):this._scene.imageProcessingConfiguration.applyByPostProcess=!1,this._cameras&&0!==this._cameras.length||(this._scene.imageProcessingConfiguration.applyByPostProcess=!1),this.imageProcessing.getEffect()||this.imageProcessing._updateParameters()),this.sharpenEnabled&&(this.sharpen.isReady()||this.sharpen.updateEffect(),this.addEffect(this._sharpenEffect),this._setAutoClearAndTextureSharing(this.sharpen)),this.grainEnabled&&(this.grain.isReady()||this.grain.updateEffect(),this.addEffect(this._grainEffect),this._setAutoClearAndTextureSharing(this.grain)),this.chromaticAberrationEnabled&&(this.chromaticAberration.isReady()||this.chromaticAberration.updateEffect(),this.addEffect(this._chromaticAberrationEffect),this._setAutoClearAndTextureSharing(this.chromaticAberration)),this.fxaaEnabled&&(this.fxaa=new B("fxaa",1,null,h.g.BILINEAR_SAMPLINGMODE,e,!1,this._defaultPipelineTextureType),this.addEffect(new U(e,this.FxaaPostProcessId,(()=>this.fxaa),!0)),this._setAutoClearAndTextureSharing(this.fxaa,!0)),null!==this._cameras&&this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name,this._cameras),(this._scene.activeCameras&&this._scene.activeCameras.length>1||this._scene.activeCamera&&-1===this._cameras.indexOf(this._scene.activeCamera))&&(this._scene.autoClear=!0),this._activeCameraChangedObserver||(this._activeCameraChangedObserver=this._scene.onActiveCameraChanged.add((()=>{this._scene.activeCamera&&-1===this._cameras.indexOf(this._scene.activeCamera)&&(this._scene.autoClear=!0)}))),this._activeCamerasChangedObserver||(this._activeCamerasChangedObserver=this._scene.onActiveCamerasChanged.add((()=>{this._scene.activeCameras&&this._scene.activeCameras.length>1&&(this._scene.autoClear=!0)}))),this._adaptPostProcessesToViewPort(),!this._enableMSAAOnFirstPostProcess(this.samples)&&this.samples>1&&o.V.Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0"),this.onBuildObservable.notifyObservers(this)}_disposePostProcesses(e=!1){for(let t=0;tnew ae(e._name,e._name._hdr,t)),e,t,s)}}(0,i.Cg)([(0,r.lK)()],ae.prototype,"sharpenEnabled",null),(0,i.Cg)([(0,r.lK)()],ae.prototype,"bloomKernel",null),(0,i.Cg)([(0,r.lK)()],ae.prototype,"_bloomWeight",void 0),(0,i.Cg)([(0,r.lK)()],ae.prototype,"_bloomThreshold",void 0),(0,i.Cg)([(0,r.lK)()],ae.prototype,"_hdr",void 0),(0,i.Cg)([(0,r.lK)()],ae.prototype,"bloomWeight",null),(0,i.Cg)([(0,r.lK)()],ae.prototype,"bloomThreshold",null),(0,i.Cg)([(0,r.lK)()],ae.prototype,"bloomScale",null),(0,i.Cg)([(0,r.lK)()],ae.prototype,"bloomEnabled",null),(0,i.Cg)([(0,r.lK)()],ae.prototype,"depthOfFieldEnabled",null),(0,i.Cg)([(0,r.lK)()],ae.prototype,"depthOfFieldBlurLevel",null),(0,i.Cg)([(0,r.lK)()],ae.prototype,"fxaaEnabled",null),(0,i.Cg)([(0,r.lK)()],ae.prototype,"samples",null),(0,i.Cg)([(0,r.lK)()],ae.prototype,"imageProcessingEnabled",null),(0,i.Cg)([(0,r.lK)()],ae.prototype,"glowLayerEnabled",null),(0,i.Cg)([(0,r.lK)()],ae.prototype,"chromaticAberrationEnabled",null),(0,i.Cg)([(0,r.lK)()],ae.prototype,"grainEnabled",null),(0,y.Y5)("BABYLON.DefaultRenderingPipeline",ae)},6532:(e,t,s)=>{s.d(t,{j:()=>c});var i=s(5524),r=s(7891),n=s(2781),a=s(6552),o=s(9259),h=s(6877),l=s(2309);class c extends r.w{get direction(){return this._effectWrapper.direction}set direction(e){this._effectWrapper.direction=e}set kernel(e){this._effectWrapper.kernel=e}get kernel(){return this._effectWrapper.kernel}set packedFloat(e){this._effectWrapper.packedFloat=e}get packedFloat(){return this._effectWrapper.packedFloat}getClassName(){return"BlurPostProcess"}constructor(e,t,s,i,r=null,a=n.g.BILINEAR_SAMPLINGMODE,o,h,c=0,u="",d=!1,_=5){const f="number"==typeof i?d:!!i.blockCompilation,p={uniforms:l.q.Uniforms,samplers:l.q.Samplers,size:"number"==typeof i?i:void 0,camera:r,samplingMode:a,engine:o,reusable:h,textureType:c,vertexUrl:l.q.VertexUrl,indexParameters:{varyingCount:0,depCount:0},textureFormat:_,defines:u,...i,blockCompilation:!0};super(e,l.q.FragmentUrl,{effectWrapper:"number"!=typeof i&&i.effectWrapper?void 0:new l.q(e,o,void 0,void 0,p),...p}),this._effectWrapper.options.blockCompilation=f,this.direction=t,this.onApplyObservable.add((()=>{this._effectWrapper.textureWidth=this._outputTexture?this._outputTexture.width:this.width,this._effectWrapper.textureHeight=this._outputTexture?this._outputTexture.height:this.height})),this.kernel=s}updateEffect(e=null,t=null,s=null,i,r,n){this._effectWrapper._updateParameters(r,n)}static _Parse(e,t,s,i){return h.p.Parse((()=>new c(e.name,e.direction,e.kernel,e.options,t,e.renderTargetSamplingMode,s.getEngine(),e.reusable,e.textureType,void 0,!1)),e,s,i)}}(0,i.Cg)([(0,o.WM)()],c.prototype,"direction",null),(0,i.Cg)([(0,o.lK)()],c.prototype,"kernel",null),(0,i.Cg)([(0,o.lK)()],c.prototype,"packedFloat",null),(0,a.Y5)("BABYLON.BlurPostProcess",c)},7891:(e,t,s)=>{s.d(t,{w:()=>f});var i=s(5524),r=s(7931),n=s(9848),a=s(9923),o=s(4420),h=s(9259),l=s(6877),c=s(6552),u=s(6326),d=s(1597),_=s(4255);u.$.prototype.setTextureFromPostProcess=function(e,t,s){let i=null;t&&(t._forcedOutputTexture?i=t._forcedOutputTexture:t._textures.data[t._currentRenderTextureInd]&&(i=t._textures.data[t._currentRenderTextureInd])),this._bindTexture(e,i?.texture??null,s)},u.$.prototype.setTextureFromPostProcessOutput=function(e,t,s){this._bindTexture(e,t?._outputTexture?.texture??null,s)},o.M.prototype.setTextureFromPostProcess=function(e,t){this._engine.setTextureFromPostProcess(this._samplers[e],t,e)},o.M.prototype.setTextureFromPostProcessOutput=function(e,t){this._engine.setTextureFromPostProcessOutput(this._samplers[e],t,e)};class f{static get ForceGLSL(){return _.$.ForceGLSL}static set ForceGLSL(e){_.$.ForceGLSL=e}static RegisterShaderCodeProcessing(e,t){_.$.RegisterShaderCodeProcessing(e,t)}get name(){return this._effectWrapper.name}set name(e){this._effectWrapper.name=e}get alphaMode(){return this._effectWrapper.alphaMode}set alphaMode(e){this._effectWrapper.alphaMode=e}get samples(){return this._samples}set samples(e){this._samples=Math.min(e,this._engine.getCaps().maxMSAASamples),this._textures.forEach((e=>{e.setSamples(this._samples)}))}get shaderLanguage(){return this._shaderLanguage}getEffectName(){return this._fragmentUrl}set onActivate(e){this._onActivateObserver&&this.onActivateObservable.remove(this._onActivateObserver),e&&(this._onActivateObserver=this.onActivateObservable.add(e))}set onSizeChanged(e){this._onSizeChangedObserver&&this.onSizeChangedObservable.remove(this._onSizeChangedObserver),this._onSizeChangedObserver=this.onSizeChangedObservable.add(e)}set onApply(e){this._onApplyObserver&&this.onApplyObservable.remove(this._onApplyObserver),this._onApplyObserver=this.onApplyObservable.add(e)}set onBeforeRender(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e)}set onAfterRender(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=this.onAfterRenderObservable.add(e)}get inputTexture(){return this._textures.data[this._currentRenderTextureInd]}set inputTexture(e){this._forcedOutputTexture=e}restoreDefaultInputTexture(){this._forcedOutputTexture&&(this._forcedOutputTexture=null,this.markTextureDirty())}getCamera(){return this._camera}get texelSize(){return this._shareOutputWithPostProcess?this._shareOutputWithPostProcess.texelSize:(this._forcedOutputTexture&&this._texelSize.copyFromFloats(1/this._forcedOutputTexture.width,1/this._forcedOutputTexture.height),this._texelSize)}constructor(e,t,s,i,o,h,l=1,c,u,d=null,p=0,g="postprocess",m,T=!1,b=5,E,x){this._parentContainer=null,this.width=-1,this.height=-1,this.nodeMaterialSource=null,this._outputTexture=null,this.autoClear=!0,this.forceAutoClearInAlphaMode=!1,this.animations=[],this.enablePixelPerfectMode=!1,this.forceFullscreenViewport=!0,this.scaleMode=1,this.alwaysForcePOT=!1,this._samples=1,this.adaptScaleToCurrentViewport=!1,this._webGPUReady=!1,this._reusable=!1,this._renderId=0,this.externalTextureSamplerBinding=!1,this._textures=new r.L(2),this._textureCache=[],this._currentRenderTextureInd=0,this._scaleRatio=new a.I9(1,1),this._texelSize=a.I9.Zero(),this.onActivateObservable=new n.cP,this.onSizeChangedObservable=new n.cP,this.onApplyObservable=new n.cP,this.onBeforeRenderObservable=new n.cP,this.onAfterRenderObservable=new n.cP;let A,R=1,M=null;if(s&&!Array.isArray(s)){const e=s;s=e.uniforms??null,i=e.samplers??null,R=e.size??1,h=e.camera??null,l=e.samplingMode??1,c=e.engine,u=e.reusable,d=Array.isArray(e.defines)?e.defines.join("\n"):e.defines??null,p=e.textureType??0,g=e.vertexUrl??"postprocess",m=e.indexParameters,T=e.blockCompilation??!1,b=e.textureFormat??5,E=e.shaderLanguage??0,M=e.uniformBuffers??null,x=e.extraInitializations,A=e.effectWrapper}else o&&(R="number"==typeof o?o:{width:o.width,height:o.height});const y=!!A;if(this._effectWrapper=A??new _.$({name:e,useShaderStore:!0,useAsPostProcess:!0,fragmentShader:t,engine:c||h?.getScene().getEngine(),uniforms:s,samplers:i,uniformBuffers:M,defines:d,vertexUrl:g,indexParameters:m,blockCompilation:!0,shaderLanguage:E,extraInitializations:void 0}),this.name=e,this.onEffectCreatedObservable=this._effectWrapper.onEffectCreatedObservable,null!=h?(this._camera=h,this._scene=h.getScene(),h.attachPostProcess(this),this._engine=this._scene.getEngine(),this._scene.postProcesses.push(this),this.uniqueId=this._scene.getUniqueId()):c&&(this._engine=c,this._engine.postProcesses.push(this)),this._options=R,this.renderTargetSamplingMode=l||1,this._reusable=u||!1,this._textureType=p,this._textureFormat=b,this._shaderLanguage=E||0,this._samplers=i||[],-1===this._samplers.indexOf("textureSampler")&&this._samplers.push("textureSampler"),this._fragmentUrl=t,this._vertexUrl=g,this._parameters=s||[],-1===this._parameters.indexOf("scale")&&this._parameters.push("scale"),this._uniformBuffers=M||[],this._indexParameters=m,!y){this._webGPUReady=1===this._shaderLanguage;const e=[];this._gatherImports(this._engine.isWebGPU&&!f.ForceGLSL,e),this._effectWrapper._webGPUReady=this._webGPUReady,this._effectWrapper._postConstructor(T,d,x,e)}}_gatherImports(e=!1,t){e&&this._webGPUReady?t.push(Promise.all([s.e(126).then(s.bind(s,2083))])):t.push(Promise.all([Promise.resolve().then(s.bind(s,6612))]))}getClassName(){return"PostProcess"}getEngine(){return this._engine}getEffect(){return this._effectWrapper.drawWrapper.effect}shareOutputWith(e){return this._disposeTextures(),this._shareOutputWithPostProcess=e,this}useOwnOutput(){0==this._textures.length&&(this._textures=new r.L(2)),this._shareOutputWithPostProcess=null}updateEffect(e=null,t=null,s=null,i,r,n,a,o){this._effectWrapper.updateEffect(e,t,s,i,r,n,a,o),this._postProcessDefines=Array.isArray(this._effectWrapper.options.defines)?this._effectWrapper.options.defines.join("\n"):this._effectWrapper.options.defines}isReusable(){return this._reusable}markTextureDirty(){this.width=-1}_createRenderTargetTexture(e,t,s=0){for(let i=0;i=0;t--)if(e-this._textureCache[t].lastUsedRenderId>100){let e=!1;for(let s=0;s0&&this._textures.reset(),this.width=e,this.height=t;let n=null;if(s)for(let e=0;e{e.samples!==this.samples&&this._engine.updateRenderTargetTextureSampleCount(e,this.samples)})),this._flushTextureCache(),this._renderId++}return u||(u=this._getTarget()),this.enablePixelPerfectMode?(this._scaleRatio.copyFromFloats(a/h,o/l),this._engine.bindFramebuffer(u,0,a,o,this.forceFullscreenViewport)):(this._scaleRatio.copyFromFloats(1,1),this._engine.bindFramebuffer(u,0,void 0,void 0,this.forceFullscreenViewport)),this._engine._debugInsertMarker?.(`post process ${this.name} input`),this.onActivateObservable.notifyObservers(e),this.autoClear&&(0===this.alphaMode||this.forceAutoClearInAlphaMode)&&this._engine.clear(this.clearColor?this.clearColor:i.clearColor,i._allowPostProcessClearColor,!0,!0),this._reusable&&(this._currentRenderTextureInd=(this._currentRenderTextureInd+1)%2),u}get isSupported(){return this._effectWrapper.drawWrapper.effect.isSupported}get aspectRatio(){return this._shareOutputWithPostProcess?this._shareOutputWithPostProcess.aspectRatio:this._forcedOutputTexture?this._forcedOutputTexture.width/this._forcedOutputTexture.height:this.width/this.height}isReady(){return this._effectWrapper.isReady()}apply(){if(!this._effectWrapper.isReady())return null;let e;return this._engine.enableEffect(this._effectWrapper.drawWrapper),this._engine.setState(!1),this._engine.setDepthBuffer(!1),this._engine.setDepthWrite(!1),this.alphaConstants&&this.getEngine().setAlphaConstants(this.alphaConstants.r,this.alphaConstants.g,this.alphaConstants.b,this.alphaConstants.a),e=this._shareOutputWithPostProcess?this._shareOutputWithPostProcess.inputTexture:this._forcedOutputTexture?this._forcedOutputTexture:this.inputTexture,this.externalTextureSamplerBinding||this._effectWrapper.drawWrapper.effect._bindTexture("textureSampler",e?.texture),this._effectWrapper.drawWrapper.effect.setVector2("scale",this._scaleRatio),this.onApplyObservable.notifyObservers(this._effectWrapper.drawWrapper.effect),this._effectWrapper.bind(),this._effectWrapper.drawWrapper.effect}_disposeTextures(){this._shareOutputWithPostProcess||this._forcedOutputTexture?this._disposeTextureCache():(this._disposeTextureCache(),this._textures.dispose())}_disposeTextureCache(){for(let e=this._textureCache.length-1;e>=0;e--)this._textureCache[e].texture.dispose();this._textureCache.length=0}setPrePassRenderer(e){return!!this._prePassEffectConfiguration&&(this._prePassEffectConfiguration=e.addEffectConfiguration(this._prePassEffectConfiguration),this._prePassEffectConfiguration.enabled=!0,!0)}dispose(e){let t;if(e=e||this._camera,this._disposeTextures(),this._scene&&(t=this._scene.postProcesses.indexOf(this),-1!==t&&this._scene.postProcesses.splice(t,1)),this._parentContainer){const e=this._parentContainer.postProcesses.indexOf(this);e>-1&&this._parentContainer.postProcesses.splice(e,1),this._parentContainer=null}if(t=this._engine.postProcesses.indexOf(this),-1!==t&&this._engine.postProcesses.splice(t,1),e){if(e.detachPostProcess(this),t=e._postProcesses.indexOf(this),0===t&&e._postProcesses.length>0){const e=this._camera._getFirstPostProcess();e&&e.markTextureDirty()}this.onActivateObservable.clear(),this.onAfterRenderObservable.clear(),this.onApplyObservable.clear(),this.onBeforeRenderObservable.clear(),this.onSizeChangedObservable.clear(),this.onEffectCreatedObservable.clear()}}serialize(){const e=l.p.Serialize(this),t=this.getCamera()||this._scene&&this._scene.activeCamera;return e.customType="BABYLON."+this.getClassName(),e.cameraId=t?t.id:null,e.reusable=this._reusable,e.textureType=this._textureType,e.fragmentUrl=this._fragmentUrl,e.parameters=this._parameters,e.samplers=this._samplers,e.uniformBuffers=this._uniformBuffers,e.options=this._options,e.defines=this._postProcessDefines,e.textureFormat=this._textureFormat,e.vertexUrl=this._vertexUrl,e.indexParameters=this._indexParameters,e}clone(){const e=this.serialize();e._engine=this._engine,e.cameraId=null;const t=f.Parse(e,this._scene,"");return t?(t.onActivateObservable=this.onActivateObservable.clone(),t.onSizeChangedObservable=this.onSizeChangedObservable.clone(),t.onApplyObservable=this.onApplyObservable.clone(),t.onBeforeRenderObservable=this.onBeforeRenderObservable.clone(),t.onAfterRenderObservable=this.onAfterRenderObservable.clone(),t._prePassEffectConfiguration=this._prePassEffectConfiguration,t):null}static Parse(e,t,s){const i=(0,c.n9)(e.customType);if(!i||!i._Parse)return null;const r=t?t.getCameraById(e.cameraId):null;return i._Parse(e,r,t,s)}static _Parse(e,t,s,i){return l.p.Parse((()=>new f(e.name,e.fragmentUrl,e.parameters,e.samplers,e.options,t,e.renderTargetSamplingMode,e._engine,e.reusable,e.defines,e.textureType,e.vertexUrl,e.indexParameters,!1,e.textureFormat)),e,s,i)}}(0,i.Cg)([(0,h.lK)()],f.prototype,"uniqueId",void 0),(0,i.Cg)([(0,h.lK)()],f.prototype,"name",null),(0,i.Cg)([(0,h.lK)()],f.prototype,"width",void 0),(0,i.Cg)([(0,h.lK)()],f.prototype,"height",void 0),(0,i.Cg)([(0,h.lK)()],f.prototype,"renderTargetSamplingMode",void 0),(0,i.Cg)([(0,h.qK)()],f.prototype,"clearColor",void 0),(0,i.Cg)([(0,h.lK)()],f.prototype,"autoClear",void 0),(0,i.Cg)([(0,h.lK)()],f.prototype,"forceAutoClearInAlphaMode",void 0),(0,i.Cg)([(0,h.lK)()],f.prototype,"alphaMode",null),(0,i.Cg)([(0,h.lK)()],f.prototype,"alphaConstants",void 0),(0,i.Cg)([(0,h.lK)()],f.prototype,"enablePixelPerfectMode",void 0),(0,i.Cg)([(0,h.lK)()],f.prototype,"forceFullscreenViewport",void 0),(0,i.Cg)([(0,h.lK)()],f.prototype,"scaleMode",void 0),(0,i.Cg)([(0,h.lK)()],f.prototype,"alwaysForcePOT",void 0),(0,i.Cg)([(0,h.lK)("samples")],f.prototype,"_samples",void 0),(0,i.Cg)([(0,h.lK)()],f.prototype,"adaptScaleToCurrentViewport",void 0),(0,c.Y5)("BABYLON.PostProcess",f)},6096:(e,t,s)=>{s.d(t,{X:()=>n});var i=s(5616),r=s(9848);class n{constructor(e){this._vertexBuffers={},this.onBeforeRenderObservable=new r.cP,this._scene=e}_prepareBuffers(){if(this._vertexBuffers[i.R.PositionKind])return;const e=[];e.push(1,1),e.push(-1,1),e.push(-1,-1),e.push(1,-1),this._vertexBuffers[i.R.PositionKind]=new i.R(this._scene.getEngine(),e,i.R.PositionKind,!1,!1,2),this._buildIndexBuffer()}_buildIndexBuffer(){const e=[];e.push(0),e.push(1),e.push(2),e.push(0),e.push(2),e.push(3),this._indexBuffer=this._scene.getEngine().createIndexBuffer(e)}_rebuild(){const e=this._vertexBuffers[i.R.PositionKind];e&&(e._rebuild(),this._buildIndexBuffer())}_prepareFrame(e=null,t=null){const s=this._scene.activeCamera;return!(!s||!(t=t||s._postProcesses.filter((e=>null!=e)))||0===t.length||!this._scene.postProcessesEnabled||(t[0].activate(s,e,null!=t),0))}directRender(e,t=null,s=!1,i=0,r=0,n=!1){const a=this._scene.getEngine();for(let o=0;onull!=e))).length||!this._scene.postProcessesEnabled)return;const a=this._scene.getEngine();for(let o=0,h=i.length;o{s.d(t,{q:()=>n});var i=s(4255),r=s(3720);class n extends i.${_gatherImports(e,t){e?(this._webGPUReady=!0,t.push(Promise.all([s.e(126).then(s.bind(s,2850)),s.e(126).then(s.bind(s,5417))]))):t.push(Promise.all([s.e(71).then(s.bind(s,4509)),s.e(71).then(s.bind(s,3802))]))}constructor(e,t=null,s,i,a){const o=!!a?.blockCompilation;super({...a,name:e,engine:t||r.N.LastCreatedEngine,useShaderStore:!0,useAsPostProcess:!0,fragmentShader:n.FragmentUrl,uniforms:n.Uniforms,samplers:n.Samplers,vertexUrl:n.VertexUrl,blockCompilation:!0}),this._packedFloat=!1,this._staticDefines="",this.textureWidth=0,this.textureHeight=0,this.options.blockCompilation=o,void 0!==s&&(this.direction=s),void 0!==i&&(this.kernel=i)}set kernel(e){this._idealKernel!==e&&(e=Math.max(e,1),this._idealKernel=e,this._kernel=this._nearestBestKernel(e),this.options.blockCompilation||this._updateParameters())}get kernel(){return this._idealKernel}set packedFloat(e){this._packedFloat!==e&&(this._packedFloat=e,this.options.blockCompilation||this._updateParameters())}get packedFloat(){return this._packedFloat}bind(){super.bind(),this._drawWrapper.effect.setFloat2("delta",1/this.textureWidth*this.direction.x,1/this.textureHeight*this.direction.y)}_updateParameters(e,t){const s=this._kernel,i=(s-1)/2;let r=[],n=[],a=0;for(let e=0;e0)return Math.max(e,3);return Math.max(t,3)}_gaussianWeight(e){const t=1/3,s=-e*e/(2*t*t);return 1/(Math.sqrt(2*Math.PI)*t)*Math.exp(s)}_glslFloat(e,t=8){return e.toFixed(t).replace(/0+$/,"")}}n.VertexUrl="kernelBlur",n.FragmentUrl="kernelBlur",n.Uniforms=["delta","direction"],n.Samplers=["circleOfConfusionSampler"]},3099:(e,t,s)=>{s.d(t,{m:()=>o});var i=s(7931),r=s(9923);class n{set opaqueSortCompareFn(e){this._opaqueSortCompareFn=e||n.PainterSortCompare,this._renderOpaque=this._renderOpaqueSorted}set alphaTestSortCompareFn(e){this._alphaTestSortCompareFn=e||n.PainterSortCompare,this._renderAlphaTest=this._renderAlphaTestSorted}set transparentSortCompareFn(e){this._transparentSortCompareFn=e||n.defaultTransparentSortCompare,this._renderTransparent=this._renderTransparentSorted}constructor(e,t,s=null,r=null,n=null){this.index=e,this._opaqueSubMeshes=new i.L(256),this._transparentSubMeshes=new i.L(256),this._alphaTestSubMeshes=new i.L(256),this._depthOnlySubMeshes=new i.L(256),this._particleSystems=new i.L(256),this._spriteManagers=new i.L(256),this._empty=!0,this._edgesRenderers=new i.b(16),this._scene=t,this.opaqueSortCompareFn=s,this.alphaTestSortCompareFn=r,this.transparentSortCompareFn=n}render(e,t,s,i){if(e)return void e(this._opaqueSubMeshes,this._alphaTestSubMeshes,this._transparentSubMeshes,this._depthOnlySubMeshes);const r=this._scene.getEngine();0!==this._depthOnlySubMeshes.length&&(r.setColorWrite(!1),this._renderAlphaTest(this._depthOnlySubMeshes),r.setColorWrite(!0)),0!==this._opaqueSubMeshes.length&&this._renderOpaque(this._opaqueSubMeshes),0!==this._alphaTestSubMeshes.length&&this._renderAlphaTest(this._alphaTestSubMeshes);const n=r.getStencilBuffer();if(r.setStencilBuffer(!1),t&&this._renderSprites(),s&&this._renderParticles(i),this.onBeforeTransparentRendering&&this.onBeforeTransparentRendering(),0!==this._transparentSubMeshes.length||this._scene.useOrderIndependentTransparency){if(r.setStencilBuffer(n),this._scene.useOrderIndependentTransparency){const e=this._scene.depthPeelingRenderer.render(this._transparentSubMeshes);e.length&&this._renderTransparent(e)}else this._renderTransparent(this._transparentSubMeshes);r.setAlphaMode(0)}if(r.setStencilBuffer(!1),this._edgesRenderers.length){for(let e=0;et._alphaIndex?1:e._alphaIndext._distanceToCamera?-1:0}static frontToBackSortCompare(e,t){return e._distanceToCamerat._distanceToCamera?1:0}static PainterSortCompare(e,t){const s=e.getMesh(),i=t.getMesh();return s.material&&i.material?s.material.uniqueId-i.material.uniqueId:s.uniqueId-i.uniqueId}prepare(){this._opaqueSubMeshes.reset(),this._transparentSubMeshes.reset(),this._alphaTestSubMeshes.reset(),this._depthOnlySubMeshes.reset(),this._particleSystems.reset(),this.prepareSprites(),this._edgesRenderers.reset(),this._empty=!0}prepareSprites(){this._spriteManagers.reset()}dispose(){this._opaqueSubMeshes.dispose(),this._transparentSubMeshes.dispose(),this._alphaTestSubMeshes.dispose(),this._depthOnlySubMeshes.dispose(),this._particleSystems.dispose(),this._spriteManagers.dispose(),this._edgesRenderers.dispose()}dispatch(e,t,s){void 0===t&&(t=e.getMesh()),void 0===s&&(s=e.getMaterial()),null!=s&&(s.needAlphaBlendingForMesh(t)?this._transparentSubMeshes.push(e):s.needAlphaTesting()?(s.needDepthPrePass&&this._depthOnlySubMeshes.push(e),this._alphaTestSubMeshes.push(e)):(s.needDepthPrePass&&this._depthOnlySubMeshes.push(e),this._opaqueSubMeshes.push(e)),t._renderingGroup=this,t._edgesRenderer&&t.isEnabled()&&t.isVisible&&t._edgesRenderer.isEnabled&&this._edgesRenderers.pushNoDuplicate(t._edgesRenderer),this._empty=!1)}dispatchSprites(e){this._spriteManagers.push(e),this._empty=!1}dispatchParticles(e){this._particleSystems.push(e),this._empty=!1}_renderParticles(e){if(0===this._particleSystems.length)return;const t=this._scene.activeCamera;this._scene.onBeforeParticlesRenderingObservable.notifyObservers(this._scene);for(let s=0;s{s(9610).l.IncludesShadersStore.bakedVertexAnimation="#ifdef BAKED_VERTEX_ANIMATION_TEXTURE\n{\n#ifdef INSTANCES\n#define BVASNAME bakedVertexAnimationSettingsInstanced\n#else\n#define BVASNAME bakedVertexAnimationSettings\n#endif\nfloat VATStartFrame=BVASNAME.x;float VATEndFrame=BVASNAME.y;float VATOffsetFrame=BVASNAME.z;float VATSpeed=BVASNAME.w;float totalFrames=VATEndFrame-VATStartFrame+1.0;float time=bakedVertexAnimationTime*VATSpeed/totalFrames;float frameCorrection=time<1.0 ? 0.0 : 1.0;float numOfFrames=totalFrames-frameCorrection;float VATFrameNum=fract(time)*numOfFrames;VATFrameNum=mod(VATFrameNum+VATOffsetFrame,numOfFrames);VATFrameNum=floor(VATFrameNum);VATFrameNum+=VATStartFrame+frameCorrection;mat4 VATInfluence;VATInfluence=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[0],VATFrameNum)*matricesWeights[0];\n#if NUM_BONE_INFLUENCERS>1\nVATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[1],VATFrameNum)*matricesWeights[1];\n#endif\n#if NUM_BONE_INFLUENCERS>2\nVATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[2],VATFrameNum)*matricesWeights[2];\n#endif\n#if NUM_BONE_INFLUENCERS>3\nVATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[3],VATFrameNum)*matricesWeights[3];\n#endif\n#if NUM_BONE_INFLUENCERS>4\nVATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[0],VATFrameNum)*matricesWeightsExtra[0];\n#endif\n#if NUM_BONE_INFLUENCERS>5\nVATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[1],VATFrameNum)*matricesWeightsExtra[1];\n#endif\n#if NUM_BONE_INFLUENCERS>6\nVATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[2],VATFrameNum)*matricesWeightsExtra[2];\n#endif\n#if NUM_BONE_INFLUENCERS>7\nVATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[3],VATFrameNum)*matricesWeightsExtra[3];\n#endif\nfinalWorld=finalWorld*VATInfluence;}\n#endif\n"},8959:(e,t,s)=>{s(9610).l.IncludesShadersStore.bakedVertexAnimationDeclaration="#ifdef BAKED_VERTEX_ANIMATION_TEXTURE\nuniform float bakedVertexAnimationTime;uniform vec2 bakedVertexAnimationTextureSizeInverted;uniform vec4 bakedVertexAnimationSettings;uniform sampler2D bakedVertexAnimationTexture;\n#ifdef INSTANCES\nattribute vec4 bakedVertexAnimationSettingsInstanced;\n#endif\n#define inline\nmat4 readMatrixFromRawSamplerVAT(sampler2D smp,float index,float frame)\n{float offset=index*4.0;float frameUV=(frame+0.5)*bakedVertexAnimationTextureSizeInverted.y;float dx=bakedVertexAnimationTextureSizeInverted.x;vec4 m0=texture2D(smp,vec2(dx*(offset+0.5),frameUV));vec4 m1=texture2D(smp,vec2(dx*(offset+1.5),frameUV));vec4 m2=texture2D(smp,vec2(dx*(offset+2.5),frameUV));vec4 m3=texture2D(smp,vec2(dx*(offset+3.5),frameUV));return mat4(m0,m1,m2,m3);}\n#endif\n"},9707:(e,t,s)=>{s(9610).l.IncludesShadersStore.bonesDeclaration="#if NUM_BONE_INFLUENCERS>0\nattribute vec4 matricesIndices;attribute vec4 matricesWeights;\n#if NUM_BONE_INFLUENCERS>4\nattribute vec4 matricesIndicesExtra;attribute vec4 matricesWeightsExtra;\n#endif\n#ifndef BAKED_VERTEX_ANIMATION_TEXTURE\n#ifdef BONETEXTURE\nuniform highp sampler2D boneSampler;uniform float boneTextureWidth;\n#else\nuniform mat4 mBones[BonesPerMesh];\n#endif\n#ifdef BONES_VELOCITY_ENABLED\nuniform mat4 mPreviousBones[BonesPerMesh];\n#endif\n#ifdef BONETEXTURE\n#define inline\nmat4 readMatrixFromRawSampler(sampler2D smp,float index)\n{float offset=index *4.0;float dx=1.0/boneTextureWidth;vec4 m0=texture2D(smp,vec2(dx*(offset+0.5),0.));vec4 m1=texture2D(smp,vec2(dx*(offset+1.5),0.));vec4 m2=texture2D(smp,vec2(dx*(offset+2.5),0.));vec4 m3=texture2D(smp,vec2(dx*(offset+3.5),0.));return mat4(m0,m1,m2,m3);}\n#endif\n#endif\n#endif\n"},3361:(e,t,s)=>{s(9610).l.IncludesShadersStore.bonesVertex="#ifndef BAKED_VERTEX_ANIMATION_TEXTURE\n#if NUM_BONE_INFLUENCERS>0\nmat4 influence;\n#ifdef BONETEXTURE\ninfluence=readMatrixFromRawSampler(boneSampler,matricesIndices[0])*matricesWeights[0];\n#if NUM_BONE_INFLUENCERS>1\ninfluence+=readMatrixFromRawSampler(boneSampler,matricesIndices[1])*matricesWeights[1];\n#endif\n#if NUM_BONE_INFLUENCERS>2\ninfluence+=readMatrixFromRawSampler(boneSampler,matricesIndices[2])*matricesWeights[2];\n#endif\n#if NUM_BONE_INFLUENCERS>3\ninfluence+=readMatrixFromRawSampler(boneSampler,matricesIndices[3])*matricesWeights[3];\n#endif\n#if NUM_BONE_INFLUENCERS>4\ninfluence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[0])*matricesWeightsExtra[0];\n#endif\n#if NUM_BONE_INFLUENCERS>5\ninfluence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[1])*matricesWeightsExtra[1];\n#endif\n#if NUM_BONE_INFLUENCERS>6\ninfluence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[2])*matricesWeightsExtra[2];\n#endif\n#if NUM_BONE_INFLUENCERS>7\ninfluence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[3])*matricesWeightsExtra[3];\n#endif\n#else\ninfluence=mBones[int(matricesIndices[0])]*matricesWeights[0];\n#if NUM_BONE_INFLUENCERS>1\ninfluence+=mBones[int(matricesIndices[1])]*matricesWeights[1];\n#endif\n#if NUM_BONE_INFLUENCERS>2\ninfluence+=mBones[int(matricesIndices[2])]*matricesWeights[2];\n#endif\n#if NUM_BONE_INFLUENCERS>3\ninfluence+=mBones[int(matricesIndices[3])]*matricesWeights[3];\n#endif\n#if NUM_BONE_INFLUENCERS>4\ninfluence+=mBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];\n#endif\n#if NUM_BONE_INFLUENCERS>5\ninfluence+=mBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];\n#endif\n#if NUM_BONE_INFLUENCERS>6\ninfluence+=mBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];\n#endif\n#if NUM_BONE_INFLUENCERS>7\ninfluence+=mBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];\n#endif\n#endif\nfinalWorld=finalWorld*influence;\n#endif\n#endif\n"},7412:(e,t,s)=>{s(9610).l.IncludesShadersStore.clipPlaneFragment="#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6)\nif (false) {}\n#endif\n#ifdef CLIPPLANE\nelse if (fClipDistance>0.0)\n{discard;}\n#endif\n#ifdef CLIPPLANE2\nelse if (fClipDistance2>0.0)\n{discard;}\n#endif\n#ifdef CLIPPLANE3\nelse if (fClipDistance3>0.0)\n{discard;}\n#endif\n#ifdef CLIPPLANE4\nelse if (fClipDistance4>0.0)\n{discard;}\n#endif\n#ifdef CLIPPLANE5\nelse if (fClipDistance5>0.0)\n{discard;}\n#endif\n#ifdef CLIPPLANE6\nelse if (fClipDistance6>0.0)\n{discard;}\n#endif\n"},6194:(e,t,s)=>{s(9610).l.IncludesShadersStore.clipPlaneFragmentDeclaration="#ifdef CLIPPLANE\nvarying float fClipDistance;\n#endif\n#ifdef CLIPPLANE2\nvarying float fClipDistance2;\n#endif\n#ifdef CLIPPLANE3\nvarying float fClipDistance3;\n#endif\n#ifdef CLIPPLANE4\nvarying float fClipDistance4;\n#endif\n#ifdef CLIPPLANE5\nvarying float fClipDistance5;\n#endif\n#ifdef CLIPPLANE6\nvarying float fClipDistance6;\n#endif\n"},7314:(e,t,s)=>{s(9610).l.IncludesShadersStore.clipPlaneVertex="#ifdef CLIPPLANE\nfClipDistance=dot(worldPos,vClipPlane);\n#endif\n#ifdef CLIPPLANE2\nfClipDistance2=dot(worldPos,vClipPlane2);\n#endif\n#ifdef CLIPPLANE3\nfClipDistance3=dot(worldPos,vClipPlane3);\n#endif\n#ifdef CLIPPLANE4\nfClipDistance4=dot(worldPos,vClipPlane4);\n#endif\n#ifdef CLIPPLANE5\nfClipDistance5=dot(worldPos,vClipPlane5);\n#endif\n#ifdef CLIPPLANE6\nfClipDistance6=dot(worldPos,vClipPlane6);\n#endif\n"},1636:(e,t,s)=>{s(9610).l.IncludesShadersStore.clipPlaneVertexDeclaration="#ifdef CLIPPLANE\nuniform vec4 vClipPlane;varying float fClipDistance;\n#endif\n#ifdef CLIPPLANE2\nuniform vec4 vClipPlane2;varying float fClipDistance2;\n#endif\n#ifdef CLIPPLANE3\nuniform vec4 vClipPlane3;varying float fClipDistance3;\n#endif\n#ifdef CLIPPLANE4\nuniform vec4 vClipPlane4;varying float fClipDistance4;\n#endif\n#ifdef CLIPPLANE5\nuniform vec4 vClipPlane5;varying float fClipDistance5;\n#endif\n#ifdef CLIPPLANE6\nuniform vec4 vClipPlane6;varying float fClipDistance6;\n#endif\n"},1218:(e,t,s)=>{s(9610).l.IncludesShadersStore.instancesDeclaration="#ifdef INSTANCES\nattribute vec4 world0;attribute vec4 world1;attribute vec4 world2;attribute vec4 world3;\n#ifdef INSTANCESCOLOR\nattribute vec4 instanceColor;\n#endif\n#if defined(THIN_INSTANCES) && !defined(WORLD_UBO)\nuniform mat4 world;\n#endif\n#if defined(VELOCITY) || defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) || defined(VELOCITY_LINEAR)\nattribute vec4 previousWorld0;attribute vec4 previousWorld1;attribute vec4 previousWorld2;attribute vec4 previousWorld3;\n#ifdef THIN_INSTANCES\nuniform mat4 previousWorld;\n#endif\n#endif\n#else\n#if !defined(WORLD_UBO)\nuniform mat4 world;\n#endif\n#if defined(VELOCITY) || defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) || defined(VELOCITY_LINEAR)\nuniform mat4 previousWorld;\n#endif\n#endif\n"},3298:(e,t,s)=>{s(9610).l.IncludesShadersStore.instancesVertex="#ifdef INSTANCES\nmat4 finalWorld=mat4(world0,world1,world2,world3);\n#if defined(PREPASS_VELOCITY) || defined(VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) || defined(VELOCITY_LINEAR)\nmat4 finalPreviousWorld=mat4(previousWorld0,previousWorld1,\npreviousWorld2,previousWorld3);\n#endif\n#ifdef THIN_INSTANCES\nfinalWorld=world*finalWorld;\n#if defined(PREPASS_VELOCITY) || defined(VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) || defined(VELOCITY_LINEAR)\nfinalPreviousWorld=previousWorld*finalPreviousWorld;\n#endif\n#endif\n#else\nmat4 finalWorld=world;\n#if defined(PREPASS_VELOCITY) || defined(VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) || defined(VELOCITY_LINEAR)\nmat4 finalPreviousWorld=previousWorld;\n#endif\n#endif\n"},5060:(e,t,s)=>{s(9610).l.IncludesShadersStore.morphTargetsVertex="#ifdef MORPHTARGETS\n#ifdef MORPHTARGETS_TEXTURE\n#if {X}==0\nfor (int i=0; i=morphTargetCount) break;vertexID=float(gl_VertexID)*morphTargetTextureInfo.x;positionUpdated+=(readVector3FromRawSampler(i,vertexID)-position)*morphTargetInfluences[i];vertexID+=1.0;\n#ifdef MORPHTARGETS_NORMAL\nnormalUpdated+=(readVector3FromRawSampler(i,vertexID) -normal)*morphTargetInfluences[i];vertexID+=1.0;\n#endif\n#ifdef MORPHTARGETS_UV\nuvUpdated+=(readVector3FromRawSampler(i,vertexID).xy-uv)*morphTargetInfluences[i];vertexID+=1.0;\n#endif\n#ifdef MORPHTARGETS_TANGENT\ntangentUpdated.xyz+=(readVector3FromRawSampler(i,vertexID) -tangent.xyz)*morphTargetInfluences[i];\n#endif\n}\n#endif\n#else\npositionUpdated+=(position{X}-position)*morphTargetInfluences[{X}];\n#ifdef MORPHTARGETS_NORMAL\nnormalUpdated+=(normal{X}-normal)*morphTargetInfluences[{X}];\n#endif\n#ifdef MORPHTARGETS_TANGENT\ntangentUpdated.xyz+=(tangent{X}-tangent.xyz)*morphTargetInfluences[{X}];\n#endif\n#ifdef MORPHTARGETS_UV\nuvUpdated+=(uv_{X}-uv)*morphTargetInfluences[{X}];\n#endif\n#endif\n#endif\n"},738:(e,t,s)=>{s(9610).l.IncludesShadersStore.morphTargetsVertexDeclaration="#ifdef MORPHTARGETS\n#ifndef MORPHTARGETS_TEXTURE\nattribute vec3 position{X};\n#ifdef MORPHTARGETS_NORMAL\nattribute vec3 normal{X};\n#endif\n#ifdef MORPHTARGETS_TANGENT\nattribute vec3 tangent{X};\n#endif\n#ifdef MORPHTARGETS_UV\nattribute vec2 uv_{X};\n#endif\n#elif {X}==0\nuniform int morphTargetCount;\n#endif\n#endif\n"},8451:(e,t,s)=>{s(9610).l.IncludesShadersStore.morphTargetsVertexGlobal="#ifdef MORPHTARGETS\n#ifdef MORPHTARGETS_TEXTURE\nfloat vertexID;\n#endif\n#endif\n"},7999:(e,t,s)=>{s(9610).l.IncludesShadersStore.morphTargetsVertexGlobalDeclaration="#ifdef MORPHTARGETS\nuniform float morphTargetInfluences[NUM_MORPH_INFLUENCERS];\n#ifdef MORPHTARGETS_TEXTURE \nuniform float morphTargetTextureIndices[NUM_MORPH_INFLUENCERS];uniform vec3 morphTargetTextureInfo;uniform highp sampler2DArray morphTargets;vec3 readVector3FromRawSampler(int targetIndex,float vertexIndex)\n{ \nfloat y=floor(vertexIndex/morphTargetTextureInfo.y);float x=vertexIndex-y*morphTargetTextureInfo.y;vec3 textureUV=vec3((x+0.5)/morphTargetTextureInfo.y,(y+0.5)/morphTargetTextureInfo.z,morphTargetTextureIndices[targetIndex]);return texture(morphTargets,textureUV).xyz;}\n#endif\n#endif\n"},8334:(e,t,s)=>{s(9610).l.IncludesShadersStore.packingFunctions="vec4 pack(float depth)\n{const vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);const vec4 bit_mask=vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}\nfloat unpack(vec4 color)\n{const vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(color,bit_shift);}"},1211:(e,t,s)=>{s(9610).l.IncludesShadersStore.pointCloudVertex="#if defined(POINTSIZE) && !defined(WEBGPU)\ngl_PointSize=pointSize;\n#endif\n"},8852:(e,t,s)=>{s.r(t),s.d(t,{depthPixelShader:()=>a});var i=s(9610);s(6194),s(8334),s(7412);const r="depthPixelShader",n="#ifdef ALPHATEST\nvarying vec2 vUV;uniform sampler2D diffuseSampler;\n#endif\n#include\nvarying float vDepthMetric;\n#ifdef PACKED\n#include\n#endif\n#ifdef STORE_CAMERASPACE_Z\nvarying vec4 vViewPos;\n#endif\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\n#include\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\n#ifdef STORE_CAMERASPACE_Z\n#ifdef PACKED\ngl_FragColor=pack(vViewPos.z);\n#else\ngl_FragColor=vec4(vViewPos.z,0.0,0.0,1.0);\n#endif\n#else\n#ifdef NONLINEARDEPTH\n#ifdef PACKED\ngl_FragColor=pack(gl_FragCoord.z);\n#else\ngl_FragColor=vec4(gl_FragCoord.z,0.0,0.0,0.0);\n#endif\n#else\n#ifdef PACKED\ngl_FragColor=pack(vDepthMetric);\n#else\ngl_FragColor=vec4(vDepthMetric,0.0,0.0,1.0);\n#endif\n#endif\n#endif\n}";i.l.ShadersStore[r]=n;const a={name:r,shader:n}},9977:(e,t,s)=>{s.r(t),s.d(t,{depthVertexShader:()=>a});var i=s(9610);s(9707),s(8959),s(7999),s(738),s(1636),s(1218);i.l.IncludesShadersStore.pointCloudVertexDeclaration="#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n",s(8451),s(5060),s(3298),s(3361),s(5523),s(7314),s(1211);const r="depthVertexShader",n="attribute vec3 position;\n#include\n#include\n#include\n#include[0..maxSimultaneousMorphTargets]\n#include\n#include\nuniform mat4 viewProjection;uniform vec2 depthValues;\n#if defined(ALPHATEST) || defined(NEED_UV)\nvarying vec2 vUV;uniform mat4 diffuseMatrix;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#endif\n#ifdef STORE_CAMERASPACE_Z\nuniform mat4 view;varying vec4 vViewPos;\n#endif\n#include\nvarying float vDepthMetric;\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void)\n{vec3 positionUpdated=position;\n#ifdef UV1\nvec2 uvUpdated=uv;\n#endif\n#include\n#include[0..maxSimultaneousMorphTargets]\n#include\n#include\n#include\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\n#include\ngl_Position=viewProjection*worldPos;\n#ifdef STORE_CAMERASPACE_Z\nvViewPos=view*worldPos;\n#else\n#ifdef USE_REVERSE_DEPTHBUFFER\nvDepthMetric=((-gl_Position.z+depthValues.x)/(depthValues.y));\n#else\nvDepthMetric=((gl_Position.z+depthValues.x)/(depthValues.y));\n#endif\n#endif\n#if defined(ALPHATEST) || defined(BASIC_RENDER)\n#ifdef UV1\nvUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#ifdef UV2\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n#include\n}\n";i.l.ShadersStore[r]=n;const a={name:r,shader:n}},6612:(e,t,s)=>{s.r(t),s.d(t,{postprocessVertexShader:()=>n});const i="postprocessVertexShader",r="attribute vec2 position;uniform vec2 scale;varying vec2 vUV;const vec2 madd=vec2(0.5,0.5);\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nvUV=(position*madd+madd)*scale;gl_Position=vec4(position,0.0,1.0);\n#define CUSTOM_VERTEX_MAIN_END\n}";s(9610).l.ShadersStore[i]=r;const n={name:i,shader:r}},8438:(e,t,s)=>{s.r(t),s.d(t,{sharpenPixelShader:()=>n});const i="sharpenPixelShader",r="varying vec2 vUV;uniform sampler2D textureSampler;uniform vec2 screenSize;uniform vec2 sharpnessAmounts;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{vec2 onePixel=vec2(1.0,1.0)/screenSize;vec4 color=texture2D(textureSampler,vUV);vec4 edgeDetection=texture2D(textureSampler,vUV+onePixel*vec2(0,-1)) +\ntexture2D(textureSampler,vUV+onePixel*vec2(-1,0)) +\ntexture2D(textureSampler,vUV+onePixel*vec2(1,0)) +\ntexture2D(textureSampler,vUV+onePixel*vec2(0,1)) -\ncolor*4.0;gl_FragColor=max(vec4(color.rgb*sharpnessAmounts.y,color.a)-(sharpnessAmounts.x*vec4(edgeDetection.rgb,0)),0.);}";s(9610).l.ShadersStore[i]=r;const n={name:i,shader:r}},7762:(e,t,s)=>{s.d(t,{WZ:()=>b});var i=s(5530),r=s(7328),n=s(861),a=s(1137),o=s(6315),h=s(9923),l=s(4609),c=s(5616),u=s(998),d=s(6552);i.e._instancedMeshFactory=(e,t)=>{const s=new _(e,t);if(t.instancedBuffers){s.instancedBuffers={};for(const e in t.instancedBuffers)s.instancedBuffers[e]=t.instancedBuffers[e]}return s};class _ extends n.u{constructor(e,t){super(e,t.getScene()),this._indexInSourceMeshInstanceArray=-1,this._distanceToCamera=0,t.addInstance(this),this._sourceMesh=t,this._unIndexed=t._unIndexed,this.position.copyFrom(t.position),this.rotation.copyFrom(t.rotation),this.scaling.copyFrom(t.scaling),t.rotationQuaternion&&(this.rotationQuaternion=t.rotationQuaternion.clone()),this.animations=t.animations.slice();for(const e of t.getAnimationRanges())null!=e&&this.createAnimationRange(e.name,e.from,e.to);this.infiniteDistance=t.infiniteDistance,this.setPivotMatrix(t.getPivotMatrix()),this.refreshBoundingInfo(!0,!0),this._syncSubMeshes()}getClassName(){return"InstancedMesh"}get lightSources(){return this._sourceMesh._lightSources}_resyncLightSources(){}_resyncLightSource(){}_removeLightSource(){}get receiveShadows(){return this._sourceMesh.receiveShadows}set receiveShadows(e){this._sourceMesh?.receiveShadows!==e&&u.S0.Warn("Setting receiveShadows on an instanced mesh has no effect")}get material(){return this._sourceMesh.material}set material(e){this._sourceMesh?.material!==e&&u.S0.Warn("Setting material on an instanced mesh has no effect")}get visibility(){return this._sourceMesh.visibility}set visibility(e){this._sourceMesh?.visibility!==e&&u.S0.Warn("Setting visibility on an instanced mesh has no effect")}get skeleton(){return this._sourceMesh.skeleton}set skeleton(e){this._sourceMesh?.skeleton!==e&&u.S0.Warn("Setting skeleton on an instanced mesh has no effect")}get renderingGroupId(){return this._sourceMesh.renderingGroupId}set renderingGroupId(e){this._sourceMesh&&e!==this._sourceMesh.renderingGroupId&&a.V.Warn("Note - setting renderingGroupId of an instanced mesh has no effect on the scene")}getTotalVertices(){return this._sourceMesh?this._sourceMesh.getTotalVertices():0}getTotalIndices(){return this._sourceMesh.getTotalIndices()}get sourceMesh(){return this._sourceMesh}createInstance(e){return this._sourceMesh.createInstance(e)}isReady(e=!1){return this._sourceMesh.isReady(e,!0)}getVerticesData(e,t,s){return this._sourceMesh.getVerticesData(e,t,s)}copyVerticesData(e,t){this._sourceMesh.copyVerticesData(e,t)}setVerticesData(e,t,s,i){return this.sourceMesh&&this.sourceMesh.setVerticesData(e,t,s,i),this.sourceMesh}updateVerticesData(e,t,s,i){return this.sourceMesh&&this.sourceMesh.updateVerticesData(e,t,s,i),this.sourceMesh}setIndices(e,t=null){return this.sourceMesh&&this.sourceMesh.setIndices(e,t),this.sourceMesh}isVerticesDataPresent(e){return this._sourceMesh.isVerticesDataPresent(e)}getIndices(){return this._sourceMesh.getIndices()}get _positions(){return this._sourceMesh._positions}refreshBoundingInfo(e=!1,t=!1){if(this.hasBoundingInfo&&this.getBoundingInfo().isLocked)return this;let s;s="object"==typeof e?e:{applySkeleton:e,applyMorph:t};const i=this._sourceMesh.geometry?this._sourceMesh.geometry.boundingBias:null;return this._refreshBoundingInfo(this._sourceMesh._getData(s,null,c.R.PositionKind),i),this}_preActivate(){return this._currentLOD&&this._currentLOD._preActivate(),this}_activate(e,t){if(super._activate(e,t),this._sourceMesh.subMeshes||a.V.Warn("Instances should only be created for meshes with geometry."),this._currentLOD){if(this._currentLOD._getWorldMatrixDeterminant()>=0!=this._getWorldMatrixDeterminant()>=0)return this._internalAbstractMeshDataInfo._actAsRegularMesh=!0,!0;if(this._internalAbstractMeshDataInfo._actAsRegularMesh=!1,this._currentLOD._registerInstanceForRenderId(this,e),t){if(!this._currentLOD._internalAbstractMeshDataInfo._isActiveIntermediate)return this._currentLOD._internalAbstractMeshDataInfo._onlyForInstancesIntermediate=!0,!0}else if(!this._currentLOD._internalAbstractMeshDataInfo._isActive)return this._currentLOD._internalAbstractMeshDataInfo._onlyForInstances=!0,!0}return!1}_postActivate(){this._sourceMesh.edgesShareWithInstances&&this._sourceMesh._edgesRenderer&&this._sourceMesh._edgesRenderer.isEnabled&&this._sourceMesh._renderingGroup?(this._sourceMesh._renderingGroup._edgesRenderers.pushNoDuplicate(this._sourceMesh._edgesRenderer),this._sourceMesh._edgesRenderer.customInstances.push(this.getWorldMatrix())):this._edgesRenderer&&this._edgesRenderer.isEnabled&&this._sourceMesh._renderingGroup&&this._sourceMesh._renderingGroup._edgesRenderers.push(this._edgesRenderer)}getWorldMatrix(){if(this._currentLOD&&this._currentLOD.billboardMode!==r.V.BILLBOARDMODE_NONE&&this._currentLOD._masterMesh!==this){this._billboardWorldMatrix||(this._billboardWorldMatrix=new h.uq);const e=this._currentLOD._masterMesh;return this._currentLOD._masterMesh=this,h.AA.Vector3[7].copyFrom(this._currentLOD.position),this._currentLOD.position.set(0,0,0),this._billboardWorldMatrix.copyFrom(this._currentLOD.computeWorldMatrix(!0)),this._currentLOD.position.copyFrom(h.AA.Vector3[7]),this._currentLOD._masterMesh=e,this._billboardWorldMatrix}return super.getWorldMatrix()}get isAnInstance(){return!0}getLOD(e){if(!e)return this;const t=this.sourceMesh.getLODLevels();if(t&&0!==t.length){const t=this.getBoundingInfo();this._currentLOD=this.sourceMesh.getLOD(e,t.boundingSphere)}else this._currentLOD=this.sourceMesh;return this._currentLOD}_preActivateForIntermediateRendering(e){return this.sourceMesh._preActivateForIntermediateRendering(e)}_syncSubMeshes(){if(this.releaseSubMeshes(),this._sourceMesh.subMeshes)for(let e=0;ee=e.concat(t.bones))),e}}class m extends g{}class T{constructor(){this.rootNodes=[],this.skeletons=[],this.animationGroups=[]}dispose(){this.rootNodes.slice(0).forEach((e=>{e.dispose()})),this.rootNodes.length=0,this.skeletons.slice(0).forEach((e=>{e.dispose()})),this.skeletons.length=0,this.animationGroups.slice(0).forEach((e=>{e.dispose()})),this.animationGroups.length=0}}class b extends g{constructor(e){super(),this._wasAddedToScene=!1,(e=e||o.q.LastCreatedScene)&&(this.scene=e,this.proceduralTextures=[],e.onDisposeObservable.add((()=>{this._wasAddedToScene||this.dispose()})),this._onContextRestoredObserver=e.getEngine().onContextRestoredObservable.add((()=>{for(const e of this.geometries)e._rebuild();for(const e of this.meshes)e._rebuild();for(const e of this.particleSystems)e.rebuild();for(const e of this.textures)e._rebuild()})))}_topologicalSort(e){const t=new Map;for(const s of e)t.set(s.uniqueId,s);const s={dependsOn:new Map,dependedBy:new Map};for(const t of e){const e=t.uniqueId;s.dependsOn.set(e,new Set),s.dependedBy.set(e,new Set)}for(const i of e){const e=i.uniqueId,r=s.dependsOn.get(e);if(i instanceof _){const n=i.sourceMesh;t.has(n.uniqueId)&&(r.add(n.uniqueId),s.dependedBy.get(n.uniqueId).add(e))}const n=s.dependedBy.get(e);for(const r of i.getDescendants()){const i=r.uniqueId;t.has(i)&&(n.add(i),s.dependsOn.get(i).add(e))}}const i=[],r=[];for(const i of e){const e=i.uniqueId;0===s.dependsOn.get(e).size&&(r.push(i),t.delete(e))}const n=r;for(;n.length>0;){const e=n.shift();i.push(e);const r=s.dependedBy.get(e.uniqueId);for(const i of Array.from(r.values())){const r=s.dependsOn.get(i);r.delete(e.uniqueId),0===r.size&&t.get(i)&&(n.push(t.get(i)),t.delete(i))}}return t.size>0&&(a.V.Error("SceneSerializer._topologicalSort: There were unvisited nodes:"),t.forEach((e=>a.V.Error(e.name)))),i}_addNodeAndDescendantsToList(e,t,s,i){if(s&&(!i||i(s))&&!t.has(s.uniqueId)){e.push(s),t.add(s.uniqueId);for(const r of s.getDescendants(!0))this._addNodeAndDescendantsToList(e,t,r,i)}}_isNodeInContainer(e){return e instanceof n.u&&-1!==this.meshes.indexOf(e)||e instanceof r.V&&-1!==this.transformNodes.indexOf(e)||e instanceof f.v&&-1!==this.lights.indexOf(e)||e instanceof p.i&&-1!==this.cameras.indexOf(e)}_isValidHierarchy(){for(const e of this.meshes)if(e.parent&&!this._isNodeInContainer(e.parent))return a.V.Warn(`Node ${e.name} has a parent that is not in the container.`),!1;for(const e of this.transformNodes)if(e.parent&&!this._isNodeInContainer(e.parent))return a.V.Warn(`Node ${e.name} has a parent that is not in the container.`),!1;for(const e of this.lights)if(e.parent&&!this._isNodeInContainer(e.parent))return a.V.Warn(`Node ${e.name} has a parent that is not in the container.`),!1;for(const e of this.cameras)if(e.parent&&!this._isNodeInContainer(e.parent))return a.V.Warn(`Node ${e.name} has a parent that is not in the container.`),!1;return!0}instantiateModelsToScene(e,t=!1,s){this._isValidHierarchy()||u.S0.Warn("SceneSerializer.InstantiateModelsToScene: The Asset Container hierarchy is not valid.");const r={},n={},a=new T,o=[],h=[],l={doNotInstantiate:!0,...s},c=[],d=new Set;for(const e of this.transformNodes)null===e.parent&&this._addNodeAndDescendantsToList(c,d,e,l.predicate);for(const e of this.meshes)null===e.parent&&this._addNodeAndDescendantsToList(c,d,e,l.predicate);const _=this._topologicalSort(c),f=(s,o)=>{if(((t,s)=>{if(r[t.uniqueId]=s.uniqueId,n[s.uniqueId]=s,e&&(s.name=e(t.name)),s instanceof i.e){const e=s;if(e.morphTargetManager){const s=t.morphTargetManager;e.morphTargetManager=s.clone();for(let t=0;te&&n[r[e.uniqueId]]))}}"InstancedMesh"!==i.getClassName()&&(i.material=n[r[t.uniqueId]])}else"MultiMaterial"===i.material.getClassName()?-1===this.scene.multiMaterials.indexOf(i.material)&&this.scene.addMultiMaterial(i.material):-1===this.scene.materials.indexOf(i.material)&&this.scene.addMaterial(i.material)}null===o.parent&&a.rootNodes.push(o)};return _.forEach((e=>{if("InstancedMesh"===e.getClassName()){const t=e,s=t.sourceMesh,i=r[s.uniqueId],a=("number"==typeof i?n[i]:s).createInstance(t.name);f(t,a)}else{let t=!0;"TransformNode"===e.getClassName()||"Node"===e.getClassName()||e.skeleton||!e.getTotalVertices||0===e.getTotalVertices()?t=!1:l.doNotInstantiate&&(t="function"==typeof l.doNotInstantiate?!l.doNotInstantiate(e):!l.doNotInstantiate);const s=t?e.createInstance(`instance of ${e.name}`):e.clone(`Clone of ${e.name}`,null,!0);if(!s)throw new Error(`Could not clone or instantiate node on Asset Container ${e.name}`);f(e,s)}})),this.skeletons.forEach((t=>{if(l.predicate&&!l.predicate(t))return;const s=t.clone(e?e(t.name):"Clone of "+t.name);for(const e of this.meshes)if(e.skeleton===t&&!e.isAnInstance){const t=n[r[e.uniqueId]];if(!t||t.isAnInstance)continue;if(t.skeleton=s,-1!==o.indexOf(s))continue;o.push(s);for(const e of s.bones)e._linkedTransformNode&&(e._linkedTransformNode=n[r[e._linkedTransformNode.uniqueId]])}a.skeletons.push(s)})),this.animationGroups.forEach((t=>{if(l.predicate&&!l.predicate(t))return;const s=t.clone(e?e(t.name):"Clone of "+t.name,(e=>n[r[e.uniqueId]]||e));a.animationGroups.push(s)})),a}addAllToScene(){if(!this._wasAddedToScene){this._isValidHierarchy()||u.S0.Warn("SceneSerializer.addAllToScene: The Asset Container hierarchy is not valid."),this._wasAddedToScene=!0,this.addToScene(null),this.environmentTexture&&(this.scene.environmentTexture=this.environmentTexture);for(const e of this.scene._serializableComponents)e.addFromContainer(this);this.scene.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver),this._onContextRestoredObserver=null}}addToScene(e=null){const t=[];this.cameras.forEach((s=>{e&&!e(s)||(this.scene.addCamera(s),t.push(s))})),this.lights.forEach((s=>{e&&!e(s)||(this.scene.addLight(s),t.push(s))})),this.meshes.forEach((s=>{e&&!e(s)||(this.scene.addMesh(s),t.push(s))})),this.skeletons.forEach((t=>{e&&!e(t)||this.scene.addSkeleton(t)})),this.animations.forEach((t=>{e&&!e(t)||this.scene.addAnimation(t)})),this.animationGroups.forEach((t=>{e&&!e(t)||this.scene.addAnimationGroup(t)})),this.multiMaterials.forEach((t=>{e&&!e(t)||this.scene.addMultiMaterial(t)})),this.materials.forEach((t=>{e&&!e(t)||this.scene.addMaterial(t)})),this.morphTargetManagers.forEach((t=>{e&&!e(t)||this.scene.addMorphTargetManager(t)})),this.geometries.forEach((t=>{e&&!e(t)||this.scene.addGeometry(t)})),this.transformNodes.forEach((s=>{e&&!e(s)||(this.scene.addTransformNode(s),t.push(s))})),this.actionManagers.forEach((t=>{e&&!e(t)||this.scene.addActionManager(t)})),this.textures.forEach((t=>{e&&!e(t)||this.scene.addTexture(t)})),this.reflectionProbes.forEach((t=>{e&&!e(t)||this.scene.addReflectionProbe(t)}));for(const e of t)e.parent&&-1===this.scene.getNodes().indexOf(e.parent)&&(e.setParent?e.setParent(null):e.parent=null)}removeAllFromScene(){this._isValidHierarchy()||u.S0.Warn("SceneSerializer.removeAllFromScene: The Asset Container hierarchy is not valid."),this._wasAddedToScene=!1,this.removeFromScene(null),this.environmentTexture===this.scene.environmentTexture&&(this.scene.environmentTexture=null);for(const e of this.scene._serializableComponents)e.removeFromContainer(this)}removeFromScene(e=null){this.cameras.forEach((t=>{e&&!e(t)||this.scene.removeCamera(t)})),this.lights.forEach((t=>{e&&!e(t)||this.scene.removeLight(t)})),this.meshes.forEach((t=>{e&&!e(t)||this.scene.removeMesh(t,!0)})),this.skeletons.forEach((t=>{e&&!e(t)||this.scene.removeSkeleton(t)})),this.animations.forEach((t=>{e&&!e(t)||this.scene.removeAnimation(t)})),this.animationGroups.forEach((t=>{e&&!e(t)||this.scene.removeAnimationGroup(t)})),this.multiMaterials.forEach((t=>{e&&!e(t)||this.scene.removeMultiMaterial(t)})),this.materials.forEach((t=>{e&&!e(t)||this.scene.removeMaterial(t)})),this.morphTargetManagers.forEach((t=>{e&&!e(t)||this.scene.removeMorphTargetManager(t)})),this.geometries.forEach((t=>{e&&!e(t)||this.scene.removeGeometry(t)})),this.transformNodes.forEach((t=>{e&&!e(t)||this.scene.removeTransformNode(t)})),this.actionManagers.forEach((t=>{e&&!e(t)||this.scene.removeActionManager(t)})),this.textures.forEach((t=>{e&&!e(t)||this.scene.removeTexture(t)})),this.reflectionProbes.forEach((t=>{e&&!e(t)||this.scene.removeReflectionProbe(t)}))}dispose(){this.cameras.slice(0).forEach((e=>{e.dispose()})),this.cameras.length=0,this.lights.slice(0).forEach((e=>{e.dispose()})),this.lights.length=0,this.meshes.slice(0).forEach((e=>{e.dispose()})),this.meshes.length=0,this.skeletons.slice(0).forEach((e=>{e.dispose()})),this.skeletons.length=0,this.animationGroups.slice(0).forEach((e=>{e.dispose()})),this.animationGroups.length=0,this.multiMaterials.slice(0).forEach((e=>{e.dispose()})),this.multiMaterials.length=0,this.materials.slice(0).forEach((e=>{e.dispose()})),this.materials.length=0,this.geometries.slice(0).forEach((e=>{e.dispose()})),this.geometries.length=0,this.transformNodes.slice(0).forEach((e=>{e.dispose()})),this.transformNodes.length=0,this.actionManagers.slice(0).forEach((e=>{e.dispose()})),this.actionManagers.length=0,this.textures.slice(0).forEach((e=>{e.dispose()})),this.textures.length=0,this.reflectionProbes.slice(0).forEach((e=>{e.dispose()})),this.reflectionProbes.length=0,this.morphTargetManagers.slice(0).forEach((e=>{e.dispose()})),this.morphTargetManagers.length=0,this.environmentTexture&&(this.environmentTexture.dispose(),this.environmentTexture=null);for(const e of this.scene._serializableComponents)e.removeFromContainer(this,!0);this._onContextRestoredObserver&&(this.scene.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver),this._onContextRestoredObserver=null)}_moveAssets(e,t,s){if(e&&t)for(const i of e){let e=!0;if(s)for(const t of s)if(i===t){e=!1;break}e&&(t.push(i),i._parentContainer=this)}}moveAllFromScene(e){this._wasAddedToScene=!1,void 0===e&&(e=new m);for(const t in this)Object.prototype.hasOwnProperty.call(this,t)&&(this[t]=this[t]||("_environmentTexture"===t?null:[]),this._moveAssets(this.scene[t],this[t],e[t]));this.environmentTexture=this.scene.environmentTexture,this.removeAllFromScene()}createRootMesh(){const e=new i.e("assetContainerRootMesh",this.scene);return this.meshes.forEach((t=>{t.parent||e.addChild(t)})),this.meshes.unshift(e),e}mergeAnimationsTo(e=o.q.LastCreatedScene,t,s=null){if(!e)return a.V.Error("No scene available to merge animations to"),[];const i=s||(t=>{let s=null;const i=t.animations.length?t.animations[0].targetProperty:"",r=t.name.split(".").join("").split("_primitive")[0];switch(i){case"position":case"rotationQuaternion":s=e.getTransformNodeByName(t.name)||e.getTransformNodeByName(r);break;case"influence":s=e.getMorphTargetByName(t.name)||e.getMorphTargetByName(r);break;default:s=e.getNodeByName(t.name)||e.getNodeByName(r)}return s});this.getNodes().forEach((e=>{const t=i(e);if(null!==t){for(const s of e.animations){const e=t.animations.filter((e=>e.targetProperty===s.targetProperty));for(const s of e){const e=t.animations.indexOf(s,0);e>-1&&t.animations.splice(e,1)}}t.animations=t.animations.concat(e.animations)}}));const r=[];return this.animationGroups.slice().forEach((e=>{r.push(e.clone(e.name,i)),e.animatables.forEach((e=>{e.stop()}))})),t.forEach((t=>{const s=i(t.target);s&&(e.beginAnimation(s,t.fromFrame,t.toFrame,t.loopAnimation,t.speedRatio,t.onAnimationEnd?t.onAnimationEnd:void 0,void 0,!0,void 0,t.onAnimationLoop?t.onAnimationLoop:void 0),e.stopAnimation(t.target))})),r}populateRootNodes(){this.rootNodes.length=0,this.meshes.forEach((e=>{e.parent||-1!==this.rootNodes.indexOf(e)||this.rootNodes.push(e)})),this.transformNodes.forEach((e=>{e.parent||-1!==this.rootNodes.indexOf(e)||this.rootNodes.push(e)})),this.lights.forEach((e=>{e.parent||-1!==this.rootNodes.indexOf(e)||this.rootNodes.push(e)})),this.cameras.forEach((e=>{e.parent||-1!==this.rootNodes.indexOf(e)||this.rootNodes.push(e)}))}addAllAssetsToContainer(e){if(!e)return;const t=[],s=new Set;for(t.push(e);t.length>0;){const e=t.pop();if(e instanceof i.e?(e.geometry&&-1===this.geometries.indexOf(e.geometry)&&this.geometries.push(e.geometry),this.meshes.push(e)):e instanceof r.V?this.transformNodes.push(e):e instanceof f.v?this.lights.push(e):e instanceof p.i&&this.cameras.push(e),e instanceof n.u){if(e.material&&-1===this.materials.indexOf(e.material)){this.materials.push(e.material);for(const t of e.material.getActiveTextures())-1===this.textures.indexOf(t)&&this.textures.push(t)}e.skeleton&&-1===this.skeletons.indexOf(e.skeleton)&&this.skeletons.push(e.skeleton),e.morphTargetManager&&-1===this.morphTargetManagers.indexOf(e.morphTargetManager)&&this.morphTargetManagers.push(e.morphTargetManager)}for(const i of e.getChildren())s.has(i)||t.push(i);s.add(e)}this.populateRootNodes()}}},4870:(e,t,s)=>{s.d(t,{b:()=>u});var i=s(5524),r=s(9923),n=s(9259),a=s(9848),o=s(6315),h=s(5503),l=s(6877);class c{constructor(){this._doNotSerialize=!1,this._isDisposed=!1,this._sceneRootNodesIndex=-1,this._isEnabled=!0,this._isParentEnabled=!0,this._isReady=!0,this._onEnabledStateChangedObservable=new a.cP,this._onClonedObservable=new a.cP}}class u{static AddNodeConstructor(e,t){this._NodeConstructors[e]=t}static Construct(e,t,s,i){const r=this._NodeConstructors[e];return r?r(t,s,i):null}set accessibilityTag(e){this._accessibilityTag=e,this.onAccessibilityTagChangedObservable.notifyObservers(e)}get accessibilityTag(){return this._accessibilityTag}get doNotSerialize(){return!!this._nodeDataStorage._doNotSerialize||!!this._parentNode&&this._parentNode.doNotSerialize}set doNotSerialize(e){this._nodeDataStorage._doNotSerialize=e}isDisposed(){return this._nodeDataStorage._isDisposed}set parent(e){if(this._parentNode===e)return;const t=this._parentNode;if(this._parentNode&&void 0!==this._parentNode._children&&null!==this._parentNode._children){const t=this._parentNode._children.indexOf(this);-1!==t&&this._parentNode._children.splice(t,1),e||this._nodeDataStorage._isDisposed||this._addToSceneRootNodes()}this._parentNode=e,this._isDirty=!0,this._parentNode&&(void 0!==this._parentNode._children&&null!==this._parentNode._children||(this._parentNode._children=new Array),this._parentNode._children.push(this),t||this._removeFromSceneRootNodes()),this._syncParentEnabledState()}get parent(){return this._parentNode}_serializeAsParent(e){e.parentId=this.uniqueId}_addToSceneRootNodes(){-1===this._nodeDataStorage._sceneRootNodesIndex&&(this._nodeDataStorage._sceneRootNodesIndex=this._scene.rootNodes.length,this._scene.rootNodes.push(this))}_removeFromSceneRootNodes(){if(-1!==this._nodeDataStorage._sceneRootNodesIndex){const e=this._scene.rootNodes,t=e.length-1;e[this._nodeDataStorage._sceneRootNodesIndex]=e[t],e[this._nodeDataStorage._sceneRootNodesIndex]._nodeDataStorage._sceneRootNodesIndex=this._nodeDataStorage._sceneRootNodesIndex,this._scene.rootNodes.pop(),this._nodeDataStorage._sceneRootNodesIndex=-1}}get animationPropertiesOverride(){return this._animationPropertiesOverride?this._animationPropertiesOverride:this._scene.animationPropertiesOverride}set animationPropertiesOverride(e){this._animationPropertiesOverride=e}getClassName(){return"Node"}set onDispose(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)}get onEnabledStateChangedObservable(){return this._nodeDataStorage._onEnabledStateChangedObservable}get onClonedObservable(){return this._nodeDataStorage._onClonedObservable}constructor(e,t=null,s=!0){this._isDirty=!1,this._nodeDataStorage=new c,this.state="",this.metadata=null,this.reservedDataStore=null,this._accessibilityTag=null,this.onAccessibilityTagChangedObservable=new a.cP,this._parentContainer=null,this.animations=[],this._ranges={},this.onReady=null,this._currentRenderId=-1,this._parentUpdateId=-1,this._childUpdateId=-1,this._waitingParentId=null,this._waitingParentInstanceIndex=null,this._waitingParsedUniqueId=null,this._cache={},this._parentNode=null,this._children=null,this._worldMatrix=r.uq.Identity(),this._worldMatrixDeterminant=0,this._worldMatrixDeterminantIsDirty=!0,this._animationPropertiesOverride=null,this._isNode=!0,this.onDisposeObservable=new a.cP,this._onDisposeObserver=null,this._behaviors=new Array,this.name=e,this.id=e,this._scene=t||o.q.LastCreatedScene,this.uniqueId=this._scene.getUniqueId(),this._initCache(),s&&this._addToSceneRootNodes()}getScene(){return this._scene}getEngine(){return this._scene.getEngine()}addBehavior(e,t=!1){return-1!==this._behaviors.indexOf(e)||(e.init(),this._scene.isLoading&&!t?this._scene.onDataLoadedObservable.addOnce((()=>{e.attach(this)})):e.attach(this),this._behaviors.push(e)),this}removeBehavior(e){const t=this._behaviors.indexOf(e);return-1===t||(this._behaviors[t].detach(),this._behaviors.splice(t,1)),this}get behaviors(){return this._behaviors}getBehaviorByName(e){for(const t of this._behaviors)if(t.name===e)return t;return null}getWorldMatrix(){return this._currentRenderId!==this._scene.getRenderId()&&this.computeWorldMatrix(),this._worldMatrix}_getWorldMatrixDeterminant(){return this._worldMatrixDeterminantIsDirty&&(this._worldMatrixDeterminantIsDirty=!1,this._worldMatrixDeterminant=this._worldMatrix.determinant()),this._worldMatrixDeterminant}get worldMatrixFromCache(){return this._worldMatrix}_initCache(){this._cache={}}updateCache(e){!e&&this.isSynchronized()||this._updateCache()}_getActionManagerForTrigger(e,t=!0){return this.parent?this.parent._getActionManagerForTrigger(e,!1):null}_updateCache(e){}_isSynchronized(){return!0}_markSyncedWithParent(){this._parentNode&&(this._parentUpdateId=this._parentNode._childUpdateId)}isSynchronizedWithParent(){return!this._parentNode||!this._parentNode._isDirty&&this._parentUpdateId===this._parentNode._childUpdateId&&this._parentNode.isSynchronized()}isSynchronized(){return!(this._parentNode&&!this.isSynchronizedWithParent())&&this._isSynchronized()}isReady(e=!1){return this._nodeDataStorage._isReady}markAsDirty(e){return this._currentRenderId=Number.MAX_VALUE,this._isDirty=!0,this}isEnabled(e=!0){return!1===e?this._nodeDataStorage._isEnabled:!!this._nodeDataStorage._isEnabled&&this._nodeDataStorage._isParentEnabled}_syncParentEnabledState(){this._nodeDataStorage._isParentEnabled=!this._parentNode||this._parentNode.isEnabled(),this._children&&this._children.forEach((e=>{e._syncParentEnabledState()}))}setEnabled(e){this._nodeDataStorage._isEnabled!==e&&(this._nodeDataStorage._isEnabled=e,this._syncParentEnabledState(),this._nodeDataStorage._onEnabledStateChangedObservable.notifyObservers(e))}isDescendantOf(e){return!!this.parent&&(this.parent===e||this.parent.isDescendantOf(e))}_getDescendants(e,t=!1,s){if(this._children)for(let i=0;i(!t||t(e))&&void 0!==e.cullingStrategy)),s}getChildren(e,t=!0){return this.getDescendants(t,e)}_setReady(e){e!==this._nodeDataStorage._isReady&&(e?(this.onReady&&this.onReady(this),this._nodeDataStorage._isReady=!0):this._nodeDataStorage._isReady=!1)}getAnimationByName(e){for(let t=0;tnew u(e,this.getScene())),this);if(t&&(i.parent=t),!s){const t=this.getDescendants(!0);for(let s=0;s{throw(0,h.n)("AnimationRange")},u._NodeConstructors={},(0,i.Cg)([(0,n.lK)()],u.prototype,"name",void 0),(0,i.Cg)([(0,n.lK)()],u.prototype,"id",void 0),(0,i.Cg)([(0,n.lK)()],u.prototype,"uniqueId",void 0),(0,i.Cg)([(0,n.lK)()],u.prototype,"state",void 0),(0,i.Cg)([(0,n.lK)()],u.prototype,"metadata",void 0)},554:(e,t,s)=>{s.d(t,{Z:()=>$});var i=s(998),r=s(6237),n=s(9848),a=s(7931);class o{constructor(){this._count=0,this._data={}}copyFrom(e){this.clear(),e.forEach(((e,t)=>this.add(e,t)))}get(e){const t=this._data[e];if(void 0!==t)return t}getOrAddWithFactory(e,t){let s=this.get(e);return void 0!==s||(s=t(e),s&&this.add(e,s)),s}getOrAdd(e,t){const s=this.get(e);return void 0!==s?s:(this.add(e,t),t)}contains(e){return void 0!==this._data[e]}add(e,t){return void 0===this._data[e]&&(this._data[e]=t,++this._count,!0)}set(e,t){return void 0!==this._data[e]&&(this._data[e]=t,!0)}getAndRemove(e){const t=this.get(e);return void 0!==t?(delete this._data[e],--this._count,t):null}remove(e){return!!this.contains(e)&&(delete this._data[e],--this._count,!0)}clear(){this._data={},this._count=0}get count(){return this._count}forEach(e){for(const t in this._data)e(t,this._data[t])}first(e){for(const t in this._data){const s=e(t,this._data[t]);if(s)return s}return null}}var h=s(7503),l=s(9923),c=s(1088),u=s(935),d=s(311);class _{constructor(e,t,s,i,r,n){this.source=e,this.pointerX=t,this.pointerY=s,this.meshUnderPointer=i,this.sourceEvent=r,this.additionalData=n}static CreateNew(e,t,s){const i=e.getScene();return new _(e,i.pointerX,i.pointerY,i.meshUnderPointer||e,t,s)}static CreateNewFromSprite(e,t,s,i){return new _(e,t.pointerX,t.pointerY,t.meshUnderPointer,s,i)}static CreateNewFromScene(e,t){return new _(null,e.pointerX,e.pointerY,e.meshUnderPointer,t)}static CreateNewFromPrimitive(e,t,s,i){return new _(e,t.x,t.y,null,s,i)}}var f=s(6096),p=s(3099),g=s(6945),m=s(8790),T=s(6315),b=s(5503),E=s(6240);class x{constructor(){this.hoverCursor="",this.actions=[],this.isRecursive=!1,this.disposeWhenUnowned=!0}static get HasTriggers(){for(const e in x.Triggers)if(Object.prototype.hasOwnProperty.call(x.Triggers,e))return!0;return!1}static get HasPickTriggers(){for(const e in x.Triggers)if(Object.prototype.hasOwnProperty.call(x.Triggers,e)){const t=parseInt(e);if(t>=1&&t<=7)return!0}return!1}static HasSpecificTrigger(e){for(const t in x.Triggers)if(Object.prototype.hasOwnProperty.call(x.Triggers,t)&&parseInt(t)===e)return!0;return!1}}x.Triggers={};var A,R,M,y,P,v,C,S=s(4146);!function(e){e[e.Generic=0]="Generic",e[e.Keyboard=1]="Keyboard",e[e.Mouse=2]="Mouse",e[e.Touch=3]="Touch",e[e.DualShock=4]="DualShock",e[e.Xbox=5]="Xbox",e[e.Switch=6]="Switch",e[e.DualSense=7]="DualSense"}(A||(A={})),function(e){e[e.Horizontal=0]="Horizontal",e[e.Vertical=1]="Vertical",e[e.LeftClick=2]="LeftClick",e[e.MiddleClick=3]="MiddleClick",e[e.RightClick=4]="RightClick",e[e.BrowserBack=5]="BrowserBack",e[e.BrowserForward=6]="BrowserForward",e[e.MouseWheelX=7]="MouseWheelX",e[e.MouseWheelY=8]="MouseWheelY",e[e.MouseWheelZ=9]="MouseWheelZ",e[e.Move=12]="Move"}(R||(R={})),function(e){e[e.Horizontal=0]="Horizontal",e[e.Vertical=1]="Vertical",e[e.LeftClick=2]="LeftClick",e[e.MiddleClick=3]="MiddleClick",e[e.RightClick=4]="RightClick",e[e.BrowserBack=5]="BrowserBack",e[e.BrowserForward=6]="BrowserForward",e[e.MouseWheelX=7]="MouseWheelX",e[e.MouseWheelY=8]="MouseWheelY",e[e.MouseWheelZ=9]="MouseWheelZ",e[e.DeltaHorizontal=10]="DeltaHorizontal",e[e.DeltaVertical=11]="DeltaVertical"}(M||(M={})),function(e){e[e.Cross=0]="Cross",e[e.Circle=1]="Circle",e[e.Square=2]="Square",e[e.Triangle=3]="Triangle",e[e.L1=4]="L1",e[e.R1=5]="R1",e[e.L2=6]="L2",e[e.R2=7]="R2",e[e.Share=8]="Share",e[e.Options=9]="Options",e[e.L3=10]="L3",e[e.R3=11]="R3",e[e.DPadUp=12]="DPadUp",e[e.DPadDown=13]="DPadDown",e[e.DPadLeft=14]="DPadLeft",e[e.DPadRight=15]="DPadRight",e[e.Home=16]="Home",e[e.TouchPad=17]="TouchPad",e[e.LStickXAxis=18]="LStickXAxis",e[e.LStickYAxis=19]="LStickYAxis",e[e.RStickXAxis=20]="RStickXAxis",e[e.RStickYAxis=21]="RStickYAxis"}(y||(y={})),function(e){e[e.Cross=0]="Cross",e[e.Circle=1]="Circle",e[e.Square=2]="Square",e[e.Triangle=3]="Triangle",e[e.L1=4]="L1",e[e.R1=5]="R1",e[e.L2=6]="L2",e[e.R2=7]="R2",e[e.Create=8]="Create",e[e.Options=9]="Options",e[e.L3=10]="L3",e[e.R3=11]="R3",e[e.DPadUp=12]="DPadUp",e[e.DPadDown=13]="DPadDown",e[e.DPadLeft=14]="DPadLeft",e[e.DPadRight=15]="DPadRight",e[e.Home=16]="Home",e[e.TouchPad=17]="TouchPad",e[e.LStickXAxis=18]="LStickXAxis",e[e.LStickYAxis=19]="LStickYAxis",e[e.RStickXAxis=20]="RStickXAxis",e[e.RStickYAxis=21]="RStickYAxis"}(P||(P={})),function(e){e[e.A=0]="A",e[e.B=1]="B",e[e.X=2]="X",e[e.Y=3]="Y",e[e.LB=4]="LB",e[e.RB=5]="RB",e[e.LT=6]="LT",e[e.RT=7]="RT",e[e.Back=8]="Back",e[e.Start=9]="Start",e[e.LS=10]="LS",e[e.RS=11]="RS",e[e.DPadUp=12]="DPadUp",e[e.DPadDown=13]="DPadDown",e[e.DPadLeft=14]="DPadLeft",e[e.DPadRight=15]="DPadRight",e[e.Home=16]="Home",e[e.LStickXAxis=17]="LStickXAxis",e[e.LStickYAxis=18]="LStickYAxis",e[e.RStickXAxis=19]="RStickXAxis",e[e.RStickYAxis=20]="RStickYAxis"}(v||(v={})),function(e){e[e.B=0]="B",e[e.A=1]="A",e[e.Y=2]="Y",e[e.X=3]="X",e[e.L=4]="L",e[e.R=5]="R",e[e.ZL=6]="ZL",e[e.ZR=7]="ZR",e[e.Minus=8]="Minus",e[e.Plus=9]="Plus",e[e.LS=10]="LS",e[e.RS=11]="RS",e[e.DPadUp=12]="DPadUp",e[e.DPadDown=13]="DPadDown",e[e.DPadLeft=14]="DPadLeft",e[e.DPadRight=15]="DPadRight",e[e.Home=16]="Home",e[e.Capture=17]="Capture",e[e.LStickXAxis=18]="LStickXAxis",e[e.LStickYAxis=19]="LStickYAxis",e[e.RStickXAxis=20]="RStickXAxis",e[e.RStickYAxis=21]="RStickYAxis"}(C||(C={}));var I=s(8123);class D{static CreateDeviceEvent(e,t,s,i,r,n,a){switch(e){case A.Keyboard:return this._CreateKeyboardEvent(s,i,r,n);case A.Mouse:if(s===R.MouseWheelX||s===R.MouseWheelY||s===R.MouseWheelZ)return this._CreateWheelEvent(e,t,s,i,r,n);case A.Touch:return this._CreatePointerEvent(e,t,s,i,r,n,a);default:throw`Unable to generate event for device ${A[e]}`}}static _CreatePointerEvent(e,t,s,i,r,n,a){const o=this._CreateMouseEvent(e,t,s,i,r,n);e===A.Mouse?(o.deviceType=A.Mouse,o.pointerId=1,o.pointerType="mouse"):(o.deviceType=A.Touch,o.pointerId=a??t,o.pointerType="touch");let h=0;return h+=r.pollInput(e,t,R.LeftClick),h+=2*r.pollInput(e,t,R.RightClick),h+=4*r.pollInput(e,t,R.MiddleClick),o.buttons=h,s===R.Move?o.type="pointermove":s>=R.LeftClick&&s<=R.RightClick&&(o.type=1===i?"pointerdown":"pointerup",o.button=s-2),o}static _CreateWheelEvent(e,t,s,i,r,n){const a=this._CreateMouseEvent(e,t,s,i,r,n);switch(a.pointerId=1,a.type="wheel",a.deltaMode=I.s.DOM_DELTA_PIXEL,a.deltaX=0,a.deltaY=0,a.deltaZ=0,s){case R.MouseWheelX:a.deltaX=i;break;case R.MouseWheelY:a.deltaY=i;break;case R.MouseWheelZ:a.deltaZ=i}return a}static _CreateMouseEvent(e,t,s,i,r,n){const a=this._CreateEvent(n),o=r.pollInput(e,t,R.Horizontal),h=r.pollInput(e,t,R.Vertical);return n?(a.movementX=0,a.movementY=0,a.offsetX=a.movementX-n.getBoundingClientRect().x,a.offsetY=a.movementY-n.getBoundingClientRect().y):(a.movementX=r.pollInput(e,t,10),a.movementY=r.pollInput(e,t,11),a.offsetX=0,a.offsetY=0),this._CheckNonCharacterKeys(a,r),a.clientX=o,a.clientY=h,a.x=o,a.y=h,a.deviceType=e,a.deviceSlot=t,a.inputIndex=s,a}static _CreateKeyboardEvent(e,t,s,i){const r=this._CreateEvent(i);return this._CheckNonCharacterKeys(r,s),r.deviceType=A.Keyboard,r.deviceSlot=0,r.inputIndex=e,r.type=1===t?"keydown":"keyup",r.key=String.fromCharCode(e),r.keyCode=e,r}static _CheckNonCharacterKeys(e,t){const s=t.isDeviceAvailable(A.Keyboard),i=s&&1===t.pollInput(A.Keyboard,0,18),r=s&&1===t.pollInput(A.Keyboard,0,17),n=s&&(1===t.pollInput(A.Keyboard,0,91)||1===t.pollInput(A.Keyboard,0,92)||1===t.pollInput(A.Keyboard,0,93)),a=s&&1===t.pollInput(A.Keyboard,0,16);e.altKey=i,e.ctrlKey=r,e.metaKey=n,e.shiftKey=a}static _CreateEvent(e){const t={preventDefault:()=>{}};return t.target=e,t}}class O{constructor(e,t,s){this._nativeInput=_native.DeviceInputSystem?new _native.DeviceInputSystem(e,t,((e,t,i,r)=>{const n=D.CreateDeviceEvent(e,t,i,r,this);s(e,t,n)})):this._createDummyNativeInput()}pollInput(e,t,s){return this._nativeInput.pollInput(e,t,s)}isDeviceAvailable(e){return e===A.Mouse||e===A.Touch}dispose(){this._nativeInput.dispose()}_createDummyNativeInput(){return{pollInput:()=>0,isDeviceAvailable:()=>!1,dispose:()=>{}}}}const F=Object.keys(R).length/2;class w{constructor(e,t,s,r){this._inputs=[],this._keyboardActive=!1,this._pointerActive=!1,this._usingSafari=i.S0.IsSafari(),this._usingMacOS=(0,m.XD)()&&/(Mac|iPhone|iPod|iPad)/i.test(navigator.platform),this._keyboardDownEvent=e=>{},this._keyboardUpEvent=e=>{},this._keyboardBlurEvent=e=>{},this._pointerMoveEvent=e=>{},this._pointerDownEvent=e=>{},this._pointerUpEvent=e=>{},this._pointerCancelEvent=e=>{},this._pointerWheelEvent=e=>{},this._pointerBlurEvent=e=>{},this._pointerMacOSChromeOutEvent=e=>{},this._eventsAttached=!1,this._mouseId=-1,this._isUsingFirefox=(0,m.XD)()&&navigator.userAgent&&-1!==navigator.userAgent.indexOf("Firefox"),this._isUsingChromium=(0,m.XD)()&&navigator.userAgent&&-1!==navigator.userAgent.indexOf("Chrome"),this._maxTouchPoints=0,this._pointerInputClearObserver=null,this._gamepadConnectedEvent=e=>{},this._gamepadDisconnectedEvent=e=>{},this._eventPrefix=i.S0.GetPointerPrefix(e),this._engine=e,this._onDeviceConnected=t,this._onDeviceDisconnected=s,this._onInputChanged=r,this._mouseId=this._isUsingFirefox?0:1,this._enableEvents(),this._usingMacOS&&(this._metaKeys=[]),this._engine._onEngineViewChanged||(this._engine._onEngineViewChanged=()=>{this._enableEvents()})}pollInput(e,t,s){const r=this._inputs[e][t];if(!r)throw`Unable to find device ${A[e]}`;e>=A.DualShock&&e<=A.DualSense&&this._updateDevice(e,t,s);const n=r[s];if(void 0===n)throw`Unable to find input ${s} for device ${A[e]} in slot ${t}`;return s===R.Move&&i.S0.Warn("Unable to provide information for PointerInput.Move. Try using PointerInput.Horizontal or PointerInput.Vertical for move data."),n}isDeviceAvailable(e){return void 0!==this._inputs[e]}dispose(){this._onDeviceConnected=()=>{},this._onDeviceDisconnected=()=>{},this._onInputChanged=()=>{},delete this._engine._onEngineViewChanged,this._elementToAttachTo&&this._disableEvents()}_enableEvents(){const e=this?._engine.getInputElement();if(e&&(!this._eventsAttached||this._elementToAttachTo!==e)){if(this._disableEvents(),this._inputs)for(const e of this._inputs)if(e)for(const t in e){const s=e[+t];if(s)for(let e=0;e{this._keyboardActive||(this._keyboardActive=!0,this._registerDevice(A.Keyboard,0,255));const t=this._inputs[A.Keyboard][0];if(t){t[e.keyCode]=1;const s=e;s.inputIndex=e.keyCode,this._usingMacOS&&e.metaKey&&"Meta"!==e.key&&(this._metaKeys.includes(e.keyCode)||this._metaKeys.push(e.keyCode)),this._onInputChanged(A.Keyboard,0,s)}},this._keyboardUpEvent=e=>{this._keyboardActive||(this._keyboardActive=!0,this._registerDevice(A.Keyboard,0,255));const t=this._inputs[A.Keyboard][0];if(t){t[e.keyCode]=0;const s=e;if(s.inputIndex=e.keyCode,this._usingMacOS&&"Meta"===e.key&&this._metaKeys.length>0){for(const e of this._metaKeys){const s=D.CreateDeviceEvent(A.Keyboard,0,e,0,this,this._elementToAttachTo);t[e]=0,this._onInputChanged(A.Keyboard,0,s)}this._metaKeys.splice(0,this._metaKeys.length)}this._onInputChanged(A.Keyboard,0,s)}},this._keyboardBlurEvent=()=>{if(this._keyboardActive){const e=this._inputs[A.Keyboard][0];for(let t=0;t{const t=this._getPointerType(e);let s=t===A.Mouse?0:this._activeTouchIds.indexOf(e.pointerId);if(t===A.Touch&&-1===s){const r=this._activeTouchIds.indexOf(-1);if(!(r>=0))return void i.S0.Warn(`Max number of touches exceeded. Ignoring touches in excess of ${this._maxTouchPoints}`);s=r,this._activeTouchIds[r]=e.pointerId,this._onDeviceConnected(t,s)}this._inputs[t]||(this._inputs[t]={}),this._inputs[t][s]||this._addPointerDevice(t,s,e.clientX,e.clientY);const r=this._inputs[t][s];if(r){const i=e;i.inputIndex=R.Move,r[R.Horizontal]=e.clientX,r[R.Vertical]=e.clientY,t===A.Touch&&0===r[R.LeftClick]&&(r[R.LeftClick]=1),void 0===e.pointerId&&(e.pointerId=this._mouseId),this._onInputChanged(t,s,i),this._usingSafari||-1===e.button||(i.inputIndex=e.button+2,r[e.button+2]=r[e.button+2]?0:1,this._onInputChanged(t,s,i))}},this._pointerDownEvent=e=>{const t=this._getPointerType(e);let s=t===A.Mouse?0:e.pointerId;if(t===A.Touch){let t=this._activeTouchIds.indexOf(e.pointerId);if(-1===t&&(t=this._activeTouchIds.indexOf(-1)),!(t>=0))return void i.S0.Warn(`Max number of touches exceeded. Ignoring touches in excess of ${this._maxTouchPoints}`);s=t,this._activeTouchIds[t]=e.pointerId}this._inputs[t]||(this._inputs[t]={}),this._inputs[t][s]?t===A.Touch&&this._onDeviceConnected(t,s):this._addPointerDevice(t,s,e.clientX,e.clientY);const r=this._inputs[t][s];if(r){const i=r[R.Horizontal],n=r[R.Vertical];if(t===A.Mouse){if(void 0===e.pointerId&&(e.pointerId=this._mouseId),!document.pointerLockElement)try{this._elementToAttachTo.setPointerCapture(this._mouseId)}catch(e){}}else if(e.pointerId&&!document.pointerLockElement)try{this._elementToAttachTo.setPointerCapture(e.pointerId)}catch(e){}r[R.Horizontal]=e.clientX,r[R.Vertical]=e.clientY,r[e.button+2]=1;const a=e;a.inputIndex=e.button+2,this._onInputChanged(t,s,a),i===e.clientX&&n===e.clientY||(a.inputIndex=R.Move,this._onInputChanged(t,s,a))}},this._pointerUpEvent=e=>{const t=this._getPointerType(e),s=t===A.Mouse?0:this._activeTouchIds.indexOf(e.pointerId);if(t===A.Touch){if(-1===s)return;this._activeTouchIds[s]=-1}const i=this._inputs[t]?.[s];if(i&&0!==i[e.button+2]){const r=i[R.Horizontal],n=i[R.Vertical];i[R.Horizontal]=e.clientX,i[R.Vertical]=e.clientY,i[e.button+2]=0;const a=e;void 0===e.pointerId&&(e.pointerId=this._mouseId),r===e.clientX&&n===e.clientY||(a.inputIndex=R.Move,this._onInputChanged(t,s,a)),a.inputIndex=e.button+2,t===A.Mouse&&this._mouseId>=0&&this._elementToAttachTo.hasPointerCapture?.(this._mouseId)?this._elementToAttachTo.releasePointerCapture(this._mouseId):e.pointerId&&this._elementToAttachTo.hasPointerCapture?.(e.pointerId)&&this._elementToAttachTo.releasePointerCapture(e.pointerId),this._onInputChanged(t,s,a),t===A.Touch&&this._onDeviceDisconnected(t,s)}},this._pointerCancelEvent=e=>{if("mouse"===e.pointerType){const e=this._inputs[A.Mouse][0];this._mouseId>=0&&this._elementToAttachTo.hasPointerCapture?.(this._mouseId)&&this._elementToAttachTo.releasePointerCapture(this._mouseId);for(let t=R.LeftClick;t<=R.BrowserForward;t++)if(1===e[t]){e[t]=0;const s=D.CreateDeviceEvent(A.Mouse,0,t,0,this,this._elementToAttachTo);this._onInputChanged(A.Mouse,0,s)}}else{const t=this._activeTouchIds.indexOf(e.pointerId);if(-1===t)return;this._elementToAttachTo.hasPointerCapture?.(e.pointerId)&&this._elementToAttachTo.releasePointerCapture(e.pointerId),this._inputs[A.Touch][t][R.LeftClick]=0;const s=D.CreateDeviceEvent(A.Touch,t,R.LeftClick,0,this,this._elementToAttachTo,e.pointerId);this._onInputChanged(A.Touch,t,s),this._activeTouchIds[t]=-1,this._onDeviceDisconnected(A.Touch,t)}},this._wheelEventName="onwheel"in document.createElement("div")?"wheel":void 0!==document.onmousewheel?"mousewheel":"DOMMouseScroll";let e=!1;const t=function(){};try{const s=Object.defineProperty({},"passive",{get:function(){e=!0}});this._elementToAttachTo.addEventListener("test",t,s),this._elementToAttachTo.removeEventListener("test",t,s)}catch(e){}this._pointerBlurEvent=()=>{if(this.isDeviceAvailable(A.Mouse)){const e=this._inputs[A.Mouse][0];this._mouseId>=0&&this._elementToAttachTo.hasPointerCapture?.(this._mouseId)&&this._elementToAttachTo.releasePointerCapture(this._mouseId);for(let t=R.LeftClick;t<=R.BrowserForward;t++)if(1===e[t]){e[t]=0;const s=D.CreateDeviceEvent(A.Mouse,0,t,0,this,this._elementToAttachTo);this._onInputChanged(A.Mouse,0,s)}}if(this.isDeviceAvailable(A.Touch)){const e=this._inputs[A.Touch];for(let t=0;t{const t=A.Mouse;this._inputs[t]||(this._inputs[t]=[]),this._inputs[t][0]||(this._pointerActive=!0,this._registerDevice(t,0,F));const s=this._inputs[t][0];if(s){s[R.MouseWheelX]=e.deltaX||0,s[R.MouseWheelY]=e.deltaY||e.wheelDelta||0,s[R.MouseWheelZ]=e.deltaZ||0;const i=e;void 0===e.pointerId&&(e.pointerId=this._mouseId),0!==s[R.MouseWheelX]&&(i.inputIndex=R.MouseWheelX,this._onInputChanged(t,0,i)),0!==s[R.MouseWheelY]&&(i.inputIndex=R.MouseWheelY,this._onInputChanged(t,0,i)),0!==s[R.MouseWheelZ]&&(i.inputIndex=R.MouseWheelZ,this._onInputChanged(t,0,i))}},this._usingMacOS&&this._isUsingChromium&&(this._pointerMacOSChromeOutEvent=e=>{e.buttons>1&&this._pointerCancelEvent(e)},this._elementToAttachTo.addEventListener("lostpointercapture",this._pointerMacOSChromeOutEvent)),this._elementToAttachTo.addEventListener(this._eventPrefix+"move",this._pointerMoveEvent),this._elementToAttachTo.addEventListener(this._eventPrefix+"down",this._pointerDownEvent),this._elementToAttachTo.addEventListener(this._eventPrefix+"up",this._pointerUpEvent),this._elementToAttachTo.addEventListener(this._eventPrefix+"cancel",this._pointerCancelEvent),this._elementToAttachTo.addEventListener("blur",this._pointerBlurEvent),this._elementToAttachTo.addEventListener(this._wheelEventName,this._pointerWheelEvent,!!e&&{passive:!1}),this._pointerInputClearObserver=this._engine.onEndFrameObservable.add((()=>{if(this.isDeviceAvailable(A.Mouse)){const e=this._inputs[A.Mouse][0];e[R.MouseWheelX]=0,e[R.MouseWheelY]=0,e[R.MouseWheelZ]=0}}))}_handleGamepadActions(){this._gamepadConnectedEvent=e=>{this._addGamePad(e.gamepad)},this._gamepadDisconnectedEvent=e=>{if(this._gamepads){const t=this._getGamepadDeviceType(e.gamepad.id),s=e.gamepad.index;this._unregisterDevice(t,s),delete this._gamepads[s]}},window.addEventListener("gamepadconnected",this._gamepadConnectedEvent),window.addEventListener("gamepaddisconnected",this._gamepadDisconnectedEvent)}_updateDevice(e,t,s){const i=navigator.getGamepads()[t];if(i&&e===this._gamepads[t]){const r=this._inputs[e][t];s>=i.buttons.length?r[s]=i.axes[s-i.buttons.length].valueOf():r[s]=i.buttons[s].value}}_getGamepadDeviceType(e){return-1!==e.indexOf("054c")?-1!==e.indexOf("0ce6")?A.DualSense:A.DualShock:-1!==e.indexOf("Xbox One")||-1!==e.search("Xbox 360")||-1!==e.search("xinput")?A.Xbox:-1!==e.indexOf("057e")?A.Switch:A.Generic}_getPointerType(e){let t=A.Mouse;return("touch"===e.pointerType||"pen"===e.pointerType||e.touches)&&(t=A.Touch),t}}class L{constructor(e,t,s=0){this.deviceType=t,this.deviceSlot=s,this.onInputChangedObservable=new n.cP,this._deviceInputSystem=e}getInput(e){return this._deviceInputSystem.pollInput(this.deviceType,this.deviceSlot,e)}}class B{constructor(e){this._registeredManagers=new Array,this._refCount=0,this.registerManager=e=>{for(let t=0;t{const t=this._registeredManagers.indexOf(e);t>-1&&this._registeredManagers.splice(t,1)};const t=Object.keys(A).length/2;this._devices=new Array(t);const s=(e,t)=>{this._devices[e]||(this._devices[e]=new Array),this._devices[e][t]||(this._devices[e][t]=t);for(const s of this._registeredManagers){const i=new L(this._deviceInputSystem,e,t);s._addDevice(i)}},i=(e,t)=>{this._devices[e]?.[t]&&delete this._devices[e][t];for(const s of this._registeredManagers)s._removeDevice(e,t)},r=(e,t,s)=>{if(s)for(const i of this._registeredManagers)i._onInputChanged(e,t,s)};"undefined"!=typeof _native?this._deviceInputSystem=new O(s,i,r):this._deviceInputSystem=new w(e,s,i,r)}dispose(){this._deviceInputSystem.dispose()}}class N{getDeviceSource(e,t){if(void 0===t){if(void 0===this._firstDevice[e])return null;t=this._firstDevice[e]}return this._devices[e]&&void 0!==this._devices[e][t]?this._devices[e][t]:null}getDeviceSources(e){return this._devices[e]?this._devices[e].filter((e=>!!e)):[]}constructor(e){const t=Object.keys(A).length/2;this._devices=new Array(t),this._firstDevice=new Array(t),this._engine=e,this._engine._deviceSourceManager||(this._engine._deviceSourceManager=new B(e)),this._engine._deviceSourceManager._refCount++,this.onDeviceConnectedObservable=new n.cP((e=>{for(const t of this._devices)if(t)for(const s of t)s&&this.onDeviceConnectedObservable.notifyObserver(e,s)})),this.onDeviceDisconnectedObservable=new n.cP,this._engine._deviceSourceManager.registerManager(this),this._onDisposeObserver=e.onDisposeObservable.add((()=>{this.dispose()}))}dispose(){this.onDeviceConnectedObservable.clear(),this.onDeviceDisconnectedObservable.clear(),this._engine._deviceSourceManager&&(this._engine._deviceSourceManager.unregisterManager(this),--this._engine._deviceSourceManager._refCount<1&&(this._engine._deviceSourceManager.dispose(),delete this._engine._deviceSourceManager)),this._engine.onDisposeObservable.remove(this._onDisposeObserver)}_addDevice(e){this._devices[e.deviceType]||(this._devices[e.deviceType]=new Array),this._devices[e.deviceType][e.deviceSlot]||(this._devices[e.deviceType][e.deviceSlot]=e,this._updateFirstDevices(e.deviceType)),this.onDeviceConnectedObservable.notifyObservers(e)}_removeDevice(e,t){const s=this._devices[e]?.[t];this.onDeviceDisconnectedObservable.notifyObservers(s),this._devices[e]?.[t]&&delete this._devices[e][t],this._updateFirstDevices(e)}_onInputChanged(e,t,s){this._devices[e]?.[t]?.onInputChangedObservable.notifyObservers(s)}_updateFirstDevices(e){switch(e){case A.Keyboard:case A.Mouse:this._firstDevice[e]=0;break;case A.Touch:case A.DualSense:case A.DualShock:case A.Xbox:case A.Switch:case A.Generic:{delete this._firstDevice[e];const t=this._devices[e];if(t)for(let s=0;s=R.MouseWheelX&&t.inputIndex<=R.MouseWheelZ?E.Zp.POINTERWHEEL:E.Zp.POINTERMOVE;let a;s.onPointerMove&&(e=e||this._pickMove(t),s.onPointerMove(t,e,n)),e?(a=new E.mx(n,t,e),this._setRayOnPointerInfo(e,t)):(a=new E.mx(n,t,null,this),this._movePointerInfo=a),s.onPointerObservable.hasObservers()&&s.onPointerObservable.notifyObservers(a,n)}_setRayOnPointerInfo(e,t){const s=this._scene;e&&U._IsPickingAvailable&&(e.ray||(e.ray=s.createPickingRay(t.offsetX,t.offsetY,l.uq.Identity(),s.activeCamera)))}_addCameraPointerObserver(e,t){return this._cameraObserverCount++,this._scene.onPointerObservable.add(e,t)}_removeCameraPointerObserver(e){return this._cameraObserverCount--,this._scene.onPointerObservable.remove(e)}_checkForPicking(){return!!(this._scene.onPointerObservable.observers.length>this._cameraObserverCount||this._scene.onPointerPick)}_checkPrePointerObservable(e,t,s){const i=this._scene,r=new E.tT(s,t,this._unTranslatedPointerX,this._unTranslatedPointerY);return e&&(r.originalPickingInfo=e,r.ray=e.ray,"xr-near"===t.pointerType&&e.originMesh&&(r.nearInteractionPickingInfo=e)),i.onPrePointerObservable.notifyObservers(r,s),!!r.skipOnPointerObservable}_pickMove(e){const t=this._scene,s=t.pick(this._unTranslatedPointerX,this._unTranslatedPointerY,t.pointerMovePredicate,t.pointerMoveFastCheck,t.cameraToUseForPointers,t.pointerMoveTrianglePredicate);return this._setCursorAndPointerOverMesh(s,e,t),s}_setCursorAndPointerOverMesh(e,t,s){const i=s.getEngine().getInputElement();if(e?.pickedMesh){if(this.setPointerOverMesh(e.pickedMesh,t.pointerId,e,t),!s.doNotHandleCursors&&i&&this._pointerOverMesh){const e=this._pointerOverMesh._getActionManagerForTrigger();e&&e.hasPointerTriggers&&(i.style.cursor=e.hoverCursor||s.hoverCursor)}}else this.setPointerOverMesh(null,t.pointerId,e,t)}simulatePointerMove(e,t){const s=new PointerEvent("pointermove",t);s.inputIndex=R.Move,this._checkPrePointerObservable(e,s,E.Zp.POINTERMOVE)||this._processPointerMove(e,s)}simulatePointerDown(e,t){const s=new PointerEvent("pointerdown",t);s.inputIndex=s.button+2,this._checkPrePointerObservable(e,s,E.Zp.POINTERDOWN)||this._processPointerDown(e,s)}_processPointerDown(e,t){const s=this._scene;if(e?.pickedMesh){this._pickedDownMesh=e.pickedMesh;const i=e.pickedMesh._getActionManagerForTrigger();if(i){if(i.hasPickTriggers)switch(i.processTrigger(5,_.CreateNew(e.pickedMesh,t,e)),t.button){case 0:i.processTrigger(2,_.CreateNew(e.pickedMesh,t,e));break;case 1:i.processTrigger(4,_.CreateNew(e.pickedMesh,t,e));break;case 2:i.processTrigger(3,_.CreateNew(e.pickedMesh,t,e))}i.hasSpecificTrigger(8)&&window.setTimeout((()=>{const e=s.pick(this._unTranslatedPointerX,this._unTranslatedPointerY,(e=>e.isPickable&&e.isVisible&&e.isReady()&&e.actionManager&&e.actionManager.hasSpecificTrigger(8)&&e===this._pickedDownMesh),!1,s.cameraToUseForPointers);e?.pickedMesh&&i&&0!==this._activePointerIdsCount&&Date.now()-this._startingPointerTime>V.LongPressDelay&&!this._isPointerSwiping()&&(this._startingPointerTime=0,i.processTrigger(8,_.CreateNew(e.pickedMesh,t)))}),V.LongPressDelay)}}else for(const i of s._pointerDownStage)e=i.action(this._unTranslatedPointerX,this._unTranslatedPointerY,e,t,!1);let i;const r=E.Zp.POINTERDOWN;e?(s.onPointerDown&&s.onPointerDown(t,e,r),i=new E.mx(r,t,e),this._setRayOnPointerInfo(e,t)):i=new E.mx(r,t,null,this),s.onPointerObservable.hasObservers()&&s.onPointerObservable.notifyObservers(i,r)}_isPointerSwiping(){return this._isSwiping}simulatePointerUp(e,t,s){const i=new PointerEvent("pointerup",t);i.inputIndex=R.Move;const r=new k;s?r.doubleClick=!0:r.singleClick=!0,this._checkPrePointerObservable(e,i,E.Zp.POINTERUP)||this._processPointerUp(e,i,r)}_processPointerUp(e,t,s){const i=this._scene;if(e?.pickedMesh){if(this._pickedUpMesh=e.pickedMesh,this._pickedDownMesh===this._pickedUpMesh&&(i.onPointerPick&&i.onPointerPick(t,e),s.singleClick&&!s.ignore&&i.onPointerObservable.observers.length>this._cameraObserverCount)){const s=E.Zp.POINTERPICK,r=new E.mx(s,t,e);this._setRayOnPointerInfo(e,t),i.onPointerObservable.notifyObservers(r,s)}const r=e.pickedMesh._getActionManagerForTrigger();if(r&&!s.ignore){r.processTrigger(7,_.CreateNew(e.pickedMesh,t,e)),!s.hasSwiped&&s.singleClick&&r.processTrigger(1,_.CreateNew(e.pickedMesh,t,e));const i=e.pickedMesh._getActionManagerForTrigger(6);s.doubleClick&&i&&i.processTrigger(6,_.CreateNew(e.pickedMesh,t,e))}}else if(!s.ignore)for(const r of i._pointerUpStage)e=r.action(this._unTranslatedPointerX,this._unTranslatedPointerY,e,t,s.doubleClick);if(this._pickedDownMesh&&this._pickedDownMesh!==this._pickedUpMesh){const e=this._pickedDownMesh._getActionManagerForTrigger(16);e&&e.processTrigger(16,_.CreateNew(this._pickedDownMesh,t))}if(!s.ignore){const r=new E.mx(E.Zp.POINTERUP,t,e);if(this._setRayOnPointerInfo(e,t),i.onPointerObservable.notifyObservers(r,E.Zp.POINTERUP),i.onPointerUp&&i.onPointerUp(t,e,E.Zp.POINTERUP),!s.hasSwiped&&!this._skipPointerTap&&!this._isMultiTouchGesture){let r=0;if(s.singleClick?r=E.Zp.POINTERTAP:s.doubleClick&&(r=E.Zp.POINTERDOUBLETAP),r){const s=new E.mx(r,t,e);i.onPointerObservable.hasObservers()&&i.onPointerObservable.hasSpecificMask(r)&&i.onPointerObservable.notifyObservers(s,r)}}}}isPointerCaptured(e=0){return this._pointerCaptures[e]}attachControl(e=!0,t=!0,s=!0,i=null){const r=this._scene,n=r.getEngine();i||(i=n.getInputElement()),this._alreadyAttached&&this.detachControl(),i&&(this._alreadyAttachedTo=i),this._deviceSourceManager=new N(n),this._initActionManager=e=>{if(!this._meshPickProceed){const t=r.skipPointerUpPicking||0===r._registeredActions&&!this._checkForPicking()&&!r.onPointerUp?null:r.pick(this._unTranslatedPointerX,this._unTranslatedPointerY,r.pointerUpPredicate,r.pointerUpFastCheck,r.cameraToUseForPointers,r.pointerUpTrianglePredicate);this._currentPickResult=t,t&&(e=t.hit&&t.pickedMesh?t.pickedMesh._getActionManagerForTrigger():null),this._meshPickProceed=!0}return e},this._delayedSimpleClick=(e,t,s)=>{if((Date.now()-this._previousStartingPointerTime>V.DoubleClickDelay&&!this._doubleClickOccured||e!==this._previousButtonPressed)&&(this._doubleClickOccured=!1,t.singleClick=!0,t.ignore=!1,this._delayedClicks[e])){const t=this._delayedClicks[e].evt,s=E.Zp.POINTERTAP,i=new E.mx(s,t,this._currentPickResult);r.onPointerObservable.hasObservers()&&r.onPointerObservable.hasSpecificMask(s)&&r.onPointerObservable.notifyObservers(i,s),this._delayedClicks[e]=null}},this._initClickEvent=(e,t,s,i)=>{const r=new k;this._currentPickResult=null;let n=null,a=e.hasSpecificMask(E.Zp.POINTERPICK)||t.hasSpecificMask(E.Zp.POINTERPICK)||e.hasSpecificMask(E.Zp.POINTERTAP)||t.hasSpecificMask(E.Zp.POINTERTAP)||e.hasSpecificMask(E.Zp.POINTERDOUBLETAP)||t.hasSpecificMask(E.Zp.POINTERDOUBLETAP);!a&&x&&(n=this._initActionManager(n,r),n&&(a=n.hasPickTriggers));let o=!1;if(a){const a=s.button;if(r.hasSwiped=this._isPointerSwiping(),!r.hasSwiped){let h=!V.ExclusiveDoubleClickMode;if(h||(h=!e.hasSpecificMask(E.Zp.POINTERDOUBLETAP)&&!t.hasSpecificMask(E.Zp.POINTERDOUBLETAP),h&&!x.HasSpecificTrigger(6)&&(n=this._initActionManager(n,r),n&&(h=!n.hasSpecificTrigger(6)))),h)(Date.now()-this._previousStartingPointerTime>V.DoubleClickDelay||a!==this._previousButtonPressed)&&(r.singleClick=!0,i(r,this._currentPickResult),o=!0);else{const e={evt:s,clickInfo:r,timeoutId:window.setTimeout(this._delayedSimpleClick.bind(this,a,r,i),V.DoubleClickDelay)};this._delayedClicks[a]=e}let l=e.hasSpecificMask(E.Zp.POINTERDOUBLETAP)||t.hasSpecificMask(E.Zp.POINTERDOUBLETAP);!l&&x.HasSpecificTrigger(6)&&(n=this._initActionManager(n,r),n&&(l=n.hasSpecificTrigger(6))),l&&(a===this._previousButtonPressed&&Date.now()-this._previousStartingPointerTime{if(this._updatePointerPosition(e),this._isSwiping||-1===this._swipeButtonPressed||(this._isSwiping=Math.abs(this._startingPointerPosition.x-this._pointerX)>V.DragMovementThreshold||Math.abs(this._startingPointerPosition.y-this._pointerY)>V.DragMovementThreshold),n.isPointerLock&&n._verifyPointerLock(),this._checkPrePointerObservable(null,e,e.inputIndex>=R.MouseWheelX&&e.inputIndex<=R.MouseWheelZ?E.Zp.POINTERWHEEL:E.Zp.POINTERMOVE))return;if(!r.cameraToUseForPointers&&!r.activeCamera)return;if(r.skipPointerMovePicking)return void this._processPointerMove(new d.G,e);r.pointerMovePredicate||(r.pointerMovePredicate=e=>e.isPickable&&e.isVisible&&e.isReady()&&e.isEnabled()&&(e.enablePointerMoveEvents||r.constantlyUpdateMeshUnderPointer||null!==e._getActionManagerForTrigger())&&(!r.cameraToUseForPointers||0!=(r.cameraToUseForPointers.layerMask&e.layerMask)));const t=r._registeredActions>0||r.constantlyUpdateMeshUnderPointer?this._pickMove(e):null;this._processPointerMove(t,e)},this._onPointerDown=e=>{const t=this._activePointerIds.indexOf(-1);if(-1===t?this._activePointerIds.push(e.pointerId):this._activePointerIds[t]=e.pointerId,this._activePointerIdsCount++,this._pickedDownMesh=null,this._meshPickProceed=!1,V.ExclusiveDoubleClickMode)for(let t=0;te.isPickable&&e.isVisible&&e.isReady()&&e.isEnabled()&&(!r.cameraToUseForPointers||0!=(r.cameraToUseForPointers.layerMask&e.layerMask))),this._pickedDownMesh=null,s=r.skipPointerDownPicking||0===r._registeredActions&&!this._checkForPicking()&&!r.onPointerDown?new d.G:r.pick(this._unTranslatedPointerX,this._unTranslatedPointerY,r.pointerDownPredicate,r.pointerDownFastCheck,r.cameraToUseForPointers,r.pointerDownTrianglePredicate),this._processPointerDown(s,e)},this._onPointerUp=e=>{const t=this._activePointerIds.indexOf(e.pointerId);-1!==t&&(this._activePointerIds[t]=-1,this._activePointerIdsCount--,this._pickedUpMesh=null,this._meshPickProceed=!1,this._updatePointerPosition(e),r.preventDefaultOnPointerUp&&i&&(e.preventDefault(),i.focus()),this._initClickEvent(r.onPrePointerObservable,r.onPointerObservable,e,((t,s)=>{if(r.onPrePointerObservable.hasObservers()&&(this._skipPointerTap=!1,!t.ignore)){if(this._checkPrePointerObservable(null,e,E.Zp.POINTERUP))return this._swipeButtonPressed===e.button&&(this._isSwiping=!1,this._swipeButtonPressed=-1),void(0===e.buttons&&(this._pointerCaptures[e.pointerId]=!1));t.hasSwiped||(t.singleClick&&r.onPrePointerObservable.hasSpecificMask(E.Zp.POINTERTAP)&&this._checkPrePointerObservable(null,e,E.Zp.POINTERTAP)&&(this._skipPointerTap=!0),t.doubleClick&&r.onPrePointerObservable.hasSpecificMask(E.Zp.POINTERDOUBLETAP)&&this._checkPrePointerObservable(null,e,E.Zp.POINTERDOUBLETAP)&&(this._skipPointerTap=!0))}this._pointerCaptures[e.pointerId]?(0===e.buttons&&(this._pointerCaptures[e.pointerId]=!1),(r.cameraToUseForPointers||r.activeCamera)&&(r.pointerUpPredicate||(r.pointerUpPredicate=e=>e.isPickable&&e.isVisible&&e.isReady()&&e.isEnabled()&&(!r.cameraToUseForPointers||0!=(r.cameraToUseForPointers.layerMask&e.layerMask))),!this._meshPickProceed&&(x&&x.HasTriggers||this._checkForPicking()||r.onPointerUp)&&this._initActionManager(null,t),s||(s=this._currentPickResult),this._processPointerUp(s,e,t),this._previousPickResult=this._currentPickResult,this._swipeButtonPressed===e.button&&(this._isSwiping=!1,this._swipeButtonPressed=-1))):this._swipeButtonPressed===e.button&&(this._isSwiping=!1,this._swipeButtonPressed=-1)})))},this._onKeyDown=e=>{const t=S.TB.KEYDOWN;if(r.onPreKeyboardObservable.hasObservers()){const s=new S.Bu(t,e);if(r.onPreKeyboardObservable.notifyObservers(s,t),s.skipOnKeyboardObservable)return}if(r.onKeyboardObservable.hasObservers()){const s=new S.W0(t,e);r.onKeyboardObservable.notifyObservers(s,t)}r.actionManager&&r.actionManager.processTrigger(14,_.CreateNewFromScene(r,e))},this._onKeyUp=e=>{const t=S.TB.KEYUP;if(r.onPreKeyboardObservable.hasObservers()){const s=new S.Bu(t,e);if(r.onPreKeyboardObservable.notifyObservers(s,t),s.skipOnKeyboardObservable)return}if(r.onKeyboardObservable.hasObservers()){const s=new S.W0(t,e);r.onKeyboardObservable.notifyObservers(s,t)}r.actionManager&&r.actionManager.processTrigger(15,_.CreateNewFromScene(r,e))},this._deviceSourceManager.onDeviceConnectedObservable.add((i=>{i.deviceType===A.Mouse?i.onInputChangedObservable.add((r=>{this._originMouseEvent=r,r.inputIndex===R.LeftClick||r.inputIndex===R.MiddleClick||r.inputIndex===R.RightClick||r.inputIndex===R.BrowserBack||r.inputIndex===R.BrowserForward?t&&1===i.getInput(r.inputIndex)?this._onPointerDown(r):e&&0===i.getInput(r.inputIndex)&&this._onPointerUp(r):s&&(r.inputIndex===R.Move?this._onPointerMove(r):r.inputIndex!==R.MouseWheelX&&r.inputIndex!==R.MouseWheelY&&r.inputIndex!==R.MouseWheelZ||this._onPointerMove(r))})):i.deviceType===A.Touch?i.onInputChangedObservable.add((r=>{r.inputIndex===R.LeftClick&&(t&&1===i.getInput(r.inputIndex)?(this._onPointerDown(r),this._activePointerIdsCount>1&&(this._isMultiTouchGesture=!0)):e&&0===i.getInput(r.inputIndex)&&(this._onPointerUp(r),0===this._activePointerIdsCount&&(this._isMultiTouchGesture=!1))),s&&r.inputIndex===R.Move&&this._onPointerMove(r)})):i.deviceType===A.Keyboard&&i.onInputChangedObservable.add((e=>{"keydown"===e.type?this._onKeyDown(e):"keyup"===e.type&&this._onKeyUp(e)}))})),this._alreadyAttached=!0}detachControl(){this._alreadyAttached&&(this._deviceSourceManager.dispose(),this._deviceSourceManager=null,this._alreadyAttachedTo&&!this._scene.doNotHandleCursors&&(this._alreadyAttachedTo.style.cursor=this._scene.defaultCursor),this._alreadyAttached=!1,this._alreadyAttachedTo=null)}setPointerOverMesh(e,t=0,s,i){if(!(this._meshUnderPointerId[t]!==e||e&&e._internalAbstractMeshDataInfo._pointerOverDisableMeshTesting))return;const r=this._meshUnderPointerId[t];let n;r&&(n=r._getActionManagerForTrigger(10),n&&n.processTrigger(10,_.CreateNew(r,i,{pointerId:t}))),e?(this._meshUnderPointerId[t]=e,this._pointerOverMesh=e,n=e._getActionManagerForTrigger(9),n&&n.processTrigger(9,_.CreateNew(e,i,{pointerId:t,pickResult:s}))):(delete this._meshUnderPointerId[t],this._pointerOverMesh=null)}getPointerOverMesh(){return this.meshUnderPointer}_invalidateMesh(e){this._pointerOverMesh===e&&(this._pointerOverMesh=null),this._pickedDownMesh===e&&(this._pickedDownMesh=null),this._pickedUpMesh===e&&(this._pickedUpMesh=null);for(const t in this._meshUnderPointerId)this._meshUnderPointerId[t]===e&&delete this._meshUnderPointerId[t]}}V.DragMovementThreshold=10,V.LongPressDelay=500,V.DoubleClickDelay=300,V.ExclusiveDoubleClickMode=!1;var G=s(4296),z=s(6041),W=s(2572);class H{static get UniqueId(){const e=this._UniqueIdCounter;return this._UniqueIdCounter++,e}}H._UniqueIdCounter=1;var K=s(655),q=s(5515),X=s(7309);class Y{constructor(){this.pointerDownFastCheck=!1,this.pointerUpFastCheck=!1,this.pointerMoveFastCheck=!1,this.skipPointerMovePicking=!1,this.skipPointerDownPicking=!1,this.skipPointerUpPicking=!1}}var j,Z=s(1137),Q=s(6552);!function(e){e[e.BackwardCompatible=0]="BackwardCompatible",e[e.Intermediate=1]="Intermediate",e[e.Aggressive=2]="Aggressive"}(j||(j={}));class ${static DefaultMaterialFactory(e){throw(0,b.n)("StandardMaterial")}static CollisionCoordinatorFactory(){throw(0,b.n)("DefaultCollisionCoordinator")}get clearColor(){return this._clearColor}set clearColor(e){e!==this._clearColor&&(this._clearColor=e,this.onClearColorChangedObservable.notifyObservers(this._clearColor))}get imageProcessingConfiguration(){return this._imageProcessingConfiguration}get performancePriority(){return this._performancePriority}set performancePriority(e){if(e!==this._performancePriority){switch(this._performancePriority=e,e){case 0:this.skipFrustumClipping=!1,this._renderingManager.maintainStateBetweenFrames=!1,this.skipPointerMovePicking=!1,this.autoClear=!0;break;case 1:this.skipFrustumClipping=!1,this._renderingManager.maintainStateBetweenFrames=!1,this.skipPointerMovePicking=!0,this.autoClear=!1;break;case 2:this.skipFrustumClipping=!0,this._renderingManager.maintainStateBetweenFrames=!0,this.skipPointerMovePicking=!0,this.autoClear=!1}this.onScenePerformancePriorityChangedObservable.notifyObservers(e)}}set forceWireframe(e){this._forceWireframe!==e&&(this._forceWireframe=e,this.markAllMaterialsAsDirty(16))}get forceWireframe(){return this._forceWireframe}set skipFrustumClipping(e){this._skipFrustumClipping!==e&&(this._skipFrustumClipping=e)}get skipFrustumClipping(){return this._skipFrustumClipping}set forcePointsCloud(e){this._forcePointsCloud!==e&&(this._forcePointsCloud=e,this.markAllMaterialsAsDirty(16))}get forcePointsCloud(){return this._forcePointsCloud}get environmentTexture(){return this._environmentTexture}set environmentTexture(e){this._environmentTexture!==e&&(this._environmentTexture=e,this.markAllMaterialsAsDirty(1))}getNodes(){let e=[];return e=e.concat(this.meshes),e=e.concat(this.lights),e=e.concat(this.cameras),e=e.concat(this.transformNodes),this.skeletons.forEach((t=>e=e.concat(t.bones))),e}get animationPropertiesOverride(){return this._animationPropertiesOverride}set animationPropertiesOverride(e){this._animationPropertiesOverride=e}set onDispose(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)}set beforeRender(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),e&&(this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e))}set afterRender(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),e&&(this._onAfterRenderObserver=this.onAfterRenderObservable.add(e))}set beforeCameraRender(e){this._onBeforeCameraRenderObserver&&this.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),this._onBeforeCameraRenderObserver=this.onBeforeCameraRenderObservable.add(e)}set afterCameraRender(e){this._onAfterCameraRenderObserver&&this.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver),this._onAfterCameraRenderObserver=this.onAfterCameraRenderObservable.add(e)}get pointerDownPredicate(){return this._pointerPickingConfiguration.pointerDownPredicate}set pointerDownPredicate(e){this._pointerPickingConfiguration.pointerDownPredicate=e}get pointerUpPredicate(){return this._pointerPickingConfiguration.pointerUpPredicate}set pointerUpPredicate(e){this._pointerPickingConfiguration.pointerUpPredicate=e}get pointerMovePredicate(){return this._pointerPickingConfiguration.pointerMovePredicate}set pointerMovePredicate(e){this._pointerPickingConfiguration.pointerMovePredicate=e}get pointerDownFastCheck(){return this._pointerPickingConfiguration.pointerDownFastCheck}set pointerDownFastCheck(e){this._pointerPickingConfiguration.pointerDownFastCheck=e}get pointerUpFastCheck(){return this._pointerPickingConfiguration.pointerUpFastCheck}set pointerUpFastCheck(e){this._pointerPickingConfiguration.pointerUpFastCheck=e}get pointerMoveFastCheck(){return this._pointerPickingConfiguration.pointerMoveFastCheck}set pointerMoveFastCheck(e){this._pointerPickingConfiguration.pointerMoveFastCheck=e}get skipPointerMovePicking(){return this._pointerPickingConfiguration.skipPointerMovePicking}set skipPointerMovePicking(e){this._pointerPickingConfiguration.skipPointerMovePicking=e}get skipPointerDownPicking(){return this._pointerPickingConfiguration.skipPointerDownPicking}set skipPointerDownPicking(e){this._pointerPickingConfiguration.skipPointerDownPicking=e}get skipPointerUpPicking(){return this._pointerPickingConfiguration.skipPointerUpPicking}set skipPointerUpPicking(e){this._pointerPickingConfiguration.skipPointerUpPicking=e}get unTranslatedPointer(){return this._inputManager.unTranslatedPointer}static get DragMovementThreshold(){return V.DragMovementThreshold}static set DragMovementThreshold(e){V.DragMovementThreshold=e}static get LongPressDelay(){return V.LongPressDelay}static set LongPressDelay(e){V.LongPressDelay=e}static get DoubleClickDelay(){return V.DoubleClickDelay}static set DoubleClickDelay(e){V.DoubleClickDelay=e}static get ExclusiveDoubleClickMode(){return V.ExclusiveDoubleClickMode}static set ExclusiveDoubleClickMode(e){V.ExclusiveDoubleClickMode=e}bindEyePosition(e,t="vEyePosition",s=!1){const i=this._forcedViewPosition?this._forcedViewPosition:this._mirroredCameraPosition?this._mirroredCameraPosition:this.activeCamera.globalPosition,r=this.useRightHandedSystem===(null!=this._mirroredCameraPosition);return l.AA.Vector4[0].set(i.x,i.y,i.z,r?-1:1),e&&(s?e.setFloat3(t,l.AA.Vector4[0].x,l.AA.Vector4[0].y,l.AA.Vector4[0].z):e.setVector4(t,l.AA.Vector4[0])),l.AA.Vector4[0]}finalizeSceneUbo(){const e=this.getSceneUniformBuffer(),t=this.bindEyePosition(null);return e.updateFloat4("vEyePosition",t.x,t.y,t.z,t.w),e.update(),e}set useRightHandedSystem(e){this._useRightHandedSystem!==e&&(this._useRightHandedSystem=e,this.markAllMaterialsAsDirty(16))}get useRightHandedSystem(){return this._useRightHandedSystem}setStepId(e){this._currentStepId=e}getStepId(){return this._currentStepId}getInternalStep(){return this._currentInternalStep}set fogEnabled(e){this._fogEnabled!==e&&(this._fogEnabled=e,this.markAllMaterialsAsDirty(16))}get fogEnabled(){return this._fogEnabled}set fogMode(e){this._fogMode!==e&&(this._fogMode=e,this.markAllMaterialsAsDirty(16))}get fogMode(){return this._fogMode}get prePass(){return!!this.prePassRenderer&&this.prePassRenderer.defaultRT.enabled}set shadowsEnabled(e){this._shadowsEnabled!==e&&(this._shadowsEnabled=e,this.markAllMaterialsAsDirty(2))}get shadowsEnabled(){return this._shadowsEnabled}set lightsEnabled(e){this._lightsEnabled!==e&&(this._lightsEnabled=e,this.markAllMaterialsAsDirty(2))}get lightsEnabled(){return this._lightsEnabled}get activeCameras(){return this._activeCameras}set activeCameras(e){this._unObserveActiveCameras&&(this._unObserveActiveCameras(),this._unObserveActiveCameras=null),e&&(this._unObserveActiveCameras=(0,X.lL)(e,(()=>{this.onActiveCamerasChanged.notifyObservers(this)}))),this._activeCameras=e}get activeCamera(){return this._activeCamera}set activeCamera(e){e!==this._activeCamera&&(this._activeCamera=e,this.onActiveCameraChanged.notifyObservers(this))}get defaultMaterial(){return this._defaultMaterial||(this._defaultMaterial=$.DefaultMaterialFactory(this)),this._defaultMaterial}set defaultMaterial(e){this._defaultMaterial=e}set texturesEnabled(e){this._texturesEnabled!==e&&(this._texturesEnabled=e,this.markAllMaterialsAsDirty(1))}get texturesEnabled(){return this._texturesEnabled}get frameGraph(){return this._frameGraph}set frameGraph(e){if(this._frameGraph)return this._frameGraph=e,void(e||(this.customRenderFunction=this._currentCustomRenderFunction));this._frameGraph=e,e&&(this._currentCustomRenderFunction=this.customRenderFunction,this.customRenderFunction=this._renderWithFrameGraph)}set skeletonsEnabled(e){this._skeletonsEnabled!==e&&(this._skeletonsEnabled=e,this.markAllMaterialsAsDirty(8))}get skeletonsEnabled(){return this._skeletonsEnabled}get collisionCoordinator(){return this._collisionCoordinator||(this._collisionCoordinator=$.CollisionCoordinatorFactory(),this._collisionCoordinator.init(this)),this._collisionCoordinator}get renderingManager(){return this._renderingManager}get frustumPlanes(){return this._frustumPlanes}_registerTransientComponents(){if(this._transientComponents.length>0){for(const e of this._transientComponents)e.register();this._transientComponents.length=0}}_addComponent(e){this._components.push(e),this._transientComponents.push(e);const t=e;t.addFromContainer&&t.serialize&&this._serializableComponents.push(t)}_getComponent(e){for(const t of this._components)if(t.name===e)return t;return null}constructor(e,t){this._inputManager=new V(this),this.cameraToUseForPointers=null,this._isScene=!0,this._blockEntityCollection=!1,this.autoClear=!0,this.autoClearDepthAndStencil=!0,this._clearColor=new z.ov(.2,.2,.3,1),this.onClearColorChangedObservable=new n.cP,this.ambientColor=new z.v9(0,0,0),this.environmentIntensity=1,this._performancePriority=0,this.onScenePerformancePriorityChangedObservable=new n.cP,this._forceWireframe=!1,this._skipFrustumClipping=!1,this._forcePointsCloud=!1,this.rootNodes=[],this.cameras=[],this.lights=[],this.meshes=[],this.skeletons=[],this.particleSystems=[],this.animations=[],this.animationGroups=[],this.multiMaterials=[],this.materials=[],this.morphTargetManagers=[],this.geometries=[],this.transformNodes=[],this.actionManagers=[],this.textures=[],this._environmentTexture=null,this.postProcesses=[],this.effectLayers=[],this.sounds=null,this.layers=[],this.lensFlareSystems=[],this.proceduralTextures=[],this.animationsEnabled=!0,this._animationPropertiesOverride=null,this.useConstantAnimationDeltaTime=!1,this.constantlyUpdateMeshUnderPointer=!1,this.hoverCursor="pointer",this.defaultCursor="",this.doNotHandleCursors=!1,this.preventDefaultOnPointerDown=!0,this.preventDefaultOnPointerUp=!0,this.metadata=null,this.reservedDataStore=null,this.disableOfflineSupportExceptionRules=[],this.onDisposeObservable=new n.cP,this._onDisposeObserver=null,this.onBeforeRenderObservable=new n.cP,this._onBeforeRenderObserver=null,this.onAfterRenderObservable=new n.cP,this.onAfterRenderCameraObservable=new n.cP,this._onAfterRenderObserver=null,this.onBeforeAnimationsObservable=new n.cP,this.onAfterAnimationsObservable=new n.cP,this.onBeforeDrawPhaseObservable=new n.cP,this.onAfterDrawPhaseObservable=new n.cP,this.onReadyObservable=new n.cP,this.onBeforeCameraRenderObservable=new n.cP,this._onBeforeCameraRenderObserver=null,this.onAfterCameraRenderObservable=new n.cP,this._onAfterCameraRenderObserver=null,this.onBeforeActiveMeshesEvaluationObservable=new n.cP,this.onAfterActiveMeshesEvaluationObservable=new n.cP,this.onBeforeParticlesRenderingObservable=new n.cP,this.onAfterParticlesRenderingObservable=new n.cP,this.onDataLoadedObservable=new n.cP,this.onNewCameraAddedObservable=new n.cP,this.onCameraRemovedObservable=new n.cP,this.onNewLightAddedObservable=new n.cP,this.onLightRemovedObservable=new n.cP,this.onNewGeometryAddedObservable=new n.cP,this.onGeometryRemovedObservable=new n.cP,this.onNewTransformNodeAddedObservable=new n.cP,this.onTransformNodeRemovedObservable=new n.cP,this.onNewMeshAddedObservable=new n.cP,this.onMeshRemovedObservable=new n.cP,this.onNewSkeletonAddedObservable=new n.cP,this.onSkeletonRemovedObservable=new n.cP,this.onNewMaterialAddedObservable=new n.cP,this.onNewMultiMaterialAddedObservable=new n.cP,this.onMaterialRemovedObservable=new n.cP,this.onMultiMaterialRemovedObservable=new n.cP,this.onNewTextureAddedObservable=new n.cP,this.onTextureRemovedObservable=new n.cP,this.onBeforeRenderTargetsRenderObservable=new n.cP,this.onAfterRenderTargetsRenderObservable=new n.cP,this.onBeforeStepObservable=new n.cP,this.onAfterStepObservable=new n.cP,this.onActiveCameraChanged=new n.cP,this.onActiveCamerasChanged=new n.cP,this.onBeforeRenderingGroupObservable=new n.cP,this.onAfterRenderingGroupObservable=new n.cP,this.onMeshImportedObservable=new n.cP,this.onAnimationFileImportedObservable=new n.cP,this._registeredForLateAnimationBindings=new a.b(256),this._pointerPickingConfiguration=new Y,this.onPrePointerObservable=new n.cP,this.onPointerObservable=new n.cP,this.onPreKeyboardObservable=new n.cP,this.onKeyboardObservable=new n.cP,this._useRightHandedSystem=!1,this._timeAccumulator=0,this._currentStepId=0,this._currentInternalStep=0,this._fogEnabled=!0,this._fogMode=$.FOGMODE_NONE,this.fogColor=new z.v9(.2,.2,.3),this.fogDensity=.1,this.fogStart=0,this.fogEnd=1e3,this.needsPreviousWorldMatrices=!1,this._shadowsEnabled=!0,this._lightsEnabled=!0,this._unObserveActiveCameras=null,this._texturesEnabled=!0,this._frameGraph=null,this.physicsEnabled=!0,this.particlesEnabled=!0,this.spritesEnabled=!0,this._skeletonsEnabled=!0,this.lensFlaresEnabled=!0,this.collisionsEnabled=!0,this.gravity=new l.Pq(0,-9.807,0),this.postProcessesEnabled=!0,this.renderTargetsEnabled=!0,this.dumpNextRenderTargets=!1,this.customRenderTargets=[],this.importedMeshesFiles=[],this.probesEnabled=!0,this._meshesForIntersections=new a.b(256),this.proceduralTexturesEnabled=!0,this._totalVertices=new G.A,this._activeIndices=new G.A,this._activeParticles=new G.A,this._activeBones=new G.A,this._animationTime=0,this.animationTimeScale=1,this._renderId=0,this._frameId=0,this._executeWhenReadyTimeoutId=null,this._intermediateRendering=!1,this._defaultFrameBufferCleared=!1,this._viewUpdateFlag=-1,this._projectionUpdateFlag=-1,this._toBeDisposed=new Array(256),this._activeRequests=new Array,this._pendingData=new Array,this._isDisposed=!1,this.dispatchAllSubMeshesOfActiveMeshes=!1,this._activeMeshes=new a.L(256),this._processedMaterials=new a.L(256),this._renderTargets=new a.b(256),this._materialsRenderTargets=new a.b(256),this._activeParticleSystems=new a.L(256),this._activeSkeletons=new a.b(32),this._softwareSkinnedMeshes=new a.b(32),this._activeAnimatables=new Array,this._transformMatrix=l.uq.Zero(),this.requireLightSorting=!1,this._components=[],this._serializableComponents=[],this._transientComponents=[],this._beforeCameraUpdateStage=g.B.Create(),this._beforeClearStage=g.B.Create(),this._beforeRenderTargetClearStage=g.B.Create(),this._gatherRenderTargetsStage=g.B.Create(),this._gatherActiveCameraRenderTargetsStage=g.B.Create(),this._isReadyForMeshStage=g.B.Create(),this._beforeEvaluateActiveMeshStage=g.B.Create(),this._evaluateSubMeshStage=g.B.Create(),this._preActiveMeshStage=g.B.Create(),this._cameraDrawRenderTargetStage=g.B.Create(),this._beforeCameraDrawStage=g.B.Create(),this._beforeRenderTargetDrawStage=g.B.Create(),this._beforeRenderingGroupDrawStage=g.B.Create(),this._beforeRenderingMeshStage=g.B.Create(),this._afterRenderingMeshStage=g.B.Create(),this._afterRenderingGroupDrawStage=g.B.Create(),this._afterCameraDrawStage=g.B.Create(),this._afterCameraPostProcessStage=g.B.Create(),this._afterRenderTargetDrawStage=g.B.Create(),this._afterRenderTargetPostProcessStage=g.B.Create(),this._afterRenderStage=g.B.Create(),this._pointerMoveStage=g.B.Create(),this._pointerDownStage=g.B.Create(),this._pointerUpStage=g.B.Create(),this._geometriesByUniqueId=null,this._defaultMeshCandidates={data:[],length:0},this._defaultSubMeshCandidates={data:[],length:0},this._preventFreeActiveMeshesAndRenderingGroups=!1,this._activeMeshesFrozen=!1,this._activeMeshesFrozenButKeepClipping=!1,this._skipEvaluateActiveMeshesCompletely=!1,this._allowPostProcessClearColor=!0,this.getDeterministicFrameTime=()=>this._engine.getTimeStep(),this._registeredActions=0,this._blockMaterialDirtyMechanism=!1,this._perfCollector=null,this.activeCameras=[];const s={useGeometryUniqueIdsMap:!0,useMaterialMeshMap:!0,useClonedMeshMap:!0,virtual:!1,...t};e=this._engine=e||T.q.LastCreatedEngine,s.virtual?e._virtualScenes.push(this):(T.q._LastCreatedScene=this,e.scenes.push(this)),this._uid=null,this._renderingManager=new p.m(this),f.X&&(this.postProcessManager=new f.X(this)),(0,m.BA)()&&this.attachControl(),this._createUbo(),c.p&&(this._imageProcessingConfiguration=new c.p),this.setDefaultCandidateProviders(),s.useGeometryUniqueIdsMap&&(this._geometriesByUniqueId={}),this.useMaterialMeshMap=s.useMaterialMeshMap,this.useClonedMeshMap=s.useClonedMeshMap,t&&t.virtual||e.onNewSceneAddedObservable.notifyObservers(this)}getClassName(){return"Scene"}_getDefaultMeshCandidates(){return this._defaultMeshCandidates.data=this.meshes,this._defaultMeshCandidates.length=this.meshes.length,this._defaultMeshCandidates}_getDefaultSubMeshCandidates(e){return this._defaultSubMeshCandidates.data=e.subMeshes,this._defaultSubMeshCandidates.length=e.subMeshes.length,this._defaultSubMeshCandidates}setDefaultCandidateProviders(){this.getActiveMeshCandidates=()=>this._getDefaultMeshCandidates(),this.getActiveSubMeshCandidates=e=>this._getDefaultSubMeshCandidates(e),this.getIntersectingSubMeshCandidates=(e,t)=>this._getDefaultSubMeshCandidates(e),this.getCollidingSubMeshCandidates=(e,t)=>this._getDefaultSubMeshCandidates(e)}get meshUnderPointer(){return this._inputManager.meshUnderPointer}get pointerX(){return this._inputManager.pointerX}set pointerX(e){this._inputManager.pointerX=e}get pointerY(){return this._inputManager.pointerY}set pointerY(e){this._inputManager.pointerY=e}getCachedMaterial(){return this._cachedMaterial}getCachedEffect(){return this._cachedEffect}getCachedVisibility(){return this._cachedVisibility}isCachedMaterialInvalid(e,t,s=1){return this._cachedEffect!==t||this._cachedMaterial!==e||this._cachedVisibility!==s}getEngine(){return this._engine}getTotalVertices(){return this._totalVertices.current}get totalVerticesPerfCounter(){return this._totalVertices}getActiveIndices(){return this._activeIndices.current}get totalActiveIndicesPerfCounter(){return this._activeIndices}getActiveParticles(){return this._activeParticles.current}get activeParticlesPerfCounter(){return this._activeParticles}getActiveBones(){return this._activeBones.current}get activeBonesPerfCounter(){return this._activeBones}getActiveMeshes(){return this._activeMeshes}getAnimationRatio(){return void 0!==this._animationRatio?this._animationRatio:1}getRenderId(){return this._renderId}getFrameId(){return this._frameId}incrementRenderId(){this._renderId++}_createUbo(){this.setSceneUniformBuffer(this.createSceneUniformBuffer())}simulatePointerMove(e,t){return this._inputManager.simulatePointerMove(e,t),this}simulatePointerDown(e,t){return this._inputManager.simulatePointerDown(e,t),this}simulatePointerUp(e,t,s){return this._inputManager.simulatePointerUp(e,t,s),this}isPointerCaptured(e=0){return this._inputManager.isPointerCaptured(e)}attachControl(e=!0,t=!0,s=!0){this._inputManager.attachControl(e,t,s)}detachControl(){this._inputManager.detachControl()}isReady(e=!0){if(this._isDisposed)return!1;let t;const s=this.getEngine(),i=s.currentRenderPassId;s.currentRenderPassId=this.activeCamera?.renderPassId??i;let r=!0;for(this._pendingData.length>0&&(r=!1),this.prePassRenderer?.update(),this.useOrderIndependentTransparency&&this.depthPeelingRenderer&&r&&(r=this.depthPeelingRenderer.isReady()),e&&(this._processedMaterials.reset(),this._materialsRenderTargets.reset()),t=0;t0;for(const e of this._isReadyForMeshStage)e.action(i,n)||(r=!1);if(!e)continue;const a=i.material||this.defaultMaterial;if(a)if(a._storeEffectOnSubMeshes)for(const e of i.subMeshes){const t=e.getMaterial();t&&t.hasRenderTargetTextures&&null!=t.getRenderTargetTextures&&-1===this._processedMaterials.indexOf(t)&&(this._processedMaterials.push(t),this._materialsRenderTargets.concatWithNoDuplicate(t.getRenderTargetTextures()))}else a.hasRenderTargetTextures&&null!=a.getRenderTargetTextures&&-1===this._processedMaterials.indexOf(a)&&(this._processedMaterials.push(a),this._materialsRenderTargets.concatWithNoDuplicate(a.getRenderTargetTextures()))}if(e)for(t=0;t0)for(const e of this.activeCameras)e.isReady(!0)||(r=!1);else this.activeCamera&&(this.activeCamera.isReady(!0)||(r=!1));for(const e of this.particleSystems)e.isReady()||(r=!1);if(this.layers)for(const e of this.layers)e.isReady()||(r=!1);return s.areAllEffectsReady()||(r=!1),s.currentRenderPassId=i,r}resetCachedMaterial(){this._cachedMaterial=null,this._cachedEffect=null,this._cachedVisibility=null}registerBeforeRender(e){this.onBeforeRenderObservable.add(e)}unregisterBeforeRender(e){this.onBeforeRenderObservable.removeCallback(e)}registerAfterRender(e){this.onAfterRenderObservable.add(e)}unregisterAfterRender(e){this.onAfterRenderObservable.removeCallback(e)}_executeOnceBeforeRender(e){const t=()=>{e(),setTimeout((()=>{this.unregisterBeforeRender(t)}))};this.registerBeforeRender(t)}executeOnceBeforeRender(e,t){void 0!==t?setTimeout((()=>{this._executeOnceBeforeRender(e)}),t):this._executeOnceBeforeRender(e)}addPendingData(e){this._pendingData.push(e)}removePendingData(e){const t=this.isLoading,s=this._pendingData.indexOf(e);-1!==s&&this._pendingData.splice(s,1),t&&!this.isLoading&&this.onDataLoadedObservable.notifyObservers(this)}getWaitingItemsCount(){return this._pendingData.length}get isLoading(){return this._pendingData.length>0}executeWhenReady(e,t=!1){this.onReadyObservable.addOnce(e),null===this._executeWhenReadyTimeoutId&&this._checkIsReady(t)}whenReadyAsync(e=!1){return new Promise((t=>{this.executeWhenReady((()=>{t()}),e)}))}_checkIsReady(e=!1){return this._registerTransientComponents(),this.isReady(e)?(this.onReadyObservable.notifyObservers(this),this.onReadyObservable.clear(),void(this._executeWhenReadyTimeoutId=null)):this._isDisposed?(this.onReadyObservable.clear(),void(this._executeWhenReadyTimeoutId=null)):void(this._executeWhenReadyTimeoutId=setTimeout((()=>{this.incrementRenderId(),this._checkIsReady(e)}),100))}get animatables(){return this._activeAnimatables}resetLastAnimationTimeFrame(){this._animationTimeLast=r.j.Now}getViewMatrix(){return this._viewMatrix}getProjectionMatrix(){return this._projectionMatrix}getTransformMatrix(){return this._transformMatrix}setTransformMatrix(e,t,s,i){s||i||!this._multiviewSceneUbo||(this._multiviewSceneUbo.dispose(),this._multiviewSceneUbo=null),this._viewUpdateFlag===e.updateFlag&&this._projectionUpdateFlag===t.updateFlag||(this._viewUpdateFlag=e.updateFlag,this._projectionUpdateFlag=t.updateFlag,this._viewMatrix=e,this._projectionMatrix=t,this._viewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix),this._frustumPlanes?W.P.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=W.P.GetPlanes(this._transformMatrix),this._multiviewSceneUbo&&this._multiviewSceneUbo.useUbo?this._updateMultiviewUbo(s,i):this._sceneUbo.useUbo&&(this._sceneUbo.updateMatrix("viewProjection",this._transformMatrix),this._sceneUbo.updateMatrix("view",this._viewMatrix),this._sceneUbo.updateMatrix("projection",this._projectionMatrix)))}getSceneUniformBuffer(){return this._multiviewSceneUbo?this._multiviewSceneUbo:this._sceneUbo}createSceneUniformBuffer(e){const t=new u.D(this._engine,void 0,!1,e??"scene");return t.addUniform("viewProjection",16),t.addUniform("view",16),t.addUniform("projection",16),t.addUniform("vEyePosition",4),t}setSceneUniformBuffer(e){this._sceneUbo=e,this._viewUpdateFlag=-1,this._projectionUpdateFlag=-1}getUniqueId(){return H.UniqueId}addMesh(e,t=!1){this._blockEntityCollection||(this.meshes.push(e),e._resyncLightSources(),e.parent||e._addToSceneRootNodes(),i.S0.SetImmediate((()=>{this.onNewMeshAddedObservable.notifyObservers(e)})),t&&e.getChildMeshes().forEach((e=>{this.addMesh(e)})))}removeMesh(e,t=!1){const s=this.meshes.indexOf(e);return-1!==s&&(this.meshes.splice(s,1),e.parent||e._removeFromSceneRootNodes()),this._inputManager._invalidateMesh(e),this.onMeshRemovedObservable.notifyObservers(e),t&&e.getChildMeshes().forEach((e=>{this.removeMesh(e)})),s}addTransformNode(e){this._blockEntityCollection||e.getScene()===this&&-1!==e._indexInSceneTransformNodesArray||(e._indexInSceneTransformNodesArray=this.transformNodes.length,this.transformNodes.push(e),e.parent||e._addToSceneRootNodes(),this.onNewTransformNodeAddedObservable.notifyObservers(e))}removeTransformNode(e){const t=e._indexInSceneTransformNodesArray;if(-1!==t){if(t!==this.transformNodes.length-1){const e=this.transformNodes[this.transformNodes.length-1];this.transformNodes[t]=e,e._indexInSceneTransformNodesArray=t}e._indexInSceneTransformNodesArray=-1,this.transformNodes.pop(),e.parent||e._removeFromSceneRootNodes()}return this.onTransformNodeRemovedObservable.notifyObservers(e),t}removeSkeleton(e){const t=this.skeletons.indexOf(e);return-1!==t&&(this.skeletons.splice(t,1),this.onSkeletonRemovedObservable.notifyObservers(e),this._executeActiveContainerCleanup(this._activeSkeletons)),t}removeMorphTargetManager(e){const t=this.morphTargetManagers.indexOf(e);return-1!==t&&this.morphTargetManagers.splice(t,1),t}removeLight(e){const t=this.lights.indexOf(e);if(-1!==t){for(const t of this.meshes)t._removeLightSource(e,!1);this.lights.splice(t,1),this.sortLightsByPriority(),e.parent||e._removeFromSceneRootNodes()}return this.onLightRemovedObservable.notifyObservers(e),t}removeCamera(e){const t=this.cameras.indexOf(e);if(-1!==t&&(this.cameras.splice(t,1),e.parent||e._removeFromSceneRootNodes()),this.activeCameras){const t=this.activeCameras.indexOf(e);-1!==t&&this.activeCameras.splice(t,1)}return this.activeCamera===e&&(this.cameras.length>0?this.activeCamera=this.cameras[0]:this.activeCamera=null),this.onCameraRemovedObservable.notifyObservers(e),t}removeParticleSystem(e){const t=this.particleSystems.indexOf(e);return-1!==t&&(this.particleSystems.splice(t,1),this._executeActiveContainerCleanup(this._activeParticleSystems)),t}removeAnimation(e){const t=this.animations.indexOf(e);return-1!==t&&this.animations.splice(t,1),t}stopAnimation(e,t,s){}removeAnimationGroup(e){const t=this.animationGroups.indexOf(e);return-1!==t&&this.animationGroups.splice(t,1),t}removeMultiMaterial(e){const t=this.multiMaterials.indexOf(e);return-1!==t&&this.multiMaterials.splice(t,1),this.onMultiMaterialRemovedObservable.notifyObservers(e),t}removeMaterial(e){const t=e._indexInSceneMaterialArray;if(-1!==t&&t{this.onNewLightAddedObservable.notifyObservers(e)}))}}sortLightsByPriority(){this.requireLightSorting&&this.lights.sort(q.c.CompareLightsPriority)}addCamera(e){this._blockEntityCollection||(this.cameras.push(e),i.S0.SetImmediate((()=>{this.onNewCameraAddedObservable.notifyObservers(e)})),e.parent||e._addToSceneRootNodes())}addSkeleton(e){this._blockEntityCollection||(this.skeletons.push(e),i.S0.SetImmediate((()=>{this.onNewSkeletonAddedObservable.notifyObservers(e)})))}addParticleSystem(e){this._blockEntityCollection||this.particleSystems.push(e)}addAnimation(e){this._blockEntityCollection||this.animations.push(e)}addAnimationGroup(e){this._blockEntityCollection||this.animationGroups.push(e)}addMultiMaterial(e){this._blockEntityCollection||(this.multiMaterials.push(e),i.S0.SetImmediate((()=>{this.onNewMultiMaterialAddedObservable.notifyObservers(e)})))}addMaterial(e){this._blockEntityCollection||e.getScene()===this&&-1!==e._indexInSceneMaterialArray||(e._indexInSceneMaterialArray=this.materials.length,this.materials.push(e),i.S0.SetImmediate((()=>{this.onNewMaterialAddedObservable.notifyObservers(e)})))}addMorphTargetManager(e){this._blockEntityCollection||this.morphTargetManagers.push(e)}addGeometry(e){this._blockEntityCollection||(this._geometriesByUniqueId&&(this._geometriesByUniqueId[e.uniqueId]=this.geometries.length),this.geometries.push(e))}addActionManager(e){this.actionManagers.push(e)}addTexture(e){this._blockEntityCollection||(this.textures.push(e),this.onNewTextureAddedObservable.notifyObservers(e))}switchActiveCamera(e,t=!0){this._engine.getInputElement()&&(this.activeCamera&&this.activeCamera.detachControl(),this.activeCamera=e,t&&e.attachControl())}setActiveCameraById(e){const t=this.getCameraById(e);return t?(this.activeCamera=t,t):null}setActiveCameraByName(e){const t=this.getCameraByName(e);return t?(this.activeCamera=t,t):null}getAnimationGroupByName(e){for(let t=0;tt.uniqueId===e))}getMaterialById(e,t=!1){return this._getMaterial(t,(t=>t.id===e))}getMaterialByName(e,t=!1){return this._getMaterial(t,(t=>t.name===e))}getLastMaterialById(e,t=!1){for(let t=this.materials.length-1;t>=0;t--)if(this.materials[t].id===e)return this.materials[t];if(t)for(let t=this.multiMaterials.length-1;t>=0;t--)if(this.multiMaterials[t].id===e)return this.multiMaterials[t];return null}getTextureByUniqueId(e){for(let t=0;t{this.onNewGeometryAddedObservable.notifyObservers(e)})),0))}removeGeometry(e){let t;if(this._geometriesByUniqueId){if(t=this._geometriesByUniqueId[e.uniqueId],void 0===t)return!1}else if(t=this.geometries.indexOf(e),t<0)return!1;if(t!==this.geometries.length-1){const e=this.geometries[this.geometries.length-1];e&&(this.geometries[t]=e,this._geometriesByUniqueId&&(this._geometriesByUniqueId[e.uniqueId]=t))}return this._geometriesByUniqueId&&(this._geometriesByUniqueId[e.uniqueId]=void 0),this.geometries.pop(),this.onGeometryRemovedObservable.notifyObservers(e),!0}getGeometries(){return this.geometries}getMeshById(e){for(let t=0;t=0;t--)if(this.meshes[t].id===e)return this.meshes[t];return null}getLastTransformNodeById(e){for(let t=this.transformNodes.length-1;t>=0;t--)if(this.transformNodes[t].id===e)return this.transformNodes[t];return null}getLastEntryById(e){let t;for(t=this.meshes.length-1;t>=0;t--)if(this.meshes[t].id===e)return this.meshes[t];for(t=this.transformNodes.length-1;t>=0;t--)if(this.transformNodes[t].id===e)return this.transformNodes[t];for(t=this.cameras.length-1;t>=0;t--)if(this.cameras[t].id===e)return this.cameras[t];for(t=this.lights.length-1;t>=0;t--)if(this.lights[t].id===e)return this.lights[t];return null}getNodeById(e){const t=this.getMeshById(e);if(t)return t;const s=this.getTransformNodeById(e);if(s)return s;const i=this.getLightById(e);if(i)return i;const r=this.getCameraById(e);if(r)return r;return this.getBoneById(e)||null}getNodeByName(e){const t=this.getMeshByName(e);if(t)return t;const s=this.getTransformNodeByName(e);if(s)return s;const i=this.getLightByName(e);if(i)return i;const r=this.getCameraByName(e);if(r)return r;return this.getBoneByName(e)||null}getMeshByName(e){for(let t=0;t=0;t--)if(this.skeletons[t].id===e)return this.skeletons[t];return null}getSkeletonByUniqueId(e){for(let t=0;t{if(this.activeCamera){if(this._frustumPlanes||this.updateTransformMatrix(),this._evaluateActiveMeshes(),this._activeMeshesFrozen=!0,this._activeMeshesFrozenButKeepClipping=r,this._skipEvaluateActiveMeshesCompletely=e,i)for(let e=0;ee.dispose()))}_evaluateActiveMeshes(){if(this._engine.snapshotRendering&&1===this._engine.snapshotRenderingMode)return void(this._activeMeshes.length>0&&(this.activeCamera?._activeMeshes.reset(),this._activeMeshes.reset(),this._renderingManager.reset(),this._processedMaterials.reset(),this._activeParticleSystems.reset(),this._activeSkeletons.reset(),this._softwareSkinnedMeshes.reset()));if(this._activeMeshesFrozen&&this._activeMeshes.length){if(!this._skipEvaluateActiveMeshesCompletely){const e=this._activeMeshes.length;for(let t=0;t0&&0!=(t.layerMask&this.activeCamera.layerMask)&&(this._skipFrustumClipping||t.alwaysSelectAsActiveMesh||t.isInFrustum(this._frustumPlanes)))){this._activeMeshes.push(t),this.activeCamera._activeMeshes.push(t),i!==t&&i._activate(this._renderId,!1);for(const e of this._preActiveMeshStage)e.action(t);t._activate(this._renderId,!1)&&(t.isAnInstance?t._internalAbstractMeshDataInfo._actAsRegularMesh&&(i=t):i._internalAbstractMeshDataInfo._onlyForInstances=!1,i._internalAbstractMeshDataInfo._isActive=!0,this._activeMesh(t,i)),t._postActivate()}}if(this.onAfterActiveMeshesEvaluationObservable.notifyObservers(this),this.particlesEnabled){this.onBeforeParticlesRenderingObservable.notifyObservers(this);for(let e=0;e0){const i=this.getActiveSubMeshCandidates(t),r=i.length;s=s||1===r;for(let n=0;n0&&this._renderTargets.concatWithNoDuplicate(e.customRenderTargets),t&&t.customRenderTargets&&t.customRenderTargets.length>0&&this._renderTargets.concatWithNoDuplicate(t.customRenderTargets),this.environmentTexture&&this.environmentTexture.isRenderTarget&&this._renderTargets.pushNoDuplicate(this.environmentTexture);for(const e of this._gatherActiveCameraRenderTargetsStage)e.action(this._renderTargets);let n=!1;if(this.renderTargetsEnabled){if(this._intermediateRendering=!0,this._renderTargets.length>0){i.S0.StartPerformanceCounter("Render targets",this._renderTargets.length>0);for(let e=0;e0),this._renderId++}for(const e of this._cameraDrawRenderTargetStage)n=e.action(this.activeCamera)||n;this._intermediateRendering=!1}this._engine.currentRenderPassId=e.outputRenderTarget?.renderPassId??e.renderPassId??0,n&&!this.prePass&&(this._bindFrameBuffer(this._activeCamera,!1),this.updateTransformMatrix()),this.onAfterRenderTargetsRenderObservable.notifyObservers(this),!this.postProcessManager||e._multiviewTexture||this.prePass||this.postProcessManager._prepareFrame();for(const e of this._beforeCameraDrawStage)e.action(this.activeCamera);this.onBeforeDrawPhaseObservable.notifyObservers(this),r.snapshotRendering&&1===r.snapshotRenderingMode&&this.finalizeSceneUbo(),this._renderingManager.render(null,null,!0,!0),this.onAfterDrawPhaseObservable.notifyObservers(this);for(const e of this._afterCameraDrawStage)e.action(this.activeCamera);if(this.postProcessManager&&!e._multiviewTexture){const t=e.outputRenderTarget?e.outputRenderTarget.renderTarget:void 0;this.postProcessManager._finalizeFrame(e.isIntermediate,t)}for(const e of this._afterCameraPostProcessStage)e.action(this.activeCamera);this._renderTargets.reset(),this.onAfterCameraRenderObservable.notifyObservers(this.activeCamera)}_processSubCameras(e,t=!0){if(0===e.cameraRigMode||e._renderingMultiview)return e._renderingMultiview&&!this._multiviewSceneUbo&&this._createMultiviewUbo(),this._renderForCamera(e,void 0,t),void this.onAfterRenderCameraObservable.notifyObservers(e);if(e._useMultiviewToSingleView)this._renderMultiviewToSingleView(e);else{this.onBeforeCameraRenderObservable.notifyObservers(e);for(let t=0;t-1&&(13===s.trigger&&s._executeCurrent(_.CreateNew(t,void 0,i)),t.actionManager.hasSpecificTrigger(13,(e=>{const t=e.mesh?e.mesh:e;return i===t}))&&13!==s.trigger||t._intersectionsInProgress.splice(n,1))}}}}_advancePhysicsEngineStep(e){}_animate(e){}animate(){if(this._engine.isDeterministicLockStep()){let e=Math.max($.MinDeltaTime,Math.min(this._engine.getDeltaTime(),$.MaxDeltaTime))+this._timeAccumulator;const t=this._engine.getTimeStep(),s=1e3/t/1e3;let i=0;const r=this._engine.getLockstepMaxSteps();let n=Math.floor(e/t);for(n=Math.min(n,r);e>0&&i0)for(let e=0;e0),this._intermediateRendering=!0;for(let s=0;s0),this._intermediateRendering=!1,this._renderId++}this._engine.currentRenderPassId=t?.renderPassId??0,this.activeCamera=t,this._activeCamera&&22!==this._activeCamera.cameraRigMode&&!this.prePass&&this._bindFrameBuffer(this._activeCamera,!1),this.onAfterRenderTargetsRenderObservable.notifyObservers(this);for(const e of this._beforeClearStage)e.action();this._clearFrameBuffer(this.activeCamera);for(const e of this._gatherRenderTargetsStage)e.action(this._renderTargets);if(this.activeCameras&&this.activeCameras.length>0)for(let e=0;e0);else{if(!this.activeCamera)throw new Error("No camera defined");this._processSubCameras(this.activeCamera,!!this.activeCamera.outputRenderTarget)}}this._checkIntersections();for(const e of this._afterRenderStage)e.action();if(this.afterRender&&this.afterRender(),this.onAfterRenderObservable.notifyObservers(this),this._toBeDisposed.length){for(let e=0;e{e.onAnimationEndObservable.clear(),e.onAnimationEnd=null})),this.stopAllAnimations()),this.resetCachedMaterial(),this.activeCamera&&(this.activeCamera._activeMeshes.dispose(),this.activeCamera=null),this.activeCameras=null,this._activeMeshes.dispose(),this._renderingManager.dispose(),this._processedMaterials.dispose(),this._activeParticleSystems.dispose(),this._activeSkeletons.dispose(),this._softwareSkinnedMeshes.dispose(),this._renderTargets.dispose(),this._materialsRenderTargets.dispose(),this._registeredForLateAnimationBindings.dispose(),this._meshesForIntersections.dispose(),this._toBeDisposed.length=0;const e=this._activeRequests.slice();for(const t of e)t.abort();this._activeRequests.length=0;try{this.onDisposeObservable.notifyObservers(this)}catch(e){Z.V.Error("An error occurred while calling onDisposeObservable!",e)}if(this.detachControl(),this._engine.getInputElement())for(let e=0;ee.dispose(!0))),this._disposeList(this.transformNodes,(e=>e.dispose(!0)));const t=this.cameras;this._disposeList(t),this._defaultMaterial&&this._defaultMaterial.dispose(),this._disposeList(this.multiMaterials),this._disposeList(this.materials),this._disposeList(this.particleSystems),this._disposeList(this.postProcesses),this._disposeList(this.textures),this._disposeList(this.morphTargetManagers),this._sceneUbo.dispose(),this._multiviewSceneUbo&&this._multiviewSceneUbo.dispose(),this.postProcessManager.dispose(),this._disposeList(this._components);let s=this._engine.scenes.indexOf(this);s>-1&&this._engine.scenes.splice(s,1),T.q._LastCreatedScene===this&&(this._engine.scenes.length>0?T.q._LastCreatedScene=this._engine.scenes[this._engine.scenes.length-1]:T.q._LastCreatedScene=null),s=this._engine._virtualScenes.indexOf(this),s>-1&&this._engine._virtualScenes.splice(s,1),this._engine.wipeCaches(!0),this.onDisposeObservable.clear(),this.onBeforeRenderObservable.clear(),this.onAfterRenderObservable.clear(),this.onBeforeRenderTargetsRenderObservable.clear(),this.onAfterRenderTargetsRenderObservable.clear(),this.onAfterStepObservable.clear(),this.onBeforeStepObservable.clear(),this.onBeforeActiveMeshesEvaluationObservable.clear(),this.onAfterActiveMeshesEvaluationObservable.clear(),this.onBeforeParticlesRenderingObservable.clear(),this.onAfterParticlesRenderingObservable.clear(),this.onBeforeDrawPhaseObservable.clear(),this.onAfterDrawPhaseObservable.clear(),this.onBeforeAnimationsObservable.clear(),this.onAfterAnimationsObservable.clear(),this.onDataLoadedObservable.clear(),this.onBeforeRenderingGroupObservable.clear(),this.onAfterRenderingGroupObservable.clear(),this.onMeshImportedObservable.clear(),this.onBeforeCameraRenderObservable.clear(),this.onAfterCameraRenderObservable.clear(),this.onAfterRenderCameraObservable.clear(),this.onReadyObservable.clear(),this.onNewCameraAddedObservable.clear(),this.onCameraRemovedObservable.clear(),this.onNewLightAddedObservable.clear(),this.onLightRemovedObservable.clear(),this.onNewGeometryAddedObservable.clear(),this.onGeometryRemovedObservable.clear(),this.onNewTransformNodeAddedObservable.clear(),this.onTransformNodeRemovedObservable.clear(),this.onNewMeshAddedObservable.clear(),this.onMeshRemovedObservable.clear(),this.onNewSkeletonAddedObservable.clear(),this.onSkeletonRemovedObservable.clear(),this.onNewMaterialAddedObservable.clear(),this.onNewMultiMaterialAddedObservable.clear(),this.onMaterialRemovedObservable.clear(),this.onMultiMaterialRemovedObservable.clear(),this.onNewTextureAddedObservable.clear(),this.onTextureRemovedObservable.clear(),this.onPrePointerObservable.clear(),this.onPointerObservable.clear(),this.onPreKeyboardObservable.clear(),this.onKeyboardObservable.clear(),this.onActiveCameraChanged.clear(),this.onScenePerformancePriorityChangedObservable.clear(),this.onClearColorChangedObservable.clear(),this._isDisposed=!0}_disposeList(e,t){const s=e.slice(0);t=t??(e=>e.dispose());for(const e of s)t(e);e.length=0}get isDisposed(){return this._isDisposed}clearCachedVertexData(){for(let e=0;e!0),this.meshes.filter(e).forEach((e=>{if(e.computeWorldMatrix(!0),!e.subMeshes||0===e.subMeshes.length||e.infiniteDistance)return;const i=e.getBoundingInfo(),r=i.boundingBox.minimumWorld,n=i.boundingBox.maximumWorld;l.Pq.CheckExtends(r,t,s),l.Pq.CheckExtends(n,t,s)})),{min:t,max:s}}createPickingRay(e,t,s,i,r=!1){throw(0,b.n)("Ray")}createPickingRayToRef(e,t,s,i,r,n=!1,a=!1){throw(0,b.n)("Ray")}createPickingRayInCameraSpace(e,t,s){throw(0,b.n)("Ray")}createPickingRayInCameraSpaceToRef(e,t,s,i){throw(0,b.n)("Ray")}pick(e,t,s,i,r,n){const a=(0,b.n)("Ray",!0);return a&&Z.V.Warn(a),new d.G}pickWithBoundingInfo(e,t,s,i,r){const n=(0,b.n)("Ray",!0);return n&&Z.V.Warn(n),new d.G}pickWithRay(e,t,s,i){throw(0,b.n)("Ray")}multiPick(e,t,s,i,r){throw(0,b.n)("Ray")}multiPickWithRay(e,t,s){throw(0,b.n)("Ray")}setPointerOverMesh(e,t,s){this._inputManager.setPointerOverMesh(e,t,s)}getPointerOverMesh(){return this._inputManager.getPointerOverMesh()}_rebuildGeometries(){for(const e of this.geometries)e._rebuild();for(const e of this.meshes)e._rebuild();this.postProcessManager&&this.postProcessManager._rebuild();for(const e of this._components)e.rebuild();for(const e of this.particleSystems)e.rebuild();if(this.spriteManagers)for(const e of this.spriteManagers)e.rebuild()}_rebuildTextures(){for(const e of this.textures)e._rebuild(!0);this.markAllMaterialsAsDirty(1)}_getByTags(e,t,s){if(void 0===t)return e;const i=[];for(const r in e){const n=e[r];h.Y&&h.Y.MatchesQuery(n,t)&&(!s||s(n))&&i.push(n)}return i}getMeshesByTags(e,t){return this._getByTags(this.meshes,e,t)}getCamerasByTags(e,t){return this._getByTags(this.cameras,e,t)}getLightsByTags(e,t){return this._getByTags(this.lights,e,t)}getMaterialByTags(e,t){return this._getByTags(this.materials,e,t).concat(this._getByTags(this.multiMaterials,e,t))}getTransformNodesByTags(e,t){return this._getByTags(this.transformNodes,e,t)}setRenderingOrder(e,t=null,s=null,i=null){this._renderingManager.setRenderingOrder(e,t,s,i)}setRenderingAutoClearDepthStencil(e,t,s=!0,i=!0){this._renderingManager.setRenderingAutoClearDepthStencil(e,t,s,i)}getAutoClearDepthStencilSetup(e){return this._renderingManager.getAutoClearDepthStencilSetup(e)}_forceBlockMaterialDirtyMechanism(e){this._blockMaterialDirtyMechanism=e}get blockMaterialDirtyMechanism(){return this._blockMaterialDirtyMechanism}set blockMaterialDirtyMechanism(e){this._blockMaterialDirtyMechanism!==e&&(this._blockMaterialDirtyMechanism=e,e||this.markAllMaterialsAsDirty(63))}markAllMaterialsAsDirty(e,t){if(!this._blockMaterialDirtyMechanism)for(const s of this.materials)t&&!t(s)||s.markAsDirty(e)}_loadFile(e,t,s,i,r,n,a){const o=(0,K.zU)(e,t,s,i?this.offlineProvider:void 0,r,n,a);return this._activeRequests.push(o),o.onCompleteObservable.add((e=>{this._activeRequests.splice(this._activeRequests.indexOf(e),1)})),o}_loadFileAsync(e,t,s,i,r){return new Promise(((n,a)=>{this._loadFile(e,(e=>{n(e)}),t,s,i,((e,t)=>{a(t)}),r)}))}_requestFile(e,t,s,i,r,n,a){const o=(0,K.sh)(e,t,s,i?this.offlineProvider:void 0,r,n,a);return this._activeRequests.push(o),o.onCompleteObservable.add((e=>{this._activeRequests.splice(this._activeRequests.indexOf(e),1)})),o}_requestFileAsync(e,t,s,i,r){return new Promise(((n,a)=>{this._requestFile(e,(e=>{n(e)}),t,s,i,(e=>{a(e)}),r)}))}_readFile(e,t,s,i,r){const n=(0,K.NJ)(e,t,s,i,r);return this._activeRequests.push(n),n.onCompleteObservable.add((e=>{this._activeRequests.splice(this._activeRequests.indexOf(e),1)})),n}_readFileAsync(e,t,s){return new Promise(((i,r)=>{this._readFile(e,(e=>{i(e)}),t,s,(e=>{r(e)}))}))}getPerfCollector(){throw(0,b.n)("performanceViewerSceneExtension")}setActiveCameraByID(e){return this.setActiveCameraById(e)}getMaterialByID(e){return this.getMaterialById(e)}getLastMaterialByID(e){return this.getLastMaterialById(e)}getTextureByUniqueID(e){return this.getTextureByUniqueId(e)}getCameraByID(e){return this.getCameraById(e)}getCameraByUniqueID(e){return this.getCameraByUniqueId(e)}getBoneByID(e){return this.getBoneById(e)}getLightByID(e){return this.getLightById(e)}getLightByUniqueID(e){return this.getLightByUniqueId(e)}getParticleSystemByID(e){return this.getParticleSystemById(e)}getGeometryByID(e){return this.getGeometryById(e)}getMeshByID(e){return this.getMeshById(e)}getMeshByUniqueID(e){return this.getMeshByUniqueId(e)}getLastMeshByID(e){return this.getLastMeshById(e)}getMeshesByID(e){return this.getMeshesById(e)}getTransformNodeByID(e){return this.getTransformNodeById(e)}getTransformNodeByUniqueID(e){return this.getTransformNodeByUniqueId(e)}getTransformNodesByID(e){return this.getTransformNodesById(e)}getNodeByID(e){return this.getNodeById(e)}getLastEntryByID(e){return this.getLastEntryById(e)}getLastSkeletonByID(e){return this.getLastSkeletonById(e)}}$.FOGMODE_NONE=0,$.FOGMODE_EXP=1,$.FOGMODE_EXP2=2,$.FOGMODE_LINEAR=3,$.MinDeltaTime=1,$.MaxDeltaTime=1e3,(0,Q.Y5)("BABYLON.Scene",$)},6945:(e,t,s)=>{s.d(t,{B:()=>r,v:()=>i});class i{}i.NAME_EFFECTLAYER="EffectLayer",i.NAME_LAYER="Layer",i.NAME_LENSFLARESYSTEM="LensFlareSystem",i.NAME_BOUNDINGBOXRENDERER="BoundingBoxRenderer",i.NAME_PARTICLESYSTEM="ParticleSystem",i.NAME_GAMEPAD="Gamepad",i.NAME_SIMPLIFICATIONQUEUE="SimplificationQueue",i.NAME_GEOMETRYBUFFERRENDERER="GeometryBufferRenderer",i.NAME_PREPASSRENDERER="PrePassRenderer",i.NAME_DEPTHRENDERER="DepthRenderer",i.NAME_DEPTHPEELINGRENDERER="DepthPeelingRenderer",i.NAME_IBLSHADOWSRENDERER="IblShadowsRenderer",i.NAME_POSTPROCESSRENDERPIPELINEMANAGER="PostProcessRenderPipelineManager",i.NAME_SPRITE="Sprite",i.NAME_SUBSURFACE="SubSurface",i.NAME_OUTLINERENDERER="Outline",i.NAME_PROCEDURALTEXTURE="ProceduralTexture",i.NAME_SHADOWGENERATOR="ShadowGenerator",i.NAME_OCTREE="Octree",i.NAME_PHYSICSENGINE="PhysicsEngine",i.NAME_AUDIO="Audio",i.NAME_FLUIDRENDERER="FluidRenderer",i.STEP_ISREADYFORMESH_EFFECTLAYER=0,i.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER=0,i.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER=0,i.STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER=0,i.STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER=1,i.STEP_BEFORECAMERADRAW_PREPASS=0,i.STEP_BEFORECAMERADRAW_EFFECTLAYER=1,i.STEP_BEFORECAMERADRAW_LAYER=2,i.STEP_BEFORERENDERTARGETDRAW_PREPASS=0,i.STEP_BEFORERENDERTARGETDRAW_LAYER=1,i.STEP_BEFORERENDERINGMESH_PREPASS=0,i.STEP_BEFORERENDERINGMESH_OUTLINE=1,i.STEP_AFTERRENDERINGMESH_PREPASS=0,i.STEP_AFTERRENDERINGMESH_OUTLINE=1,i.STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW=0,i.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER=1,i.STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE=0,i.STEP_BEFORECLEAR_PROCEDURALTEXTURE=0,i.STEP_BEFORECLEAR_PREPASS=1,i.STEP_BEFORERENDERTARGETCLEAR_PREPASS=0,i.STEP_AFTERRENDERTARGETDRAW_PREPASS=0,i.STEP_AFTERRENDERTARGETDRAW_LAYER=1,i.STEP_AFTERCAMERADRAW_PREPASS=0,i.STEP_AFTERCAMERADRAW_EFFECTLAYER=1,i.STEP_AFTERCAMERADRAW_LENSFLARESYSTEM=2,i.STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW=3,i.STEP_AFTERCAMERADRAW_LAYER=4,i.STEP_AFTERCAMERADRAW_FLUIDRENDERER=5,i.STEP_AFTERCAMERAPOSTPROCESS_LAYER=0,i.STEP_AFTERRENDERTARGETPOSTPROCESS_LAYER=0,i.STEP_AFTERRENDER_AUDIO=0,i.STEP_GATHERRENDERTARGETS_DEPTHRENDERER=0,i.STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER=1,i.STEP_GATHERRENDERTARGETS_SHADOWGENERATOR=2,i.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER=3,i.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER=0,i.STEP_GATHERACTIVECAMERARENDERTARGETS_FLUIDRENDERER=1,i.STEP_POINTERMOVE_SPRITE=0,i.STEP_POINTERDOWN_SPRITE=0,i.STEP_POINTERUP_SPRITE=0;class r extends Array{constructor(e){super(...e)}static Create(){return Object.create(r.prototype)}registerStep(e,t,s){let i=0,r=Number.MAX_VALUE;for(;i{function i(e,t,s,i){var r,n=arguments.length,a=n<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,s):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,s,i);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(a=(n<3?r(a):n>3?r(t,s,a):r(t,s))||a);return n>3&&a&&Object.defineProperty(t,s,a),a}s.d(t,{Cg:()=>i}),Object.create,Object.create}}]); \ No newline at end of file diff --git a/docs/static/pmx_converter/928.bundle.js b/docs/static/pmx_converter/928.bundle.js deleted file mode 100644 index d9fdddc..0000000 --- a/docs/static/pmx_converter/928.bundle.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunkbabylon_mmd=self.webpackChunkbabylon_mmd||[]).push([[928],{9928:(e,n,a)=>{a.r(n),a.d(n,{Dispose:()=>u,DumpData:()=>d,DumpDataAsync:()=>l,DumpFramebuffer:()=>c,DumpTools:()=>m});var r=a(4255),s=a(998),t=a(4867),i=a(6315);let p,o=null;async function c(e,n,a,r,s="image/png",t,i){const p=await a.readPixels(0,0,e,n);d(e,n,new Uint8Array(p.buffer),r,s,t,!0,void 0,i)}function l(e,n,a,r="image/png",s,t=!1,i=!1,p){return new Promise((o=>{d(e,n,a,(e=>o(e)),r,s,t,i,p)}))}function d(e,n,c,l,d="image/png",m,f=!1,h=!1,w){(async function(){return o||(o=new Promise(((e,n)=>{let s,t=null;const o={preserveDrawingBuffer:!0,depth:!1,stencil:!1,alpha:!0,premultipliedAlpha:!1,antialias:!1,failIfMajorPerformanceCaveat:!1};Promise.resolve().then(a.bind(a,6321)).then((({ThinEngine:c})=>{try{s=new OffscreenCanvas(100,100),t=new c(s,!1,o)}catch(e){s=document.createElement("canvas"),t=new c(s,!1,o)}i.q.Instances.pop(),i.q.OnEnginesDisposedObservable.add((e=>{t&&e!==t&&!t.isDisposed&&0===i.q.Instances.length&&u()})),t.getCaps().parallelShaderCompile=void 0;const l=new r.J(t);a.e(71).then(a.bind(a,9820)).then((({passPixelShader:a})=>{if(!t)return void n("Engine is not defined");const i=new r.$({engine:t,name:a.name,fragmentShader:a.shader,samplerNames:["textureSampler"]});p={canvas:s,engine:t,renderer:l,wrapper:i},e(p)}))})).catch(n)}))),await o})().then((a=>{if(a.engine.setSize(e,n,!0),c instanceof Float32Array){const e=new Uint8Array(c.length);let n=c.length;for(;n--;){const a=c[n];e[n]=Math.round(255*(0,t.OQ)(a))}c=e}const r=a.engine.createRawTexture(c,e,n,5,!1,!f,1);a.renderer.setViewport(),a.renderer.applyEffectWrapper(a.wrapper),a.wrapper.effect._bindTexture("textureSampler",r),a.renderer.draw(),h?s.S0.ToBlob(a.canvas,(e=>{const n=new FileReader;n.onload=e=>{const n=e.target.result;l&&l(n)},n.readAsArrayBuffer(e)}),d,w):s.S0.EncodeScreenshotCanvasData(a.canvas,l,d,m,w),r.dispose()}))}function u(){p?(p.wrapper.dispose(),p.renderer.dispose(),p.engine.dispose()):o?.then((e=>{e.wrapper.dispose(),e.renderer.dispose(),e.engine.dispose()})),o=null,p=null}const m={DumpData:d,DumpDataAsync:l,DumpFramebuffer:c,Dispose:u};s.S0.DumpData=d,s.S0.DumpDataAsync=l,s.S0.DumpFramebuffer=c}}]); \ No newline at end of file diff --git a/docs/static/pmx_converter/glslShaders.bundle.js b/docs/static/pmx_converter/glslShaders.bundle.js deleted file mode 100644 index b91dd9d..0000000 --- a/docs/static/pmx_converter/glslShaders.bundle.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunkbabylon_mmd=self.webpackChunkbabylon_mmd||[]).push([[71],{3357:(e,n,i)=>{i.r(n),i.d(n,{mmdOutlinePixelShader:()=>r}),i(6194),i(4581),i(7412),i(9741);const o="mmdOutlinePixelShader",t="\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\nuniform vec4 color;\n#ifdef ALPHATEST\nvarying vec2 vUV;uniform sampler2D diffuseSampler;\n#endif\n#include\n#include\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\n#include\ngl_FragColor=color;\n#define CUSTOM_FRAGMENT_MAIN_END\n}\n";i(9610).l.ShadersStore[o]=t;const r={name:o,shader:t}},5043:(e,n,i)=>{i.r(n),i.d(n,{mmdOutlineVertexShader:()=>r}),i(9707),i(8959),i(7999),i(738),i(1636),i(1218),i(4581),i(8451),i(5060),i(3298),i(3361),i(5523),i(7314),i(2215);const o="mmdOutlineVertexShader",t="\nattribute vec3 position;attribute vec3 normal;\n#include\n#include\n#include\n#include[0..maxSimultaneousMorphTargets]\n#include\nuniform float offset;\n#include\nuniform vec2 viewport;uniform mat3 view;uniform mat4 viewProjection;\n#ifdef WORLDPOS_REQUIRED\nuniform mat4 inverseViewProjection;\n#endif\n#ifdef ALPHATEST\nvarying vec2 vUV;uniform mat4 diffuseMatrix;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#endif\n#include\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void)\n{vec3 positionUpdated=position;vec3 normalUpdated=normal;\n#ifdef UV1\nvec2 uvUpdated=uv;\n#endif\n#include\n#include[0..maxSimultaneousMorphTargets]\n#include\n#include\n#include\nvec3 viewNormal=view*(mat3(finalWorld)*normalUpdated);vec4 projectedPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);vec2 screenNormal=normalize(vec2(viewNormal));projectedPosition.xy+=screenNormal/(viewport*0.25/*0.5 */)*offset*projectedPosition.w;gl_Position=projectedPosition;\n#ifdef WORLDPOS_REQUIRED\nvec4 worldPos=inverseViewProjection*projectedPosition;\n#endif\n#ifdef ALPHATEST\n#ifdef UV1\nvUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#ifdef UV2\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n#include\n#include\n}\n";i(9610).l.ShadersStore[o]=t;const r={name:o,shader:t}},2968:(e,n,i)=>{i.r(n),i.d(n,{MmdPluginMaterial:()=>f});var o=i(5662),t=i(426),r=i(8257),a=i(9339),l=i(5041);class f extends t.ZL{isCompatible(e){return e===o.w.GLSL}getCustomCode(e){if("vertex"===e){const e={};return e.CUSTOM_VERTEX_DEFINITIONS=a.B,e[`!${(0,r.N)("finalWorld=finalWorld*influence;")}`]=`\n${l.Z}\nfinalWorld=(finalWorld*influence);\n`,e}if("fragment"===e){const e={CUSTOM_FRAGMENT_DEFINITIONS:"\n#if defined(SPHERE_TEXTURE) && defined(NORMAL)\nuniform sampler2D sphereSampler;\n#endif\n#ifdef TOON_TEXTURE\nuniform sampler2D toonSampler;\n#endif\n"};e[`!${(0,r.N)("#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION) || defined(PREPASS)\nuniform mat4 view;\n#endif")}`]="\n#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION) || defined(PREPASS)\nuniform mat4 view;\n#elif defined(NORMAL) && defined(SPHERE_TEXTURE)\nuniform mat4 view;\n#endif\n",e.CUSTOM_FRAGMENT_MAIN_BEGIN="\n#ifdef TOON_TEXTURE\nvec3 toonNdl;\n#endif\n",e[`!${(0,r.N)("vec3 diffuseColor=vDiffuseColor.rgb;")}`]="\n#ifdef APPLY_AMBIENT_COLOR_TO_DIFFUSE\nvec3 diffuseColor=clamp(vDiffuseColor.rgb+vAmbientColor,0.0,1.0);\n#else\nvec3 diffuseColor=(vDiffuseColor.rgb);\n#endif\n",e[`!${(0,r.N)("float alpha=vDiffuseColor.a;")}`]="\n#ifdef CLAMP_ALPHA\nfloat alpha=clamp(vDiffuseColor.a,0.0,1.0);\n#else\nfloat alpha=vDiffuseColor.a;\n#endif\n",e[`!${(0,r.N)("baseColor=texture2D(diffuseSampler,vDiffuseUV+uvOffset);")}`]="\n#if defined(DIFFUSE) && defined(TEXTURE_COLOR)\nbaseColor=texture2D(diffuseSampler,(vDiffuseUV+uvOffset));baseColor.rgb=mix(\nvec3(1.0),\nbaseColor.rgb*textureMultiplicativeColor.rgb,\ntextureMultiplicativeColor.a\n);baseColor.rgb=clamp(\nbaseColor.rgb+(baseColor.rgb-vec3(1.0))*textureAdditiveColor.a,\n0.0,\n1.0\n)+textureAdditiveColor.rgb;\n#else\nbaseColor=texture2D(diffuseSampler,(vDiffuseUV+uvOffset));\n#endif\n",e[`!${(0,r.N)("struct lightingInfo\n{")}`]="\nstruct lightingInfo {\n#ifdef TOON_TEXTURE\n#ifndef NDOTL\nfloat ndl;\n#endif\nfloat isToon;\n#endif\n",e[`!${(0,r.N)("result.diffuse=ndl*diffuseColor*attenuation;")}`]="\n#ifdef TOON_TEXTURE\nresult.diffuse=diffuseColor*attenuation;result.ndl=ndl;result.isToon=1.0;\n#elif defined(IGNORE_DIFFUSE_WHEN_TOON_TEXTURE_DISABLED) \nresult.diffuse=diffuseColor*attenuation;\n#else\nresult.diffuse=(ndl*diffuseColor*attenuation);\n#endif\n",e[`!${(0,r.N)("diffuseBase+=info.diffuse*shadow;")}`]="\n#ifdef TOON_TEXTURE\ntoonNdl=vec3(clamp(info.ndl*shadow,0.02,0.98));toonNdl.r=texture2D(toonSampler,vec2(0.5,toonNdl.r)).r;toonNdl.g=texture2D(toonSampler,vec2(0.5,toonNdl.g)).g;toonNdl.b=texture2D(toonSampler,vec2(0.5,toonNdl.b)).b;\n#ifdef TOON_TEXTURE_COLOR\ntoonNdl=mix(\nvec3(1.0),\ntoonNdl*toonTextureMultiplicativeColor.rgb,\ntoonTextureMultiplicativeColor.a\n);toonNdl=clamp(\ntoonNdl+(toonNdl-vec3(1.0))*toonTextureAdditiveColor.a,\n0.0,\n1.0\n)+toonTextureAdditiveColor.rgb;\n#endif\ndiffuseBase+=mix(info.diffuse*shadow,toonNdl*info.diffuse,info.isToon);\n#elif defined(IGNORE_DIFFUSE_WHEN_TOON_TEXTURE_DISABLED)\ndiffuseBase+=info.diffuse;\n#else\ndiffuseBase+=(info.diffuse*shadow);\n#endif\n";const n="\n#ifdef EMISSIVEASILLUMINATION\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#else\n#ifdef LINKEMISSIVEWITHDIFFUSE\nvec3 finalDiffuse=clamp((diffuseBase+emissiveColor)*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#else\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor+emissiveColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#endif\n#endif\n";return e[`!${(0,r.N)(n)}`]=`\n#ifdef APPLY_AMBIENT_COLOR_TO_DIFFUSE\n#ifdef EMISSIVEASILLUMINATION\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor,0.0,1.0)*baseColor.rgb;\n#else\n#ifdef LINKEMISSIVEWITHDIFFUSE\nvec3 finalDiffuse=clamp((diffuseBase+emissiveColor)*diffuseColor,0.0,1.0)*baseColor.rgb;\n#else\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor+emissiveColor,0.0,1.0)*baseColor.rgb;\n#endif\n#endif\n#else\n${n.replace("diffuseBase","(diffuseBase)")}#endif\n`,e.CUSTOM_FRAGMENT_BEFORE_FOG="\n#if defined(NORMAL) && defined(SPHERE_TEXTURE)\nvec3 viewSpaceNormal=normalize(mat3(view)*vNormalW);vec2 sphereUV=viewSpaceNormal.xy*0.5+0.5;vec4 sphereReflectionColor=texture2D(sphereSampler,sphereUV);\n#ifdef SPHERE_TEXTURE_COLOR\nsphereReflectionColor.rgb=mix(\nvec3(1.0),\nsphereReflectionColor.rgb*sphereTextureMultiplicativeColor.rgb,\nsphereTextureMultiplicativeColor.a\n);sphereReflectionColor.rgb=clamp(\nsphereReflectionColor.rgb+(sphereReflectionColor.rgb-vec3(1.0))*sphereTextureAdditiveColor.a,\n0.0,\n1.0\n)+sphereTextureAdditiveColor.rgb;\n#endif\nsphereReflectionColor.rgb*=diffuseBase;\n#ifdef SPHERE_TEXTURE_BLEND_MODE_MULTIPLY\ncolor*=sphereReflectionColor;\n#elif defined(SPHERE_TEXTURE_BLEND_MODE_ADD)\ncolor=vec4(color.rgb+sphereReflectionColor.rgb,color.a);\n#endif\n#endif\n",e}return null}getUniforms(e){return{...super.getUniforms(e),fragment:"\n#if defined(DIFFUSE) && defined(TEXTURE_COLOR)\nuniform vec4 textureMultiplicativeColor;uniform vec4 textureAdditiveColor;\n#endif\n#if defined(SPHERE_TEXTURE) && defined(SPHERE_TEXTURE_COLOR)\nuniform vec4 sphereTextureMultiplicativeColor;uniform vec4 sphereTextureAdditiveColor;\n#endif\n#if defined(TOON_TEXTURE) && defined(TOON_TEXTURE_COLOR)\nuniform vec4 toonTextureMultiplicativeColor;uniform vec4 toonTextureAdditiveColor;\n#endif\n"}}}},9457:(e,n,i)=>{i.r(n),i.d(n,{textureAlphaCheckerPixelShader:()=>r});const o="textureAlphaCheckerPixelShader",t="\nprecision highp float;uniform sampler2D textureSampler;varying vec2 vUv;void main() {gl_FragColor=vec4(vec3(1.0)-vec3(texture2D(textureSampler,vUv).a),1.0);}\n";i(9610).l.ShadersStore[o]=t;const r={name:o,shader:t}},71:(e,n,i)=>{i.r(n),i.d(n,{textureAlphaCheckerVertexShader:()=>r});const o="textureAlphaCheckerVertexShader",t="\nprecision highp float;attribute vec2 uv;varying vec2 vUv;void main() {vUv=uv;gl_Position=vec4(mod(uv,1.0)*2.0-1.0,0.0,1.0);}\n";i(9610).l.ShadersStore[o]=t;const r={name:o,shader:t}},1438:(e,n,i)=>{var o=i(9610);i(8764),i(6467);o.l.IncludesShadersStore.defaultUboDeclaration="layout(std140,column_major) uniform;uniform Material\n{vec4 diffuseLeftColor;vec4 diffuseRightColor;vec4 opacityParts;vec4 reflectionLeftColor;vec4 reflectionRightColor;vec4 refractionLeftColor;vec4 refractionRightColor;vec4 emissiveLeftColor;vec4 emissiveRightColor;vec2 vDiffuseInfos;vec2 vAmbientInfos;vec2 vOpacityInfos;vec2 vReflectionInfos;vec3 vReflectionPosition;vec3 vReflectionSize;vec2 vEmissiveInfos;vec2 vLightmapInfos;vec2 vSpecularInfos;vec3 vBumpInfos;mat4 diffuseMatrix;mat4 ambientMatrix;mat4 opacityMatrix;mat4 reflectionMatrix;mat4 emissiveMatrix;mat4 lightmapMatrix;mat4 specularMatrix;mat4 bumpMatrix;vec2 vTangentSpaceParams;float pointSize;float alphaCutOff;mat4 refractionMatrix;vec4 vRefractionInfos;vec3 vRefractionPosition;vec3 vRefractionSize;vec4 vSpecularColor;vec3 vEmissiveColor;vec4 vDiffuseColor;vec3 vAmbientColor;\n#define ADDITIONAL_UBO_DECLARATION\n};\n#include\n#include\n"},3325:(e,n,i)=>{i(9610).l.IncludesShadersStore.helperFunctions="const float PI=3.1415926535897932384626433832795;const float RECIPROCAL_PI=0.3183098861837907;const float RECIPROCAL_PI2=0.15915494309189535;const float HALF_MIN=5.96046448e-08; \nconst float LinearEncodePowerApprox=2.2;const float GammaEncodePowerApprox=1.0/LinearEncodePowerApprox;const vec3 LuminanceEncodeApprox=vec3(0.2126,0.7152,0.0722);const float Epsilon=0.0000001;\n#define saturate(x) clamp(x,0.0,1.0)\n#define absEps(x) abs(x)+Epsilon\n#define maxEps(x) max(x,Epsilon)\n#define saturateEps(x) clamp(x,Epsilon,1.0)\nmat3 transposeMat3(mat3 inMatrix) {vec3 i0=inMatrix[0];vec3 i1=inMatrix[1];vec3 i2=inMatrix[2];mat3 outMatrix=mat3(\nvec3(i0.x,i1.x,i2.x),\nvec3(i0.y,i1.y,i2.y),\nvec3(i0.z,i1.z,i2.z)\n);return outMatrix;}\nmat3 inverseMat3(mat3 inMatrix) {float a00=inMatrix[0][0],a01=inMatrix[0][1],a02=inMatrix[0][2];float a10=inMatrix[1][0],a11=inMatrix[1][1],a12=inMatrix[1][2];float a20=inMatrix[2][0],a21=inMatrix[2][1],a22=inMatrix[2][2];float b01=a22*a11-a12*a21;float b11=-a22*a10+a12*a20;float b21=a21*a10-a11*a20;float det=a00*b01+a01*b11+a02*b21;return mat3(b01,(-a22*a01+a02*a21),(a12*a01-a02*a11),\nb11,(a22*a00-a02*a20),(-a12*a00+a02*a10),\nb21,(-a21*a00+a01*a20),(a11*a00-a01*a10))/det;}\n#if USE_EXACT_SRGB_CONVERSIONS\nvec3 toLinearSpaceExact(vec3 color)\n{vec3 nearZeroSection=0.0773993808*color;vec3 remainingSection=pow(0.947867299*(color+vec3(0.055)),vec3(2.4));\n#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)\nreturn mix(remainingSection,nearZeroSection,lessThanEqual(color,vec3(0.04045)));\n#else\nreturn\nvec3(\ncolor.r<=0.04045 ? nearZeroSection.r : remainingSection.r,\ncolor.g<=0.04045 ? nearZeroSection.g : remainingSection.g,\ncolor.b<=0.04045 ? nearZeroSection.b : remainingSection.b);\n#endif\n}\nvec3 toGammaSpaceExact(vec3 color)\n{vec3 nearZeroSection=12.92*color;vec3 remainingSection=1.055*pow(color,vec3(0.41666))-vec3(0.055);\n#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)\nreturn mix(remainingSection,nearZeroSection,lessThanEqual(color,vec3(0.0031308)));\n#else\nreturn\nvec3(\ncolor.r<=0.0031308 ? nearZeroSection.r : remainingSection.r,\ncolor.g<=0.0031308 ? nearZeroSection.g : remainingSection.g,\ncolor.b<=0.0031308 ? nearZeroSection.b : remainingSection.b);\n#endif\n}\n#endif\nfloat toLinearSpace(float color)\n{\n#if USE_EXACT_SRGB_CONVERSIONS\nfloat nearZeroSection=0.0773993808*color;float remainingSection=pow(0.947867299*(color+0.055),2.4);return color<=0.04045 ? nearZeroSection : remainingSection;\n#else\nreturn pow(color,LinearEncodePowerApprox);\n#endif\n}\nvec3 toLinearSpace(vec3 color)\n{\n#if USE_EXACT_SRGB_CONVERSIONS\nreturn toLinearSpaceExact(color);\n#else\nreturn pow(color,vec3(LinearEncodePowerApprox));\n#endif\n}\nvec4 toLinearSpace(vec4 color)\n{\n#if USE_EXACT_SRGB_CONVERSIONS\nreturn vec4(toLinearSpaceExact(color.rgb),color.a);\n#else\nreturn vec4(pow(color.rgb,vec3(LinearEncodePowerApprox)),color.a);\n#endif\n}\nfloat toGammaSpace(float color)\n{\n#if USE_EXACT_SRGB_CONVERSIONS\nfloat nearZeroSection=12.92*color;float remainingSection=1.055*pow(color,0.41666)-0.055;return color<=0.0031308 ? nearZeroSection : remainingSection;\n#else\nreturn pow(color,GammaEncodePowerApprox);\n#endif\n}\nvec3 toGammaSpace(vec3 color)\n{\n#if USE_EXACT_SRGB_CONVERSIONS\nreturn toGammaSpaceExact(color);\n#else\nreturn pow(color,vec3(GammaEncodePowerApprox));\n#endif\n}\nvec4 toGammaSpace(vec4 color)\n{\n#if USE_EXACT_SRGB_CONVERSIONS\nreturn vec4(toGammaSpaceExact(color.rgb),color.a);\n#else\nreturn vec4(pow(color.rgb,vec3(GammaEncodePowerApprox)),color.a);\n#endif\n}\nfloat square(float value)\n{return value*value;}\nvec3 square(vec3 value)\n{return value*value;}\nfloat pow5(float value) {float sq=value*value;return sq*sq*value;}\nfloat getLuminance(vec3 color)\n{return clamp(dot(color,LuminanceEncodeApprox),0.,1.);}\nfloat getRand(vec2 seed) {return fract(sin(dot(seed.xy ,vec2(12.9898,78.233)))*43758.5453);}\nfloat dither(vec2 seed,float varianceAmount) {float rand=getRand(seed);float normVariance=varianceAmount/255.0;float dither=mix(-normVariance,normVariance,rand);return dither;}\nconst float rgbdMaxRange=255.0;vec4 toRGBD(vec3 color) {float maxRGB=maxEps(max(color.r,max(color.g,color.b)));float D =max(rgbdMaxRange/maxRGB,1.);D =clamp(floor(D)/255.0,0.,1.);vec3 rgb=color.rgb*D;rgb=toGammaSpace(rgb);return vec4(clamp(rgb,0.,1.),D); }\nvec3 fromRGBD(vec4 rgbd) {rgbd.rgb=toLinearSpace(rgbd.rgb);return rgbd.rgb/rgbd.a;}\nvec3 parallaxCorrectNormal( vec3 vertexPos,vec3 origVec,vec3 cubeSize,vec3 cubePos ) {vec3 invOrigVec=vec3(1.0,1.0,1.0)/origVec;vec3 halfSize=cubeSize*0.5;vec3 intersecAtMaxPlane=(cubePos+halfSize-vertexPos)*invOrigVec;vec3 intersecAtMinPlane=(cubePos-halfSize-vertexPos)*invOrigVec;vec3 largestIntersec=max(intersecAtMaxPlane,intersecAtMinPlane);float distance=min(min(largestIntersec.x,largestIntersec.y),largestIntersec.z);vec3 intersectPositionWS=vertexPos+origVec*distance;return intersectPositionWS-cubePos;}\n"},9392:(e,n,i)=>{i(9610).l.IncludesShadersStore.imageProcessingDeclaration="#ifdef EXPOSURE\nuniform float exposureLinear;\n#endif\n#ifdef CONTRAST\nuniform float contrast;\n#endif\n#if defined(VIGNETTE) || defined(DITHER)\nuniform vec2 vInverseScreenSize;\n#endif\n#ifdef VIGNETTE\nuniform vec4 vignetteSettings1;uniform vec4 vignetteSettings2;\n#endif\n#ifdef COLORCURVES\nuniform vec4 vCameraColorCurveNegative;uniform vec4 vCameraColorCurveNeutral;uniform vec4 vCameraColorCurvePositive;\n#endif\n#ifdef COLORGRADING\n#ifdef COLORGRADING3D\nuniform highp sampler3D txColorTransform;\n#else\nuniform sampler2D txColorTransform;\n#endif\nuniform vec4 colorTransformSettings;\n#endif\n#ifdef DITHER\nuniform float ditherIntensity;\n#endif\n"},4017:(e,n,i)=>{i(9610).l.IncludesShadersStore.imageProcessingFunctions="#if defined(COLORGRADING) && !defined(COLORGRADING3D)\n/** \n* Polyfill for SAMPLE_TEXTURE_3D,which is unsupported in WebGL.\n* sampler3dSetting.x=textureOffset (0.5/textureSize).\n* sampler3dSetting.y=textureSize.\n*/\n#define inline\nvec3 sampleTexture3D(sampler2D colorTransform,vec3 color,vec2 sampler3dSetting)\n{float sliceSize=2.0*sampler3dSetting.x; \n#ifdef SAMPLER3DGREENDEPTH\nfloat sliceContinuous=(color.g-sampler3dSetting.x)*sampler3dSetting.y;\n#else\nfloat sliceContinuous=(color.b-sampler3dSetting.x)*sampler3dSetting.y;\n#endif\nfloat sliceInteger=floor(sliceContinuous);float sliceFraction=sliceContinuous-sliceInteger;\n#ifdef SAMPLER3DGREENDEPTH\nvec2 sliceUV=color.rb;\n#else\nvec2 sliceUV=color.rg;\n#endif\nsliceUV.x*=sliceSize;sliceUV.x+=sliceInteger*sliceSize;sliceUV=saturate(sliceUV);vec4 slice0Color=texture2D(colorTransform,sliceUV);sliceUV.x+=sliceSize;sliceUV=saturate(sliceUV);vec4 slice1Color=texture2D(colorTransform,sliceUV);vec3 result=mix(slice0Color.rgb,slice1Color.rgb,sliceFraction);\n#ifdef SAMPLER3DBGRMAP\ncolor.rgb=result.rgb;\n#else\ncolor.rgb=result.bgr;\n#endif\nreturn color;}\n#endif\n#if TONEMAPPING==3\nconst float PBRNeutralStartCompression=0.8-0.04;const float PBRNeutralDesaturation=0.15;vec3 PBRNeutralToneMapping( vec3 color ) {float x=min(color.r,min(color.g,color.b));float offset=x<0.08 ? x-6.25*x*x : 0.04;color-=offset;float peak=max(color.r,max(color.g,color.b));if (peak{i(9610).l.IncludesShadersStore.kernelBlurVaryingDeclaration="varying vec2 sampleCoord{X};"},4581:(e,n,i)=>{i(9610).l.IncludesShadersStore.logDepthDeclaration="#ifdef LOGARITHMICDEPTH\nuniform float logarithmicDepthConstant;varying float vFragmentDepth;\n#endif\n"},9741:(e,n,i)=>{i(9610).l.IncludesShadersStore.logDepthFragment="#ifdef LOGARITHMICDEPTH\ngl_FragDepthEXT=log2(vFragmentDepth)*logarithmicDepthConstant*0.5;\n#endif\n"},2215:(e,n,i)=>{i(9610).l.IncludesShadersStore.logDepthVertex="#ifdef LOGARITHMICDEPTH\nvFragmentDepth=1.0+gl_Position.w;gl_Position.z=log2(max(0.000001,vFragmentDepth))*logarithmicDepthConstant;\n#endif\n"},4980:(e,n,i)=>{i(9610).l.IncludesShadersStore.mainUVVaryingDeclaration="#ifdef MAINUV{X}\nvarying vec2 vMainUV{X};\n#endif\n"},6467:(e,n,i)=>{i(9610).l.IncludesShadersStore.meshUboDeclaration="#ifdef WEBGL2\nuniform mat4 world;uniform float visibility;\n#else\nlayout(std140,column_major) uniform;uniform Mesh\n{mat4 world;float visibility;};\n#endif\n#define WORLD_UBO\n"},8764:(e,n,i)=>{i(9610).l.IncludesShadersStore.sceneUboDeclaration="layout(std140,column_major) uniform;uniform Scene {mat4 viewProjection;\n#ifdef MULTIVIEW\nmat4 viewProjectionR;\n#endif \nmat4 view;mat4 projection;vec4 vEyePosition;};\n"},5426:(e,n,i)=>{i.r(n),i.d(n,{shadowMapFragmentSoftTransparentShadow:()=>r});const o="shadowMapFragmentSoftTransparentShadow",t="#if SM_SOFTTRANSPARENTSHADOW==1\nif ((bayerDither8(floor(mod(gl_FragCoord.xy,8.0))))/64.0>=softTransparentShadowSM.x*alpha) discard;\n#endif\n";i(9610).l.IncludesShadersStore[o]=t;const r={name:o,shader:t}},9336:(e,n,i)=>{i.r(n),i.d(n,{bloomMergePixelShader:()=>r});const o="bloomMergePixelShader",t="uniform sampler2D textureSampler;uniform sampler2D bloomBlur;varying vec2 vUV;uniform float bloomWeight;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{gl_FragColor=texture2D(textureSampler,vUV);vec3 blurred=texture2D(bloomBlur,vUV).rgb;gl_FragColor.rgb=gl_FragColor.rgb+(blurred.rgb*bloomWeight); }\n";i(9610).l.ShadersStore[o]=t;const r={name:o,shader:t}},2048:(e,n,i)=>{i.r(n),i.d(n,{chromaticAberrationPixelShader:()=>r});const o="chromaticAberrationPixelShader",t="uniform sampler2D textureSampler; \nuniform float chromatic_aberration;uniform float radialIntensity;uniform vec2 direction;uniform vec2 centerPosition;uniform float screen_width;uniform float screen_height;varying vec2 vUV;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{vec2 centered_screen_pos=vec2(vUV.x-centerPosition.x,vUV.y-centerPosition.y);vec2 directionOfEffect=direction;if(directionOfEffect.x==0. && directionOfEffect.y==0.){directionOfEffect=normalize(centered_screen_pos);}\nfloat radius2=centered_screen_pos.x*centered_screen_pos.x\n+ centered_screen_pos.y*centered_screen_pos.y;float radius=sqrt(radius2);vec3 ref_indices=vec3(-0.3,0.0,0.3);float ref_shiftX=chromatic_aberration*pow(radius,radialIntensity)*directionOfEffect.x/screen_width;float ref_shiftY=chromatic_aberration*pow(radius,radialIntensity)*directionOfEffect.y/screen_height;vec2 ref_coords_r=vec2(vUV.x+ref_indices.r*ref_shiftX,vUV.y+ref_indices.r*ref_shiftY*0.5);vec2 ref_coords_g=vec2(vUV.x+ref_indices.g*ref_shiftX,vUV.y+ref_indices.g*ref_shiftY*0.5);vec2 ref_coords_b=vec2(vUV.x+ref_indices.b*ref_shiftX,vUV.y+ref_indices.b*ref_shiftY*0.5);vec4 r=texture2D(textureSampler,ref_coords_r);vec4 g=texture2D(textureSampler,ref_coords_g);vec4 b=texture2D(textureSampler,ref_coords_b);float a=clamp(r.a+g.a+b.a,0.,1.);gl_FragColor=vec4(r.r,g.g,b.b,a);}";i(9610).l.ShadersStore[o]=t;const r={name:o,shader:t}},7694:(e,n,i)=>{i.r(n),i.d(n,{circleOfConfusionPixelShader:()=>r});const o="circleOfConfusionPixelShader",t="uniform sampler2D depthSampler;varying vec2 vUV;\n#ifndef COC_DEPTH_NOT_NORMALIZED\nuniform vec2 cameraMinMaxZ;\n#endif\nuniform float focusDistance;uniform float cocPrecalculation;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{float depth=texture2D(depthSampler,vUV).r;\n#define CUSTOM_COC_DEPTH\n#ifdef COC_DEPTH_NOT_NORMALIZED\nfloat pixelDistance=depth*1000.0;\n#else\nfloat pixelDistance=(cameraMinMaxZ.x+cameraMinMaxZ.y*depth)*1000.0; \n#endif\n#define CUSTOM_COC_PIXELDISTANCE\nfloat coc=abs(cocPrecalculation*((focusDistance-pixelDistance)/pixelDistance));coc=clamp(coc,0.0,1.0);gl_FragColor=vec4(coc,coc,coc,1.0);}\n";i(9610).l.ShadersStore[o]=t;const r={name:o,shader:t}},9041:(e,n,i)=>{i.r(n),i.d(n,{defaultPixelShader:()=>a});var o=i(9610);o.l.IncludesShadersStore.decalFragmentDeclaration="#ifdef DECAL\nuniform vec4 vDecalInfos;\n#endif\n";o.l.IncludesShadersStore.defaultFragmentDeclaration="uniform vec4 vEyePosition;uniform vec4 vDiffuseColor;uniform vec4 vSpecularColor;uniform vec3 vEmissiveColor;uniform vec3 vAmbientColor;uniform float visibility;\n#ifdef DIFFUSE\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef AMBIENT\nuniform vec2 vAmbientInfos;\n#endif\n#ifdef OPACITY \nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;uniform vec2 vTangentSpaceParams;\n#endif\n#ifdef ALPHATEST\nuniform float alphaCutOff;\n#endif\n#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION) || defined(PREPASS)\nuniform mat4 view;\n#endif\n#ifdef REFRACTION\nuniform vec4 vRefractionInfos;\n#ifndef REFRACTIONMAP_3D\nuniform mat4 refractionMatrix;\n#endif\n#ifdef REFRACTIONFRESNEL\nuniform vec4 refractionLeftColor;uniform vec4 refractionRightColor;\n#endif\n#if defined(USE_LOCAL_REFRACTIONMAP_CUBIC) && defined(REFRACTIONMAP_3D)\nuniform vec3 vRefractionPosition;uniform vec3 vRefractionSize; \n#endif\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\nuniform vec2 vSpecularInfos;\n#endif\n#ifdef DIFFUSEFRESNEL\nuniform vec4 diffuseLeftColor;uniform vec4 diffuseRightColor;\n#endif\n#ifdef OPACITYFRESNEL\nuniform vec4 opacityParts;\n#endif\n#ifdef EMISSIVEFRESNEL\nuniform vec4 emissiveLeftColor;uniform vec4 emissiveRightColor;\n#endif\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\n#if defined(REFLECTIONMAP_PLANAR) || defined(REFLECTIONMAP_CUBIC) || defined(REFLECTIONMAP_PROJECTION) || defined(REFLECTIONMAP_EQUIRECTANGULAR) || defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_SKYBOX)\nuniform mat4 reflectionMatrix;\n#endif\n#ifndef REFLECTIONMAP_SKYBOX\n#if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC)\nuniform vec3 vReflectionPosition;uniform vec3 vReflectionSize; \n#endif\n#endif\n#ifdef REFLECTIONFRESNEL\nuniform vec4 reflectionLeftColor;uniform vec4 reflectionRightColor;\n#endif\n#endif\n#ifdef DETAIL\nuniform vec4 vDetailInfos;\n#endif\n#include\n#define ADDITIONAL_FRAGMENT_DECLARATION\n",i(1438);o.l.IncludesShadersStore.prePassDeclaration="#ifdef PREPASS\n#extension GL_EXT_draw_buffers : require\nlayout(location=0) out highp vec4 glFragData[{X}];highp vec4 gl_FragColor;\n#ifdef PREPASS_LOCAL_POSITION\nvarying highp vec3 vPosition;\n#endif\n#ifdef PREPASS_DEPTH\nvarying highp vec3 vViewPos;\n#endif\n#if defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR)\nvarying highp vec4 vCurrentPosition;varying highp vec4 vPreviousPosition;\n#endif\n#endif\n";o.l.IncludesShadersStore.oitDeclaration="#ifdef ORDER_INDEPENDENT_TRANSPARENCY\n#extension GL_EXT_draw_buffers : require\nlayout(location=0) out vec2 depth; \nlayout(location=1) out vec4 frontColor;layout(location=2) out vec4 backColor;\n#define MAX_DEPTH 99999.0\nhighp vec4 gl_FragColor;uniform sampler2D oitDepthSampler;uniform sampler2D oitFrontColorSampler;\n#endif\n",i(4980),i(3325);o.l.IncludesShadersStore.lightFragmentDeclaration="#ifdef LIGHT{X}\nuniform vec4 vLightData{X};uniform vec4 vLightDiffuse{X};\n#ifdef SPECULARTERM\nuniform vec4 vLightSpecular{X};\n#else\nvec4 vLightSpecular{X}=vec4(0.);\n#endif\n#ifdef SHADOW{X}\n#ifdef SHADOWCSM{X}\nuniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];uniform float viewFrustumZ{X}[SHADOWCSMNUM_CASCADES{X}];uniform float frustumLengths{X}[SHADOWCSMNUM_CASCADES{X}];uniform float cascadeBlendFactor{X};varying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];varying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];varying vec4 vPositionFromCamera{X};\n#if defined(SHADOWPCSS{X})\nuniform highp sampler2DArrayShadow shadowTexture{X};uniform highp sampler2DArray depthTexture{X};uniform vec2 lightSizeUVCorrection{X}[SHADOWCSMNUM_CASCADES{X}];uniform float depthCorrection{X}[SHADOWCSMNUM_CASCADES{X}];uniform float penumbraDarkness{X};\n#elif defined(SHADOWPCF{X})\nuniform highp sampler2DArrayShadow shadowTexture{X};\n#else\nuniform highp sampler2DArray shadowTexture{X};\n#endif\n#ifdef SHADOWCSMDEBUG{X}\nconst vec3 vCascadeColorsMultiplier{X}[8]=vec3[8]\n(\nvec3 ( 1.5,0.0,0.0 ),\nvec3 ( 0.0,1.5,0.0 ),\nvec3 ( 0.0,0.0,5.5 ),\nvec3 ( 1.5,0.0,5.5 ),\nvec3 ( 1.5,1.5,0.0 ),\nvec3 ( 1.0,1.0,1.0 ),\nvec3 ( 0.0,1.0,5.5 ),\nvec3 ( 0.5,3.5,0.75 )\n);vec3 shadowDebug{X};\n#endif\n#ifdef SHADOWCSMUSESHADOWMAXZ{X}\nint index{X}=-1;\n#else\nint index{X}=SHADOWCSMNUM_CASCADES{X}-1;\n#endif\nfloat diff{X}=0.;\n#elif defined(SHADOWCUBE{X})\nuniform samplerCube shadowTexture{X};\n#else\nvarying vec4 vPositionFromLight{X};varying float vDepthMetric{X};\n#if defined(SHADOWPCSS{X})\nuniform highp sampler2DShadow shadowTexture{X};uniform highp sampler2D depthTexture{X};\n#elif defined(SHADOWPCF{X})\nuniform highp sampler2DShadow shadowTexture{X};\n#else\nuniform sampler2D shadowTexture{X};\n#endif\nuniform mat4 lightMatrix{X};\n#endif\nuniform vec4 shadowsInfo{X};uniform vec2 depthValues{X};\n#endif\n#ifdef SPOTLIGHT{X}\nuniform vec4 vLightDirection{X};uniform vec4 vLightFalloff{X};\n#elif defined(POINTLIGHT{X})\nuniform vec4 vLightFalloff{X};\n#elif defined(HEMILIGHT{X})\nuniform vec3 vLightGround{X};\n#endif\n#ifdef PROJECTEDLIGHTTEXTURE{X}\nuniform mat4 textureProjectionMatrix{X};uniform sampler2D projectionLightTexture{X};\n#endif\n#endif\n";o.l.IncludesShadersStore.lightUboDeclaration="#ifdef LIGHT{X}\nuniform Light{X}\n{vec4 vLightData;vec4 vLightDiffuse;vec4 vLightSpecular;\n#ifdef SPOTLIGHT{X}\nvec4 vLightDirection;vec4 vLightFalloff;\n#elif defined(POINTLIGHT{X})\nvec4 vLightFalloff;\n#elif defined(HEMILIGHT{X})\nvec3 vLightGround;\n#endif\nvec4 shadowsInfo;vec2 depthValues;} light{X};\n#ifdef PROJECTEDLIGHTTEXTURE{X}\nuniform mat4 textureProjectionMatrix{X};uniform sampler2D projectionLightTexture{X};\n#endif\n#ifdef SHADOW{X}\n#ifdef SHADOWCSM{X}\nuniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];uniform float viewFrustumZ{X}[SHADOWCSMNUM_CASCADES{X}];uniform float frustumLengths{X}[SHADOWCSMNUM_CASCADES{X}];uniform float cascadeBlendFactor{X};varying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];varying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];varying vec4 vPositionFromCamera{X};\n#if defined(SHADOWPCSS{X})\nuniform highp sampler2DArrayShadow shadowTexture{X};uniform highp sampler2DArray depthTexture{X};uniform vec2 lightSizeUVCorrection{X}[SHADOWCSMNUM_CASCADES{X}];uniform float depthCorrection{X}[SHADOWCSMNUM_CASCADES{X}];uniform float penumbraDarkness{X};\n#elif defined(SHADOWPCF{X})\nuniform highp sampler2DArrayShadow shadowTexture{X};\n#else\nuniform highp sampler2DArray shadowTexture{X};\n#endif\n#ifdef SHADOWCSMDEBUG{X}\nconst vec3 vCascadeColorsMultiplier{X}[8]=vec3[8]\n(\nvec3 ( 1.5,0.0,0.0 ),\nvec3 ( 0.0,1.5,0.0 ),\nvec3 ( 0.0,0.0,5.5 ),\nvec3 ( 1.5,0.0,5.5 ),\nvec3 ( 1.5,1.5,0.0 ),\nvec3 ( 1.0,1.0,1.0 ),\nvec3 ( 0.0,1.0,5.5 ),\nvec3 ( 0.5,3.5,0.75 )\n);vec3 shadowDebug{X};\n#endif\n#ifdef SHADOWCSMUSESHADOWMAXZ{X}\nint index{X}=-1;\n#else\nint index{X}=SHADOWCSMNUM_CASCADES{X}-1;\n#endif\nfloat diff{X}=0.;\n#elif defined(SHADOWCUBE{X})\nuniform samplerCube shadowTexture{X}; \n#else\nvarying vec4 vPositionFromLight{X};varying float vDepthMetric{X};\n#if defined(SHADOWPCSS{X})\nuniform highp sampler2DShadow shadowTexture{X};uniform highp sampler2D depthTexture{X};\n#elif defined(SHADOWPCF{X})\nuniform highp sampler2DShadow shadowTexture{X};\n#else\nuniform sampler2D shadowTexture{X};\n#endif\nuniform mat4 lightMatrix{X};\n#endif\n#endif\n#endif\n";o.l.IncludesShadersStore.lightsFragmentFunctions="struct lightingInfo\n{vec3 diffuse;\n#ifdef SPECULARTERM\nvec3 specular;\n#endif\n#ifdef NDOTL\nfloat ndl;\n#endif\n};lightingInfo computeLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,float range,float glossiness) {lightingInfo result;vec3 lightVectorW;float attenuation=1.0;if (lightData.w==0.)\n{vec3 direction=lightData.xyz-vPositionW;attenuation=max(0.,1.0-length(direction)/range);lightVectorW=normalize(direction);}\nelse\n{lightVectorW=normalize(-lightData.xyz);}\nfloat ndl=max(0.,dot(vNormal,lightVectorW));\n#ifdef NDOTL\nresult.ndl=ndl;\n#endif\nresult.diffuse=ndl*diffuseColor*attenuation;\n#ifdef SPECULARTERM\nvec3 angleW=normalize(viewDirectionW+lightVectorW);float specComp=max(0.,dot(vNormal,angleW));specComp=pow(specComp,max(1.,glossiness));result.specular=specComp*specularColor*attenuation;\n#endif\nreturn result;}\nlightingInfo computeSpotLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec4 lightDirection,vec3 diffuseColor,vec3 specularColor,float range,float glossiness) {lightingInfo result;vec3 direction=lightData.xyz-vPositionW;vec3 lightVectorW=normalize(direction);float attenuation=max(0.,1.0-length(direction)/range);float cosAngle=max(0.,dot(lightDirection.xyz,-lightVectorW));if (cosAngle>=lightDirection.w)\n{cosAngle=max(0.,pow(cosAngle,lightData.w));attenuation*=cosAngle;float ndl=max(0.,dot(vNormal,lightVectorW));\n#ifdef NDOTL\nresult.ndl=ndl;\n#endif\nresult.diffuse=ndl*diffuseColor*attenuation;\n#ifdef SPECULARTERM\nvec3 angleW=normalize(viewDirectionW+lightVectorW);float specComp=max(0.,dot(vNormal,angleW));specComp=pow(specComp,max(1.,glossiness));result.specular=specComp*specularColor*attenuation;\n#endif\nreturn result;}\nresult.diffuse=vec3(0.);\n#ifdef SPECULARTERM\nresult.specular=vec3(0.);\n#endif\n#ifdef NDOTL\nresult.ndl=0.;\n#endif\nreturn result;}\nlightingInfo computeHemisphericLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,vec3 groundColor,float glossiness) {lightingInfo result;float ndl=dot(vNormal,lightData.xyz)*0.5+0.5;\n#ifdef NDOTL\nresult.ndl=ndl;\n#endif\nresult.diffuse=mix(groundColor,diffuseColor,ndl);\n#ifdef SPECULARTERM\nvec3 angleW=normalize(viewDirectionW+lightData.xyz);float specComp=max(0.,dot(vNormal,angleW));specComp=pow(specComp,max(1.,glossiness));result.specular=specComp*specularColor;\n#endif\nreturn result;}\n#define inline\nvec3 computeProjectionTextureDiffuseLighting(sampler2D projectionLightSampler,mat4 textureProjectionMatrix,vec3 posW){vec4 strq=textureProjectionMatrix*vec4(posW,1.0);strq/=strq.w;vec3 textureColor=texture2D(projectionLightSampler,strq.xy).rgb;return textureColor;}";o.l.IncludesShadersStore.shadowsFragmentFunctions="#ifdef SHADOWS\n#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)\n#define TEXTUREFUNC(s,c,l) texture2DLodEXT(s,c,l)\n#else\n#define TEXTUREFUNC(s,c,b) texture2D(s,c,b)\n#endif\n#ifndef SHADOWFLOAT\nfloat unpack(vec4 color)\n{const vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(color,bit_shift);}\n#endif\nfloat computeFallOff(float value,vec2 clipSpace,float frustumEdgeFalloff)\n{float mask=smoothstep(1.0-frustumEdgeFalloff,1.00000012,clamp(dot(clipSpace,clipSpace),0.,1.));return mix(value,1.0,mask);}\n#define inline\nfloat computeShadowCube(vec3 worldPos,vec3 lightPosition,samplerCube shadowSampler,float darkness,vec2 depthValues)\n{vec3 directionToLight=worldPos-lightPosition;float depth=length(directionToLight);depth=(depth+depthValues.x)/(depthValues.y);depth=clamp(depth,0.,1.0);directionToLight=normalize(directionToLight);directionToLight.y=-directionToLight.y;\n#ifndef SHADOWFLOAT\nfloat shadow=unpack(textureCube(shadowSampler,directionToLight));\n#else\nfloat shadow=textureCube(shadowSampler,directionToLight).x;\n#endif\nreturn depth>shadow ? darkness : 1.0;}\n#define inline\nfloat computeShadowWithPoissonSamplingCube(vec3 worldPos,vec3 lightPosition,samplerCube shadowSampler,float mapSize,float darkness,vec2 depthValues)\n{vec3 directionToLight=worldPos-lightPosition;float depth=length(directionToLight);depth=(depth+depthValues.x)/(depthValues.y);depth=clamp(depth,0.,1.0);directionToLight=normalize(directionToLight);directionToLight.y=-directionToLight.y;float visibility=1.;vec3 poissonDisk[4];poissonDisk[0]=vec3(-1.0,1.0,-1.0);poissonDisk[1]=vec3(1.0,-1.0,-1.0);poissonDisk[2]=vec3(-1.0,-1.0,-1.0);poissonDisk[3]=vec3(1.0,-1.0,1.0);\n#ifndef SHADOWFLOAT\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize))shadow ? computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff) : 1.;}\n#endif\n#define inline\nfloat computeShadow(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float frustumEdgeFalloff)\n{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec2 uv=0.5*clipSpace.xy+vec2(0.5);if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{return 1.0;}\nelse\n{float shadowPixelDepth=clamp(depthMetric,0.,1.0);\n#ifndef SHADOWFLOAT\nfloat shadow=unpack(TEXTUREFUNC(shadowSampler,uv,0.));\n#else\nfloat shadow=TEXTUREFUNC(shadowSampler,uv,0.).x;\n#endif\nreturn shadowPixelDepth>shadow ? computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff) : 1.;}}\n#define inline\nfloat computeShadowWithPoissonSampling(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float mapSize,float darkness,float frustumEdgeFalloff)\n{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec2 uv=0.5*clipSpace.xy+vec2(0.5);if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{return 1.0;}\nelse\n{float shadowPixelDepth=clamp(depthMetric,0.,1.0);float visibility=1.;vec2 poissonDisk[4];poissonDisk[0]=vec2(-0.94201624,-0.39906216);poissonDisk[1]=vec2(0.94558609,-0.76890725);poissonDisk[2]=vec2(-0.094184101,-0.92938870);poissonDisk[3]=vec2(0.34495938,0.29387760);\n#ifndef SHADOWFLOAT\nif (unpack(TEXTUREFUNC(shadowSampler,uv+poissonDisk[0]*mapSize,0.))1.0 || uv.y<0. || uv.y>1.0)\n{return 1.0;}\nelse\n{float shadowPixelDepth=clamp(depthMetric,0.,1.0);\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(TEXTUREFUNC(shadowSampler,uv,0.));\n#else\nfloat shadowMapSample=TEXTUREFUNC(shadowSampler,uv,0.).x;\n#endif\nfloat esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);return computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);}}\n#define inline\nfloat computeShadowWithCloseESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)\n{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec2 uv=0.5*clipSpace.xy+vec2(0.5);if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{return 1.0;}\nelse\n{float shadowPixelDepth=clamp(depthMetric,0.,1.0); \n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(TEXTUREFUNC(shadowSampler,uv,0.));\n#else\nfloat shadowMapSample=TEXTUREFUNC(shadowSampler,uv,0.).x;\n#endif\nfloat esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);return computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);}}\n#ifdef IS_NDC_HALF_ZRANGE\n#define ZINCLIP clipSpace.z\n#else\n#define ZINCLIP uvDepth.z\n#endif\n#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)\n#define GREATEST_LESS_THAN_ONE 0.99999994\n#define DISABLE_UNIFORMITY_ANALYSIS\n#define inline\nfloat computeShadowWithCSMPCF1(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,float darkness,float frustumEdgeFalloff)\n{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));uvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);vec4 uvDepthLayer=vec4(uvDepth.x,uvDepth.y,layer,uvDepth.z);float shadow=texture2D(shadowSampler,uvDepthLayer);shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}\n#define inline\nfloat computeShadowWithCSMPCF3(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\n{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));uvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);vec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x; \nuv+=0.5; \nvec2 st=fract(uv); \nvec2 base_uv=floor(uv)-0.5; \nbase_uv*=shadowMapSizeAndInverse.y; \nvec2 uvw0=3.-2.*st;vec2 uvw1=1.+2.*st;vec2 u=vec2((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y;vec2 v=vec2((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y;float shadow=0.;shadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[0]),layer,uvDepth.z));shadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[0]),layer,uvDepth.z));shadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[1]),layer,uvDepth.z));shadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[1]),layer,uvDepth.z));shadow=shadow/16.;shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}\n#define inline\nfloat computeShadowWithCSMPCF5(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\n{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));uvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);vec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x; \nuv+=0.5; \nvec2 st=fract(uv); \nvec2 base_uv=floor(uv)-0.5; \nbase_uv*=shadowMapSizeAndInverse.y; \nvec2 uvw0=4.-3.*st;vec2 uvw1=vec2(7.);vec2 uvw2=1.+3.*st;vec3 u=vec3((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y;vec3 v=vec3((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y;float shadow=0.;shadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[0]),layer,uvDepth.z));shadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[0]),layer,uvDepth.z));shadow+=uvw2.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[0]),layer,uvDepth.z));shadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[1]),layer,uvDepth.z));shadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[1]),layer,uvDepth.z));shadow+=uvw2.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[1]),layer,uvDepth.z));shadow+=uvw0.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[2]),layer,uvDepth.z));shadow+=uvw1.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[2]),layer,uvDepth.z));shadow+=uvw2.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[2]),layer,uvDepth.z));shadow=shadow/144.;shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}\n#define inline\nfloat computeShadowWithPCF1(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,float darkness,float frustumEdgeFalloff)\n{if (depthMetric>1.0 || depthMetric<0.0) {return 1.0;}\nelse\n{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));uvDepth.z=ZINCLIP;float shadow=TEXTUREFUNC(shadowSampler,uvDepth,0.);shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}}\n#define inline\nfloat computeShadowWithPCF3(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\n{if (depthMetric>1.0 || depthMetric<0.0) {return 1.0;}\nelse\n{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));uvDepth.z=ZINCLIP;vec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x; \nuv+=0.5; \nvec2 st=fract(uv); \nvec2 base_uv=floor(uv)-0.5; \nbase_uv*=shadowMapSizeAndInverse.y; \nvec2 uvw0=3.-2.*st;vec2 uvw1=1.+2.*st;vec2 u=vec2((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y;vec2 v=vec2((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y;float shadow=0.;shadow+=uvw0.x*uvw0.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z),0.);shadow+=uvw1.x*uvw0.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z),0.);shadow+=uvw0.x*uvw1.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z),0.);shadow+=uvw1.x*uvw1.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z),0.);shadow=shadow/16.;shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}}\n#define inline\nfloat computeShadowWithPCF5(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\n{if (depthMetric>1.0 || depthMetric<0.0) {return 1.0;}\nelse\n{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));uvDepth.z=ZINCLIP;vec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x; \nuv+=0.5; \nvec2 st=fract(uv); \nvec2 base_uv=floor(uv)-0.5; \nbase_uv*=shadowMapSizeAndInverse.y; \nvec2 uvw0=4.-3.*st;vec2 uvw1=vec2(7.);vec2 uvw2=1.+3.*st;vec3 u=vec3((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y;vec3 v=vec3((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y;float shadow=0.;shadow+=uvw0.x*uvw0.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z),0.);shadow+=uvw1.x*uvw0.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z),0.);shadow+=uvw2.x*uvw0.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[0]),uvDepth.z),0.);shadow+=uvw0.x*uvw1.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z),0.);shadow+=uvw1.x*uvw1.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z),0.);shadow+=uvw2.x*uvw1.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[1]),uvDepth.z),0.);shadow+=uvw0.x*uvw2.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[2]),uvDepth.z),0.);shadow+=uvw1.x*uvw2.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[2]),uvDepth.z),0.);shadow+=uvw2.x*uvw2.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[2]),uvDepth.z),0.);shadow=shadow/144.;shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}}\nconst vec3 PoissonSamplers32[64]=vec3[64](\nvec3(0.06407013,0.05409927,0.),\nvec3(0.7366577,0.5789394,0.),\nvec3(-0.6270542,-0.5320278,0.),\nvec3(-0.4096107,0.8411095,0.),\nvec3(0.6849564,-0.4990818,0.),\nvec3(-0.874181,-0.04579735,0.),\nvec3(0.9989998,0.0009880066,0.),\nvec3(-0.004920578,-0.9151649,0.),\nvec3(0.1805763,0.9747483,0.),\nvec3(-0.2138451,0.2635818,0.),\nvec3(0.109845,0.3884785,0.),\nvec3(0.06876755,-0.3581074,0.),\nvec3(0.374073,-0.7661266,0.),\nvec3(0.3079132,-0.1216763,0.),\nvec3(-0.3794335,-0.8271583,0.),\nvec3(-0.203878,-0.07715034,0.),\nvec3(0.5912697,0.1469799,0.),\nvec3(-0.88069,0.3031784,0.),\nvec3(0.5040108,0.8283722,0.),\nvec3(-0.5844124,0.5494877,0.),\nvec3(0.6017799,-0.1726654,0.),\nvec3(-0.5554981,0.1559997,0.),\nvec3(-0.3016369,-0.3900928,0.),\nvec3(-0.5550632,-0.1723762,0.),\nvec3(0.925029,0.2995041,0.),\nvec3(-0.2473137,0.5538505,0.),\nvec3(0.9183037,-0.2862392,0.),\nvec3(0.2469421,0.6718712,0.),\nvec3(0.3916397,-0.4328209,0.),\nvec3(-0.03576927,-0.6220032,0.),\nvec3(-0.04661255,0.7995201,0.),\nvec3(0.4402924,0.3640312,0.),\nvec3(0.),\nvec3(0.),\nvec3(0.),\nvec3(0.),\nvec3(0.),\nvec3(0.),\nvec3(0.),\nvec3(0.),\nvec3(0.),\nvec3(0.),\nvec3(0.),\nvec3(0.),\nvec3(0.),\nvec3(0.),\nvec3(0.),\nvec3(0.),\nvec3(0.),\nvec3(0.),\nvec3(0.),\nvec3(0.),\nvec3(0.),\nvec3(0.),\nvec3(0.),\nvec3(0.),\nvec3(0.),\nvec3(0.),\nvec3(0.),\nvec3(0.),\nvec3(0.),\nvec3(0.),\nvec3(0.),\nvec3(0.)\n);const vec3 PoissonSamplers64[64]=vec3[64](\nvec3(-0.613392,0.617481,0.),\nvec3(0.170019,-0.040254,0.),\nvec3(-0.299417,0.791925,0.),\nvec3(0.645680,0.493210,0.),\nvec3(-0.651784,0.717887,0.),\nvec3(0.421003,0.027070,0.),\nvec3(-0.817194,-0.271096,0.),\nvec3(-0.705374,-0.668203,0.),\nvec3(0.977050,-0.108615,0.),\nvec3(0.063326,0.142369,0.),\nvec3(0.203528,0.214331,0.),\nvec3(-0.667531,0.326090,0.),\nvec3(-0.098422,-0.295755,0.),\nvec3(-0.885922,0.215369,0.),\nvec3(0.566637,0.605213,0.),\nvec3(0.039766,-0.396100,0.),\nvec3(0.751946,0.453352,0.),\nvec3(0.078707,-0.715323,0.),\nvec3(-0.075838,-0.529344,0.),\nvec3(0.724479,-0.580798,0.),\nvec3(0.222999,-0.215125,0.),\nvec3(-0.467574,-0.405438,0.),\nvec3(-0.248268,-0.814753,0.),\nvec3(0.354411,-0.887570,0.),\nvec3(0.175817,0.382366,0.),\nvec3(0.487472,-0.063082,0.),\nvec3(-0.084078,0.898312,0.),\nvec3(0.488876,-0.783441,0.),\nvec3(0.470016,0.217933,0.),\nvec3(-0.696890,-0.549791,0.),\nvec3(-0.149693,0.605762,0.),\nvec3(0.034211,0.979980,0.),\nvec3(0.503098,-0.308878,0.),\nvec3(-0.016205,-0.872921,0.),\nvec3(0.385784,-0.393902,0.),\nvec3(-0.146886,-0.859249,0.),\nvec3(0.643361,0.164098,0.),\nvec3(0.634388,-0.049471,0.),\nvec3(-0.688894,0.007843,0.),\nvec3(0.464034,-0.188818,0.),\nvec3(-0.440840,0.137486,0.),\nvec3(0.364483,0.511704,0.),\nvec3(0.034028,0.325968,0.),\nvec3(0.099094,-0.308023,0.),\nvec3(0.693960,-0.366253,0.),\nvec3(0.678884,-0.204688,0.),\nvec3(0.001801,0.780328,0.),\nvec3(0.145177,-0.898984,0.),\nvec3(0.062655,-0.611866,0.),\nvec3(0.315226,-0.604297,0.),\nvec3(-0.780145,0.486251,0.),\nvec3(-0.371868,0.882138,0.),\nvec3(0.200476,0.494430,0.),\nvec3(-0.494552,-0.711051,0.),\nvec3(0.612476,0.705252,0.),\nvec3(-0.578845,-0.768792,0.),\nvec3(-0.772454,-0.090976,0.),\nvec3(0.504440,0.372295,0.),\nvec3(0.155736,0.065157,0.),\nvec3(0.391522,0.849605,0.),\nvec3(-0.620106,-0.328104,0.),\nvec3(0.789239,-0.419965,0.),\nvec3(-0.545396,0.538133,0.),\nvec3(-0.178564,-0.596057,0.)\n);\n#define inline\nfloat computeShadowWithCSMPCSS(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray depthSampler,highp sampler2DArrayShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,int searchTapCount,int pcfTapCount,vec3[64] poissonSamplers,vec2 lightSizeUVCorrection,float depthCorrection,float penumbraDarkness)\n{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));uvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);vec4 uvDepthLayer=vec4(uvDepth.x,uvDepth.y,layer,uvDepth.z);float blockerDepth=0.0;float sumBlockerDepth=0.0;float numBlocker=0.0;for (int i=0; i1.0 || depthMetric<0.0) {return 1.0;}\nelse\n{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));uvDepth.z=ZINCLIP;float blockerDepth=0.0;float sumBlockerDepth=0.0;float numBlocker=0.0;for (int i=0; i{i.r(n),i.d(n,{defaultVertexShader:()=>a});var o=i(9610);o.l.IncludesShadersStore.decalVertexDeclaration="#ifdef DECAL\nuniform vec4 vDecalInfos;uniform mat4 decalMatrix;\n#endif\n";o.l.IncludesShadersStore.defaultVertexDeclaration="uniform mat4 viewProjection;\n#ifdef MULTIVIEW\nmat4 viewProjectionR;\n#endif \nuniform mat4 view;\n#ifdef DIFFUSE\nuniform mat4 diffuseMatrix;uniform vec2 vDiffuseInfos;\n#endif\n#ifdef AMBIENT\nuniform mat4 ambientMatrix;uniform vec2 vAmbientInfos;\n#endif\n#ifdef OPACITY\nuniform mat4 opacityMatrix;uniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;uniform mat4 emissiveMatrix;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;uniform mat4 lightmapMatrix;\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\nuniform vec2 vSpecularInfos;uniform mat4 specularMatrix;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;uniform mat4 bumpMatrix;\n#endif\n#ifdef REFLECTION\nuniform mat4 reflectionMatrix;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n#ifdef DETAIL\nuniform vec4 vDetailInfos;uniform mat4 detailMatrix;\n#endif\n#include\n#define ADDITIONAL_VERTEX_DECLARATION\n",i(1438);o.l.IncludesShadersStore.uvAttributeDeclaration="#ifdef UV{X}\nattribute vec2 uv{X};\n#endif\n",i(3325),i(9707),i(8959),i(1218);o.l.IncludesShadersStore.prePassVertexDeclaration="#ifdef PREPASS\n#ifdef PREPASS_LOCAL_POSITION\nvarying vec3 vPosition;\n#endif\n#ifdef PREPASS_DEPTH\nvarying vec3 vViewPos;\n#endif\n#if defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR)\nuniform mat4 previousViewProjection;varying vec4 vCurrentPosition;varying vec4 vPreviousPosition;\n#endif\n#endif\n",i(4980);o.l.IncludesShadersStore.samplerVertexDeclaration="#if defined(_DEFINENAME_) && _DEFINENAME_DIRECTUV==0\nvarying vec2 v_VARYINGNAME_UV;\n#endif\n";o.l.IncludesShadersStore.bumpVertexDeclaration="#if defined(BUMP) || defined(PARALLAX) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC)\n#if defined(TANGENT) && defined(NORMAL) \nvarying mat3 vTBN;\n#endif\n#endif\n",i(1636);o.l.IncludesShadersStore.fogVertexDeclaration="#ifdef FOG\nvarying vec3 vFogDistance;\n#endif\n";o.l.IncludesShadersStore.lightVxFragmentDeclaration="#ifdef LIGHT{X}\nuniform vec4 vLightData{X};uniform vec4 vLightDiffuse{X};\n#ifdef SPECULARTERM\nuniform vec4 vLightSpecular{X};\n#else\nvec4 vLightSpecular{X}=vec4(0.);\n#endif\n#ifdef SHADOW{X}\n#ifdef SHADOWCSM{X}\nuniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];varying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];varying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];varying vec4 vPositionFromCamera{X};\n#elif defined(SHADOWCUBE{X})\n#else\nvarying vec4 vPositionFromLight{X};varying float vDepthMetric{X};uniform mat4 lightMatrix{X};\n#endif\nuniform vec4 shadowsInfo{X};uniform vec2 depthValues{X};\n#endif\n#ifdef SPOTLIGHT{X}\nuniform vec4 vLightDirection{X};uniform vec4 vLightFalloff{X};\n#elif defined(POINTLIGHT{X})\nuniform vec4 vLightFalloff{X};\n#elif defined(HEMILIGHT{X})\nuniform vec3 vLightGround{X};\n#endif\n#endif\n";o.l.IncludesShadersStore.lightVxUboDeclaration="#ifdef LIGHT{X}\nuniform Light{X}\n{vec4 vLightData;vec4 vLightDiffuse;vec4 vLightSpecular;\n#ifdef SPOTLIGHT{X}\nvec4 vLightDirection;vec4 vLightFalloff;\n#elif defined(POINTLIGHT{X})\nvec4 vLightFalloff;\n#elif defined(HEMILIGHT{X})\nvec3 vLightGround;\n#endif\nvec4 shadowsInfo;vec2 depthValues;} light{X};\n#ifdef SHADOW{X}\n#ifdef SHADOWCSM{X}\nuniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];varying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];varying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];varying vec4 vPositionFromCamera{X};\n#elif defined(SHADOWCUBE{X})\n#else\nvarying vec4 vPositionFromLight{X};varying float vDepthMetric{X};uniform mat4 lightMatrix{X};\n#endif\n#endif\n#endif\n",i(7999),i(738),i(4581),i(8451),i(5060),i(3298),i(3361),i(5523);o.l.IncludesShadersStore.prePassVertex="#ifdef PREPASS_DEPTH\nvViewPos=(view*worldPos).rgb;\n#endif\n#ifdef PREPASS_LOCAL_POSITION\nvPosition=positionUpdated.xyz;\n#endif\n#if (defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR)) && defined(BONES_VELOCITY_ENABLED)\nvCurrentPosition=viewProjection*worldPos;\n#if NUM_BONE_INFLUENCERS>0\nmat4 previousInfluence;previousInfluence=mPreviousBones[int(matricesIndices[0])]*matricesWeights[0];\n#if NUM_BONE_INFLUENCERS>1\npreviousInfluence+=mPreviousBones[int(matricesIndices[1])]*matricesWeights[1];\n#endif \n#if NUM_BONE_INFLUENCERS>2\npreviousInfluence+=mPreviousBones[int(matricesIndices[2])]*matricesWeights[2];\n#endif \n#if NUM_BONE_INFLUENCERS>3\npreviousInfluence+=mPreviousBones[int(matricesIndices[3])]*matricesWeights[3];\n#endif\n#if NUM_BONE_INFLUENCERS>4\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];\n#endif \n#if NUM_BONE_INFLUENCERS>5\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];\n#endif \n#if NUM_BONE_INFLUENCERS>6\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];\n#endif \n#if NUM_BONE_INFLUENCERS>7\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];\n#endif\nvPreviousPosition=previousViewProjection*finalPreviousWorld*previousInfluence*vec4(positionUpdated,1.0);\n#else\nvPreviousPosition=previousViewProjection*finalPreviousWorld*vec4(positionUpdated,1.0);\n#endif\n#endif\n";o.l.IncludesShadersStore.uvVariableDeclaration="#if !defined(UV{X}) && defined(MAINUV{X})\nvec2 uv{X}=vec2(0.,0.);\n#endif\n#ifdef MAINUV{X}\nvMainUV{X}=uv{X};\n#endif\n";o.l.IncludesShadersStore.samplerVertexImplementation="#if defined(_DEFINENAME_) && _DEFINENAME_DIRECTUV==0\nif (v_INFONAME_==0.)\n{v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uvUpdated,1.0,0.0));}\n#ifdef UV2\nelse if (v_INFONAME_==1.)\n{v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv2,1.0,0.0));}\n#endif\n#ifdef UV3\nelse if (v_INFONAME_==2.)\n{v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv3,1.0,0.0));}\n#endif\n#ifdef UV4\nelse if (v_INFONAME_==3.)\n{v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv4,1.0,0.0));}\n#endif\n#ifdef UV5\nelse if (v_INFONAME_==4.)\n{v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv5,1.0,0.0));}\n#endif\n#ifdef UV6\nelse if (v_INFONAME_==5.)\n{v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv6,1.0,0.0));}\n#endif\n#endif\n";o.l.IncludesShadersStore.bumpVertex="#if defined(BUMP) || defined(PARALLAX) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC)\n#if defined(TANGENT) && defined(NORMAL)\nvec3 tbnNormal=normalize(normalUpdated);vec3 tbnTangent=normalize(tangentUpdated.xyz);vec3 tbnBitangent=cross(tbnNormal,tbnTangent)*tangentUpdated.w;vTBN=mat3(finalWorld)*mat3(tbnTangent,tbnBitangent,tbnNormal);\n#endif\n#endif\n",i(7314);o.l.IncludesShadersStore.fogVertex="#ifdef FOG\nvFogDistance=(view*worldPos).xyz;\n#endif\n";o.l.IncludesShadersStore.shadowsVertex="#ifdef SHADOWS\n#if defined(SHADOWCSM{X})\nvPositionFromCamera{X}=view*worldPos;for (int i=0; i{i.r(n),i.d(n,{depthBoxBlurPixelShader:()=>r});const o="depthBoxBlurPixelShader",t="varying vec2 vUV;uniform sampler2D textureSampler;uniform vec2 screenSize;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{vec4 colorDepth=vec4(0.0);for (int x=-OFFSET; x<=OFFSET; x++)\nfor (int y=-OFFSET; y<=OFFSET; y++)\ncolorDepth+=texture2D(textureSampler,vUV+vec2(x,y)/screenSize);gl_FragColor=(colorDepth/float((OFFSET*2+1)*(OFFSET*2+1)));}";i(9610).l.ShadersStore[o]=t;const r={name:o,shader:t}},9411:(e,n,i)=>{i.r(n),i.d(n,{depthOfFieldMergePixelShader:()=>r});const o="depthOfFieldMergePixelShader",t="#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)\n#define TEXTUREFUNC(s,c,lod) texture2DLodEXT(s,c,lod)\n#else\n#define TEXTUREFUNC(s,c,bias) texture2D(s,c,bias)\n#endif\nuniform sampler2D textureSampler;varying vec2 vUV;uniform sampler2D circleOfConfusionSampler;uniform sampler2D blurStep0;\n#if BLUR_LEVEL>0\nuniform sampler2D blurStep1;\n#endif\n#if BLUR_LEVEL>1\nuniform sampler2D blurStep2;\n#endif\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{float coc=TEXTUREFUNC(circleOfConfusionSampler,vUV,0.0).r;\n#if BLUR_LEVEL==0\nvec4 original=TEXTUREFUNC(textureSampler,vUV,0.0);vec4 blurred0=TEXTUREFUNC(blurStep0,vUV,0.0);gl_FragColor=mix(original,blurred0,coc);\n#endif\n#if BLUR_LEVEL==1\nif(coc<0.5){vec4 original=TEXTUREFUNC(textureSampler,vUV,0.0);vec4 blurred1=TEXTUREFUNC(blurStep1,vUV,0.0);gl_FragColor=mix(original,blurred1,coc/0.5);}else{vec4 blurred0=TEXTUREFUNC(blurStep0,vUV,0.0);vec4 blurred1=TEXTUREFUNC(blurStep1,vUV,0.0);gl_FragColor=mix(blurred1,blurred0,(coc-0.5)/0.5);}\n#endif\n#if BLUR_LEVEL==2\nif(coc<0.33){vec4 original=TEXTUREFUNC(textureSampler,vUV,0.0);vec4 blurred2=TEXTUREFUNC(blurStep2,vUV,0.0);gl_FragColor=mix(original,blurred2,coc/0.33);}else if(coc<0.66){vec4 blurred1=TEXTUREFUNC(blurStep1,vUV,0.0);vec4 blurred2=TEXTUREFUNC(blurStep2,vUV,0.0);gl_FragColor=mix(blurred2,blurred1,(coc-0.33)/0.33);}else{vec4 blurred0=TEXTUREFUNC(blurStep0,vUV,0.0);vec4 blurred1=TEXTUREFUNC(blurStep1,vUV,0.0);gl_FragColor=mix(blurred1,blurred0,(coc-0.66)/0.34);}\n#endif\n}\n";i(9610).l.ShadersStore[o]=t;const r={name:o,shader:t}},5491:(e,n,i)=>{i.r(n),i.d(n,{extractHighlightsPixelShader:()=>a});var o=i(9610);i(3325);const t="extractHighlightsPixelShader",r="#include\nvarying vec2 vUV;uniform sampler2D textureSampler;uniform float threshold;uniform float exposure;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) \n{gl_FragColor=texture2D(textureSampler,vUV);float luma=dot(LuminanceEncodeApprox,gl_FragColor.rgb*exposure);gl_FragColor.rgb=step(threshold,luma)*gl_FragColor.rgb;}";o.l.ShadersStore[t]=r;const a={name:t,shader:r}},5499:(e,n,i)=>{i.r(n),i.d(n,{fxaaPixelShader:()=>r});const o="fxaaPixelShader",t="#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)\n#define TEXTUREFUNC(s,c,l) texture2DLodEXT(s,c,l)\n#else\n#define TEXTUREFUNC(s,c,b) texture2D(s,c,b)\n#endif\nuniform sampler2D textureSampler;uniform vec2 texelSize;varying vec2 vUV;varying vec2 sampleCoordS;varying vec2 sampleCoordE;varying vec2 sampleCoordN;varying vec2 sampleCoordW;varying vec2 sampleCoordNW;varying vec2 sampleCoordSE;varying vec2 sampleCoordNE;varying vec2 sampleCoordSW;const float fxaaQualitySubpix=1.0;const float fxaaQualityEdgeThreshold=0.166;const float fxaaQualityEdgeThresholdMin=0.0833;const vec3 kLumaCoefficients=vec3(0.2126,0.7152,0.0722);\n#define FxaaLuma(rgba) dot(rgba.rgb,kLumaCoefficients)\nvoid main(){vec2 posM;posM.x=vUV.x;posM.y=vUV.y;vec4 rgbyM=TEXTUREFUNC(textureSampler,vUV,0.0);float lumaM=FxaaLuma(rgbyM);float lumaS=FxaaLuma(TEXTUREFUNC(textureSampler,sampleCoordS,0.0));float lumaE=FxaaLuma(TEXTUREFUNC(textureSampler,sampleCoordE,0.0));float lumaN=FxaaLuma(TEXTUREFUNC(textureSampler,sampleCoordN,0.0));float lumaW=FxaaLuma(TEXTUREFUNC(textureSampler,sampleCoordW,0.0));float maxSM=max(lumaS,lumaM);float minSM=min(lumaS,lumaM);float maxESM=max(lumaE,maxSM);float minESM=min(lumaE,minSM);float maxWN=max(lumaN,lumaW);float minWN=min(lumaN,lumaW);float rangeMax=max(maxWN,maxESM);float rangeMin=min(minWN,minESM);float rangeMaxScaled=rangeMax*fxaaQualityEdgeThreshold;float range=rangeMax-rangeMin;float rangeMaxClamped=max(fxaaQualityEdgeThresholdMin,rangeMaxScaled);\n#ifndef MALI\nif(range=edgeVert;float subpixA=subpixNSWE*2.0+subpixNWSWNESE;if (!horzSpan)\n{lumaN=lumaW;}\nif (!horzSpan) \n{lumaS=lumaE;}\nif (horzSpan) \n{lengthSign=texelSize.y;}\nfloat subpixB=(subpixA*(1.0/12.0))-lumaM;float gradientN=lumaN-lumaM;float gradientS=lumaS-lumaM;float lumaNN=lumaN+lumaM;float lumaSS=lumaS+lumaM;bool pairN=abs(gradientN)>=abs(gradientS);float gradient=max(abs(gradientN),abs(gradientS));if (pairN)\n{lengthSign=-lengthSign;}\nfloat subpixC=clamp(abs(subpixB)*subpixRcpRange,0.0,1.0);vec2 posB;posB.x=posM.x;posB.y=posM.y;vec2 offNP;offNP.x=(!horzSpan) ? 0.0 : texelSize.x;offNP.y=(horzSpan) ? 0.0 : texelSize.y;if (!horzSpan) \n{posB.x+=lengthSign*0.5;}\nif (horzSpan)\n{posB.y+=lengthSign*0.5;}\nvec2 posN;posN.x=posB.x-offNP.x*1.5;posN.y=posB.y-offNP.y*1.5;vec2 posP;posP.x=posB.x+offNP.x*1.5;posP.y=posB.y+offNP.y*1.5;float subpixD=((-2.0)*subpixC)+3.0;float lumaEndN=FxaaLuma(TEXTUREFUNC(textureSampler,posN,0.0));float subpixE=subpixC*subpixC;float lumaEndP=FxaaLuma(TEXTUREFUNC(textureSampler,posP,0.0));if (!pairN) \n{lumaNN=lumaSS;}\nfloat gradientScaled=gradient*1.0/4.0;float lumaMM=lumaM-lumaNN*0.5;float subpixF=subpixD*subpixE;bool lumaMLTZero=lumaMM<0.0;lumaEndN-=lumaNN*0.5;lumaEndP-=lumaNN*0.5;bool doneN=abs(lumaEndN)>=gradientScaled;bool doneP=abs(lumaEndP)>=gradientScaled;if (!doneN) \n{posN.x-=offNP.x*3.0;}\nif (!doneN) \n{posN.y-=offNP.y*3.0;}\nbool doneNP=(!doneN) || (!doneP);if (!doneP) \n{posP.x+=offNP.x*3.0;}\nif (!doneP)\n{posP.y+=offNP.y*3.0;}\nif (doneNP)\n{if (!doneN) lumaEndN=FxaaLuma(TEXTUREFUNC(textureSampler,posN.xy,0.0));if (!doneP) lumaEndP=FxaaLuma(TEXTUREFUNC(textureSampler,posP.xy,0.0));if (!doneN) lumaEndN=lumaEndN-lumaNN*0.5;if (!doneP) lumaEndP=lumaEndP-lumaNN*0.5;doneN=abs(lumaEndN)>=gradientScaled;doneP=abs(lumaEndP)>=gradientScaled;if (!doneN) posN.x-=offNP.x*12.0;if (!doneN) posN.y-=offNP.y*12.0;doneNP=(!doneN) || (!doneP);if (!doneP) posP.x+=offNP.x*12.0;if (!doneP) posP.y+=offNP.y*12.0;}\nfloat dstN=posM.x-posN.x;float dstP=posP.x-posM.x;if (!horzSpan)\n{dstN=posM.y-posN.y;}\nif (!horzSpan) \n{dstP=posP.y-posM.y;}\nbool goodSpanN=(lumaEndN<0.0) != lumaMLTZero;float spanLength=(dstP+dstN);bool goodSpanP=(lumaEndP<0.0) != lumaMLTZero;float spanLengthRcp=1.0/spanLength;bool directionN=dstN{i.r(n),i.d(n,{fxaaVertexShader:()=>r});const o="fxaaVertexShader",t="attribute vec2 position;uniform vec2 texelSize;varying vec2 vUV;varying vec2 sampleCoordS;varying vec2 sampleCoordE;varying vec2 sampleCoordN;varying vec2 sampleCoordW;varying vec2 sampleCoordNW;varying vec2 sampleCoordSE;varying vec2 sampleCoordNE;varying vec2 sampleCoordSW;const vec2 madd=vec2(0.5,0.5);\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nvUV=(position*madd+madd);sampleCoordS=vUV+vec2( 0.0,1.0)*texelSize;sampleCoordE=vUV+vec2( 1.0,0.0)*texelSize;sampleCoordN=vUV+vec2( 0.0,-1.0)*texelSize;sampleCoordW=vUV+vec2(-1.0,0.0)*texelSize;sampleCoordNW=vUV+vec2(-1.0,-1.0)*texelSize;sampleCoordSE=vUV+vec2( 1.0,1.0)*texelSize;sampleCoordNE=vUV+vec2( 1.0,-1.0)*texelSize;sampleCoordSW=vUV+vec2(-1.0,1.0)*texelSize;gl_Position=vec4(position,0.0,1.0);\n#define CUSTOM_VERTEX_MAIN_END\n}";i(9610).l.ShadersStore[o]=t;const r={name:o,shader:t}},7094:(e,n,i)=>{i.r(n),i.d(n,{glowBlurPostProcessPixelShader:()=>r});const o="glowBlurPostProcessPixelShader",t="varying vec2 vUV;uniform sampler2D textureSampler;uniform vec2 screenSize;uniform vec2 direction;uniform float blurWidth;float getLuminance(vec3 color)\n{return dot(color,vec3(0.2126,0.7152,0.0722));}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{float weights[7];weights[0]=0.05;weights[1]=0.1;weights[2]=0.2;weights[3]=0.3;weights[4]=0.2;weights[5]=0.1;weights[6]=0.05;vec2 texelSize=vec2(1.0/screenSize.x,1.0/screenSize.y);vec2 texelStep=texelSize*direction*blurWidth;vec2 start=vUV-3.0*texelStep;vec4 baseColor=vec4(0.,0.,0.,0.);vec2 texelOffset=vec2(0.,0.);for (int i=0; i<7; i++)\n{vec4 texel=texture2D(textureSampler,start+texelOffset);baseColor.a+=texel.a*weights[i];float luminance=getLuminance(baseColor.rgb);float luminanceTexel=getLuminance(texel.rgb);float choice=step(luminanceTexel,luminance);baseColor.rgb=choice*baseColor.rgb+(1.0-choice)*texel.rgb;texelOffset+=texelStep;}\ngl_FragColor=baseColor;}";i(9610).l.ShadersStore[o]=t;const r={name:o,shader:t}},3234:(e,n,i)=>{i.r(n),i.d(n,{glowMapGenerationPixelShader:()=>a});var o=i(9610);i(3325),i(6194),i(7412);const t="glowMapGenerationPixelShader",r="#if defined(DIFFUSE_ISLINEAR) || defined(EMISSIVE_ISLINEAR)\n#include\n#endif\n#ifdef DIFFUSE\nvarying vec2 vUVDiffuse;uniform sampler2D diffuseSampler;\n#endif\n#ifdef OPACITY\nvarying vec2 vUVOpacity;uniform sampler2D opacitySampler;uniform float opacityIntensity;\n#endif\n#ifdef EMISSIVE\nvarying vec2 vUVEmissive;uniform sampler2D emissiveSampler;\n#endif\n#ifdef VERTEXALPHA\nvarying vec4 vColor;\n#endif\nuniform vec4 glowColor;uniform float glowIntensity;\n#include\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\n#include\nvec4 finalColor=glowColor;\n#ifdef DIFFUSE\nvec4 albedoTexture=texture2D(diffuseSampler,vUVDiffuse);\n#ifdef DIFFUSE_ISLINEAR\nalbedoTexture=toGammaSpace(albedoTexture);\n#endif\n#ifdef GLOW\nfinalColor.a*=albedoTexture.a;\n#endif\n#ifdef HIGHLIGHT\nfinalColor.a=albedoTexture.a;\n#endif\n#endif\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vUVOpacity);\n#ifdef OPACITYRGB\nfinalColor.a*=getLuminance(opacityMap.rgb);\n#else\nfinalColor.a*=opacityMap.a;\n#endif\nfinalColor.a*=opacityIntensity;\n#endif\n#ifdef VERTEXALPHA\nfinalColor.a*=vColor.a;\n#endif\n#ifdef ALPHATEST\nif (finalColor.a{i.r(n),i.d(n,{glowMapGenerationVertexShader:()=>a});var o=i(9610);i(9707),i(8959),i(7999),i(738),i(1636),i(1218),i(8451),i(5060),i(3298),i(3361),i(5523),i(7314);const t="glowMapGenerationVertexShader",r="attribute vec3 position;\n#include\n#include\n#include\n#include[0..maxSimultaneousMorphTargets]\n#include\n#include\nuniform mat4 viewProjection;varying vec4 vPosition;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef DIFFUSE\nvarying vec2 vUVDiffuse;uniform mat4 diffuseMatrix;\n#endif\n#ifdef OPACITY\nvarying vec2 vUVOpacity;uniform mat4 opacityMatrix;\n#endif\n#ifdef EMISSIVE\nvarying vec2 vUVEmissive;uniform mat4 emissiveMatrix;\n#endif\n#ifdef VERTEXALPHA\nattribute vec4 color;varying vec4 vColor;\n#endif\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void)\n{vec3 positionUpdated=position;\n#ifdef UV1\nvec2 uvUpdated=uv;\n#endif\n#include\n#include[0..maxSimultaneousMorphTargets]\n#include\n#include\n#include\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\n#ifdef CUBEMAP\nvPosition=worldPos;gl_Position=viewProjection*finalWorld*vec4(position,1.0);\n#else\nvPosition=viewProjection*worldPos;gl_Position=vPosition;\n#endif\n#ifdef DIFFUSE\n#ifdef DIFFUSEUV1\nvUVDiffuse=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#ifdef DIFFUSEUV2\nvUVDiffuse=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n#ifdef OPACITY\n#ifdef OPACITYUV1\nvUVOpacity=vec2(opacityMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#ifdef OPACITYUV2\nvUVOpacity=vec2(opacityMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n#ifdef EMISSIVE\n#ifdef EMISSIVEUV1\nvUVEmissive=vec2(emissiveMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#ifdef EMISSIVEUV2\nvUVEmissive=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n#ifdef VERTEXALPHA\nvColor=color;\n#endif\n#include\n}";o.l.ShadersStore[t]=r;const a={name:t,shader:r}},9858:(e,n,i)=>{i.r(n),i.d(n,{glowMapMergePixelShader:()=>r});const o="glowMapMergePixelShader",t="varying vec2 vUV;uniform sampler2D textureSampler;\n#ifdef EMISSIVE\nuniform sampler2D textureSampler2;\n#endif\nuniform float offset;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\nvec4 baseColor=texture2D(textureSampler,vUV);\n#ifdef EMISSIVE\nbaseColor+=texture2D(textureSampler2,vUV);baseColor*=offset;\n#else\nbaseColor.a=abs(offset-baseColor.a);\n#ifdef STROKE\nfloat alpha=smoothstep(.0,.1,baseColor.a);baseColor.a=alpha;baseColor.rgb=baseColor.rgb*alpha;\n#endif\n#endif\n#if LDR\nbaseColor=clamp(baseColor,0.,1.0);\n#endif\ngl_FragColor=baseColor;\n#define CUSTOM_FRAGMENT_MAIN_END\n}";i(9610).l.ShadersStore[o]=t;const r={name:o,shader:t}},1288:(e,n,i)=>{i.r(n),i.d(n,{glowMapMergeVertexShader:()=>r});const o="glowMapMergeVertexShader",t="attribute vec2 position;varying vec2 vUV;const vec2 madd=vec2(0.5,0.5);\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nvUV=position*madd+madd;gl_Position=vec4(position,0.0,1.0);\n#define CUSTOM_VERTEX_MAIN_END\n}";i(9610).l.ShadersStore[o]=t;const r={name:o,shader:t}},890:(e,n,i)=>{i.r(n),i.d(n,{grainPixelShader:()=>a});var o=i(9610);i(3325);const t="grainPixelShader",r="#include\nuniform sampler2D textureSampler; \nuniform float intensity;uniform float animatedSeed;varying vec2 vUV;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{gl_FragColor=texture2D(textureSampler,vUV);vec2 seed=vUV*(animatedSeed);float grain=dither(seed,intensity);float lum=getLuminance(gl_FragColor.rgb);float grainAmount=(cos(-PI+(lum*PI*2.))+1.)/2.;gl_FragColor.rgb+=grain*grainAmount;gl_FragColor.rgb=max(gl_FragColor.rgb,0.0);}";o.l.ShadersStore[t]=r;const a={name:t,shader:r}},3153:(e,n,i)=>{i.r(n),i.d(n,{imageProcessingPixelShader:()=>a});var o=i(9610);i(9392),i(3325),i(4017);const t="imageProcessingPixelShader",r="varying vec2 vUV;uniform sampler2D textureSampler;\n#include\n#include\n#include\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{vec4 result=texture2D(textureSampler,vUV);\n#ifdef IMAGEPROCESSING\n#ifndef FROMLINEARSPACE\nresult.rgb=toLinearSpace(result.rgb);\n#endif\nresult=applyImageProcessing(result);\n#else\n#ifdef FROMLINEARSPACE\nresult=applyImageProcessing(result);\n#endif\n#endif\ngl_FragColor=result;}";o.l.ShadersStore[t]=r;const a={name:t,shader:r}},4509:(e,n,i)=>{i.r(n),i.d(n,{kernelBlurPixelShader:()=>a});var o=i(9610);i(7382),i(8334);o.l.IncludesShadersStore.kernelBlurFragment="#ifdef DOF\nfactor=sampleCoC(sampleCoord{X}); \ncomputedWeight=KERNEL_WEIGHT{X}*factor;sumOfWeights+=computedWeight;\n#else\ncomputedWeight=KERNEL_WEIGHT{X};\n#endif\n#ifdef PACKEDFLOAT\nblend+=unpack(texture2D(textureSampler,sampleCoord{X}))*computedWeight;\n#else\nblend+=texture2D(textureSampler,sampleCoord{X})*computedWeight;\n#endif\n";o.l.IncludesShadersStore.kernelBlurFragment2="#ifdef DOF\nfactor=sampleCoC(sampleCenter+delta*KERNEL_DEP_OFFSET{X});computedWeight=KERNEL_DEP_WEIGHT{X}*factor;sumOfWeights+=computedWeight;\n#else\ncomputedWeight=KERNEL_DEP_WEIGHT{X};\n#endif\n#ifdef PACKEDFLOAT\nblend+=unpack(texture2D(textureSampler,sampleCenter+delta*KERNEL_DEP_OFFSET{X}))*computedWeight;\n#else\nblend+=texture2D(textureSampler,sampleCenter+delta*KERNEL_DEP_OFFSET{X})*computedWeight;\n#endif\n";const t="kernelBlurPixelShader",r="uniform sampler2D textureSampler;uniform vec2 delta;varying vec2 sampleCenter;\n#ifdef DOF\nuniform sampler2D circleOfConfusionSampler;float sampleCoC(in vec2 offset) {float coc=texture2D(circleOfConfusionSampler,offset).r;return coc; }\n#endif\n#include[0..varyingCount]\n#ifdef PACKEDFLOAT\n#include\n#endif\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{float computedWeight=0.0;\n#ifdef PACKEDFLOAT\nfloat blend=0.;\n#else\nvec4 blend=vec4(0.);\n#endif\n#ifdef DOF\nfloat sumOfWeights=CENTER_WEIGHT; \nfloat factor=0.0;\n#ifdef PACKEDFLOAT\nblend+=unpack(texture2D(textureSampler,sampleCenter))*CENTER_WEIGHT;\n#else\nblend+=texture2D(textureSampler,sampleCenter)*CENTER_WEIGHT;\n#endif\n#endif\n#include[0..varyingCount]\n#include[0..depCount]\n#ifdef PACKEDFLOAT\ngl_FragColor=pack(blend);\n#else\ngl_FragColor=blend;\n#endif\n#ifdef DOF\ngl_FragColor/=sumOfWeights;\n#endif\n}";o.l.ShadersStore[t]=r;const a={name:t,shader:r}},3802:(e,n,i)=>{i.r(n),i.d(n,{kernelBlurVertexShader:()=>a});var o=i(9610);i(7382);o.l.IncludesShadersStore.kernelBlurVertex="sampleCoord{X}=sampleCenter+delta*KERNEL_OFFSET{X};";const t="kernelBlurVertexShader",r="attribute vec2 position;uniform vec2 delta;varying vec2 sampleCenter;\n#include[0..varyingCount]\nconst vec2 madd=vec2(0.5,0.5);\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nsampleCenter=(position*madd+madd);\n#include[0..varyingCount]\ngl_Position=vec4(position,0.0,1.0);\n#define CUSTOM_VERTEX_MAIN_END\n}";o.l.ShadersStore[t]=r;const a={name:t,shader:r}},9278:(e,n,i)=>{i.r(n),i.d(n,{lodPixelShader:()=>r});const o="lodPixelShader",t="#extension GL_EXT_shader_texture_lod : enable\nprecision highp float;const float GammaEncodePowerApprox=1.0/2.2;varying vec2 vUV;uniform sampler2D textureSampler;uniform float lod;uniform vec2 texSize;uniform int gamma;void main(void)\n{gl_FragColor=texture2DLodEXT(textureSampler,vUV,lod);if (gamma==0) {gl_FragColor.rgb=pow(gl_FragColor.rgb,vec3(GammaEncodePowerApprox));}}\n";i(9610).l.ShadersStore[o]=t;const r={name:o,shader:t}},2905:(e,n,i)=>{i.r(n),i.d(n,{lodCubePixelShader:()=>r});const o="lodCubePixelShader",t="precision highp float;const float GammaEncodePowerApprox=1.0/2.2;varying vec2 vUV;uniform samplerCube textureSampler;uniform float lod;uniform int gamma;void main(void)\n{vec2 uv=vUV*2.0-1.0;\n#ifdef POSITIVEX\ngl_FragColor=textureCube(textureSampler,vec3(1.001,uv.y,uv.x),lod);\n#endif\n#ifdef NEGATIVEX\ngl_FragColor=textureCube(textureSampler,vec3(-1.001,uv.y,uv.x),lod);\n#endif\n#ifdef POSITIVEY\ngl_FragColor=textureCube(textureSampler,vec3(uv.y,1.001,uv.x),lod);\n#endif\n#ifdef NEGATIVEY\ngl_FragColor=textureCube(textureSampler,vec3(uv.y,-1.001,uv.x),lod);\n#endif\n#ifdef POSITIVEZ\ngl_FragColor=textureCube(textureSampler,vec3(uv,1.001),lod);\n#endif\n#ifdef NEGATIVEZ\ngl_FragColor=textureCube(textureSampler,vec3(uv,-1.001),lod);\n#endif\nif (gamma==0) {gl_FragColor.rgb=pow(gl_FragColor.rgb,vec3(GammaEncodePowerApprox));}}\n";i(9610).l.ShadersStore[o]=t;const r={name:o,shader:t}},9820:(e,n,i)=>{i.r(n),i.d(n,{passPixelShader:()=>r});const o="passPixelShader",t="varying vec2 vUV;uniform sampler2D textureSampler;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) \n{gl_FragColor=texture2D(textureSampler,vUV);}";i(9610).l.ShadersStore[o]=t;const r={name:o,shader:t}},4511:(e,n,i)=>{i.r(n),i.d(n,{passCubePixelShader:()=>r});const o="passCubePixelShader",t="varying vec2 vUV;uniform samplerCube textureSampler;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) \n{vec2 uv=vUV*2.0-1.0;\n#ifdef POSITIVEX\ngl_FragColor=textureCube(textureSampler,vec3(1.001,uv.y,uv.x));\n#endif\n#ifdef NEGATIVEX\ngl_FragColor=textureCube(textureSampler,vec3(-1.001,uv.y,uv.x));\n#endif\n#ifdef POSITIVEY\ngl_FragColor=textureCube(textureSampler,vec3(uv.y,1.001,uv.x));\n#endif\n#ifdef NEGATIVEY\ngl_FragColor=textureCube(textureSampler,vec3(uv.y,-1.001,uv.x));\n#endif\n#ifdef POSITIVEZ\ngl_FragColor=textureCube(textureSampler,vec3(uv,1.001));\n#endif\n#ifdef NEGATIVEZ\ngl_FragColor=textureCube(textureSampler,vec3(uv,-1.001));\n#endif\n}";i(9610).l.ShadersStore[o]=t;const r={name:o,shader:t}},9682:(e,n,i)=>{i.r(n),i.d(n,{rgbdDecodePixelShader:()=>a});var o=i(9610);i(3325);const t="rgbdDecodePixelShader",r="varying vec2 vUV;uniform sampler2D textureSampler;\n#include\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) \n{gl_FragColor=vec4(fromRGBD(texture2D(textureSampler,vUV)),1.0);}";o.l.ShadersStore[t]=r;const a={name:t,shader:r}},2646:(e,n,i)=>{i.r(n),i.d(n,{rgbdEncodePixelShader:()=>a});var o=i(9610);i(3325);const t="rgbdEncodePixelShader",r="varying vec2 vUV;uniform sampler2D textureSampler;\n#include\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) \n{gl_FragColor=toRGBD(texture2D(textureSampler,vUV).rgb);}";o.l.ShadersStore[t]=r;const a={name:t,shader:r}},357:(e,n,i)=>{i.r(n),i.d(n,{shadowMapPixelShader:()=>a});var o=i(9610);i(8334);o.l.IncludesShadersStore.bayerDitherFunctions="float bayerDither2(vec2 _P) {return mod(2.0*_P.y+_P.x+1.0,4.0);}\nfloat bayerDither4(vec2 _P) {vec2 P1=mod(_P,2.0); \nvec2 P2=floor(0.5*mod(_P,4.0)); \nreturn 4.0*bayerDither2(P1)+bayerDither2(P2);}\nfloat bayerDither8(vec2 _P) {vec2 P1=mod(_P,2.0); \nvec2 P2=floor(0.5 *mod(_P,4.0)); \nvec2 P4=floor(0.25*mod(_P,8.0)); \nreturn 4.0*(4.0*bayerDither2(P1)+bayerDither2(P2))+bayerDither2(P4);}\n";o.l.IncludesShadersStore.shadowMapFragmentExtraDeclaration="#if SM_FLOAT==0\n#include\n#endif\n#if SM_SOFTTRANSPARENTSHADOW==1\n#include\nuniform vec2 softTransparentShadowSM;\n#endif\nvarying float vDepthMetricSM;\n#if SM_USEDISTANCE==1\nuniform vec3 lightDataSM;varying vec3 vPositionWSM;\n#endif\nuniform vec3 biasAndScaleSM;uniform vec2 depthValuesSM;\n#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP==1\nvarying float zSM;\n#endif\n",i(6194),i(7412);o.l.IncludesShadersStore.shadowMapFragment="float depthSM=vDepthMetricSM;\n#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP==1\n#if SM_USEDISTANCE==1\ndepthSM=(length(vPositionWSM-lightDataSM)+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;\n#else\n#ifdef USE_REVERSE_DEPTHBUFFER\ndepthSM=(-zSM+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;\n#else\ndepthSM=(zSM+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;\n#endif\n#endif\n#ifdef USE_REVERSE_DEPTHBUFFER\ngl_FragDepth=clamp(1.0-depthSM,0.0,1.0);\n#else\ngl_FragDepth=clamp(depthSM,0.0,1.0); \n#endif\n#elif SM_USEDISTANCE==1\ndepthSM=(length(vPositionWSM-lightDataSM)+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;\n#endif\n#if SM_ESM==1\ndepthSM=clamp(exp(-min(87.,biasAndScaleSM.z*depthSM)),0.,1.);\n#endif\n#if SM_FLOAT==1\ngl_FragColor=vec4(depthSM,1.0,1.0,1.0);\n#else\ngl_FragColor=pack(depthSM);\n#endif\nreturn;";const t="shadowMapPixelShader",r="#include\n#ifdef ALPHATEXTURE\nvarying vec2 vUV;uniform sampler2D diffuseSampler;\n#endif\n#include\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\n#include\n#ifdef ALPHATEXTURE\nvec4 opacityMap=texture2D(diffuseSampler,vUV);float alphaFromAlphaTexture=opacityMap.a;\n#if SM_SOFTTRANSPARENTSHADOW==1\nif (softTransparentShadowSM.y==1.0) {opacityMap.rgb=opacityMap.rgb*vec3(0.3,0.59,0.11);alphaFromAlphaTexture=opacityMap.x+opacityMap.y+opacityMap.z;}\n#endif\n#ifdef ALPHATESTVALUE\nif (alphaFromAlphaTexture=softTransparentShadowSM.x*alphaFromAlphaTexture) discard;\n#else\nif ((bayerDither8(floor(mod(gl_FragCoord.xy,8.0))))/64.0>=softTransparentShadowSM.x) discard;\n#endif\n#endif\n#include\n}";o.l.ShadersStore[t]=r;const a={name:t,shader:r}},3906:(e,n,i)=>{i.r(n),i.d(n,{shadowMapVertexShader:()=>a});var o=i(9610);i(9707),i(8959),i(7999),i(738),i(3325);o.l.IncludesShadersStore.sceneVertexDeclaration="uniform mat4 viewProjection;\n#ifdef MULTIVIEW\nuniform mat4 viewProjectionR;\n#endif\nuniform mat4 view;uniform mat4 projection;uniform vec4 vEyePosition;\n";o.l.IncludesShadersStore.meshVertexDeclaration="uniform mat4 world;uniform float visibility;\n";o.l.IncludesShadersStore.shadowMapVertexDeclaration="#include\n#include\n",i(8764),i(6467);o.l.IncludesShadersStore.shadowMapUboDeclaration="layout(std140,column_major) uniform;\n#include\n#include\n";o.l.IncludesShadersStore.shadowMapVertexExtraDeclaration="#if SM_NORMALBIAS==1\nuniform vec3 lightDataSM;\n#endif\nuniform vec3 biasAndScaleSM;uniform vec2 depthValuesSM;varying float vDepthMetricSM;\n#if SM_USEDISTANCE==1\nvarying vec3 vPositionWSM;\n#endif\n#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP==1\nvarying float zSM;\n#endif\n",i(1636),i(8451),i(5060),i(3298),i(3361),i(5523);o.l.IncludesShadersStore.shadowMapVertexNormalBias="#if SM_NORMALBIAS==1\n#if SM_DIRECTIONINLIGHTDATA==1\nvec3 worldLightDirSM=normalize(-lightDataSM.xyz);\n#else\nvec3 directionToLightSM=lightDataSM.xyz-worldPos.xyz;vec3 worldLightDirSM=normalize(directionToLightSM);\n#endif\nfloat ndlSM=dot(vNormalW,worldLightDirSM);float sinNLSM=sqrt(1.0-ndlSM*ndlSM);float normalBiasSM=biasAndScaleSM.y*sinNLSM;worldPos.xyz-=vNormalW*normalBiasSM;\n#endif\n";o.l.IncludesShadersStore.shadowMapVertexMetric="#if SM_USEDISTANCE==1\nvPositionWSM=worldPos.xyz;\n#endif\n#if SM_DEPTHTEXTURE==1\n#ifdef IS_NDC_HALF_ZRANGE\n#define BIASFACTOR 0.5\n#else\n#define BIASFACTOR 1.0\n#endif\n#ifdef USE_REVERSE_DEPTHBUFFER\ngl_Position.z-=biasAndScaleSM.x*gl_Position.w*BIASFACTOR;\n#else\ngl_Position.z+=biasAndScaleSM.x*gl_Position.w*BIASFACTOR;\n#endif\n#endif\n#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP==1\nzSM=gl_Position.z;gl_Position.z=0.0;\n#elif SM_USEDISTANCE==0\n#ifdef USE_REVERSE_DEPTHBUFFER\nvDepthMetricSM=(-gl_Position.z+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;\n#else\nvDepthMetricSM=(gl_Position.z+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;\n#endif\n#endif\n",i(7314);const t="shadowMapVertexShader",r="attribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#include\n#include\n#include\n#include[0..maxSimultaneousMorphTargets]\n#ifdef INSTANCES\nattribute vec4 world0;attribute vec4 world1;attribute vec4 world2;attribute vec4 world3;\n#endif\n#include\n#include<__decl__shadowMapVertex>\n#ifdef ALPHATEXTURE\nvarying vec2 vUV;uniform mat4 diffuseMatrix;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#endif\n#include\n#include\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void)\n{vec3 positionUpdated=position;\n#ifdef UV1\nvec2 uvUpdated=uv;\n#endif\n#ifdef NORMAL\nvec3 normalUpdated=normal;\n#endif\n#include\n#include[0..maxSimultaneousMorphTargets]\n#include\n#include\n#include\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\n#ifdef NORMAL\nmat3 normWorldSM=mat3(finalWorld);\n#if defined(INSTANCES) && defined(THIN_INSTANCES)\nvec3 vNormalW=normalUpdated/vec3(dot(normWorldSM[0],normWorldSM[0]),dot(normWorldSM[1],normWorldSM[1]),dot(normWorldSM[2],normWorldSM[2]));vNormalW=normalize(normWorldSM*vNormalW);\n#else\n#ifdef NONUNIFORMSCALING\nnormWorldSM=transposeMat3(inverseMat3(normWorldSM));\n#endif\nvec3 vNormalW=normalize(normWorldSM*normalUpdated);\n#endif\n#endif\n#include\ngl_Position=viewProjection*worldPos;\n#include\n#ifdef ALPHATEXTURE\n#ifdef UV1\nvUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#ifdef UV2\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n#include\n}";o.l.ShadersStore[t]=r;const a={name:t,shader:r}}}]); \ No newline at end of file diff --git a/docs/static/pmx_converter/index.html b/docs/static/pmx_converter/index.html index 0029ebb..97181bf 100644 --- a/docs/static/pmx_converter/index.html +++ b/docs/static/pmx_converter/index.html @@ -1 +1 @@ -babylon-mmd \ No newline at end of file +babylon-mmd \ No newline at end of file diff --git a/docs/static/pmx_converter/main.bundle.js b/docs/static/pmx_converter/main.bundle.js index 696841f..eb0a7e7 100644 --- a/docs/static/pmx_converter/main.bundle.js +++ b/docs/static/pmx_converter/main.bundle.js @@ -1 +1,4 @@ -(()=>{"use strict";var e,t,n,r={7198:(e,t,n)=>{n.d(t,{B:()=>r});const r="\n#ifndef SDEFDECLARATION\n#define SDEFDECLARATION\n#if NUM_BONE_INFLUENCERS>0 && defined(SDEF)\nattribute matricesSdefC: vec3f;attribute matricesSdefRW0: vec3f;attribute matricesSdefRW1: vec3f;fn rotationMatrixToQuaternion(matrix: mat3x3f)->vec4f {let trace: f32=matrix[0][0]+matrix[1][1]+matrix[2][2];var s: f32;var sqrtParam: f32;if (trace>0.0) {sqrtParam=trace+1.0;} else if (matrix[0][0]>matrix[1][1] && matrix[0][0]>matrix[2][2]) {sqrtParam=1.0+matrix[0][0]-matrix[1][1]-matrix[2][2];} else if (matrix[1][1]>matrix[2][2]) {sqrtParam=1.0+matrix[1][1]-matrix[0][0]-matrix[2][2];} else {sqrtParam=1.0+matrix[2][2]-matrix[0][0]-matrix[1][1];}\nlet sqrtValue: f32=sqrt(sqrtParam);if (trace>0.0) {s=0.5/sqrtValue;return vec4f(\n(matrix[1][2]-matrix[2][1])*s,\n(matrix[2][0]-matrix[0][2])*s,\n(matrix[0][1]-matrix[1][0])*s,\n0.25/s\n);} else if (matrix[0][0]>matrix[1][1] && matrix[0][0]>matrix[2][2]) {s=2.0*sqrtValue;return vec4f(\n0.25*s,\n(matrix[0][1]+matrix[1][0])/s,\n(matrix[2][0]+matrix[0][2])/s,\n(matrix[1][2]-matrix[2][1])/s\n);} else if (matrix[1][1]>matrix[2][2]) {s=2.0*sqrtValue;return vec4f(\n(matrix[0][1]+matrix[1][0])/s,\n0.25*s,\n(matrix[1][2]+matrix[2][1])/s,\n(matrix[2][0]-matrix[0][2])/s\n);} else {s=2.0*sqrtValue;return vec4f(\n(matrix[2][0]+matrix[0][2])/s,\n(matrix[1][2]+matrix[2][1])/s,\n0.25*s,\n(matrix[0][1]-matrix[1][0])/s\n);}}\nfn quaternionToRotationMatrix(q: vec4f)->mat3x3f {let xx: f32=q.x*q.x;let yy: f32=q.y*q.y;let zz: f32=q.z*q.z;let xy: f32=q.x*q.y;let zw: f32=q.z*q.w;let zx: f32=q.z*q.x;let yw: f32=q.y*q.w;let yz: f32=q.y*q.z;let xw: f32=q.x*q.w;return mat3x3f(\n1.0-2.0*(yy+zz),2.0*(xy+zw),2.0*(zx-yw),\n2.0*(xy-zw),1.0-2.0*(zz+xx),2.0*(yz+xw),\n2.0*(zx+yw),2.0*(yz-xw),1.0-2.0*(yy+xx)\n);}\nfn slerp(q0: vec4f,_q1: vec4f,t: f32)->vec4f {var q1: vec4f=_q1;var cosTheta: f32=dot(q0,q1);q1=mix(-q1,q1,step(0.0,cosTheta));cosTheta=abs(cosTheta);if (cosTheta>0.999999) {return normalize(mix(q0,q1,t));}\nvar theta: f32=acos(cosTheta);var sinTheta: f32=sin(theta);var w0: f32=sin((1.0-t)*theta)/sinTheta;var w1: f32=sin(t*theta)/sinTheta;return q0*w0+q1*w1;}\n#endif\n#endif\n"},4122:(e,t,n)=>{n.d(t,{Z:()=>r});const r="\n#ifndef SDEFVERTEX\n#define SDEFVERTEX\n#if !defined(BAKED_VERTEX_ANIMATION_TEXTURE) && defined(SDEF)\n#if NUM_BONE_INFLUENCERS>0\n{let weight0: f32=vertexInputs.matricesWeights[0];let weight1: f32=vertexInputs.matricesWeights[1];\n#ifdef BONETEXTURE\nlet transformMatrix0: mat4x4f=readMatrixFromRawSampler(boneSampler,vertexInputs.matricesIndices[0]);let transformMatrix1: mat4x4f=readMatrixFromRawSampler(boneSampler,vertexInputs.matricesIndices[1]);\n#else\nlet transformMatrix0: mat4x4f=uniforms.mBones[int(vertexInputs.matricesIndices[0])];let transformMatrix1: mat4x4f=uniforms.mBones[int(vertexInputs.matricesIndices[1])];\n#endif\nlet slerpedRotationMatrix: mat3x3f=quaternionToRotationMatrix(slerp(\nrotationMatrixToQuaternion(mat3x3f(transformMatrix0[0].xyz,transformMatrix0[1].xyz,transformMatrix0[2].xyz)),\nrotationMatrixToQuaternion(mat3x3f(transformMatrix1[0].xyz,transformMatrix1[1].xyz,transformMatrix1[2].xyz)),\nweight1\n));var sdefInflunce: mat4x4f=mat4x4f(\nvec4f(1.0,0.0,0.0,0.0),\nvec4f(0.0,1.0,0.0,0.0),\nvec4f(0.0,0.0,1.0,0.0),\nvec4f(-vertexInputs.matricesSdefC,1.0)\n);let rotationMatrix: mat4x4f=mat4x4f(\nvec4f(slerpedRotationMatrix[0],0.0),\nvec4f(slerpedRotationMatrix[1],0.0),\nvec4f(slerpedRotationMatrix[2],0.0),\nvec4f(0.0,0.0,0.0,1.0)\n);sdefInflunce=rotationMatrix*sdefInflunce;let positionOffset: vec3f =\n(transformMatrix0*vec4f(vertexInputs.matricesSdefRW0,1)).xyz*weight0 +\n(transformMatrix1*vec4f(vertexInputs.matricesSdefRW1,1)).xyz*weight1;sdefInflunce[3]+=vec4f(positionOffset,0.0);let useLinearDeform: f32=step(0.0,-abs(vertexInputs.matricesSdefRW0.x));influence=mat4x4f(\nmix(sdefInflunce[0],influence[0],useLinearDeform),\nmix(sdefInflunce[1],influence[1],useLinearDeform),\nmix(sdefInflunce[2],influence[2],useLinearDeform),\nmix(sdefInflunce[3],influence[3],useLinearDeform)\n);}\n#endif\n#endif\n#endif\n"},9339:(e,t,n)=>{n.d(t,{B:()=>r});const r="\n#ifndef SDEFDECLARATION\n#define SDEFDECLARATION\n#if NUM_BONE_INFLUENCERS>0 && defined(SDEF)\nattribute vec3 matricesSdefC;attribute vec3 matricesSdefRW0;attribute vec3 matricesSdefRW1;vec4 rotationMatrixToQuaternion(mat3 matrix) {float trace=matrix[0][0]+matrix[1][1]+matrix[2][2];float s;float sqrtParam;if (trace>0.0) {sqrtParam=trace+1.0;} else if (matrix[0][0]>matrix[1][1] && matrix[0][0]>matrix[2][2]) {sqrtParam=1.0+matrix[0][0]-matrix[1][1]-matrix[2][2];} else if (matrix[1][1]>matrix[2][2]) {sqrtParam=1.0+matrix[1][1]-matrix[0][0]-matrix[2][2];} else {sqrtParam=1.0+matrix[2][2]-matrix[0][0]-matrix[1][1];}\nfloat sqrtValue=sqrt(sqrtParam);if (trace>0.0) {s=0.5/sqrtValue;return vec4(\n(matrix[1][2]-matrix[2][1])*s,\n(matrix[2][0]-matrix[0][2])*s,\n(matrix[0][1]-matrix[1][0])*s,\n0.25/s\n);} else if (matrix[0][0]>matrix[1][1] && matrix[0][0]>matrix[2][2]) {s=2.0*sqrtValue;return vec4(\n0.25*s,\n(matrix[0][1]+matrix[1][0])/s,\n(matrix[2][0]+matrix[0][2])/s,\n(matrix[1][2]-matrix[2][1])/s\n);} else if (matrix[1][1]>matrix[2][2]) {s=2.0*sqrtValue;return vec4(\n(matrix[0][1]+matrix[1][0])/s,\n0.25*s,\n(matrix[1][2]+matrix[2][1])/s,\n(matrix[2][0]-matrix[0][2])/s\n);} else {s=2.0*sqrtValue;return vec4(\n(matrix[2][0]+matrix[0][2])/s,\n(matrix[1][2]+matrix[2][1])/s,\n0.25*s,\n(matrix[0][1]-matrix[1][0])/s\n);}}\nmat3 quaternionToRotationMatrix(vec4 q) {float xx=q.x*q.x;float yy=q.y*q.y;float zz=q.z*q.z;float xy=q.x*q.y;float zw=q.z*q.w;float zx=q.z*q.x;float yw=q.y*q.w;float yz=q.y*q.z;float xw=q.x*q.w;return mat3(\n1.0-2.0*(yy+zz),2.0*(xy+zw),2.0*(zx-yw),\n2.0*(xy-zw),1.0-2.0*(zz+xx),2.0*(yz+xw),\n2.0*(zx+yw),2.0*(yz-xw),1.0-2.0*(yy+xx)\n);}\nvec4 slerp(vec4 q0,vec4 q1,float t) {float cosTheta=dot(q0,q1);q1=mix(-q1,q1,step(0.0,cosTheta));cosTheta=abs(cosTheta);if (cosTheta>0.999999) {return normalize(mix(q0,q1,t));}\nfloat theta=acos(cosTheta);float sinTheta=sin(theta);float w0=sin((1.0-t)*theta)/sinTheta;float w1=sin(t*theta)/sinTheta;return q0*w0+q1*w1;}\n#endif\n#endif\n"},5041:(e,t,n)=>{n.d(t,{Z:()=>r});const r="\n#ifndef SDEFVERTEX\n#define SDEFVERTEX\n#if !defined(BAKED_VERTEX_ANIMATION_TEXTURE) && defined(SDEF)\n#if NUM_BONE_INFLUENCERS>0\n{float weight0=matricesWeights[0];float weight1=matricesWeights[1];\n#ifdef BONETEXTURE\nmat4 transformMatrix0=readMatrixFromRawSampler(boneSampler,matricesIndices[0]);mat4 transformMatrix1=readMatrixFromRawSampler(boneSampler,matricesIndices[1]);\n#else\nmat4 transformMatrix0=mBones[int(matricesIndices[0])];mat4 transformMatrix1=mBones[int(matricesIndices[1])];\n#endif\nmat3 slerpedRotationMatrix=quaternionToRotationMatrix(slerp(\nrotationMatrixToQuaternion(mat3(transformMatrix0)),\nrotationMatrixToQuaternion(mat3(transformMatrix1)),\nweight1\n));mat4 sdefInflunce=mat4(\nvec4(1.0,0.0,0.0,0.0),\nvec4(0.0,1.0,0.0,0.0),\nvec4(0.0,0.0,1.0,0.0),\nvec4(-matricesSdefC,1.0)\n);mat4 rotationMatrix=mat4(\nvec4(slerpedRotationMatrix[0],0.0),\nvec4(slerpedRotationMatrix[1],0.0),\nvec4(slerpedRotationMatrix[2],0.0),\nvec4(0.0,0.0,0.0,1.0)\n);sdefInflunce=rotationMatrix*sdefInflunce;vec3 positionOffset =\nvec3(transformMatrix0*vec4(matricesSdefRW0,1))*weight0 +\nvec3(transformMatrix1*vec4(matricesSdefRW1,1))*weight1;sdefInflunce[3]+=vec4(positionOffset,0.0);float useLinearDeform=step(0.0,-abs(matricesSdefRW0.x));influence=mat4(\nmix(sdefInflunce[0],influence[0],useLinearDeform),\nmix(sdefInflunce[1],influence[1],useLinearDeform),\nmix(sdefInflunce[2],influence[2],useLinearDeform),\nmix(sdefInflunce[3],influence[3],useLinearDeform)\n);}\n#endif\n#endif\n#endif\n"},3036:(e,t,n)=>{n.d(t,{V:()=>r});class r{static AdditionalUV1Kind="additionalUv1";static AdditionalUV2Kind="additionalUv2";static AdditionalUV3Kind="additionalUv3";static AdditionalUV4Kind="additionalUv4";static MatricesSdefCKind="matricesSdefC";static MatricesSdefRW0Kind="matricesSdefRW0";static MatricesSdefRW1Kind="matricesSdefRW1";static MatricesSdefR0Kind="matricesSdefR0";static MatricesSdefR1Kind="matricesSdefR1";static EdgeScaleKind="edgeScale"}},426:(e,t,n)=>{n.d(t,{ZL:()=>p,rw:()=>r});var r,i=n(6125),s=n(9526),o=n(2277),a=n(6041),l=n(9259),d=n(6552),h=n(3036),c=function(e,t,n,r){var i,s=arguments.length,o=s<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(o=(s<3?i(o):s>3?i(t,n,o):i(t,n))||o);return s>3&&o&&Object.defineProperty(t,n,o),o};class u extends s.M{SPHERE_TEXTURE=!1;SPHERE_TEXTURE_BLEND_MODE_MULTIPLY=!1;SPHERE_TEXTURE_BLEND_MODE_ADD=!1;TOON_TEXTURE=!1;IGNORE_DIFFUSE_WHEN_TOON_TEXTURE_DISABLED=!1;APPLY_AMBIENT_COLOR_TO_DIFFUSE=!1;CLAMP_ALPHA=!1;TEXTURE_COLOR=!1;SPHERE_TEXTURE_COLOR=!1;TOON_TEXTURE_COLOR=!1;SDEF=!1}!function(e){e[e.Multiply=1]="Multiply",e[e.Add=2]="Add",e[e.SubTexture=3]="SubTexture"}(r||(r={}));class p extends o.y{_sphereTexture=null;_sphereTextureBlendMode=r.Add;_toonTexture=null;_ignoreDiffuseWhenToonTextureIsNull=!1;textureMultiplicativeColor=new a.ov(1,1,1,1);textureAdditiveColor=new a.ov(0,0,0,0);sphereTextureMultiplicativeColor=new a.ov(1,1,1,1);sphereTextureAdditiveColor=new a.ov(0,0,0,0);toonTextureMultiplicativeColor=new a.ov(1,1,1,1);toonTextureAdditiveColor=new a.ov(0,0,0,0);_applyAmbientColorToDiffuse=!0;_clampAlpha=!0;_useTextureColor=!1;_useSphereTextureColor=!1;_useToonTextureColor=!1;_isEnabled=!1;get isEnabled(){return this._isEnabled}set isEnabled(e){this._isEnabled!==e&&(this._isEnabled=e,this.markAllDefinesAsDirty(),this._enable(e))}get sphereTexture(){return this._sphereTexture}set sphereTexture(e){this._sphereTexture!==e&&(this._sphereTexture=e,this._markAllSubMeshesAsTexturesDirty())}get sphereTextureBlendMode(){return this._sphereTextureBlendMode}set sphereTextureBlendMode(e){this._sphereTextureBlendMode!==e&&(this._sphereTextureBlendMode=e,this.markAllDefinesAsDirty())}get toonTexture(){return this._toonTexture}set toonTexture(e){this._toonTexture!==e&&(this._toonTexture=e,this._markAllSubMeshesAsTexturesDirty())}get ignoreDiffuseWhenToonTextureIsNull(){return this._ignoreDiffuseWhenToonTextureIsNull}set ignoreDiffuseWhenToonTextureIsNull(e){this._ignoreDiffuseWhenToonTextureIsNull!==e&&(this._ignoreDiffuseWhenToonTextureIsNull=e,this.markAllDefinesAsDirty())}get applyAmbientColorToDiffuse(){return this._applyAmbientColorToDiffuse}set applyAmbientColorToDiffuse(e){this._applyAmbientColorToDiffuse!==e&&(this._applyAmbientColorToDiffuse=e,this.markAllDefinesAsDirty())}get clampAlpha(){return this._clampAlpha}set clampAlpha(e){this._clampAlpha!==e&&(this._clampAlpha=e,this.markAllDefinesAsDirty())}get useTextureColor(){return this._useTextureColor}set useTextureColor(e){this._useTextureColor!==e&&(this._useTextureColor=e,this.markAllDefinesAsDirty())}get useSphereTextureColor(){return this._useSphereTextureColor}set useSphereTextureColor(e){this._useSphereTextureColor!==e&&(this._useSphereTextureColor=e,this.markAllDefinesAsDirty())}get useToonTextureColor(){return this._useToonTextureColor}set useToonTextureColor(e){this._useToonTextureColor!==e&&(this._useToonTextureColor=e,this.markAllDefinesAsDirty())}_internalMarkAllSubMeshesAsTexturesDirty;_markAllSubMeshesAsTexturesDirty(){this._enable(this._isEnabled),this._internalMarkAllSubMeshesAsTexturesDirty()}isCompatible(e){return!0}constructor(e,t=!0,n=!1,r=!1){super(e,"MmdMaterial",100,new u,t,n,r),this._internalMarkAllSubMeshesAsTexturesDirty=e._dirtyCallbacks[i.Y.MATERIAL_TextureDirtyFlag]}isReadyForSubMesh(e,t){return!this._isEnabled||!(e._areTexturesDirty&&t.texturesEnabled&&this._sphereTexture&&!this._sphereTexture.isReadyOrNotBlocking())}bindForSubMesh(e,t,n,r){if(!this._isEnabled)return;const i=r.materialDefines,s=this._material.isFrozen;e.useUbo&&s&&e.isSync||(i.DIFFUSE&&i.TEXTURE_COLOR&&(e.updateDirectColor4("textureMultiplicativeColor",this.textureMultiplicativeColor),e.updateDirectColor4("textureAdditiveColor",this.textureAdditiveColor)),i.NORMAL&&i.SPHERE_TEXTURE&&i.SPHERE_TEXTURE_COLOR&&(e.updateDirectColor4("sphereTextureMultiplicativeColor",this.sphereTextureMultiplicativeColor),e.updateDirectColor4("sphereTextureAdditiveColor",this.sphereTextureAdditiveColor)),i.TOON_TEXTURE&&i.TOON_TEXTURE_COLOR&&(e.updateDirectColor4("toonTextureMultiplicativeColor",this.toonTextureMultiplicativeColor),e.updateDirectColor4("toonTextureAdditiveColor",this.toonTextureAdditiveColor)),i.SPHERE_TEXTURE&&null!==r.effect&&this._material.bindView(r.effect)),t.texturesEnabled&&(i.NORMAL&&this._sphereTexture&&e.setTexture("sphereSampler",this._sphereTexture),this._toonTexture&&e.setTexture("toonSampler",this._toonTexture))}dispose(e){e&&(this._sphereTexture?.dispose(),this._toonTexture?.dispose())}prepareDefines(e,t,n){if(this._isEnabled){const i=t.texturesEnabled;e.SPHERE_TEXTURE=null!==this._sphereTexture&&i,e.SPHERE_TEXTURE_BLEND_MODE_MULTIPLY=this._sphereTextureBlendMode===r.Multiply,e.SPHERE_TEXTURE_BLEND_MODE_ADD=this._sphereTextureBlendMode===r.Add,e.TOON_TEXTURE=null!==this._toonTexture&&i,e.IGNORE_DIFFUSE_WHEN_TOON_TEXTURE_DISABLED=this._ignoreDiffuseWhenToonTextureIsNull,e.APPLY_AMBIENT_COLOR_TO_DIFFUSE=this._applyAmbientColorToDiffuse,e.CLAMP_ALPHA=this._clampAlpha,e.TEXTURE_COLOR=this._useTextureColor,e.SPHERE_TEXTURE_COLOR=this._useSphereTextureColor,e.TOON_TEXTURE_COLOR=this._useToonTextureColor,e.SDEF=n.useBones&&n.computeBonesUsingShaders&&!!n.skeleton&&n.isVerticesDataPresent(h.V.MatricesSdefCKind)}else e.SPHERE_TEXTURE=!1,e.SPHERE_TEXTURE_BLEND_MODE_MULTIPLY=!1,e.SPHERE_TEXTURE_BLEND_MODE_ADD=!1,e.TOON_TEXTURE=!1,e.IGNORE_DIFFUSE_WHEN_TOON_TEXTURE_DISABLED=!1,e.APPLY_AMBIENT_COLOR_TO_DIFFUSE=!1,e.CLAMP_ALPHA=!1,e.TEXTURE_COLOR=!1,e.SPHERE_TEXTURE_COLOR=!1,e.TOON_TEXTURE_COLOR=!1,e.SDEF=!1}hasTexture(e){return this._sphereTexture===e||this._toonTexture===e}getActiveTextures(e){this._sphereTexture&&e.push(this._sphereTexture),this._toonTexture&&e.push(this._toonTexture)}getAnimatables(e){this._sphereTexture&&this._sphereTexture.animations&&0{var r=n(3720);class i{_canvas;_engine;_scene;_onTick;constructor(e){this._canvas=e.canvas,this._engine=e.engine,this._scene=null,this._onTick=null}static async Create(e){const t=new i(e);return t._scene=await t._initialize(e.sceneBuilder),t._onTick=t._makeOnTick(),t}run(){const e=this._engine;window.addEventListener("resize",this._onResize),e.runRenderLoop(this._onTick)}dispose(){window.removeEventListener("resize",this._onResize),this._engine.dispose()}_onResize=()=>{this._engine.resize()};async _initialize(e){return await e.build(this._canvas,this._engine)}_makeOnTick(){const e=this._scene;return()=>e.render()}}n(9679),n(9400),n(994),n(1318);var s=n(5616),o=n(6125),a=n(492),l=n(5476),d=n(2565),h=n(467),c=n(5662),u=n(9923),p=n(554),g=n(6945),f=n(3036),m=n(9339),x=n(5041),y=n(7198),A=n(4122);class T{static OverrideEngineCreateEffect(e){const t=e.createEffect.bind(e);e.createEffect=function(e,n,r,i,s,o,a,l,d,h=c.w.GLSL,u){let p;if(p=n.attributes?n:{attributes:n,uniformsNames:r,uniformBuffersNames:[],samplers:i??[],defines:s??"",fallbacks:o??null,onCompiled:a??null,onError:l??null,indexParameters:d??null,shaderLanguage:h,extraInitializationsAsync:u},(p.uniformsNames.includes("mBones")||p.samplers.includes("boneSampler"))&&-1===p.defines.indexOf("#define SDEF")){p.attributes.push(f.V.MatricesSdefCKind),p.attributes.push(f.V.MatricesSdefRW0Kind),p.attributes.push(f.V.MatricesSdefRW1Kind),p.defines+="\n#define SDEF";const e=p.processCodeAfterIncludes;p.processCodeAfterIncludes=e?function(t,n){return n=e(t,n),T.ProcessSdefCode(t,n)}:T.ProcessSdefCode}return t(e,p,this)}}static ProcessSdefCode(e,t){if("vertex"!==e)return t;if(t.includes("finalWorld=finalWorld*influence;")){const e=t.includes("fn main"),n="#define CUSTOM_VERTEX_DEFINITIONS";if(t.includes(n))t=t.replace(n,`${n}\n${e?y.B:m.B}`);else{const n="void main() {";t=t.replace(n,`${e?y.B:m.B}\nvoid main() {`)}const r=new RegExp("finalWorld=finalWorld\\*influence;","g");t=t.replace(r,`${e?A.Z:x.Z}\nfinalWorld=finalWorld*influence;`)}return t}}p.Z.prototype.getMmdOutlineRenderer=function(){return this._mmdOutlineRenderer||(this._mmdOutlineRenderer=new M(this)),this._mmdOutlineRenderer};class M{name="MmdOutline";scene;zOffset=4;zOffsetUnits=0;_engine;_passIdForDrawWrapper;constructor(e){this.scene=e,this._engine=e.getEngine(),this.scene._addComponent(this),this._passIdForDrawWrapper=this._engine.createRenderPassId("Mmd Outline Renderer")}register(){this.scene._afterRenderingMeshStage.registerStep(g.v.STEP_AFTERRENDERINGMESH_OUTLINE,this,this._afterRenderingMesh)}rebuild(){}dispose(){this._engine.releaseRenderPassId(this._passIdForDrawWrapper)}static _ViewMatrix=new Float32Array(9);static _InverseViewProjectionMatrix=new u.uq;render(e,t,n){n=n??this._passIdForDrawWrapper;const r=this.scene,i=r.getEngine(),s=i.getCaps().instancedArrays&&(null!==t.visibleInstances[e._id]&&void 0!==t.visibleInstances[e._id]||e.getRenderingMesh().hasThinInstances);if(!this.isReady(e,s,n))return;const o=e.getMesh(),d=o._internalAbstractMeshDataInfo._actAsRegularMesh?o:null,c=e.getRenderingMesh(),u=d||c,p=e.getMaterial();if(!p||!r.activeCamera)return;const g=e._getDrawWrapper(n),f=l.E.GetEffect(g);i.enableEffect(g),p.useLogarithmicDepth&&f.setFloat("logarithmicDepthConstant",2/(Math.log(r.activeCamera.maxZ+1)/Math.LN2)),f.setFloat("offset",p.outlineWidth),f.setColor4("color",p.outlineColor,p.outlineAlpha);const m=i.getRenderHeight(),x=i.getRenderWidth();f.setFloat2("viewport",x,m);const y=M._ViewMatrix;{const e=r.getViewMatrix().m;y[0]=e[0],y[1]=e[1],y[2]=e[2],y[3]=e[4],y[4]=e[5],y[5]=e[6],y[6]=e[8],y[7]=e[9],y[8]=e[10]}f.setMatrix3x3("view",y),f.setMatrix("viewProjection",r.getTransformMatrix()),f.setMatrix("world",u.getWorldMatrix()),(0,h.f$)(c,f),(0,h.nR)(c,f),c.morphTargetManager&&c.morphTargetManager.isUsingTextureForTargets&&c.morphTargetManager._bind(f),s||c._bind(e,f,p.fillMode);const A=e.getMesh().bakedVertexAnimationManager;if(A&&A.isEnabled&&A.bind(f,s),p&&p.needAlphaTesting()){const e=p.getAlphaTestTexture();e&&(f.setTexture("diffuseSampler",e),f.setMatrix("diffuseMatrix",e.getTextureMatrix()))}(0,a.gS)(f,p,r),f.defines.includes("WORLDPOS_REQUIRED")&&f.setMatrix("inverseViewProjection",r.getTransformMatrix().invertToRef(M._InverseViewProjectionMatrix)),i.setZOffset(this.zOffset),i.setZOffsetUnits(this.zOffsetUnits),c._processRendering(u,e,f,p.fillMode,t,s,((e,t)=>{f.setMatrix("world",t)})),i.setZOffset(0),i.setZOffsetUnits(0)}isReady(e,t,r){r=r??this._passIdForDrawWrapper;const i=[],o=[s.R.PositionKind,s.R.NormalKind],l=e.getMesh(),u=e.getMaterial();if(!u)return!1;const p=l.getScene();u.needAlphaTesting()&&(i.push("#define ALPHATEST"),l.isVerticesDataPresent(s.R.UVKind)&&(o.push(s.R.UVKind),i.push("#define UV1")),l.isVerticesDataPresent(s.R.UV2Kind)&&(o.push(s.R.UV2Kind),i.push("#define UV2"))),u.useLogarithmicDepth&&i.push("#define LOGARITHMICDEPTH"),(0,a.tv)(u,p,i);let g=!1;for(let e=0;e4&&(o.push(s.R.MatricesIndicesExtraKind),o.push(s.R.MatricesWeightsExtraKind)),l.isVerticesDataPresent(f.V.MatricesSdefCKind)&&(o.push(f.V.MatricesSdefCKind),o.push(f.V.MatricesSdefRW0Kind),o.push(f.V.MatricesSdefRW1Kind),i.push("#define SDEF"));const e=l.skeleton;i.push("#define NUM_BONE_INFLUENCERS "+l.numBoneInfluencers),l.numBoneInfluencers>0&&m.addCPUSkinningFallback(0,l),e.isUsingTextureForMatrices?i.push("#define BONETEXTURE"):i.push("#define BonesPerMesh "+(e.bones.length+1))}else i.push("#define NUM_BONE_INFLUENCERS 0");const x=l.morphTargetManager;let y=0;x&&(y=x.numMaxInfluencers||x.numInfluencers,y>0&&(i.push("#define MORPHTARGETS"),i.push("#define NUM_MORPH_INFLUENCERS "+y),x.isUsingTextureForTargets&&i.push("#define MORPHTARGETS_TEXTURE"),(0,h.MF)(o,l,y))),t&&(i.push("#define INSTANCES"),(0,h.te)(o),e.getRenderingMesh().hasThinInstances&&i.push("#define THIN_INSTANCES"));const A=l.bakedVertexAnimationManager;A&&A.isEnabled&&(i.push("#define BAKED_VERTEX_ANIMATION_TEXTURE"),t&&o.push("bakedVertexAnimationSettingsInstanced"));const M=e._getDrawWrapper(r,!0),_=M.defines,b=i.join("\n");if(_!==b){const e=["world","mBones","viewport","view","viewProjection","diffuseMatrix","offset","color","logarithmicDepthConstant","morphTargetInfluences","boneTextureWidth","morphTargetCount","morphTargetTextureInfo","morphTargetTextureIndices","bakedVertexAnimationSettings","bakedVertexAnimationTextureSizeInverted","bakedVertexAnimationTime","bakedVertexAnimationTexture"],t=["diffuseSampler","boneSampler","morphTargets","bakedVertexAnimationTexture"];(0,a.TV)(e),g&&e.push("inverseViewProjection");const r=p.getEngine().isWebGPU?c.w.WGSL:c.w.GLSL;M.setEffect(this.scene.getEngine().createEffect("mmdOutline",{attributes:o,uniformsNames:e,uniformBuffersNames:[],samplers:t,defines:b,fallbacks:m,onCompiled:null,onError:null,indexParameters:{maxSimultaneousMorphTargets:y},processCodeAfterIncludes:T.ProcessSdefCode,shaderLanguage:r,extraInitializationsAsync:async()=>{r===c.w.WGSL?await Promise.all([n.e(126).then(n.bind(n,8980)),n.e(126).then(n.bind(n,1870))]):await Promise.all([n.e(71).then(n.bind(n,3357)),n.e(71).then(n.bind(n,5043))])}},this.scene.getEngine()),b)}return M.effect.isReady()}_afterRenderingMesh(e,t,n){const r=t.getMaterial();if(null!==r&&r.renderOutline){const e=this._engine,r=e.getDepthWrite(),i=e.getAlphaMode(),s=e.alphaState.alphaBlend;e.setDepthWrite(!0),e.setAlphaMode(o.Y.ALPHA_COMBINE,!0),e.setState(!0,void 0,void 0,void 0,!!this.scene._mirroredCameraPosition),this.render(t,n,this._passIdForDrawWrapper),e.setAlphaMode(i,!0),e.setDepthWrite(r),e.alphaState.alphaBlend=s}}}var _,b,I=n(5909);class v{log(e){console.log(e)}warn(e){console.warn(e)}error(e){console.error(e)}}class w{isDeviceLittleEndian;_dataView;_decoder;_offset;constructor(e){this.isDeviceLittleEndian=this._getIsDeviceLittleEndian(),this._dataView=new DataView(e),this._decoder=null,this._offset=0}get offset(){return this._offset}set offset(e){this._offset=e}_getIsDeviceLittleEndian(){const e=new Int16Array([256]);return 1===new Int8Array(e.buffer)[1]}swap16Array(e){for(let t=0;t>8&255}}swap32Array(e){for(let t=0;t>8&65280|n>>24&255}}getUint8(){const e=this._dataView.getUint8(this._offset);return this._offset+=1,e}getInt8(){const e=this._dataView.getInt8(this._offset);return this._offset+=1,e}getUint8Array(e){const t=new Uint8Array(this._dataView.buffer,this._offset,e.byteLength);e.set(t),this._offset+=e.byteLength}getUint16(){const e=this._dataView.getUint16(this._offset,!0);return this._offset+=2,e}getUint16Array(e){const t=new Uint8Array(this._dataView.buffer,this._offset,e.byteLength);new Uint8Array(e.buffer,e.byteOffset,e.byteLength).set(t),this._offset+=e.byteLength,this.isDeviceLittleEndian||this.swap16Array(e)}getInt16(){const e=this._dataView.getInt16(this._offset,!0);return this._offset+=2,e}getUint32(){const e=this._dataView.getUint32(this._offset,!0);return this._offset+=4,e}getUint32Array(e){const t=new Uint8Array(this._dataView.buffer,this._offset,e.byteLength);new Uint8Array(e.buffer,e.byteOffset,e.byteLength).set(t),this._offset+=e.byteLength,this.isDeviceLittleEndian||this.swap32Array(e)}getInt32(){const e=this._dataView.getInt32(this._offset,!0);return this._offset+=4,e}getInt32Array(e){const t=new Uint8Array(this._dataView.buffer,this._offset,e.byteLength);new Uint8Array(e.buffer,e.byteOffset,e.byteLength).set(t),this._offset+=e.byteLength,this.isDeviceLittleEndian||this.swap32Array(e)}getFloat32(){const e=this._dataView.getFloat32(this._offset,!0);return this._offset+=4,e}getFloat32Array(e){const t=new Uint8Array(this._dataView.buffer,this._offset,e.byteLength);new Uint8Array(e.buffer,e.byteOffset,e.byteLength).set(t),this._offset+=e.byteLength,this.isDeviceLittleEndian||this.swap32Array(e)}getFloat32Tuple(e){const t=new Array(e);for(let n=0;n0&&t.warn(`There are ${n.bytesAvailable} bytes left after parsing`),{header:r,vertices:i,indices:s,textures:u,materials:p,bones:f,morphs:d,displayFrames:h,rigidBodies:g,joints:m,softBodies:[]}}static _ParseHeader(e){if(e.bytesAvailable<7)throw new Error("is not pmd file");const t=e.getSignatureString(3);if("Pmd"!==t)throw new Error("is not pmd file");const n=e.getFloat32(),r=e.getDecoderString(20,!0),i=e.getDecoderString(256,!0);return{signature:t,version:n,encoding:b.Header.Encoding.ShiftJis,additionalVec4Count:0,vertexIndexSize:2,textureIndexSize:4,materialIndexSize:4,boneIndexSize:2,morphIndexSize:2,rigidBodyIndexSize:4,modelName:r,englishModelName:"",comment:i,englishComment:""}}static async _ParseVerticesAsync(e){const t=e.getUint32(),n=[];let r=performance.now();for(let i=0;isetTimeout(e,0))),r=performance.now())}return n}static _ParseIndices(e){const t=e.getUint32(),n=new Uint16Array(t);return e.getUint16Array(n),n}static _ParseMaterials(e){const t=e.getUint32(),n=[];for(let r=0;rd[e+1][1]){h=!1;break}if(!h){d.sort(((e,t)=>e[1]-t[1]));const e=new Array(d.length);for(let t=1;td[t][0]||void 0!==e[t-1])&&(n=!1),n||(e[t]=o[d[t-1][0]])}const t=new Map;for(let n=0;n{this._createTexture(t,n,i,e,o,a,((e,t)=>{l?.(e,t)}),d)}),void 0,!0,!0,((e,t)=>{l?.(e?e.status+" "+e.statusText:"",t)}))}loadFromArrayBuffer(e){this._createTexture(this._scene,this._assetContainer,this._textureName,e,this._options,this._onLoad,((e,t)=>{this._onError?.(e,t)}),this._forcedExtension)}_onDisposeCallback=null;registerOnDisposeCallback(e){this._onDisposeCallback=e,this._texture.onDisposeObservable.addOnce(e)}unregisterOnDisposeCallback(){const e=this._onDisposeCallback;return null===e?null:(this._onDisposeCallback=null,this._texture.onDisposeObservable.removeCallback(e),e)}_createTexture(e,t,n,r,i,s,o,a){e._blockEntityCollection=!!t;const l={noMipmap:i.noMipmap,invertY:i.invertY,samplingMode:i.samplingMode,onLoad:()=>{null===this._texture?null!==s&&K._.SetImmediate(s):s?.()},onError:o,buffer:r,deleteBuffer:i.deleteBuffer,format:i.format,mimeType:i.mimeType,forcedExtension:a},d=this._texture=new W.g("data:"+n,e,l);d._parentContainer=t,e._blockEntityCollection=!1,t?.textures.push(d),d.name=n}get texture(){return this._texture}}class j{onModelTextureLoadedObservable=new Map;textureCache=new Map;_textureLoadInfoMap=new Map;_loadingModels=new Map;_errorTexturesReferenceCount=new Map;_incrementLeftLoadCount(e){let t=this._loadingModels.get(e);void 0===t&&(t=new Q(e),this._loadingModels.set(e,t)),t.leftLoadCount+=1;let n=this.onModelTextureLoadedObservable.get(e);return void 0===n&&(n=new q.cP,this.onModelTextureLoadedObservable.set(e,n)),t}_decrementLeftLoadCount(e){if(e.leftLoadCount-=1,!e.isRequesting&&0===e.leftLoadCount){this._removeErrorTexturesReferenceCount(e.uniqueId),this._loadingModels.delete(e.uniqueId);const t=this.onModelTextureLoadedObservable.get(e.uniqueId);t?.notifyObservers(),t?.clear(),this.onModelTextureLoadedObservable.delete(e.uniqueId)}}loadModelTexturesEnd(e){const t=this._loadingModels.get(e);if(void 0!==t&&(t.isRequesting=!1,0===t.leftLoadCount)){this._removeErrorTexturesReferenceCount(e),this._loadingModels.delete(e);const t=this.onModelTextureLoadedObservable.get(e);t?.notifyObservers(),t?.clear(),this.onModelTextureLoadedObservable.delete(e)}}_addErrorTextureReferenceCount(e,t){this._loadingModels.get(e).errorTextureDatas.push(t),this._errorTexturesReferenceCount.set(t,(this._errorTexturesReferenceCount.get(t)??0)+1)}_removeErrorTexturesReferenceCount(e){const t=this._loadingModels.get(e);for(let e=0;e{this._textureLoadInfoMap.delete(e.cacheKey),this.textureCache.delete(e.cacheKey),this._errorTexturesReferenceCount.delete(e)}))}_createTextureCacheKey(e,t){const n=e.lastIndexOf(".");let r="";return-1!==n&&(r=e.substring(n),e=e.substring(0,n)),e+ +(t.noMipmap??!1)+ +(t.invertY??!0)+(t.samplingMode??W.g.TRILINEAR_SAMPLINGMODE)+(t.format??o.Y.TEXTUREFORMAT_RGBA)+r}async _loadTextureAsyncInternal(e,t,n,r,i,s,o){const a=this._incrementLeftLoadCount(e),l=this._createTextureCacheKey(t,o);let d=this._textureLoadInfoMap.get(l);void 0===d&&(d=new X,this._textureLoadInfoMap.set(l,d));let h=this.textureCache.get(l);if(void 0===h&&!d.hasLoadError){const a=null!==r?H.Data[r]:t;h=new Y(l,i,s,a,t,null!==n,o,(()=>{this._handleTextureOnDispose(h),d.hasLoadError=!1,d.observable.notifyObservers(!1),d.observable.clear()}),((t,n)=>{null!==h.texture&&this._handleTextureOnDispose(h),this._addErrorTextureReferenceCount(e,h),d.hasLoadError=!0,d.observable.notifyObservers(!0),d.observable.clear()}),o.forcedExtension),this.textureCache.set(l,h);const c=n instanceof Blob?await n.arrayBuffer():n;null!==c&&h.loadFromArrayBuffer(c)}return null!==h.texture&&h.texture.isReady()?(this._decrementLeftLoadCount(a),d.hasLoadError?null:h.texture):new Promise((e=>{d.observable.addOnce((t=>{this._decrementLeftLoadCount(a),e(t?null:h.texture)}))}))}async loadTextureAsync(e,t,n,r,i,s){let o;"number"==typeof n?((n<-1||9=0;a--)(i=e[a])&&(o=(s<3?i(o):s>3?i(t,n,o):i(t,n))||o);return s>3&&o&&Object.defineProperty(t,n,o),o};class re{isMock=!0;sphereTexture=null;sphereTextureBlendMode=te.rw.Add;toonTexture=null;ignoreDiffuseWhenToonTextureIsNull=!1;applyAmbientColorToDiffuse=!0;clampAlpha=!0;textureMultiplicativeColor=new z.ov(1,1,1,1);textureAdditiveColor=new z.ov(0,0,0,0);sphereTextureMultiplicativeColor=new z.ov(1,1,1,1);sphereTextureAdditiveColor=new z.ov(0,0,0,0);toonTextureMultiplicativeColor=new z.ov(1,1,1,1);toonTextureAdditiveColor=new z.ov(0,0,0,0);useTextureColor=!1;useSphereTextureColor=!1;useToonTextureColor=!1}class ie extends $.F{_pluginMaterial;_renderOutline=!1;outlineWidth=.01;outlineColor=new z.v9(0,0,0);outlineAlpha=1;_disposed=!1;constructor(e,t,n=!1){super(e,t,n),this.specularColor=new z.v9(0,0,0),(this._pluginMaterial=new re).ignoreDiffuseWhenToonTextureIsNull=!0,this._initPluginShaderSourceAsync(this._shaderLanguage)}async _initPluginShaderSourceAsync(e){const t=e===c.w.GLSL?(await Promise.all([n.e(71),n.e(257)]).then(n.bind(n,2968))).MmdPluginMaterial:(await Promise.all([n.e(126),n.e(257)]).then(n.bind(n,9325))).MmdPluginMaterial;if(this._disposed)return;const r=this._pluginMaterial,i=this._pluginMaterial=new t(this);i.isEnabled=!0,i.sphereTexture=r.sphereTexture,i.sphereTextureBlendMode=r.sphereTextureBlendMode,i.toonTexture=r.toonTexture,i.ignoreDiffuseWhenToonTextureIsNull=r.ignoreDiffuseWhenToonTextureIsNull,i.applyAmbientColorToDiffuse=r.applyAmbientColorToDiffuse,i.clampAlpha=r.clampAlpha,i.textureMultiplicativeColor=r.textureMultiplicativeColor,i.textureAdditiveColor=r.textureAdditiveColor,i.sphereTextureMultiplicativeColor=r.sphereTextureMultiplicativeColor,i.sphereTextureAdditiveColor=r.sphereTextureAdditiveColor,i.toonTextureMultiplicativeColor=r.toonTextureMultiplicativeColor,i.toonTextureAdditiveColor=r.toonTextureAdditiveColor,i.useTextureColor=r.useTextureColor,i.useSphereTextureColor=r.useSphereTextureColor,i.useToonTextureColor=r.useToonTextureColor}dispose(e,t){super.dispose(e,t),this._disposed=!0}isReadyForSubMesh(e,t,n){return!this._pluginMaterial.isMock&&super.isReadyForSubMesh(e,t,n)}get sphereTexture(){return this._pluginMaterial.sphereTexture}set sphereTexture(e){this._pluginMaterial.sphereTexture=e}get sphereTextureBlendMode(){return this._pluginMaterial.sphereTextureBlendMode}set sphereTextureBlendMode(e){this._pluginMaterial.sphereTextureBlendMode=e}get toonTexture(){return this._pluginMaterial.toonTexture}set toonTexture(e){this._pluginMaterial.toonTexture=e}get ignoreDiffuseWhenToonTextureIsNull(){return this._pluginMaterial.ignoreDiffuseWhenToonTextureIsNull}set ignoreDiffuseWhenToonTextureIsNull(e){this._pluginMaterial.ignoreDiffuseWhenToonTextureIsNull=e}get applyAmbientColorToDiffuse(){return this._pluginMaterial.applyAmbientColorToDiffuse}set applyAmbientColorToDiffuse(e){this._pluginMaterial.applyAmbientColorToDiffuse=e}get clampAlpha(){return this._pluginMaterial.clampAlpha}set clampAlpha(e){this._pluginMaterial.clampAlpha=e}get textureMultiplicativeColor(){return this._pluginMaterial.useTextureColor=!0,this._pluginMaterial.textureMultiplicativeColor}set textureMultiplicativeColor(e){this._pluginMaterial.useTextureColor=!0,this._pluginMaterial.textureMultiplicativeColor=e}get textureAdditiveColor(){return this._pluginMaterial.useTextureColor=!0,this._pluginMaterial.textureAdditiveColor}set textureAdditiveColor(e){this._pluginMaterial.useTextureColor=!0,this._pluginMaterial.textureAdditiveColor=e}get sphereTextureMultiplicativeColor(){return this._pluginMaterial.useSphereTextureColor=!0,this._pluginMaterial.sphereTextureMultiplicativeColor}set sphereTextureMultiplicativeColor(e){this._pluginMaterial.useSphereTextureColor=!0,this._pluginMaterial.sphereTextureMultiplicativeColor=e}get sphereTextureAdditiveColor(){return this._pluginMaterial.useSphereTextureColor=!0,this._pluginMaterial.sphereTextureAdditiveColor}set sphereTextureAdditiveColor(e){this._pluginMaterial.useSphereTextureColor=!0,this._pluginMaterial.sphereTextureAdditiveColor=e}get toonTextureMultiplicativeColor(){return this._pluginMaterial.useToonTextureColor=!0,this._pluginMaterial.toonTextureMultiplicativeColor}set toonTextureMultiplicativeColor(e){this._pluginMaterial.useToonTextureColor=!0,this._pluginMaterial.toonTextureMultiplicativeColor=e}get toonTextureAdditiveColor(){return this._pluginMaterial.useToonTextureColor=!0,this._pluginMaterial.toonTextureAdditiveColor}set toonTextureAdditiveColor(e){this._pluginMaterial.useToonTextureColor=!0,this._pluginMaterial.toonTextureAdditiveColor=e}get renderOutline(){return this._renderOutline}set renderOutline(e){e&&this.getScene().getMmdOutlineRenderer?.(),this._renderOutline=e}needAlphaBlending(){return!this._disableAlphaBlending&&(super.needAlphaBlending()||null!==this._pluginMaterial.sphereTexture&&this._pluginMaterial.sphereTextureBlendMode===te.rw.Multiply)}clone(e,t=!0,n=""){const r=Z.p.Clone((()=>new ie(e,this.getScene())),this,{cloneTexturesOnlyOnce:t});return r.name=e,r.id=e,this.stencil.copyTo(r.stencil),this._clonePlugins(r,n),r}static Parse(e,t,n){const r=Z.p.Parse((()=>new ie(e.name,t)),e,t,n);return e.stencil&&r.stencil.parse(e.stencil,t,n),N.i._ParsePlugins(e,r,t,n),r}}ne([(0,J.lK)("renderOutline")],ie.prototype,"_renderOutline",void 0),ne([(0,J.lK)()],ie.prototype,"outlineWidth",void 0),ne([(0,J.jT)()],ie.prototype,"outlineColor",void 0),ne([(0,J.lK)()],ie.prototype,"outlineAlpha",void 0),(0,ee.Y5)("BABYLON.MmdStandardMaterial",ie);class se{files;_fileRootId;_fileMap=new Map;constructor(e,t,n){if(t=G(t),this.files=e,this._fileRootId=n,0!==e.length)if(e[0]instanceof File)for(const r of e){const e=G(r.webkitRelativePath);if(!e.startsWith(t))continue;const i=n+G(e.slice(t.length));this._fileMap.set(G(i).toUpperCase(),r)}else for(const t of e){const e=n+G(t.relativePath);this._fileMap.set(G(e).toUpperCase(),t)}}createFullPath(e){return this._fileRootId+G(e)}resolve(e){const t=G(e);return this._fileMap.get(t.toUpperCase())}}var oe,ae,le=n(917),de=n(6882);!function(e){e[e.Opaque=N.i.MATERIAL_OPAQUE]="Opaque",e[e.AlphaTest=N.i.MATERIAL_ALPHATEST]="AlphaTest",e[e.AlphaBlend=N.i.MATERIAL_ALPHABLEND]="AlphaBlend"}(oe||(oe={}));class he{_scene;_renderTargetTexture;_resultPixelsBuffer;constructor(e,t=512){this._scene=e;const n=e.getEngine(),r=this._renderTargetTexture=new de.$("texture_alpha_checker",t,e,{generateDepthBuffer:!1,generateStencilBuffer:!1,generateMipMaps:!1,type:o.Y.TEXTURETYPE_UNSIGNED_BYTE,format:n.isWebGPU||n.version>1?o.Y.TEXTUREFORMAT_RED:o.Y.TEXTUREFORMAT_RGBA,doNotChangeAspectRatio:!0});r.noPrePassRenderer=!0,r.anisotropicFilteringLevel=1,r.renderParticles=!1,r.optimizeUVAllocation=!0,r.ignoreCameraViewport=!0,r.clearColor=new z.ov(0,0,0,1),this._resultPixelsBuffer=new Uint8Array(t*t*4)}async _renderTexture(e,t,n){const r=he._GetShader(this._scene);r.setTexture("textureSampler",e);let i=null;null!==n&&(i=t.subMeshes,t.subMeshes=[t.subMeshes[n]]);const s=this._renderTargetTexture;for(s.renderList=[t],s.setMaterialForRendering(t,r);!s.isReadyForRendering()||!r.isReady();)if(await new Promise((e=>{setTimeout(e,0)})),null===s._texture)return new Uint8Array(0);const o=t._internalAbstractMeshDataInfo._currentLODIsUpToDate,a=t._internalAbstractMeshDataInfo._currentLOD;t._internalAbstractMeshDataInfo._currentLODIsUpToDate=!0,t._internalAbstractMeshDataInfo._currentLOD=t;const l=t._nodeDataStorage._isEnabled,d=t._nodeDataStorage._isParentEnabled;t._nodeDataStorage._isEnabled=!0,t._nodeDataStorage._isParentEnabled=!0,s.render(!1,!1),t._nodeDataStorage._isParentEnabled=d,t._nodeDataStorage._isEnabled=l,t._internalAbstractMeshDataInfo._currentLOD=a,t._internalAbstractMeshDataInfo._currentLODIsUpToDate=o;const h=r.getEffect();t.geometry._releaseVertexArrayObject(h);const c=t.subMeshes;for(let e=0,t=c.length;e{this._taskQueue.push(e)})),this._blockRendering=!0;const s=await this._renderTexture(e,t,n);let o=0,a=0,l=0;for(let e=0;e{this._taskQueue.push(e)})),this._blockRendering=!0;const r=await this._renderTexture(e,t,n);for(let e=0;e{t===c.w.WGSL?await Promise.all([n.e(126).then(n.bind(n,1306)),n.e(126).then(n.bind(n,6876))]):await Promise.all([n.e(71).then(n.bind(n,9457)),n.e(71).then(n.bind(n,71))])}});r.backFaceCulling=!1,r.alphaMode=o.Y.ALPHA_DISABLE,e.onDisposeObservable.add((()=>{e._textureAlphaCheckerShader?.dispose(),e._textureAlphaCheckerShader=null})),e._textureAlphaCheckerShader=r}return e._textureAlphaCheckerShader}static DisposeShader(e){e._textureAlphaCheckerShader?.dispose(),e._textureAlphaCheckerShader=null}}!function(e){e[e.DepthWriteAlphaBlendingWithEvaluation=0]="DepthWriteAlphaBlendingWithEvaluation",e[e.DepthWriteAlphaBlending=1]="DepthWriteAlphaBlending",e[e.AlphaEvaluation=2]="AlphaEvaluation"}(ae||(ae={}));class ce{renderMethod=ae.DepthWriteAlphaBlendingWithEvaluation;forceDisableAlphaEvaluation=!1;alphaThreshold=195;alphaBlendThreshold=100;alphaEvaluationResolution=512;deleteTextureBufferAfterLoad=!0;_textureLoader=new j;nextStartingAlphaIndex=65536;alphaIndexIncrementsPerModel=1024;_setMeshesAlphaIndex(e){let t=this.nextStartingAlphaIndex;for(let n=0;nnull!==m?m:this.forceDisableAlphaEvaluation?null:m=new he(d,this.alphaEvaluationResolution),y=new se(o,i,s),A=[],T={lengthComputable:!0,loaded:0,total:3*t.length},M=()=>{T.loaded+=1,p?.(T)},_=[];for(let s=0;sthis.setAlphaBlendMode(l,o,a[s],u,x);if(void 0!==p){const e=p.then(g);t.push(e)}else{const e=g();void 0!==e&&t.push(e)}const f=this.loadSphereTexture(e,l,o,r,n[o.sphereTextureIndex]??null,d,h,i,y,u,M);void 0!==f&&t.push(f);const m=this.loadToonTexture(e,l,o,r,n[o.toonTextureIndex]??null,d,h,i,y,u,M);void 0!==m&&t.push(m);const T=this.loadOutlineRenderingProperties(l,o,u);void 0!==T&&t.push(T),A.push(...t),Promise.all(t).then((()=>{this.afterBuildSingleMaterial(l,s,o,r,n,d,i)}))}_.push(l)}this._textureLoader.loadModelTexturesEnd(e);const b=this._textureLoader.onModelTextureLoadedObservable.get(e);return void 0!==b?b.addOnce((()=>{Promise.all(A).then((()=>{m?.dispose(),d._forceBlockMaterialDirtyMechanism(f),null!==c&&this._buildTextureNameMap(t,_,r,n,c),g?.()}))})):Promise.all(A).then((()=>{m?.dispose(),d._forceBlockMaterialDirtyMechanism(f),null!==c&&this._buildTextureNameMap(t,_,r,n,c),g?.()})),_}_buildTextureNameMap(e,t,n,r,i){for(let s=0;s{const r=t.diffuse;e.diffuseColor=new z.v9(r[0],r[1],r[2]);const i=t.specular;e.specularColor=new z.v9(i[0],i[1],i[2]);const s=t.ambient;e.ambientColor=new z.v9(s[0],s[1],s[2]);const o=t.diffuse[3];if(e.alpha=o,0===o)for(let e=0;e{t.backFaceCulling=!(n.flag&b.Material.Flag.IsDoubleSided);const u=r[i?.imagePathIndex??-1];if(void 0!==u){const n=d.createFullPath(u);let r;const p=d.resolve(n);r=void 0!==p?await this._textureLoader.loadTextureFromBufferAsync(e,n,p instanceof File?p:p.data,s,a,{...i,deleteBuffer:this.deleteTextureBufferAfterLoad,format:o.Y.TEXTUREFORMAT_RGBA,mimeType:p instanceof File?p.type:p.mimeType}):await this._textureLoader.loadTextureAsync(e,l,u,s,a,{...i,deleteBuffer:this.deleteTextureBufferAfterLoad,format:o.Y.TEXTUREFORMAT_RGBA});const g=r;null!==g?t.diffuseTexture=g:h.error(`Failed to load diffuse texture: ${n}`),c?.()}else c?.()};async _evaluateDiffuseTextureTransparencyMode(e,t,n,r,i){let s=Number.MIN_SAFE_INTEGER;if(this.renderMethod===ae.DepthWriteAlphaBlendingWithEvaluation){let r=t>>4&3;if(0==(3^r)&&(r=-1),-1===r){s=N.i.MATERIAL_OPAQUE;const t=i();if(null!==t)for(let r=0;r{if(this.renderMethod===ae.DepthWriteAlphaBlending)return e.diffuseTexture&&(e.diffuseTexture.hasAlpha=!0,e.useAlphaFromDiffuseTexture=!0),e.transparencyMode=N.i.MATERIAL_ALPHABLEND,void(e.forceDepthWrite=!0);if(this.renderMethod===ae.DepthWriteAlphaBlendingWithEvaluation&&e.alpha<1)return e.diffuseTexture&&(e.diffuseTexture.hasAlpha=!0,e.useAlphaFromDiffuseTexture=!0),e.transparencyMode=N.i.MATERIAL_ALPHABLEND,void(e.forceDepthWrite=!0);const s=e.diffuseTexture,o=t.evaluatedTransparency??-1;if(null!==s){const t=await this._evaluateDiffuseTextureTransparencyMode(s,o,n,r,i);if(null!==t){const n=t!==N.i.MATERIAL_OPAQUE;n&&(s.hasAlpha=!0),e.useAlphaFromDiffuseTexture=n,e.transparencyMode=t,this.renderMethod===ae.DepthWriteAlphaBlendingWithEvaluation&&(e.forceDepthWrite=n)}}else if(this.renderMethod===ae.DepthWriteAlphaBlendingWithEvaluation){let t=o>>4&3;0==(3^t)&&(t=0),e.transparencyMode=0===t?N.i.MATERIAL_OPAQUE:N.i.MATERIAL_ALPHABLEND}else{let t=15&o;0==(15^t)&&(t=0),e.transparencyMode=N.i.MATERIAL_OPAQUE}};loadSphereTexture=async(e,t,n,r,i,s,a,l,d,h,c)=>{if(n.sphereTextureMode!==b.Material.SphereTextureMode.Off){const u=r[i?.imagePathIndex??-1];if(void 0!==u){const r=s.getEngine().isWebGPU||n.sphereTextureMode===b.Material.SphereTextureMode.Multiply?o.Y.TEXTUREFORMAT_RGBA:o.Y.TEXTUREFORMAT_RGB,p=d.createFullPath(u);let g;const f=d.resolve(p);g=void 0!==f?await this._textureLoader.loadTextureFromBufferAsync(e,p,f instanceof File?f:f.data,s,a,{...i,deleteBuffer:this.deleteTextureBufferAfterLoad,format:r,mimeType:f instanceof File?f.type:f.mimeType}):await this._textureLoader.loadTextureAsync(e,l,u,s,a,{...i,deleteBuffer:this.deleteTextureBufferAfterLoad,format:r}),null!==g?(t.sphereTexture=g,t.sphereTextureBlendMode=n.sphereTextureMode):h.error(`Failed to load sphere texture: ${p}`),c?.()}else c?.()}else c?.()};loadToonTexture=async(e,t,n,r,i,s,a,l,d,h,c)=>{let u;if(u=n.isSharedToonTexture?n.toonTextureIndex:r[i?.imagePathIndex??-1],void 0!==u){const n=d.createFullPath(u.toString());let r;const p="string"==typeof u?d.resolve(n):void 0;r=void 0!==p?await this._textureLoader.loadTextureFromBufferAsync(e,n,p instanceof File?p:p.data,s,a,{...i,deleteBuffer:this.deleteTextureBufferAfterLoad,format:s.getEngine().isWebGPU?o.Y.TEXTUREFORMAT_RGBA:o.Y.TEXTUREFORMAT_RGB,mimeType:p instanceof File?p.type:p.mimeType}):await this._textureLoader.loadTextureAsync(e,l,u,s,a,{...i,deleteBuffer:this.deleteTextureBufferAfterLoad,format:s.getEngine().isWebGPU?o.Y.TEXTUREFORMAT_RGBA:o.Y.TEXTUREFORMAT_RGB}),null!==r?t.toonTexture=r:h.error(`Failed to load toon texture: ${n}`),c?.()}else c?.()};loadOutlineRenderingProperties=(e,t,n)=>{if(t.flag&b.Material.Flag.EnabledToonEdge){void 0===p.Z.prototype.getMmdOutlineRenderer&&n.warn('MMD Outline Renderer is not available. Please import "babylon-mmd/esm/Loader/mmdOutlineRenderer".'),e.renderOutline=!0,e.outlineWidth=t.edgeSize;const r=t.edgeColor;e.outlineColor=new z.v9(r[0],r[1],r[2]),e.outlineAlpha=r[3]}};afterBuildSingleMaterial=()=>{}}class ue{lengthComputable;total;_onProgress;_unprocessedTasks;_processingTasks;_endedTaskNames;_endedTasksTotal;constructor(e,t,n){this.lengthComputable=e;let r=0;for(let e=0;e=n.cost&&(this._processingTasks.delete(e),this._endedTaskNames.add(e),this._endedTasksTotal+=n.cost))}setTaskProgress(e,t){const n=this._getTaskState(e);return null!==n&&(n.progress=t,n.progress>=n.cost&&(this._processingTasks.delete(e),this._endedTaskNames.add(e),this._endedTasksTotal+=n.cost),!0)}setTaskProgressRatio(e,t,n){const r=this._getTaskState(e);return null!==r&&(r.progress=n?Math.floor(r.cost*t):r.cost*t,r.progress>=r.cost&&(this._processingTasks.delete(e),this._endedTaskNames.add(e),this._endedTasksTotal+=r.cost),!0)}endTask(e){const t=this._getTaskState(e);null!==t&&(this._processingTasks.delete(e),this._endedTaskNames.add(e),this._endedTasksTotal+=t.cost)}invokeProgressEvent(){null!==this._onProgress&&this._onProgress({lengthComputable:this.lengthComputable,loaded:this.loaded,total:this.total})}get loaded(){let e=this._endedTasksTotal;for(const[t,n]of this._processingTasks)e+=n.progress;return e}}class pe{name;extensions;materialBuilder;useSdef;buildSkeleton;buildMorph;boundingBoxMargin;preserveSerializationData;_loggingEnabled;log;warn;error;static _SharedStandardMaterialBuilder=new ce;constructor(e,t,n={},r){this.name=e,this.extensions=t,r=r??{materialBuilder:pe._SharedStandardMaterialBuilder,useSdef:!0,buildSkeleton:!0,buildMorph:!0,boundingBoxMargin:10,preserveSerializationData:!1,loggingEnabled:!1},this.materialBuilder=n.materialBuilder??r.materialBuilder,this.useSdef=n.useSdef??r.useSdef,this.buildSkeleton=n.buildSkeleton??r.buildSkeleton,this.buildMorph=n.buildMorph??r.buildMorph,this.boundingBoxMargin=n.boundingBoxMargin??r.boundingBoxMargin,this.preserveSerializationData=n.preserveSerializationData??r.preserveSerializationData,this._loggingEnabled=n.loggingEnabled??r.loggingEnabled,this._loggingEnabled?(this.log=this._logEnabled,this.warn=this._warnEnabled,this.error=this._errorEnabled):(this.log=this._logDisabled,this.warn=this._warnDisabled,this.error=this._errorDisabled)}importMeshAsync(e,t,n,r,i,s){return this._loadAsyncInternal(t,null,n,r,i)}loadAsync(e,t,n,r,i){return this._loadAsyncInternal(e,null,t,n,r).then((()=>{}))}loadAssetContainerAsync(e,t,n,r,i){const s=new P.WZ(e);return this._loadAsyncInternal(e,s,t,n,r).then((()=>s))}async _loadAsyncInternal(e,t,n,r,i){const s=await this._parseFileAsync(n.arrayBuffer),o=new ue(!0,this._getProgressTaskCosts(n,s),i??null);o.endTask("Parse"),o.invokeProgressEvent(),e._blockEntityCollection=!!t;const a=new F.e(s.header.modelName,e);a._parentContainer=t,e._blockEntityCollection=!1,a.setEnabled(!1);const l=await this._buildGeometryAsync(n,s,a,e,t,o),d=n.preserveSerializationData?new Map:null,{materials:h,multiMaterials:c,textureLoadPromise:u}=await this._buildMaterialAsync(n,s,a,l.meshes,d,e,t,r,o),p=[];let g=null;n.buildSkeleton?g=await this._buildSkeletonAsync(n,s,l.meshes,e,t,p,o):o.endTask("Build Skeleton");const f=[];let m=null;if(n.buildMorph&&(m=await this._buildMorphAsync(n,s,l,e,t,f,o)),0!==n.boundingBoxMargin&&this._applyBoundingBoxMargin(l.meshes,n.boundingBoxMargin),a.metadata={isMmdModel:!0,header:{modelName:s.header.modelName,englishModelName:s.header.englishModelName,comment:s.header.comment,englishComment:s.header.englishComment},bones:p,morphs:f,rigidBodies:s.rigidBodies,joints:s.joints,meshes:l.meshes,materials:h,skeleton:g},n.preserveSerializationData){const e=[],t=s.materials;for(let n=0;n4,g=p?this.getVerticesData(s.R.MatricesIndicesExtraKind):null,m=p?this.getVerticesData(s.R.MatricesWeightsExtraKind):null,x=e.getTransformMatrices(this),y=u.Pq.Zero(),A=new u.uq,T=new u.uq,M=new u.uq,_=new u.uq,b=new u.PT,I=new u.PT,v=new u.Pq,w=n._sourcePositions,E=n._sourceNormals;let S,C=0;for(let e=0;e0&&(u.uq.FromFloat32ArrayToRefScaled(x,Math.floor(16*h[C+S]),n,T),A.addToSelf(T));if(p)for(S=0;S<4;S++)n=m[C+S],n>0&&(u.uq.FromFloat32ArrayToRefScaled(x,Math.floor(16*g[C+S]),n,T),A.addToSelf(T));u.Pq.TransformCoordinatesFromFloatsToRef(w[e],w[e+1],w[e+2],A,y),y.toArray(r,e),t&&(u.Pq.TransformNormalFromFloatsToRef(E[e],E[e+1],E[e+2],A,y),y.toArray(i,e)),A.reset()}else{const n=c[C+0],s=c[C+1];u.uq.FromArrayToRef(x,Math.floor(16*h[C+0]),M),u.uq.FromArrayToRef(x,Math.floor(16*h[C+1]),_),u.PT.FromRotationMatrixToRef(M,b),u.PT.FromRotationMatrixToRef(_,I),u.uq.FromQuaternionToRef(u.PT.SlerpToRef(b,I,s,b),T),u.Pq.TransformCoordinatesFromFloatsToRef(w[e]-a[e],w[e+1]-a[e+1],w[e+2]-a[e+2],T,v),u.Pq.TransformCoordinatesFromFloatsToRef(l[e],l[e+1],l[e+2],M,y).scaleAndAddToRef(n,v),u.Pq.TransformCoordinatesFromFloatsToRef(d[e],d[e+1],d[e+2],_,y).scaleAndAddToRef(s,v),v.toArray(r,e),t&&(u.Pq.TransformNormalFromFloatsToRef(E[e],E[e+1],E[e+2],T,v),v.toArray(i,e))}}return this.updateVerticesData(s.R.PositionKind,r),t&&this.updateVerticesData(s.R.NormalKind,i),this}getClassName(){return"SdefMesh"}clone(e="",t=null,n,r=!0){return new fe(e,this.getScene(),t,this,n,r)}}(0,ee.Y5)("BABYLON.SdefMesh",fe);class me extends pe{referenceFiles;constructor(e,t,n={},r){super(e,t,n,r),this.referenceFiles=n.referenceFiles??r?.referenceFiles??[]}loadFile(e,t,n,r,i,s,o){const a=this.materialBuilder,l=this.useSdef,d=this.buildSkeleton,h=this.buildMorph,c=this.boundingBoxMargin,u=this.referenceFiles,p=this.preserveSerializationData;return e._loadFile(t,((e,n)=>{const i={arrayBuffer:e,pmFileId:t instanceof File?ge.GetId(t).toString():t,materialBuilder:a,useSdef:l,buildSkeleton:d,buildMorph:h,boundingBoxMargin:c,referenceFiles:u,preserveSerializationData:p};r(i,n)}),i,!0,s,o)}_getProgressTaskCosts(e,t){const n=super._getProgressTaskCosts(e,t);if(n.push({name:"Build Geometry",cost:t.indices.length}),e.buildMorph){let e=0;const r=t.morphs;for(let t=0;t{d=e.materialBuilder.buildMaterials(n.uniqueId,t.materials,h,t.textures,a,"file:"+e.pmFileId+"_",e.referenceFiles,c,r,s,o,i,this,(e=>{e.lengthComputable&&(l.setTaskProgressRatio("Texture Load",e.loaded/e.total,!0),l.invokeProgressEvent())}),(()=>u()))})),p=Array.isArray(d)?d:await d;for(let e=0;ePromise.reject(e)))}}(0,I.cH)(new xe);class ye{_vertexIndexSize;_textureIndexSize;_materialIndexSize;_boneIndexSize;_morphIndexSize;_rigidBodyIndexSize;constructor(e,t,n,r,i,s){this._vertexIndexSize=e,this._textureIndexSize=t,this._materialIndexSize=n,this._boneIndexSize=r,this._morphIndexSize=i,this._rigidBodyIndexSize=s}getVertexIndex(e){switch(this._vertexIndexSize){case 1:return e.getUint8();case 2:return e.getUint16();case 4:return e.getInt32();default:throw new Error(`Invalid vertexIndexSize: ${this._vertexIndexSize}`)}}_getNonVertexIndex(e,t){switch(t){case 1:return e.getInt8();case 2:return e.getInt16();case 4:return e.getInt32();default:throw new Error(`Invalid indexSize: ${t}`)}}getTextureIndex(e){return this._getNonVertexIndex(e,this._textureIndexSize)}getMaterialIndex(e){return this._getNonVertexIndex(e,this._materialIndexSize)}getBoneIndex(e){return this._getNonVertexIndex(e,this._boneIndexSize)}getMorphIndex(e){return this._getNonVertexIndex(e,this._morphIndexSize)}getRigidBodyIndex(e){return this._getNonVertexIndex(e,this._rigidBodyIndexSize)}}class Ae{constructor(){}static async ParseAsync(e,t=new v){const n=new w(e),r=this._ParseHeader(n,t),i=new ye(r.vertexIndexSize,r.textureIndexSize,r.materialIndexSize,r.boneIndexSize,r.morphIndexSize,r.rigidBodyIndexSize),s=await this._ParseVerticesAsync(n,i,r),o=this._ParseIndices(n,i,r),a=this._ParseTextures(n),l=this._ParseMaterials(n,i),d=this._ParseBones(n,i),h=this._ParseMorphs(n,i),c=this._ParseDisplayFrames(n,i),u=this._ParseRigidBodies(n,i),p=this._ParseJoints(n,i),g=r.version<=2?[]:this._ParseSoftBodies(n,i,r);return n.bytesAvailable>0&&t.warn(`There are ${n.bytesAvailable} bytes left after parsing`),{header:r,vertices:s,indices:o,textures:a,materials:l,bones:d,morphs:h,displayFrames:c,rigidBodies:u,joints:p,softBodies:g}}static _ParseHeader(e,t){if(e.bytesAvailable<17)throw new RangeError("is not pmx file");const n=e.getSignatureString(3);if("PMX"!==n)throw new RangeError("is not pmx file");e.getInt8();const r=e.getFloat32(),i=e.getUint8(),s=e.getUint8();e.initializeTextDecoder(s===b.Header.Encoding.Utf8?"utf-8":"utf-16le");const o=e.getUint8(),a=e.getUint8(),l=e.getUint8(),d=e.getUint8(),h=e.getUint8(),c=e.getUint8(),u=e.getUint8();if(i<8)throw new Error(`Invalid globalsCount: ${i}`);if(8setTimeout(e,0))),s=performance.now())}return i}static _ParseIndices(e,t,n){const r=e.getInt32(),i=new ArrayBuffer(r*n.vertexIndexSize);let s;switch(n.vertexIndexSize){case 1:s=new Uint8Array(i);break;case 2:s=new Uint16Array(i);break;case 4:s=new Int32Array(i);break;default:throw new Error(`Invalid vertexIndexSize: ${n.vertexIndexSize}`)}for(let n=0;nPromise.reject(e)))}}(0,I.cH)(new Me);var _e,be,Ie,ve=n(9057),we=n(5581),Ee=n(1513),Se=n(8595),Ce=n(8529),Fe=n(3770);!function(e){e.isMmdMesh=function(e){return!(null===e.metadata||!e.metadata.isMmdModel)},e.isMmdSkinnedMesh=function(e){return!(null===e.metadata||!e.metadata.isMmdModel)&&null!==e.metadata.skeleton}}(_e||(_e={})),function(e){e.isSerializationMetadata=function(e){return!0===e.containsSerializationData}}(be||(be={}));class Be{_dataView;_encoder;_offset;constructor(e){this._dataView=new DataView(e),this._encoder=new TextEncoder,this._offset=0}get offset(){return this._offset}set offset(e){this._offset=e}setUint8(e){this._dataView.setUint8(this._offset,e),this._offset+=1}setUint8Array(e){const t=this._dataView;for(let n=0;n0;){const e=t.pop(),n=i.get(e),r=e.children;for(let e=0;e{const t=e.children;for(let r=0;r{const n=r.get(e);if(void 0!==n)for(let e=0;ee.texture===M)):-1,I=d.sphereTexture,v=I?y.findIndex((e=>e.texture===I)):-1,w=d.sphereTextureBlendMode??b.Material.SphereTextureMode.Off,E=d.toonTexture,S=!!E&&E.name.startsWith("file:shared_toon_texture_")&&E.name.length<=27&&!isNaN(Number(E.name.substring(25)));let C;C=S?Number(E.name.substring(25))-1:E?y.findIndex((e=>e.texture===E)):-1;const F={name:n,englishName:s,diffuse:l,specular:h,shininess:u,ambient:p,evaluatedTransparency:g,flag:f,edgeColor:m,edgeSize:x,textureIndex:_,sphereTextureIndex:v,sphereTextureMode:w,isSharedToonTexture:S,toonTextureIndex:C,comment:e?.comment??"",linkedMaterial:d};A.push(F)}}}}const M=new Array(a.morphs.length).fill(null);for(let e=0;ee.linkedMaterial===i));w.setInt32(s),w.setUint32(r.verticesStart),w.setUint32(r.verticesCount),w.setUint32(r.indexStart),w.setUint32(r.indexCount)}}else{const e=t.material,n=A.findIndex((t=>t.linkedMaterial===e));w.setInt32(n)}const i=n.getVerticesData(s.R.PositionKind),o=i.length/3;w.setUint32(o),w.setFloat32Array(i);let a=n.getVerticesData(s.R.NormalKind);if(a.length!==3*o){this.warn(`mesh ${t.name} normals vertex count is different from positions vertex count`);const e=new Float32Array(3*o);e.set(a),a=e}w.setFloat32Array(a);let l=n.getVerticesData(s.R.UVKind);if(l.length!==2*o){this.warn(`mesh ${t.name} uv vertex count is different from positions vertex count`);const e=new Float32Array(2*o);e.set(l),l=e}w.setFloat32Array(l);const h=[];{const e=n.getVerticesData(f.V.AdditionalUV1Kind);null!==e&&h.push(e);const t=n.getVerticesData(f.V.AdditionalUV2Kind);null!==t&&h.push(t);const r=n.getVerticesData(f.V.AdditionalUV3Kind);null!==r&&h.push(r);const i=n.getVerticesData(f.V.AdditionalUV4Kind);null!==i&&h.push(i)}w.setUint8(h.length);for(let e=0;e0;){const r=i.pop(),s=r.getParent();if(s?r.getLocalMatrix().multiplyToRef(s.getFinalMatrix(),r.getFinalMatrix()):t?r.getLocalMatrix().multiplyToRef(t,r.getFinalMatrix()):r.getFinalMatrix().copyFrom(r.getLocalMatrix()),-1!==r._index){const t=null===r._index?n:r._index;r.getAbsoluteInverseBindMatrix().multiplyToArray(r.getFinalMatrix(),e,16*t)}const o=r.getChildren();for(const e of o)i.push(e)}}}this._identity.copyToArray(e,16*this.bones.length)}}}async function De(e,t=""){const n=[];for(let r=0;r{e.readEntries(t,n)}));n.push(...await De(r,t+i.name+"/"))}else n.push(i)}return n}const Pe=document.createElement("canvas");Pe.style.width="100%",Pe.style.height="100%",Pe.style.display="block",document.body.appendChild(Pe);const ke=new r.N(Pe,!1,{preserveDrawingBuffer:!1,stencil:!1,antialias:!0,alpha:!0,premultipliedAlpha:!1,powerPreference:"high-performance",doNotHandleTouchAction:!0,doNotHandleContextLost:!0,audioEngine:!1,disableWebGL2Support:!1},!0);i.Create({canvas:Pe,engine:ke,sceneBuilder:new class{async build(e,t){T.OverrideEngineCreateEffect(t);const n=new ce;n.deleteTextureBufferAfterLoad=!1,n.renderMethod=ae.AlphaEvaluation;const r=new p.Z(t);r.ambientColor=new z.v9(.5,.5,.5);const i=new ve.L("camera",0,0,45,new u.Pq(0,10,0),r);i.maxZ=5e3,i.fov=Math.PI/180*30,i.speed=.5,i.setPosition(new u.Pq(0,10,-45)),i.attachControl(e,!0);const s=new Ee.g("hemisphericLight",new u.Pq(0,1,0),r);s.intensity=.5,s.specular=new z.v9(0,0,0),s.groundColor=new z.v9(1,1,1);const o=new we.Z("directionalLight",new u.Pq(.5,-1,1),r);o.intensity=.5,o.autoCalcShadowZBounds=!1,o.autoUpdateExtends=!1,o.shadowMaxZ=60,o.shadowMinZ=-30,o.orthoTop=54,o.orthoBottom=-3,o.orthoLeft=-30,o.orthoRight=30,o.shadowOrthoScale=0;const a=new Se.o(1024,o,!0,i);a.transparencyShadow=!0,a.usePercentageCloserFiltering=!0,a.forceBackFacesOnly=!1,a.bias=.01,a.filteringQuality=Se.o.QUALITY_MEDIUM,a.frustumEdgeFalloff=.1,(0,Ce.km)("ground1",{width:100,height:100,subdivisions:2,updatable:!1},r).receiveShadows=!0;const l=new Fe.e("default",!0,r);l.samples=4,l.fxaaEnabled=!0,l.imageProcessingEnabled=!1;const d=new he(r),h=async e=>{if(y)return;if(null!==g){for(const e of g.metadata.meshes)a.removeShadowCaster(e);g.dispose(!1,!0),g=null}y=!0,t.displayLoadingUI();const i=e.webkitRelativePath;R.textContent=e.name,g=await(0,I.kS)(e,r,{onProgress:n=>t.loadingUIText=`


Loading (${e.name})... ${n.loaded}/${n.total} (${Math.floor(100*n.loaded/n.total)}%)`,rootUrl:i.substring(0,i.lastIndexOf("/")+1),pluginOptions:{mmdmodel:{materialBuilder:n,buildSkeleton:!0,buildMorph:!0,boundingBoxMargin:0,preserveSerializationData:$.checked,loggingEnabled:!0,referenceFiles:E}}}).then((e=>{e.addAllToScene();const t=e.meshes[0];return Ue.OverrideComputeTransformMatrices(t.metadata.skeleton),t.metadata.skeleton?._markAsDirty(),t}));{const e=g.metadata.meshes;for(let t=0;te.material===r));for(const e of t)if(await d.hasFragmentsOnlyOpaqueOnGeometry(i,e,null)){f[n]=!1;break}}else f[n]=!1;m[n]=r.transparencyMode??-1}}G(),t.hideLoadingUI(),setTimeout((()=>y=!1),1500)};let c=null,g=null;const f=[],m=[];let x="Alpha Mode",y=!1;const A=e=>{if(null===g)return;const t=g.metadata.materials;if("Alpha Mode"===e)for(let e=0;e{F.style.backgroundColor="#444444",B.style.backgroundColor="#111111",V.style.display="block",U.style.display="block",D.style.display="block",L.style.display="none",q.style.display="none",K.style.display="none"},C.appendChild(F);const B=document.createElement("div");B.textContent="Fix Material",B.style.width="100%",B.style.height="auto",B.style.border="none",B.style.backgroundColor="#111111",B.style.fontSize="20px",B.style.textAlign="center",B.style.color="white",B.style.cursor="pointer",B.onclick=()=>{F.style.backgroundColor="#111111",B.style.backgroundColor="#444444",V.style.display="none",U.style.display="none",D.style.display="none",L.style.display="flex",q.style.display="block",K.style.display="block"},C.appendChild(B);const R=document.createElement("div");R.textContent="No PMX file selected",R.style.width="350px",R.style.height="auto",R.style.fontSize="18px",R.style.marginBottom="10px",R.style.border="1px solid black",R.style.boxSizing="border-box",R.style.padding="10px",R.style.overflow="scroll",v.appendChild(R);const U=document.createElement("div");U.textContent="Files",U.style.width="100%",U.style.height="auto",U.style.fontSize="18px",U.style.backgroundColor="#444444",U.style.color="white",U.style.padding="2px 5px",U.style.boxSizing="border-box",v.appendChild(U);const D=document.createElement("div");D.style.width="350px",D.style.flexGrow="1",D.style.overflow="auto",D.style.marginBottom="10px",D.style.border="1px solid black",D.style.boxSizing="border-box",v.appendChild(D);const P=document.createElement("ul");P.style.height="auto",P.style.fontSize="16px",D.appendChild(P);const k=()=>{P.innerHTML="";for(const e of E){const t=document.createElement("li");t.style.whiteSpace="nowrap";const n=e.webkitRelativePath;t.textContent=n.substring(n.indexOf("/")+1),(e.name.endsWith(".pmx")||e.name.endsWith(".pmd"))&&(t.style.color="blue",t.style.cursor="pointer",t.style.textDecoration="underline",t.onclick=()=>{c=e,h(e)}),P.appendChild(t)}},V=document.createElement("input");V.style.width="100%",V.style.minHeight="80px",V.style.display="block",V.style.backgroundColor="black",V.style.color="white",V.style.marginBottom="10px",V.style.fontSize="20px",V.type="file",V.setAttribute("directory",""),V.setAttribute("webkitdirectory",""),V.setAttribute("allowdirs",""),V.ondragover=e=>{e.preventDefault()},V.ondrop=async e=>{e.preventDefault();const t=e.dataTransfer.items;if(!t)return;const n=[];for(let e=0;e{r.file(e,t)}));""===i.webkitRelativePath&&(Object.defineProperty(i,"webkitRelativePath",{writable:!0}),i.webkitRelativePath=r.fullPath),t.push(i)}return t}(r),k()},V.onchange=()=>{null!==V.files&&(E=Array.from(V.files),k())},v.appendChild(V);const L=document.createElement("div");L.style.width="100%",L.style.height="auto",L.style.display="flex",L.style.flexDirection="row",L.style.justifyContent="space-between",v.appendChild(L);const O=document.createElement("button");O.textContent="Alpha Mode",O.style.flexGrow="1",O.style.height="auto",O.style.border="none",O.style.fontSize="16px",O.style.backgroundColor="#444444",O.style.color="white",O.style.cursor="pointer",O.onclick=()=>{"Alpha Mode"!==x&&(O.style.backgroundColor="#444444",W.style.backgroundColor="#111111",x="Alpha Mode",A(x),G())},L.appendChild(O);const W=document.createElement("button");W.textContent="Force Depth Write Mode",W.style.flexGrow="1",W.style.height="auto",W.style.border="none",W.style.fontSize="16px",W.style.backgroundColor="#111111",W.style.color="white",W.style.cursor="pointer",W.onclick=()=>{"Force Depth Write Mode"!==x&&(O.style.backgroundColor="#111111",W.style.backgroundColor="#444444",x="Force Depth Write Mode",A(x),G())},L.appendChild(W);const q=document.createElement("div");q.textContent="Materials",q.style.width="100%",q.style.height="auto",q.style.fontSize="18px",q.style.backgroundColor="#444444",q.style.color="white",q.style.padding="2px 5px",q.style.boxSizing="border-box",v.appendChild(q);const K=document.createElement("div");K.style.width="350px",K.style.flexGrow="1",K.style.overflow="auto",K.style.marginBottom="10px",K.style.border="1px solid black",K.style.boxSizing="border-box",v.appendChild(K);const H=document.createElement("ol");H.start=0,H.style.height="auto",H.style.fontSize="16px",K.appendChild(H);const G=()=>{if(H.innerHTML="",null===g)return;const e=g.metadata.meshes;for(let n=0;n{null===r.transparencyMode&&(r.transparencyMode=0),r.transparencyMode=(r.transparencyMode+1)%3,m[s]=r.transparencyMode,e.textContent=t(r.transparencyMode??0)},i.appendChild(e)}else{const e=document.createElement("button");e.style.float="right",e.style.width="100px",e.style.height="auto",e.style.fontSize="14px",e.style.marginRight="10px",e.style.border="none",e.textContent=r.transparencyMode===N.i.MATERIAL_OPAQUE?"Opaque":"Alpha Blend";const t=n;e.onclick=()=>{r.transparencyMode=r.transparencyMode===N.i.MATERIAL_OPAQUE?N.i.MATERIAL_ALPHABLEND:N.i.MATERIAL_OPAQUE,f[t]=r.transparencyMode===N.i.MATERIAL_ALPHABLEND,e.textContent=r.transparencyMode===N.i.MATERIAL_OPAQUE?"Opaque":"Alpha Blend"},i.appendChild(e)}H.appendChild(i)}function t(e){switch(e){case N.i.MATERIAL_OPAQUE:return"Opaque";case N.i.MATERIAL_ALPHATEST:return"Alpha Test";case N.i.MATERIAL_ALPHABLEND:return"Alpha Blend";default:return"Unknown"}}},Q=document.createElement("div");Q.style.width="100%",Q.style.height="auto",Q.style.display="flex",Q.style.flexDirection="column",Q.style.justifyContent="center",Q.style.alignItems="center",Q.style.marginBottom="10px",Q.style.border="1px solid black",Q.style.padding="20px",Q.style.boxSizing="border-box",v.appendChild(Q);const X=document.createElement("div");X.style.width="100%",X.style.height="30px",X.style.display="flex",X.style.flexDirection="row",X.style.justifyContent="space-between",X.style.alignItems="center",X.style.marginBottom="10px",Q.appendChild(X);const Y=document.createElement("label");Y.textContent="Preserve Serialization Data",Y.title="If enabled, the converted file will be larger, but the converted file will be able to be converted back to PMX without any loss of data in technically(currently BPMX to PMX conversion is not supported).",Y.style.textAlign="left",Y.style.marginRight="10px",Y.style.fontSize="16px",X.appendChild(Y);const j=document.createElement("label");j.textContent="(reload required)",j.style.fontSize="11px",j.style.color="gray",j.style.flexGrow="1",X.appendChild(j);const $=document.createElement("input");$.style.width="16px",$.style.height="16px",$.type="checkbox",$.checked=!0,X.appendChild($),$.onclick=e=>{y?e.preventDefault():null!==c&&h(c)};const J=document.createElement("div");J.style.width="100%",J.style.height="30px",J.style.display="flex",J.style.flexDirection="row",J.style.justifyContent="space-between",J.style.alignItems="center",J.style.marginBottom="10px",Q.appendChild(J);const Z=document.createElement("label");Z.textContent="Build Skeleton",Z.title="If your model don't need to be animated by skeleton(e.g. stage model), you can disable this option to reduce the size of the converted file. also, it can improve the performance of the converted model.",Z.style.textAlign="left",Z.style.marginRight="10px",Z.style.fontSize="16px",Z.style.flexGrow="1",J.appendChild(Z);const ee=document.createElement("input");ee.style.width="16px",ee.style.height="16px",ee.type="checkbox",ee.checked=!0,J.appendChild(ee);const te=document.createElement("div");te.style.width="100%",te.style.height="30px",te.style.display="flex",te.style.flexDirection="row",te.style.justifyContent="space-between",te.style.alignItems="center",te.style.marginBottom="10px",Q.appendChild(te);const ne=document.createElement("label");ne.textContent="Build Morph",ne.title="If your model don't need to be animated by morph targets(e.g. stage model), you can disable this option to reduce the size of the converted file. also, it can improve the performance of the converted model.",ne.style.textAlign="left",ne.style.marginRight="10px",ne.style.fontSize="16px",ne.style.flexGrow="1",te.appendChild(ne);const re=document.createElement("input");re.style.width="16px",re.style.height="16px",re.type="checkbox",re.checked=!0,te.appendChild(re);const ie=document.createElement("div");ie.style.width="100%",ie.style.height="auto",ie.style.display="flex",ie.style.flexDirection="row",ie.style.justifyContent="space-between",ie.style.alignItems="center",v.appendChild(ie);const se=document.createElement("button");return se.textContent="Convert",se.style.width="100%",se.style.height="60px",se.style.border="none",se.style.fontSize="20px",ie.appendChild(se),se.onclick=async()=>{if(y)return;if(null===c)return;if(null===g)return;y=!0,t.displayLoadingUI(),t.loadingUIText=`


Converting (${c.name})...`;const e=w.convert(g,{includeSkinningData:ee.checked,includeMorphData:re.checked,translucentMaterials:f,alphaEvaluateResults:m}),n=new Blob([e],{type:"application/octet-stream"}),r=URL.createObjectURL(n),i=document.createElement("a");i.href=r,i.download=`${c.name.substring(0,c.name.lastIndexOf("."))}.bpmx`,i.click(),URL.revokeObjectURL(r),i.remove(),await new Promise((e=>{setTimeout((()=>{t.hideLoadingUI(),e()}),1500)})),y=!1},F.click(),t.resize(!0),r}}}).then((e=>e.run()))}},i={};function s(e){var t=i[e];if(void 0!==t)return t.exports;var n=i[e]={exports:{}};return r[e](n,n.exports,s),n.exports}s.m=r,e=[],s.O=(t,n,r,i)=>{if(!n){var o=1/0;for(h=0;h=i)&&Object.keys(s.O).every((e=>s.O[e](n[l])))?n.splice(l--,1):(a=!1,i0&&e[h-1][2]>i;h--)e[h]=e[h-1];e[h]=[n,r,i]},s.d=(e,t)=>{for(var n in t)s.o(t,n)&&!s.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},s.f={},s.e=e=>Promise.all(Object.keys(s.f).reduce(((t,n)=>(s.f[n](e,t),t)),[])),s.u=e=>(({71:"glslShaders",126:"wgslShaders"}[e]||e)+".bundle.js"),s.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),t={},n="babylon-mmd:",s.l=(e,r,i,o)=>{if(t[e])t[e].push(r);else{var a,l;if(void 0!==i)for(var d=document.getElementsByTagName("script"),h=0;h{a.onerror=a.onload=null,clearTimeout(p);var i=t[e];if(delete t[e],a.parentNode&&a.parentNode.removeChild(a),i&&i.forEach((e=>e(r))),n)return n(r)},p=setTimeout(u.bind(null,void 0,{type:"timeout",target:a}),12e4);a.onerror=u.bind(null,a.onerror),a.onload=u.bind(null,a.onload),l&&document.head.appendChild(a)}},s.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e;s.g.importScripts&&(e=s.g.location+"");var t=s.g.document;if(!e&&t&&(t.currentScript&&"SCRIPT"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var n=t.getElementsByTagName("script");if(n.length)for(var r=n.length-1;r>-1&&(!e||!/^http(s?):/.test(e));)e=n[r--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),s.p=e})(),(()=>{var e={792:0};s.f.j=(t,n)=>{var r=s.o(e,t)?e[t]:void 0;if(0!==r)if(r)n.push(r[2]);else{var i=new Promise(((n,i)=>r=e[t]=[n,i]));n.push(r[2]=i);var o=s.p+s.u(t),a=new Error;s.l(o,(n=>{if(s.o(e,t)&&(0!==(r=e[t])&&(e[t]=void 0),r)){var i=n&&("load"===n.type?"missing":n.type),o=n&&n.target&&n.target.src;a.message="Loading chunk "+t+" failed.\n("+i+": "+o+")",a.name="ChunkLoadError",a.type=i,a.request=o,r[1](a)}}),"chunk-"+t,t)}},s.O.j=t=>0===e[t];var t=(t,n)=>{var r,i,[o,a,l]=n,d=0;if(o.some((t=>0!==e[t]))){for(r in a)s.o(a,r)&&(s.m[r]=a[r]);if(l)var h=l(s)}for(t&&t(n);ds(8822)));o=s.O(o)})(); \ No newline at end of file +"use strict";(self.webpackChunkbabylon_mmd=self.webpackChunkbabylon_mmd||[]).push([[833],{7540:(e,t,s)=>{s.d(t,{X5:()=>b});var i=s(9923),r=s(6041),n=s(4867),a=s(6552),o=s(6227),h=s(4870),l=s(521),c=s(2366),u=s(6877);const d=Object.freeze(new i.PT(0,0,0,0)),_=Object.freeze(i.Pq.Zero()),f=Object.freeze(i.I9.Zero()),p=Object.freeze(l.o.Zero()),g=Object.freeze(r.v9.Black()),m=Object.freeze(new r.ov(0,0,0,0)),T={key:0,repeatCount:0,loopMode:2};class b{static _PrepareAnimation(e,t,s,n,a,o,h,c){let u;if(!isNaN(parseFloat(a))&&isFinite(a)?u=b.ANIMATIONTYPE_FLOAT:a instanceof i.PT?u=b.ANIMATIONTYPE_QUATERNION:a instanceof i.Pq?u=b.ANIMATIONTYPE_VECTOR3:a instanceof i.I9?u=b.ANIMATIONTYPE_VECTOR2:a instanceof r.v9?u=b.ANIMATIONTYPE_COLOR3:a instanceof r.ov?u=b.ANIMATIONTYPE_COLOR4:a instanceof l.o&&(u=b.ANIMATIONTYPE_SIZE),null==u)return null;const d=new b(e,t,s,u,h),_=[{frame:0,value:a},{frame:n,value:o}];return d.setKeys(_),void 0!==c&&d.setEasingFunction(c),d}static CreateAnimation(e,t,s,i){const r=new b(e+"Animation",e,s,t,b.ANIMATIONLOOPMODE_CONSTANT);return r.setEasingFunction(i),r}static CreateAndStartAnimation(e,t,s,i,r,n,a,o,h,l,c){const u=b._PrepareAnimation(e,s,i,r,n,a,o,h);return u?(t.getScene&&(c=t.getScene()),c?c.beginDirectAnimation(t,[u],0,r,1===u.loopMode,1,l):null):null}static CreateAndStartHierarchyAnimation(e,t,s,i,r,n,a,o,h,l,c){const u=b._PrepareAnimation(e,i,r,n,a,o,h,l);return u?t.getScene().beginDirectHierarchyAnimation(t,s,[u],0,n,1===u.loopMode,1,c):null}static CreateMergeAndStartAnimation(e,t,s,i,r,n,a,o,h,l){const c=b._PrepareAnimation(e,s,i,r,n,a,o,h);return c?(t.animations.push(c),t.getScene().beginAnimation(t,0,r,1===c.loopMode,1,l)):null}static MakeAnimationAdditive(e,t,s,r=!1,n){let a;a="object"==typeof t?t:{referenceFrame:t??0,range:s,cloneOriginalAnimation:r,clonedAnimationName:n};let o=e;if(a.cloneOriginalAnimation&&(o=e.clone(),o.name=a.clonedAnimationName||o.name),!o._keys.length)return o;const h=a.referenceFrame&&a.referenceFrame>=0?a.referenceFrame:0;let l=0;const c=o._keys[0];let u=o._keys.length-1;const d=o._keys[u],_={referenceValue:c.value,referencePosition:i.AA.Vector3[0],referenceQuaternion:i.AA.Quaternion[0],referenceScaling:i.AA.Vector3[1],keyPosition:i.AA.Vector3[2],keyQuaternion:i.AA.Quaternion[1],keyScaling:i.AA.Vector3[3]};let f=c.frame,p=d.frame;if(a.range){const e=o.getRange(a.range);e&&(f=e.from,p=e.to)}else f=a.fromFrame??f,p=a.toFrame??p;if(f!==c.frame&&(l=o.createKeyForFrame(f)),p!==d.frame&&(u=o.createKeyForFrame(p)),1===o._keys.length){const e=o._getKeyValue(o._keys[0]);_.referenceValue=e.clone?e.clone():e}else if(h<=c.frame){const e=o._getKeyValue(c.value);_.referenceValue=e.clone?e.clone():e}else if(h>=d.frame){const e=o._getKeyValue(d.value);_.referenceValue=e.clone?e.clone():e}else{T.key=0;const e=o._interpolate(h,T);_.referenceValue=e.clone?e.clone():e}o.dataType===b.ANIMATIONTYPE_QUATERNION?_.referenceValue.normalize().conjugateInPlace():o.dataType===b.ANIMATIONTYPE_MATRIX&&(_.referenceValue.decompose(_.referenceScaling,_.referenceQuaternion,_.referencePosition),_.referenceQuaternion.normalize().conjugateInPlace());let g=Number.MAX_VALUE;const m=a.clipKeys?[]:null;for(let e=l;e<=u;e++){let t=o._keys[e];if((m||a.cloneOriginalAnimation)&&(t={frame:t.frame,value:t.value.clone?t.value.clone():t.value,inTangent:t.inTangent,outTangent:t.outTangent,interpolation:t.interpolation,lockedTangent:t.lockedTangent},m&&(g===Number.MAX_VALUE&&(g=t.frame),t.frame-=g,m.push(t))),!e||o.dataType===b.ANIMATIONTYPE_FLOAT||t.value!==c.value)switch(o.dataType){case b.ANIMATIONTYPE_MATRIX:t.value.decompose(_.keyScaling,_.keyQuaternion,_.keyPosition),_.keyPosition.subtractInPlace(_.referencePosition),_.keyScaling.divideInPlace(_.referenceScaling),_.referenceQuaternion.multiplyToRef(_.keyQuaternion,_.keyQuaternion),i.uq.ComposeToRef(_.keyScaling,_.keyQuaternion,_.keyPosition,t.value);break;case b.ANIMATIONTYPE_QUATERNION:_.referenceValue.multiplyToRef(t.value,t.value);break;case b.ANIMATIONTYPE_VECTOR2:case b.ANIMATIONTYPE_VECTOR3:case b.ANIMATIONTYPE_COLOR3:case b.ANIMATIONTYPE_COLOR4:t.value.subtractToRef(_.referenceValue,t.value);break;case b.ANIMATIONTYPE_SIZE:t.value.width-=_.referenceValue.width,t.value.height-=_.referenceValue.height;break;default:t.value-=_.referenceValue}}return m&&o.setKeys(m,!0),o}static TransitionTo(e,t,s,i,r,n,a,o=null){if(a<=0)return s[e]=t,o&&o(),null;const h=r*(a/1e3);n.setKeys([{frame:0,value:s[e].clone?s[e].clone():s[e]},{frame:h,value:t}]),s.animations||(s.animations=[]),s.animations.push(n);const l=i.beginAnimation(s,0,h,!1);return l.onAnimationEnd=o,l}get runtimeAnimations(){return this._runtimeAnimations}get hasRunningRuntimeAnimations(){for(const e of this._runtimeAnimations)if(!e.isStopped())return!0;return!1}constructor(e,t,s,i,r,n){this.name=e,this.targetProperty=t,this.framePerSecond=s,this.dataType=i,this.loopMode=r,this.enableBlending=n,this._easingFunction=null,this._runtimeAnimations=new Array,this._events=new Array,this.blendingSpeed=.01,this._ranges={},this.targetPropertyPath=t.split("."),this.dataType=i,this.loopMode=void 0===r?b.ANIMATIONLOOPMODE_CYCLE:r,this.uniqueId=b._UniqueIdGenerator++}toString(e){let t="Name: "+this.name+", property: "+this.targetProperty;if(t+=", datatype: "+["Float","Vector3","Quaternion","Matrix","Color3","Vector2"][this.dataType],t+=", nKeys: "+(this._keys?this._keys.length:"none"),t+=", nRanges: "+(this._ranges?Object.keys(this._ranges).length:"none"),e){t+=", Ranges: {";let e=!0;for(const s in this._ranges)e&&(t+=", ",e=!1),t+=s;t+="}"}return t}addEvent(e){this._events.push(e),this._events.sort(((e,t)=>e.frame-t.frame))}removeEvents(e){for(let t=0;t=0;s--)this._keys[s].frame>=e&&this._keys[s].frame<=t&&this._keys.splice(s,1)}this._ranges[e]=null}}getRange(e){return this._ranges[e]}getKeys(){return this._keys}getHighestFrame(){let e=0;for(let t=0,s=this._keys.length;t0)return t.highLimitValue.clone?t.highLimitValue.clone():t.highLimitValue;const i=this._keys,r=i.length;let n=t.key;for(;n>=0&&e=i[n+1].frame;)++n;if(t.key=n,n<0)return s?void 0:this._getKeyValue(i[0].value);if(n+1>r-1)return s?void 0:this._getKeyValue(i[r-1].value);const a=i[n],o=i[n+1];if(s&&(e===a.frame||e===o.frame))return;const h=this._getKeyValue(a.value),l=this._getKeyValue(o.value);if(1===a.interpolation)return o.frame>e?h:l;const c=void 0!==a.outTangent&&void 0!==o.inTangent,u=o.frame-a.frame;let T=(e-a.frame)/u;const E=a.easingFunction||this.getEasingFunction();switch(null!==E&&(T=E.ease(T)),this.dataType){case b.ANIMATIONTYPE_FLOAT:{const e=c?this.floatInterpolateFunctionWithTangents(h,a.outTangent*u,l,o.inTangent*u,T):this.floatInterpolateFunction(h,l,T);switch(t.loopMode){case b.ANIMATIONLOOPMODE_CYCLE:case b.ANIMATIONLOOPMODE_CONSTANT:case b.ANIMATIONLOOPMODE_YOYO:return e;case b.ANIMATIONLOOPMODE_RELATIVE:case b.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return(t.offsetValue??0)*t.repeatCount+e}break}case b.ANIMATIONTYPE_QUATERNION:{const e=c?this.quaternionInterpolateFunctionWithTangents(h,a.outTangent.scale(u),l,o.inTangent.scale(u),T):this.quaternionInterpolateFunction(h,l,T);switch(t.loopMode){case b.ANIMATIONLOOPMODE_CYCLE:case b.ANIMATIONLOOPMODE_CONSTANT:case b.ANIMATIONLOOPMODE_YOYO:return e;case b.ANIMATIONLOOPMODE_RELATIVE:case b.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return e.addInPlace((t.offsetValue||d).scale(t.repeatCount))}return e}case b.ANIMATIONTYPE_VECTOR3:{const e=c?this.vector3InterpolateFunctionWithTangents(h,a.outTangent.scale(u),l,o.inTangent.scale(u),T):this.vector3InterpolateFunction(h,l,T);switch(t.loopMode){case b.ANIMATIONLOOPMODE_CYCLE:case b.ANIMATIONLOOPMODE_CONSTANT:case b.ANIMATIONLOOPMODE_YOYO:return e;case b.ANIMATIONLOOPMODE_RELATIVE:case b.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return e.add((t.offsetValue||_).scale(t.repeatCount))}break}case b.ANIMATIONTYPE_VECTOR2:{const e=c?this.vector2InterpolateFunctionWithTangents(h,a.outTangent.scale(u),l,o.inTangent.scale(u),T):this.vector2InterpolateFunction(h,l,T);switch(t.loopMode){case b.ANIMATIONLOOPMODE_CYCLE:case b.ANIMATIONLOOPMODE_CONSTANT:case b.ANIMATIONLOOPMODE_YOYO:return e;case b.ANIMATIONLOOPMODE_RELATIVE:case b.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return e.add((t.offsetValue||f).scale(t.repeatCount))}break}case b.ANIMATIONTYPE_SIZE:switch(t.loopMode){case b.ANIMATIONLOOPMODE_CYCLE:case b.ANIMATIONLOOPMODE_CONSTANT:case b.ANIMATIONLOOPMODE_YOYO:return this.sizeInterpolateFunction(h,l,T);case b.ANIMATIONLOOPMODE_RELATIVE:case b.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return this.sizeInterpolateFunction(h,l,T).add((t.offsetValue||p).scale(t.repeatCount))}break;case b.ANIMATIONTYPE_COLOR3:{const e=c?this.color3InterpolateFunctionWithTangents(h,a.outTangent.scale(u),l,o.inTangent.scale(u),T):this.color3InterpolateFunction(h,l,T);switch(t.loopMode){case b.ANIMATIONLOOPMODE_CYCLE:case b.ANIMATIONLOOPMODE_CONSTANT:case b.ANIMATIONLOOPMODE_YOYO:return e;case b.ANIMATIONLOOPMODE_RELATIVE:case b.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return e.add((t.offsetValue||g).scale(t.repeatCount))}break}case b.ANIMATIONTYPE_COLOR4:{const e=c?this.color4InterpolateFunctionWithTangents(h,a.outTangent.scale(u),l,o.inTangent.scale(u),T):this.color4InterpolateFunction(h,l,T);switch(t.loopMode){case b.ANIMATIONLOOPMODE_CYCLE:case b.ANIMATIONLOOPMODE_CONSTANT:case b.ANIMATIONLOOPMODE_YOYO:return e;case b.ANIMATIONLOOPMODE_RELATIVE:case b.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return e.add((t.offsetValue||m).scale(t.repeatCount))}break}case b.ANIMATIONTYPE_MATRIX:switch(t.loopMode){case b.ANIMATIONLOOPMODE_CYCLE:case b.ANIMATIONLOOPMODE_CONSTANT:case b.ANIMATIONLOOPMODE_YOYO:return b.AllowMatricesInterpolation?this.matrixInterpolateFunction(h,l,T,t.workValue):h;case b.ANIMATIONLOOPMODE_RELATIVE:case b.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return h}}return 0}matrixInterpolateFunction(e,t,s,r){return b.AllowMatrixDecomposeForInterpolation?r?(i.uq.DecomposeLerpToRef(e,t,s,r),r):i.uq.DecomposeLerp(e,t,s):r?(i.uq.LerpToRef(e,t,s,r),r):i.uq.Lerp(e,t,s)}clone(){const e=new b(this.name,this.targetPropertyPath.join("."),this.framePerSecond,this.dataType,this.loopMode);if(e.enableBlending=this.enableBlending,e.blendingSpeed=this.blendingSpeed,this._keys&&e.setKeys(this._keys),this._ranges){e._ranges={};for(const t in this._ranges){const s=this._ranges[t];s&&(e._ranges[t]=s.clone())}}return e}setKeys(e,t=!1){this._keys=t?e:e.slice(0)}createKeyForFrame(e){T.key=0;const t=this._interpolate(e,T,!0);if(!t)return this._keys[T.key].frame===e?T.key:T.key+1;const s={frame:e,value:t.clone?t.clone():t};return this._keys.splice(T.key+1,0,s),T.key+1}serialize(){const e={};e.name=this.name,e.property=this.targetProperty,e.framePerSecond=this.framePerSecond,e.dataType=this.dataType,e.loopBehavior=this.loopMode,e.enableBlending=this.enableBlending,e.blendingSpeed=this.blendingSpeed;const t=this.dataType;e.keys=[];const s=this.getKeys();for(let i=0;i=2&&(h=t.values[1]),t.values.length>=3&&(l=t.values[2]),t.values.length>=4&&(c=t.values[3]);break;case b.ANIMATIONTYPE_QUATERNION:if(a=i.PT.FromArray(t.values),t.values.length>=8){const e=i.PT.FromArray(t.values.slice(4,8));e.equals(i.PT.Zero())||(h=e)}if(t.values.length>=12){const e=i.PT.FromArray(t.values.slice(8,12));e.equals(i.PT.Zero())||(l=e)}t.values.length>=13&&(c=t.values[12]);break;case b.ANIMATIONTYPE_MATRIX:a=i.uq.FromArray(t.values),t.values.length>=17&&(c=t.values[16]);break;case b.ANIMATIONTYPE_COLOR3:a=r.v9.FromArray(t.values),t.values[3]&&(h=r.v9.FromArray(t.values[3])),t.values[4]&&(l=r.v9.FromArray(t.values[4])),t.values[5]&&(c=t.values[5]);break;case b.ANIMATIONTYPE_COLOR4:a=r.ov.FromArray(t.values),t.values[4]&&(h=r.ov.FromArray(t.values[4])),t.values[5]&&(l=r.ov.FromArray(t.values[5])),t.values[6]&&(c=r.ov.FromArray(t.values[6]));break;case b.ANIMATIONTYPE_VECTOR3:default:a=i.Pq.FromArray(t.values),t.values[3]&&(h=i.Pq.FromArray(t.values[3])),t.values[4]&&(l=i.Pq.FromArray(t.values[4])),t.values[5]&&(c=t.values[5])}const u={};u.frame=t.frame,u.value=a,null!=h&&(u.inTangent=h),null!=l&&(u.outTangent=l),null!=c&&(u.interpolation=c),n.push(u)}if(t.setKeys(n),e.ranges)for(o=0;o{const r=new c.u;r.addEventListener("readystatechange",(()=>{if(4==r.readyState)if(200==r.status){let t=JSON.parse(r.responseText);if(t.animations&&(t=t.animations),t.length){const e=[];for(const s of t)e.push(this.Parse(s));s(e)}else{const i=this.Parse(t);e&&(i.name=e),s(i)}}else i("Unable to load the animation")})),r.open("GET",t),r.send()}))}static ParseFromSnippetAsync(e){return new Promise(((t,s)=>{const i=new c.u;i.addEventListener("readystatechange",(()=>{if(4==i.readyState)if(200==i.status){const s=JSON.parse(JSON.parse(i.responseText).jsonPayload);if(s.animations){const i=JSON.parse(s.animations),r=[];for(const t of i.animations){const s=this.Parse(t);s.snippetId=e,r.push(s)}t(r)}else{const i=JSON.parse(s.animation),r=this.Parse(i);r.snippetId=e,t(r)}}else s("Unable to load the snippet "+e)})),i.open("GET",this.SnippetUrl+"/"+e.replace(/#/g,"/")),i.send()}))}}b._UniqueIdGenerator=0,b.AllowMatricesInterpolation=!1,b.AllowMatrixDecomposeForInterpolation=!0,b.SnippetUrl="https://snippet.babylonjs.com",b.ANIMATIONTYPE_FLOAT=0,b.ANIMATIONTYPE_VECTOR3=1,b.ANIMATIONTYPE_QUATERNION=2,b.ANIMATIONTYPE_MATRIX=3,b.ANIMATIONTYPE_COLOR3=4,b.ANIMATIONTYPE_COLOR4=7,b.ANIMATIONTYPE_VECTOR2=5,b.ANIMATIONTYPE_SIZE=6,b.ANIMATIONLOOPMODE_RELATIVE=0,b.ANIMATIONLOOPMODE_CYCLE=1,b.ANIMATIONLOOPMODE_CONSTANT=2,b.ANIMATIONLOOPMODE_YOYO=4,b.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT=5,b.CreateFromSnippetAsync=b.ParseFromSnippetAsync,(0,a.Y5)("BABYLON.Animation",b),h.b._AnimationRangeFactory=(e,t,s)=>new o.K(e,t,s)},6227:(e,t,s)=>{s.d(t,{K:()=>i});class i{constructor(e,t,s){this.name=e,this.from=t,this.to=s}clone(){return new i(this.name,this.from,this.to)}}},6504:(e,t,s)=>{s.d(t,{$:()=>a});var i=s(9923),r=s(7309),n=s(4870);class a extends n.b{get _matrix(){return this._compose(),this._localMatrix}set _matrix(e){(e.updateFlag!==this._localMatrix.updateFlag||this._needToCompose)&&(this._needToCompose=!1,this._localMatrix.copyFrom(e),this._markAsDirtyAndDecompose())}constructor(e,t,s=null,r=null,n=null,a=null,o=null){super(e,t.getScene(),!1),this.name=e,this.children=[],this.animations=[],this._index=null,this._scalingDeterminant=1,this._needToDecompose=!0,this._needToCompose=!1,this._linkedTransformNode=null,this._waitingTransformNodeId=null,this._skeleton=t,this._localMatrix=r?.clone()??i.uq.Identity(),this._restMatrix=n??this._localMatrix.clone(),this._bindMatrix=a??this._localMatrix.clone(),this._index=o,this._absoluteMatrix=new i.uq,this._absoluteBindMatrix=new i.uq,this._absoluteInverseBindMatrix=new i.uq,this._finalMatrix=new i.uq,t.bones.push(this),this.setParent(s,!1),this._updateAbsoluteBindMatrices()}getClassName(){return"Bone"}getSkeleton(){return this._skeleton}get parent(){return this._parentNode}getParent(){return this.parent}getChildren(){return this.children}getIndex(){return null===this._index?this.getSkeleton().bones.indexOf(this):this._index}set parent(e){this.setParent(e)}setParent(e,t=!0){if(this.parent!==e){if(this.parent){const e=this.parent.children.indexOf(this);-1!==e&&this.parent.children.splice(e,1)}this._parentNode=e,this.parent&&this.parent.children.push(this),t&&this._updateAbsoluteBindMatrices(),this.markAsDirty()}}getLocalMatrix(){return this._compose(),this._localMatrix}getBindMatrix(){return this._bindMatrix}getBaseMatrix(){return this.getBindMatrix()}getRestMatrix(){return this._restMatrix}getRestPose(){return this.getRestMatrix()}setRestMatrix(e){this._restMatrix.copyFrom(e)}setRestPose(e){this.setRestMatrix(e)}getBindPose(){return this.getBindMatrix()}setBindMatrix(e){this.updateMatrix(e)}setBindPose(e){this.setBindMatrix(e)}getFinalMatrix(){return this._finalMatrix}getWorldMatrix(){return this.getFinalMatrix()}returnToRest(){if(this._linkedTransformNode){const e=i.AA.Vector3[0],t=i.AA.Quaternion[0],s=i.AA.Vector3[1];this.getRestMatrix().decompose(e,t,s),this._linkedTransformNode.position.copyFrom(s),this._linkedTransformNode.rotationQuaternion=this._linkedTransformNode.rotationQuaternion??i.PT.Identity(),this._linkedTransformNode.rotationQuaternion.copyFrom(t),this._linkedTransformNode.scaling.copyFrom(e)}else this._matrix=this._restMatrix}getAbsoluteInverseBindMatrix(){return this._absoluteInverseBindMatrix}getInvertedAbsoluteTransform(){return this.getAbsoluteInverseBindMatrix()}getAbsoluteMatrix(){return this._absoluteMatrix}getAbsoluteTransform(){return this._absoluteMatrix}linkTransformNode(e){this._linkedTransformNode&&this._skeleton._numBonesWithLinkedTransformNode--,this._linkedTransformNode=e,this._linkedTransformNode&&this._skeleton._numBonesWithLinkedTransformNode++}getTransformNode(){return this._linkedTransformNode}get position(){return this._decompose(),this._localPosition}set position(e){this._decompose(),this._localPosition.copyFrom(e),this._markAsDirtyAndCompose()}get rotation(){return this.getRotation()}set rotation(e){this.setRotation(e)}get rotationQuaternion(){return this._decompose(),this._localRotation}set rotationQuaternion(e){this.setRotationQuaternion(e)}get scaling(){return this.getScale()}set scaling(e){this.setScale(e)}get animationPropertiesOverride(){return this._skeleton.animationPropertiesOverride}_decompose(){this._needToDecompose&&(this._needToDecompose=!1,this._localScaling||(this._localScaling=i.Pq.Zero(),this._localRotation=i.PT.Zero(),this._localPosition=i.Pq.Zero()),this._localMatrix.decompose(this._localScaling,this._localRotation,this._localPosition))}_compose(){this._needToCompose&&(this._localScaling?(this._needToCompose=!1,i.uq.ComposeToRef(this._localScaling,this._localRotation,this._localPosition,this._localMatrix)):this._needToCompose=!1)}updateMatrix(e,t=!0,s=!0){this._bindMatrix.copyFrom(e),t&&this._updateAbsoluteBindMatrices(),s?this._matrix=e:this.markAsDirty()}_updateAbsoluteBindMatrices(e,t=!0){if(e||(e=this._bindMatrix),this.parent?e.multiplyToRef(this.parent._absoluteBindMatrix,this._absoluteBindMatrix):this._absoluteBindMatrix.copyFrom(e),this._absoluteBindMatrix.invertToRef(this._absoluteInverseBindMatrix),t)for(let e=0;e{s.d(t,{E:()=>_});var i=s(6504),r=s(9848),n=s(9923),a=s(2781);class o extends a.g{constructor(e,t,s,i,r,n=!0,o=!1,h=3,l=0,c,u){super(null,r,!n,o,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,c),this.format=i,this._engine&&(this._engine._caps.textureFloatLinearFiltering||1!==l||(h=1),this._engine._caps.textureHalfFloatLinearFiltering||2!==l||(h=1),this._texture=this._engine.createRawTexture(e,t,s,i,n,o,h,null,l,c??0,u??!1),this.wrapU=a.g.CLAMP_ADDRESSMODE,this.wrapV=a.g.CLAMP_ADDRESSMODE)}update(e){this._getEngine().updateRawTexture(this._texture,e,this._texture.format,this._texture.invertY,null,this._texture.type,this._texture._useSRGBBuffer)}clone(){if(!this._texture)return super.clone();const e=new o(null,this.getSize().width,this.getSize().height,this.format,this.getScene(),this._texture.generateMipMaps,this._invertY,this.samplingMode,this._texture.type,this._texture._creationFlags,this._useSRGBBuffer);return e._texture=this._texture,this._texture.incrementReferences(),e}static CreateLuminanceTexture(e,t,s,i,r=!0,n=!1,a=3){return new o(e,t,s,1,i,r,n,a)}static CreateLuminanceAlphaTexture(e,t,s,i,r=!0,n=!1,a=3){return new o(e,t,s,2,i,r,n,a)}static CreateAlphaTexture(e,t,s,i,r=!0,n=!1,a=3){return new o(e,t,s,0,i,r,n,a)}static CreateRGBTexture(e,t,s,i,r=!0,n=!1,a=3,h=0,l=0,c=!1){return new o(e,t,s,4,i,r,n,a,h,l,c)}static CreateRGBATexture(e,t,s,i,r=!0,n=!1,a=3,h=0,l=0,c=!1){return new o(e,t,s,5,i,r,n,a,h,l,c)}static CreateRGBAStorageTexture(e,t,s,i,r=!0,n=!1,a=3,h=0,l=!1){return new o(e,t,s,5,i,r,n,a,h,1,l)}static CreateRTexture(e,t,s,i,r=!0,n=!1,h=a.g.TRILINEAR_SAMPLINGMODE,l=1){return new o(e,t,s,6,i,r,n,h,l)}static CreateRStorageTexture(e,t,s,i,r=!0,n=!1,h=a.g.TRILINEAR_SAMPLINGMODE,l=1){return new o(e,t,s,6,i,r,n,h,l,1)}}var h=s(7540),l=s(6227),c=s(6315),u=s(1137),d=s(4609);class _{get useTextureToStoreBoneMatrices(){return this._useTextureToStoreBoneMatrices}set useTextureToStoreBoneMatrices(e){this._useTextureToStoreBoneMatrices=e,this._markAsDirty()}get animationPropertiesOverride(){return this._animationPropertiesOverride?this._animationPropertiesOverride:this._scene.animationPropertiesOverride}set animationPropertiesOverride(e){this._animationPropertiesOverride=e}get isUsingTextureForMatrices(){return this.useTextureToStoreBoneMatrices&&this._canUseTextureForBones}get uniqueId(){return this._uniqueId}constructor(e,t,s){this.name=e,this.id=t,this.bones=[],this.needInitialSkinMatrix=!1,this._isDirty=!0,this._meshesWithPoseMatrix=new Array,this._identity=n.uq.Identity(),this._currentRenderId=-1,this._ranges={},this._absoluteTransformIsDirty=!0,this._canUseTextureForBones=!1,this._uniqueId=0,this._numBonesWithLinkedTransformNode=0,this._hasWaitingData=null,this._parentContainer=null,this.doNotSerialize=!1,this._useTextureToStoreBoneMatrices=!0,this._animationPropertiesOverride=null,this.onBeforeComputeObservable=new r.cP,this.bones=[],this._scene=s||c.q.LastCreatedScene,this._uniqueId=this._scene.getUniqueId(),this._scene.addSkeleton(this),this._isDirty=!0;const i=this._scene.getEngine().getCaps();this._canUseTextureForBones=i.textureFloat&&i.maxVertexTextureImageUnits>0}getClassName(){return"Skeleton"}getChildren(){return this.bones.filter((e=>!e.getParent()))}getTransformMatrices(e){if(this.needInitialSkinMatrix){if(!e)throw new Error("getTransformMatrices: When using the needInitialSkinMatrix flag, a mesh must be provided");return e._bonesTransformMatrices||this.prepare(!0),e._bonesTransformMatrices}return this._transformMatrices&&!this._isDirty||this.prepare(!this._transformMatrices),this._transformMatrices}getTransformMatrixTexture(e){return this.needInitialSkinMatrix&&e._transformMatrixTexture?e._transformMatrixTexture:this._transformMatrixTexture}getScene(){return this._scene}toString(e){let t=`Name: ${this.name}, nBones: ${this.bones.length}`;if(t+=`, nAnimationRanges: ${this._ranges?Object.keys(this._ranges).length:"none"}`,e){t+=", Ranges: {";let e=!0;for(const s in this._ranges)e&&(t+=", ",e=!1),t+=s;t+="}"}return t}getBoneIndexByName(e){for(let t=0,s=this.bones.length;t-1&&this._meshesWithPoseMatrix.splice(t,1)}_computeTransformMatrices(e,t){this.onBeforeComputeObservable.notifyObservers(this);for(let s=0;s0)for(const e of this.bones)if(e._linkedTransformNode){const t=e._linkedTransformNode;e.position=t.position,t.rotationQuaternion?e.rotationQuaternion=t.rotationQuaternion:e.rotation=t.rotation,e.scaling=t.scaling}if(this.needInitialSkinMatrix)for(const e of this._meshesWithPoseMatrix){const t=e.getPoseMatrix();let s=this._isDirty;if(e._bonesTransformMatrices&&e._bonesTransformMatrices.length===16*(this.bones.length+1)||(e._bonesTransformMatrices=new Float32Array(16*(this.bones.length+1)),s=!0),s){if(this._synchronizedWithMesh!==e){this._synchronizedWithMesh=e;for(const e of this.bones)e.getParent()||(e.getBindMatrix().multiplyToRef(t,n.AA.Matrix[1]),e._updateAbsoluteBindMatrices(n.AA.Matrix[1]));if(this.isUsingTextureForMatrices){const t=4*(this.bones.length+1);e._transformMatrixTexture&&e._transformMatrixTexture.getSize().width===t||(e._transformMatrixTexture&&e._transformMatrixTexture.dispose(),e._transformMatrixTexture=o.CreateRGBATexture(e._bonesTransformMatrices,4*(this.bones.length+1),1,this._scene,!1,!1,1,1))}}this._computeTransformMatrices(e._bonesTransformMatrices,t),this.isUsingTextureForMatrices&&e._transformMatrixTexture&&e._transformMatrixTexture.update(e._bonesTransformMatrices)}}else{if(!this._isDirty)return;this._transformMatrices&&this._transformMatrices.length===16*(this.bones.length+1)||(this._transformMatrices=new Float32Array(16*(this.bones.length+1)),this.isUsingTextureForMatrices&&(this._transformMatrixTexture&&this._transformMatrixTexture.dispose(),this._transformMatrixTexture=o.CreateRGBATexture(this._transformMatrices,4*(this.bones.length+1),1,this._scene,!1,!1,1,1))),this._computeTransformMatrices(this._transformMatrices,null),this.isUsingTextureForMatrices&&this._transformMatrixTexture&&this._transformMatrixTexture.update(this._transformMatrices)}this._isDirty=!1}getAnimatables(){if(!this._animatables||this._animatables.length!==this.bones.length){this._animatables=[];for(let e=0;e{t.animations.forEach((t=>{t.enableBlending=!0,t.blendingSpeed=e}))}))}dispose(){if(this._meshesWithPoseMatrix.length=0,this.getScene().stopAnimation(this),this.getScene().removeSkeleton(this),this._parentContainer){const e=this._parentContainer.skeletons.indexOf(this);e>-1&&this._parentContainer.skeletons.splice(e,1),this._parentContainer=null}this._transformMatrixTexture&&(this._transformMatrixTexture.dispose(),this._transformMatrixTexture=null)}serialize(){const e={};e.name=this.name,e.id=this.id,this.dimensionsAtRest&&(e.dimensionsAtRest=this.dimensionsAtRest.asArray()),e.bones=[],e.needInitialSkinMatrix=this.needInitialSkinMatrix;for(let t=0;t0&&(r.animation=s.animations[0].serialize()),e.ranges=[];for(const t in this._ranges){const s=this._ranges[t];if(!s)continue;const i={};i.name=t,i.from=s.from,i.to=s.to,e.ranges.push(i)}}return e}static Parse(e,t){const s=new _(e.name,e.id,t);let r;for(e.dimensionsAtRest&&(s.dimensionsAtRest=n.Pq.FromArray(e.dimensionsAtRest)),s.needInitialSkinMatrix=e.needInitialSkinMatrix,r=0;r-1&&(o=s.bones[t.parentBoneIndex]);const l=t.rest?n.uq.FromArray(t.rest):null,c=new i.$(t.name,s,o,n.uq.FromArray(t.matrix),l,null,a);void 0!==t.id&&null!==t.id&&(c.id=t.id),t.length&&(c.length=t.length),t.metadata&&(c.metadata=t.metadata),t.animation&&c.animations.push(h.X5.Parse(t.animation)),void 0!==t.linkedTransformNodeId&&null!==t.linkedTransformNodeId&&(s._hasWaitingData=!0,c._waitingTransformNodeId=t.linkedTransformNodeId)}if(e.ranges)for(r=0;r0&&(e=this._meshesWithPoseMatrix[0].getPoseMatrix()),e}sortBones(){const e=[],t=new Array(this.bones.length);for(let s=0;s{e.setCurrentPoseAsRest()}))}}},5616:(e,t,s)=>{s.d(t,{R:()=>a,h:()=>n});var i=s(1504),r=s(1137);class n{get isDisposed(){return this._isDisposed}constructor(e,t,s,r=0,n=!1,a=!1,o=!1,h,l){this._isAlreadyOwned=!1,this._isDisposed=!1,e&&e.getScene?this._engine=e.getScene().getEngine():this._engine=e,this._updatable=s,this._instanced=a,this._divisor=h||1,this._label=l,t instanceof i.n?(this._data=null,this._buffer=t):(this._data=t,this._buffer=null),this.byteStride=o?r:r*Float32Array.BYTES_PER_ELEMENT,n||this.create()}createVertexBuffer(e,t,s,i,r,n=!1,o){const h=n?t:t*Float32Array.BYTES_PER_ELEMENT,l=i?n?i:i*Float32Array.BYTES_PER_ELEMENT:this.byteStride;return new a(this._engine,this,e,this._updatable,!0,l,void 0===r?this._instanced:r,h,s,void 0,void 0,!0,this._divisor||o)}isUpdatable(){return this._updatable}getData(){return this._data}getBuffer(){return this._buffer}getStrideSize(){return this.byteStride/Float32Array.BYTES_PER_ELEMENT}create(e=null){!e&&this._buffer||(e=e||this._data)&&(this._buffer?this._updatable&&(this._engine.updateDynamicVertexBuffer(this._buffer,e),this._data=e):this._updatable?(this._buffer=this._engine.createDynamicVertexBuffer(e,this._label),this._data=e):this._buffer=this._engine.createVertexBuffer(e,void 0,this._label))}_rebuild(){if(this._data)this._buffer=null,this.create(this._data);else{if(!this._buffer)return;if(this._buffer.capacity>0)return void(this._updatable?this._buffer=this._engine.createDynamicVertexBuffer(this._buffer.capacity,this._label):this._buffer=this._engine.createVertexBuffer(this._buffer.capacity,void 0,this._label));r.V.Warn(`Missing data for buffer "${this._label}" ${this._buffer?"(uniqueId: "+this._buffer.uniqueId+")":""}. Buffer reconstruction failed.`),this._buffer=null}}update(e){this.create(e)}updateDirectly(e,t,s,i=!1){this._buffer&&this._updatable&&(this._engine.updateDynamicVertexBuffer(this._buffer,e,i?t:t*Float32Array.BYTES_PER_ELEMENT,s?s*this.byteStride:void 0),this._data=0===t&&void 0===s?e:null)}_increaseReferences(){this._buffer&&(this._isAlreadyOwned?this._buffer.references++:this._isAlreadyOwned=!0)}dispose(){this._buffer&&this._engine._releaseBuffer(this._buffer)&&(this._isDisposed=!0,this._data=null,this._buffer=null)}}class a{get isDisposed(){return this._isDisposed}get instanceDivisor(){return this._instanceDivisor}set instanceDivisor(e){const t=0!=e;this._instanceDivisor=e,t!==this._instanced&&(this._instanced=t,this._computeHashCode())}get _maxVerticesCount(){const e=this.getData();return e?Array.isArray(e)?e.length/(this.byteStride/4)-this.byteOffset/4:(e.byteLength-this.byteOffset)/this.byteStride:0}constructor(e,t,s,i,r,o,h,l,c,u,d=!1,_=!1,f=1,p=!1){this._isDisposed=!1;let g=!1;if(this.engine=e,"object"==typeof i&&null!==i?(g=i.updatable??!1,r=i.postponeInternalCreation,o=i.stride,h=i.instanced,l=i.offset,c=i.size,u=i.type,d=i.normalized??!1,_=i.useBytes??!1,f=i.divisor??1,p=i.takeBufferOwnership??!1,this._label=i.label):g=!!i,t instanceof n?(this._buffer=t,this._ownsBuffer=p):(this._buffer=new n(e,t,g,o,r,h,_,f,this._label),this._ownsBuffer=!0),this.uniqueId=a._Counter++,this._kind=s,void 0===u){const e=this.getData();this.type=e?a.GetDataType(e):a.FLOAT}else this.type=u;const m=a.GetTypeByteLength(this.type);_?(this._size=c||(o?o/m:a.DeduceStride(s)),this.byteStride=o||this._buffer.byteStride||this._size*m,this.byteOffset=l||0):(this._size=c||o||a.DeduceStride(s),this.byteStride=o?o*m:this._buffer.byteStride||this._size*m,this.byteOffset=(l||0)*m),this.normalized=d,this._instanced=void 0!==h&&h,this._instanceDivisor=h?f:0,this._alignBuffer(),this._computeHashCode()}_computeHashCode(){this.hashCode=(this.type-5120<<0)+((this.normalized?1:0)<<3)+(this._size<<4)+((this._instanced?1:0)<<6)+(this.byteStride<<12)}_rebuild(){this._buffer?._rebuild()}getKind(){return this._kind}isUpdatable(){return this._buffer.isUpdatable()}getData(){return this._buffer.getData()}getFloatData(e,t){const s=this.getData();return s?a.GetFloatData(s,this._size,this.type,this.byteOffset,this.byteStride,this.normalized,e,t):null}getBuffer(){return this._buffer.getBuffer()}getWrapperBuffer(){return this._buffer}getStrideSize(){return this.byteStride/a.GetTypeByteLength(this.type)}getOffset(){return this.byteOffset/a.GetTypeByteLength(this.type)}getSize(e=!1){return e?this._size*a.GetTypeByteLength(this.type):this._size}getIsInstanced(){return this._instanced}getInstanceDivisor(){return this._instanceDivisor}create(e){this._buffer.create(e),this._alignBuffer()}update(e){this._buffer.update(e),this._alignBuffer()}updateDirectly(e,t,s=!1){this._buffer.updateDirectly(e,t,void 0,s),this._alignBuffer()}dispose(){this._ownsBuffer&&this._buffer.dispose(),this._isDisposed=!0}forEach(e,t){a.ForEach(this._buffer.getData(),this.byteOffset,this.byteStride,this._size,this.type,e,this.normalized,t)}_alignBuffer(){}static DeduceStride(e){switch(e){case a.UVKind:case a.UV2Kind:case a.UV3Kind:case a.UV4Kind:case a.UV5Kind:case a.UV6Kind:return 2;case a.NormalKind:case a.PositionKind:return 3;case a.ColorKind:case a.ColorInstanceKind:case a.MatricesIndicesKind:case a.MatricesIndicesExtraKind:case a.MatricesWeightsKind:case a.MatricesWeightsExtraKind:case a.TangentKind:return 4;default:throw new Error("Invalid kind '"+e+"'")}}static GetDataType(e){return e instanceof Int8Array?a.BYTE:e instanceof Uint8Array?a.UNSIGNED_BYTE:e instanceof Int16Array?a.SHORT:e instanceof Uint16Array?a.UNSIGNED_SHORT:e instanceof Int32Array?a.INT:e instanceof Uint32Array?a.UNSIGNED_INT:a.FLOAT}static GetTypeByteLength(e){switch(e){case a.BYTE:case a.UNSIGNED_BYTE:return 1;case a.SHORT:case a.UNSIGNED_SHORT:return 2;case a.INT:case a.UNSIGNED_INT:case a.FLOAT:return 4;default:throw new Error(`Invalid type '${e}'`)}}static ForEach(e,t,s,i,r,n,o,h){if(e instanceof Array){let r=t/4;const a=s/4;for(let t=0;tr[t]=e)),r}if(!(e instanceof Array||e instanceof Float32Array)||0!==i||e.length!==u){if(e instanceof Array){const t=i/4;return e.slice(t,t+u)}if(e instanceof ArrayBuffer)return new Float32Array(e,i,u);{const t=e.byteOffset+i;if(0!=(3&t)&&(r.V.Warn("Float array must be aligned to 4-bytes border"),l=!0),l){const s=new Uint8Array(u*Float32Array.BYTES_PER_ELEMENT),i=new Uint8Array(e.buffer,t,s.length);return s.set(i),new Float32Array(s.buffer)}return new Float32Array(e.buffer,t,u)}}return l?e.slice():e}}a._Counter=0,a.BYTE=5120,a.UNSIGNED_BYTE=5121,a.SHORT=5122,a.UNSIGNED_SHORT=5123,a.INT=5124,a.UNSIGNED_INT=5125,a.FLOAT=5126,a.PositionKind="position",a.NormalKind="normal",a.TangentKind="tangent",a.UVKind="uv",a.UV2Kind="uv2",a.UV3Kind="uv3",a.UV4Kind="uv4",a.UV5Kind="uv5",a.UV6Kind="uv6",a.ColorKind="color",a.ColorInstanceKind="instanceColor",a.MatricesIndicesKind="matricesIndices",a.MatricesWeightsKind="matricesWeights",a.MatricesIndicesExtraKind="matricesIndicesExtra",a.MatricesWeightsExtraKind="matricesWeightsExtra"},1504:(e,t,s)=>{s.d(t,{n:()=>i});class i{get underlyingResource(){return null}constructor(){this.references=0,this.capacity=0,this.is32Bits=!1,this.uniqueId=i._Counter++}}i._Counter=0},9057:(e,t,s)=>{s.d(t,{L:()=>L});var i=s(5524),r=s(9259),n=s(9848),a=s(9923),o=s(4867),h=s(4870),l=s(5530),c=s(6240),u=s(6237),d=s(5559);class _{constructor(){this._zoomStopsAnimation=!1,this._idleRotationSpeed=.05,this._idleRotationWaitTime=2e3,this._idleRotationSpinupTime=2e3,this.targetAlpha=null,this._isPointerDown=!1,this._lastFrameTime=null,this._lastInteractionTime=-1/0,this._cameraRotationSpeed=0,this._lastFrameRadius=0}get name(){return"AutoRotation"}set zoomStopsAnimation(e){this._zoomStopsAnimation=e}get zoomStopsAnimation(){return this._zoomStopsAnimation}set idleRotationSpeed(e){this._idleRotationSpeed=e}get idleRotationSpeed(){return this._idleRotationSpeed}set idleRotationWaitTime(e){this._idleRotationWaitTime=e}get idleRotationWaitTime(){return this._idleRotationWaitTime}set idleRotationSpinupTime(e){this._idleRotationSpinupTime=e}get idleRotationSpinupTime(){return this._idleRotationSpinupTime}get rotationInProgress(){return Math.abs(this._cameraRotationSpeed)>0}init(){}attach(e){this._attachedCamera=e;const t=this._attachedCamera.getScene();this._onPrePointerObservableObserver=t.onPrePointerObservable.add((e=>{e.type!==c.Zp.POINTERDOWN?e.type===c.Zp.POINTERUP&&(this._isPointerDown=!1):this._isPointerDown=!0})),this._onAfterCheckInputsObserver=e.onAfterCheckInputsObservable.add((()=>{if(this._reachTargetAlpha())return;const e=u.j.Now;let t=0;null!=this._lastFrameTime&&(t=e-this._lastFrameTime),this._lastFrameTime=e,this._applyUserInteraction();const s=e-this._lastInteractionTime-this._idleRotationWaitTime,i=Math.max(Math.min(s/this._idleRotationSpinupTime,1),0);this._cameraRotationSpeed=this._idleRotationSpeed*i,this._attachedCamera&&(this._attachedCamera.alpha-=this._cameraRotationSpeed*(t/1e3))}))}detach(){if(!this._attachedCamera)return;const e=this._attachedCamera.getScene();this._onPrePointerObservableObserver&&e.onPrePointerObservable.remove(this._onPrePointerObservableObserver),this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),this._attachedCamera=null,this._lastFrameTime=null}resetLastInteractionTime(e){this._lastInteractionTime=e??u.j.Now}_reachTargetAlpha(){return!(!this._attachedCamera||!this.targetAlpha)&&Math.abs(this._attachedCamera.alpha-this.targetAlpha)=.5?.5*(1-this.easeInCore(2*(1-e)))+.5:.5*this.easeInCore(2*e)}}f.EASINGMODE_EASEIN=0,f.EASINGMODE_EASEOUT=1,f.EASINGMODE_EASEINOUT=2;var p=s(7540);class g{constructor(){this.transitionDuration=450,this.lowerRadiusTransitionRange=2,this.upperRadiusTransitionRange=-2,this._autoTransitionRange=!1,this._radiusIsAnimating=!1,this._radiusBounceTransition=null,this._animatables=new Array}get name(){return"Bouncing"}get autoTransitionRange(){return this._autoTransitionRange}set autoTransitionRange(e){if(this._autoTransitionRange===e)return;this._autoTransitionRange=e;const t=this._attachedCamera;t&&(e?this._onMeshTargetChangedObserver=t.onMeshTargetChangedObservable.add((e=>{if(e&&(e.computeWorldMatrix(!0),e.getBoundingInfo)){const t=e.getBoundingInfo().diagonalLength;this.lowerRadiusTransitionRange=.05*t,this.upperRadiusTransitionRange=.05*t}})):this._onMeshTargetChangedObserver&&t.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver))}init(){}attach(e){this._attachedCamera=e,this._onAfterCheckInputsObserver=e.onAfterCheckInputsObservable.add((()=>{this._attachedCamera&&(this._isRadiusAtLimit(this._attachedCamera.lowerRadiusLimit)&&this._applyBoundRadiusAnimation(this.lowerRadiusTransitionRange),this._isRadiusAtLimit(this._attachedCamera.upperRadiusLimit)&&this._applyBoundRadiusAnimation(this.upperRadiusTransitionRange))}))}detach(){this._attachedCamera&&(this._onAfterCheckInputsObserver&&this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),this._onMeshTargetChangedObserver&&this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver),this._attachedCamera=null)}_isRadiusAtLimit(e){return!!this._attachedCamera&&this._attachedCamera.radius===e&&!this._radiusIsAnimating}_applyBoundRadiusAnimation(e){if(!this._attachedCamera)return;this._radiusBounceTransition||(g.EasingFunction.setEasingMode(g.EasingMode),this._radiusBounceTransition=p.X5.CreateAnimation("radius",p.X5.ANIMATIONTYPE_FLOAT,60,g.EasingFunction)),this._cachedWheelPrecision=this._attachedCamera.wheelPrecision,this._attachedCamera.wheelPrecision=1/0,this._attachedCamera.inertialRadiusOffset=0,this.stopAllAnimations(),this._radiusIsAnimating=!0;const t=p.X5.TransitionTo("radius",this._attachedCamera.radius+e,this._attachedCamera,this._attachedCamera.getScene(),60,this._radiusBounceTransition,this.transitionDuration,(()=>this._clearAnimationLocks()));t&&this._animatables.push(t)}_clearAnimationLocks(){this._radiusIsAnimating=!1,this._attachedCamera&&(this._attachedCamera.wheelPrecision=this._cachedWheelPrecision)}stopAllAnimations(){for(this._attachedCamera&&(this._attachedCamera.animations=[]);this._animatables.length;)this._animatables[0].onAnimationEnd=null,this._animatables[0].stop(),this._animatables.shift()}}g.EasingFunction=new class extends f{constructor(e=1){super(),this.amplitude=e}easeInCore(e){const t=Math.max(0,this.amplitude);return Math.pow(e,3)-e*t*Math.sin(3.141592653589793*e)}}(.3),g.EasingMode=f.EASINGMODE_EASEOUT;class m{constructor(){this.onTargetFramingAnimationEndObservable=new n.cP,this._mode=m.FitFrustumSidesMode,this._radiusScale=1,this._positionScale=.5,this._defaultElevation=.3,this._elevationReturnTime=1500,this._elevationReturnWaitTime=1e3,this._zoomStopsAnimation=!1,this._framingTime=1500,this.autoCorrectCameraLimitsAndSensibility=!0,this._isPointerDown=!1,this._lastInteractionTime=-1/0,this._animatables=new Array,this._betaIsAnimating=!1}get name(){return"Framing"}set mode(e){this._mode=e}get mode(){return this._mode}set radiusScale(e){this._radiusScale=e}get radiusScale(){return this._radiusScale}set positionScale(e){this._positionScale=e}get positionScale(){return this._positionScale}set defaultElevation(e){this._defaultElevation=e}get defaultElevation(){return this._defaultElevation}set elevationReturnTime(e){this._elevationReturnTime=e}get elevationReturnTime(){return this._elevationReturnTime}set elevationReturnWaitTime(e){this._elevationReturnWaitTime=e}get elevationReturnWaitTime(){return this._elevationReturnWaitTime}set zoomStopsAnimation(e){this._zoomStopsAnimation=e}get zoomStopsAnimation(){return this._zoomStopsAnimation}set framingTime(e){this._framingTime=e}get framingTime(){return this._framingTime}init(){}attach(e){this._attachedCamera=e;const t=this._attachedCamera.getScene();m.EasingFunction.setEasingMode(m.EasingMode),this._onPrePointerObservableObserver=t.onPrePointerObservable.add((e=>{e.type!==c.Zp.POINTERDOWN?e.type===c.Zp.POINTERUP&&(this._isPointerDown=!1):this._isPointerDown=!0})),this._onMeshTargetChangedObserver=e.onMeshTargetChangedObservable.add((e=>{e&&e.getBoundingInfo&&this.zoomOnMesh(e,void 0,(()=>{this.onTargetFramingAnimationEndObservable.notifyObservers()}))})),this._onAfterCheckInputsObserver=e.onAfterCheckInputsObservable.add((()=>{this._applyUserInteraction(),this._maintainCameraAboveGround()}))}detach(){if(!this._attachedCamera)return;const e=this._attachedCamera.getScene();this._onPrePointerObservableObserver&&e.onPrePointerObservable.remove(this._onPrePointerObservableObserver),this._onAfterCheckInputsObserver&&this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),this._onMeshTargetChangedObserver&&this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver),this._attachedCamera=null}zoomOnMesh(e,t=!1,s=null){e.computeWorldMatrix(!0);const i=e.getBoundingInfo().boundingBox;this.zoomOnBoundingInfo(i.minimumWorld,i.maximumWorld,t,s)}zoomOnMeshHierarchy(e,t=!1,s=null){e.computeWorldMatrix(!0);const i=e.getHierarchyBoundingVectors(!0);this.zoomOnBoundingInfo(i.min,i.max,t,s)}zoomOnMeshesHierarchy(e,t=!1,s=null){const i=new a.Pq(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),r=new a.Pq(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);for(let t=0;t{this.stopAllAnimations(),i&&i(),this._attachedCamera&&this._attachedCamera.useInputToRestoreState&&this._attachedCamera.storeState()})),l&&this._animatables.push(l),!0}_calculateLowerRadiusFromModelBoundingSphere(e,t){const s=this._attachedCamera;if(!s)return 0;let i=s._calculateLowerRadiusFromModelBoundingSphere(e,t,this._radiusScale);return s.lowerRadiusLimit&&this._mode===m.IgnoreBoundsSizeMode&&(i=is.upperRadiusLimit?s.upperRadiusLimit:i),i}_maintainCameraAboveGround(){if(this._elevationReturnTime<0)return;const e=u.j.Now-this._lastInteractionTime,t=.5*Math.PI-this._defaultElevation,s=.5*Math.PI;if(this._attachedCamera&&!this._betaIsAnimating&&this._attachedCamera.beta>s&&e>=this._elevationReturnWaitTime){this._betaIsAnimating=!0,this.stopAllAnimations(),this._betaTransition||(this._betaTransition=p.X5.CreateAnimation("beta",p.X5.ANIMATIONTYPE_FLOAT,60,m.EasingFunction));const e=p.X5.TransitionTo("beta",t,this._attachedCamera,this._attachedCamera.getScene(),60,this._betaTransition,this._elevationReturnTime,(()=>{this._clearAnimationLocks(),this.stopAllAnimations()}));e&&this._animatables.push(e)}}_clearAnimationLocks(){this._betaIsAnimating=!1}_applyUserInteraction(){this.isUserIsMoving&&(this._lastInteractionTime=u.j.Now,this.stopAllAnimations(),this._clearAnimationLocks())}stopAllAnimations(){for(this._attachedCamera&&(this._attachedCamera.animations=[]);this._animatables.length;)this._animatables[0]&&(this._animatables[0].onAnimationEnd=null,this._animatables[0].stop()),this._animatables.shift()}get isUserIsMoving(){return!!this._attachedCamera&&(0!==this._attachedCamera.inertialAlphaOffset||0!==this._attachedCamera.inertialBetaOffset||0!==this._attachedCamera.inertialRadiusOffset||0!==this._attachedCamera.inertialPanningX||0!==this._attachedCamera.inertialPanningY||this._isPointerDown)}}m.EasingFunction=new class extends f{constructor(e=2){super(),this.exponent=e}easeInCore(e){return this.exponent<=0?e:(Math.exp(this.exponent*e)-1)/(Math.exp(this.exponent)-1)}},m.EasingMode=f.EASINGMODE_EASEINOUT,m.IgnoreBoundsSizeMode=0,m.FitFrustumSidesMode=1;var T=s(388),b=s(8733);h.b.AddNodeConstructor("TargetCamera",((e,t)=>()=>new E(e,a.Pq.Zero(),t)));class E extends T.i{constructor(e,t,s,i=!0){super(e,t,s,i),this._tmpUpVector=a.Pq.Zero(),this._tmpTargetVector=a.Pq.Zero(),this.cameraDirection=new a.Pq(0,0,0),this.cameraRotation=new a.I9(0,0),this.ignoreParentScaling=!1,this.updateUpVectorFromRotation=!1,this._tmpQuaternion=new a.PT,this.rotation=new a.Pq(0,0,0),this.speed=2,this.noRotationConstraint=!1,this.invertRotation=!1,this.inverseRotationSpeed=.2,this.lockedTarget=null,this._currentTarget=a.Pq.Zero(),this._initialFocalDistance=1,this._viewMatrix=a.uq.Zero(),this._camMatrix=a.uq.Zero(),this._cameraTransformMatrix=a.uq.Zero(),this._cameraRotationMatrix=a.uq.Zero(),this._referencePoint=new a.Pq(0,0,1),this._transformedReferencePoint=a.Pq.Zero(),this._deferredPositionUpdate=new a.Pq,this._deferredRotationQuaternionUpdate=new a.PT,this._deferredRotationUpdate=new a.Pq,this._deferredUpdated=!1,this._deferOnly=!1,this._defaultUp=a.Pq.Up(),this._cachedRotationZ=0,this._cachedQuaternionRotationZ=0}getFrontPosition(e){this.getWorldMatrix();const t=this.getTarget().subtract(this.position);return t.normalize(),t.scaleInPlace(e),this.globalPosition.add(t)}_getLockedTargetPosition(){if(!this.lockedTarget)return null;if(this.lockedTarget.absolutePosition){const e=this.lockedTarget;e.computeWorldMatrix().getTranslationToRef(e.absolutePosition)}return this.lockedTarget.absolutePosition||this.lockedTarget}storeState(){return this._storedPosition=this.position.clone(),this._storedRotation=this.rotation.clone(),this.rotationQuaternion&&(this._storedRotationQuaternion=this.rotationQuaternion.clone()),super.storeState()}_restoreStateValues(){return!!super._restoreStateValues()&&(this.position=this._storedPosition.clone(),this.rotation=this._storedRotation.clone(),this.rotationQuaternion&&(this.rotationQuaternion=this._storedRotationQuaternion.clone()),this.cameraDirection.copyFromFloats(0,0,0),this.cameraRotation.copyFromFloats(0,0),!0)}_initCache(){super._initCache(),this._cache.lockedTarget=new a.Pq(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.rotation=new a.Pq(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.rotationQuaternion=new a.PT(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)}_updateCache(e){e||super._updateCache();const t=this._getLockedTargetPosition();t?this._cache.lockedTarget?this._cache.lockedTarget.copyFrom(t):this._cache.lockedTarget=t.clone():this._cache.lockedTarget=null,this._cache.rotation.copyFrom(this.rotation),this.rotationQuaternion&&this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion)}_isSynchronizedViewMatrix(){if(!super._isSynchronizedViewMatrix())return!1;const e=this._getLockedTargetPosition();return(this._cache.lockedTarget?this._cache.lockedTarget.equals(e):!e)&&(this.rotationQuaternion?this.rotationQuaternion.equals(this._cache.rotationQuaternion):this._cache.rotation.equals(this.rotation))}_computeLocalCameraSpeed(){const e=this.getEngine();return this.speed*Math.sqrt(e.getDeltaTime()/(100*e.getFps()))}setTarget(e){this.upVector.normalize(),this._initialFocalDistance=e.subtract(this.position).length(),this.position.z===e.z&&(this.position.z+=d.bH),this._referencePoint.normalize().scaleInPlace(this._initialFocalDistance),a.uq.LookAtLHToRef(this.position,e,this._defaultUp,this._camMatrix),this._camMatrix.invert(),this.rotation.x=Math.atan(this._camMatrix.m[6]/this._camMatrix.m[10]);const t=e.subtract(this.position);t.x>=0?this.rotation.y=-Math.atan(t.z/t.x)+Math.PI/2:this.rotation.y=-Math.atan(t.z/t.x)-Math.PI/2,this.rotation.z=0,isNaN(this.rotation.x)&&(this.rotation.x=0),isNaN(this.rotation.y)&&(this.rotation.y=0),isNaN(this.rotation.z)&&(this.rotation.z=0),this.rotationQuaternion&&a.PT.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this.rotationQuaternion)}get target(){return this.getTarget()}set target(e){this.setTarget(e)}getTarget(){return this._currentTarget}_decideIfNeedsToMove(){return Math.abs(this.cameraDirection.x)>0||Math.abs(this.cameraDirection.y)>0||Math.abs(this.cameraDirection.z)>0}_updatePosition(){if(this.parent)return this.parent.getWorldMatrix().invertToRef(a.AA.Matrix[0]),a.Pq.TransformNormalToRef(this.cameraDirection,a.AA.Matrix[0],a.AA.Vector3[0]),this._deferredPositionUpdate.addInPlace(a.AA.Vector3[0]),void(this._deferOnly?this._deferredUpdated=!0:this.position.copyFrom(this._deferredPositionUpdate));this._deferredPositionUpdate.addInPlace(this.cameraDirection),this._deferOnly?this._deferredUpdated=!0:this.position.copyFrom(this._deferredPositionUpdate)}_checkInputs(){const e=this.invertRotation?-this.inverseRotationSpeed:1,t=this._decideIfNeedsToMove(),s=this.cameraRotation.x||this.cameraRotation.y;if(this._deferredUpdated=!1,this._deferredRotationUpdate.copyFrom(this.rotation),this._deferredPositionUpdate.copyFrom(this.position),this.rotationQuaternion&&this._deferredRotationQuaternionUpdate.copyFrom(this.rotationQuaternion),t&&this._updatePosition(),s){if(this.rotationQuaternion&&this.rotationQuaternion.toEulerAnglesToRef(this._deferredRotationUpdate),this._deferredRotationUpdate.x+=this.cameraRotation.x*e,this._deferredRotationUpdate.y+=this.cameraRotation.y*e,!this.noRotationConstraint){const e=1.570796;this._deferredRotationUpdate.x>e&&(this._deferredRotationUpdate.x=e),this._deferredRotationUpdate.x<-e&&(this._deferredRotationUpdate.x=-e)}this._deferOnly?this._deferredUpdated=!0:this.rotation.copyFrom(this._deferredRotationUpdate),this.rotationQuaternion&&this._deferredRotationUpdate.lengthSquared()&&(a.PT.RotationYawPitchRollToRef(this._deferredRotationUpdate.y,this._deferredRotationUpdate.x,this._deferredRotationUpdate.z,this._deferredRotationQuaternionUpdate),this._deferOnly?this._deferredUpdated=!0:this.rotationQuaternion.copyFrom(this._deferredRotationQuaternionUpdate))}t&&(Math.abs(this.cameraDirection.x){}}add(e){const t=e.getSimpleName();this.attached[t]?x.V.Warn("camera input of type "+t+" already exists on camera"):(this.attached[t]=e,e.camera=this.camera,e.checkInputs&&(this.checkInputs=this._addCheckInputs(e.checkInputs.bind(e))),this.attachedToElement&&e.attachControl(this.noPreventDefault))}remove(e){for(const t in this.attached){const s=this.attached[t];if(s===e)return s.detachControl(),s.camera=null,delete this.attached[t],void this.rebuildInputCheck()}}removeByType(e){for(const t in this.attached){const s=this.attached[t];s.getClassName()===e&&(s.detachControl(),s.camera=null,delete this.attached[t],this.rebuildInputCheck())}}_addCheckInputs(e){const t=this.checkInputs;return()=>{t(),e()}}attachInput(e){this.attachedToElement&&e.attachControl(this.noPreventDefault)}attachElement(e=!1){if(!this.attachedToElement){e=!T.i.ForceAttachControlToAlwaysPreventDefault&&e,this.attachedToElement=!0,this.noPreventDefault=e;for(const t in this.attached)this.attached[t].attachControl(e)}}detachElement(e=!1){for(const t in this.attached)this.attached[t].detachControl(),e&&(this.attached[t].camera=null);this.attachedToElement=!1}rebuildInputCheck(){this.checkInputs=()=>{};for(const e in this.attached){const t=this.attached[e];t.checkInputs&&(this.checkInputs=this._addCheckInputs(t.checkInputs.bind(t)))}}clear(){this.attachedToElement&&this.detachElement(!0),this.attached={},this.attachedToElement=!1,this.checkInputs=()=>{}}serialize(e){const t={};for(const e in this.attached){const s=this.attached[e],i=A.p.Serialize(s);t[s.getClassName()]=i}e.inputsmgr=t}parse(e){const t=e.inputsmgr;if(t){this.clear();for(const e in t){const s=R[e];if(s){const i=t[e],r=A.p.Parse((()=>new s),i,null);this.add(r)}}}else for(const t in this.attached){const s=R[this.attached[t].getClassName()];if(s){const i=A.p.Parse((()=>new s),e,null);this.remove(this.attached[t]),this.add(i)}}}}var y=s(998);class P{constructor(){this._currentActiveButton=-1,this.buttons=[0,1,2]}attachControl(e){e=y.S0.BackCompatCameraNoPreventDefault(arguments);const t=this.camera.getEngine(),s=t.getInputElement();let i=0,r=null;this._pointA=null,this._pointB=null,this._altKey=!1,this._ctrlKey=!1,this._metaKey=!1,this._shiftKey=!1,this._buttonsPressed=0,this._pointerInput=n=>{const a=n.event,o="touch"===a.pointerType;if(n.type!==c.Zp.POINTERMOVE&&-1===this.buttons.indexOf(a.button))return;const h=a.target;if(this._altKey=a.altKey,this._ctrlKey=a.ctrlKey,this._metaKey=a.metaKey,this._shiftKey=a.shiftKey,this._buttonsPressed=a.buttons,t.isPointerLock){const e=a.movementX,t=a.movementY;this.onTouch(null,e,t),this._pointA=null,this._pointB=null}else{if(n.type!==c.Zp.POINTERDOWN&&n.type!==c.Zp.POINTERDOUBLETAP&&o&&this._pointA?.pointerId!==a.pointerId&&this._pointB?.pointerId!==a.pointerId)return;if(n.type!==c.Zp.POINTERDOWN||-1!==this._currentActiveButton&&!o)if(n.type===c.Zp.POINTERDOUBLETAP)this.onDoubleTap(a.pointerType);else if(n.type!==c.Zp.POINTERUP||this._currentActiveButton!==a.button&&!o){if(n.type===c.Zp.POINTERMOVE)if(e||a.preventDefault(),this._pointA&&null===this._pointB){const e=a.clientX-this._pointA.x,t=a.clientY-this._pointA.y;this._pointA.x=a.clientX,this._pointA.y=a.clientY,this.onTouch(this._pointA,e,t)}else if(this._pointA&&this._pointB){const e=this._pointA.pointerId===a.pointerId?this._pointA:this._pointB;e.x=a.clientX,e.y=a.clientY;const t=this._pointA.x-this._pointB.x,s=this._pointA.y-this._pointB.y,o=t*t+s*s,h={x:(this._pointA.x+this._pointB.x)/2,y:(this._pointA.y+this._pointB.y)/2,pointerId:a.pointerId,type:n.type};this.onMultiTouch(this._pointA,this._pointB,i,o,r,h),r=h,i=o}}else{try{h?.releasePointerCapture(a.pointerId)}catch(e){}o||(this._pointB=null),t._badOS?this._pointA=this._pointB=null:this._pointB&&this._pointA&&this._pointA.pointerId==a.pointerId?(this._pointA=this._pointB,this._pointB=null):this._pointA&&this._pointB&&this._pointB.pointerId==a.pointerId?this._pointB=null:this._pointA=this._pointB=null,(0!==i||r)&&(this.onMultiTouch(this._pointA,this._pointB,i,0,r,null),i=0,r=null),this._currentActiveButton=-1,this.onButtonUp(a),e||a.preventDefault()}else{try{h?.setPointerCapture(a.pointerId)}catch(e){}if(null===this._pointA)this._pointA={x:a.clientX,y:a.clientY,pointerId:a.pointerId,type:a.pointerType};else{if(null!==this._pointB)return;this._pointB={x:a.clientX,y:a.clientY,pointerId:a.pointerId,type:a.pointerType}}-1!==this._currentActiveButton||o||(this._currentActiveButton=a.button),this.onButtonDown(a),e||(a.preventDefault(),s&&s.focus())}}},this._observer=this.camera.getScene()._inputManager._addCameraPointerObserver(this._pointerInput,c.Zp.POINTERDOWN|c.Zp.POINTERUP|c.Zp.POINTERMOVE|c.Zp.POINTERDOUBLETAP),this._onLostFocus=()=>{this._pointA=this._pointB=null,i=0,r=null,this.onLostFocus()},this._contextMenuBind=e=>this.onContextMenu(e),s&&s.addEventListener("contextmenu",this._contextMenuBind,!1);const n=this.camera.getScene().getEngine().getHostWindow();n&&y.S0.RegisterTopRootEvents(n,[{name:"blur",handler:this._onLostFocus}])}detachControl(){if(this._onLostFocus){const e=this.camera.getScene().getEngine().getHostWindow();e&&y.S0.UnregisterTopRootEvents(e,[{name:"blur",handler:this._onLostFocus}])}if(this._observer){if(this.camera.getScene()._inputManager._removeCameraPointerObserver(this._observer),this._observer=null,this._contextMenuBind){const e=this.camera.getScene().getEngine().getInputElement();e&&e.removeEventListener("contextmenu",this._contextMenuBind)}this._onLostFocus=null}this._altKey=!1,this._ctrlKey=!1,this._metaKey=!1,this._shiftKey=!1,this._buttonsPressed=0,this._currentActiveButton=-1}getClassName(){return"BaseCameraPointersInput"}getSimpleName(){return"pointers"}onDoubleTap(e){}onTouch(e,t,s){}onMultiTouch(e,t,s,i,r,n){}onContextMenu(e){e.preventDefault()}onButtonDown(e){}onButtonUp(e){}onLostFocus(){}}(0,i.Cg)([(0,r.lK)()],P.prototype,"buttons",void 0);class v extends P{constructor(){super(...arguments),this.buttons=[0,1,2],this.angularSensibilityX=1e3,this.angularSensibilityY=1e3,this.pinchPrecision=12,this.pinchDeltaPercentage=0,this.useNaturalPinchZoom=!1,this.pinchZoom=!0,this.panningSensibility=1e3,this.multiTouchPanning=!0,this.multiTouchPanAndZoom=!0,this.pinchInwards=!0,this._isPanClick=!1,this._twoFingerActivityCount=0,this._isPinching=!1}getClassName(){return"ArcRotateCameraPointersInput"}_computeMultiTouchPanning(e,t){if(0!==this.panningSensibility&&e&&t){const s=t.x-e.x,i=t.y-e.y;this.camera.inertialPanningX+=-s/this.panningSensibility,this.camera.inertialPanningY+=i/this.panningSensibility}}_computePinchZoom(e,t){const s=this.camera.radius||v.MinimumRadiusForPinch;this.useNaturalPinchZoom?this.camera.radius=s*Math.sqrt(e)/Math.sqrt(t):this.pinchDeltaPercentage?this.camera.inertialRadiusOffset+=.001*(t-e)*s*this.pinchDeltaPercentage:this.camera.inertialRadiusOffset+=(t-e)/(this.pinchPrecision*(this.pinchInwards?1:-1)*(this.angularSensibilityX+this.angularSensibilityY)/2)}onTouch(e,t,s){0!==this.panningSensibility&&(this._ctrlKey&&this.camera._useCtrlForPanning||this._isPanClick)?(this.camera.inertialPanningX+=-t/this.panningSensibility,this.camera.inertialPanningY+=s/this.panningSensibility):(this.camera.inertialAlphaOffset-=t/this.angularSensibilityX,this.camera.inertialBetaOffset-=s/this.angularSensibilityY)}onDoubleTap(){this.camera.useInputToRestoreState&&this.camera.restoreState()}onMultiTouch(e,t,s,i,r,n){0===s&&null===r||0===i&&null===n||(this.multiTouchPanAndZoom?(this._computePinchZoom(s,i),this._computeMultiTouchPanning(r,n)):this.multiTouchPanning&&this.pinchZoom?(this._twoFingerActivityCount++,this._isPinching||this._twoFingerActivityCount<20&&Math.abs(Math.sqrt(i)-Math.sqrt(s))>this.camera.pinchToPanMaxDistance?(this._computePinchZoom(s,i),this._isPinching=!0):this._computeMultiTouchPanning(r,n)):this.multiTouchPanning?this._computeMultiTouchPanning(r,n):this.pinchZoom&&this._computePinchZoom(s,i))}onButtonDown(e){this._isPanClick=e.button===this.camera._panningMouseButton}onButtonUp(e){this._twoFingerActivityCount=0,this._isPinching=!1}onLostFocus(){this._isPanClick=!1,this._twoFingerActivityCount=0,this._isPinching=!1}}v.MinimumRadiusForPinch=.001,(0,i.Cg)([(0,r.lK)()],v.prototype,"buttons",void 0),(0,i.Cg)([(0,r.lK)()],v.prototype,"angularSensibilityX",void 0),(0,i.Cg)([(0,r.lK)()],v.prototype,"angularSensibilityY",void 0),(0,i.Cg)([(0,r.lK)()],v.prototype,"pinchPrecision",void 0),(0,i.Cg)([(0,r.lK)()],v.prototype,"pinchDeltaPercentage",void 0),(0,i.Cg)([(0,r.lK)()],v.prototype,"useNaturalPinchZoom",void 0),(0,i.Cg)([(0,r.lK)()],v.prototype,"pinchZoom",void 0),(0,i.Cg)([(0,r.lK)()],v.prototype,"panningSensibility",void 0),(0,i.Cg)([(0,r.lK)()],v.prototype,"multiTouchPanning",void 0),(0,i.Cg)([(0,r.lK)()],v.prototype,"multiTouchPanAndZoom",void 0),R.ArcRotateCameraPointersInput=v;var C=s(4146);class S{constructor(){this.keysUp=[38],this.keysDown=[40],this.keysLeft=[37],this.keysRight=[39],this.keysReset=[220],this.panningSensibility=50,this.zoomingSensibility=25,this.useAltToZoom=!0,this.angularSpeed=.01,this._keys=new Array}attachControl(e){e=y.S0.BackCompatCameraNoPreventDefault(arguments),this._onCanvasBlurObserver||(this._scene=this.camera.getScene(),this._engine=this._scene.getEngine(),this._onCanvasBlurObserver=this._engine.onCanvasBlurObservable.add((()=>{this._keys.length=0})),this._onKeyboardObserver=this._scene.onKeyboardObservable.add((t=>{const s=t.event;if(!s.metaKey)if(t.type===C.TB.KEYDOWN)this._ctrlPressed=s.ctrlKey,this._altPressed=s.altKey,(-1!==this.keysUp.indexOf(s.keyCode)||-1!==this.keysDown.indexOf(s.keyCode)||-1!==this.keysLeft.indexOf(s.keyCode)||-1!==this.keysRight.indexOf(s.keyCode)||-1!==this.keysReset.indexOf(s.keyCode))&&(-1===this._keys.indexOf(s.keyCode)&&this._keys.push(s.keyCode),s.preventDefault&&(e||s.preventDefault()));else if(-1!==this.keysUp.indexOf(s.keyCode)||-1!==this.keysDown.indexOf(s.keyCode)||-1!==this.keysLeft.indexOf(s.keyCode)||-1!==this.keysRight.indexOf(s.keyCode)||-1!==this.keysReset.indexOf(s.keyCode)){const t=this._keys.indexOf(s.keyCode);t>=0&&this._keys.splice(t,1),s.preventDefault&&(e||s.preventDefault())}})))}detachControl(){this._scene&&(this._onKeyboardObserver&&this._scene.onKeyboardObservable.remove(this._onKeyboardObserver),this._onCanvasBlurObserver&&this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver),this._onKeyboardObserver=null,this._onCanvasBlurObserver=null),this._keys.length=0}checkInputs(){if(this._onKeyboardObserver){const e=this.camera;for(let t=0;t0?i/(1+this.wheelDeltaPercentage):i*(1+this.wheelDeltaPercentage),s}attachControl(e){e=y.S0.BackCompatCameraNoPreventDefault(arguments),this._wheel=t=>{if(t.type!==c.Zp.POINTERWHEEL)return;const s=t.event;let i=0;const r=s.deltaMode===D.s.DOM_DELTA_LINE?40:1,n=-s.deltaY*r;if(this.customComputeDeltaFromMouseWheel)i=this.customComputeDeltaFromMouseWheel(n,this,s);else if(this.wheelDeltaPercentage){if(i=this._computeDeltaFromMouseWheelLegacyEvent(n,this.camera.radius),i>0){let e=this.camera.radius,t=this.camera.inertialRadiusOffset+i;for(let s=0;s<20&&Math.abs(t)>.001;s++)e-=t,t*=this.camera.inertia;e=(0,o.OQ)(e,0,Number.MAX_VALUE),i=this._computeDeltaFromMouseWheelLegacyEvent(n,e)}}else i=n/(40*this.wheelPrecision);i&&(this.zoomToMouseLocation?(this._hitPlane||this._updateHitPlane(),this._zoomToMouse(i)):this.camera.inertialRadiusOffset+=i),s.preventDefault&&(e||s.preventDefault())},this._observer=this.camera.getScene()._inputManager._addCameraPointerObserver(this._wheel,c.Zp.POINTERWHEEL),this.zoomToMouseLocation&&this._inertialPanning.setAll(0)}detachControl(){this._observer&&(this.camera.getScene()._inputManager._removeCameraPointerObserver(this._observer),this._observer=null,this._wheel=null)}checkInputs(){if(!this.zoomToMouseLocation)return;const e=this.camera;0+e.inertialAlphaOffset+e.inertialBetaOffset+e.inertialRadiusOffset&&(this._updateHitPlane(),e.target.addInPlace(this._inertialPanning),this._inertialPanning.scaleInPlace(e.inertia),this._zeroIfClose(this._inertialPanning))}getClassName(){return"ArcRotateCameraMouseWheelInput"}getSimpleName(){return"mousewheel"}_updateHitPlane(){const e=this.camera,t=e.target.subtract(e.position);this._hitPlane=I.Z.FromPositionAndNormal(e.target,t)}_getPosition(){const e=this.camera,t=e.getScene(),s=t.createPickingRay(t.pointerX,t.pointerY,a.uq.Identity(),e,!1);0===e.targetScreenOffset.x&&0===e.targetScreenOffset.y||(this._viewOffset.set(e.targetScreenOffset.x,e.targetScreenOffset.y,0),e.getViewMatrix().invertToRef(e._cameraTransformMatrix),this._globalOffset=a.Pq.TransformNormal(this._viewOffset,e._cameraTransformMatrix),s.origin.addInPlace(this._globalOffset));let i=0;return this._hitPlane&&(i=s.intersectsPlane(this._hitPlane)??0),s.origin.addInPlace(s.direction.scaleInPlace(i))}_zoomToMouse(e){const t=this.camera,s=1-t.inertia;if(t.lowerRadiusLimit){const i=t.lowerRadiusLimit??0;t.radius-(t.inertialRadiusOffset+e)/si&&(e=(t.radius-i)*s-t.inertialRadiusOffset)}const i=e/s/t.radius,r=this._getPosition(),n=a.AA.Vector3[6];r.subtractToRef(t.target,n),n.scaleInPlace(i),n.scaleInPlace(s),this._inertialPanning.addInPlace(n),t.inertialRadiusOffset+=e}_zeroIfClose(e){Math.abs(e.x)()=>new L(e,0,0,1,a.Pq.Zero(),t)));class L extends E{get target(){return this._target}set target(e){this.setTarget(e)}get targetHost(){return this._targetHost}set targetHost(e){e&&this.setTarget(e)}getTarget(){return this.target}get position(){return this._position}set position(e){this.setPosition(e)}set upVector(e){this._upToYMatrix||(this._yToUpMatrix=new a.uq,this._upToYMatrix=new a.uq,this._upVector=a.Pq.Zero()),e.normalize(),this._upVector.copyFrom(e),this.setMatUp()}get upVector(){return this._upVector}setMatUp(){a.uq.RotationAlignToRef(a.Pq.UpReadOnly,this._upVector,this._yToUpMatrix),a.uq.RotationAlignToRef(this._upVector,a.Pq.UpReadOnly,this._upToYMatrix)}get angularSensibilityX(){const e=this.inputs.attached.pointers;return e?e.angularSensibilityX:0}set angularSensibilityX(e){const t=this.inputs.attached.pointers;t&&(t.angularSensibilityX=e)}get angularSensibilityY(){const e=this.inputs.attached.pointers;return e?e.angularSensibilityY:0}set angularSensibilityY(e){const t=this.inputs.attached.pointers;t&&(t.angularSensibilityY=e)}get pinchPrecision(){const e=this.inputs.attached.pointers;return e?e.pinchPrecision:0}set pinchPrecision(e){const t=this.inputs.attached.pointers;t&&(t.pinchPrecision=e)}get pinchDeltaPercentage(){const e=this.inputs.attached.pointers;return e?e.pinchDeltaPercentage:0}set pinchDeltaPercentage(e){const t=this.inputs.attached.pointers;t&&(t.pinchDeltaPercentage=e)}get useNaturalPinchZoom(){const e=this.inputs.attached.pointers;return!!e&&e.useNaturalPinchZoom}set useNaturalPinchZoom(e){const t=this.inputs.attached.pointers;t&&(t.useNaturalPinchZoom=e)}get panningSensibility(){const e=this.inputs.attached.pointers;return e?e.panningSensibility:0}set panningSensibility(e){const t=this.inputs.attached.pointers;t&&(t.panningSensibility=e)}get keysUp(){const e=this.inputs.attached.keyboard;return e?e.keysUp:[]}set keysUp(e){const t=this.inputs.attached.keyboard;t&&(t.keysUp=e)}get keysDown(){const e=this.inputs.attached.keyboard;return e?e.keysDown:[]}set keysDown(e){const t=this.inputs.attached.keyboard;t&&(t.keysDown=e)}get keysLeft(){const e=this.inputs.attached.keyboard;return e?e.keysLeft:[]}set keysLeft(e){const t=this.inputs.attached.keyboard;t&&(t.keysLeft=e)}get keysRight(){const e=this.inputs.attached.keyboard;return e?e.keysRight:[]}set keysRight(e){const t=this.inputs.attached.keyboard;t&&(t.keysRight=e)}get wheelPrecision(){const e=this.inputs.attached.mousewheel;return e?e.wheelPrecision:0}set wheelPrecision(e){const t=this.inputs.attached.mousewheel;t&&(t.wheelPrecision=e)}get zoomToMouseLocation(){const e=this.inputs.attached.mousewheel;return!!e&&e.zoomToMouseLocation}set zoomToMouseLocation(e){const t=this.inputs.attached.mousewheel;t&&(t.zoomToMouseLocation=e)}get wheelDeltaPercentage(){const e=this.inputs.attached.mousewheel;return e?e.wheelDeltaPercentage:0}set wheelDeltaPercentage(e){const t=this.inputs.attached.mousewheel;t&&(t.wheelDeltaPercentage=e)}get bouncingBehavior(){return this._bouncingBehavior}get useBouncingBehavior(){return null!=this._bouncingBehavior}set useBouncingBehavior(e){e!==this.useBouncingBehavior&&(e?(this._bouncingBehavior=new g,this.addBehavior(this._bouncingBehavior)):this._bouncingBehavior&&(this.removeBehavior(this._bouncingBehavior),this._bouncingBehavior=null))}get framingBehavior(){return this._framingBehavior}get useFramingBehavior(){return null!=this._framingBehavior}set useFramingBehavior(e){e!==this.useFramingBehavior&&(e?(this._framingBehavior=new m,this.addBehavior(this._framingBehavior)):this._framingBehavior&&(this.removeBehavior(this._framingBehavior),this._framingBehavior=null))}get autoRotationBehavior(){return this._autoRotationBehavior}get useAutoRotationBehavior(){return null!=this._autoRotationBehavior}set useAutoRotationBehavior(e){e!==this.useAutoRotationBehavior&&(e?(this._autoRotationBehavior=new _,this.addBehavior(this._autoRotationBehavior)):this._autoRotationBehavior&&(this.removeBehavior(this._autoRotationBehavior),this._autoRotationBehavior=null))}constructor(e,t,s,i,r,o,h=!0){super(e,a.Pq.Zero(),o,h),this.inertialAlphaOffset=0,this.inertialBetaOffset=0,this.inertialRadiusOffset=0,this.lowerAlphaLimit=null,this.upperAlphaLimit=null,this.lowerBetaLimit=.01,this.upperBetaLimit=Math.PI-.01,this.lowerRadiusLimit=null,this.upperRadiusLimit=null,this.inertialPanningX=0,this.inertialPanningY=0,this.pinchToPanMaxDistance=20,this.panningDistanceLimit=null,this.panningOriginTarget=a.Pq.Zero(),this.panningInertia=.9,this.zoomOnFactor=1,this.targetScreenOffset=a.I9.Zero(),this.allowUpsideDown=!0,this.useInputToRestoreState=!0,this.restoreStateInterpolationFactor=0,this._viewMatrix=new a.uq,this.panningAxis=new a.Pq(1,1,0),this._transformedDirection=new a.Pq,this.mapPanning=!1,this._progressiveRestore=!1,this.onMeshTargetChangedObservable=new n.cP,this.checkCollisions=!1,this.collisionRadius=new a.Pq(.5,.5,.5),this._previousPosition=a.Pq.Zero(),this._collisionVelocity=a.Pq.Zero(),this._newPosition=a.Pq.Zero(),this._computationVector=a.Pq.Zero(),this._onCollisionPositionChange=(e,t,s=null)=>{s?(this.setPosition(t),this.onCollide&&this.onCollide(s)):this._previousPosition.copyFrom(this._position);const i=Math.cos(this.alpha),r=Math.sin(this.alpha),n=Math.cos(this.beta);let a=Math.sin(this.beta);0===a&&(a=1e-4);const o=this._getTargetPosition();this._computationVector.copyFromFloats(this.radius*i*a,this.radius*n,this.radius*r*a),o.addToRef(this._computationVector,this._newPosition),this._position.copyFrom(this._newPosition);let h=this.upVector;this.allowUpsideDown&&this.beta<0&&(h=h.clone(),h=h.negate()),this._computeViewMatrix(this._position,o,h),this._viewMatrix.addAtIndex(12,this.targetScreenOffset.x),this._viewMatrix.addAtIndex(13,this.targetScreenOffset.y),this._collisionTriggered=!1},this._target=a.Pq.Zero(),r&&this.setTarget(r),this.alpha=t,this.beta=s,this.radius=i,this.getViewMatrix(),this.inputs=new F(this),this.inputs.addKeyboard().addMouseWheel().addPointers()}_initCache(){super._initCache(),this._cache._target=new a.Pq(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.alpha=void 0,this._cache.beta=void 0,this._cache.radius=void 0,this._cache.targetScreenOffset=a.I9.Zero()}_updateCache(e){e||super._updateCache(),this._cache._target.copyFrom(this._getTargetPosition()),this._cache.alpha=this.alpha,this._cache.beta=this.beta,this._cache.radius=this.radius,this._cache.targetScreenOffset.copyFrom(this.targetScreenOffset)}_getTargetPosition(){if(this._targetHost&&this._targetHost.getAbsolutePosition){const e=this._targetHost.getAbsolutePosition();this._targetBoundingCenter?e.addToRef(this._targetBoundingCenter,this._target):this._target.copyFrom(e)}return this._getLockedTargetPosition()||this._target}storeState(){return this._storedAlpha=this._goalAlpha=this.alpha,this._storedBeta=this._goalBeta=this.beta,this._storedRadius=this._goalRadius=this.radius,this._storedTarget=this._goalTarget=this._getTargetPosition().clone(),this._storedTargetScreenOffset=this._goalTargetScreenOffset=this.targetScreenOffset.clone(),super.storeState()}_restoreStateValues(){return this.hasStateStored()&&this.restoreStateInterpolationFactor>d.bH&&this.restoreStateInterpolationFactor<1?(this.interpolateTo(this._storedAlpha,this._storedBeta,this._storedRadius,this._storedTarget,this._storedTargetScreenOffset),!0):!!super._restoreStateValues()&&(this.setTarget(this._storedTarget.clone()),this.alpha=this._storedAlpha,this.beta=this._storedBeta,this.radius=this._storedRadius,this.targetScreenOffset=this._storedTargetScreenOffset.clone(),this.inertialAlphaOffset=0,this.inertialBetaOffset=0,this.inertialRadiusOffset=0,this.inertialPanningX=0,this.inertialPanningY=0,!0)}interpolateTo(e=this.alpha,t=this.beta,s=this.radius,i=this.target,r=this.targetScreenOffset){this._progressiveRestore=!0,this.inertialAlphaOffset=0,this.inertialBetaOffset=0,this.inertialRadiusOffset=0,this.inertialPanningX=0,this.inertialPanningY=0,e=(0,o.OQ)(e,this.lowerAlphaLimit??-1/0,this.upperAlphaLimit??1/0),t=(0,o.OQ)(t,this.lowerBetaLimit??-1/0,this.upperBetaLimit??1/0),s=(0,o.OQ)(s,this.lowerRadiusLimit??-1/0,this.upperRadiusLimit??1/0),this._goalAlpha=e,this._goalBeta=t,this._goalRadius=s,this._goalTarget=i,this._goalTargetScreenOffset=r}_isSynchronizedViewMatrix(){return!!super._isSynchronizedViewMatrix()&&this._cache._target.equals(this._getTargetPosition())&&this._cache.alpha===this.alpha&&this._cache.beta===this.beta&&this._cache.radius===this.radius&&this._cache.targetScreenOffset.equals(this.targetScreenOffset)}attachControl(e,t,s=!0,i=2){const r=arguments;t=y.S0.BackCompatCameraNoPreventDefault(r),this._useCtrlForPanning=s,this._panningMouseButton=i,"boolean"==typeof r[0]&&(r.length>1&&(this._useCtrlForPanning=r[1]),r.length>2&&(this._panningMouseButton=r[2])),this.inputs.attachElement(t),this._reset=()=>{this.inertialAlphaOffset=0,this.inertialBetaOffset=0,this.inertialRadiusOffset=0,this.inertialPanningX=0,this.inertialPanningY=0}}detachControl(){this.inputs.detachElement(),this._reset&&this._reset()}_checkInputs(){if(!this._collisionTriggered){if(this.inputs.checkInputs(),this._progressiveRestore){const e=this._scene.getEngine().getDeltaTime()/1e3,t=1-Math.pow(2,-e/this.restoreStateInterpolationFactor);this.setTarget(a.Pq.Lerp(this.getTarget(),this._goalTarget,t)),a.PT.RotationAlphaBetaGammaToRef(this._goalAlpha,this._goalBeta,0,a.AA.Quaternion[0]),a.PT.RotationAlphaBetaGammaToRef(this.alpha,this.beta,0,a.AA.Quaternion[1]),a.PT.SlerpToRef(a.AA.Quaternion[1],a.AA.Quaternion[0],t,a.AA.Quaternion[2]),a.AA.Quaternion[2].normalize(),a.AA.Quaternion[2].toAlphaBetaGammaToRef(a.AA.Vector3[0]),this.alpha=a.AA.Vector3[0].x,this.beta=a.AA.Vector3[0].y,this.radius+=(this._goalRadius-this.radius)*t,a.I9.LerpToRef(this.targetScreenOffset,this._goalTargetScreenOffset,t,this.targetScreenOffset),(a.Pq.DistanceSquared(this.getTarget(),this._goalTarget)Math.PI&&(this.beta=this.beta-2*Math.PI):this.betathis.upperBetaLimit&&(this.beta=this.upperBetaLimit),null!==this.lowerAlphaLimit&&this.alphathis.upperAlphaLimit&&(this.alpha=this.upperAlphaLimit),null!==this.lowerRadiusLimit&&this.radiusthis.upperRadiusLimit&&(this.radius=this.upperRadiusLimit,this.inertialRadiusOffset=0)}rebuildAnglesAndRadius(){this._position.subtractToRef(this._getTargetPosition(),this._computationVector),0===this._upVector.x&&1===this._upVector.y&&0===this._upVector.z||a.Pq.TransformCoordinatesToRef(this._computationVector,this._upToYMatrix,this._computationVector),this.radius=this._computationVector.length(),0===this.radius&&(this.radius=1e-4);const e=this.alpha;0===this._computationVector.x&&0===this._computationVector.z?this.alpha=Math.PI/2:this.alpha=Math.acos(this._computationVector.x/Math.sqrt(Math.pow(this._computationVector.x,2)+Math.pow(this._computationVector.z,2))),this._computationVector.z<0&&(this.alpha=2*Math.PI-this.alpha);const t=Math.round((e-this.alpha)/(2*Math.PI));this.alpha+=2*t*Math.PI,this.beta=Math.acos(this._computationVector.y/this.radius),this._checkLimits()}setPosition(e){this._position.equals(e)||(this._position.copyFrom(e),this.rebuildAnglesAndRadius())}setTarget(e,t=!1,s=!1,i=!1){if(i=this.overrideCloneAlphaBetaRadius??i,e.computeWorldMatrix)t&&e.getBoundingInfo?this._targetBoundingCenter=e.getBoundingInfo().boundingBox.centerWorld.clone():this._targetBoundingCenter=null,e.computeWorldMatrix(),this._targetHost=e,this._target=this._getTargetPosition(),this.onMeshTargetChangedObservable.notifyObservers(this._targetHost);else{const t=e,i=this._getTargetPosition();if(i&&!s&&i.equals(t))return;this._targetHost=null,this._target=t,this._targetBoundingCenter=null,this.onMeshTargetChangedObservable.notifyObservers(null)}i||this.rebuildAnglesAndRadius()}_getViewMatrix(){const e=Math.cos(this.alpha),t=Math.sin(this.alpha),s=Math.cos(this.beta);let i=Math.sin(this.beta);0===i&&(i=1e-4),0===this.radius&&(this.radius=1e-4);const r=this._getTargetPosition();if(this._computationVector.copyFromFloats(this.radius*e*i,this.radius*s,this.radius*t*i),0===this._upVector.x&&1===this._upVector.y&&0===this._upVector.z||a.Pq.TransformCoordinatesToRef(this._computationVector,this._yToUpMatrix,this._computationVector),r.addToRef(this._computationVector,this._newPosition),this.getScene().collisionsEnabled&&this.checkCollisions){const e=this.getScene().collisionCoordinator;this._collider||(this._collider=e.createCollider()),this._collider._radius=this.collisionRadius,this._newPosition.subtractToRef(this._position,this._collisionVelocity),this._collisionTriggered=!0,e.getNewPosition(this._position,this._collisionVelocity,this._collider,3,null,this._onCollisionPositionChange,this.uniqueId)}else{this._position.copyFrom(this._newPosition);let e=this.upVector;this.allowUpsideDown&&i<0&&(e=e.negate()),this._computeViewMatrix(this._position,r,e),this._viewMatrix.addAtIndex(12,this.targetScreenOffset.x),this._viewMatrix.addAtIndex(13,this.targetScreenOffset.y)}return this._currentTarget=r,this._viewMatrix}zoomOn(e,t=!1){e=e||this.getScene().meshes;const s=l.e.MinMax(e);let i=this._calculateLowerRadiusFromModelBoundingSphere(s.min,s.max);i=Math.max(Math.min(i,this.upperRadiusLimit||Number.MAX_VALUE),this.lowerRadiusLimit||0),this.radius=i*this.zoomOnFactor,this.focusOn({min:s.min,max:s.max,distance:i},t)}focusOn(e,t=!1){let s,i;if(void 0===e.min){const t=e||this.getScene().meshes;s=l.e.MinMax(t),i=a.Pq.Distance(s.min,s.max)}else s=e,i=e.distance;this._target=l.e.Center(s),t||(this.maxZ=2*i)}createRigCamera(e,t){let s=0;switch(this.cameraRigMode){case T.i.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case T.i.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case T.i.RIG_MODE_STEREOSCOPIC_OVERUNDER:case T.i.RIG_MODE_STEREOSCOPIC_INTERLACED:case T.i.RIG_MODE_VR:s=this._cameraRigParams.stereoHalfAngle*(0===t?1:-1);break;case T.i.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:s=this._cameraRigParams.stereoHalfAngle*(0===t?-1:1)}const i=new L(e,this.alpha+s,this.beta,this.radius,this._target,this.getScene());return i._cameraRigParams={},i.isRigCamera=!0,i.rigParent=this,i.upVector=this.upVector,i.mode=this.mode,i.orthoLeft=this.orthoLeft,i.orthoRight=this.orthoRight,i.orthoBottom=this.orthoBottom,i.orthoTop=this.orthoTop,i}_updateRigCameras(){const e=this._rigCameras[0],t=this._rigCameras[1];switch(e.beta=t.beta=this.beta,this.cameraRigMode){case T.i.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case T.i.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case T.i.RIG_MODE_STEREOSCOPIC_OVERUNDER:case T.i.RIG_MODE_STEREOSCOPIC_INTERLACED:case T.i.RIG_MODE_VR:e.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle,t.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle;break;case T.i.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:e.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle,t.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle}super._updateRigCameras()}_calculateLowerRadiusFromModelBoundingSphere(e,t,s=1){const i=a.Pq.Distance(e,t),r=this.getScene().getEngine().getAspectRatio(this),n=Math.tan(this.fov/2),o=n*r,h=.5*i*s,l=h*Math.sqrt(1+1/(o*o)),c=h*Math.sqrt(1+1/(n*n));return Math.max(l,c)}dispose(){this.inputs.clear(),super.dispose()}getClassName(){return"ArcRotateCamera"}}(0,i.Cg)([(0,r.lK)()],L.prototype,"alpha",void 0),(0,i.Cg)([(0,r.lK)()],L.prototype,"beta",void 0),(0,i.Cg)([(0,r.lK)()],L.prototype,"radius",void 0),(0,i.Cg)([(0,r.lK)()],L.prototype,"overrideCloneAlphaBetaRadius",void 0),(0,i.Cg)([(0,r.P_)("target")],L.prototype,"_target",void 0),(0,i.Cg)([(0,r.xG)("targetHost")],L.prototype,"_targetHost",void 0),(0,i.Cg)([(0,r.lK)()],L.prototype,"inertialAlphaOffset",void 0),(0,i.Cg)([(0,r.lK)()],L.prototype,"inertialBetaOffset",void 0),(0,i.Cg)([(0,r.lK)()],L.prototype,"inertialRadiusOffset",void 0),(0,i.Cg)([(0,r.lK)()],L.prototype,"lowerAlphaLimit",void 0),(0,i.Cg)([(0,r.lK)()],L.prototype,"upperAlphaLimit",void 0),(0,i.Cg)([(0,r.lK)()],L.prototype,"lowerBetaLimit",void 0),(0,i.Cg)([(0,r.lK)()],L.prototype,"upperBetaLimit",void 0),(0,i.Cg)([(0,r.lK)()],L.prototype,"lowerRadiusLimit",void 0),(0,i.Cg)([(0,r.lK)()],L.prototype,"upperRadiusLimit",void 0),(0,i.Cg)([(0,r.lK)()],L.prototype,"inertialPanningX",void 0),(0,i.Cg)([(0,r.lK)()],L.prototype,"inertialPanningY",void 0),(0,i.Cg)([(0,r.lK)()],L.prototype,"pinchToPanMaxDistance",void 0),(0,i.Cg)([(0,r.lK)()],L.prototype,"panningDistanceLimit",void 0),(0,i.Cg)([(0,r.P_)()],L.prototype,"panningOriginTarget",void 0),(0,i.Cg)([(0,r.lK)()],L.prototype,"panningInertia",void 0),(0,i.Cg)([(0,r.lK)()],L.prototype,"zoomToMouseLocation",null),(0,i.Cg)([(0,r.lK)()],L.prototype,"zoomOnFactor",void 0),(0,i.Cg)([(0,r.WM)()],L.prototype,"targetScreenOffset",void 0),(0,i.Cg)([(0,r.lK)()],L.prototype,"allowUpsideDown",void 0),(0,i.Cg)([(0,r.lK)()],L.prototype,"useInputToRestoreState",void 0),(0,i.Cg)([(0,r.lK)()],L.prototype,"restoreStateInterpolationFactor",void 0),(0,w.Y5)("BABYLON.ArcRotateCamera",L)},388:(e,t,s)=>{s.d(t,{i:()=>g});var i=s(5524),r=s(9259),n=s(7931),a=s(998),o=s(9848),h=s(9923),l=s(4870),c=s(1137),u=s(6552),d=s(5503),_=s(4494),f=s(2572),p=s(6877);class g extends l.b{get position(){return this._position}set position(e){this._position=e}set upVector(e){this._upVector=e}get upVector(){return this._upVector}get screenArea(){let e=0,t=0;if(this.mode===g.PERSPECTIVE_CAMERA)this.fovMode===g.FOVMODE_VERTICAL_FIXED?(t=2*this.minZ*Math.tan(this.fov/2),e=this.getEngine().getAspectRatio(this)*t):(e=2*this.minZ*Math.tan(this.fov/2),t=e/this.getEngine().getAspectRatio(this));else{const s=this.getEngine().getRenderWidth()/2,i=this.getEngine().getRenderHeight()/2;e=(this.orthoRight??s)-(this.orthoLeft??-s),t=(this.orthoTop??i)-(this.orthoBottom??-i)}return e*t}set orthoLeft(e){this._orthoLeft=e;for(const t of this._rigCameras)t.orthoLeft=e}get orthoLeft(){return this._orthoLeft}set orthoRight(e){this._orthoRight=e;for(const t of this._rigCameras)t.orthoRight=e}get orthoRight(){return this._orthoRight}set orthoBottom(e){this._orthoBottom=e;for(const t of this._rigCameras)t.orthoBottom=e}get orthoBottom(){return this._orthoBottom}set orthoTop(e){this._orthoTop=e;for(const t of this._rigCameras)t.orthoTop=e}get orthoTop(){return this._orthoTop}set mode(e){this._mode=e;for(const t of this._rigCameras)t.mode=e}get mode(){return this._mode}get hasMoved(){return this._hasMoved}constructor(e,t,s,i=!0){super(e,s,!1),this._position=h.Pq.Zero(),this._upVector=h.Pq.Up(),this.oblique=null,this._orthoLeft=null,this._orthoRight=null,this._orthoBottom=null,this._orthoTop=null,this.fov=.8,this.projectionPlaneTilt=0,this.minZ=1,this.maxZ=1e4,this.inertia=.9,this._mode=g.PERSPECTIVE_CAMERA,this.isIntermediate=!1,this.viewport=new _.L(0,0,1,1),this.layerMask=268435455,this.fovMode=g.FOVMODE_VERTICAL_FIXED,this.cameraRigMode=g.RIG_MODE_NONE,this.customRenderTargets=[],this.outputRenderTarget=null,this.onViewMatrixChangedObservable=new o.cP,this.onProjectionMatrixChangedObservable=new o.cP,this.onAfterCheckInputsObservable=new o.cP,this.onRestoreStateObservable=new o.cP,this.isRigCamera=!1,this._hasMoved=!1,this._rigCameras=new Array,this._skipRendering=!1,this._projectionMatrix=new h.uq,this._postProcesses=new Array,this._activeMeshes=new n.L(256),this._globalPosition=h.Pq.Zero(),this._computedViewMatrix=h.uq.Identity(),this._doNotComputeProjectionMatrix=!1,this._transformMatrix=h.uq.Zero(),this._refreshFrustumPlanes=!0,this._absoluteRotation=h.PT.Identity(),this._isCamera=!0,this._isLeftCamera=!1,this._isRightCamera=!1,this.getScene().addCamera(this),i&&!this.getScene().activeCamera&&(this.getScene().activeCamera=this),this.position=t,this.renderPassId=this.getScene().getEngine().createRenderPassId(`Camera ${e}`)}storeState(){return this._stateStored=!0,this._storedFov=this.fov,this}hasStateStored(){return!!this._stateStored}_restoreStateValues(){return!!this._stateStored&&(this.fov=this._storedFov,!0)}restoreState(){return!!this._restoreStateValues()&&(this.onRestoreStateObservable.notifyObservers(this),!0)}getClassName(){return"Camera"}toString(e){let t="Name: "+this.name;if(t+=", type: "+this.getClassName(),this.animations)for(let s=0;s-1?(c.V.Error("You're trying to reuse a post process not defined as reusable."),0):(null==t||t<0?this._postProcesses.push(e):null===this._postProcesses[t]?this._postProcesses[t]=e:this._postProcesses.splice(t,0,e),this._cascadePostProcessesToRigCams(),this._scene.prePassRenderer&&this._scene.prePassRenderer.markAsDirty(),this._postProcesses.indexOf(e))}detachPostProcess(e){const t=this._postProcesses.indexOf(e);-1!==t&&(this._postProcesses[t]=null),this._scene.prePassRenderer&&this._scene.prePassRenderer.markAsDirty(),this._cascadePostProcessesToRigCams()}getWorldMatrix(){return this._isSynchronizedViewMatrix()||this.getViewMatrix(),this._worldMatrix}_getViewMatrix(){return h.uq.Identity()}getViewMatrix(e){return!e&&this._isSynchronizedViewMatrix()||(this._hasMoved=!0,this.updateCache(),this._computedViewMatrix=this._getViewMatrix(),this._currentRenderId=this.getScene().getRenderId(),this._childUpdateId++,this._refreshFrustumPlanes=!0,this._cameraRigParams&&this._cameraRigParams.vrPreViewMatrix&&this._computedViewMatrix.multiplyToRef(this._cameraRigParams.vrPreViewMatrix,this._computedViewMatrix),this.parent&&this.parent.onViewMatrixChangedObservable&&this.parent.onViewMatrixChangedObservable.notifyObservers(this.parent),this.onViewMatrixChangedObservable.notifyObservers(this),this._computedViewMatrix.invertToRef(this._worldMatrix)),this._computedViewMatrix}freezeProjectionMatrix(e){this._doNotComputeProjectionMatrix=!0,void 0!==e&&(this._projectionMatrix=e)}unfreezeProjectionMatrix(){this._doNotComputeProjectionMatrix=!1}getProjectionMatrix(e){if(this._doNotComputeProjectionMatrix||!e&&this._isSynchronizedProjectionMatrix())return this._projectionMatrix;this._cache.mode=this.mode,this._cache.minZ=this.minZ,this._cache.maxZ=this.maxZ,this._refreshFrustumPlanes=!0;const t=this.getEngine(),s=this.getScene(),i=t.useReverseDepthBuffer;if(this.mode===g.PERSPECTIVE_CAMERA){let e;this._cache.fov=this.fov,this._cache.fovMode=this.fovMode,this._cache.aspectRatio=t.getAspectRatio(this),this._cache.projectionPlaneTilt=this.projectionPlaneTilt,this.minZ<=0&&(this.minZ=.1),e=s.useRightHandedSystem?h.uq.PerspectiveFovRHToRef:h.uq.PerspectiveFovLHToRef,e(this.fov,t.getAspectRatio(this),i?this.maxZ:this.minZ,i?this.minZ:this.maxZ,this._projectionMatrix,this.fovMode===g.FOVMODE_VERTICAL_FIXED,t.isNDCHalfZRange,this.projectionPlaneTilt,i)}else{const e=t.getRenderWidth()/2,r=t.getRenderHeight()/2;s.useRightHandedSystem?this.oblique?h.uq.ObliqueOffCenterRHToRef(this.orthoLeft??-e,this.orthoRight??e,this.orthoBottom??-r,this.orthoTop??r,i?this.maxZ:this.minZ,i?this.minZ:this.maxZ,this.oblique.length,this.oblique.angle,this._computeObliqueDistance(this.oblique.offset),this._projectionMatrix,t.isNDCHalfZRange):h.uq.OrthoOffCenterRHToRef(this.orthoLeft??-e,this.orthoRight??e,this.orthoBottom??-r,this.orthoTop??r,i?this.maxZ:this.minZ,i?this.minZ:this.maxZ,this._projectionMatrix,t.isNDCHalfZRange):this.oblique?h.uq.ObliqueOffCenterLHToRef(this.orthoLeft??-e,this.orthoRight??e,this.orthoBottom??-r,this.orthoTop??r,i?this.maxZ:this.minZ,i?this.minZ:this.maxZ,this.oblique.length,this.oblique.angle,this._computeObliqueDistance(this.oblique.offset),this._projectionMatrix,t.isNDCHalfZRange):h.uq.OrthoOffCenterLHToRef(this.orthoLeft??-e,this.orthoRight??e,this.orthoBottom??-r,this.orthoTop??r,i?this.maxZ:this.minZ,i?this.minZ:this.maxZ,this._projectionMatrix,t.isNDCHalfZRange),this._cache.orthoLeft=this.orthoLeft,this._cache.orthoRight=this.orthoRight,this._cache.orthoBottom=this.orthoBottom,this._cache.orthoTop=this.orthoTop,this._cache.obliqueAngle=this.oblique?.angle,this._cache.obliqueLength=this.oblique?.length,this._cache.obliqueOffset=this.oblique?.offset,this._cache.renderWidth=t.getRenderWidth(),this._cache.renderHeight=t.getRenderHeight()}return this.onProjectionMatrixChangedObservable.notifyObservers(this),this._projectionMatrix}getTransformationMatrix(){return this._computedViewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix),this._transformMatrix}_computeObliqueDistance(e){return(this.radius||(this.target?h.Pq.Distance(this.position,this.target):this.position.length()))+e}_updateFrustumPlanes(){this._refreshFrustumPlanes&&(this.getTransformationMatrix(),this._frustumPlanes?f.P.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=f.P.GetPlanes(this._transformMatrix),this._refreshFrustumPlanes=!1)}isInFrustum(e,t=!1){if(this._updateFrustumPlanes(),t&&this.rigCameras.length>0){let t=!1;return this.rigCameras.forEach((s=>{s._updateFrustumPlanes(),t=t||e.isInFrustum(s._frustumPlanes)})),t}return e.isInFrustum(this._frustumPlanes)}isCompletelyInFrustum(e){return this._updateFrustumPlanes(),e.isCompletelyInFrustum(this._frustumPlanes)}getForwardRay(e=100,t,s){throw(0,d.n)("Ray")}getForwardRayToRef(e,t=100,s,i){throw(0,d.n)("Ray")}dispose(e,t=!1){for(this.onViewMatrixChangedObservable.clear(),this.onProjectionMatrixChangedObservable.clear(),this.onAfterCheckInputsObservable.clear(),this.onRestoreStateObservable.clear(),this.inputs&&this.inputs.clear(),this.getScene().stopAnimation(this),this.getScene().removeCamera(this);this._rigCameras.length>0;){const e=this._rigCameras.pop();e&&e.dispose()}if(this._parentContainer){const e=this._parentContainer.cameras.indexOf(this);e>-1&&this._parentContainer.cameras.splice(e,1),this._parentContainer=null}if(this._rigPostProcess)this._rigPostProcess.dispose(this),this._rigPostProcess=null,this._postProcesses.length=0;else if(this.cameraRigMode!==g.RIG_MODE_NONE)this._rigPostProcess=null,this._postProcesses.length=0;else{let e=this._postProcesses.length;for(;--e>=0;){const t=this._postProcesses[e];t&&t.dispose(this)}}let s=this.customRenderTargets.length;for(;--s>=0;)this.customRenderTargets[s].dispose();this.customRenderTargets.length=0,this._activeMeshes.dispose(),this.getScene().getEngine().releaseRenderPassId(this.renderPassId),super.dispose(e,t)}get isLeftCamera(){return this._isLeftCamera}get isRightCamera(){return this._isRightCamera}get leftCamera(){return this._rigCameras.length<1?null:this._rigCameras[0]}get rightCamera(){return this._rigCameras.length<2?null:this._rigCameras[1]}getLeftTarget(){return this._rigCameras.length<1?null:this._rigCameras[0].getTarget()}getRightTarget(){return this._rigCameras.length<2?null:this._rigCameras[1].getTarget()}setCameraRigMode(e,t){if(this.cameraRigMode!==e){for(;this._rigCameras.length>0;){const e=this._rigCameras.pop();e&&e.dispose()}if(this.cameraRigMode=e,this._cameraRigParams={},this._cameraRigParams.interaxialDistance=t.interaxialDistance||.0637,this._cameraRigParams.stereoHalfAngle=a.S0.ToRadians(this._cameraRigParams.interaxialDistance/.0637),this.cameraRigMode!==g.RIG_MODE_NONE){const e=this.createRigCamera(this.name+"_L",0);e&&(e._isLeftCamera=!0);const t=this.createRigCamera(this.name+"_R",1);t&&(t._isRightCamera=!0),e&&t&&(this._rigCameras.push(e),this._rigCameras.push(t))}this._setRigMode(t),this._cascadePostProcessesToRigCams(),this.update()}}_setRigMode(e){}_getVRProjectionMatrix(){return h.uq.PerspectiveFovLHToRef(this._cameraRigParams.vrMetrics.aspectRatioFov,this._cameraRigParams.vrMetrics.aspectRatio,this.minZ,this.maxZ,this._cameraRigParams.vrWorkMatrix,!0,this.getEngine().isNDCHalfZRange),this._cameraRigParams.vrWorkMatrix.multiplyToRef(this._cameraRigParams.vrHMatrix,this._projectionMatrix),this._projectionMatrix}setCameraRigParameter(e,t){this._cameraRigParams||(this._cameraRigParams={}),this._cameraRigParams[e]=t,"interaxialDistance"===e&&(this._cameraRigParams.stereoHalfAngle=a.S0.ToRadians(t/.0637))}createRigCamera(e,t){return null}_updateRigCameras(){for(let e=0;eg._CreateDefaultParsedCamera(t,s))}computeWorldMatrix(){return this.getWorldMatrix()}static Parse(e,t){const s=e.type,i=g.GetConstructorFromName(s,e.name,t,e.interaxial_distance,e.isStereoscopicSideBySide),r=p.p.Parse(i,e,t);if(void 0!==e.parentId&&(r._waitingParentId=e.parentId),void 0!==e.parentInstanceIndex&&(r._waitingParentInstanceIndex=e.parentInstanceIndex),r.inputs&&(r.inputs.parse(e),r._setupInputs()),e.upVector&&(r.upVector=h.Pq.FromArray(e.upVector)),r.setPosition&&(r.position.copyFromFloats(0,0,0),r.setPosition(h.Pq.FromArray(e.position))),e.target&&r.setTarget&&r.setTarget(h.Pq.FromArray(e.target)),e.cameraRigMode){const t=e.interaxial_distance?{interaxialDistance:e.interaxial_distance}:{};r.setCameraRigMode(e.cameraRigMode,t)}if(e.animations){for(let t=0;t{throw(0,d.n)("UniversalCamera")},g.PERSPECTIVE_CAMERA=0,g.ORTHOGRAPHIC_CAMERA=1,g.FOVMODE_VERTICAL_FIXED=0,g.FOVMODE_HORIZONTAL_FIXED=1,g.RIG_MODE_NONE=0,g.RIG_MODE_STEREOSCOPIC_ANAGLYPH=10,g.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL=11,g.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED=12,g.RIG_MODE_STEREOSCOPIC_OVERUNDER=13,g.RIG_MODE_STEREOSCOPIC_INTERLACED=14,g.RIG_MODE_VR=20,g.RIG_MODE_CUSTOM=22,g.ForceAttachControlToAlwaysPreventDefault=!1,(0,i.Cg)([(0,r.P_)("position")],g.prototype,"_position",void 0),(0,i.Cg)([(0,r.P_)("upVector")],g.prototype,"_upVector",void 0),(0,i.Cg)([(0,r.lK)()],g.prototype,"orthoLeft",null),(0,i.Cg)([(0,r.lK)()],g.prototype,"orthoRight",null),(0,i.Cg)([(0,r.lK)()],g.prototype,"orthoBottom",null),(0,i.Cg)([(0,r.lK)()],g.prototype,"orthoTop",null),(0,i.Cg)([(0,r.lK)()],g.prototype,"fov",void 0),(0,i.Cg)([(0,r.lK)()],g.prototype,"projectionPlaneTilt",void 0),(0,i.Cg)([(0,r.lK)()],g.prototype,"minZ",void 0),(0,i.Cg)([(0,r.lK)()],g.prototype,"maxZ",void 0),(0,i.Cg)([(0,r.lK)()],g.prototype,"inertia",void 0),(0,i.Cg)([(0,r.lK)()],g.prototype,"mode",null),(0,i.Cg)([(0,r.lK)()],g.prototype,"layerMask",void 0),(0,i.Cg)([(0,r.lK)()],g.prototype,"fovMode",void 0),(0,i.Cg)([(0,r.lK)()],g.prototype,"cameraRigMode",void 0),(0,i.Cg)([(0,r.lK)()],g.prototype,"interaxialDistance",void 0),(0,i.Cg)([(0,r.lK)()],g.prototype,"isStereoscopicSideBySide",void 0)},311:(e,t,s)=>{s.d(t,{G:()=>n});var i=s(9923),r=s(5616);class n{constructor(){this.hit=!1,this.distance=0,this.pickedPoint=null,this.pickedMesh=null,this.bu=0,this.bv=0,this.faceId=-1,this.subMeshFaceId=-1,this.subMeshId=0,this.pickedSprite=null,this.thinInstanceIndex=-1,this.ray=null,this.originMesh=null,this.aimTransform=null,this.gripTransform=null}getNormal(e=!1,t=!0){if(!this.pickedMesh||t&&!this.pickedMesh.isVerticesDataPresent(r.R.NormalKind))return null;let s,n=this.pickedMesh.getIndices();0===n?.length&&(n=null);const a=i.AA.Vector3[0],o=i.AA.Vector3[1],h=i.AA.Vector3[2];if(t){const e=this.pickedMesh.getVerticesData(r.R.NormalKind);let t=n?i.Pq.FromArrayToRef(e,3*n[3*this.faceId],a):a.copyFromFloats(e[3*this.faceId*3],e[3*this.faceId*3+1],e[3*this.faceId*3+2]),l=n?i.Pq.FromArrayToRef(e,3*n[3*this.faceId+1],o):o.copyFromFloats(e[3*(3*this.faceId+1)],e[3*(3*this.faceId+1)+1],e[3*(3*this.faceId+1)+2]),c=n?i.Pq.FromArrayToRef(e,3*n[3*this.faceId+2],h):h.copyFromFloats(e[3*(3*this.faceId+2)],e[3*(3*this.faceId+2)+1],e[3*(3*this.faceId+2)+2]);t=t.scale(this.bu),l=l.scale(this.bv),c=c.scale(1-this.bu-this.bv),s=new i.Pq(t.x+l.x+c.x,t.y+l.y+c.y,t.z+l.z+c.z)}else{const e=this.pickedMesh.getVerticesData(r.R.PositionKind),t=n?i.Pq.FromArrayToRef(e,3*n[3*this.faceId],a):a.copyFromFloats(e[3*this.faceId*3],e[3*this.faceId*3+1],e[3*this.faceId*3+2]),l=n?i.Pq.FromArrayToRef(e,3*n[3*this.faceId+1],o):o.copyFromFloats(e[3*(3*this.faceId+1)],e[3*(3*this.faceId+1)+1],e[3*(3*this.faceId+1)+2]),c=n?i.Pq.FromArrayToRef(e,3*n[3*this.faceId+2],h):h.copyFromFloats(e[3*(3*this.faceId+2)],e[3*(3*this.faceId+2)+1],e[3*(3*this.faceId+2)+2]),u=t.subtract(l),d=c.subtract(l);s=i.Pq.Cross(u,d)}const l=(e,t)=>{let s=e.getWorldMatrix();e.nonUniformScaling&&(i.AA.Matrix[0].copyFrom(s),s=i.AA.Matrix[0],s.setTranslationFromFloats(0,0,0),s.invert(),s.transposeToRef(i.AA.Matrix[1]),s=i.AA.Matrix[1]),i.Pq.TransformNormalToRef(t,s,t)};if(e&&l(this.pickedMesh,s),this.ray){const t=i.AA.Vector3[0].copyFrom(s);e||l(this.pickedMesh,t),i.Pq.Dot(t,this.ray.direction)>0&&s.negateInPlace()}return s.normalize(),s}getTextureCoordinates(e=r.R.UVKind){if(!this.pickedMesh||!this.pickedMesh.isVerticesDataPresent(e))return null;const t=this.pickedMesh.getIndices();if(!t)return null;const s=this.pickedMesh.getVerticesData(e);if(!s)return null;let n=i.I9.FromArray(s,2*t[3*this.faceId]),a=i.I9.FromArray(s,2*t[3*this.faceId+1]),o=i.I9.FromArray(s,2*t[3*this.faceId+2]);return n=n.scale(this.bu),a=a.scale(this.bv),o=o.scale(1-this.bu-this.bv),new i.I9(n.x+a.x+o.x,n.y+a.y+o.y)}}},1313:(e,t,s)=>{s.d(t,{rX:()=>i});let i=!1},2564:(e,t,s)=>{s.d(t,{j:()=>d});var i=s(7309),r=s(9923),n=s(5559);class a{constructor(e,t,s){this.vectors=(0,i.mI)(8,r.Pq.Zero),this.center=r.Pq.Zero(),this.centerWorld=r.Pq.Zero(),this.extendSize=r.Pq.Zero(),this.extendSizeWorld=r.Pq.Zero(),this.directions=(0,i.mI)(3,r.Pq.Zero),this.vectorsWorld=(0,i.mI)(8,r.Pq.Zero),this.minimumWorld=r.Pq.Zero(),this.maximumWorld=r.Pq.Zero(),this.minimum=r.Pq.Zero(),this.maximum=r.Pq.Zero(),this._drawWrapperFront=null,this._drawWrapperBack=null,this.reConstruct(e,t,s)}reConstruct(e,t,s){const i=e.x,n=e.y,a=e.z,o=t.x,h=t.y,l=t.z,c=this.vectors;this.minimum.copyFromFloats(i,n,a),this.maximum.copyFromFloats(o,h,l),c[0].copyFromFloats(i,n,a),c[1].copyFromFloats(o,h,l),c[2].copyFromFloats(o,n,a),c[3].copyFromFloats(i,h,a),c[4].copyFromFloats(i,n,l),c[5].copyFromFloats(o,h,a),c[6].copyFromFloats(i,h,l),c[7].copyFromFloats(o,n,l),t.addToRef(e,this.center).scaleInPlace(.5),t.subtractToRef(e,this.extendSize).scaleInPlace(.5),this._worldMatrix=s||r.uq.IdentityReadOnly,this._update(this._worldMatrix)}scale(e){const t=a._TmpVector3,s=this.maximum.subtractToRef(this.minimum,t[0]),i=s.length();s.normalizeFromLength(i);const r=i*e,n=s.scaleInPlace(.5*r),o=this.center.subtractToRef(n,t[1]),h=this.center.addToRef(n,t[2]);return this.reConstruct(o,h,this._worldMatrix),this}getWorldMatrix(){return this._worldMatrix}_update(e){const t=this.minimumWorld,s=this.maximumWorld,i=this.directions,n=this.vectorsWorld,a=this.vectors;if(e.isIdentity()){t.copyFrom(this.minimum),s.copyFrom(this.maximum);for(let e=0;e<8;++e)n[e].copyFrom(a[e]);this.extendSizeWorld.copyFrom(this.extendSize),this.centerWorld.copyFrom(this.center)}else{t.setAll(Number.MAX_VALUE),s.setAll(-Number.MAX_VALUE);for(let i=0;i<8;++i){const o=n[i];r.Pq.TransformCoordinatesToRef(a[i],e,o),t.minimizeInPlace(o),s.maximizeInPlace(o)}s.subtractToRef(t,this.extendSizeWorld).scaleInPlace(.5),s.addToRef(t,this.centerWorld).scaleInPlace(.5)}r.Pq.FromArrayToRef(e.m,0,i[0]),r.Pq.FromArrayToRef(e.m,4,i[1]),r.Pq.FromArrayToRef(e.m,8,i[2]),this._worldMatrix=e}isInFrustum(e){return a.IsInFrustum(this.vectorsWorld,e)}isCompletelyInFrustum(e){return a.IsCompletelyInFrustum(this.vectorsWorld,e)}intersectsPoint(e){const t=this.minimumWorld,s=this.maximumWorld,i=t.x,r=t.y,a=t.z,o=s.x,h=s.y,l=s.z,c=e.x,u=e.y,d=e.z,_=-n.bH;return!(o-c<_||_>c-i||h-u<_||_>u-r||l-d<_||_>d-a)}intersectsSphere(e){return a.IntersectsSphere(this.minimumWorld,this.maximumWorld,e.centerWorld,e.radiusWorld)}intersectsMinMax(e,t){const s=this.minimumWorld,i=this.maximumWorld,r=s.x,n=s.y,a=s.z,o=i.x,h=i.y,l=i.z,c=e.x,u=e.y,d=e.z,_=t.x,f=t.y,p=t.z;return!(o_||hf||lp)}dispose(){this._drawWrapperFront?.dispose(),this._drawWrapperBack?.dispose()}static Intersects(e,t){return e.intersectsMinMax(t.minimumWorld,t.maximumWorld)}static IntersectsSphere(e,t,s,i){const n=a._TmpVector3[0];return r.Pq.ClampToRef(s,e,t,n),r.Pq.DistanceSquared(s,n)<=i*i}static IsCompletelyInFrustum(e,t){for(let s=0;s<6;++s){const i=t[s];for(let t=0;t<8;++t)if(i.dotCoordinate(e[t])<0)return!1}return!0}static IsInFrustum(e,t){for(let s=0;s<6;++s){let i=!0;const r=t[s];for(let t=0;t<8;++t)if(r.dotCoordinate(e[t])>=0){i=!1;break}if(i)return!1}return!0}}a._TmpVector3=(0,i.mI)(3,r.Pq.Zero);class o{constructor(e,t,s){this.center=r.Pq.Zero(),this.centerWorld=r.Pq.Zero(),this.minimum=r.Pq.Zero(),this.maximum=r.Pq.Zero(),this.reConstruct(e,t,s)}reConstruct(e,t,s){this.minimum.copyFrom(e),this.maximum.copyFrom(t);const i=r.Pq.Distance(e,t);t.addToRef(e,this.center).scaleInPlace(.5),this.radius=.5*i,this._update(s||r.uq.IdentityReadOnly)}scale(e){const t=this.radius*e,s=o._TmpVector3,i=s[0].setAll(t),r=this.center.subtractToRef(i,s[1]),n=this.center.addToRef(i,s[2]);return this.reConstruct(r,n,this._worldMatrix),this}getWorldMatrix(){return this._worldMatrix}_update(e){if(e.isIdentity())this.centerWorld.copyFrom(this.center),this.radiusWorld=this.radius;else{r.Pq.TransformCoordinatesToRef(this.center,e,this.centerWorld);const t=o._TmpVector3[0];r.Pq.TransformNormalFromFloatsToRef(1,1,1,e,t),this.radiusWorld=Math.max(Math.abs(t.x),Math.abs(t.y),Math.abs(t.z))*this.radius}}isInFrustum(e){const t=this.centerWorld,s=this.radiusWorld;for(let i=0;i<6;i++)if(e[i].dotCoordinate(t)<=-s)return!1;return!0}isCenterInFrustum(e){const t=this.centerWorld;for(let s=0;s<6;s++)if(e[s].dotCoordinate(t)<0)return!1;return!0}intersectsPoint(e){const t=r.Pq.DistanceSquared(this.centerWorld,e);return!(this.radiusWorld*this.radiusWorld{const i=r.Pq.Dot(t.centerWorld,e),n=Math.abs(r.Pq.Dot(t.directions[0],e))*t.extendSize.x+Math.abs(r.Pq.Dot(t.directions[1],e))*t.extendSize.y+Math.abs(r.Pq.Dot(t.directions[2],e))*t.extendSize.z;s.min=i-n,s.max=i+n},u=(e,t,s)=>(c(e,t,h),c(e,s,l),!(h.min>l.max||l.min>h.max));class d{constructor(e,t,s){this._isLocked=!1,this.boundingBox=new a(e,t,s),this.boundingSphere=new o(e,t,s)}reConstruct(e,t,s){this.boundingBox.reConstruct(e,t,s),this.boundingSphere.reConstruct(e,t,s)}get minimum(){return this.boundingBox.minimum}get maximum(){return this.boundingBox.maximum}get isLocked(){return this._isLocked}set isLocked(e){this._isLocked=e}update(e){this._isLocked||(this.boundingBox._update(e),this.boundingSphere._update(e))}centerOn(e,t){const s=d._TmpVector3[0].copyFrom(e).subtractInPlace(t),i=d._TmpVector3[1].copyFrom(e).addInPlace(t);return this.boundingBox.reConstruct(s,i,this.boundingBox.getWorldMatrix()),this.boundingSphere.reConstruct(s,i,this.boundingBox.getWorldMatrix()),this}encapsulate(e){const t=r.Pq.Minimize(this.minimum,e),s=r.Pq.Maximize(this.maximum,e);return this.reConstruct(t,s,this.boundingBox.getWorldMatrix()),this}encapsulateBoundingInfo(e){const t=r.AA.Matrix[0];this.boundingBox.getWorldMatrix().invertToRef(t);const s=r.AA.Vector3[0];return r.Pq.TransformCoordinatesToRef(e.boundingBox.minimumWorld,t,s),this.encapsulate(s),r.Pq.TransformCoordinatesToRef(e.boundingBox.maximumWorld,t,s),this.encapsulate(s),this}scale(e){return this.boundingBox.scale(e),this.boundingSphere.scale(e),this}isInFrustum(e,t=0){return!(2!==t&&3!==t||!this.boundingSphere.isCenterInFrustum(e))||!!this.boundingSphere.isInFrustum(e)&&(!(1!==t&&3!==t)||this.boundingBox.isInFrustum(e))}get diagonalLength(){const e=this.boundingBox;return e.maximumWorld.subtractToRef(e.minimumWorld,d._TmpVector3[0]).length()}isCompletelyInFrustum(e){return this.boundingBox.isCompletelyInFrustum(e)}_checkCollision(e){return e._canDoCollision(this.boundingSphere.centerWorld,this.boundingSphere.radiusWorld,this.boundingBox.minimumWorld,this.boundingBox.maximumWorld)}intersectsPoint(e){return!!this.boundingSphere.centerWorld&&!!this.boundingSphere.intersectsPoint(e)&&!!this.boundingBox.intersectsPoint(e)}intersects(e,t){if(!o.Intersects(this.boundingSphere,e.boundingSphere))return!1;if(!a.Intersects(this.boundingBox,e.boundingBox))return!1;if(!t)return!0;const s=this.boundingBox,i=e.boundingBox;return!!(u(s.directions[0],s,i)&&u(s.directions[1],s,i)&&u(s.directions[2],s,i)&&u(i.directions[0],s,i)&&u(i.directions[1],s,i)&&u(i.directions[2],s,i)&&u(r.Pq.Cross(s.directions[0],i.directions[0]),s,i)&&u(r.Pq.Cross(s.directions[0],i.directions[1]),s,i)&&u(r.Pq.Cross(s.directions[0],i.directions[2]),s,i)&&u(r.Pq.Cross(s.directions[1],i.directions[0]),s,i)&&u(r.Pq.Cross(s.directions[1],i.directions[1]),s,i)&&u(r.Pq.Cross(s.directions[1],i.directions[2]),s,i)&&u(r.Pq.Cross(s.directions[2],i.directions[0]),s,i)&&u(r.Pq.Cross(s.directions[2],i.directions[1]),s,i)&&u(r.Pq.Cross(s.directions[2],i.directions[2]),s,i))}}d._TmpVector3=(0,i.mI)(2,r.Pq.Zero)},9125:(e,t,s)=>{s.d(t,{nO:()=>M,pB:()=>A,M0:()=>R,Iq:()=>S,J:()=>I});class i{constructor(){this.children=[]}isValid(e){return!0}process(e,t){let s="";if(this.line){let i=this.line;const r=t.processor;if(r){r.lineProcessor&&(i=r.lineProcessor(i,t.isFragment,t.processingContext));const s=t.processor?.attributeKeywordName??"attribute",n=t.isFragment&&t.processor?.varyingFragmentKeywordName?t.processor?.varyingFragmentKeywordName:!t.isFragment&&t.processor?.varyingVertexKeywordName?t.processor?.varyingVertexKeywordName:"varying";!t.isFragment&&r.attributeProcessor&&this.line.startsWith(s)?i=r.attributeProcessor(this.line,e,t.processingContext):r.varyingProcessor&&(r.varyingCheck?.(this.line,t.isFragment)||!r.varyingCheck&&this.line.startsWith(n))?i=r.varyingProcessor(this.line,t.isFragment,e,t.processingContext):r.uniformProcessor&&r.uniformRegexp&&r.uniformRegexp.test(this.line)?t.lookForClosingBracketForUniformBuffer||(i=r.uniformProcessor(this.line,t.isFragment,e,t.processingContext)):r.uniformBufferProcessor&&r.uniformBufferRegexp&&r.uniformBufferRegexp.test(this.line)?t.lookForClosingBracketForUniformBuffer||(i=r.uniformBufferProcessor(this.line,t.isFragment,t.processingContext),t.lookForClosingBracketForUniformBuffer=!0):r.textureProcessor&&r.textureRegexp&&r.textureRegexp.test(this.line)?i=r.textureProcessor(this.line,t.isFragment,e,t.processingContext):(r.uniformProcessor||r.uniformBufferProcessor)&&this.line.startsWith("uniform")&&!t.lookForClosingBracketForUniformBuffer&&(/uniform\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s+(\S+)\s*;/.test(this.line)?r.uniformProcessor&&(i=r.uniformProcessor(this.line,t.isFragment,e,t.processingContext)):r.uniformBufferProcessor&&(i=r.uniformBufferProcessor(this.line,t.isFragment,t.processingContext),t.lookForClosingBracketForUniformBuffer=!0)),t.lookForClosingBracketForUniformBuffer&&-1!==this.line.indexOf("}")&&(t.lookForClosingBracketForUniformBuffer=!1,r.endOfUniformBufferProcessor&&(i=r.endOfUniformBufferProcessor(this.line,t.isFragment,t.processingContext)))}s+=i+"\n"}return this.children.forEach((i=>{s+=i.process(e,t)})),this.additionalDefineKey&&(e[this.additionalDefineKey]=this.additionalDefineValue||"true"),s}}class r{constructor(){this._lines=[]}get currentLine(){return this._lines[this.lineIndex]}get canRead(){return this.lineIndex1&&this._lines.push(e);else{const e=t.split(";");for(let t=0;t{c=c.trim(),""!==c&&(s.push(c),c="")},n=e=>{io._Stack[i],h=()=>-1===i?"!!INVALID EXPRESSION!!":o._Stack[i--];let l=0,c="";for(;l1){for(r();-1!==i&&o._OperatorPriority[a()]>=o._OperatorPriority[u];)s.push(h());n(u),l++}else c+=t;l++}for(r();-1!==i;)"("===a()?h():s.push(h());return o._InfixToPostfixCache.size>=o.InfixToPostfixCacheLimitSize&&o.ClearCache(),o._InfixToPostfixCache.set(e,{result:s,accessTime:Date.now()}),s}static ClearCache(){const e=Array.from(o._InfixToPostfixCache.entries()).sort(((e,t)=>e[1].accessTime-t[1].accessTime));for(let t=0;t":s=i>r;break;case"<":s=i=":s=i>=r;break;case"==":s=i===r;break;case"!=":s=i!==r}return s}}var d=s(5503),_=s(6741);const f=/defined\s*?\((.+?)\)/g,p=/defined\s*?\[(.+?)\]/g,g=/#include\s?<(.+)>(\((.*)\))*(\[(.*)\])*/g,m=/__decl__/,T=/light\{X\}.(\w*)/g,b=/\{X\}/g,E=[],x=/(#ifdef)|(#else)|(#elif)|(#endif)|(#ifndef)|(#if)/;function A(e){e.processor&&e.processor.initializeShaders&&e.processor.initializeShaders(e.processingContext)}function R(e,t,s,n){t.processor?.preProcessShaderCode&&(e=t.processor.preProcessShaderCode(e,t.isFragment)),S(e,t,(e=>{t.processCodeAfterIncludes&&(e=t.processCodeAfterIncludes(t.isFragment?"fragment":"vertex",e,t.defines));const a=function(e,t,s){let n=function(e,t){if(t.processor?.noPrecision)return e;const s=t.shouldUseHighPrecisionShader;return-1===e.indexOf("precision highp float")?e=s?"precision highp float;\n"+e:"precision mediump float;\n"+e:s||(e=e.replace("precision highp float","precision mediump float")),e}(e,t);if(!t.processor)return n;if(0===t.processor.shaderLanguage&&-1!==n.indexOf("#version 3")&&(n=n.replace("#version 300 es",""),!t.processor.parseGLES3))return n;const a=t.defines,o=function(e,t){const s=e.defines,i={};for(const e of s){const t=e.replace("#define","").replace(";","").trim().split(" ");i[t[0]]=t.length>1?t[1]:""}return 0===e.processor?.shaderLanguage&&(i.GL_ES="true"),i.__VERSION__=e.version,i[e.platformName]="true",(0,_.xt)(i,t?.isNDCHalfZRange,t?.useReverseDepthBuffer,t?.useExactSrgbConversions),i}(t,s);return t.processor.preProcessor&&(n=t.processor.preProcessor(n,a,o,t.isFragment,t.processingContext)),n=function(e,t,s){const n=new i,a=new r;return a.lineIndex=-1,a.lines=e.split("\n"),C(a,n),n.process(t,s)}(n,o,t),t.processor.postProcessor&&(n=t.processor.postProcessor(n,a,t.isFragment,t.processingContext,s?{drawBuffersExtensionDisabled:!s.getCaps().drawBuffersExtension}:{})),s?._features.needShaderCodeInlining&&(n=s.inlineShaderCode(n)),n}(e,t,n);s(a,e)}))}function M(e,t,s){return s.processor&&s.processor.finalizeShaders?s.processor.finalizeShaders(e,t,s.processingContext):{vertexCode:e,fragmentCode:t}}function y(e){const t=/defined\((.+)\)/.exec(e);if(t&&t.length)return new h(t[1].trim(),"!"===e[0]);const s=["==","!=",">=","<=","<",">"];let i="",r=0;for(i of s)if(r=e.indexOf(i),r>-1)break;if(-1===r)return new h(e);const n=e.substring(0,r).trim(),a=e.substring(r+i.length).trim();return new u(n,i,a)}function P(e,t){const s=new a,i=e.substring(0,t);let r=e.substring(t);return r=r.substring(0,(r.indexOf("//")+1||r.length+1)-1).trim(),s.testExpression="#ifdef"===i?new h(r):"#ifndef"===i?new h(r,!0):function(e){e=e.replace(f,"defined[$1]");const t=o.infixToPostfix(e),s=[];for(const e of t)if("||"!==e&&"&&"!==e)s.push(e);else if(s.length>=2){let t=s[s.length-1],i=s[s.length-2];s.length-=2;const r="&&"==e?new c:new l;"string"==typeof t&&(t=t.replace(p,"defined($1)")),"string"==typeof i&&(i=i.replace(p,"defined($1)")),r.leftOperand="string"==typeof i?y(i):i,r.rightOperand="string"==typeof t?y(t):t,s.push(r)}let i=s[s.length-1];return"string"==typeof i&&(i=i.replace(p,"defined($1)")),"string"==typeof i?y(i):i}(r),s}function v(e,t,s){let r=e.currentLine;for(;C(e,s);){r=e.currentLine;const n=r.substring(0,5).toLowerCase();if("#else"===n){const s=new i;return t.children.push(s),void C(e,s)}if("#elif"===n){const e=P(r,5);t.children.push(e),s=e}}}function C(e,t){for(;e.canRead;){e.lineIndex++;const s=e.currentLine;if(s.indexOf("#")>=0){const i=x.exec(s);if(i&&i.length){switch(i[0]){case"#ifdef":{const i=new n;t.children.push(i);const r=P(s,6);i.children.push(r),v(e,i,r);break}case"#else":case"#elif":return!0;case"#endif":return!1;case"#ifndef":{const i=new n;t.children.push(i);const r=P(s,7);i.children.push(r),v(e,i,r);break}case"#if":{const i=new n,r=P(s,3);t.children.push(i),i.children.push(r),v(e,i,r);break}}continue}}const r=new i;if(r.line=s,t.children.push(r),"#"===s[0]&&"d"===s[1]){const e=s.replace(";","").split(" ");r.additionalDefineKey=e[1],3===e.length&&(r.additionalDefineValue=e[2])}}return!1}function S(e,t,s){let i;for(E.length=0;null!==(i=g.exec(e));)E.push(i);let r=String(e),n=[e],a=!1;for(const e of E){let i=e[1];if(-1!==i.indexOf("__decl__")&&(i=i.replace(m,""),t.supportsUniformBuffers&&(i=i.replace("Vertex","Ubo").replace("Fragment","Ubo")),i+="Declaration"),!t.includesShadersStore[i]){const e=t.shadersRepository+"ShadersInclude/"+i+".fx";return void I.loadFile(e,(e=>{t.includesShadersStore[i]=e,S(n.join(""),t,s)}))}{let s=t.includesShadersStore[i];if(e[2]){const t=e[3].split(",");for(let e=0;et+"{X}"))),s+=a.replace(b,e.toString())+"\n"}else t.supportsUniformBuffers||(s=s.replace(T,((e,t)=>t+"{X}"))),s=s.replace(b,i)}const r=[];for(const t of n){const i=t.split(e[0]);for(let e=0;e=0||s.indexOf("#include <")>=0}}E.length=0,r=n.join(""),a?S(r.toString(),t,s):s(r)}const I={loadFile:(e,t,s,i,r,n)=>{throw(0,d.n)("FileTools")}}},7716:(e,t,s)=>{s.d(t,{d:()=>i});class i{get underlyingResource(){return this._webGLTexture}constructor(e=null,t){if(this._MSAARenderBuffers=null,this._context=t,!e&&!(e=t.createTexture()))throw new Error("Unable to create webGL texture");this.set(e)}setUsage(){}set(e){this._webGLTexture=e}reset(){this._webGLTexture=null,this._MSAARenderBuffers=null}addMSAARenderBuffer(e){this._MSAARenderBuffers||(this._MSAARenderBuffers=[]),this._MSAARenderBuffers.push(e)}releaseMSAARenderBuffers(){if(this._MSAARenderBuffers){for(const e of this._MSAARenderBuffers)this._context.deleteRenderbuffer(e);this._MSAARenderBuffers=null}}getMSAARenderBuffer(e=0){return this._MSAARenderBuffers?.[e]??null}release(){this.releaseMSAARenderBuffers(),this._webGLTexture&&this._context.deleteTexture(this._webGLTexture),this.reset()}}},6741:(e,t,s)=>{s.d(t,{W0:()=>a,iL:()=>n,kZ:()=>h,sg:()=>r,xt:()=>o});var i=s(5503);s(8790);const r={};function n(e,t,s=""){return s+(t?t+"\n":"")+e}function a(e,t,s,n,a,o,h){const l=h||r.loadFile;if(l)return l(e,t,s,n,a,o);throw(0,i.n)("FileTools")}function o(e,t,s,i){if(e)return t?e.IS_NDC_HALF_ZRANGE="":delete e.IS_NDC_HALF_ZRANGE,s?e.USE_REVERSE_DEPTHBUFFER="":delete e.USE_REVERSE_DEPTHBUFFER,void(i?e.USE_EXACT_SRGB_CONVERSIONS="":delete e.USE_EXACT_SRGB_CONVERSIONS);{let e="";return t&&(e+="#define IS_NDC_HALF_ZRANGE"),s&&(e&&(e+="\n"),e+="#define USE_REVERSE_DEPTHBUFFER"),i&&(e&&(e+="\n"),e+="#define USE_EXACT_SRGB_CONVERSIONS"),e}}function h(e,t,s=!1,i){switch(e){case 3:{const e=(ArrayBuffer,new Int8Array(t));return i&&e.set(new Int8Array(i)),e}case 0:{const e=(ArrayBuffer,new Uint8Array(t));return i&&e.set(new Uint8Array(i)),e}case 4:{const e=t instanceof ArrayBuffer?new Int16Array(t):new Int16Array(s?t/2:t);return i&&e.set(new Int16Array(i)),e}case 5:case 8:case 9:case 10:case 2:{const e=t instanceof ArrayBuffer?new Uint16Array(t):new Uint16Array(s?t/2:t);return i&&e.set(new Uint16Array(i)),e}case 6:{const e=t instanceof ArrayBuffer?new Int32Array(t):new Int32Array(s?t/4:t);return i&&e.set(new Int32Array(i)),e}case 7:case 11:case 12:case 13:case 14:case 15:{const e=t instanceof ArrayBuffer?new Uint32Array(t):new Uint32Array(s?t/4:t);return i&&e.set(new Uint32Array(i)),e}case 1:{const e=t instanceof ArrayBuffer?new Float32Array(t):new Float32Array(s?t/4:t);return i&&e.set(new Float32Array(i)),e}}const r=(ArrayBuffer,new Uint8Array(t));return i&&r.set(new Uint8Array(i)),r}},6326:(e,t,s)=>{s.d(t,{$:()=>b});var i=s(6315),r=s(1137),n=s(4420),a=s(215),o=s(6237);class h{constructor(e=!0){this._isDepthTestDirty=!1,this._isDepthMaskDirty=!1,this._isDepthFuncDirty=!1,this._isCullFaceDirty=!1,this._isCullDirty=!1,this._isZOffsetDirty=!1,this._isFrontFaceDirty=!1,e&&this.reset()}get isDirty(){return this._isDepthFuncDirty||this._isDepthTestDirty||this._isDepthMaskDirty||this._isCullFaceDirty||this._isCullDirty||this._isZOffsetDirty||this._isFrontFaceDirty}get zOffset(){return this._zOffset}set zOffset(e){this._zOffset!==e&&(this._zOffset=e,this._isZOffsetDirty=!0)}get zOffsetUnits(){return this._zOffsetUnits}set zOffsetUnits(e){this._zOffsetUnits!==e&&(this._zOffsetUnits=e,this._isZOffsetDirty=!0)}get cullFace(){return this._cullFace}set cullFace(e){this._cullFace!==e&&(this._cullFace=e,this._isCullFaceDirty=!0)}get cull(){return this._cull}set cull(e){this._cull!==e&&(this._cull=e,this._isCullDirty=!0)}get depthFunc(){return this._depthFunc}set depthFunc(e){this._depthFunc!==e&&(this._depthFunc=e,this._isDepthFuncDirty=!0)}get depthMask(){return this._depthMask}set depthMask(e){this._depthMask!==e&&(this._depthMask=e,this._isDepthMaskDirty=!0)}get depthTest(){return this._depthTest}set depthTest(e){this._depthTest!==e&&(this._depthTest=e,this._isDepthTestDirty=!0)}get frontFace(){return this._frontFace}set frontFace(e){this._frontFace!==e&&(this._frontFace=e,this._isFrontFaceDirty=!0)}reset(){this._depthMask=!0,this._depthTest=!0,this._depthFunc=null,this._cullFace=null,this._cull=null,this._zOffset=0,this._zOffsetUnits=0,this._frontFace=null,this._isDepthTestDirty=!0,this._isDepthMaskDirty=!0,this._isDepthFuncDirty=!1,this._isCullFaceDirty=!1,this._isCullDirty=!1,this._isZOffsetDirty=!0,this._isFrontFaceDirty=!1}apply(e){this.isDirty&&(this._isCullDirty&&(this.cull?e.enable(e.CULL_FACE):e.disable(e.CULL_FACE),this._isCullDirty=!1),this._isCullFaceDirty&&(e.cullFace(this.cullFace),this._isCullFaceDirty=!1),this._isDepthMaskDirty&&(e.depthMask(this.depthMask),this._isDepthMaskDirty=!1),this._isDepthTestDirty&&(this.depthTest?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST),this._isDepthTestDirty=!1),this._isDepthFuncDirty&&(e.depthFunc(this.depthFunc),this._isDepthFuncDirty=!1),this._isZOffsetDirty&&(this.zOffset||this.zOffsetUnits?(e.enable(e.POLYGON_OFFSET_FILL),e.polygonOffset(this.zOffset,this.zOffsetUnits)):e.disable(e.POLYGON_OFFSET_FILL),this._isZOffsetDirty=!1),this._isFrontFaceDirty&&(e.frontFace(this.frontFace),this._isFrontFaceDirty=!1))}}class l{get isDirty(){return this._isStencilTestDirty||this._isStencilMaskDirty||this._isStencilFuncDirty||this._isStencilOpDirty}get func(){return this._func}set func(e){this._func!==e&&(this._func=e,this._isStencilFuncDirty=!0)}get funcRef(){return this._funcRef}set funcRef(e){this._funcRef!==e&&(this._funcRef=e,this._isStencilFuncDirty=!0)}get funcMask(){return this._funcMask}set funcMask(e){this._funcMask!==e&&(this._funcMask=e,this._isStencilFuncDirty=!0)}get opStencilFail(){return this._opStencilFail}set opStencilFail(e){this._opStencilFail!==e&&(this._opStencilFail=e,this._isStencilOpDirty=!0)}get opDepthFail(){return this._opDepthFail}set opDepthFail(e){this._opDepthFail!==e&&(this._opDepthFail=e,this._isStencilOpDirty=!0)}get opStencilDepthPass(){return this._opStencilDepthPass}set opStencilDepthPass(e){this._opStencilDepthPass!==e&&(this._opStencilDepthPass=e,this._isStencilOpDirty=!0)}get mask(){return this._mask}set mask(e){this._mask!==e&&(this._mask=e,this._isStencilMaskDirty=!0)}get enabled(){return this._enabled}set enabled(e){this._enabled!==e&&(this._enabled=e,this._isStencilTestDirty=!0)}constructor(e=!0){this._isStencilTestDirty=!1,this._isStencilMaskDirty=!1,this._isStencilFuncDirty=!1,this._isStencilOpDirty=!1,this.useStencilGlobalOnly=!1,e&&this.reset()}reset(){this.stencilMaterial=void 0,this.stencilGlobal?.reset(),this._isStencilTestDirty=!0,this._isStencilMaskDirty=!0,this._isStencilFuncDirty=!0,this._isStencilOpDirty=!0}apply(e){if(!e)return;const t=!this.useStencilGlobalOnly&&!!this.stencilMaterial?.enabled;this.enabled=t?this.stencilMaterial.enabled:this.stencilGlobal.enabled,this.func=t?this.stencilMaterial.func:this.stencilGlobal.func,this.funcRef=t?this.stencilMaterial.funcRef:this.stencilGlobal.funcRef,this.funcMask=t?this.stencilMaterial.funcMask:this.stencilGlobal.funcMask,this.opStencilFail=t?this.stencilMaterial.opStencilFail:this.stencilGlobal.opStencilFail,this.opDepthFail=t?this.stencilMaterial.opDepthFail:this.stencilGlobal.opDepthFail,this.opStencilDepthPass=t?this.stencilMaterial.opStencilDepthPass:this.stencilGlobal.opStencilDepthPass,this.mask=t?this.stencilMaterial.mask:this.stencilGlobal.mask,this.isDirty&&(this._isStencilTestDirty&&(this.enabled?e.enable(e.STENCIL_TEST):e.disable(e.STENCIL_TEST),this._isStencilTestDirty=!1),this._isStencilMaskDirty&&(e.stencilMask(this.mask),this._isStencilMaskDirty=!1),this._isStencilFuncDirty&&(e.stencilFunc(this.func,this.funcRef,this.funcMask),this._isStencilFuncDirty=!1),this._isStencilOpDirty&&(e.stencilOp(this.opStencilFail,this.opDepthFail,this.opStencilDepthPass),this._isStencilOpDirty=!1))}}class c{constructor(){this.reset()}reset(){this.enabled=!1,this.mask=255,this.func=c.ALWAYS,this.funcRef=1,this.funcMask=255,this.opStencilFail=c.KEEP,this.opDepthFail=c.KEEP,this.opStencilDepthPass=c.REPLACE}get stencilFunc(){return this.func}set stencilFunc(e){this.func=e}get stencilFuncRef(){return this.funcRef}set stencilFuncRef(e){this.funcRef=e}get stencilFuncMask(){return this.funcMask}set stencilFuncMask(e){this.funcMask=e}get stencilOpStencilFail(){return this.opStencilFail}set stencilOpStencilFail(e){this.opStencilFail=e}get stencilOpDepthFail(){return this.opDepthFail}set stencilOpDepthFail(e){this.opDepthFail=e}get stencilOpStencilDepthPass(){return this.opStencilDepthPass}set stencilOpStencilDepthPass(e){this.opStencilDepthPass=e}get stencilMask(){return this.mask}set stencilMask(e){this.mask=e}get stencilTest(){return this.enabled}set stencilTest(e){this.enabled=e}}c.ALWAYS=519,c.KEEP=7680,c.REPLACE=7681;class u{constructor(){this._blendFunctionParameters=new Array(4),this._blendEquationParameters=new Array(2),this._blendConstants=new Array(4),this._isBlendConstantsDirty=!1,this._alphaBlend=!1,this._isAlphaBlendDirty=!1,this._isBlendFunctionParametersDirty=!1,this._isBlendEquationParametersDirty=!1,this.reset()}get isDirty(){return this._isAlphaBlendDirty||this._isBlendFunctionParametersDirty||this._isBlendEquationParametersDirty}get alphaBlend(){return this._alphaBlend}set alphaBlend(e){this._alphaBlend!==e&&(this._alphaBlend=e,this._isAlphaBlendDirty=!0)}setAlphaBlendConstants(e,t,s,i){this._blendConstants[0]===e&&this._blendConstants[1]===t&&this._blendConstants[2]===s&&this._blendConstants[3]===i||(this._blendConstants[0]=e,this._blendConstants[1]=t,this._blendConstants[2]=s,this._blendConstants[3]=i,this._isBlendConstantsDirty=!0)}setAlphaBlendFunctionParameters(e,t,s,i){this._blendFunctionParameters[0]===e&&this._blendFunctionParameters[1]===t&&this._blendFunctionParameters[2]===s&&this._blendFunctionParameters[3]===i||(this._blendFunctionParameters[0]=e,this._blendFunctionParameters[1]=t,this._blendFunctionParameters[2]=s,this._blendFunctionParameters[3]=i,this._isBlendFunctionParametersDirty=!0)}setAlphaEquationParameters(e,t){this._blendEquationParameters[0]===e&&this._blendEquationParameters[1]===t||(this._blendEquationParameters[0]=e,this._blendEquationParameters[1]=t,this._isBlendEquationParametersDirty=!0)}reset(){this._alphaBlend=!1,this._blendFunctionParameters[0]=null,this._blendFunctionParameters[1]=null,this._blendFunctionParameters[2]=null,this._blendFunctionParameters[3]=null,this._blendEquationParameters[0]=null,this._blendEquationParameters[1]=null,this._blendConstants[0]=null,this._blendConstants[1]=null,this._blendConstants[2]=null,this._blendConstants[3]=null,this._isAlphaBlendDirty=!0,this._isBlendFunctionParametersDirty=!1,this._isBlendEquationParametersDirty=!1,this._isBlendConstantsDirty=!1}apply(e){this.isDirty&&(this._isAlphaBlendDirty&&(this._alphaBlend?e.enable(e.BLEND):e.disable(e.BLEND),this._isAlphaBlendDirty=!1),this._isBlendFunctionParametersDirty&&(e.blendFuncSeparate(this._blendFunctionParameters[0],this._blendFunctionParameters[1],this._blendFunctionParameters[2],this._blendFunctionParameters[3]),this._isBlendFunctionParametersDirty=!1),this._isBlendEquationParametersDirty&&(e.blendEquationSeparate(this._blendEquationParameters[0],this._blendEquationParameters[1]),this._isBlendEquationParametersDirty=!1),this._isBlendConstantsDirty&&(e.blendColor(this._blendConstants[0],this._blendConstants[1],this._blendConstants[2],this._blendConstants[3]),this._isBlendConstantsDirty=!1))}}var d=s(5503),_=s(854),f=s(8790),p=s(9848),g=s(6741),m=s(8454);function T(e,t){if((0,f.BA)()){const{requestAnimationFrame:s}=t||window;if("function"==typeof s)return s(e)}else if("function"==typeof requestAnimationFrame)return requestAnimationFrame(e);return setTimeout(e,16)}class b{get frameId(){return this._frameId}get isWebGPU(){return this._isWebGPU}_getShaderProcessor(e){return this._shaderProcessor}get shaderPlatformName(){return this._shaderPlatformName}_clearEmptyResources(){this._emptyTexture=null,this._emptyCubeTexture=null,this._emptyTexture3D=null,this._emptyTexture2DArray=null}get useReverseDepthBuffer(){return this._useReverseDepthBuffer}set useReverseDepthBuffer(e){e!==this._useReverseDepthBuffer&&(this._useReverseDepthBuffer=e,this._depthCullingState.depthFunc=e?518:515)}setColorWrite(e){e!==this._colorWrite&&(this._colorWriteChanged=!0,this._colorWrite=e)}getColorWrite(){return this._colorWrite}get depthCullingState(){return this._depthCullingState}get alphaState(){return this._alphaState}get stencilState(){return this._stencilState}get stencilStateComposer(){return this._stencilStateComposer}_getGlobalDefines(e){if(e)return this.isNDCHalfZRange?e.IS_NDC_HALF_ZRANGE="":delete e.IS_NDC_HALF_ZRANGE,this.useReverseDepthBuffer?e.USE_REVERSE_DEPTHBUFFER="":delete e.USE_REVERSE_DEPTHBUFFER,void(this.useExactSrgbConversions?e.USE_EXACT_SRGB_CONVERSIONS="":delete e.USE_EXACT_SRGB_CONVERSIONS);{let e="";return this.isNDCHalfZRange&&(e+="#define IS_NDC_HALF_ZRANGE"),this.useReverseDepthBuffer&&(e&&(e+="\n"),e+="#define USE_REVERSE_DEPTHBUFFER"),this.useExactSrgbConversions&&(e&&(e+="\n"),e+="#define USE_EXACT_SRGB_CONVERSIONS"),e}}_rebuildInternalTextures(){const e=this._internalTexturesCache.slice();for(const t of e)t._rebuild()}_rebuildRenderTargetWrappers(){const e=this._renderTargetWrapperCache.slice();for(const t of e)t._rebuild()}_rebuildEffects(){for(const e in this._compiledEffects){const t=this._compiledEffects[e];t._pipelineContext=null,t._prepareEffect()}n.M.ResetCache()}_rebuildGraphicsResources(){this.wipeCaches(!0),this._rebuildEffects(),this._rebuildComputeEffects?.(),this._rebuildBuffers(),this._rebuildInternalTextures(),this._rebuildTextures(),this._rebuildRenderTargetWrappers(),this.wipeCaches(!0)}_flagContextRestored(){r.V.Warn(this.name+" context successfully restored."),this.onContextRestoredObservable.notifyObservers(this),this._contextWasLost=!1}_restoreEngineAfterContextLost(e){setTimeout((async()=>{this._clearEmptyResources();const t=this._depthCullingState.depthTest,s=this._depthCullingState.depthFunc,i=this._depthCullingState.depthMask,r=this._stencilState.stencilTest;await e(),this._rebuildGraphicsResources(),this._depthCullingState.depthTest=t,this._depthCullingState.depthFunc=s,this._depthCullingState.depthMask=i,this._stencilState.stencilTest=r,this._flagContextRestored()}),0)}get isDisposed(){return this._isDisposed}get snapshotRendering(){return!1}set snapshotRendering(e){}get snapshotRenderingMode(){return 0}set snapshotRenderingMode(e){}getClassName(){return"AbstractEngine"}get emptyTexture(){return this._emptyTexture||(this._emptyTexture=this.createRawTexture(new Uint8Array(4),1,1,5,!1,!1,1)),this._emptyTexture}get emptyTexture3D(){return this._emptyTexture3D||(this._emptyTexture3D=this.createRawTexture3D(new Uint8Array(4),1,1,1,5,!1,!1,1)),this._emptyTexture3D}get emptyTexture2DArray(){return this._emptyTexture2DArray||(this._emptyTexture2DArray=this.createRawTexture2DArray(new Uint8Array(4),1,1,1,5,!1,!1,1)),this._emptyTexture2DArray}get emptyCubeTexture(){if(!this._emptyCubeTexture){const e=new Uint8Array(4),t=[e,e,e,e,e,e];this._emptyCubeTexture=this.createRawCubeTexture(t,1,5,0,!1,!1,1)}return this._emptyCubeTexture}get activeRenderLoops(){return this._activeRenderLoops}stopRenderLoop(e){if(!e)return this._activeRenderLoops.length=0,void this._cancelFrame();const t=this._activeRenderLoops.indexOf(e);t>=0&&(this._activeRenderLoops.splice(t,1),0==this._activeRenderLoops.length&&this._cancelFrame())}_cancelFrame(){if(0!==this._frameHandler){const e=this._frameHandler;if(this._frameHandler=0,(0,f.BA)()){const{cancelAnimationFrame:t}=this.getHostWindow()||window;if("function"==typeof t)return t(e)}else if("function"==typeof cancelAnimationFrame)return cancelAnimationFrame(e);return clearTimeout(e)}}beginFrame(){this.onBeginFrameObservable.notifyObservers(this)}endFrame(){this._frameId++,this.onEndFrameObservable.notifyObservers(this)}_renderLoop(){if(this._frameHandler=0,!this._contextWasLost){let e=!0;(this._isDisposed||!this.renderEvenInBackground&&this._windowIsBackground)&&(e=!1),e&&(this.beginFrame(),this._renderViews()||this._renderFrame(),this.endFrame())}this._activeRenderLoops.length>0&&0===this._frameHandler&&(this._frameHandler=this._queueNewFrame(this._boundRenderFunction,this.getHostWindow()))}_renderFrame(){for(let e=0;e-1?e.substring(P).toLowerCase():"");v.indexOf("?")>-1&&(v=v.split("?")[0]);const C=(0,m.gT)(v,g);n&&n.addPendingData(M),M.url=e,M.generateMipMaps=!t,M.samplingMode=a,M.invertY=s,M._useSRGBBuffer=this._getUseSRGBBuffer(!!E,t),this._doNotHandleContextLost||(M._buffer=u);let S=null;o&&!d&&(S=M.onLoadedObservable.add(o)),d||this._internalTexturesCache.push(M);const I=(s,d)=>{n&&n.removePendingData(M),e===y?(S&&M.onLoadedObservable.remove(S),i.q.UseFallbackTexture&&e!==i.q.FallbackTexture&&this._createTextureBase(i.q.FallbackTexture,t,M.invertY,n,a,null,h,l,c,u,M),s=(s||"Unknown error")+(i.q.UseFallbackTexture?" - Fallback texture was used":""),M.onErrorObservable.notifyObservers({message:s,exception:d}),h&&h(s,d)):(r.V.Warn(`Failed to load ${e}, falling back to ${y}`),this._createTextureBase(y,t,M.invertY,n,a,o,h,l,c,u,M,f,p,g,T,E))};if(C){const t=async e=>{(await C).loadData(e,M,((e,t,s,i,r,o)=>{o?I("TextureLoader failed to load data"):l(M,v,n,{width:e,height:t},M.invertY,!s,i,(()=>(r(),!1)),a)}),T)};u?u instanceof ArrayBuffer?t(new Uint8Array(u)):ArrayBuffer.isView(u)?t(u):h&&h("Unable to load: only ArrayBuffer or ArrayBufferView is supported",null):this._loadFile(e,(e=>t(new Uint8Array(e))),void 0,n?n.offlineProvider:void 0,!0,((e,t)=>{I("Unable to load "+(e&&e.responseURL,t))}))}else{const s=e=>{A&&!this._doNotHandleContextLost&&(M._buffer=e),l(M,v,n,e,M.invertY,t,!1,c,a)};!x||R?u&&("string"==typeof u.decoding||u.close)?s(u):b._FileToolsLoadImage(e||"",s,I,n?n.offlineProvider:null,g,M.invertY&&this._features.needsInvertingBitmap?{imageOrientation:"flipY"}:void 0):"string"==typeof u||u instanceof ArrayBuffer||ArrayBuffer.isView(u)||u instanceof Blob?b._FileToolsLoadImage(u,s,I,n?n.offlineProvider:null,g,M.invertY&&this._features.needsInvertingBitmap?{imageOrientation:"flipY"}:void 0):u&&s(u)}return M}_rebuildBuffers(){for(const e of this._uniformBuffers)e._rebuildAfterContextLost()}get _shouldUseHighPrecisionShader(){return!(!this._caps.highPrecisionShaderSupported||!this._highPrecisionShadersAllowed)}getHostDocument(){return this._renderingCanvas&&this._renderingCanvas.ownerDocument?this._renderingCanvas.ownerDocument:(0,f.Nf)()?document:null}getLoadedTexturesCache(){return this._internalTexturesCache}clearInternalTexturesCache(){this._internalTexturesCache.length=0}getCaps(){return this._caps}resetTextureCache(){for(const e in this._boundTexturesCache)Object.prototype.hasOwnProperty.call(this._boundTexturesCache,e)&&(this._boundTexturesCache[e]=null);this._currentTextureChannel=-1}get name(){return this._name}set name(e){this._name=e}static get NpmPackage(){return"babylonjs@7.35.1"}static get Version(){return"7.35.1"}getRenderingCanvas(){return this._renderingCanvas}getAudioContext(){return this._audioContext}getAudioDestination(){return this._audioDestination}setHardwareScalingLevel(e){this._hardwareScalingLevel=e,this.resize()}getHardwareScalingLevel(){return this._hardwareScalingLevel}get doNotHandleContextLost(){return this._doNotHandleContextLost}set doNotHandleContextLost(e){this._doNotHandleContextLost=e}get isStencilEnable(){return this._isStencilEnable}getCreationOptions(){return this._creationOptions}constructor(e,t,s){this._colorWrite=!0,this._colorWriteChanged=!0,this._depthCullingState=new h,this._stencilStateComposer=new l,this._stencilState=new c,this._alphaState=new u,this._alphaMode=1,this._alphaEquation=0,this._activeRequests=[],this._badOS=!1,this._badDesktopOS=!1,this._compatibilityMode=!0,this._internalTexturesCache=new Array,this._currentRenderTarget=null,this._boundTexturesCache={},this._activeChannel=0,this._currentTextureChannel=-1,this._viewportCached={x:0,y:0,z:0,w:0},this._isWebGPU=!1,this.onCanvasBlurObservable=new p.cP,this.onCanvasFocusObservable=new p.cP,this.onNewSceneAddedObservable=new p.cP,this.onResizeObservable=new p.cP,this.onCanvasPointerOutObservable=new p.cP,this.disablePerformanceMonitorInBackground=!1,this.disableVertexArrayObjects=!1,this._frameId=0,this.hostInformation={isMobile:!1},this.isFullscreen=!1,this.enableOfflineSupport=!1,this.disableManifestCheck=!1,this.disableContextMenu=!0,this.currentRenderPassId=0,this.isPointerLock=!1,this.postProcesses=[],this.canvasTabIndex=1,this._contextWasLost=!1,this._useReverseDepthBuffer=!1,this.isNDCHalfZRange=!1,this.hasOriginBottomLeft=!0,this._renderTargetWrapperCache=new Array,this._compiledEffects={},this._isDisposed=!1,this.scenes=[],this._virtualScenes=new Array,this.onBeforeTextureInitObservable=new p.cP,this.renderEvenInBackground=!0,this.preventCacheWipeBetweenFrames=!1,this._frameHandler=0,this._activeRenderLoops=new Array,this._windowIsBackground=!1,this._boundRenderFunction=()=>this._renderLoop(),this.onBeforeShaderCompilationObservable=new p.cP,this.onAfterShaderCompilationObservable=new p.cP,this.onBeginFrameObservable=new p.cP,this.onEndFrameObservable=new p.cP,this._transformTextureUrl=null,this._uniformBuffers=new Array,this._storageBuffers=new Array,this._highPrecisionShadersAllowed=!0,this.onContextLostObservable=new p.cP,this.onContextRestoredObservable=new p.cP,this._name="",this.premultipliedAlpha=!0,this.adaptToDeviceRatio=!1,this._lastDevicePixelRatio=1,this._doNotHandleContextLost=!1,this.cullBackFaces=null,this._renderPassNames=["main"],this._fps=60,this._deltaTime=0,this._deterministicLockstep=!1,this._lockstepMaxSteps=4,this._timeStep=1/60,this.onDisposeObservable=new p.cP,i.q.Instances.push(this),this.startTime=o.j.Now,this._stencilStateComposer.stencilGlobal=this._stencilState,a.I.SetMatrixPrecision(!!t.useHighPrecisionMatrix),(0,f.XD)()&&navigator.userAgent&&(this._badOS=/iPad/i.test(navigator.userAgent)||/iPhone/i.test(navigator.userAgent),this._badDesktopOS=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)),this.adaptToDeviceRatio=s??!1,t.antialias=e??t.antialias,t.deterministicLockstep=t.deterministicLockstep??!1,t.lockstepMaxSteps=t.lockstepMaxSteps??4,t.timeStep=t.timeStep??1/60,t.audioEngine=t.audioEngine??!0,t.stencil=t.stencil??!0,this._audioContext=t.audioEngineOptions?.audioContext??null,this._audioDestination=t.audioEngineOptions?.audioDestination??null,this.premultipliedAlpha=t.premultipliedAlpha??!0,this._doNotHandleContextLost=!!t.doNotHandleContextLost,this._isStencilEnable=!!t.stencil,this.useExactSrgbConversions=t.useExactSrgbConversions??!1;const r=(0,f.BA)()&&window.devicePixelRatio||1,n=t.limitDeviceRatio||r;s=s||t.adaptToDeviceRatio||!1,this._hardwareScalingLevel=s?1/Math.min(n,r):1,this._lastDevicePixelRatio=r,this._creationOptions=t}resize(e=!1){let t,s;if(this.adaptToDeviceRatio){const e=(0,f.BA)()&&window.devicePixelRatio||1,t=this._lastDevicePixelRatio/e;this._lastDevicePixelRatio=e,this._hardwareScalingLevel*=t}if((0,f.BA)()&&(0,f.Nf)())if(this._renderingCanvas){const e=this._renderingCanvas.getBoundingClientRect?this._renderingCanvas.getBoundingClientRect():{width:this._renderingCanvas.width*this._hardwareScalingLevel,height:this._renderingCanvas.height*this._hardwareScalingLevel};t=this._renderingCanvas.clientWidth||e.width||this._renderingCanvas.width||100,s=this._renderingCanvas.clientHeight||e.height||this._renderingCanvas.height||100}else t=window.innerWidth,s=window.innerHeight;else t=this._renderingCanvas?this._renderingCanvas.width:100,s=this._renderingCanvas?this._renderingCanvas.height:100;this.setSize(t/this._hardwareScalingLevel,s/this._hardwareScalingLevel,e)}setSize(e,t,s=!1){if(!this._renderingCanvas)return!1;if(e|=0,t|=0,!s&&this._renderingCanvas.width===e&&this._renderingCanvas.height===t)return!1;if(this._renderingCanvas.width=e,this._renderingCanvas.height=t,this.scenes){for(let e=0;e{const e=navigator.userAgent;this.hostInformation.isMobile=-1!==e.indexOf("Mobile")||-1!==e.indexOf("Mac")&&(0,f.Nf)()&&"ontouchend"in document},this._checkForMobile(),(0,f.BA)()&&window.addEventListener("resize",this._checkForMobile))}createVideoElement(e){return document.createElement("video")}_reportDrawCall(e=1){this._drawCalls?.addCount(e,!1)}getFps(){return this._fps}getDeltaTime(){return this._deltaTime}isDeterministicLockStep(){return this._deterministicLockstep}getLockstepMaxSteps(){return this._lockstepMaxSteps}getTimeStep(){return 1e3*this._timeStep}_createImageBitmapFromSource(e,t){throw new Error("createImageBitmapFromSource is not implemented")}createImageBitmap(e,t){return createImageBitmap(e,t)}resizeImageBitmap(e,t,s){throw new Error("resizeImageBitmap is not implemented")}getFontOffset(e){throw new Error("getFontOffset is not implemented")}static _CreateCanvas(e,t){if("undefined"==typeof document)return new OffscreenCanvas(e,t);const s=document.createElement("canvas");return s.width=e,s.height=t,s}createCanvas(e,t){return b._CreateCanvas(e,t)}static _FileToolsLoadImage(e,t,s,i,r,n){throw(0,d.n)("FileTools")}_loadFile(e,t,s,i,r,n){const a=(0,g.W0)(e,t,s,i,r,n);return this._activeRequests.push(a),a.onCompleteObservable.add((()=>{const e=this._activeRequests.indexOf(a);-1!==e&&this._activeRequests.splice(e,1)})),a}static _FileToolsLoadFile(e,t,s,i,r,n){if(g.sg.loadFile)return g.sg.loadFile(e,t,s,i,r,n);throw(0,d.n)("FileTools")}dispose(){for(this.releaseEffects(),this._isDisposed=!0,this.stopRenderLoop(),this._emptyTexture&&(this._releaseTexture(this._emptyTexture),this._emptyTexture=null),this._emptyCubeTexture&&(this._releaseTexture(this._emptyCubeTexture),this._emptyCubeTexture=null),this._renderingCanvas=null,this.onBeforeTextureInitObservable&&this.onBeforeTextureInitObservable.clear();this.postProcesses.length;)this.postProcesses[0].dispose();for(;this.scenes.length;)this.scenes[0].dispose();for(;this._virtualScenes.length;)this._virtualScenes[0].dispose();this.releaseComputeEffects?.(),n.M.ResetCache();for(const e of this._activeRequests)e.abort();this._boundRenderFunction=null,this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onResizeObservable.clear(),this.onCanvasBlurObservable.clear(),this.onCanvasFocusObservable.clear(),this.onCanvasPointerOutObservable.clear(),this.onNewSceneAddedObservable.clear(),(0,f.BA)()&&window.removeEventListener("resize",this._checkForMobile);const e=i.q.Instances.indexOf(this);e>=0&&i.q.Instances.splice(e,1),i.q.Instances.length||(i.q.OnEnginesDisposedObservable.notifyObservers(this),i.q.OnEnginesDisposedObservable.clear()),this.onBeginFrameObservable.clear(),this.onEndFrameObservable.clear()}static DefaultLoadingScreenFactory(e){throw(0,d.n)("LoadingScreen")}static MarkAllMaterialsAsDirty(e,t){for(let s=0;s{s.d(t,{Y:()=>i});class i{}i.AUTOSAMPLERSUFFIX="Sampler",i.DISABLEUA="#define DISABLE_UNIFORMITY_ANALYSIS",i.ALPHA_DISABLE=0,i.ALPHA_ADD=1,i.ALPHA_COMBINE=2,i.ALPHA_SUBTRACT=3,i.ALPHA_MULTIPLY=4,i.ALPHA_MAXIMIZED=5,i.ALPHA_ONEONE=6,i.ALPHA_PREMULTIPLIED=7,i.ALPHA_PREMULTIPLIED_PORTERDUFF=8,i.ALPHA_INTERPOLATE=9,i.ALPHA_SCREENMODE=10,i.ALPHA_ONEONE_ONEONE=11,i.ALPHA_ALPHATOCOLOR=12,i.ALPHA_REVERSEONEMINUS=13,i.ALPHA_SRC_DSTONEMINUSSRCALPHA=14,i.ALPHA_ONEONE_ONEZERO=15,i.ALPHA_EXCLUSION=16,i.ALPHA_LAYER_ACCUMULATE=17,i.ALPHA_EQUATION_ADD=0,i.ALPHA_EQUATION_SUBSTRACT=1,i.ALPHA_EQUATION_REVERSE_SUBTRACT=2,i.ALPHA_EQUATION_MAX=3,i.ALPHA_EQUATION_MIN=4,i.ALPHA_EQUATION_DARKEN=5,i.DELAYLOADSTATE_NONE=0,i.DELAYLOADSTATE_LOADED=1,i.DELAYLOADSTATE_LOADING=2,i.DELAYLOADSTATE_NOTLOADED=4,i.NEVER=512,i.ALWAYS=519,i.LESS=513,i.EQUAL=514,i.LEQUAL=515,i.GREATER=516,i.GEQUAL=518,i.NOTEQUAL=517,i.KEEP=7680,i.ZERO=0,i.REPLACE=7681,i.INCR=7682,i.DECR=7683,i.INVERT=5386,i.INCR_WRAP=34055,i.DECR_WRAP=34056,i.TEXTURE_CLAMP_ADDRESSMODE=0,i.TEXTURE_WRAP_ADDRESSMODE=1,i.TEXTURE_MIRROR_ADDRESSMODE=2,i.TEXTURE_CREATIONFLAG_STORAGE=1,i.TEXTUREFORMAT_ALPHA=0,i.TEXTUREFORMAT_LUMINANCE=1,i.TEXTUREFORMAT_LUMINANCE_ALPHA=2,i.TEXTUREFORMAT_RGB=4,i.TEXTUREFORMAT_RGBA=5,i.TEXTUREFORMAT_RED=6,i.TEXTUREFORMAT_R=6,i.TEXTUREFORMAT_RG=7,i.TEXTUREFORMAT_RED_INTEGER=8,i.TEXTUREFORMAT_R_INTEGER=8,i.TEXTUREFORMAT_RG_INTEGER=9,i.TEXTUREFORMAT_RGB_INTEGER=10,i.TEXTUREFORMAT_RGBA_INTEGER=11,i.TEXTUREFORMAT_BGRA=12,i.TEXTUREFORMAT_DEPTH24_STENCIL8=13,i.TEXTUREFORMAT_DEPTH32_FLOAT=14,i.TEXTUREFORMAT_DEPTH16=15,i.TEXTUREFORMAT_DEPTH24=16,i.TEXTUREFORMAT_DEPTH24UNORM_STENCIL8=17,i.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8=18,i.TEXTUREFORMAT_STENCIL8=19,i.TEXTUREFORMAT_UNDEFINED=4294967295,i.TEXTUREFORMAT_COMPRESSED_RGBA_BPTC_UNORM=36492,i.TEXTUREFORMAT_COMPRESSED_SRGB_ALPHA_BPTC_UNORM=36493,i.TEXTUREFORMAT_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT=36495,i.TEXTUREFORMAT_COMPRESSED_RGB_BPTC_SIGNED_FLOAT=36494,i.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5=33779,i.TEXTUREFORMAT_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919,i.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT3=33778,i.TEXTUREFORMAT_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918,i.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT1=33777,i.TEXTUREFORMAT_COMPRESSED_RGB_S3TC_DXT1=33776,i.TEXTUREFORMAT_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917,i.TEXTUREFORMAT_COMPRESSED_SRGB_S3TC_DXT1_EXT=35916,i.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_4x4=37808,i.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840,i.TEXTUREFORMAT_COMPRESSED_RGB_ETC1_WEBGL=36196,i.TEXTUREFORMAT_COMPRESSED_RGB8_ETC2=37492,i.TEXTUREFORMAT_COMPRESSED_SRGB8_ETC2=37493,i.TEXTUREFORMAT_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494,i.TEXTUREFORMAT_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495,i.TEXTUREFORMAT_COMPRESSED_RGBA8_ETC2_EAC=37496,i.TEXTUREFORMAT_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37497,i.TEXTURETYPE_UNSIGNED_BYTE=0,i.TEXTURETYPE_UNSIGNED_INT=0,i.TEXTURETYPE_FLOAT=1,i.TEXTURETYPE_HALF_FLOAT=2,i.TEXTURETYPE_BYTE=3,i.TEXTURETYPE_SHORT=4,i.TEXTURETYPE_UNSIGNED_SHORT=5,i.TEXTURETYPE_INT=6,i.TEXTURETYPE_UNSIGNED_INTEGER=7,i.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4=8,i.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1=9,i.TEXTURETYPE_UNSIGNED_SHORT_5_6_5=10,i.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV=11,i.TEXTURETYPE_UNSIGNED_INT_24_8=12,i.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV=13,i.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV=14,i.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV=15,i.TEXTURETYPE_UNDEFINED=16,i.TEXTURE_2D=3553,i.TEXTURE_2D_ARRAY=35866,i.TEXTURE_CUBE_MAP=34067,i.TEXTURE_CUBE_MAP_ARRAY=3735928559,i.TEXTURE_3D=32879,i.TEXTURE_NEAREST_SAMPLINGMODE=1,i.TEXTURE_NEAREST_NEAREST=1,i.TEXTURE_BILINEAR_SAMPLINGMODE=2,i.TEXTURE_LINEAR_LINEAR=2,i.TEXTURE_TRILINEAR_SAMPLINGMODE=3,i.TEXTURE_LINEAR_LINEAR_MIPLINEAR=3,i.TEXTURE_NEAREST_NEAREST_MIPNEAREST=4,i.TEXTURE_NEAREST_LINEAR_MIPNEAREST=5,i.TEXTURE_NEAREST_LINEAR_MIPLINEAR=6,i.TEXTURE_NEAREST_LINEAR=7,i.TEXTURE_NEAREST_NEAREST_MIPLINEAR=8,i.TEXTURE_LINEAR_NEAREST_MIPNEAREST=9,i.TEXTURE_LINEAR_NEAREST_MIPLINEAR=10,i.TEXTURE_LINEAR_LINEAR_MIPNEAREST=11,i.TEXTURE_LINEAR_NEAREST=12,i.TEXTURE_EXPLICIT_MODE=0,i.TEXTURE_SPHERICAL_MODE=1,i.TEXTURE_PLANAR_MODE=2,i.TEXTURE_CUBIC_MODE=3,i.TEXTURE_PROJECTION_MODE=4,i.TEXTURE_SKYBOX_MODE=5,i.TEXTURE_INVCUBIC_MODE=6,i.TEXTURE_EQUIRECTANGULAR_MODE=7,i.TEXTURE_FIXED_EQUIRECTANGULAR_MODE=8,i.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE=9,i.TEXTURE_FILTERING_QUALITY_OFFLINE=4096,i.TEXTURE_FILTERING_QUALITY_HIGH=64,i.TEXTURE_FILTERING_QUALITY_MEDIUM=16,i.TEXTURE_FILTERING_QUALITY_LOW=8,i.SCALEMODE_FLOOR=1,i.SCALEMODE_NEAREST=2,i.SCALEMODE_CEILING=3,i.MATERIAL_TextureDirtyFlag=1,i.MATERIAL_LightDirtyFlag=2,i.MATERIAL_FresnelDirtyFlag=4,i.MATERIAL_AttributesDirtyFlag=8,i.MATERIAL_MiscDirtyFlag=16,i.MATERIAL_PrePassDirtyFlag=32,i.MATERIAL_AllDirtyFlag=63,i.MATERIAL_TriangleFillMode=0,i.MATERIAL_WireFrameFillMode=1,i.MATERIAL_PointFillMode=2,i.MATERIAL_PointListDrawMode=3,i.MATERIAL_LineListDrawMode=4,i.MATERIAL_LineLoopDrawMode=5,i.MATERIAL_LineStripDrawMode=6,i.MATERIAL_TriangleStripDrawMode=7,i.MATERIAL_TriangleFanDrawMode=8,i.MATERIAL_ClockWiseSideOrientation=0,i.MATERIAL_CounterClockWiseSideOrientation=1,i.ACTION_NothingTrigger=0,i.ACTION_OnPickTrigger=1,i.ACTION_OnLeftPickTrigger=2,i.ACTION_OnRightPickTrigger=3,i.ACTION_OnCenterPickTrigger=4,i.ACTION_OnPickDownTrigger=5,i.ACTION_OnDoublePickTrigger=6,i.ACTION_OnPickUpTrigger=7,i.ACTION_OnPickOutTrigger=16,i.ACTION_OnLongPressTrigger=8,i.ACTION_OnPointerOverTrigger=9,i.ACTION_OnPointerOutTrigger=10,i.ACTION_OnEveryFrameTrigger=11,i.ACTION_OnIntersectionEnterTrigger=12,i.ACTION_OnIntersectionExitTrigger=13,i.ACTION_OnKeyDownTrigger=14,i.ACTION_OnKeyUpTrigger=15,i.PARTICLES_BILLBOARDMODE_Y=2,i.PARTICLES_BILLBOARDMODE_ALL=7,i.PARTICLES_BILLBOARDMODE_STRETCHED=8,i.PARTICLES_BILLBOARDMODE_STRETCHED_LOCAL=9,i.MESHES_CULLINGSTRATEGY_STANDARD=0,i.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY=1,i.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION=2,i.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY=3,i.SCENELOADER_NO_LOGGING=0,i.SCENELOADER_MINIMAL_LOGGING=1,i.SCENELOADER_SUMMARY_LOGGING=2,i.SCENELOADER_DETAILED_LOGGING=3,i.PREPASS_IRRADIANCE_TEXTURE_TYPE=0,i.PREPASS_POSITION_TEXTURE_TYPE=1,i.PREPASS_VELOCITY_TEXTURE_TYPE=2,i.PREPASS_REFLECTIVITY_TEXTURE_TYPE=3,i.PREPASS_COLOR_TEXTURE_TYPE=4,i.PREPASS_DEPTH_TEXTURE_TYPE=5,i.PREPASS_NORMAL_TEXTURE_TYPE=6,i.PREPASS_ALBEDO_SQRT_TEXTURE_TYPE=7,i.PREPASS_WORLD_NORMAL_TEXTURE_TYPE=8,i.PREPASS_LOCAL_POSITION_TEXTURE_TYPE=9,i.PREPASS_SCREENSPACE_DEPTH_TEXTURE_TYPE=10,i.PREPASS_VELOCITY_LINEAR_TEXTURE_TYPE=11,i.PREPASS_ALBEDO_TEXTURE_TYPE=12,i.BUFFER_CREATIONFLAG_READ=1,i.BUFFER_CREATIONFLAG_WRITE=2,i.BUFFER_CREATIONFLAG_READWRITE=3,i.BUFFER_CREATIONFLAG_UNIFORM=4,i.BUFFER_CREATIONFLAG_VERTEX=8,i.BUFFER_CREATIONFLAG_INDEX=16,i.BUFFER_CREATIONFLAG_STORAGE=32,i.BUFFER_CREATIONFLAG_INDIRECT=64,i.RENDERPASS_MAIN=0,i.INPUT_ALT_KEY=18,i.INPUT_CTRL_KEY=17,i.INPUT_META_KEY1=91,i.INPUT_META_KEY2=92,i.INPUT_META_KEY3=93,i.INPUT_SHIFT_KEY=16,i.SNAPSHOTRENDERING_STANDARD=0,i.SNAPSHOTRENDERING_FAST=1,i.PERSPECTIVE_CAMERA=0,i.ORTHOGRAPHIC_CAMERA=1,i.FOVMODE_VERTICAL_FIXED=0,i.FOVMODE_HORIZONTAL_FIXED=1,i.RIG_MODE_NONE=0,i.RIG_MODE_STEREOSCOPIC_ANAGLYPH=10,i.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL=11,i.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED=12,i.RIG_MODE_STEREOSCOPIC_OVERUNDER=13,i.RIG_MODE_STEREOSCOPIC_INTERLACED=14,i.RIG_MODE_VR=20,i.RIG_MODE_CUSTOM=22,i.MAX_SUPPORTED_UV_SETS=6,i.GL_ALPHA_EQUATION_ADD=32774,i.GL_ALPHA_EQUATION_MIN=32775,i.GL_ALPHA_EQUATION_MAX=32776,i.GL_ALPHA_EQUATION_SUBTRACT=32778,i.GL_ALPHA_EQUATION_REVERSE_SUBTRACT=32779,i.GL_ALPHA_FUNCTION_SRC=768,i.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_COLOR=769,i.GL_ALPHA_FUNCTION_SRC_ALPHA=770,i.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA=771,i.GL_ALPHA_FUNCTION_DST_ALPHA=772,i.GL_ALPHA_FUNCTION_ONE_MINUS_DST_ALPHA=773,i.GL_ALPHA_FUNCTION_DST_COLOR=774,i.GL_ALPHA_FUNCTION_ONE_MINUS_DST_COLOR=775,i.GL_ALPHA_FUNCTION_SRC_ALPHA_SATURATED=776,i.GL_ALPHA_FUNCTION_CONSTANT_COLOR=32769,i.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_COLOR=32770,i.GL_ALPHA_FUNCTION_CONSTANT_ALPHA=32771,i.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_ALPHA=32772,i.GL_ALPHA_FUNCTION_SRC1_COLOR=35065,i.GL_ALPHA_FUNCTION_ONE_MINUS_SRC1_COLOR=35066,i.GL_ALPHA_FUNCTION_SRC1_ALPHA=34185,i.GL_ALPHA_FUNCTION_ONE_MINUS_SRC1_ALPHA=35067,i.SnippetUrl="https://snippet.babylonjs.com",i.FOGMODE_NONE=0,i.FOGMODE_EXP=1,i.FOGMODE_EXP2=2,i.FOGMODE_LINEAR=3,i.BYTE=5120,i.UNSIGNED_BYTE=5121,i.SHORT=5122,i.UNSIGNED_SHORT=5123,i.INT=5124,i.UNSIGNED_INT=5125,i.FLOAT=5126,i.PositionKind="position",i.NormalKind="normal",i.TangentKind="tangent",i.UVKind="uv",i.UV2Kind="uv2",i.UV3Kind="uv3",i.UV4Kind="uv4",i.UV5Kind="uv5",i.UV6Kind="uv6",i.ColorKind="color",i.ColorInstanceKind="instanceColor",i.MatricesIndicesKind="matricesIndices",i.MatricesWeightsKind="matricesWeights",i.MatricesIndicesExtraKind="matricesIndicesExtra",i.MatricesWeightsExtraKind="matricesWeightsExtra"},3720:(e,t,s)=>{s.d(t,{N:()=>C});var i=s(854),r=s(6315),n=s(6321),a=s(6237);class o{constructor(e=30){this._enabled=!0,this._rollingFrameTime=new h(e)}sampleFrame(e=a.j.Now){if(this._enabled){if(null!=this._lastFrameTimeMs){const t=e-this._lastFrameTimeMs;this._rollingFrameTime.add(t)}this._lastFrameTimeMs=e}}get averageFrameTime(){return this._rollingFrameTime.average}get averageFrameTimeVariance(){return this._rollingFrameTime.variance}get instantaneousFrameTime(){return this._rollingFrameTime.history(0)}get averageFPS(){return 1e3/this._rollingFrameTime.average}get instantaneousFPS(){const e=this._rollingFrameTime.history(0);return 0===e?0:1e3/e}get isSaturated(){return this._rollingFrameTime.isSaturated()}enable(){this._enabled=!0}disable(){this._enabled=!1,this._lastFrameTimeMs=null}get isEnabled(){return this._enabled}reset(){this._lastFrameTimeMs=null,this._rollingFrameTime.reset()}}class h{constructor(e){this._samples=new Array(e),this.reset()}add(e){let t;if(this.isSaturated()){const e=this._samples[this._pos];t=e-this.average,this.average-=t/(this._sampleCount-1),this._m2-=t*(e-this.average)}else this._sampleCount++;t=e-this.average,this.average+=t/this._sampleCount,this._m2+=t*(e-this.average),this.variance=this._m2/(this._sampleCount-1),this._samples[this._pos]=e,this._pos++,this._pos%=this._samples.length}history(e){if(e>=this._sampleCount||e>=this._samples.length)return 0;const t=this._wrapPosition(this._pos-1);return this._samples[this._wrapPosition(t-e)]}isSaturated(){return this._sampleCount>=this._samples.length}reset(){this.average=0,this.variance=0,this._sampleCount=0,this._pos=0,this._m2=0}_wrapPosition(e){const t=this._samples.length;return(e%t+t)%t}}var l=s(4329),c=s(1137),u=s(7716);n.ThinEngine.prototype.setAlphaMode=function(e,t=!1){if(this._alphaMode!==e){switch(e){case 0:this._alphaState.alphaBlend=!1;break;case 7:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE_MINUS_SRC_ALPHA,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case 8:case 14:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE_MINUS_SRC_ALPHA,this._gl.ONE,this._gl.ONE_MINUS_SRC_ALPHA),this._alphaState.alphaBlend=!0;break;case 2:this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA,this._gl.ONE_MINUS_SRC_ALPHA,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case 6:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE,this._gl.ZERO,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case 1:this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA,this._gl.ONE,this._gl.ZERO,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case 3:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ZERO,this._gl.ONE_MINUS_SRC_COLOR,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case 4:this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_COLOR,this._gl.ZERO,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case 5:this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA,this._gl.ONE_MINUS_SRC_COLOR,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case 9:this._alphaState.setAlphaBlendFunctionParameters(this._gl.CONSTANT_COLOR,this._gl.ONE_MINUS_CONSTANT_COLOR,this._gl.CONSTANT_ALPHA,this._gl.ONE_MINUS_CONSTANT_ALPHA),this._alphaState.alphaBlend=!0;break;case 10:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE_MINUS_SRC_COLOR,this._gl.ONE,this._gl.ONE_MINUS_SRC_ALPHA),this._alphaState.alphaBlend=!0;break;case 11:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case 12:this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_ALPHA,this._gl.ONE,this._gl.ZERO,this._gl.ZERO),this._alphaState.alphaBlend=!0;break;case 13:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE_MINUS_DST_COLOR,this._gl.ONE_MINUS_SRC_COLOR,this._gl.ONE_MINUS_DST_ALPHA,this._gl.ONE_MINUS_SRC_ALPHA),this._alphaState.alphaBlend=!0;break;case 15:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE,this._gl.ONE,this._gl.ZERO),this._alphaState.alphaBlend=!0;break;case 16:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE_MINUS_DST_COLOR,this._gl.ONE_MINUS_SRC_COLOR,this._gl.ZERO,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case 17:this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA,this._gl.ONE_MINUS_SRC_ALPHA,this._gl.ONE,this._gl.ONE_MINUS_SRC_ALPHA),this._alphaState.alphaBlend=!0}t||(this.depthCullingState.depthMask=0===e),this._alphaMode=e}else if(!t){const t=0===e;this.depthCullingState.depthMask!==t&&(this.depthCullingState.depthMask=t)}};var d=s(1597);function _(e,t,s,i){let r,n=1;1===i?r=new Float32Array(t*s*4):2===i?(r=new Uint16Array(t*s*4),n=15360):r=7===i?new Uint32Array(t*s*4):new Uint8Array(t*s*4);for(let i=0;i{const s=f.width,n=a(e);if(n){if(o){const e=this._getWebGLTextureType(r);let t=this._getInternalFormat(i);const a=this._getRGBABufferInternalSizedFormat(r);let h=!1;t===d.RGB&&(t=d.RGBA,h=!0),this._bindTextureDirectly(d.TEXTURE_CUBE_MAP,f,!0),this._unpackFlipY(!1);const l=o(n);for(let i=0;i>i;for(let s=0;s<6;s++){let o=l[i][s];h&&(o=_(o,n,n,r)),d.texImage2D(s,i,a,n,n,0,t,e,o)}}this._bindTextureDirectly(d.TEXTURE_CUBE_MAP,null)}else this.updateRawCubeTexture(f,n,i,r,u);f.isReady=!0,t?.removePendingData(f),f.onLoadedObservable.notifyObservers(f),f.onLoadedObservable.clear(),h&&h()}};return this._loadFile(e,(e=>{p(e)}),void 0,t?.offlineProvider,!0,((e,s)=>{t?.removePendingData(f),l&&e&&l(e.status+" "+e.statusText,s)})),f},n.ThinEngine.prototype.createRawTexture2DArray=f(!1),n.ThinEngine.prototype.createRawTexture3D=f(!0),n.ThinEngine.prototype.updateRawTexture2DArray=p(!1),n.ThinEngine.prototype.updateRawTexture3D=p(!0);var g=s(6741);n.ThinEngine.prototype._readTexturePixelsSync=function(e,t,s,i=-1,r=0,n=null,a=!0,o=!1,h=0,l=0){const c=this._gl;if(!c)throw new Error("Engine does not have gl rendering context.");if(!this._dummyFramebuffer){const e=c.createFramebuffer();if(!e)throw new Error("Unable to create dummy framebuffer");this._dummyFramebuffer=e}c.bindFramebuffer(c.FRAMEBUFFER,this._dummyFramebuffer),i>-1?c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0,c.TEXTURE_CUBE_MAP_POSITIVE_X+i,e._hardwareTexture?.underlyingResource,r):c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0,c.TEXTURE_2D,e._hardwareTexture?.underlyingResource,r);let u=void 0!==e.type?this._getWebGLTextureType(e.type):c.UNSIGNED_BYTE;return o?n||(n=(0,g.kZ)(e.type,4*t*s)):u===c.UNSIGNED_BYTE?(n||(n=new Uint8Array(4*t*s)),u=c.UNSIGNED_BYTE):(n||(n=new Float32Array(4*t*s)),u=c.FLOAT),a&&this.flushFramebuffer(),c.readPixels(h,l,t,s,c.RGBA,u,n),c.bindFramebuffer(c.FRAMEBUFFER,this._currentFramebuffer),n},n.ThinEngine.prototype._readTexturePixels=function(e,t,s,i=-1,r=0,n=null,a=!0,o=!1,h=0,l=0){return Promise.resolve(this._readTexturePixelsSync(e,t,s,i,r,n,a,o,h,l))},n.ThinEngine.prototype.updateDynamicIndexBuffer=function(e,t,s=0){let i;this._currentBoundBuffer[this._gl.ELEMENT_ARRAY_BUFFER]=null,this.bindIndexBuffer(e),i=e.is32Bits?t instanceof Uint32Array?t:new Uint32Array(t):t instanceof Uint16Array?t:new Uint16Array(t),this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER,i,this._gl.DYNAMIC_DRAW),this._resetIndexBufferBinding()},n.ThinEngine.prototype.updateDynamicVertexBuffer=function(e,t,s,i){this.bindArrayBuffer(e),void 0===s&&(s=0);const r=t.byteLength||t.length;void 0===i||i>=r&&0===s?t instanceof Array?this._gl.bufferSubData(this._gl.ARRAY_BUFFER,s,new Float32Array(t)):this._gl.bufferSubData(this._gl.ARRAY_BUFFER,s,t):t instanceof Array?this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,new Float32Array(t).subarray(s,s+i)):(t=t instanceof ArrayBuffer?new Uint8Array(t,s,i):new Uint8Array(t.buffer,t.byteOffset+s,i),this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,t)),this._resetVertexBufferBinding()},n.ThinEngine.prototype._createDepthStencilCubeTexture=function(e,t){const s=new i.h(this,12);if(s.isCube=!0,1===this.webGLVersion)return c.V.Error("Depth cube texture is not supported by WebGL 1."),s;const r={bilinearFiltering:!1,comparisonFunction:0,generateStencil:!1,...t},n=this._gl;this._bindTextureDirectly(n.TEXTURE_CUBE_MAP,s,!0),this._setupDepthStencilTexture(s,e,r.bilinearFiltering,r.comparisonFunction);for(let t=0;t<6;t++)r.generateStencil?n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,n.DEPTH24_STENCIL8,e,e,0,n.DEPTH_STENCIL,n.UNSIGNED_INT_24_8,null):n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,n.DEPTH_COMPONENT24,e,e,0,n.DEPTH_COMPONENT,n.UNSIGNED_INT,null);return this._bindTextureDirectly(n.TEXTURE_CUBE_MAP,null),this._internalTexturesCache.push(s),s},n.ThinEngine.prototype._setCubeMapTextureParams=function(e,t,s){const i=this._gl;i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_MIN_FILTER,t?i.LINEAR_MIPMAP_LINEAR:i.LINEAR),i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),e.samplingMode=t?3:2,t&&this.getCaps().textureMaxLevel&&void 0!==s&&s>0&&(i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_MAX_LEVEL,s),e._maxLodLevel=s),this._bindTextureDirectly(i.TEXTURE_CUBE_MAP,null)},n.ThinEngine.prototype.createCubeTexture=function(e,t,s,i,r=null,n=null,a,o=null,h=!1,l=0,u=0,_=null,f,p=!1,g=null){const m=this._gl;return this.createCubeTextureBase(e,t,s,!!i,r,n,a,o,h,l,u,_,(e=>this._bindTextureDirectly(m.TEXTURE_CUBE_MAP,e,!0)),((e,t)=>{const s=this.needPOTTextures?(0,d.R)(t[0].width,this._caps.maxCubemapTextureSize):t[0].width,n=s,o=[m.TEXTURE_CUBE_MAP_POSITIVE_X,m.TEXTURE_CUBE_MAP_POSITIVE_Y,m.TEXTURE_CUBE_MAP_POSITIVE_Z,m.TEXTURE_CUBE_MAP_NEGATIVE_X,m.TEXTURE_CUBE_MAP_NEGATIVE_Y,m.TEXTURE_CUBE_MAP_NEGATIVE_Z];this._bindTextureDirectly(m.TEXTURE_CUBE_MAP,e,!0),this._unpackFlipY(!1);const h=a?this._getInternalFormat(a,e._useSRGBBuffer):e._useSRGBBuffer?this._glSRGBExtensionValues.SRGB8_ALPHA8:m.RGBA;let l=a?this._getInternalFormat(a):m.RGBA;e._useSRGBBuffer&&1===this.webGLVersion&&(l=h);for(let e=0;e0}get is3D(){return this.depth>0}get size(){return this.width}get width(){return this._size.width||this._size}get height(){return this._size.height||this._size}get layers(){return this._size.layers||0}get depth(){return this._size.depth||0}get texture(){return this._textures?.[0]??null}get textures(){return this._textures}get faceIndices(){return this._faceIndices}get layerIndices(){return this._layerIndices}getBaseArrayLayer(e){if(!this._textures)return-1;const t=this._textures[e],s=this._layerIndices?.[e]??0,i=this._faceIndices?.[e]??0;return t.isCube?6*s+i:t.is3D?0:s}get samples(){return this._samples}setSamples(e,t=!0,s=!1){if(this.samples===e&&!s)return e;const i=this._isMulti?this._engine.updateMultipleRenderTargetTextureSampleCount(this,e,t):this._engine.updateRenderTargetTextureSampleCount(this,e);return this._samples=e,i}constructor(e,t,s,i,r){this._textures=null,this._faceIndices=null,this._layerIndices=null,this._samples=1,this._attachments=null,this._generateStencilBuffer=!1,this._generateDepthBuffer=!1,this._depthStencilTextureWithStencil=!1,this._isMulti=e,this._isCube=t,this._size=s,this._engine=i,this._depthStencilTexture=null,this.label=r}setTextures(e){Array.isArray(e)?this._textures=e:this._textures=e?[e]:null}setTexture(e,t=0,s=!0){this._textures||(this._textures=[]),this._textures[t]!==e&&(this._textures[t]&&s&&this._textures[t].dispose(),this._textures[t]=e)}setLayerAndFaceIndices(e,t){this._layerIndices=e,this._faceIndices=t}setLayerAndFaceIndex(e=0,t,s){this._layerIndices||(this._layerIndices=[]),this._faceIndices||(this._faceIndices=[]),void 0!==t&&t>=0&&(this._layerIndices[e]=t),void 0!==s&&s>=0&&(this._faceIndices[e]=s)}createDepthStencilTexture(e=0,t=!0,s=!1,i=1,r=14,n){return this._depthStencilTexture?.dispose(),this._depthStencilTextureWithStencil=s,this._depthStencilTextureLabel=n,this._depthStencilTexture=this._engine.createDepthStencilTexture(this._size,{bilinearFiltering:t,comparisonFunction:e,generateStencil:s,isCube:this._isCube,samples:i,depthTextureFormat:r,label:n},this),this._depthStencilTexture}_shareDepth(e){this.shareDepth(e)}shareDepth(e){this._depthStencilTexture&&(e._depthStencilTexture&&e._depthStencilTexture.dispose(),e._depthStencilTexture=this._depthStencilTexture,e._depthStencilTextureWithStencil=this._depthStencilTextureWithStencil,this._depthStencilTexture.incrementReferences())}_swapAndDie(e){this.texture&&this.texture._swapAndDie(e),this._textures=null,this.dispose(!0)}_cloneRenderTargetWrapper(){let e=null;if(this._isMulti){const t=this.textures;if(t&&t.length>0){let s=!1,i=t.length,r=-1;const n=t[t.length-1]._source;14!==n&&12!==n||(s=!0,r=t[t.length-1].format,i--);const a=[],o=[],h=[],l=[],c=[],u=[],d=[],_={};for(let e=0;e1&&e.setSamples(this.samples),e._swapRenderTargetWrapper(this),e.dispose()}}releaseTextures(){if(this._textures)for(let e=0;e1){const r=this._context,n=r["COLOR_ATTACHMENT"+t];e.is2DArray||e.is3D?(s=s??this.layerIndices?.[t]??0,r.framebufferTextureLayer(r.FRAMEBUFFER,n,e._hardwareTexture.underlyingResource,i,s)):e.isCube?(s=s??this.faceIndices?.[t]??0,r.framebufferTexture2D(r.FRAMEBUFFER,n,r.TEXTURE_CUBE_MAP_POSITIVE_X+s,e._hardwareTexture.underlyingResource,i)):r.framebufferTexture2D(r.FRAMEBUFFER,n,r.TEXTURE_2D,e._hardwareTexture.underlyingResource,i)}else{const r=this._context,n=r["COLOR_ATTACHMENT"+t+"_WEBGL"],a=void 0!==s?r.TEXTURE_CUBE_MAP_POSITIVE_X+s:r.TEXTURE_2D;r.framebufferTexture2D(r.FRAMEBUFFER,n,a,e._hardwareTexture.underlyingResource,i)}n._bindUnboundFramebuffer(a)}setTexture(e,t=0,s=!0){super.setTexture(e,t,s),this._bindTextureRenderTarget(e,t)}setLayerAndFaceIndices(e,t){if(super.setLayerAndFaceIndices(e,t),!this.textures||!this.layerIndices||!this.faceIndices)return;const s=this._attachments?.length??this.textures.length;for(let e=0;e1){const e=i._hardwareTexture.getMSAARenderBuffer(0);s._MSAAFramebuffer=_.createFramebuffer(),this._bindUnboundFramebuffer(s._MSAAFramebuffer),_.framebufferRenderbuffer(_.FRAMEBUFFER,_.COLOR_ATTACHMENT0,_.RENDERBUFFER,e),this._bindUnboundFramebuffer(null)}}else this.updateRenderTargetTextureSampleCount(s,h);return s},n.ThinEngine.prototype._createDepthStencilTexture=function(e,t,s){const r=this._gl,n=e.layers||0,a=e.depth||0;let o=r.TEXTURE_2D;0!==n?o=r.TEXTURE_2D_ARRAY:0!==a&&(o=r.TEXTURE_3D);const h=new i.h(this,12);if(h.label=t.label,!this._caps.depthTextureExtension)return c.V.Error("Depth texture is not supported by your browser or hardware."),h;const l={bilinearFiltering:!1,comparisonFunction:0,generateStencil:!1,...t};if(this._bindTextureDirectly(o,h,!0),this._setupDepthStencilTexture(h,e,0!==l.comparisonFunction&&l.bilinearFiltering,l.comparisonFunction,l.samples),void 0!==l.depthTextureFormat){if(15!==l.depthTextureFormat&&16!==l.depthTextureFormat&&17!==l.depthTextureFormat&&13!==l.depthTextureFormat&&14!==l.depthTextureFormat&&18!==l.depthTextureFormat)return c.V.Error(`Depth texture ${l.depthTextureFormat} format is not supported.`),h;h.format=l.depthTextureFormat}else h.format=l.generateStencil?13:16;const u=17===h.format||13===h.format||18===h.format;let d=r.UNSIGNED_INT;15===h.format?d=r.UNSIGNED_SHORT:17===h.format||13===h.format?d=r.UNSIGNED_INT_24_8:14===h.format?d=r.FLOAT:18===h.format&&(d=r.FLOAT_32_UNSIGNED_INT_24_8_REV);const _=u?r.DEPTH_STENCIL:r.DEPTH_COMPONENT,f=this._getInternalFormatFromDepthTextureFormat(h.format,!0,u);return h.is2DArray?r.texImage3D(o,0,f,h.width,h.height,n,0,_,d,null):h.is3D?r.texImage3D(o,0,f,h.width,h.height,a,0,_,d,null):r.texImage2D(o,0,f,h.width,h.height,0,_,d,null),this._bindTextureDirectly(o,null),this._internalTexturesCache.push(h),s._depthStencilBuffer&&(r.deleteRenderbuffer(s._depthStencilBuffer),s._depthStencilBuffer=null),this._bindUnboundFramebuffer(s._MSAAFramebuffer??s._framebuffer),s._generateStencilBuffer=u,s._depthStencilTextureWithStencil=u,s._depthStencilBuffer=this._setupFramebufferDepthAttachments(s._generateStencilBuffer,s._generateDepthBuffer,s.width,s.height,s.samples,h.format),this._bindUnboundFramebuffer(null),h},n.ThinEngine.prototype.updateRenderTargetTextureSampleCount=function(e,t){if(this.webGLVersion<2||!e)return 1;if(e.samples===t)return t;const s=this._gl;t=Math.min(t,this.getCaps().maxMSAASamples),e._depthStencilBuffer&&(s.deleteRenderbuffer(e._depthStencilBuffer),e._depthStencilBuffer=null),e._MSAAFramebuffer&&(s.deleteFramebuffer(e._MSAAFramebuffer),e._MSAAFramebuffer=null);const i=e.texture?._hardwareTexture;if(i?.releaseMSAARenderBuffers(),e.texture&&t>1&&"function"==typeof s.renderbufferStorageMultisample){const r=s.createFramebuffer();if(!r)throw new Error("Unable to create multi sampled framebuffer");e._MSAAFramebuffer=r,this._bindUnboundFramebuffer(e._MSAAFramebuffer);const n=this._createRenderBuffer(e.texture.width,e.texture.height,t,-1,this._getRGBABufferInternalSizedFormat(e.texture.type,e.texture.format,e.texture._useSRGBBuffer),s.COLOR_ATTACHMENT0,!1);if(!n)throw new Error("Unable to create multi sampled framebuffer");i?.addMSAARenderBuffer(n)}this._bindUnboundFramebuffer(e._MSAAFramebuffer??e._framebuffer),e.texture&&(e.texture.samples=t),e._samples=t;const r=e._depthStencilTexture?e._depthStencilTexture.format:void 0;return e._depthStencilBuffer=this._setupFramebufferDepthAttachments(e._generateStencilBuffer,e._generateDepthBuffer,e.width,e.height,t,r),this._bindUnboundFramebuffer(null),t},n.ThinEngine.prototype._setupDepthStencilTexture=function(e,t,s,i,r=1){const n=t.width??t,a=t.height??t,o=t.layers||0,h=t.depth||0;e.baseWidth=n,e.baseHeight=a,e.width=n,e.height=a,e.is2DArray=o>0,e.depth=o||h,e.isReady=!0,e.samples=r,e.generateMipMaps=!1,e.samplingMode=s?2:1,e.type=0,e._comparisonFunction=i;const l=this._gl,c=this._getTextureTarget(e),u=this._getSamplingParameters(e.samplingMode,!1);l.texParameteri(c,l.TEXTURE_MAG_FILTER,u.mag),l.texParameteri(c,l.TEXTURE_MIN_FILTER,u.min),l.texParameteri(c,l.TEXTURE_WRAP_S,l.CLAMP_TO_EDGE),l.texParameteri(c,l.TEXTURE_WRAP_T,l.CLAMP_TO_EDGE),this.webGLVersion>1&&(0===i?(l.texParameteri(c,l.TEXTURE_COMPARE_FUNC,515),l.texParameteri(c,l.TEXTURE_COMPARE_MODE,l.NONE)):(l.texParameteri(c,l.TEXTURE_COMPARE_FUNC,i),l.texParameteri(c,l.TEXTURE_COMPARE_MODE,l.COMPARE_REF_TO_TEXTURE)))},n.ThinEngine.prototype.setDepthStencilTexture=function(e,t,s,i){void 0!==e&&(t&&(this._boundUniforms[e]=t),s&&s.depthStencilTexture?this._setTexture(e,s,!1,!0,i):this._setTexture(e,null,void 0,void 0,i))},n.ThinEngine.prototype.createRenderTargetCubeTexture=function(e,t){const s=this._createHardwareRenderTargetWrapper(!1,!0,e),r={generateMipMaps:!0,generateDepthBuffer:!0,generateStencilBuffer:!1,type:0,samplingMode:3,format:5,...t};r.generateStencilBuffer=r.generateDepthBuffer&&r.generateStencilBuffer,(1!==r.type||this._caps.textureFloatLinearFiltering)&&(2!==r.type||this._caps.textureHalfFloatLinearFiltering)||(r.samplingMode=1);const n=this._gl,a=new i.h(this,5);this._bindTextureDirectly(n.TEXTURE_CUBE_MAP,a,!0);const o=this._getSamplingParameters(r.samplingMode,r.generateMipMaps);1!==r.type||this._caps.textureFloat||(r.type=0,c.V.Warn("Float textures are not supported. Cube render target forced to TEXTURETYPE_UNESIGNED_BYTE type")),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_MAG_FILTER,o.mag),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_MIN_FILTER,o.min),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE);for(let t=0;t<6;t++)n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,this._getRGBABufferInternalSizedFormat(r.type,r.format),e,e,0,this._getInternalFormat(r.format),this._getWebGLTextureType(r.type),null);const h=n.createFramebuffer();return this._bindUnboundFramebuffer(h),s._depthStencilBuffer=this._setupFramebufferDepthAttachments(r.generateStencilBuffer,r.generateDepthBuffer,e,e),r.generateMipMaps&&n.generateMipmap(n.TEXTURE_CUBE_MAP),this._bindTextureDirectly(n.TEXTURE_CUBE_MAP,null),this._bindUnboundFramebuffer(null),s._framebuffer=h,s._generateDepthBuffer=r.generateDepthBuffer,s._generateStencilBuffer=r.generateStencilBuffer,a.width=e,a.height=e,a.isReady=!0,a.isCube=!0,a.samples=1,a.generateMipMaps=r.generateMipMaps,a.samplingMode=r.samplingMode,a.type=r.type,a.format=r.format,this._internalTexturesCache.push(a),s.setTextures(a),s};var E=s(4640),x=s(2667),A=s(3537);n.ThinEngine.prototype.createPrefilteredCubeTexture=function(e,t,s,r,n=null,a=null,o,h=null,l=!0){return this.createCubeTexture(e,t,null,!1,(e=>{if(!e)return void(n&&n(null));const a=e.texture;if(l?e.info.sphericalPolynomial&&(a._sphericalPolynomial=e.info.sphericalPolynomial):a._sphericalPolynomial=new E.Q,a._source=9,this.getCaps().textureLOD)return void(n&&n(a));const o=this._gl,h=e.width;if(!h)return;const u=[];for(let n=0;n<3;n++){const l=1-n/2,d=r,_=Math.log2(h)*s+r,f=d+(_-d)*l,p=Math.round(Math.min(Math.max(f,0),_)),g=new i.h(this,2);if(g.type=a.type,g.format=a.format,g.width=Math.pow(2,Math.max(Math.log2(h)-p,0)),g.height=g.width,g.isCube=!0,g._cachedWrapU=0,g._cachedWrapV=0,this._bindTextureDirectly(o.TEXTURE_CUBE_MAP,g,!0),g.samplingMode=2,o.texParameteri(o.TEXTURE_CUBE_MAP,o.TEXTURE_MAG_FILTER,o.LINEAR),o.texParameteri(o.TEXTURE_CUBE_MAP,o.TEXTURE_MIN_FILTER,o.LINEAR),o.texParameteri(o.TEXTURE_CUBE_MAP,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_CUBE_MAP,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),e.isDDS){const t=e.info,s=e.data;this._unpackFlipY(t.isCompressed),A.D.UploadDDSLevels(this,g,s,t,!0,6,p)}else c.V.Warn("DDS is the only prefiltered cube map supported so far.");this._bindTextureDirectly(o.TEXTURE_CUBE_MAP,null);const m=new x.t(t);m._isCube=!0,m._texture=g,g.isReady=!0,u.push(m)}a._lodTextureHigh=u[2],a._lodTextureMid=u[1],a._lodTextureLow=u[0],n&&n(a)}),a,o,h,l,s,r)},n.ThinEngine.prototype.createUniformBuffer=function(e,t){const s=this._gl.createBuffer();if(!s)throw new Error("Unable to create uniform buffer");const i=new l.A(s);return this.bindUniformBuffer(i),e instanceof Float32Array?this._gl.bufferData(this._gl.UNIFORM_BUFFER,e,this._gl.STATIC_DRAW):this._gl.bufferData(this._gl.UNIFORM_BUFFER,new Float32Array(e),this._gl.STATIC_DRAW),this.bindUniformBuffer(null),i.references=1,i},n.ThinEngine.prototype.createDynamicUniformBuffer=function(e,t){const s=this._gl.createBuffer();if(!s)throw new Error("Unable to create dynamic uniform buffer");const i=new l.A(s);return this.bindUniformBuffer(i),e instanceof Float32Array?this._gl.bufferData(this._gl.UNIFORM_BUFFER,e,this._gl.DYNAMIC_DRAW):this._gl.bufferData(this._gl.UNIFORM_BUFFER,new Float32Array(e),this._gl.DYNAMIC_DRAW),this.bindUniformBuffer(null),i.references=1,i},n.ThinEngine.prototype.updateUniformBuffer=function(e,t,s,i){this.bindUniformBuffer(e),void 0===s&&(s=0),void 0===i?t instanceof Float32Array?this._gl.bufferSubData(this._gl.UNIFORM_BUFFER,s,t):this._gl.bufferSubData(this._gl.UNIFORM_BUFFER,s,new Float32Array(t)):t instanceof Float32Array?this._gl.bufferSubData(this._gl.UNIFORM_BUFFER,0,t.subarray(s,s+i)):this._gl.bufferSubData(this._gl.UNIFORM_BUFFER,0,new Float32Array(t).subarray(s,s+i)),this.bindUniformBuffer(null)},n.ThinEngine.prototype.bindUniformBuffer=function(e){this._gl.bindBuffer(this._gl.UNIFORM_BUFFER,e?e.underlyingResource:null)},n.ThinEngine.prototype.bindUniformBufferBase=function(e,t,s){this._gl.bindBufferBase(this._gl.UNIFORM_BUFFER,t,e?e.underlyingResource:null)},n.ThinEngine.prototype.bindUniformBlock=function(e,t,s){const i=e.program,r=this._gl.getUniformBlockIndex(i,t);4294967295!==r&&this._gl.uniformBlockBinding(i,r,s)};var R=s(8790);function M(e){if(e.requestPointerLock){const t=e.requestPointerLock();t instanceof Promise?t.then((()=>{e.focus()})).catch((()=>{})):e.focus()}}b.$.prototype.displayLoadingUI=function(){if(!(0,R.BA)())return;const e=this.loadingScreen;e&&e.displayLoadingUI()},b.$.prototype.hideLoadingUI=function(){if(!(0,R.BA)())return;const e=this._loadingScreen;e&&e.hideLoadingUI()},Object.defineProperty(b.$.prototype,"loadingScreen",{get:function(){return!this._loadingScreen&&this._renderingCanvas&&(this._loadingScreen=b.$.DefaultLoadingScreenFactory(this._renderingCanvas)),this._loadingScreen},set:function(e){this._loadingScreen=e},enumerable:!0,configurable:!0}),Object.defineProperty(b.$.prototype,"loadingUIText",{set:function(e){this.loadingScreen.loadingUIText=e},enumerable:!0,configurable:!0}),Object.defineProperty(b.$.prototype,"loadingUIBackgroundColor",{set:function(e){this.loadingScreen.loadingUIBackgroundColor=e},enumerable:!0,configurable:!0}),b.$.prototype.getInputElement=function(){return this._renderingCanvas},b.$.prototype.getRenderingCanvasClientRect=function(){return this._renderingCanvas?this._renderingCanvas.getBoundingClientRect():null},b.$.prototype.getInputElementClientRect=function(){return this._renderingCanvas?this.getInputElement().getBoundingClientRect():null},b.$.prototype.getAspectRatio=function(e,t=!1){const s=e.viewport;return this.getRenderWidth(t)*s.width/(this.getRenderHeight(t)*s.height)},b.$.prototype.getScreenAspectRatio=function(){return this.getRenderWidth(!0)/this.getRenderHeight(!0)},b.$.prototype._verifyPointerLock=function(){this._onPointerLockChange?.()},b.$.prototype.setAlphaEquation=function(e){if(this._alphaEquation!==e){switch(e){case 0:this._alphaState.setAlphaEquationParameters(32774,32774);break;case 1:this._alphaState.setAlphaEquationParameters(32778,32778);break;case 2:this._alphaState.setAlphaEquationParameters(32779,32779);break;case 3:this._alphaState.setAlphaEquationParameters(32776,32776);break;case 4:this._alphaState.setAlphaEquationParameters(32775,32775);break;case 5:this._alphaState.setAlphaEquationParameters(32775,32774)}this._alphaEquation=e}},b.$.prototype.getInputElement=function(){return this._renderingCanvas},b.$.prototype.getDepthFunction=function(){return this._depthCullingState.depthFunc},b.$.prototype.setDepthFunction=function(e){this._depthCullingState.depthFunc=e},b.$.prototype.setDepthFunctionToGreater=function(){this.setDepthFunction(516)},b.$.prototype.setDepthFunctionToGreaterOrEqual=function(){this.setDepthFunction(518)},b.$.prototype.setDepthFunctionToLess=function(){this.setDepthFunction(513)},b.$.prototype.setDepthFunctionToLessOrEqual=function(){this.setDepthFunction(515)},b.$.prototype.getDepthWrite=function(){return this._depthCullingState.depthMask},b.$.prototype.setDepthWrite=function(e){this._depthCullingState.depthMask=e},b.$.prototype.getStencilBuffer=function(){return this._stencilState.stencilTest},b.$.prototype.setStencilBuffer=function(e){this._stencilState.stencilTest=e},b.$.prototype.getStencilMask=function(){return this._stencilState.stencilMask},b.$.prototype.setStencilMask=function(e){this._stencilState.stencilMask=e},b.$.prototype.getStencilFunction=function(){return this._stencilState.stencilFunc},b.$.prototype.getStencilFunctionReference=function(){return this._stencilState.stencilFuncRef},b.$.prototype.getStencilFunctionMask=function(){return this._stencilState.stencilFuncMask},b.$.prototype.setStencilFunction=function(e){this._stencilState.stencilFunc=e},b.$.prototype.setStencilFunctionReference=function(e){this._stencilState.stencilFuncRef=e},b.$.prototype.setStencilFunctionMask=function(e){this._stencilState.stencilFuncMask=e},b.$.prototype.getStencilOperationFail=function(){return this._stencilState.stencilOpStencilFail},b.$.prototype.getStencilOperationDepthFail=function(){return this._stencilState.stencilOpDepthFail},b.$.prototype.getStencilOperationPass=function(){return this._stencilState.stencilOpStencilDepthPass},b.$.prototype.setStencilOperationFail=function(e){this._stencilState.stencilOpStencilFail=e},b.$.prototype.setStencilOperationDepthFail=function(e){this._stencilState.stencilOpDepthFail=e},b.$.prototype.setStencilOperationPass=function(e){this._stencilState.stencilOpStencilDepthPass=e},b.$.prototype.cacheStencilState=function(){this._cachedStencilBuffer=this.getStencilBuffer(),this._cachedStencilFunction=this.getStencilFunction(),this._cachedStencilMask=this.getStencilMask(),this._cachedStencilOperationPass=this.getStencilOperationPass(),this._cachedStencilOperationFail=this.getStencilOperationFail(),this._cachedStencilOperationDepthFail=this.getStencilOperationDepthFail(),this._cachedStencilReference=this.getStencilFunctionReference()},b.$.prototype.restoreStencilState=function(){this.setStencilFunction(this._cachedStencilFunction),this.setStencilMask(this._cachedStencilMask),this.setStencilBuffer(this._cachedStencilBuffer),this.setStencilOperationPass(this._cachedStencilOperationPass),this.setStencilOperationFail(this._cachedStencilOperationFail),this.setStencilOperationDepthFail(this._cachedStencilOperationDepthFail),this.setStencilFunctionReference(this._cachedStencilReference)},b.$.prototype.setAlphaConstants=function(e,t,s,i){this._alphaState.setAlphaBlendConstants(e,t,s,i)},b.$.prototype.getAlphaMode=function(){return this._alphaMode},b.$.prototype.getAlphaEquation=function(){return this._alphaEquation},b.$.prototype.getRenderPassNames=function(){return this._renderPassNames},b.$.prototype.getCurrentRenderPassName=function(){return this._renderPassNames[this.currentRenderPassId]},b.$.prototype.createRenderPassId=function(e){const t=++b.$._RenderPassIdCounter;return this._renderPassNames[t]=e??"NONAME",t},b.$.prototype.releaseRenderPassId=function(e){this._renderPassNames[e]=void 0;for(let t=0;tnew v(e,t,s);class v{get audioContext(){return this._audioContextInitialized||this._initializeAudioContext(),this._audioContext}constructor(e=null,t=null,s=null){if(this._audioContext=null,this._audioContextInitialized=!1,this._muteButton=null,this._audioDestination=null,this.canUseWebAudio=!1,this.WarnedWebAudioUnsupported=!1,this.isMP3supported=!1,this.isOGGsupported=!1,this.unlocked=!1,this.useCustomUnlockedButton=!1,this.onAudioUnlockedObservable=new P.cP,this.onAudioLockedObservable=new P.cP,this._tryToRun=!1,this._onResize=()=>{this._moveButtonToTopLeft()},!(0,R.BA)())return;void 0!==window.AudioContext&&(this.canUseWebAudio=!0);const i=document.createElement("audio");this._hostElement=e,this._audioContext=t,this._audioDestination=s;try{i&&i.canPlayType&&(i.canPlayType('audio/mpeg; codecs="mp3"').replace(/^no$/,"")||i.canPlayType("audio/mp3").replace(/^no$/,""))&&(this.isMP3supported=!0)}catch(e){}try{i&&i.canPlayType&&i.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,"")&&(this.isOGGsupported=!0)}catch(e){}}lock(){this._triggerSuspendedState()}unlock(){if("running"===this._audioContext?.state)return this._hideMuteButton(),void(this.unlocked||(this.unlocked=!0,this.onAudioUnlockedObservable.notifyObservers(this)));this._tryToRun?this._audioContext?.suspend().then((()=>{this._tryToRun=!1,this._triggerRunningState()})):this._triggerRunningState()}_resumeAudioContextOnStateChange(){this._audioContext?.addEventListener("statechange",(()=>{this.unlocked&&"running"!==this._audioContext?.state&&this._resumeAudioContext()}),{once:!0,passive:!0,signal:AbortSignal.timeout(3e3)})}_resumeAudioContext(){return this._audioContext?.resume?this._audioContext.resume():Promise.resolve()}_initializeAudioContext(){try{this.canUseWebAudio&&(this._audioContext||(this._audioContext=new AudioContext),this.masterGain=this._audioContext.createGain(),this.masterGain.gain.value=1,this._audioDestination||(this._audioDestination=this._audioContext.destination),this.masterGain.connect(this._audioDestination),this._audioContextInitialized=!0,"running"===this._audioContext.state&&this._triggerRunningState())}catch(e){this.canUseWebAudio=!1,c.V.Error("Web Audio: "+e.message)}}_triggerRunningState(){this._tryToRun||(this._tryToRun=!0,this._resumeAudioContext().then((()=>{this._tryToRun=!1,this._muteButton&&this._hideMuteButton(),this.unlocked=!0,this.onAudioUnlockedObservable.notifyObservers(this)})).catch((()=>{this._tryToRun=!1,this.unlocked=!1})))}_triggerSuspendedState(){this.unlocked=!1,this.onAudioLockedObservable.notifyObservers(this),this._displayMuteButton()}_displayMuteButton(){if(this.useCustomUnlockedButton||this._muteButton)return;this._muteButton=document.createElement("BUTTON"),this._muteButton.className="babylonUnmuteIcon",this._muteButton.id="babylonUnmuteIconBtn",this._muteButton.title="Unmute";const e=".babylonUnmuteIcon { position: absolute; left: 20px; top: 20px; height: 40px; width: 60px; background-color: rgba(51,51,51,0.7); background-image: url("+(window.SVGSVGElement?"data:image/svg+xml;charset=UTF-8,%3Csvg%20version%3D%221.1%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2239%22%20height%3D%2232%22%20viewBox%3D%220%200%2039%2032%22%3E%3Cpath%20fill%3D%22white%22%20d%3D%22M9.625%2018.938l-0.031%200.016h-4.953q-0.016%200-0.031-0.016v-12.453q0-0.016%200.031-0.016h4.953q0.031%200%200.031%200.016v12.453zM12.125%207.688l8.719-8.703v27.453l-8.719-8.719-0.016-0.047v-9.938zM23.359%207.875l1.406-1.406%204.219%204.203%204.203-4.203%201.422%201.406-4.219%204.219%204.219%204.203-1.484%201.359-4.141-4.156-4.219%204.219-1.406-1.422%204.219-4.203z%22%3E%3C%2Fpath%3E%3C%2Fsvg%3E":"https://cdn.babylonjs.com/Assets/audio.png")+"); background-size: 80%; background-repeat:no-repeat; background-position: center; background-position-y: 4px; border: none; outline: none; transition: transform 0.125s ease-out; cursor: pointer; z-index: 9999; } .babylonUnmuteIcon:hover { transform: scale(1.05) } .babylonUnmuteIcon:active { background-color: rgba(51,51,51,1) }",t=document.createElement("style");t.appendChild(document.createTextNode(e)),document.getElementsByTagName("head")[0].appendChild(t),document.body.appendChild(this._muteButton),this._moveButtonToTopLeft(),this._muteButton.addEventListener("touchend",(()=>{this._triggerRunningState()}),!0),this._muteButton.addEventListener("click",(()=>{this.unlock()}),!0),window.addEventListener("resize",this._onResize)}_moveButtonToTopLeft(){this._hostElement&&this._muteButton&&(this._muteButton.style.top=this._hostElement.offsetTop+20+"px",this._muteButton.style.left=this._hostElement.offsetLeft+20+"px")}_hideMuteButton(){this._muteButton&&(document.body.removeChild(this._muteButton),this._muteButton=null)}dispose(){this.canUseWebAudio&&this._audioContextInitialized&&(this._connectedAnalyser&&this._audioContext&&(this._connectedAnalyser.stopDebugCanvas(),this._connectedAnalyser.dispose(),this.masterGain.disconnect(),this.masterGain.connect(this._audioContext.destination),this._connectedAnalyser=null),this.masterGain.gain.value=1),this.WarnedWebAudioUnsupported=!1,this._hideMuteButton(),window.removeEventListener("resize",this._onResize),this.onAudioUnlockedObservable.clear(),this.onAudioLockedObservable.clear()}getGlobalVolume(){return this.canUseWebAudio&&this._audioContextInitialized?this.masterGain.gain.value:-1}setGlobalVolume(e){this.canUseWebAudio&&this._audioContextInitialized&&(this.masterGain.gain.value=e)}connectToAnalyser(e){this._connectedAnalyser&&this._connectedAnalyser.stopDebugCanvas(),this.canUseWebAudio&&this._audioContextInitialized&&this._audioContext&&(this._connectedAnalyser=e,this.masterGain.disconnect(),this._connectedAnalyser.connectAudioNodes(this.masterGain,this._audioContext.destination))}}class C extends n.ThinEngine{static get NpmPackage(){return b.$.NpmPackage}static get Version(){return b.$.Version}static get Instances(){return r.q.Instances}static get LastCreatedEngine(){return r.q.LastCreatedEngine}static get LastCreatedScene(){return r.q.LastCreatedScene}static DefaultLoadingScreenFactory(e){return b.$.DefaultLoadingScreenFactory(e)}get _supportsHardwareTextureRescaling(){return!!C._RescalePostProcessFactory}_measureFps(){this._performanceMonitor.sampleFrame(),this._fps=this._performanceMonitor.averageFPS,this._deltaTime=this._performanceMonitor.instantaneousFrameTime||0}get performanceMonitor(){return this._performanceMonitor}constructor(e,t,s,i=!1){if(super(e,t,s,i),this.customAnimationFrameRequester=null,this._performanceMonitor=new o,this._drawCalls=new y.A,e&&(this._features.supportRenderPasses=!0,s=this._creationOptions,e.getContext)){const t=e;this._sharedInit(t)}}_initGLContext(){super._initGLContext(),this._rescalePostProcess=null}_sharedInit(e){super._sharedInit(e),function(e,t,s){e._onCanvasFocus=()=>{e.onCanvasFocusObservable.notifyObservers(e)},e._onCanvasBlur=()=>{e.onCanvasBlurObservable.notifyObservers(e)},e._onCanvasContextMenu=t=>{e.disableContextMenu&&t.preventDefault()},t.addEventListener("focus",e._onCanvasFocus),t.addEventListener("blur",e._onCanvasBlur),t.addEventListener("contextmenu",e._onCanvasContextMenu),e._onBlur=()=>{e.disablePerformanceMonitorInBackground&&e.performanceMonitor.disable(),e._windowIsBackground=!0},e._onFocus=()=>{e.disablePerformanceMonitorInBackground&&e.performanceMonitor.enable(),e._windowIsBackground=!1},e._onCanvasPointerOut=s=>{document.elementFromPoint(s.clientX,s.clientY)!==t&&e.onCanvasPointerOutObservable.notifyObservers(s)};const i=e.getHostWindow();i&&"function"==typeof i.addEventListener&&(i.addEventListener("blur",e._onBlur),i.addEventListener("focus",e._onFocus)),t.addEventListener("pointerout",e._onCanvasPointerOut),s.doNotHandleTouchAction||function(e){e&&e.setAttribute&&(e.setAttribute("touch-action","none"),e.style.touchAction="none",e.style.webkitTapHighlightColor="transparent")}(t),!b.$.audioEngine&&s.audioEngine&&b.$.AudioEngineFactory&&(b.$.audioEngine=b.$.AudioEngineFactory(e.getRenderingCanvas(),e.getAudioContext(),e.getAudioDestination())),(0,R.Nf)()&&(e._onFullscreenChange=()=>{e.isFullscreen=!!document.fullscreenElement,e.isFullscreen&&e._pointerLockRequested&&t&&M(t)},document.addEventListener("fullscreenchange",e._onFullscreenChange,!1),document.addEventListener("webkitfullscreenchange",e._onFullscreenChange,!1),e._onPointerLockChange=()=>{e.isPointerLock=document.pointerLockElement===t},document.addEventListener("pointerlockchange",e._onPointerLockChange,!1),document.addEventListener("webkitpointerlockchange",e._onPointerLockChange,!1)),e.enableOfflineSupport=void 0!==b.$.OfflineProviderFactory,e._deterministicLockstep=!!s.deterministicLockstep,e._lockstepMaxSteps=s.lockstepMaxSteps||0,e._timeStep=s.timeStep||1/60}(this,e,this._creationOptions)}resizeImageBitmap(e,t,s){return function(e,t,s,i){const r=e.createCanvas(s,i).getContext("2d");if(!r)throw new Error("Unable to get 2d context for resizeImageBitmap");return r.drawImage(t,0,0),r.getImageData(0,0,s,i).data}(this,e,t,s)}_createImageBitmapFromSource(e,t){return function(e,t,s){return new Promise(((i,r)=>{const n=new Image;n.onload=()=>{n.decode().then((()=>{e.createImageBitmap(n,s).then((e=>{i(e)}))}))},n.onerror=()=>{r(`Error loading image ${n.src}`)},n.src=t}))}(this,e,t)}switchFullscreen(e){this.isFullscreen?this.exitFullscreen():this.enterFullscreen(e)}enterFullscreen(e){this.isFullscreen||(this._pointerLockRequested=e,this._renderingCanvas&&function(e){const t=e.requestFullscreen||e.webkitRequestFullscreen;t&&t.call(e)}(this._renderingCanvas))}exitFullscreen(){this.isFullscreen&&function(){const e=document;document.exitFullscreen?document.exitFullscreen():e.webkitCancelFullScreen&&e.webkitCancelFullScreen()}()}setDitheringState(e){e?this._gl.enable(this._gl.DITHER):this._gl.disable(this._gl.DITHER)}setRasterizerState(e){e?this._gl.disable(this._gl.RASTERIZER_DISCARD):this._gl.enable(this._gl.RASTERIZER_DISCARD)}setDirectViewport(e,t,s,i){const r=this._cachedViewport;return this._cachedViewport=null,this._viewport(e,t,s,i),r}scissorClear(e,t,s,i,r){this.enableScissor(e,t,s,i),this.clear(r,!0,!0,!0),this.disableScissor()}enableScissor(e,t,s,i){const r=this._gl;r.enable(r.SCISSOR_TEST),r.scissor(e,t,s,i)}disableScissor(){const e=this._gl;e.disable(e.SCISSOR_TEST)}_loadFileAsync(e,t,s){return new Promise(((i,r)=>{this._loadFile(e,(e=>{i(e)}),void 0,t,s,((e,t)=>{r(t)}))}))}getVertexShaderSource(e){const t=this._gl.getAttachedShaders(e);return t?this._gl.getShaderSource(t[0]):null}getFragmentShaderSource(e){const t=this._gl.getAttachedShaders(e);return t?this._gl.getShaderSource(t[1]):null}set framebufferDimensionsObject(e){this._framebufferDimensionsObject=e,this._framebufferDimensionsObject&&this.onResizeObservable.notifyObservers(this)}_rebuildBuffers(){for(const e of this.scenes)e.resetCachedMaterial(),e._rebuildGeometries();for(const e of this._virtualScenes)e.resetCachedMaterial(),e._rebuildGeometries();super._rebuildBuffers()}getFontOffset(e){return function(e){const t=document.createElement("span");t.textContent="Hg",t.style.font=e;const s=document.createElement("div");s.style.display="inline-block",s.style.width="1px",s.style.height="0px",s.style.verticalAlign="bottom";const i=document.createElement("div");i.style.whiteSpace="nowrap",i.appendChild(t),i.appendChild(s),document.body.appendChild(i);let r=0,n=0;try{n=s.getBoundingClientRect().top-t.getBoundingClientRect().top,s.style.verticalAlign="baseline",r=s.getBoundingClientRect().top-t.getBoundingClientRect().top}finally{document.body.removeChild(i)}return{ascent:r,height:n,descent:n-r}}(e)}_cancelFrame(){if(this.customAnimationFrameRequester){if(0!==this._frameHandler){this._frameHandler=0;const{cancelAnimationFrame:e}=this.customAnimationFrameRequester;e&&e(this.customAnimationFrameRequester.requestID)}}else super._cancelFrame()}_renderLoop(){if(this._frameHandler=0,!this._contextWasLost){let e=!0;(this.isDisposed||!this.renderEvenInBackground&&this._windowIsBackground)&&(e=!1),e&&(this.beginFrame(),this._renderViews()||this._renderFrame(),this.endFrame())}this._activeRenderLoops.length>0&&0===this._frameHandler&&(this.customAnimationFrameRequester?(this.customAnimationFrameRequester.requestID=this._queueNewFrame(this.customAnimationFrameRequester.renderFunction||this._boundRenderFunction,this.customAnimationFrameRequester),this._frameHandler=this.customAnimationFrameRequester.requestID):this._frameHandler=this._queueNewFrame(this._boundRenderFunction,this.getHostWindow()))}enterPointerlock(){this._renderingCanvas&&M(this._renderingCanvas)}exitPointerlock(){document.exitPointerLock&&document.exitPointerLock()}beginFrame(){this._measureFps(),super.beginFrame()}_deletePipelineContext(e){const t=e;t&&t.program&&t.transformFeedback&&(this.deleteTransformFeedback(t.transformFeedback),t.transformFeedback=null),super._deletePipelineContext(e)}createShaderProgram(e,t,s,i,r,n=null){r=r||this._gl,this.onBeforeShaderCompilationObservable.notifyObservers(this);const a=super.createShaderProgram(e,t,s,i,r,n);return this.onAfterShaderCompilationObservable.notifyObservers(this),a}_createShaderProgram(e,t,s,i,r=null){const n=i.createProgram();if(e.program=n,!n)throw new Error("Unable to create program");if(i.attachShader(n,t),i.attachShader(n,s),this.webGLVersion>1&&r){const t=this.createTransformFeedback();this.bindTransformFeedback(t),this.setTranformFeedbackVaryings(n,r),e.transformFeedback=t}return i.linkProgram(n),this.webGLVersion>1&&r&&this.bindTransformFeedback(null),e.context=i,e.vertexShader=t,e.fragmentShader=s,e.isParallelCompiled||this._finalizePipelineContext(e),n}_releaseTexture(e){super._releaseTexture(e)}_releaseRenderTargetWrapper(e){super._releaseRenderTargetWrapper(e),this.scenes.forEach((t=>{t.postProcesses.forEach((t=>{t._outputTexture===e&&(t._outputTexture=null)})),t.cameras.forEach((t=>{t._postProcesses.forEach((t=>{t&&t._outputTexture===e&&(t._outputTexture=null)}))}))}))}_rescaleTexture(e,t,s,i,r){this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MAG_FILTER,this._gl.LINEAR),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MIN_FILTER,this._gl.LINEAR),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_S,this._gl.CLAMP_TO_EDGE),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_T,this._gl.CLAMP_TO_EDGE);const n=this.createRenderTargetTexture({width:t.width,height:t.height},{generateMipMaps:!1,type:0,samplingMode:2,generateDepthBuffer:!1,generateStencilBuffer:!1});if(!this._rescalePostProcess&&C._RescalePostProcessFactory&&(this._rescalePostProcess=C._RescalePostProcessFactory(this)),this._rescalePostProcess){this._rescalePostProcess.externalTextureSamplerBinding=!0;const a=()=>{this._rescalePostProcess.onApply=function(t){t._bindTexture("textureSampler",e)};let a=s;a||(a=this.scenes[this.scenes.length-1]),a.postProcessManager.directRender([this._rescalePostProcess],n,!0),this._bindTextureDirectly(this._gl.TEXTURE_2D,t,!0),this._gl.copyTexImage2D(this._gl.TEXTURE_2D,0,i,0,0,t.width,t.height,0),this.unBindFramebuffer(n),n.dispose(),r&&r()},o=this._rescalePostProcess.getEffect();o?o.executeWhenCompiled(a):this._rescalePostProcess.onEffectCreatedObservable.addOnce((e=>{e.executeWhenCompiled(a)}))}}wrapWebGLTexture(e,t=!1,s=3,r=0,n=0){const a=new u.d(e,this._gl),o=new i.h(this,0,!0);return o._hardwareTexture=a,o.baseWidth=r,o.baseHeight=n,o.width=r,o.height=n,o.isReady=!0,o.useMipMaps=t,this.updateTextureSamplingMode(s,o),o}_uploadImageToTexture(e,t,s=0,i=0){const r=this._gl,n=this._getWebGLTextureType(e.type),a=this._getInternalFormat(e.format),o=this._getRGBABufferInternalSizedFormat(e.type,a),h=e.isCube?r.TEXTURE_CUBE_MAP:r.TEXTURE_2D;this._bindTextureDirectly(h,e,!0),this._unpackFlipY(e.invertY);let l=r.TEXTURE_2D;e.isCube&&(l=r.TEXTURE_CUBE_MAP_POSITIVE_X+s),r.texImage2D(l,i,o,a,n,t),this._bindTextureDirectly(h,null,!0)}updateTextureComparisonFunction(e,t){if(1===this.webGLVersion)return void c.V.Error("WebGL 1 does not support texture comparison.");const s=this._gl;e.isCube?(this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,e,!0),0===t?(s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_COMPARE_FUNC,515),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_COMPARE_MODE,s.NONE)):(s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_COMPARE_FUNC,t),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_COMPARE_MODE,s.COMPARE_REF_TO_TEXTURE)),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null)):(this._bindTextureDirectly(this._gl.TEXTURE_2D,e,!0),0===t?(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_COMPARE_FUNC,515),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_COMPARE_MODE,s.NONE)):(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_COMPARE_FUNC,t),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_COMPARE_MODE,s.COMPARE_REF_TO_TEXTURE)),this._bindTextureDirectly(this._gl.TEXTURE_2D,null)),e._comparisonFunction=t}createInstancesBuffer(e){const t=this._gl.createBuffer();if(!t)throw new Error("Unable to create instance buffer");const s=new l.A(t);return s.capacity=e,this.bindArrayBuffer(s),this._gl.bufferData(this._gl.ARRAY_BUFFER,e,this._gl.DYNAMIC_DRAW),s.references=1,s}deleteInstancesBuffer(e){this._gl.deleteBuffer(e)}_clientWaitAsync(e,t=0,s=10){const i=this._gl;return new Promise(((r,n)=>{const a=()=>{const o=i.clientWaitSync(e,t,0);o!=i.WAIT_FAILED?o!=i.TIMEOUT_EXPIRED?r():setTimeout(a,s):n()};a()}))}_readPixelsAsync(e,t,s,i,r,n,a){if(this._webGLVersion<2)throw new Error("_readPixelsAsync only work on WebGL2+");const o=this._gl,h=o.createBuffer();o.bindBuffer(o.PIXEL_PACK_BUFFER,h),o.bufferData(o.PIXEL_PACK_BUFFER,a.byteLength,o.STREAM_READ),o.readPixels(e,t,s,i,r,n,0),o.bindBuffer(o.PIXEL_PACK_BUFFER,null);const l=o.fenceSync(o.SYNC_GPU_COMMANDS_COMPLETE,0);return l?(o.flush(),this._clientWaitAsync(l,0,10).then((()=>(o.deleteSync(l),o.bindBuffer(o.PIXEL_PACK_BUFFER,h),o.getBufferSubData(o.PIXEL_PACK_BUFFER,0,a),o.bindBuffer(o.PIXEL_PACK_BUFFER,null),o.deleteBuffer(h),a)))):null}dispose(){this.hideLoadingUI(),this._rescalePostProcess&&this._rescalePostProcess.dispose(),function(e,t){1===r.q.Instances.length&&b.$.audioEngine&&(b.$.audioEngine.dispose(),b.$.audioEngine=null);const s=e.getHostWindow();s&&"function"==typeof s.removeEventListener&&(s.removeEventListener("blur",e._onBlur),s.removeEventListener("focus",e._onFocus)),t&&(t.removeEventListener("focus",e._onCanvasFocus),t.removeEventListener("blur",e._onCanvasBlur),t.removeEventListener("pointerout",e._onCanvasPointerOut),t.removeEventListener("contextmenu",e._onCanvasContextMenu)),(0,R.Nf)()&&(document.removeEventListener("fullscreenchange",e._onFullscreenChange),document.removeEventListener("mozfullscreenchange",e._onFullscreenChange),document.removeEventListener("webkitfullscreenchange",e._onFullscreenChange),document.removeEventListener("msfullscreenchange",e._onFullscreenChange),document.removeEventListener("pointerlockchange",e._onPointerLockChange),document.removeEventListener("mspointerlockchange",e._onPointerLockChange),document.removeEventListener("mozpointerlockchange",e._onPointerLockChange),document.removeEventListener("webkitpointerlockchange",e._onPointerLockChange))}(this,this._renderingCanvas),super.dispose()}}C.ALPHA_DISABLE=0,C.ALPHA_ADD=1,C.ALPHA_COMBINE=2,C.ALPHA_SUBTRACT=3,C.ALPHA_MULTIPLY=4,C.ALPHA_MAXIMIZED=5,C.ALPHA_ONEONE=6,C.ALPHA_PREMULTIPLIED=7,C.ALPHA_PREMULTIPLIED_PORTERDUFF=8,C.ALPHA_INTERPOLATE=9,C.ALPHA_SCREENMODE=10,C.DELAYLOADSTATE_NONE=0,C.DELAYLOADSTATE_LOADED=1,C.DELAYLOADSTATE_LOADING=2,C.DELAYLOADSTATE_NOTLOADED=4,C.NEVER=512,C.ALWAYS=519,C.LESS=513,C.EQUAL=514,C.LEQUAL=515,C.GREATER=516,C.GEQUAL=518,C.NOTEQUAL=517,C.KEEP=7680,C.REPLACE=7681,C.INCR=7682,C.DECR=7683,C.INVERT=5386,C.INCR_WRAP=34055,C.DECR_WRAP=34056,C.TEXTURE_CLAMP_ADDRESSMODE=0,C.TEXTURE_WRAP_ADDRESSMODE=1,C.TEXTURE_MIRROR_ADDRESSMODE=2,C.TEXTUREFORMAT_ALPHA=0,C.TEXTUREFORMAT_LUMINANCE=1,C.TEXTUREFORMAT_LUMINANCE_ALPHA=2,C.TEXTUREFORMAT_RGB=4,C.TEXTUREFORMAT_RGBA=5,C.TEXTUREFORMAT_RED=6,C.TEXTUREFORMAT_R=6,C.TEXTUREFORMAT_RG=7,C.TEXTUREFORMAT_RED_INTEGER=8,C.TEXTUREFORMAT_R_INTEGER=8,C.TEXTUREFORMAT_RG_INTEGER=9,C.TEXTUREFORMAT_RGB_INTEGER=10,C.TEXTUREFORMAT_RGBA_INTEGER=11,C.TEXTURETYPE_UNSIGNED_BYTE=0,C.TEXTURETYPE_UNSIGNED_INT=0,C.TEXTURETYPE_FLOAT=1,C.TEXTURETYPE_HALF_FLOAT=2,C.TEXTURETYPE_BYTE=3,C.TEXTURETYPE_SHORT=4,C.TEXTURETYPE_UNSIGNED_SHORT=5,C.TEXTURETYPE_INT=6,C.TEXTURETYPE_UNSIGNED_INTEGER=7,C.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4=8,C.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1=9,C.TEXTURETYPE_UNSIGNED_SHORT_5_6_5=10,C.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV=11,C.TEXTURETYPE_UNSIGNED_INT_24_8=12,C.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV=13,C.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV=14,C.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV=15,C.TEXTURE_NEAREST_SAMPLINGMODE=1,C.TEXTURE_BILINEAR_SAMPLINGMODE=2,C.TEXTURE_TRILINEAR_SAMPLINGMODE=3,C.TEXTURE_NEAREST_NEAREST_MIPLINEAR=8,C.TEXTURE_LINEAR_LINEAR_MIPNEAREST=11,C.TEXTURE_LINEAR_LINEAR_MIPLINEAR=3,C.TEXTURE_NEAREST_NEAREST_MIPNEAREST=4,C.TEXTURE_NEAREST_LINEAR_MIPNEAREST=5,C.TEXTURE_NEAREST_LINEAR_MIPLINEAR=6,C.TEXTURE_NEAREST_LINEAR=7,C.TEXTURE_NEAREST_NEAREST=1,C.TEXTURE_LINEAR_NEAREST_MIPNEAREST=9,C.TEXTURE_LINEAR_NEAREST_MIPLINEAR=10,C.TEXTURE_LINEAR_LINEAR=2,C.TEXTURE_LINEAR_NEAREST=12,C.TEXTURE_EXPLICIT_MODE=0,C.TEXTURE_SPHERICAL_MODE=1,C.TEXTURE_PLANAR_MODE=2,C.TEXTURE_CUBIC_MODE=3,C.TEXTURE_PROJECTION_MODE=4,C.TEXTURE_SKYBOX_MODE=5,C.TEXTURE_INVCUBIC_MODE=6,C.TEXTURE_EQUIRECTANGULAR_MODE=7,C.TEXTURE_FIXED_EQUIRECTANGULAR_MODE=8,C.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE=9,C.SCALEMODE_FLOOR=1,C.SCALEMODE_NEAREST=2,C.SCALEMODE_CEILING=3},6315:(e,t,s)=>{s.d(t,{q:()=>r});var i=s(9848);class r{static get LastCreatedEngine(){return 0===this.Instances.length?null:this.Instances[this.Instances.length-1]}static get LastCreatedScene(){return this._LastCreatedScene}}r.Instances=[],r.OnEnginesDisposedObservable=new i.cP,r._LastCreatedScene=null,r.UseFallbackTexture=!0,r.FallbackTexture=""},215:(e,t,s)=>{s.d(t,{I:()=>i});class i{static SetMatrixPrecision(e){if(i.MatrixTrackPrecisionChange=!1,e&&!i.MatrixUse64Bits&&i.MatrixTrackedMatrices)for(let e=0;e{s.d(t,{l:()=>i});class i{static GetShadersRepository(e=0){return 0===e?i.ShadersRepository:i.ShadersRepositoryWGSL}static GetShadersStore(e=0){return 0===e?i.ShadersStore:i.ShadersStoreWGSL}static GetIncludesShadersStore(e=0){return 0===e?i.IncludesShadersStore:i.IncludesShadersStoreWGSL}}i.ShadersRepository="src/Shaders/",i.ShadersStore={},i.IncludesShadersStore={},i.ShadersRepositoryWGSL="src/ShadersWGSL/",i.ShadersStoreWGSL={},i.IncludesShadersStoreWGSL={}},5852:(e,t,s)=>{s.d(t,{tI:()=>d,bS:()=>T,tg:()=>_,YM:()=>f,C5:()=>m,GX:()=>u,kf:()=>l,EX:()=>c,Cm:()=>h,N5:()=>o});class i{constructor(){this._valueCache={},this.vertexCompilationError=null,this.fragmentCompilationError=null,this.programLinkError=null,this.programValidationError=null,this._isDisposed=!1}get isAsync(){return this.isParallelCompiled}get isReady(){return!!this.program&&(!this.isParallelCompiled||this.engine._isRenderingStateCompiled(this))}_handlesSpectorRebuildCallback(e){e&&this.program&&e(this.program)}setEngine(e){this.engine=e}_fillEffectInformation(e,t,s,i,r,n,a,o){const h=this.engine;if(h.supportsUniformBuffers)for(const s in t)e.bindUniformBlock(s,t[s]);let l;for(this.engine.getUniforms(this,s).forEach(((e,t)=>{i[s[t]]=e})),this._uniforms=i,l=0;l{n[e]=t}));for(const e of h.getAttributes(this,a))o.push(e)}dispose(){this._uniforms={},this._isDisposed=!0}_cacheMatrix(e,t){const s=this._valueCache[e],i=t.updateFlag;return(void 0===s||s!==i)&&(this._valueCache[e]=i,!0)}_cacheFloat2(e,t,s){let i=this._valueCache[e];if(!i||2!==i.length)return i=[t,s],this._valueCache[e]=i,!0;let r=!1;return i[0]!==t&&(i[0]=t,r=!0),i[1]!==s&&(i[1]=s,r=!0),r}_cacheFloat3(e,t,s,i){let r=this._valueCache[e];if(!r||3!==r.length)return r=[t,s,i],this._valueCache[e]=r,!0;let n=!1;return r[0]!==t&&(r[0]=t,n=!0),r[1]!==s&&(r[1]=s,n=!0),r[2]!==i&&(r[2]=i,n=!0),n}_cacheFloat4(e,t,s,i,r){let n=this._valueCache[e];if(!n||4!==n.length)return n=[t,s,i,r],this._valueCache[e]=n,!0;let a=!1;return n[0]!==t&&(n[0]=t,a=!0),n[1]!==s&&(n[1]=s,a=!0),n[2]!==i&&(n[2]=i,a=!0),n[3]!==r&&(n[3]=r,a=!0),a}setInt(e,t){const s=this._valueCache[e];void 0!==s&&s===t||this.engine.setInt(this._uniforms[e],t)&&(this._valueCache[e]=t)}setInt2(e,t,s){this._cacheFloat2(e,t,s)&&(this.engine.setInt2(this._uniforms[e],t,s)||(this._valueCache[e]=null))}setInt3(e,t,s,i){this._cacheFloat3(e,t,s,i)&&(this.engine.setInt3(this._uniforms[e],t,s,i)||(this._valueCache[e]=null))}setInt4(e,t,s,i,r){this._cacheFloat4(e,t,s,i,r)&&(this.engine.setInt4(this._uniforms[e],t,s,i,r)||(this._valueCache[e]=null))}setIntArray(e,t){this._valueCache[e]=null,this.engine.setIntArray(this._uniforms[e],t)}setIntArray2(e,t){this._valueCache[e]=null,this.engine.setIntArray2(this._uniforms[e],t)}setIntArray3(e,t){this._valueCache[e]=null,this.engine.setIntArray3(this._uniforms[e],t)}setIntArray4(e,t){this._valueCache[e]=null,this.engine.setIntArray4(this._uniforms[e],t)}setUInt(e,t){const s=this._valueCache[e];void 0!==s&&s===t||this.engine.setUInt(this._uniforms[e],t)&&(this._valueCache[e]=t)}setUInt2(e,t,s){this._cacheFloat2(e,t,s)&&(this.engine.setUInt2(this._uniforms[e],t,s)||(this._valueCache[e]=null))}setUInt3(e,t,s,i){this._cacheFloat3(e,t,s,i)&&(this.engine.setUInt3(this._uniforms[e],t,s,i)||(this._valueCache[e]=null))}setUInt4(e,t,s,i,r){this._cacheFloat4(e,t,s,i,r)&&(this.engine.setUInt4(this._uniforms[e],t,s,i,r)||(this._valueCache[e]=null))}setUIntArray(e,t){this._valueCache[e]=null,this.engine.setUIntArray(this._uniforms[e],t)}setUIntArray2(e,t){this._valueCache[e]=null,this.engine.setUIntArray2(this._uniforms[e],t)}setUIntArray3(e,t){this._valueCache[e]=null,this.engine.setUIntArray3(this._uniforms[e],t)}setUIntArray4(e,t){this._valueCache[e]=null,this.engine.setUIntArray4(this._uniforms[e],t)}setArray(e,t){this._valueCache[e]=null,this.engine.setArray(this._uniforms[e],t)}setArray2(e,t){this._valueCache[e]=null,this.engine.setArray2(this._uniforms[e],t)}setArray3(e,t){this._valueCache[e]=null,this.engine.setArray3(this._uniforms[e],t)}setArray4(e,t){this._valueCache[e]=null,this.engine.setArray4(this._uniforms[e],t)}setMatrices(e,t){t&&(this._valueCache[e]=null,this.engine.setMatrices(this._uniforms[e],t))}setMatrix(e,t){this._cacheMatrix(e,t)&&(this.engine.setMatrices(this._uniforms[e],t.asArray())||(this._valueCache[e]=null))}setMatrix3x3(e,t){this._valueCache[e]=null,this.engine.setMatrix3x3(this._uniforms[e],t)}setMatrix2x2(e,t){this._valueCache[e]=null,this.engine.setMatrix2x2(this._uniforms[e],t)}setFloat(e,t){const s=this._valueCache[e];void 0!==s&&s===t||this.engine.setFloat(this._uniforms[e],t)&&(this._valueCache[e]=t)}setVector2(e,t){this._cacheFloat2(e,t.x,t.y)&&(this.engine.setFloat2(this._uniforms[e],t.x,t.y)||(this._valueCache[e]=null))}setFloat2(e,t,s){this._cacheFloat2(e,t,s)&&(this.engine.setFloat2(this._uniforms[e],t,s)||(this._valueCache[e]=null))}setVector3(e,t){this._cacheFloat3(e,t.x,t.y,t.z)&&(this.engine.setFloat3(this._uniforms[e],t.x,t.y,t.z)||(this._valueCache[e]=null))}setFloat3(e,t,s,i){this._cacheFloat3(e,t,s,i)&&(this.engine.setFloat3(this._uniforms[e],t,s,i)||(this._valueCache[e]=null))}setVector4(e,t){this._cacheFloat4(e,t.x,t.y,t.z,t.w)&&(this.engine.setFloat4(this._uniforms[e],t.x,t.y,t.z,t.w)||(this._valueCache[e]=null))}setQuaternion(e,t){this._cacheFloat4(e,t.x,t.y,t.z,t.w)&&(this.engine.setFloat4(this._uniforms[e],t.x,t.y,t.z,t.w)||(this._valueCache[e]=null))}setFloat4(e,t,s,i,r){this._cacheFloat4(e,t,s,i,r)&&(this.engine.setFloat4(this._uniforms[e],t,s,i,r)||(this._valueCache[e]=null))}setColor3(e,t){this._cacheFloat3(e,t.r,t.g,t.b)&&(this.engine.setFloat3(this._uniforms[e],t.r,t.g,t.b)||(this._valueCache[e]=null))}setColor4(e,t,s){this._cacheFloat4(e,t.r,t.g,t.b,s)&&(this.engine.setFloat4(this._uniforms[e],t.r,t.g,t.b,s)||(this._valueCache[e]=null))}setDirectColor4(e,t){this._cacheFloat4(e,t.r,t.g,t.b,t.a)&&(this.engine.setFloat4(this._uniforms[e],t.r,t.g,t.b,t.a)||(this._valueCache[e]=null))}_getVertexShaderCode(){return this.vertexShader?this.engine._getShaderSource(this.vertexShader):null}_getFragmentShaderCode(){return this.fragmentShader?this.engine._getShaderSource(this.fragmentShader):null}}var r=s(6741);const n=new WeakMap,a={_webGLVersion:2,cachedPipelines:{}};function o(e){let t=n.get(e);if(!t){if(!e)return a;t={_webGLVersion:e.TEXTURE_BINDING_3D?2:1,_context:e,cachedPipelines:{}},n.set(e,t)}return t}function h(e){n.delete(e)}function l(e,t,s,i,r,n){const a=o(i);return n||(n=a._createShaderProgramInjection??d),n(e,g(t,"vertex",i,a._contextWasLost),g(s,"fragment",i,a._contextWasLost),i,r,a.validateShaderPrograms)}function c(e,t,s,i,r,n=null,a){const h=o(r);a||(a=h._createShaderProgramInjection??d);const l=h._webGLVersion>1?"#version 300 es\n#define WEBGL2 \n":"";return a(e,p(t,"vertex",i,l,r,h._contextWasLost),p(s,"fragment",i,l,r,h._contextWasLost),r,n,h.validateShaderPrograms)}function u(e,t){const s=new i,r=o(e);return r.parallelShaderCompile&&(s.isParallelCompiled=!0),s.context=r._context,s}function d(e,t,s,i,r=null,n){const a=i.createProgram();if(e.program=a,!a)throw new Error("Unable to create program");return i.attachShader(a,t),i.attachShader(a,s),i.linkProgram(a),e.context=i,e.vertexShader=t,e.fragmentShader=s,e.isParallelCompiled||_(e,i,n),a}function _(e,t,s){const i=e.context,r=e.vertexShader,n=e.fragmentShader,a=e.program;if(!i.getProgramParameter(a,i.LINK_STATUS)){if(!t.getShaderParameter(r,t.COMPILE_STATUS)){const s=t.getShaderInfoLog(r);if(s)throw e.vertexCompilationError=s,new Error("VERTEX SHADER "+s)}if(!t.getShaderParameter(n,t.COMPILE_STATUS)){const s=t.getShaderInfoLog(n);if(s)throw e.fragmentCompilationError=s,new Error("FRAGMENT SHADER "+s)}const s=i.getProgramInfoLog(a);if(s)throw e.programLinkError=s,new Error(s)}if(s&&(i.validateProgram(a),!i.getProgramParameter(a,i.VALIDATE_STATUS))){const t=i.getProgramInfoLog(a);if(t)throw e.programValidationError=t,new Error(t)}i.deleteShader(r),i.deleteShader(n),e.vertexShader=void 0,e.fragmentShader=void 0,e.onCompiled&&(e.onCompiled(),e.onCompiled=void 0)}function f(e,t,s,i,r,n,a,h,u,d="",_,f,p){const g=o(e.context);f||(f=g.createRawShaderProgramInjection??l),p||(p=g.createShaderProgramInjection??c);const m=e;m.program=i?f(m,t,s,m.context,u):p(m,t,s,h,m.context,u),m.program.__SPECTOR_rebuildProgram=a,_()}function p(e,t,s,i,n,a){return g((0,r.iL)(e,s,i),t,n,a)}function g(e,t,s,i){const r=s.createShader("vertex"===t?s.VERTEX_SHADER:s.FRAGMENT_SHADER);if(!r){let e=s.NO_ERROR,r=s.NO_ERROR;for(;(r=s.getError())!==s.NO_ERROR;)e=r;throw new Error(`Something went wrong while creating a gl ${t} shader object. gl error=${e}, gl isContextLost=${s.isContextLost()}, _contextWasLost=${i}`)}return s.shaderSource(r,e),s.compileShader(r),r}function m(e,t){t.useProgram(e)}function T(e,t){const s=e;if(!s.isParallelCompiled)return void t(e);const i=s.onCompiled;s.onCompiled=()=>{i?.(),t(e)}}},6321:(e,t,s)=>{s.r(t),s.d(t,{ThinEngine:()=>T});var i=s(5852),r=s(1137),n=s(8790);class a{constructor(){this.shaderLanguage=0}postProcessor(e,t,s,i,r){if(r.drawBuffersExtensionDisabled){const t=/#extension.+GL_EXT_draw_buffers.+(enable|require)/g;e=e.replace(t,"")}return e}}const o=/(flat\s)?\s*varying\s*.*/;class h{constructor(){this.shaderLanguage=0}attributeProcessor(e){return e.replace("attribute","in")}varyingCheck(e,t){return o.test(e)}varyingProcessor(e,t){return e.replace("varying",t?"in":"out")}postProcessor(e,t,s){const i=-1!==e.search(/#extension.+GL_EXT_draw_buffers.+require/);if(e=(e=e.replace(/#extension.+(GL_OVR_multiview2|GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth|GL_EXT_draw_buffers).+(enable|require)/g,"")).replace(/texture2D\s*\(/g,"texture("),s){const t=-1!==e.search(/layout *\(location *= *0\) *out/g);e=(e=(e=(e=(e=(e=(e=e.replace(/texture2DLodEXT\s*\(/g,"textureLod(")).replace(/textureCubeLodEXT\s*\(/g,"textureLod(")).replace(/textureCube\s*\(/g,"texture(")).replace(/gl_FragDepthEXT/g,"gl_FragDepth")).replace(/gl_FragColor/g,"glFragColor")).replace(/gl_FragData/g,"glFragData")).replace(/void\s+?main\s*\(/g,(i||t?"":"layout(location = 0) out vec4 glFragColor;\n")+"void main(")}else if(-1!==t.indexOf("#define MULTIVIEW"))return"#extension GL_OVR_multiview2 : require\nlayout (num_views = 2) in;\n"+e;return e}}var l=s(4329),c=s(1597),u=s(6326),d=s(7716),_=s(854),f=s(4420),p=s(6741),g=s(7647);class m{}class T extends u.${get name(){return this._name}set name(e){this._name=e}get version(){return this._webGLVersion}static get ShadersRepository(){return f.M.ShadersRepository}static set ShadersRepository(e){f.M.ShadersRepository=e}get supportsUniformBuffers(){return this.webGLVersion>1&&!this.disableUniformBuffers}get needPOTTextures(){return this._webGLVersion<2||this.forcePOTTextures}get _supportsHardwareTextureRescaling(){return!1}set framebufferDimensionsObject(e){this._framebufferDimensionsObject=e}snapshotRenderingReset(){this.snapshotRendering=!1}constructor(e,t,s,n){if(s=s||{},super(t??s.antialias,s,n),this._name="WebGL",this.forcePOTTextures=!1,this.validateShaderPrograms=!1,this.disableUniformBuffers=!1,this._webGLVersion=1,this._vertexAttribArraysEnabled=[],this._uintIndicesCurrentlySet=!1,this._currentBoundBuffer=new Array,this._currentFramebuffer=null,this._dummyFramebuffer=null,this._currentBufferPointers=new Array,this._currentInstanceLocations=new Array,this._currentInstanceBuffers=new Array,this._vaoRecordInProgress=!1,this._mustWipeVertexAttributes=!1,this._nextFreeTextureSlots=new Array,this._maxSimultaneousTextures=0,this._maxMSAASamplesOverride=null,this._unpackFlipYCached=null,this.enableUnpackFlipYCached=!0,this._boundUniforms={},!e)return;let o=null;if(e.getContext){if(o=e,this._renderingCanvas=o,void 0===s.preserveDrawingBuffer&&(s.preserveDrawingBuffer=!1),void 0===s.xrCompatible&&(s.xrCompatible=!1),navigator&&navigator.userAgent){this._setupMobileChecks();const e=navigator.userAgent;for(const t of T.ExceptionList){const i=t.key,r=t.targets;if(new RegExp(i).test(e)){if(t.capture&&t.captureConstraint){const s=t.capture,i=t.captureConstraint,r=new RegExp(s).exec(e);if(r&&r.length>0&&parseInt(r[r.length-1])>=i)continue}for(const e of r)switch(e){case"uniformBuffer":this.disableUniformBuffers=!0;break;case"vao":this.disableVertexArrayObjects=!0;break;case"antialias":s.antialias=!1;break;case"maxMSAASamples":this._maxMSAASamplesOverride=1}}}}if(this._doNotHandleContextLost||(this._onContextLost=e=>{e.preventDefault(),this._contextWasLost=!0,r.V.Warn("WebGL context lost."),this.onContextLostObservable.notifyObservers(this)},this._onContextRestored=()=>{this._restoreEngineAfterContextLost((()=>this._initGLContext()))},o.addEventListener("webglcontextlost",this._onContextLost,!1),o.addEventListener("webglcontextrestored",this._onContextRestored,!1),s.powerPreference=s.powerPreference||"high-performance"),this._badDesktopOS&&(s.xrCompatible=!1),!s.disableWebGL2Support)try{this._gl=o.getContext("webgl2",s)||o.getContext("experimental-webgl2",s),this._gl&&(this._webGLVersion=2,this._shaderPlatformName="WEBGL2",this._gl.deleteQuery||(this._webGLVersion=1,this._shaderPlatformName="WEBGL1"))}catch(e){}if(!this._gl){if(!o)throw new Error("The provided canvas is null or undefined.");try{this._gl=o.getContext("webgl",s)||o.getContext("experimental-webgl",s)}catch(e){throw new Error("WebGL not supported")}}if(!this._gl)throw new Error("WebGL not supported")}else{this._gl=e,this._renderingCanvas=this._gl.canvas,this._gl.renderbufferStorageMultisample?(this._webGLVersion=2,this._shaderPlatformName="WEBGL2"):this._shaderPlatformName="WEBGL1";const t=this._gl.getContextAttributes();t&&(s.stencil=t.stencil)}this._gl.pixelStorei(this._gl.UNPACK_COLORSPACE_CONVERSION_WEBGL,this._gl.NONE),void 0!==s.useHighPrecisionFloats&&(this._highPrecisionShadersAllowed=s.useHighPrecisionFloats),this.resize(),this._initGLContext(),this._initFeatures();for(let e=0;e1?new h:new a;const l=`Babylon.js v${T.Version}`;r.V.Log(l+` - ${this.description}`),this._renderingCanvas&&this._renderingCanvas.setAttribute&&this._renderingCanvas.setAttribute("data-engine",l);const c=(0,i.N5)(this._gl);c.validateShaderPrograms=this.validateShaderPrograms,c.parallelShaderCompile=this._caps.parallelShaderCompile}_clearEmptyResources(){this._dummyFramebuffer=null,super._clearEmptyResources()}_getShaderProcessingContext(e){return null}areAllEffectsReady(){for(const e in this._compiledEffects)if(!this._compiledEffects[e].isReady())return!1;return!0}_initGLContext(){this._caps={maxTexturesImageUnits:this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS),maxCombinedTexturesImageUnits:this._gl.getParameter(this._gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS),maxVertexTextureImageUnits:this._gl.getParameter(this._gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS),maxTextureSize:this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE),maxSamples:this._webGLVersion>1?this._gl.getParameter(this._gl.MAX_SAMPLES):1,maxCubemapTextureSize:this._gl.getParameter(this._gl.MAX_CUBE_MAP_TEXTURE_SIZE),maxRenderTextureSize:this._gl.getParameter(this._gl.MAX_RENDERBUFFER_SIZE),maxVertexAttribs:this._gl.getParameter(this._gl.MAX_VERTEX_ATTRIBS),maxVaryingVectors:this._gl.getParameter(this._gl.MAX_VARYING_VECTORS),maxFragmentUniformVectors:this._gl.getParameter(this._gl.MAX_FRAGMENT_UNIFORM_VECTORS),maxVertexUniformVectors:this._gl.getParameter(this._gl.MAX_VERTEX_UNIFORM_VECTORS),parallelShaderCompile:this._gl.getExtension("KHR_parallel_shader_compile")||void 0,standardDerivatives:this._webGLVersion>1||null!==this._gl.getExtension("OES_standard_derivatives"),maxAnisotropy:1,astc:this._gl.getExtension("WEBGL_compressed_texture_astc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_astc"),bptc:this._gl.getExtension("EXT_texture_compression_bptc")||this._gl.getExtension("WEBKIT_EXT_texture_compression_bptc"),s3tc:this._gl.getExtension("WEBGL_compressed_texture_s3tc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc"),s3tc_srgb:this._gl.getExtension("WEBGL_compressed_texture_s3tc_srgb")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc_srgb"),pvrtc:this._gl.getExtension("WEBGL_compressed_texture_pvrtc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),etc1:this._gl.getExtension("WEBGL_compressed_texture_etc1")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_etc1"),etc2:this._gl.getExtension("WEBGL_compressed_texture_etc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_etc")||this._gl.getExtension("WEBGL_compressed_texture_es3_0"),textureAnisotropicFilterExtension:this._gl.getExtension("EXT_texture_filter_anisotropic")||this._gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic")||this._gl.getExtension("MOZ_EXT_texture_filter_anisotropic"),uintIndices:this._webGLVersion>1||null!==this._gl.getExtension("OES_element_index_uint"),fragmentDepthSupported:this._webGLVersion>1||null!==this._gl.getExtension("EXT_frag_depth"),highPrecisionShaderSupported:!1,timerQuery:this._gl.getExtension("EXT_disjoint_timer_query_webgl2")||this._gl.getExtension("EXT_disjoint_timer_query"),supportOcclusionQuery:this._webGLVersion>1,canUseTimestampForTimerQuery:!1,drawBuffersExtension:!1,maxMSAASamples:1,colorBufferFloat:!!(this._webGLVersion>1&&this._gl.getExtension("EXT_color_buffer_float")),supportFloatTexturesResolve:!1,rg11b10ufColorRenderable:!1,colorBufferHalfFloat:!!(this._webGLVersion>1&&this._gl.getExtension("EXT_color_buffer_half_float")),textureFloat:!!(this._webGLVersion>1||this._gl.getExtension("OES_texture_float")),textureHalfFloat:!!(this._webGLVersion>1||this._gl.getExtension("OES_texture_half_float")),textureHalfFloatRender:!1,textureFloatLinearFiltering:!1,textureFloatRender:!1,textureHalfFloatLinearFiltering:!1,vertexArrayObject:!1,instancedArrays:!1,textureLOD:!!(this._webGLVersion>1||this._gl.getExtension("EXT_shader_texture_lod")),texelFetch:1!==this._webGLVersion,blendMinMax:!1,multiview:this._gl.getExtension("OVR_multiview2"),oculusMultiview:this._gl.getExtension("OCULUS_multiview"),depthTextureExtension:!1,canUseGLInstanceID:this._webGLVersion>1,canUseGLVertexID:this._webGLVersion>1,supportComputeShaders:!1,supportSRGBBuffers:!1,supportTransformFeedbacks:this._webGLVersion>1,textureMaxLevel:this._webGLVersion>1,texture2DArrayMaxLayerCount:this._webGLVersion>1?this._gl.getParameter(this._gl.MAX_ARRAY_TEXTURE_LAYERS):128,disableMorphTargetTexture:!1},this._caps.supportFloatTexturesResolve=this._caps.colorBufferFloat,this._caps.rg11b10ufColorRenderable=this._caps.colorBufferFloat,this._glVersion=this._gl.getParameter(this._gl.VERSION);const e=this._gl.getExtension("WEBGL_debug_renderer_info");if(null!=e&&(this._glRenderer=this._gl.getParameter(e.UNMASKED_RENDERER_WEBGL),this._glVendor=this._gl.getParameter(e.UNMASKED_VENDOR_WEBGL)),this._glVendor||(this._glVendor=this._gl.getParameter(this._gl.VENDOR)||"Unknown vendor"),this._glRenderer||(this._glRenderer=this._gl.getParameter(this._gl.RENDERER)||"Unknown renderer"),36193!==this._gl.HALF_FLOAT_OES&&(this._gl.HALF_FLOAT_OES=36193),34842!==this._gl.RGBA16F&&(this._gl.RGBA16F=34842),34836!==this._gl.RGBA32F&&(this._gl.RGBA32F=34836),35056!==this._gl.DEPTH24_STENCIL8&&(this._gl.DEPTH24_STENCIL8=35056),this._caps.timerQuery&&(1===this._webGLVersion&&(this._gl.getQuery=this._caps.timerQuery.getQueryEXT.bind(this._caps.timerQuery)),this._caps.canUseTimestampForTimerQuery=(this._gl.getQuery(this._caps.timerQuery.TIMESTAMP_EXT,this._caps.timerQuery.QUERY_COUNTER_BITS_EXT)??0)>0),this._caps.maxAnisotropy=this._caps.textureAnisotropicFilterExtension?this._gl.getParameter(this._caps.textureAnisotropicFilterExtension.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0,this._caps.textureFloatLinearFiltering=!(!this._caps.textureFloat||!this._gl.getExtension("OES_texture_float_linear")),this._caps.textureFloatRender=!(!this._caps.textureFloat||!this._canRenderToFloatFramebuffer()),this._caps.textureHalfFloatLinearFiltering=!!(this._webGLVersion>1||this._caps.textureHalfFloat&&this._gl.getExtension("OES_texture_half_float_linear")),this._caps.astc&&(this._gl.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=this._caps.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR),this._caps.bptc&&(this._gl.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=this._caps.bptc.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT),this._caps.s3tc_srgb&&(this._gl.COMPRESSED_SRGB_S3TC_DXT1_EXT=this._caps.s3tc_srgb.COMPRESSED_SRGB_S3TC_DXT1_EXT,this._gl.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=this._caps.s3tc_srgb.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,this._gl.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=this._caps.s3tc_srgb.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT),this._caps.etc2&&(this._gl.COMPRESSED_SRGB8_ETC2=this._caps.etc2.COMPRESSED_SRGB8_ETC2,this._gl.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=this._caps.etc2.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC),this._webGLVersion>1&&5131!==this._gl.HALF_FLOAT_OES&&(this._gl.HALF_FLOAT_OES=5131),this._caps.textureHalfFloatRender=this._caps.textureHalfFloat&&this._canRenderToHalfFloatFramebuffer(),this._webGLVersion>1)this._caps.drawBuffersExtension=!0,this._caps.maxMSAASamples=null!==this._maxMSAASamplesOverride?this._maxMSAASamplesOverride:this._gl.getParameter(this._gl.MAX_SAMPLES),this._caps.maxDrawBuffers=this._gl.getParameter(this._gl.MAX_DRAW_BUFFERS);else{const e=this._gl.getExtension("WEBGL_draw_buffers");if(null!==e){this._caps.drawBuffersExtension=!0,this._gl.drawBuffers=e.drawBuffersWEBGL.bind(e),this._caps.maxDrawBuffers=this._gl.getParameter(e.MAX_DRAW_BUFFERS_WEBGL),this._gl.DRAW_FRAMEBUFFER=this._gl.FRAMEBUFFER;for(let t=0;t<16;t++)this._gl["COLOR_ATTACHMENT"+t+"_WEBGL"]=e["COLOR_ATTACHMENT"+t+"_WEBGL"]}}if(this._webGLVersion>1)this._caps.depthTextureExtension=!0;else{const e=this._gl.getExtension("WEBGL_depth_texture");null!=e&&(this._caps.depthTextureExtension=!0,this._gl.UNSIGNED_INT_24_8=e.UNSIGNED_INT_24_8_WEBGL)}if(this.disableVertexArrayObjects)this._caps.vertexArrayObject=!1;else if(this._webGLVersion>1)this._caps.vertexArrayObject=!0;else{const e=this._gl.getExtension("OES_vertex_array_object");null!=e&&(this._caps.vertexArrayObject=!0,this._gl.createVertexArray=e.createVertexArrayOES.bind(e),this._gl.bindVertexArray=e.bindVertexArrayOES.bind(e),this._gl.deleteVertexArray=e.deleteVertexArrayOES.bind(e))}if(this._webGLVersion>1)this._caps.instancedArrays=!0;else{const e=this._gl.getExtension("ANGLE_instanced_arrays");null!=e?(this._caps.instancedArrays=!0,this._gl.drawArraysInstanced=e.drawArraysInstancedANGLE.bind(e),this._gl.drawElementsInstanced=e.drawElementsInstancedANGLE.bind(e),this._gl.vertexAttribDivisor=e.vertexAttribDivisorANGLE.bind(e)):this._caps.instancedArrays=!1}if(this._gl.getShaderPrecisionFormat){const e=this._gl.getShaderPrecisionFormat(this._gl.VERTEX_SHADER,this._gl.HIGH_FLOAT),t=this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER,this._gl.HIGH_FLOAT);e&&t&&(this._caps.highPrecisionShaderSupported=0!==e.precision&&0!==t.precision)}if(this._webGLVersion>1)this._caps.blendMinMax=!0;else{const e=this._gl.getExtension("EXT_blend_minmax");null!=e&&(this._caps.blendMinMax=!0,this._gl.MAX=e.MAX_EXT,this._gl.MIN=e.MIN_EXT)}if(!this._caps.supportSRGBBuffers){if(this._webGLVersion>1)this._caps.supportSRGBBuffers=!0,this._glSRGBExtensionValues={SRGB:WebGL2RenderingContext.SRGB,SRGB8:WebGL2RenderingContext.SRGB8,SRGB8_ALPHA8:WebGL2RenderingContext.SRGB8_ALPHA8};else{const e=this._gl.getExtension("EXT_sRGB");null!=e&&(this._caps.supportSRGBBuffers=!0,this._glSRGBExtensionValues={SRGB:e.SRGB_EXT,SRGB8:e.SRGB_ALPHA_EXT,SRGB8_ALPHA8:e.SRGB_ALPHA_EXT})}if(this._creationOptions){const e=this._creationOptions.forceSRGBBufferSupportState;void 0!==e&&(this._caps.supportSRGBBuffers=this._caps.supportSRGBBuffers&&e)}}this._depthCullingState.depthTest=!0,this._depthCullingState.depthFunc=this._gl.LEQUAL,this._depthCullingState.depthMask=!0,this._maxSimultaneousTextures=this._caps.maxCombinedTexturesImageUnits;for(let e=0;e=65535)return new Uint32Array(e);return new Uint16Array(e)}return new Uint16Array(e)}bindArrayBuffer(e){this._vaoRecordInProgress||this._unbindVertexArrayObject(),this._bindBuffer(e,this._gl.ARRAY_BUFFER)}bindUniformBlock(e,t,s){const i=e.program,r=this._gl.getUniformBlockIndex(i,t);this._gl.uniformBlockBinding(i,r,s)}bindIndexBuffer(e){this._vaoRecordInProgress||this._unbindVertexArrayObject(),this._bindBuffer(e,this._gl.ELEMENT_ARRAY_BUFFER)}_bindBuffer(e,t){(this._vaoRecordInProgress||this._currentBoundBuffer[t]!==e)&&(this._gl.bindBuffer(t,e?e.underlyingResource:null),this._currentBoundBuffer[t]=e)}updateArrayBuffer(e){this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,e)}_vertexAttribPointer(e,t,s,i,r,n,a){const o=this._currentBufferPointers[t];if(!o)return;let h=!1;o.active?(o.buffer!==e&&(o.buffer=e,h=!0),o.size!==s&&(o.size=s,h=!0),o.type!==i&&(o.type=i,h=!0),o.normalized!==r&&(o.normalized=r,h=!0),o.stride!==n&&(o.stride=n,h=!0),o.offset!==a&&(o.offset=a,h=!0)):(h=!0,o.active=!0,o.index=t,o.size=s,o.type=i,o.normalized=r,o.stride=n,o.offset=a,o.buffer=e),(h||this._vaoRecordInProgress)&&(this.bindArrayBuffer(e),i===this._gl.UNSIGNED_INT||i===this._gl.INT?this._gl.vertexAttribIPointer(t,s,i,n,a):this._gl.vertexAttribPointer(t,s,i,r,n,a))}_bindIndexBufferWithCache(e){null!=e&&this._cachedIndexBuffer!==e&&(this._cachedIndexBuffer=e,this.bindIndexBuffer(e),this._uintIndicesCurrentlySet=e.is32Bits)}_bindVertexBuffersAttributes(e,t,s){const i=t.getAttributesNames();this._vaoRecordInProgress||this._unbindVertexArrayObject(),this.unbindAllAttributes();for(let r=0;r=0){const t=i[r];let a=null;if(s&&(a=s[t]),a||(a=e[t]),!a)continue;this._gl.enableVertexAttribArray(n),this._vaoRecordInProgress||(this._vertexAttribArraysEnabled[n]=!0);const o=a.getBuffer();o&&(this._vertexAttribPointer(o,n,a.getSize(),a.type,a.normalized,a.byteStride,a.byteOffset),a.getIsInstanced()&&(this._gl.vertexAttribDivisor(n,a.getInstanceDivisor()),this._vaoRecordInProgress||(this._currentInstanceLocations.push(n),this._currentInstanceBuffers.push(o))))}}}recordVertexArrayObject(e,t,s,i){const r=this._gl.createVertexArray();if(!r)throw new Error("Unable to create VAO");return this._vaoRecordInProgress=!0,this._gl.bindVertexArray(r),this._mustWipeVertexAttributes=!0,this._bindVertexBuffersAttributes(e,s,i),this.bindIndexBuffer(t),this._vaoRecordInProgress=!1,this._gl.bindVertexArray(null),r}bindVertexArrayObject(e,t){this._cachedVertexArrayObject!==e&&(this._cachedVertexArrayObject=e,this._gl.bindVertexArray(e),this._cachedVertexBuffers=null,this._cachedIndexBuffer=null,this._uintIndicesCurrentlySet=null!=t&&t.is32Bits,this._mustWipeVertexAttributes=!0)}bindBuffersDirectly(e,t,s,i,r){if(this._cachedVertexBuffers!==e||this._cachedEffectForVertexBuffers!==r){this._cachedVertexBuffers=e,this._cachedEffectForVertexBuffers=r;const t=r.getAttributesCount();this._unbindVertexArrayObject(),this.unbindAllAttributes();let n=0;for(let a=0;a=0&&(this._gl.enableVertexAttribArray(t),this._vertexAttribArraysEnabled[t]=!0,this._vertexAttribPointer(e,t,s[a],this._gl.FLOAT,!1,i,n)),n+=4*s[a]}}this._bindIndexBufferWithCache(t)}_unbindVertexArrayObject(){this._cachedVertexArrayObject&&(this._cachedVertexArrayObject=null,this._gl.bindVertexArray(null))}bindBuffers(e,t,s,i){this._cachedVertexBuffers===e&&this._cachedEffectForVertexBuffers===s||(this._cachedVertexBuffers=e,this._cachedEffectForVertexBuffers=s,this._bindVertexBuffersAttributes(e,s,i)),this._bindIndexBufferWithCache(t)}unbindInstanceAttributes(){let e;for(let t=0,s=this._currentInstanceLocations.length;t1||this.isWebGPU)),(1!==o||this._caps.textureFloatLinearFiltering)&&(2!==o||this._caps.textureHalfFloatLinearFiltering)||(h=1),1!==o||this._caps.textureFloat||(o=0,r.V.Warn("Float textures are not supported. Type forced to TEXTURETYPE_UNSIGNED_BYTE"));const d=this._gl,f=new _.h(this,i),p=e.width||e,g=e.height||e,m=e.depth||0,T=e.layers||0,b=this._getSamplingParameters(h,a),E=0!==T?d.TEXTURE_2D_ARRAY:0!==m?d.TEXTURE_3D:d.TEXTURE_2D,x=this._getRGBABufferInternalSizedFormat(o,l,c),A=this._getInternalFormat(l),R=this._getWebGLTextureType(o);return this._bindTextureDirectly(E,f),0!==T?(f.is2DArray=!0,d.texImage3D(E,0,x,p,g,T,0,A,R,null)):0!==m?(f.is3D=!0,d.texImage3D(E,0,x,p,g,m,0,A,R,null)):d.texImage2D(E,0,x,p,g,0,A,R,null),d.texParameteri(E,d.TEXTURE_MAG_FILTER,b.mag),d.texParameteri(E,d.TEXTURE_MIN_FILTER,b.min),d.texParameteri(E,d.TEXTURE_WRAP_S,d.CLAMP_TO_EDGE),d.texParameteri(E,d.TEXTURE_WRAP_T,d.CLAMP_TO_EDGE),a&&this._gl.generateMipmap(E),this._bindTextureDirectly(E,null),f._useSRGBBuffer=c,f.baseWidth=p,f.baseHeight=g,f.width=p,f.height=g,f.depth=T,f.isReady=!0,f.samples=u,f.generateMipMaps=a,f.samplingMode=h,f.type=o,f.format=l,f.label=n,this._internalTexturesCache.push(f),f}_getUseSRGBBuffer(e,t){return e&&this._caps.supportSRGBBuffers&&(this.webGLVersion>1||t)}createTexture(e,t,s,i,r=3,n=null,a=null,o=null,h=null,l=null,c=null,u,d,f,p){return this._createTextureBase(e,t,s,i,r,n,a,((...e)=>this._prepareWebGLTexture(...e,l)),((e,t,s,r,n,a)=>{const o=this._gl,h=s.width===e&&s.height===t;n._creationFlags=f??0;const l=this._getTexImageParametersForCreateTexture(n.format,n._useSRGBBuffer);if(h)return o.texImage2D(o.TEXTURE_2D,0,l.internalFormat,l.format,l.type,s),!1;const c=this._caps.maxTextureSize;if(s.width>c||s.height>c||!this._supportsHardwareTextureRescaling)return this._prepareWorkingCanvas(),!(!this._workingCanvas||!this._workingContext||(this._workingCanvas.width=e,this._workingCanvas.height=t,this._workingContext.drawImage(s,0,0,s.width,s.height,0,0,e,t),o.texImage2D(o.TEXTURE_2D,0,l.internalFormat,l.format,l.type,this._workingCanvas),n.width=e,n.height=t,1));{const e=new _.h(this,2);this._bindTextureDirectly(o.TEXTURE_2D,e,!0),o.texImage2D(o.TEXTURE_2D,0,l.internalFormat,l.format,l.type,s),this._rescaleTexture(e,n,i,l.format,(()=>{this._releaseTexture(e),this._bindTextureDirectly(o.TEXTURE_2D,n,!0),a()}))}return!0}),o,h,l,c,u,d,p)}_getTexImageParametersForCreateTexture(e,t){let s,i;return 1===this.webGLVersion?(s=this._getInternalFormat(e,t),i=s):(s=this._getInternalFormat(e,!1),i=this._getRGBABufferInternalSizedFormat(0,e,t)),{internalFormat:i,format:s,type:this._gl.UNSIGNED_BYTE}}_rescaleTexture(e,t,s,i,r){}_unpackFlipY(e){this._unpackFlipYCached!==e&&(this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL,e?1:0),this.enableUnpackFlipYCached&&(this._unpackFlipYCached=e))}_getUnpackAlignement(){return this._gl.getParameter(this._gl.UNPACK_ALIGNMENT)}_getTextureTarget(e){return e.isCube?this._gl.TEXTURE_CUBE_MAP:e.is3D?this._gl.TEXTURE_3D:e.is2DArray||e.isMultiview?this._gl.TEXTURE_2D_ARRAY:this._gl.TEXTURE_2D}updateTextureSamplingMode(e,t,s=!1){const i=this._getTextureTarget(t),r=this._getSamplingParameters(e,t.useMipMaps||s);this._setTextureParameterInteger(i,this._gl.TEXTURE_MAG_FILTER,r.mag,t),this._setTextureParameterInteger(i,this._gl.TEXTURE_MIN_FILTER,r.min),s&&(t.generateMipMaps=!0,this._gl.generateMipmap(i)),this._bindTextureDirectly(i,null),t.samplingMode=e}updateTextureDimensions(e,t,s,i=1){}updateTextureWrappingMode(e,t,s=null,i=null){const r=this._getTextureTarget(e);null!==t&&(this._setTextureParameterInteger(r,this._gl.TEXTURE_WRAP_S,this._getTextureWrapMode(t),e),e._cachedWrapU=t),null!==s&&(this._setTextureParameterInteger(r,this._gl.TEXTURE_WRAP_T,this._getTextureWrapMode(s),e),e._cachedWrapV=s),(e.is2DArray||e.is3D)&&null!==i&&(this._setTextureParameterInteger(r,this._gl.TEXTURE_WRAP_R,this._getTextureWrapMode(i),e),e._cachedWrapR=i),this._bindTextureDirectly(r,null)}_uploadCompressedDataToTextureDirectly(e,t,s,i,r,n=0,a=0){const o=this._gl;let h=o.TEXTURE_2D;if(e.isCube&&(h=o.TEXTURE_CUBE_MAP_POSITIVE_X+n),e._useSRGBBuffer)switch(t){case 37492:case 36196:this._caps.etc2?t=o.COMPRESSED_SRGB8_ETC2:e._useSRGBBuffer=!1;break;case 37496:this._caps.etc2?t=o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:e._useSRGBBuffer=!1;break;case 36492:t=o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT;break;case 37808:t=o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR;break;case 33776:this._caps.s3tc_srgb?t=o.COMPRESSED_SRGB_S3TC_DXT1_EXT:e._useSRGBBuffer=!1;break;case 33777:this._caps.s3tc_srgb?t=o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:e._useSRGBBuffer=!1;break;case 33779:this._caps.s3tc_srgb?t=o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:e._useSRGBBuffer=!1;break;default:e._useSRGBBuffer=!1}this._gl.compressedTexImage2D(h,a,t,s,i,0,r)}_uploadDataToTextureDirectly(e,t,s=0,i=0,r,n=!1){const a=this._gl,o=this._getWebGLTextureType(e.type),h=this._getInternalFormat(e.format),l=void 0===r?this._getRGBABufferInternalSizedFormat(e.type,e.format,e._useSRGBBuffer):this._getInternalFormat(r,e._useSRGBBuffer);this._unpackFlipY(e.invertY);let c=a.TEXTURE_2D;e.isCube&&(c=a.TEXTURE_CUBE_MAP_POSITIVE_X+s);const u=Math.round(Math.log(e.width)*Math.LOG2E),d=Math.round(Math.log(e.height)*Math.LOG2E),_=n?e.width:Math.pow(2,Math.max(u-i,0)),f=n?e.height:Math.pow(2,Math.max(d-i,0));a.texImage2D(c,i,l,_,f,0,h,o,t)}updateTextureData(e,t,s,i,r,n,a=0,o=0,h=!1){const l=this._gl,c=this._getWebGLTextureType(e.type),u=this._getInternalFormat(e.format);this._unpackFlipY(e.invertY);let d=l.TEXTURE_2D,_=l.TEXTURE_2D;e.isCube&&(_=l.TEXTURE_CUBE_MAP_POSITIVE_X+a,d=l.TEXTURE_CUBE_MAP),this._bindTextureDirectly(d,e,!0),l.texSubImage2D(_,o,s,i,r,n,u,c,t),h&&this._gl.generateMipmap(_),this._bindTextureDirectly(d,null)}_uploadArrayBufferViewToTexture(e,t,s=0,i=0){const r=this._gl,n=e.isCube?r.TEXTURE_CUBE_MAP:r.TEXTURE_2D;this._bindTextureDirectly(n,e,!0),this._uploadDataToTextureDirectly(e,t,s,i),this._bindTextureDirectly(n,null,!0)}_prepareWebGLTextureContinuation(e,t,s,i,r){const n=this._gl;if(!n)return;const a=this._getSamplingParameters(r,!s);n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,a.mag),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,a.min),s||i||n.generateMipmap(n.TEXTURE_2D),this._bindTextureDirectly(n.TEXTURE_2D,null),t&&t.removePendingData(e),e.onLoadedObservable.notifyObservers(e),e.onLoadedObservable.clear()}_prepareWebGLTexture(e,t,s,i,r,n,a,o,h,l){const u=this.getCaps().maxTextureSize,d=Math.min(u,this.needPOTTextures?(0,c.R)(i.width,u):i.width),_=Math.min(u,this.needPOTTextures?(0,c.R)(i.height,u):i.height),f=this._gl;f&&(e._hardwareTexture?(this._bindTextureDirectly(f.TEXTURE_2D,e,!0),this._unpackFlipY(void 0===r||!!r),e.baseWidth=i.width,e.baseHeight=i.height,e.width=d,e.height=_,e.isReady=!0,e.type=-1!==e.type?e.type:0,e.format=-1!==e.format?e.format:l??(".jpg"!==t||e._useSRGBBuffer?5:4),o(d,_,i,t,e,(()=>{this._prepareWebGLTextureContinuation(e,s,n,a,h)}))||this._prepareWebGLTextureContinuation(e,s,n,a,h)):s&&s.removePendingData(e))}_getInternalFormatFromDepthTextureFormat(e,t,s){const i=this._gl;if(!t)return i.STENCIL_INDEX8;let r=s?i.DEPTH_STENCIL:i.DEPTH_COMPONENT;return this.webGLVersion>1?15===e?r=i.DEPTH_COMPONENT16:16===e?r=i.DEPTH_COMPONENT24:17===e||13===e?r=s?i.DEPTH24_STENCIL8:i.DEPTH_COMPONENT24:14===e?r=i.DEPTH_COMPONENT32F:18===e&&(r=s?i.DEPTH32F_STENCIL8:i.DEPTH_COMPONENT32F):r=i.DEPTH_COMPONENT16,r}_setupFramebufferDepthAttachments(e,t,s,i,r=1,n){const a=this._gl;n=n??(e?13:14);const o=this._getInternalFormatFromDepthTextureFormat(n,t,e);return e&&t?this._createRenderBuffer(s,i,r,a.DEPTH_STENCIL,o,a.DEPTH_STENCIL_ATTACHMENT):t?this._createRenderBuffer(s,i,r,o,o,a.DEPTH_ATTACHMENT):e?this._createRenderBuffer(s,i,r,o,o,a.STENCIL_ATTACHMENT):null}_createRenderBuffer(e,t,s,i,r,n,a=!0){const o=this._gl.createRenderbuffer();return this._updateRenderBuffer(o,e,t,s,i,r,n,a)}_updateRenderBuffer(e,t,s,i,r,n,a,o=!0){const h=this._gl;return h.bindRenderbuffer(h.RENDERBUFFER,e),i>1&&h.renderbufferStorageMultisample?h.renderbufferStorageMultisample(h.RENDERBUFFER,i,n,t,s):h.renderbufferStorage(h.RENDERBUFFER,r,t,s),h.framebufferRenderbuffer(h.FRAMEBUFFER,a,h.RENDERBUFFER,e),o&&h.bindRenderbuffer(h.RENDERBUFFER,null),e}_releaseTexture(e){this._deleteTexture(e._hardwareTexture),this.unbindAllTextures();const t=this._internalTexturesCache.indexOf(e);-1!==t&&this._internalTexturesCache.splice(t,1),e._lodTextureHigh&&e._lodTextureHigh.dispose(),e._lodTextureMid&&e._lodTextureMid.dispose(),e._lodTextureLow&&e._lodTextureLow.dispose(),e._irradianceTexture&&e._irradianceTexture.dispose()}_deleteTexture(e){e?.release()}_setProgram(e){this._currentProgram!==e&&((0,i.C5)(e,this._gl),this._currentProgram=e)}bindSamplers(e){const t=e.getPipelineContext();this._setProgram(t.program);const s=e.getSamplers();for(let t=0;t-1;if(s&&a&&(this._activeChannel=t._associatedChannel),this._boundTexturesCache[this._activeChannel]!==t||i){if(this._activateCurrentTexture(),t&&t.isMultiview)throw r.V.Error(["_bindTextureDirectly called with a multiview texture!",e,t]),"_bindTextureDirectly called with a multiview texture!";this._gl.bindTexture(e,t?._hardwareTexture?.underlyingResource??null),this._boundTexturesCache[this._activeChannel]=t,t&&(t._associatedChannel=this._activeChannel)}else s&&(n=!0,this._activateCurrentTexture());return a&&!s&&this._bindSamplerUniformToChannel(t._associatedChannel,this._activeChannel),n}_bindTexture(e,t,s){if(void 0===e)return;t&&(t._associatedChannel=e),this._activeChannel=e;const i=t?this._getTextureTarget(t):this._gl.TEXTURE_2D;this._bindTextureDirectly(i,t)}unbindAllTextures(){for(let e=0;e1&&(this._bindTextureDirectly(this._gl.TEXTURE_3D,null),this._bindTextureDirectly(this._gl.TEXTURE_2D_ARRAY,null))}setTexture(e,t,s,i){void 0!==e&&(t&&(this._boundUniforms[e]=t),this._setTexture(e,s))}_bindSamplerUniformToChannel(e,t){const s=this._boundUniforms[e];s&&s._currentState!==t&&(this._gl.uniform1i(s,t),s._currentState=t)}_getTextureWrapMode(e){switch(e){case 1:return this._gl.REPEAT;case 0:return this._gl.CLAMP_TO_EDGE;case 2:return this._gl.MIRRORED_REPEAT}return this._gl.REPEAT}_setTexture(e,t,s=!1,i=!1,r=""){if(!t)return null!=this._boundTexturesCache[e]&&(this._activeChannel=e,this._bindTextureDirectly(this._gl.TEXTURE_2D,null),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null),this.webGLVersion>1&&(this._bindTextureDirectly(this._gl.TEXTURE_3D,null),this._bindTextureDirectly(this._gl.TEXTURE_2D_ARRAY,null))),!1;if(t.video){this._activeChannel=e;const s=t.getInternalTexture();s&&(s._associatedChannel=e),t.update()}else if(4===t.delayLoadState)return t.delayLoad(),!1;let n;n=i?t.depthStencilTexture:t.isReady()?t.getInternalTexture():t.isCube?this.emptyCubeTexture:t.is3D?this.emptyTexture3D:t.is2DArray?this.emptyTexture2DArray:this.emptyTexture,!s&&n&&(n._associatedChannel=e);let a=!0;this._boundTexturesCache[e]===n&&(s||this._bindSamplerUniformToChannel(n._associatedChannel,e),a=!1),this._activeChannel=e;const o=this._getTextureTarget(n);if(a&&this._bindTextureDirectly(o,n,s),n&&!n.isMultiview){if(n.isCube&&n._cachedCoordinatesMode!==t.coordinatesMode){n._cachedCoordinatesMode=t.coordinatesMode;const e=3!==t.coordinatesMode&&5!==t.coordinatesMode?1:0;t.wrapU=e,t.wrapV=e}n._cachedWrapU!==t.wrapU&&(n._cachedWrapU=t.wrapU,this._setTextureParameterInteger(o,this._gl.TEXTURE_WRAP_S,this._getTextureWrapMode(t.wrapU),n)),n._cachedWrapV!==t.wrapV&&(n._cachedWrapV=t.wrapV,this._setTextureParameterInteger(o,this._gl.TEXTURE_WRAP_T,this._getTextureWrapMode(t.wrapV),n)),n.is3D&&n._cachedWrapR!==t.wrapR&&(n._cachedWrapR=t.wrapR,this._setTextureParameterInteger(o,this._gl.TEXTURE_WRAP_R,this._getTextureWrapMode(t.wrapR),n)),this._setAnisotropicLevel(o,n,t.anisotropicFilteringLevel)}return!0}setTextureArray(e,t,s,i){if(void 0!==e&&t){this._textureUnits&&this._textureUnits.length===s.length||(this._textureUnits=new Int32Array(s.length));for(let t=0;t=this._caps.maxVertexAttribs||!this._vertexAttribArraysEnabled[e]||this.disableAttributeByIndex(e)}releaseEffects(){const e=Object.keys(this._compiledEffects);for(const t of e)this._compiledEffects[t].dispose();this._compiledEffects={}}dispose(){(0,n.BA)()&&this._renderingCanvas&&(this._doNotHandleContextLost||(this._renderingCanvas.removeEventListener("webglcontextlost",this._onContextLost),this._renderingCanvas.removeEventListener("webglcontextrestored",this._onContextRestored))),super.dispose(),this._dummyFramebuffer&&this._gl.deleteFramebuffer(this._dummyFramebuffer),this.unbindAllAttributes(),this._boundUniforms={},this._workingCanvas=null,this._workingContext=null,this._currentBufferPointers.length=0,this._currentProgram=null,this._creationOptions.loseContextOnDispose&&this._gl.getExtension("WEBGL_lose_context")?.loseContext(),(0,i.Cm)(this._gl)}attachContextLostEvent(e){this._renderingCanvas&&this._renderingCanvas.addEventListener("webglcontextlost",e,!1)}attachContextRestoredEvent(e){this._renderingCanvas&&this._renderingCanvas.addEventListener("webglcontextrestored",e,!1)}getError(){return this._gl.getError()}_canRenderToFloatFramebuffer(){return this._webGLVersion>1?this._caps.colorBufferFloat:this._canRenderToFramebuffer(1)}_canRenderToHalfFloatFramebuffer(){return this._webGLVersion>1?this._caps.colorBufferFloat:this._canRenderToFramebuffer(2)}_canRenderToFramebuffer(e){const t=this._gl;for(;t.getError()!==t.NO_ERROR;);let s=!0;const i=t.createTexture();t.bindTexture(t.TEXTURE_2D,i),t.texImage2D(t.TEXTURE_2D,0,this._getRGBABufferInternalSizedFormat(e),1,1,0,t.RGBA,this._getWebGLTextureType(e),null),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST);const r=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,r),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,i,0);const n=t.checkFramebufferStatus(t.FRAMEBUFFER);if(s=s&&n===t.FRAMEBUFFER_COMPLETE,s=s&&t.getError()===t.NO_ERROR,s&&(t.clear(t.COLOR_BUFFER_BIT),s=s&&t.getError()===t.NO_ERROR),s){t.bindFramebuffer(t.FRAMEBUFFER,null);const e=t.RGBA,i=t.UNSIGNED_BYTE,r=new Uint8Array(4);t.readPixels(0,0,1,1,e,i,r),s=s&&t.getError()===t.NO_ERROR}for(t.deleteTexture(i),t.deleteFramebuffer(r),t.bindFramebuffer(t.FRAMEBUFFER,null);!s&&t.getError()!==t.NO_ERROR;);return s}_getWebGLTextureType(e){if(1===this._webGLVersion){switch(e){case 1:return this._gl.FLOAT;case 2:return this._gl.HALF_FLOAT_OES;case 0:return this._gl.UNSIGNED_BYTE;case 8:return this._gl.UNSIGNED_SHORT_4_4_4_4;case 9:return this._gl.UNSIGNED_SHORT_5_5_5_1;case 10:return this._gl.UNSIGNED_SHORT_5_6_5}return this._gl.UNSIGNED_BYTE}switch(e){case 3:return this._gl.BYTE;case 0:return this._gl.UNSIGNED_BYTE;case 4:return this._gl.SHORT;case 5:return this._gl.UNSIGNED_SHORT;case 6:return this._gl.INT;case 7:return this._gl.UNSIGNED_INT;case 1:return this._gl.FLOAT;case 2:return this._gl.HALF_FLOAT;case 8:return this._gl.UNSIGNED_SHORT_4_4_4_4;case 9:return this._gl.UNSIGNED_SHORT_5_5_5_1;case 10:return this._gl.UNSIGNED_SHORT_5_6_5;case 11:return this._gl.UNSIGNED_INT_2_10_10_10_REV;case 12:return this._gl.UNSIGNED_INT_24_8;case 13:return this._gl.UNSIGNED_INT_10F_11F_11F_REV;case 14:return this._gl.UNSIGNED_INT_5_9_9_9_REV;case 15:return this._gl.FLOAT_32_UNSIGNED_INT_24_8_REV}return this._gl.UNSIGNED_BYTE}_getInternalFormat(e,t=!1){let s=t?this._glSRGBExtensionValues.SRGB8_ALPHA8:this._gl.RGBA;switch(e){case 0:s=this._gl.ALPHA;break;case 1:s=this._gl.LUMINANCE;break;case 2:s=this._gl.LUMINANCE_ALPHA;break;case 6:s=this._gl.RED;break;case 7:s=this._gl.RG;break;case 4:s=t?this._glSRGBExtensionValues.SRGB:this._gl.RGB;break;case 5:s=t?this._glSRGBExtensionValues.SRGB8_ALPHA8:this._gl.RGBA}if(this._webGLVersion>1)switch(e){case 8:s=this._gl.RED_INTEGER;break;case 9:s=this._gl.RG_INTEGER;break;case 10:s=this._gl.RGB_INTEGER;break;case 11:s=this._gl.RGBA_INTEGER}return s}_getRGBABufferInternalSizedFormat(e,t,s=!1){if(1===this._webGLVersion){if(void 0!==t)switch(t){case 0:return this._gl.ALPHA;case 1:return this._gl.LUMINANCE;case 2:return this._gl.LUMINANCE_ALPHA;case 4:return s?this._glSRGBExtensionValues.SRGB:this._gl.RGB}return this._gl.RGBA}switch(e){case 3:switch(t){case 6:return this._gl.R8_SNORM;case 7:return this._gl.RG8_SNORM;case 4:return this._gl.RGB8_SNORM;case 8:return this._gl.R8I;case 9:return this._gl.RG8I;case 10:return this._gl.RGB8I;case 11:return this._gl.RGBA8I;default:return this._gl.RGBA8_SNORM}case 0:switch(t){case 6:return this._gl.R8;case 7:return this._gl.RG8;case 4:return s?this._glSRGBExtensionValues.SRGB8:this._gl.RGB8;case 5:return s?this._glSRGBExtensionValues.SRGB8_ALPHA8:this._gl.RGBA8;case 8:return this._gl.R8UI;case 9:return this._gl.RG8UI;case 10:return this._gl.RGB8UI;case 11:return this._gl.RGBA8UI;case 0:return this._gl.ALPHA;case 1:return this._gl.LUMINANCE;case 2:return this._gl.LUMINANCE_ALPHA;default:return this._gl.RGBA8}case 4:switch(t){case 8:return this._gl.R16I;case 9:return this._gl.RG16I;case 10:return this._gl.RGB16I;default:return this._gl.RGBA16I}case 5:switch(t){case 8:return this._gl.R16UI;case 9:return this._gl.RG16UI;case 10:return this._gl.RGB16UI;default:return this._gl.RGBA16UI}case 6:switch(t){case 8:return this._gl.R32I;case 9:return this._gl.RG32I;case 10:return this._gl.RGB32I;default:return this._gl.RGBA32I}case 7:switch(t){case 8:return this._gl.R32UI;case 9:return this._gl.RG32UI;case 10:return this._gl.RGB32UI;default:return this._gl.RGBA32UI}case 1:switch(t){case 6:return this._gl.R32F;case 7:return this._gl.RG32F;case 4:return this._gl.RGB32F;default:return this._gl.RGBA32F}case 2:switch(t){case 6:return this._gl.R16F;case 7:return this._gl.RG16F;case 4:return this._gl.RGB16F;default:return this._gl.RGBA16F}case 10:return this._gl.RGB565;case 13:return this._gl.R11F_G11F_B10F;case 14:return this._gl.RGB9_E5;case 8:return this._gl.RGBA4;case 9:return this._gl.RGB5_A1;case 11:switch(t){case 5:default:return this._gl.RGB10_A2;case 11:return this._gl.RGB10_A2UI}}return s?this._glSRGBExtensionValues.SRGB8_ALPHA8:this._gl.RGBA8}readPixels(e,t,s,i,r=!0,n=!0){const a=r?4:3,o=r?this._gl.RGBA:this._gl.RGB,h=new Uint8Array(i*s*a);return n&&this.flushFramebuffer(),this._gl.readPixels(e,t,s,i,o,this._gl.UNSIGNED_BYTE,h),Promise.resolve(h)}static get IsSupportedAsync(){return Promise.resolve(this.isSupported())}static get IsSupported(){return this.isSupported()}static isSupported(){if(null!==this._HasMajorPerformanceCaveat)return!this._HasMajorPerformanceCaveat;if(null===this._IsSupported)try{const e=u.$._CreateCanvas(1,1),t=e.getContext("webgl")||e.getContext("experimental-webgl");this._IsSupported=null!=t&&!!window.WebGLRenderingContext}catch(e){this._IsSupported=!1}return this._IsSupported}static get HasMajorPerformanceCaveat(){if(null===this._HasMajorPerformanceCaveat)try{const e=u.$._CreateCanvas(1,1),t=e.getContext("webgl",{failIfMajorPerformanceCaveat:!0})||e.getContext("experimental-webgl",{failIfMajorPerformanceCaveat:!0});this._HasMajorPerformanceCaveat=!t}catch(e){this._HasMajorPerformanceCaveat=!1}return this._HasMajorPerformanceCaveat}}T._TempClearColorUint32=new Uint32Array(4),T._TempClearColorInt32=new Int32Array(4),T.ExceptionList=[{key:"Chrome/63.0",capture:"63\\.0\\.3239\\.(\\d+)",captureConstraint:108,targets:["uniformBuffer"]},{key:"Firefox/58",capture:null,captureConstraint:null,targets:["uniformBuffer"]},{key:"Firefox/59",capture:null,captureConstraint:null,targets:["uniformBuffer"]},{key:"Chrome/72.+?Mobile",capture:null,captureConstraint:null,targets:["vao"]},{key:"Chrome/73.+?Mobile",capture:null,captureConstraint:null,targets:["vao"]},{key:"Chrome/74.+?Mobile",capture:null,captureConstraint:null,targets:["vao"]},{key:"Mac OS.+Chrome/71",capture:null,captureConstraint:null,targets:["vao"]},{key:"Mac OS.+Chrome/72",capture:null,captureConstraint:null,targets:["vao"]},{key:"Mac OS.+Chrome",capture:null,captureConstraint:null,targets:["uniformBuffer"]},{key:"Chrome/12\\d\\..+?Mobile",capture:null,captureConstraint:null,targets:["uniformBuffer"]},{key:".*AppleWebKit.*(15.4).*Safari",capture:null,captureConstraint:null,targets:["antialias","maxMSAASamples"]},{key:".*(15.4).*AppleWebKit.*Safari",capture:null,captureConstraint:null,targets:["antialias","maxMSAASamples"]}],T._ConcatenateShader=p.iL,T._IsSupported=null,T._HasMajorPerformanceCaveat=null},8123:(e,t,s)=>{var i;s.d(t,{s:()=>r}),function(e){e[e.PointerMove=0]="PointerMove",e[e.PointerDown=1]="PointerDown",e[e.PointerUp=2]="PointerUp"}(i||(i={}));class r{}r.DOM_DELTA_PIXEL=0,r.DOM_DELTA_LINE=1,r.DOM_DELTA_PAGE=2},4146:(e,t,s)=>{s.d(t,{Bu:()=>n,TB:()=>i,W0:()=>r});class i{}i.KEYDOWN=1,i.KEYUP=2;class r{constructor(e,t){this.type=e,this.event=t}}class n extends r{get skipOnPointerObservable(){return this.skipOnKeyboardObservable}set skipOnPointerObservable(e){this.skipOnKeyboardObservable=e}constructor(e,t){super(e,t),this.type=e,this.event=t,this.skipOnKeyboardObservable=!1}}},6240:(e,t,s)=>{s.d(t,{Zp:()=>r,mx:()=>o,tT:()=>a});var i=s(9923);class r{}r.POINTERDOWN=1,r.POINTERUP=2,r.POINTERMOVE=4,r.POINTERWHEEL=8,r.POINTERPICK=16,r.POINTERTAP=32,r.POINTERDOUBLETAP=64;class n{constructor(e,t){this.type=e,this.event=t}}class a extends n{constructor(e,t,s,r){super(e,t),this.ray=null,this.originalPickingInfo=null,this.skipOnPointerObservable=!1,this.localPosition=new i.I9(s,r)}}class o extends n{get pickInfo(){return this._pickInfo||this._generatePickInfo(),this._pickInfo}constructor(e,t,s,i=null){super(e,t),this._pickInfo=s,this._inputManager=i}_generatePickInfo(){this._inputManager&&(this._pickInfo=this._inputManager._pickMove(this.event),this._inputManager._setRayOnPointerInfo(this._pickInfo,this.event),this._inputManager=null)}}},8595:(e,t,s)=>{s.d(t,{o:()=>T});var i=s(9923),r=s(6041),n=s(5616),a=s(4704),o=s(2781),h=s(6882),l=s(7891),c=s(6532),u=s(9848),d=s(5503),_=s(2565),f=s(3099),p=s(5476),g=s(492),m=s(467);class T{get bias(){return this._bias}set bias(e){this._bias=e}get normalBias(){return this._normalBias}set normalBias(e){this._normalBias=e}get blurBoxOffset(){return this._blurBoxOffset}set blurBoxOffset(e){this._blurBoxOffset!==e&&(this._blurBoxOffset=e,this._disposeBlurPostProcesses())}get blurScale(){return this._blurScale}set blurScale(e){this._blurScale!==e&&(this._blurScale=e,this._disposeBlurPostProcesses())}get blurKernel(){return this._blurKernel}set blurKernel(e){this._blurKernel!==e&&(this._blurKernel=e,this._disposeBlurPostProcesses())}get useKernelBlur(){return this._useKernelBlur}set useKernelBlur(e){this._useKernelBlur!==e&&(this._useKernelBlur=e,this._disposeBlurPostProcesses())}get depthScale(){return void 0!==this._depthScale?this._depthScale:this._light.getDepthScale()}set depthScale(e){this._depthScale=e}_validateFilter(e){return e}get filter(){return this._filter}set filter(e){if(e=this._validateFilter(e),this._light.needCube()){if(e===T.FILTER_BLUREXPONENTIALSHADOWMAP)return void(this.useExponentialShadowMap=!0);if(e===T.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP)return void(this.useCloseExponentialShadowMap=!0);if(e===T.FILTER_PCF||e===T.FILTER_PCSS)return void(this.usePoissonSampling=!0)}e!==T.FILTER_PCF&&e!==T.FILTER_PCSS||this._scene.getEngine()._features.supportShadowSamplers?this._filter!==e&&(this._filter=e,this._disposeBlurPostProcesses(),this._applyFilterValues(),this._light._markMeshesAsLightDirty()):this.usePoissonSampling=!0}get usePoissonSampling(){return this.filter===T.FILTER_POISSONSAMPLING}set usePoissonSampling(e){const t=this._validateFilter(T.FILTER_POISSONSAMPLING);(e||this.filter===T.FILTER_POISSONSAMPLING)&&(this.filter=e?t:T.FILTER_NONE)}get useExponentialShadowMap(){return this.filter===T.FILTER_EXPONENTIALSHADOWMAP}set useExponentialShadowMap(e){const t=this._validateFilter(T.FILTER_EXPONENTIALSHADOWMAP);(e||this.filter===T.FILTER_EXPONENTIALSHADOWMAP)&&(this.filter=e?t:T.FILTER_NONE)}get useBlurExponentialShadowMap(){return this.filter===T.FILTER_BLUREXPONENTIALSHADOWMAP}set useBlurExponentialShadowMap(e){const t=this._validateFilter(T.FILTER_BLUREXPONENTIALSHADOWMAP);(e||this.filter===T.FILTER_BLUREXPONENTIALSHADOWMAP)&&(this.filter=e?t:T.FILTER_NONE)}get useCloseExponentialShadowMap(){return this.filter===T.FILTER_CLOSEEXPONENTIALSHADOWMAP}set useCloseExponentialShadowMap(e){const t=this._validateFilter(T.FILTER_CLOSEEXPONENTIALSHADOWMAP);(e||this.filter===T.FILTER_CLOSEEXPONENTIALSHADOWMAP)&&(this.filter=e?t:T.FILTER_NONE)}get useBlurCloseExponentialShadowMap(){return this.filter===T.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP}set useBlurCloseExponentialShadowMap(e){const t=this._validateFilter(T.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP);(e||this.filter===T.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP)&&(this.filter=e?t:T.FILTER_NONE)}get usePercentageCloserFiltering(){return this.filter===T.FILTER_PCF}set usePercentageCloserFiltering(e){const t=this._validateFilter(T.FILTER_PCF);(e||this.filter===T.FILTER_PCF)&&(this.filter=e?t:T.FILTER_NONE)}get filteringQuality(){return this._filteringQuality}set filteringQuality(e){this._filteringQuality!==e&&(this._filteringQuality=e,this._disposeBlurPostProcesses(),this._applyFilterValues(),this._light._markMeshesAsLightDirty())}get useContactHardeningShadow(){return this.filter===T.FILTER_PCSS}set useContactHardeningShadow(e){const t=this._validateFilter(T.FILTER_PCSS);(e||this.filter===T.FILTER_PCSS)&&(this.filter=e?t:T.FILTER_NONE)}get contactHardeningLightSizeUVRatio(){return this._contactHardeningLightSizeUVRatio}set contactHardeningLightSizeUVRatio(e){this._contactHardeningLightSizeUVRatio=e}get darkness(){return this._darkness}set darkness(e){this.setDarkness(e)}getDarkness(){return this._darkness}setDarkness(e){return this._darkness=e>=1?1:e<=0?0:e,this}get transparencyShadow(){return this._transparencyShadow}set transparencyShadow(e){this.setTransparencyShadow(e)}setTransparencyShadow(e){return this._transparencyShadow=e,this}getShadowMap(){return this._shadowMap}getShadowMapForRendering(){return this._shadowMap2?this._shadowMap2:this._shadowMap}getClassName(){return T.CLASSNAME}addShadowCaster(e,t=!0){if(!this._shadowMap)return this;if(this._shadowMap.renderList||(this._shadowMap.renderList=[]),-1===this._shadowMap.renderList.indexOf(e)&&this._shadowMap.renderList.push(e),t)for(const t of e.getChildMeshes())-1===this._shadowMap.renderList.indexOf(t)&&this._shadowMap.renderList.push(t);return this}removeShadowCaster(e,t=!0){if(!this._shadowMap||!this._shadowMap.renderList)return this;const s=this._shadowMap.renderList.indexOf(e);if(-1!==s&&this._shadowMap.renderList.splice(s,1),t)for(const t of e.getChildren())this.removeShadowCaster(t);return this}getLight(){return this._light}get shaderLanguage(){return this._shaderLanguage}_getCamera(){return this._camera??this._scene.activeCamera}get mapSize(){return this._mapSize}set mapSize(e){this._mapSize=e,this._light._markMeshesAsLightDirty(),this.recreateShadowMap()}constructor(e,t,s,r,n,a=!1){this.onBeforeShadowMapRenderObservable=new u.cP,this.onAfterShadowMapRenderObservable=new u.cP,this.onBeforeShadowMapRenderMeshObservable=new u.cP,this.onAfterShadowMapRenderMeshObservable=new u.cP,this._bias=5e-5,this._normalBias=0,this._blurBoxOffset=1,this._blurScale=2,this._blurKernel=1,this._useKernelBlur=!1,this._filter=T.FILTER_NONE,this._filteringQuality=T.QUALITY_HIGH,this._contactHardeningLightSizeUVRatio=.1,this._darkness=0,this._transparencyShadow=!1,this.enableSoftTransparentShadow=!1,this.useOpacityTextureForTransparentShadow=!1,this.frustumEdgeFalloff=0,this._shaderLanguage=0,this.forceBackFacesOnly=!1,this._lightDirection=i.Pq.Zero(),this._viewMatrix=i.uq.Zero(),this._projectionMatrix=i.uq.Zero(),this._transformMatrix=i.uq.Zero(),this._cachedPosition=new i.Pq(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cachedDirection=new i.Pq(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._currentFaceIndex=0,this._currentFaceIndexCache=0,this._defaultTextureMatrix=i.uq.Identity(),this._shadersLoaded=!1,this._mapSize=e,this._light=t,this._scene=t.getScene(),this._camera=r??null,this._useRedTextureType=!!n,this._initShaderSourceAsync(a);let o=t._shadowGenerators;o||(o=t._shadowGenerators=new Map),o.set(this._camera,this),this.id=t.id,this._useUBO=this._scene.getEngine().supportsUniformBuffers,this._useUBO&&(this._sceneUBOs=[],this._sceneUBOs.push(this._scene.createSceneUniformBuffer(`Scene for Shadow Generator (light "${this._light.name}")`))),T._SceneComponentInitialization(this._scene);const h=this._scene.getEngine().getCaps();s?h.textureFloatRender&&h.textureFloatLinearFiltering?this._textureType=1:h.textureHalfFloatRender&&h.textureHalfFloatLinearFiltering?this._textureType=2:this._textureType=0:h.textureHalfFloatRender&&h.textureHalfFloatLinearFiltering?this._textureType=2:h.textureFloatRender&&h.textureFloatLinearFiltering?this._textureType=1:this._textureType=0,this._initializeGenerator(),this._applyFilterValues()}_initializeGenerator(){this._light._markMeshesAsLightDirty(),this._initializeShadowMap()}_createTargetRenderTexture(){const e=this._scene.getEngine();e._features.supportDepthStencilTexture?(this._shadowMap=new h.$(this._light.name+"_shadowMap",this._mapSize,this._scene,!1,!0,this._textureType,this._light.needCube(),void 0,!1,!1,void 0,this._useRedTextureType?6:5),this._shadowMap.createDepthStencilTexture(e.useReverseDepthBuffer?516:513,!0,void 0,void 0,void 0,`DepthStencilForShadowGenerator-${this._light.name}`)):this._shadowMap=new h.$(this._light.name+"_shadowMap",this._mapSize,this._scene,!1,!0,this._textureType,this._light.needCube()),this._shadowMap.noPrePassRenderer=!0}_initializeShadowMap(){if(this._createTargetRenderTexture(),null===this._shadowMap)return;this._shadowMap.wrapU=o.g.CLAMP_ADDRESSMODE,this._shadowMap.wrapV=o.g.CLAMP_ADDRESSMODE,this._shadowMap.anisotropicFilteringLevel=1,this._shadowMap.updateSamplingMode(o.g.BILINEAR_SAMPLINGMODE),this._shadowMap.renderParticles=!1,this._shadowMap.ignoreCameraViewport=!0,this._storedUniqueId&&(this._shadowMap.uniqueId=this._storedUniqueId),this._shadowMap.customRenderFunction=(e,t,s,i)=>this._renderForShadowMap(e,t,s,i),this._shadowMap.customIsReadyFunction=()=>!0;const e=this._scene.getEngine();this._shadowMap.onBeforeBindObservable.add((()=>{this._currentSceneUBO=this._scene.getSceneUniformBuffer(),e._debugPushGroup?.(`shadow map generation for pass id ${e.currentRenderPassId}`,1)})),this._shadowMap.onBeforeRenderObservable.add((t=>{this._sceneUBOs&&this._scene.setSceneUniformBuffer(this._sceneUBOs[0]),this._currentFaceIndex=t,this._filter===T.FILTER_PCF&&e.setColorWrite(!1),this.getTransformMatrix(),this._scene.setTransformMatrix(this._viewMatrix,this._projectionMatrix),this._useUBO&&(this._scene.getSceneUniformBuffer().unbindEffect(),this._scene.finalizeSceneUbo())})),this._shadowMap.onAfterUnbindObservable.add((()=>{if(this._sceneUBOs&&this._scene.setSceneUniformBuffer(this._currentSceneUBO),this._scene.updateTransformMatrix(),this._filter===T.FILTER_PCF&&e.setColorWrite(!0),!this.useBlurExponentialShadowMap&&!this.useBlurCloseExponentialShadowMap)return void e._debugPopGroup?.(1);const t=this.getShadowMapForRendering();t&&(this._scene.postProcessManager.directRender(this._blurPostProcesses,t.renderTarget,!0),e.unBindFramebuffer(t.renderTarget,!0)),e._debugPopGroup?.(1)}));const t=new r.ov(0,0,0,0),s=new r.ov(1,1,1,1);this._shadowMap.onClearObservable.add((e=>{this._filter===T.FILTER_PCF?e.clear(s,!1,!0,!1):this.useExponentialShadowMap||this.useBlurExponentialShadowMap?e.clear(t,!0,!0,!1):e.clear(s,!0,!0,!1)})),this._shadowMap.onResizeObservable.add((e=>{this._storedUniqueId=this._shadowMap.uniqueId,this._mapSize=e.getRenderSize(),this._light._markMeshesAsLightDirty(),this.recreateShadowMap()}));for(let e=f.m.MIN_RENDERINGGROUPS;e{e.setTexture("textureSampler",this._shadowMap)})),this._kernelBlurYPostprocess=new c.j(this._light.name+"KernelBlurY",new i.I9(0,1),this.blurKernel,1,null,o.g.BILINEAR_SAMPLINGMODE,e,!1,this._textureType),this._kernelBlurXPostprocess.autoClear=!1,this._kernelBlurYPostprocess.autoClear=!1,0===this._textureType&&(this._kernelBlurXPostprocess.packedFloat=!0,this._kernelBlurYPostprocess.packedFloat=!0),this._blurPostProcesses=[this._kernelBlurXPostprocess,this._kernelBlurYPostprocess]):(this._boxBlurPostprocess=new l.w(this._light.name+"DepthBoxBlur","depthBoxBlur",["screenSize","boxOffset"],[],1,null,o.g.BILINEAR_SAMPLINGMODE,e,!1,"#define OFFSET "+this._blurBoxOffset,this._textureType,void 0,void 0,void 0,void 0,this._shaderLanguage),this._boxBlurPostprocess.externalTextureSamplerBinding=!0,this._boxBlurPostprocess.onApplyObservable.add((e=>{e.setFloat2("screenSize",t,t),e.setTexture("textureSampler",this._shadowMap)})),this._boxBlurPostprocess.autoClear=!1,this._blurPostProcesses=[this._boxBlurPostprocess])}_renderForShadowMap(e,t,s,i){let r;if(i.length)for(r=0;r{i===s||e?(i.getMeshUniformBuffer().bindToEffect(c,"Mesh"),i.transferToEffect(e?t:f)):(s.getMeshUniformBuffer().bindToEffect(c,"Mesh"),s.transferToEffect(t))})),this.forceBackFacesOnly&&n.setState(!0,0,!1,!1,o.cullBackFaces),this.onAfterShadowMapRenderObservable.notifyObservers(c),this.onAfterShadowMapRenderMeshObservable.notifyObservers(s)}else this._shadowMap&&this._shadowMap.resetRefreshCounter()}_applyFilterValues(){this._shadowMap&&(this.filter===T.FILTER_NONE||this.filter===T.FILTER_PCSS?this._shadowMap.updateSamplingMode(o.g.NEAREST_SAMPLINGMODE):this._shadowMap.updateSamplingMode(o.g.BILINEAR_SAMPLINGMODE))}forceCompilation(e,t){const s={useInstances:!1,...t},i=this.getShadowMap();if(!i)return void(e&&e(this));const r=i.renderList;if(!r)return void(e&&e(this));const n=[];for(const e of r)n.push(...e.subMeshes);if(0===n.length)return void(e&&e(this));let a=0;const o=()=>{if(this._scene&&this._scene.getEngine()){for(;this.isReady(n[a],s.useInstances,n[a].getMaterial()?.needAlphaBlendingForMesh(n[a].getMesh())??!1);)if(a++,a>=n.length)return void(e&&e(this));setTimeout(o,16)}};o()}forceCompilationAsync(e){return new Promise((t=>{this.forceCompilation((()=>{t()}),e)}))}_isReadyCustomDefines(e,t,s){}_prepareShadowDefines(e,t,s,i){s.push("#define SM_LIGHTTYPE_"+this._light.getClassName().toUpperCase()),s.push("#define SM_FLOAT "+(0!==this._textureType?"1":"0")),s.push("#define SM_ESM "+(this.useExponentialShadowMap||this.useBlurExponentialShadowMap?"1":"0")),s.push("#define SM_DEPTHTEXTURE "+(this.usePercentageCloserFiltering||this.useContactHardeningShadow?"1":"0"));const r=e.getMesh();return s.push("#define SM_NORMALBIAS "+(this.normalBias&&r.isVerticesDataPresent(n.R.NormalKind)?"1":"0")),s.push("#define SM_DIRECTIONINLIGHTDATA "+(this.getLight().getTypeID()===a.v.LIGHTTYPEID_DIRECTIONALLIGHT?"1":"0")),s.push("#define SM_USEDISTANCE "+(this._light.needCube()?"1":"0")),s.push("#define SM_SOFTTRANSPARENTSHADOW "+(this.enableSoftTransparentShadow&&i?"1":"0")),this._isReadyCustomDefines(s,e,t),s}isReady(e,t,s){if(!this._shadersLoaded)return!1;const i=e.getMaterial(),r=i?.shadowDepthWrapper;if(this._opacityTexture=null,!i)return!1;const a=[];if(this._prepareShadowDefines(e,t,a,s),r){if(!r.isReadyForSubMesh(e,a,this,t,this._scene.getEngine().currentRenderPassId))return!1}else{const s=e._getDrawWrapper(void 0,!0);let r=s.effect,o=s.defines;const h=[n.R.PositionKind],l=e.getMesh();this.normalBias&&l.isVerticesDataPresent(n.R.NormalKind)&&(h.push(n.R.NormalKind),a.push("#define NORMAL"),l.nonUniformScaling&&a.push("#define NONUNIFORMSCALING"));const c=i.needAlphaTesting();if((c||i.needAlphaBlending())&&(this.useOpacityTextureForTransparentShadow?this._opacityTexture=i.opacityTexture:this._opacityTexture=i.getAlphaTestTexture(),this._opacityTexture)){if(!this._opacityTexture.isReady())return!1;const e=i.alphaCutOff??T.DEFAULT_ALPHA_CUTOFF;a.push("#define ALPHATEXTURE"),c&&a.push(`#define ALPHATESTVALUE ${e}${e%1==0?".":""}`),l.isVerticesDataPresent(n.R.UVKind)&&(h.push(n.R.UVKind),a.push("#define UV1")),l.isVerticesDataPresent(n.R.UV2Kind)&&1===this._opacityTexture.coordinatesIndex&&(h.push(n.R.UV2Kind),a.push("#define UV2"))}const u=new _.J;if(l.useBones&&l.computeBonesUsingShaders&&l.skeleton){h.push(n.R.MatricesIndicesKind),h.push(n.R.MatricesWeightsKind),l.numBoneInfluencers>4&&(h.push(n.R.MatricesIndicesExtraKind),h.push(n.R.MatricesWeightsExtraKind));const e=l.skeleton;a.push("#define NUM_BONE_INFLUENCERS "+l.numBoneInfluencers),l.numBoneInfluencers>0&&u.addCPUSkinningFallback(0,l),e.isUsingTextureForMatrices?a.push("#define BONETEXTURE"):a.push("#define BonesPerMesh "+(e.bones.length+1))}else a.push("#define NUM_BONE_INFLUENCERS 0");const d=l.morphTargetManager;let f=0;if(d&&(f=d.numMaxInfluencers||d.numInfluencers,f>0&&(a.push("#define MORPHTARGETS"),a.push("#define NUM_MORPH_INFLUENCERS "+f),d.isUsingTextureForTargets&&a.push("#define MORPHTARGETS_TEXTURE"),(0,m.MF)(h,l,f))),(0,g.tv)(i,this._scene,a),t&&(a.push("#define INSTANCES"),(0,m.te)(h),e.getRenderingMesh().hasThinInstances&&a.push("#define THIN_INSTANCES")),this.customShaderOptions&&this.customShaderOptions.defines)for(const e of this.customShaderOptions.defines)-1===a.indexOf(e)&&a.push(e);const p=l.bakedVertexAnimationManager;p&&p.isEnabled&&(a.push("#define BAKED_VERTEX_ANIMATION_TEXTURE"),t&&h.push("bakedVertexAnimationSettingsInstanced"));const b=a.join("\n");if(o!==b){o=b;let e="shadowMap";const t=["world","mBones","viewProjection","diffuseMatrix","lightDataSM","depthValuesSM","biasAndScaleSM","morphTargetInfluences","morphTargetCount","boneTextureWidth","softTransparentShadowSM","morphTargetTextureInfo","morphTargetTextureIndices","bakedVertexAnimationSettings","bakedVertexAnimationTextureSizeInverted","bakedVertexAnimationTime","bakedVertexAnimationTexture"],i=["diffuseSampler","boneSampler","morphTargets","bakedVertexAnimationTexture"],n=["Scene","Mesh"];if((0,g.TV)(t),this.customShaderOptions){if(e=this.customShaderOptions.shaderName,this.customShaderOptions.attributes)for(const e of this.customShaderOptions.attributes)-1===h.indexOf(e)&&h.push(e);if(this.customShaderOptions.uniforms)for(const e of this.customShaderOptions.uniforms)-1===t.indexOf(e)&&t.push(e);if(this.customShaderOptions.samplers)for(const e of this.customShaderOptions.samplers)-1===i.indexOf(e)&&i.push(e)}const a=this._scene.getEngine();r=a.createEffect(e,{attributes:h,uniformsNames:t,uniformBuffersNames:n,samplers:i,defines:b,fallbacks:u,onCompiled:null,onError:null,indexParameters:{maxSimultaneousMorphTargets:f},shaderLanguage:this._shaderLanguage},a),s.setEffect(r,o)}if(!r.isReady())return!1}return(this.useBlurExponentialShadowMap||this.useBlurCloseExponentialShadowMap)&&(this._blurPostProcesses&&this._blurPostProcesses.length||this._initializeBlurRTTAndPostProcesses()),!(this._kernelBlurXPostprocess&&!this._kernelBlurXPostprocess.isReady()||this._kernelBlurYPostprocess&&!this._kernelBlurYPostprocess.isReady()||this._boxBlurPostprocess&&!this._boxBlurPostprocess.isReady())}prepareDefines(e,t){const s=this._scene,i=this._light;s.shadowsEnabled&&i.shadowEnabled&&(e["SHADOW"+t]=!0,this.useContactHardeningShadow?(e["SHADOWPCSS"+t]=!0,this._filteringQuality===T.QUALITY_LOW?e["SHADOWLOWQUALITY"+t]=!0:this._filteringQuality===T.QUALITY_MEDIUM&&(e["SHADOWMEDIUMQUALITY"+t]=!0)):this.usePercentageCloserFiltering?(e["SHADOWPCF"+t]=!0,this._filteringQuality===T.QUALITY_LOW?e["SHADOWLOWQUALITY"+t]=!0:this._filteringQuality===T.QUALITY_MEDIUM&&(e["SHADOWMEDIUMQUALITY"+t]=!0)):this.usePoissonSampling?e["SHADOWPOISSON"+t]=!0:this.useExponentialShadowMap||this.useBlurExponentialShadowMap?e["SHADOWESM"+t]=!0:(this.useCloseExponentialShadowMap||this.useBlurCloseExponentialShadowMap)&&(e["SHADOWCLOSEESM"+t]=!0),i.needCube()&&(e["SHADOWCUBE"+t]=!0))}bindShadowLight(e,t){const s=this._light;if(!this._scene.shadowsEnabled||!s.shadowEnabled)return;const i=this._getCamera();if(!i)return;const r=this.getShadowMap();if(!r)return;s.needCube()||t.setMatrix("lightMatrix"+e,this.getTransformMatrix());const n=this.getShadowMapForRendering();this._filter===T.FILTER_PCF?(t.setDepthStencilTexture("shadowTexture"+e,n),s._uniformBuffer.updateFloat4("shadowsInfo",this.getDarkness(),r.getSize().width,1/r.getSize().width,this.frustumEdgeFalloff,e)):this._filter===T.FILTER_PCSS?(t.setDepthStencilTexture("shadowTexture"+e,n),t.setTexture("depthTexture"+e,n),s._uniformBuffer.updateFloat4("shadowsInfo",this.getDarkness(),1/r.getSize().width,this._contactHardeningLightSizeUVRatio*r.getSize().width,this.frustumEdgeFalloff,e)):(t.setTexture("shadowTexture"+e,n),s._uniformBuffer.updateFloat4("shadowsInfo",this.getDarkness(),this.blurScale/r.getSize().width,this.depthScale,this.frustumEdgeFalloff,e)),s._uniformBuffer.updateFloat2("depthValues",this.getLight().getDepthMinZ(i),this.getLight().getDepthMinZ(i)+this.getLight().getDepthMaxZ(i),e)}get viewMatrix(){return this._viewMatrix}get projectionMatrix(){return this._projectionMatrix}getTransformMatrix(){const e=this._scene;if(this._currentRenderId===e.getRenderId()&&this._currentFaceIndexCache===this._currentFaceIndex)return this._transformMatrix;this._currentRenderId=e.getRenderId(),this._currentFaceIndexCache=this._currentFaceIndex;let t=this._light.position;if(this._light.computeTransformedInformation()&&(t=this._light.transformedPosition),i.Pq.NormalizeToRef(this._light.getShadowDirection(this._currentFaceIndex),this._lightDirection),1===Math.abs(i.Pq.Dot(this._lightDirection,i.Pq.Up()))&&(this._lightDirection.z=1e-13),this._light.needProjectionMatrixCompute()||!this._cachedPosition||!this._cachedDirection||!t.equals(this._cachedPosition)||!this._lightDirection.equals(this._cachedDirection)){this._cachedPosition.copyFrom(t),this._cachedDirection.copyFrom(this._lightDirection),i.uq.LookAtLHToRef(t,t.add(this._lightDirection),i.Pq.Up(),this._viewMatrix);const e=this.getShadowMap();if(e){const t=e.renderList;t&&this._light.setShadowProjectionMatrix(this._projectionMatrix,this._viewMatrix,t)}this._viewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix)}return this._transformMatrix}recreateShadowMap(){const e=this._shadowMap;if(!e)return;const t=e.renderList;if(this._disposeRTTandPostProcesses(),this._initializeGenerator(),this.filter=this._filter,this._applyFilterValues(),t){this._shadowMap.renderList||(this._shadowMap.renderList=[]);for(const e of t)this._shadowMap.renderList.push(e)}else this._shadowMap.renderList=null}_disposeBlurPostProcesses(){this._shadowMap2&&(this._shadowMap2.dispose(),this._shadowMap2=null),this._boxBlurPostprocess&&(this._boxBlurPostprocess.dispose(),this._boxBlurPostprocess=null),this._kernelBlurXPostprocess&&(this._kernelBlurXPostprocess.dispose(),this._kernelBlurXPostprocess=null),this._kernelBlurYPostprocess&&(this._kernelBlurYPostprocess.dispose(),this._kernelBlurYPostprocess=null),this._blurPostProcesses=[]}_disposeRTTandPostProcesses(){this._shadowMap&&(this._shadowMap.dispose(),this._shadowMap=null),this._disposeBlurPostProcesses()}_disposeSceneUBOs(){if(this._sceneUBOs){for(const e of this._sceneUBOs)e.dispose();this._sceneUBOs=[]}}dispose(){if(this._disposeRTTandPostProcesses(),this._disposeSceneUBOs(),this._light){if(this._light._shadowGenerators){const e=this._light._shadowGenerators.entries();for(let t=e.next();!0!==t.done;t=e.next()){const[e,s]=t.value;s===this&&this._light._shadowGenerators.delete(e)}0===this._light._shadowGenerators.size&&(this._light._shadowGenerators=null)}this._light._markMeshesAsLightDirty()}this.onBeforeShadowMapRenderMeshObservable.clear(),this.onBeforeShadowMapRenderObservable.clear(),this.onAfterShadowMapRenderMeshObservable.clear(),this.onAfterShadowMapRenderObservable.clear()}serialize(){const e={},t=this.getShadowMap();if(!t)return e;if(e.className=this.getClassName(),e.lightId=this._light.id,e.cameraId=this._camera?.id,e.id=this.id,e.mapSize=t.getRenderSize(),e.forceBackFacesOnly=this.forceBackFacesOnly,e.darkness=this.getDarkness(),e.transparencyShadow=this._transparencyShadow,e.frustumEdgeFalloff=this.frustumEdgeFalloff,e.bias=this.bias,e.normalBias=this.normalBias,e.usePercentageCloserFiltering=this.usePercentageCloserFiltering,e.useContactHardeningShadow=this.useContactHardeningShadow,e.contactHardeningLightSizeUVRatio=this.contactHardeningLightSizeUVRatio,e.filteringQuality=this.filteringQuality,e.useExponentialShadowMap=this.useExponentialShadowMap,e.useBlurExponentialShadowMap=this.useBlurExponentialShadowMap,e.useCloseExponentialShadowMap=this.useBlurExponentialShadowMap,e.useBlurCloseExponentialShadowMap=this.useBlurExponentialShadowMap,e.usePoissonSampling=this.usePoissonSampling,e.depthScale=this.depthScale,e.blurBoxOffset=this.blurBoxOffset,e.blurKernel=this.blurKernel,e.blurScale=this.blurScale,e.useKernelBlur=this.useKernelBlur,e.renderList=[],t.renderList)for(let s=0;s{throw(0,d.n)("ShadowGeneratorSceneComponent")}},9400:(e,t,s)=>{var i=s(8595),r=s(9923),n=s(6882),a=s(5503),o=s(2564),h=s(6041),l=s(5616),c=s(2781),u=s(388),d=(s(8852),s(9977),s(492)),_=s(467),f=s(2565);class p{get shaderLanguage(){return this._shaderLanguage}setMaterialForRendering(e,t){this._depthMap.setMaterialForRendering(e,t)}constructor(e,t=1,s=null,i=!1,r=c.g.TRILINEAR_SAMPLINGMODE,a=!1,o){this._shaderLanguage=0,this.enabled=!0,this.forceDepthWriteTransparentMeshes=!1,this.useOnlyInActiveCamera=!1,this.reverseCulling=!1,this._shadersLoaded=!1,this._scene=e,this._storeNonLinearDepth=i,this._storeCameraSpaceZ=a,this.isPacked=0===t,this.isPacked?this.clearColor=new h.ov(1,1,1,1):this.clearColor=new h.ov(a?1e8:1,0,0,1),this._initShaderSourceAsync(),p._SceneComponentInitialization(this._scene);const l=e.getEngine();this._camera=s,r!==c.g.NEAREST_SAMPLINGMODE&&(1!==t||l._caps.textureFloatLinearFiltering||(r=c.g.NEAREST_SAMPLINGMODE),2!==t||l._caps.textureHalfFloatLinearFiltering||(r=c.g.NEAREST_SAMPLINGMODE));const f=this.isPacked||!l._features.supportExtendedTextureFormats?5:6;this._depthMap=new n.$(o??"DepthRenderer",{width:l.getRenderWidth(),height:l.getRenderHeight()},this._scene,!1,!0,t,!1,r,void 0,void 0,void 0,f),this._depthMap.wrapU=c.g.CLAMP_ADDRESSMODE,this._depthMap.wrapV=c.g.CLAMP_ADDRESSMODE,this._depthMap.refreshRate=1,this._depthMap.renderParticles=!1,this._depthMap.renderList=null,this._depthMap.noPrePassRenderer=!0,this._depthMap.activeCamera=this._camera,this._depthMap.ignoreCameraViewport=!0,this._depthMap.useCameraPostProcesses=!1,this._depthMap.onClearObservable.add((e=>{e.clear(this.clearColor,!0,!0,!0)})),this._depthMap.onBeforeBindObservable.add((()=>{l._debugPushGroup?.("depth renderer",1)})),this._depthMap.onAfterUnbindObservable.add((()=>{l._debugPopGroup?.(1)})),this._depthMap.customIsReadyFunction=(e,t,s)=>{if((s||0===t)&&e.subMeshes)for(let t=0;t{const t=e.getRenderingMesh(),s=e.getEffectiveMesh(),i=this._scene,r=i.getEngine(),n=e.getMaterial();if(s._internalAbstractMeshDataInfo._isActiveIntermediate=!1,!n||s.infiniteDistance||n.disableDepthWrite||0===e.verticesCount||e._renderId===i.getRenderId())return;const a=s._getWorldMatrixDeterminant()<0;let o=n._getEffectiveOrientation(t);a&&(o=0===o?1:0);const h=0===o;r.setState(n.backFaceCulling,0,!1,h,this.reverseCulling?!n.cullBackFaces:n.cullBackFaces);const l=t._getInstancesRenderList(e._id,!!e.getReplacementMesh());if(l.mustReturn)return;const c=r.getCaps().instancedArrays&&(null!==l.visibleInstances[e._id]&&void 0!==l.visibleInstances[e._id]||t.hasThinInstances),f=this._camera||i.activeCamera;if(this.isReady(e,c)&&f){e._renderId=i.getRenderId();const a=s._internalAbstractMeshDataInfo._materialForRenderPass?.[r.currentRenderPassId];let o=e._getDrawWrapper();!o&&a&&(o=a._getDrawWrapper());const h=f.mode===u.i.ORTHOGRAPHIC_CAMERA;if(!o)return;const p=o.effect;let g,m;if(r.enableEffect(o),c||t._bind(e,p,n.fillMode),a?a.bindForSubMesh(s.getWorldMatrix(),s,e):(p.setMatrix("viewProjection",i.getTransformMatrix()),p.setMatrix("world",s.getWorldMatrix()),this._storeCameraSpaceZ&&p.setMatrix("view",i.getViewMatrix())),h?(g=!r.useReverseDepthBuffer&&r.isNDCHalfZRange?0:1,m=r.useReverseDepthBuffer&&r.isNDCHalfZRange?0:1):(g=r.useReverseDepthBuffer&&r.isNDCHalfZRange?f.minZ:r.isNDCHalfZRange?0:f.minZ,m=r.useReverseDepthBuffer&&r.isNDCHalfZRange?0:f.maxZ),p.setFloat2("depthValues",g,g+m),!a){if(n.needAlphaTesting()){const e=n.getAlphaTestTexture();e&&(p.setTexture("diffuseSampler",e),p.setMatrix("diffuseMatrix",e.getTextureMatrix()))}(0,_.f$)(t,p),(0,d.gS)(p,n,i),(0,_.nR)(t,p),t.morphTargetManager&&t.morphTargetManager.isUsingTextureForTargets&&t.morphTargetManager._bind(p);const s=e.getMesh().bakedVertexAnimationManager;s&&s.isEnabled&&s.bind(p,c),n.pointsCloud&&p.setFloat("pointSize",n.pointSize)}t._processRendering(s,e,p,n.fillMode,l,c,((e,t)=>p.setMatrix("world",t)))}};this._depthMap.customRenderFunction=(e,t,s,i)=>{let r;if(i.length)for(r=0;r4&&(h.push(l.R.MatricesIndicesExtraKind),h.push(l.R.MatricesWeightsExtraKind)),o.push("#define NUM_BONE_INFLUENCERS "+i.numBoneInfluencers),i.numBoneInfluencers>0&&c.addCPUSkinningFallback(0,i);const e=i.skeleton;e.isUsingTextureForMatrices?o.push("#define BONETEXTURE"):o.push("#define BonesPerMesh "+(e.bones.length+1))}else o.push("#define NUM_BONE_INFLUENCERS 0");const u=i.morphTargetManager;let p=0;u&&(p=u.numMaxInfluencers||u.numInfluencers,p>0&&(o.push("#define MORPHTARGETS"),o.push("#define NUM_MORPH_INFLUENCERS "+p),u.isUsingTextureForTargets&&o.push("#define MORPHTARGETS_TEXTURE"),(0,_.MF)(h,i,p))),a.pointsCloud&&o.push("#define POINTSIZE"),t&&(o.push("#define INSTANCES"),(0,_.te)(h),e.getRenderingMesh().hasThinInstances&&o.push("#define THIN_INSTANCES"));const g=i.bakedVertexAnimationManager;g&&g.isEnabled&&(o.push("#define BAKED_VERTEX_ANIMATION_TEXTURE"),t&&h.push("bakedVertexAnimationSettingsInstanced")),this._storeNonLinearDepth&&o.push("#define NONLINEARDEPTH"),this._storeCameraSpaceZ&&o.push("#define STORE_CAMERASPACE_Z"),this.isPacked&&o.push("#define PACKED"),(0,d.tv)(a,r,o);const m=e._getDrawWrapper(void 0,!0),T=m.defines,b=o.join("\n");if(T!==b){const e=["world","mBones","boneTextureWidth","pointSize","viewProjection","view","diffuseMatrix","depthValues","morphTargetInfluences","morphTargetCount","morphTargetTextureInfo","morphTargetTextureIndices","bakedVertexAnimationSettings","bakedVertexAnimationTextureSizeInverted","bakedVertexAnimationTime","bakedVertexAnimationTexture"],t=["diffuseSampler","morphTargets","boneSampler","bakedVertexAnimationTexture"];(0,d.TV)(e),m.setEffect(s.createEffect("depth",{attributes:h,uniformsNames:e,uniformBuffersNames:[],samplers:t,defines:b,fallbacks:c,onCompiled:null,onError:null,indexParameters:{maxSimultaneousMorphTargets:p},shaderLanguage:this._shaderLanguage},s))}return m.effect.isReady()}getDepthMap(){return this._depthMap}dispose(){const e=[];for(const t in this._scene._depthRenderer)this._scene._depthRenderer[t]===this&&e.push(t);if(e.length>0){this._depthMap.dispose();for(const t of e)delete this._scene._depthRenderer[t]}}}p.ForceGLSL=!1,p._SceneComponentInitialization=e=>{throw(0,a.n)("DepthRendererSceneComponent")};var g=s(9848),m=s(7891),T=s(6096);s(9610).l.ShadersStore.minmaxReduxPixelShader="varying vec2 vUV;uniform sampler2D textureSampler;\n#if defined(INITIAL)\nuniform sampler2D sourceTexture;uniform vec2 texSize;void main(void)\n{ivec2 coord=ivec2(vUV*(texSize-1.0));float f1=texelFetch(sourceTexture,coord,0).r;float f2=texelFetch(sourceTexture,coord+ivec2(1,0),0).r;float f3=texelFetch(sourceTexture,coord+ivec2(1,1),0).r;float f4=texelFetch(sourceTexture,coord+ivec2(0,1),0).r;float minz=min(min(min(f1,f2),f3),f4);\n#ifdef DEPTH_REDUX\nfloat maxz=max(max(max(sign(1.0-f1)*f1,sign(1.0-f2)*f2),sign(1.0-f3)*f3),sign(1.0-f4)*f4);\n#else\nfloat maxz=max(max(max(f1,f2),f3),f4);\n#endif\nglFragColor=vec4(minz,maxz,0.,0.);}\n#elif defined(MAIN)\nuniform vec2 texSize;void main(void)\n{ivec2 coord=ivec2(vUV*(texSize-1.0));vec2 f1=texelFetch(textureSampler,coord,0).rg;vec2 f2=texelFetch(textureSampler,coord+ivec2(1,0),0).rg;vec2 f3=texelFetch(textureSampler,coord+ivec2(1,1),0).rg;vec2 f4=texelFetch(textureSampler,coord+ivec2(0,1),0).rg;float minz=min(min(min(f1.x,f2.x),f3.x),f4.x);float maxz=max(max(max(f1.y,f2.y),f3.y),f4.y);glFragColor=vec4(minz,maxz,0.,0.);}\n#elif defined(ONEBEFORELAST)\nuniform ivec2 texSize;void main(void)\n{ivec2 coord=ivec2(vUV*vec2(texSize-1));vec2 f1=texelFetch(textureSampler,coord % texSize,0).rg;vec2 f2=texelFetch(textureSampler,(coord+ivec2(1,0)) % texSize,0).rg;vec2 f3=texelFetch(textureSampler,(coord+ivec2(1,1)) % texSize,0).rg;vec2 f4=texelFetch(textureSampler,(coord+ivec2(0,1)) % texSize,0).rg;float minz=min(f1.x,f2.x);float maxz=max(f1.y,f2.y);glFragColor=vec4(minz,maxz,0.,0.);}\n#elif defined(LAST)\nvoid main(void)\n{glFragColor=vec4(0.);if (true) { \ndiscard;}}\n#endif\n";class b{constructor(e){this.onAfterReductionPerformed=new g.cP,this._forceFullscreenViewport=!0,this._activated=!1,this._camera=e,this._postProcessManager=new T.X(e.getScene()),this._onContextRestoredObserver=e.getEngine().onContextRestoredObservable.add((()=>{this._postProcessManager._rebuild()}))}get sourceTexture(){return this._sourceTexture}setSourceTexture(e,t,s=2,i=!0){if(e===this._sourceTexture)return;this.dispose(!1),this._sourceTexture=e,this._reductionSteps=[],this._forceFullscreenViewport=i;const r=this._camera.getScene(),n=new m.w("Initial reduction phase","minmaxRedux",["texSize"],["sourceTexture"],1,null,1,r.getEngine(),!1,"#define INITIAL"+(t?"\n#define DEPTH_REDUX":""),s,void 0,void 0,void 0,7);n.autoClear=!1,n.forceFullscreenViewport=i;let a=this._sourceTexture.getRenderWidth(),o=this._sourceTexture.getRenderHeight();n.onApply=((e,t)=>s=>{s.setTexture("sourceTexture",this._sourceTexture),s.setFloat2("texSize",e,t)})(a,o),this._reductionSteps.push(n);let h=1;for(;a>1||o>1;){a=Math.max(Math.round(a/2),1),o=Math.max(Math.round(o/2),1);const e=new m.w("Reduction phase "+h,"minmaxRedux",["texSize"],null,{width:a,height:o},null,1,r.getEngine(),!1,"#define "+(1==a&&1==o?"LAST":1==a||1==o?"ONEBEFORELAST":"MAIN"),s,void 0,void 0,void 0,7);if(e.autoClear=!1,e.forceFullscreenViewport=i,e.onApply=((e,t)=>s=>{1==e||1==t?s.setInt2("texSize",e,t):s.setFloat2("texSize",e,t)})(a,o),this._reductionSteps.push(e),h++,1==a&&1==o){const t=(e,t,s)=>{const i=new Float32Array(4*e*t),n={min:0,max:0};return()=>{r.getEngine()._readTexturePixels(s.inputTexture.texture,e,t,-1,0,i,!1),n.min=i[0],n.max=i[1],this.onAfterReductionPerformed.notifyObservers(n)}};e.onAfterRenderObservable.add(t(a,o,e))}}}get refreshRate(){return this._sourceTexture?this._sourceTexture.refreshRate:-1}set refreshRate(e){this._sourceTexture&&(this._sourceTexture.refreshRate=e)}get activated(){return this._activated}activate(){!this._onAfterUnbindObserver&&this._sourceTexture&&(this._onAfterUnbindObserver=this._sourceTexture.onAfterUnbindObservable.add((()=>{const e=this._camera.getScene().getEngine();e._debugPushGroup?.("min max reduction",1),this._reductionSteps[0].activate(this._camera),this._postProcessManager.directRender(this._reductionSteps,this._reductionSteps[0].inputTexture,this._forceFullscreenViewport),e.unBindFramebuffer(this._reductionSteps[0].inputTexture,!1),e._debugPopGroup?.(1)})),this._activated=!0)}deactivate(){this._onAfterUnbindObserver&&this._sourceTexture&&(this._sourceTexture.onAfterUnbindObservable.remove(this._onAfterUnbindObserver),this._onAfterUnbindObserver=null,this._activated=!1)}dispose(e=!0){if(e&&(this.onAfterReductionPerformed.clear(),this._onContextRestoredObserver&&(this._camera.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver),this._onContextRestoredObserver=null)),this.deactivate(),this._reductionSteps){for(let e=0;ethis._computeShadowCastersBoundingInfo()))),this._freezeShadowCastersBoundingInfo=e,e&&this._computeShadowCastersBoundingInfo()}_computeShadowCastersBoundingInfo(){if(this._scbiMin.copyFromFloats(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._scbiMax.copyFromFloats(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),this._shadowMap&&this._shadowMap.renderList){const e=this._shadowMap.renderList;for(let t=0;tt&&(e=0,t=1),e<0&&(e=0),t>1&&(t=1),this._minDistance=e,this._maxDistance=t,this._breaksAreDirty=!0)}get minDistance(){return this._minDistance}get maxDistance(){return this._maxDistance}getClassName(){return C.CLASSNAME}getCascadeMinExtents(e){return e>=0&&e=0&&et.maxZ&&0!==t.maxZ||(this._shadowMaxZ=e,this._light._markMeshesAsLightDirty(),this._breaksAreDirty=!0):this._shadowMaxZ=e}get debug(){return this._debug}set debug(e){this._debug=e,this._light._markMeshesAsLightDirty()}get depthClamp(){return this._depthClamp}set depthClamp(e){this._depthClamp=e}get cascadeBlendPercentage(){return this._cascadeBlendPercentage}set cascadeBlendPercentage(e){this._cascadeBlendPercentage=e,this._light._markMeshesAsLightDirty()}get lambda(){return this._lambda}set lambda(e){const t=Math.min(Math.max(e,0),1);this._lambda!=t&&(this._lambda=t,this._breaksAreDirty=!0)}getCascadeViewMatrix(e){return e>=0&&e=0&&e=0&&e{let t=e.min,s=e.max;t>=s&&(t=0,s=1),t==this._minDistance&&s==this._maxDistance||this.setMinMaxDistance(t,s)})),this._depthReducer.setDepthRenderer(this._depthRenderer)),this._depthReducer.activate()}}get autoCalcDepthBoundsRefreshRate(){return this._depthReducer?.depthRenderer?.getDepthMap().refreshRate??-1}set autoCalcDepthBoundsRefreshRate(e){this._depthReducer?.depthRenderer&&(this._depthReducer.depthRenderer.getDepthMap().refreshRate=e)}splitFrustum(){this._breaksAreDirty=!0}_splitFrustum(){const e=this._getCamera();if(!e)return;const t=e.minZ,s=e.maxZ||this._shadowMaxZ,i=s-t,r=this._minDistance,n=t+r*i,a=t+(this._shadowMaxZ=t?Math.min((this._shadowMaxZ-t)/(s-t),this._maxDistance):this._maxDistance)*i,o=a-n,h=a/n;for(let e=0;e{this._sceneUBOs&&this._scene.setSceneUniformBuffer(this._sceneUBOs[t]),this._currentLayer=t,this._filter===i.o.FILTER_PCF&&e.setColorWrite(!1),this._scene.setTransformMatrix(this.getCascadeViewMatrix(t),this.getCascadeProjectionMatrix(t)),this._useUBO&&(this._scene.getSceneUniformBuffer().unbindEffect(),this._scene.finalizeSceneUbo())})),this._shadowMap.onBeforeBindObservable.add((()=>{this._currentSceneUBO=this._scene.getSceneUniformBuffer(),e._debugPushGroup?.(`cascaded shadow map generation for pass id ${e.currentRenderPassId}`,1),this._breaksAreDirty&&this._splitFrustum(),this._computeMatrices()})),this._splitFrustum()}_bindCustomEffectForRenderSubMeshForShadowMap(e,t){t.setMatrix("viewProjection",this.getCascadeTransformMatrix(this._currentLayer))}_isReadyCustomDefines(e){e.push("#define SM_DEPTHCLAMP "+(this._depthClamp&&this._filter!==i.o.FILTER_PCSS?"1":"0"))}prepareDefines(e,t){super.prepareDefines(e,t);const s=this._scene,i=this._light;if(!s.shadowsEnabled||!i.shadowEnabled)return;e["SHADOWCSM"+t]=!0,e["SHADOWCSMDEBUG"+t]=this.debug,e["SHADOWCSMNUM_CASCADES"+t]=this.numCascades,e["SHADOWCSM_RIGHTHANDED"+t]=s.useRightHandedSystem;const r=this._getCamera();r&&this._shadowMaxZ<=(r.maxZ||this._shadowMaxZ)&&(e["SHADOWCSMUSESHADOWMAXZ"+t]=!0),0===this.cascadeBlendPercentage&&(e["SHADOWCSMNOBLEND"+t]=!0)}bindShadowLight(e,t){const s=this._light;if(!this._scene.shadowsEnabled||!s.shadowEnabled)return;const r=this._getCamera();if(!r)return;const n=this.getShadowMap();if(!n)return;const a=n.getSize().width;if(t.setMatrices("lightMatrix"+e,this._transformMatricesAsArray),t.setArray("viewFrustumZ"+e,this._viewSpaceFrustumsZ),t.setFloat("cascadeBlendFactor"+e,0===this.cascadeBlendPercentage?1e4:1/this.cascadeBlendPercentage),t.setArray("frustumLengths"+e,this._frustumLengths),this._filter===i.o.FILTER_PCF)t.setDepthStencilTexture("shadowTexture"+e,n),s._uniformBuffer.updateFloat4("shadowsInfo",this.getDarkness(),a,1/a,this.frustumEdgeFalloff,e);else if(this._filter===i.o.FILTER_PCSS){for(let e=0;enew C(e,t,void 0,s)));return void 0!==e.numCascades&&(s.numCascades=e.numCascades),void 0!==e.debug&&(s.debug=e.debug),void 0!==e.stabilizeCascades&&(s.stabilizeCascades=e.stabilizeCascades),void 0!==e.lambda&&(s.lambda=e.lambda),void 0!==e.cascadeBlendPercentage&&(s.cascadeBlendPercentage=e.cascadeBlendPercentage),void 0!==e.depthClamp&&(s.depthClamp=e.depthClamp),void 0!==e.autoCalcDepthBounds&&(s.autoCalcDepthBounds=e.autoCalcDepthBounds),void 0!==e.shadowMaxZ&&(s.shadowMaxZ=e.shadowMaxZ),void 0!==e.penumbraDarkness&&(s.penumbraDarkness=e.penumbraDarkness),void 0!==e.freezeShadowCastersBoundingInfo&&(s.freezeShadowCastersBoundingInfo=e.freezeShadowCastersBoundingInfo),void 0!==e.minDistance&&void 0!==e.maxDistance&&s.setMinMaxDistance(e.minDistance,e.maxDistance),s}}C._FrustumCornersNDCSpace=[new r.Pq(-1,1,-1),new r.Pq(1,1,-1),new r.Pq(1,-1,-1),new r.Pq(-1,-1,-1),new r.Pq(-1,1,1),new r.Pq(1,1,1),new r.Pq(1,-1,1),new r.Pq(-1,-1,1)],C.CLASSNAME="CascadedShadowGenerator",C.DEFAULT_CASCADES_COUNT=4,C.MIN_CASCADES_COUNT=2,C.MAX_CASCADES_COUNT=4,C._SceneComponentInitialization=e=>{throw(0,a.n)("ShadowGeneratorSceneComponent")};var S=s(6945);(0,s(3084).ji)(S.v.NAME_SHADOWGENERATOR,((e,t)=>{if(void 0!==e.shadowGenerators&&null!==e.shadowGenerators)for(let s=0,r=e.shadowGenerators.length;s{let t=e._getComponent(S.v.NAME_SHADOWGENERATOR);t||(t=new I(e),e._addComponent(t))}},5581:(e,t,s)=>{s.d(t,{Z:()=>u});var i=s(5524),r=s(9259),n=s(9923),a=s(4870),o=s(4704),h=s(8733);class l extends o.v{constructor(){super(...arguments),this._needProjectionMatrixCompute=!0,this._viewMatrix=n.uq.Identity(),this._projectionMatrix=n.uq.Identity()}_setPosition(e){this._position=e}get position(){return this._position}set position(e){this._setPosition(e)}_setDirection(e){this._direction=e}get direction(){return this._direction}set direction(e){this._setDirection(e)}get shadowMinZ(){return this._shadowMinZ}set shadowMinZ(e){this._shadowMinZ=e,this.forceProjectionMatrixCompute()}get shadowMaxZ(){return this._shadowMaxZ}set shadowMaxZ(e){this._shadowMaxZ=e,this.forceProjectionMatrixCompute()}computeTransformedInformation(){return!(!this.parent||!this.parent.getWorldMatrix||(this.transformedPosition||(this.transformedPosition=n.Pq.Zero()),n.Pq.TransformCoordinatesToRef(this.position,this.parent.getWorldMatrix(),this.transformedPosition),this.direction&&(this.transformedDirection||(this.transformedDirection=n.Pq.Zero()),n.Pq.TransformNormalToRef(this.direction,this.parent.getWorldMatrix(),this.transformedDirection)),0))}getDepthScale(){return 50}getShadowDirection(e){return this.transformedDirection?this.transformedDirection:this.direction}getAbsolutePosition(){return this.transformedPosition?this.transformedPosition:this.position}setDirectionToTarget(e){return this.direction=n.Pq.Normalize(e.subtract(this.position)),this.direction}getRotation(){this.direction.normalize();const e=n.Pq.Cross(this.direction,h._0.Y),t=n.Pq.Cross(e,this.direction);return n.Pq.RotationFromAxis(e,t,this.direction)}needCube(){return!1}needProjectionMatrixCompute(){return this._needProjectionMatrixCompute}forceProjectionMatrixCompute(){this._needProjectionMatrixCompute=!0}_initCache(){super._initCache(),this._cache.position=n.Pq.Zero()}_isSynchronized(){return!!this._cache.position.equals(this.position)}computeWorldMatrix(e){return!e&&this.isSynchronized()?(this._currentRenderId=this.getScene().getRenderId(),this._worldMatrix):(this._updateCache(),this._cache.position.copyFrom(this.position),this._worldMatrix||(this._worldMatrix=n.uq.Identity()),n.uq.TranslationToRef(this.position.x,this.position.y,this.position.z,this._worldMatrix),this.parent&&this.parent.getWorldMatrix&&(this._worldMatrix.multiplyToRef(this.parent.getWorldMatrix(),this._worldMatrix),this._markSyncedWithParent()),this._worldMatrixDeterminantIsDirty=!0,this._worldMatrix)}getDepthMinZ(e){return void 0!==this.shadowMinZ?this.shadowMinZ:e.minZ}getDepthMaxZ(e){return void 0!==this.shadowMaxZ?this.shadowMaxZ:e.maxZ}setShadowProjectionMatrix(e,t,s){return this.customProjectionMatrixBuilder?this.customProjectionMatrixBuilder(t,s,e):this._setDefaultShadowProjectionMatrix(e,t,s),this}_syncParentEnabledState(){super._syncParentEnabledState(),this.parent&&this.parent.getWorldMatrix||(this.transformedPosition=null,this.transformedDirection=null)}getViewMatrix(e){const t=n.AA.Vector3[0];let s=this.position;this.computeTransformedInformation()&&(s=this.transformedPosition),n.Pq.NormalizeToRef(this.getShadowDirection(e),t),1===Math.abs(n.Pq.Dot(t,n.Pq.Up()))&&(t.z=1e-13);const i=n.AA.Vector3[1];return s.addToRef(t,i),n.uq.LookAtLHToRef(s,i,n.Pq.Up(),this._viewMatrix),this._viewMatrix}getProjectionMatrix(e,t){return this.setShadowProjectionMatrix(this._projectionMatrix,e??this._viewMatrix,t??[]),this._projectionMatrix}}(0,i.Cg)([(0,r.P_)()],l.prototype,"position",null),(0,i.Cg)([(0,r.P_)()],l.prototype,"direction",null),(0,i.Cg)([(0,r.lK)()],l.prototype,"shadowMinZ",null),(0,i.Cg)([(0,r.lK)()],l.prototype,"shadowMaxZ",null);var c=s(6552);a.b.AddNodeConstructor("Light_Type_1",((e,t)=>()=>new u(e,n.Pq.Zero(),t)));class u extends l{get shadowFrustumSize(){return this._shadowFrustumSize}set shadowFrustumSize(e){this._shadowFrustumSize=e,this.forceProjectionMatrixCompute()}get shadowOrthoScale(){return this._shadowOrthoScale}set shadowOrthoScale(e){this._shadowOrthoScale=e,this.forceProjectionMatrixCompute()}get orthoLeft(){return this._orthoLeft}set orthoLeft(e){this._orthoLeft=e}get orthoRight(){return this._orthoRight}set orthoRight(e){this._orthoRight=e}get orthoTop(){return this._orthoTop}set orthoTop(e){this._orthoTop=e}get orthoBottom(){return this._orthoBottom}set orthoBottom(e){this._orthoBottom=e}constructor(e,t,s){super(e,s),this._shadowFrustumSize=0,this._shadowOrthoScale=.1,this.autoUpdateExtends=!0,this.autoCalcShadowZBounds=!1,this._orthoLeft=Number.MAX_VALUE,this._orthoRight=Number.MIN_VALUE,this._orthoTop=Number.MIN_VALUE,this._orthoBottom=Number.MAX_VALUE,this.position=t.scale(-1),this.direction=t}getClassName(){return"DirectionalLight"}getTypeID(){return o.v.LIGHTTYPEID_DIRECTIONALLIGHT}_setDefaultShadowProjectionMatrix(e,t,s){this.shadowFrustumSize>0?this._setDefaultFixedFrustumShadowProjectionMatrix(e):this._setDefaultAutoExtendShadowProjectionMatrix(e,t,s)}_setDefaultFixedFrustumShadowProjectionMatrix(e){const t=this.getScene().activeCamera;t&&n.uq.OrthoLHToRef(this.shadowFrustumSize,this.shadowFrustumSize,void 0!==this.shadowMinZ?this.shadowMinZ:t.minZ,void 0!==this.shadowMaxZ?this.shadowMaxZ:t.maxZ,e,this.getScene().getEngine().isNDCHalfZRange)}_setDefaultAutoExtendShadowProjectionMatrix(e,t,s){const i=this.getScene().activeCamera;if(!i)return;if(this.autoUpdateExtends||this._orthoLeft===Number.MAX_VALUE){const e=n.Pq.Zero();this._orthoLeft=Number.MAX_VALUE,this._orthoRight=-Number.MAX_VALUE,this._orthoTop=-Number.MAX_VALUE,this._orthoBottom=Number.MAX_VALUE;let i=Number.MAX_VALUE,r=-Number.MAX_VALUE;for(let a=0;athis._orthoRight&&(this._orthoRight=e.x),e.y>this._orthoTop&&(this._orthoTop=e.y),this.autoCalcShadowZBounds&&(e.zr&&(r=e.z))}this.autoCalcShadowZBounds&&(this._shadowMinZ=i,this._shadowMaxZ=r)}const r=this._orthoRight-this._orthoLeft,a=this._orthoTop-this._orthoBottom,o=void 0!==this.shadowMinZ?this.shadowMinZ:i.minZ,h=void 0!==this.shadowMaxZ?this.shadowMaxZ:i.maxZ,l=this.getScene().getEngine().useReverseDepthBuffer;n.uq.OrthoOffCenterLHToRef(this._orthoLeft-r*this.shadowOrthoScale,this._orthoRight+r*this.shadowOrthoScale,this._orthoBottom-a*this.shadowOrthoScale,this._orthoTop+a*this.shadowOrthoScale,l?h:o,l?o:h,e,this.getScene().getEngine().isNDCHalfZRange)}_buildUniformLayout(){this._uniformBuffer.addUniform("vLightData",4),this._uniformBuffer.addUniform("vLightDiffuse",4),this._uniformBuffer.addUniform("vLightSpecular",4),this._uniformBuffer.addUniform("shadowsInfo",3),this._uniformBuffer.addUniform("depthValues",2),this._uniformBuffer.create()}transferToEffect(e,t){return this.computeTransformedInformation()?(this._uniformBuffer.updateFloat4("vLightData",this.transformedDirection.x,this.transformedDirection.y,this.transformedDirection.z,1,t),this):(this._uniformBuffer.updateFloat4("vLightData",this.direction.x,this.direction.y,this.direction.z,1,t),this)}transferToNodeMaterialEffect(e,t){return this.computeTransformedInformation()?(e.setFloat3(t,this.transformedDirection.x,this.transformedDirection.y,this.transformedDirection.z),this):(e.setFloat3(t,this.direction.x,this.direction.y,this.direction.z),this)}getDepthMinZ(e){const t=this._scene.getEngine();return!t.useReverseDepthBuffer&&t.isNDCHalfZRange?0:1}getDepthMaxZ(e){const t=this._scene.getEngine();return t.useReverseDepthBuffer&&t.isNDCHalfZRange?0:1}prepareLightSpecificDefines(e,t){e["DIRLIGHT"+t]=!0}}(0,i.Cg)([(0,r.lK)()],u.prototype,"shadowFrustumSize",null),(0,i.Cg)([(0,r.lK)()],u.prototype,"shadowOrthoScale",null),(0,i.Cg)([(0,r.lK)()],u.prototype,"autoUpdateExtends",void 0),(0,i.Cg)([(0,r.lK)()],u.prototype,"autoCalcShadowZBounds",void 0),(0,i.Cg)([(0,r.lK)("orthoLeft")],u.prototype,"_orthoLeft",void 0),(0,i.Cg)([(0,r.lK)("orthoRight")],u.prototype,"_orthoRight",void 0),(0,i.Cg)([(0,r.lK)("orthoTop")],u.prototype,"_orthoTop",void 0),(0,i.Cg)([(0,r.lK)("orthoBottom")],u.prototype,"_orthoBottom",void 0),(0,c.Y5)("BABYLON.DirectionalLight",u)},1513:(e,t,s)=>{s.d(t,{g:()=>c});var i=s(5524),r=s(9259),n=s(9923),a=s(6041),o=s(4870),h=s(4704),l=s(6552);o.b.AddNodeConstructor("Light_Type_3",((e,t)=>()=>new c(e,n.Pq.Zero(),t)));class c extends h.v{constructor(e,t,s){super(e,s),this.groundColor=new a.v9(0,0,0),this.direction=t||n.Pq.Up()}_buildUniformLayout(){this._uniformBuffer.addUniform("vLightData",4),this._uniformBuffer.addUniform("vLightDiffuse",4),this._uniformBuffer.addUniform("vLightSpecular",4),this._uniformBuffer.addUniform("vLightGround",3),this._uniformBuffer.addUniform("shadowsInfo",3),this._uniformBuffer.addUniform("depthValues",2),this._uniformBuffer.create()}getClassName(){return"HemisphericLight"}setDirectionToTarget(e){return this.direction=n.Pq.Normalize(e.subtract(n.Pq.Zero())),this.direction}getShadowGenerator(){return null}transferToEffect(e,t){const s=n.Pq.Normalize(this.direction);return this._uniformBuffer.updateFloat4("vLightData",s.x,s.y,s.z,0,t),this._uniformBuffer.updateColor3("vLightGround",this.groundColor.scale(this.intensity),t),this}transferToNodeMaterialEffect(e,t){const s=n.Pq.Normalize(this.direction);return e.setFloat3(t,s.x,s.y,s.z),this}computeWorldMatrix(){return this._worldMatrix||(this._worldMatrix=n.uq.Identity()),this._worldMatrix}getTypeID(){return h.v.LIGHTTYPEID_HEMISPHERICLIGHT}prepareLightSpecificDefines(e,t){e["HEMILIGHT"+t]=!0}}(0,i.Cg)([(0,r.jT)()],c.prototype,"groundColor",void 0),(0,i.Cg)([(0,r.P_)()],c.prototype,"direction",void 0),(0,l.Y5)("BABYLON.HemisphericLight",c)},4704:(e,t,s)=>{s.d(t,{v:()=>d});var i=s(5524),r=s(9259),n=s(9923),a=s(6041),o=s(4870),h=s(935),l=s(6552),c=s(5515),u=s(6877);class d extends o.b{get range(){return this._range}set range(e){this._range=e,this._inverseSquaredRange=1/(this.range*this.range)}get intensityMode(){return this._intensityMode}set intensityMode(e){this._intensityMode=e,this._computePhotometricScale()}get radius(){return this._radius}set radius(e){this._radius=e,this._computePhotometricScale()}get shadowEnabled(){return this._shadowEnabled}set shadowEnabled(e){this._shadowEnabled!==e&&(this._shadowEnabled=e,this._markMeshesAsLightDirty())}get includedOnlyMeshes(){return this._includedOnlyMeshes}set includedOnlyMeshes(e){this._includedOnlyMeshes=e,this._hookArrayForIncludedOnly(e)}get excludedMeshes(){return this._excludedMeshes}set excludedMeshes(e){this._excludedMeshes=e,this._hookArrayForExcluded(e)}get excludeWithLayerMask(){return this._excludeWithLayerMask}set excludeWithLayerMask(e){this._excludeWithLayerMask=e,this._resyncMeshes()}get includeOnlyWithLayerMask(){return this._includeOnlyWithLayerMask}set includeOnlyWithLayerMask(e){this._includeOnlyWithLayerMask=e,this._resyncMeshes()}get lightmapMode(){return this._lightmapMode}set lightmapMode(e){this._lightmapMode!==e&&(this._lightmapMode=e,this._markMeshesAsLightDirty())}getViewMatrix(e){return null}getProjectionMatrix(e,t){return null}constructor(e,t){super(e,t,!1),this.diffuse=new a.v9(1,1,1),this.specular=new a.v9(1,1,1),this.falloffType=d.FALLOFF_DEFAULT,this.intensity=1,this._range=Number.MAX_VALUE,this._inverseSquaredRange=0,this._photometricScale=1,this._intensityMode=d.INTENSITYMODE_AUTOMATIC,this._radius=1e-5,this.renderPriority=0,this._shadowEnabled=!0,this._excludeWithLayerMask=0,this._includeOnlyWithLayerMask=0,this._lightmapMode=0,this._shadowGenerators=null,this._excludedMeshesIds=new Array,this._includedOnlyMeshesIds=new Array,this._isLight=!0,this.getScene().addLight(this),this._uniformBuffer=new h.D(this.getScene().getEngine(),void 0,void 0,e),this._buildUniformLayout(),this.includedOnlyMeshes=[],this.excludedMeshes=[],this._resyncMeshes()}transferTexturesToEffect(e,t){return this}_bindLight(e,t,s,i,r=!0){const n=e.toString();let o=!1;if(this._uniformBuffer.bindToEffect(s,"Light"+n),this._renderId!==t.getRenderId()||this._lastUseSpecular!==i||!this._uniformBuffer.useUbo){this._renderId=t.getRenderId(),this._lastUseSpecular=i;const e=this.getScaledIntensity();this.transferToEffect(s,n),this.diffuse.scaleToRef(e,a.IG.Color3[0]),this._uniformBuffer.updateColor4("vLightDiffuse",a.IG.Color3[0],this.range,n),i&&(this.specular.scaleToRef(e,a.IG.Color3[1]),this._uniformBuffer.updateColor4("vLightSpecular",a.IG.Color3[1],this.radius,n)),o=!0}if(this.transferTexturesToEffect(s,n),t.shadowsEnabled&&this.shadowEnabled&&r){const e=this.getShadowGenerator(t.activeCamera)??this.getShadowGenerator();e&&(e.bindShadowLight(n,s),o=!0)}o?this._uniformBuffer.update():this._uniformBuffer.bindUniformBuffer()}getClassName(){return"Light"}toString(e){let t="Name: "+this.name;if(t+=", type: "+["Point","Directional","Spot","Hemispheric"][this.getTypeID()],this.animations)for(let s=0;s0&&-1===this.includedOnlyMeshes.indexOf(e)||this.excludedMeshes&&this.excludedMeshes.length>0&&-1!==this.excludedMeshes.indexOf(e)||0!==this.includeOnlyWithLayerMask&&0==(this.includeOnlyWithLayerMask&e.layerMask)||0!==this.excludeWithLayerMask&&this.excludeWithLayerMask&e.layerMask))}dispose(e,t=!1){if(this._shadowGenerators){const e=this._shadowGenerators.values();for(let t=e.next();!0!==t.done;t=e.next())t.value.dispose();this._shadowGenerators=null}if(this.getScene().stopAnimation(this),this._parentContainer){const e=this._parentContainer.lights.indexOf(this);e>-1&&this._parentContainer.lights.splice(e,1),this._parentContainer=null}for(const e of this.getScene().meshes)e._removeLightSource(this,!0);this._uniformBuffer.dispose(),this.getScene().removeLight(this),super.dispose(e,t)}getTypeID(){return 0}getScaledIntensity(){return this._photometricScale*this.intensity}clone(e,t=null){const s=d.GetConstructorFromName(this.getTypeID(),e,this.getScene());if(!s)return null;const i=u.p.Clone(s,this);return e&&(i.name=e),t&&(i.parent=t),i.setEnabled(this.isEnabled()),this.onClonedObservable.notifyObservers(i),i}serialize(){const e=u.p.Serialize(this);return e.uniqueId=this.uniqueId,e.type=this.getTypeID(),this.parent&&this.parent._serializeAsParent(e),this.excludedMeshes.length>0&&(e.excludedMeshesIds=[],this.excludedMeshes.forEach((t=>{e.excludedMeshesIds.push(t.id)}))),this.includedOnlyMeshes.length>0&&(e.includedOnlyMeshesIds=[],this.includedOnlyMeshes.forEach((t=>{e.includedOnlyMeshesIds.push(t.id)}))),u.p.AppendSerializedAnimations(this,e),e.ranges=this.serializeAnimationRanges(),e.isEnabled=this.isEnabled(),e}static GetConstructorFromName(e,t,s){return o.b.Construct("Light_Type_"+e,t,s)||null}static Parse(e,t){const s=d.GetConstructorFromName(e.type,e.name,t);if(!s)return null;const i=u.p.Parse(s,e,t);if(e.excludedMeshesIds&&(i._excludedMeshesIds=e.excludedMeshesIds),e.includedOnlyMeshesIds&&(i._includedOnlyMeshesIds=e.includedOnlyMeshesIds),void 0!==e.parentId&&(i._waitingParentId=e.parentId),void 0!==e.parentInstanceIndex&&(i._waitingParentInstanceIndex=e.parentInstanceIndex),void 0!==e.falloffType&&(i.falloffType=e.falloffType),void 0!==e.lightmapMode&&(i.lightmapMode=e.lightmapMode),e.animations){for(let t=0;t{const i=t.apply(e,s);for(const e of s)e._resyncLightSource(this);return i};const s=e.splice;e.splice=(t,i)=>{const r=s.apply(e,[t,i]);for(const e of r)e._resyncLightSource(this);return r};for(const t of e)t._resyncLightSource(this)}_hookArrayForIncludedOnly(e){const t=e.push;e.push=(...s)=>{const i=t.apply(e,s);return this._resyncMeshes(),i};const s=e.splice;e.splice=(t,i)=>{const r=s.apply(e,[t,i]);return this._resyncMeshes(),r},this._resyncMeshes()}_resyncMeshes(){for(const e of this.getScene().meshes)e._resyncLightSource(this)}_markMeshesAsLightDirty(){for(const e of this.getScene().meshes)-1!==e.lightSources.indexOf(this)&&e._markSubMeshesAsLightDirty()}_computePhotometricScale(){this._photometricScale=this._getPhotometricScale(),this.getScene().resetCachedMaterial()}_getPhotometricScale(){let e=0;const t=this.getTypeID();let s=this.intensityMode;switch(s===d.INTENSITYMODE_AUTOMATIC&&(s=t===d.LIGHTTYPEID_DIRECTIONALLIGHT?d.INTENSITYMODE_ILLUMINANCE:d.INTENSITYMODE_LUMINOUSINTENSITY),t){case d.LIGHTTYPEID_POINTLIGHT:case d.LIGHTTYPEID_SPOTLIGHT:switch(s){case d.INTENSITYMODE_LUMINOUSPOWER:e=1/(4*Math.PI);break;case d.INTENSITYMODE_LUMINOUSINTENSITY:e=1;break;case d.INTENSITYMODE_LUMINANCE:e=this.radius*this.radius}break;case d.LIGHTTYPEID_DIRECTIONALLIGHT:switch(s){case d.INTENSITYMODE_ILLUMINANCE:e=1;break;case d.INTENSITYMODE_LUMINANCE:{let t=this.radius;t=Math.max(t,.001),e=2*Math.PI*(1-Math.cos(t));break}}break;case d.LIGHTTYPEID_HEMISPHERICLIGHT:e=1}return e}_reorderLightsInScene(){const e=this.getScene();0!=this._renderPriority&&(e.requireLightSorting=!0),this.getScene().sortLightsByPriority()}}d.FALLOFF_DEFAULT=c.c.FALLOFF_DEFAULT,d.FALLOFF_PHYSICAL=c.c.FALLOFF_PHYSICAL,d.FALLOFF_GLTF=c.c.FALLOFF_GLTF,d.FALLOFF_STANDARD=c.c.FALLOFF_STANDARD,d.LIGHTMAP_DEFAULT=c.c.LIGHTMAP_DEFAULT,d.LIGHTMAP_SPECULAR=c.c.LIGHTMAP_SPECULAR,d.LIGHTMAP_SHADOWSONLY=c.c.LIGHTMAP_SHADOWSONLY,d.INTENSITYMODE_AUTOMATIC=c.c.INTENSITYMODE_AUTOMATIC,d.INTENSITYMODE_LUMINOUSPOWER=c.c.INTENSITYMODE_LUMINOUSPOWER,d.INTENSITYMODE_LUMINOUSINTENSITY=c.c.INTENSITYMODE_LUMINOUSINTENSITY,d.INTENSITYMODE_ILLUMINANCE=c.c.INTENSITYMODE_ILLUMINANCE,d.INTENSITYMODE_LUMINANCE=c.c.INTENSITYMODE_LUMINANCE,d.LIGHTTYPEID_POINTLIGHT=c.c.LIGHTTYPEID_POINTLIGHT,d.LIGHTTYPEID_DIRECTIONALLIGHT=c.c.LIGHTTYPEID_DIRECTIONALLIGHT,d.LIGHTTYPEID_SPOTLIGHT=c.c.LIGHTTYPEID_SPOTLIGHT,d.LIGHTTYPEID_HEMISPHERICLIGHT=c.c.LIGHTTYPEID_HEMISPHERICLIGHT,(0,i.Cg)([(0,r.jT)()],d.prototype,"diffuse",void 0),(0,i.Cg)([(0,r.jT)()],d.prototype,"specular",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"falloffType",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"intensity",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"range",null),(0,i.Cg)([(0,r.lK)()],d.prototype,"intensityMode",null),(0,i.Cg)([(0,r.lK)()],d.prototype,"radius",null),(0,i.Cg)([(0,r.lK)()],d.prototype,"_renderPriority",void 0),(0,i.Cg)([(0,r.$z)("_reorderLightsInScene")],d.prototype,"renderPriority",void 0),(0,i.Cg)([(0,r.lK)("shadowEnabled")],d.prototype,"_shadowEnabled",void 0),(0,i.Cg)([(0,r.lK)("excludeWithLayerMask")],d.prototype,"_excludeWithLayerMask",void 0),(0,i.Cg)([(0,r.lK)("includeOnlyWithLayerMask")],d.prototype,"_includeOnlyWithLayerMask",void 0),(0,i.Cg)([(0,r.lK)("lightmapMode")],d.prototype,"_lightmapMode",void 0)},5515:(e,t,s)=>{s.d(t,{c:()=>i});class i{static CompareLightsPriority(e,t){return e.shadowEnabled!==t.shadowEnabled?(t.shadowEnabled?1:0)-(e.shadowEnabled?1:0):t.renderPriority-e.renderPriority}}i.FALLOFF_DEFAULT=0,i.FALLOFF_PHYSICAL=1,i.FALLOFF_GLTF=2,i.FALLOFF_STANDARD=3,i.LIGHTMAP_DEFAULT=0,i.LIGHTMAP_SPECULAR=1,i.LIGHTMAP_SHADOWSONLY=2,i.INTENSITYMODE_AUTOMATIC=0,i.INTENSITYMODE_LUMINOUSPOWER=1,i.INTENSITYMODE_LUMINOUSINTENSITY=2,i.INTENSITYMODE_ILLUMINANCE=3,i.INTENSITYMODE_LUMINANCE=4,i.LIGHTTYPEID_POINTLIGHT=0,i.LIGHTTYPEID_DIRECTIONALLIGHT=1,i.LIGHTTYPEID_SPOTLIGHT=2,i.LIGHTTYPEID_HEMISPHERICLIGHT=3},3084:(e,t,s)=>{s.d(t,{ji:()=>r});const i={};function r(e,t){i[e]=t}},9679:(e,t,s)=>{var i=s(6326);class r{constructor(e,t="",s="black"){this._renderingCanvas=e,this._loadingText=t,this._loadingDivBackgroundColor=s,this._resizeLoadingUI=()=>{const e=this._renderingCanvas.getBoundingClientRect(),t=window.getComputedStyle(this._renderingCanvas).position;this._loadingDiv&&(this._loadingDiv.style.position="fixed"===t?"fixed":"absolute",this._loadingDiv.style.left=e.left+"px",this._loadingDiv.style.top=e.top+"px",this._loadingDiv.style.width=e.width+"px",this._loadingDiv.style.height=e.height+"px")}}displayLoadingUI(){if(this._loadingDiv)return;this._loadingDiv=document.createElement("div"),this._loadingDiv.id="babylonjsLoadingDiv",this._loadingDiv.style.opacity="0",this._loadingDiv.style.transition="opacity 1.5s ease",this._loadingDiv.style.pointerEvents="none",this._loadingDiv.style.display="grid",this._loadingDiv.style.gridTemplateRows="100%",this._loadingDiv.style.gridTemplateColumns="100%",this._loadingDiv.style.justifyItems="center",this._loadingDiv.style.alignItems="center",this._loadingTextDiv=document.createElement("div"),this._loadingTextDiv.style.position="absolute",this._loadingTextDiv.style.left="0",this._loadingTextDiv.style.top="50%",this._loadingTextDiv.style.marginTop="80px",this._loadingTextDiv.style.width="100%",this._loadingTextDiv.style.height="20px",this._loadingTextDiv.style.fontFamily="Arial",this._loadingTextDiv.style.fontSize="14px",this._loadingTextDiv.style.color="white",this._loadingTextDiv.style.textAlign="center",this._loadingTextDiv.style.zIndex="1",this._loadingTextDiv.innerHTML="Loading",this._loadingDiv.appendChild(this._loadingTextDiv),this._loadingTextDiv.innerHTML=this._loadingText,this._style=document.createElement("style"),this._style.type="text/css",this._style.innerHTML="@-webkit-keyframes spin1 { 0% { -webkit-transform: rotate(0deg);}\n 100% { -webkit-transform: rotate(360deg);}\n } @keyframes spin1 { 0% { transform: rotate(0deg);}\n 100% { transform: rotate(360deg);}\n }",document.getElementsByTagName("head")[0].appendChild(this._style);const e=!!window.SVGSVGElement,t=new Image;r.DefaultLogoUrl?t.src=r.DefaultLogoUrl:t.src=e?"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxODAuMTcgMjA4LjA0Ij48ZGVmcz48c3R5bGU+LmNscy0xe2ZpbGw6I2ZmZjt9LmNscy0ye2ZpbGw6I2UwNjg0Yjt9LmNscy0ze2ZpbGw6I2JiNDY0Yjt9LmNscy00e2ZpbGw6I2UwZGVkODt9LmNscy01e2ZpbGw6I2Q1ZDJjYTt9PC9zdHlsZT48L2RlZnM+PHRpdGxlPkJhYnlsb25Mb2dvPC90aXRsZT48ZyBpZD0iTGF5ZXJfMiIgZGF0YS1uYW1lPSJMYXllciAyIj48ZyBpZD0iUGFnZV9FbGVtZW50cyIgZGF0YS1uYW1lPSJQYWdlIEVsZW1lbnRzIj48cGF0aCBjbGFzcz0iY2xzLTEiIGQ9Ik05MC4wOSwwLDAsNTJWMTU2bDkwLjA5LDUyLDkwLjA4LTUyVjUyWiIvPjxwb2x5Z29uIGNsYXNzPSJjbHMtMiIgcG9pbnRzPSIxODAuMTcgNTIuMDEgMTUxLjk3IDM1LjczIDEyNC44NSA1MS4zOSAxNTMuMDUgNjcuNjcgMTgwLjE3IDUyLjAxIi8+PHBvbHlnb24gY2xhc3M9ImNscy0yIiBwb2ludHM9IjI3LjEyIDY3LjY3IDExNy4yMSAxNS42NiA5MC4wOCAwIDAgNTIuMDEgMjcuMTIgNjcuNjciLz48cG9seWdvbiBjbGFzcz0iY2xzLTIiIHBvaW50cz0iNjEuODkgMTIwLjMgOTAuMDggMTM2LjU4IDExOC4yOCAxMjAuMyA5MC4wOCAxMDQuMDIgNjEuODkgMTIwLjMiLz48cG9seWdvbiBjbGFzcz0iY2xzLTMiIHBvaW50cz0iMTUzLjA1IDY3LjY3IDE1My4wNSAxNDAuMzcgOTAuMDggMTc2LjcyIDI3LjEyIDE0MC4zNyAyNy4xMiA2Ny42NyAwIDUyLjAxIDAgMTU2LjAzIDkwLjA4IDIwOC4wNCAxODAuMTcgMTU2LjAzIDE4MC4xNyA1Mi4wMSAxNTMuMDUgNjcuNjciLz48cG9seWdvbiBjbGFzcz0iY2xzLTMiIHBvaW50cz0iOTAuMDggNzEuNDYgNjEuODkgODcuNzQgNjEuODkgMTIwLjMgOTAuMDggMTA0LjAyIDExOC4yOCAxMjAuMyAxMTguMjggODcuNzQgOTAuMDggNzEuNDYiLz48cG9seWdvbiBjbGFzcz0iY2xzLTQiIHBvaW50cz0iMTUzLjA1IDY3LjY3IDExOC4yOCA4Ny43NCAxMTguMjggMTIwLjMgOTAuMDggMTM2LjU4IDkwLjA4IDE3Ni43MiAxNTMuMDUgMTQwLjM3IDE1My4wNSA2Ny42NyIvPjxwb2x5Z29uIGNsYXNzPSJjbHMtNSIgcG9pbnRzPSIyNy4xMiA2Ny42NyA2MS44OSA4Ny43NCA2MS44OSAxMjAuMyA5MC4wOCAxMzYuNTggOTAuMDggMTc2LjcyIDI3LjEyIDE0MC4zNyAyNy4xMiA2Ny42NyIvPjwvZz48L2c+PC9zdmc+":"https://cdn.babylonjs.com/Assets/babylonLogo.png",t.style.width="150px",t.style.gridColumn="1",t.style.gridRow="1",t.style.top="50%",t.style.left="50%",t.style.transform="translate(-50%, -50%)",t.style.position="absolute";const s=document.createElement("div");s.style.width="300px",s.style.gridColumn="1",s.style.gridRow="1",s.style.top="50%",s.style.left="50%",s.style.transform="translate(-50%, -50%)",s.style.position="absolute";const i=new Image;if(r.DefaultSpinnerUrl?i.src=r.DefaultSpinnerUrl:i.src=e?"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzOTIgMzkyIj48ZGVmcz48c3R5bGU+LmNscy0xe2ZpbGw6I2UwNjg0Yjt9LmNscy0ye2ZpbGw6bm9uZTt9PC9zdHlsZT48L2RlZnM+PHRpdGxlPlNwaW5uZXJJY29uPC90aXRsZT48ZyBpZD0iTGF5ZXJfMiIgZGF0YS1uYW1lPSJMYXllciAyIj48ZyBpZD0iU3Bpbm5lciI+PHBhdGggY2xhc3M9ImNscy0xIiBkPSJNNDAuMjEsMTI2LjQzYzMuNy03LjMxLDcuNjctMTQuNDQsMTItMjEuMzJsMy4zNi01LjEsMy41Mi01YzEuMjMtMS42MywyLjQxLTMuMjksMy42NS00LjkxczIuNTMtMy4yMSwzLjgyLTQuNzlBMTg1LjIsMTg1LjIsMCwwLDEsODMuNCw2Ny40M2EyMDgsMjA4LDAsMCwxLDE5LTE1LjY2YzMuMzUtMi40MSw2Ljc0LTQuNzgsMTAuMjUtN3M3LjExLTQuMjgsMTAuNzUtNi4zMmM3LjI5LTQsMTQuNzMtOCwyMi41My0xMS40OSwzLjktMS43Miw3Ljg4LTMuMywxMi00LjY0YTEwNC4yMiwxMDQuMjIsMCwwLDEsMTIuNDQtMy4yMyw2Mi40NCw2Mi40NCwwLDAsMSwxMi43OC0xLjM5QTI1LjkyLDI1LjkyLDAsMCwxLDE5NiwyMS40NGE2LjU1LDYuNTUsMCwwLDEsMi4wNSw5LDYuNjYsNi42NiwwLDAsMS0xLjY0LDEuNzhsLS40MS4yOWEyMi4wNywyMi4wNywwLDAsMS01Ljc4LDMsMzAuNDIsMzAuNDIsMCwwLDEtNS42NywxLjYyLDM3LjgyLDM3LjgyLDAsMCwxLTUuNjkuNzFjLTEsMC0xLjkuMTgtMi44NS4yNmwtMi44NS4yNHEtNS43Mi41MS0xMS40OCwxLjFjLTMuODQuNC03LjcxLjgyLTExLjU4LDEuNGExMTIuMzQsMTEyLjM0LDAsMCwwLTIyLjk0LDUuNjFjLTMuNzIsMS4zNS03LjM0LDMtMTAuOTQsNC42NHMtNy4xNCwzLjUxLTEwLjYsNS41MUExNTEuNiwxNTEuNiwwLDAsMCw2OC41Niw4N0M2Ny4yMyw4OC40OCw2Niw5MCw2NC42NCw5MS41NnMtMi41MSwzLjE1LTMuNzUsNC43M2wtMy41NCw0LjljLTEuMTMsMS42Ni0yLjIzLDMuMzUtMy4zMyw1YTEyNywxMjcsMCwwLDAtMTAuOTMsMjEuNDksMS41OCwxLjU4LDAsMSwxLTMtMS4xNVM0MC4xOSwxMjYuNDcsNDAuMjEsMTI2LjQzWiIvPjxyZWN0IGNsYXNzPSJjbHMtMiIgd2lkdGg9IjM5MiIgaGVpZ2h0PSIzOTIiLz48L2c+PC9nPjwvc3ZnPg==":"https://cdn.babylonjs.com/Assets/loadingIcon.png",i.style.animation="spin1 0.75s infinite linear",i.style.transformOrigin="50% 50%",!e){const e={w:16,h:18.5},s={w:30,h:30};t.style.width=`${e.w}vh`,t.style.height=`${e.h}vh`,t.style.left=`calc(50% - ${e.w/2}vh)`,t.style.top=`calc(50% - ${e.h/2}vh)`,i.style.width=`${s.w}vh`,i.style.height=`${s.h}vh`,i.style.left=`calc(50% - ${s.w/2}vh)`,i.style.top=`calc(50% - ${s.h/2}vh)`}s.appendChild(i),this._loadingDiv.appendChild(t),this._loadingDiv.appendChild(s),this._resizeLoadingUI(),window.addEventListener("resize",this._resizeLoadingUI),this._loadingDiv.style.backgroundColor=this._loadingDivBackgroundColor,document.body.appendChild(this._loadingDiv),this._loadingDiv.style.opacity="1"}hideLoadingUI(){this._loadingDiv&&(this._loadingDiv.style.opacity="0",this._loadingDiv.addEventListener("transitionend",(()=>{this._loadingTextDiv&&(this._loadingTextDiv.remove(),this._loadingTextDiv=null),this._loadingDiv&&(this._loadingDiv.remove(),this._loadingDiv=null),this._style&&(this._style.remove(),this._style=null),window.removeEventListener("resize",this._resizeLoadingUI)})))}set loadingUIText(e){this._loadingText=e,this._loadingTextDiv&&(this._loadingTextDiv.innerHTML=this._loadingText)}get loadingUIText(){return this._loadingText}get loadingUIBackgroundColor(){return this._loadingDivBackgroundColor}set loadingUIBackgroundColor(e){this._loadingDivBackgroundColor=e,this._loadingDiv&&(this._loadingDiv.style.backgroundColor=this._loadingDivBackgroundColor)}}r.DefaultLogoUrl="",r.DefaultSpinnerUrl="",i.$.DefaultLoadingScreenFactory=e=>new r(e)},5909:(e,t,s)=>{s.d(t,{kS:()=>C,cH:()=>R});var i,r=s(998),n=s(9848),a=s(554),o=s(6315),h=s(1137),l=s(7597),c=s(655),u=s(8563),d=s(8688),_=s(6326),f=s(2366);!function(e){e[e.Clean=0]="Clean",e[e.Stop=1]="Stop",e[e.Sync=2]="Sync",e[e.NoSync=3]="NoSync"}(i||(i={}));const p=new n.cP,g={};let m=!1;function T(){return g[".babylon"]}function b(e,t){return g[e]||(h.V.Warn("Unable to find a plugin to load "+e+" files. Trying to use .babylon default plugin. To load from a specific filetype (eg. gltf) see: https://doc.babylonjs.com/features/featuresDeepDive/importers/loadingFileTypes"),t?T():void 0)}function E(e,t,s){let i="Unable to load from "+(e.rawData?"binary data":e.url);return t?i+=`: ${t}`:s&&(i+=`: ${s}`),i}async function x(e,t,s,i,r,n,a,o,h){const l="data:"===(u=e.url).substring(0,5)?u.substring(5):null;var u;if(e.rawData&&!a)throw"When using ArrayBufferView to load data the file extension must be provided.";const d=l||a?"":function(e){const t=e.indexOf("?");-1!==t&&(e=e.substring(0,t));const s=e.lastIndexOf(".");return e.substring(s,e.length).toLowerCase()}(e.url);let m=a?b(a,!0):l?function(e){for(const t in g){const s=g[t].plugin;if(s.canDirectLoad&&s.canDirectLoad(e))return g[t]}return T()}(e.url):b(d,!1);if(!m&&d){if(e.url&&!e.url.startsWith("blob:")){const t=await function(e,t){const s=t.method||"GET";return new Promise(((i,r)=>{const n=new f.u;n.addEventListener("readystatechange",(()=>{if(4==n.readyState)if(200==n.status){const e={};if(t.responseHeaders)for(const s of t.responseHeaders)e[s]=n.getResponseHeader(s)||"";i({response:n.response,headerValues:e})}else r(`Unable to fetch data from ${e}. Error code: ${n.status}`)})),n.open(s,e),n.send()}))}(e.url,{method:"HEAD",responseHeaders:["Content-Type"]}),s=t.headerValues?t.headerValues["Content-Type"]:"";s&&(m=function(e){for(const t in g){const s=g[t];if(s.mimeType===e)return s}}(s))}m||(m=T())}if(!m)throw new Error(`No plugin or fallback for ${a??e.url}`);if(!1===h?.[m.plugin.name]?.enabled)throw new Error(`The '${m.plugin.name}' plugin is disabled via the loader options passed to the loading operation.`);if(e.rawData&&!m.isBinary)throw"Loading from ArrayBufferView can not be used with plugins that don't support binary loading.";return(e=>{if(m.plugin.createPlugin){const t=m.plugin.createPlugin(h??{});return t instanceof Promise?(t.then(e).catch((e=>{r("Error instantiating plugin.",e)})),null):(e(t),t)}return e(m.plugin),m.plugin})((h=>{if(!h)throw`The loader plugin corresponding to the '${a}' file type has not been found. If using es6, please import the plugin you wish to use before.`;if(p.notifyObservers(h),l&&(h.canDirectLoad&&h.canDirectLoad(e.url)||!(0,c.f2)(e.url))){if(h.directLoad){const e=h.directLoad(t,l);e instanceof Promise?e.then((e=>{s(h,e)})).catch((e=>{r("Error in directLoad of _loadData: "+e,e)})):s(h,e)}else s(h,l);return}const u=m.isBinary,d=(e,i)=>{t.isDisposed?r("Scene has been disposed"):s(h,e,i)};let f=null,g=!1;h.onDisposeObservable?.add((()=>{g=!0,f&&(f.abort(),f=null),n()}));const T=()=>{if(g)return;const s=(e,t)=>{r(e?.statusText,t)};if(!h.loadFile&&e.rawData)throw"Plugin does not support loading ArrayBufferView.";f=h.loadFile?h.loadFile(t,e.rawData||e.file||e.url,e.rootUrl,d,i,u,s,o):t._loadFile(e.file||e.url,d,i,!0,u,s)},b=t.getEngine();let E=b.enableOfflineSupport;if(E){let s=!1;for(const i of t.disableOfflineSupportExceptionRules)if(i.test(e.url)){s=!0;break}E=!s}E&&_.$.OfflineProviderFactory?t.offlineProvider=_.$.OfflineProviderFactory(e.url,T,b.disableManifestCheck):T()}))}function A(e,t){let s,i,n=null,a=null;if(t)if(t.name)s=`file:${t.name}`,i=t.name,n=t;else if(ArrayBuffer.isView(t))s="",i=(0,d.z)(),a=t;else if(t.startsWith("data:"))s=t,i="";else if(e){const n=t;if("/"===n.substring(0,1))return r.S0.Error("Wrong sceneFilename parameter"),null;s=e+n,i=n}else s=t,i=r.S0.GetFilename(t),e=r.S0.GetFolderPath(t);else s=e,i=r.S0.GetFilename(e),e=r.S0.GetFolderPath(e);return{url:s,rootUrl:e,name:i,file:n,rawData:a}}function R(e){if("string"==typeof e.extensions){const t=e.extensions;g[t.toLowerCase()]={plugin:e,isBinary:!1}}else{const t=e.extensions;Object.keys(t).forEach((s=>{g[s.toLowerCase()]={plugin:e,isBinary:t[s].isBinary,mimeType:t[s].mimeType}}))}}async function M(e,t,s="",i=o.q.LastCreatedScene,r=null,n=null,a=null,l=null,c="",d={}){if(!i)return h.V.Error("No scene available to import mesh to"),null;const _=A(t,s);if(!_)return null;const f={};i.addPendingData(f);const p=()=>{i.removePendingData(f)},g=(e,t)=>{const s=E(_,e,t);a?a(i,s,new u.bu(s,u.tG.SceneLoaderError,t)):h.V.Error(s),p()},m=n?e=>{try{n(e)}catch(e){g("Error in onProgress callback: "+e,e)}}:void 0,T=(e,t,s,n,a,o,h,l)=>{if(i.importedMeshesFiles.push(_.url),r)try{r(e,t,s,n,a,o,h,l)}catch(e){g("Error in onSuccess callback: "+e,e)}i.removePendingData(f)};return await x(_,i,((t,s,r)=>{if(t.rewriteRootURL&&(_.rootUrl=t.rewriteRootURL(_.rootUrl,r)),t.importMesh){const r=[],n=[],a=[];if(!t.importMesh(e,i,s,_.rootUrl,r,n,a,g))return;i.loadingPluginName=t.name,T(r,n,a,[],[],[],[],[])}else t.importMeshAsync(e,i,s,_.rootUrl,m,_.name).then((e=>{i.loadingPluginName=t.name,T(e.meshes,e.particleSystems,e.skeletons,e.animationGroups,e.transformNodes,e.geometries,e.lights,e.spriteManagers)})).catch((e=>{g(e.message,e)}))}),m,g,p,l,c,d)}function y(e,t="",s=o.q.LastCreatedEngine,i=null,n=null,h=null,l=null,c="",u={}){s?P(e,t,new a.Z(s),i,n,h,l,c,u):r.S0.Error("No engine available")}async function P(e,t="",s=o.q.LastCreatedScene,i=null,r=null,n=null,a=null,c="",d={}){if(!s)return h.V.Error("No scene available to append to"),null;const _=A(e,t);if(!_)return null;const f={};s.addPendingData(f);const p=()=>{s.removePendingData(f)};l.B.ShowLoadingScreen&&!m&&(m=!0,s.getEngine().displayLoadingUI(),s.executeWhenReady((()=>{s.getEngine().hideLoadingUI(),m=!1})));const g=(e,t)=>{const i=E(_,e,t);n?n(s,i,new u.bu(i,u.tG.SceneLoaderError,t)):h.V.Error(i),p()},T=r?e=>{try{r(e)}catch(e){g("Error in onProgress callback",e)}}:void 0,b=()=>{if(i)try{i(s)}catch(e){g("Error in onSuccess callback",e)}s.removePendingData(f)};return await x(_,s,((e,t)=>{if(e.load){if(!e.load(s,t,_.rootUrl,g))return;s.loadingPluginName=e.name,b()}else e.loadAsync(s,t,_.rootUrl,T,_.name).then((()=>{s.loadingPluginName=e.name,b()})).catch((e=>{g(e.message,e)}))}),T,g,p,a,c,d)}async function v(e,t="",s=o.q.LastCreatedScene,i=null,r=null,n=null,a=null,l="",c={}){if(!s)return h.V.Error("No scene available to load asset container to"),null;const d=A(e,t);if(!d)return null;const _={};s.addPendingData(_);const f=()=>{s.removePendingData(_)},p=(e,t)=>{const i=E(d,e,t);n?n(s,i,new u.bu(i,u.tG.SceneLoaderError,t)):h.V.Error(i),f()},g=r?e=>{try{r(e)}catch(e){p("Error in onProgress callback",e)}}:void 0,m=e=>{if(i)try{i(e)}catch(e){p("Error in onSuccess callback",e)}s.removePendingData(_)};return await x(d,s,((e,t)=>{if(e.loadAssetContainer){const i=e.loadAssetContainer(s,t,d.rootUrl,p);if(!i)return;i.populateRootNodes(),s.loadingPluginName=e.name,m(i)}else e.loadAssetContainerAsync?e.loadAssetContainerAsync(s,t,d.rootUrl,g,d.name).then((t=>{t.populateRootNodes(),s.loadingPluginName=e.name,m(t)})).catch((e=>{p(e.message,e)})):p("LoadAssetContainer is not supported by this plugin. Plugin did not provide a loadAssetContainer or loadAssetContainerAsync method.")}),g,p,f,a,l,c)}function C(e,t,s){const{rootUrl:i="",onProgress:r,pluginExtension:n,name:a,pluginOptions:o}=s??{};return S(i,e,t,r,n,a,o)}function S(e,t,s,i,r,n,a){return new Promise(((o,h)=>{v(e,t,s,(e=>{o(e)}),i,((e,t,s)=>{h(s||new Error(t))}),r,n,a)}))}function I(e,t="",s=o.q.LastCreatedScene,i=!0,r=0,n=null,a=null,l=null,c=null,u=null,d="",_={}){if(!s)return void h.V.Error("No scene available to load animations to");if(i){for(const e of s.animatables)e.reset();s.stopAllAnimations(),s.animationGroups.slice().forEach((e=>{e.dispose()})),s.getNodes().forEach((e=>{e.animations&&(e.animations=[])}))}else switch(r){case 0:s.animationGroups.slice().forEach((e=>{e.dispose()}));break;case 1:s.animationGroups.forEach((e=>{e.stop()}));break;case 2:s.animationGroups.forEach((e=>{e.reset(),e.restart()}));break;case 3:break;default:return void h.V.Error("Unknown animation group loading mode value '"+r+"'")}const f=s.animatables.length;v(e,t,s,(e=>{e.mergeAnimationsTo(s,s.animatables.slice(f),n),e.dispose(),s.onAnimationFileImportedObservable.notifyObservers(s),a&&a(s)}),l,c,u,d,_)}class D{static get ForceFullSceneLoadingForIncremental(){return l.B.ForceFullSceneLoadingForIncremental}static set ForceFullSceneLoadingForIncremental(e){l.B.ForceFullSceneLoadingForIncremental=e}static get ShowLoadingScreen(){return l.B.ShowLoadingScreen}static set ShowLoadingScreen(e){l.B.ShowLoadingScreen=e}static get loggingLevel(){return l.B.loggingLevel}static set loggingLevel(e){l.B.loggingLevel=e}static get CleanBoneMatrixWeights(){return l.B.CleanBoneMatrixWeights}static set CleanBoneMatrixWeights(e){l.B.CleanBoneMatrixWeights=e}static GetDefaultPlugin(){return T()}static GetPluginForExtension(e){return b(e,!0)?.plugin}static IsPluginForExtensionAvailable(e){return function(e){return!!g[e]}(e)}static RegisterPlugin(e){R(e)}static ImportMesh(e,t,s,i,r,n,a,o,h){M(e,t,s,i,r,n,a,o,h)}static ImportMeshAsync(e,t,s,i,r,n,a){return function(e,t,s,i,r,n,a,o){return new Promise(((o,h)=>{M(e,t,s,i,((e,t,s,i,r,n,a,h)=>{o({meshes:e,particleSystems:t,skeletons:s,animationGroups:i,transformNodes:r,geometries:n,lights:a,spriteManagers:h})}),r,((e,t,s)=>{h(s||new Error(t))}),n,a,undefined)}))}(e,t,s,i,r,n,a)}static Load(e,t,s,i,r,n,a,o){y(e,t,s,i,r,n,a,o)}static LoadAsync(e,t,s,i,r,n){return function(e,t,s,i,r,n,a){return new Promise(((o,h)=>{y(e,t,s,(e=>{o(e)}),i,((e,t,s)=>{h(s||new Error(t))}),r,n,a)}))}(e,t,s,i,r,n)}static Append(e,t,s,i,r,n,a,o){P(e,t,s,i,r,n,a,o)}static AppendAsync(e,t,s,i,r,n){return function(e,t,s,i,r,n,a){return new Promise(((o,h)=>{P(e,t,s,(e=>{o(e)}),i,((e,t,s)=>{h(s||new Error(t))}),r,n,a)}))}(e,t,s,i,r,n)}static LoadAssetContainer(e,t,s,i,r,n,a,o){v(e,t,s,i,r,n,a,o)}static LoadAssetContainerAsync(e,t,s,i,r,n){return S(e,t,s,i,r,n)}static ImportAnimations(e,t,s,i,r,n,a,o,h,l,c){I(e,t,s,i,r,n,a,o,h,l,c)}static ImportAnimationsAsync(e,t,s,i,r,n,a,o,h,l,c){return function(e,t,s,i,r,n,a,o,h,l){return new Promise(((c,u)=>{I(e,t,s,i,r,n,(e=>{c(e)}),a,((e,t,s)=>{u(s||new Error(t))}),o,h,l)}))}(e,t,s,i,r,n,o,l,c)}}D.NO_LOGGING=0,D.MINIMAL_LOGGING=1,D.SUMMARY_LOGGING=2,D.DETAILED_LOGGING=3,D.OnPluginActivatedObservable=p},7597:(e,t,s)=>{s.d(t,{B:()=>i});class i{static get ForceFullSceneLoadingForIncremental(){return i._ForceFullSceneLoadingForIncremental}static set ForceFullSceneLoadingForIncremental(e){i._ForceFullSceneLoadingForIncremental=e}static get ShowLoadingScreen(){return i._ShowLoadingScreen}static set ShowLoadingScreen(e){i._ShowLoadingScreen=e}static get loggingLevel(){return i._LoggingLevel}static set loggingLevel(e){i._LoggingLevel=e}static get CleanBoneMatrixWeights(){return i._CleanBoneMatrixWeights}static set CleanBoneMatrixWeights(e){i._CleanBoneMatrixWeights=e}}i._ForceFullSceneLoadingForIncremental=!1,i._ShowLoadingScreen=!0,i._CleanBoneMatrixWeights=!1,i._LoggingLevel=0},994:(e,t,s)=>{s.r(t),s.d(t,{_DDSTextureLoader:()=>n});var i=s(4640),r=s(3537);class n{constructor(){this.supportCascades=!0}loadCubeData(e,t,s,n){const a=t.getEngine();let o,h=!1,l=1e3;if(Array.isArray(e))for(let s=0;s1)&&t.generateMipMaps,a._unpackFlipY(o.isCompressed),r.D.UploadDDSLevels(a,t,i,o,h,6,-1,s),o.isFourCC||1!==o.mipmapCount?l=o.mipmapCount-1:a.generateMipMapsForCubemap(t)}else{const n=e;o=r.D.GetDDSInfo(n),t.width=o.width,t.height=o.height,s&&(o.sphericalPolynomial=new i.Q),h=(o.isRGB||o.isLuminance||o.mipmapCount>1)&&t.generateMipMaps,a._unpackFlipY(o.isCompressed),r.D.UploadDDSLevels(a,t,n,o,h,6),o.isFourCC||1!==o.mipmapCount?l=o.mipmapCount-1:a.generateMipMapsForCubemap(t,!1)}a._setCubeMapTextureParams(t,h,l),t.isReady=!0,t.onLoadedObservable.notifyObservers(t),t.onLoadedObservable.clear(),n&&n({isDDS:!0,width:t.width,info:o,data:e,texture:t})}loadData(e,t,s){const i=r.D.GetDDSInfo(e),n=(i.isRGB||i.isLuminance||i.mipmapCount>1)&&t.generateMipMaps&&Math.max(i.width,i.height)>>i.mipmapCount-1==1;s(i.width,i.height,n,i.isFourCC,(()=>{r.D.UploadDDSLevels(t.getEngine(),t,e,i,n,1)}))}}},8454:(e,t,s)=>{s.d(t,{gT:()=>a});var i=s(1137);const r=new Map;function n(e,t){(function(e){return r.delete(e)})(e)&&i.V.Warn(`Extension with the name '${name}' already exists`),r.set(e,t)}function a(e,t){"image/ktx"!==t&&"image/ktx2"!==t||(e=".ktx"),r.has(e)||(e.endsWith(".dds")&&n(".dds",(()=>Promise.resolve().then(s.bind(s,994)).then((e=>new e._DDSTextureLoader)))),e.endsWith(".basis")&&n(".basis",(()=>s.e(692).then(s.bind(s,6692)).then((e=>new e._BasisTextureLoader)))),e.endsWith(".env")&&n(".env",(()=>s.e(834).then(s.bind(s,5834)).then((e=>new e._ENVTextureLoader)))),e.endsWith(".hdr")&&n(".hdr",(()=>s.e(608).then(s.bind(s,5608)).then((e=>new e._HDRTextureLoader)))),(e.endsWith(".ktx")||e.endsWith(".ktx2"))&&(n(".ktx",(()=>s.e(788).then(s.bind(s,788)).then((e=>new e._KTXTextureLoader)))),n(".ktx2",(()=>s.e(788).then(s.bind(s,788)).then((e=>new e._KTXTextureLoader))))),e.endsWith(".tga")&&n(".tga",(()=>Promise.resolve().then(s.bind(s,1318)).then((e=>new e._TGATextureLoader)))),e.endsWith(".exr")&&n(".exr",(()=>s.e(685).then(s.bind(s,8685)).then((e=>new e._ExrTextureLoader)))));const i=r.get(e);return i?Promise.resolve(i(t)):null}},1318:(e,t,s)=>{s.r(t),s.d(t,{_TGATextureLoader:()=>o});var i=s(1137);function r(e){let t=0;return{id_length:e[t++],colormap_type:e[t++],image_type:e[t++],colormap_index:e[t++]|e[t++]<<8,colormap_length:e[t++]|e[t++]<<8,colormap_size:e[t++],origin:[e[t++]|e[t++]<<8,e[t++]|e[t++]<<8],width:e[t++]|e[t++]<<8,height:e[t++]|e[t++]<<8,pixel_size:e[t++],flags:e[t++]}}function n(e,t){if(t.length<19)return void i.V.Error("Unable to load TGA file - Not enough data to contain header");let s=18;const n=r(t);if(n.id_length+s>t.length)return void i.V.Error("Unable to load TGA file - Not enough data");s+=n.id_length;let o,h=!1,l=!1,c=!1;switch(n.image_type){case 9:h=!0;case 1:l=!0;break;case 10:h=!0;case 2:break;case 11:h=!0;case 3:c=!0}const u=n.pixel_size>>3,d=n.width*n.height*u;let _,f,p,g,m,T,b;if(l&&(_=t.subarray(s,s+=n.colormap_length*(n.colormap_size>>3))),h){let e,i,r;o=new Uint8Array(d);let n=0;const a=new Uint8Array(u);for(;s>4){default:case 2:f=0,g=1,b=n.width,p=0,m=1,T=n.height;break;case 0:f=0,g=1,b=n.width,p=n.height-1,m=-1,T=-1;break;case 3:f=n.width-1,g=-1,b=-1,p=0,m=1,T=n.height;break;case 1:f=n.width-1,g=-1,b=-1,p=n.height-1,m=-1,T=-1}const E="_getImageData"+(c?"Grey":"")+n.pixel_size+"bits",x=a[E](n,_,o,p,m,T,f,g,b);e.getEngine()._uploadDataToTextureDirectly(e,x)}const a={GetTGAHeader:r,UploadContent:n,_getImageData8bits:function(e,t,s,i,r,n,a,o,h){const l=s,c=t,u=e.width,d=e.height;let _,f,p,g=0;const m=new Uint8Array(u*d*4);for(p=i;p!==n;p+=r)for(f=a;f!==h;f+=o,g++)_=l[g],m[4*(f+u*p)+3]=255,m[4*(f+u*p)+2]=c[3*_+0],m[4*(f+u*p)+1]=c[3*_+1],m[4*(f+u*p)+0]=c[3*_+2];return m},_getImageData16bits:function(e,t,s,i,r,n,a,o,h){const l=s,c=e.width,u=e.height;let d,_,f,p=0;const g=new Uint8Array(c*u*4);for(f=i;f!==n;f+=r)for(_=a;_!==h;_+=o,p+=2){d=l[p+0]+(l[p+1]<<8);const e=255*((31744&d)>>10)/31|0,t=255*((992&d)>>5)/31|0,s=255*(31&d)/31|0;g[4*(_+c*f)+0]=e,g[4*(_+c*f)+1]=t,g[4*(_+c*f)+2]=s,g[4*(_+c*f)+3]=32768&d?0:255}return g},_getImageData24bits:function(e,t,s,i,r,n,a,o,h){const l=s,c=e.width,u=e.height;let d,_,f=0;const p=new Uint8Array(c*u*4);for(_=i;_!==n;_+=r)for(d=a;d!==h;d+=o,f+=3)p[4*(d+c*_)+3]=255,p[4*(d+c*_)+2]=l[f+0],p[4*(d+c*_)+1]=l[f+1],p[4*(d+c*_)+0]=l[f+2];return p},_getImageData32bits:function(e,t,s,i,r,n,a,o,h){const l=s,c=e.width,u=e.height;let d,_,f=0;const p=new Uint8Array(c*u*4);for(_=i;_!==n;_+=r)for(d=a;d!==h;d+=o,f+=4)p[4*(d+c*_)+2]=l[f+0],p[4*(d+c*_)+1]=l[f+1],p[4*(d+c*_)+0]=l[f+2],p[4*(d+c*_)+3]=l[f+3];return p},_getImageDataGrey8bits:function(e,t,s,i,r,n,a,o,h){const l=s,c=e.width,u=e.height;let d,_,f,p=0;const g=new Uint8Array(c*u*4);for(f=i;f!==n;f+=r)for(_=a;_!==h;_+=o,p++)d=l[p],g[4*(_+c*f)+0]=d,g[4*(_+c*f)+1]=d,g[4*(_+c*f)+2]=d,g[4*(_+c*f)+3]=255;return g},_getImageDataGrey16bits:function(e,t,s,i,r,n,a,o,h){const l=s,c=e.width,u=e.height;let d,_,f=0;const p=new Uint8Array(c*u*4);for(_=i;_!==n;_+=r)for(d=a;d!==h;d+=o,f+=2)p[4*(d+c*_)+0]=l[f+0],p[4*(d+c*_)+1]=l[f+0],p[4*(d+c*_)+2]=l[f+0],p[4*(d+c*_)+3]=l[f+1];return p}};class o{constructor(){this.supportCascades=!1}loadCubeData(){throw".env not supported in Cube."}loadData(e,t,s){const i=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),a=r(i);s(a.width,a.height,t.generateMipMaps,!1,(()=>{n(t,i)}))}}},2667:(e,t,s)=>{s.d(t,{t:()=>d});var i=s(5524),r=s(9259),n=s(9848),a=s(9923),o=s(6315),h=s(8688),l=(s(655),s(521));class c{get wrapU(){return this._wrapU}set wrapU(e){this._wrapU=e}get wrapV(){return this._wrapV}set wrapV(e){this._wrapV=e}get coordinatesMode(){return 0}get isCube(){return!!this._texture&&this._texture.isCube}set isCube(e){this._texture&&(this._texture.isCube=e)}get is3D(){return!!this._texture&&this._texture.is3D}set is3D(e){this._texture&&(this._texture.is3D=e)}get is2DArray(){return!!this._texture&&this._texture.is2DArray}set is2DArray(e){this._texture&&(this._texture.is2DArray=e)}getClassName(){return"ThinTexture"}static _IsRenderTargetWrapper(e){return void 0!==e?.shareDepth}constructor(e){this._wrapU=1,this._wrapV=1,this.wrapR=1,this.anisotropicFilteringLevel=4,this.delayLoadState=0,this._texture=null,this._engine=null,this._cachedSize=l.o.Zero(),this._cachedBaseSize=l.o.Zero(),this._initialSamplingMode=2,this._texture=c._IsRenderTargetWrapper(e)?e.texture:e,this._texture&&(this._engine=this._texture.getEngine())}isReady(){return 4===this.delayLoadState?(this.delayLoad(),!1):!!this._texture&&this._texture.isReady}delayLoad(){}getInternalTexture(){return this._texture}getSize(){if(this._texture){if(this._texture.width)return this._cachedSize.width=this._texture.width,this._cachedSize.height=this._texture.height,this._cachedSize;if(this._texture._size)return this._cachedSize.width=this._texture._size,this._cachedSize.height=this._texture._size,this._cachedSize}return this._cachedSize}getBaseSize(){return this.isReady()&&this._texture?this._texture._size?(this._cachedBaseSize.width=this._texture._size,this._cachedBaseSize.height=this._texture._size,this._cachedBaseSize):(this._cachedBaseSize.width=this._texture.baseWidth,this._cachedBaseSize.height=this._texture.baseHeight,this._cachedBaseSize):(this._cachedBaseSize.width=0,this._cachedBaseSize.height=0,this._cachedBaseSize)}get samplingMode(){return this._texture?this._texture.samplingMode:this._initialSamplingMode}updateSamplingMode(e){this._texture&&this._engine&&this._engine.updateTextureSamplingMode(e,this._texture)}releaseInternalTexture(){this._texture&&(this._texture.dispose(),this._texture=null)}dispose(){this._texture&&(this.releaseInternalTexture(),this._engine=null)}}var u=s(6877);class d extends c{set hasAlpha(e){this._hasAlpha!==e&&(this._hasAlpha=e,this._scene&&this._scene.markAllMaterialsAsDirty(1,(e=>e.hasTexture(this))))}get hasAlpha(){return this._hasAlpha}set getAlphaFromRGB(e){this._getAlphaFromRGB!==e&&(this._getAlphaFromRGB=e,this._scene&&this._scene.markAllMaterialsAsDirty(1,(e=>e.hasTexture(this))))}get getAlphaFromRGB(){return this._getAlphaFromRGB}set coordinatesIndex(e){this._coordinatesIndex!==e&&(this._coordinatesIndex=e,this._scene&&this._scene.markAllMaterialsAsDirty(1,(e=>e.hasTexture(this))))}get coordinatesIndex(){return this._coordinatesIndex}set coordinatesMode(e){this._coordinatesMode!==e&&(this._coordinatesMode=e,this._scene&&this._scene.markAllMaterialsAsDirty(1,(e=>e.hasTexture(this))))}get coordinatesMode(){return this._coordinatesMode}get wrapU(){return this._wrapU}set wrapU(e){this._wrapU=e}get wrapV(){return this._wrapV}set wrapV(e){this._wrapV=e}get isCube(){return this._texture?this._texture.isCube:this._isCube}set isCube(e){this._texture?this._texture.isCube=e:this._isCube=e}get is3D(){return!!this._texture&&this._texture.is3D}set is3D(e){this._texture&&(this._texture.is3D=e)}get is2DArray(){return!!this._texture&&this._texture.is2DArray}set is2DArray(e){this._texture&&(this._texture.is2DArray=e)}get gammaSpace(){return this._texture?(null===this._texture._gammaSpace&&(this._texture._gammaSpace=this._gammaSpace),this._texture._gammaSpace&&!this._texture._useSRGBBuffer):this._gammaSpace}set gammaSpace(e){if(this._texture){if(this._texture._gammaSpace===e)return;this._texture._gammaSpace=e}else{if(this._gammaSpace===e)return;this._gammaSpace=e}this.getScene()?.markAllMaterialsAsDirty(1,(e=>e.hasTexture(this)))}get isRGBD(){return null!=this._texture&&this._texture._isRGBD}set isRGBD(e){e!==this.isRGBD&&(this._texture&&(this._texture._isRGBD=e),this.getScene()?.markAllMaterialsAsDirty(1,(e=>e.hasTexture(this))))}get noMipmap(){return!1}get lodGenerationOffset(){return this._texture?this._texture._lodGenerationOffset:0}set lodGenerationOffset(e){this._texture&&(this._texture._lodGenerationOffset=e)}get lodGenerationScale(){return this._texture?this._texture._lodGenerationScale:0}set lodGenerationScale(e){this._texture&&(this._texture._lodGenerationScale=e)}get linearSpecularLOD(){return!!this._texture&&this._texture._linearSpecularLOD}set linearSpecularLOD(e){this._texture&&(this._texture._linearSpecularLOD=e)}get irradianceTexture(){return this._texture?this._texture._irradianceTexture:null}set irradianceTexture(e){this._texture&&(this._texture._irradianceTexture=e)}get uid(){return this._uid||(this._uid=(0,h.z)()),this._uid}toString(){return this.name}getClassName(){return"BaseTexture"}set onDispose(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)}get isBlocking(){return!0}get loadingError(){return this._loadingError}get errorObject(){return this._errorObject}constructor(e,t=null){super(null),this.metadata=null,this.reservedDataStore=null,this._hasAlpha=!1,this._getAlphaFromRGB=!1,this.level=1,this._coordinatesIndex=0,this.optimizeUVAllocation=!0,this._coordinatesMode=0,this.wrapR=1,this.anisotropicFilteringLevel=d.DEFAULT_ANISOTROPIC_FILTERING_LEVEL,this._isCube=!1,this._gammaSpace=!0,this.invertZ=!1,this.lodLevelInAlpha=!1,this.isRenderTarget=!1,this._prefiltered=!1,this._forceSerialize=!1,this.animations=[],this.onDisposeObservable=new n.cP,this._onDisposeObserver=null,this._scene=null,this._uid=null,this._parentContainer=null,this._loadingError=!1,e?d._IsScene(e)?this._scene=e:this._engine=e:this._scene=o.q.LastCreatedScene,this._scene&&(this.uniqueId=this._scene.getUniqueId(),this._scene.addTexture(this),this._engine=this._scene.getEngine()),this._texture=t,this._uid=null}getScene(){return this._scene}_getEngine(){return this._engine}getTextureMatrix(){return a.uq.IdentityReadOnly}getReflectionTextureMatrix(){return a.uq.IdentityReadOnly}getRefractionTextureMatrix(){return this.getReflectionTextureMatrix()}isReadyOrNotBlocking(){return!this.isBlocking||this.isReady()||this.loadingError}scale(e){}get canRescale(){return!1}_getFromCache(e,t,s,i,r,n){const a=this._getEngine();if(!a)return null;const o=a._getUseSRGBBuffer(!!r,t),h=a.getLoadedTexturesCache();for(let a=0;a=0&&this._scene.textures.splice(e,1),this._scene.onTextureRemovedObservable.notifyObservers(this),this._scene=null,this._parentContainer){const e=this._parentContainer.textures.indexOf(this);e>-1&&this._parentContainer.textures.splice(e,1),this._parentContainer=null}}this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.metadata=null,super.dispose()}serialize(e=!1){if(!this.name&&!e)return null;const t=u.p.Serialize(this);return u.p.AppendSerializedAnimations(this,t),t}static WhenAllReady(e,t){let s=e.length;if(0!==s)for(let i=0;i{0==--s&&t()})):0==--s&&t()}}else t()}static _IsScene(e){return"Scene"===e.getClassName()}}d.DEFAULT_ANISOTROPIC_FILTERING_LEVEL=4,(0,i.Cg)([(0,r.lK)()],d.prototype,"uniqueId",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"name",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"displayName",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"metadata",void 0),(0,i.Cg)([(0,r.lK)("hasAlpha")],d.prototype,"_hasAlpha",void 0),(0,i.Cg)([(0,r.lK)("getAlphaFromRGB")],d.prototype,"_getAlphaFromRGB",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"level",void 0),(0,i.Cg)([(0,r.lK)("coordinatesIndex")],d.prototype,"_coordinatesIndex",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"optimizeUVAllocation",void 0),(0,i.Cg)([(0,r.lK)("coordinatesMode")],d.prototype,"_coordinatesMode",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"wrapU",null),(0,i.Cg)([(0,r.lK)()],d.prototype,"wrapV",null),(0,i.Cg)([(0,r.lK)()],d.prototype,"wrapR",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"anisotropicFilteringLevel",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"isCube",null),(0,i.Cg)([(0,r.lK)()],d.prototype,"is3D",null),(0,i.Cg)([(0,r.lK)()],d.prototype,"is2DArray",null),(0,i.Cg)([(0,r.lK)()],d.prototype,"gammaSpace",null),(0,i.Cg)([(0,r.lK)()],d.prototype,"invertZ",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"lodLevelInAlpha",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"lodGenerationOffset",null),(0,i.Cg)([(0,r.lK)()],d.prototype,"lodGenerationScale",null),(0,i.Cg)([(0,r.lK)()],d.prototype,"linearSpecularLOD",null),(0,i.Cg)([(0,r.uM)()],d.prototype,"irradianceTexture",null),(0,i.Cg)([(0,r.lK)()],d.prototype,"isRenderTarget",void 0)},854:(e,t,s)=>{s.d(t,{h:()=>a});var i,r=s(9848);class n{get wrapU(){return this._cachedWrapU}set wrapU(e){this._cachedWrapU=e}get wrapV(){return this._cachedWrapV}set wrapV(e){this._cachedWrapV=e}get wrapR(){return this._cachedWrapR}set wrapR(e){this._cachedWrapR=e}get anisotropicFilteringLevel(){return this._cachedAnisotropicFilteringLevel}set anisotropicFilteringLevel(e){this._cachedAnisotropicFilteringLevel=e}get comparisonFunction(){return this._comparisonFunction}set comparisonFunction(e){this._comparisonFunction=e}get useMipMaps(){return this._useMipMaps}set useMipMaps(e){this._useMipMaps=e}constructor(){this.samplingMode=-1,this._useMipMaps=!0,this._cachedWrapU=null,this._cachedWrapV=null,this._cachedWrapR=null,this._cachedAnisotropicFilteringLevel=null,this._comparisonFunction=0}setParameters(e=1,t=1,s=1,i=1,r=2,n=0){return this._cachedWrapU=e,this._cachedWrapV=t,this._cachedWrapR=s,this._cachedAnisotropicFilteringLevel=i,this.samplingMode=r,this._comparisonFunction=n,this}compareSampler(e){return this._cachedWrapU===e._cachedWrapU&&this._cachedWrapV===e._cachedWrapV&&this._cachedWrapR===e._cachedWrapR&&this._cachedAnisotropicFilteringLevel===e._cachedAnisotropicFilteringLevel&&this.samplingMode===e.samplingMode&&this._comparisonFunction===e._comparisonFunction&&this._useMipMaps===e._useMipMaps}}!function(e){e[e.Unknown=0]="Unknown",e[e.Url=1]="Url",e[e.Temp=2]="Temp",e[e.Raw=3]="Raw",e[e.Dynamic=4]="Dynamic",e[e.RenderTarget=5]="RenderTarget",e[e.MultiRenderTarget=6]="MultiRenderTarget",e[e.Cube=7]="Cube",e[e.CubeRaw=8]="CubeRaw",e[e.CubePrefiltered=9]="CubePrefiltered",e[e.Raw3D=10]="Raw3D",e[e.Raw2DArray=11]="Raw2DArray",e[e.DepthStencil=12]="DepthStencil",e[e.CubeRawRGBD=13]="CubeRawRGBD",e[e.Depth=14]="Depth"}(i||(i={}));class a extends n{get useMipMaps(){return this.generateMipMaps}set useMipMaps(e){this.generateMipMaps=e}get uniqueId(){return this._uniqueId}_setUniqueId(e){this._uniqueId=e}getEngine(){return this._engine}get source(){return this._source}constructor(e,t,s=!1){super(),this.isReady=!1,this.isCube=!1,this.is3D=!1,this.is2DArray=!1,this.isMultiview=!1,this.url="",this.generateMipMaps=!1,this.samples=0,this.type=-1,this.format=-1,this.onLoadedObservable=new r.cP,this.onErrorObservable=new r.cP,this.onRebuildCallback=null,this.width=0,this.height=0,this.depth=0,this.baseWidth=0,this.baseHeight=0,this.baseDepth=0,this.invertY=!1,this._invertVScale=!1,this._associatedChannel=-1,this._source=0,this._buffer=null,this._bufferView=null,this._bufferViewArray=null,this._bufferViewArrayArray=null,this._size=0,this._extension="",this._files=null,this._workingCanvas=null,this._workingContext=null,this._cachedCoordinatesMode=null,this._isDisabled=!1,this._compression=null,this._sphericalPolynomial=null,this._sphericalPolynomialPromise=null,this._sphericalPolynomialComputed=!1,this._lodGenerationScale=0,this._lodGenerationOffset=0,this._useSRGBBuffer=!1,this._creationFlags=0,this._lodTextureHigh=null,this._lodTextureMid=null,this._lodTextureLow=null,this._isRGBD=!1,this._linearSpecularLOD=!1,this._irradianceTexture=null,this._hardwareTexture=null,this._maxLodLevel=null,this._references=1,this._gammaSpace=null,this._premulAlpha=!1,this._dynamicTextureSource=null,this._engine=e,this._source=t,this._uniqueId=a._Counter++,s||(this._hardwareTexture=e._createHardwareTexture())}incrementReferences(){this._references++}updateSize(e,t,s=1){this._engine.updateTextureDimensions(this,e,t,s),this.width=e,this.height=t,this.depth=s,this.baseWidth=e,this.baseHeight=t,this.baseDepth=s,this._size=e*t*s}_rebuild(){if(this.isReady=!1,this._cachedCoordinatesMode=null,this._cachedWrapU=null,this._cachedWrapV=null,this._cachedWrapR=null,this._cachedAnisotropicFilteringLevel=null,this.onRebuildCallback){const e=this.onRebuildCallback(this),t=t=>{t._swapAndDie(this,!1),this.isReady=e.isReady};return void(e.isAsync?e.proxy.then(t):t(e.proxy))}let e;switch(this.source){case 2:case 12:case 14:break;case 1:return void(e=this._engine.createTexture(this._originalUrl??this.url,!this.generateMipMaps,this.invertY,null,this.samplingMode,(e=>{e._swapAndDie(this,!1),this.isReady=!0}),null,this._buffer,void 0,this.format,this._extension,void 0,void 0,void 0,this._useSRGBBuffer));case 3:e=this._engine.createRawTexture(this._bufferView,this.baseWidth,this.baseHeight,this.format,this.generateMipMaps,this.invertY,this.samplingMode,this._compression,this.type,this._creationFlags,this._useSRGBBuffer),e._swapAndDie(this,!1),this.isReady=!0;break;case 10:e=this._engine.createRawTexture3D(this._bufferView,this.baseWidth,this.baseHeight,this.baseDepth,this.format,this.generateMipMaps,this.invertY,this.samplingMode,this._compression,this.type),e._swapAndDie(this,!1),this.isReady=!0;break;case 11:e=this._engine.createRawTexture2DArray(this._bufferView,this.baseWidth,this.baseHeight,this.baseDepth,this.format,this.generateMipMaps,this.invertY,this.samplingMode,this._compression,this.type),e._swapAndDie(this,!1),this.isReady=!0;break;case 4:e=this._engine.createDynamicTexture(this.baseWidth,this.baseHeight,this.generateMipMaps,this.samplingMode),e._swapAndDie(this,!1),this._dynamicTextureSource&&this._engine.updateDynamicTexture(this,this._dynamicTextureSource,this.invertY,this._premulAlpha,this.format,!0);break;case 7:return void(e=this._engine.createCubeTexture(this.url,null,this._files,!this.generateMipMaps,(()=>{e._swapAndDie(this,!1),this.isReady=!0}),null,this.format,this._extension,!1,0,0,null,void 0,this._useSRGBBuffer,ArrayBuffer.isView(this._buffer)?this._buffer:null));case 8:e=this._engine.createRawCubeTexture(this._bufferViewArray,this.width,this._originalFormat??this.format,this.type,this.generateMipMaps,this.invertY,this.samplingMode,this._compression),e._swapAndDie(this,!1),this.isReady=!0;break;case 13:return;case 9:return e=this._engine.createPrefilteredCubeTexture(this.url,null,this._lodGenerationScale,this._lodGenerationOffset,(e=>{e&&e._swapAndDie(this,!1),this.isReady=!0}),null,this.format,this._extension),void(e._sphericalPolynomial=this._sphericalPolynomial)}}_swapAndDie(e,t=!0){this._hardwareTexture?.setUsage(e._source,this.generateMipMaps,this.is2DArray,this.isCube,this.is3D,this.width,this.height,this.depth),e._hardwareTexture=this._hardwareTexture,t&&(e._isRGBD=this._isRGBD),this._lodTextureHigh&&(e._lodTextureHigh&&e._lodTextureHigh.dispose(),e._lodTextureHigh=this._lodTextureHigh),this._lodTextureMid&&(e._lodTextureMid&&e._lodTextureMid.dispose(),e._lodTextureMid=this._lodTextureMid),this._lodTextureLow&&(e._lodTextureLow&&e._lodTextureLow.dispose(),e._lodTextureLow=this._lodTextureLow),this._irradianceTexture&&(e._irradianceTexture&&e._irradianceTexture.dispose(),e._irradianceTexture=this._irradianceTexture);const s=this._engine.getLoadedTexturesCache();let i=s.indexOf(this);-1!==i&&s.splice(i,1),i=s.indexOf(e),-1===i&&s.push(e)}dispose(){this._references--,this.onLoadedObservable.clear(),this.onErrorObservable.clear(),0===this._references&&(this._engine._releaseTexture(this),this._hardwareTexture=null,this._dynamicTextureSource=null)}}a._Counter=0},6882:(e,t,s)=>{s.d(t,{$:()=>_});var i=s(9848),r=s(9923),n=s(2781),a=s(6096),o=s(1597),h=s(4420),l=s(1137),c=s(3099),u=s(7309);class d{get renderList(){return this._renderList}set renderList(e){this._renderList!==e&&(this._unObserveRenderList&&(this._unObserveRenderList(),this._unObserveRenderList=null),e&&(this._unObserveRenderList=(0,u.lL)(e,this._renderListHasChanged)),this._renderList=e)}get renderPassIds(){return this._renderPassIds}get currentRefreshId(){return this._currentRefreshId}setMaterialForRendering(e,t){let s;s=Array.isArray(e)?e:[e];for(let e=0;e{const s=this._renderList?this._renderList.length:0;(0===t&&s>0||0===s)&&this._scene.meshes.forEach((e=>{e._markSubMeshesAsLightDirty()}))},this.particleSystemList=null,this.getCustomRenderList=null,this.renderParticles=!0,this.renderSprites=!1,this.forceLayerMaskCheck=!1,this.onBeforeRenderObservable=new i.cP,this.onAfterRenderObservable=new i.cP,this.onBeforeRenderingManagerRenderObservable=new i.cP,this.onAfterRenderingManagerRenderObservable=new i.cP,this.onFastPathRenderObservable=new i.cP,this._currentRefreshId=-1,this._refreshRate=1,this._currentSceneCamera=null,this.name=e,this._scene=t,this.renderList=[],this._renderPassIds=[],this.options={numPasses:1,doNotChangeAspectRatio:!0,...s},this._createRenderPassId(),this.renderPassId=this._renderPassIds[0],this._renderingManager=new c.m(t),this._renderingManager._useSceneAutoClearSetup=!0}_releaseRenderPassId(){const e=this._scene.getEngine();for(let t=0;t1&&(e.incrementRenderId(),e.resetCachedMaterial())}const n=this.particleSystemList||e.particleSystems;for(const e of n)e.isReady()||(i=!1);return t.currentRenderPassId=s,i}_prepareRenderingManager(e,t,s){const i=this._scene,r=i.activeCamera;this._renderingManager.reset();const n=i.getRenderId();for(let a=0;a{for(const e of this._scene._beforeRenderTargetClearStage)e.action(this,this._currentFaceIndex,this._currentLayer);this.onClearObservable.hasObservers()?this.onClearObservable.notifyObservers(M):this.skipInitialClear||M.clear(this.clearColor||this._scene.clearColor,!0,!0,!0),this._doNotChangeAspectRatio||this._scene.updateTransformMatrix(!0);for(const e of this._scene._beforeRenderTargetDrawStage)e.action(this,this._currentFaceIndex,this._currentLayer)})),this._objectRenderer.onAfterRenderingManagerRenderObservable.add((()=>{for(const e of this._scene._afterRenderTargetDrawStage)e.action(this,this._currentFaceIndex,this._currentLayer);const e=this._texture?.generateMipMaps??!1;this._texture&&(this._texture.generateMipMaps=!1),this._postProcessManager?this._postProcessManager._finalizeFrame(!1,this._renderTarget??void 0,this._currentFaceIndex,this._postProcesses,this.ignoreCameraViewport):this._currentUseCameraPostProcess&&this._scene.postProcessManager._finalizeFrame(!1,this._renderTarget??void 0,this._currentFaceIndex);for(const e of this._scene._afterRenderTargetPostProcessStage)e.action(this,this._currentFaceIndex,this._currentLayer);this._texture&&(this._texture.generateMipMaps=e),this._doNotChangeAspectRatio||this._scene.updateTransformMatrix(!0),this._currentDumpForDebug&&(this._dumpTools?this._dumpTools.DumpFramebuffer(this.getRenderWidth(),this.getRenderHeight(),M):l.V.Error("dumpTools module is still being loaded. To speed up the process import dump tools directly in your project"))})),this._objectRenderer.onFastPathRenderObservable.add((()=>{this.onClearObservable.hasObservers()?this.onClearObservable.notifyObservers(M):this.skipInitialClear||M.clear(this.clearColor||this._scene.clearColor,!0,!0,!0)})),this._resizeObserver=M.onResizeObservable.add((()=>{})),this._generateMipMaps=!!a,this._doNotChangeAspectRatio=o,p||(this._renderTargetOptions={generateMipMaps:a,type:h,format:this._format??void 0,samplingMode:this.samplingMode,generateDepthBuffer:_,generateStencilBuffer:f,samples:T,creationFlags:b,noColorAttachment:E,useSRGBBuffer:x,colorAttachment:A,label:this.name},this.samplingMode===n.g.NEAREST_SAMPLINGMODE&&(this.wrapU=n.g.CLAMP_ADDRESSMODE,this.wrapV=n.g.CLAMP_ADDRESSMODE),m||(c?(this._renderTarget=s.getEngine().createRenderTargetCubeTexture(this.getRenderSize(),this._renderTargetOptions),this.coordinatesMode=n.g.INVCUBIC_MODE,this._textureMatrix=r.uq.Identity()):this._renderTarget=s.getEngine().createRenderTargetTexture(this._size,this._renderTargetOptions),this._texture=this._renderTarget.texture,void 0!==T&&(this.samples=T)))}createDepthStencilTexture(e=0,t=!0,s=!1,i=1,r=14,n){this._renderTarget?.createDepthStencilTexture(e,t,s,i,r,n)}_processSizeParameter(e){if(e.ratio){this._sizeRatio=e.ratio;const t=this._getEngine();this._size={width:this._bestReflectionRenderTargetDimension(t.getRenderWidth(),this._sizeRatio),height:this._bestReflectionRenderTargetDimension(t.getRenderHeight(),this._sizeRatio)}}else this._size=e}get samples(){return this._renderTarget?.samples??this._samples}set samples(e){this._renderTarget&&(this._samples=this._renderTarget.setSamples(e))}addPostProcess(e){if(!this._postProcessManager){const e=this.getScene();if(!e)return;this._postProcessManager=new a.X(e),this._postProcesses=new Array}this._postProcesses.push(e),this._postProcesses[0].autoClear=!1}clearPostProcesses(e=!1){if(this._postProcesses){if(e)for(const e of this._postProcesses)e.dispose();this._postProcesses=[]}}removePostProcess(e){if(!this._postProcesses)return;const t=this._postProcesses.indexOf(e);-1!==t&&(this._postProcesses.splice(t,1),this._postProcesses.length>0&&(this._postProcesses[0].autoClear=!1))}resetRefreshCounter(){this._objectRenderer.resetRefreshCounter()}get refreshRate(){return this._objectRenderer.refreshRate}set refreshRate(e){this._objectRenderer.refreshRate=e}_shouldRender(){return this._objectRenderer.shouldRender()}getRenderSize(){return this.getRenderWidth()}getRenderWidth(){return this._size.width?this._size.width:this._size}getRenderHeight(){return this._size.width?this._size.height:this._size}getRenderLayers(){const e=this._size.layers;if(e)return e;return this._size.depth||0}disableRescaling(){this._canRescale=!1}get canRescale(){return this._canRescale}scale(e){const t=Math.max(1,this.getRenderSize()*e);this.resize(t)}getReflectionTextureMatrix(){return this.isCube?this._textureMatrix:super.getReflectionTextureMatrix()}resize(e){const t=this.isCube;this._renderTarget?.dispose(),this._renderTarget=null;const s=this.getScene();s&&(this._processSizeParameter(e),this._renderTarget=t?s.getEngine().createRenderTargetCubeTexture(this.getRenderSize(),this._renderTargetOptions):s.getEngine().createRenderTargetTexture(this._size,this._renderTargetOptions),this._texture=this._renderTarget.texture,void 0!==this._renderTargetOptions.samples&&(this.samples=this._renderTargetOptions.samples),this.onResizeObservable.hasObservers()&&this.onResizeObservable.notifyObservers(this))}render(e=!1,t=!1){this._render(e,t)}isReadyForRendering(){this._dumpToolsLoading||(this._dumpToolsLoading=!0,s.e(928).then(s.bind(s,9928)).then((e=>this._dumpTools=e))),this._objectRenderer.prepareRenderList(),this.onBeforeBindObservable.notifyObservers(this),this._objectRenderer.initRender(this.getRenderWidth(),this.getRenderHeight());const e=this._objectRenderer._checkReadiness();return this.onAfterUnbindObservable.notifyObservers(this),this._objectRenderer.finishRender(),e}_render(e=!1,t=!1){const s=this.getScene();if(s){if(void 0!==this.useCameraPostProcesses&&(e=this.useCameraPostProcesses),this._objectRenderer.prepareRenderList(),this.onBeforeBindObservable.notifyObservers(this),this._objectRenderer.initRender(this.getRenderWidth(),this.getRenderHeight()),!this.is2DArray&&!this.is3D||this.isMulti)if(this.isCube&&!this.isMulti)for(let i=0;i<6;i++)this._renderToTarget(i,e,t),s.incrementRenderId(),s.resetCachedMaterial();else this._renderToTarget(0,e,t);else for(let i=0;i{this.onAfterRenderObservable.notifyObservers(t)}))}_prepareFrame(e,t,s,i){this._postProcessManager?this._prePassEnabled||this._postProcessManager._prepareFrame(this._texture,this._postProcesses):i&&e.postProcessManager._prepareFrame(this._texture)||this._bindFrameBuffer(t,s)}_renderToTarget(e,t,s,i=0){const r=this.getScene();if(!r)return;const n=r.getEngine();this._currentFaceIndex=e,this._currentLayer=i,this._currentUseCameraPostProcess=t,this._currentDumpForDebug=s,this._prepareFrame(r,e,i,t),n._debugPushGroup?.(`render to face #${e} layer #${i}`,2),this._objectRenderer.render(e+i,!0),n._debugPopGroup?.(2),this._unbindFrameBuffer(n,e),this._texture&&this.isCube&&5===e&&n.generateMipMapsForCubemap(this._texture,!0)}setRenderingOrder(e,t=null,s=null,i=null){this._objectRenderer.setRenderingOrder(e,t,s,i)}setRenderingAutoClearDepthStencil(e,t){this._objectRenderer.setRenderingAutoClearDepthStencil(e,t)}clone(){const e=this.getSize(),t=new _(this.name,e,this.getScene(),this._renderTargetOptions.generateMipMaps,this._doNotChangeAspectRatio,this._renderTargetOptions.type,this.isCube,this._renderTargetOptions.samplingMode,this._renderTargetOptions.generateDepthBuffer,this._renderTargetOptions.generateStencilBuffer,void 0,this._renderTargetOptions.format,void 0,this._renderTargetOptions.samples);return t.hasAlpha=this.hasAlpha,t.level=this.level,t.coordinatesMode=this.coordinatesMode,this.renderList&&(t.renderList=this.renderList.slice(0)),t}serialize(){if(!this.name)return null;const e=super.serialize();if(e.renderTargetSize=this.getRenderSize(),e.renderList=[],this.renderList)for(let t=0;t=0&&e.customRenderTargets.splice(t,1);for(const s of e.cameras)t=s.customRenderTargets.indexOf(this),t>=0&&s.customRenderTargets.splice(t,1);this._renderTarget?.dispose(),this._renderTarget=null,this._texture=null,super.dispose()}_rebuild(){this._objectRenderer._rebuild(),this._postProcessManager&&this._postProcessManager._rebuild()}freeRenderingGroups(){this._objectRenderer.freeRenderingGroups()}getViewCount(){return 1}}_.REFRESHRATE_RENDER_ONCE=d.REFRESHRATE_RENDER_ONCE,_.REFRESHRATE_RENDER_ONEVERYFRAME=d.REFRESHRATE_RENDER_ONEVERYFRAME,_.REFRESHRATE_RENDER_ONEVERYTWOFRAMES=d.REFRESHRATE_RENDER_ONEVERYTWOFRAMES,n.g._CreateRenderTargetTexture=(e,t,s,i,r)=>new _(e,t,s,i)},2781:(e,t,s)=>{s.d(t,{g:()=>m});var i=s(5524),r=s(9259),n=s(9848),a=s(9923),o=s(2667),h=s(6552),l=s(5503),c=s(2940),u=s(9337),d=s(4100),_=s(6181);function f(e,t,s=!1){const i=t.width,r=t.height;if(e instanceof Float32Array){let t=e.byteLength/e.BYTES_PER_ELEMENT;const s=new Uint8Array(t);for(;--t>=0;){let i=e[t];i<0?i=0:i>1&&(i=1),s[t]=255*i}e=s}const n=document.createElement("canvas");n.width=i,n.height=r;const a=n.getContext("2d");if(!a)return null;const o=a.createImageData(i,r);if(o.data.set(e),a.putImageData(o,0,0),s){const e=document.createElement("canvas");e.width=i,e.height=r;const t=e.getContext("2d");return t?(t.translate(0,r),t.scale(1,-1),t.drawImage(n,0,0),e.toDataURL("image/png")):null}return n.toDataURL("image/png")}var p=s(1313),g=s(6877);class m extends o.t{static _CreateVideoTexture(e,t,s,i=!1,r=!1,n=m.TRILINEAR_SAMPLINGMODE,a={},o,h=5){throw(0,l.n)("VideoTexture")}get noMipmap(){return this._noMipmap}get mimeType(){return this._mimeType}set isBlocking(e){this._isBlocking=e}get isBlocking(){return this._isBlocking}get invertY(){return this._invertY}constructor(e,t,s,i,r=m.TRILINEAR_SAMPLINGMODE,a=null,o=null,h=null,l=!1,u,d,_,f,g){let T;super(t),this.url=null,this.uOffset=0,this.vOffset=0,this.uScale=1,this.vScale=1,this.uAng=0,this.vAng=0,this.wAng=0,this.uRotationCenter=.5,this.vRotationCenter=.5,this.wRotationCenter=.5,this.homogeneousRotationInUVTransform=!1,this.inspectableCustomProperties=null,this._noMipmap=!1,this._invertY=!1,this._rowGenerationMatrix=null,this._cachedTextureMatrix=null,this._projectionModeMatrix=null,this._t0=null,this._t1=null,this._t2=null,this._cachedUOffset=-1,this._cachedVOffset=-1,this._cachedUScale=0,this._cachedVScale=0,this._cachedUAng=-1,this._cachedVAng=-1,this._cachedWAng=-1,this._cachedReflectionProjectionMatrixId=-1,this._cachedURotationCenter=-1,this._cachedVRotationCenter=-1,this._cachedWRotationCenter=-1,this._cachedHomogeneousRotationInUVTransform=!1,this._cachedIdentity3x2=!0,this._cachedReflectionTextureMatrix=null,this._cachedReflectionUOffset=-1,this._cachedReflectionVOffset=-1,this._cachedReflectionUScale=0,this._cachedReflectionVScale=0,this._cachedReflectionCoordinatesMode=-1,this._buffer=null,this._deleteBuffer=!1,this._format=null,this._delayedOnLoad=null,this._delayedOnError=null,this.onLoadObservable=new n.cP,this._isBlocking=!0,this.name=e||"",this.url=e;let b=!1,E=null,x=!0;"object"==typeof s&&null!==s?(T=s.noMipmap??!1,i=s.invertY??!p.rX,r=s.samplingMode??m.TRILINEAR_SAMPLINGMODE,a=s.onLoad??null,o=s.onError??null,h=s.buffer??null,l=s.deleteBuffer??!1,u=s.format,d=s.mimeType,_=s.loaderOptions,f=s.creationFlags,b=s.useSRGBBuffer??!1,E=s.internalTexture??null,x=s.gammaSpace??x,g=s.forcedExtension??g):T=!!s,this._gammaSpace=x,this._noMipmap=T,this._invertY=void 0===i?!p.rX:i,this._initialSamplingMode=r,this._buffer=h,this._deleteBuffer=l,this._mimeType=d,this._loaderOptions=_,this._creationFlags=f,this._useSRGBBuffer=b,this._forcedExtension=g,u&&(this._format=u);const A=this.getScene(),R=this._getEngine();if(!R)return;R.onBeforeTextureInitObservable.notifyObservers(this);const M=()=>{this._texture&&(this._texture._invertVScale&&(this.vScale*=-1,this.vOffset+=1),null!==this._texture._cachedWrapU&&(this.wrapU=this._texture._cachedWrapU,this._texture._cachedWrapU=null),null!==this._texture._cachedWrapV&&(this.wrapV=this._texture._cachedWrapV,this._texture._cachedWrapV=null),null!==this._texture._cachedWrapR&&(this.wrapR=this._texture._cachedWrapR,this._texture._cachedWrapR=null)),this.onLoadObservable.hasObservers()&&this.onLoadObservable.notifyObservers(this),a&&a(),!this.isBlocking&&A&&A.resetCachedMaterial()},y=(e,t)=>{this._loadingError=!0,this._errorObject={message:e,exception:t},o&&o(e,t),m.OnTextureLoadErrorObservable.notifyObservers(this)};if(!this.url&&!E)return this._delayedOnLoad=M,void(this._delayedOnError=y);if(this._texture=E??this._getFromCache(this.url,T,r,this._invertY,b,this.isCube),this._texture)if(this._texture.isReady)c._.SetImmediate((()=>M()));else{const e=this._texture.onLoadedObservable.add(M);this._texture.onErrorObservable.add((t=>{y(t.message,t.exception),this._texture?.onLoadedObservable.remove(e)}))}else if(A&&A.useDelayedTextureLoading)this.delayLoadState=4,this._delayedOnLoad=M,this._delayedOnError=y;else{try{this._texture=R.createTexture(this.url,T,this._invertY,A,r,M,y,this._buffer,void 0,this._format,this._forcedExtension,d,_,f,b)}catch(e){throw y("error loading",e),e}l&&(this._buffer=null)}}updateURL(e,t=null,s,i){this.url&&(this.releaseInternalTexture(),this.getScene().markAllMaterialsAsDirty(1,(e=>e.hasTexture(this)))),this.name&&!this.name.startsWith("data:")||(this.name=e),this.url=e,this._buffer=t,this._forcedExtension=i,this.delayLoadState=4,s&&(this._delayedOnLoad=s),this.delayLoad()}delayLoad(){if(4!==this.delayLoadState)return;const e=this.getScene();e&&(this.delayLoadState=1,this._texture=this._getFromCache(this.url,this._noMipmap,this.samplingMode,this._invertY,this._useSRGBBuffer,this.isCube),this._texture?this._delayedOnLoad&&(this._texture.isReady?c._.SetImmediate(this._delayedOnLoad):this._texture.onLoadedObservable.add(this._delayedOnLoad)):(this._texture=e.getEngine().createTexture(this.url,this._noMipmap,this._invertY,e,this.samplingMode,this._delayedOnLoad,this._delayedOnError,this._buffer,null,this._format,this._forcedExtension,this._mimeType,this._loaderOptions,this._creationFlags,this._useSRGBBuffer),this._deleteBuffer&&(this._buffer=null)),this._delayedOnLoad=null,this._delayedOnError=null)}_prepareRowForTextureGeneration(e,t,s,i){e*=this._cachedUScale,t*=this._cachedVScale,e-=this.uRotationCenter*this._cachedUScale,t-=this.vRotationCenter*this._cachedVScale,s-=this.wRotationCenter,a.Pq.TransformCoordinatesFromFloatsToRef(e,t,s,this._rowGenerationMatrix,i),i.x+=this.uRotationCenter*this._cachedUScale+this._cachedUOffset,i.y+=this.vRotationCenter*this._cachedVScale+this._cachedVOffset,i.z+=this.wRotationCenter}getTextureMatrix(e=1){if(this.uOffset===this._cachedUOffset&&this.vOffset===this._cachedVOffset&&this.uScale*e===this._cachedUScale&&this.vScale===this._cachedVScale&&this.uAng===this._cachedUAng&&this.vAng===this._cachedVAng&&this.wAng===this._cachedWAng&&this.uRotationCenter===this._cachedURotationCenter&&this.vRotationCenter===this._cachedVRotationCenter&&this.wRotationCenter===this._cachedWRotationCenter&&this.homogeneousRotationInUVTransform===this._cachedHomogeneousRotationInUVTransform)return this._cachedTextureMatrix;this._cachedUOffset=this.uOffset,this._cachedVOffset=this.vOffset,this._cachedUScale=this.uScale*e,this._cachedVScale=this.vScale,this._cachedUAng=this.uAng,this._cachedVAng=this.vAng,this._cachedWAng=this.wAng,this._cachedURotationCenter=this.uRotationCenter,this._cachedVRotationCenter=this.vRotationCenter,this._cachedWRotationCenter=this.wRotationCenter,this._cachedHomogeneousRotationInUVTransform=this.homogeneousRotationInUVTransform,this._cachedTextureMatrix&&this._rowGenerationMatrix||(this._cachedTextureMatrix=a.uq.Zero(),this._rowGenerationMatrix=new a.uq,this._t0=a.Pq.Zero(),this._t1=a.Pq.Zero(),this._t2=a.Pq.Zero()),a.uq.RotationYawPitchRollToRef(this.vAng,this.uAng,this.wAng,this._rowGenerationMatrix),this.homogeneousRotationInUVTransform?(a.uq.TranslationToRef(-this._cachedURotationCenter,-this._cachedVRotationCenter,-this._cachedWRotationCenter,a.AA.Matrix[0]),a.uq.TranslationToRef(this._cachedURotationCenter,this._cachedVRotationCenter,this._cachedWRotationCenter,a.AA.Matrix[1]),a.uq.ScalingToRef(this._cachedUScale,this._cachedVScale,0,a.AA.Matrix[2]),a.uq.TranslationToRef(this._cachedUOffset,this._cachedVOffset,0,a.AA.Matrix[3]),a.AA.Matrix[0].multiplyToRef(this._rowGenerationMatrix,this._cachedTextureMatrix),this._cachedTextureMatrix.multiplyToRef(a.AA.Matrix[1],this._cachedTextureMatrix),this._cachedTextureMatrix.multiplyToRef(a.AA.Matrix[2],this._cachedTextureMatrix),this._cachedTextureMatrix.multiplyToRef(a.AA.Matrix[3],this._cachedTextureMatrix),this._cachedTextureMatrix.setRowFromFloats(2,this._cachedTextureMatrix.m[12],this._cachedTextureMatrix.m[13],this._cachedTextureMatrix.m[14],1)):(this._prepareRowForTextureGeneration(0,0,0,this._t0),this._prepareRowForTextureGeneration(1,0,0,this._t1),this._prepareRowForTextureGeneration(0,1,0,this._t2),this._t1.subtractInPlace(this._t0),this._t2.subtractInPlace(this._t0),a.uq.FromValuesToRef(this._t1.x,this._t1.y,this._t1.z,0,this._t2.x,this._t2.y,this._t2.z,0,this._t0.x,this._t0.y,this._t0.z,0,0,0,0,1,this._cachedTextureMatrix));const t=this.getScene();if(!t)return this._cachedTextureMatrix;const s=this._cachedIdentity3x2;return this._cachedIdentity3x2=this._cachedTextureMatrix.isIdentityAs3x2(),this.optimizeUVAllocation&&s!==this._cachedIdentity3x2&&t.markAllMaterialsAsDirty(1,(e=>e.hasTexture(this))),this._cachedTextureMatrix}getReflectionTextureMatrix(){const e=this.getScene();if(!e)return this._cachedReflectionTextureMatrix;if(this.uOffset===this._cachedReflectionUOffset&&this.vOffset===this._cachedReflectionVOffset&&this.uScale===this._cachedReflectionUScale&&this.vScale===this._cachedReflectionVScale&&this.coordinatesMode===this._cachedReflectionCoordinatesMode){if(this.coordinatesMode!==m.PROJECTION_MODE)return this._cachedReflectionTextureMatrix;if(this._cachedReflectionProjectionMatrixId===e.getProjectionMatrix().updateFlag)return this._cachedReflectionTextureMatrix}this._cachedReflectionTextureMatrix||(this._cachedReflectionTextureMatrix=a.uq.Zero()),this._projectionModeMatrix||(this._projectionModeMatrix=a.uq.Zero());const t=this._cachedReflectionCoordinatesMode!==this.coordinatesMode;switch(this._cachedReflectionUOffset=this.uOffset,this._cachedReflectionVOffset=this.vOffset,this._cachedReflectionUScale=this.uScale,this._cachedReflectionVScale=this.vScale,this._cachedReflectionCoordinatesMode=this.coordinatesMode,this.coordinatesMode){case m.PLANAR_MODE:a.uq.IdentityToRef(this._cachedReflectionTextureMatrix),this._cachedReflectionTextureMatrix[0]=this.uScale,this._cachedReflectionTextureMatrix[5]=this.vScale,this._cachedReflectionTextureMatrix[12]=this.uOffset,this._cachedReflectionTextureMatrix[13]=this.vOffset;break;case m.PROJECTION_MODE:{a.uq.FromValuesToRef(.5,0,0,0,0,-.5,0,0,0,0,0,0,.5,.5,1,1,this._projectionModeMatrix);const t=e.getProjectionMatrix();this._cachedReflectionProjectionMatrixId=t.updateFlag,t.multiplyToRef(this._projectionModeMatrix,this._cachedReflectionTextureMatrix);break}default:a.uq.IdentityToRef(this._cachedReflectionTextureMatrix)}return t&&e.markAllMaterialsAsDirty(1,(e=>e.hasTexture(this))),this._cachedReflectionTextureMatrix}clone(){const e={noMipmap:this._noMipmap,invertY:this._invertY,samplingMode:this.samplingMode,onLoad:void 0,onError:void 0,buffer:this._texture?this._texture._buffer:void 0,deleteBuffer:this._deleteBuffer,format:this.textureFormat,mimeType:this.mimeType,loaderOptions:this._loaderOptions,creationFlags:this._creationFlags,useSRGBBuffer:this._useSRGBBuffer};return g.p.Clone((()=>new m(this._texture?this._texture.url:null,this.getScene(),e)),this)}serialize(){const e=this.name;m.SerializeBuffers||this.name.startsWith("data:")&&(this.name=""),this.name.startsWith("data:")&&this.url===this.name&&(this.url="");const t=super.serialize(m._SerializeInternalTextureUniqueId);return t?((m.SerializeBuffers||m.ForceSerializeBuffers)&&("string"==typeof this._buffer&&"data:"===this._buffer.substring(0,5)?(t.base64String=this._buffer,t.name=t.name.replace("data:","")):this.url&&this.url.startsWith("data:")&&this._buffer instanceof Uint8Array?t.base64String="data:image/png;base64,"+(0,_.EL)(this._buffer):(m.ForceSerializeBuffers||this.url&&this.url.startsWith("blob:")||this._forceSerialize)&&(t.base64String=!this._engine||this._engine._features.supportSyncTextureRead?function(e,t=0,s=0){const i=e.getInternalTexture();if(!i)return null;const r=e._readPixelsSync(t,s);return r?f(r,e.getSize(),i.invertY):null}(this):async function(e,t=0,s=0){const i=e.getInternalTexture();if(!i)return null;const r=await e.readPixels(t,s);return r?f(r,e.getSize(),i.invertY):null}(this))),t.invertY=this._invertY,t.samplingMode=this.samplingMode,t._creationFlags=this._creationFlags,t._useSRGBBuffer=this._useSRGBBuffer,m._SerializeInternalTextureUniqueId&&(t.internalTextureUniqueId=this._texture?.uniqueId),t.internalTextureLabel=this._texture?.label,t.noMipmap=this._noMipmap,this.name=e,t):null}getClassName(){return"Texture"}dispose(){super.dispose(),this.onLoadObservable.clear(),this._delayedOnLoad=null,this._delayedOnError=null,this._buffer=null}static Parse(e,t,s){if(e.customType){const i=u.n.Instantiate(e.customType).Parse(e,t,s);return e.samplingMode&&i.updateSamplingMode&&i._samplingMode&&i._samplingMode!==e.samplingMode&&i.updateSamplingMode(e.samplingMode),i}if(e.isCube&&!e.isRenderTarget)return m._CubeTextureParser(e,t,s);const i=void 0!==e.internalTextureUniqueId;if(!e.name&&!e.isRenderTarget&&!i)return null;let r;if(i){const s=t.getEngine().getLoadedTexturesCache();for(const t of s)if(t.uniqueId===e.internalTextureUniqueId){r=t;break}}const n=t=>{if(t&&t._texture&&(t._texture._cachedWrapU=null,t._texture._cachedWrapV=null,t._texture._cachedWrapR=null),e.samplingMode){const s=e.samplingMode;t&&t.samplingMode!==s&&t.updateSamplingMode(s)}if(t&&e.animations)for(let s=0;s{let i=!0;if(e.noMipmap&&(i=!1),e.mirrorPlane){const s=m._CreateMirror(e.name,e.renderTargetSize,t,i);return s._waitingRenderList=e.renderList,s.mirrorPlane=d.Z.FromArray(e.mirrorPlane),n(s),s}if(e.isRenderTarget){let s=null;if(e.isCube){if(t.reflectionProbes)for(let s=0;s{n(a)}),e._creationFlags??0,e._useSRGBBuffer??!1),a.name=e.name;else{let o;o=e.name&&(e.name.indexOf("://")>0||e.name.startsWith("data:"))?e.name:s+e.name,e.url&&(e.url.startsWith("data:")||m.UseSerializedUrlIfAny)&&(o=e.url);const h={noMipmap:!i,invertY:e.invertY,samplingMode:e.samplingMode,onLoad:()=>{n(a)},internalTexture:r};a=new m(o,t,h)}return a}}),e,t)}static CreateFromBase64String(e,t,s,i,r,n=m.TRILINEAR_SAMPLINGMODE,a=null,o=null,h=5,l,c){return new m("data:"+t,s,i,r,n,a,o,e,!1,h,void 0,void 0,l,c)}static LoadFromDataString(e,t,s,i=!1,r,n=!0,a=m.TRILINEAR_SAMPLINGMODE,o=null,h=null,l=5,c,u){return"data:"!==e.substring(0,5)&&(e="data:"+e),new m(e,s,r,n,a,o,h,t,i,l,void 0,void 0,c,u)}}m.SerializeBuffers=!0,m.ForceSerializeBuffers=!1,m.OnTextureLoadErrorObservable=new n.cP,m._SerializeInternalTextureUniqueId=!1,m._CubeTextureParser=(e,t,s)=>{throw(0,l.n)("CubeTexture")},m._CreateMirror=(e,t,s,i)=>{throw(0,l.n)("MirrorTexture")},m._CreateRenderTargetTexture=(e,t,s,i,r)=>{throw(0,l.n)("RenderTargetTexture")},m.NEAREST_SAMPLINGMODE=1,m.NEAREST_NEAREST_MIPLINEAR=8,m.BILINEAR_SAMPLINGMODE=2,m.LINEAR_LINEAR_MIPNEAREST=11,m.TRILINEAR_SAMPLINGMODE=3,m.LINEAR_LINEAR_MIPLINEAR=3,m.NEAREST_NEAREST_MIPNEAREST=4,m.NEAREST_LINEAR_MIPNEAREST=5,m.NEAREST_LINEAR_MIPLINEAR=6,m.NEAREST_LINEAR=7,m.NEAREST_NEAREST=1,m.LINEAR_NEAREST_MIPNEAREST=9,m.LINEAR_NEAREST_MIPLINEAR=10,m.LINEAR_LINEAR=2,m.LINEAR_NEAREST=12,m.EXPLICIT_MODE=0,m.SPHERICAL_MODE=1,m.PLANAR_MODE=2,m.CUBIC_MODE=3,m.PROJECTION_MODE=4,m.SKYBOX_MODE=5,m.INVCUBIC_MODE=6,m.EQUIRECTANGULAR_MODE=7,m.FIXED_EQUIRECTANGULAR_MODE=8,m.FIXED_EQUIRECTANGULAR_MIRRORED_MODE=9,m.CLAMP_ADDRESSMODE=0,m.WRAP_ADDRESSMODE=1,m.MIRROR_ADDRESSMODE=2,m.UseSerializedUrlIfAny=!1,(0,i.Cg)([(0,r.lK)()],m.prototype,"url",void 0),(0,i.Cg)([(0,r.lK)()],m.prototype,"uOffset",void 0),(0,i.Cg)([(0,r.lK)()],m.prototype,"vOffset",void 0),(0,i.Cg)([(0,r.lK)()],m.prototype,"uScale",void 0),(0,i.Cg)([(0,r.lK)()],m.prototype,"vScale",void 0),(0,i.Cg)([(0,r.lK)()],m.prototype,"uAng",void 0),(0,i.Cg)([(0,r.lK)()],m.prototype,"vAng",void 0),(0,i.Cg)([(0,r.lK)()],m.prototype,"wAng",void 0),(0,i.Cg)([(0,r.lK)()],m.prototype,"uRotationCenter",void 0),(0,i.Cg)([(0,r.lK)()],m.prototype,"vRotationCenter",void 0),(0,i.Cg)([(0,r.lK)()],m.prototype,"wRotationCenter",void 0),(0,i.Cg)([(0,r.lK)()],m.prototype,"homogeneousRotationInUVTransform",void 0),(0,i.Cg)([(0,r.lK)()],m.prototype,"isBlocking",null),(0,h.Y5)("BABYLON.Texture",m),g.p._TextureParser=m.Parse},492:(e,t,s)=>{function i(e){-1===e.indexOf("vClipPlane")&&e.push("vClipPlane"),-1===e.indexOf("vClipPlane2")&&e.push("vClipPlane2"),-1===e.indexOf("vClipPlane3")&&e.push("vClipPlane3"),-1===e.indexOf("vClipPlane4")&&e.push("vClipPlane4"),-1===e.indexOf("vClipPlane5")&&e.push("vClipPlane5"),-1===e.indexOf("vClipPlane6")&&e.push("vClipPlane6")}function r(e,t,s){const i=!!(e.clipPlane??t.clipPlane),r=!!(e.clipPlane2??t.clipPlane2),n=!!(e.clipPlane3??t.clipPlane3),a=!!(e.clipPlane4??t.clipPlane4),o=!!(e.clipPlane5??t.clipPlane5),h=!!(e.clipPlane6??t.clipPlane6);i&&s.push("#define CLIPPLANE"),r&&s.push("#define CLIPPLANE2"),n&&s.push("#define CLIPPLANE3"),a&&s.push("#define CLIPPLANE4"),o&&s.push("#define CLIPPLANE5"),h&&s.push("#define CLIPPLANE6")}function n(e,t,s){let i=!1;const r=!!(e.clipPlane??t.clipPlane),n=!!(e.clipPlane2??t.clipPlane2),a=!!(e.clipPlane3??t.clipPlane3),o=!!(e.clipPlane4??t.clipPlane4),h=!!(e.clipPlane5??t.clipPlane5),l=!!(e.clipPlane6??t.clipPlane6);return s.CLIPPLANE!==r&&(s.CLIPPLANE=r,i=!0),s.CLIPPLANE2!==n&&(s.CLIPPLANE2=n,i=!0),s.CLIPPLANE3!==a&&(s.CLIPPLANE3=a,i=!0),s.CLIPPLANE4!==o&&(s.CLIPPLANE4=o,i=!0),s.CLIPPLANE5!==h&&(s.CLIPPLANE5=h,i=!0),s.CLIPPLANE6!==l&&(s.CLIPPLANE6=l,i=!0),i}function a(e,t,s){let i=t.clipPlane??s.clipPlane;o(e,"vClipPlane",i),i=t.clipPlane2??s.clipPlane2,o(e,"vClipPlane2",i),i=t.clipPlane3??s.clipPlane3,o(e,"vClipPlane3",i),i=t.clipPlane4??s.clipPlane4,o(e,"vClipPlane4",i),i=t.clipPlane5??s.clipPlane5,o(e,"vClipPlane5",i),i=t.clipPlane6??s.clipPlane6,o(e,"vClipPlane6",i)}function o(e,t,s){s&&e.setFloat4(t,s.normal.x,s.normal.y,s.normal.z,s.d)}s.d(t,{Eq:()=>n,TV:()=>i,gS:()=>a,tv:()=>r})},5476:(e,t,s)=>{s.d(t,{E:()=>i});class i{static GetEffect(e){return void 0===e.getPipelineContext?e.effect:e}constructor(e,t=!0){this._wasPreviouslyReady=!1,this._forceRebindOnNextCall=!0,this._wasPreviouslyUsingInstances=null,this.effect=null,this.defines=null,this.drawContext=e.createDrawContext(),t&&(this.materialContext=e.createMaterialContext())}setEffect(e,t,s=!0){this.effect=e,void 0!==t&&(this.defines=t),s&&this.drawContext?.reset()}dispose(){this.drawContext?.dispose()}}},7647:(e,t,s)=>{s.d(t,{b4:()=>l,bu:()=>u,mO:()=>c,uR:()=>_});var i=s(8790),r=s(5852),n=s(9610),a=s(1137),o=s(9125),h=s(6741);function l(e,t){return(0,r.N5)(t).cachedPipelines[e]}function c(e){const t=e._name,s=e.context;if(t&&s){const e=(0,r.N5)(s),i=e.cachedPipelines[t];i?.dispose(),delete e.cachedPipelines[t]}}function u(e,t,s,r,n,a,h){let l,c;const u=(0,i.BA)()?a?.getHostDocument():null;l="string"==typeof t?t:t.vertexSource?"source:"+t.vertexSource:t.vertexElement?u?.getElementById(t.vertexElement)||t.vertexElement:t.vertex||t,c="string"==typeof t?t:t.fragmentSource?"source:"+t.fragmentSource:t.fragmentElement?u?.getElementById(t.fragmentElement)||t.fragmentElement:t.fragment||t;const _=[void 0,void 0],f=()=>{if(_[0]&&_[1]){e.isFragment=!0;const[i,l]=_;(0,o.M0)(l,e,((a,l)=>{h&&(h._fragmentSourceCodeBeforeMigration=l),s&&(a=s("fragment",a));const c=(0,o.nO)(i,a,e);e=null;const u=function(e,t,s,i){return s?{vertexSourceCode:(1===i?"//":"")+"#define SHADER_NAME vertex:"+(s.vertexElement||s.vertex||s.spectorName||s)+"\n"+e,fragmentSourceCode:(1===i?"//":"")+"#define SHADER_NAME fragment:"+(s.fragmentElement||s.fragment||s.spectorName||s)+"\n"+t}:{vertexSourceCode:e,fragmentSourceCode:t}}(c.vertexCode,c.fragmentCode,t,n);r?.(u.vertexSourceCode,u.fragmentSourceCode)}),a)}};d(l,"Vertex","",(t=>{(0,o.pB)(e),(0,o.M0)(t,e,((e,i)=>{h&&(h._rawVertexSourceCode=t,h._vertexSourceCodeBeforeMigration=i),s&&(e=s("vertex",e)),_[0]=e,f()}),a)}),n),d(c,"Fragment","Pixel",(e=>{h&&(h._rawFragmentSourceCode=e),_[1]=e,f()}),n)}function d(e,t,s,r,a,o){if("undefined"!=typeof HTMLElement&&e instanceof HTMLElement)return void r((0,i.Zl)(e));if("source:"===e.substring(0,7))return void r(e.substring(7));if("base64:"===e.substring(0,7))return void r(window.atob(e.substring(7)));const l=n.l.GetShadersStore(a);if(l[e+t+"Shader"])return void r(l[e+t+"Shader"]);if(s&&l[e+s+"Shader"])return void r(l[e+s+"Shader"]);let c;if(c="."===e[0]||"/"===e[0]||e.indexOf("http")>-1?e:n.l.GetShadersRepository(a)+e,!(o=o||h.W0))throw new Error("loadFileInjection is not defined");o(c+"."+t.toLowerCase()+".fx",r)}const _=(e,t,s,i)=>{try{const n=e.existingPipelineContext||t(e.shaderProcessingContext);return n._name=e.name,e.name&&e.context&&((0,r.N5)(e.context).cachedPipelines[e.name]=n),s(n,e.vertex,e.fragment,!!e.createAsRaw,"","",e.rebuildRebind,e.defines,e.transformFeedbackVaryings,"",(()=>{i(n,(()=>{e.onRenderingStateCompiled?.(n)}))})),n}catch(e){throw a.V.Error("Error compiling effect"),e}}},4420:(e,t,s)=>{s.d(t,{M:()=>o});var i=s(9848),r=s(1137),n=s(9610),a=s(7647);class o{static get ShadersRepository(){return n.l.ShadersRepository}static set ShadersRepository(e){n.l.ShadersRepository=e}get onBindObservable(){return this._onBindObservable||(this._onBindObservable=new i.cP),this._onBindObservable}get shaderLanguage(){return this._shaderLanguage}constructor(e,t,s,r=null,n,h=null,l=null,c=null,u=null,d,_="",f=0,p){this.defines="",this.onCompiled=null,this.onError=null,this.onBind=null,this.uniqueId=0,this.onCompileObservable=new i.cP,this.onErrorObservable=new i.cP,this._onBindObservable=null,this._isDisposed=!1,this._refCount=1,this._bonesComputationForcedToCPU=!1,this._uniformBuffersNames={},this._multiTarget=!1,this._samplers={},this._isReady=!1,this._compilationError="",this._allFallbacksProcessed=!1,this._uniforms={},this._key="",this._fallbacks=null,this._vertexSourceCodeOverride="",this._fragmentSourceCodeOverride="",this._transformFeedbackVaryings=null,this._pipelineContext=null,this._vertexSourceCode="",this._fragmentSourceCode="",this._vertexSourceCodeBeforeMigration="",this._fragmentSourceCodeBeforeMigration="",this._rawVertexSourceCode="",this._rawFragmentSourceCode="",this._processCodeAfterIncludes=void 0,this._processFinalCode=null,this.name=e,this._key=_;const g=this._key.replace(/\r/g,"").replace(/\n/g,"|");let m;if(t.attributes){const e=t;if(this._engine=s,this._attributesNames=e.attributes,this._uniformsNames=e.uniformsNames.concat(e.samplers),this._samplerList=e.samplers.slice(),this.defines=e.defines,this.onError=e.onError,this.onCompiled=e.onCompiled,this._fallbacks=e.fallbacks,this._indexParameters=e.indexParameters,this._transformFeedbackVaryings=e.transformFeedbackVaryings||null,this._multiTarget=!!e.multiTarget,this._shaderLanguage=e.shaderLanguage??0,e.uniformBuffersNames){this._uniformBuffersNamesList=e.uniformBuffersNames.slice();for(let t=0;t{this._vertexSourceCode=e,this._fragmentSourceCode=s,this._prepareEffect(t)}),this._shaderLanguage,this._engine,this)}get key(){return this._key}isReady(){try{return this._isReadyInternal()}catch{return!1}}_isReadyInternal(){return!!this._engine.isDisposed||!!this._isReady||!!this._pipelineContext&&this._pipelineContext.isReady}getEngine(){return this._engine}getPipelineContext(){return this._pipelineContext}getAttributesNames(){return this._attributesNames}getAttributeLocation(e){return this._attributes[e]}getAttributeLocationByName(e){return this._attributeLocationByName[e]}getAttributesCount(){return this._attributes.length}getUniformIndex(e){return this._uniformsNames.indexOf(e)}getUniform(e){return this._uniforms[e]}getSamplers(){return this._samplerList}getUniformNames(){return this._uniformsNames}getUniformBuffersNames(){return this._uniformBuffersNamesList}getIndexParameters(){return this._indexParameters}getCompilationError(){return this._compilationError}allFallbacksProcessed(){return this._allFallbacksProcessed}executeWhenCompiled(e){this.isReady()?e(this):(this.onCompileObservable.add((t=>{e(t)})),this._pipelineContext&&!this._pipelineContext.isAsync||setTimeout((()=>{this._checkIsReady(null)}),16))}_checkIsReady(e){try{if(this._isReadyInternal())return}catch(t){return void this._processCompilationErrors(t,e)}this._isDisposed||setTimeout((()=>{this._checkIsReady(e)}),16)}get vertexSourceCode(){return this._vertexSourceCodeOverride&&this._fragmentSourceCodeOverride?this._vertexSourceCodeOverride:this._pipelineContext?._getVertexShaderCode()??this._vertexSourceCode}get fragmentSourceCode(){return this._vertexSourceCodeOverride&&this._fragmentSourceCodeOverride?this._fragmentSourceCodeOverride:this._pipelineContext?._getFragmentShaderCode()??this._fragmentSourceCode}get vertexSourceCodeBeforeMigration(){return this._vertexSourceCodeBeforeMigration}get fragmentSourceCodeBeforeMigration(){return this._fragmentSourceCodeBeforeMigration}get rawVertexSourceCode(){return this._rawVertexSourceCode}get rawFragmentSourceCode(){return this._rawFragmentSourceCode}getPipelineGenerationOptions(){return{platformName:this._engine.shaderPlatformName,shaderLanguage:this._shaderLanguage,shaderNameOrContent:this.name,key:this._key,defines:this.defines.split("\n"),addGlobalDefines:!1,extendedProcessingOptions:{indexParameters:this._indexParameters,isNDCHalfZRange:this._engine.isNDCHalfZRange,useReverseDepthBuffer:this._engine.useReverseDepthBuffer,supportsUniformBuffers:this._engine.supportsUniformBuffers},extendedCreatePipelineOptions:{transformFeedbackVaryings:this._transformFeedbackVaryings,createAsRaw:!(!this._vertexSourceCodeOverride||!this._fragmentSourceCodeOverride)}}}_rebuildProgram(e,t,s,i){this._isReady=!1,this._vertexSourceCodeOverride=e,this._fragmentSourceCodeOverride=t,this.onError=(e,t)=>{i&&i(t)},this.onCompiled=()=>{const e=this.getEngine().scenes;if(e)for(let t=0;tthis._rebuildProgram(e,t,s,i),defines:i,transformFeedbackVaryings:this._transformFeedbackVaryings,name:this._key.replace(/\r/g,"").replace(/\n/g,"|"),createAsRaw:s,parallelShaderCompile:o._caps.parallelShaderCompile,shaderProcessingContext:this._processingContext,onRenderingStateCompiled:s=>{t&&!e&&this._engine._deletePipelineContext(t),s&&this._onRenderingStateCompiled(s)}},this._engine.createPipelineContext.bind(this._engine),this._engine._preparePipelineContext.bind(this._engine),this._engine._executeWhenRenderingStateIsCompiled.bind(this._engine)),this._pipelineContext.isAsync&&this._checkIsReady(t)}catch(e){this._processCompilationErrors(e,t)}}_getShaderCodeAndErrorLine(e,t,s){const i=s?/FRAGMENT SHADER ERROR: 0:(\d+?):/:/VERTEX SHADER ERROR: 0:(\d+?):/;let r=null;if(t&&e){const n=t.match(i);if(n&&2===n.length){const t=parseInt(n[1]),i=e.split("\n",-1);i.length>=t&&(r=`Offending line [${t}] in ${s?"fragment":"vertex"} code: ${i[t-1]}`)}}return[e,r]}_processCompilationErrors(e,t=null){this._compilationError=e.message;const s=this._attributesNames,i=this._fallbacks;if(r.V.Error("Unable to compile effect:"),r.V.Error("Uniforms: "+this._uniformsNames.map((function(e){return" "+e}))),r.V.Error("Attributes: "+s.map((function(e){return" "+e}))),r.V.Error("Defines:\n"+this.defines),o.LogShaderCodeOnCompilationError){let e=null,t=null,s=null;this._pipelineContext?._getVertexShaderCode()&&([s,e]=this._getShaderCodeAndErrorLine(this._pipelineContext._getVertexShaderCode(),this._compilationError,!1),s&&(r.V.Error("Vertex code:"),r.V.Error(s))),this._pipelineContext?._getFragmentShaderCode()&&([s,t]=this._getShaderCodeAndErrorLine(this._pipelineContext?._getFragmentShaderCode(),this._compilationError,!0),s&&(r.V.Error("Fragment code:"),r.V.Error(s))),e&&r.V.Error(e),t&&r.V.Error(t)}r.V.Error("Error: "+this._compilationError);const n=()=>{this.onError&&this.onError(this,this._compilationError),this.onErrorObservable.notifyObservers(this)};t&&(this._pipelineContext=t,this._isReady=!0,n()),i?(this._pipelineContext=null,i.hasMoreFallbacks?(this._allFallbacksProcessed=!1,r.V.Error("Trying next fallback."),this.defines=i.reduce(this.defines,this),this._prepareEffect()):(this._allFallbacksProcessed=!0,n(),this.onErrorObservable.clear(),this._fallbacks&&this._fallbacks.unBindMesh())):(this._allFallbacksProcessed=!0,t||n())}get isSupported(){return""===this._compilationError}_bindTexture(e,t){this._engine._bindTexture(this._samplers[e],t,e)}setTexture(e,t){this._engine.setTexture(this._samplers[e],this._uniforms[e],t,e)}setTextureArray(e,t){const s=e+"Ex";if(-1===this._samplerList.indexOf(s+"0")){const i=this._samplerList.indexOf(e);for(let e=1;e0||(this._pipelineContext&&(0,a.mO)(this._pipelineContext),this._engine._releaseEffect(this),this.clearCodeCache(),this._isDisposed=!0)}static RegisterShader(e,t,s,i=0){t&&(n.l.GetShadersStore(i)[`${e}PixelShader`]=t),s&&(n.l.GetShadersStore(i)[`${e}VertexShader`]=s)}static ResetCache(){o._BaseCache={}}}o.LogShaderCodeOnCompilationError=!0,o.AutomaticallyClearCodeCache=!1,o._UniqueIdSeed=0,o._BaseCache={},o.ShadersStore=n.l.ShadersStore,o.IncludesShadersStore=n.l.IncludesShadersStore},2565:(e,t,s)=>{s.d(t,{J:()=>i});class i{constructor(){this._defines={},this._currentRank=32,this._maxRank=-1,this._mesh=null}unBindMesh(){this._mesh=null}addFallback(e,t){this._defines[e]||(ethis._maxRank&&(this._maxRank=e),this._defines[e]=new Array),this._defines[e].push(t)}addCPUSkinningFallback(e,t){this._mesh=t,ethis._maxRank&&(this._maxRank=e)}get hasMoreFallbacks(){return this._currentRank<=this._maxRank}reduce(e,t){if(this._mesh&&this._mesh.computeBonesUsingShaders&&this._mesh.numBoneInfluencers>0){this._mesh.computeBonesUsingShaders=!1,e=e.replace("#define NUM_BONE_INFLUENCERS "+this._mesh.numBoneInfluencers,"#define NUM_BONE_INFLUENCERS 0"),t._bonesComputationForcedToCPU=!0;const s=this._mesh.getScene();for(let e=0;e0&&(i.computeBonesUsingShaders=!1)}}else{const t=this._defines[this._currentRank];if(t)for(let s=0;s{s.d(t,{$:()=>c,J:()=>l});var i=s(5616),r=s(4494),n=s(9848),a=s(4420),o=s(5476);s(6612);const h={positions:[1,1,-1,1,-1,-1,1,-1],indices:[0,1,2,0,2,3]};class l{constructor(e,t=h){this._fullscreenViewport=new r.L(0,0,1,1);const s=t.positions??h.positions,n=t.indices??h.indices;this.engine=e,this._vertexBuffers={[i.R.PositionKind]:new i.R(e,s,i.R.PositionKind,!1,!1,2)},this._indexBuffer=e.createIndexBuffer(n),this._onContextRestoredObserver=e.onContextRestoredObservable.add((()=>{this._indexBuffer=e.createIndexBuffer(n);for(const e in this._vertexBuffers)this._vertexBuffers[e]._rebuild()}))}setViewport(e=this._fullscreenViewport){this.engine.setViewport(e)}bindBuffers(e){this.engine.bindBuffers(this._vertexBuffers,this._indexBuffer,e)}applyEffectWrapper(e){this.engine.setState(!0),this.engine.depthCullingState.depthTest=!1,this.engine.stencilState.stencilTest=!1,this.engine.enableEffect(e.drawWrapper),this.bindBuffers(e.effect),e.onApplyObservable.notifyObservers({})}saveStates(){this._savedStateDepthTest=this.engine.depthCullingState.depthTest,this._savedStateStencilTest=this.engine.stencilState.stencilTest}restoreStates(){this.engine.depthCullingState.depthTest=this._savedStateDepthTest,this.engine.stencilState.stencilTest=this._savedStateStencilTest}draw(){this.engine.drawElementsType(0,0,6)}_isRenderTargetTexture(e){return void 0!==e.renderTarget}render(e,t=null){if(!e.effect.isReady())return;this.saveStates(),this.setViewport();const s=null===t?null:this._isRenderTargetTexture(t)?t.renderTarget:t;s&&this.engine.bindFramebuffer(s),this.applyEffectWrapper(e),this.draw(),s&&this.engine.unBindFramebuffer(s),this.restoreStates()}dispose(){const e=this._vertexBuffers[i.R.PositionKind];e&&(e.dispose(),delete this._vertexBuffers[i.R.PositionKind]),this._indexBuffer&&this.engine._releaseBuffer(this._indexBuffer),this._onContextRestoredObserver&&(this.engine.onContextRestoredObservable.remove(this._onContextRestoredObserver),this._onContextRestoredObserver=null)}}class c{static RegisterShaderCodeProcessing(e,t){t?c._CustomShaderCodeProcessing[e??""]=t:delete c._CustomShaderCodeProcessing[e??""]}static _GetShaderCodeProcessing(e){return c._CustomShaderCodeProcessing[e]??c._CustomShaderCodeProcessing[""]}get name(){return this.options.name}set name(e){this.options.name=e}isReady(){return this._drawWrapper.effect?.isReady()??!1}get drawWrapper(){return this._drawWrapper}get effect(){return this._drawWrapper.effect}set effect(e){this._drawWrapper.effect=e}constructor(e){this.alphaMode=0,this.onEffectCreatedObservable=new n.cP(void 0,!0),this.onApplyObservable=new n.cP,this._shadersLoaded=!1,this._webGPUReady=!1,this._importPromises=[],this.options={...e,name:e.name||"effectWrapper",engine:e.engine,uniforms:e.uniforms||e.uniformNames||[],uniformNames:void 0,samplers:e.samplers||e.samplerNames||[],samplerNames:void 0,attributeNames:e.attributeNames||["position"],uniformBuffers:e.uniformBuffers||[],defines:e.defines||"",useShaderStore:e.useShaderStore||!1,vertexUrl:e.vertexUrl||e.vertexShader||"postprocess",vertexShader:void 0,fragmentShader:e.fragmentShader||"pass",indexParameters:e.indexParameters,blockCompilation:e.blockCompilation||!1,shaderLanguage:e.shaderLanguage||0,onCompiled:e.onCompiled||void 0,extraInitializations:e.extraInitializations||void 0,extraInitializationsAsync:e.extraInitializationsAsync||void 0,useAsPostProcess:e.useAsPostProcess??!1},this.options.uniformNames=this.options.uniforms,this.options.samplerNames=this.options.samplers,this.options.vertexShader=this.options.vertexUrl,this.options.useAsPostProcess&&(-1===this.options.samplers.indexOf("textureSampler")&&this.options.samplers.push("textureSampler"),-1===this.options.uniforms.indexOf("scale")&&this.options.uniforms.push("scale")),e.vertexUrl||e.vertexShader?this._shaderPath={vertexSource:this.options.vertexShader}:(this.options.useAsPostProcess||(this.options.uniforms.push("scale"),this.onApplyObservable.add((()=>{this.effect.setFloat2("scale",1,1)}))),this._shaderPath={vertex:this.options.vertexShader}),this._shaderPath.fragmentSource=this.options.fragmentShader,this._shaderPath.spectorName=this.options.name,this.options.useShaderStore&&(this._shaderPath.fragment=this._shaderPath.fragmentSource,this._shaderPath.vertex||(this._shaderPath.vertex=this._shaderPath.vertexSource),delete this._shaderPath.fragmentSource,delete this._shaderPath.vertexSource),this.onApplyObservable.add((()=>{this.bind()})),this.options.useShaderStore||(this._onContextRestoredObserver=this.options.engine.onContextRestoredObservable.add((()=>{this.effect._pipelineContext=null,this.effect._prepareEffect()}))),this._drawWrapper=new o.E(this.options.engine),this._webGPUReady=1===this.options.shaderLanguage;const t=Array.isArray(this.options.defines)?this.options.defines.join("\n"):this.options.defines;this._postConstructor(this.options.blockCompilation,t,this.options.extraInitializations)}_gatherImports(e=!1,t){this.options.useAsPostProcess&&(e&&this._webGPUReady?t.push(Promise.all([s.e(126).then(s.bind(s,2083))])):t.push(Promise.all([Promise.resolve().then(s.bind(s,6612))])))}_postConstructor(e,t=null,s,i){this._importPromises.length=0,i&&this._importPromises.push(...i);const r=this.options.engine.isWebGPU&&!c.ForceGLSL;this._gatherImports(r,this._importPromises),void 0!==s&&s(r,this._importPromises),r&&this._webGPUReady&&(this.options.shaderLanguage=1),e||this.updateEffect(t)}updateEffect(e=null,t=null,s=null,i,r,n,o,h){const l=c._GetShaderCodeProcessing(this.name);if(l?.defineCustomBindings){const i=t?.slice()??[];i.push(...this.options.uniforms);const r=s?.slice()??[];r.push(...this.options.samplers),e=l.defineCustomBindings(this.name,e,i,r),t=i,s=r}this.options.defines=e||"";const u=this._shadersLoaded||0===this._importPromises.length?void 0:async()=>{await Promise.all(this._importPromises),this._shadersLoaded=!0};let d;d=this.options.extraInitializationsAsync?async()=>{u?.(),await this.options.extraInitializationsAsync}:u,this.options.useShaderStore?this._drawWrapper.effect=this.options.engine.createEffect({vertex:o??this._shaderPath.vertex,fragment:h??this._shaderPath.fragment},{attributes:this.options.attributeNames,uniformsNames:t||this.options.uniforms,uniformBuffersNames:this.options.uniformBuffers,samplers:s||this.options.samplers,defines:null!==e?e:"",fallbacks:null,onCompiled:r??this.options.onCompiled,onError:n??null,indexParameters:i||this.options.indexParameters,processCodeAfterIncludes:l?.processCodeAfterIncludes?(e,t)=>l.processCodeAfterIncludes(this.name,e,t):null,processFinalCode:l?.processFinalCode?(e,t)=>l.processFinalCode(this.name,e,t):null,shaderLanguage:this.options.shaderLanguage,extraInitializationsAsync:d},this.options.engine):this._drawWrapper.effect=new a.M(this._shaderPath,this.options.attributeNames,t||this.options.uniforms,s||this.options.samplerNames,this.options.engine,e,void 0,r||this.options.onCompiled,void 0,void 0,void 0,this.options.shaderLanguage,d),this.onEffectCreatedObservable.notifyObservers(this._drawWrapper.effect)}bind(){this.options.useAsPostProcess&&(this.options.engine.setAlphaMode(this.alphaMode),this.drawWrapper.effect.setFloat2("scale",1,1)),c._GetShaderCodeProcessing(this.name)?.bindCustomBindings?.(this.name,this._drawWrapper.effect)}dispose(e=!1){this._onContextRestoredObserver&&(this.effect.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver),this._onContextRestoredObserver=null),this.onEffectCreatedObservable.clear(),this.effect.dispose()}}c.ForceGLSL=!1,c._CustomShaderCodeProcessing={}},1088:(e,t,s)=>{s.d(t,{p:()=>d});var i=s(5524),r=s(9259),n=s(9848),a=s(6041),o=s(6877);function h(e){e.push("vCameraColorCurveNeutral","vCameraColorCurvePositive","vCameraColorCurveNegative")}class l{constructor(){this._dirty=!0,this._tempColor=new a.ov(0,0,0,0),this._globalCurve=new a.ov(0,0,0,0),this._highlightsCurve=new a.ov(0,0,0,0),this._midtonesCurve=new a.ov(0,0,0,0),this._shadowsCurve=new a.ov(0,0,0,0),this._positiveCurve=new a.ov(0,0,0,0),this._negativeCurve=new a.ov(0,0,0,0),this._globalHue=30,this._globalDensity=0,this._globalSaturation=0,this._globalExposure=0,this._highlightsHue=30,this._highlightsDensity=0,this._highlightsSaturation=0,this._highlightsExposure=0,this._midtonesHue=30,this._midtonesDensity=0,this._midtonesSaturation=0,this._midtonesExposure=0,this._shadowsHue=30,this._shadowsDensity=0,this._shadowsSaturation=0,this._shadowsExposure=0}get globalHue(){return this._globalHue}set globalHue(e){this._globalHue=e,this._dirty=!0}get globalDensity(){return this._globalDensity}set globalDensity(e){this._globalDensity=e,this._dirty=!0}get globalSaturation(){return this._globalSaturation}set globalSaturation(e){this._globalSaturation=e,this._dirty=!0}get globalExposure(){return this._globalExposure}set globalExposure(e){this._globalExposure=e,this._dirty=!0}get highlightsHue(){return this._highlightsHue}set highlightsHue(e){this._highlightsHue=e,this._dirty=!0}get highlightsDensity(){return this._highlightsDensity}set highlightsDensity(e){this._highlightsDensity=e,this._dirty=!0}get highlightsSaturation(){return this._highlightsSaturation}set highlightsSaturation(e){this._highlightsSaturation=e,this._dirty=!0}get highlightsExposure(){return this._highlightsExposure}set highlightsExposure(e){this._highlightsExposure=e,this._dirty=!0}get midtonesHue(){return this._midtonesHue}set midtonesHue(e){this._midtonesHue=e,this._dirty=!0}get midtonesDensity(){return this._midtonesDensity}set midtonesDensity(e){this._midtonesDensity=e,this._dirty=!0}get midtonesSaturation(){return this._midtonesSaturation}set midtonesSaturation(e){this._midtonesSaturation=e,this._dirty=!0}get midtonesExposure(){return this._midtonesExposure}set midtonesExposure(e){this._midtonesExposure=e,this._dirty=!0}get shadowsHue(){return this._shadowsHue}set shadowsHue(e){this._shadowsHue=e,this._dirty=!0}get shadowsDensity(){return this._shadowsDensity}set shadowsDensity(e){this._shadowsDensity=e,this._dirty=!0}get shadowsSaturation(){return this._shadowsSaturation}set shadowsSaturation(e){this._shadowsSaturation=e,this._dirty=!0}get shadowsExposure(){return this._shadowsExposure}set shadowsExposure(e){this._shadowsExposure=e,this._dirty=!0}getClassName(){return"ColorCurves"}static Bind(e,t,s="vCameraColorCurvePositive",i="vCameraColorCurveNeutral",r="vCameraColorCurveNegative"){e._dirty&&(e._dirty=!1,e._getColorGradingDataToRef(e._globalHue,e._globalDensity,e._globalSaturation,e._globalExposure,e._globalCurve),e._getColorGradingDataToRef(e._highlightsHue,e._highlightsDensity,e._highlightsSaturation,e._highlightsExposure,e._tempColor),e._tempColor.multiplyToRef(e._globalCurve,e._highlightsCurve),e._getColorGradingDataToRef(e._midtonesHue,e._midtonesDensity,e._midtonesSaturation,e._midtonesExposure,e._tempColor),e._tempColor.multiplyToRef(e._globalCurve,e._midtonesCurve),e._getColorGradingDataToRef(e._shadowsHue,e._shadowsDensity,e._shadowsSaturation,e._shadowsExposure,e._tempColor),e._tempColor.multiplyToRef(e._globalCurve,e._shadowsCurve),e._highlightsCurve.subtractToRef(e._midtonesCurve,e._positiveCurve),e._midtonesCurve.subtractToRef(e._shadowsCurve,e._negativeCurve)),t&&(t.setFloat4(s,e._positiveCurve.r,e._positiveCurve.g,e._positiveCurve.b,e._positiveCurve.a),t.setFloat4(i,e._midtonesCurve.r,e._midtonesCurve.g,e._midtonesCurve.b,e._midtonesCurve.a),t.setFloat4(r,e._negativeCurve.r,e._negativeCurve.g,e._negativeCurve.b,e._negativeCurve.a))}_getColorGradingDataToRef(e,t,s,i,r){null!=e&&(e=l._Clamp(e,0,360),t=l._Clamp(t,-100,100),s=l._Clamp(s,-100,100),i=l._Clamp(i,-100,100),t=l._ApplyColorGradingSliderNonlinear(t),t*=.5,i=l._ApplyColorGradingSliderNonlinear(i),t<0&&(t*=-1,e=(e+180)%360),l._FromHSBToRef(e,t,50+.25*i,r),r.scaleToRef(2,r),r.a=1+.01*s)}static _ApplyColorGradingSliderNonlinear(e){e/=100;let t=Math.abs(e);return t=Math.pow(t,2),e<0&&(t*=-1),t*=100,t}static _FromHSBToRef(e,t,s,i){let r=l._Clamp(e,0,360);const n=l._Clamp(t/100,0,1),a=l._Clamp(s/100,0,1);if(0===n)i.r=a,i.g=a,i.b=a;else{r/=60;const e=Math.floor(r),t=r-e,s=a*(1-n),o=a*(1-n*t),h=a*(1-n*(1-t));switch(e){case 0:i.r=a,i.g=h,i.b=s;break;case 1:i.r=o,i.g=a,i.b=s;break;case 2:i.r=s,i.g=a,i.b=h;break;case 3:i.r=s,i.g=o,i.b=a;break;case 4:i.r=h,i.g=s,i.b=a;break;default:i.r=a,i.g=s,i.b=o}}i.a=1}static _Clamp(e,t,s){return Math.min(Math.max(e,t),s)}clone(){return o.p.Clone((()=>new l),this)}serialize(){return o.p.Serialize(this)}static Parse(e){return o.p.Parse((()=>new l),e,null,null)}}l.PrepareUniforms=h,(0,i.Cg)([(0,r.lK)()],l.prototype,"_globalHue",void 0),(0,i.Cg)([(0,r.lK)()],l.prototype,"_globalDensity",void 0),(0,i.Cg)([(0,r.lK)()],l.prototype,"_globalSaturation",void 0),(0,i.Cg)([(0,r.lK)()],l.prototype,"_globalExposure",void 0),(0,i.Cg)([(0,r.lK)()],l.prototype,"_highlightsHue",void 0),(0,i.Cg)([(0,r.lK)()],l.prototype,"_highlightsDensity",void 0),(0,i.Cg)([(0,r.lK)()],l.prototype,"_highlightsSaturation",void 0),(0,i.Cg)([(0,r.lK)()],l.prototype,"_highlightsExposure",void 0),(0,i.Cg)([(0,r.lK)()],l.prototype,"_midtonesHue",void 0),(0,i.Cg)([(0,r.lK)()],l.prototype,"_midtonesDensity",void 0),(0,i.Cg)([(0,r.lK)()],l.prototype,"_midtonesSaturation",void 0),(0,i.Cg)([(0,r.lK)()],l.prototype,"_midtonesExposure",void 0),o.p._ColorCurvesParser=l.Parse;var c=s(1597),u=s(6552);class d{constructor(){this.colorCurves=new l,this._colorCurvesEnabled=!1,this._colorGradingEnabled=!1,this._colorGradingWithGreenDepth=!0,this._colorGradingBGR=!0,this._exposure=1,this._toneMappingEnabled=!1,this._toneMappingType=d.TONEMAPPING_STANDARD,this._contrast=1,this.vignetteStretch=0,this.vignetteCenterX=0,this.vignetteCenterY=0,this.vignetteWeight=1.5,this.vignetteColor=new a.ov(0,0,0,0),this.vignetteCameraFov=.5,this._vignetteBlendMode=d.VIGNETTEMODE_MULTIPLY,this._vignetteEnabled=!1,this._ditheringEnabled=!1,this._ditheringIntensity=1/255,this._skipFinalColorClamp=!1,this._applyByPostProcess=!1,this._isEnabled=!0,this.onUpdateParameters=new n.cP}get colorCurvesEnabled(){return this._colorCurvesEnabled}set colorCurvesEnabled(e){this._colorCurvesEnabled!==e&&(this._colorCurvesEnabled=e,this._updateParameters())}get colorGradingTexture(){return this._colorGradingTexture}set colorGradingTexture(e){this._colorGradingTexture!==e&&(this._colorGradingTexture=e,this._updateParameters())}get colorGradingEnabled(){return this._colorGradingEnabled}set colorGradingEnabled(e){this._colorGradingEnabled!==e&&(this._colorGradingEnabled=e,this._updateParameters())}get colorGradingWithGreenDepth(){return this._colorGradingWithGreenDepth}set colorGradingWithGreenDepth(e){this._colorGradingWithGreenDepth!==e&&(this._colorGradingWithGreenDepth=e,this._updateParameters())}get colorGradingBGR(){return this._colorGradingBGR}set colorGradingBGR(e){this._colorGradingBGR!==e&&(this._colorGradingBGR=e,this._updateParameters())}get exposure(){return this._exposure}set exposure(e){this._exposure!==e&&(this._exposure=e,this._updateParameters())}get toneMappingEnabled(){return this._toneMappingEnabled}set toneMappingEnabled(e){this._toneMappingEnabled!==e&&(this._toneMappingEnabled=e,this._updateParameters())}get toneMappingType(){return this._toneMappingType}set toneMappingType(e){this._toneMappingType!==e&&(this._toneMappingType=e,this._updateParameters())}get contrast(){return this._contrast}set contrast(e){this._contrast!==e&&(this._contrast=e,this._updateParameters())}get vignetteCentreY(){return this.vignetteCenterY}set vignetteCentreY(e){this.vignetteCenterY=e}get vignetteCentreX(){return this.vignetteCenterX}set vignetteCentreX(e){this.vignetteCenterX=e}get vignetteBlendMode(){return this._vignetteBlendMode}set vignetteBlendMode(e){this._vignetteBlendMode!==e&&(this._vignetteBlendMode=e,this._updateParameters())}get vignetteEnabled(){return this._vignetteEnabled}set vignetteEnabled(e){this._vignetteEnabled!==e&&(this._vignetteEnabled=e,this._updateParameters())}get ditheringEnabled(){return this._ditheringEnabled}set ditheringEnabled(e){this._ditheringEnabled!==e&&(this._ditheringEnabled=e,this._updateParameters())}get ditheringIntensity(){return this._ditheringIntensity}set ditheringIntensity(e){this._ditheringIntensity!==e&&(this._ditheringIntensity=e,this._updateParameters())}get skipFinalColorClamp(){return this._skipFinalColorClamp}set skipFinalColorClamp(e){this._skipFinalColorClamp!==e&&(this._skipFinalColorClamp=e,this._updateParameters())}get applyByPostProcess(){return this._applyByPostProcess}set applyByPostProcess(e){this._applyByPostProcess!==e&&(this._applyByPostProcess=e,this._updateParameters())}get isEnabled(){return this._isEnabled}set isEnabled(e){this._isEnabled!==e&&(this._isEnabled=e,this._updateParameters())}_updateParameters(){this.onUpdateParameters.notifyObservers(this)}getClassName(){return"ImageProcessingConfiguration"}prepareDefines(e,t=!1){if(t!==this.applyByPostProcess||!this._isEnabled)return e.VIGNETTE=!1,e.TONEMAPPING=0,e.CONTRAST=!1,e.EXPOSURE=!1,e.COLORCURVES=!1,e.COLORGRADING=!1,e.COLORGRADING3D=!1,e.DITHER=!1,e.IMAGEPROCESSING=!1,e.SKIPFINALCOLORCLAMP=this.skipFinalColorClamp,void(e.IMAGEPROCESSINGPOSTPROCESS=this.applyByPostProcess&&this._isEnabled);if(e.VIGNETTE=this.vignetteEnabled,e.VIGNETTEBLENDMODEMULTIPLY=this.vignetteBlendMode===d._VIGNETTEMODE_MULTIPLY,e.VIGNETTEBLENDMODEOPAQUE=!e.VIGNETTEBLENDMODEMULTIPLY,this._toneMappingEnabled)switch(this._toneMappingType){case d.TONEMAPPING_KHR_PBR_NEUTRAL:e.TONEMAPPING=3;break;case d.TONEMAPPING_ACES:e.TONEMAPPING=2;break;default:e.TONEMAPPING=1}else e.TONEMAPPING=0;e.CONTRAST=1!==this.contrast,e.EXPOSURE=1!==this.exposure,e.COLORCURVES=this.colorCurvesEnabled&&!!this.colorCurves,e.COLORGRADING=this.colorGradingEnabled&&!!this.colorGradingTexture,e.COLORGRADING?e.COLORGRADING3D=this.colorGradingTexture.is3D:e.COLORGRADING3D=!1,e.SAMPLER3DGREENDEPTH=this.colorGradingWithGreenDepth,e.SAMPLER3DBGRMAP=this.colorGradingBGR,e.DITHER=this._ditheringEnabled,e.IMAGEPROCESSINGPOSTPROCESS=this.applyByPostProcess,e.SKIPFINALCOLORCLAMP=this.skipFinalColorClamp,e.IMAGEPROCESSING=e.VIGNETTE||!!e.TONEMAPPING||e.CONTRAST||e.EXPOSURE||e.COLORCURVES||e.COLORGRADING||e.DITHER}isReady(){return!this.colorGradingEnabled||!this.colorGradingTexture||this.colorGradingTexture.isReady()}bind(e,t){if(this._colorCurvesEnabled&&this.colorCurves&&l.Bind(this.colorCurves,e),this._vignetteEnabled||this._ditheringEnabled){const s=1/e.getEngine().getRenderWidth(),i=1/e.getEngine().getRenderHeight();if(e.setFloat2("vInverseScreenSize",s,i),this._ditheringEnabled&&e.setFloat("ditherIntensity",.5*this._ditheringIntensity),this._vignetteEnabled){const r=null!=t?t:i/s;let n=Math.tan(.5*this.vignetteCameraFov),a=n*r;const o=Math.sqrt(a*n);a=(0,c.zF)(a,o,this.vignetteStretch),n=(0,c.zF)(n,o,this.vignetteStretch),e.setFloat4("vignetteSettings1",a,n,-a*this.vignetteCenterX,-n*this.vignetteCenterY);const h=-2*this.vignetteWeight;e.setFloat4("vignetteSettings2",this.vignetteColor.r,this.vignetteColor.g,this.vignetteColor.b,h)}}if(e.setFloat("exposureLinear",this.exposure),e.setFloat("contrast",this.contrast),this.colorGradingTexture){e.setTexture("txColorTransform",this.colorGradingTexture);const t=this.colorGradingTexture.getSize().height;e.setFloat4("colorTransformSettings",(t-1)/t,.5/t,t,this.colorGradingTexture.level)}}clone(){return o.p.Clone((()=>new d),this)}serialize(){return o.p.Serialize(this)}static Parse(e){const t=o.p.Parse((()=>new d),e,null,null);return void 0!==e.vignetteCentreX&&(t.vignetteCenterX=e.vignetteCentreX),void 0!==e.vignetteCentreY&&(t.vignetteCenterY=e.vignetteCentreY),t}static get VIGNETTEMODE_MULTIPLY(){return this._VIGNETTEMODE_MULTIPLY}static get VIGNETTEMODE_OPAQUE(){return this._VIGNETTEMODE_OPAQUE}}d.TONEMAPPING_STANDARD=0,d.TONEMAPPING_ACES=1,d.TONEMAPPING_KHR_PBR_NEUTRAL=2,d.PrepareUniforms=function(e,t){t.EXPOSURE&&e.push("exposureLinear"),t.CONTRAST&&e.push("contrast"),t.COLORGRADING&&e.push("colorTransformSettings"),(t.VIGNETTE||t.DITHER)&&e.push("vInverseScreenSize"),t.VIGNETTE&&(e.push("vignetteSettings1"),e.push("vignetteSettings2")),t.COLORCURVES&&h(e),t.DITHER&&e.push("ditherIntensity")},d.PrepareSamplers=function(e,t){t.COLORGRADING&&e.push("txColorTransform")},d._VIGNETTEMODE_MULTIPLY=0,d._VIGNETTEMODE_OPAQUE=1,(0,i.Cg)([(0,r.wL)()],d.prototype,"colorCurves",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"_colorCurvesEnabled",void 0),(0,i.Cg)([(0,r.uM)("colorGradingTexture")],d.prototype,"_colorGradingTexture",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"_colorGradingEnabled",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"_colorGradingWithGreenDepth",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"_colorGradingBGR",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"_exposure",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"_toneMappingEnabled",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"_toneMappingType",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"_contrast",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"vignetteStretch",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"vignetteCenterX",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"vignetteCenterY",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"vignetteWeight",void 0),(0,i.Cg)([(0,r.qK)()],d.prototype,"vignetteColor",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"vignetteCameraFov",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"_vignetteBlendMode",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"_vignetteEnabled",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"_ditheringEnabled",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"_ditheringIntensity",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"_skipFinalColorClamp",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"_applyByPostProcess",void 0),(0,i.Cg)([(0,r.lK)()],d.prototype,"_isEnabled",void 0),o.p._ImageProcessingConfigurationParser=d.Parse,(0,u.Y5)("BABYLON.ImageProcessingConfiguration",d)},8986:(e,t,s)=>{s.d(t,{i:()=>g});var i=s(5524),r=s(9259),n=s(998),a=s(9848),o=s(6315),h=s(1846),l=s(935),c=s(1137),u=s(4100),d=s(5476),_=s(6877);class f{constructor(){this.reset()}reset(){this.enabled=!1,this.mask=255,this.func=519,this.funcRef=1,this.funcMask=255,this.opStencilFail=7680,this.opDepthFail=7680,this.opStencilDepthPass=7681}get func(){return this._func}set func(e){this._func=e}get funcRef(){return this._funcRef}set funcRef(e){this._funcRef=e}get funcMask(){return this._funcMask}set funcMask(e){this._funcMask=e}get opStencilFail(){return this._opStencilFail}set opStencilFail(e){this._opStencilFail=e}get opDepthFail(){return this._opDepthFail}set opDepthFail(e){this._opDepthFail=e}get opStencilDepthPass(){return this._opStencilDepthPass}set opStencilDepthPass(e){this._opStencilDepthPass=e}get mask(){return this._mask}set mask(e){this._mask=e}get enabled(){return this._enabled}set enabled(e){this._enabled=e}getClassName(){return"MaterialStencilState"}copyTo(e){_.p.Clone((()=>e),this)}serialize(){return _.p.Serialize(this)}parse(e,t,s){_.p.Parse((()=>this),e,t,s)}}(0,i.Cg)([(0,r.lK)()],f.prototype,"func",null),(0,i.Cg)([(0,r.lK)()],f.prototype,"funcRef",null),(0,i.Cg)([(0,r.lK)()],f.prototype,"funcMask",null),(0,i.Cg)([(0,r.lK)()],f.prototype,"opStencilFail",null),(0,i.Cg)([(0,r.lK)()],f.prototype,"opDepthFail",null),(0,i.Cg)([(0,r.lK)()],f.prototype,"opStencilDepthPass",null),(0,i.Cg)([(0,r.lK)()],f.prototype,"mask",null),(0,i.Cg)([(0,r.lK)()],f.prototype,"enabled",null);var p=s(467);class g{get shaderLanguage(){return this._shaderLanguage}get canRenderToMRT(){return!1}set alpha(e){if(this._alpha===e)return;const t=this._alpha;this._alpha=e,1!==t&&1!==e||this.markAsDirty(g.MiscDirtyFlag+g.PrePassDirtyFlag)}get alpha(){return this._alpha}set backFaceCulling(e){this._backFaceCulling!==e&&(this._backFaceCulling=e,this.markAsDirty(g.TextureDirtyFlag))}get backFaceCulling(){return this._backFaceCulling}set cullBackFaces(e){this._cullBackFaces!==e&&(this._cullBackFaces=e,this.markAsDirty(g.TextureDirtyFlag))}get cullBackFaces(){return this._cullBackFaces}get blockDirtyMechanism(){return this._blockDirtyMechanism}set blockDirtyMechanism(e){this._blockDirtyMechanism!==e&&(this._blockDirtyMechanism=e,e||this.markDirty())}atomicMaterialsUpdate(e){this.blockDirtyMechanism=!0;try{e(this)}finally{this.blockDirtyMechanism=!1}}get hasRenderTargetTextures(){return this._eventInfo.hasRenderTargetTextures=!1,this._callbackPluginEventHasRenderTargetTextures(this._eventInfo),this._eventInfo.hasRenderTargetTextures}set onDispose(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)}get onBindObservable(){return this._onBindObservable||(this._onBindObservable=new a.cP),this._onBindObservable}set onBind(e){this._onBindObserver&&this.onBindObservable.remove(this._onBindObserver),this._onBindObserver=this.onBindObservable.add(e)}get onUnBindObservable(){return this._onUnBindObservable||(this._onUnBindObservable=new a.cP),this._onUnBindObservable}get onEffectCreatedObservable(){return this._onEffectCreatedObservable||(this._onEffectCreatedObservable=new a.cP),this._onEffectCreatedObservable}set alphaMode(e){this._alphaMode!==e&&(this._alphaMode=e,this.markAsDirty(g.TextureDirtyFlag))}get alphaMode(){return this._alphaMode}set needDepthPrePass(e){this._needDepthPrePass!==e&&(this._needDepthPrePass=e,this._needDepthPrePass&&(this.checkReadyOnEveryCall=!0))}get needDepthPrePass(){return this._needDepthPrePass}get isPrePassCapable(){return!1}set fogEnabled(e){this._fogEnabled!==e&&(this._fogEnabled=e,this.markAsDirty(g.MiscDirtyFlag))}get fogEnabled(){return this._fogEnabled}get wireframe(){switch(this._fillMode){case g.WireFrameFillMode:case g.LineListDrawMode:case g.LineLoopDrawMode:case g.LineStripDrawMode:return!0}return this._scene.forceWireframe}set wireframe(e){this.fillMode=e?g.WireFrameFillMode:g.TriangleFillMode}get pointsCloud(){switch(this._fillMode){case g.PointFillMode:case g.PointListDrawMode:return!0}return this._scene.forcePointsCloud}set pointsCloud(e){this.fillMode=e?g.PointFillMode:g.TriangleFillMode}get fillMode(){return this._fillMode}set fillMode(e){this._fillMode!==e&&(this._fillMode=e,this.markAsDirty(g.MiscDirtyFlag))}get useLogarithmicDepth(){return this._useLogarithmicDepth}set useLogarithmicDepth(e){const t=this.getScene().getEngine().getCaps().fragmentDepthSupported;e&&!t&&c.V.Warn("Logarithmic depth has been requested for a material on a device that doesn't support it."),this._useLogarithmicDepth=e&&t,this._markAllSubMeshesAsMiscDirty()}_getDrawWrapper(){return this._drawWrapper}_setDrawWrapper(e){this._drawWrapper=e}constructor(e,t,s,i=!1){this.shadowDepthWrapper=null,this.allowShaderHotSwapping=!0,this._shaderLanguage=0,this._forceGLSL=!1,this.metadata=null,this.reservedDataStore=null,this.checkReadyOnEveryCall=!1,this.checkReadyOnlyOnce=!1,this.state="",this._alpha=1,this._backFaceCulling=!0,this._cullBackFaces=!0,this._blockDirtyMechanism=!1,this.sideOrientation=null,this.onCompiled=null,this.onError=null,this.getRenderTargetTextures=null,this.doNotSerialize=!1,this._storeEffectOnSubMeshes=!1,this.animations=null,this.onDisposeObservable=new a.cP,this._onDisposeObserver=null,this._onUnBindObservable=null,this._onBindObserver=null,this._alphaMode=2,this._needDepthPrePass=!1,this.disableDepthWrite=!1,this.disableColorWrite=!1,this.forceDepthWrite=!1,this.depthFunction=0,this.separateCullingPass=!1,this._fogEnabled=!0,this.pointSize=1,this.zOffset=0,this.zOffsetUnits=0,this.stencil=new f,this._useUBO=!1,this._fillMode=g.TriangleFillMode,this._cachedDepthWriteState=!1,this._cachedColorWriteState=!1,this._cachedDepthFunctionState=0,this._indexInSceneMaterialArray=-1,this.meshMap=null,this._parentContainer=null,this._uniformBufferLayoutBuilt=!1,this._eventInfo={},this._callbackPluginEventGeneric=()=>{},this._callbackPluginEventIsReadyForSubMesh=()=>{},this._callbackPluginEventPrepareDefines=()=>{},this._callbackPluginEventPrepareDefinesBeforeAttributes=()=>{},this._callbackPluginEventHardBindForSubMesh=()=>{},this._callbackPluginEventBindForSubMesh=()=>{},this._callbackPluginEventHasRenderTargetTextures=()=>{},this._callbackPluginEventFillRenderTargetTextures=()=>{},this._forceAlphaTest=!1,this._transparencyMode=null,this.name=e;const r=t||o.q.LastCreatedScene;r&&(this._scene=r,this._dirtyCallbacks={},this._forceGLSL=i,this._dirtyCallbacks[1]=this._markAllSubMeshesAsTexturesDirty.bind(this),this._dirtyCallbacks[2]=this._markAllSubMeshesAsLightsDirty.bind(this),this._dirtyCallbacks[4]=this._markAllSubMeshesAsFresnelDirty.bind(this),this._dirtyCallbacks[8]=this._markAllSubMeshesAsAttributesDirty.bind(this),this._dirtyCallbacks[16]=this._markAllSubMeshesAsMiscDirty.bind(this),this._dirtyCallbacks[32]=this._markAllSubMeshesAsPrePassDirty.bind(this),this._dirtyCallbacks[63]=this._markAllSubMeshesAsAllDirty.bind(this),this.id=e||n.S0.RandomId(),this.uniqueId=this._scene.getUniqueId(),this._materialContext=this._scene.getEngine().createMaterialContext(),this._drawWrapper=new d.E(this._scene.getEngine(),!1),this._drawWrapper.materialContext=this._materialContext,this._uniformBuffer=new l.D(this._scene.getEngine(),void 0,void 0,e),this._useUBO=this.getScene().getEngine().supportsUniformBuffers,this._createUniformBuffer(),s||this._scene.addMaterial(this),this._scene.useMaterialMeshMap&&(this.meshMap={}),g.OnEventObservable.notifyObservers(this,1))}_createUniformBuffer(){const e=this.getScene().getEngine();this._uniformBuffer?.dispose(),e.isWebGPU&&!this._forceGLSL?(this._uniformBuffer=new l.D(e,void 0,void 0,this.name,!0),this._shaderLanguage=1):this._uniformBuffer=new l.D(this._scene.getEngine(),void 0,void 0,this.name),this._uniformBufferLayoutBuilt=!1}toString(e){return"Name: "+this.name}getClassName(){return"Material"}get _isMaterial(){return!0}get isFrozen(){return this.checkReadyOnlyOnce}freeze(){this.markDirty(),this.checkReadyOnlyOnce=!0}unfreeze(){this.markDirty(),this.checkReadyOnlyOnce=!1}isReady(e,t){return!0}isReadyForSubMesh(e,t,s){const i=t.materialDefines;return!!i&&(this._eventInfo.isReadyForSubMesh=!0,this._eventInfo.defines=i,this._callbackPluginEventIsReadyForSubMesh(this._eventInfo),this._eventInfo.isReadyForSubMesh)}getEffect(){return this._drawWrapper.effect}getScene(){return this._scene}_getEffectiveOrientation(e){return null!==this.sideOrientation?this.sideOrientation:e.sideOrientation}get transparencyMode(){return this._transparencyMode}set transparencyMode(e){this._transparencyMode!==e&&(this._transparencyMode=e,this._forceAlphaTest=e===g.MATERIAL_ALPHATESTANDBLEND,this._markAllSubMeshesAsTexturesAndMiscDirty())}get _disableAlphaBlending(){return this._transparencyMode===g.MATERIAL_OPAQUE||this._transparencyMode===g.MATERIAL_ALPHATEST}needAlphaBlending(){return!this._disableAlphaBlending&&this.alpha<1}needAlphaBlendingForMesh(e){return e.visibility<1||!this._disableAlphaBlending&&(e.hasVertexAlpha||this.needAlphaBlending())}needAlphaTesting(){return!!this._forceAlphaTest}_shouldTurnAlphaTestOn(e){return!this.needAlphaBlendingForMesh(e)&&this.needAlphaTesting()}getAlphaTestTexture(){return null}markDirty(e=!1){const t=this.getScene().meshes;for(const s of t)if(s.subMeshes)for(const t of s.subMeshes)if(t.getMaterial()===this)for(const s of t._drawWrappers)s&&this._materialContext===s.materialContext&&(s._wasPreviouslyReady=!1,s._wasPreviouslyUsingInstances=null,s._forceRebindOnNextCall=e);e&&this.markAsDirty(g.AllDirtyFlag)}_preBind(e,t=null){const s=this._scene.getEngine(),i=(null==t?this.sideOrientation:t)===g.ClockWiseSideOrientation;return s.enableEffect(e||this._getDrawWrapper()),s.setState(this.backFaceCulling,this.zOffset,!1,i,this._scene._mirroredCameraPosition?!this.cullBackFaces:this.cullBackFaces,this.stencil,this.zOffsetUnits),i}bind(e,t){}buildUniformLayout(){const e=this._uniformBuffer;this._eventInfo.ubo=e,this._callbackPluginEventGeneric(8,this._eventInfo),e.create(),this._uniformBufferLayoutBuilt=!0}bindForSubMesh(e,t,s){const i=s._drawWrapper;this._eventInfo.subMesh=s,this._callbackPluginEventBindForSubMesh(this._eventInfo),i._forceRebindOnNextCall=!1}bindOnlyWorldMatrix(e){}bindView(e){this._useUBO?this._needToBindSceneUbo=!0:e.setMatrix("view",this.getScene().getViewMatrix())}bindViewProjection(e){this._useUBO?this._needToBindSceneUbo=!0:(e.setMatrix("viewProjection",this.getScene().getTransformMatrix()),e.setMatrix("projection",this.getScene().getProjectionMatrix()))}bindEyePosition(e,t){this._useUBO?this._needToBindSceneUbo=!0:this._scene.bindEyePosition(e,t)}_afterBind(e,t=null,s){if(this._scene._cachedMaterial=this,this._needToBindSceneUbo&&t&&(this._needToBindSceneUbo=!1,(0,p._8)(t,this.getScene().getSceneUniformBuffer()),this._scene.finalizeSceneUbo()),this._scene._cachedVisibility=e?e.visibility:1,this._onBindObservable&&e&&this._onBindObservable.notifyObservers(e),this.disableDepthWrite){const e=this._scene.getEngine();this._cachedDepthWriteState=e.getDepthWrite(),e.setDepthWrite(!1)}if(this.disableColorWrite){const e=this._scene.getEngine();this._cachedColorWriteState=e.getColorWrite(),e.setColorWrite(!1)}if(0!==this.depthFunction){const e=this._scene.getEngine();this._cachedDepthFunctionState=e.getDepthFunction()||0,e.setDepthFunction(this.depthFunction)}}unbind(){this._onUnBindObservable&&this._onUnBindObservable.notifyObservers(this),0!==this.depthFunction&&this._scene.getEngine().setDepthFunction(this._cachedDepthFunctionState),this.disableDepthWrite&&this._scene.getEngine().setDepthWrite(this._cachedDepthWriteState),this.disableColorWrite&&this._scene.getEngine().setColorWrite(this._cachedColorWriteState)}getAnimatables(){return this._eventInfo.animatables=[],this._callbackPluginEventGeneric(256,this._eventInfo),this._eventInfo.animatables}getActiveTextures(){return this._eventInfo.activeTextures=[],this._callbackPluginEventGeneric(512,this._eventInfo),this._eventInfo.activeTextures}hasTexture(e){return this._eventInfo.hasTexture=!1,this._eventInfo.texture=e,this._callbackPluginEventGeneric(1024,this._eventInfo),this._eventInfo.hasTexture}clone(e){return null}_clonePlugins(e,t){const s={};if(this._serializePlugins(s),g._ParsePlugins(s,e,this._scene,t),this.pluginManager)for(const t of this.pluginManager._plugins){const s=e.pluginManager.getPlugin(t.name);s&&t.copyTo(s)}}getBindedMeshes(){if(this.meshMap){const e=[];for(const t in this.meshMap){const s=this.meshMap[t];s&&e.push(s)}return e}return this._scene.meshes.filter((e=>e.material===this))}forceCompilation(e,t,s,i){const r={clipPlane:!1,useInstances:!1,...s},n=this.getScene(),a=this.allowShaderHotSwapping;this.allowShaderHotSwapping=!1;const o=()=>{if(!this._scene||!this._scene.getEngine())return;const s=n.clipPlane;if(r.clipPlane&&(n.clipPlane=new u.Z(0,0,0,1)),this._storeEffectOnSubMeshes){let s=!0,n=null;if(e.subMeshes){const t=new h.K(0,0,0,0,0,e,void 0,!1,!1);t.materialDefines&&(t.materialDefines._renderId=-1),this.isReadyForSubMesh(e,t,r.useInstances)||(t.effect&&t.effect.getCompilationError()&&t.effect.allFallbacksProcessed()?n=t.effect.getCompilationError():(s=!1,setTimeout(o,16)))}s&&(this.allowShaderHotSwapping=a,n&&i&&i(n),t&&t(this))}else this.isReady()?(this.allowShaderHotSwapping=a,t&&t(this)):setTimeout(o,16);r.clipPlane&&(n.clipPlane=s)};o()}forceCompilationAsync(e,t){return new Promise(((s,i)=>{this.forceCompilation(e,(()=>{s()}),t,(e=>{i(e)}))}))}markAsDirty(e){this.getScene().blockMaterialDirtyMechanism||this._blockDirtyMechanism||(g._DirtyCallbackArray.length=0,e&g.TextureDirtyFlag&&g._DirtyCallbackArray.push(g._TextureDirtyCallBack),e&g.LightDirtyFlag&&g._DirtyCallbackArray.push(g._LightsDirtyCallBack),e&g.FresnelDirtyFlag&&g._DirtyCallbackArray.push(g._FresnelDirtyCallBack),e&g.AttributesDirtyFlag&&g._DirtyCallbackArray.push(g._AttributeDirtyCallBack),e&g.MiscDirtyFlag&&g._DirtyCallbackArray.push(g._MiscDirtyCallBack),e&g.PrePassDirtyFlag&&g._DirtyCallbackArray.push(g._PrePassDirtyCallBack),g._DirtyCallbackArray.length&&this._markAllSubMeshesAsDirty(g._RunDirtyCallBacks),this.getScene().resetCachedMaterial())}resetDrawCache(){const e=this.getScene().meshes;for(const t of e)if(t.subMeshes)for(const e of t.subMeshes)e.getMaterial()===this&&e.resetDrawCache()}_markAllSubMeshesAsDirty(e){if(this.getScene().blockMaterialDirtyMechanism||this._blockDirtyMechanism)return;const t=this.getScene().meshes;for(const s of t)if(s.subMeshes)for(const t of s.subMeshes)if(t.getMaterial(!1)===this)for(const s of t._drawWrappers)s&&s.defines&&s.defines.markAllAsDirty&&this._materialContext===s.materialContext&&e(s.defines)}_markScenePrePassDirty(){if(this.getScene().blockMaterialDirtyMechanism||this._blockDirtyMechanism)return;const e=this.getScene().enablePrePassRenderer();e&&e.markAsDirty()}_markAllSubMeshesAsAllDirty(){this._markAllSubMeshesAsDirty(g._AllDirtyCallBack)}_markAllSubMeshesAsImageProcessingDirty(){this._markAllSubMeshesAsDirty(g._ImageProcessingDirtyCallBack)}_markAllSubMeshesAsTexturesDirty(){this._markAllSubMeshesAsDirty(g._TextureDirtyCallBack)}_markAllSubMeshesAsFresnelDirty(){this._markAllSubMeshesAsDirty(g._FresnelDirtyCallBack)}_markAllSubMeshesAsFresnelAndMiscDirty(){this._markAllSubMeshesAsDirty(g._FresnelAndMiscDirtyCallBack)}_markAllSubMeshesAsLightsDirty(){this._markAllSubMeshesAsDirty(g._LightsDirtyCallBack)}_markAllSubMeshesAsAttributesDirty(){this._markAllSubMeshesAsDirty(g._AttributeDirtyCallBack)}_markAllSubMeshesAsMiscDirty(){this._markAllSubMeshesAsDirty(g._MiscDirtyCallBack)}_markAllSubMeshesAsPrePassDirty(){this._markAllSubMeshesAsDirty(g._MiscDirtyCallBack)}_markAllSubMeshesAsTexturesAndMiscDirty(){this._markAllSubMeshesAsDirty(g._TextureAndMiscDirtyCallBack)}_checkScenePerformancePriority(){if(0!==this._scene.performancePriority){this.checkReadyOnlyOnce=!0;const e=this._scene.onScenePerformancePriorityChangedObservable.addOnce((()=>{this.checkReadyOnlyOnce=!1}));this.onDisposeObservable.add((()=>{this._scene.onScenePerformancePriorityChangedObservable.remove(e)}))}}setPrePassRenderer(e){return!1}dispose(e,t,s){const i=this.getScene();if(i.stopAnimation(this),i.freeProcessedMaterials(),i.removeMaterial(this),this._eventInfo.forceDisposeTextures=t,this._callbackPluginEventGeneric(2,this._eventInfo),this._parentContainer){const e=this._parentContainer.materials.indexOf(this);e>-1&&this._parentContainer.materials.splice(e,1),this._parentContainer=null}if(!0!==s)if(this.meshMap)for(const t in this.meshMap){const s=this.meshMap[t];s&&(s.material=null,this.releaseVertexArrayObject(s,e))}else{const t=i.meshes;for(const s of t)s.material!==this||s.sourceMesh||(s.material=null,this.releaseVertexArrayObject(s,e))}this._uniformBuffer.dispose(),e&&this._drawWrapper.effect&&(this._storeEffectOnSubMeshes||this._drawWrapper.effect.dispose(),this._drawWrapper.effect=null),this.metadata=null,this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this._onBindObservable&&this._onBindObservable.clear(),this._onUnBindObservable&&this._onUnBindObservable.clear(),this._onEffectCreatedObservable&&this._onEffectCreatedObservable.clear(),this._eventInfo&&(this._eventInfo={})}releaseVertexArrayObject(e,t){const s=e.geometry;if(s)if(this._storeEffectOnSubMeshes){if(e.subMeshes)for(const i of e.subMeshes)s._releaseVertexArrayObject(i.effect),t&&i.effect&&i.effect.dispose()}else s._releaseVertexArrayObject(this._drawWrapper.effect)}serialize(){const e=_.p.Serialize(this);return e.stencil=this.stencil.serialize(),e.uniqueId=this.uniqueId,this._serializePlugins(e),e}_serializePlugins(e){if(e.plugins={},this.pluginManager)for(const t of this.pluginManager._plugins)e.plugins[t.getClassName()]=t.serialize()}static Parse(e,t,s){if(e.customType){if("BABYLON.PBRMaterial"===e.customType&&e.overloadedAlbedo&&(e.customType="BABYLON.LegacyPBRMaterial",!BABYLON.LegacyPBRMaterial))return c.V.Error("Your scene is trying to load a legacy version of the PBRMaterial, please, include it from the materials library."),null}else e.customType="BABYLON.StandardMaterial";const i=n.S0.Instantiate(e.customType).Parse(e,t,s);return i._loadedUniqueId=e.uniqueId,i}static _ParsePlugins(e,t,s,i){if(e.plugins)for(const r in e.plugins){const a=e.plugins[r];let o=t.pluginManager?.getPlugin(a.name);if(!o){const e=n.S0.Instantiate("BABYLON."+r);e&&(o=new e(t))}o?.parse(a,s,i)}}}g.TriangleFillMode=0,g.WireFrameFillMode=1,g.PointFillMode=2,g.PointListDrawMode=3,g.LineListDrawMode=4,g.LineLoopDrawMode=5,g.LineStripDrawMode=6,g.TriangleStripDrawMode=7,g.TriangleFanDrawMode=8,g.ClockWiseSideOrientation=0,g.CounterClockWiseSideOrientation=1,g.TextureDirtyFlag=1,g.LightDirtyFlag=2,g.FresnelDirtyFlag=4,g.AttributesDirtyFlag=8,g.MiscDirtyFlag=16,g.PrePassDirtyFlag=32,g.AllDirtyFlag=63,g.MATERIAL_OPAQUE=0,g.MATERIAL_ALPHATEST=1,g.MATERIAL_ALPHABLEND=2,g.MATERIAL_ALPHATESTANDBLEND=3,g.MATERIAL_NORMALBLENDMETHOD_WHITEOUT=0,g.MATERIAL_NORMALBLENDMETHOD_RNM=1,g.OnEventObservable=new a.cP,g._AllDirtyCallBack=e=>e.markAllAsDirty(),g._ImageProcessingDirtyCallBack=e=>e.markAsImageProcessingDirty(),g._TextureDirtyCallBack=e=>e.markAsTexturesDirty(),g._FresnelDirtyCallBack=e=>e.markAsFresnelDirty(),g._MiscDirtyCallBack=e=>e.markAsMiscDirty(),g._PrePassDirtyCallBack=e=>e.markAsPrePassDirty(),g._LightsDirtyCallBack=e=>e.markAsLightDirty(),g._AttributeDirtyCallBack=e=>e.markAsAttributesDirty(),g._FresnelAndMiscDirtyCallBack=e=>{g._FresnelDirtyCallBack(e),g._MiscDirtyCallBack(e)},g._TextureAndMiscDirtyCallBack=e=>{g._TextureDirtyCallBack(e),g._MiscDirtyCallBack(e)},g._DirtyCallbackArray=[],g._RunDirtyCallBacks=e=>{for(const t of g._DirtyCallbackArray)t(e)},(0,i.Cg)([(0,r.lK)()],g.prototype,"id",void 0),(0,i.Cg)([(0,r.lK)()],g.prototype,"uniqueId",void 0),(0,i.Cg)([(0,r.lK)()],g.prototype,"name",void 0),(0,i.Cg)([(0,r.lK)()],g.prototype,"metadata",void 0),(0,i.Cg)([(0,r.lK)()],g.prototype,"checkReadyOnEveryCall",void 0),(0,i.Cg)([(0,r.lK)()],g.prototype,"checkReadyOnlyOnce",void 0),(0,i.Cg)([(0,r.lK)()],g.prototype,"state",void 0),(0,i.Cg)([(0,r.lK)("alpha")],g.prototype,"_alpha",void 0),(0,i.Cg)([(0,r.lK)("backFaceCulling")],g.prototype,"_backFaceCulling",void 0),(0,i.Cg)([(0,r.lK)("cullBackFaces")],g.prototype,"_cullBackFaces",void 0),(0,i.Cg)([(0,r.lK)()],g.prototype,"sideOrientation",void 0),(0,i.Cg)([(0,r.lK)("alphaMode")],g.prototype,"_alphaMode",void 0),(0,i.Cg)([(0,r.lK)()],g.prototype,"_needDepthPrePass",void 0),(0,i.Cg)([(0,r.lK)()],g.prototype,"disableDepthWrite",void 0),(0,i.Cg)([(0,r.lK)()],g.prototype,"disableColorWrite",void 0),(0,i.Cg)([(0,r.lK)()],g.prototype,"forceDepthWrite",void 0),(0,i.Cg)([(0,r.lK)()],g.prototype,"depthFunction",void 0),(0,i.Cg)([(0,r.lK)()],g.prototype,"separateCullingPass",void 0),(0,i.Cg)([(0,r.lK)("fogEnabled")],g.prototype,"_fogEnabled",void 0),(0,i.Cg)([(0,r.lK)()],g.prototype,"pointSize",void 0),(0,i.Cg)([(0,r.lK)()],g.prototype,"zOffset",void 0),(0,i.Cg)([(0,r.lK)()],g.prototype,"zOffsetUnits",void 0),(0,i.Cg)([(0,r.lK)()],g.prototype,"pointsCloud",null),(0,i.Cg)([(0,r.lK)()],g.prototype,"fillMode",null),(0,i.Cg)([(0,r.lK)()],g.prototype,"useLogarithmicDepth",null),(0,i.Cg)([(0,r.lK)()],g.prototype,"transparencyMode",null)},9526:(e,t,s)=>{s.d(t,{M:()=>i});class i{constructor(e){if(this._keys=[],this._isDirty=!0,this._areLightsDirty=!0,this._areLightsDisposed=!1,this._areAttributesDirty=!0,this._areTexturesDirty=!0,this._areFresnelDirty=!0,this._areMiscDirty=!0,this._arePrePassDirty=!0,this._areImageProcessingDirty=!0,this._normals=!1,this._uvs=!1,this._needNormals=!1,this._needUVs=!1,this._externalProperties=e,e)for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&this._setDefaultValue(t)}get isDirty(){return this._isDirty}markAsProcessed(){this._isDirty=!1,this._areAttributesDirty=!1,this._areTexturesDirty=!1,this._areFresnelDirty=!1,this._areLightsDirty=!1,this._areLightsDisposed=!1,this._areMiscDirty=!1,this._arePrePassDirty=!1,this._areImageProcessingDirty=!1}markAsUnprocessed(){this._isDirty=!0}markAllAsDirty(){this._areTexturesDirty=!0,this._areAttributesDirty=!0,this._areLightsDirty=!0,this._areFresnelDirty=!0,this._areMiscDirty=!0,this._arePrePassDirty=!1,this._areImageProcessingDirty=!0,this._isDirty=!0}markAsImageProcessingDirty(){this._areImageProcessingDirty=!0,this._isDirty=!0}markAsLightDirty(e=!1){this._areLightsDirty=!0,this._areLightsDisposed=this._areLightsDisposed||e,this._isDirty=!0}markAsAttributesDirty(){this._areAttributesDirty=!0,this._isDirty=!0}markAsTexturesDirty(){this._areTexturesDirty=!0,this._isDirty=!0}markAsFresnelDirty(){this._areFresnelDirty=!0,this._isDirty=!0}markAsMiscDirty(){this._areMiscDirty=!0,this._isDirty=!0}markAsPrePassDirty(){this._arePrePassDirty=!0,this._isDirty=!0}rebuild(){this._keys.length=0;for(const e of Object.keys(this))"_"!==e[0]&&this._keys.push(e);if(this._externalProperties)for(const e in this._externalProperties)-1===this._keys.indexOf(e)&&this._keys.push(e)}isEqual(e){if(this._keys.length!==e._keys.length)return!1;for(let t=0;tthis._setDefaultValue(e)))}_setDefaultValue(e){const t=this._externalProperties?.[e]?.type??typeof this[e],s=this._externalProperties?.[e]?.default;switch(t){case"number":this[e]=s??0;break;case"string":this[e]=s??"";break;default:this[e]=s??!1}}toString(){let e="";for(let t=0;t{s.d(t,{Bb:()=>L,DL:()=>c,ER:()=>M,IF:()=>_,J2:()=>b,MF:()=>d,N4:()=>F,Nc:()=>O,OR:()=>S,RL:()=>A,VO:()=>D,YT:()=>m,Yy:()=>u,_8:()=>g,az:()=>v,c4:()=>y,f$:()=>E,fm:()=>P,mA:()=>T,nR:()=>p,ni:()=>R,qB:()=>I,te:()=>f});var i=s(1137),r=s(6041),n=s(6315),a=s(5515),o=s(492);const h=r.v9.Black(),l={NUM_MORPH_INFLUENCERS:0};function c(e,t,s){if(!e||e.LOGARITHMICDEPTH||e.indexOf&&e.indexOf("LOGARITHMICDEPTH")>=0){const e=s.activeCamera;1===e.mode&&i.V.Error("Logarithmic depth is not compatible with orthographic cameras!",20),t.setFloat("logarithmicDepthConstant",2/(Math.log(e.maxZ+1)/Math.LN2))}}function u(e,t,s,i=!1){s&&e.fogEnabled&&(!t||t.applyFog)&&0!==e.fogMode&&(s.setFloat4("vFogInfos",e.fogMode,e.fogStart,e.fogEnd,e.fogDensity),i?(e.fogColor.toLinearSpaceToRef(h,e.getEngine().useExactSrgbConversions),s.setColor3("vFogColor",h)):s.setColor3("vFogColor",e.fogColor))}function d(e,t,s){l.NUM_MORPH_INFLUENCERS=s,_(e,t,l)}function _(e,t,s){const r=s.NUM_MORPH_INFLUENCERS;if(r>0&&n.q.LastCreatedEngine){const a=n.q.LastCreatedEngine.getCaps().maxVertexAttribs,o=t.morphTargetManager;if(o?.isUsingTextureForTargets)return;const h=o&&o.supportsNormals&&s.NORMAL,l=o&&o.supportsTangents&&s.TANGENT,c=o&&o.supportsUVs&&s.UV1;for(let s=0;sa&&i.V.Error("Cannot add more vertex attributes for mesh "+t.name)}}function f(e,t=!1){e.push("world0"),e.push("world1"),e.push("world2"),e.push("world3"),t&&(e.push("previousWorld0"),e.push("previousWorld1"),e.push("previousWorld2"),e.push("previousWorld3"))}function p(e,t){const s=e.morphTargetManager;e&&s&&t.setFloatArray("morphTargetInfluences",s.influences)}function g(e,t){t.bindToEffect(e,"Scene")}function m(e,t,s){t._needUVs=!0,t[s]=!0,e.optimizeUVAllocation&&e.getTextureMatrix().isIdentityAs3x2()?(t[s+"DIRECTUV"]=e.coordinatesIndex+1,t["MAINUV"+(e.coordinatesIndex+1)]=!0):t[s+"DIRECTUV"]=0}function T(e,t,s){const i=e.getTextureMatrix();t.updateMatrix(s+"Matrix",i)}function b(e,t,s){s.BAKED_VERTEX_ANIMATION_TEXTURE&&s.INSTANCES&&e.push("bakedVertexAnimationSettingsInstanced")}function E(e,t,s){var i;if(t&&e&&(e.computeBonesUsingShaders&&t._bonesComputationForcedToCPU&&(e.computeBonesUsingShaders=!1),e.useBones&&e.computeBonesUsingShaders&&e.skeleton)){const r=e.skeleton;if(r.isUsingTextureForMatrices&&t.getUniformIndex("boneTextureWidth")>-1){const s=r.getTransformMatrixTexture(e);t.setTexture("boneSampler",s),t.setFloat("boneTextureWidth",4*(r.bones.length+1))}else{const n=r.getTransformMatrices(e);n&&(t.setMatrices("mBones",n),s&&e.getScene().prePassRenderer&&e.getScene().prePassRenderer.getIndex(2)&&(s.previousBones[e.uniqueId]||(s.previousBones[e.uniqueId]=n.slice()),t.setMatrices("mPreviousBones",s.previousBones[e.uniqueId]),i=n,s.previousBones[e.uniqueId].set(i)))}}}function x(e,t,s,i,r,n=!0){e._bindLight(t,s,i,r,n)}function A(e,t,s,i,r=4){const n=Math.min(t.lightSources.length,r);for(let r=0;r0&&(i.addCPUSkinningFallback(0,t),e.push("matricesIndices"),e.push("matricesWeights"),s.NUM_BONE_INFLUENCERS>4&&(e.push("matricesIndicesExtra"),e.push("matricesWeightsExtra")))}function M(e,t){(t.INSTANCES||t.THIN_INSTANCES)&&f(e,!!t.PREPASS_VELOCITY),t.INSTANCESCOLOR&&e.push("instanceColor")}function y(e,t,s=4,i=0){let r=0;for(let n=0;n0&&(r=i+n,t.addFallback(r,"LIGHT"+n)),e.SHADOWS||(e["SHADOW"+n]&&t.addFallback(i,"SHADOW"+n),e["SHADOWPCF"+n]&&t.addFallback(i,"SHADOWPCF"+n),e["SHADOWPCSS"+n]&&t.addFallback(i,"SHADOWPCSS"+n),e["SHADOWPOISSON"+n]&&t.addFallback(i,"SHADOWPOISSON"+n),e["SHADOWESM"+n]&&t.addFallback(i,"SHADOWESM"+n),e["SHADOWCLOSEESM"+n]&&t.addFallback(i,"SHADOWCLOSEESM"+n));return r++}function P(e,t,s,i,r,n,a,o=!1){a._areMiscDirty&&(a.LOGARITHMICDEPTH=s,a.POINTSIZE=i,a.FOG=r&&function(e,t){return t.fogEnabled&&e.applyFog&&0!==t.fogMode}(e,t),a.NONUNIFORMSCALING=e.nonUniformScaling,a.ALPHATEST=n,a.DECAL_AFTER_DETAIL=o)}function v(e,t,s,i,r=4,n=!1){if(!s._areLightsDirty)return s._needNormals;let a=0;const o={needNormals:s._needNormals,needRebuild:!1,lightmapMode:!1,shadowEnabled:!1,specularEnabled:!1};if(e.lightsEnabled&&!n)for(const n of t.lightSources)if(C(e,t,n,a,s,i,o),a++,a===r)break;s.SPECULARTERM=o.specularEnabled,s.SHADOWS=o.shadowEnabled;for(let e=a;e0&&(o.shadowEnabled=!0,t.prepareDefines(r,i))}}s.lightmapMode!=a.c.LIGHTMAP_DEFAULT?(o.lightmapMode=!0,r["LIGHTMAPEXCLUDED"+i]=!0,r["LIGHTMAPNOSPECULAR"+i]=s.lightmapMode==a.c.LIGHTMAP_SHADOWSONLY):(r["LIGHTMAPEXCLUDED"+i]=!1,r["LIGHTMAPNOSPECULAR"+i]=!1)}function S(e,t,s,i,r,n=null,a=!1){let h=function(e,t){let s=!1;if(e.activeCamera){const i=t.CAMERA_ORTHOGRAPHIC?1:0,r=t.CAMERA_PERSPECTIVE?1:0,n=1===e.activeCamera.mode?1:0,a=0===e.activeCamera.mode?1:0;(i^n||r^a)&&(t.CAMERA_ORTHOGRAPHIC=1===n,t.CAMERA_PERSPECTIVE=1===a,s=!0)}return s}(e,i);!1!==n&&(h=(0,o.Eq)(s,e,i)),i.DEPTHPREPASS!==!t.getColorWrite()&&(i.DEPTHPREPASS=!i.DEPTHPREPASS,h=!0),i.INSTANCES!==r&&(i.INSTANCES=r,h=!0),i.THIN_INSTANCES!==a&&(i.THIN_INSTANCES=a,h=!0),h&&i.markAsUnprocessed()}function I(e,t,s,i,r=!1,n=!0,a=!0){if(!t._areAttributesDirty&&t._needNormals===t._normals&&t._needUVs===t._uvs)return!1;t._normals=t._needNormals,t._uvs=t._needUVs,t.NORMAL=t._needNormals&&e.isVerticesDataPresent("normal"),t._needNormals&&e.isVerticesDataPresent("tangent")&&(t.TANGENT=!0);for(let s=1;s<=6;++s)t["UV"+s]=!!t._needUVs&&e.isVerticesDataPresent(`uv${1===s?"":s}`);if(s){const s=e.useVertexColors&&e.isVerticesDataPresent("color");t.VERTEXCOLOR=s,t.VERTEXALPHA=e.hasVertexAlpha&&s&&n}return e.isVerticesDataPresent("instanceColor")&&(e.hasInstances||e.hasThinInstances)&&(t.INSTANCESCOLOR=!0),i&&function(e,t){if(e.useBones&&e.computeBonesUsingShaders&&e.skeleton){t.NUM_BONE_INFLUENCERS=e.numBoneInfluencers;const s=void 0!==t.BONETEXTURE;if(e.skeleton.isUsingTextureForMatrices&&s)t.BONETEXTURE=!0;else{t.BonesPerMesh=e.skeleton.bones.length+1,t.BONETEXTURE=!s&&void 0;const i=e.getScene().prePassRenderer;if(i&&i.enabled){const s=-1===i.excludedSkinnedMesh.indexOf(e);t.BONES_VELOCITY_ENABLED=s}}}else t.NUM_BONE_INFLUENCERS=0,t.BonesPerMesh=0,void 0!==t.BONETEXTURE&&(t.BONETEXTURE=!1)}(e,t),r&&function(e,t){const s=e.morphTargetManager;s?(t.MORPHTARGETS_UV=s.supportsUVs&&t.UV1,t.MORPHTARGETS_TANGENT=s.supportsTangents&&t.TANGENT,t.MORPHTARGETS_NORMAL=s.supportsNormals&&t.NORMAL,t.NUM_MORPH_INFLUENCERS=s.numMaxInfluencers||s.numInfluencers,t.MORPHTARGETS=t.NUM_MORPH_INFLUENCERS>0,t.MORPHTARGETS_TEXTURE=s.isUsingTextureForTargets):(t.MORPHTARGETS_UV=!1,t.MORPHTARGETS_TANGENT=!1,t.MORPHTARGETS_NORMAL=!1,t.MORPHTARGETS=!1,t.NUM_MORPH_INFLUENCERS=0)}(e,t),a&&function(e,t){const s=e.bakedVertexAnimationManager;t.BAKED_VERTEX_ANIMATION_TEXTURE=!(!s||!s.isEnabled)}(e,t),!0}function D(e,t){if(e.activeCamera){const s=t.MULTIVIEW;t.MULTIVIEW=null!==e.activeCamera.outputRenderTarget&&e.activeCamera.outputRenderTarget.getViewCount()>1,t.MULTIVIEW!=s&&t.markAsUnprocessed()}}function O(e,t,s){const i=t.ORDER_INDEPENDENT_TRANSPARENCY,r=t.ORDER_INDEPENDENT_TRANSPARENCY_16BITS;t.ORDER_INDEPENDENT_TRANSPARENCY=e.useOrderIndependentTransparency&&s,t.ORDER_INDEPENDENT_TRANSPARENCY_16BITS=!e.getEngine().getCaps().textureFloatLinearFiltering,i===t.ORDER_INDEPENDENT_TRANSPARENCY&&r===t.ORDER_INDEPENDENT_TRANSPARENCY_16BITS||t.markAsUnprocessed()}function F(e,t,s){const i=t.PREPASS;if(!t._arePrePassDirty)return;const r=[{type:1,define:"PREPASS_POSITION",index:"PREPASS_POSITION_INDEX"},{type:9,define:"PREPASS_LOCAL_POSITION",index:"PREPASS_LOCAL_POSITION_INDEX"},{type:2,define:"PREPASS_VELOCITY",index:"PREPASS_VELOCITY_INDEX"},{type:11,define:"PREPASS_VELOCITY_LINEAR",index:"PREPASS_VELOCITY_LINEAR_INDEX"},{type:3,define:"PREPASS_REFLECTIVITY",index:"PREPASS_REFLECTIVITY_INDEX"},{type:0,define:"PREPASS_IRRADIANCE",index:"PREPASS_IRRADIANCE_INDEX"},{type:7,define:"PREPASS_ALBEDO_SQRT",index:"PREPASS_ALBEDO_SQRT_INDEX"},{type:5,define:"PREPASS_DEPTH",index:"PREPASS_DEPTH_INDEX"},{type:10,define:"PREPASS_SCREENSPACE_DEPTH",index:"PREPASS_SCREENSPACE_DEPTH_INDEX"},{type:6,define:"PREPASS_NORMAL",index:"PREPASS_NORMAL_INDEX"},{type:8,define:"PREPASS_WORLD_NORMAL",index:"PREPASS_WORLD_NORMAL_INDEX"}];if(e.prePassRenderer&&e.prePassRenderer.enabled&&s){t.PREPASS=!0,t.SCENE_MRT_COUNT=e.prePassRenderer.mrtCount,t.PREPASS_NORMAL_WORLDSPACE=e.prePassRenderer.generateNormalsInWorldSpace,t.PREPASS_COLOR=!0,t.PREPASS_COLOR_INDEX=0;for(let s=0;s{s.d(t,{y:()=>g});var i=s(5524),r=s(9259),n=s(8986),a=s(6315),o=s(9125),h=s(9610);const l=new RegExp("^([gimus]+)!");class c{constructor(e){this._plugins=[],this._activePlugins=[],this._activePluginsForExtraEvents=[],this._material=e,this._scene=e.getScene(),this._engine=this._scene.getEngine()}_addPlugin(e){for(let t=0;tthis._handlePluginEvent(e,t),this._plugins.push(e),this._plugins.sort(((e,t)=>e.priority-t.priority)),this._codeInjectionPoints={};const s={};s[c._MaterialPluginClassToMainDefine[t]]={type:"boolean",default:!0};for(const e of this._plugins)e.collectDefines(s),this._collectPointNames("vertex",e.getCustomCode("vertex",this._material.shaderLanguage)),this._collectPointNames("fragment",e.getCustomCode("fragment",this._material.shaderLanguage));return this._defineNamesFromPlugins=s,!0}_activatePlugin(e){-1===this._activePlugins.indexOf(e)&&(this._activePlugins.push(e),this._activePlugins.sort(((e,t)=>e.priority-t.priority)),this._material._callbackPluginEventIsReadyForSubMesh=this._handlePluginEventIsReadyForSubMesh.bind(this),this._material._callbackPluginEventPrepareDefinesBeforeAttributes=this._handlePluginEventPrepareDefinesBeforeAttributes.bind(this),this._material._callbackPluginEventPrepareDefines=this._handlePluginEventPrepareDefines.bind(this),this._material._callbackPluginEventBindForSubMesh=this._handlePluginEventBindForSubMesh.bind(this),e.registerForExtraEvents&&(this._activePluginsForExtraEvents.push(e),this._activePluginsForExtraEvents.sort(((e,t)=>e.priority-t.priority)),this._material._callbackPluginEventHasRenderTargetTextures=this._handlePluginEventHasRenderTargetTextures.bind(this),this._material._callbackPluginEventFillRenderTargetTextures=this._handlePluginEventFillRenderTargetTextures.bind(this),this._material._callbackPluginEventHardBindForSubMesh=this._handlePluginEventHardBindForSubMesh.bind(this)))}getPlugin(e){for(let t=0;t0&&e.uniforms.push(...this._uniformList),this._samplerList.length>0&&e.samplers.push(...this._samplerList),this._uboList.length>0&&e.uniformBuffersNames.push(...this._uboList),e.customCode=this._injectCustomCode(e,e.customCode);break}case 8:{const e=t;this._uboDeclaration="",this._vertexDeclaration="",this._fragmentDeclaration="",this._uniformList=[],this._samplerList=[],this._uboList=[];const s=1===this._material.shaderLanguage;for(const t of this._plugins){const i=t.getUniforms(this._material.shaderLanguage);if(i){if(i.ubo)for(const t of i.ubo){if(t.size&&t.type){const i=t.arraySize??0;if(e.ubo.addUniform(t.name,t.size,i),s){let e;switch(t.type){case"mat4":e="mat4x4f";break;case"float":e="f32";break;default:e=`${t.type}f`}this._uboDeclaration+=`uniform ${t.name}: ${e}${i>0?`[${i}]`:""};\n`}else this._uboDeclaration+=`${t.type} ${t.name}${i>0?`[${i}]`:""};\n`}this._uniformList.push(t.name)}i.vertex&&(this._vertexDeclaration+=i.vertex+"\n"),i.fragment&&(this._fragmentDeclaration+=i.fragment+"\n")}t.getSamplers(this._samplerList),t.getUniformBuffersNames(this._uboList)}break}}}_collectPointNames(e,t){if(t)for(const s in t)this._codeInjectionPoints[e]||(this._codeInjectionPoints[e]={}),this._codeInjectionPoints[e][s]=!0}_injectCustomCode(e,t){return(s,i)=>{t&&(i=t(s,i)),this._uboDeclaration&&(i=i.replace("#define ADDITIONAL_UBO_DECLARATION",this._uboDeclaration)),this._vertexDeclaration&&(i=i.replace("#define ADDITIONAL_VERTEX_DECLARATION",this._vertexDeclaration)),this._fragmentDeclaration&&(i=i.replace("#define ADDITIONAL_FRAGMENT_DECLARATION",this._fragmentDeclaration));const r=this._codeInjectionPoints?.[s];if(!r)return i;let n=null;for(let t in r){let r="";for(const i of this._activePlugins){let a=i.getCustomCode(s,this._material.shaderLanguage)?.[t];if(a){if(i.resolveIncludes){if(null===n){const t=0;n={defines:[],indexParameters:e.indexParameters,isFragment:!1,shouldUseHighPrecisionShader:this._engine._shouldUseHighPrecisionShader,processor:void 0,supportsUniformBuffers:this._engine.supportsUniformBuffers,shadersRepository:h.l.GetShadersRepository(t),includesShadersStore:h.l.GetIncludesShadersStore(t),version:void 0,platformName:this._engine.shaderPlatformName,processingContext:void 0,isNDCHalfZRange:this._engine.isNDCHalfZRange,useReverseDepthBuffer:this._engine.useReverseDepthBuffer,processCodeAfterIncludes:void 0}}n.isFragment="fragment"===s,(0,o.Iq)(a,n,(e=>a=e))}r+=a+"\n"}}if(r.length>0)if("!"===t.charAt(0)){t=t.substring(1);let e="g";if("!"===t.charAt(0))e="",t=t.substring(1);else{const s=l.exec(t);s&&s.length>=2&&(e=s[1],t=t.substring(e.length+1))}e.indexOf("g")<0&&(e+="g");const s=i,n=new RegExp(t,e);let a=n.exec(s);for(;null!==a;){let e=r;for(let t=0;t{u.length=0,d=!1,n.i.OnEventObservable.remove(_),_=null}));const u=[];let d=!1,_=null;var f=s(6877),p=s(6552);class g{isCompatible(e){return 0===e}_enable(e){e&&this._pluginManager._activatePlugin(this)}constructor(e,t,s,i,r=!0,n=!1,a=!1){this.priority=500,this.resolveIncludes=!1,this.registerForExtraEvents=!1,this._material=e,this.name=t,this.priority=s,this.resolveIncludes=a,e.pluginManager||(e.pluginManager=new c(e),e.onDisposeObservable.add((()=>{e.pluginManager=void 0}))),this._pluginDefineNames=i,this._pluginManager=e.pluginManager,r&&this._pluginManager._addPlugin(this),n&&this._enable(!0),this.markAllDefinesAsDirty=e._dirtyCallbacks[63]}getClassName(){return"MaterialPluginBase"}isReadyForSubMesh(e,t,s,i){return!0}hardBindForSubMesh(e,t,s,i){}bindForSubMesh(e,t,s,i){}dispose(e){}getCustomCode(e,t=0){return null}collectDefines(e){if(this._pluginDefineNames)for(const t of Object.keys(this._pluginDefineNames)){if("_"===t[0])continue;const s=typeof this._pluginDefineNames[t];e[t]={type:"number"===s?"number":"string"===s?"string":"boolean"===s?"boolean":"object",default:this._pluginDefineNames[t]}}}prepareDefinesBeforeAttributes(e,t,s){}prepareDefines(e,t,s){}hasTexture(e){return!1}hasRenderTargetTextures(){return!1}fillRenderTargetTextures(e){}getActiveTextures(e){}getAnimatables(e){}addFallbacks(e,t,s){return s}getSamplers(e){}getAttributes(e,t,s){}getUniformBuffersNames(e){}getUniforms(e=0){return{}}copyTo(e){f.p.Clone((()=>e),this)}serialize(){return f.p.Serialize(this)}parse(e,t,s){f.p.Parse((()=>this),e,t,s)}}(0,i.Cg)([(0,r.lK)()],g.prototype,"name",void 0),(0,i.Cg)([(0,r.lK)()],g.prototype,"priority",void 0),(0,i.Cg)([(0,r.lK)()],g.prototype,"resolveIncludes",void 0),(0,i.Cg)([(0,r.lK)()],g.prototype,"registerForExtraEvents",void 0),(0,p.Y5)("BABYLON.MaterialPluginBase",g)},1644:(e,t,s)=>{s.d(t,{E:()=>n});var i=s(9923),r=s(8986);class n extends r.i{constructor(e,t,s=!0,r=!1){super(e,t,void 0,r),this._normalMatrix=new i.uq,this._storeEffectOnSubMeshes=s}getEffect(){return this._storeEffectOnSubMeshes?this._activeEffect:super.getEffect()}isReady(e,t){return!!e&&(!this._storeEffectOnSubMeshes||!e.subMeshes||0===e.subMeshes.length||this.isReadyForSubMesh(e,e.subMeshes[0],t))}_isReadyForSubMesh(e){const t=e.materialDefines;return!(this.checkReadyOnEveryCall||!e.effect||!t||t._renderId!==this.getScene().getRenderId())}bindOnlyWorldMatrix(e){this._activeEffect.setMatrix("world",e)}bindOnlyNormalMatrix(e){this._activeEffect.setMatrix("normalMatrix",e)}bind(e,t){t&&this.bindForSubMesh(e,t,t.subMeshes[0])}_afterBind(e,t=null,s){super._afterBind(e,t,s),this.getScene()._cachedEffect=t,s?s._drawWrapper._forceRebindOnNextCall=!1:this._drawWrapper._forceRebindOnNextCall=!1}_mustRebind(e,t,s,i=1){return s._drawWrapper._forceRebindOnNextCall||e.isCachedMaterialInvalid(this,t,i)}dispose(e,t,s){this._activeEffect=void 0,super.dispose(e,t,s)}}},5662:(e,t,s)=>{var i;s.d(t,{w:()=>i}),function(e){e[e.GLSL=0]="GLSL",e[e.WGSL=1]="WGSL"}(i||(i={}))},917:(e,t,s)=>{s.d(t,{B:()=>m});var i=s(6877),r=s(554),n=s(9923),a=s(5616),o=s(2781),h=s(6552),l=s(6041),c=s(2565),u=s(2366),d=s(1644),_=s(6315),f=s(492),p=s(467);const g={effect:null,subMesh:null};class m extends d.E{constructor(e,t,s,i={},r=!0){super(e,t,r),this._textures={},this._textureArrays={},this._externalTextures={},this._floats={},this._ints={},this._uints={},this._floatsArrays={},this._colors3={},this._colors3Arrays={},this._colors4={},this._colors4Arrays={},this._vectors2={},this._vectors3={},this._vectors4={},this._quaternions={},this._quaternionsArrays={},this._matrices={},this._matrixArrays={},this._matrices3x3={},this._matrices2x2={},this._vectors2Arrays={},this._vectors3Arrays={},this._vectors4Arrays={},this._uniformBuffers={},this._textureSamplers={},this._storageBuffers={},this._cachedWorldViewMatrix=new n.uq,this._cachedWorldViewProjectionMatrix=new n.uq,this._multiview=!1,this._materialHelperNeedsPreviousMatrices=!1,this._shaderPath=s,this._options={needAlphaBlending:!1,needAlphaTesting:!1,attributes:["position","normal","uv"],uniforms:["worldViewProjection"],uniformBuffers:[],samplers:[],externalTextures:[],samplerObjects:[],storageBuffers:[],defines:[],useClipPlane:!1,...i}}get shaderPath(){return this._shaderPath}set shaderPath(e){this._shaderPath=e}get options(){return this._options}get isMultiview(){return this._multiview}getClassName(){return"ShaderMaterial"}needAlphaBlending(){return this.alpha<1||this._options.needAlphaBlending}needAlphaTesting(){return this._options.needAlphaTesting}_checkUniform(e){-1===this._options.uniforms.indexOf(e)&&this._options.uniforms.push(e)}setTexture(e,t){return-1===this._options.samplers.indexOf(e)&&this._options.samplers.push(e),this._textures[e]=t,this}removeTexture(e){delete this._textures[e]}setTextureArray(e,t){return-1===this._options.samplers.indexOf(e)&&this._options.samplers.push(e),this._checkUniform(e),this._textureArrays[e]=t,this}setExternalTexture(e,t){return-1===this._options.externalTextures.indexOf(e)&&this._options.externalTextures.push(e),this._externalTextures[e]=t,this}setFloat(e,t){return this._checkUniform(e),this._floats[e]=t,this}setInt(e,t){return this._checkUniform(e),this._ints[e]=t,this}setUInt(e,t){return this._checkUniform(e),this._uints[e]=t,this}setFloats(e,t){return this._checkUniform(e),this._floatsArrays[e]=t,this}setColor3(e,t){return this._checkUniform(e),this._colors3[e]=t,this}setColor3Array(e,t){return this._checkUniform(e),this._colors3Arrays[e]=t.reduce(((e,t)=>(t.toArray(e,e.length),e)),[]),this}setColor4(e,t){return this._checkUniform(e),this._colors4[e]=t,this}setColor4Array(e,t){return this._checkUniform(e),this._colors4Arrays[e]=t.reduce(((e,t)=>(t.toArray(e,e.length),e)),[]),this}setVector2(e,t){return this._checkUniform(e),this._vectors2[e]=t,this}setVector3(e,t){return this._checkUniform(e),this._vectors3[e]=t,this}setVector4(e,t){return this._checkUniform(e),this._vectors4[e]=t,this}setQuaternion(e,t){return this._checkUniform(e),this._quaternions[e]=t,this}setQuaternionArray(e,t){return this._checkUniform(e),this._quaternionsArrays[e]=t.reduce(((e,t)=>(t.toArray(e,e.length),e)),[]),this}setMatrix(e,t){return this._checkUniform(e),this._matrices[e]=t,this}setMatrices(e,t){this._checkUniform(e);const s=new Float32Array(16*t.length);for(let e=0;et===e||t.startsWith(s)));return i>=0&&this.options.defines.splice(i,1),("boolean"!=typeof t||t)&&this.options.defines.push(s+t),this}isReadyForSubMesh(e,t,s){return this.isReady(e,s,t)}isReady(e,t,s){const i=s&&this._storeEffectOnSubMeshes;if(this.isFrozen){const e=i?s._drawWrapper:this._drawWrapper;if(e.effect&&e._wasPreviouslyReady&&e._wasPreviouslyUsingInstances===t)return!0}const n=this.getScene(),o=n.getEngine(),h=[],l=[],u=new c.J;let d=this._shaderPath,_=this._options.uniforms,m=this._options.uniformBuffers,T=this._options.samplers;o.getCaps().multiview&&n.activeCamera&&n.activeCamera.outputRenderTarget&&n.activeCamera.outputRenderTarget.getViewCount()>1&&(this._multiview=!0,h.push("#define MULTIVIEW"),-1!==_.indexOf("viewProjection")&&-1===_.indexOf("viewProjectionR")&&_.push("viewProjectionR"));for(let e=0;e4&&(l.push(a.R.MatricesIndicesExtraKind),l.push(a.R.MatricesWeightsExtraKind));const t=e.skeleton;h.push("#define NUM_BONE_INFLUENCERS "+e.numBoneInfluencers),u.addCPUSkinningFallback(0,e),t.isUsingTextureForMatrices?(h.push("#define BONETEXTURE"),-1===_.indexOf("boneTextureWidth")&&_.push("boneTextureWidth"),-1===this._options.samplers.indexOf("boneSampler")&&this._options.samplers.push("boneSampler")):(h.push("#define BonesPerMesh "+(t.bones.length+1)),-1===_.indexOf("mBones")&&_.push("mBones"))}else h.push("#define NUM_BONE_INFLUENCERS 0");let b=0;const E=e?e.morphTargetManager:null;if(E){const e=E.supportsUVs&&-1!==h.indexOf("#define UV1"),t=E.supportsTangents&&-1!==h.indexOf("#define TANGENT"),s=E.supportsNormals&&-1!==h.indexOf("#define NORMAL");b=E.numMaxInfluencers||E.numInfluencers,e&&h.push("#define MORPHTARGETS_UV"),t&&h.push("#define MORPHTARGETS_TANGENT"),s&&h.push("#define MORPHTARGETS_NORMAL"),b>0&&h.push("#define MORPHTARGETS"),E.isUsingTextureForTargets&&(h.push("#define MORPHTARGETS_TEXTURE"),-1===_.indexOf("morphTargetTextureIndices")&&_.push("morphTargetTextureIndices"),-1===this._options.samplers.indexOf("morphTargets")&&this._options.samplers.push("morphTargets")),h.push("#define NUM_MORPH_INFLUENCERS "+b);for(let i=0;i0&&(_=_.slice(),_.push("morphTargetInfluences"),_.push("morphTargetCount"),_.push("morphTargetTextureInfo"),_.push("morphTargetTextureIndices"))}else h.push("#define NUM_MORPH_INFLUENCERS 0");if(e){const t=e.bakedVertexAnimationManager;t&&t.isEnabled&&(h.push("#define BAKED_VERTEX_ANIMATION_TEXTURE"),-1===_.indexOf("bakedVertexAnimationSettings")&&_.push("bakedVertexAnimationSettings"),-1===_.indexOf("bakedVertexAnimationTextureSizeInverted")&&_.push("bakedVertexAnimationTextureSizeInverted"),-1===_.indexOf("bakedVertexAnimationTime")&&_.push("bakedVertexAnimationTime"),-1===this._options.samplers.indexOf("bakedVertexAnimationTexture")&&this._options.samplers.push("bakedVertexAnimationTexture")),(0,p.J2)(l,e,h)}for(const e in this._textures)if(!this._textures[e].isReady())return!1;e&&this._shouldTurnAlphaTestOn(e)&&h.push("#define ALPHATEST"),!1!==this._options.useClipPlane&&((0,f.TV)(_),(0,f.tv)(this,n,h)),n.fogEnabled&&e?.applyFog&&n.fogMode!==r.Z.FOGMODE_NONE&&(h.push("#define FOG"),-1===_.indexOf("view")&&_.push("view"),-1===_.indexOf("vFogInfos")&&_.push("vFogInfos"),-1===_.indexOf("vFogColor")&&_.push("vFogColor")),this._useLogarithmicDepth&&(h.push("#define LOGARITHMICDEPTH"),-1===_.indexOf("logarithmicDepthConstant")&&_.push("logarithmicDepthConstant")),this.customShaderNameResolve&&(_=_.slice(),m=m.slice(),T=T.slice(),d=this.customShaderNameResolve(this.name,_,m,T,h,l));const x=i?s._getDrawWrapper(void 0,!0):this._drawWrapper,A=x?.effect??null,R=x?.defines??null,M=h.join("\n");let y=A;return R!==M&&(y=o.createEffect(d,{attributes:l,uniformsNames:_,uniformBuffersNames:m,samplers:T,defines:M,fallbacks:u,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousMorphTargets:b},shaderLanguage:this._options.shaderLanguage,extraInitializationsAsync:this._options.extraInitializationsAsync},o),i?s.setEffect(y,M,this._materialContext):x&&x.setEffect(y,M),this._onEffectCreatedObservable&&(g.effect=y,g.subMesh=s??e?.subMeshes[0]??null,this._onEffectCreatedObservable.notifyObservers(g))),x._wasPreviouslyUsingInstances=!!t,!(!y?.isReady()??1)&&(A!==y&&n.resetCachedMaterial(),x._wasPreviouslyReady=!0,!0)}bindOnlyWorldMatrix(e,t){const s=this.getScene(),i=t??this.getEffect();i&&(-1!==this._options.uniforms.indexOf("world")&&i.setMatrix("world",e),-1!==this._options.uniforms.indexOf("worldView")&&(e.multiplyToRef(s.getViewMatrix(),this._cachedWorldViewMatrix),i.setMatrix("worldView",this._cachedWorldViewMatrix)),-1!==this._options.uniforms.indexOf("worldViewProjection")&&(e.multiplyToRef(s.getTransformMatrix(),this._cachedWorldViewProjectionMatrix),i.setMatrix("worldViewProjection",this._cachedWorldViewProjectionMatrix)),-1!==this._options.uniforms.indexOf("view")&&i.setMatrix("view",s.getViewMatrix()))}bindForSubMesh(e,t,s){this.bind(e,t,s._drawWrapperOverride?.effect,s)}bind(e,t,s,i){const r=i&&this._storeEffectOnSubMeshes,n=s??(r?i.effect:this.getEffect());if(!n)return;const a=this.getScene();this._activeEffect=n,this.bindOnlyWorldMatrix(e,s);const o=this._options.uniformBuffers;let h=!1;if(n&&o&&o.length>0&&a.getEngine().supportsUniformBuffers)for(let s=0;s0&&(0,p.nR)(t,n);const s=t.bakedVertexAnimationManager;if(s&&s.isEnabled){const e=r?i._drawWrapper:this._drawWrapper;t.bakedVertexAnimationManager?.bind(n,!!e._wasPreviouslyUsingInstances)}}this._afterBind(t,n,i)}getActiveTextures(){const e=super.getActiveTextures();for(const t in this._textures)e.push(this._textures[t]);for(const t in this._textureArrays){const s=this._textureArrays[t];for(let t=0;tnew m(e,this.getScene(),this._shaderPath,this._options,this._storeEffectOnSubMeshes)),this);t.name=e,t.id=e,"object"==typeof t._shaderPath&&(t._shaderPath={...t._shaderPath}),this._options={...this._options},Object.keys(this._options).forEach((e=>{const t=this._options[e];Array.isArray(t)&&(this._options[e]=t.slice(0))})),this.stencil.copyTo(t.stencil);for(const e in this._textures)t.setTexture(e,this._textures[e]);for(const e in this._textureArrays)t.setTextureArray(e,this._textureArrays[e]);for(const e in this._externalTextures)t.setExternalTexture(e,this._externalTextures[e]);for(const e in this._ints)t.setInt(e,this._ints[e]);for(const e in this._uints)t.setUInt(e,this._uints[e]);for(const e in this._floats)t.setFloat(e,this._floats[e]);for(const e in this._floatsArrays)t.setFloats(e,this._floatsArrays[e]);for(const e in this._colors3)t.setColor3(e,this._colors3[e]);for(const e in this._colors3Arrays)t._colors3Arrays[e]=this._colors3Arrays[e];for(const e in this._colors4)t.setColor4(e,this._colors4[e]);for(const e in this._colors4Arrays)t._colors4Arrays[e]=this._colors4Arrays[e];for(const e in this._vectors2)t.setVector2(e,this._vectors2[e]);for(const e in this._vectors3)t.setVector3(e,this._vectors3[e]);for(const e in this._vectors4)t.setVector4(e,this._vectors4[e]);for(const e in this._quaternions)t.setQuaternion(e,this._quaternions[e]);for(const e in this._quaternionsArrays)t._quaternionsArrays[e]=this._quaternionsArrays[e];for(const e in this._matrices)t.setMatrix(e,this._matrices[e]);for(const e in this._matrixArrays)t._matrixArrays[e]=this._matrixArrays[e].slice();for(const e in this._matrices3x3)t.setMatrix3x3(e,this._matrices3x3[e]);for(const e in this._matrices2x2)t.setMatrix2x2(e,this._matrices2x2[e]);for(const e in this._vectors2Arrays)t.setArray2(e,this._vectors2Arrays[e]);for(const e in this._vectors3Arrays)t.setArray3(e,this._vectors3Arrays[e]);for(const e in this._vectors4Arrays)t.setArray4(e,this._vectors4Arrays[e]);for(const e in this._uniformBuffers)t.setUniformBuffer(e,this._uniformBuffers[e]);for(const e in this._textureSamplers)t.setTextureSampler(e,this._textureSamplers[e]);for(const e in this._storageBuffers)t.setStorageBuffer(e,this._storageBuffers[e]);return t}dispose(e,t,s){if(t){let e;for(e in this._textures)this._textures[e].dispose();for(e in this._textureArrays){const t=this._textureArrays[e];for(let e=0;enew m(e.name,t,e.shaderPath,e.options,e.storeEffectOnSubMeshes)),e,t,s);let a;for(a in e.stencil&&r.stencil.parse(e.stencil,t,s),e.textures)r.setTexture(a,o.g.Parse(e.textures[a],t,s));for(a in e.textureArrays){const i=e.textureArrays[a],n=[];for(let e=0;e(s%3==0?e.push([t]):e[e.length-1].push(t),e)),[]).map((e=>l.v9.FromArray(e)));r.setColor3Array(a,t)}for(a in e.colors4)r.setColor4(a,l.ov.FromArray(e.colors4[a]));for(a in e.colors4Arrays){const t=e.colors4Arrays[a].reduce(((e,t,s)=>(s%4==0?e.push([t]):e[e.length-1].push(t),e)),[]).map((e=>l.ov.FromArray(e)));r.setColor4Array(a,t)}for(a in e.vectors2)r.setVector2(a,n.I9.FromArray(e.vectors2[a]));for(a in e.vectors3)r.setVector3(a,n.Pq.FromArray(e.vectors3[a]));for(a in e.vectors4)r.setVector4(a,n.IU.FromArray(e.vectors4[a]));for(a in e.quaternions)r.setQuaternion(a,n.PT.FromArray(e.quaternions[a]));for(a in e.matrices)r.setMatrix(a,n.uq.FromArray(e.matrices[a]));for(a in e.matrixArray)r._matrixArrays[a]=new Float32Array(e.matrixArray[a]);for(a in e.matrices3x3)r.setMatrix3x3(a,e.matrices3x3[a]);for(a in e.matrices2x2)r.setMatrix2x2(a,e.matrices2x2[a]);for(a in e.vectors2Arrays)r.setArray2(a,e.vectors2Arrays[a]);for(a in e.vectors3Arrays)r.setArray3(a,e.vectors3Arrays[a]);for(a in e.vectors4Arrays)r.setArray4(a,e.vectors4Arrays[a]);for(a in e.quaternionsArrays)r.setArray4(a,e.quaternionsArrays[a]);return r}static ParseFromFileAsync(e,t,s,i=""){return new Promise(((r,n)=>{const a=new u.u;a.addEventListener("readystatechange",(()=>{if(4==a.readyState)if(200==a.status){const t=JSON.parse(a.responseText),n=this.Parse(t,s||_.q.LastCreatedScene,i);e&&(n.name=e),r(n)}else n("Unable to load the ShaderMaterial")})),a.open("GET",t),a.send()}))}static ParseFromSnippetAsync(e,t,s=""){return new Promise(((i,r)=>{const n=new u.u;n.addEventListener("readystatechange",(()=>{if(4==n.readyState)if(200==n.status){const r=JSON.parse(JSON.parse(n.responseText).jsonPayload),a=JSON.parse(r.shaderMaterial),o=this.Parse(a,t||_.q.LastCreatedScene,s);o.snippetId=e,i(o)}else r("Unable to load the snippet "+e)})),n.open("GET",this.SnippetUrl+"/"+e.replace(/#/g,"/")),n.send()}))}}m.SnippetUrl="https://snippet.babylonjs.com",m.CreateFromSnippetAsync=m.ParseFromSnippetAsync,(0,h.Y5)("BABYLON.ShaderMaterial",m)},2673:(e,t,s)=>{s.d(t,{F:()=>I});var i=s(5524),r=s(9259),n=s(7931),a=s(554),o=s(9923),h=s(6041),l=s(5616);class c{constructor(){this.previousWorldMatrices={},this.previousBones={}}static AddUniforms(e){e.push("previousWorld","previousViewProjection","mPreviousBones")}static AddSamplers(e){}bindForSubMesh(e,t,s,i,r){if(t.prePassRenderer&&t.prePassRenderer.enabled&&t.prePassRenderer.currentRTisSceneRT&&(-1!==t.prePassRenderer.getIndex(2)||-1!==t.prePassRenderer.getIndex(11))){this.previousWorldMatrices[s.uniqueId]||(this.previousWorldMatrices[s.uniqueId]=i.clone()),this.previousViewProjection||(this.previousViewProjection=t.getTransformMatrix().clone(),this.currentViewProjection=t.getTransformMatrix().clone());const r=t.getEngine();this.currentViewProjection.updateFlag!==t.getTransformMatrix().updateFlag?(this._lastUpdateFrameId=r.frameId,this.previousViewProjection.copyFrom(this.currentViewProjection),this.currentViewProjection.copyFrom(t.getTransformMatrix())):this._lastUpdateFrameId!==r.frameId&&(this._lastUpdateFrameId=r.frameId,this.previousViewProjection.copyFrom(this.currentViewProjection)),e.setMatrix("previousWorld",this.previousWorldMatrices[s.uniqueId]),e.setMatrix("previousViewProjection",this.previousViewProjection),this.previousWorldMatrices[s.uniqueId]=i.clone()}}}var u=s(1088),d=s(8986),_=s(9526),f=s(1644),p=s(2781),g=s(6552),m=s(6326);class T{static get DiffuseTextureEnabled(){return this._DiffuseTextureEnabled}static set DiffuseTextureEnabled(e){this._DiffuseTextureEnabled!==e&&(this._DiffuseTextureEnabled=e,m.$.MarkAllMaterialsAsDirty(1))}static get DetailTextureEnabled(){return this._DetailTextureEnabled}static set DetailTextureEnabled(e){this._DetailTextureEnabled!==e&&(this._DetailTextureEnabled=e,m.$.MarkAllMaterialsAsDirty(1))}static get DecalMapEnabled(){return this._DecalMapEnabled}static set DecalMapEnabled(e){this._DecalMapEnabled!==e&&(this._DecalMapEnabled=e,m.$.MarkAllMaterialsAsDirty(1))}static get AmbientTextureEnabled(){return this._AmbientTextureEnabled}static set AmbientTextureEnabled(e){this._AmbientTextureEnabled!==e&&(this._AmbientTextureEnabled=e,m.$.MarkAllMaterialsAsDirty(1))}static get OpacityTextureEnabled(){return this._OpacityTextureEnabled}static set OpacityTextureEnabled(e){this._OpacityTextureEnabled!==e&&(this._OpacityTextureEnabled=e,m.$.MarkAllMaterialsAsDirty(1))}static get ReflectionTextureEnabled(){return this._ReflectionTextureEnabled}static set ReflectionTextureEnabled(e){this._ReflectionTextureEnabled!==e&&(this._ReflectionTextureEnabled=e,m.$.MarkAllMaterialsAsDirty(1))}static get EmissiveTextureEnabled(){return this._EmissiveTextureEnabled}static set EmissiveTextureEnabled(e){this._EmissiveTextureEnabled!==e&&(this._EmissiveTextureEnabled=e,m.$.MarkAllMaterialsAsDirty(1))}static get SpecularTextureEnabled(){return this._SpecularTextureEnabled}static set SpecularTextureEnabled(e){this._SpecularTextureEnabled!==e&&(this._SpecularTextureEnabled=e,m.$.MarkAllMaterialsAsDirty(1))}static get BumpTextureEnabled(){return this._BumpTextureEnabled}static set BumpTextureEnabled(e){this._BumpTextureEnabled!==e&&(this._BumpTextureEnabled=e,m.$.MarkAllMaterialsAsDirty(1))}static get LightmapTextureEnabled(){return this._LightmapTextureEnabled}static set LightmapTextureEnabled(e){this._LightmapTextureEnabled!==e&&(this._LightmapTextureEnabled=e,m.$.MarkAllMaterialsAsDirty(1))}static get RefractionTextureEnabled(){return this._RefractionTextureEnabled}static set RefractionTextureEnabled(e){this._RefractionTextureEnabled!==e&&(this._RefractionTextureEnabled=e,m.$.MarkAllMaterialsAsDirty(1))}static get ColorGradingTextureEnabled(){return this._ColorGradingTextureEnabled}static set ColorGradingTextureEnabled(e){this._ColorGradingTextureEnabled!==e&&(this._ColorGradingTextureEnabled=e,m.$.MarkAllMaterialsAsDirty(1))}static get FresnelEnabled(){return this._FresnelEnabled}static set FresnelEnabled(e){this._FresnelEnabled!==e&&(this._FresnelEnabled=e,m.$.MarkAllMaterialsAsDirty(4))}static get ClearCoatTextureEnabled(){return this._ClearCoatTextureEnabled}static set ClearCoatTextureEnabled(e){this._ClearCoatTextureEnabled!==e&&(this._ClearCoatTextureEnabled=e,m.$.MarkAllMaterialsAsDirty(1))}static get ClearCoatBumpTextureEnabled(){return this._ClearCoatBumpTextureEnabled}static set ClearCoatBumpTextureEnabled(e){this._ClearCoatBumpTextureEnabled!==e&&(this._ClearCoatBumpTextureEnabled=e,m.$.MarkAllMaterialsAsDirty(1))}static get ClearCoatTintTextureEnabled(){return this._ClearCoatTintTextureEnabled}static set ClearCoatTintTextureEnabled(e){this._ClearCoatTintTextureEnabled!==e&&(this._ClearCoatTintTextureEnabled=e,m.$.MarkAllMaterialsAsDirty(1))}static get SheenTextureEnabled(){return this._SheenTextureEnabled}static set SheenTextureEnabled(e){this._SheenTextureEnabled!==e&&(this._SheenTextureEnabled=e,m.$.MarkAllMaterialsAsDirty(1))}static get AnisotropicTextureEnabled(){return this._AnisotropicTextureEnabled}static set AnisotropicTextureEnabled(e){this._AnisotropicTextureEnabled!==e&&(this._AnisotropicTextureEnabled=e,m.$.MarkAllMaterialsAsDirty(1))}static get ThicknessTextureEnabled(){return this._ThicknessTextureEnabled}static set ThicknessTextureEnabled(e){this._ThicknessTextureEnabled!==e&&(this._ThicknessTextureEnabled=e,m.$.MarkAllMaterialsAsDirty(1))}static get RefractionIntensityTextureEnabled(){return this._ThicknessTextureEnabled}static set RefractionIntensityTextureEnabled(e){this._RefractionIntensityTextureEnabled!==e&&(this._RefractionIntensityTextureEnabled=e,m.$.MarkAllMaterialsAsDirty(1))}static get TranslucencyIntensityTextureEnabled(){return this._TranslucencyIntensityTextureEnabled}static set TranslucencyIntensityTextureEnabled(e){this._TranslucencyIntensityTextureEnabled!==e&&(this._TranslucencyIntensityTextureEnabled=e,m.$.MarkAllMaterialsAsDirty(1))}static get TranslucencyColorTextureEnabled(){return this._TranslucencyColorTextureEnabled}static set TranslucencyColorTextureEnabled(e){this._TranslucencyColorTextureEnabled!==e&&(this._TranslucencyColorTextureEnabled=e,m.$.MarkAllMaterialsAsDirty(1))}static get IridescenceTextureEnabled(){return this._IridescenceTextureEnabled}static set IridescenceTextureEnabled(e){this._IridescenceTextureEnabled!==e&&(this._IridescenceTextureEnabled=e,m.$.MarkAllMaterialsAsDirty(1))}}T._DiffuseTextureEnabled=!0,T._DetailTextureEnabled=!0,T._DecalMapEnabled=!0,T._AmbientTextureEnabled=!0,T._OpacityTextureEnabled=!0,T._ReflectionTextureEnabled=!0,T._EmissiveTextureEnabled=!0,T._SpecularTextureEnabled=!0,T._BumpTextureEnabled=!0,T._LightmapTextureEnabled=!0,T._RefractionTextureEnabled=!0,T._ColorGradingTextureEnabled=!0,T._FresnelEnabled=!0,T._ClearCoatTextureEnabled=!0,T._ClearCoatBumpTextureEnabled=!0,T._ClearCoatTintTextureEnabled=!0,T._SheenTextureEnabled=!0,T._AnisotropicTextureEnabled=!0,T._ThicknessTextureEnabled=!0,T._RefractionIntensityTextureEnabled=!0,T._TranslucencyIntensityTextureEnabled=!0,T._TranslucencyColorTextureEnabled=!0,T._IridescenceTextureEnabled=!0;var b=s(2565),E=s(2277),x=s(467);class A extends _.M{constructor(){super(...arguments),this.DETAIL=!1,this.DETAILDIRECTUV=0,this.DETAIL_NORMALBLENDMETHOD=0}}class R extends E.y{_markAllSubMeshesAsTexturesDirty(){this._enable(this._isEnabled),this._internalMarkAllSubMeshesAsTexturesDirty()}isCompatible(){return!0}constructor(e,t=!0){super(e,"DetailMap",140,new A,t),this._texture=null,this.diffuseBlendLevel=1,this.roughnessBlendLevel=1,this.bumpLevel=1,this._normalBlendMethod=d.i.MATERIAL_NORMALBLENDMETHOD_WHITEOUT,this._isEnabled=!1,this.isEnabled=!1,this._internalMarkAllSubMeshesAsTexturesDirty=e._dirtyCallbacks[1]}isReadyForSubMesh(e,t,s){return!this._isEnabled||!(e._areTexturesDirty&&t.texturesEnabled&&s.getCaps().standardDerivatives&&this._texture&&T.DetailTextureEnabled&&!this._texture.isReady())}prepareDefines(e,t){if(this._isEnabled){e.DETAIL_NORMALBLENDMETHOD=this._normalBlendMethod;const s=t.getEngine();e._areTexturesDirty&&(s.getCaps().standardDerivatives&&this._texture&&T.DetailTextureEnabled&&this._isEnabled?((0,x.YT)(this._texture,e,"DETAIL"),e.DETAIL_NORMALBLENDMETHOD=this._normalBlendMethod):e.DETAIL=!1)}else e.DETAIL=!1}bindForSubMesh(e,t){if(!this._isEnabled)return;const s=this._material.isFrozen;e.useUbo&&s&&e.isSync||this._texture&&T.DetailTextureEnabled&&(e.updateFloat4("vDetailInfos",this._texture.coordinatesIndex,this.diffuseBlendLevel,this.bumpLevel,this.roughnessBlendLevel),(0,x.mA)(this._texture,e,"detail")),t.texturesEnabled&&this._texture&&T.DetailTextureEnabled&&e.setTexture("detailSampler",this._texture)}hasTexture(e){return this._texture===e}getActiveTextures(e){this._texture&&e.push(this._texture)}getAnimatables(e){this._texture&&this._texture.animations&&this._texture.animations.length>0&&e.push(this._texture)}dispose(e){e&&this._texture?.dispose()}getClassName(){return"DetailMapConfiguration"}getSamplers(e){e.push("detailSampler")}getUniforms(){return{ubo:[{name:"vDetailInfos",size:4,type:"vec4"},{name:"detailMatrix",size:16,type:"mat4"}]}}}(0,i.Cg)([(0,r.uM)("detailTexture"),(0,r.$z)("_markAllSubMeshesAsTexturesDirty")],R.prototype,"texture",void 0),(0,i.Cg)([(0,r.lK)()],R.prototype,"diffuseBlendLevel",void 0),(0,i.Cg)([(0,r.lK)()],R.prototype,"roughnessBlendLevel",void 0),(0,i.Cg)([(0,r.lK)()],R.prototype,"bumpLevel",void 0),(0,i.Cg)([(0,r.lK)(),(0,r.$z)("_markAllSubMeshesAsTexturesDirty")],R.prototype,"normalBlendMethod",void 0),(0,i.Cg)([(0,r.lK)(),(0,r.$z)("_markAllSubMeshesAsTexturesDirty")],R.prototype,"isEnabled",void 0);var M,y=s(492),P=s(6877);!function(e){e[e.Zero=0]="Zero",e[e.One=1]="One",e[e.MaxViewZ=2]="MaxViewZ"}(M||(M={}));class v{static CreateConfiguration(e){return v._Configurations[e]={defines:{},previousWorldMatrices:{},previousViewProjection:o.uq.Zero(),currentViewProjection:o.uq.Zero(),previousBones:{},lastUpdateFrameId:-1,excludedSkinnedMesh:[]},v._Configurations[e]}static DeleteConfiguration(e){delete v._Configurations[e]}static GetConfiguration(e){return v._Configurations[e]}static AddUniformsAndSamplers(e,t){e.push("previousWorld","previousViewProjection","mPreviousBones")}static MarkAsDirty(e,t){for(const s of t)if(s.subMeshes)for(const t of s.subMeshes)t._removeDrawWrapper(e)}static PrepareDefines(e,t,s){if(!s._arePrePassDirty)return;const i=v._Configurations[e];if(!i)return;s.PREPASS=!0,s.PREPASS_COLOR=!1,s.PREPASS_COLOR_INDEX=-1;let r=0;for(let e=0;e{this._markAllSubMeshesAsImageProcessingDirty()}))))}get isPrePassCapable(){return!this.disableDepthWrite}get cameraColorCurvesEnabled(){return this.imageProcessingConfiguration.colorCurvesEnabled}set cameraColorCurvesEnabled(e){this.imageProcessingConfiguration.colorCurvesEnabled=e}get cameraColorGradingEnabled(){return this.imageProcessingConfiguration.colorGradingEnabled}set cameraColorGradingEnabled(e){this.imageProcessingConfiguration.colorGradingEnabled=e}get cameraToneMappingEnabled(){return this._imageProcessingConfiguration.toneMappingEnabled}set cameraToneMappingEnabled(e){this._imageProcessingConfiguration.toneMappingEnabled=e}get cameraExposure(){return this._imageProcessingConfiguration.exposure}set cameraExposure(e){this._imageProcessingConfiguration.exposure=e}get cameraContrast(){return this._imageProcessingConfiguration.contrast}set cameraContrast(e){this._imageProcessingConfiguration.contrast=e}get cameraColorGradingTexture(){return this._imageProcessingConfiguration.colorGradingTexture}set cameraColorGradingTexture(e){this._imageProcessingConfiguration.colorGradingTexture=e}get cameraColorCurves(){return this._imageProcessingConfiguration.colorCurves}set cameraColorCurves(e){this._imageProcessingConfiguration.colorCurves=e}get canRenderToMRT(){return!0}constructor(e,t,s=!1){super(e,t,void 0,s||I.ForceGLSL),this._diffuseTexture=null,this._ambientTexture=null,this._opacityTexture=null,this._reflectionTexture=null,this._emissiveTexture=null,this._specularTexture=null,this._bumpTexture=null,this._lightmapTexture=null,this._refractionTexture=null,this.ambientColor=new h.v9(0,0,0),this.diffuseColor=new h.v9(1,1,1),this.specularColor=new h.v9(1,1,1),this.emissiveColor=new h.v9(0,0,0),this.specularPower=64,this._useAlphaFromDiffuseTexture=!1,this._useEmissiveAsIllumination=!1,this._linkEmissiveWithDiffuse=!1,this._useSpecularOverAlpha=!1,this._useReflectionOverAlpha=!1,this._disableLighting=!1,this._useObjectSpaceNormalMap=!1,this._useParallax=!1,this._useParallaxOcclusion=!1,this.parallaxScaleBias=.05,this._roughness=0,this.indexOfRefraction=.98,this.invertRefractionY=!0,this.alphaCutOff=.4,this._useLightmapAsShadowmap=!1,this._useReflectionFresnelFromSpecular=!1,this._useGlossinessFromSpecularMapAlpha=!1,this._maxSimultaneousLights=4,this._invertNormalMapX=!1,this._invertNormalMapY=!1,this._twoSidedLighting=!1,this._applyDecalMapAfterDetailMap=!1,this._shadersLoaded=!1,this._renderTargets=new n.L(16),this._worldViewProjectionMatrix=o.uq.Zero(),this._globalAmbientColor=new h.v9(0,0,0),this._cacheHasRenderTargetTextures=!1,this.detailMap=new R(this),this._attachImageProcessingConfiguration(null),this.prePassConfiguration=new c,this.getRenderTargetTextures=()=>(this._renderTargets.reset(),I.ReflectionTextureEnabled&&this._reflectionTexture&&this._reflectionTexture.isRenderTarget&&this._renderTargets.push(this._reflectionTexture),I.RefractionTextureEnabled&&this._refractionTexture&&this._refractionTexture.isRenderTarget&&this._renderTargets.push(this._refractionTexture),this._eventInfo.renderTargets=this._renderTargets,this._callbackPluginEventFillRenderTargetTextures(this._eventInfo),this._renderTargets)}get hasRenderTargetTextures(){return!!(I.ReflectionTextureEnabled&&this._reflectionTexture&&this._reflectionTexture.isRenderTarget)||!!(I.RefractionTextureEnabled&&this._refractionTexture&&this._refractionTexture.isRenderTarget)||this._cacheHasRenderTargetTextures}getClassName(){return"StandardMaterial"}needAlphaBlending(){return!this._disableAlphaBlending&&(this.alpha<1||null!=this._opacityTexture||this._shouldUseAlphaFromDiffuseTexture()||this._opacityFresnelParameters&&this._opacityFresnelParameters.isEnabled)}needAlphaTesting(){return!!this._forceAlphaTest||this._hasAlphaChannel()&&(null==this._transparencyMode||this._transparencyMode===d.i.MATERIAL_ALPHATEST)}_shouldUseAlphaFromDiffuseTexture(){return null!=this._diffuseTexture&&this._diffuseTexture.hasAlpha&&this._useAlphaFromDiffuseTexture&&this._transparencyMode!==d.i.MATERIAL_OPAQUE}_hasAlphaChannel(){return null!=this._diffuseTexture&&this._diffuseTexture.hasAlpha||null!=this._opacityTexture}getAlphaTestTexture(){return this._diffuseTexture}isReadyForSubMesh(e,t,i=!1){this._uniformBufferLayoutBuilt||this.buildUniformLayout();const r=t._drawWrapper;if(r.effect&&this.isFrozen&&r._wasPreviouslyReady&&r._wasPreviouslyUsingInstances===i)return!0;t.materialDefines||(this._callbackPluginEventGeneric(4,this._eventInfo),t.materialDefines=new S(this._eventInfo.defineNames));const n=this.getScene(),a=t.materialDefines;if(this._isReadyForSubMesh(t))return!0;const o=n.getEngine();a._needNormals=(0,x.az)(n,e,a,!0,this._maxSimultaneousLights,this._disableLighting),(0,x.VO)(n,a);const h=this.needAlphaBlendingForMesh(e)&&this.getScene().useOrderIndependentTransparency;if((0,x.N4)(n,a,this.canRenderToMRT&&!h),(0,x.Nc)(n,a,h),v.PrepareDefines(o.currentRenderPassId,e,a),a._areTexturesDirty){this._eventInfo.hasRenderTargetTextures=!1,this._callbackPluginEventHasRenderTargetTextures(this._eventInfo),this._cacheHasRenderTargetTextures=this._eventInfo.hasRenderTargetTextures,a._needUVs=!1;for(let e=1;e<=6;++e)a["MAINUV"+e]=!1;if(n.texturesEnabled){if(a.DIFFUSEDIRECTUV=0,a.BUMPDIRECTUV=0,a.AMBIENTDIRECTUV=0,a.OPACITYDIRECTUV=0,a.EMISSIVEDIRECTUV=0,a.SPECULARDIRECTUV=0,a.LIGHTMAPDIRECTUV=0,this._diffuseTexture&&I.DiffuseTextureEnabled){if(!this._diffuseTexture.isReadyOrNotBlocking())return!1;(0,x.YT)(this._diffuseTexture,a,"DIFFUSE")}else a.DIFFUSE=!1;if(this._ambientTexture&&I.AmbientTextureEnabled){if(!this._ambientTexture.isReadyOrNotBlocking())return!1;(0,x.YT)(this._ambientTexture,a,"AMBIENT")}else a.AMBIENT=!1;if(this._opacityTexture&&I.OpacityTextureEnabled){if(!this._opacityTexture.isReadyOrNotBlocking())return!1;(0,x.YT)(this._opacityTexture,a,"OPACITY"),a.OPACITYRGB=this._opacityTexture.getAlphaFromRGB}else a.OPACITY=!1;if(this._reflectionTexture&&I.ReflectionTextureEnabled){if(!this._reflectionTexture.isReadyOrNotBlocking())return!1;switch(a._needNormals=!0,a.REFLECTION=!0,a.ROUGHNESS=this._roughness>0,a.REFLECTIONOVERALPHA=this._useReflectionOverAlpha,a.INVERTCUBICMAP=this._reflectionTexture.coordinatesMode===p.g.INVCUBIC_MODE,a.REFLECTIONMAP_3D=this._reflectionTexture.isCube,a.REFLECTIONMAP_OPPOSITEZ=a.REFLECTIONMAP_3D&&this.getScene().useRightHandedSystem?!this._reflectionTexture.invertZ:this._reflectionTexture.invertZ,a.RGBDREFLECTION=this._reflectionTexture.isRGBD,this._reflectionTexture.coordinatesMode){case p.g.EXPLICIT_MODE:a.setReflectionMode("REFLECTIONMAP_EXPLICIT");break;case p.g.PLANAR_MODE:a.setReflectionMode("REFLECTIONMAP_PLANAR");break;case p.g.PROJECTION_MODE:a.setReflectionMode("REFLECTIONMAP_PROJECTION");break;case p.g.SKYBOX_MODE:a.setReflectionMode("REFLECTIONMAP_SKYBOX");break;case p.g.SPHERICAL_MODE:a.setReflectionMode("REFLECTIONMAP_SPHERICAL");break;case p.g.EQUIRECTANGULAR_MODE:a.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR");break;case p.g.FIXED_EQUIRECTANGULAR_MODE:a.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR_FIXED");break;case p.g.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:a.setReflectionMode("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED");break;case p.g.CUBIC_MODE:case p.g.INVCUBIC_MODE:default:a.setReflectionMode("REFLECTIONMAP_CUBIC")}a.USE_LOCAL_REFLECTIONMAP_CUBIC=!!this._reflectionTexture.boundingBoxSize}else a.REFLECTION=!1,a.REFLECTIONMAP_OPPOSITEZ=!1;if(this._emissiveTexture&&I.EmissiveTextureEnabled){if(!this._emissiveTexture.isReadyOrNotBlocking())return!1;(0,x.YT)(this._emissiveTexture,a,"EMISSIVE")}else a.EMISSIVE=!1;if(this._lightmapTexture&&I.LightmapTextureEnabled){if(!this._lightmapTexture.isReadyOrNotBlocking())return!1;(0,x.YT)(this._lightmapTexture,a,"LIGHTMAP"),a.USELIGHTMAPASSHADOWMAP=this._useLightmapAsShadowmap,a.RGBDLIGHTMAP=this._lightmapTexture.isRGBD}else a.LIGHTMAP=!1;if(this._specularTexture&&I.SpecularTextureEnabled){if(!this._specularTexture.isReadyOrNotBlocking())return!1;(0,x.YT)(this._specularTexture,a,"SPECULAR"),a.GLOSSINESS=this._useGlossinessFromSpecularMapAlpha}else a.SPECULAR=!1;if(n.getEngine().getCaps().standardDerivatives&&this._bumpTexture&&I.BumpTextureEnabled){if(!this._bumpTexture.isReady())return!1;(0,x.YT)(this._bumpTexture,a,"BUMP"),a.PARALLAX=this._useParallax,a.PARALLAX_RHS=n.useRightHandedSystem,a.PARALLAXOCCLUSION=this._useParallaxOcclusion,a.OBJECTSPACE_NORMALMAP=this._useObjectSpaceNormalMap}else a.BUMP=!1,a.PARALLAX=!1,a.PARALLAX_RHS=!1,a.PARALLAXOCCLUSION=!1;if(this._refractionTexture&&I.RefractionTextureEnabled){if(!this._refractionTexture.isReadyOrNotBlocking())return!1;a._needUVs=!0,a.REFRACTION=!0,a.REFRACTIONMAP_3D=this._refractionTexture.isCube,a.RGBDREFRACTION=this._refractionTexture.isRGBD,a.USE_LOCAL_REFRACTIONMAP_CUBIC=!!this._refractionTexture.boundingBoxSize}else a.REFRACTION=!1;a.TWOSIDEDLIGHTING=!this._backFaceCulling&&this._twoSidedLighting}else a.DIFFUSE=!1,a.AMBIENT=!1,a.OPACITY=!1,a.REFLECTION=!1,a.EMISSIVE=!1,a.LIGHTMAP=!1,a.BUMP=!1,a.REFRACTION=!1;a.ALPHAFROMDIFFUSE=this._shouldUseAlphaFromDiffuseTexture(),a.EMISSIVEASILLUMINATION=this._useEmissiveAsIllumination,a.LINKEMISSIVEWITHDIFFUSE=this._linkEmissiveWithDiffuse,a.SPECULAROVERALPHA=this._useSpecularOverAlpha,a.PREMULTIPLYALPHA=7===this.alphaMode||8===this.alphaMode,a.ALPHATEST_AFTERALLALPHACOMPUTATIONS=null!==this.transparencyMode,a.ALPHABLEND=null===this.transparencyMode||this.needAlphaBlendingForMesh(e)}if(this._eventInfo.isReadyForSubMesh=!0,this._eventInfo.defines=a,this._eventInfo.subMesh=t,this._callbackPluginEventIsReadyForSubMesh(this._eventInfo),!this._eventInfo.isReadyForSubMesh)return!1;if(a._areImageProcessingDirty&&this._imageProcessingConfiguration){if(!this._imageProcessingConfiguration.isReady())return!1;this._imageProcessingConfiguration.prepareDefines(a),a.IS_REFLECTION_LINEAR=null!=this.reflectionTexture&&!this.reflectionTexture.gammaSpace,a.IS_REFRACTION_LINEAR=null!=this.refractionTexture&&!this.refractionTexture.gammaSpace}a._areFresnelDirty&&(I.FresnelEnabled?(this._diffuseFresnelParameters||this._opacityFresnelParameters||this._emissiveFresnelParameters||this._refractionFresnelParameters||this._reflectionFresnelParameters)&&(a.DIFFUSEFRESNEL=this._diffuseFresnelParameters&&this._diffuseFresnelParameters.isEnabled,a.OPACITYFRESNEL=this._opacityFresnelParameters&&this._opacityFresnelParameters.isEnabled,a.REFLECTIONFRESNEL=this._reflectionFresnelParameters&&this._reflectionFresnelParameters.isEnabled,a.REFLECTIONFRESNELFROMSPECULAR=this._useReflectionFresnelFromSpecular,a.REFRACTIONFRESNEL=this._refractionFresnelParameters&&this._refractionFresnelParameters.isEnabled,a.EMISSIVEFRESNEL=this._emissiveFresnelParameters&&this._emissiveFresnelParameters.isEnabled,a._needNormals=!0,a.FRESNEL=!0):a.FRESNEL=!1),(0,x.fm)(e,n,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e)||this._forceAlphaTest,a,this._applyDecalMapAfterDetailMap),(0,x.OR)(n,o,this,a,i,null,t.getRenderingMesh().hasThinInstances),this._eventInfo.defines=a,this._eventInfo.mesh=e,this._callbackPluginEventPrepareDefinesBeforeAttributes(this._eventInfo),(0,x.qB)(e,a,!0,!0,!0),this._callbackPluginEventPrepareDefines(this._eventInfo);let d=!1;if(a.isDirty){const i=a._areLightsDisposed;a.markAsProcessed();const r=new b.J;a.REFLECTION&&r.addFallback(0,"REFLECTION"),a.SPECULAR&&r.addFallback(0,"SPECULAR"),a.BUMP&&r.addFallback(0,"BUMP"),a.PARALLAX&&r.addFallback(1,"PARALLAX"),a.PARALLAX_RHS&&r.addFallback(1,"PARALLAX_RHS"),a.PARALLAXOCCLUSION&&r.addFallback(0,"PARALLAXOCCLUSION"),a.SPECULAROVERALPHA&&r.addFallback(0,"SPECULAROVERALPHA"),a.FOG&&r.addFallback(1,"FOG"),a.POINTSIZE&&r.addFallback(0,"POINTSIZE"),a.LOGARITHMICDEPTH&&r.addFallback(0,"LOGARITHMICDEPTH"),(0,x.c4)(a,r,this._maxSimultaneousLights),a.SPECULARTERM&&r.addFallback(0,"SPECULARTERM"),a.DIFFUSEFRESNEL&&r.addFallback(1,"DIFFUSEFRESNEL"),a.OPACITYFRESNEL&&r.addFallback(2,"OPACITYFRESNEL"),a.REFLECTIONFRESNEL&&r.addFallback(3,"REFLECTIONFRESNEL"),a.EMISSIVEFRESNEL&&r.addFallback(4,"EMISSIVEFRESNEL"),a.FRESNEL&&r.addFallback(4,"FRESNEL"),a.MULTIVIEW&&r.addFallback(0,"MULTIVIEW");const h=[l.R.PositionKind];a.NORMAL&&h.push(l.R.NormalKind),a.TANGENT&&h.push(l.R.TangentKind);for(let e=1;e<=6;++e)a["UV"+e]&&h.push(`uv${1===e?"":e}`);a.VERTEXCOLOR&&h.push(l.R.ColorKind),(0,x.ni)(h,e,a,r),(0,x.ER)(h,a),(0,x.IF)(h,e,a),(0,x.J2)(h,e,a);let _="default";const f=["world","view","viewProjection","vEyePosition","vLightsType","vAmbientColor","vDiffuseColor","vSpecularColor","vEmissiveColor","visibility","vFogInfos","vFogColor","pointSize","vDiffuseInfos","vAmbientInfos","vOpacityInfos","vReflectionInfos","vEmissiveInfos","vSpecularInfos","vBumpInfos","vLightmapInfos","vRefractionInfos","mBones","diffuseMatrix","ambientMatrix","opacityMatrix","reflectionMatrix","emissiveMatrix","specularMatrix","bumpMatrix","normalMatrix","lightmapMatrix","refractionMatrix","diffuseLeftColor","diffuseRightColor","opacityParts","reflectionLeftColor","reflectionRightColor","emissiveLeftColor","emissiveRightColor","refractionLeftColor","refractionRightColor","vReflectionPosition","vReflectionSize","vRefractionPosition","vRefractionSize","logarithmicDepthConstant","vTangentSpaceParams","alphaCutOff","boneTextureWidth","morphTargetTextureInfo","morphTargetTextureIndices"],p=["diffuseSampler","ambientSampler","opacitySampler","reflectionCubeSampler","reflection2DSampler","emissiveSampler","specularSampler","bumpSampler","lightmapSampler","refractionCubeSampler","refraction2DSampler","boneSampler","morphTargets","oitDepthSampler","oitFrontColorSampler"],g=["Material","Scene","Mesh"],m={maxSimultaneousLights:this._maxSimultaneousLights,maxSimultaneousMorphTargets:a.NUM_MORPH_INFLUENCERS};this._eventInfo.fallbacks=r,this._eventInfo.fallbackRank=0,this._eventInfo.defines=a,this._eventInfo.uniforms=f,this._eventInfo.attributes=h,this._eventInfo.samplers=p,this._eventInfo.uniformBuffersNames=g,this._eventInfo.customCode=void 0,this._eventInfo.mesh=e,this._eventInfo.indexParameters=m,this._callbackPluginEventGeneric(128,this._eventInfo),v.AddUniformsAndSamplers(f,p),c.AddUniforms(f),c.AddSamplers(p),u.p&&(u.p.PrepareUniforms(f,a),u.p.PrepareSamplers(p,a)),(0,x.Bb)({uniformsNames:f,uniformBuffersNames:g,samplers:p,defines:a,maxSimultaneousLights:this._maxSimultaneousLights}),(0,y.TV)(f);const T={};this.customShaderNameResolve&&(_=this.customShaderNameResolve(_,f,g,p,a,h,T));const E=a.toString(),A=t.effect;let R=n.getEngine().createEffect(_,{attributes:h,uniformsNames:f,uniformBuffersNames:g,samplers:p,defines:E,fallbacks:r,onCompiled:this.onCompiled,onError:this.onError,indexParameters:m,processFinalCode:T.processFinalCode,processCodeAfterIncludes:this._eventInfo.customCode,multiTarget:a.PREPASS,shaderLanguage:this._shaderLanguage,extraInitializationsAsync:this._shadersLoaded?void 0:async()=>{1===this._shaderLanguage?await Promise.all([s.e(126).then(s.bind(s,6234)),s.e(126).then(s.bind(s,2727))]):await Promise.all([s.e(71).then(s.bind(s,5735)),s.e(71).then(s.bind(s,9041))]),this._shadersLoaded=!0}},o);if(this._eventInfo.customCode=void 0,R)if(this._onEffectCreatedObservable&&(C.effect=R,C.subMesh=t,this._onEffectCreatedObservable.notifyObservers(C)),this.allowShaderHotSwapping&&A&&!R.isReady()){if(R=A,a.markAsUnprocessed(),d=this.isFrozen,i)return a._areLightsDisposed=!0,!1}else n.resetCachedMaterial(),t.setEffect(R,a,this._materialContext)}return!(!t.effect||!t.effect.isReady()||(a._renderId=n.getRenderId(),r._wasPreviouslyReady=!d,r._wasPreviouslyUsingInstances=i,this._checkScenePerformancePriority(),0))}buildUniformLayout(){const e=this._uniformBuffer;e.addUniform("diffuseLeftColor",4),e.addUniform("diffuseRightColor",4),e.addUniform("opacityParts",4),e.addUniform("reflectionLeftColor",4),e.addUniform("reflectionRightColor",4),e.addUniform("refractionLeftColor",4),e.addUniform("refractionRightColor",4),e.addUniform("emissiveLeftColor",4),e.addUniform("emissiveRightColor",4),e.addUniform("vDiffuseInfos",2),e.addUniform("vAmbientInfos",2),e.addUniform("vOpacityInfos",2),e.addUniform("vReflectionInfos",2),e.addUniform("vReflectionPosition",3),e.addUniform("vReflectionSize",3),e.addUniform("vEmissiveInfos",2),e.addUniform("vLightmapInfos",2),e.addUniform("vSpecularInfos",2),e.addUniform("vBumpInfos",3),e.addUniform("diffuseMatrix",16),e.addUniform("ambientMatrix",16),e.addUniform("opacityMatrix",16),e.addUniform("reflectionMatrix",16),e.addUniform("emissiveMatrix",16),e.addUniform("lightmapMatrix",16),e.addUniform("specularMatrix",16),e.addUniform("bumpMatrix",16),e.addUniform("vTangentSpaceParams",2),e.addUniform("pointSize",1),e.addUniform("alphaCutOff",1),e.addUniform("refractionMatrix",16),e.addUniform("vRefractionInfos",4),e.addUniform("vRefractionPosition",3),e.addUniform("vRefractionSize",3),e.addUniform("vSpecularColor",4),e.addUniform("vEmissiveColor",3),e.addUniform("vDiffuseColor",4),e.addUniform("vAmbientColor",3),super.buildUniformLayout()}bindForSubMesh(e,t,s){const i=this.getScene(),r=s.materialDefines;if(!r)return;const n=s.effect;if(!n)return;this._activeEffect=n,t.getMeshUniformBuffer().bindToEffect(n,"Mesh"),t.transferToEffect(e),this._uniformBuffer.bindToEffect(n,"Material"),this.prePassConfiguration.bindForSubMesh(this._activeEffect,i,t,e,this.isFrozen),v.Bind(i.getEngine().currentRenderPassId,this._activeEffect,t,e),this._eventInfo.subMesh=s,this._callbackPluginEventHardBindForSubMesh(this._eventInfo),r.OBJECTSPACE_NORMALMAP&&(e.toNormalMatrix(this._normalMatrix),this.bindOnlyNormalMatrix(this._normalMatrix));const o=this._mustRebind(i,n,s,t.visibility);(0,x.f$)(t,n);const l=this._uniformBuffer;if(o){if(this.bindViewProjection(n),!l.useUbo||!this.isFrozen||!l.isSync||s._drawWrapper._forceRebindOnNextCall){if(I.FresnelEnabled&&r.FRESNEL&&(this.diffuseFresnelParameters&&this.diffuseFresnelParameters.isEnabled&&(l.updateColor4("diffuseLeftColor",this.diffuseFresnelParameters.leftColor,this.diffuseFresnelParameters.power),l.updateColor4("diffuseRightColor",this.diffuseFresnelParameters.rightColor,this.diffuseFresnelParameters.bias)),this.opacityFresnelParameters&&this.opacityFresnelParameters.isEnabled&&l.updateColor4("opacityParts",new h.v9(this.opacityFresnelParameters.leftColor.toLuminance(),this.opacityFresnelParameters.rightColor.toLuminance(),this.opacityFresnelParameters.bias),this.opacityFresnelParameters.power),this.reflectionFresnelParameters&&this.reflectionFresnelParameters.isEnabled&&(l.updateColor4("reflectionLeftColor",this.reflectionFresnelParameters.leftColor,this.reflectionFresnelParameters.power),l.updateColor4("reflectionRightColor",this.reflectionFresnelParameters.rightColor,this.reflectionFresnelParameters.bias)),this.refractionFresnelParameters&&this.refractionFresnelParameters.isEnabled&&(l.updateColor4("refractionLeftColor",this.refractionFresnelParameters.leftColor,this.refractionFresnelParameters.power),l.updateColor4("refractionRightColor",this.refractionFresnelParameters.rightColor,this.refractionFresnelParameters.bias)),this.emissiveFresnelParameters&&this.emissiveFresnelParameters.isEnabled&&(l.updateColor4("emissiveLeftColor",this.emissiveFresnelParameters.leftColor,this.emissiveFresnelParameters.power),l.updateColor4("emissiveRightColor",this.emissiveFresnelParameters.rightColor,this.emissiveFresnelParameters.bias))),i.texturesEnabled){if(this._diffuseTexture&&I.DiffuseTextureEnabled&&(l.updateFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),(0,x.mA)(this._diffuseTexture,l,"diffuse")),this._ambientTexture&&I.AmbientTextureEnabled&&(l.updateFloat2("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level),(0,x.mA)(this._ambientTexture,l,"ambient")),this._opacityTexture&&I.OpacityTextureEnabled&&(l.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),(0,x.mA)(this._opacityTexture,l,"opacity")),this._hasAlphaChannel()&&l.updateFloat("alphaCutOff",this.alphaCutOff),this._reflectionTexture&&I.ReflectionTextureEnabled&&(l.updateFloat2("vReflectionInfos",this._reflectionTexture.level,this.roughness),l.updateMatrix("reflectionMatrix",this._reflectionTexture.getReflectionTextureMatrix()),this._reflectionTexture.boundingBoxSize)){const e=this._reflectionTexture;l.updateVector3("vReflectionPosition",e.boundingBoxPosition),l.updateVector3("vReflectionSize",e.boundingBoxSize)}if(this._emissiveTexture&&I.EmissiveTextureEnabled&&(l.updateFloat2("vEmissiveInfos",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),(0,x.mA)(this._emissiveTexture,l,"emissive")),this._lightmapTexture&&I.LightmapTextureEnabled&&(l.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),(0,x.mA)(this._lightmapTexture,l,"lightmap")),this._specularTexture&&I.SpecularTextureEnabled&&(l.updateFloat2("vSpecularInfos",this._specularTexture.coordinatesIndex,this._specularTexture.level),(0,x.mA)(this._specularTexture,l,"specular")),this._bumpTexture&&i.getEngine().getCaps().standardDerivatives&&I.BumpTextureEnabled&&(l.updateFloat3("vBumpInfos",this._bumpTexture.coordinatesIndex,1/this._bumpTexture.level,this.parallaxScaleBias),(0,x.mA)(this._bumpTexture,l,"bump"),i._mirroredCameraPosition?l.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?1:-1,this._invertNormalMapY?1:-1):l.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?-1:1,this._invertNormalMapY?-1:1)),this._refractionTexture&&I.RefractionTextureEnabled){let e=1;if(this._refractionTexture.isCube||(l.updateMatrix("refractionMatrix",this._refractionTexture.getReflectionTextureMatrix()),this._refractionTexture.depth&&(e=this._refractionTexture.depth)),l.updateFloat4("vRefractionInfos",this._refractionTexture.level,this.indexOfRefraction,e,this.invertRefractionY?-1:1),this._refractionTexture.boundingBoxSize){const e=this._refractionTexture;l.updateVector3("vRefractionPosition",e.boundingBoxPosition),l.updateVector3("vRefractionSize",e.boundingBoxSize)}}}this.pointsCloud&&l.updateFloat("pointSize",this.pointSize),l.updateColor4("vSpecularColor",this.specularColor,this.specularPower),l.updateColor3("vEmissiveColor",I.EmissiveTextureEnabled?this.emissiveColor:h.v9.BlackReadOnly),l.updateColor4("vDiffuseColor",this.diffuseColor,this.alpha),i.ambientColor.multiplyToRef(this.ambientColor,this._globalAmbientColor),l.updateColor3("vAmbientColor",this._globalAmbientColor)}i.texturesEnabled&&(this._diffuseTexture&&I.DiffuseTextureEnabled&&n.setTexture("diffuseSampler",this._diffuseTexture),this._ambientTexture&&I.AmbientTextureEnabled&&n.setTexture("ambientSampler",this._ambientTexture),this._opacityTexture&&I.OpacityTextureEnabled&&n.setTexture("opacitySampler",this._opacityTexture),this._reflectionTexture&&I.ReflectionTextureEnabled&&(this._reflectionTexture.isCube?n.setTexture("reflectionCubeSampler",this._reflectionTexture):n.setTexture("reflection2DSampler",this._reflectionTexture)),this._emissiveTexture&&I.EmissiveTextureEnabled&&n.setTexture("emissiveSampler",this._emissiveTexture),this._lightmapTexture&&I.LightmapTextureEnabled&&n.setTexture("lightmapSampler",this._lightmapTexture),this._specularTexture&&I.SpecularTextureEnabled&&n.setTexture("specularSampler",this._specularTexture),this._bumpTexture&&i.getEngine().getCaps().standardDerivatives&&I.BumpTextureEnabled&&n.setTexture("bumpSampler",this._bumpTexture),this._refractionTexture&&I.RefractionTextureEnabled&&(this._refractionTexture.isCube?n.setTexture("refractionCubeSampler",this._refractionTexture):n.setTexture("refraction2DSampler",this._refractionTexture))),this.getScene().useOrderIndependentTransparency&&this.needAlphaBlendingForMesh(t)&&this.getScene().depthPeelingRenderer.bind(n),this._eventInfo.subMesh=s,this._callbackPluginEventBindForSubMesh(this._eventInfo),(0,y.gS)(n,this,i),this.bindEyePosition(n)}else i.getEngine()._features.needToAlwaysBindUniformBuffers&&(this._needToBindSceneUbo=!0);!o&&this.isFrozen||(i.lightsEnabled&&!this._disableLighting&&(0,x.RL)(i,t,n,r,this._maxSimultaneousLights),(i.fogEnabled&&t.applyFog&&i.fogMode!==a.Z.FOGMODE_NONE||this._reflectionTexture||this._refractionTexture||t.receiveShadows||r.PREPASS)&&this.bindView(n),(0,x.Yy)(i,t,n),r.NUM_MORPH_INFLUENCERS&&(0,x.nR)(t,n),r.BAKED_VERTEX_ANIMATION_TEXTURE&&t.bakedVertexAnimationManager?.bind(n,r.INSTANCES),this.useLogarithmicDepth&&(0,x.DL)(r,n,i),this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.applyByPostProcess&&this._imageProcessingConfiguration.bind(this._activeEffect)),this._afterBind(t,this._activeEffect,s),l.update()}getAnimatables(){const e=super.getAnimatables();return this._diffuseTexture&&this._diffuseTexture.animations&&this._diffuseTexture.animations.length>0&&e.push(this._diffuseTexture),this._ambientTexture&&this._ambientTexture.animations&&this._ambientTexture.animations.length>0&&e.push(this._ambientTexture),this._opacityTexture&&this._opacityTexture.animations&&this._opacityTexture.animations.length>0&&e.push(this._opacityTexture),this._reflectionTexture&&this._reflectionTexture.animations&&this._reflectionTexture.animations.length>0&&e.push(this._reflectionTexture),this._emissiveTexture&&this._emissiveTexture.animations&&this._emissiveTexture.animations.length>0&&e.push(this._emissiveTexture),this._specularTexture&&this._specularTexture.animations&&this._specularTexture.animations.length>0&&e.push(this._specularTexture),this._bumpTexture&&this._bumpTexture.animations&&this._bumpTexture.animations.length>0&&e.push(this._bumpTexture),this._lightmapTexture&&this._lightmapTexture.animations&&this._lightmapTexture.animations.length>0&&e.push(this._lightmapTexture),this._refractionTexture&&this._refractionTexture.animations&&this._refractionTexture.animations.length>0&&e.push(this._refractionTexture),e}getActiveTextures(){const e=super.getActiveTextures();return this._diffuseTexture&&e.push(this._diffuseTexture),this._ambientTexture&&e.push(this._ambientTexture),this._opacityTexture&&e.push(this._opacityTexture),this._reflectionTexture&&e.push(this._reflectionTexture),this._emissiveTexture&&e.push(this._emissiveTexture),this._specularTexture&&e.push(this._specularTexture),this._bumpTexture&&e.push(this._bumpTexture),this._lightmapTexture&&e.push(this._lightmapTexture),this._refractionTexture&&e.push(this._refractionTexture),e}hasTexture(e){return!!super.hasTexture(e)||this._diffuseTexture===e||this._ambientTexture===e||this._opacityTexture===e||this._reflectionTexture===e||this._emissiveTexture===e||this._specularTexture===e||this._bumpTexture===e||this._lightmapTexture===e||this._refractionTexture===e}dispose(e,t){t&&(this._diffuseTexture?.dispose(),this._ambientTexture?.dispose(),this._opacityTexture?.dispose(),this._reflectionTexture?.dispose(),this._emissiveTexture?.dispose(),this._specularTexture?.dispose(),this._bumpTexture?.dispose(),this._lightmapTexture?.dispose(),this._refractionTexture?.dispose()),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),super.dispose(e,t)}clone(e,t=!0,s=""){const i=P.p.Clone((()=>new I(e,this.getScene())),this,{cloneTexturesOnlyOnce:t});return i.name=e,i.id=e,this.stencil.copyTo(i.stencil),this._clonePlugins(i,s),i}static Parse(e,t,s){const i=P.p.Parse((()=>new I(e.name,t)),e,t,s);return e.stencil&&i.stencil.parse(e.stencil,t,s),d.i._ParsePlugins(e,i,t,s),i}static get DiffuseTextureEnabled(){return T.DiffuseTextureEnabled}static set DiffuseTextureEnabled(e){T.DiffuseTextureEnabled=e}static get DetailTextureEnabled(){return T.DetailTextureEnabled}static set DetailTextureEnabled(e){T.DetailTextureEnabled=e}static get AmbientTextureEnabled(){return T.AmbientTextureEnabled}static set AmbientTextureEnabled(e){T.AmbientTextureEnabled=e}static get OpacityTextureEnabled(){return T.OpacityTextureEnabled}static set OpacityTextureEnabled(e){T.OpacityTextureEnabled=e}static get ReflectionTextureEnabled(){return T.ReflectionTextureEnabled}static set ReflectionTextureEnabled(e){T.ReflectionTextureEnabled=e}static get EmissiveTextureEnabled(){return T.EmissiveTextureEnabled}static set EmissiveTextureEnabled(e){T.EmissiveTextureEnabled=e}static get SpecularTextureEnabled(){return T.SpecularTextureEnabled}static set SpecularTextureEnabled(e){T.SpecularTextureEnabled=e}static get BumpTextureEnabled(){return T.BumpTextureEnabled}static set BumpTextureEnabled(e){T.BumpTextureEnabled=e}static get LightmapTextureEnabled(){return T.LightmapTextureEnabled}static set LightmapTextureEnabled(e){T.LightmapTextureEnabled=e}static get RefractionTextureEnabled(){return T.RefractionTextureEnabled}static set RefractionTextureEnabled(e){T.RefractionTextureEnabled=e}static get ColorGradingTextureEnabled(){return T.ColorGradingTextureEnabled}static set ColorGradingTextureEnabled(e){T.ColorGradingTextureEnabled=e}static get FresnelEnabled(){return T.FresnelEnabled}static set FresnelEnabled(e){T.FresnelEnabled=e}}I.ForceGLSL=!1,(0,i.Cg)([(0,r.uM)("diffuseTexture")],I.prototype,"_diffuseTexture",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsTexturesAndMiscDirty")],I.prototype,"diffuseTexture",void 0),(0,i.Cg)([(0,r.uM)("ambientTexture")],I.prototype,"_ambientTexture",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsTexturesDirty")],I.prototype,"ambientTexture",void 0),(0,i.Cg)([(0,r.uM)("opacityTexture")],I.prototype,"_opacityTexture",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsTexturesAndMiscDirty")],I.prototype,"opacityTexture",void 0),(0,i.Cg)([(0,r.uM)("reflectionTexture")],I.prototype,"_reflectionTexture",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsTexturesDirty")],I.prototype,"reflectionTexture",void 0),(0,i.Cg)([(0,r.uM)("emissiveTexture")],I.prototype,"_emissiveTexture",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsTexturesDirty")],I.prototype,"emissiveTexture",void 0),(0,i.Cg)([(0,r.uM)("specularTexture")],I.prototype,"_specularTexture",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsTexturesDirty")],I.prototype,"specularTexture",void 0),(0,i.Cg)([(0,r.uM)("bumpTexture")],I.prototype,"_bumpTexture",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsTexturesDirty")],I.prototype,"bumpTexture",void 0),(0,i.Cg)([(0,r.uM)("lightmapTexture")],I.prototype,"_lightmapTexture",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsTexturesDirty")],I.prototype,"lightmapTexture",void 0),(0,i.Cg)([(0,r.uM)("refractionTexture")],I.prototype,"_refractionTexture",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsTexturesDirty")],I.prototype,"refractionTexture",void 0),(0,i.Cg)([(0,r.jT)("ambient")],I.prototype,"ambientColor",void 0),(0,i.Cg)([(0,r.jT)("diffuse")],I.prototype,"diffuseColor",void 0),(0,i.Cg)([(0,r.jT)("specular")],I.prototype,"specularColor",void 0),(0,i.Cg)([(0,r.jT)("emissive")],I.prototype,"emissiveColor",void 0),(0,i.Cg)([(0,r.lK)()],I.prototype,"specularPower",void 0),(0,i.Cg)([(0,r.lK)("useAlphaFromDiffuseTexture")],I.prototype,"_useAlphaFromDiffuseTexture",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsTexturesAndMiscDirty")],I.prototype,"useAlphaFromDiffuseTexture",void 0),(0,i.Cg)([(0,r.lK)("useEmissiveAsIllumination")],I.prototype,"_useEmissiveAsIllumination",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsTexturesDirty")],I.prototype,"useEmissiveAsIllumination",void 0),(0,i.Cg)([(0,r.lK)("linkEmissiveWithDiffuse")],I.prototype,"_linkEmissiveWithDiffuse",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsTexturesDirty")],I.prototype,"linkEmissiveWithDiffuse",void 0),(0,i.Cg)([(0,r.lK)("useSpecularOverAlpha")],I.prototype,"_useSpecularOverAlpha",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsTexturesDirty")],I.prototype,"useSpecularOverAlpha",void 0),(0,i.Cg)([(0,r.lK)("useReflectionOverAlpha")],I.prototype,"_useReflectionOverAlpha",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsTexturesDirty")],I.prototype,"useReflectionOverAlpha",void 0),(0,i.Cg)([(0,r.lK)("disableLighting")],I.prototype,"_disableLighting",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsLightsDirty")],I.prototype,"disableLighting",void 0),(0,i.Cg)([(0,r.lK)("useObjectSpaceNormalMap")],I.prototype,"_useObjectSpaceNormalMap",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsTexturesDirty")],I.prototype,"useObjectSpaceNormalMap",void 0),(0,i.Cg)([(0,r.lK)("useParallax")],I.prototype,"_useParallax",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsTexturesDirty")],I.prototype,"useParallax",void 0),(0,i.Cg)([(0,r.lK)("useParallaxOcclusion")],I.prototype,"_useParallaxOcclusion",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsTexturesDirty")],I.prototype,"useParallaxOcclusion",void 0),(0,i.Cg)([(0,r.lK)()],I.prototype,"parallaxScaleBias",void 0),(0,i.Cg)([(0,r.lK)("roughness")],I.prototype,"_roughness",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsTexturesDirty")],I.prototype,"roughness",void 0),(0,i.Cg)([(0,r.lK)()],I.prototype,"indexOfRefraction",void 0),(0,i.Cg)([(0,r.lK)()],I.prototype,"invertRefractionY",void 0),(0,i.Cg)([(0,r.lK)()],I.prototype,"alphaCutOff",void 0),(0,i.Cg)([(0,r.lK)("useLightmapAsShadowmap")],I.prototype,"_useLightmapAsShadowmap",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsTexturesDirty")],I.prototype,"useLightmapAsShadowmap",void 0),(0,i.Cg)([(0,r.Y9)("diffuseFresnelParameters")],I.prototype,"_diffuseFresnelParameters",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsFresnelDirty")],I.prototype,"diffuseFresnelParameters",void 0),(0,i.Cg)([(0,r.Y9)("opacityFresnelParameters")],I.prototype,"_opacityFresnelParameters",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsFresnelAndMiscDirty")],I.prototype,"opacityFresnelParameters",void 0),(0,i.Cg)([(0,r.Y9)("reflectionFresnelParameters")],I.prototype,"_reflectionFresnelParameters",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsFresnelDirty")],I.prototype,"reflectionFresnelParameters",void 0),(0,i.Cg)([(0,r.Y9)("refractionFresnelParameters")],I.prototype,"_refractionFresnelParameters",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsFresnelDirty")],I.prototype,"refractionFresnelParameters",void 0),(0,i.Cg)([(0,r.Y9)("emissiveFresnelParameters")],I.prototype,"_emissiveFresnelParameters",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsFresnelDirty")],I.prototype,"emissiveFresnelParameters",void 0),(0,i.Cg)([(0,r.lK)("useReflectionFresnelFromSpecular")],I.prototype,"_useReflectionFresnelFromSpecular",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsFresnelDirty")],I.prototype,"useReflectionFresnelFromSpecular",void 0),(0,i.Cg)([(0,r.lK)("useGlossinessFromSpecularMapAlpha")],I.prototype,"_useGlossinessFromSpecularMapAlpha",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsTexturesDirty")],I.prototype,"useGlossinessFromSpecularMapAlpha",void 0),(0,i.Cg)([(0,r.lK)("maxSimultaneousLights")],I.prototype,"_maxSimultaneousLights",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsLightsDirty")],I.prototype,"maxSimultaneousLights",void 0),(0,i.Cg)([(0,r.lK)("invertNormalMapX")],I.prototype,"_invertNormalMapX",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsTexturesDirty")],I.prototype,"invertNormalMapX",void 0),(0,i.Cg)([(0,r.lK)("invertNormalMapY")],I.prototype,"_invertNormalMapY",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsTexturesDirty")],I.prototype,"invertNormalMapY",void 0),(0,i.Cg)([(0,r.lK)("twoSidedLighting")],I.prototype,"_twoSidedLighting",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsTexturesDirty")],I.prototype,"twoSidedLighting",void 0),(0,i.Cg)([(0,r.lK)("applyDecalMapAfterDetailMap")],I.prototype,"_applyDecalMapAfterDetailMap",void 0),(0,i.Cg)([(0,r.$z)("_markAllSubMeshesAsMiscDirty")],I.prototype,"applyDecalMapAfterDetailMap",void 0),(0,g.Y5)("BABYLON.StandardMaterial",I),a.Z.DefaultMaterialFactory=e=>new I("default material",e)},935:(e,t,s)=>{s.d(t,{D:()=>n});var i=s(1137),r=s(998);class n{constructor(e,t,s,i,r=!1){this._valueCache={},this._engine=e,this._noUBO=!e.supportsUniformBuffers||r,this._dynamic=s,this._name=i??"no-name",this._data=t||[],this._uniformLocations={},this._uniformSizes={},this._uniformArraySizes={},this._uniformLocationPointer=0,this._needSync=!1,this._engine._features.trackUbosInFrame&&(this._buffers=[],this._bufferIndex=-1,this._createBufferOnWrite=!1,this._currentFrameId=0),this._noUBO?(this.updateMatrix3x3=this._updateMatrix3x3ForEffect,this.updateMatrix2x2=this._updateMatrix2x2ForEffect,this.updateFloat=this._updateFloatForEffect,this.updateFloat2=this._updateFloat2ForEffect,this.updateFloat3=this._updateFloat3ForEffect,this.updateFloat4=this._updateFloat4ForEffect,this.updateFloatArray=this._updateFloatArrayForEffect,this.updateArray=this._updateArrayForEffect,this.updateIntArray=this._updateIntArrayForEffect,this.updateUIntArray=this._updateUIntArrayForEffect,this.updateMatrix=this._updateMatrixForEffect,this.updateMatrices=this._updateMatricesForEffect,this.updateVector3=this._updateVector3ForEffect,this.updateVector4=this._updateVector4ForEffect,this.updateColor3=this._updateColor3ForEffect,this.updateColor4=this._updateColor4ForEffect,this.updateDirectColor4=this._updateDirectColor4ForEffect,this.updateInt=this._updateIntForEffect,this.updateInt2=this._updateInt2ForEffect,this.updateInt3=this._updateInt3ForEffect,this.updateInt4=this._updateInt4ForEffect,this.updateUInt=this._updateUIntForEffect,this.updateUInt2=this._updateUInt2ForEffect,this.updateUInt3=this._updateUInt3ForEffect,this.updateUInt4=this._updateUInt4ForEffect):(this._engine._uniformBuffers.push(this),this.updateMatrix3x3=this._updateMatrix3x3ForUniform,this.updateMatrix2x2=this._updateMatrix2x2ForUniform,this.updateFloat=this._updateFloatForUniform,this.updateFloat2=this._updateFloat2ForUniform,this.updateFloat3=this._updateFloat3ForUniform,this.updateFloat4=this._updateFloat4ForUniform,this.updateFloatArray=this._updateFloatArrayForUniform,this.updateArray=this._updateArrayForUniform,this.updateIntArray=this._updateIntArrayForUniform,this.updateUIntArray=this._updateUIntArrayForUniform,this.updateMatrix=this._updateMatrixForUniform,this.updateMatrices=this._updateMatricesForUniform,this.updateVector3=this._updateVector3ForUniform,this.updateVector4=this._updateVector4ForUniform,this.updateColor3=this._updateColor3ForUniform,this.updateColor4=this._updateColor4ForUniform,this.updateDirectColor4=this._updateDirectColor4ForUniform,this.updateInt=this._updateIntForUniform,this.updateInt2=this._updateInt2ForUniform,this.updateInt3=this._updateInt3ForUniform,this.updateInt4=this._updateInt4ForUniform,this.updateUInt=this._updateUIntForUniform,this.updateUInt2=this._updateUInt2ForUniform,this.updateUInt3=this._updateUInt3ForUniform,this.updateUInt4=this._updateUInt4ForUniform)}get useUbo(){return!this._noUBO}get isSync(){return!this._needSync}isDynamic(){return void 0!==this._dynamic}getData(){return this._bufferData}getBuffer(){return this._buffer}_fillAlignment(e){let t;if(t=e<=2?e:4,this._uniformLocationPointer%t!=0){const e=this._uniformLocationPointer;this._uniformLocationPointer+=t-this._uniformLocationPointer%t;const s=this._uniformLocationPointer-e;for(let e=0;e0){if(t instanceof Array)throw"addUniform should not be use with Array in UBO: "+e;this._fillAlignment(4),this._uniformArraySizes[e]={strideSize:t,arraySize:s},16==t?t*=s:t=t*s+(4-t)*s,i=[];for(let e=0;e1&&this._buffers[this._bufferIndex][1]){if(this._buffersEqual(this._bufferData,this._buffers[this._bufferIndex][1]))return this._needSync=!1,void(this._createBufferOnWrite=this._engine._features.trackUbosInFrame);this._copyBuffer(this._bufferData,this._buffers[this._bufferIndex][1])}this._engine.updateUniformBuffer(this._buffer,this._bufferData),this._engine._features._collectUbosUpdatedInFrame&&(n._UpdatedUbosInFrame[this._name]||(n._UpdatedUbosInFrame[this._name]=0),n._UpdatedUbosInFrame[this._name]++),this._needSync=!1,this._createBufferOnWrite=this._engine._features.trackUbosInFrame}else this._createBufferOnWrite=this._engine._features.trackUbosInFrame;else this.create()}_createNewBuffer(){this._bufferIndex+10?(this._needSync=0!==this._bufferIndex,this._bufferIndex=0,this._buffer=this._buffers[this._bufferIndex][0]):this._bufferIndex=-1)}updateUniform(e,t,s){this._checkNewFrame();let r=this._uniformLocations[e];if(void 0===r){if(this._buffer)return void i.V.Error("Cannot add an uniform after UBO has been created. uniformName="+e);this.addUniform(e,s),r=this._uniformLocations[e]}if(this._buffer||this.create(),this._dynamic)for(let e=0;e{s.d(t,{_0:()=>a});var i,r,n=s(9923);!function(e){e[e.LOCAL=0]="LOCAL",e[e.WORLD=1]="WORLD",e[e.BONE=2]="BONE"}(i||(i={}));class a{}a.X=new n.Pq(1,0,0),a.Y=new n.Pq(0,1,0),a.Z=new n.Pq(0,0,1),function(e){e[e.X=0]="X",e[e.Y=1]="Y",e[e.Z=2]="Z"}(r||(r={}))},6041:(e,t,s)=>{s.d(t,{IG:()=>_,ov:()=>d,v9:()=>u});var i=s(7309),r=s(6552),n=s(5559),a=s(4867);function o(e){return Math.pow(e,n.tk)}function h(e){return e<=.04045?.0773993808*e:Math.pow(.947867299*(e+.055),2.4)}function l(e){return Math.pow(e,n.rv)}function c(e){return e<=.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}class u{constructor(e=0,t=0,s=0){this.r=e,this.g=t,this.b=s}toString(){return"{R: "+this.r+" G:"+this.g+" B:"+this.b+"}"}getClassName(){return"Color3"}getHashCode(){let e=255*this.r|0;return e=397*e^(255*this.g|0),e=397*e^(255*this.b|0),e}toArray(e,t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,this}fromArray(e,t=0){return u.FromArrayToRef(e,t,this),this}toColor4(e=1){return new d(this.r,this.g,this.b,e)}asArray(){return[this.r,this.g,this.b]}toLuminance(){return.3*this.r+.59*this.g+.11*this.b}multiply(e){return new u(this.r*e.r,this.g*e.g,this.b*e.b)}multiplyToRef(e,t){return t.r=this.r*e.r,t.g=this.g*e.g,t.b=this.b*e.b,t}multiplyInPlace(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyByFloats(e,t,s){return new u(this.r*e,this.g*t,this.b*s)}divide(e){throw new ReferenceError("Can not divide a color")}divideToRef(e,t){throw new ReferenceError("Can not divide a color")}divideInPlace(e){throw new ReferenceError("Can not divide a color")}minimizeInPlace(e){return this.minimizeInPlaceFromFloats(e.r,e.g,e.b)}maximizeInPlace(e){return this.maximizeInPlaceFromFloats(e.r,e.g,e.b)}minimizeInPlaceFromFloats(e,t,s){return this.r=Math.min(e,this.r),this.g=Math.min(t,this.g),this.b=Math.min(s,this.b),this}maximizeInPlaceFromFloats(e,t,s){return this.r=Math.max(e,this.r),this.g=Math.max(t,this.g),this.b=Math.max(s,this.b),this}floorToRef(e){throw new ReferenceError("Can not floor a color")}floor(){throw new ReferenceError("Can not floor a color")}fractToRef(e){throw new ReferenceError("Can not fract a color")}fract(){throw new ReferenceError("Can not fract a color")}equals(e){return e&&this.r===e.r&&this.g===e.g&&this.b===e.b}equalsFloats(e,t,s){return this.equalsToFloats(e,t,s)}equalsToFloats(e,t,s){return this.r===e&&this.g===t&&this.b===s}equalsWithEpsilon(e,t=n.bH){return(0,a.Mj)(this.r,e.r,t)&&(0,a.Mj)(this.g,e.g,t)&&(0,a.Mj)(this.b,e.b,t)}negate(){throw new ReferenceError("Can not negate a color")}negateInPlace(){throw new ReferenceError("Can not negate a color")}negateToRef(e){throw new ReferenceError("Can not negate a color")}scale(e){return new u(this.r*e,this.g*e,this.b*e)}scaleInPlace(e){return this.r*=e,this.g*=e,this.b*=e,this}scaleToRef(e,t){return t.r=this.r*e,t.g=this.g*e,t.b=this.b*e,t}scaleAndAddToRef(e,t){return t.r+=this.r*e,t.g+=this.g*e,t.b+=this.b*e,t}clampToRef(e=0,t=1,s){return s.r=(0,a.OQ)(this.r,e,t),s.g=(0,a.OQ)(this.g,e,t),s.b=(0,a.OQ)(this.b,e,t),s}add(e){return new u(this.r+e.r,this.g+e.g,this.b+e.b)}addInPlace(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addInPlaceFromFloats(e,t,s){return this.r+=e,this.g+=t,this.b+=s,this}addToRef(e,t){return t.r=this.r+e.r,t.g=this.g+e.g,t.b=this.b+e.b,t}subtract(e){return new u(this.r-e.r,this.g-e.g,this.b-e.b)}subtractToRef(e,t){return t.r=this.r-e.r,t.g=this.g-e.g,t.b=this.b-e.b,t}subtractInPlace(e){return this.r-=e.r,this.g-=e.g,this.b-=e.b,this}subtractFromFloats(e,t,s){return new u(this.r-e,this.g-t,this.b-s)}subtractFromFloatsToRef(e,t,s,i){return i.r=this.r-e,i.g=this.g-t,i.b=this.b-s,i}clone(){return new u(this.r,this.g,this.b)}copyFrom(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copyFromFloats(e,t,s){return this.r=e,this.g=t,this.b=s,this}set(e,t,s){return this.copyFromFloats(e,t,s)}setAll(e){return this.r=this.g=this.b=e,this}toHexString(){const e=Math.round(255*this.r),t=Math.round(255*this.g),s=Math.round(255*this.b);return"#"+(0,a.Db)(e)+(0,a.Db)(t)+(0,a.Db)(s)}fromHexString(e){return"#"!==e.substring(0,1)||7!==e.length||(this.r=parseInt(e.substring(1,3),16)/255,this.g=parseInt(e.substring(3,5),16)/255,this.b=parseInt(e.substring(5,7),16)/255),this}toHSV(){return this.toHSVToRef(new u)}toHSVToRef(e){const t=this.r,s=this.g,i=this.b,r=Math.max(t,s,i),n=Math.min(t,s,i);let a=0,o=0;const h=r,l=r-n;return 0!==r&&(o=l/r),r!=n&&(r==t?(a=(s-i)/l,s=0&&n<=1?(o=r,h=a):n>=1&&n<=2?(o=a,h=r):n>=2&&n<=3?(h=r,l=a):n>=3&&n<=4?(h=a,l=r):n>=4&&n<=5?(o=a,l=r):n>=5&&n<=6&&(o=r,l=a);const c=s-r;return i.r=o+c,i.g=h+c,i.b=l+c,i}static FromHSV(e,t,s){const i=new u(0,0,0);return u.HSVtoRGBToRef(e,t,s,i),i}static FromHexString(e){return new u(0,0,0).fromHexString(e)}static FromArray(e,t=0){return new u(e[t],e[t+1],e[t+2])}static FromArrayToRef(e,t=0,s){s.r=e[t],s.g=e[t+1],s.b=e[t+2]}static FromInts(e,t,s){return new u(e/255,t/255,s/255)}static Lerp(e,t,s){const i=new u(0,0,0);return u.LerpToRef(e,t,s,i),i}static LerpToRef(e,t,s,i){i.r=e.r+(t.r-e.r)*s,i.g=e.g+(t.g-e.g)*s,i.b=e.b+(t.b-e.b)*s}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,d=e.r*o+s.r*h+t.r*l+i.r*c,_=e.g*o+s.g*h+t.g*l+i.g*c,f=e.b*o+s.b*h+t.b*l+i.b*c;return new u(d,_,f)}static Hermite1stDerivative(e,t,s,i,r){const n=u.Black();return this.Hermite1stDerivativeToRef(e,t,s,i,r,n),n}static Hermite1stDerivativeToRef(e,t,s,i,r,n){const a=r*r;n.r=6*(a-r)*e.r+(3*a-4*r+1)*t.r+6*(-a+r)*s.r+(3*a-2*r)*i.r,n.g=6*(a-r)*e.g+(3*a-4*r+1)*t.g+6*(-a+r)*s.g+(3*a-2*r)*i.g,n.b=6*(a-r)*e.b+(3*a-4*r+1)*t.b+6*(-a+r)*s.b+(3*a-2*r)*i.b}static Red(){return new u(1,0,0)}static Green(){return new u(0,1,0)}static Blue(){return new u(0,0,1)}static Black(){return new u(0,0,0)}static get BlackReadOnly(){return u._BlackReadOnly}static White(){return new u(1,1,1)}static Purple(){return new u(.5,0,.5)}static Magenta(){return new u(1,0,1)}static Yellow(){return new u(1,1,0)}static Gray(){return new u(.5,.5,.5)}static Teal(){return new u(0,1,1)}static Random(){return new u(Math.random(),Math.random(),Math.random())}}u._BlackReadOnly=u.Black(),Object.defineProperties(u.prototype,{dimension:{value:[3]},rank:{value:1}});class d{constructor(e=0,t=0,s=0,i=1){this.r=e,this.g=t,this.b=s,this.a=i}asArray(){return[this.r,this.g,this.b,this.a]}toArray(e,t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e[t+3]=this.a,this}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this.a=e[t+3],this}equals(e){return e&&this.r===e.r&&this.g===e.g&&this.b===e.b&&this.a===e.a}add(e){return new d(this.r+e.r,this.g+e.g,this.b+e.b,this.a+e.a)}addToRef(e,t){return t.r=this.r+e.r,t.g=this.g+e.g,t.b=this.b+e.b,t.a=this.a+e.a,t}addInPlace(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this.a+=e.a,this}addInPlaceFromFloats(e,t,s,i){return this.r+=e,this.g+=t,this.b+=s,this.a+=i,this}subtract(e){return new d(this.r-e.r,this.g-e.g,this.b-e.b,this.a-e.a)}subtractToRef(e,t){return t.r=this.r-e.r,t.g=this.g-e.g,t.b=this.b-e.b,t.a=this.a-e.a,t}subtractInPlace(e){return this.r-=e.r,this.g-=e.g,this.b-=e.b,this.a-=e.a,this}subtractFromFloats(e,t,s,i){return new d(this.r-e,this.g-t,this.b-s,this.a-i)}subtractFromFloatsToRef(e,t,s,i,r){return r.r=this.r-e,r.g=this.g-t,r.b=this.b-s,r.a=this.a-i,r}scale(e){return new d(this.r*e,this.g*e,this.b*e,this.a*e)}scaleInPlace(e){return this.r*=e,this.g*=e,this.b*=e,this.a*=e,this}scaleToRef(e,t){return t.r=this.r*e,t.g=this.g*e,t.b=this.b*e,t.a=this.a*e,t}scaleAndAddToRef(e,t){return t.r+=this.r*e,t.g+=this.g*e,t.b+=this.b*e,t.a+=this.a*e,t}clampToRef(e=0,t=1,s){return s.r=(0,a.OQ)(this.r,e,t),s.g=(0,a.OQ)(this.g,e,t),s.b=(0,a.OQ)(this.b,e,t),s.a=(0,a.OQ)(this.a,e,t),s}multiply(e){return new d(this.r*e.r,this.g*e.g,this.b*e.b,this.a*e.a)}multiplyToRef(e,t){return t.r=this.r*e.r,t.g=this.g*e.g,t.b=this.b*e.b,t.a=this.a*e.a,t}multiplyInPlace(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this.a*=e.a,this}multiplyByFloats(e,t,s,i){return new d(this.r*e,this.g*t,this.b*s,this.a*i)}divide(e){throw new ReferenceError("Can not divide a color")}divideToRef(e,t){throw new ReferenceError("Can not divide a color")}divideInPlace(e){throw new ReferenceError("Can not divide a color")}minimizeInPlace(e){return this.r=Math.min(this.r,e.r),this.g=Math.min(this.g,e.g),this.b=Math.min(this.b,e.b),this.a=Math.min(this.a,e.a),this}maximizeInPlace(e){return this.r=Math.max(this.r,e.r),this.g=Math.max(this.g,e.g),this.b=Math.max(this.b,e.b),this.a=Math.max(this.a,e.a),this}minimizeInPlaceFromFloats(e,t,s,i){return this.r=Math.min(e,this.r),this.g=Math.min(t,this.g),this.b=Math.min(s,this.b),this.a=Math.min(i,this.a),this}maximizeInPlaceFromFloats(e,t,s,i){return this.r=Math.max(e,this.r),this.g=Math.max(t,this.g),this.b=Math.max(s,this.b),this.a=Math.max(i,this.a),this}floorToRef(e){throw new ReferenceError("Can not floor a color")}floor(){throw new ReferenceError("Can not floor a color")}fractToRef(e){throw new ReferenceError("Can not fract a color")}fract(){throw new ReferenceError("Can not fract a color")}negate(){throw new ReferenceError("Can not negate a color")}negateInPlace(){throw new ReferenceError("Can not negate a color")}negateToRef(e){throw new ReferenceError("Can not negate a color")}equalsWithEpsilon(e,t=n.bH){return(0,a.Mj)(this.r,e.r,t)&&(0,a.Mj)(this.g,e.g,t)&&(0,a.Mj)(this.b,e.b,t)&&(0,a.Mj)(this.a,e.a,t)}equalsToFloats(e,t,s,i){return this.r===e&&this.g===t&&this.b===s&&this.a===i}toString(){return"{R: "+this.r+" G:"+this.g+" B:"+this.b+" A:"+this.a+"}"}getClassName(){return"Color4"}getHashCode(){let e=255*this.r|0;return e=397*e^(255*this.g|0),e=397*e^(255*this.b|0),e=397*e^(255*this.a|0),e}clone(){return(new d).copyFrom(this)}copyFrom(e){return this.r=e.r,this.g=e.g,this.b=e.b,this.a=e.a,this}copyFromFloats(e,t,s,i){return this.r=e,this.g=t,this.b=s,this.a=i,this}set(e,t,s,i){return this.copyFromFloats(e,t,s,i)}setAll(e){return this.r=this.g=this.b=this.a=e,this}toHexString(e=!1){const t=Math.round(255*this.r),s=Math.round(255*this.g),i=Math.round(255*this.b);if(e)return"#"+(0,a.Db)(t)+(0,a.Db)(s)+(0,a.Db)(i);const r=Math.round(255*this.a);return"#"+(0,a.Db)(t)+(0,a.Db)(s)+(0,a.Db)(i)+(0,a.Db)(r)}fromHexString(e){return"#"!==e.substring(0,1)||9!==e.length&&7!==e.length||(this.r=parseInt(e.substring(1,3),16)/255,this.g=parseInt(e.substring(3,5),16)/255,this.b=parseInt(e.substring(5,7),16)/255,9===e.length&&(this.a=parseInt(e.substring(7,9),16)/255)),this}toLinearSpace(e=!1){const t=new d;return this.toLinearSpaceToRef(t,e),t}toLinearSpaceToRef(e,t=!1){return t?(e.r=h(this.r),e.g=h(this.g),e.b=h(this.b)):(e.r=o(this.r),e.g=o(this.g),e.b=o(this.b)),e.a=this.a,this}toGammaSpace(e=!1){const t=new d;return this.toGammaSpaceToRef(t,e),t}toGammaSpaceToRef(e,t=!1){return t?(e.r=c(this.r),e.g=c(this.g),e.b=c(this.b)):(e.r=l(this.r),e.g=l(this.g),e.b=l(this.b)),e.a=this.a,this}static FromHexString(e){return"#"!==e.substring(0,1)||9!==e.length&&7!==e.length?new d(0,0,0,0):new d(0,0,0,1).fromHexString(e)}static Lerp(e,t,s){return d.LerpToRef(e,t,s,new d)}static LerpToRef(e,t,s,i){return i.r=e.r+(t.r-e.r)*s,i.g=e.g+(t.g-e.g)*s,i.b=e.b+(t.b-e.b)*s,i.a=e.a+(t.a-e.a)*s,i}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.r*o+s.r*h+t.r*l+i.r*c,_=e.g*o+s.g*h+t.g*l+i.g*c,f=e.b*o+s.b*h+t.b*l+i.b*c,p=e.a*o+s.a*h+t.a*l+i.a*c;return new d(u,_,f,p)}static Hermite1stDerivative(e,t,s,i,r){const n=new d;return this.Hermite1stDerivativeToRef(e,t,s,i,r,n),n}static Hermite1stDerivativeToRef(e,t,s,i,r,n){const a=r*r;n.r=6*(a-r)*e.r+(3*a-4*r+1)*t.r+6*(-a+r)*s.r+(3*a-2*r)*i.r,n.g=6*(a-r)*e.g+(3*a-4*r+1)*t.g+6*(-a+r)*s.g+(3*a-2*r)*i.g,n.b=6*(a-r)*e.b+(3*a-4*r+1)*t.b+6*(-a+r)*s.b+(3*a-2*r)*i.b,n.a=6*(a-r)*e.a+(3*a-4*r+1)*t.a+6*(-a+r)*s.a+(3*a-2*r)*i.a}static FromColor3(e,t=1){return new d(e.r,e.g,e.b,t)}static FromArray(e,t=0){return new d(e[t],e[t+1],e[t+2],e[t+3])}static FromArrayToRef(e,t=0,s){s.r=e[t],s.g=e[t+1],s.b=e[t+2],s.a=e[t+3]}static FromInts(e,t,s,i){return new d(e/255,t/255,s/255,i/255)}static CheckColors4(e,t){if(e.length===3*t){const t=[];for(let s=0;snew d(0,0,0,0))),(0,r.Y5)("BABYLON.Color3",u),(0,r.Y5)("BABYLON.Color4",d)},5559:(e,t,s)=>{s.d(t,{bH:()=>n,rv:()=>i,tk:()=>r});const i=1/2.2,r=2.2,n=(Math.sqrt(5),.001)},2572:(e,t,s)=>{s.d(t,{P:()=>r});var i=s(4100);class r{static GetPlanes(e){const t=[];for(let e=0;e<6;e++)t.push(new i.Z(0,0,0,0));return r.GetPlanesToRef(e,t),t}static GetNearPlaneToRef(e,t){const s=e.m;t.normal.x=s[3]+s[2],t.normal.y=s[7]+s[6],t.normal.z=s[11]+s[10],t.d=s[15]+s[14],t.normalize()}static GetFarPlaneToRef(e,t){const s=e.m;t.normal.x=s[3]-s[2],t.normal.y=s[7]-s[6],t.normal.z=s[11]-s[10],t.d=s[15]-s[14],t.normalize()}static GetLeftPlaneToRef(e,t){const s=e.m;t.normal.x=s[3]+s[0],t.normal.y=s[7]+s[4],t.normal.z=s[11]+s[8],t.d=s[15]+s[12],t.normalize()}static GetRightPlaneToRef(e,t){const s=e.m;t.normal.x=s[3]-s[0],t.normal.y=s[7]-s[4],t.normal.z=s[11]-s[8],t.d=s[15]-s[12],t.normalize()}static GetTopPlaneToRef(e,t){const s=e.m;t.normal.x=s[3]-s[1],t.normal.y=s[7]-s[5],t.normal.z=s[11]-s[9],t.d=s[15]-s[13],t.normalize()}static GetBottomPlaneToRef(e,t){const s=e.m;t.normal.x=s[3]+s[1],t.normal.y=s[7]+s[5],t.normal.z=s[11]+s[9],t.d=s[15]+s[13],t.normalize()}static GetPlanesToRef(e,t){r.GetNearPlaneToRef(e,t[0]),r.GetFarPlaneToRef(e,t[1]),r.GetLeftPlaneToRef(e,t[2]),r.GetRightPlaneToRef(e,t[3]),r.GetTopPlaneToRef(e,t[4]),r.GetBottomPlaneToRef(e,t[5])}static IsPointInFrustum(e,t){for(let s=0;s<6;s++)if(t[s].dotCoordinate(e)<0)return!1;return!0}}},1139:(e,t,s)=>{s.d(t,{b8:()=>h,cD:()=>o});var i=s(5524),r=s(9923),n=s(9259);class a{static extractMinAndMaxIndexed(e,t,s,i,r,n){for(let a=s;a!Array.isArray(e)&&!Array.isArray(t)))],a,"extractMinAndMaxIndexed",null),(0,i.Cg)([n.Cx.filter(((...[e])=>!Array.isArray(e)))],a,"extractMinAndMax",null)},1903:(e,t,s)=>{var i;s.d(t,{vr:()=>r}),s(4867),s(9923),s(5559),function(e){e[e.CW=0]="CW",e[e.CCW=1]="CCW"}(i||(i={}));class r{static Interpolate(e,t,s,i,r){const n=1-3*i+3*t,a=3*i-6*t,o=3*t;let h=e;for(let t=0;t<5;t++){const t=h*h;h-=1/(3*n*t+2*a*h+o)*(n*(t*h)+a*t+o*h-e),h=Math.min(1,Math.max(0,h))}return 3*Math.pow(1-h,2)*h*s+3*(1-h)*Math.pow(h,2)*r+Math.pow(h,3)}}},4100:(e,t,s)=>{s.d(t,{Z:()=>r});var i=s(9923);class r{constructor(e,t,s,r){this.normal=new i.Pq(e,t,s),this.d=r}asArray(){return[this.normal.x,this.normal.y,this.normal.z,this.d]}clone(){return new r(this.normal.x,this.normal.y,this.normal.z,this.d)}getClassName(){return"Plane"}getHashCode(){let e=this.normal.getHashCode();return e=397*e^(0|this.d),e}normalize(){const e=Math.sqrt(this.normal.x*this.normal.x+this.normal.y*this.normal.y+this.normal.z*this.normal.z);let t=0;return 0!==e&&(t=1/e),this.normal.x*=t,this.normal.y*=t,this.normal.z*=t,this.d*=t,this}transform(e){const t=r._TmpMatrix;e.invertToRef(t);const s=t.m,i=this.normal.x,n=this.normal.y,a=this.normal.z,o=this.d,h=i*s[0]+n*s[1]+a*s[2]+o*s[3],l=i*s[4]+n*s[5]+a*s[6]+o*s[7],c=i*s[8]+n*s[9]+a*s[10]+o*s[11],u=i*s[12]+n*s[13]+a*s[14]+o*s[15];return new r(h,l,c,u)}dotCoordinate(e){return this.normal.x*e.x+this.normal.y*e.y+this.normal.z*e.z+this.d}copyFromPoints(e,t,s){const i=t.x-e.x,r=t.y-e.y,n=t.z-e.z,a=s.x-e.x,o=s.y-e.y,h=s.z-e.z,l=r*h-n*o,c=n*a-i*h,u=i*o-r*a,d=Math.sqrt(l*l+c*c+u*u);let _;return _=0!==d?1/d:0,this.normal.x=l*_,this.normal.y=c*_,this.normal.z=u*_,this.d=-(this.normal.x*e.x+this.normal.y*e.y+this.normal.z*e.z),this}isFrontFacingTo(e,t){return i.Pq.Dot(this.normal,e)<=t}signedDistanceTo(e){return i.Pq.Dot(e,this.normal)+this.d}static FromArray(e){return new r(e[0],e[1],e[2],e[3])}static FromPoints(e,t,s){const i=new r(0,0,0,0);return i.copyFromPoints(e,t,s),i}static FromPositionAndNormal(e,t){const s=new r(0,0,0,0);return this.FromPositionAndNormalToRef(e,t,s)}static FromPositionAndNormalToRef(e,t,s){return s.normal.copyFrom(t),s.normal.normalize(),s.d=-e.dot(s.normal),s}static SignedDistanceToPlaneFromPositionAndNormal(e,t,s){const r=-(t.x*e.x+t.y*e.y+t.z*e.z);return i.Pq.Dot(s,t)+r}}r._TmpMatrix=i.uq.Identity()},4867:(e,t,s)=>{function i(e,t,s=1401298e-51){return Math.abs(e-t)<=s}function r(e,t){return e===t?e:Math.random()*(t-e)+e}function n(e,t,s){return e+(t-e)*s}function a(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 o(e,t=0,s=1){return Math.min(s,Math.max(t,e))}function h(e){return e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI))}function l(e){const t=e.toString(16);return e<=15?("0"+t).toUpperCase():t.toUpperCase()}function c(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}s.d(t,{C0:()=>c,Db:()=>l,Mj:()=>i,OQ:()=>o,VD:()=>r,cP:()=>n,ed:()=>h,t:()=>a})},521:(e,t,s)=>{s.d(t,{o:()=>i});class i{constructor(e,t){this.width=e,this.height=t}toString(){return`{W: ${this.width}, H: ${this.height}}`}getClassName(){return"Size"}getHashCode(){let e=0|this.width;return e=397*e^(0|this.height),e}copyFrom(e){this.width=e.width,this.height=e.height}copyFromFloats(e,t){return this.width=e,this.height=t,this}set(e,t){return this.copyFromFloats(e,t)}multiplyByFloats(e,t){return new i(this.width*e,this.height*t)}clone(){return new i(this.width,this.height)}equals(e){return!!e&&this.width===e.width&&this.height===e.height}get surface(){return this.width*this.height}static Zero(){return new i(0,0)}add(e){return new i(this.width+e.width,this.height+e.height)}subtract(e){return new i(this.width-e.width,this.height-e.height)}scale(e){return new i(this.width*e,this.height*e)}static Lerp(e,t,s){const r=e.width+(t.width-e.width)*s,n=e.height+(t.height-e.height)*s;return new i(r,n)}}},9923:(e,t,s)=>{s.d(t,{AA:()=>g,I9:()=>c,IU:()=>d,PT:()=>_,Pq:()=>u,uq:()=>f});var i=s(5559),r=s(7309),n=s(6552),a=s(215),o=s(6315),h=s(4867);const l=e=>parseInt(e.toString().replace(/\W/g,""));class c{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=l(this.x);return e=397*e^l(this.y),e}toArray(e,t=0){return e[t]=this.x,e[t+1]=this.y,this}fromArray(e,t=0){return c.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 c(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 c(this.x+e.x,this.y+e.y)}subtract(e){return new c(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 c(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 c(this.x*e,this.y*t)}divide(e){return new c(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 c(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 c(-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 c(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=i.bH){return e&&(0,h.Mj)(this.x,e.x,t)&&(0,h.Mj)(this.y,e.y,t)}equalsToFloats(e,t){return this.x===e&&this.y===t}floor(){return new c(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 c(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}rotateToRef(e,t){const s=Math.cos(e),i=Math.sin(e),r=s*this.x-i*this.y,n=i*this.x+s*this.y;return t.x=r,t.y=n,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 c;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 c(this.x,this.y)}dot(e){return this.x*e.x+this.y*e.y}static Zero(){return new c(0,0)}static One(){return new c(1,1)}static Random(e=0,t=1){return new c((0,h.VD)(e,t),(0,h.VD)(e,t))}static RandomToRef(e=0,t=1,s){return s.copyFromFloats((0,h.VD)(e,t),(0,h.VD)(e,t))}static get ZeroReadOnly(){return c._ZeroReadOnly}static FromArray(e,t=0){return new c(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 c(o,h)}static ClampToRef(e,t,s,i){return i.x=(0,h.OQ)(e.x,t.x,s.x),i.y=(0,h.OQ)(e.y,t.y,s.y),i}static Clamp(e,t,s){const i=(0,h.OQ)(e.x,t.x,s.x),r=(0,h.OQ)(e.y,t.y,s.y);return new c(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,u=a-n,d=e.x*o+s.x*h+t.x*l+i.x*u,_=e.y*o+s.y*h+t.y*l+i.y*u;return new c(d,_)}static Hermite1stDerivative(e,t,s,i,r){return this.Hermite1stDerivativeToRef(e,t,s,i,r,new c)}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 c.LerpToRef(e,t,s,new c)}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 c.NormalizeToRef(e,new c)}static NormalizeToRef(e,t){return e.normalizeToRef(t),t}static Minimize(e,t){const s=e.xt.x?e.x:t.x,i=e.y>t.y?e.y:t.y;return new c(s,i)}static Transform(e,t){return c.TransformToRef(e,t,new c)}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(c.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 c.CenterToRef(e,t,new c)}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=c.DistanceSquared(t,s);if(0===i)return c.Distance(e,t);const r=s.subtract(t),n=Math.max(0,Math.min(1,c.Dot(e.subtract(t),r)/i)),a=t.add(r.multiplyByFloats(n,n));return c.Distance(e,a)}}c._ZeroReadOnly=c.Zero(),Object.defineProperties(c.prototype,{dimension:{value:[2]},rank:{value:1}});class u{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=l(this._x);return e=397*e^l(this._y),e=397*e^l(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 u.FromArrayToRef(e,t,this),this}toQuaternion(){return _.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 u(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 u(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 u(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 u(-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 u(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 u)}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 u)}projectOnPlaneToRef(e,t,s){const i=e.normal,r=e.d,n=p.Vector3[0];this.subtractToRef(t,n),n.normalize();const a=u.Dot(n,i);if(Math.abs(a)<1e-10)s.setAll(1/0);else{const e=-(u.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=i.bH){return e&&(0,h.Mj)(this._x,e._x,t)&&(0,h.Mj)(this._y,e._y,t)&&(0,h.Mj)(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 u(this._x*e,this._y*t,this._z*s)}divide(e){return new u(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 ethis._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(!(0,h.Mj)(t,s,e))return!0;const i=Math.abs(this._z);return!(0,h.Mj)(t,i,e)||!(0,h.Mj)(s,i,e)}get isNonUniform(){const e=Math.abs(this._x);return e!==Math.abs(this._y)||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 u(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 u(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=p.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(p.Matrix[0]),u.TransformCoordinatesToRef(this,p.Matrix[0],t),t}rotateByQuaternionAroundPointToRef(e,t,s){return this.subtractToRef(t,p.Vector3[0]),p.Vector3[0].rotateByQuaternionToRef(e,p.Vector3[0]),t.addToRef(p.Vector3[0],s),s}cross(e){return u.CrossToRef(this,e,new u)}normalizeFromLength(e){return 0===e||1===e?this:this.scaleInPlace(1/e)}normalizeToNew(){return this.normalizeToRef(new u)}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 u(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=u.Dot(e,s);return(r-i)/(r-u.Dot(t,s))}static GetAngleBetweenVectors(e,t,s){const i=e.normalizeToRef(p.Vector3[1]),r=t.normalizeToRef(p.Vector3[2]);let n=u.Dot(i,r);n=(0,h.OQ)(n,-1,1);const a=Math.acos(n),o=p.Vector3[3];return u.CrossToRef(i,r,o),u.Dot(o,s)>0?isNaN(a)?0:a:isNaN(a)?-Math.PI:-Math.acos(n)}static GetAngleBetweenVectorsOnPlane(e,t,s){p.Vector3[0].copyFrom(e);const i=p.Vector3[0];p.Vector3[1].copyFrom(t);const r=p.Vector3[1];p.Vector3[2].copyFrom(s);const n=p.Vector3[2],a=p.Vector3[3],o=p.Vector3[4];i.normalize(),r.normalize(),n.normalize(),u.CrossToRef(n,i,a),u.CrossToRef(a,n,o);const l=Math.atan2(u.Dot(r,a),u.Dot(r,o));return(0,h.ed)(l)}static PitchYawRollToMoveBetweenPointsToRef(e,t,s){const i=g.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=u.Zero();return u.PitchYawRollToMoveBetweenPointsToRef(e,t,s)}static SlerpToRef(e,t,s,r){s=(0,h.OQ)(s,0,1);const n=p.Vector3[0],a=p.Vector3[1];n.copyFrom(e);const o=n.length();n.normalizeFromLength(o),a.copyFrom(t);const l=a.length();a.normalizeFromLength(l);const c=u.Dot(n,a);let d,_;if(c<1-i.bH){const e=Math.acos(c),t=1/Math.sin(e);d=Math.sin((1-s)*e)*t,_=Math.sin(s*e)*t}else d=1-s,_=s;return n.scaleInPlace(d),a.scaleInPlace(_),r.copyFrom(n).addInPlace(a),r.scaleInPlace((0,h.cP)(o,l,s)),r}static SmoothToRef(e,t,s,i,r){return u.SlerpToRef(e,t,0===i?1:s/i,r),r}static FromArray(e,t=0){return new u(e[t],e[t+1],e[t+2])}static FromFloatArray(e,t){return u.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 u.FromArrayToRef(e,t,s)}static FromFloatsToRef(e,t,s,i){return i.copyFromFloats(e,t,s),i}static Zero(){return new u(0,0,0)}static One(){return new u(1,1,1)}static Up(){return new u(0,1,0)}static get UpReadOnly(){return u._UpReadOnly}static get DownReadOnly(){return u._DownReadOnly}static get RightReadOnly(){return u._RightReadOnly}static get LeftReadOnly(){return u._LeftReadOnly}static get LeftHandedForwardReadOnly(){return u._LeftHandedForwardReadOnly}static get RightHandedForwardReadOnly(){return u._RightHandedForwardReadOnly}static get LeftHandedBackwardReadOnly(){return u._LeftHandedBackwardReadOnly}static get RightHandedBackwardReadOnly(){return u._RightHandedBackwardReadOnly}static get ZeroReadOnly(){return u._ZeroReadOnly}static get OneReadOnly(){return u._OneReadOnly}static Down(){return new u(0,-1,0)}static Forward(e=!1){return new u(0,0,e?-1:1)}static Backward(e=!1){return new u(0,0,e?1:-1)}static Right(){return new u(1,0,0)}static Left(){return new u(-1,0,0)}static Random(e=0,t=1){return new u((0,h.VD)(e,t),(0,h.VD)(e,t),(0,h.VD)(e,t))}static RandomToRef(e=0,t=1,s){return s.copyFromFloats((0,h.VD)(e,t),(0,h.VD)(e,t),(0,h.VD)(e,t))}static TransformCoordinates(e,t){const s=u.Zero();return u.TransformCoordinatesToRef(e,t,s),s}static TransformCoordinatesToRef(e,t,s){return u.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=u.Zero();return u.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 u(o,h,l)}static Clamp(e,t,s){const i=new u;return u.ClampToRef(e,t,s,i),i}static ClampToRef(e,t,s,i){let r=e._x;r=r>s._x?s._x:r,r=rs._y?s._y:n,n=ns._z?s._z:a,a=a0&&S<0?(D.copyFrom(a),O=t,F=s):S>0&&I<0?(D.copyFrom(l),O=s,F=r):(D.copyFrom(o).scaleInPlace(-1),O=r,F=t);const w=p.Vector3[9],L=p.Vector3[4];if(O.subtractToRef(x,y),F.subtractToRef(x,w),u.CrossToRef(y,w,L),!(u.Dot(L,c)<0))return n.copyFrom(x),Math.abs(T*b);const B=p.Vector3[5];u.CrossToRef(D,L,B),B.normalize();const N=p.Vector3[9];N.copyFrom(O).subtractInPlace(x);const U=N.length();if(Uthis.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 d(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 d(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 d)}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 u(this.x,this.y,this.z)}clone(){return new d(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,s,i){return this.x=e,this.y=t,this.z=s,this.w=i,this}set(e,t,s,i){return this.copyFromFloats(e,t,s,i)}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 d(e[t],e[t+1],e[t+2],e[t+3])}static FromArrayToRef(e,t,s){return s.x=e[t],s.y=e[t+1],s.z=e[t+2],s.w=e[t+3],s}static FromFloatArrayToRef(e,t,s){return d.FromArrayToRef(e,t,s),s}static FromFloatsToRef(e,t,s,i,r){return r.x=e,r.y=t,r.z=s,r.w=i,r}static Zero(){return new d(0,0,0,0)}static One(){return new d(1,1,1,1)}static Random(e=0,t=1){return new d((0,h.VD)(e,t),(0,h.VD)(e,t),(0,h.VD)(e,t),(0,h.VD)(e,t))}static RandomToRef(e=0,t=1,s){return s.x=(0,h.VD)(e,t),s.y=(0,h.VD)(e,t),s.z=(0,h.VD)(e,t),s.w=(0,h.VD)(e,t),s}static Clamp(e,t,s){return d.ClampToRef(e,t,s,new d)}static ClampToRef(e,t,s,i){return i.x=(0,h.OQ)(e.x,t.x,s.x),i.y=(0,h.OQ)(e.y,t.y,s.y),i.z=(0,h.OQ)(e.z,t.z,s.z),i.w=(0,h.OQ)(e.w,t.w,s.w),i}static CheckExtends(e,t,s){t.minimizeInPlace(e),s.maximizeInPlace(e)}static get ZeroReadOnly(){return d._ZeroReadOnly}static Normalize(e){return d.NormalizeToRef(e,new d)}static NormalizeToRef(e,t){return e.normalizeToRef(t),t}static Minimize(e,t){const s=new d;return s.copyFrom(e),s.minimizeInPlace(t),s}static Maximize(e,t){const s=new d;return s.copyFrom(e),s.maximizeInPlace(t),s}static Distance(e,t){return Math.sqrt(d.DistanceSquared(e,t))}static DistanceSquared(e,t){const s=e.x-t.x,i=e.y-t.y,r=e.z-t.z,n=e.w-t.w;return s*s+i*i+r*r+n*n}static Center(e,t){return d.CenterToRef(e,t,new d)}static CenterToRef(e,t,s){return s.x=(e.x+t.x)/2,s.y=(e.y+t.y)/2,s.z=(e.z+t.z)/2,s.w=(e.w+t.w)/2,s}static TransformCoordinates(e,t){return d.TransformCoordinatesToRef(e,t,new d)}static TransformCoordinatesToRef(e,t,s){return d.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=e*n[3]+t*n[7]+s*n[11]+n[15];return r.x=a,r.y=o,r.z=h,r.w=l,r}static TransformNormal(e,t){return d.TransformNormalToRef(e,t,new d)}static TransformNormalToRef(e,t,s){const i=t.m,r=e.x*i[0]+e.y*i[4]+e.z*i[8],n=e.x*i[1]+e.y*i[5]+e.z*i[9],a=e.x*i[2]+e.y*i[6]+e.z*i[10];return s.x=r,s.y=n,s.z=a,s.w=e.w,s}static TransformNormalFromFloatsToRef(e,t,s,i,r,n){const a=r.m;return n.x=e*a[0]+t*a[4]+s*a[8],n.y=e*a[1]+t*a[5]+s*a[9],n.z=e*a[2]+t*a[6]+s*a[10],n.w=i,n}static FromVector3(e,t=0){return new d(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}}d._ZeroReadOnly=d.Zero(),Object.defineProperties(d.prototype,{dimension:{value:[4]},rank:{value:1}});class _{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=1){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"Quaternion"}getHashCode(){let e=l(this._x);return e=397*e^l(this._y),e=397*e^l(this._z),e=397*e^l(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 _.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=i.bH){return e&&(0,h.Mj)(this._x,e._x,t)&&(0,h.Mj)(this._y,e._y,t)&&(0,h.Mj)(this._z,e._z,t)&&(0,h.Mj)(this._w,e._w,t)}clone(){return new _(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,s,i){return this._x=e,this._y=t,this._z=s,this._w=i,this._isDirty=!0,this}set(e,t,s,i){return this.copyFromFloats(e,t,s,i)}setAll(e){return this.copyFromFloats(e,e,e,e)}add(e){return new _(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,s,i){return this._x+=e,this._y+=t,this._z+=s,this._w+=i,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,s,i){return this.subtractFromFloatsToRef(e,t,s,i,new _)}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._isDirty=!0,r}subtract(e){return new _(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 _(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 _(0,0,0,1);return this.multiplyToRef(e,t),t}multiplyToRef(e,t){const s=this._x*e._w+this._y*e._z-this._z*e._y+this._w*e._x,i=-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(s,i,r,n),t}multiplyInPlace(e){return this.multiplyToRef(e,this)}multiplyByFloats(e,t,s,i){return this._x*=e,this._y*=t,this._z*=s,this._w*=i,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 _)}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,s,i){return this._x===e&&this._y===t&&this._z===s&&this._w===i}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 _(-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 _(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=u.Zero();return this.toEulerAnglesToRef(e),e}toEulerAnglesToRef(e){const t=this._z,s=this._x,i=this._y,r=this._w,n=i*t-s*r,a=.4999999;if(n<-a)e._y=2*Math.atan2(i,r),e._x=Math.PI/2,e._z=0,e._isDirty=!0;else if(n>a)e._y=2*Math.atan2(i,r),e._x=-Math.PI/2,e._z=0,e._isDirty=!0;else{const a=r*r,o=t*t,h=s*s,l=i*i;e._z=Math.atan2(2*(s*i+t*r),-o-h+l+a),e._x=Math.asin(-2*n),e._y=Math.atan2(2*(t*s+i*r),o-h-l+a),e._isDirty=!0}return e}toAlphaBetaGammaToRef(e){const t=this._z,s=this._x,i=this._y,r=this._w,n=Math.sqrt(s*s+i*i),a=Math.sqrt(t*t+r*r),o=2*Math.atan2(n,a),h=2*Math.atan2(t,r),l=2*Math.atan2(i,s),c=(h+l)/2,u=(h-l)/2;return e.set(u,o,c),e}toRotationMatrix(e){return f.FromQuaternionToRef(this,e),e}fromRotationMatrix(e){return _.FromRotationMatrixToRef(e,this),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}static FromRotationMatrix(e){const t=new _;return _.FromRotationMatrixToRef(e,t),t}static FromRotationMatrixToRef(e,t){const s=e.m,i=s[0],r=s[4],n=s[8],a=s[1],o=s[5],h=s[9],l=s[2],c=s[6],u=s[10],d=i+o+u;let _;return d>0?(_=.5/Math.sqrt(d+1),t._w=.25/_,t._x=(c-h)*_,t._y=(n-l)*_,t._z=(a-r)*_,t._isDirty=!0):i>o&&i>u?(_=2*Math.sqrt(1+i-o-u),t._w=(c-h)/_,t._x=.25*_,t._y=(r+a)/_,t._z=(n+l)/_,t._isDirty=!0):o>u?(_=2*Math.sqrt(1+o-i-u),t._w=(n-l)/_,t._x=(r+a)/_,t._y=.25*_,t._z=(h+c)/_,t._isDirty=!0):(_=2*Math.sqrt(1+u-i-o),t._w=(a-r)/_,t._x=(n+l)/_,t._y=(h+c)/_,t._z=.25*_,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,s=.1){const i=_.Dot(e,t);return 1-i*i<=s}static SmoothToRef(e,t,s,i,r){let n=0===i?1:s/i;return n=(0,h.OQ)(n,0,1),_.SlerpToRef(e,t,n,r),r}static Zero(){return new _(0,0,0,0)}static Inverse(e){return new _(-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 _(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 _.RotationAxisToRef(e,t,new _)}static RotationAxisToRef(e,t,s){s._w=Math.cos(t/2);const i=Math.sin(t/2)/e.length();return s._x=e._x*i,s._y=e._y*i,s._z=e._z*i,s._isDirty=!0,s}static FromArray(e,t){return t||(t=0),new _(e[t],e[t+1],e[t+2],e[t+3])}static FromArrayToRef(e,t,s){return s._x=e[t],s._y=e[t+1],s._z=e[t+2],s._w=e[t+3],s._isDirty=!0,s}static FromFloatsToRef(e,t,s,i,r){return r.copyFromFloats(e,t,s,i),r}static FromEulerAngles(e,t,s){const i=new _;return _.RotationYawPitchRollToRef(t,e,s,i),i}static FromEulerAnglesToRef(e,t,s,i){return _.RotationYawPitchRollToRef(t,e,s,i),i}static FromEulerVector(e){const t=new _;return _.RotationYawPitchRollToRef(e._y,e._x,e._z,t),t}static FromEulerVectorToRef(e,t){return _.RotationYawPitchRollToRef(e._y,e._x,e._z,t),t}static FromUnitVectorsToRef(e,t,s,r=i.bH){const n=u.Dot(e,t)+1;return nMath.abs(e.z)?s.set(-e.y,e.x,0,0):s.set(0,-e.z,e.y,0):(u.CrossToRef(e,t,g.Vector3[0]),s.set(g.Vector3[0].x,g.Vector3[0].y,g.Vector3[0].z,n)),s.normalize()}static RotationYawPitchRoll(e,t,s){const i=new _;return _.RotationYawPitchRollToRef(e,t,s,i),i}static RotationYawPitchRollToRef(e,t,s,i){const r=.5*s,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),d=Math.cos(a);return i._x=d*l*h+u*c*o,i._y=u*c*h-d*l*o,i._z=d*c*o-u*l*h,i._w=d*c*h+u*l*o,i._isDirty=!0,i}static RotationAlphaBetaGamma(e,t,s){const i=new _;return _.RotationAlphaBetaGammaToRef(e,t,s,i),i}static RotationAlphaBetaGammaToRef(e,t,s,i){const r=.5*(s+e),n=.5*(s-e),a=.5*t;return i._x=Math.cos(n)*Math.sin(a),i._y=Math.sin(n)*Math.sin(a),i._z=Math.sin(r)*Math.cos(a),i._w=Math.cos(r)*Math.cos(a),i._isDirty=!0,i}static RotationQuaternionFromAxis(e,t,s){const i=new _(0,0,0,0);return _.RotationQuaternionFromAxisToRef(e,t,s,i),i}static RotationQuaternionFromAxisToRef(e,t,s,i){const r=p.Matrix[0];return e=e.normalizeToRef(p.Vector3[0]),t=t.normalizeToRef(p.Vector3[1]),s=s.normalizeToRef(p.Vector3[2]),f.FromXYZAxesToRef(e,t,s,r),_.FromRotationMatrixToRef(r,i),i}static FromLookDirectionLH(e,t){const s=new _;return _.FromLookDirectionLHToRef(e,t,s),s}static FromLookDirectionLHToRef(e,t,s){const i=p.Matrix[0];return f.LookDirectionLHToRef(e,t,i),_.FromRotationMatrixToRef(i,s),s}static FromLookDirectionRH(e,t){const s=new _;return _.FromLookDirectionRHToRef(e,t,s),s}static FromLookDirectionRHToRef(e,t,s){const i=p.Matrix[0];return f.LookDirectionRHToRef(e,t,i),_.FromRotationMatrixToRef(i,s)}static Slerp(e,t,s){const i=_.Identity();return _.SlerpToRef(e,t,s,i),i}static SlerpToRef(e,t,s,i){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-s,r=o?-s:s;else{const e=Math.acos(a),t=1/Math.sin(e);n=Math.sin((1-s)*e)*t,r=o?-Math.sin(s*e)*t:Math.sin(s*e)*t}return i._x=n*e._x+r*t._x,i._y=n*e._y+r*t._y,i._z=n*e._z+r*t._z,i._w=n*e._w+r*t._w,i._isDirty=!0,i}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,f=e._z*o+s._z*h+t._z*l+i._z*c,p=e._w*o+s._w*h+t._w*l+i._w*c;return new _(u,d,f,p)}static Hermite1stDerivative(e,t,s,i,r){const n=new _;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._w=6*(a-r)*e._w+(3*a-4*r+1)*t._w+6*(-a+r)*s._w+(3*a-2*r)*i._w,n._isDirty=!0,n}static Normalize(e){const t=_.Zero();return _.NormalizeToRef(e,t),t}static NormalizeToRef(e,t){return e.normalizeToRef(t),t}static Clamp(e,t,s){const i=new _;return _.ClampToRef(e,t,s,i),i}static ClampToRef(e,t,s,i){return i.copyFromFloats((0,h.OQ)(e.x,t.x,s.x),(0,h.OQ)(e.y,t.y,s.y),(0,h.OQ)(e.z,t.z,s.z),(0,h.OQ)(e.w,t.w,s.w))}static Random(e=0,t=1){return new _((0,h.VD)(e,t),(0,h.VD)(e,t),(0,h.VD)(e,t),(0,h.VD)(e,t))}static RandomToRef(e=0,t=1,s){return s.copyFromFloats((0,h.VD)(e,t),(0,h.VD)(e,t),(0,h.VD)(e,t),(0,h.VD)(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(_.DistanceSquared(e,t))}static DistanceSquared(e,t){const s=e.x-t.x,i=e.y-t.y,r=e.z-t.z,n=e.w-t.w;return s*s+i*i+r*r+n*n}static Center(e,t){return _.CenterToRef(e,t,_.Zero())}static CenterToRef(e,t,s){return s.copyFromFloats((e.x+t.x)/2,(e.y+t.y)/2,(e.z+t.z)/2,(e.w+t.w)/2)}}Object.defineProperties(_.prototype,{dimension:{value:[4]},rank:{value:1}});class f{static get Use64Bits(){return a.I.MatrixUse64Bits}get m(){return this._m}markAsUpdated(){this.updateFlag=f._UpdateFlagSeed++,this._isIdentity=!1,this._isIdentity3x2=!1,this._isIdentityDirty=!0,this._isIdentity3x2Dirty=!0}_updateIdentityStatus(e,t=!1,s=!1,i=!0){this._isIdentity=e,this._isIdentity3x2=e||s,this._isIdentityDirty=!this._isIdentity&&t,this._isIdentity3x2Dirty=!this._isIdentity3x2&&i}constructor(){this._isIdentity=!1,this._isIdentityDirty=!0,this._isIdentity3x2=!0,this._isIdentity3x2Dirty=!0,this.updateFlag=-1,a.I.MatrixTrackPrecisionChange&&a.I.MatrixTrackedMatrices.push(this),this._m=new a.I.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[11]&&0===e[12]&&0===e[13]&&0===e[14]&&1===e[15]}return this._isIdentity}isIdentityAs3x2(){return this._isIdentity3x2Dirty&&(this._isIdentity3x2Dirty=!1,1!==this._m[0]||1!==this._m[5]||1!==this._m[15]||0!==this._m[1]||0!==this._m[2]||0!==this._m[3]||0!==this._m[4]||0!==this._m[6]||0!==this._m[7]||0!==this._m[8]||0!==this._m[9]||0!==this._m[10]||0!==this._m[11]||0!==this._m[12]||0!==this._m[13]||0!==this._m[14]?this._isIdentity3x2=!1:this._isIdentity3x2=!0),this._isIdentity3x2}determinant(){if(!0===this._isIdentity)return 1;const e=this._m,t=e[0],s=e[1],i=e[2],r=e[3],n=e[4],a=e[5],o=e[6],h=e[7],l=e[8],c=e[9],u=e[10],d=e[11],_=e[12],f=e[13],p=e[14],g=e[15],m=u*g-p*d,T=c*g-f*d,b=c*p-f*u,E=l*g-_*d,x=l*p-u*_,A=l*f-_*c;return t*+(a*m-o*T+h*b)+s*-(n*m-o*E+h*x)+i*+(n*T-a*E+h*A)+r*-(n*b-a*x+o*A)}toString(){return`{${this.m[0]}, ${this.m[1]}, ${this.m[2]}, ${this.m[3]}\n${this.m[4]}, ${this.m[5]}, ${this.m[6]}, ${this.m[7]}\n${this.m[8]}, ${this.m[9]}, ${this.m[10]}, ${this.m[11]}\n${this.m[12]}, ${this.m[13]}, ${this.m[14]}, ${this.m[15]}}`}toArray(e=null,t=0){if(!e)return this._m;const s=this._m;for(let i=0;i<16;i++)e[t+i]=s[i];return this}asArray(){return this._m}fromArray(e,t=0){return f.FromArrayToRef(e,t,this)}copyFromFloats(...e){return f.FromArrayToRef(e,0,this)}set(...e){const t=this._m;for(let s=0;s<16;s++)t[s]=e[s];return this.markAsUpdated(),this}setAll(e){const t=this._m;for(let s=0;s<16;s++)t[s]=e;return this.markAsUpdated(),this}invert(){return this.invertToRef(this),this}reset(){return f.FromValuesToRef(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,this),this._updateIdentityStatus(!1),this}add(e){const t=new f;return this.addToRef(e,t),t}addToRef(e,t){const s=this._m,i=t._m,r=e.m;for(let e=0;e<16;e++)i[e]=s[e]+r[e];return t.markAsUpdated(),t}addToSelf(e){const t=this._m,s=e.m;return t[0]+=s[0],t[1]+=s[1],t[2]+=s[2],t[3]+=s[3],t[4]+=s[4],t[5]+=s[5],t[6]+=s[6],t[7]+=s[7],t[8]+=s[8],t[9]+=s[9],t[10]+=s[10],t[11]+=s[11],t[12]+=s[12],t[13]+=s[13],t[14]+=s[14],t[15]+=s[15],this.markAsUpdated(),this}addInPlace(e){const t=this._m,s=e.m;for(let e=0;e<16;e++)t[e]+=s[e];return this.markAsUpdated(),this}addInPlaceFromFloats(...e){const t=this._m;for(let s=0;s<16;s++)t[s]+=e[s];return this.markAsUpdated(),this}subtract(e){const t=this._m,s=e.m;for(let e=0;e<16;e++)t[e]-=s[e];return this.markAsUpdated(),this}subtractToRef(e,t){const s=this._m,i=e.m,r=t._m;for(let e=0;e<16;e++)r[e]=s[e]-i[e];return t.markAsUpdated(),t}subtractInPlace(e){const t=this._m,s=e.m;for(let e=0;e<16;e++)t[e]-=s[e];return this.markAsUpdated(),this}subtractFromFloats(...e){return this.subtractFromFloatsToRef(...e,new f)}subtractFromFloatsToRef(...e){const t=e.pop(),s=this._m,i=t._m,r=e;for(let e=0;e<16;e++)i[e]=s[e]-r[e];return t.markAsUpdated(),t}invertToRef(e){if(!0===this._isIdentity)return f.IdentityToRef(e),e;const t=this._m,s=t[0],i=t[1],r=t[2],n=t[3],a=t[4],o=t[5],h=t[6],l=t[7],c=t[8],u=t[9],d=t[10],_=t[11],p=t[12],g=t[13],m=t[14],T=t[15],b=d*T-m*_,E=u*T-g*_,x=u*m-g*d,A=c*T-p*_,R=c*m-d*p,M=c*g-p*u,y=+(o*b-h*E+l*x),P=-(a*b-h*A+l*R),v=+(a*E-o*A+l*M),C=-(a*x-o*R+h*M),S=s*y+i*P+r*v+n*C;if(0===S)return e.copyFrom(this),e;const I=1/S,D=h*T-m*l,O=o*T-g*l,F=o*m-g*h,w=a*T-p*l,L=a*m-p*h,B=a*g-p*o,N=h*_-d*l,U=o*_-u*l,k=o*d-u*h,V=a*_-c*l,G=a*d-c*h,z=a*u-c*o,W=-(i*b-r*E+n*x),H=+(s*b-r*A+n*R),K=-(s*E-i*A+n*M),q=+(s*x-i*R+r*M),X=+(i*D-r*O+n*F),Y=-(s*D-r*w+n*L),j=+(s*O-i*w+n*B),Z=-(s*F-i*L+r*B),Q=-(i*N-r*U+n*k),$=+(s*N-r*V+n*G),J=-(s*U-i*V+n*z),ee=+(s*k-i*G+r*z);return f.FromValuesToRef(y*I,W*I,X*I,Q*I,P*I,H*I,Y*I,$*I,v*I,K*I,j*I,J*I,C*I,q*I,Z*I,ee*I,e),e}addAtIndex(e,t){return this._m[e]+=t,this.markAsUpdated(),this}multiplyAtIndex(e,t){return this._m[e]*=t,this.markAsUpdated(),this}setTranslationFromFloats(e,t,s){return this._m[12]=e,this._m[13]=t,this._m[14]=s,this.markAsUpdated(),this}addTranslationFromFloats(e,t,s){return this._m[12]+=e,this._m[13]+=t,this._m[14]+=s,this.markAsUpdated(),this}setTranslation(e){return this.setTranslationFromFloats(e._x,e._y,e._z)}getTranslation(){return new u(this._m[12],this._m[13],this._m[14])}getTranslationToRef(e){return e.x=this._m[12],e.y=this._m[13],e.z=this._m[14],e}removeRotationAndScaling(){const e=this.m;return f.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,e[12],e[13],e[14],e[15],this),this._updateIdentityStatus(0===e[12]&&0===e[13]&&0===e[14]&&1===e[15]),this}copyFrom(e){e.copyToArray(this._m);const t=e;return this.updateFlag=t.updateFlag,this._updateIdentityStatus(t._isIdentity,t._isIdentityDirty,t._isIdentity3x2,t._isIdentity3x2Dirty),this}copyToArray(e,t=0){const s=this._m;return e[t]=s[0],e[t+1]=s[1],e[t+2]=s[2],e[t+3]=s[3],e[t+4]=s[4],e[t+5]=s[5],e[t+6]=s[6],e[t+7]=s[7],e[t+8]=s[8],e[t+9]=s[9],e[t+10]=s[10],e[t+11]=s[11],e[t+12]=s[12],e[t+13]=s[13],e[t+14]=s[14],e[t+15]=s[15],this}multiply(e){const t=new f;return this.multiplyToRef(e,t),t}multiplyInPlace(e){const t=this._m,s=e.m;for(let e=0;e<16;e++)t[e]*=s[e];return this.markAsUpdated(),this}multiplyByFloats(...e){const t=this._m;for(let s=0;s<16;s++)t[s]*=e[s];return this.markAsUpdated(),this}multiplyByFloatsToRef(...e){const t=e.pop(),s=this._m,i=t._m,r=e;for(let e=0;e<16;e++)i[e]=s[e]*r[e];return t.markAsUpdated(),t}multiplyToRef(e,t){return this._isIdentity?(t.copyFrom(e),t):e._isIdentity?(t.copyFrom(this),t):(this.multiplyToArray(e,t._m,0),t.markAsUpdated(),t)}multiplyToArray(e,t,s){const i=this._m,r=e.m,n=i[0],a=i[1],o=i[2],h=i[3],l=i[4],c=i[5],u=i[6],d=i[7],_=i[8],f=i[9],p=i[10],g=i[11],m=i[12],T=i[13],b=i[14],E=i[15],x=r[0],A=r[1],R=r[2],M=r[3],y=r[4],P=r[5],v=r[6],C=r[7],S=r[8],I=r[9],D=r[10],O=r[11],F=r[12],w=r[13],L=r[14],B=r[15];return t[s]=n*x+a*y+o*S+h*F,t[s+1]=n*A+a*P+o*I+h*w,t[s+2]=n*R+a*v+o*D+h*L,t[s+3]=n*M+a*C+o*O+h*B,t[s+4]=l*x+c*y+u*S+d*F,t[s+5]=l*A+c*P+u*I+d*w,t[s+6]=l*R+c*v+u*D+d*L,t[s+7]=l*M+c*C+u*O+d*B,t[s+8]=_*x+f*y+p*S+g*F,t[s+9]=_*A+f*P+p*I+g*w,t[s+10]=_*R+f*v+p*D+g*L,t[s+11]=_*M+f*C+p*O+g*B,t[s+12]=m*x+T*y+b*S+E*F,t[s+13]=m*A+T*P+b*I+E*w,t[s+14]=m*R+T*v+b*D+E*L,t[s+15]=m*M+T*C+b*O+E*B,this}divide(e){return this.divideToRef(e,new f)}divideToRef(e,t){const s=this._m,i=e.m,r=t._m;for(let e=0;e<16;e++)r[e]=s[e]/i[e];return t.markAsUpdated(),t}divideInPlace(e){const t=this._m,s=e.m;for(let e=0;e<16;e++)t[e]/=s[e];return this.markAsUpdated(),this}minimizeInPlace(e){const t=this._m,s=e.m;for(let e=0;e<16;e++)t[e]=Math.min(t[e],s[e]);return this.markAsUpdated(),this}minimizeInPlaceFromFloats(...e){const t=this._m;for(let s=0;s<16;s++)t[s]=Math.min(t[s],e[s]);return this.markAsUpdated(),this}maximizeInPlace(e){const t=this._m,s=e.m;for(let e=0;e<16;e++)t[e]=Math.min(t[e],s[e]);return this.markAsUpdated(),this}maximizeInPlaceFromFloats(...e){const t=this._m;for(let s=0;s<16;s++)t[s]=Math.min(t[s],e[s]);return this.markAsUpdated(),this}negate(){return this.negateToRef(new f)}negateInPlace(){const e=this._m;for(let t=0;t<16;t++)e[t]=-e[t];return this.markAsUpdated(),this}negateToRef(e){const t=this._m,s=e._m;for(let e=0;e<16;e++)s[e]=-t[e];return e.markAsUpdated(),e}equals(e){const t=e;if(!t)return!1;if((this._isIdentity||t._isIdentity)&&!this._isIdentityDirty&&!t._isIdentityDirty)return this._isIdentity&&t._isIdentity;const s=this.m,i=t.m;return s[0]===i[0]&&s[1]===i[1]&&s[2]===i[2]&&s[3]===i[3]&&s[4]===i[4]&&s[5]===i[5]&&s[6]===i[6]&&s[7]===i[7]&&s[8]===i[8]&&s[9]===i[9]&&s[10]===i[10]&&s[11]===i[11]&&s[12]===i[12]&&s[13]===i[13]&&s[14]===i[14]&&s[15]===i[15]}equalsWithEpsilon(e,t=0){const s=this._m,i=e.m;for(let e=0;e<16;e++)if(!(0,h.Mj)(s[e],i[e],t))return!1;return!0}equalsToFloats(...e){const t=this._m;for(let s=0;s<16;s++)if(t[s]!=e[s])return!1;return!0}floor(){return this.floorToRef(new f)}floorToRef(e){const t=this._m,s=e._m;for(let e=0;e<16;e++)s[e]=Math.floor(t[e]);return e.markAsUpdated(),e}fract(){return this.fractToRef(new f)}fractToRef(e){const t=this._m,s=e._m;for(let e=0;e<16;e++)s[e]=t[e]-Math.floor(t[e]);return e.markAsUpdated(),e}clone(){const e=new f;return e.copyFrom(this),e}getClassName(){return"Matrix"}getHashCode(){let e=l(this._m[0]);for(let t=1;t<16;t++)e=397*e^l(this._m[t]);return e}decomposeToTransformNode(e){return e.rotationQuaternion=e.rotationQuaternion||new _,this.decompose(e.scaling,e.rotationQuaternion,e.position)}decompose(e,t,s,i,r=!0){if(this._isIdentity)return s&&s.setAll(0),e&&e.setAll(1),t&&t.copyFromFloats(0,0,0,1),!0;const n=this._m;if(s&&s.copyFromFloats(n[12],n[13],n[14]),(e=e||p.Vector3[0]).x=Math.sqrt(n[0]*n[0]+n[1]*n[1]+n[2]*n[2]),e.y=Math.sqrt(n[4]*n[4]+n[5]*n[5]+n[6]*n[6]),e.z=Math.sqrt(n[8]*n[8]+n[9]*n[9]+n[10]*n[10]),i){const t=(r?i.absoluteScaling.x:i.scaling.x)<0?-1:1,s=(r?i.absoluteScaling.y:i.scaling.y)<0?-1:1,n=(r?i.absoluteScaling.z:i.scaling.z)<0?-1:1;e.x*=t,e.y*=s,e.z*=n}else this.determinant()<=0&&(e.y*=-1);if(0===e._x||0===e._y||0===e._z)return t&&t.copyFromFloats(0,0,0,1),!1;if(t){const s=1/e._x,i=1/e._y,r=1/e._z;f.FromValuesToRef(n[0]*s,n[1]*s,n[2]*s,0,n[4]*i,n[5]*i,n[6]*i,0,n[8]*r,n[9]*r,n[10]*r,0,0,0,0,1,p.Matrix[0]),_.FromRotationMatrixToRef(p.Matrix[0],t)}return!0}getRow(e){if(e<0||e>3)return null;const t=4*e;return new d(this._m[t+0],this._m[t+1],this._m[t+2],this._m[t+3])}getRowToRef(e,t){if(e>=0&&e<=3){const s=4*e;t.x=this._m[s+0],t.y=this._m[s+1],t.z=this._m[s+2],t.w=this._m[s+3]}return t}setRow(e,t){return this.setRowFromFloats(e,t.x,t.y,t.z,t.w)}transpose(){const e=new f;return f.TransposeToRef(this,e),e}transposeToRef(e){return f.TransposeToRef(this,e),e}setRowFromFloats(e,t,s,i,r){if(e<0||e>3)return this;const n=4*e;return this._m[n+0]=t,this._m[n+1]=s,this._m[n+2]=i,this._m[n+3]=r,this.markAsUpdated(),this}scale(e){const t=new f;return this.scaleToRef(e,t),t}scaleToRef(e,t){for(let s=0;s<16;s++)t._m[s]=this._m[s]*e;return t.markAsUpdated(),t}scaleAndAddToRef(e,t){for(let s=0;s<16;s++)t._m[s]+=this._m[s]*e;return t.markAsUpdated(),t}scaleInPlace(e){const t=this._m;for(let s=0;s<16;s++)t[s]*=e;return this.markAsUpdated(),this}toNormalMatrix(e){const t=p.Matrix[0];this.invertToRef(t),t.transposeToRef(e);const s=e._m;return f.FromValuesToRef(s[0],s[1],s[2],0,s[4],s[5],s[6],0,s[8],s[9],s[10],0,0,0,0,1,e),e}getRotationMatrix(){const e=new f;return this.getRotationMatrixToRef(e),e}getRotationMatrixToRef(e){const t=p.Vector3[0];if(!this.decompose(t))return f.IdentityToRef(e),e;const s=this._m,i=1/t._x,r=1/t._y,n=1/t._z;return f.FromValuesToRef(s[0]*i,s[1]*i,s[2]*i,0,s[4]*r,s[5]*r,s[6]*r,0,s[8]*n,s[9]*n,s[10]*n,0,0,0,0,1,e),e}toggleModelMatrixHandInPlace(){const e=this._m;return e[2]*=-1,e[6]*=-1,e[8]*=-1,e[9]*=-1,e[14]*=-1,this.markAsUpdated(),this}toggleProjectionMatrixHandInPlace(){const e=this._m;return e[8]*=-1,e[9]*=-1,e[10]*=-1,e[11]*=-1,this.markAsUpdated(),this}static FromArray(e,t=0){const s=new f;return f.FromArrayToRef(e,t,s),s}static FromArrayToRef(e,t,s){for(let i=0;i<16;i++)s._m[i]=e[i+t];return s.markAsUpdated(),s}static FromFloat32ArrayToRefScaled(e,t,s,i){return i._m[0]=e[0+t]*s,i._m[1]=e[1+t]*s,i._m[2]=e[2+t]*s,i._m[3]=e[3+t]*s,i._m[4]=e[4+t]*s,i._m[5]=e[5+t]*s,i._m[6]=e[6+t]*s,i._m[7]=e[7+t]*s,i._m[8]=e[8+t]*s,i._m[9]=e[9+t]*s,i._m[10]=e[10+t]*s,i._m[11]=e[11+t]*s,i._m[12]=e[12+t]*s,i._m[13]=e[13+t]*s,i._m[14]=e[14+t]*s,i._m[15]=e[15+t]*s,i.markAsUpdated(),i}static get IdentityReadOnly(){return f._IdentityReadOnly}static FromValuesToRef(e,t,s,i,r,n,a,o,h,l,c,u,d,_,f,p,g){const m=g._m;m[0]=e,m[1]=t,m[2]=s,m[3]=i,m[4]=r,m[5]=n,m[6]=a,m[7]=o,m[8]=h,m[9]=l,m[10]=c,m[11]=u,m[12]=d,m[13]=_,m[14]=f,m[15]=p,g.markAsUpdated()}static FromValues(e,t,s,i,r,n,a,o,h,l,c,u,d,_,p,g){const m=new f,T=m._m;return T[0]=e,T[1]=t,T[2]=s,T[3]=i,T[4]=r,T[5]=n,T[6]=a,T[7]=o,T[8]=h,T[9]=l,T[10]=c,T[11]=u,T[12]=d,T[13]=_,T[14]=p,T[15]=g,m.markAsUpdated(),m}static Compose(e,t,s){const i=new f;return f.ComposeToRef(e,t,s,i),i}static ComposeToRef(e,t,s,i){const r=i._m,n=t._x,a=t._y,o=t._z,h=t._w,l=n+n,c=a+a,u=o+o,d=n*l,_=n*c,f=n*u,p=a*c,g=a*u,m=o*u,T=h*l,b=h*c,E=h*u,x=e._x,A=e._y,R=e._z;return r[0]=(1-(p+m))*x,r[1]=(_+E)*x,r[2]=(f-b)*x,r[3]=0,r[4]=(_-E)*A,r[5]=(1-(d+m))*A,r[6]=(g+T)*A,r[7]=0,r[8]=(f+b)*R,r[9]=(g-T)*R,r[10]=(1-(d+p))*R,r[11]=0,r[12]=s._x,r[13]=s._y,r[14]=s._z,r[15]=1,i.markAsUpdated(),i}static Identity(){const e=f.FromValues(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return e._updateIdentityStatus(!0),e}static IdentityToRef(e){return f.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,e),e._updateIdentityStatus(!0),e}static Zero(){const e=f.FromValues(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);return e._updateIdentityStatus(!1),e}static RotationX(e){const t=new f;return f.RotationXToRef(e,t),t}static Invert(e){const t=new f;return e.invertToRef(t),t}static RotationXToRef(e,t){const s=Math.sin(e),i=Math.cos(e);return f.FromValuesToRef(1,0,0,0,0,i,s,0,0,-s,i,0,0,0,0,1,t),t._updateIdentityStatus(1===i&&0===s),t}static RotationY(e){const t=new f;return f.RotationYToRef(e,t),t}static RotationYToRef(e,t){const s=Math.sin(e),i=Math.cos(e);return f.FromValuesToRef(i,0,-s,0,0,1,0,0,s,0,i,0,0,0,0,1,t),t._updateIdentityStatus(1===i&&0===s),t}static RotationZ(e){const t=new f;return f.RotationZToRef(e,t),t}static RotationZToRef(e,t){const s=Math.sin(e),i=Math.cos(e);return f.FromValuesToRef(i,s,0,0,-s,i,0,0,0,0,1,0,0,0,0,1,t),t._updateIdentityStatus(1===i&&0===s),t}static RotationAxis(e,t){const s=new f;return f.RotationAxisToRef(e,t,s),s}static RotationAxisToRef(e,t,s){const i=Math.sin(-t),r=Math.cos(-t),n=1-r;e=e.normalizeToRef(p.Vector3[0]);const a=s._m;return a[0]=e._x*e._x*n+r,a[1]=e._x*e._y*n-e._z*i,a[2]=e._x*e._z*n+e._y*i,a[3]=0,a[4]=e._y*e._x*n+e._z*i,a[5]=e._y*e._y*n+r,a[6]=e._y*e._z*n-e._x*i,a[7]=0,a[8]=e._z*e._x*n-e._y*i,a[9]=e._z*e._y*n+e._x*i,a[10]=e._z*e._z*n+r,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,s.markAsUpdated(),s}static RotationAlignToRef(e,t,s,r=!1){const n=u.Dot(t,e),a=s._m;if(n<-1+i.bH)a[0]=-1,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=r?1:-1,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=r?-1:1,a[11]=0;else{const s=u.Cross(t,e),i=1/(1+n);a[0]=s._x*s._x*i+n,a[1]=s._y*s._x*i-s._z,a[2]=s._z*s._x*i+s._y,a[3]=0,a[4]=s._x*s._y*i+s._z,a[5]=s._y*s._y*i+n,a[6]=s._z*s._y*i-s._x,a[7]=0,a[8]=s._x*s._z*i-s._y,a[9]=s._y*s._z*i+s._x,a[10]=s._z*s._z*i+n,a[11]=0}return a[12]=0,a[13]=0,a[14]=0,a[15]=1,s.markAsUpdated(),s}static RotationYawPitchRoll(e,t,s){const i=new f;return f.RotationYawPitchRollToRef(e,t,s,i),i}static RotationYawPitchRollToRef(e,t,s,i){return _.RotationYawPitchRollToRef(e,t,s,p.Quaternion[0]),p.Quaternion[0].toRotationMatrix(i),i}static Scaling(e,t,s){const i=new f;return f.ScalingToRef(e,t,s,i),i}static ScalingToRef(e,t,s,i){return f.FromValuesToRef(e,0,0,0,0,t,0,0,0,0,s,0,0,0,0,1,i),i._updateIdentityStatus(1===e&&1===t&&1===s),i}static Translation(e,t,s){const i=new f;return f.TranslationToRef(e,t,s,i),i}static TranslationToRef(e,t,s,i){return f.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,e,t,s,1,i),i._updateIdentityStatus(0===e&&0===t&&0===s),i}static Lerp(e,t,s){const i=new f;return f.LerpToRef(e,t,s,i),i}static LerpToRef(e,t,s,i){const r=i._m,n=e.m,a=t.m;for(let e=0;e<16;e++)r[e]=n[e]*(1-s)+a[e]*s;return i.markAsUpdated(),i}static DecomposeLerp(e,t,s){const i=new f;return f.DecomposeLerpToRef(e,t,s,i),i}static DecomposeLerpToRef(e,t,s,i){const r=p.Vector3[0],n=p.Quaternion[0],a=p.Vector3[1];e.decompose(r,n,a);const o=p.Vector3[2],h=p.Quaternion[1],l=p.Vector3[3];t.decompose(o,h,l);const c=p.Vector3[4];u.LerpToRef(r,o,s,c);const d=p.Quaternion[2];_.SlerpToRef(n,h,s,d);const g=p.Vector3[5];return u.LerpToRef(a,l,s,g),f.ComposeToRef(c,d,g,i),i}static LookAtLH(e,t,s){const i=new f;return f.LookAtLHToRef(e,t,s,i),i}static LookAtLHToRef(e,t,s,i){const r=p.Vector3[0],n=p.Vector3[1],a=p.Vector3[2];t.subtractToRef(e,a),a.normalize(),u.CrossToRef(s,a,r);const o=r.lengthSquared();0===o?r.x=1:r.normalizeFromLength(Math.sqrt(o)),u.CrossToRef(a,r,n),n.normalize();const h=-u.Dot(r,e),l=-u.Dot(n,e),c=-u.Dot(a,e);return f.FromValuesToRef(r._x,n._x,a._x,0,r._y,n._y,a._y,0,r._z,n._z,a._z,0,h,l,c,1,i),i}static LookAtRH(e,t,s){const i=new f;return f.LookAtRHToRef(e,t,s,i),i}static LookAtRHToRef(e,t,s,i){const r=p.Vector3[0],n=p.Vector3[1],a=p.Vector3[2];e.subtractToRef(t,a),a.normalize(),u.CrossToRef(s,a,r);const o=r.lengthSquared();0===o?r.x=1:r.normalizeFromLength(Math.sqrt(o)),u.CrossToRef(a,r,n),n.normalize();const h=-u.Dot(r,e),l=-u.Dot(n,e),c=-u.Dot(a,e);return f.FromValuesToRef(r._x,n._x,a._x,0,r._y,n._y,a._y,0,r._z,n._z,a._z,0,h,l,c,1,i),i}static LookDirectionLH(e,t){const s=new f;return f.LookDirectionLHToRef(e,t,s),s}static LookDirectionLHToRef(e,t,s){const i=p.Vector3[0];i.copyFrom(e),i.scaleInPlace(-1);const r=p.Vector3[1];return u.CrossToRef(t,i,r),f.FromValuesToRef(r._x,r._y,r._z,0,t._x,t._y,t._z,0,i._x,i._y,i._z,0,0,0,0,1,s),s}static LookDirectionRH(e,t){const s=new f;return f.LookDirectionRHToRef(e,t,s),s}static LookDirectionRHToRef(e,t,s){const i=p.Vector3[2];return u.CrossToRef(t,e,i),f.FromValuesToRef(i._x,i._y,i._z,0,t._x,t._y,t._z,0,e._x,e._y,e._z,0,0,0,0,1,s),s}static OrthoLH(e,t,s,i,r){const n=new f;return f.OrthoLHToRef(e,t,s,i,n,r),n}static OrthoLHToRef(e,t,s,i,r,n){const a=2/e,o=2/t,h=2/(i-s),l=-(i+s)/(i-s);return f.FromValuesToRef(a,0,0,0,0,o,0,0,0,0,h,0,0,0,l,1,r),n&&r.multiplyToRef(m,r),r._updateIdentityStatus(1===a&&1===o&&1===h&&0===l),r}static OrthoOffCenterLH(e,t,s,i,r,n,a){const o=new f;return f.OrthoOffCenterLHToRef(e,t,s,i,r,n,o,a),o}static OrthoOffCenterLHToRef(e,t,s,i,r,n,a,o){const h=2/(t-e),l=2/(i-s),c=2/(n-r),u=-(n+r)/(n-r),d=(e+t)/(e-t),_=(i+s)/(s-i);return f.FromValuesToRef(h,0,0,0,0,l,0,0,0,0,c,0,d,_,u,1,a),o&&a.multiplyToRef(m,a),a.markAsUpdated(),a}static ObliqueOffCenterLHToRef(e,t,s,i,r,n,a,o,h,l,c){const u=-a*Math.cos(o),d=-a*Math.sin(o);return f.TranslationToRef(0,0,-h,p.Matrix[1]),f.FromValuesToRef(1,0,0,0,0,1,0,0,u,d,1,0,0,0,0,1,p.Matrix[0]),p.Matrix[1].multiplyToRef(p.Matrix[0],p.Matrix[0]),f.TranslationToRef(0,0,h,p.Matrix[1]),p.Matrix[0].multiplyToRef(p.Matrix[1],p.Matrix[0]),f.OrthoOffCenterLHToRef(e,t,s,i,r,n,l,c),p.Matrix[0].multiplyToRef(l,l),l}static OrthoOffCenterRH(e,t,s,i,r,n,a){const o=new f;return f.OrthoOffCenterRHToRef(e,t,s,i,r,n,o,a),o}static OrthoOffCenterRHToRef(e,t,s,i,r,n,a,o){return f.OrthoOffCenterLHToRef(e,t,s,i,r,n,a,o),a._m[10]*=-1,a}static ObliqueOffCenterRHToRef(e,t,s,i,r,n,a,o,h,l,c){const u=a*Math.cos(o),d=a*Math.sin(o);return f.TranslationToRef(0,0,h,p.Matrix[1]),f.FromValuesToRef(1,0,0,0,0,1,0,0,u,d,1,0,0,0,0,1,p.Matrix[0]),p.Matrix[1].multiplyToRef(p.Matrix[0],p.Matrix[0]),f.TranslationToRef(0,0,-h,p.Matrix[1]),p.Matrix[0].multiplyToRef(p.Matrix[1],p.Matrix[0]),f.OrthoOffCenterRHToRef(e,t,s,i,r,n,l,c),p.Matrix[0].multiplyToRef(l,l),l}static PerspectiveLH(e,t,s,i,r,n=0){const a=new f,o=2*s/e,h=2*s/t,l=(i+s)/(i-s),c=-2*i*s/(i-s),u=Math.tan(n);return f.FromValuesToRef(o,0,0,0,0,h,0,u,0,0,l,1,0,0,c,0,a),r&&a.multiplyToRef(m,a),a._updateIdentityStatus(!1),a}static PerspectiveFovLH(e,t,s,i,r,n=0,a=!1){const o=new f;return f.PerspectiveFovLHToRef(e,t,s,i,o,!0,r,n,a),o}static PerspectiveFovLHToRef(e,t,s,i,r,n=!0,a,o=0,h=!1){const l=s,c=i,u=1/Math.tan(.5*e),d=n?u/t:u,_=n?u:u*t,p=h&&0===l?-1:0!==c?(c+l)/(c-l):1,g=h&&0===l?2*c:0!==c?-2*c*l/(c-l):-2*l,T=Math.tan(o);return f.FromValuesToRef(d,0,0,0,0,_,0,T,0,0,p,1,0,0,g,0,r),a&&r.multiplyToRef(m,r),r._updateIdentityStatus(!1),r}static PerspectiveFovReverseLHToRef(e,t,s,i,r,n=!0,a,o=0){const h=1/Math.tan(.5*e),l=n?h/t:h,c=n?h:h*t,u=Math.tan(o);return f.FromValuesToRef(l,0,0,0,0,c,0,u,0,0,-s,1,0,0,1,0,r),a&&r.multiplyToRef(m,r),r._updateIdentityStatus(!1),r}static PerspectiveFovRH(e,t,s,i,r,n=0,a=!1){const o=new f;return f.PerspectiveFovRHToRef(e,t,s,i,o,!0,r,n,a),o}static PerspectiveFovRHToRef(e,t,s,i,r,n=!0,a,o=0,h=!1){const l=s,c=i,u=1/Math.tan(.5*e),d=n?u/t:u,_=n?u:u*t,p=h&&0===l?1:0!==c?-(c+l)/(c-l):-1,g=h&&0===l?2*c:0!==c?-2*c*l/(c-l):-2*l,T=Math.tan(o);return f.FromValuesToRef(d,0,0,0,0,_,0,T,0,0,p,-1,0,0,g,0,r),a&&r.multiplyToRef(m,r),r._updateIdentityStatus(!1),r}static PerspectiveFovReverseRHToRef(e,t,s,i,r,n=!0,a,o=0){const h=1/Math.tan(.5*e),l=n?h/t:h,c=n?h:h*t,u=Math.tan(o);return f.FromValuesToRef(l,0,0,0,0,c,0,u,0,0,-s,-1,0,0,-1,0,r),a&&r.multiplyToRef(m,r),r._updateIdentityStatus(!1),r}static GetFinalMatrix(e,t,s,i,r,n){const a=e.width,o=e.height,h=e.x,l=e.y,c=f.FromValues(a/2,0,0,0,0,-o/2,0,0,0,0,n-r,0,h+a/2,o/2+l,r,1),u=new f;return t.multiplyToRef(s,u),u.multiplyToRef(i,u),u.multiplyToRef(c,u)}static GetAsMatrix2x2(e){const t=e.m,s=[t[0],t[1],t[4],t[5]];return a.I.MatrixUse64Bits?s:new Float32Array(s)}static GetAsMatrix3x3(e){const t=e.m,s=[t[0],t[1],t[2],t[4],t[5],t[6],t[8],t[9],t[10]];return a.I.MatrixUse64Bits?s:new Float32Array(s)}static Transpose(e){const t=new f;return f.TransposeToRef(e,t),t}static TransposeToRef(e,t){const s=e.m,i=s[0],r=s[4],n=s[8],a=s[12],o=s[1],h=s[5],l=s[9],c=s[13],u=s[2],d=s[6],_=s[10],f=s[14],p=s[3],g=s[7],m=s[11],T=s[15],b=t._m;return b[0]=i,b[1]=r,b[2]=n,b[3]=a,b[4]=o,b[5]=h,b[6]=l,b[7]=c,b[8]=u,b[9]=d,b[10]=_,b[11]=f,b[12]=p,b[13]=g,b[14]=m,b[15]=T,t.markAsUpdated(),t._updateIdentityStatus(e._isIdentity,e._isIdentityDirty),t}static Reflection(e){const t=new f;return f.ReflectionToRef(e,t),t}static ReflectionToRef(e,t){e.normalize();const s=e.normal.x,i=e.normal.y,r=e.normal.z,n=-2*s,a=-2*i,o=-2*r;return f.FromValuesToRef(n*s+1,a*s,o*s,0,n*i,a*i+1,o*i,0,n*r,a*r,o*r+1,0,n*e.d,a*e.d,o*e.d,1,t),t}static FromXYZAxesToRef(e,t,s,i){return f.FromValuesToRef(e._x,e._y,e._z,0,t._x,t._y,t._z,0,s._x,s._y,s._z,0,0,0,0,1,i),i}static FromQuaternionToRef(e,t){const s=e._x*e._x,i=e._y*e._y,r=e._z*e._z,n=e._x*e._y,a=e._z*e._w,o=e._z*e._x,h=e._y*e._w,l=e._y*e._z,c=e._x*e._w;return t._m[0]=1-2*(i+r),t._m[1]=2*(n+a),t._m[2]=2*(o-h),t._m[3]=0,t._m[4]=2*(n-a),t._m[5]=1-2*(r+s),t._m[6]=2*(l+c),t._m[7]=0,t._m[8]=2*(o+h),t._m[9]=2*(l-c),t._m[10]=1-2*(i+s),t._m[11]=0,t._m[12]=0,t._m[13]=0,t._m[14]=0,t._m[15]=1,t.markAsUpdated(),t}}f._UpdateFlagSeed=0,f._IdentityReadOnly=f.Identity(),Object.defineProperties(f.prototype,{dimension:{value:[4,4]},rank:{value:2}});class p{}p.Vector3=(0,r.ln)(11,u.Zero),p.Matrix=(0,r.ln)(2,f.Identity),p.Quaternion=(0,r.ln)(3,_.Zero);class g{}g.Vector2=(0,r.ln)(3,c.Zero),g.Vector3=(0,r.ln)(13,u.Zero),g.Vector4=(0,r.ln)(3,d.Zero),g.Quaternion=(0,r.ln)(3,_.Zero),g.Matrix=(0,r.ln)(8,f.Identity),(0,n.Y5)("BABYLON.Vector2",c),(0,n.Y5)("BABYLON.Vector3",u),(0,n.Y5)("BABYLON.Vector4",d),(0,n.Y5)("BABYLON.Matrix",f);const m=f.FromValues(1,0,0,0,0,1,0,0,0,0,.5,0,0,0,.5,1)},4494:(e,t,s)=>{s.d(t,{L:()=>i});class i{constructor(e,t,s,i){this.x=e,this.y=t,this.width=s,this.height=i}toGlobal(e,t){return new i(this.x*e,this.y*t,this.width*e,this.height*t)}toGlobalToRef(e,t,s){return s.x=this.x*e,s.y=this.y*t,s.width=this.width*e,s.height=this.height*t,this}clone(){return new i(this.x,this.y,this.width,this.height)}}},4640:(e,t,s)=>{s.d(t,{O:()=>h,Q:()=>l});var i=s(9923);s(8733),s(6041),s(5559),s(2572),s(1903),s(4100),s(521),s(4494);const r=[Math.sqrt(1/(4*Math.PI)),-Math.sqrt(3/(4*Math.PI)),Math.sqrt(3/(4*Math.PI)),-Math.sqrt(3/(4*Math.PI)),Math.sqrt(15/(4*Math.PI)),-Math.sqrt(15/(4*Math.PI)),Math.sqrt(5/(16*Math.PI)),-Math.sqrt(15/(4*Math.PI)),Math.sqrt(15/(16*Math.PI))],n=[()=>1,e=>e.y,e=>e.z,e=>e.x,e=>e.x*e.y,e=>e.y*e.z,e=>3*e.z*e.z-1,e=>e.x*e.z,e=>e.x*e.x-e.y*e.y],a=(e,t)=>r[e]*n[e](t),o=[Math.PI,2*Math.PI/3,2*Math.PI/3,2*Math.PI/3,Math.PI/4,Math.PI/4,Math.PI/4,Math.PI/4,Math.PI/4];class h{constructor(){this.preScaled=!1,this.l00=i.Pq.Zero(),this.l1_1=i.Pq.Zero(),this.l10=i.Pq.Zero(),this.l11=i.Pq.Zero(),this.l2_2=i.Pq.Zero(),this.l2_1=i.Pq.Zero(),this.l20=i.Pq.Zero(),this.l21=i.Pq.Zero(),this.l22=i.Pq.Zero()}addLight(e,t,s){i.AA.Vector3[0].set(t.r,t.g,t.b);const r=i.AA.Vector3[0],n=i.AA.Vector3[1];r.scaleToRef(s,n),n.scaleToRef(a(0,e),i.AA.Vector3[2]),this.l00.addInPlace(i.AA.Vector3[2]),n.scaleToRef(a(1,e),i.AA.Vector3[2]),this.l1_1.addInPlace(i.AA.Vector3[2]),n.scaleToRef(a(2,e),i.AA.Vector3[2]),this.l10.addInPlace(i.AA.Vector3[2]),n.scaleToRef(a(3,e),i.AA.Vector3[2]),this.l11.addInPlace(i.AA.Vector3[2]),n.scaleToRef(a(4,e),i.AA.Vector3[2]),this.l2_2.addInPlace(i.AA.Vector3[2]),n.scaleToRef(a(5,e),i.AA.Vector3[2]),this.l2_1.addInPlace(i.AA.Vector3[2]),n.scaleToRef(a(6,e),i.AA.Vector3[2]),this.l20.addInPlace(i.AA.Vector3[2]),n.scaleToRef(a(7,e),i.AA.Vector3[2]),this.l21.addInPlace(i.AA.Vector3[2]),n.scaleToRef(a(8,e),i.AA.Vector3[2]),this.l22.addInPlace(i.AA.Vector3[2])}scaleInPlace(e){this.l00.scaleInPlace(e),this.l1_1.scaleInPlace(e),this.l10.scaleInPlace(e),this.l11.scaleInPlace(e),this.l2_2.scaleInPlace(e),this.l2_1.scaleInPlace(e),this.l20.scaleInPlace(e),this.l21.scaleInPlace(e),this.l22.scaleInPlace(e)}convertIncidentRadianceToIrradiance(){this.l00.scaleInPlace(o[0]),this.l1_1.scaleInPlace(o[1]),this.l10.scaleInPlace(o[2]),this.l11.scaleInPlace(o[3]),this.l2_2.scaleInPlace(o[4]),this.l2_1.scaleInPlace(o[5]),this.l20.scaleInPlace(o[6]),this.l21.scaleInPlace(o[7]),this.l22.scaleInPlace(o[8])}convertIrradianceToLambertianRadiance(){this.scaleInPlace(1/Math.PI)}preScaleForRendering(){this.preScaled=!0,this.l00.scaleInPlace(r[0]),this.l1_1.scaleInPlace(r[1]),this.l10.scaleInPlace(r[2]),this.l11.scaleInPlace(r[3]),this.l2_2.scaleInPlace(r[4]),this.l2_1.scaleInPlace(r[5]),this.l20.scaleInPlace(r[6]),this.l21.scaleInPlace(r[7]),this.l22.scaleInPlace(r[8])}updateFromArray(e){return i.Pq.FromArrayToRef(e[0],0,this.l00),i.Pq.FromArrayToRef(e[1],0,this.l1_1),i.Pq.FromArrayToRef(e[2],0,this.l10),i.Pq.FromArrayToRef(e[3],0,this.l11),i.Pq.FromArrayToRef(e[4],0,this.l2_2),i.Pq.FromArrayToRef(e[5],0,this.l2_1),i.Pq.FromArrayToRef(e[6],0,this.l20),i.Pq.FromArrayToRef(e[7],0,this.l21),i.Pq.FromArrayToRef(e[8],0,this.l22),this}updateFromFloatsArray(e){return i.Pq.FromFloatsToRef(e[0],e[1],e[2],this.l00),i.Pq.FromFloatsToRef(e[3],e[4],e[5],this.l1_1),i.Pq.FromFloatsToRef(e[6],e[7],e[8],this.l10),i.Pq.FromFloatsToRef(e[9],e[10],e[11],this.l11),i.Pq.FromFloatsToRef(e[12],e[13],e[14],this.l2_2),i.Pq.FromFloatsToRef(e[15],e[16],e[17],this.l2_1),i.Pq.FromFloatsToRef(e[18],e[19],e[20],this.l20),i.Pq.FromFloatsToRef(e[21],e[22],e[23],this.l21),i.Pq.FromFloatsToRef(e[24],e[25],e[26],this.l22),this}static FromArray(e){return(new h).updateFromArray(e)}static FromPolynomial(e){const t=new h;return t.l00=e.xx.scale(.376127).add(e.yy.scale(.376127)).add(e.zz.scale(.376126)),t.l1_1=e.y.scale(.977204),t.l10=e.z.scale(.977204),t.l11=e.x.scale(.977204),t.l2_2=e.xy.scale(1.16538),t.l2_1=e.yz.scale(1.16538),t.l20=e.zz.scale(1.34567).subtract(e.xx.scale(.672834)).subtract(e.yy.scale(.672834)),t.l21=e.zx.scale(1.16538),t.l22=e.xx.scale(1.16538).subtract(e.yy.scale(1.16538)),t.l1_1.scaleInPlace(-1),t.l11.scaleInPlace(-1),t.l2_1.scaleInPlace(-1),t.l21.scaleInPlace(-1),t.scaleInPlace(Math.PI),t}}class l{constructor(){this.x=i.Pq.Zero(),this.y=i.Pq.Zero(),this.z=i.Pq.Zero(),this.xx=i.Pq.Zero(),this.yy=i.Pq.Zero(),this.zz=i.Pq.Zero(),this.xy=i.Pq.Zero(),this.yz=i.Pq.Zero(),this.zx=i.Pq.Zero()}get preScaledHarmonics(){return this._harmonics||(this._harmonics=h.FromPolynomial(this)),this._harmonics.preScaled||this._harmonics.preScaleForRendering(),this._harmonics}addAmbient(e){i.AA.Vector3[0].copyFromFloats(e.r,e.g,e.b);const t=i.AA.Vector3[0];this.xx.addInPlace(t),this.yy.addInPlace(t),this.zz.addInPlace(t)}scaleInPlace(e){this.x.scaleInPlace(e),this.y.scaleInPlace(e),this.z.scaleInPlace(e),this.xx.scaleInPlace(e),this.yy.scaleInPlace(e),this.zz.scaleInPlace(e),this.yz.scaleInPlace(e),this.zx.scaleInPlace(e),this.xy.scaleInPlace(e)}updateFromHarmonics(e){return this._harmonics=e,this.x.copyFrom(e.l11),this.x.scaleInPlace(1.02333).scaleInPlace(-1),this.y.copyFrom(e.l1_1),this.y.scaleInPlace(1.02333).scaleInPlace(-1),this.z.copyFrom(e.l10),this.z.scaleInPlace(1.02333),this.xx.copyFrom(e.l00),i.AA.Vector3[0].copyFrom(e.l20).scaleInPlace(.247708),i.AA.Vector3[1].copyFrom(e.l22).scaleInPlace(.429043),this.xx.scaleInPlace(.886277).subtractInPlace(i.AA.Vector3[0]).addInPlace(i.AA.Vector3[1]),this.yy.copyFrom(e.l00),this.yy.scaleInPlace(.886277).subtractInPlace(i.AA.Vector3[0]).subtractInPlace(i.AA.Vector3[1]),this.zz.copyFrom(e.l00),i.AA.Vector3[0].copyFrom(e.l20).scaleInPlace(.495417),this.zz.scaleInPlace(.886277).addInPlace(i.AA.Vector3[0]),this.yz.copyFrom(e.l2_1),this.yz.scaleInPlace(.858086).scaleInPlace(-1),this.zx.copyFrom(e.l21),this.zx.scaleInPlace(.858086).scaleInPlace(-1),this.xy.copyFrom(e.l2_2),this.xy.scaleInPlace(.858086),this.scaleInPlace(1/Math.PI),this}static FromHarmonics(e){return(new l).updateFromHarmonics(e)}static FromArray(e){const t=new l;return i.Pq.FromArrayToRef(e[0],0,t.x),i.Pq.FromArrayToRef(e[1],0,t.y),i.Pq.FromArrayToRef(e[2],0,t.z),i.Pq.FromArrayToRef(e[3],0,t.xx),i.Pq.FromArrayToRef(e[4],0,t.yy),i.Pq.FromArrayToRef(e[5],0,t.zz),i.Pq.FromArrayToRef(e[6],0,t.yz),i.Pq.FromArrayToRef(e[7],0,t.zx),i.Pq.FromArrayToRef(e[8],0,t.xy),t}}},8529:(e,t,s)=>{s.d(t,{km:()=>g});var i=s(9923),r=s(6041),n=s(5530),a=s(6803),o=s(5616);n.e._GroundMeshParser=(e,t)=>h.Parse(e,t);class h extends n.e{constructor(e,t){super(e,t),this.generateOctree=!1}getClassName(){return"GroundMesh"}get subdivisions(){return Math.min(this._subdivisionsX,this._subdivisionsY)}get subdivisionsX(){return this._subdivisionsX}get subdivisionsY(){return this._subdivisionsY}optimize(e,t=32){this._subdivisionsX=e,this._subdivisionsY=e,this.subdivide(e);this.createOrUpdateSubmeshesOctree&&this.createOrUpdateSubmeshesOctree(t)}getHeightAtCoordinates(e,t){const s=this.getWorldMatrix(),r=i.AA.Matrix[5];s.invertToRef(r);const n=i.AA.Vector3[8];if(i.Pq.TransformCoordinatesFromFloatsToRef(e,0,t,r,n),e=n.x,t=n.z,e=this._maxX||t<=this._minZ||t>this._maxZ)return this.position.y;this._heightQuads&&0!=this._heightQuads.length||(this._initHeightQuads(),this._computeHeightQuads());const a=this._getFacetAt(e,t),o=-(a.x*e+a.z*t+a.w)/a.y;return i.Pq.TransformCoordinatesFromFloatsToRef(0,o,0,s,n),n.y}getNormalAtCoordinates(e,t){const s=new i.Pq(0,1,0);return this.getNormalAtCoordinatesToRef(e,t,s),s}getNormalAtCoordinatesToRef(e,t,s){const r=this.getWorldMatrix(),n=i.AA.Matrix[5];r.invertToRef(n);const a=i.AA.Vector3[8];if(i.Pq.TransformCoordinatesFromFloatsToRef(e,0,t,n,a),e=a.x,t=a.z,ethis._maxX||tthis._maxZ)return this;this._heightQuads&&0!=this._heightQuads.length||(this._initHeightQuads(),this._computeHeightQuads());const o=this._getFacetAt(e,t);return i.Pq.TransformNormalFromFloatsToRef(o.x,o.y,o.z,r,s),this}updateCoordinateHeights(){return this._heightQuads&&0!=this._heightQuads.length||this._initHeightQuads(),this._computeHeightQuads(),this}_getFacetAt(e,t){const s=Math.floor((e+this._maxX)*this._subdivisionsX/this._width),i=Math.floor(-(t+this._maxZ)*this._subdivisionsY/this._height+this._subdivisionsY),r=this._heightQuads[i*this._subdivisionsX+s];let n;return n=te.maxHeight){_=!0;const t=e.maxHeight;e.maxHeight=e.minHeight,e.minHeight=t}for(h=0;h<=e.subdivisions;h++)for(l=0;l<=e.subdivisions;l++){const t=new i.Pq(l*e.width/e.subdivisions-e.width/2,0,(e.subdivisions-h)*e.height/e.subdivisions-e.height/2),r=4*(((t.x+e.width/2)/e.width*(e.bufferWidth-1)|0)+((1-(t.z+e.height/2)/e.height)*(e.bufferHeight-1)|0)*e.bufferWidth);let a=e.buffer[r]/255,f=e.buffer[r+1]/255,p=e.buffer[r+2]/255;const g=e.buffer[r+3]/255;_&&(a=1-a,f=1-f,p=1-p);const m=a*c.r+f*c.g+p*c.b;t.y=g>=d?e.minHeight+(e.maxHeight-e.minHeight)*m:e.minHeight-u.bH,e.heightBuffer&&(e.heightBuffer[h*(e.subdivisions+1)+l]=t.y),s.push(t.x,t.y,t.z),n.push(0,0,0),o.push(l/e.subdivisions,1-h/e.subdivisions)}for(h=0;h=e.minHeight,c=s[3*r+1]>=e.minHeight,u=s[3*n+1]>=e.minHeight;o&&c&&u&&(t.push(i),t.push(r),t.push(n)),s[3*a+1]>=e.minHeight&&o&&u&&(t.push(a),t.push(i),t.push(n))}a.P.ComputeNormals(s,t,n);const f=new a.P;return f.indices=t,f.positions=s,f.normals=n,f.uvs=o,f}function g(e,t={},s){const i=new h(e,s);return i._setReady(!1),i._subdivisionsX=t.subdivisionsX||t.subdivisions||1,i._subdivisionsY=t.subdivisionsY||t.subdivisions||1,i._width=t.width||1,i._height=t.height||1,i._maxX=i._width/2,i._maxZ=i._height/2,i._minX=-i._maxX,i._minZ=-i._maxZ,_(t).applyToMesh(i,t.updatable),i._setReady(!0),i}a.P.CreateGround=_,a.P.CreateTiledGround=f,a.P.CreateGroundFromHeightMap=p,n.e.CreateGround=(e,t,s,i,r,n)=>g(e,{width:t,height:s,subdivisions:i,updatable:n},r),n.e.CreateTiledGround=(e,t,s,i,r,a,o,h,l)=>function(e,t,s=null){const i=new n.e(e,s);return f(t).applyToMesh(i,t.updatable),i}(e,{xmin:t,zmin:s,xmax:i,zmax:r,subdivisions:a,precision:o,updatable:l},h),n.e.CreateGroundFromHeightMap=(e,t,s,i,n,a,o,u,d,_,f)=>function(e,t,s={},i=null){const n=s.width||10,a=s.height||10,o=s.subdivisions||1,u=s.minHeight||0,d=s.maxHeight||1,_=s.colorFilter||new r.v9(.3,.59,.11),f=s.alphaFilter||0,g=s.updatable,m=s.onReady;i=i||c.q.LastCreatedScene;const T=new h(e,i);let b;T._subdivisionsX=o,T._subdivisionsY=o,T._width=n,T._height=a,T._maxX=T._width/2,T._maxZ=T._height/2,T._minX=-T._maxX,T._minZ=-T._maxZ,T._setReady(!1),s.passHeightBufferInCallback&&(b=new Float32Array((o+1)*(o+1)));const E=(e,t,s)=>{p({width:n,height:a,subdivisions:o,minHeight:u,maxHeight:d,colorFilter:_,buffer:e,bufferWidth:t,bufferHeight:s,alphaFilter:f,heightBuffer:b}).applyToMesh(T,g),m&&m(T,b),T._setReady(!0)};if("string"==typeof t){const e=e=>{const t=e.width,s=e.height;if(i.isDisposed)return;const r=i?.getEngine().resizeImageBitmap(e,t,s);E(r,t,s)};l.S0.LoadImage(t,e,s.onError?s.onError:()=>{},i.offlineProvider)}else E(t.data,t.width,t.height);return T}(e,t,{width:s,height:i,subdivisions:n,minHeight:a,maxHeight:o,updatable:d,onReady:_,alphaFilter:f},u)},4329:(e,t,s)=>{s.d(t,{A:()=>r});var i=s(1504);class r extends i.n{constructor(e){super(),this._buffer=e}get underlyingResource(){return this._buffer}}},861:(e,t,s)=>{s.d(t,{u:()=>R});var i=s(5524),r=s(9848),n=s(9923),a=s(5616),o=s(6803),h=s(7328),l=s(311),c=s(2564),u=s(935);class d{constructor(){this._checkCollisions=!1,this._collisionMask=-1,this._collisionGroup=-1,this._surroundingMeshes=null,this._collider=null,this._oldPositionForCollisions=new n.Pq(0,0,0),this._diffPositionForCollisions=new n.Pq(0,0,0),this._collisionResponse=!0}}var _=s(5503),f=s(1139),p=s(6041),g=s(5559),m=s(8733),T=s(6552),b=s(9259),E=s(6326);class x{constructor(){this.facetNb=0,this.partitioningSubdivisions=10,this.partitioningBBoxRatio=1.01,this.facetDataEnabled=!1,this.facetParameters={},this.bbSize=n.Pq.Zero(),this.subDiv={max:1,X:1,Y:1,Z:1},this.facetDepthSort=!1,this.facetDepthSortEnabled=!1}}class A{constructor(){this._hasVertexAlpha=!1,this._useVertexColors=!0,this._numBoneInfluencers=4,this._applyFog=!0,this._receiveShadows=!1,this._facetData=new x,this._visibility=1,this._skeleton=null,this._layerMask=268435455,this._computeBonesUsingShaders=!0,this._isActive=!1,this._onlyForInstances=!1,this._isActiveIntermediate=!1,this._onlyForInstancesIntermediate=!1,this._actAsRegularMesh=!1,this._currentLOD=null,this._currentLODIsUpToDate=!1,this._collisionRetryCount=3,this._morphTargetManager=null,this._renderingGroupId=0,this._bakedVertexAnimationManager=null,this._material=null,this._positions=null,this._pointerOverDisableMeshTesting=!1,this._meshCollisionData=new d,this._enableDistantPicking=!1,this._rawBoundingInfo=null,this._sideOrientationHint=!1,this._inheritVisibility=!1}}class R extends h.V{static get BILLBOARDMODE_NONE(){return h.V.BILLBOARDMODE_NONE}static get BILLBOARDMODE_X(){return h.V.BILLBOARDMODE_X}static get BILLBOARDMODE_Y(){return h.V.BILLBOARDMODE_Y}static get BILLBOARDMODE_Z(){return h.V.BILLBOARDMODE_Z}static get BILLBOARDMODE_ALL(){return h.V.BILLBOARDMODE_ALL}static get BILLBOARDMODE_USE_POSITION(){return h.V.BILLBOARDMODE_USE_POSITION}get facetNb(){return this._internalAbstractMeshDataInfo._facetData.facetNb}get partitioningSubdivisions(){return this._internalAbstractMeshDataInfo._facetData.partitioningSubdivisions}set partitioningSubdivisions(e){this._internalAbstractMeshDataInfo._facetData.partitioningSubdivisions=e}get partitioningBBoxRatio(){return this._internalAbstractMeshDataInfo._facetData.partitioningBBoxRatio}set partitioningBBoxRatio(e){this._internalAbstractMeshDataInfo._facetData.partitioningBBoxRatio=e}get mustDepthSortFacets(){return this._internalAbstractMeshDataInfo._facetData.facetDepthSort}set mustDepthSortFacets(e){this._internalAbstractMeshDataInfo._facetData.facetDepthSort=e}get facetDepthSortFrom(){return this._internalAbstractMeshDataInfo._facetData.facetDepthSortFrom}set facetDepthSortFrom(e){this._internalAbstractMeshDataInfo._facetData.facetDepthSortFrom=e}get collisionRetryCount(){return this._internalAbstractMeshDataInfo._collisionRetryCount}set collisionRetryCount(e){this._internalAbstractMeshDataInfo._collisionRetryCount=e}get isFacetDataEnabled(){return this._internalAbstractMeshDataInfo._facetData.facetDataEnabled}get morphTargetManager(){return this._internalAbstractMeshDataInfo._morphTargetManager}set morphTargetManager(e){this._internalAbstractMeshDataInfo._morphTargetManager!==e&&(this._internalAbstractMeshDataInfo._morphTargetManager=e,this._syncGeometryWithMorphTargetManager())}get bakedVertexAnimationManager(){return this._internalAbstractMeshDataInfo._bakedVertexAnimationManager}set bakedVertexAnimationManager(e){this._internalAbstractMeshDataInfo._bakedVertexAnimationManager!==e&&(this._internalAbstractMeshDataInfo._bakedVertexAnimationManager=e,this._markSubMeshesAsAttributesDirty())}_syncGeometryWithMorphTargetManager(){}_updateNonUniformScalingState(e){return!!super._updateNonUniformScalingState(e)&&(this._markSubMeshesAsMiscDirty(),!0)}get rawBoundingInfo(){return this._internalAbstractMeshDataInfo._rawBoundingInfo}set rawBoundingInfo(e){this._internalAbstractMeshDataInfo._rawBoundingInfo=e}set onCollide(e){this._internalAbstractMeshDataInfo._meshCollisionData._onCollideObserver&&this.onCollideObservable.remove(this._internalAbstractMeshDataInfo._meshCollisionData._onCollideObserver),this._internalAbstractMeshDataInfo._meshCollisionData._onCollideObserver=this.onCollideObservable.add(e)}set onCollisionPositionChange(e){this._internalAbstractMeshDataInfo._meshCollisionData._onCollisionPositionChangeObserver&&this.onCollisionPositionChangeObservable.remove(this._internalAbstractMeshDataInfo._meshCollisionData._onCollisionPositionChangeObserver),this._internalAbstractMeshDataInfo._meshCollisionData._onCollisionPositionChangeObserver=this.onCollisionPositionChangeObservable.add(e)}get visibility(){return this._internalAbstractMeshDataInfo._visibility}set visibility(e){if(this._internalAbstractMeshDataInfo._visibility===e)return;const t=this._internalAbstractMeshDataInfo._visibility;this._internalAbstractMeshDataInfo._visibility=e,(1===t&&1!==e||1!==t&&1===e)&&this._markSubMeshesAsDirty((e=>{e.markAsMiscDirty(),e.markAsPrePassDirty()}))}get inheritVisibility(){return this._internalAbstractMeshDataInfo._inheritVisibility}set inheritVisibility(e){this._internalAbstractMeshDataInfo._inheritVisibility=e}get isVisible(){if(!this._isVisible||!this.inheritVisibility||!this._parentNode)return this._isVisible;if(this._isVisible){let e=this._parentNode;for(;e;){const t=e.isVisible;if(void 0!==t)return t;e=e.parent}}return this._isVisible}set isVisible(e){this._isVisible=e}get pointerOverDisableMeshTesting(){return this._internalAbstractMeshDataInfo._pointerOverDisableMeshTesting}set pointerOverDisableMeshTesting(e){this._internalAbstractMeshDataInfo._pointerOverDisableMeshTesting=e}get renderingGroupId(){return this._internalAbstractMeshDataInfo._renderingGroupId}set renderingGroupId(e){this._internalAbstractMeshDataInfo._renderingGroupId=e}get material(){return this._internalAbstractMeshDataInfo._material}set material(e){this._setMaterial(e)}_setMaterial(e){this._internalAbstractMeshDataInfo._material!==e&&(this._internalAbstractMeshDataInfo._material&&this._internalAbstractMeshDataInfo._material.meshMap&&(this._internalAbstractMeshDataInfo._material.meshMap[this.uniqueId]=void 0),this._internalAbstractMeshDataInfo._material=e,e&&e.meshMap&&(e.meshMap[this.uniqueId]=this),this.onMaterialChangedObservable.hasObservers()&&this.onMaterialChangedObservable.notifyObservers(this),this.subMeshes&&(this.resetDrawCache(),this._unBindEffect()))}getMaterialForRenderPass(e){return this._internalAbstractMeshDataInfo._materialForRenderPass?.[e]}setMaterialForRenderPass(e,t){this.resetDrawCache(e),this._internalAbstractMeshDataInfo._materialForRenderPass||(this._internalAbstractMeshDataInfo._materialForRenderPass=[]),this._internalAbstractMeshDataInfo._materialForRenderPass[e]=t}get receiveShadows(){return this._internalAbstractMeshDataInfo._receiveShadows}set receiveShadows(e){this._internalAbstractMeshDataInfo._receiveShadows!==e&&(this._internalAbstractMeshDataInfo._receiveShadows=e,this._markSubMeshesAsLightDirty())}get hasVertexAlpha(){return this._internalAbstractMeshDataInfo._hasVertexAlpha}set hasVertexAlpha(e){this._internalAbstractMeshDataInfo._hasVertexAlpha!==e&&(this._internalAbstractMeshDataInfo._hasVertexAlpha=e,this._markSubMeshesAsAttributesDirty(),this._markSubMeshesAsMiscDirty())}get useVertexColors(){return this._internalAbstractMeshDataInfo._useVertexColors}set useVertexColors(e){this._internalAbstractMeshDataInfo._useVertexColors!==e&&(this._internalAbstractMeshDataInfo._useVertexColors=e,this._markSubMeshesAsAttributesDirty())}get computeBonesUsingShaders(){return this._internalAbstractMeshDataInfo._computeBonesUsingShaders}set computeBonesUsingShaders(e){this._internalAbstractMeshDataInfo._computeBonesUsingShaders!==e&&(this._internalAbstractMeshDataInfo._computeBonesUsingShaders=e,this._markSubMeshesAsAttributesDirty())}get numBoneInfluencers(){return this._internalAbstractMeshDataInfo._numBoneInfluencers}set numBoneInfluencers(e){this._internalAbstractMeshDataInfo._numBoneInfluencers!==e&&(this._internalAbstractMeshDataInfo._numBoneInfluencers=e,this._markSubMeshesAsAttributesDirty())}get applyFog(){return this._internalAbstractMeshDataInfo._applyFog}set applyFog(e){this._internalAbstractMeshDataInfo._applyFog!==e&&(this._internalAbstractMeshDataInfo._applyFog=e,this._markSubMeshesAsMiscDirty())}get enableDistantPicking(){return this._internalAbstractMeshDataInfo._enableDistantPicking}set enableDistantPicking(e){this._internalAbstractMeshDataInfo._enableDistantPicking=e}get layerMask(){return this._internalAbstractMeshDataInfo._layerMask}set layerMask(e){e!==this._internalAbstractMeshDataInfo._layerMask&&(this._internalAbstractMeshDataInfo._layerMask=e,this._resyncLightSources())}get collisionMask(){return this._internalAbstractMeshDataInfo._meshCollisionData._collisionMask}set collisionMask(e){this._internalAbstractMeshDataInfo._meshCollisionData._collisionMask=isNaN(e)?-1:e}get collisionResponse(){return this._internalAbstractMeshDataInfo._meshCollisionData._collisionResponse}set collisionResponse(e){this._internalAbstractMeshDataInfo._meshCollisionData._collisionResponse=e}get collisionGroup(){return this._internalAbstractMeshDataInfo._meshCollisionData._collisionGroup}set collisionGroup(e){this._internalAbstractMeshDataInfo._meshCollisionData._collisionGroup=isNaN(e)?-1:e}get surroundingMeshes(){return this._internalAbstractMeshDataInfo._meshCollisionData._surroundingMeshes}set surroundingMeshes(e){this._internalAbstractMeshDataInfo._meshCollisionData._surroundingMeshes=e}get lightSources(){return this._lightSources}set skeleton(e){const t=this._internalAbstractMeshDataInfo._skeleton;t&&t.needInitialSkinMatrix&&t._unregisterMeshWithPoseMatrix(this),e&&e.needInitialSkinMatrix&&e._registerMeshWithPoseMatrix(this),this._internalAbstractMeshDataInfo._skeleton=e,this._internalAbstractMeshDataInfo._skeleton||(this._bonesTransformMatrices=null),this._markSubMeshesAsAttributesDirty()}get skeleton(){return this._internalAbstractMeshDataInfo._skeleton}constructor(e,t=null){switch(super(e,t,!1),this._internalAbstractMeshDataInfo=new A,this._waitingMaterialId=null,this._waitingMorphTargetManagerId=null,this.cullingStrategy=R.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY,this.onCollideObservable=new r.cP,this.onCollisionPositionChangeObservable=new r.cP,this.onMaterialChangedObservable=new r.cP,this.definedFacingForward=!0,this._occlusionQuery=null,this._renderingGroup=null,this.alphaIndex=Number.MAX_VALUE,this._isVisible=!0,this.isPickable=!0,this.isNearPickable=!1,this.isNearGrabbable=!1,this.showSubMeshesBoundingBox=!1,this.isBlocker=!1,this.enablePointerMoveEvents=!1,this.outlineColor=p.v9.Red(),this.outlineWidth=.02,this.overlayColor=p.v9.Red(),this.overlayAlpha=.5,this.useOctreeForRenderingSelection=!0,this.useOctreeForPicking=!0,this.useOctreeForCollisions=!0,this.alwaysSelectAsActiveMesh=!1,this.doNotSyncBoundingInfo=!1,this.actionManager=null,this.ellipsoid=new n.Pq(.5,1,.5),this.ellipsoidOffset=new n.Pq(0,0,0),this.edgesWidth=1,this.edgesColor=new p.ov(1,0,0,1),this._edgesRenderer=null,this._masterMesh=null,this._boundingInfo=null,this._boundingInfoIsDirty=!0,this._renderId=0,this._intersectionsInProgress=new Array,this._unIndexed=!1,this._lightSources=new Array,this._waitingData={lods:null,actions:null,freezeWorldMatrix:null},this._bonesTransformMatrices=null,this._transformMatrixTexture=null,this.onRebuildObservable=new r.cP,this._onCollisionPositionChange=(e,t,s=null)=>{t.subtractToRef(this._internalAbstractMeshDataInfo._meshCollisionData._oldPositionForCollisions,this._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions),this._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions.length()>E.$.CollisionsEpsilon&&this.position.addInPlace(this._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions),s&&this.onCollideObservable.notifyObservers(s),this.onCollisionPositionChangeObservable.notifyObservers(this.position)},(t=this.getScene()).addMesh(this),this._resyncLightSources(),this._uniformBuffer=new u.D(this.getScene().getEngine(),void 0,void 0,e,!this.getScene().getEngine().isWebGPU),this._buildUniformLayout(),t.performancePriority){case 2:this.doNotSyncBoundingInfo=!0;case 1:this.alwaysSelectAsActiveMesh=!0,this.isPickable=!1}}_buildUniformLayout(){this._uniformBuffer.addUniform("world",16),this._uniformBuffer.addUniform("visibility",1),this._uniformBuffer.create()}transferToEffect(e){const t=this._uniformBuffer;t.updateMatrix("world",e),t.updateFloat("visibility",this._internalAbstractMeshDataInfo._visibility),t.update()}getMeshUniformBuffer(){return this._uniformBuffer}getClassName(){return"AbstractMesh"}toString(e){let t="Name: "+this.name+", isInstance: "+("InstancedMesh"!==this.getClassName()?"YES":"NO");t+=", # of submeshes: "+(this.subMeshes?this.subMeshes.length:0);const s=this._internalAbstractMeshDataInfo._skeleton;return s&&(t+=", skeleton: "+s.name),e&&(t+=", billboard mode: "+["NONE","X","Y",null,"Z",null,null,"ALL"][this.billboardMode],t+=", freeze wrld mat: "+(this._isWorldMatrixFrozen||this._waitingData.freezeWorldMatrix?"YES":"NO")),t}_getEffectiveParent(){return this._masterMesh&&this.billboardMode!==h.V.BILLBOARDMODE_NONE?this._masterMesh:super._getEffectiveParent()}_getActionManagerForTrigger(e,t=!0){if(this.actionManager&&(t||this.actionManager.isRecursive)){if(!e)return this.actionManager;if(this.actionManager.hasSpecificTrigger(e))return this.actionManager}return this.parent?this.parent._getActionManagerForTrigger(e,!1):null}_rebuild(e=!1){if(this.onRebuildObservable.notifyObservers(this),null!==this._occlusionQuery&&(this._occlusionQuery=null),this.subMeshes){for(const e of this.subMeshes)e._rebuild();this.resetDrawCache()}}_resyncLightSources(){this._lightSources.length=0;for(const e of this.getScene().lights)e.isEnabled()&&e.canAffectMesh(this)&&this._lightSources.push(e);this._markSubMeshesAsLightDirty()}_resyncLightSource(e){const t=e.isEnabled()&&e.canAffectMesh(this),s=this._lightSources.indexOf(e);let i=!1;if(-1===s){if(!t)return;this._lightSources.push(e)}else{if(t)return;i=!0,this._lightSources.splice(s,1)}this._markSubMeshesAsLightDirty(i)}_unBindEffect(){for(const e of this.subMeshes)e.setEffect(null)}_removeLightSource(e,t){const s=this._lightSources.indexOf(e);-1!==s&&(this._lightSources.splice(s,1),this._markSubMeshesAsLightDirty(t))}_markSubMeshesAsDirty(e){if(this.subMeshes)for(const t of this.subMeshes)for(let s=0;st.markAsLightDirty(e)))}_markSubMeshesAsAttributesDirty(){this._markSubMeshesAsDirty((e=>e.markAsAttributesDirty()))}_markSubMeshesAsMiscDirty(){this._markSubMeshesAsDirty((e=>e.markAsMiscDirty()))}markAsDirty(e){return this._currentRenderId=Number.MAX_VALUE,super.markAsDirty(e),this._isDirty=!0,this}resetDrawCache(e){if(this.subMeshes)for(const t of this.subMeshes)t.resetDrawCache(e)}get isBlocked(){return!1}getLOD(e){return this}getTotalVertices(){return 0}getTotalIndices(){return 0}getIndices(){return null}getVerticesData(e){return null}setVerticesData(e,t,s,i){return this}updateVerticesData(e,t,s,i){return this}setIndices(e,t){return this}isVerticesDataPresent(e){return!1}getBoundingInfo(){return this._masterMesh?this._masterMesh.getBoundingInfo():(this._boundingInfoIsDirty&&(this._boundingInfoIsDirty=!1,this._updateBoundingInfo()),this._boundingInfo)}getRawBoundingInfo(){return this.rawBoundingInfo??this.getBoundingInfo()}setBoundingInfo(e){return this._boundingInfo=e,this}get hasBoundingInfo(){return null!==this._boundingInfo}buildBoundingInfo(e,t,s){return this._boundingInfo=new c.j(e,t,s),this._boundingInfo}normalizeToUnitCube(e=!0,t=!1,s){return super.normalizeToUnitCube(e,t,s)}get useBones(){return this.skeleton&&this.getScene().skeletonsEnabled&&this.isVerticesDataPresent(a.R.MatricesIndicesKind)&&this.isVerticesDataPresent(a.R.MatricesWeightsKind)}_preActivate(){}_preActivateForIntermediateRendering(e){}_activate(e,t){return this._renderId=e,!0}_postActivate(){}_freeze(){}_unFreeze(){}getWorldMatrix(){return this._masterMesh&&this.billboardMode===h.V.BILLBOARDMODE_NONE?this._masterMesh.getWorldMatrix():super.getWorldMatrix()}_getWorldMatrixDeterminant(){return this._masterMesh?this._masterMesh._getWorldMatrixDeterminant():super._getWorldMatrixDeterminant()}get isAnInstance(){return!1}get hasInstances(){return!1}get hasThinInstances(){return!1}movePOV(e,t,s){return this.position.addInPlace(this.calcMovePOV(e,t,s)),this}calcMovePOV(e,t,s){const i=new n.uq;(this.rotationQuaternion?this.rotationQuaternion:n.PT.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z)).toRotationMatrix(i);const r=n.Pq.Zero(),a=this.definedFacingForward?-1:1;return n.Pq.TransformCoordinatesFromFloatsToRef(e*a,t,s*a,i,r),r}rotatePOV(e,t,s){return this.rotation.addInPlace(this.calcRotatePOV(e,t,s)),this}calcRotatePOV(e,t,s){const i=this.definedFacingForward?1:-1;return new n.Pq(e*i,t,s*i)}_refreshBoundingInfo(e,t){if(e){const s=(0,f.b8)(e,0,this.getTotalVertices(),t);this._boundingInfo?this._boundingInfo.reConstruct(s.minimum,s.maximum):this._boundingInfo=new c.j(s.minimum,s.maximum)}if(this.subMeshes)for(let t=0;t0&&(n.uq.FromFloat32ArrayToRefScaled(s,Math.floor(16*i[a+_]),f,u),c.addToSelf(u));if(o&&h)for(_=0;_<4;_++)f=h[a+_],f>0&&(n.uq.FromFloat32ArrayToRefScaled(s,Math.floor(16*o[a+_]),f,u),c.addToSelf(u));d(e[t],e[t+1],e[t+2],c,l),l.toArray(e,t)}}(e,t,s,i,r,o,h)}_getData(e,t,s=a.R.PositionKind){const i=e.cache,r=e=>{if(i){const t=i._vertexData||(i._vertexData={});return t[e]||this.copyVerticesData(e,t),t[e]}return this.getVerticesData(e)};if(t||(t=r(s)),!t)return null;if(i?(i._outputData?i._outputData.set(t):i._outputData=new Float32Array(t),t=i._outputData):(e.applyMorph&&this.morphTargetManager||e.applySkeleton&&this.skeleton)&&(t=t.slice()),e.applyMorph&&this.morphTargetManager&&function(e,t,s){let i=null;switch(t){case a.R.PositionKind:i=e=>e.getPositions();break;case a.R.NormalKind:i=e=>e.getNormals();break;case a.R.TangentKind:i=e=>e.getTangents();break;case a.R.UVKind:i=e=>e.getUVs();break;default:return}for(let t=0;t4,o=n?r(a.R.MatricesIndicesExtraKind):null,h=n?r(a.R.MatricesWeightsExtraKind):null,l=this.skeleton.getTransformMatrices(this);R._ApplySkeleton(t,s,l,e,i,o,h)}}if(!1!==e.updatePositionsArray&&s===a.R.PositionKind){const e=this._internalAbstractMeshDataInfo._positions||[],s=e.length;if(e.length=t.length/3,s1||!i.IsGlobal)&&i.updateBoundingInfo(e)}return this}_afterComputeWorldMatrix(){this.doNotSyncBoundingInfo||(this._boundingInfoIsDirty=!0)}isInFrustum(e){return this.getBoundingInfo().isInFrustum(e,this.cullingStrategy)}isCompletelyInFrustum(e){return this.getBoundingInfo().isCompletelyInFrustum(e)}intersectsMesh(e,t=!1,s){const i=this.getBoundingInfo(),r=e.getBoundingInfo();if(i.intersects(r,t))return!0;if(s)for(const s of this.getChildMeshes())if(s.intersectsMesh(e,t,!0))return!0;return!1}intersectsPoint(e){return this.getBoundingInfo().intersectsPoint(e)}get checkCollisions(){return this._internalAbstractMeshDataInfo._meshCollisionData._checkCollisions}set checkCollisions(e){this._internalAbstractMeshDataInfo._meshCollisionData._checkCollisions=e}get collider(){return this._internalAbstractMeshDataInfo._meshCollisionData._collider}moveWithCollisions(e){this.getAbsolutePosition().addToRef(this.ellipsoidOffset,this._internalAbstractMeshDataInfo._meshCollisionData._oldPositionForCollisions);const t=this.getScene().collisionCoordinator;return this._internalAbstractMeshDataInfo._meshCollisionData._collider||(this._internalAbstractMeshDataInfo._meshCollisionData._collider=t.createCollider()),this._internalAbstractMeshDataInfo._meshCollisionData._collider._radius=this.ellipsoid,t.getNewPosition(this._internalAbstractMeshDataInfo._meshCollisionData._oldPositionForCollisions,e,this._internalAbstractMeshDataInfo._meshCollisionData._collider,this.collisionRetryCount,this,this._onCollisionPositionChange,this.uniqueId),this}_collideForSubMesh(e,t,s){if(this._generatePointsArray(),!this._positions)return this;if(!e._lastColliderWorldVertices||!e._lastColliderTransformMatrix.equals(t)){e._lastColliderTransformMatrix=t.clone(),e._lastColliderWorldVertices=[],e._trianglePlanes=[];const s=e.verticesStart,i=e.verticesStart+e.verticesCount;for(let r=s;r1&&!n._checkCollision(e)||this._collideForSubMesh(n,t,e)}return this}_shouldConvertRHS(){return!1}_checkCollision(e){if(!this.getBoundingInfo()._checkCollision(e))return this;const t=n.AA.Matrix[0],s=n.AA.Matrix[1];return n.uq.ScalingToRef(1/e._radius.x,1/e._radius.y,1/e._radius.z,t),this.worldMatrixFromCache.multiplyToRef(t,s),this._processCollisionsForSubMeshes(e,s),this}_generatePointsArray(){return!1}intersects(e,t,s,i=!1,r,a=!1){const o=new l.G,h=this.getClassName(),c="InstancedLinesMesh"===h||"LinesMesh"===h||"GreasedLineMesh"===h?this.intersectionThreshold:0,u=this.getBoundingInfo();if(!this.subMeshes)return o;if(!(a||e.intersectsSphere(u.boundingSphere,c)&&e.intersectsBox(u.boundingBox,c)))return o;if(i)return o.hit=!a,o.pickedMesh=a?null:this,o.distance=a?0:n.Pq.Distance(e.origin,u.boundingSphere.center),o.subMeshId=0,o;if(!this._generatePointsArray())return o;let d=null;const _=this._scene.getIntersectingSubMeshCandidates(this,e),f=_.length;let p=!1;for(let e=0;e1&&!a&&!r.canIntersects(e))continue;const n=r.intersects(e,this._positions,this.getIndices(),t,s);if(n&&(t||!d||n.distancee!==this&&e.actionManager===this.actionManager))&&this.actionManager.dispose(),this.actionManager=null),this._internalAbstractMeshDataInfo._skeleton=null,this._transformMatrixTexture&&(this._transformMatrixTexture.dispose(),this._transformMatrixTexture=null),s=0;s{let t=e.includedOnlyMeshes.indexOf(this);-1!==t&&e.includedOnlyMeshes.splice(t,1),t=e.excludedMeshes.indexOf(this),-1!==t&&e.excludedMeshes.splice(t,1);const s=e.getShadowGenerators();if(s){const e=s.values();for(let s=e.next();!0!==s.done;s=e.next()){const e=s.value.getShadowMap();e&&e.renderList&&(t=e.renderList.indexOf(this),-1!==t&&e.renderList.splice(t,1))}}})),"InstancedMesh"===this.getClassName()&&"InstancedLinesMesh"===this.getClassName()||this.releaseSubMeshes();const r=i.getEngine();if(null!==this._occlusionQuery&&(this.isOcclusionQueryInProgress=!1,r.deleteQuery(this._occlusionQuery),this._occlusionQuery=null),r.wipeCaches(),i.removeMesh(this),this._parentContainer){const e=this._parentContainer.meshes.indexOf(this);e>-1&&this._parentContainer.meshes.splice(e,1),this._parentContainer=null}if(t&&this.material&&("MultiMaterial"===this.material.getClassName()?this.material.dispose(!1,!0,!0):this.material.dispose(!1,!0)),!e)for(s=0;s65535){t=!0;break}e.depthSortedIndices=t?new Uint32Array(s):new Uint16Array(s)}if(e.facetDepthSortFunction=function(e,t){return t.sqDistance-e.sqDistance},!e.facetDepthSortFrom){const t=this.getScene().activeCamera;e.facetDepthSortFrom=t?t.position:n.Pq.Zero()}e.depthSortedFacets=[];for(let t=0;tg.bH?r.maximum.x-r.minimum.x:g.bH,e.bbSize.y=r.maximum.y-r.minimum.y>g.bH?r.maximum.y-r.minimum.y:g.bH,e.bbSize.z=r.maximum.z-r.minimum.z>g.bH?r.maximum.z-r.minimum.z:g.bH;let h=e.bbSize.x>e.bbSize.y?e.bbSize.x:e.bbSize.y;if(h=h>e.bbSize.z?h:e.bbSize.z,e.subDiv.max=e.partitioningSubdivisions,e.subDiv.X=Math.floor(e.subDiv.max*e.bbSize.x/h),e.subDiv.Y=Math.floor(e.subDiv.max*e.bbSize.y/h),e.subDiv.Z=Math.floor(e.subDiv.max*e.bbSize.z/h),e.subDiv.X=e.subDiv.X<1?1:e.subDiv.X,e.subDiv.Y=e.subDiv.Y<1?1:e.subDiv.Y,e.subDiv.Z=e.subDiv.Z<1?1:e.subDiv.Z,e.facetParameters.facetNormals=this.getFacetLocalNormals(),e.facetParameters.facetPositions=this.getFacetLocalPositions(),e.facetParameters.facetPartitioning=this.getFacetLocalPartitioning(),e.facetParameters.bInfo=r,e.facetParameters.bbSize=e.bbSize,e.facetParameters.subDiv=e.subDiv,e.facetParameters.ratio=this.partitioningBBoxRatio,e.facetParameters.depthSort=e.facetDepthSort,e.facetDepthSort&&e.facetDepthSortEnabled&&(this.computeWorldMatrix(!0),this._worldMatrix.invertToRef(e.invertedMatrix),n.Pq.TransformCoordinatesToRef(e.facetDepthSortFrom,e.invertedMatrix,e.facetDepthSortOrigin),e.facetParameters.distanceTo=e.facetDepthSortOrigin),e.facetParameters.depthSortedFacets=e.depthSortedFacets,i&&o.P.ComputeNormals(t,s,i,e.facetParameters),e.facetDepthSort&&e.facetDepthSortEnabled){e.depthSortedFacets.sort(e.facetDepthSortFunction);const t=e.depthSortedIndices.length/3|0;for(let i=0;ir.subDiv.max||a<0||a>r.subDiv.max||o<0||o>r.subDiv.max?null:r.facetPartitioning[n+r.subDiv.max*a+r.subDiv.max*r.subDiv.max*o]}getClosestFacetAtCoordinates(e,t,s,i,r=!1,a=!0){const o=this.getWorldMatrix(),h=n.AA.Matrix[5];o.invertToRef(h);const l=n.AA.Vector3[8];n.Pq.TransformCoordinatesFromFloatsToRef(e,t,s,h,l);const c=this.getClosestFacetAtLocalCoordinates(l.x,l.y,l.z,i,r,a);return i&&n.Pq.TransformCoordinatesFromFloatsToRef(i.x,i.y,i.z,o,i),c}getClosestFacetAtLocalCoordinates(e,t,s,i,r=!1,n=!0){let a=null,o=0,h=0,l=0,c=0,u=0,d=0,_=0,f=0;const p=this.getFacetLocalPositions(),g=this.getFacetLocalNormals(),m=this.getFacetsAtLocalCoordinates(e,t,s);if(!m)return null;let T,b,E,x=Number.MAX_VALUE,A=x;for(let R=0;R=0||r&&!n&&c<=0)&&(c=b.x*E.x+b.y*E.y+b.z*E.z,u=-(b.x*e+b.y*t+b.z*s-c)/(b.x*b.x+b.y*b.y+b.z*b.z),d=e+b.x*u,_=t+b.y*u,f=s+b.z*u,o=d-e,h=_-t,l=f-s,A=o*o+h*h+l*l,Ae.emitter===this))}}R.OCCLUSION_TYPE_NONE=0,R.OCCLUSION_TYPE_OPTIMISTIC=1,R.OCCLUSION_TYPE_STRICT=2,R.OCCLUSION_ALGORITHM_TYPE_ACCURATE=0,R.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE=1,R.CULLINGSTRATEGY_STANDARD=0,R.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY=1,R.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION=2,R.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY=3,(0,i.Cg)([b.Cx.filter(((...[e,t,s,i,r])=>!(Array.isArray(e)||Array.isArray(t)||Array.isArray(s)||Array.isArray(i)||Array.isArray(r))))],R,"_ApplySkeleton",null),(0,T.Y5)("BABYLON.AbstractMesh",R)},1359:(e,t,s)=>{s.d(t,{V:()=>g});var i=s(9923),r=s(6041),n=s(6803),a=s(5616),o=s(1846),h=s(7597),l=s(2564),c=s(998),u=s(7503),d=s(1139),_=s(6315),f=s(1313),p=s(1137);class g{get boundingBias(){return this._boundingBias}set boundingBias(e){this._boundingBias?this._boundingBias.copyFrom(e):this._boundingBias=e.clone(),this._updateBoundingInfo(!0,null)}static CreateGeometryForMesh(e){const t=new g(g.RandomId(),e.getScene());return t.applyToMesh(e),t}get meshes(){return this._meshes}constructor(e,t,s,i=!1,r=null){this.delayLoadState=0,this._totalVertices=0,this._isDisposed=!1,this._indexBufferIsUpdatable=!1,this._positionsCache=[],this._parentContainer=null,this.useBoundingInfoFromGeometry=!1,this._scene=t||_.q.LastCreatedScene,this._scene&&(this.id=e,this.uniqueId=this._scene.getUniqueId(),this._engine=this._scene.getEngine(),this._meshes=[],this._vertexBuffers={},this._indices=[],this._updatable=i,s?this.setAllVerticesData(s,i):this._totalVertices=0,this._engine.getCaps().vertexArrayObject&&(this._vertexArrayObjects={}),r&&(this.applyToMesh(r),r.computeWorldMatrix(!0)))}get extend(){return this._extend}getScene(){return this._scene}getEngine(){return this._engine}isReady(){return 1===this.delayLoadState||0===this.delayLoadState}get doNotSerialize(){for(let e=0;e{e._rebuild()}))}setAllVerticesData(e,t){e.applyToGeometry(this,t),this._notifyUpdate()}setVerticesData(e,t,s=!1,i){s&&Array.isArray(t)&&(t=new Float32Array(t));const r=new a.R(this._engine,t,e,{updatable:s,postponeInternalCreation:0===this._meshes.length,stride:i,label:"Geometry_"+this.id+"_"+e});this.setVerticesBuffer(r)}removeVerticesData(e){this._vertexBuffers[e]&&(this._vertexBuffers[e].dispose(),delete this._vertexBuffers[e]),this._vertexArrayObjects&&this._disposeVertexArrayObjects()}setVerticesBuffer(e,t=null,s=!0){const r=e.getKind();this._vertexBuffers[r]&&s&&this._vertexBuffers[r].dispose(),e._buffer&&e._buffer._increaseReferences(),this._vertexBuffers[r]=e;const n=this._meshes,o=n.length;if(r===a.R.PositionKind){this._totalVertices=t??e._maxVerticesCount,this._updateExtend(e.getFloatData(this._totalVertices)),this._resetPointsArrayCache();const s=this._extend&&this._extend.minimum||new i.Pq(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),r=this._extend&&this._extend.maximum||new i.Pq(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE);for(let e=0;eh[t]=e))}(i,s.getSize(),s.type,s.byteOffset,s.byteStride,s.normalized,this._totalVertices,t[e])}isVertexBufferUpdatable(e){const t=this._vertexBuffers[e];return!!t&&t.isUpdatable()}getVertexBuffer(e){return this.isReady()?this._vertexBuffers[e]:null}getVertexBuffers(){return this.isReady()?this._vertexBuffers:null}isVerticesDataPresent(e){return this._vertexBuffers?void 0!==this._vertexBuffers[e]:!!this._delayInfo&&-1!==this._delayInfo.indexOf(e)}getVerticesDataKinds(){const e=[];let t;if(!this._vertexBuffers&&this._delayInfo)for(t in this._delayInfo)e.push(t);else for(t in this._vertexBuffers)e.push(t);return e}updateIndices(e,t,s=!1){if(this._indexBuffer)if(this._indexBufferIsUpdatable){const i=e.length!==this._indices.length;if(s||(this._indices=e.slice()),this._engine.updateDynamicIndexBuffer(this._indexBuffer,e,t),i)for(const e of this._meshes)e._createGlobalSubMesh(!0)}else this.setIndices(e,null,!0)}setIndexBuffer(e,t,s){this._indices=[],this._indexBufferIsUpdatable=!1,this._indexBuffer=e,this._totalVertices=t,this._totalIndices=s,e.is32Bits||(e.is32Bits=this._totalIndices>65535);for(const e of this._meshes)e._createGlobalSubMesh(!0),e.synchronizeInstances();this._notifyUpdate()}setIndices(e,t=null,s=!1,i=!1){this._indexBuffer&&this._engine._releaseBuffer(this._indexBuffer),this._indices=e,this._indexBufferIsUpdatable=s,0!==this._meshes.length&&this._indices&&(this._indexBuffer=this._engine.createIndexBuffer(this._indices,s,"Geometry_"+this.id+"_IndexBuffer")),null!=t&&(this._totalVertices=t);for(const e of this._meshes)e._createGlobalSubMesh(!i),e.synchronizeInstances();this._notifyUpdate()}getTotalIndices(){return this.isReady()?void 0!==this._totalIndices?this._totalIndices:this._indices.length:0}getIndices(e,t){if(!this.isReady())return null;const s=this._indices;return t||e&&1!==this._meshes.length?s.slice():s}getIndexBuffer(){return this.isReady()?this._indexBuffer:null}_releaseVertexArrayObject(e=null){e&&this._vertexArrayObjects&&this._vertexArrayObjects[e.key]&&(this._engine.releaseVertexArrayObject(this._vertexArrayObjects[e.key]),delete this._vertexArrayObjects[e.key])}releaseForMesh(e,t){const s=this._meshes,i=s.indexOf(e);-1!==i&&(s.splice(i,1),this._vertexArrayObjects&&e._invalidateInstanceVertexArrayObject(),e._geometry=null,0===s.length&&t&&this.dispose())}applyToMesh(e){if(e._geometry===this)return;const t=e._geometry;t&&t.releaseForMesh(e),this._vertexArrayObjects&&e._invalidateInstanceVertexArrayObject();const s=this._meshes;e._geometry=this,e._internalAbstractMeshDataInfo._positions=null,this._scene.pushGeometry(this),s.push(e),this.isReady()?this._applyToMesh(e):this._boundingInfo&&e.setBoundingInfo(this._boundingInfo)}_updateExtend(e=null){if(this.useBoundingInfoFromGeometry&&this._boundingInfo)this._extend={minimum:this._boundingInfo.minimum.clone(),maximum:this._boundingInfo.maximum.clone()};else{if(!e&&!(e=this.getVerticesData(a.R.PositionKind)))return;this._extend=(0,d.b8)(e,0,this._totalVertices,this.boundingBias,3)}}_applyToMesh(e){const t=this._meshes.length;for(const s in this._vertexBuffers)1===t&&this._vertexBuffers[s].create(),s===a.R.PositionKind&&(this._extend||this._updateExtend(),e.buildBoundingInfo(this._extend.minimum,this._extend.maximum),e._createGlobalSubMesh(e.isUnIndexed),e._updateBoundingInfo());1===t&&this._indices&&this._indices.length>0&&(this._indexBuffer=this._engine.createIndexBuffer(this._indices,this._updatable,"Geometry_"+this.id+"_IndexBuffer")),e._syncGeometryWithMorphTargetManager(),e.synchronizeInstances()}_notifyUpdate(e){this.onGeometryUpdated&&this.onGeometryUpdated(this,e),this._vertexArrayObjects&&this._disposeVertexArrayObjects();for(const e of this._meshes)e._markSubMeshesAsAttributesDirty()}load(e,t){2!==this.delayLoadState&&(this.isReady()?t&&t():(this.delayLoadState=2,this._queueLoad(e,t)))}_queueLoad(e,t){this.delayLoadingFile&&(e.addPendingData(this),e._loadFile(this.delayLoadingFile,(s=>{if(!this._delayLoadingFunction)return;this._delayLoadingFunction(JSON.parse(s),this),this.delayLoadState=1,this._delayInfo=[],e.removePendingData(this);const i=this._meshes,r=i.length;for(let e=0;e0){for(let t=0;t0){for(let e=0;e0){for(let e=0;e-1&&this._parentContainer.geometries.splice(e,1),this._parentContainer=null}this._isDisposed=!0}copy(e){const t=new n.P;t.indices=[];const s=this.getIndices();if(s)for(let e=0;e0){const i=new Float32Array(e,s.positionsAttrDesc.offset,s.positionsAttrDesc.count);t.setVerticesData(a.R.PositionKind,i,!1)}if(s.normalsAttrDesc&&s.normalsAttrDesc.count>0){const i=new Float32Array(e,s.normalsAttrDesc.offset,s.normalsAttrDesc.count);t.setVerticesData(a.R.NormalKind,i,!1)}if(s.tangetsAttrDesc&&s.tangetsAttrDesc.count>0){const i=new Float32Array(e,s.tangetsAttrDesc.offset,s.tangetsAttrDesc.count);t.setVerticesData(a.R.TangentKind,i,!1)}if(s.uvsAttrDesc&&s.uvsAttrDesc.count>0){const i=new Float32Array(e,s.uvsAttrDesc.offset,s.uvsAttrDesc.count);if(f.rX)for(let e=1;e0){const i=new Float32Array(e,s.uvs2AttrDesc.offset,s.uvs2AttrDesc.count);if(f.rX)for(let e=1;e0){const i=new Float32Array(e,s.uvs3AttrDesc.offset,s.uvs3AttrDesc.count);if(f.rX)for(let e=1;e0){const i=new Float32Array(e,s.uvs4AttrDesc.offset,s.uvs4AttrDesc.count);if(f.rX)for(let e=1;e0){const i=new Float32Array(e,s.uvs5AttrDesc.offset,s.uvs5AttrDesc.count);if(f.rX)for(let e=1;e0){const i=new Float32Array(e,s.uvs6AttrDesc.offset,s.uvs6AttrDesc.count);if(f.rX)for(let e=1;e0){const i=new Float32Array(e,s.colorsAttrDesc.offset,s.colorsAttrDesc.count);t.setVerticesData(a.R.ColorKind,i,!1,s.colorsAttrDesc.stride)}if(s.matricesIndicesAttrDesc&&s.matricesIndicesAttrDesc.count>0){const i=new Int32Array(e,s.matricesIndicesAttrDesc.offset,s.matricesIndicesAttrDesc.count),r=[];for(let e=0;e>8),r.push((16711680&t)>>16),r.push(t>>24&255)}t.setVerticesData(a.R.MatricesIndicesKind,r,!1)}if(s.matricesIndicesExtraAttrDesc&&s.matricesIndicesExtraAttrDesc.count>0){const i=new Int32Array(e,s.matricesIndicesExtraAttrDesc.offset,s.matricesIndicesExtraAttrDesc.count),r=[];for(let e=0;e>8),r.push((16711680&t)>>16),r.push(t>>24&255)}t.setVerticesData(a.R.MatricesIndicesExtraKind,r,!1)}if(s.matricesWeightsAttrDesc&&s.matricesWeightsAttrDesc.count>0){const i=new Float32Array(e,s.matricesWeightsAttrDesc.offset,s.matricesWeightsAttrDesc.count);t.setVerticesData(a.R.MatricesWeightsKind,i,!1)}if(s.indicesAttrDesc&&s.indicesAttrDesc.count>0){const i=new Int32Array(e,s.indicesAttrDesc.offset,s.indicesAttrDesc.count);t.setIndices(i,null)}if(s.subMeshesAttrDesc&&s.subMeshesAttrDesc.count>0){const i=new Int32Array(e,s.subMeshesAttrDesc.offset,5*s.subMeshesAttrDesc.count);t.subMeshes=[];for(let e=0;e>8),s.push((16711680&i)>>16),s.push(i>>24&255)}t.setVerticesData(a.R.MatricesIndicesKind,s,e.matricesIndices._updatable)}if(e.matricesIndicesExtra)if(e.matricesIndicesExtra._isExpanded)delete e.matricesIndices._isExpanded,t.setVerticesData(a.R.MatricesIndicesExtraKind,e.matricesIndicesExtra,e.matricesIndicesExtra._updatable);else{const s=[];for(let t=0;t>8),s.push((16711680&i)>>16),s.push(i>>24&255)}t.setVerticesData(a.R.MatricesIndicesExtraKind,s,e.matricesIndicesExtra._updatable)}e.matricesWeights&&(g._CleanMatricesWeights(e,t),t.setVerticesData(a.R.MatricesWeightsKind,e.matricesWeights,e.matricesWeights._updatable)),e.matricesWeightsExtra&&t.setVerticesData(a.R.MatricesWeightsExtraKind,e.matricesWeightsExtra,e.matricesWeights._updatable),t.setIndices(e.indices,null)}if(e.subMeshes){t.subMeshes=[];for(let s=0;s-1))return;{const s=t.getScene().getLastSkeletonById(e.skeletonId);if(!s)return;i=s.bones.length}const r=t.getVerticesData(a.R.MatricesIndicesKind),n=t.getVerticesData(a.R.MatricesIndicesExtraKind),o=e.matricesWeights,l=e.matricesWeightsExtra,c=e.numBoneInfluencer,u=o.length;for(let e=0;ec-1)&&(a=c-1),t>s){const s=1/t;for(let t=0;t<4;t++)o[e+t]*=s;if(l)for(let t=0;t<4;t++)l[e+t]*=s}else a>=4?(l[e+a-4]=1-t,n[e+a-4]=i):(o[e+a]=1-t,r[e+a]=i)}t.setVerticesData(a.R.MatricesIndicesKind,r),e.matricesWeightsExtra&&t.setVerticesData(a.R.MatricesIndicesExtraKind,n)}static Parse(e,t,s){const r=new g(e.id,t,void 0,e.updatable);return r._loadedUniqueId=e.uniqueId,u.Y&&u.Y.AddTagsTo(r,e.tags),e.delayLoadingFile?(r.delayLoadState=4,r.delayLoadingFile=s+e.delayLoadingFile,r._boundingInfo=new l.j(i.Pq.FromArray(e.boundingBoxMinimum),i.Pq.FromArray(e.boundingBoxMaximum)),r._delayInfo=[],e.hasUVs&&r._delayInfo.push(a.R.UVKind),e.hasUVs2&&r._delayInfo.push(a.R.UV2Kind),e.hasUVs3&&r._delayInfo.push(a.R.UV3Kind),e.hasUVs4&&r._delayInfo.push(a.R.UV4Kind),e.hasUVs5&&r._delayInfo.push(a.R.UV5Kind),e.hasUVs6&&r._delayInfo.push(a.R.UV6Kind),e.hasColors&&r._delayInfo.push(a.R.ColorKind),e.hasMatricesIndices&&r._delayInfo.push(a.R.MatricesIndicesKind),e.hasMatricesWeights&&r._delayInfo.push(a.R.MatricesWeightsKind),r._delayLoadingFunction=n.P.ImportVertexData):n.P.ImportVertexData(e,r),t.pushGeometry(r,!0),r}}},5530:(e,t,s)=>{s.d(t,{e:()=>I});var i=s(9848),r=s(998),n=s(4609),a=s(7503),o=s(163),h=s(388),l=s(9923),c=s(6041),u=s(4870),d=s(5616),_=s(6803),f=s(1359),p=s(861),g=s(1846),m=s(8986),T=s(6552);class b extends m.i{get subMaterials(){return this._subMaterials}set subMaterials(e){this._subMaterials=e,this._hookArray(e)}getChildren(){return this.subMaterials}constructor(e,t){super(e,t,!0),this._waitingSubMaterialsUniqueIds=[],this.getScene().addMultiMaterial(this),this.subMaterials=[],this._storeEffectOnSubMeshes=!0}_hookArray(e){const t=e.push;e.push=(...s)=>{const i=t.apply(e,s);return this._markAllSubMeshesAsTexturesDirty(),i};const s=e.splice;e.splice=(t,i)=>{const r=s.apply(e,[t,i]);return this._markAllSubMeshesAsTexturesDirty(),r}}getSubMaterial(e){return e<0||e>=this.subMaterials.length?this.getScene().defaultMaterial:this.subMaterials[e]}getActiveTextures(){return super.getActiveTextures().concat(...this.subMaterials.map((e=>e?e.getActiveTextures():[])))}hasTexture(e){if(super.hasTexture(e))return!0;for(let t=0;t=0&&i.multiMaterials.splice(r,1),super.dispose(e,t)}static ParseMultiMaterial(e,t){const s=new b(e.name,t);return s.id=e.id,s._loadedUniqueId=e.uniqueId,a.Y&&a.Y.AddTagsTo(s,e.tags),e.materialsUniqueIds?s._waitingSubMaterialsUniqueIds=e.materialsUniqueIds:e.materials.forEach((e=>s.subMaterials.push(t.getLastMaterialById(e)))),s}}(0,T.Y5)("BABYLON.MultiMaterial",b);var E=s(7597),x=s(6877),A=s(1137),R=s(5503),M=s(6945);class y{constructor(e,t){this.distanceOrScreenCoverage=e,this.mesh=t}}class P{constructor(){this.visibleInstances={},this.batchCache=new v,this.batchCacheReplacementModeInFrozenMode=new v,this.instancesBufferSize=2048}}class v{constructor(){this.mustReturn=!1,this.visibleInstances=new Array,this.renderSelf=[],this.hardwareInstancedRendering=[]}}class C{constructor(){this.instancesCount=0,this.matrixBuffer=null,this.previousMatrixBuffer=null,this.matrixBufferSize=512,this.matrixData=null,this.boundingVectors=[],this.worldMatrices=null}}class S{constructor(){this._areNormalsFrozen=!1,this._source=null,this.meshMap=null,this._preActivateId=-1,this._LODLevels=new Array,this._useLODScreenCoverage=!1,this._effectiveMaterial=null,this._forcedInstanceCount=0,this._overrideRenderingFillMode=null}}class I extends p.u{static _GetDefaultSideOrientation(e){return e||I.FRONTSIDE}get useLODScreenCoverage(){return this._internalMeshDataInfo._useLODScreenCoverage}set useLODScreenCoverage(e){this._internalMeshDataInfo._useLODScreenCoverage=e,this._sortLODLevels()}get computeBonesUsingShaders(){return this._internalAbstractMeshDataInfo._computeBonesUsingShaders}set computeBonesUsingShaders(e){this._internalAbstractMeshDataInfo._computeBonesUsingShaders!==e&&(e&&this._internalMeshDataInfo._sourcePositions&&(this.setVerticesData(d.R.PositionKind,this._internalMeshDataInfo._sourcePositions,!0),this._internalMeshDataInfo._sourceNormals&&this.setVerticesData(d.R.NormalKind,this._internalMeshDataInfo._sourceNormals,!0),this._internalMeshDataInfo._sourcePositions=null,this._internalMeshDataInfo._sourceNormals=null),this._internalAbstractMeshDataInfo._computeBonesUsingShaders=e,this._markSubMeshesAsAttributesDirty())}get onBeforeRenderObservable(){return this._internalMeshDataInfo._onBeforeRenderObservable||(this._internalMeshDataInfo._onBeforeRenderObservable=new i.cP),this._internalMeshDataInfo._onBeforeRenderObservable}get onBeforeBindObservable(){return this._internalMeshDataInfo._onBeforeBindObservable||(this._internalMeshDataInfo._onBeforeBindObservable=new i.cP),this._internalMeshDataInfo._onBeforeBindObservable}get onAfterRenderObservable(){return this._internalMeshDataInfo._onAfterRenderObservable||(this._internalMeshDataInfo._onAfterRenderObservable=new i.cP),this._internalMeshDataInfo._onAfterRenderObservable}get onBetweenPassObservable(){return this._internalMeshDataInfo._onBetweenPassObservable||(this._internalMeshDataInfo._onBetweenPassObservable=new i.cP),this._internalMeshDataInfo._onBetweenPassObservable}get onBeforeDrawObservable(){return this._internalMeshDataInfo._onBeforeDrawObservable||(this._internalMeshDataInfo._onBeforeDrawObservable=new i.cP),this._internalMeshDataInfo._onBeforeDrawObservable}set onBeforeDraw(e){this._onBeforeDrawObserver&&this.onBeforeDrawObservable.remove(this._onBeforeDrawObserver),this._onBeforeDrawObserver=this.onBeforeDrawObservable.add(e)}get hasInstances(){return this.instances.length>0}get hasThinInstances(){return(this.forcedInstanceCount||this._thinInstanceDataStorage.instancesCount||0)>0}get forcedInstanceCount(){return this._internalMeshDataInfo._forcedInstanceCount}set forcedInstanceCount(e){this._internalMeshDataInfo._forcedInstanceCount=e}get sideOrientation(){return this._internalMeshDataInfo._sideOrientation}set sideOrientation(e){this._internalMeshDataInfo._sideOrientation=e,this._internalAbstractMeshDataInfo._sideOrientationHint=this._scene.useRightHandedSystem&&1===e||!this._scene.useRightHandedSystem&&0===e}get overrideMaterialSideOrientation(){return this.sideOrientation}set overrideMaterialSideOrientation(e){this.sideOrientation=e,this.material&&(this.material.sideOrientation=null)}get overrideRenderingFillMode(){return this._internalMeshDataInfo._overrideRenderingFillMode}set overrideRenderingFillMode(e){this._internalMeshDataInfo._overrideRenderingFillMode=e}get material(){return this._internalAbstractMeshDataInfo._material}set material(e){e&&(this.material&&null===this.material.sideOrientation||this._internalAbstractMeshDataInfo._sideOrientationHint)&&(e.sideOrientation=null),this._setMaterial(e)}get source(){return this._internalMeshDataInfo._source}get cloneMeshMap(){return this._internalMeshDataInfo.meshMap}get isUnIndexed(){return this._unIndexed}set isUnIndexed(e){this._unIndexed!==e&&(this._unIndexed=e,this._markSubMeshesAsAttributesDirty())}get worldMatrixInstancedBuffer(){return this._instanceDataStorage.instancesData}get previousWorldMatrixInstancedBuffer(){return this._instanceDataStorage.instancesPreviousData}get manualUpdateOfWorldMatrixInstancedBuffer(){return this._instanceDataStorage.manualUpdate}set manualUpdateOfWorldMatrixInstancedBuffer(e){this._instanceDataStorage.manualUpdate=e}get manualUpdateOfPreviousWorldMatrixInstancedBuffer(){return this._instanceDataStorage.previousManualUpdate}set manualUpdateOfPreviousWorldMatrixInstancedBuffer(e){this._instanceDataStorage.previousManualUpdate=e}get forceWorldMatrixInstancedBufferUpdate(){return this._instanceDataStorage.forceMatrixUpdates}set forceWorldMatrixInstancedBufferUpdate(e){this._instanceDataStorage.forceMatrixUpdates=e}_copySource(e,t,s=!0){const i=this.getScene();if(e._geometry&&e._geometry.applyToMesh(this),n.r.DeepCopy(e,this,["name","material","skeleton","instances","parent","uniqueId","source","metadata","morphTargetManager","hasInstances","worldMatrixInstancedBuffer","previousWorldMatrixInstancedBuffer","hasLODLevels","geometry","isBlocked","areNormalsFrozen","facetNb","isFacetDataEnabled","lightSources","useBones","isAnInstance","collider","edgesRenderer","forward","up","right","absolutePosition","absoluteScaling","absoluteRotationQuaternion","isWorldMatrixFrozen","nonUniformScaling","behaviors","worldMatrixFromCache","hasThinInstances","cloneMeshMap","hasBoundingInfo","physicsBody","physicsImpostor"],["_poseMatrix"]),this._internalMeshDataInfo._source=e,i.useClonedMeshMap&&(e._internalMeshDataInfo.meshMap||(e._internalMeshDataInfo.meshMap={}),e._internalMeshDataInfo.meshMap[this.uniqueId]=this),this._originalBuilderSideOrientation=e._originalBuilderSideOrientation,this._creationDataStorage=e._creationDataStorage,e._ranges){const t=e._ranges;for(const e in t)Object.prototype.hasOwnProperty.call(t,e)&&t[e]&&this.createAnimationRange(e,t[e].from,t[e].to)}if(e.metadata&&e.metadata.clone?this.metadata=e.metadata.clone():this.metadata=e.metadata,this._internalMetadata=e._internalMetadata,a.Y&&a.Y.HasTags(e)&&a.Y.AddTagsTo(this,a.Y.GetTags(e,!0)),this.setEnabled(e.isEnabled(!1)),this.parent=e.parent,this.setPivotMatrix(e.getPivotMatrix(),this._postMultiplyPivotMatrix),this.id=this.name+"."+e.id,this.material=e.material,!t){const t=e.getDescendants(!0);for(let e=0;e{e&&s&&(this._uniformBuffer?this.transferToEffect(t):s.bindOnlyWorldMatrix(t))},r&&this._copySource(r,n,a),null!==s&&(this.parent=s),this._instanceDataStorage.hardwareInstancedRendering=this.getEngine().getCaps().instancedArrays,this._internalMeshDataInfo._onMeshReadyObserverAdded=e=>{e.unregisterOnNextCall=!0,this.isReady(!0)?this.onMeshReadyObservable.notifyObservers(this):this._internalMeshDataInfo._checkReadinessObserver||(this._internalMeshDataInfo._checkReadinessObserver=this._scene.onBeforeRenderObservable.add((()=>{this.isReady(!0)&&(this._scene.onBeforeRenderObservable.remove(this._internalMeshDataInfo._checkReadinessObserver),this._internalMeshDataInfo._checkReadinessObserver=null,this.onMeshReadyObservable.notifyObservers(this))})))},this.onMeshReadyObservable=new i.cP(this._internalMeshDataInfo._onMeshReadyObserverAdded),r&&r.onClonedObservable.notifyObservers(this)}instantiateHierarchy(e=null,t,s){const i=0===this.getTotalVertices()||t&&t.doNotInstantiate&&(!0===t.doNotInstantiate||t.doNotInstantiate(this))?this.clone("Clone of "+(this.name||this.id),e||this.parent,!0):this.createInstance("instance of "+(this.name||this.id));i.parent=e||this.parent,i.position=this.position.clone(),i.scaling=this.scaling.clone(),this.rotationQuaternion?i.rotationQuaternion=this.rotationQuaternion.clone():i.rotation=this.rotation.clone(),s&&s(this,i);for(const e of this.getChildTransformNodes(!0))"InstancedMesh"===e.getClassName()&&"Mesh"===i.getClassName()&&e.sourceMesh===this?e.instantiateHierarchy(i,{doNotInstantiate:t&&t.doNotInstantiate||!1,newSourcedMesh:i},s):e.instantiateHierarchy(i,t,s);return i}getClassName(){return"Mesh"}get _isMesh(){return!0}toString(e){let t=super.toString(e);if(t+=", n vertices: "+this.getTotalVertices(),t+=", parent: "+(this._waitingParentId?this._waitingParentId:this.parent?this.parent.name:"NONE"),this.animations)for(let s=0;s0}getLODLevels(){return this._internalMeshDataInfo._LODLevels}_sortLODLevels(){const e=this._internalMeshDataInfo._useLODScreenCoverage?-1:1;this._internalMeshDataInfo._LODLevels.sort(((t,s)=>t.distanceOrScreenCoverages.distanceOrScreenCoverage?-e:0))}addLODLevel(e,t){if(t&&t._masterMesh)return A.V.Warn("You cannot use a mesh as LOD level twice"),this;const s=new y(e,t);return this._internalMeshDataInfo._LODLevels.push(s),t&&(t._masterMesh=this),this._sortLODLevels(),this}getLODLevelAtDistance(e){const t=this._internalMeshDataInfo;for(let s=0;sa*n)return this.onLODLevelSelection&&this.onLODLevelSelection(n,this,this),this;for(let e=0;e0||this.hasThinInstances);this.computeWorldMatrix();const n=this.material||i.defaultMaterial;if(n)if(n._storeEffectOnSubMeshes)for(const e of this.subMeshes){const t=e.getMaterial();if(t)if(t._storeEffectOnSubMeshes){if(!t.isReadyForSubMesh(this,e,r))return!1}else if(!t.isReady(this,r))return!1}else if(!n.isReady(this,r))return!1;const a=s.currentRenderPassId;for(const e of this.lightSources){const t=e.getShadowGenerators();if(!t)continue;const i=t.values();for(let e=i.next();!0!==e.done;e=i.next()){const t=e.value;if(t&&(!t.getShadowMap()?.renderList||t.getShadowMap()?.renderList&&-1!==t.getShadowMap()?.renderList?.indexOf(this))){const e=t.getShadowMap().renderPassIds??[s.currentRenderPassId];for(let i=0;i0){const s=this.getIndices();if(!s)return null;const i=s.length;let r=!1;if(e)r=!0;else for(const e of this.subMeshes){if(e.indexStart+e.indexCount>i){r=!0;break}if(e.verticesStart+e.verticesCount>t){r=!0;break}}if(!r)return this.subMeshes[0]}return this.releaseSubMeshes(),new g.K(0,0,t,0,this.getTotalIndices(),this)}subdivide(e){if(e<1)return;const t=this.getTotalIndices();let s=t/e|0,i=0;for(;s%3!=0;)s++;this.releaseSubMeshes();for(let r=0;r=t);r++)g.K.CreateFromIndices(0,i,r===e-1?t-i:s,this,void 0,!1),i+=s;this.refreshBoundingInfo(),this.synchronizeInstances()}setVerticesData(e,t,s=!1,i){if(this._geometry)this._geometry.setVerticesData(e,t,s,i);else{const i=new _.P;i.set(t,e);const r=this.getScene();new f.V(f.V.RandomId(),r,i,s,this)}return this}removeVerticesData(e){this._geometry&&this._geometry.removeVerticesData(e)}markVerticesDataAsUpdatable(e,t=!0){const s=this.getVertexBuffer(e);s&&s.isUpdatable()!==t&&this.setVerticesData(e,this.getVerticesData(e),t)}setVerticesBuffer(e,t=!0){return this._geometry||(this._geometry=f.V.CreateGeometryForMesh(this)),this._geometry.setVerticesBuffer(e,null,t),this}updateVerticesData(e,t,s,i){return this._geometry?(i?(this.makeGeometryUnique(),this.updateVerticesData(e,t,s,!1)):this._geometry.updateVerticesData(e,t,s),this):this}updateMeshPositions(e,t=!0){const s=this.getVerticesData(d.R.PositionKind);if(!s)return this;if(e(s),this.updateVerticesData(d.R.PositionKind,s,!1,!1),t){const e=this.getIndices(),t=this.getVerticesData(d.R.NormalKind);if(!t)return this;_.P.ComputeNormals(s,e,t),this.updateVerticesData(d.R.NormalKind,t,!1,!1)}return this}makeGeometryUnique(){if(!this._geometry)return this;if(1===this._geometry.meshes.length)return this;const e=this._geometry,t=this._geometry.copy(f.V.RandomId());return e.releaseForMesh(this,!0),t.applyToMesh(this),this}setIndexBuffer(e,t,s){let i=this._geometry;i||(i=new f.V(f.V.RandomId(),this.getScene(),void 0,void 0,this)),i.setIndexBuffer(e,t,s)}setIndices(e,t=null,s=!1,i=!1){if(this._geometry)this._geometry.setIndices(e,t,s,i);else{const t=new _.P;t.indices=e;const i=this.getScene();new f.V(f.V.RandomId(),i,t,s,this)}return this}updateIndices(e,t,s=!1){return this._geometry?(this._geometry.updateIndices(e,t,s),this):this}toLeftHanded(){return this._geometry?(this._geometry.toLeftHanded(),this):this}_bind(e,t,s,i=!0){if(!this._geometry)return this;const r=this.getScene().getEngine();let n;if(this._unIndexed)n=this._getRenderingFillMode(s)===m.i.WireFrameFillMode?e._getLinesIndexBuffer(this.getIndices(),r):null;else switch(this._getRenderingFillMode(s)){case m.i.PointFillMode:n=null;break;case m.i.WireFrameFillMode:n=e._getLinesIndexBuffer(this.getIndices(),r);break;default:case m.i.TriangleFillMode:n=this._geometry.getIndexBuffer()}return this._bindDirect(t,n,i)}_bindDirect(e,t,s=!0){return this._geometry?(this.morphTargetManager&&this.morphTargetManager.isUsingTextureForTargets&&this.morphTargetManager._bind(e),s&&this._userInstancedBuffersStorage&&!this.hasThinInstances?this._geometry._bind(e,t,this._userInstancedBuffersStorage.vertexBuffers,this._userInstancedBuffersStorage.vertexArrayObjects):this._geometry._bind(e,t),this):this}_draw(e,t,s){if(!this._geometry||!this._geometry.getVertexBuffers()||!this._unIndexed&&!this._geometry.getIndexBuffer())return this;this._internalMeshDataInfo._onBeforeDrawObservable&&this._internalMeshDataInfo._onBeforeDrawObservable.notifyObservers(this);const i=this.getScene().getEngine();return this._unIndexed&&t!==m.i.WireFrameFillMode||t==m.i.PointFillMode?i.drawArraysType(t,e.verticesStart,e.verticesCount,this.forcedInstanceCount||s):t==m.i.WireFrameFillMode?i.drawElementsType(t,0,e._linesIndexCount,this.forcedInstanceCount||s):i.drawElementsType(t,e.indexStart,e.indexCount,this.forcedInstanceCount||s),this}registerBeforeRender(e){return this.onBeforeRenderObservable.add(e),this}unregisterBeforeRender(e){return this.onBeforeRenderObservable.removeCallback(e),this}registerAfterRender(e){return this.onAfterRenderObservable.add(e),this}unregisterAfterRender(e){return this.onAfterRenderObservable.removeCallback(e),this}_getInstancesRenderList(e,t=!1){if(this._instanceDataStorage.isFrozen){if(t)return this._instanceDataStorage.batchCacheReplacementModeInFrozenMode.hardwareInstancedRendering[e]=!1,this._instanceDataStorage.batchCacheReplacementModeInFrozenMode.renderSelf[e]=!0,this._instanceDataStorage.batchCacheReplacementModeInFrozenMode;if(this._instanceDataStorage.previousBatch)return this._instanceDataStorage.previousBatch}const s=this.getScene(),i=s._isInIntermediateRendering(),r=i?this._internalAbstractMeshDataInfo._onlyForInstancesIntermediate:this._internalAbstractMeshDataInfo._onlyForInstances,n=this._instanceDataStorage.batchCache;if(n.mustReturn=!1,n.renderSelf[e]=t||!r&&this.isEnabled()&&this.isVisible,n.visibleInstances[e]=null,this._instanceDataStorage.visibleInstances&&!t){const t=this._instanceDataStorage.visibleInstances,r=s.getRenderId(),a=i?t.intermediateDefaultRenderId:t.defaultRenderId;n.visibleInstances[e]=t[r],!n.visibleInstances[e]&&a&&(n.visibleInstances[e]=t[a])}return n.hardwareInstancedRendering[e]=!t&&this._instanceDataStorage.hardwareInstancedRendering&&null!==n.visibleInstances[e]&&void 0!==n.visibleInstances[e],this._instanceDataStorage.previousBatch=n,n}_renderWithInstances(e,t,s,i,r){const n=s.visibleInstances[e._id],a=n?n.length:0,o=this._instanceDataStorage,h=o.instancesBufferSize;let c=o.instancesBuffer,u=o.instancesPreviousBuffer;const _=16*(a+1)*4;for(;o.instancesBufferSize<_;)o.instancesBufferSize*=2;o.instancesData&&h==o.instancesBufferSize||(o.instancesData=new Float32Array(o.instancesBufferSize/4)),(this._scene.needsPreviousWorldMatrices&&!o.instancesPreviousData||h!=o.instancesBufferSize)&&(o.instancesPreviousData=new Float32Array(o.instancesBufferSize/4));let f=0,p=0;const g=s.renderSelf[e._id],m=!c||h!==o.instancesBufferSize||this._scene.needsPreviousWorldMatrices&&!o.instancesPreviousBuffer;if(this._instanceDataStorage.manualUpdate||o.isFrozen&&!m)p=(g?1:0)+a;else{const t=this.getWorldMatrix();if(g&&(this._scene.needsPreviousWorldMatrices&&(o.masterMeshPreviousWorldMatrix?(o.masterMeshPreviousWorldMatrix.copyToArray(o.instancesPreviousData,f),o.masterMeshPreviousWorldMatrix.copyFrom(t)):(o.masterMeshPreviousWorldMatrix=t.clone(),o.masterMeshPreviousWorldMatrix.copyToArray(o.instancesPreviousData,f))),t.copyToArray(o.instancesData,f),f+=16,p++),n){if(I.INSTANCEDMESH_SORT_TRANSPARENT&&this._scene.activeCamera&&e.getMaterial()?.needAlphaBlendingForMesh(e.getRenderingMesh())){const e=this._scene.activeCamera.globalPosition;for(let t=0;te._distanceToCamera>t._distanceToCamera?-1:e._distanceToCamera1&&i.activeCamera===i.activeCameras[0]||r<=1)&&this._checkOcclusionQuery()&&!this._occlusionDataStorage.forceRenderingWhenOccluded)return this;const n=this._getInstancesRenderList(e._id,!!s);if(n.mustReturn)return this;if(!this._geometry||!this._geometry.getVertexBuffers()||!this._unIndexed&&!this._geometry.getIndexBuffer())return this;const a=i.getEngine();let o=0,h=null;this.ignoreCameraMaxZ&&i.activeCamera&&!i._isInIntermediateRendering()&&(o=i.activeCamera.maxZ,h=i.activeCamera,i.activeCamera.maxZ=0,i.updateTransformMatrix(!0)),this._internalMeshDataInfo._onBeforeRenderObservable&&this._internalMeshDataInfo._onBeforeRenderObservable.notifyObservers(this);const l=e.getRenderingMesh(),c=n.hardwareInstancedRendering[e._id]||l.hasThinInstances||!!this._userInstancedBuffersStorage&&!e.getMesh()._internalAbstractMeshDataInfo._actAsRegularMesh,u=this._instanceDataStorage,d=e.getMaterial();if(!d)return h&&(h.maxZ=o,i.updateTransformMatrix(!0)),this;if(u.isFrozen&&this._internalMeshDataInfo._effectiveMaterial&&this._internalMeshDataInfo._effectiveMaterial===d){if(d._storeEffectOnSubMeshes&&!e._drawWrapper?._wasPreviouslyReady||!d._storeEffectOnSubMeshes&&!d._getDrawWrapper()._wasPreviouslyReady)return h&&(h.maxZ=o,i.updateTransformMatrix(!0)),this}else{if(d._storeEffectOnSubMeshes){if(!d.isReadyForSubMesh(this,e,c))return h&&(h.maxZ=o,i.updateTransformMatrix(!0)),this}else if(!d.isReady(this,c))return h&&(h.maxZ=o,i.updateTransformMatrix(!0)),this;this._internalMeshDataInfo._effectiveMaterial=d}let _;t&&a.setAlphaMode(this._internalMeshDataInfo._effectiveMaterial.alphaMode),_=this._internalMeshDataInfo._effectiveMaterial._storeEffectOnSubMeshes?e._drawWrapper:this._internalMeshDataInfo._effectiveMaterial._getDrawWrapper();const f=_?.effect??null;for(const t of i._beforeRenderingMeshStage)t.action(this,e,n,f);if(!_||!f)return h&&(h.maxZ=o,i.updateTransformMatrix(!0)),this;const p=s||this;let g;if(u.isFrozen||!this._internalMeshDataInfo._effectiveMaterial.backFaceCulling&&null===this._internalMeshDataInfo._effectiveMaterial.sideOrientation&&!this._internalMeshDataInfo._effectiveMaterial.twoSidedLighting)g=u.sideOrientation;else{const e=p._getWorldMatrixDeterminant();g=this._internalMeshDataInfo._effectiveMaterial._getEffectiveOrientation(this),e<0&&(g=g===m.i.ClockWiseSideOrientation?m.i.CounterClockWiseSideOrientation:m.i.ClockWiseSideOrientation),u.sideOrientation=g}const T=this._internalMeshDataInfo._effectiveMaterial._preBind(_,g);this._internalMeshDataInfo._effectiveMaterial.forceDepthWrite&&a.setDepthWrite(!0);const b=this._internalMeshDataInfo._effectiveMaterial,E=b.fillMode;this._internalMeshDataInfo._onBeforeBindObservable&&this._internalMeshDataInfo._onBeforeBindObservable.notifyObservers(this),c||this._bind(e,f,E,!1);const x=p.getWorldMatrix();b._storeEffectOnSubMeshes?b.bindForSubMesh(x,this,e):b.bind(x,this),!b.backFaceCulling&&b.separateCullingPass&&(a.setState(!0,b.zOffset,!1,!T,b.cullBackFaces,b.stencil,b.zOffsetUnits),this._processRendering(this,e,f,E,n,c,this._onBeforeDraw,this._internalMeshDataInfo._effectiveMaterial),a.setState(!0,b.zOffset,!1,T,b.cullBackFaces,b.stencil,b.zOffsetUnits),this._internalMeshDataInfo._onBetweenPassObservable&&this._internalMeshDataInfo._onBetweenPassObservable.notifyObservers(e)),this._processRendering(this,e,f,E,n,c,this._onBeforeDraw,this._internalMeshDataInfo._effectiveMaterial),this._internalMeshDataInfo._effectiveMaterial.unbind();for(const t of i._afterRenderingMeshStage)t.action(this,e,n,f);return this._internalMeshDataInfo._onAfterRenderObservable&&this._internalMeshDataInfo._onAfterRenderObservable.notifyObservers(this),h&&(h.maxZ=o,i.updateTransformMatrix(!0)),2!==i.performancePriority||u.isFrozen||this._freeze(),this}cleanMatrixWeights(){this.isVerticesDataPresent(d.R.MatricesWeightsKind)&&(this.isVerticesDataPresent(d.R.MatricesWeightsExtraKind)?this._normalizeSkinWeightsAndExtra():this._normalizeSkinFourWeights())}_normalizeSkinFourWeights(){const e=this.getVerticesData(d.R.MatricesWeightsKind),t=e.length;for(let s=0;ss&&i++,0!==n&&u++,c+=n,s=n}if(h[u]++,u>n&&(n=u),0===c)r++;else{const s=1/c;let i=0;for(let r=0;r.001&&a++}}const l=this.skeleton.bones.length,c=this.getVerticesData(d.R.MatricesIndicesKind),u=this.getVerticesData(d.R.MatricesIndicesExtraKind);let _=0;for(let e=0;e=l||s<0)&&_++}return{skinned:!0,valid:0===r&&0===a&&0===_,report:"Number of Weights = "+s/4+"\nMaximum influences = "+n+"\nMissing Weights = "+r+"\nNot Sorted = "+i+"\nNot Normalized = "+a+"\nWeightCounts = ["+h+"]\nNumber of bones = "+l+"\nBad Bone Indices = "+_}}_checkDelayState(){const e=this.getScene();return this._geometry?this._geometry.load(e):4===this.delayLoadState&&(this.delayLoadState=2,this._queueLoad(e)),this}_queueLoad(e){e.addPendingData(this);const t=-1!==this.delayLoadingFile.indexOf(".babylonbinarymeshdata");return r.S0.LoadFile(this.delayLoadingFile,(t=>{t instanceof ArrayBuffer?this._delayLoadingFunction(t,this):this._delayLoadingFunction(JSON.parse(t),this),this.instances.forEach((e=>{e.refreshBoundingInfo(),e._syncSubMeshes()})),this.delayLoadState=1,e.removePendingData(this)}),(()=>{}),e.offlineProvider,t),this}isInFrustum(e){return 2!==this.delayLoadState&&!!super.isInFrustum(e)&&(this._checkDelayState(),!0)}setMaterialById(e){const t=this.getScene().materials;let s;for(s=t.length-1;s>-1;s--)if(t[s].id===e)return this.material=t[s],this;const i=this.getScene().multiMaterials;for(s=i.length-1;s>-1;s--)if(i[s].id===e)return this.material=i[s],this;return this}getAnimatables(){const e=[];return this.material&&e.push(this.material),this.skeleton&&e.push(this.skeleton),e}bakeTransformIntoVertices(e){if(!this.isVerticesDataPresent(d.R.PositionKind))return this;const t=this.subMeshes.splice(0);this._resetPointsArrayCache();let s=this.getVerticesData(d.R.PositionKind);const i=l.Pq.Zero();let r;for(r=0;r{const r=e.width,h=e.height,l=this.getEngine().createCanvas(r,h).getContext("2d");l.drawImage(e,0,0);const c=l.getImageData(0,0,r,h).data;this.applyDisplacementMapFromBuffer(c,r,h,t,s,n,a,o),i&&i(this)}),h||(()=>{}),l.offlineProvider),this}applyDisplacementMapFromBuffer(e,t,s,i,r,n,a,o=!1){if(!this.isVerticesDataPresent(d.R.PositionKind)||!this.isVerticesDataPresent(d.R.NormalKind)||!this.isVerticesDataPresent(d.R.UVKind))return A.V.Warn("Cannot call applyDisplacementMap: Given mesh is not complete. Position, Normal or UV are missing"),this;const h=this.getVerticesData(d.R.PositionKind,!0,!0),c=this.getVerticesData(d.R.NormalKind),u=this.getVerticesData(d.R.UVKind);let f=l.Pq.Zero();const p=l.Pq.Zero(),g=l.I9.Zero();n=n||l.I9.Zero(),a=a||new l.I9(1,1);for(let o=0;o!this.getVertexBuffer(e)?.getIsInstanced())),s=this.getIndices(),i={},r=(e,t)=>{const i=new Float32Array(s.length*t);let r=0;for(let n=0;n{const t=i.length-1-e,s=i[t];for(let e=0;e{for(let e=0;e-1&&(i._waitingMorphTargetManagerId=e.morphTargetManagerId),void 0!==e.skeletonId&&null!==e.skeletonId&&(i.skeleton=t.getLastSkeletonById(e.skeletonId),e.numBoneInfluencers&&(i.numBoneInfluencers=e.numBoneInfluencers)),e.animations){for(let t=0;t4,h=o?this.getVerticesData(d.R.MatricesIndicesExtraKind):null,c=o?this.getVerticesData(d.R.MatricesWeightsExtraKind):null,u=e.getTransformMatrices(this),_=l.Pq.Zero(),f=new l.uq,p=new l.uq;let g,m=0;for(let e=0;e0&&(l.uq.FromFloat32ArrayToRefScaled(u,Math.floor(16*n[m+g]),d,p),f.addToSelf(p));if(o)for(g=0;g<4;g++)d=c[m+g],d>0&&(l.uq.FromFloat32ArrayToRefScaled(u,Math.floor(16*h[m+g]),d,p),f.addToSelf(p));l.Pq.TransformCoordinatesFromFloatsToRef(s._sourcePositions[e],s._sourcePositions[e+1],s._sourcePositions[e+2],f,_),_.toArray(i,e),t&&(l.Pq.TransformNormalFromFloatsToRef(s._sourceNormals[e],s._sourceNormals[e+1],s._sourceNormals[e+2],f,_),_.toArray(r,e)),f.reset()}return this.updateVerticesData(d.R.PositionKind,i),t&&this.updateVerticesData(d.R.NormalKind,r),this}static MinMax(e){let t=null,s=null;return e.forEach((function(e){const i=e.getBoundingInfo().boundingBox;t&&s?(t.minimizeInPlace(i.minimumWorld),s.maximizeInPlace(i.maximumWorld)):(t=i.minimumWorld,s=i.maximumWorld)})),t&&s?{min:t,max:s}:{min:l.Pq.Zero(),max:l.Pq.Zero()}}static Center(e){const t=e instanceof Array?I.MinMax(e):e;return l.Pq.Center(t.min,t.max)}static MergeMeshes(e,t=!0,s,i,r,n){return(0,o.V1)(I._MergeMeshesCoroutine(e,t,s,i,r,n,!1))}static MergeMeshesAsync(e,t=!0,s,i,r,n){return(0,o.kj)(I._MergeMeshesCoroutine(e,t,s,i,r,n,!0),(0,o.VP)())}static*_MergeMeshesCoroutine(e,t=!0,s,i,r,n,a){if(0===(e=e.filter(Boolean)).length)return null;let o;if(!s){let t=0;for(o=0;o=65536)return A.V.Warn("Cannot merge meshes because resulting mesh will have more than 65536 vertices. Please use allow32BitsIndices = true to use 32 bits indices"),null}n&&(r=!1);const h=new Array,l=new Array,c=new Array,u=e[0].sideOrientation;for(o=0;o{const t=e.computeWorldMatrix(!0);return{vertexData:_.P.ExtractFromMesh(e,!1,!1),transform:t}},{vertexData:p,transform:m}=f(d);a&&(yield);const T=new Array(e.length-1);for(let t=1;t{throw(0,R.n)("GroundMesh")},I._GoldbergMeshParser=(e,t)=>{throw(0,R.n)("GoldbergMesh")},I._LinesMeshParser=(e,t)=>{throw(0,R.n)("LinesMesh")},I._GreasedLineMeshParser=(e,t)=>{throw(0,R.n)("GreasedLineMesh")},I._GreasedLineRibbonMeshParser=(e,t)=>{throw(0,R.n)("GreasedLineRibbonMesh")},I._TrailMeshParser=(e,t)=>{throw(0,R.n)("TrailMesh")},(0,T.Y5)("BABYLON.Mesh",I)},6803:(e,t,s)=>{s.d(t,{P:()=>f});var i=s(5524),r=s(9923),n=s(5616),a=s(5503),o=s(6041),h=s(1137),l=s(9259),c=s(163),u=s(8563),d=s(1846);class _{}class f{constructor(){this.uniqueId=0,this.metadata={},this._applyTo=(0,c.Aj)(this._applyToCoroutine.bind(this)),this.uniqueId=f._UniqueIDGenerator,f._UniqueIDGenerator++}set(e,t){switch(e.length||h.V.Warn(`Setting vertex data kind '${t}' with an empty array`),t){case n.R.PositionKind:this.positions=e;break;case n.R.NormalKind:this.normals=e;break;case n.R.TangentKind:this.tangents=e;break;case n.R.UVKind:this.uvs=e;break;case n.R.UV2Kind:this.uvs2=e;break;case n.R.UV3Kind:this.uvs3=e;break;case n.R.UV4Kind:this.uvs4=e;break;case n.R.UV5Kind:this.uvs5=e;break;case n.R.UV6Kind:this.uvs6=e;break;case n.R.ColorKind:this.colors=e;break;case n.R.MatricesIndicesKind:this.matricesIndices=e;break;case n.R.MatricesWeightsKind:this.matricesWeights=e;break;case n.R.MatricesIndicesExtraKind:this.matricesIndicesExtra=e;break;case n.R.MatricesWeightsExtraKind:this.matricesWeightsExtra=e}}applyToMesh(e,t){return this._applyTo(e,t,!1),this}applyToGeometry(e,t){return this._applyTo(e,t,!1),this}updateMesh(e){return this._update(e),this}updateGeometry(e){return this._update(e),this}*_applyToCoroutine(e,t=!1,s){if(this.positions&&(e.setVerticesData(n.R.PositionKind,this.positions,t),s&&(yield)),this.normals&&(e.setVerticesData(n.R.NormalKind,this.normals,t),s&&(yield)),this.tangents&&(e.setVerticesData(n.R.TangentKind,this.tangents,t),s&&(yield)),this.uvs&&(e.setVerticesData(n.R.UVKind,this.uvs,t),s&&(yield)),this.uvs2&&(e.setVerticesData(n.R.UV2Kind,this.uvs2,t),s&&(yield)),this.uvs3&&(e.setVerticesData(n.R.UV3Kind,this.uvs3,t),s&&(yield)),this.uvs4&&(e.setVerticesData(n.R.UV4Kind,this.uvs4,t),s&&(yield)),this.uvs5&&(e.setVerticesData(n.R.UV5Kind,this.uvs5,t),s&&(yield)),this.uvs6&&(e.setVerticesData(n.R.UV6Kind,this.uvs6,t),s&&(yield)),this.colors&&(e.setVerticesData(n.R.ColorKind,this.colors,t),this.hasVertexAlpha&&void 0!==e.hasVertexAlpha&&(e.hasVertexAlpha=!0),s&&(yield)),this.matricesIndices&&(e.setVerticesData(n.R.MatricesIndicesKind,this.matricesIndices,t),s&&(yield)),this.matricesWeights&&(e.setVerticesData(n.R.MatricesWeightsKind,this.matricesWeights,t),s&&(yield)),this.matricesIndicesExtra&&(e.setVerticesData(n.R.MatricesIndicesExtraKind,this.matricesIndicesExtra,t),s&&(yield)),this.matricesWeightsExtra&&(e.setVerticesData(n.R.MatricesWeightsExtraKind,this.matricesWeightsExtra,t),s&&(yield)),this.indices?(e.setIndices(this.indices,null,t),s&&(yield)):e.setIndices([],null),e.subMeshes&&this.materialInfos&&this.materialInfos.length>1){const t=e;t.subMeshes=[];for(const e of this.materialInfos)new d.K(e.materialIndex,e.verticesStart,e.verticesCount,e.indexStart,e.indexCount,t)}return this}_update(e,t,s){return this.positions&&e.updateVerticesData(n.R.PositionKind,this.positions,t,s),this.normals&&e.updateVerticesData(n.R.NormalKind,this.normals,t,s),this.tangents&&e.updateVerticesData(n.R.TangentKind,this.tangents,t,s),this.uvs&&e.updateVerticesData(n.R.UVKind,this.uvs,t,s),this.uvs2&&e.updateVerticesData(n.R.UV2Kind,this.uvs2,t,s),this.uvs3&&e.updateVerticesData(n.R.UV3Kind,this.uvs3,t,s),this.uvs4&&e.updateVerticesData(n.R.UV4Kind,this.uvs4,t,s),this.uvs5&&e.updateVerticesData(n.R.UV5Kind,this.uvs5,t,s),this.uvs6&&e.updateVerticesData(n.R.UV6Kind,this.uvs6,t,s),this.colors&&e.updateVerticesData(n.R.ColorKind,this.colors,t,s),this.matricesIndices&&e.updateVerticesData(n.R.MatricesIndicesKind,this.matricesIndices,t,s),this.matricesWeights&&e.updateVerticesData(n.R.MatricesWeightsKind,this.matricesWeights,t,s),this.matricesIndicesExtra&&e.updateVerticesData(n.R.MatricesIndicesExtraKind,this.matricesIndicesExtra,t,s),this.matricesWeightsExtra&&e.updateVerticesData(n.R.MatricesWeightsExtraKind,this.matricesWeightsExtra,t,s),this.indices&&e.setIndices(this.indices,null),this}static _TransformVector3Coordinates(e,t,s=0,i=e.length){const n=r.AA.Vector3[0],a=r.AA.Vector3[1];for(let o=s;o({vertexData:e}))):[{vertexData:e}];return(0,c.V1)(this._mergeCoroutine(void 0,n,t,!1,s,i,r))}*_mergeCoroutine(e,t,s=!1,i,r,a=!1,o=!1){this._validate();let h=t.map((e=>e.vertexData)),l=this;if(o)for(const e of h)e&&(e._validate(),!this.normals&&e.normals&&(this.normals=new Float32Array(this.positions.length)),!this.tangents&&e.tangents&&(this.tangents=new Float32Array(this.positions.length/3*4)),!this.uvs&&e.uvs&&(this.uvs=new Float32Array(this.positions.length/3*2)),!this.uvs2&&e.uvs2&&(this.uvs2=new Float32Array(this.positions.length/3*2)),!this.uvs3&&e.uvs3&&(this.uvs3=new Float32Array(this.positions.length/3*2)),!this.uvs4&&e.uvs4&&(this.uvs4=new Float32Array(this.positions.length/3*2)),!this.uvs5&&e.uvs5&&(this.uvs5=new Float32Array(this.positions.length/3*2)),!this.uvs6&&e.uvs6&&(this.uvs6=new Float32Array(this.positions.length/3*2)),!this.colors&&e.colors&&(this.colors=new Float32Array(this.positions.length/3*4),this.colors.fill(1)),!this.matricesIndices&&e.matricesIndices&&(this.matricesIndices=new Float32Array(this.positions.length/3*4)),!this.matricesWeights&&e.matricesWeights&&(this.matricesWeights=new Float32Array(this.positions.length/3*4)),!this.matricesIndicesExtra&&e.matricesIndicesExtra&&(this.matricesIndicesExtra=new Float32Array(this.positions.length/3*4)),!this.matricesWeightsExtra&&e.matricesWeightsExtra&&(this.matricesWeightsExtra=new Float32Array(this.positions.length/3*4)));for(const e of h)if(e)if(o)this.normals&&!e.normals&&(e.normals=new Float32Array(e.positions.length)),this.tangents&&!e.tangents&&(e.tangents=new Float32Array(e.positions.length/3*4)),this.uvs&&!e.uvs&&(e.uvs=new Float32Array(e.positions.length/3*2)),this.uvs2&&!e.uvs2&&(e.uvs2=new Float32Array(e.positions.length/3*2)),this.uvs3&&!e.uvs3&&(e.uvs3=new Float32Array(e.positions.length/3*2)),this.uvs4&&!e.uvs4&&(e.uvs4=new Float32Array(e.positions.length/3*2)),this.uvs5&&!e.uvs5&&(e.uvs5=new Float32Array(e.positions.length/3*2)),this.uvs6&&!e.uvs6&&(e.uvs6=new Float32Array(e.positions.length/3*2)),this.colors&&!e.colors&&(e.colors=new Float32Array(e.positions.length/3*4),e.colors.fill(1)),this.matricesIndices&&!e.matricesIndices&&(e.matricesIndices=new Float32Array(e.positions.length/3*4)),this.matricesWeights&&!e.matricesWeights&&(e.matricesWeights=new Float32Array(e.positions.length/3*4)),this.matricesIndicesExtra&&!e.matricesIndicesExtra&&(e.matricesIndicesExtra=new Float32Array(e.positions.length/3*4)),this.matricesWeightsExtra&&!e.matricesWeightsExtra&&(e.matricesWeightsExtra=new Float32Array(e.positions.length/3*4));else if(e._validate(),!this.normals!=!e.normals||!this.tangents!=!e.tangents||!this.uvs!=!e.uvs||!this.uvs2!=!e.uvs2||!this.uvs3!=!e.uvs3||!this.uvs4!=!e.uvs4||!this.uvs5!=!e.uvs5||!this.uvs6!=!e.uvs6||!this.colors!=!e.colors||!this.matricesIndices!=!e.matricesIndices||!this.matricesWeights!=!e.matricesWeights||!this.matricesIndicesExtra!=!e.matricesIndicesExtra||!this.matricesWeightsExtra!=!e.matricesWeightsExtra)throw new Error("Cannot merge vertex data that do not have the same set of attributes");if(a){let s=0,i=0,r=0;const n=[];let a=null;const o=[];for(const t of this.splitBasedOnMaterialID())o.push({vertexData:t,transform:e});for(const e of t)if(e.vertexData)for(const t of e.vertexData.splitBasedOnMaterialID())o.push({vertexData:t,transform:e.transform});o.sort(((e,t)=>{const s=e.vertexData.materialInfos?e.vertexData.materialInfos[0].materialIndex:0,i=t.vertexData.materialInfos?t.vertexData.materialInfos[0].materialIndex:0;return s>i?1:s===i?0:-1}));for(const e of o){const t=e.vertexData;if(s=t.materialInfos?t.materialInfos[0].materialIndex:0,a&&a.materialIndex===s)a.indexCount+=t.indices.length,a.verticesCount+=t.positions.length/3;else{const e=new _;e.materialIndex=s,e.indexStart=i,e.indexCount=t.indices.length,e.verticesStart=r,e.verticesCount=t.positions.length/3,n.push(e),a=e}i+=t.indices.length,r+=t.positions.length/3}const c=o.splice(0,1)[0];l=c.vertexData,e=c.transform,h=o.map((e=>e.vertexData)),t=o,this.materialInfos=n}const c=h.reduce(((e,t)=>e+(t.indices?.length??0)),l.indices?.length??0);let u=r||h.some((e=>e.indices===l.indices))?l.indices?.slice():l.indices;if(c>0){let r=u?.length??0;if(u||(u=new Array(c)),u.length!==c){if(Array.isArray(u))u.length=c;else{const e=s||u instanceof Uint32Array?new Uint32Array(c):new Uint16Array(c);e.set(u),u=e}e&&e.determinant()<0&&f._FlipFaces(u,0,r)}let n=l.positions?l.positions.length/3:0;for(const{vertexData:e,transform:s}of t)if(e.indices){for(let t=0;t[e.vertexData.positions,e.transform]))),i&&(yield),l.normals&&(this.normals=f._MergeElement(n.R.NormalKind,l.normals,e,t.map((e=>[e.vertexData.normals,e.transform]))),i&&(yield)),l.tangents&&(this.tangents=f._MergeElement(n.R.TangentKind,l.tangents,e,t.map((e=>[e.vertexData.tangents,e.transform]))),i&&(yield)),l.uvs&&(this.uvs=f._MergeElement(n.R.UVKind,l.uvs,e,t.map((e=>[e.vertexData.uvs,e.transform]))),i&&(yield)),l.uvs2&&(this.uvs2=f._MergeElement(n.R.UV2Kind,l.uvs2,e,t.map((e=>[e.vertexData.uvs2,e.transform]))),i&&(yield)),l.uvs3&&(this.uvs3=f._MergeElement(n.R.UV3Kind,l.uvs3,e,t.map((e=>[e.vertexData.uvs3,e.transform]))),i&&(yield)),l.uvs4&&(this.uvs4=f._MergeElement(n.R.UV4Kind,l.uvs4,e,t.map((e=>[e.vertexData.uvs4,e.transform]))),i&&(yield)),l.uvs5&&(this.uvs5=f._MergeElement(n.R.UV5Kind,l.uvs5,e,t.map((e=>[e.vertexData.uvs5,e.transform]))),i&&(yield)),l.uvs6&&(this.uvs6=f._MergeElement(n.R.UV6Kind,l.uvs6,e,t.map((e=>[e.vertexData.uvs6,e.transform]))),i&&(yield)),l.colors&&(this.colors=f._MergeElement(n.R.ColorKind,l.colors,e,t.map((e=>[e.vertexData.colors,e.transform]))),(void 0!==l.hasVertexAlpha||t.some((e=>void 0!==e.vertexData.hasVertexAlpha)))&&(this.hasVertexAlpha=l.hasVertexAlpha||t.some((e=>e.vertexData.hasVertexAlpha))),i&&(yield)),l.matricesIndices&&(this.matricesIndices=f._MergeElement(n.R.MatricesIndicesKind,l.matricesIndices,e,t.map((e=>[e.vertexData.matricesIndices,e.transform]))),i&&(yield)),l.matricesWeights&&(this.matricesWeights=f._MergeElement(n.R.MatricesWeightsKind,l.matricesWeights,e,t.map((e=>[e.vertexData.matricesWeights,e.transform]))),i&&(yield)),l.matricesIndicesExtra&&(this.matricesIndicesExtra=f._MergeElement(n.R.MatricesIndicesExtraKind,l.matricesIndicesExtra,e,t.map((e=>[e.vertexData.matricesIndicesExtra,e.transform]))),i&&(yield)),l.matricesWeightsExtra&&(this.matricesWeightsExtra=f._MergeElement(n.R.MatricesWeightsExtraKind,l.matricesWeightsExtra,e,t.map((e=>[e.vertexData.matricesWeightsExtra,e.transform])))),this}static _MergeElement(e,t,s,i){const r=i.filter((e=>null!==e[0]&&void 0!==e[0]));if(!t&&0==r.length)return t;if(!t)return this._MergeElement(e,r[0][0],r[0][1],r.slice(1));const a=r.reduce(((e,t)=>e+t[0].length),t.length),o=e===n.R.PositionKind?f._TransformVector3Coordinates:e===n.R.NormalKind?f._TransformVector3Normals:e===n.R.TangentKind?f._TransformVector4Normals:()=>{};if(t instanceof Float32Array){const e=new Float32Array(a);e.set(t),s&&o(e,s,0,t.length);let i=t.length;for(const[t,s]of r)e.set(t,i),s&&o(e,s,i,t.length),i+=t.length;return e}{const e=new Array(a);for(let s=0;s{const s=n.R.DeduceStride(e);if(t.length%s!=0)throw new Error("The "+e+"s array count must be a multiple of "+s);return t.length/s},t=e(n.R.PositionKind,this.positions),s=(s,i)=>{const r=e(s,i);if(r!==t)throw new Error("The "+s+"s element count ("+r+") does not match the positions count ("+t+")")};this.normals&&s(n.R.NormalKind,this.normals),this.tangents&&s(n.R.TangentKind,this.tangents),this.uvs&&s(n.R.UVKind,this.uvs),this.uvs2&&s(n.R.UV2Kind,this.uvs2),this.uvs3&&s(n.R.UV3Kind,this.uvs3),this.uvs4&&s(n.R.UV4Kind,this.uvs4),this.uvs5&&s(n.R.UV5Kind,this.uvs5),this.uvs6&&s(n.R.UV6Kind,this.uvs6),this.colors&&s(n.R.ColorKind,this.colors),this.matricesIndices&&s(n.R.MatricesIndicesKind,this.matricesIndices),this.matricesWeights&&s(n.R.MatricesWeightsKind,this.matricesWeights),this.matricesIndicesExtra&&s(n.R.MatricesIndicesExtraKind,this.matricesIndicesExtra),this.matricesWeightsExtra&&s(n.R.MatricesWeightsExtraKind,this.matricesWeightsExtra)}clone(){const e=this.serialize();return f.Parse(e)}serialize(){const e={};if(this.positions&&(e.positions=Array.from(this.positions)),this.normals&&(e.normals=Array.from(this.normals)),this.tangents&&(e.tangents=Array.from(this.tangents)),this.uvs&&(e.uvs=Array.from(this.uvs)),this.uvs2&&(e.uvs2=Array.from(this.uvs2)),this.uvs3&&(e.uvs3=Array.from(this.uvs3)),this.uvs4&&(e.uvs4=Array.from(this.uvs4)),this.uvs5&&(e.uvs5=Array.from(this.uvs5)),this.uvs6&&(e.uvs6=Array.from(this.uvs6)),this.colors&&(e.colors=Array.from(this.colors),e.hasVertexAlpha=this.hasVertexAlpha),this.matricesIndices&&(e.matricesIndices=Array.from(this.matricesIndices),e.matricesIndices._isExpanded=!0),this.matricesWeights&&(e.matricesWeights=Array.from(this.matricesWeights)),this.matricesIndicesExtra&&(e.matricesIndicesExtra=Array.from(this.matricesIndicesExtra),e.matricesIndicesExtra._isExpanded=!0),this.matricesWeightsExtra&&(e.matricesWeightsExtra=Array.from(this.matricesWeightsExtra)),e.indices=Array.from(this.indices),this.materialInfos){e.materialInfos=[];for(const t of this.materialInfos){const s={indexStart:t.indexStart,indexCount:t.indexCount,materialIndex:t.materialIndex,verticesStart:t.verticesStart,verticesCount:t.verticesCount};e.materialInfos.push(s)}}return e}static ExtractFromMesh(e,t,s){return f._ExtractFrom(e,t,s)}static ExtractFromGeometry(e,t,s){return f._ExtractFrom(e,t,s)}static _ExtractFrom(e,t,s){const i=new f;if(e.isVerticesDataPresent(n.R.PositionKind)&&(i.positions=e.getVerticesData(n.R.PositionKind,t,s)),e.isVerticesDataPresent(n.R.NormalKind)&&(i.normals=e.getVerticesData(n.R.NormalKind,t,s)),e.isVerticesDataPresent(n.R.TangentKind)&&(i.tangents=e.getVerticesData(n.R.TangentKind,t,s)),e.isVerticesDataPresent(n.R.UVKind)&&(i.uvs=e.getVerticesData(n.R.UVKind,t,s)),e.isVerticesDataPresent(n.R.UV2Kind)&&(i.uvs2=e.getVerticesData(n.R.UV2Kind,t,s)),e.isVerticesDataPresent(n.R.UV3Kind)&&(i.uvs3=e.getVerticesData(n.R.UV3Kind,t,s)),e.isVerticesDataPresent(n.R.UV4Kind)&&(i.uvs4=e.getVerticesData(n.R.UV4Kind,t,s)),e.isVerticesDataPresent(n.R.UV5Kind)&&(i.uvs5=e.getVerticesData(n.R.UV5Kind,t,s)),e.isVerticesDataPresent(n.R.UV6Kind)&&(i.uvs6=e.getVerticesData(n.R.UV6Kind,t,s)),e.isVerticesDataPresent(n.R.ColorKind)){const r=e.geometry||e,a=r.getVertexBuffer(n.R.ColorKind),o=r.getVerticesData(n.R.ColorKind,t,s);if(3===a.getSize()){const e=new Float32Array(4*o.length/3);for(let t=0,s=0;t!Array.isArray(e)))],f,"_TransformVector3Coordinates",null),(0,i.Cg)([l.Cx.filter(((...[e])=>!Array.isArray(e)))],f,"_TransformVector3Normals",null),(0,i.Cg)([l.Cx.filter(((...[e])=>!Array.isArray(e)))],f,"_TransformVector4Normals",null),(0,i.Cg)([l.Cx.filter(((...[e])=>!Array.isArray(e)))],f,"_FlipFaces",null)},1846:(e,t,s)=>{s.d(t,{K:()=>h});var i=s(5616);class r{constructor(e,t,s){this.bu=e,this.bv=t,this.distance=s,this.faceId=0,this.subMeshId=0}}var n=s(2564),a=s(1139),o=s(5476);class h{get materialDefines(){return this._mainDrawWrapperOverride?this._mainDrawWrapperOverride.defines:this._getDrawWrapper()?.defines}set materialDefines(e){(this._mainDrawWrapperOverride??this._getDrawWrapper(void 0,!0)).defines=e}_getDrawWrapper(e,t=!1){e=e??this._engine.currentRenderPassId;let s=this._drawWrappers[e];return!s&&t&&(this._drawWrappers[e]=s=new o.E(this._mesh.getScene().getEngine())),s}_removeDrawWrapper(e,t=!0){t&&this._drawWrappers[e]?.dispose(),this._drawWrappers[e]=void 0}get effect(){return this._mainDrawWrapperOverride?this._mainDrawWrapperOverride.effect:this._getDrawWrapper()?.effect??null}get _drawWrapper(){return this._mainDrawWrapperOverride??this._getDrawWrapper(void 0,!0)}get _drawWrapperOverride(){return this._mainDrawWrapperOverride}_setMainDrawWrapperOverride(e){this._mainDrawWrapperOverride=e}setEffect(e,t=null,s,i=!0){const r=this._drawWrapper;r.setEffect(e,t,i),void 0!==s&&(r.materialContext=s),e||(r.defines=null,r.materialContext=void 0)}resetDrawCache(e){if(this._drawWrappers){if(void 0!==e)return void this._removeDrawWrapper(e);for(const e of this._drawWrappers)e?.dispose()}this._drawWrappers=[]}static AddToMesh(e,t,s,i,r,n,a,o=!0){return new h(e,t,s,i,r,n,a,o)}constructor(e,t,s,i,r,n,a,o=!0,h=!0){this.materialIndex=e,this.verticesStart=t,this.verticesCount=s,this.indexStart=i,this.indexCount=r,this._mainDrawWrapperOverride=null,this._linesIndexCount=0,this._linesIndexBuffer=null,this._lastColliderWorldVertices=null,this._lastColliderTransformMatrix=null,this._wasDispatched=!1,this._renderId=0,this._alphaIndex=0,this._distanceToCamera=0,this._currentMaterial=null,this._mesh=n,this._renderingMesh=a||n,h&&n.subMeshes.push(this),this._engine=this._mesh.getScene().getEngine(),this.resetDrawCache(),this._trianglePlanes=[],this._id=n.subMeshes.length-1,o&&(this.refreshBoundingInfo(),n.computeWorldMatrix(!0))}get IsGlobal(){return 0===this.verticesStart&&this.verticesCount===this._mesh.getTotalVertices()&&0===this.indexStart&&this.indexCount===this._mesh.getTotalIndices()}getBoundingInfo(){return this.IsGlobal||this._mesh.hasThinInstances?this._mesh.getBoundingInfo():this._boundingInfo}setBoundingInfo(e){return this._boundingInfo=e,this}getMesh(){return this._mesh}getRenderingMesh(){return this._renderingMesh}getReplacementMesh(){return this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh?this._mesh:null}getEffectiveMesh(){return(this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh?this._mesh:null)||this._renderingMesh}getMaterial(e=!0){const t=this._renderingMesh.getMaterialForRenderPass(this._engine.currentRenderPassId)??this._renderingMesh.material;if(!t)return e?this._mesh.getScene().defaultMaterial:null;if(this._isMultiMaterial(t)){const e=t.getSubMaterial(this.materialIndex);return this._currentMaterial!==e&&(this._currentMaterial=e,this.resetDrawCache()),e}return t}_isMultiMaterial(e){return void 0!==e.getSubMaterial}refreshBoundingInfo(e=null){if(this._lastColliderWorldVertices=null,this.IsGlobal||!this._renderingMesh||!this._renderingMesh.geometry)return this;if(e||(e=this._renderingMesh.getVerticesData(i.R.PositionKind)),!e)return this._boundingInfo=this._mesh.getBoundingInfo(),this;const t=this._renderingMesh.getIndices();let s;if(0===this.indexStart&&this.indexCount===t.length){const e=this._renderingMesh.getBoundingInfo();s={minimum:e.minimum.clone(),maximum:e.maximum.clone()}}else s=(0,a.cD)(e,t,this.indexStart,this.indexCount,this._renderingMesh.geometry.boundingBias);return this._boundingInfo?this._boundingInfo.reConstruct(s.minimum,s.maximum):this._boundingInfo=new n.j(s.minimum,s.maximum),this}_checkCollision(e){return this.getBoundingInfo()._checkCollision(e)}updateBoundingInfo(e){let t=this.getBoundingInfo();return t||(this.refreshBoundingInfo(),t=this.getBoundingInfo()),t&&t.update(e),this}isInFrustum(e){const t=this.getBoundingInfo();return!!t&&t.isInFrustum(e,this._mesh.cullingStrategy)}isCompletelyInFrustum(e){const t=this.getBoundingInfo();return!!t&&t.isCompletelyInFrustum(e)}render(e){return this._renderingMesh.render(this,e,this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh?this._mesh:void 0),this}_getLinesIndexBuffer(e,t){if(!this._linesIndexBuffer){const s=[];for(let t=this.indexStart;to&&(o=t)}return new h(e,a,o-a+1,t,s,i,r,n)}}},7328:(e,t,s)=>{s.d(t,{V:()=>u});var i=s(5524),r=s(9259),n=s(6877),a=s(9848),o=s(9923),h=s(4870),l=s(6552);const c=o.uq.Compose(o.Pq.One(),o.PT.FromEulerAngles(0,Math.PI,0),o.Pq.Zero());class u extends h.b{get billboardMode(){return this._billboardMode}set billboardMode(e){this._billboardMode!==e&&(this._billboardMode=e,this._cache.useBillboardPosition=0!=(this._billboardMode&u.BILLBOARDMODE_USE_POSITION),this._computeUseBillboardPath())}get preserveParentRotationForBillboard(){return this._preserveParentRotationForBillboard}set preserveParentRotationForBillboard(e){e!==this._preserveParentRotationForBillboard&&(this._preserveParentRotationForBillboard=e,this._computeUseBillboardPath())}_computeUseBillboardPath(){this._cache.useBillboardPath=this._billboardMode!==u.BILLBOARDMODE_NONE&&!this.preserveParentRotationForBillboard}get infiniteDistance(){return this._infiniteDistance}set infiniteDistance(e){this._infiniteDistance!==e&&(this._infiniteDistance=e)}constructor(e,t=null,s=!0){super(e,t,!1),this._forward=new o.Pq(0,0,1),this._up=new o.Pq(0,1,0),this._right=new o.Pq(1,0,0),this._position=o.Pq.Zero(),this._rotation=o.Pq.Zero(),this._rotationQuaternion=null,this._scaling=o.Pq.One(),this._transformToBoneReferal=null,this._isAbsoluteSynced=!1,this._billboardMode=u.BILLBOARDMODE_NONE,this._preserveParentRotationForBillboard=!1,this.scalingDeterminant=1,this._infiniteDistance=!1,this.ignoreNonUniformScaling=!1,this.reIntegrateRotationIntoRotationQuaternion=!1,this._poseMatrix=null,this._localMatrix=o.uq.Zero(),this._usePivotMatrix=!1,this._absolutePosition=o.Pq.Zero(),this._absoluteScaling=o.Pq.Zero(),this._absoluteRotationQuaternion=o.PT.Identity(),this._pivotMatrix=o.uq.Identity(),this._postMultiplyPivotMatrix=!1,this._isWorldMatrixFrozen=!1,this._indexInSceneTransformNodesArray=-1,this.onAfterWorldMatrixUpdateObservable=new a.cP,this._nonUniformScaling=!1,s&&this.getScene().addTransformNode(this)}getClassName(){return"TransformNode"}get position(){return this._position}set position(e){this._position=e,this._markAsDirtyInternal()}isUsingPivotMatrix(){return this._usePivotMatrix}isUsingPostMultiplyPivotMatrix(){return this._postMultiplyPivotMatrix}get rotation(){return this._rotation}set rotation(e){this._rotation=e,this._rotationQuaternion=null,this._markAsDirtyInternal()}get scaling(){return this._scaling}set scaling(e){this._scaling=e,this._markAsDirtyInternal()}get rotationQuaternion(){return this._rotationQuaternion}set rotationQuaternion(e){this._rotationQuaternion=e,e&&this._rotation.setAll(0),this._markAsDirtyInternal()}_markAsDirtyInternal(){this._isDirty||(this._isDirty=!0,this.customMarkAsDirty&&this.customMarkAsDirty())}get forward(){return o.Pq.TransformNormalFromFloatsToRef(0,0,this.getScene().useRightHandedSystem?-1:1,this.getWorldMatrix(),this._forward),this._forward.normalize()}get up(){return o.Pq.TransformNormalFromFloatsToRef(0,1,0,this.getWorldMatrix(),this._up),this._up.normalize()}get right(){return o.Pq.TransformNormalFromFloatsToRef(this.getScene().useRightHandedSystem?-1:1,0,0,this.getWorldMatrix(),this._right),this._right.normalize()}updatePoseMatrix(e){return this._poseMatrix?(this._poseMatrix.copyFrom(e),this):(this._poseMatrix=e.clone(),this)}getPoseMatrix(){return this._poseMatrix||(this._poseMatrix=o.uq.Identity()),this._poseMatrix}_isSynchronized(){const e=this._cache;return!(this._billboardMode!==e.billboardMode||this._billboardMode!==u.BILLBOARDMODE_NONE||e.pivotMatrixUpdated||this._infiniteDistance||this._position._isDirty||this._scaling._isDirty||this._rotationQuaternion&&this._rotationQuaternion._isDirty||this._rotation._isDirty)}_initCache(){super._initCache();const e=this._cache;e.localMatrixUpdated=!1,e.billboardMode=-1,e.infiniteDistance=!1,e.useBillboardPosition=!1,e.useBillboardPath=!1}get absolutePosition(){return this.getAbsolutePosition()}get absoluteScaling(){return this._syncAbsoluteScalingAndRotation(),this._absoluteScaling}get absoluteRotationQuaternion(){return this._syncAbsoluteScalingAndRotation(),this._absoluteRotationQuaternion}setPreTransformMatrix(e){return this.setPivotMatrix(e,!1)}setPivotMatrix(e,t=!0){return this._pivotMatrix.copyFrom(e),this._usePivotMatrix=!this._pivotMatrix.isIdentity(),this._cache.pivotMatrixUpdated=!0,this._postMultiplyPivotMatrix=t,this._postMultiplyPivotMatrix&&(this._pivotMatrixInverse?this._pivotMatrix.invertToRef(this._pivotMatrixInverse):this._pivotMatrixInverse=o.uq.Invert(this._pivotMatrix)),this}getPivotMatrix(){return this._pivotMatrix}instantiateHierarchy(e=null,t,s){const i=this.clone("Clone of "+(this.name||this.id),e||this.parent,!0);i&&s&&s(this,i);for(const e of this.getChildTransformNodes(!0))e.instantiateHierarchy(i,t,s);return i}freezeWorldMatrix(e=null,t=!1){return e?t?(this._rotation.setAll(0),this._rotationQuaternion=this._rotationQuaternion||o.PT.Identity(),e.decompose(this._scaling,this._rotationQuaternion,this._position),this.computeWorldMatrix(!0)):(this._worldMatrix=e,this._absolutePosition.copyFromFloats(this._worldMatrix.m[12],this._worldMatrix.m[13],this._worldMatrix.m[14]),this._afterComputeWorldMatrix()):(this._isWorldMatrixFrozen=!1,this.computeWorldMatrix(!0)),this._isDirty=!1,this._isWorldMatrixFrozen=!0,this}unfreezeWorldMatrix(){return this._isWorldMatrixFrozen=!1,this.computeWorldMatrix(!0),this}get isWorldMatrixFrozen(){return this._isWorldMatrixFrozen}getAbsolutePosition(){return this.computeWorldMatrix(),this._absolutePosition}setAbsolutePosition(e){if(!e)return this;let t,s,i;if(void 0===e.x){if(arguments.length<3)return this;t=arguments[0],s=arguments[1],i=arguments[2]}else t=e.x,s=e.y,i=e.z;if(this.parent){const e=o.AA.Matrix[0];this.parent.getWorldMatrix().invertToRef(e),o.Pq.TransformCoordinatesFromFloatsToRef(t,s,i,e,this.position)}else this.position.x=t,this.position.y=s,this.position.z=i;return this._absolutePosition.copyFrom(e),this}setPositionWithLocalVector(e){return this.computeWorldMatrix(),this.position=o.Pq.TransformNormal(e,this._localMatrix),this}getPositionExpressedInLocalSpace(){this.computeWorldMatrix();const e=o.AA.Matrix[0];return this._localMatrix.invertToRef(e),o.Pq.TransformNormal(this.position,e)}locallyTranslate(e){return this.computeWorldMatrix(!0),this.position=o.Pq.TransformCoordinates(e,this._localMatrix),this}lookAt(e,t=0,s=0,i=0,r=0){const n=u._LookAtVectorCache,a=0===r?this.position:this.getAbsolutePosition();if(e.subtractToRef(a,n),this.setDirection(n,t,s,i),1===r&&this.parent)if(this.rotationQuaternion){const e=o.AA.Matrix[0];this.rotationQuaternion.toRotationMatrix(e);const t=o.AA.Matrix[1];this.parent.getWorldMatrix().getRotationMatrixToRef(t),t.invert(),e.multiplyToRef(t,e),this.rotationQuaternion.fromRotationMatrix(e)}else{const e=o.AA.Quaternion[0];o.PT.FromEulerVectorToRef(this.rotation,e);const t=o.AA.Matrix[0];e.toRotationMatrix(t);const s=o.AA.Matrix[1];this.parent.getWorldMatrix().getRotationMatrixToRef(s),s.invert(),t.multiplyToRef(s,t),e.fromRotationMatrix(t),e.toEulerAnglesToRef(this.rotation)}return this}getDirection(e){const t=o.Pq.Zero();return this.getDirectionToRef(e,t),t}getDirectionToRef(e,t){return o.Pq.TransformNormalToRef(e,this.getWorldMatrix(),t),this}setDirection(e,t=0,s=0,i=0){const r=-Math.atan2(e.z,e.x)+Math.PI/2,n=Math.sqrt(e.x*e.x+e.z*e.z),a=-Math.atan2(e.y,n);return this.rotationQuaternion?o.PT.RotationYawPitchRollToRef(r+t,a+s,i,this.rotationQuaternion):(this.rotation.x=a+s,this.rotation.y=r+t,this.rotation.z=i),this}setPivotPoint(e,t=0){0==this.getScene().getRenderId()&&this.computeWorldMatrix(!0);const s=this.getWorldMatrix();if(1==t){const t=o.AA.Matrix[0];s.invertToRef(t),e=o.Pq.TransformCoordinates(e,t)}return this.setPivotMatrix(o.uq.Translation(-e.x,-e.y,-e.z),!0)}getPivotPoint(){const e=o.Pq.Zero();return this.getPivotPointToRef(e),e}getPivotPointToRef(e){return e.x=-this._pivotMatrix.m[12],e.y=-this._pivotMatrix.m[13],e.z=-this._pivotMatrix.m[14],this}getAbsolutePivotPoint(){const e=o.Pq.Zero();return this.getAbsolutePivotPointToRef(e),e}getAbsolutePivotPointToRef(e){return this.getPivotPointToRef(e),o.Pq.TransformCoordinatesToRef(e,this.getWorldMatrix(),e),this}markAsDirty(e){if(this._isDirty)return this;if(this._children)for(const t of this._children)t.markAsDirty(e);return super.markAsDirty(e)}setParent(e,t=!1,s=!1){if(!e&&!this.parent)return this;const i=o.AA.Quaternion[0],r=o.AA.Vector3[0],n=o.AA.Vector3[1],a=o.AA.Matrix[1];o.uq.IdentityToRef(a);const h=o.AA.Matrix[0];this.computeWorldMatrix(!0);let l=this.rotationQuaternion;return l||(l=u._TmpRotation,o.PT.RotationYawPitchRollToRef(this._rotation.y,this._rotation.x,this._rotation.z,l)),o.uq.ComposeToRef(this.scaling,l,this.position,h),this.parent&&h.multiplyToRef(this.parent.computeWorldMatrix(!0),h),e&&(e.computeWorldMatrix(!0).invertToRef(a),h.multiplyToRef(a,h)),h.decompose(n,i,r,t?this:void 0),this.rotationQuaternion?this.rotationQuaternion.copyFrom(i):i.toEulerAnglesToRef(this.rotation),this.scaling.copyFrom(n),this.position.copyFrom(r),this.parent=e,s&&this.setPivotMatrix(o.uq.Identity()),this}addChild(e,t=!1){return e.setParent(this,t),this}removeChild(e,t=!1){return e.setParent(null,t),this}get nonUniformScaling(){return this._nonUniformScaling}_updateNonUniformScalingState(e){return this._nonUniformScaling!==e&&(this._nonUniformScaling=e,!0)}attachToBone(e,t){return this._currentParentWhenAttachingToBone=this.parent,this._transformToBoneReferal=t,this.parent=e,e.getSkeleton().prepare(!0),e.getFinalMatrix().determinant()<0&&(this.scalingDeterminant*=-1),this}detachFromBone(e=!1){return this.parent?(this.parent.getWorldMatrix().determinant()<0&&(this.scalingDeterminant*=-1),this._transformToBoneReferal=null,this.parent=e?this._currentParentWhenAttachingToBone:null,this):(e&&(this.parent=this._currentParentWhenAttachingToBone),this)}rotate(e,t,s){let i;if(e.normalize(),this.rotationQuaternion||(this.rotationQuaternion=this.rotation.toQuaternion(),this.rotation.setAll(0)),s&&0!==s){if(this.parent){const s=this.parent.getWorldMatrix(),i=o.AA.Matrix[0];s.invertToRef(i),e=o.Pq.TransformNormal(e,i),s.determinant()<0&&(t*=-1)}i=o.PT.RotationAxisToRef(e,t,u._RotationAxisCache),i.multiplyToRef(this.rotationQuaternion,this.rotationQuaternion)}else i=o.PT.RotationAxisToRef(e,t,u._RotationAxisCache),this.rotationQuaternion.multiplyToRef(i,this.rotationQuaternion);return this}rotateAround(e,t,s){t.normalize(),this.rotationQuaternion||(this.rotationQuaternion=o.PT.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z),this.rotation.setAll(0));const i=o.AA.Vector3[0],r=o.AA.Vector3[1],n=o.AA.Vector3[2],a=o.AA.Quaternion[0],h=o.AA.Matrix[0],l=o.AA.Matrix[1],c=o.AA.Matrix[2],u=o.AA.Matrix[3];return e.subtractToRef(this.position,i),o.uq.TranslationToRef(i.x,i.y,i.z,h),o.uq.TranslationToRef(-i.x,-i.y,-i.z,l),o.uq.RotationAxisToRef(t,s,c),l.multiplyToRef(c,u),u.multiplyToRef(h,u),u.decompose(r,a,n),this.position.addInPlace(n),a.multiplyToRef(this.rotationQuaternion,this.rotationQuaternion),this}translate(e,t,s){const i=e.scale(t);if(s&&0!==s)this.setAbsolutePosition(this.getAbsolutePosition().add(i));else{const e=this.getPositionExpressedInLocalSpace().add(i);this.setPositionWithLocalVector(e)}return this}addRotation(e,t,s){let i;this.rotationQuaternion?i=this.rotationQuaternion:(i=o.AA.Quaternion[1],o.PT.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,i));const r=o.AA.Quaternion[0];return o.PT.RotationYawPitchRollToRef(t,e,s,r),i.multiplyInPlace(r),this.rotationQuaternion||i.toEulerAnglesToRef(this.rotation),this}_getEffectiveParent(){return this.parent}isWorldMatrixCameraDependent(){return this._infiniteDistance&&!this.parent||this._billboardMode!==u.BILLBOARDMODE_NONE&&!this.preserveParentRotationForBillboard}computeWorldMatrix(e=!1,t=null){if(this._isWorldMatrixFrozen&&!this._isDirty)return this._worldMatrix;const s=this.getScene().getRenderId();if(!this._isDirty&&!e&&(this._currentRenderId===s||this.isSynchronized()))return this._currentRenderId=s,this._worldMatrix;t=t||this.getScene().activeCamera,this._updateCache();const i=this._cache;i.pivotMatrixUpdated=!1,i.billboardMode=this.billboardMode,i.infiniteDistance=this.infiniteDistance,i.parent=this._parentNode,this._currentRenderId=s,this._childUpdateId+=1,this._isDirty=!1,this._position._isDirty=!1,this._rotation._isDirty=!1,this._scaling._isDirty=!1;const r=this._getEffectiveParent(),n=u._TmpScaling;let a,h=this._position;if(this._infiniteDistance&&!this.parent&&t){const e=t.getWorldMatrix(),s=new o.Pq(e.m[12],e.m[13],e.m[14]);h=u._TmpTranslation,h.copyFromFloats(this._position.x+s.x,this._position.y+s.y,this._position.z+s.z)}if(n.copyFromFloats(this._scaling.x*this.scalingDeterminant,this._scaling.y*this.scalingDeterminant,this._scaling.z*this.scalingDeterminant),this._rotationQuaternion?(this._rotationQuaternion._isDirty=!1,a=this._rotationQuaternion,this.reIntegrateRotationIntoRotationQuaternion&&this.rotation.lengthSquared()&&(this._rotationQuaternion.multiplyInPlace(o.PT.RotationYawPitchRoll(this._rotation.y,this._rotation.x,this._rotation.z)),this._rotation.copyFromFloats(0,0,0))):(a=u._TmpRotation,o.PT.RotationYawPitchRollToRef(this._rotation.y,this._rotation.x,this._rotation.z,a)),this._usePivotMatrix){const e=o.AA.Matrix[1];o.uq.ScalingToRef(n.x,n.y,n.z,e);const t=o.AA.Matrix[0];a.toRotationMatrix(t),this._pivotMatrix.multiplyToRef(e,o.AA.Matrix[4]),o.AA.Matrix[4].multiplyToRef(t,this._localMatrix),this._postMultiplyPivotMatrix&&this._localMatrix.multiplyToRef(this._pivotMatrixInverse,this._localMatrix),this._localMatrix.addTranslationFromFloats(h.x,h.y,h.z)}else o.uq.ComposeToRef(n,a,h,this._localMatrix);if(r&&r.getWorldMatrix){if(e&&r.computeWorldMatrix(e),i.useBillboardPath){if(this._transformToBoneReferal){const e=this.parent;e.getSkeleton().prepare(),e.getFinalMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(),o.AA.Matrix[7])}else o.AA.Matrix[7].copyFrom(r.getWorldMatrix());const e=o.AA.Vector3[5],t=o.AA.Vector3[6],s=o.AA.Quaternion[0];o.AA.Matrix[7].decompose(t,s,e),o.uq.ScalingToRef(t.x,t.y,t.z,o.AA.Matrix[7]),o.AA.Matrix[7].setTranslation(e),u.BillboardUseParentOrientation&&(this._position.applyRotationQuaternionToRef(s,e),this._localMatrix.setTranslation(e)),this._localMatrix.multiplyToRef(o.AA.Matrix[7],this._worldMatrix)}else if(this._transformToBoneReferal){const e=this.parent;e.getSkeleton().prepare(),this._localMatrix.multiplyToRef(e.getFinalMatrix(),o.AA.Matrix[6]),o.AA.Matrix[6].multiplyToRef(this._transformToBoneReferal.getWorldMatrix(),this._worldMatrix)}else this._localMatrix.multiplyToRef(r.getWorldMatrix(),this._worldMatrix);this._markSyncedWithParent()}else this._worldMatrix.copyFrom(this._localMatrix);if(i.useBillboardPath&&t&&this.billboardMode&&!i.useBillboardPosition){const e=o.AA.Vector3[0];if(this._worldMatrix.getTranslationToRef(e),o.AA.Matrix[1].copyFrom(t.getViewMatrix()),this._scene.useRightHandedSystem&&o.AA.Matrix[1].multiplyToRef(c,o.AA.Matrix[1]),o.AA.Matrix[1].setTranslationFromFloats(0,0,0),o.AA.Matrix[1].invertToRef(o.AA.Matrix[0]),(this.billboardMode&u.BILLBOARDMODE_ALL)!==u.BILLBOARDMODE_ALL){o.AA.Matrix[0].decompose(void 0,o.AA.Quaternion[0],void 0);const e=o.AA.Vector3[1];o.AA.Quaternion[0].toEulerAnglesToRef(e),(this.billboardMode&u.BILLBOARDMODE_X)!==u.BILLBOARDMODE_X&&(e.x=0),(this.billboardMode&u.BILLBOARDMODE_Y)!==u.BILLBOARDMODE_Y&&(e.y=0),(this.billboardMode&u.BILLBOARDMODE_Z)!==u.BILLBOARDMODE_Z&&(e.z=0),o.uq.RotationYawPitchRollToRef(e.y,e.x,e.z,o.AA.Matrix[0])}this._worldMatrix.setTranslationFromFloats(0,0,0),this._worldMatrix.multiplyToRef(o.AA.Matrix[0],this._worldMatrix),this._worldMatrix.setTranslation(o.AA.Vector3[0])}else if(i.useBillboardPath&&t&&i.useBillboardPosition){const e=o.AA.Vector3[0];this._worldMatrix.getTranslationToRef(e);const s=t.globalPosition;this._worldMatrix.invertToRef(o.AA.Matrix[1]);const i=o.AA.Vector3[1];o.Pq.TransformCoordinatesToRef(s,o.AA.Matrix[1],i),i.normalize();const r=-Math.atan2(i.z,i.x)+Math.PI/2,n=Math.sqrt(i.x*i.x+i.z*i.z),a=-Math.atan2(i.y,n);if(o.PT.RotationYawPitchRollToRef(r,a,0,o.AA.Quaternion[0]),(this.billboardMode&u.BILLBOARDMODE_ALL)!==u.BILLBOARDMODE_ALL){const e=o.AA.Vector3[1];o.AA.Quaternion[0].toEulerAnglesToRef(e),(this.billboardMode&u.BILLBOARDMODE_X)!==u.BILLBOARDMODE_X&&(e.x=0),(this.billboardMode&u.BILLBOARDMODE_Y)!==u.BILLBOARDMODE_Y&&(e.y=0),(this.billboardMode&u.BILLBOARDMODE_Z)!==u.BILLBOARDMODE_Z&&(e.z=0),o.uq.RotationYawPitchRollToRef(e.y,e.x,e.z,o.AA.Matrix[0])}else o.uq.FromQuaternionToRef(o.AA.Quaternion[0],o.AA.Matrix[0]);this._worldMatrix.setTranslationFromFloats(0,0,0),this._worldMatrix.multiplyToRef(o.AA.Matrix[0],this._worldMatrix),this._worldMatrix.setTranslation(o.AA.Vector3[0])}return this.ignoreNonUniformScaling?this._updateNonUniformScalingState(!1):this._scaling.isNonUniformWithinEpsilon(1e-6)?this._updateNonUniformScalingState(!0):r&&r._nonUniformScaling?this._updateNonUniformScalingState(r._nonUniformScaling):this._updateNonUniformScalingState(!1),this._afterComputeWorldMatrix(),this._absolutePosition.copyFromFloats(this._worldMatrix.m[12],this._worldMatrix.m[13],this._worldMatrix.m[14]),this._isAbsoluteSynced=!1,this.onAfterWorldMatrixUpdateObservable.notifyObservers(this),this._poseMatrix||(this._poseMatrix=o.uq.Invert(this._worldMatrix)),this._worldMatrixDeterminantIsDirty=!0,this._worldMatrix}resetLocalMatrix(e=!0){if(this.computeWorldMatrix(),e){const e=this.getChildren();for(let t=0;tnew u(e,this.getScene())),this);if(i.name=e,i.id=e,t&&(i.parent=t),!s){const t=this.getDescendants(!0);for(let s=0;snew u(e.name,t)),e,t,s);if(e.localMatrix?i.setPreTransformMatrix(o.uq.FromArray(e.localMatrix)):e.pivotMatrix&&i.setPivotMatrix(o.uq.FromArray(e.pivotMatrix)),i.setEnabled(e.isEnabled),i._waitingParsedUniqueId=e.uniqueId,void 0!==e.parentId&&(i._waitingParentId=e.parentId),void 0!==e.parentInstanceIndex&&(i._waitingParentInstanceIndex=e.parentInstanceIndex),e.animations){for(let t=0;t(!t||t(e))&&e instanceof u)),s}dispose(e,t=!1){if(this.getScene().stopAnimation(this),this.getScene().removeTransformNode(this),this._parentContainer){const e=this._parentContainer.transformNodes.indexOf(this);e>-1&&this._parentContainer.transformNodes.splice(e,1),this._parentContainer=null}if(this.onAfterWorldMatrixUpdateObservable.clear(),e){const e=this.getChildTransformNodes(!0);for(const t of e)t.parent=null,t.computeWorldMatrix(!0)}super.dispose(e,t)}normalizeToUnitCube(e=!0,t=!1,s){let i=null,r=null;t&&(this.rotationQuaternion?(r=this.rotationQuaternion.clone(),this.rotationQuaternion.copyFromFloats(0,0,0,1)):this.rotation&&(i=this.rotation.clone(),this.rotation.copyFromFloats(0,0,0)));const n=this.getHierarchyBoundingVectors(e,s),a=n.max.subtract(n.min),o=Math.max(a.x,a.y,a.z);if(0===o)return this;const h=1/o;return this.scaling.scaleInPlace(h),t&&(this.rotationQuaternion&&r?this.rotationQuaternion.copyFrom(r):this.rotation&&i&&this.rotation.copyFrom(i)),this}_syncAbsoluteScalingAndRotation(){this._isAbsoluteSynced||(this._worldMatrix.decompose(this._absoluteScaling,this._absoluteRotationQuaternion),this._isAbsoluteSynced=!0)}}u.BILLBOARDMODE_NONE=0,u.BILLBOARDMODE_X=1,u.BILLBOARDMODE_Y=2,u.BILLBOARDMODE_Z=4,u.BILLBOARDMODE_ALL=7,u.BILLBOARDMODE_USE_POSITION=128,u.BillboardUseParentOrientation=!1,u._TmpRotation=o.PT.Zero(),u._TmpScaling=o.Pq.Zero(),u._TmpTranslation=o.Pq.Zero(),u._LookAtVectorCache=new o.Pq(0,0,0),u._RotationAxisCache=new o.PT,(0,i.Cg)([(0,r.P_)("position")],u.prototype,"_position",void 0),(0,i.Cg)([(0,r.P_)("rotation")],u.prototype,"_rotation",void 0),(0,i.Cg)([(0,r.bR)("rotationQuaternion")],u.prototype,"_rotationQuaternion",void 0),(0,i.Cg)([(0,r.P_)("scaling")],u.prototype,"_scaling",void 0),(0,i.Cg)([(0,r.lK)("billboardMode")],u.prototype,"_billboardMode",void 0),(0,i.Cg)([(0,r.lK)()],u.prototype,"scalingDeterminant",void 0),(0,i.Cg)([(0,r.lK)("infiniteDistance")],u.prototype,"_infiniteDistance",void 0),(0,i.Cg)([(0,r.lK)()],u.prototype,"ignoreNonUniformScaling",void 0),(0,i.Cg)([(0,r.lK)()],u.prototype,"reIntegrateRotationIntoRotationQuaternion",void 0)},6755:(e,t,s)=>{s.d(t,{d:()=>l});var i=s(9923),r=s(4867),n=s(4640),a=s(5559),o=s(6041);class h{constructor(e,t,s,i){this.name=e,this.worldAxisForNormal=t,this.worldAxisForFileX=s,this.worldAxisForFileY=i}}class l{static ConvertCubeMapTextureToSphericalPolynomial(e){if(!e.isCube)return null;e.getScene()?.getEngine().flushFramebuffer();const t=e.getSize().width,s=e.readPixels(0,void 0,void 0,!1),i=e.readPixels(1,void 0,void 0,!1);let r,n;e.isRenderTarget?(r=e.readPixels(3,void 0,void 0,!1),n=e.readPixels(2,void 0,void 0,!1)):(r=e.readPixels(2,void 0,void 0,!1),n=e.readPixels(3,void 0,void 0,!1));const a=e.readPixels(4,void 0,void 0,!1),o=e.readPixels(5,void 0,void 0,!1),h=e.gammaSpace;let l=0;return 1!=e.textureType&&2!=e.textureType||(l=1),new Promise((e=>{Promise.all([i,s,r,n,a,o]).then((([s,i,r,n,a,o])=>{const c={size:t,right:i,left:s,up:r,down:n,front:a,back:o,format:5,type:l,gammaSpace:h};e(this.ConvertCubeMapToSphericalPolynomial(c))}))}))}static _AreaElement(e,t){return Math.atan2(e*t,Math.sqrt(e*e+t*t+1))}static ConvertCubeMapToSphericalPolynomial(e){const t=new n.O;let s=0;const i=2/e.size,h=i,l=.5*i,c=l-1;for(let n=0;n<6;n++){const u=this._FileFaces[n],d=e[u.name];let _=c;const f=5===e.format?4:3;for(let n=0;nE){const t=E/e;m*=t,T*=t,b*=t}}else m=(0,r.OQ)(m,0,E),T=(0,r.OQ)(T,0,E),b=(0,r.OQ)(b,0,E);const x=new o.v9(m,T,b);t.addLight(c,x,g),s+=g,p+=i}_+=h}}const u=4*Math.PI*6/6/s;return t.scaleInPlace(u),t.convertIncidentRadianceToIrradiance(),t.convertIrradianceToLambertianRadiance(),n.Q.FromHarmonics(t)}}l._FileFaces=[new h("right",new i.Pq(1,0,0),new i.Pq(0,0,-1),new i.Pq(0,-1,0)),new h("left",new i.Pq(-1,0,0),new i.Pq(0,0,1),new i.Pq(0,-1,0)),new h("up",new i.Pq(0,1,0),new i.Pq(1,0,0),new i.Pq(0,0,1)),new h("down",new i.Pq(0,-1,0),new i.Pq(1,0,0),new i.Pq(0,0,-1)),new h("front",new i.Pq(0,0,1),new i.Pq(1,0,0),new i.Pq(0,-1,0)),new h("back",new i.Pq(0,0,-1),new i.Pq(-1,0,0),new i.Pq(0,-1,0))],l.MAX_HDRI_VALUE=4096,l.PRESERVE_CLAMPED_COLORS=!1},7309:(e,t,s)=>{function i(e,t){const s=[];for(let i=0;ia,ln:()=>r,mI:()=>i});const n=["push","splice","pop","shift","unshift"];function a(e,t){const s=n.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()=>{s.forEach((e=>{e?.()}))}}},163:(e,t,s)=>{function i(e,t,s){try{const i=e.next();i.done?t(i):i.value?i.value.then((()=>{i.value=void 0,t(i)}),s):t(i)}catch(e){s(e)}}function r(e=25){let t;return(s,r,n)=>{const a=performance.now();void 0===t||a-t>e?(t=a,setTimeout((()=>{i(s,r,n)}),0)):i(s,r,n)}}function n(e,t,s,i,r){const n=()=>{let a;const o=e=>{e.done?s(e.value):void 0===a?a=!0:n()};do{a=void 0,r&&r.aborted?i(new Error("Aborted")):t(e,o,i),void 0===a&&(a=!1)}while(a)};n()}function a(e,t){let s;return n(e,i,(e=>s=e),(e=>{throw e}),t),s}function o(e,t,s){return new Promise(((i,r)=>{n(e,t,i,r,s)}))}function h(e,t){return(...s)=>a(e(...s),t)}s.d(t,{Aj:()=>h,V1:()=>a,VP:()=>r,kj:()=>o})},3537:(e,t,s)=>{s.d(t,{D:()=>b});var i=s(4867),r=s(1137),n=s(6755),a=s(1947),o=s(854),h=s(655),l=s(8688),c=s(6326),u=s(8454);c.$.prototype._partialLoadFile=function(e,t,s,i,r=null){this._loadFile(e,(e=>{s[t]=e,s._internalCount++,6===s._internalCount&&i(s)}),void 0,void 0,!0,((e,t)=>{r&&e&&r(e.status+" "+e.statusText,t)}))},c.$.prototype._cascadeLoadFiles=function(e,t,s,i=null){const r=[];r._internalCount=0;for(let e=0;e<6;e++)this._partialLoadFile(s[e],e,r,t,i)},c.$.prototype._cascadeLoadImgs=function(e,t,s,i,r=null,n){const a=[];a._internalCount=0;for(let o=0;o<6;o++)this._partialLoadImg(i[o],o,a,e,t,s,r,n)},c.$.prototype._partialLoadImg=function(e,t,s,i,r,n,a=null,o){const c=(0,l.z)();(0,h.W$)(e,(e=>{s[t]=e,s._internalCount++,i&&i.removePendingData(c),6===s._internalCount&&n&&n(r,s)}),((e,t)=>{i&&i.removePendingData(c),a&&a(e,t)}),i?i.offlineProvider:null,o),i&&i.addPendingData(c)},c.$.prototype.createCubeTextureBase=function(e,t,s,i,n=null,a=null,h,l=null,c=!1,d=0,_=0,f=null,p=null,g=null,m=!1,T=null){const b=f||new o.h(this,7);b.isCube=!0,b.url=e,b.generateMipMaps=!i,b._lodGenerationScale=d,b._lodGenerationOffset=_,b._useSRGBBuffer=!!m&&this._caps.supportSRGBBuffers&&(this.version>1||this.isWebGPU||!!i),b!==f&&(b.label=e.substring(0,60)),this._doNotHandleContextLost||(b._extension=l,b._files=s,b._buffer=T);const E=e;this._transformTextureUrl&&!f&&(e=this._transformTextureUrl(e));const x=e.split("?")[0],A=x.lastIndexOf("."),R=l||(A>-1?x.substring(A).toLowerCase():""),M=(0,u.gT)(R),y=(o,u)=>{e===E?a&&o&&a(o.status+" "+o.statusText,u):(r.V.Warn(`Failed to load ${e}, falling back to the ${E}`),this.createCubeTextureBase(E,t,s,!!i,n,a,h,l,c,d,_,b,p,g,m,T))};if(M)M.then((i=>{const o=e=>{p&&p(b,e),i.loadCubeData(e,b,c,n,a)};T?o(T):s&&6===s.length?i.supportCascades?this._cascadeLoadFiles(t,(e=>o(e.map((e=>new Uint8Array(e))))),s,a):a?a("Textures type does not support cascades."):r.V.Warn("Texture loader does not support cascades."):this._loadFile(e,(e=>o(new Uint8Array(e))),void 0,void 0,!0,y)}));else{if(!s||0===s.length)throw new Error("Cannot load cubemap because files were not defined, or the correct loader was not found.");this._cascadeLoadImgs(t,b,((e,t)=>{g&&g(e,t)}),s,a)}return this._internalTexturesCache.push(b),b};const d=131072,_=131072;function f(e){return e.charCodeAt(0)+(e.charCodeAt(1)<<8)+(e.charCodeAt(2)<<16)+(e.charCodeAt(3)<<24)}const p=f("DXT1"),g=f("DXT3"),m=f("DXT5"),T=f("DX10");class b{static GetDDSInfo(e){const t=new Int32Array(e.buffer,e.byteOffset,31),s=new Int32Array(e.buffer,e.byteOffset,35);let i=1;t[2]&d&&(i=Math.max(1,t[7]));const r=t[21],n=r===T?s[32]:0;let a=0;switch(r){case 113:a=2;break;case 116:a=1;break;case T:if(10===n){a=2;break}if(2===n){a=1;break}}return{width:t[4],height:t[3],mipmapCount:i,isFourCC:4==(4&t[20]),isRGB:64==(64&t[20]),isLuminance:(t[20]&_)===_,isCube:512==(512&t[28]),isCompressed:r===p||r===g||r===m,dxgiFormat:n,textureType:a}}static _GetHalfFloatAsFloatRGBAArrayBuffer(e,t,s,i,r,n){const o=new Float32Array(i),h=new Uint16Array(r,s);let l=0;for(let s=0;s>8)}static _GetRGBArrayBuffer(e,t,s,i,r,n,a,o){const h=new Uint8Array(i),l=new Uint8Array(r,s);let c=0;for(let s=0;s>8&255,O>>16&255,O>>24&255))])}var O;const F=b._ExtractLongWordOrder(f[23]),w=b._ExtractLongWordOrder(f[24]),L=b._ExtractLongWordOrder(f[25]),B=b._ExtractLongWordOrder(f[26]);D&&(C=e._getRGBABufferInternalSizedFormat(i.textureType)),y=1,f[2]&d&&!1!==a&&(y=Math.max(1,f[7]));const N=l||0,U=e.getCaps();for(let r=N;r0?i.sphericalPolynomial=n.d.ConvertCubeMapToSphericalPolynomial({size:f[4],right:u[0],left:u[1],up:u[2],down:u[3],front:u[4],back:u[5],format:5,type:1,gammaSpace:!1}):i.sphericalPolynomial=void 0}}b.StoreLODInAlphaChannel=!1},6080:(e,t,s)=>{s.d(t,{B:()=>n,K:()=>a});const i={},r={};function n(e){const t=e.getClassName();return r[t]||(r[t]={}),r[t]}function a(e){const t=e.getClassName();if(i[t])return i[t];i[t]={};const s=i[t];let n=e,a=t;for(;a;){const e=r[a];for(const t in e)s[t]=e[t];let t,i=!1;do{if(t=Object.getPrototypeOf(n),!t.getClassName){i=!0;break}if(t.getClassName()!==a)break;n=t}while(t);if(i)break;a=t.getClassName(),n=t}return s}},9259:(e,t,s)=>{s.d(t,{$z:()=>n,Cx:()=>m,P_:()=>u,WM:()=>c,Y9:()=>l,bR:()=>p,fW:()=>g,jT:()=>h,lK:()=>a,qK:()=>f,uM:()=>o,wL:()=>_,xG:()=>d});var i=s(6080);function r(e,t){return(s,r)=>{const n=(0,i.B)(s);n[r]||(n[r]={type:e,sourceName:t})}}function n(e,t=null){return function(e,t=null){return(s,i)=>{const r=t||"_"+i;Object.defineProperty(s,i,{get:function(){return this[r]},set:function(t){"function"==typeof this.equals&&this.equals(t)||this[r]!==t&&(this[r]=t,s[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 d(e){return r(6,e)}function _(e){return r(7,e)}function f(e){return r(8,e)}function p(e){return r(10,e)}function g(e){return r(11,e)}function m(e,t,s,i){const r=s.value;s.value=(...s)=>{let n=r;if("undefined"!=typeof _native&&_native[t]){const e=_native[t];n=i?(...t)=>i(...t)?e(...t):r(...t):e}return e[t]=n,n(...s)}}m.filter=function(e){return(t,s,i)=>m(t,s,i,e)}},6877:(e,t,s)=>{s.d(t,{p:()=>l});var i=s(5503),r=s(7503),n=s(6041),a=s(9923),o=s(6080);const h=function(e,t,s,i={}){const n=e();r.Y&&r.Y.HasTags(t)&&r.Y.AddTagsTo(n,r.Y.GetTags(t,!0));const a=(0,o.K)(n),h={};for(const e in a){const r=a[e],o=t[e],c=r.type;if(null!=o&&("uniqueId"!==e||l.AllowLoadingUniqueId))switch(c){case 0:case 6:case 11:n[e]=o;break;case 1:i.cloneTexturesOnlyOnce&&h[o.uniqueId]?n[e]=h[o.uniqueId]:(n[e]=s||o.isRenderTarget?o:o.clone(),h[o.uniqueId]=n[e]);break;case 2:case 3:case 4:case 5:case 7:case 10:case 12:n[e]=s?o:o.clone()}}return n};class l{static AppendSerializedAnimations(e,t){if(e.animations){t.animations=[];for(let s=0;s{throw(0,i.n)("ImageProcessingConfiguration")},l._FresnelParametersParser=e=>{throw(0,i.n)("FresnelParameters")},l._ColorCurvesParser=e=>{throw(0,i.n)("ColorCurves")},l._TextureParser=(e,t,s)=>{throw(0,i.n)("Texture")}},4609:(e,t,s)=>{s.d(t,{r:()=>n});var i=s(1137);const r=(e,t,s)=>e?e.getClassName&&"Mesh"===e.getClassName()?null:!e.getClassName||"SubMesh"!==e.getClassName()&&"PhysicsBody"!==e.getClassName()?e.clone?e.clone():Array.isArray(e)?e.slice():s&&"object"==typeof e?{...e}:null:e.clone(t):null;class n{static DeepCopy(e,t,s,n,a=!1){const o=function(e){const t=[];do{Object.getOwnPropertyNames(e).forEach((function(e){-1===t.indexOf(e)&&t.push(e)}))}while(e=Object.getPrototypeOf(e));return t}(e);for(const h of o){if("_"===h[0]&&(!n||-1===n.indexOf(h)))continue;if(h.endsWith("Observable"))continue;if(s&&-1!==s.indexOf(h))continue;const o=e[h],l=typeof o;if("function"!==l)try{if("object"===l)if(o instanceof Uint8Array)t[h]=Uint8Array.from(o);else if(o instanceof Array){if(t[h]=[],o.length>0)if("object"==typeof o[0])for(let e=0;e{s.d(t,{n:()=>r});const i={};function r(e,t=!1){if(!t||!i[e])return i[e]=!0,`${e} needs to be imported before as it contains a side-effect required by your code.`}},8790:(e,t,s)=>{function i(){return"undefined"!=typeof window}function r(){return"undefined"!=typeof navigator}function n(){return"undefined"!=typeof document}function a(e){let t="",s=e.firstChild;for(;s;)3===s.nodeType&&(t+=s.textContent),s=s.nextSibling;return t}s.d(t,{BA:()=>i,Nf:()=>n,XD:()=>r,Zl:()=>a})},8563:(e,t,s)=>{s.d(t,{Cf:()=>i,bu:()=>n,tG:()=>r});class i extends Error{}i._setPrototypeOf=Object.setPrototypeOf||((e,t)=>(e.__proto__=t,e));const r={MeshInvalidPositionsError:0,UnsupportedTextureError:1e3,GLTFLoaderUnexpectedMagicError:2e3,SceneLoaderError:3e3,LoadFileError:4e3,RequestFileError:4001,ReadFileError:4002};class n extends i{constructor(e,t,s){super(e),this.errorCode=t,this.innerError=s,this.name="RuntimeError",i._setPrototypeOf(this,n.prototype)}}},655:(e,t,s)=>{s.d(t,{rz:()=>S,eC:()=>b,f2:()=>v,zU:()=>M,W$:()=>A,NJ:()=>R,sh:()=>y,M1:()=>E});var i=s(2366),r=s(8790),n=s(9848);class a{}a.FilesToLoad={};var o=s(8563),h=s(6181),l=s(9125),c=s(6315),u=s(1137),d=s(2940),_=s(6741),f=s(6326);const p=new RegExp(/^data:([^,]+\/[^,]+)?;base64,/i);class g extends o.bu{constructor(e,t){super(e,o.tG.LoadFileError),this.name="LoadFileError",o.Cf._setPrototypeOf(this,g.prototype),t instanceof i.u?this.request=t:this.file=t}}class m extends o.bu{constructor(e,t){super(e,o.tG.RequestFileError),this.request=t,this.name="RequestFileError",o.Cf._setPrototypeOf(this,m.prototype)}}class T extends o.bu{constructor(e,t){super(e,o.tG.ReadFileError),this.file=t,this.name="ReadFileError",o.Cf._setPrototypeOf(this,T.prototype)}}const b={DefaultRetryStrategy:class{static ExponentialBackoff(e=3,t=500){return(s,i,r)=>0!==i.status||r>=e||-1!==s.indexOf("file:")?-1:Math.pow(2,r)*t}}.ExponentialBackoff(),BaseUrl:"",CorsBehavior:"anonymous",PreprocessUrl:e=>e,ScriptBaseUrl:"",ScriptPreprocessUrl:e=>e,CleanUrl:e=>e.replace(/#/gm,"%23")},E=(e,t)=>{if((!e||0!==e.indexOf("data:"))&&b.CorsBehavior)if("string"==typeof b.CorsBehavior||b.CorsBehavior instanceof String)t.crossOrigin=b.CorsBehavior;else{const s=b.CorsBehavior(e);s&&(t.crossOrigin=s)}},x={getRequiredSize:null},A=(e,t,s,r,n="",o)=>{const l=c.q.LastCreatedEngine;if("undefined"==typeof HTMLImageElement&&!l?._features.forceBitmapOverHTMLImageElement)return s("LoadImage is only supported in web or BabylonNative environments."),null;let u,d=!1;e instanceof ArrayBuffer||ArrayBuffer.isView(e)?"undefined"!=typeof Blob&&"undefined"!=typeof URL?(u=URL.createObjectURL(new Blob([e],{type:n})),d=!0):u=`data:${n};base64,`+(0,h.EL)(e):e instanceof Blob?(u=URL.createObjectURL(e),d=!0):(u=b.CleanUrl(e),u=b.PreprocessUrl(u));const _=t=>{if(s){const i=u||e.toString();s(`Error while trying to load image: ${0===i.indexOf("http")||i.length<=128?i:i.slice(0,128)+"..."}`,t)}};if(l?._features.forceBitmapOverHTMLImageElement)return M(u,(i=>{l.createImageBitmap(new Blob([i],{type:n}),{premultiplyAlpha:"none",...o}).then((e=>{t(e),d&&URL.revokeObjectURL(u)})).catch((t=>{s&&s("Error while trying to load image: "+e,t)}))}),void 0,r||void 0,!0,((e,t)=>{_(t)})),null;const f=new Image;if(x.getRequiredSize){const t=x.getRequiredSize(e);t.width&&(f.width=t.width),t.height&&(f.height=t.height)}E(u,f);const p=[],g=()=>{p.forEach((e=>{e.target.removeEventListener(e.name,e.handler)})),p.length=0};p.push({target:f,name:"load",handler:()=>{g(),t(f),d&&f.src&&URL.revokeObjectURL(f.src)}}),p.push({target:f,name:"error",handler:e=>{g(),_(e),d&&f.src&&URL.revokeObjectURL(f.src)}}),p.push({target:document,name:"securitypolicyviolation",handler:e=>{if(e.blockedURI!==f.src||"report"===e.disposition)return;g();const t=new Error(`CSP violation of policy ${e.effectiveDirective} ${e.blockedURI}. Current policy is ${e.originalPolicy}`);c.q.UseFallbackTexture=!1,_(t),d&&f.src&&URL.revokeObjectURL(f.src),f.src=""}}),p.forEach((e=>{e.target.addEventListener(e.name,e.handler)}));const m="blob:"===u.substring(0,5),T="data:"===u.substring(0,5),A=()=>{m||T||!i.u.IsCustomRequestAvailable?f.src=u:M(u,((e,t,s)=>{const i=new Blob([e],{type:!n&&s?s:n}),r=URL.createObjectURL(i);d=!0,f.src=r}),void 0,r||void 0,!0,((e,t)=>{_(t)}))};if(!m&&!T&&r&&r.enableTexturesOffline)r.open((()=>{r&&r.loadImage(u,f)}),A);else{if(-1!==u.indexOf("file:")){const e=decodeURIComponent(u.substring(5).toLowerCase());if(a.FilesToLoad[e]&&"undefined"!=typeof URL){try{let t;try{t=URL.createObjectURL(a.FilesToLoad[e])}catch(s){t=URL.createObjectURL(a.FilesToLoad[e])}f.src=t,d=!0}catch(e){f.src=""}return f}}A()}return f},R=(e,t,s,i,r)=>{const a=new FileReader,o={onCompleteObservable:new n.cP,abort:()=>a.abort()};return a.onloadend=()=>o.onCompleteObservable.notifyObservers(o),r&&(a.onerror=()=>{r(new T(`Unable to read ${e.name}`,e))}),a.onload=e=>{t(e.target.result)},s&&(a.onprogress=s),i?a.readAsArrayBuffer(e):a.readAsText(e),o},M=(e,t,s,i,r,o,h)=>{if(e.name)return R(e,t,s,r,o?e=>{o(void 0,e)}:void 0);const l=e;if(-1!==l.indexOf("file:")){let e=decodeURIComponent(l.substring(5).toLowerCase());0===e.indexOf("./")&&(e=e.substring(2));const i=a.FilesToLoad[e];if(i)return R(i,t,s,r,o?e=>o(void 0,new g(e.message,e.file)):void 0)}const{match:c,type:_}=C(l);if(c){const e={onCompleteObservable:new n.cP,abort:()=>()=>{}};try{const e=r?S(l):I(l);t(e,void 0,_)}catch(e){o?o(void 0,e):u.V.Error(e.message||"Failed to parse the Data URL")}return d._.SetImmediate((()=>{e.onCompleteObservable.notifyObservers(e)})),e}return y(l,((e,s)=>{t(e,s?.responseURL,s?.getResponseHeader("content-type"))}),s,i,r,o?e=>{o(e.request,new g(e.message,e.request))}:void 0,h)},y=(e,t,s,a,o,h,l)=>{e=b.CleanUrl(e),e=b.PreprocessUrl(e);const c=b.BaseUrl+e;let d=!1;const _={onCompleteObservable:new n.cP,abort:()=>d=!0},f=()=>{let e,n=new i.u,a=null;const f=()=>{n&&(s&&n.removeEventListener("progress",s),e&&n.removeEventListener("readystatechange",e),n.removeEventListener("loadend",p))};let p=()=>{f(),_.onCompleteObservable.notifyObservers(_),_.onCompleteObservable.clear(),s=void 0,e=null,p=null,h=void 0,l=void 0,t=void 0};_.abort=()=>{d=!0,p&&p(),n&&n.readyState!==(XMLHttpRequest.DONE||4)&&n.abort(),null!==a&&(clearTimeout(a),a=null),n=null};const g=e=>{const t=e.message||"Unknown error";h&&n?h(new m(t,n)):u.V.Error(t)},T=u=>{if(n){if(n.open("GET",c),l)try{l(n)}catch(e){return void g(e)}o&&(n.responseType="arraybuffer"),s&&n.addEventListener("progress",s),p&&n.addEventListener("loadend",p),e=()=>{if(!d&&n&&n.readyState===(XMLHttpRequest.DONE||4)){if(e&&n.removeEventListener("readystatechange",e),n.status>=200&&n.status<300||0===n.status&&(!(0,r.BA)()||P())){try{t&&t(o?n.response:n.responseText,n)}catch(e){g(e)}return}const s=b.DefaultRetryStrategy;if(s){const e=s(c,n,u);if(-1!==e)return f(),n=new i.u,void(a=setTimeout((()=>T(u+1)),e))}const l=new m("Error status: "+n.status+" "+n.statusText+" - Unable to load "+c,n);h&&h(l)}},n.addEventListener("readystatechange",e),n.send()}};T(0)};if(a&&a.enableSceneOffline){const i=e=>{e&&e.status>400?h&&h(e):f()},r=()=>{a&&a.loadFile(b.BaseUrl+e,(e=>{!d&&t&&t(e),_.onCompleteObservable.notifyObservers(_)}),s?e=>{!d&&s&&s(e)}:void 0,i,o)};a.open(r,i)}else f();return _},P=()=>"undefined"!=typeof location&&"file:"===location.protocol,v=e=>p.test(e),C=e=>{const t=p.exec(e);return null===t||0===t.length?{match:!1,type:""}:{match:!0,type:t[0].replace("data:","").replace("base64,","")}};function S(e){return(0,h.yS)(e.split(",")[1])}const I=e=>(0,h.AV)(e.split(",")[1]);let D;f.$._FileToolsLoadImage=A,_.sg.loadFile=M,l.J.loadFile=M,((e,t,s,i,r,n,a,o,h,l)=>{D={DecodeBase64UrlToBinary:e,DecodeBase64UrlToString:t,DefaultRetryStrategy:s.DefaultRetryStrategy,BaseUrl:s.BaseUrl,CorsBehavior:s.CorsBehavior,PreprocessUrl:s.PreprocessUrl,IsBase64DataUrl:i,IsFileURL:r,LoadFile:n,LoadImage:a,ReadFile:o,RequestFile:h,SetCorsBehavior:l},Object.defineProperty(D,"DefaultRetryStrategy",{get:function(){return s.DefaultRetryStrategy},set:function(e){s.DefaultRetryStrategy=e}}),Object.defineProperty(D,"BaseUrl",{get:function(){return s.BaseUrl},set:function(e){s.BaseUrl=e}}),Object.defineProperty(D,"PreprocessUrl",{get:function(){return s.PreprocessUrl},set:function(e){s.PreprocessUrl=e}}),Object.defineProperty(D,"CorsBehavior",{get:function(){return s.CorsBehavior},set:function(e){s.CorsBehavior=e}})})(S,I,b,v,P,M,A,R,y,E)},8688:(e,t,s)=>{function i(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))}s.d(t,{z:()=>i})},9337:(e,t,s)=>{s.d(t,{n:()=>n});var i=s(1137),r=s(6552);class n{static Instantiate(e){if(this.RegisteredExternalClasses&&this.RegisteredExternalClasses[e])return this.RegisteredExternalClasses[e];const t=(0,r.n9)(e);if(t)return t;i.V.Warn(e+" not found, you may have missed an import.");const s=e.split(".");let n=window||this;for(let e=0,t=s.length;e{s.d(t,{V:()=>i});class i{static _CheckLimit(e,t){let s=i._LogLimitOutputs[e];return s?s.current++:(s={limit:t,current:1},i._LogLimitOutputs[e]=s),s.current<=s.limit}static _GenerateLimitMessage(e,t=1){const s=i._LogLimitOutputs[e];if(!s||!i.MessageLimitReached)return;const r=this._Levels[t];s.current===s.limit&&i[r.name](i.MessageLimitReached.replace(/%LIMIT%/g,""+s.limit).replace(/%TYPE%/g,r.name??""))}static _AddLogEntry(e){i._LogCache=e+i._LogCache,i.OnNewCacheEntry&&i.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 r=Array.isArray(t)?t[0]:t;if(void 0!==s&&!i._CheckLimit(r,s))return;const n=i._FormatMessage(r),a=this._Levels[e],o=Array.isArray(t)?t.slice(1):[];a.logFunc&&a.logFunc("BJS - "+n,...o);const h=`
${n}

`;i._AddLogEntry(h),i._GenerateLimitMessage(r,e)}static get LogCache(){return i._LogCache}static ClearLogCache(){i._LogCache="",i._LogLimitOutputs={},i.errorsCount=0}static set LogLevels(e){i.Log=i._LogDisabled,i.Warn=i._LogDisabled,i.Error=i._LogDisabled,[i.MessageLogLevel,i.WarningLogLevel,i.ErrorLogLevel].forEach((t=>{if((e&t)===t){const e=this._Levels[t];i[e.name]=i._LogEnabled.bind(i,t)}}))}}i.NoneLogLevel=0,i.MessageLogLevel=1,i.WarningLogLevel=2,i.ErrorLogLevel=4,i.AllLogLevel=7,i.MessageLimitReached="Too many %TYPE%s (%LIMIT%), no more %TYPE%s will be reported for this message.",i._LogCache="",i._LogLimitOutputs={},i._Levels=[{},{color:"white",logFunc:console.log,name:"Log"},{color:"orange",logFunc:console.warn,name:"Warn"},{},{color:"red",logFunc:console.error,name:"Error"}],i.errorsCount=0,i.Log=i._LogEnabled.bind(i,i.MessageLogLevel),i.Warn=i._LogEnabled.bind(i,i.WarningLogLevel),i.Error=i._LogEnabled.bind(i,i.ErrorLogLevel)},9848:(e,t,s)=>{s.d(t,{cP:()=>n});class i{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 r{constructor(e,t,s=null){this.callback=e,this.mask=t,this.scope=s,this._willBeUnregistered=!1,this.unregisterOnNextCall=!1,this._remove=null}remove(){this._remove&&this._remove()}}class n{static FromPromise(e,t){const s=new n;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 i(0),e&&(this._onObserverAdded=e)}add(e,t=-1,s=!1,i=null,n=!1){if(!e)return null;const a=new r(e,t,i);return a.unregisterOnNextCall=n,s?this._observers.unshift(a):this._observers.push(a),this._onObserverAdded&&this._onObserverAdded(a),this._hasNotified&&this.notifyIfTriggered&&void 0!==this._lastNotifiedValue&&this.notifyObserver(a,this._lastNotifiedValue),a._remove=()=>{this.remove(a)},a}addOnce(e){return this.add(e,void 0,void 0,void 0,!0)}remove(e){return!!e&&(e._remove=null,-1!==this._observers.indexOf(e)&&(this._deferUnregister(e),!0))}removeCallback(e,t){for(let s=0;s{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 n;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}}},4296:(e,t,s)=>{s.d(t,{A:()=>r});var i=s(6237);class r{get min(){return this._min}get max(){return this._max}get average(){return this._average}get lastSecAverage(){return this._lastSecAverage}get current(){return this._current}get total(){return this._totalAccumulated}get count(){return this._totalValueCount}constructor(){this._startMonitoringTime=0,this._min=0,this._max=0,this._average=0,this._lastSecAverage=0,this._current=0,this._totalValueCount=0,this._totalAccumulated=0,this._lastSecAccumulated=0,this._lastSecTime=0,this._lastSecValueCount=0}fetchNewFrame(){this._totalValueCount++,this._current=0,this._lastSecValueCount++}addCount(e,t){r.Enabled&&(this._current+=e,t&&this._fetchResult())}beginMonitoring(){r.Enabled&&(this._startMonitoringTime=i.j.Now)}endMonitoring(e=!0){if(!r.Enabled)return;e&&this.fetchNewFrame();const t=i.j.Now;this._current=t-this._startMonitoringTime,e&&this._fetchResult()}endFrame(){this._fetchResult()}_fetchResult(){this._totalAccumulated+=this._current,this._lastSecAccumulated+=this._current,this._min=Math.min(this._min,this._current),this._max=Math.max(this._max,this._current),this._average=this._totalAccumulated/this._totalValueCount;const e=i.j.Now;e-this._lastSecTime>1e3&&(this._lastSecAverage=this._lastSecAccumulated/this._lastSecValueCount,this._lastSecTime=e,this._lastSecAccumulated=0,this._lastSecValueCount=0)}}r.Enabled=!0},6237:(e,t,s)=>{s.d(t,{j:()=>r});var i=s(8790);class r{static get Now(){return(0,i.BA)()&&window.performance&&window.performance.now?window.performance.now():Date.now()}}},7931:(e,t,s)=>{s.d(t,{L:()=>i,b:()=>r});class i{constructor(e){this.length=0,this.data=new Array(e),this._id=i._GlobalId++}push(e){this.data[this.length++]=e,this.length>this.data.length&&(this.data.length*=2)}forEach(e){for(let t=0;tthis.data.length&&(this.data.length=2*(this.length+e.length));for(let t=0;t=this.length?-1:t}contains(e){return-1!==this.indexOf(e)}}i._GlobalId=0;class r extends i{constructor(){super(...arguments),this._duplicateId=0}push(e){super.push(e),e.__smartArrayFlags||(e.__smartArrayFlags={}),e.__smartArrayFlags[this._id]=this._duplicateId}pushNoDuplicate(e){return!(e.__smartArrayFlags&&e.__smartArrayFlags[this._id]===this._duplicateId||(this.push(e),0))}reset(){super.reset(),this._duplicateId++}concatWithNoDuplicate(e){if(0!==e.length){this.length+e.length>this.data.length&&(this.data.length=2*(this.length+e.length));for(let t=0;t{s.d(t,{AV:()=>r,EL:()=>i,yS:()=>n});const i=e=>{const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";let s,i,r,n,a,o,h,l="",c=0;const u=ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e);for(;c>2,a=(3&s)<<4|i>>4,o=(15&i)<<2|r>>6,h=63&r,isNaN(i)?o=h=64:isNaN(r)&&(h=64),l+=t.charAt(n)+t.charAt(a)+t.charAt(o)+t.charAt(h);return l},r=e=>atob(e),n=e=>{const t=r(e),s=t.length,i=new Uint8Array(new ArrayBuffer(s));for(let e=0;e{s.d(t,{Y:()=>r});class i{static Eval(e,t){return"true"===(e=e.match(/\([^()]*\)/g)?e.replace(/\([^()]*\)/g,(e=>(e=e.slice(1,e.length-1),i._HandleParenthesisContent(e,t)))):i._HandleParenthesisContent(e,t))||"false"!==e&&i.Eval(e,t)}static _HandleParenthesisContent(e,t){let s;t=t||(e=>"true"===e);const r=e.split("||");for(const e in r)if(Object.prototype.hasOwnProperty.call(r,e)){let n=i._SimplifyNegation(r[e].trim());const a=n.split("&&");if(a.length>1)for(let e=0;e(e=e.replace(/[\s]/g,(()=>""))).length%2?"!":""))).trim())?e="false":"!false"===e&&(e="true"),e}}class r{static EnableFor(e){e._tags=e._tags||{},e.hasTags=()=>r.HasTags(e),e.addTags=t=>r.AddTagsTo(e,t),e.removeTags=t=>r.RemoveTagsFrom(e,t),e.matchesTagsQuery=t=>r.MatchesQuery(e,t)}static DisableFor(e){delete e._tags,delete e.hasTags,delete e.addTags,delete e.removeTags,delete e.matchesTagsQuery}static HasTags(e){if(!e._tags)return!1;const t=e._tags;for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!0;return!1}static GetTags(e,t=!0){if(!e._tags)return null;if(t){const t=[];for(const s in e._tags)Object.prototype.hasOwnProperty.call(e._tags,s)&&!0===e._tags[s]&&t.push(s);return t.join(" ")}return e._tags}static AddTagsTo(e,t){t&&"string"==typeof t&&t.split(" ").forEach((function(t){r._AddTagTo(e,t)}))}static _AddTagTo(e,t){""!==(t=t.trim())&&"true"!==t&&"false"!==t&&(t.match(/[\s]/)||t.match(/^([!]|([|]|[&]){2})/)||(r.EnableFor(e),e._tags[t]=!0))}static RemoveTagsFrom(e,t){if(!r.HasTags(e))return;const s=t.split(" ");for(const t in s)r._RemoveTagFrom(e,s[t])}static _RemoveTagFrom(e,t){delete e._tags[t]}static MatchesQuery(e,t){return void 0===t||(""===t?r.HasTags(e):i.Eval(t,(t=>r.HasTags(e)&&e._tags[t])))}}},1947:(e,t,s)=>{s.d(t,{Qs:()=>h,SX:()=>d,LZ:()=>u}),s(2781),s(6882);var i=s(7891),r=s(6326),n=s(6552),a=s(6877);class o extends i.w{getClassName(){return"PassPostProcess"}constructor(e,t,s=null,i,r,n,a=0,o=!1){super(e,"pass",null,null,t,s,i,r,n,void 0,a,void 0,null,o)}_gatherImports(e,t){e?(this._webGPUReady=!0,t.push(Promise.all([s.e(126).then(s.bind(s,9965))]))):t.push(Promise.all([s.e(71).then(s.bind(s,9820))])),super._gatherImports(e,t)}static _Parse(e,t,s,i){return a.p.Parse((()=>new o(e.name,e.options,t,e.renderTargetSamplingMode,e._engine,e.reusable)),e,s,i)}}function h(e,t,s,r,n,a,o,h){const l=t.getEngine();return t.isReady=!1,n=n??t.samplingMode,r=r??t.type,a=a??t.format,o=o??t.width,h=h??t.height,-1===r&&(r=0),new Promise((c=>{const u=new i.w("postprocess",e,null,null,1,null,n,l,!1,void 0,r,void 0,null,!1,a);u.externalTextureSamplerBinding=!0;const d=l.createRenderTargetTexture({width:o,height:h},{generateDepthBuffer:!1,generateMipMaps:!1,generateStencilBuffer:!1,samplingMode:n,type:r,format:a});u.onEffectCreatedObservable.addOnce((e=>{e.executeWhenCompiled((()=>{u.onApply=e=>{e._bindTexture("textureSampler",t),e.setFloat2("scale",1,1)},s.postProcessManager.directRender([u],d,!0),l.restoreDefaultFramebuffer(),l._releaseTexture(t),u&&u.dispose(),d._swapAndDie(t),t.type=r,t.format=5,t.isReady=!0,c(t)}))}))}))}let l,c;function u(e){l||(l=new Float32Array(1),c=new Int32Array(l.buffer)),l[0]=e;const t=c[0];let s=t>>16&32768,i=t>>12&2047;const r=t>>23&255;return r<103?s:r>142?(s|=31744,s|=(255==r?0:1)&&8388607&t,s):r<113?(i|=2048,s|=(i>>114-r)+(i>>113-r&1),s):(s|=r-112<<10|i>>1,s+=1&i,s)}function d(e){const t=(32768&e)>>15,s=(31744&e)>>10,i=1023&e;return 0===s?(t?-1:1)*Math.pow(2,-14)*(i/Math.pow(2,10)):31==s?i?NaN:1/0*(t?-1:1):(t?-1:1)*Math.pow(2,s-15)*(1+i/Math.pow(2,10))}(0,n.Y5)("BABYLON.PassPostProcess",o),i.w,r.$._RescalePostProcessFactory=e=>new o("rescale",1,null,2,e,!1,0)},2940:(e,t,s)=>{s.d(t,{_:()=>r});var i=s(8790);class r{static SetImmediate(e){(0,i.BA)()&&window.setImmediate?window.setImmediate(e):setTimeout(e,1)}}},1597:(e,t,s)=>{function i(e){let t=1;do{t*=2}while(te-s?s:t}function a(e){return e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,++e}function o(e){return e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,(e|=e>>16)-(e>>1)}function h(e,t,s=2){let i;switch(s){case 1:i=o(e);break;case 2:i=n(e);break;default:i=a(e)}return Math.min(i,t)}s.d(t,{C4:()=>o,L8:()=>i,OG:()=>n,R:()=>h,zF:()=>r})},998:(e,t,s)=>{s.d(t,{LV:()=>m,S0:()=>g});var i=s(9848),r=s(8790),n=s(1137),a=s(4609),o=s(6237),h=s(5503),l=s(2366),c=s(6315),u=s(655),d=s(2940),_=s(9337),f=s(8688),p=s(1597);class g{static get BaseUrl(){return u.eC.BaseUrl}static set BaseUrl(e){u.eC.BaseUrl=e}static get CleanUrl(){return u.eC.CleanUrl}static set CleanUrl(e){u.eC.CleanUrl=e}static IsAbsoluteUrl(e){return 0===e.indexOf("//")||-1!==e.indexOf("://")&&-1!==e.indexOf(".")&&-1!==e.indexOf("/")&&!(e.indexOf(":")>e.indexOf("/"))&&(e.indexOf("://"){(0,u.zU)(e,(e=>{s(e)}),void 0,void 0,t,((e,t)=>{i(t)}))}))}static GetBabylonScriptURL(e,t){if(!e)return"";if(g.ScriptBaseUrl&&e.startsWith(g._DefaultCdnUrl)){const t="/"===g.ScriptBaseUrl[g.ScriptBaseUrl.length-1]?g.ScriptBaseUrl.substring(0,g.ScriptBaseUrl.length-1):g.ScriptBaseUrl;e=e.replace(g._DefaultCdnUrl,t)}return e=g.ScriptPreprocessUrl(e),t&&(e=g.GetAbsoluteUrl(e)),e}static LoadBabylonScript(e,t,s,i){e=g.GetBabylonScriptURL(e),g.LoadScript(e,t,s)}static LoadBabylonScriptAsync(e){return e=g.GetBabylonScriptURL(e),g.LoadScriptAsync(e)}static LoadScript(e,t,s,i,n=!1){if("function"==typeof importScripts){try{importScripts(e),t&&t()}catch(t){s?.(`Unable to load script '${e}' in worker`,t)}return}if(!(0,r.BA)())return void s?.(`Cannot load script '${e}' outside of a window or a worker`);const a=document.getElementsByTagName("head")[0],o=document.createElement("script");n?(o.setAttribute("type","module"),o.innerText=e):(o.setAttribute("type","text/javascript"),o.setAttribute("src",e)),i&&(o.id=i),o.onload=()=>{t&&t()},o.onerror=t=>{s&&s(`Unable to load script '${e}'`,t)},a.appendChild(o)}static LoadScriptAsync(e,t){return new Promise(((s,i)=>{this.LoadScript(e,(()=>{s()}),((e,t)=>{i(t||new Error(e))}),t)}))}static ReadFileAsDataURL(e,t,s){const r=new FileReader,n={onCompleteObservable:new i.cP,abort:()=>r.abort()};return r.onloadend=()=>{n.onCompleteObservable.notifyObservers(n)},r.onload=e=>{t(e.target.result)},r.onprogress=s,r.readAsDataURL(e),n}static ReadFile(e,t,s,i,r){return(0,u.NJ)(e,t,s,i,r)}static FileAsURL(e){const t=new Blob([e]);return window.URL.createObjectURL(t)}static Format(e,t=2){return e.toFixed(t)}static DeepCopy(e,t,s,i){a.r.DeepCopy(e,t,s,i)}static IsEmpty(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}static RegisterTopRootEvents(e,t){for(let s=0;s{const i=atob(this.toDataURL(t,s).split(",")[1]),r=i.length,n=new Uint8Array(r);for(let e=0;et(e))):e.toBlob((function(e){t(e)}),s,i)}static DownloadBlob(e,t){if("download"in document.createElement("a")){if(!t){const e=new Date;t="screenshot_"+(e.getFullYear()+"-"+(e.getMonth()+1)).slice(2)+"-"+e.getDate()+"_"+e.getHours()+"-"+("0"+e.getMinutes()).slice(-2)+".png"}g.Download(e,t)}else if(e&&"undefined"!=typeof URL){const t=URL.createObjectURL(e),s=window.open("");if(!s)return;const i=s.document.createElement("img");i.onload=function(){URL.revokeObjectURL(t)},i.src=t,s.document.body.appendChild(i)}}static EncodeScreenshotCanvasData(e,t,s="image/png",i,r){if("string"!=typeof i&&t){if(t){if(g._IsOffScreenCanvas(e))return void e.convertToBlob({type:s,quality:r}).then((e=>{const s=new FileReader;s.readAsDataURL(e),s.onloadend=()=>{const e=s.result;t(e)}}));const i=e.toDataURL(s,r);t(i)}}else this.ToBlob(e,(function(e){e&&g.DownloadBlob(e,i),t&&t("")}),s,r)}static Download(e,t){if("undefined"==typeof URL)return;const s=window.URL.createObjectURL(e),i=document.createElement("a");document.body.appendChild(i),i.style.display="none",i.href=s,i.download=t,i.addEventListener("click",(()=>{i.parentElement&&i.parentElement.removeChild(i)})),i.click(),window.URL.revokeObjectURL(s)}static BackCompatCameraNoPreventDefault(e){return"boolean"==typeof e[0]?e[0]:"boolean"==typeof e[1]&&e[1]}static CreateScreenshot(e,t,s,i,r="image/png",n=!1,a){throw(0,h.n)("ScreenshotTools")}static CreateScreenshotAsync(e,t,s,i="image/png",r){throw(0,h.n)("ScreenshotTools")}static CreateScreenshotUsingRenderTarget(e,t,s,i,r="image/png",n=1,a=!1,o,l=!1,c=!1,u=!0,d,_){throw(0,h.n)("ScreenshotTools")}static CreateScreenshotUsingRenderTargetAsync(e,t,s,i="image/png",r=1,n=!1,a,o=!1,l=!1,c=!0,u,d){throw(0,h.n)("ScreenshotTools")}static RandomId(){return(0,f.z)()}static IsBase64(e){return(0,u.f2)(e)}static DecodeBase64(e){return(0,u.rz)(e)}static get errorsCount(){return n.V.errorsCount}static Log(e){n.V.Log(e)}static Warn(e){n.V.Warn(e)}static Error(e){n.V.Error(e)}static get LogCache(){return n.V.LogCache}static ClearLogCache(){n.V.ClearLogCache()}static set LogLevels(e){n.V.LogLevels=e}static set PerformanceLogLevel(e){return(e&g.PerformanceUserMarkLogLevel)===g.PerformanceUserMarkLogLevel?(g.StartPerformanceCounter=g._StartUserMark,void(g.EndPerformanceCounter=g._EndUserMark)):(e&g.PerformanceConsoleLogLevel)===g.PerformanceConsoleLogLevel?(g.StartPerformanceCounter=g._StartPerformanceConsole,void(g.EndPerformanceCounter=g._EndPerformanceConsole)):(g.StartPerformanceCounter=g._StartPerformanceCounterDisabled,void(g.EndPerformanceCounter=g._EndPerformanceCounterDisabled))}static _StartPerformanceCounterDisabled(e,t){}static _EndPerformanceCounterDisabled(e,t){}static _StartUserMark(e,t=!0){if(!g._Performance){if(!(0,r.BA)())return;g._Performance=window.performance}t&&g._Performance.mark&&g._Performance.mark(e+"-Begin")}static _EndUserMark(e,t=!0){t&&g._Performance.mark&&(g._Performance.mark(e+"-End"),g._Performance.measure(e,e+"-Begin",e+"-End"))}static _StartPerformanceConsole(e,t=!0){t&&(g._StartUserMark(e,t),console.time&&console.time(e))}static _EndPerformanceConsole(e,t=!0){t&&(g._EndUserMark(e,t),console.timeEnd(e))}static get Now(){return o.j.Now}static GetClassName(e,t=!1){let s=null;return!t&&e.getClassName?s=e.getClassName():(e instanceof Object&&(s=(t?e:Object.getPrototypeOf(e)).constructor.__bjsclassName__),s||(s=typeof e)),s}static First(e,t){for(const s of e)if(t(s))return s;return null}static getFullClassName(e,t=!1){let s=null,i=null;if(!t&&e.getClassName)s=e.getClassName();else{if(e instanceof Object){const r=t?e:Object.getPrototypeOf(e);s=r.constructor.__bjsclassName__,i=r.constructor.__bjsmoduleName__}s||(s=typeof e)}return s?(null!=i?i+".":"")+s:null}static DelayAsync(e){return new Promise((t=>{setTimeout((()=>{t()}),e)}))}static IsSafari(){return!!(0,r.XD)()&&/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}}g.UseCustomRequestHeaders=!1,g.CustomRequestHeaders=l.u.CustomRequestHeaders,g.GetDOMTextContent=r.Zl,g._DefaultCdnUrl="https://cdn.babylonjs.com",g.GetAbsoluteUrl="object"==typeof document?e=>{const t=document.createElement("a");return t.href=e,t.href}:"function"==typeof URL&&"object"==typeof location?e=>new URL(e,location.origin).href:()=>{throw new Error("Unable to get absolute URL. Override BABYLON.Tools.GetAbsoluteUrl to a custom implementation for the current context.")},g.NoneLogLevel=n.V.NoneLogLevel,g.MessageLogLevel=n.V.MessageLogLevel,g.WarningLogLevel=n.V.WarningLogLevel,g.ErrorLogLevel=n.V.ErrorLogLevel,g.AllLogLevel=n.V.AllLogLevel,g.IsWindowObjectExist=r.BA,g.PerformanceNoneLogLevel=0,g.PerformanceUserMarkLogLevel=1,g.PerformanceConsoleLogLevel=2,g.StartPerformanceCounter=g._StartPerformanceCounterDisabled,g.EndPerformanceCounter=g._EndPerformanceCounterDisabled;class m{constructor(e,t,s,i=0){this.iterations=e,this.index=i-1,this._done=!1,this._fn=t,this._successCallback=s}executeNext(){this._done||(this.index+1{r&&r()?i.breakLoop():setTimeout((()=>{for(let n=0;n=e)break;if(s(a),r&&r()){i.breakLoop();break}}i.executeNext()}),n)}),i)}}g.Mix=p.zF,g.IsExponentOfTwo=p.L8,c.q.FallbackTexture="data:image/jpg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/4QBmRXhpZgAATU0AKgAAAAgABAEaAAUAAAABAAAAPgEbAAUAAAABAAAARgEoAAMAAAABAAIAAAExAAIAAAAQAAAATgAAAAAAAABgAAAAAQAAAGAAAAABcGFpbnQubmV0IDQuMC41AP/bAEMABAIDAwMCBAMDAwQEBAQFCQYFBQUFCwgIBgkNCw0NDQsMDA4QFBEODxMPDAwSGBITFRYXFxcOERkbGRYaFBYXFv/bAEMBBAQEBQUFCgYGChYPDA8WFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFv/AABEIAQABAAMBIgACEQEDEQH/xAAfAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgv/xAC1EAACAQMDAgQDBQUEBAAAAX0BAgMABBEFEiExQQYTUWEHInEUMoGRoQgjQrHBFVLR8CQzYnKCCQoWFxgZGiUmJygpKjQ1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4eLj5OXm5+jp6vHy8/T19vf4+fr/xAAfAQADAQEBAQEBAQEBAAAAAAAAAQIDBAUGBwgJCgv/xAC1EQACAQIEBAMEBwUEBAABAncAAQIDEQQFITEGEkFRB2FxEyIygQgUQpGhscEJIzNS8BVictEKFiQ04SXxFxgZGiYnKCkqNTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqCg4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2dri4+Tl5ufo6ery8/T19vf4+fr/2gAMAwEAAhEDEQA/APH6KKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FCiiigD6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++gooooA+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gUKKKKAPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76CiiigD5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BQooooA+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/voKKKKAPl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FCiiigD6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++gooooA+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gUKKKKAPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76CiiigD5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BQooooA+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/voKKKKAPl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FCiiigD6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++gooooA+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gUKKKKAPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76P//Z"},6552:(e,t,s)=>{s.d(t,{Y5:()=>r,n9:()=>n});const i={};function r(e,t){i[e]=t}function n(e){return i[e]}},2366:(e,t,s)=>{s.d(t,{u:()=>i});class i{constructor(){this._xhr="undefined"!=typeof _native&&_native.XMLHttpRequest?new _native.XMLHttpRequest:new XMLHttpRequest,this._requestURL=""}static get IsCustomRequestAvailable(){return Object.keys(i.CustomRequestHeaders).length>0||i.CustomRequestModifiers.length>0}get requestURL(){return this._requestURL}_injectCustomRequestHeaders(){if(!this._shouldSkipRequestModifications(this._requestURL))for(const e in i.CustomRequestHeaders){const t=i.CustomRequestHeaders[e];t&&this._xhr.setRequestHeader(e,t)}}_shouldSkipRequestModifications(e){return i.SkipRequestModificationForBabylonCDN&&(e.includes("preview.babylonjs.com")||e.includes("cdn.babylonjs.com"))}get onprogress(){return this._xhr.onprogress}set onprogress(e){this._xhr.onprogress=e}get readyState(){return this._xhr.readyState}get status(){return this._xhr.status}get statusText(){return this._xhr.statusText}get response(){return this._xhr.response}get responseURL(){return this._xhr.responseURL}get responseText(){return this._xhr.responseText}get responseType(){return this._xhr.responseType}set responseType(e){this._xhr.responseType=e}get timeout(){return this._xhr.timeout}set timeout(e){this._xhr.timeout=e}addEventListener(e,t,s){this._xhr.addEventListener(e,t,s)}removeEventListener(e,t,s){this._xhr.removeEventListener(e,t,s)}abort(){this._xhr.abort()}send(e){i.CustomRequestHeaders&&this._injectCustomRequestHeaders(),this._xhr.send(e)}open(e,t){for(const e of i.CustomRequestModifiers){if(this._shouldSkipRequestModifications(t))return;e(this._xhr,t)}t=(t=t.replace("file:http:","http:")).replace("file:https:","https:"),this._requestURL=t,this._xhr.open(e,t,!0)}setRequestHeader(e,t){this._xhr.setRequestHeader(e,t)}getResponseHeader(e){return this._xhr.getResponseHeader(e)}}i.CustomRequestHeaders={},i.CustomRequestModifiers=new Array,i.SkipRequestModificationForBabylonCDN=!0},706:(e,t,s)=>{s.d(t,{M:()=>c});var i=s(5524),r=s(9848),n=s(6315),a=s(5616),o=s(9259),h=s(6877),l=s(6552);class c{get influence(){return this._influence}set influence(e){if(this._influence===e)return;const t=this._influence;this._influence=e,this.onInfluenceChanged.hasObservers()&&this.onInfluenceChanged.notifyObservers(0===t||0===e)}get animationPropertiesOverride(){return!this._animationPropertiesOverride&&this._scene?this._scene.animationPropertiesOverride:this._animationPropertiesOverride}set animationPropertiesOverride(e){this._animationPropertiesOverride=e}constructor(e,t=0,s=null){this.name=e,this.animations=[],this._positions=null,this._normals=null,this._tangents=null,this._uvs=null,this._uniqueId=0,this.onInfluenceChanged=new r.cP,this._onDataLayoutChanged=new r.cP,this._animationPropertiesOverride=null,this.id=e,this._scene=s||n.q.LastCreatedScene,this.influence=t,this._scene&&(this._uniqueId=this._scene.getUniqueId())}get uniqueId(){return this._uniqueId}get hasPositions(){return!!this._positions}get hasNormals(){return!!this._normals}get hasTangents(){return!!this._tangents}get hasUVs(){return!!this._uvs}setPositions(e){const t=this.hasPositions;this._positions=e,t!==this.hasPositions&&this._onDataLayoutChanged.notifyObservers(void 0)}getPositions(){return this._positions}setNormals(e){const t=this.hasNormals;this._normals=e,t!==this.hasNormals&&this._onDataLayoutChanged.notifyObservers(void 0)}getNormals(){return this._normals}setTangents(e){const t=this.hasTangents;this._tangents=e,t!==this.hasTangents&&this._onDataLayoutChanged.notifyObservers(void 0)}getTangents(){return this._tangents}setUVs(e){const t=this.hasUVs;this._uvs=e,t!==this.hasUVs&&this._onDataLayoutChanged.notifyObservers(void 0)}getUVs(){return this._uvs}clone(){const e=h.p.Clone((()=>new c(this.name,this.influence,this._scene)),this);return e._positions=this._positions,e._normals=this._normals,e._tangents=this._tangents,e._uvs=this._uvs,e}serialize(){const e={};return e.name=this.name,e.influence=this.influence,e.positions=Array.prototype.slice.call(this.getPositions()),null!=this.id&&(e.id=this.id),this.hasNormals&&(e.normals=Array.prototype.slice.call(this.getNormals())),this.hasTangents&&(e.tangents=Array.prototype.slice.call(this.getTangents())),this.hasUVs&&(e.uvs=Array.prototype.slice.call(this.getUVs())),h.p.AppendSerializedAnimations(this,e),e}getClassName(){return"MorphTarget"}static Parse(e,t){const s=new c(e.name,e.influence);if(s.setPositions(e.positions),null!=e.id&&(s.id=e.id),e.normals&&s.setNormals(e.normals),e.tangents&&s.setTangents(e.tangents),e.uvs&&s.setUVs(e.uvs),e.animations){for(let t=0;t{s.d(t,{j:()=>l});var i=s(7931),r=s(1137),n=s(6315),a=s(706),o=s(2781);class h extends o.g{get depth(){return this._depth}constructor(e,t,s,i,r,n,a=!0,h=!1,l=o.g.TRILINEAR_SAMPLINGMODE,c=0,u){super(null,n,!a,h),this.format=r,this._texture=n.getEngine().createRawTexture2DArray(e,t,s,i,r,a,h,l,null,c,u),this._depth=i,this.is2DArray=!0}update(e){this._texture&&this._getEngine().updateRawTexture2DArray(this._texture,e,this._texture.format,this._texture.invertY,null,this._texture.type)}static CreateRGBATexture(e,t,s,i,r,n=!0,a=!1,o=3,l=0){return new h(e,t,s,i,5,r,n,a,o,l)}}class l{set areUpdatesFrozen(e){e?this._blockCounter++:(this._blockCounter--,this._blockCounter<=0&&(this._blockCounter=0,this._syncActiveTargets(!0)))}get areUpdatesFrozen(){return this._blockCounter>0}constructor(e=null){if(this._targets=new Array,this._targetInfluenceChangedObservers=new Array,this._targetDataLayoutChangedObservers=new Array,this._activeTargets=new i.L(16),this._supportsNormals=!1,this._supportsTangents=!1,this._supportsUVs=!1,this._vertexCount=0,this._uniqueId=0,this._tempInfluences=new Array,this._canUseTextureForTargets=!1,this._blockCounter=0,this._textureVertexStride=0,this._textureWidth=0,this._textureHeight=1,this._parentContainer=null,this.optimizeInfluencers=!0,this.enableNormalMorphing=!0,this.enableTangentMorphing=!0,this.enableUVMorphing=!0,this._numMaxInfluencers=0,this._useTextureToStoreTargets=!0,e||(e=n.q.LastCreatedScene),this._scene=e,this._scene){this._scene.addMorphTargetManager(this),this._uniqueId=this._scene.getUniqueId();const e=this._scene.getEngine().getCaps();this._canUseTextureForTargets=e.canUseGLVertexID&&e.textureFloat&&e.maxVertexTextureImageUnits>0&&e.texture2DArrayMaxLayerCount>1}}get numMaxInfluencers(){return this._numMaxInfluencers}set numMaxInfluencers(e){this._numMaxInfluencers!==e&&(this._numMaxInfluencers=e,this._syncActiveTargets(!0))}get uniqueId(){return this._uniqueId}get vertexCount(){return this._vertexCount}get supportsNormals(){return this._supportsNormals&&this.enableNormalMorphing}get supportsTangents(){return this._supportsTangents&&this.enableTangentMorphing}get supportsUVs(){return this._supportsUVs&&this.enableUVMorphing}get numTargets(){return this._targets.length}get numInfluencers(){return this._activeTargets.length}get influences(){return this._influences}get useTextureToStoreTargets(){return this._useTextureToStoreTargets}set useTextureToStoreTargets(e){this._useTextureToStoreTargets=e}get isUsingTextureForTargets(){return l.EnableTextureStorage&&this.useTextureToStoreTargets&&this._canUseTextureForTargets&&!this._scene?.getEngine().getCaps().disableMorphTargetTexture}getActiveTarget(e){return this._activeTargets.data[e]}getTarget(e){return this._targets[e]}getTargetByName(e){for(const t of this._targets)if(t.name===e)return t;return null}addTarget(e){this._targets.push(e),this._targetInfluenceChangedObservers.push(e.onInfluenceChanged.add((e=>{this._syncActiveTargets(e)}))),this._targetDataLayoutChangedObservers.push(e._onDataLayoutChanged.add((()=>{this._syncActiveTargets(!0)}))),this._syncActiveTargets(!0)}removeTarget(e){const t=this._targets.indexOf(e);t>=0&&(this._targets.splice(t,1),e.onInfluenceChanged.remove(this._targetInfluenceChangedObservers.splice(t,1)[0]),e._onDataLayoutChanged.remove(this._targetDataLayoutChangedObservers.splice(t,1)[0]),this._syncActiveTargets(!0)),this._scene&&this._scene.stopAnimation(e)}_bind(e){e.setFloat3("morphTargetTextureInfo",this._textureVertexStride,this._textureWidth,this._textureHeight),e.setFloatArray("morphTargetTextureIndices",this._morphTargetTextureIndices),e.setTexture("morphTargets",this._targetStoreTexture),e.setInt("morphTargetCount",this.numInfluencers)}clone(){const e=new l(this._scene);for(const t of this._targets)e.addTarget(t.clone());return e.enableNormalMorphing=this.enableNormalMorphing,e.enableTangentMorphing=this.enableTangentMorphing,e.enableUVMorphing=this.enableUVMorphing,e}serialize(){const e={};e.id=this.uniqueId,e.targets=[];for(const t of this._targets)e.targets.push(t.serialize());return e}_syncActiveTargets(e){if(this.areUpdatesFrozen)return;let t=0;this._activeTargets.reset(),this._supportsNormals=!0,this._supportsTangents=!0,this._supportsUVs=!0,this._vertexCount=0,this._scene&&this._targets.length>this._scene.getEngine().getCaps().texture2DArrayMaxLayerCount&&(this.useTextureToStoreTargets=!1),this._morphTargetTextureIndices&&this._morphTargetTextureIndices.length===this._targets.length||(this._morphTargetTextureIndices=new Float32Array(this._targets.length));let s=-1;for(const e of this._targets){if(s++,0===e.influence&&this.optimizeInfluencers)continue;if(this._activeTargets.length>=l.MaxActiveMorphTargetsInVertexAttributeMode&&!this.isUsingTextureForTargets)break;this._activeTargets.push(e),this._morphTargetTextureIndices[t]=s,this._tempInfluences[t++]=e.influence,this._supportsNormals=this._supportsNormals&&e.hasNormals,this._supportsTangents=this._supportsTangents&&e.hasTangents,this._supportsUVs=this._supportsUVs&&e.hasUVs;const i=e.getPositions();if(i){const e=i.length/3;if(0===this._vertexCount)this._vertexCount=e;else if(this._vertexCount!==e)return void r.V.Error("Incompatible target. Targets must all have the same vertices count.")}}this._morphTargetTextureIndices.length!==t&&(this._morphTargetTextureIndices=this._morphTargetTextureIndices.slice(0,t)),this._influences&&this._influences.length===t||(this._influences=new Float32Array(t));for(let e=0;e0)){this._textureVertexStride=1,this._supportsNormals&&this._textureVertexStride++,this._supportsTangents&&this._textureVertexStride++,this._supportsUVs&&this._textureVertexStride++,this._textureWidth=this._vertexCount*this._textureVertexStride||1,this._textureHeight=1;const e=this._scene.getEngine().getCaps().maxTextureSize;this._textureWidth>e&&(this._textureHeight=Math.ceil(this._textureWidth/e),this._textureWidth=e);let t=!0;if(this._targetStoreTexture){const e=this._targetStoreTexture.getSize();e.width===this._textureWidth&&e.height===this._textureHeight&&this._targetStoreTexture.depth===this._targets.length&&(t=!1)}if(t){this._targetStoreTexture&&this._targetStoreTexture.dispose();const e=this._targets.length,t=new Float32Array(e*this._textureWidth*this._textureHeight*4);let s=0;for(let i=0;i-1&&this._parentContainer.morphTargetManagers.splice(e,1),this._parentContainer=null}for(const e of this._targets)this._scene.stopAnimation(e)}}static Parse(e,t){const s=new l(t);for(const i of e.targets)s.addTarget(a.M.Parse(i,t));return s}}l.EnableTextureStorage=!0,l.MaxActiveMorphTargetsInVertexAttributeMode=8},3770:(e,t,s)=>{s.d(t,{e:()=>ae});var i=s(5524),r=s(9259),n=s(6877),a=s(9848),o=s(1137),h=s(2781),l=s(554),c=s(9923),u=s(5616),d=s(6882),_=s(8986),f=s(6532),p=s(998),g=s(6041),m=s(6315),T=s(5503),b=s(2565),E=s(5476),x=s(492),A=s(467),R=s(1597);class M{get camera(){return this._effectLayerOptions.camera}get renderingGroupId(){return this._effectLayerOptions.renderingGroupId}set renderingGroupId(e){this._effectLayerOptions.renderingGroupId=e}get mainTexture(){return this._mainTexture}get shaderLanguage(){return this._shaderLanguage}setMaterialForRendering(e,t){if(this._mainTexture.setMaterialForRendering(e,t),Array.isArray(e))for(let s=0;s{if((s||0===t)&&e.subMeshes)for(let t=0;t{let r;this.onBeforeRenderMainTextureObservable.notifyObservers(this);const n=this._scene.getEngine();if(i.length){for(n.setColorWrite(!1),r=0;r{e.clear(this.neutralColor,!0,!0,!0)})),this._scene.getBoundingBoxRenderer){const e=this._scene.getBoundingBoxRenderer().enabled;this._mainTexture.onBeforeBindObservable.add((()=>{this._scene.getBoundingBoxRenderer().enabled=!this.disableBoundingBoxesFromEffectLayer&&e})),this._mainTexture.onAfterUnbindObservable.add((()=>{this._scene.getBoundingBoxRenderer().enabled=e}))}}_addCustomEffectDefines(e){}_isReady(e,t,s){const i=this._scene.getEngine(),r=e.getMesh(),n=r._internalAbstractMeshDataInfo._materialForRenderPass?.[i.currentRenderPassId];if(n)return n.isReadyForSubMesh(r,e,t);const a=e.getMaterial();if(!a)return!1;if(this._useMeshMaterial(e.getRenderingMesh()))return a.isReadyForSubMesh(e.getMesh(),e,t);const o=[],h=[u.R.PositionKind];let l=!1,c=!1;if(a){const e=a.needAlphaTesting(),t=a.getAlphaTestTexture(),s=t&&t.hasAlpha&&(a.useAlphaFromDiffuseTexture||a._useAlphaFromAlbedoTexture);t&&(e||s)&&(o.push("#define DIFFUSE"),r.isVerticesDataPresent(u.R.UV2Kind)&&1===t.coordinatesIndex?(o.push("#define DIFFUSEUV2"),c=!0):r.isVerticesDataPresent(u.R.UVKind)&&(o.push("#define DIFFUSEUV1"),l=!0),e&&(o.push("#define ALPHATEST"),o.push("#define ALPHATESTVALUE 0.4")),t.gammaSpace||o.push("#define DIFFUSE_ISLINEAR"));const i=a.opacityTexture;i&&(o.push("#define OPACITY"),r.isVerticesDataPresent(u.R.UV2Kind)&&1===i.coordinatesIndex?(o.push("#define OPACITYUV2"),c=!0):r.isVerticesDataPresent(u.R.UVKind)&&(o.push("#define OPACITYUV1"),l=!0))}s&&(o.push("#define EMISSIVE"),r.isVerticesDataPresent(u.R.UV2Kind)&&1===s.coordinatesIndex?(o.push("#define EMISSIVEUV2"),c=!0):r.isVerticesDataPresent(u.R.UVKind)&&(o.push("#define EMISSIVEUV1"),l=!0),s.gammaSpace||o.push("#define EMISSIVE_ISLINEAR")),r.useVertexColors&&r.isVerticesDataPresent(u.R.ColorKind)&&r.hasVertexAlpha&&a.transparencyMode!==_.i.MATERIAL_OPAQUE&&(h.push(u.R.ColorKind),o.push("#define VERTEXALPHA")),l&&(h.push(u.R.UVKind),o.push("#define UV1")),c&&(h.push(u.R.UV2Kind),o.push("#define UV2"));const d=new b.J;if(r.useBones&&r.computeBonesUsingShaders){h.push(u.R.MatricesIndicesKind),h.push(u.R.MatricesWeightsKind),r.numBoneInfluencers>4&&(h.push(u.R.MatricesIndicesExtraKind),h.push(u.R.MatricesWeightsExtraKind)),o.push("#define NUM_BONE_INFLUENCERS "+r.numBoneInfluencers);const e=r.skeleton;e&&e.isUsingTextureForMatrices?o.push("#define BONETEXTURE"):o.push("#define BonesPerMesh "+(e?e.bones.length+1:0)),r.numBoneInfluencers>0&&d.addCPUSkinningFallback(0,r)}else o.push("#define NUM_BONE_INFLUENCERS 0");const f=r.morphTargetManager;let p=0;f&&(p=f.numMaxInfluencers||f.numInfluencers,p>0&&(o.push("#define MORPHTARGETS"),o.push("#define NUM_MORPH_INFLUENCERS "+p),f.isUsingTextureForTargets&&o.push("#define MORPHTARGETS_TEXTURE"),(0,A.MF)(h,r,p))),t&&(o.push("#define INSTANCES"),(0,A.te)(h),e.getRenderingMesh().hasThinInstances&&o.push("#define THIN_INSTANCES")),(0,x.tv)(a,this._scene,o),this._addCustomEffectDefines(o);const g=e._getDrawWrapper(void 0,!0),m=g.defines,T=o.join("\n");if(m!==T){const e=["world","mBones","viewProjection","glowColor","morphTargetInfluences","morphTargetCount","boneTextureWidth","diffuseMatrix","emissiveMatrix","opacityMatrix","opacityIntensity","morphTargetTextureInfo","morphTargetTextureIndices","glowIntensity"];(0,x.TV)(e),g.setEffect(this._engine.createEffect("glowMapGeneration",h,e,["diffuseSampler","emissiveSampler","opacitySampler","boneSampler","morphTargets"],T,d,void 0,void 0,{maxSimultaneousMorphTargets:p},this._shaderLanguage,this._shadersLoaded?void 0:async()=>{await this._importShadersAsync(),this._shadersLoaded=!0}),T)}const E=g.effect.isReady();return this._arePostProcessAndMergeReady()&&E}async _importShadersAsync(){1===this._shaderLanguage?await Promise.all([s.e(126).then(s.bind(s,8267)),s.e(126).then(s.bind(s,9073))]):await Promise.all([s.e(71).then(s.bind(s,136)),s.e(71).then(s.bind(s,3234))])}_arePostProcessAndMergeReady(){let e=!0;for(let t=0;tl.setMatrix("world",t)))}else this._mainTexture.resetRefreshCounter();this.onAfterRenderMeshToEffect.notifyObservers(i)}_useMeshMaterial(e){return!1}_rebuild(){const e=this._vertexBuffers[u.R.PositionKind];e&&e._rebuild(),this._generateIndexBuffer()}_disposeTextureAndPostProcesses(){this._mainTexture.dispose();for(let e=0;e-1&&this._scene.effectLayers.splice(t,1),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onBeforeRenderMainTextureObservable.clear(),this.onBeforeComposeObservable.clear(),this.onBeforeRenderMeshToEffect.clear(),this.onAfterRenderMeshToEffect.clear(),this.onAfterComposeObservable.clear(),this.onSizeChangedObservable.clear()}getClassName(){return"EffectLayer"}static Parse(e,t,s){return p.S0.Instantiate(e.customType).Parse(e,t,s)}}M.ForceGLSL=!1,M._SceneComponentInitialization=e=>{throw(0,T.n)("EffectLayerSceneComponent")},(0,i.Cg)([(0,r.lK)()],M.prototype,"name",void 0),(0,i.Cg)([(0,r.qK)()],M.prototype,"neutralColor",void 0),(0,i.Cg)([(0,r.lK)()],M.prototype,"isEnabled",void 0),(0,i.Cg)([(0,r.fW)()],M.prototype,"camera",null),(0,i.Cg)([(0,r.lK)()],M.prototype,"renderingGroupId",null),(0,i.Cg)([(0,r.lK)()],M.prototype,"disableBoundingBoxesFromEffectLayer",void 0);var y=s(6552),P=s(388),v=s(6945);(0,s(3084).ji)(v.v.NAME_EFFECTLAYER,((e,t,s,i)=>{if(e.effectLayers){s.effectLayers||(s.effectLayers=[]);for(let r=0;r{this.scene.addEffectLayer(e)}))}removeFromContainer(e,t){e.effectLayers&&e.effectLayers.forEach((e=>{this.scene.removeEffectLayer(e),t&&e.dispose()}))}dispose(){const e=this.scene.effectLayers;for(;e.length;)e[0].dispose()}_isReadyForMesh(e,t){const s=this._engine.currentRenderPassId,i=this.scene.effectLayers;for(const r of i){if(!r.hasMesh(e))continue;const i=r._mainTexture;this._engine.currentRenderPassId=i.renderPassId;for(const i of e.subMeshes)if(!r.isReady(i,t))return this._engine.currentRenderPassId=s,!1}return this._engine.currentRenderPassId=s,!0}_renderMainTexture(e){this._renderEffects=!1,this._needStencil=!1;let t=!1;const s=this.scene.effectLayers;if(s&&s.length>0){this._previousStencilState=this._engine.getStencilBuffer();for(const i of s)if(i.shouldRender()&&(!i.camera||i.camera.cameraRigMode===P.i.RIG_MODE_NONE&&e===i.camera||i.camera.cameraRigMode!==P.i.RIG_MODE_NONE&&i.camera._rigCameras.indexOf(e)>-1)){this._renderEffects=!0,this._needStencil=this._needStencil||i.needStencil();const e=i._mainTexture;e._shouldRender()&&(this.scene.incrementRenderId(),e.render(!1,!1),t=!0)}this.scene.incrementRenderId()}return t}_setStencil(){this._needStencil&&this._engine.setStencilBuffer(!0)}_setStencilBack(){this._needStencil&&this._engine.setStencilBuffer(this._previousStencilState)}_draw(e){if(this._renderEffects){this._engine.setDepthBuffer(!1);const t=this.scene.effectLayers;for(let s=0;s{let t=e._getComponent(v.v.NAME_EFFECTLAYER);t||(t=new C(e),e._addComponent(t))},l.Z.prototype.getGlowLayerByName=function(e){for(let t=0;t{await this._importShadersAsync(),this._shadersLoaded=!0})}_createTextureAndPostProcesses(){let e=this._mainTextureDesiredSize.width,t=this._mainTextureDesiredSize.height;e=this._engine.needPOTTextures?(0,R.R)(e,this._maxSize):e,t=this._engine.needPOTTextures?(0,R.R)(t,this._maxSize):t;let s=0;s=this._engine.getCaps().textureHalfFloatRender?2:0,this._blurTexture1=new d.$("GlowLayerBlurRTT",{width:e,height:t},this._scene,!1,!0,s),this._blurTexture1.wrapU=h.g.CLAMP_ADDRESSMODE,this._blurTexture1.wrapV=h.g.CLAMP_ADDRESSMODE,this._blurTexture1.updateSamplingMode(h.g.BILINEAR_SAMPLINGMODE),this._blurTexture1.renderParticles=!1,this._blurTexture1.ignoreCameraViewport=!0;const i=Math.floor(e/2),r=Math.floor(t/2);this._blurTexture2=new d.$("GlowLayerBlurRTT2",{width:i,height:r},this._scene,!1,!0,s),this._blurTexture2.wrapU=h.g.CLAMP_ADDRESSMODE,this._blurTexture2.wrapV=h.g.CLAMP_ADDRESSMODE,this._blurTexture2.updateSamplingMode(h.g.BILINEAR_SAMPLINGMODE),this._blurTexture2.renderParticles=!1,this._blurTexture2.ignoreCameraViewport=!0,this._textures=[this._blurTexture1,this._blurTexture2];const n=this._getEffectiveBlurKernelSize();this._horizontalBlurPostprocess1=new f.j("GlowLayerHBP1",new c.I9(1,0),n,{width:e,height:t},null,h.g.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,s),this._horizontalBlurPostprocess1.width=e,this._horizontalBlurPostprocess1.height=t,this._horizontalBlurPostprocess1.externalTextureSamplerBinding=!0,this._horizontalBlurPostprocess1.onApplyObservable.add((e=>{e.setTexture("textureSampler",this._mainTexture)})),this._verticalBlurPostprocess1=new f.j("GlowLayerVBP1",new c.I9(0,1),n,{width:e,height:t},null,h.g.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,s),this._horizontalBlurPostprocess2=new f.j("GlowLayerHBP2",new c.I9(1,0),n,{width:i,height:r},null,h.g.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,s),this._horizontalBlurPostprocess2.width=i,this._horizontalBlurPostprocess2.height=r,this._horizontalBlurPostprocess2.externalTextureSamplerBinding=!0,this._horizontalBlurPostprocess2.onApplyObservable.add((e=>{e.setTexture("textureSampler",this._blurTexture1)})),this._verticalBlurPostprocess2=new f.j("GlowLayerVBP2",new c.I9(0,1),n,{width:i,height:r},null,h.g.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,s),this._postProcesses=[this._horizontalBlurPostprocess1,this._verticalBlurPostprocess1,this._horizontalBlurPostprocess2,this._verticalBlurPostprocess2],this._postProcesses1=[this._horizontalBlurPostprocess1,this._verticalBlurPostprocess1],this._postProcesses2=[this._horizontalBlurPostprocess2,this._verticalBlurPostprocess2],this._mainTexture.samples=this._options.mainTextureSamples,this._mainTexture.onAfterUnbindObservable.add((()=>{const e=this._blurTexture1.renderTarget;if(e){this._scene.postProcessManager.directRender(this._postProcesses1,e,!0);const t=this._blurTexture2.renderTarget;t&&this._scene.postProcessManager.directRender(this._postProcesses2,t,!0),this._engine.unBindFramebuffer(t??e,!0)}})),this._postProcesses.map((e=>{e.autoClear=!1}))}_getEffectiveBlurKernelSize(){return this._options.blurKernelSize/2}isReady(e,t){const s=e.getMaterial(),i=e.getRenderingMesh();if(!s||!i)return!1;const r=s.emissiveTexture;return super._isReady(e,t,r)}needStencil(){return!1}_canRenderMesh(e,t){return!0}_internalRender(e){e.setTexture("textureSampler",this._blurTexture1),e.setTexture("textureSampler2",this._blurTexture2),e.setFloat("offset",this._intensity);const t=this._engine,s=t.getStencilBuffer();t.setStencilBuffer(!1),t.drawElementsType(_.i.TriangleFillMode,0,6),t.setStencilBuffer(s)}_setEmissiveTextureAndColor(e,t,s){let i=1;this.customEmissiveTextureSelector?this._emissiveTextureAndColor.texture=this.customEmissiveTextureSelector(e,t,s):s?(this._emissiveTextureAndColor.texture=s.emissiveTexture,this._emissiveTextureAndColor.texture&&(i=this._emissiveTextureAndColor.texture.level)):this._emissiveTextureAndColor.texture=null,this.customEmissiveColorSelector?this.customEmissiveColorSelector(e,t,s,this._emissiveTextureAndColor.color):s.emissiveColor?(i*=s.emissiveIntensity??1,this._emissiveTextureAndColor.color.set(s.emissiveColor.r*i,s.emissiveColor.g*i,s.emissiveColor.b*i,s.alpha)):this._emissiveTextureAndColor.color.set(this.neutralColor.r,this.neutralColor.g,this.neutralColor.b,this.neutralColor.a)}_shouldRenderMesh(e){return this.hasMesh(e)}_addCustomEffectDefines(e){e.push("#define GLOW")}addExcludedMesh(e){-1===this._excludedMeshes.indexOf(e.uniqueId)&&this._excludedMeshes.push(e.uniqueId)}removeExcludedMesh(e){const t=this._excludedMeshes.indexOf(e.uniqueId);-1!==t&&this._excludedMeshes.splice(t,1)}addIncludedOnlyMesh(e){-1===this._includedOnlyMeshes.indexOf(e.uniqueId)&&this._includedOnlyMeshes.push(e.uniqueId)}removeIncludedOnlyMesh(e){const t=this._includedOnlyMeshes.indexOf(e.uniqueId);-1!==t&&this._includedOnlyMeshes.splice(t,1)}hasMesh(e){return!!super.hasMesh(e)&&(this._includedOnlyMeshes.length?-1!==this._includedOnlyMeshes.indexOf(e.uniqueId):!this._excludedMeshes.length||-1===this._excludedMeshes.indexOf(e.uniqueId))}_useMeshMaterial(e){return 0!=this._meshesUsingTheirOwnMaterials.length&&this._meshesUsingTheirOwnMaterials.indexOf(e.uniqueId)>-1}referenceMeshToUseItsOwnMaterial(e){e.resetDrawCache(this._mainTexture.renderPassId),this._meshesUsingTheirOwnMaterials.push(e.uniqueId),e.onDisposeObservable.add((()=>{this._disposeMesh(e)}))}unReferenceMeshFromUsingItsOwnMaterial(e){let t=this._meshesUsingTheirOwnMaterials.indexOf(e.uniqueId);for(;t>=0;)this._meshesUsingTheirOwnMaterials.splice(t,1),t=this._meshesUsingTheirOwnMaterials.indexOf(e.uniqueId);e.resetDrawCache(this._mainTexture.renderPassId)}_disposeMesh(e){this.removeIncludedOnlyMesh(e),this.removeExcludedMesh(e)}getClassName(){return"GlowLayer"}serialize(){const e=n.p.Serialize(this);let t;if(e.customType="BABYLON.GlowLayer",e.includedMeshes=[],this._includedOnlyMeshes.length)for(t=0;tnew S(e.name,t,e.options)),e,t,s);let r;for(r=0;r{e.setFloat2("screenSize",this.width,this.height),e.setFloat2("sharpnessAmounts",this.edgeAmount,this.colorAmount)}}_gatherImports(e,t){e?(this._webGPUReady=!0,t.push(Promise.all([s.e(126).then(s.bind(s,5381))]))):t.push(Promise.all([Promise.resolve().then(s.bind(s,8438))])),super._gatherImports(e,t)}static _Parse(e,t,s,i){return n.p.Parse((()=>new D(e.name,e.options,t,e.renderTargetSamplingMode,s.getEngine(),e.textureType,e.reusable)),e,s,i)}}(0,i.Cg)([(0,r.lK)()],D.prototype,"colorAmount",void 0),(0,i.Cg)([(0,r.lK)()],D.prototype,"edgeAmount",void 0),(0,y.Y5)("BABYLON.SharpenPostProcess",D);var O=s(1088);class F extends I.w{get imageProcessingConfiguration(){return this._imageProcessingConfiguration}set imageProcessingConfiguration(e){e.applyByPostProcess=!0,this._attachImageProcessingConfiguration(e)}_attachImageProcessingConfiguration(e,t=!1){if(e!==this._imageProcessingConfiguration){if(this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),e)this._imageProcessingConfiguration=e;else{let e=null;const t=this.getEngine(),s=this.getCamera();if(s)e=s.getScene();else if(t&&t.scenes){const s=t.scenes;e=s[s.length-1]}else e=m.q.LastCreatedScene;this._imageProcessingConfiguration=e?e.imageProcessingConfiguration:new O.p}this._imageProcessingConfiguration&&(this._imageProcessingObserver=this._imageProcessingConfiguration.onUpdateParameters.add((()=>{this._updateParameters()}))),t||this._updateParameters()}}get isSupported(){const e=this.getEffect();return!e||e.isSupported}get colorCurves(){return this.imageProcessingConfiguration.colorCurves}set colorCurves(e){this.imageProcessingConfiguration.colorCurves=e}get colorCurvesEnabled(){return this.imageProcessingConfiguration.colorCurvesEnabled}set colorCurvesEnabled(e){this.imageProcessingConfiguration.colorCurvesEnabled=e}get colorGradingTexture(){return this.imageProcessingConfiguration.colorGradingTexture}set colorGradingTexture(e){this.imageProcessingConfiguration.colorGradingTexture=e}get colorGradingEnabled(){return this.imageProcessingConfiguration.colorGradingEnabled}set colorGradingEnabled(e){this.imageProcessingConfiguration.colorGradingEnabled=e}get exposure(){return this.imageProcessingConfiguration.exposure}set exposure(e){this.imageProcessingConfiguration.exposure=e}get toneMappingEnabled(){return this._imageProcessingConfiguration.toneMappingEnabled}set toneMappingEnabled(e){this._imageProcessingConfiguration.toneMappingEnabled=e}get toneMappingType(){return this._imageProcessingConfiguration.toneMappingType}set toneMappingType(e){this._imageProcessingConfiguration.toneMappingType=e}get contrast(){return this.imageProcessingConfiguration.contrast}set contrast(e){this.imageProcessingConfiguration.contrast=e}get vignetteStretch(){return this.imageProcessingConfiguration.vignetteStretch}set vignetteStretch(e){this.imageProcessingConfiguration.vignetteStretch=e}get vignetteCentreX(){return this.imageProcessingConfiguration.vignetteCenterX}set vignetteCentreX(e){this.imageProcessingConfiguration.vignetteCenterX=e}get vignetteCentreY(){return this.imageProcessingConfiguration.vignetteCenterY}set vignetteCentreY(e){this.imageProcessingConfiguration.vignetteCenterY=e}get vignetteCenterY(){return this.imageProcessingConfiguration.vignetteCenterY}set vignetteCenterY(e){this.imageProcessingConfiguration.vignetteCenterY=e}get vignetteCenterX(){return this.imageProcessingConfiguration.vignetteCenterX}set vignetteCenterX(e){this.imageProcessingConfiguration.vignetteCenterX=e}get vignetteWeight(){return this.imageProcessingConfiguration.vignetteWeight}set vignetteWeight(e){this.imageProcessingConfiguration.vignetteWeight=e}get vignetteColor(){return this.imageProcessingConfiguration.vignetteColor}set vignetteColor(e){this.imageProcessingConfiguration.vignetteColor=e}get vignetteCameraFov(){return this.imageProcessingConfiguration.vignetteCameraFov}set vignetteCameraFov(e){this.imageProcessingConfiguration.vignetteCameraFov=e}get vignetteBlendMode(){return this.imageProcessingConfiguration.vignetteBlendMode}set vignetteBlendMode(e){this.imageProcessingConfiguration.vignetteBlendMode=e}get vignetteEnabled(){return this.imageProcessingConfiguration.vignetteEnabled}set vignetteEnabled(e){this.imageProcessingConfiguration.vignetteEnabled=e}get ditheringIntensity(){return this.imageProcessingConfiguration.ditheringIntensity}set ditheringIntensity(e){this.imageProcessingConfiguration.ditheringIntensity=e}get ditheringEnabled(){return this.imageProcessingConfiguration.ditheringEnabled}set ditheringEnabled(e){this.imageProcessingConfiguration.ditheringEnabled=e}get fromLinearSpace(){return this._fromLinearSpace}set fromLinearSpace(e){this._fromLinearSpace!==e&&(this._fromLinearSpace=e,this._updateParameters())}constructor(e,t,s=null,i,r,n,a=0,o){super(e,"imageProcessing",[],[],t,s,i,r,n,null,a,"postprocess",null,!0),this._fromLinearSpace=!0,this._defines={IMAGEPROCESSING:!1,VIGNETTE:!1,VIGNETTEBLENDMODEMULTIPLY:!1,VIGNETTEBLENDMODEOPAQUE:!1,TONEMAPPING:0,CONTRAST:!1,COLORCURVES:!1,COLORGRADING:!1,COLORGRADING3D:!1,FROMLINEARSPACE:!1,SAMPLER3DGREENDEPTH:!1,SAMPLER3DBGRMAP:!1,DITHER:!1,IMAGEPROCESSINGPOSTPROCESS:!1,EXPOSURE:!1,SKIPFINALCOLORCLAMP:!1},o?(o.applyByPostProcess=!0,this._attachImageProcessingConfiguration(o,!0),this._updateParameters()):(this._attachImageProcessingConfiguration(null,!0),this.imageProcessingConfiguration.applyByPostProcess=!0),this.onApply=e=>{this.imageProcessingConfiguration.bind(e,this.aspectRatio)}}_gatherImports(e,t){e?(this._webGPUReady=!0,t.push(s.e(126).then(s.bind(s,7614)))):t.push(s.e(71).then(s.bind(s,3153))),super._gatherImports(e,t)}getClassName(){return"ImageProcessingPostProcess"}_updateParameters(){this._defines.FROMLINEARSPACE=this._fromLinearSpace,this.imageProcessingConfiguration.prepareDefines(this._defines,!0);let e="";for(const t in this._defines){const s=this._defines[t];switch(typeof s){case"number":case"string":e+=`#define ${t} ${s};\n`;break;default:s&&(e+=`#define ${t};\n`)}}const t=["textureSampler"],s=["scale"];O.p&&(O.p.PrepareSamplers(t,this._defines),O.p.PrepareUniforms(s,this._defines)),this.updateEffect(e,s,t)}dispose(e){super.dispose(e),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),this._imageProcessingConfiguration&&(this.imageProcessingConfiguration.applyByPostProcess=!1)}}(0,i.Cg)([(0,r.lK)()],F.prototype,"_fromLinearSpace",void 0);class w extends I.w{getClassName(){return"ChromaticAberrationPostProcess"}constructor(e,t,s,i,r,n,a,o,h=0,l=!1){super(e,"chromaticAberration",["chromatic_aberration","screen_width","screen_height","direction","radialIntensity","centerPosition"],[],i,r,n,a,o,null,h,void 0,null,l),this.aberrationAmount=30,this.radialIntensity=0,this.direction=new c.I9(.707,.707),this.centerPosition=new c.I9(.5,.5),this.screenWidth=t,this.screenHeight=s,this.onApplyObservable.add((e=>{e.setFloat("chromatic_aberration",this.aberrationAmount),e.setFloat("screen_width",t),e.setFloat("screen_height",s),e.setFloat("radialIntensity",this.radialIntensity),e.setFloat2("direction",this.direction.x,this.direction.y),e.setFloat2("centerPosition",this.centerPosition.x,this.centerPosition.y)}))}_gatherImports(e,t){e?(this._webGPUReady=!0,t.push(Promise.all([s.e(126).then(s.bind(s,9619))]))):t.push(Promise.all([s.e(71).then(s.bind(s,2048))])),super._gatherImports(e,t)}static _Parse(e,t,s,i){return n.p.Parse((()=>new w(e.name,e.screenWidth,e.screenHeight,e.options,t,e.renderTargetSamplingMode,s.getEngine(),e.reusable,e.textureType,!1)),e,s,i)}}(0,i.Cg)([(0,r.lK)()],w.prototype,"aberrationAmount",void 0),(0,i.Cg)([(0,r.lK)()],w.prototype,"radialIntensity",void 0),(0,i.Cg)([(0,r.lK)()],w.prototype,"direction",void 0),(0,i.Cg)([(0,r.lK)()],w.prototype,"centerPosition",void 0),(0,i.Cg)([(0,r.lK)()],w.prototype,"screenWidth",void 0),(0,i.Cg)([(0,r.lK)()],w.prototype,"screenHeight",void 0),(0,y.Y5)("BABYLON.ChromaticAberrationPostProcess",w);class L extends I.w{getClassName(){return"GrainPostProcess"}constructor(e,t,s,i,r,n,a=0,o=!1){super(e,"grain",["intensity","animatedSeed"],[],t,s,i,r,n,null,a,void 0,null,o),this.intensity=30,this.animated=!1,this.onApplyObservable.add((e=>{e.setFloat("intensity",this.intensity),e.setFloat("animatedSeed",this.animated?Math.random()+1:1)}))}_gatherImports(e,t){e?(this._webGPUReady=!0,t.push(Promise.all([s.e(126).then(s.bind(s,8625))]))):t.push(Promise.all([s.e(71).then(s.bind(s,890))])),super._gatherImports(e,t)}static _Parse(e,t,s,i){return n.p.Parse((()=>new L(e.name,e.options,t,e.renderTargetSamplingMode,s.getEngine(),e.reusable)),e,s,i)}}(0,i.Cg)([(0,r.lK)()],L.prototype,"intensity",void 0),(0,i.Cg)([(0,r.lK)()],L.prototype,"animated",void 0),(0,y.Y5)("BABYLON.GrainPostProcess",L);class B extends I.w{getClassName(){return"FxaaPostProcess"}constructor(e,t,s=null,i,r,n,a=0){super(e,"fxaa",["texelSize"],null,t,s,i||h.g.BILINEAR_SAMPLINGMODE,r,n,null,a,"fxaa",void 0,!0);const o=this._getDefines();this.updateEffect(o),this.onApplyObservable.add((e=>{const t=this.texelSize;e.setFloat2("texelSize",t.x,t.y)}))}_gatherImports(e,t){e?(this._webGPUReady=!0,t.push(Promise.all([s.e(126).then(s.bind(s,2578)),s.e(126).then(s.bind(s,3208))]))):t.push(Promise.all([s.e(71).then(s.bind(s,5499)),s.e(71).then(s.bind(s,9669))])),super._gatherImports(e,t)}_getDefines(){const e=this.getEngine();return e&&e.extractDriverInfo().toLowerCase().indexOf("mali")>-1?"#define MALI 1\n":null}static _Parse(e,t,s,i){return n.p.Parse((()=>new B(e.name,e.options,t,e.renderTargetSamplingMode,s.getEngine(),e.reusable)),e,s,i)}}(0,y.Y5)("BABYLON.FxaaPostProcess",B);class N{get name(){return this._name}get cameras(){return this._cameras}get engine(){return this._engine}constructor(e,t){this._engine=e,this._name=t,this._renderEffects={},this._renderEffectsForIsolatedPass=new Array,this._cameras=[]}getClassName(){return"PostProcessRenderPipeline"}get isSupported(){for(const e in this._renderEffects)if(Object.prototype.hasOwnProperty.call(this._renderEffects,e)&&!this._renderEffects[e].isSupported)return!1;return!0}addEffect(e){this._renderEffects[e._name]=e}_rebuild(){}_enableEffect(e,t){const s=this._renderEffects[e];s&&s._enable(p.S0.MakeArray(t||this._cameras))}_disableEffect(e,t){const s=this._renderEffects[e];s&&s._disable(p.S0.MakeArray(t||this._cameras))}_attachCameras(e,t){const s=p.S0.MakeArray(e||this._cameras);if(!s)return;const i=[];let r;for(r=0;r0){const s=this._renderEffects[t[0]].getPostProcesses();s&&(s[0].samples=e)}return!0}_adaptPostProcessesToViewPort(){const e=Object.keys(this._renderEffects);for(const t of e){const e=this._renderEffects[t].getPostProcesses();if(e)for(const t of e)t.adaptScaleToCurrentViewport=!0}}setPrePassRenderer(e){return!1}dispose(){}}(0,i.Cg)([(0,r.lK)()],N.prototype,"_name",void 0);class U{constructor(e,t,s,i){this._name=t,this._singleInstance=i||!0,this._getPostProcesses=s,this._cameras={},this._indicesForCamera={},this._postProcesses={}}get isSupported(){for(const e in this._postProcesses)if(Object.prototype.hasOwnProperty.call(this._postProcesses,e)){const t=this._postProcesses[e];for(let e=0;e{const t=i.attachPostProcess(e);this._indicesForCamera[r].push(t)})),this._cameras[r]||(this._cameras[r]=i)}}_detachCameras(e){const t=p.S0.MakeArray(e||this._cameras);if(t)for(let e=0;e{s.detachPostProcess(e)})),this._cameras[i]&&(this._cameras[i]=null),delete this._indicesForCamera[i]}}_enable(e){const t=p.S0.MakeArray(e||this._cameras);if(t)for(let e=0;e{s.detachPostProcess(e)}))}}getPostProcesses(e){return this._singleInstance?this._postProcesses[0]:e?this._postProcesses[e.name]:null}}var k=s(4255),V=s(3720);class G extends k.${_gatherImports(e,t){e?(this._webGPUReady=!0,t.push(s.e(126).then(s.bind(s,2217)))):t.push(s.e(71).then(s.bind(s,7694)))}constructor(e,t=null,s){super({...s,name:e,engine:t||V.N.LastCreatedEngine,useShaderStore:!0,useAsPostProcess:!0,fragmentShader:G.FragmentUrl,uniforms:G.Uniforms,samplers:G.Samplers,defines:s?.depthNotNormalized?G.DefinesDepthNotNormalized:void 0}),this.lensSize=50,this.fStop=1.4,this.focusDistance=2e3,this.focalLength=50}bind(){super.bind();const e=this.options,t=this._drawWrapper.effect;e.depthNotNormalized||t.setFloat2("cameraMinMaxZ",this.camera.minZ,this.camera.maxZ-this.camera.minZ);const s=this.lensSize/this.fStop*this.focalLength/(this.focusDistance-this.focalLength);t.setFloat("focusDistance",this.focusDistance),t.setFloat("cocPrecalculation",s)}}G.FragmentUrl="circleOfConfusion",G.Uniforms=["cameraMinMaxZ","focusDistance","cocPrecalculation"],G.Samplers=["depthSampler"],G.DefinesDepthNotNormalized="#define COC_DEPTH_NOT_NORMALIZED";class z extends I.w{get lensSize(){return this._effectWrapper.lensSize}set lensSize(e){this._effectWrapper.lensSize=e}get fStop(){return this._effectWrapper.fStop}set fStop(e){this._effectWrapper.fStop=e}get focusDistance(){return this._effectWrapper.focusDistance}set focusDistance(e){this._effectWrapper.focusDistance=e}get focalLength(){return this._effectWrapper.focalLength}set focalLength(e){this._effectWrapper.focalLength=e}getClassName(){return"CircleOfConfusionPostProcess"}constructor(e,t,s,i,r,n,a,h=0,l=!1){const c={uniforms:G.Uniforms,samplers:G.Samplers,defines:"object"==typeof s&&s.depthNotNormalized?G.DefinesDepthNotNormalized:void 0,size:"number"==typeof s?s:void 0,camera:i,samplingMode:r,engine:n,reusable:a,textureType:h,blockCompilation:l,...s};super(e,G.FragmentUrl,{effectWrapper:"number"!=typeof s&&s.effectWrapper?void 0:new G(e,n,c),...c}),this._depthTexture=null,this._depthTexture=t,this.onApplyObservable.add((e=>{this._depthTexture?(e.setTexture("depthSampler",this._depthTexture),this._effectWrapper.camera=this._depthTexture.activeCamera):o.V.Warn("No depth texture set on CircleOfConfusionPostProcess")}))}set depthTexture(e){this._depthTexture=e}}(0,i.Cg)([(0,r.lK)()],z.prototype,"lensSize",null),(0,i.Cg)([(0,r.lK)()],z.prototype,"fStop",null),(0,i.Cg)([(0,r.lK)()],z.prototype,"focusDistance",null),(0,i.Cg)([(0,r.lK)()],z.prototype,"focalLength",null),(0,y.Y5)("BABYLON.CircleOfConfusionPostProcess",z);class W extends f.j{getClassName(){return"DepthOfFieldBlurPostProcess"}constructor(e,t,s,i,r,n,a,o=null,l=h.g.BILINEAR_SAMPLINGMODE,c,u,d=0,_=!1,f=5){super(e,s,i,{camera:n,engine:c,reusable:u,textureType:d,defines:"#define DOF 1\n",blockCompilation:_,textureFormat:f,...r,samplingMode:2}),this.externalTextureSamplerBinding=!!o,this.onApplyObservable.add((e=>{null!=o&&e.setTextureFromPostProcess("textureSampler",o),e.setTextureFromPostProcessOutput("circleOfConfusionSampler",a)}))}}(0,y.Y5)("BABYLON.DepthOfFieldBlurPostProcess",W);class H extends k.${_gatherImports(e,t){e?(this._webGPUReady=!0,t.push(s.e(126).then(s.bind(s,9480)))):t.push(s.e(71).then(s.bind(s,9411)))}constructor(e,t=null,s){super({...s,name:e,engine:t||V.N.LastCreatedEngine,useShaderStore:!0,useAsPostProcess:!0,fragmentShader:H.FragmentUrl,samplers:H.Samplers})}}H.FragmentUrl="depthOfFieldMerge",H.Samplers=["circleOfConfusionSampler","blurStep0","blurStep1","blurStep2"];class K extends I.w{getClassName(){return"DepthOfFieldMergePostProcess"}constructor(e,t,s,i,r,n,a,o,h,l=0,c=!1){const u="number"==typeof r?c:!!r.blockCompilation,d={samplers:H.Samplers,size:"number"==typeof r?r:void 0,camera:n,samplingMode:a,engine:o,reusable:h,textureType:l,...r,blockCompilation:!0};super(e,H.FragmentUrl,{effectWrapper:"number"!=typeof r&&r.effectWrapper?void 0:new H(e,o,d),...d}),this._blurSteps=i,this.externalTextureSamplerBinding=!0,this.onApplyObservable.add((e=>{e.setTextureFromPostProcess("textureSampler",t),e.setTextureFromPostProcessOutput("circleOfConfusionSampler",s),i.forEach(((t,s)=>{e.setTextureFromPostProcessOutput("blurStep"+(i.length-s-1),t)}))})),u||this.updateEffect()}updateEffect(e=null,t=null,s=null,i,r,n){e||(e="",e+="#define BLUR_LEVEL "+(this._blurSteps.length-1)+"\n"),super.updateEffect(e,t,s,i,r,n)}}var q,X,Y=s(2309);!function(e){e[e.Low=0]="Low",e[e.Medium=1]="Medium",e[e.High=2]="High"}(q||(q={}));class j{set focalLength(e){this._circleOfConfusion.focalLength=e}get focalLength(){return this._circleOfConfusion.focalLength}set fStop(e){this._circleOfConfusion.fStop=e}get fStop(){return this._circleOfConfusion.fStop}set focusDistance(e){this._circleOfConfusion.focusDistance=e}get focusDistance(){return this._circleOfConfusion.focusDistance}set lensSize(e){this._circleOfConfusion.lensSize=e}get lensSize(){return this._circleOfConfusion.lensSize}constructor(e,t,s=0,i=!1,r=!1){this._depthOfFieldBlurX=[],this._depthOfFieldBlurY=[],this._circleOfConfusion=new G(e,t,{depthNotNormalized:i,blockCompilation:r}),this.blurLevel=s;let n=1,a=15;switch(s){case 2:n=3,a=51;break;case 1:n=2,a=31;break;default:a=15,n=1}const o=a/Math.pow(2,n-1);let h=1;for(let s=0;sthis._effects),!0),this._effects=[],this._thinDepthOfFieldEffect=new j("Depth of Field",a,s,!1,r);const o=a.isWebGPU||a.version>1?6:5;this._circleOfConfusion=new z("circleOfConfusion",t,{size:1,samplingMode:h.g.BILINEAR_SAMPLINGMODE,engine:a,textureType:i,blockCompilation:r,depthNotNormalized:n,effectWrapper:this._thinDepthOfFieldEffect._circleOfConfusion},null),this._depthOfFieldBlurY=[],this._depthOfFieldBlurX=[];const l=this._thinDepthOfFieldEffect._depthOfFieldBlurX.length;for(let e=0;e{this.externalTextureSamplerBinding=!!this._inputPostProcess,this._inputPostProcess&&e.setTextureFromPostProcess("textureSampler",this._inputPostProcess)}))}}(0,i.Cg)([(0,r.lK)()],J.prototype,"threshold",null),(0,y.Y5)("BABYLON.ExtractHighlightsPostProcess",J);class ee extends k.${_gatherImports(e,t){e?(this._webGPUReady=!0,t.push(s.e(126).then(s.bind(s,6645)))):t.push(s.e(71).then(s.bind(s,9336)))}constructor(e,t=null,s){super({...s,name:e,engine:t||V.N.LastCreatedEngine,useShaderStore:!0,useAsPostProcess:!0,fragmentShader:ee.FragmentUrl,uniforms:ee.Uniforms,samplers:ee.Samplers}),this.weight=1}bind(){super.bind(),this._drawWrapper.effect.setFloat("bloomWeight",this.weight)}}ee.FragmentUrl="bloomMerge",ee.Uniforms=["bloomWeight"],ee.Samplers=["bloomBlur"];class te extends I.w{get weight(){return this._effectWrapper.weight}set weight(e){this._effectWrapper.weight=e}getClassName(){return"BloomMergePostProcess"}constructor(e,t,s,i,r,n=null,a,o,h,l=0,c=!1){const u="number"==typeof r?c:!!r.blockCompilation,d={uniforms:ee.Uniforms,samplers:ee.Samplers,size:"number"==typeof r?r:void 0,camera:n,samplingMode:a,engine:o,reusable:h,textureType:l,...r,blockCompilation:!0};super(e,ee.FragmentUrl,{effectWrapper:"number"!=typeof r&&r.effectWrapper?void 0:new ee(e,o,d),...d}),this.weight=i,this.externalTextureSamplerBinding=!0,this.onApplyObservable.add((e=>{e.setTextureFromPostProcess("textureSampler",t),e.setTextureFromPostProcessOutput("bloomBlur",s)})),u||this.updateEffect()}}(0,i.Cg)([(0,r.lK)()],te.prototype,"weight",null),(0,y.Y5)("BABYLON.BloomMergePostProcess",te);class se{get threshold(){return this._downscale.threshold}set threshold(e){this._downscale.threshold=e}get weight(){return this._merge.weight}set weight(e){this._merge.weight=e}get kernel(){return this._blurX.kernel/this.scale}set kernel(e){this._blurX.kernel=e*this.scale,this._blurY.kernel=e*this.scale}constructor(e,t,s,i=!1){this.scale=s,this._downscale=new $(e+"_downscale",t,{blockCompilation:i}),this._blurX=new Y.q(e+"_blurX",t,new c.I9(1,0),10,{blockCompilation:i}),this._blurY=new Y.q(e+"_blurY",t,new c.I9(0,1),10,{blockCompilation:i}),this._merge=new ee(e+"_merge",t,{blockCompilation:i})}isReady(){return this._downscale.isReady()&&this._blurX.isReady()&&this._blurY.isReady()&&this._merge.isReady()}}class ie extends U{get threshold(){return this._thinBloomEffect.threshold}set threshold(e){this._thinBloomEffect.threshold=e}get weight(){return this._thinBloomEffect.weight}set weight(e){this._thinBloomEffect.weight=e}get kernel(){return this._thinBloomEffect.kernel}set kernel(e){this._thinBloomEffect.kernel=e}get bloomScale(){return this._thinBloomEffect.scale}constructor(e,t,s,i,r=0,n=!1){const a=e._renderForCamera?e.getEngine():e;super(a,"bloom",(()=>this._effects),!0),this._effects=[],this._thinBloomEffect=new se("bloom",a,t,n),this._downscale=new J("highlights",{size:1,samplingMode:h.g.BILINEAR_SAMPLINGMODE,engine:a,textureType:r,blockCompilation:n,effectWrapper:this._thinBloomEffect._downscale}),this._blurX=new f.j("horizontal blur",this._thinBloomEffect._blurX.direction,this._thinBloomEffect._blurX.kernel,{size:t,samplingMode:h.g.BILINEAR_SAMPLINGMODE,engine:a,textureType:r,blockCompilation:n,effectWrapper:this._thinBloomEffect._blurX}),this._blurX.alwaysForcePOT=!0,this._blurX.autoClear=!1,this._blurY=new f.j("vertical blur",this._thinBloomEffect._blurY.direction,this._thinBloomEffect._blurY.kernel,{size:t,samplingMode:h.g.BILINEAR_SAMPLINGMODE,engine:a,textureType:r,blockCompilation:n,effectWrapper:this._thinBloomEffect._blurY}),this._blurY.alwaysForcePOT=!0,this._blurY.autoClear=!1,this.kernel=i,this._effects=[this._downscale,this._blurX,this._blurY],this._merge=new te("bloomMerge",this._downscale,this._blurY,s,{size:t,samplingMode:h.g.BILINEAR_SAMPLINGMODE,engine:a,textureType:r,blockCompilation:n,effectWrapper:this._thinBloomEffect._merge}),this._merge.autoClear=!1,this._effects.push(this._merge)}disposeEffects(e){for(let t=0;tthis.sharpen),!0),this.depthOfField=new Z(this._scene,null,this._depthOfFieldBlurLevel,this._defaultPipelineTextureType,!0),this._hardwareScaleLevel=o.getHardwareScalingLevel(),this._resizeObserver=o.onResizeObservable.add((()=>{this._hardwareScaleLevel=o.getHardwareScalingLevel(),this.bloomKernel=this._bloomKernel})),this.bloom=new ie(this._scene,this._bloomScale,this._bloomWeight,this.bloomKernel/this._hardwareScaleLevel,this._defaultPipelineTextureType,!0),this.chromaticAberration=new w("ChromaticAberration",o.getRenderWidth(),o.getRenderHeight(),1,null,h.g.BILINEAR_SAMPLINGMODE,o,!1,this._defaultPipelineTextureType,!0),this._chromaticAberrationEffect=new U(o,this.ChromaticAberrationPostProcessId,(()=>this.chromaticAberration),!0),this.grain=new L("Grain",1,null,h.g.BILINEAR_SAMPLINGMODE,o,!1,this._defaultPipelineTextureType,!0),this._grainEffect=new U(o,this.GrainPostProcessId,(()=>this.grain),!0);let l=!0;this._imageProcessingConfigurationObserver=this._scene.imageProcessingConfiguration.onUpdateParameters.add((()=>{this.bloom._downscale._exposure=this._scene.imageProcessingConfiguration.exposure,this.imageProcessingEnabled!==this._scene.imageProcessingConfiguration.isEnabled&&(this._imageProcessingEnabled=this._scene.imageProcessingConfiguration.isEnabled,l?p.S0.SetImmediate((()=>{this._buildPipeline()})):this._buildPipeline())})),this._buildPipeline(),l=!1}getClassName(){return"DefaultRenderingPipeline"}prepare(){const e=this._buildAllowed;this._buildAllowed=!0,this._buildPipeline(),this._buildAllowed=e}_setAutoClearAndTextureSharing(e,t=!1){this._hasCleared?e.autoClear=!1:(e.autoClear=!0,this._scene.autoClear=!1,this._hasCleared=!0),t||(this._prevPrevPostProcess?e.shareOutputWith(this._prevPrevPostProcess):e.useOwnOutput(),this._prevPostProcess&&(this._prevPrevPostProcess=this._prevPostProcess),this._prevPostProcess=e)}_buildPipeline(){if(!this._buildAllowed)return;this._scene.autoClear=!0;const e=this._scene.getEngine();if(this._disposePostProcesses(),null!==this._cameras&&(this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._cameras),this._cameras=this._camerasToBeAttached.slice()),this._reset(),this._prevPostProcess=null,this._prevPrevPostProcess=null,this._hasCleared=!1,this.depthOfFieldEnabled){if(this._cameras.length>1){for(const e of this._cameras)this._scene.enableDepthRenderer(e).useOnlyInActiveCamera=!0;this._depthOfFieldSceneObserver=this._scene.onAfterRenderTargetsRenderObservable.add((e=>{this._cameras.indexOf(e.activeCamera)>-1&&(this.depthOfField.depthTexture=e.enableDepthRenderer(e.activeCamera).getDepthMap())}))}else{this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);const e=this._scene.enableDepthRenderer(this._cameras[0]);this.depthOfField.depthTexture=e.getDepthMap()}this.depthOfField._isReady()||this.depthOfField._updateEffects(),this.addEffect(this.depthOfField),this._setAutoClearAndTextureSharing(this.depthOfField._effects[0],!0)}else this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);this.bloomEnabled&&(this.bloom._isReady()||this.bloom._updateEffects(),this.addEffect(this.bloom),this._setAutoClearAndTextureSharing(this.bloom._effects[0],!0)),this._imageProcessingEnabled&&(this.imageProcessing=new F("imageProcessing",1,null,h.g.BILINEAR_SAMPLINGMODE,e,!1,this._defaultPipelineTextureType,this.scene.imageProcessingConfiguration),this._hdr?(this.addEffect(new U(e,this.ImageProcessingPostProcessId,(()=>this.imageProcessing),!0)),this._setAutoClearAndTextureSharing(this.imageProcessing)):this._scene.imageProcessingConfiguration.applyByPostProcess=!1,this._cameras&&0!==this._cameras.length||(this._scene.imageProcessingConfiguration.applyByPostProcess=!1),this.imageProcessing.getEffect()||this.imageProcessing._updateParameters()),this.sharpenEnabled&&(this.sharpen.isReady()||this.sharpen.updateEffect(),this.addEffect(this._sharpenEffect),this._setAutoClearAndTextureSharing(this.sharpen)),this.grainEnabled&&(this.grain.isReady()||this.grain.updateEffect(),this.addEffect(this._grainEffect),this._setAutoClearAndTextureSharing(this.grain)),this.chromaticAberrationEnabled&&(this.chromaticAberration.isReady()||this.chromaticAberration.updateEffect(),this.addEffect(this._chromaticAberrationEffect),this._setAutoClearAndTextureSharing(this.chromaticAberration)),this.fxaaEnabled&&(this.fxaa=new B("fxaa",1,null,h.g.BILINEAR_SAMPLINGMODE,e,!1,this._defaultPipelineTextureType),this.addEffect(new U(e,this.FxaaPostProcessId,(()=>this.fxaa),!0)),this._setAutoClearAndTextureSharing(this.fxaa,!0)),null!==this._cameras&&this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name,this._cameras),(this._scene.activeCameras&&this._scene.activeCameras.length>1||this._scene.activeCamera&&-1===this._cameras.indexOf(this._scene.activeCamera))&&(this._scene.autoClear=!0),this._activeCameraChangedObserver||(this._activeCameraChangedObserver=this._scene.onActiveCameraChanged.add((()=>{this._scene.activeCamera&&-1===this._cameras.indexOf(this._scene.activeCamera)&&(this._scene.autoClear=!0)}))),this._activeCamerasChangedObserver||(this._activeCamerasChangedObserver=this._scene.onActiveCamerasChanged.add((()=>{this._scene.activeCameras&&this._scene.activeCameras.length>1&&(this._scene.autoClear=!0)}))),this._adaptPostProcessesToViewPort(),!this._enableMSAAOnFirstPostProcess(this.samples)&&this.samples>1&&o.V.Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0"),this.onBuildObservable.notifyObservers(this)}_disposePostProcesses(e=!1){for(let t=0;tnew ae(e._name,e._name._hdr,t)),e,t,s)}}(0,i.Cg)([(0,r.lK)()],ae.prototype,"sharpenEnabled",null),(0,i.Cg)([(0,r.lK)()],ae.prototype,"bloomKernel",null),(0,i.Cg)([(0,r.lK)()],ae.prototype,"_bloomWeight",void 0),(0,i.Cg)([(0,r.lK)()],ae.prototype,"_bloomThreshold",void 0),(0,i.Cg)([(0,r.lK)()],ae.prototype,"_hdr",void 0),(0,i.Cg)([(0,r.lK)()],ae.prototype,"bloomWeight",null),(0,i.Cg)([(0,r.lK)()],ae.prototype,"bloomThreshold",null),(0,i.Cg)([(0,r.lK)()],ae.prototype,"bloomScale",null),(0,i.Cg)([(0,r.lK)()],ae.prototype,"bloomEnabled",null),(0,i.Cg)([(0,r.lK)()],ae.prototype,"depthOfFieldEnabled",null),(0,i.Cg)([(0,r.lK)()],ae.prototype,"depthOfFieldBlurLevel",null),(0,i.Cg)([(0,r.lK)()],ae.prototype,"fxaaEnabled",null),(0,i.Cg)([(0,r.lK)()],ae.prototype,"samples",null),(0,i.Cg)([(0,r.lK)()],ae.prototype,"imageProcessingEnabled",null),(0,i.Cg)([(0,r.lK)()],ae.prototype,"glowLayerEnabled",null),(0,i.Cg)([(0,r.lK)()],ae.prototype,"chromaticAberrationEnabled",null),(0,i.Cg)([(0,r.lK)()],ae.prototype,"grainEnabled",null),(0,y.Y5)("BABYLON.DefaultRenderingPipeline",ae)},6532:(e,t,s)=>{s.d(t,{j:()=>c});var i=s(5524),r=s(7891),n=s(2781),a=s(6552),o=s(9259),h=s(6877),l=s(2309);class c extends r.w{get direction(){return this._effectWrapper.direction}set direction(e){this._effectWrapper.direction=e}set kernel(e){this._effectWrapper.kernel=e}get kernel(){return this._effectWrapper.kernel}set packedFloat(e){this._effectWrapper.packedFloat=e}get packedFloat(){return this._effectWrapper.packedFloat}getClassName(){return"BlurPostProcess"}constructor(e,t,s,i,r=null,a=n.g.BILINEAR_SAMPLINGMODE,o,h,c=0,u="",d=!1,_=5){const f="number"==typeof i?d:!!i.blockCompilation,p={uniforms:l.q.Uniforms,samplers:l.q.Samplers,size:"number"==typeof i?i:void 0,camera:r,samplingMode:a,engine:o,reusable:h,textureType:c,vertexUrl:l.q.VertexUrl,indexParameters:{varyingCount:0,depCount:0},textureFormat:_,defines:u,...i,blockCompilation:!0};super(e,l.q.FragmentUrl,{effectWrapper:"number"!=typeof i&&i.effectWrapper?void 0:new l.q(e,o,void 0,void 0,p),...p}),this._effectWrapper.options.blockCompilation=f,this.direction=t,this.onApplyObservable.add((()=>{this._effectWrapper.textureWidth=this._outputTexture?this._outputTexture.width:this.width,this._effectWrapper.textureHeight=this._outputTexture?this._outputTexture.height:this.height})),this.kernel=s}updateEffect(e=null,t=null,s=null,i,r,n){this._effectWrapper._updateParameters(r,n)}static _Parse(e,t,s,i){return h.p.Parse((()=>new c(e.name,e.direction,e.kernel,e.options,t,e.renderTargetSamplingMode,s.getEngine(),e.reusable,e.textureType,void 0,!1)),e,s,i)}}(0,i.Cg)([(0,o.WM)()],c.prototype,"direction",null),(0,i.Cg)([(0,o.lK)()],c.prototype,"kernel",null),(0,i.Cg)([(0,o.lK)()],c.prototype,"packedFloat",null),(0,a.Y5)("BABYLON.BlurPostProcess",c)},7891:(e,t,s)=>{s.d(t,{w:()=>f});var i=s(5524),r=s(7931),n=s(9848),a=s(9923),o=s(4420),h=s(9259),l=s(6877),c=s(6552),u=s(6326),d=s(1597),_=s(4255);u.$.prototype.setTextureFromPostProcess=function(e,t,s){let i=null;t&&(t._forcedOutputTexture?i=t._forcedOutputTexture:t._textures.data[t._currentRenderTextureInd]&&(i=t._textures.data[t._currentRenderTextureInd])),this._bindTexture(e,i?.texture??null,s)},u.$.prototype.setTextureFromPostProcessOutput=function(e,t,s){this._bindTexture(e,t?._outputTexture?.texture??null,s)},o.M.prototype.setTextureFromPostProcess=function(e,t){this._engine.setTextureFromPostProcess(this._samplers[e],t,e)},o.M.prototype.setTextureFromPostProcessOutput=function(e,t){this._engine.setTextureFromPostProcessOutput(this._samplers[e],t,e)};class f{static get ForceGLSL(){return _.$.ForceGLSL}static set ForceGLSL(e){_.$.ForceGLSL=e}static RegisterShaderCodeProcessing(e,t){_.$.RegisterShaderCodeProcessing(e,t)}get name(){return this._effectWrapper.name}set name(e){this._effectWrapper.name=e}get alphaMode(){return this._effectWrapper.alphaMode}set alphaMode(e){this._effectWrapper.alphaMode=e}get samples(){return this._samples}set samples(e){this._samples=Math.min(e,this._engine.getCaps().maxMSAASamples),this._textures.forEach((e=>{e.setSamples(this._samples)}))}get shaderLanguage(){return this._shaderLanguage}getEffectName(){return this._fragmentUrl}set onActivate(e){this._onActivateObserver&&this.onActivateObservable.remove(this._onActivateObserver),e&&(this._onActivateObserver=this.onActivateObservable.add(e))}set onSizeChanged(e){this._onSizeChangedObserver&&this.onSizeChangedObservable.remove(this._onSizeChangedObserver),this._onSizeChangedObserver=this.onSizeChangedObservable.add(e)}set onApply(e){this._onApplyObserver&&this.onApplyObservable.remove(this._onApplyObserver),this._onApplyObserver=this.onApplyObservable.add(e)}set onBeforeRender(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e)}set onAfterRender(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=this.onAfterRenderObservable.add(e)}get inputTexture(){return this._textures.data[this._currentRenderTextureInd]}set inputTexture(e){this._forcedOutputTexture=e}restoreDefaultInputTexture(){this._forcedOutputTexture&&(this._forcedOutputTexture=null,this.markTextureDirty())}getCamera(){return this._camera}get texelSize(){return this._shareOutputWithPostProcess?this._shareOutputWithPostProcess.texelSize:(this._forcedOutputTexture&&this._texelSize.copyFromFloats(1/this._forcedOutputTexture.width,1/this._forcedOutputTexture.height),this._texelSize)}constructor(e,t,s,i,o,h,l=1,c,u,d=null,p=0,g="postprocess",m,T=!1,b=5,E,x){this._parentContainer=null,this.width=-1,this.height=-1,this.nodeMaterialSource=null,this._outputTexture=null,this.autoClear=!0,this.forceAutoClearInAlphaMode=!1,this.animations=[],this.enablePixelPerfectMode=!1,this.forceFullscreenViewport=!0,this.scaleMode=1,this.alwaysForcePOT=!1,this._samples=1,this.adaptScaleToCurrentViewport=!1,this._webGPUReady=!1,this._reusable=!1,this._renderId=0,this.externalTextureSamplerBinding=!1,this._textures=new r.L(2),this._textureCache=[],this._currentRenderTextureInd=0,this._scaleRatio=new a.I9(1,1),this._texelSize=a.I9.Zero(),this.onActivateObservable=new n.cP,this.onSizeChangedObservable=new n.cP,this.onApplyObservable=new n.cP,this.onBeforeRenderObservable=new n.cP,this.onAfterRenderObservable=new n.cP;let A,R=1,M=null;if(s&&!Array.isArray(s)){const e=s;s=e.uniforms??null,i=e.samplers??null,R=e.size??1,h=e.camera??null,l=e.samplingMode??1,c=e.engine,u=e.reusable,d=Array.isArray(e.defines)?e.defines.join("\n"):e.defines??null,p=e.textureType??0,g=e.vertexUrl??"postprocess",m=e.indexParameters,T=e.blockCompilation??!1,b=e.textureFormat??5,E=e.shaderLanguage??0,M=e.uniformBuffers??null,x=e.extraInitializations,A=e.effectWrapper}else o&&(R="number"==typeof o?o:{width:o.width,height:o.height});const y=!!A;if(this._effectWrapper=A??new _.$({name:e,useShaderStore:!0,useAsPostProcess:!0,fragmentShader:t,engine:c||h?.getScene().getEngine(),uniforms:s,samplers:i,uniformBuffers:M,defines:d,vertexUrl:g,indexParameters:m,blockCompilation:!0,shaderLanguage:E,extraInitializations:void 0}),this.name=e,this.onEffectCreatedObservable=this._effectWrapper.onEffectCreatedObservable,null!=h?(this._camera=h,this._scene=h.getScene(),h.attachPostProcess(this),this._engine=this._scene.getEngine(),this._scene.postProcesses.push(this),this.uniqueId=this._scene.getUniqueId()):c&&(this._engine=c,this._engine.postProcesses.push(this)),this._options=R,this.renderTargetSamplingMode=l||1,this._reusable=u||!1,this._textureType=p,this._textureFormat=b,this._shaderLanguage=E||0,this._samplers=i||[],-1===this._samplers.indexOf("textureSampler")&&this._samplers.push("textureSampler"),this._fragmentUrl=t,this._vertexUrl=g,this._parameters=s||[],-1===this._parameters.indexOf("scale")&&this._parameters.push("scale"),this._uniformBuffers=M||[],this._indexParameters=m,!y){this._webGPUReady=1===this._shaderLanguage;const e=[];this._gatherImports(this._engine.isWebGPU&&!f.ForceGLSL,e),this._effectWrapper._webGPUReady=this._webGPUReady,this._effectWrapper._postConstructor(T,d,x,e)}}_gatherImports(e=!1,t){e&&this._webGPUReady?t.push(Promise.all([s.e(126).then(s.bind(s,2083))])):t.push(Promise.all([Promise.resolve().then(s.bind(s,6612))]))}getClassName(){return"PostProcess"}getEngine(){return this._engine}getEffect(){return this._effectWrapper.drawWrapper.effect}shareOutputWith(e){return this._disposeTextures(),this._shareOutputWithPostProcess=e,this}useOwnOutput(){0==this._textures.length&&(this._textures=new r.L(2)),this._shareOutputWithPostProcess=null}updateEffect(e=null,t=null,s=null,i,r,n,a,o){this._effectWrapper.updateEffect(e,t,s,i,r,n,a,o),this._postProcessDefines=Array.isArray(this._effectWrapper.options.defines)?this._effectWrapper.options.defines.join("\n"):this._effectWrapper.options.defines}isReusable(){return this._reusable}markTextureDirty(){this.width=-1}_createRenderTargetTexture(e,t,s=0){for(let i=0;i=0;t--)if(e-this._textureCache[t].lastUsedRenderId>100){let e=!1;for(let s=0;s0&&this._textures.reset(),this.width=e,this.height=t;let n=null;if(s)for(let e=0;e{e.samples!==this.samples&&this._engine.updateRenderTargetTextureSampleCount(e,this.samples)})),this._flushTextureCache(),this._renderId++}return u||(u=this._getTarget()),this.enablePixelPerfectMode?(this._scaleRatio.copyFromFloats(a/h,o/l),this._engine.bindFramebuffer(u,0,a,o,this.forceFullscreenViewport)):(this._scaleRatio.copyFromFloats(1,1),this._engine.bindFramebuffer(u,0,void 0,void 0,this.forceFullscreenViewport)),this._engine._debugInsertMarker?.(`post process ${this.name} input`),this.onActivateObservable.notifyObservers(e),this.autoClear&&(0===this.alphaMode||this.forceAutoClearInAlphaMode)&&this._engine.clear(this.clearColor?this.clearColor:i.clearColor,i._allowPostProcessClearColor,!0,!0),this._reusable&&(this._currentRenderTextureInd=(this._currentRenderTextureInd+1)%2),u}get isSupported(){return this._effectWrapper.drawWrapper.effect.isSupported}get aspectRatio(){return this._shareOutputWithPostProcess?this._shareOutputWithPostProcess.aspectRatio:this._forcedOutputTexture?this._forcedOutputTexture.width/this._forcedOutputTexture.height:this.width/this.height}isReady(){return this._effectWrapper.isReady()}apply(){if(!this._effectWrapper.isReady())return null;let e;return this._engine.enableEffect(this._effectWrapper.drawWrapper),this._engine.setState(!1),this._engine.setDepthBuffer(!1),this._engine.setDepthWrite(!1),this.alphaConstants&&this.getEngine().setAlphaConstants(this.alphaConstants.r,this.alphaConstants.g,this.alphaConstants.b,this.alphaConstants.a),e=this._shareOutputWithPostProcess?this._shareOutputWithPostProcess.inputTexture:this._forcedOutputTexture?this._forcedOutputTexture:this.inputTexture,this.externalTextureSamplerBinding||this._effectWrapper.drawWrapper.effect._bindTexture("textureSampler",e?.texture),this._effectWrapper.drawWrapper.effect.setVector2("scale",this._scaleRatio),this.onApplyObservable.notifyObservers(this._effectWrapper.drawWrapper.effect),this._effectWrapper.bind(),this._effectWrapper.drawWrapper.effect}_disposeTextures(){this._shareOutputWithPostProcess||this._forcedOutputTexture?this._disposeTextureCache():(this._disposeTextureCache(),this._textures.dispose())}_disposeTextureCache(){for(let e=this._textureCache.length-1;e>=0;e--)this._textureCache[e].texture.dispose();this._textureCache.length=0}setPrePassRenderer(e){return!!this._prePassEffectConfiguration&&(this._prePassEffectConfiguration=e.addEffectConfiguration(this._prePassEffectConfiguration),this._prePassEffectConfiguration.enabled=!0,!0)}dispose(e){let t;if(e=e||this._camera,this._disposeTextures(),this._scene&&(t=this._scene.postProcesses.indexOf(this),-1!==t&&this._scene.postProcesses.splice(t,1)),this._parentContainer){const e=this._parentContainer.postProcesses.indexOf(this);e>-1&&this._parentContainer.postProcesses.splice(e,1),this._parentContainer=null}if(t=this._engine.postProcesses.indexOf(this),-1!==t&&this._engine.postProcesses.splice(t,1),e){if(e.detachPostProcess(this),t=e._postProcesses.indexOf(this),0===t&&e._postProcesses.length>0){const e=this._camera._getFirstPostProcess();e&&e.markTextureDirty()}this.onActivateObservable.clear(),this.onAfterRenderObservable.clear(),this.onApplyObservable.clear(),this.onBeforeRenderObservable.clear(),this.onSizeChangedObservable.clear(),this.onEffectCreatedObservable.clear()}}serialize(){const e=l.p.Serialize(this),t=this.getCamera()||this._scene&&this._scene.activeCamera;return e.customType="BABYLON."+this.getClassName(),e.cameraId=t?t.id:null,e.reusable=this._reusable,e.textureType=this._textureType,e.fragmentUrl=this._fragmentUrl,e.parameters=this._parameters,e.samplers=this._samplers,e.uniformBuffers=this._uniformBuffers,e.options=this._options,e.defines=this._postProcessDefines,e.textureFormat=this._textureFormat,e.vertexUrl=this._vertexUrl,e.indexParameters=this._indexParameters,e}clone(){const e=this.serialize();e._engine=this._engine,e.cameraId=null;const t=f.Parse(e,this._scene,"");return t?(t.onActivateObservable=this.onActivateObservable.clone(),t.onSizeChangedObservable=this.onSizeChangedObservable.clone(),t.onApplyObservable=this.onApplyObservable.clone(),t.onBeforeRenderObservable=this.onBeforeRenderObservable.clone(),t.onAfterRenderObservable=this.onAfterRenderObservable.clone(),t._prePassEffectConfiguration=this._prePassEffectConfiguration,t):null}static Parse(e,t,s){const i=(0,c.n9)(e.customType);if(!i||!i._Parse)return null;const r=t?t.getCameraById(e.cameraId):null;return i._Parse(e,r,t,s)}static _Parse(e,t,s,i){return l.p.Parse((()=>new f(e.name,e.fragmentUrl,e.parameters,e.samplers,e.options,t,e.renderTargetSamplingMode,e._engine,e.reusable,e.defines,e.textureType,e.vertexUrl,e.indexParameters,!1,e.textureFormat)),e,s,i)}}(0,i.Cg)([(0,h.lK)()],f.prototype,"uniqueId",void 0),(0,i.Cg)([(0,h.lK)()],f.prototype,"name",null),(0,i.Cg)([(0,h.lK)()],f.prototype,"width",void 0),(0,i.Cg)([(0,h.lK)()],f.prototype,"height",void 0),(0,i.Cg)([(0,h.lK)()],f.prototype,"renderTargetSamplingMode",void 0),(0,i.Cg)([(0,h.qK)()],f.prototype,"clearColor",void 0),(0,i.Cg)([(0,h.lK)()],f.prototype,"autoClear",void 0),(0,i.Cg)([(0,h.lK)()],f.prototype,"forceAutoClearInAlphaMode",void 0),(0,i.Cg)([(0,h.lK)()],f.prototype,"alphaMode",null),(0,i.Cg)([(0,h.lK)()],f.prototype,"alphaConstants",void 0),(0,i.Cg)([(0,h.lK)()],f.prototype,"enablePixelPerfectMode",void 0),(0,i.Cg)([(0,h.lK)()],f.prototype,"forceFullscreenViewport",void 0),(0,i.Cg)([(0,h.lK)()],f.prototype,"scaleMode",void 0),(0,i.Cg)([(0,h.lK)()],f.prototype,"alwaysForcePOT",void 0),(0,i.Cg)([(0,h.lK)("samples")],f.prototype,"_samples",void 0),(0,i.Cg)([(0,h.lK)()],f.prototype,"adaptScaleToCurrentViewport",void 0),(0,c.Y5)("BABYLON.PostProcess",f)},6096:(e,t,s)=>{s.d(t,{X:()=>n});var i=s(5616),r=s(9848);class n{constructor(e){this._vertexBuffers={},this.onBeforeRenderObservable=new r.cP,this._scene=e}_prepareBuffers(){if(this._vertexBuffers[i.R.PositionKind])return;const e=[];e.push(1,1),e.push(-1,1),e.push(-1,-1),e.push(1,-1),this._vertexBuffers[i.R.PositionKind]=new i.R(this._scene.getEngine(),e,i.R.PositionKind,!1,!1,2),this._buildIndexBuffer()}_buildIndexBuffer(){const e=[];e.push(0),e.push(1),e.push(2),e.push(0),e.push(2),e.push(3),this._indexBuffer=this._scene.getEngine().createIndexBuffer(e)}_rebuild(){const e=this._vertexBuffers[i.R.PositionKind];e&&(e._rebuild(),this._buildIndexBuffer())}_prepareFrame(e=null,t=null){const s=this._scene.activeCamera;return!(!s||!(t=t||s._postProcesses.filter((e=>null!=e)))||0===t.length||!this._scene.postProcessesEnabled||(t[0].activate(s,e,null!=t),0))}directRender(e,t=null,s=!1,i=0,r=0,n=!1){const a=this._scene.getEngine();for(let o=0;onull!=e))).length||!this._scene.postProcessesEnabled)return;const a=this._scene.getEngine();for(let o=0,h=i.length;o{s.d(t,{q:()=>n});var i=s(4255),r=s(3720);class n extends i.${_gatherImports(e,t){e?(this._webGPUReady=!0,t.push(Promise.all([s.e(126).then(s.bind(s,2850)),s.e(126).then(s.bind(s,5417))]))):t.push(Promise.all([s.e(71).then(s.bind(s,4509)),s.e(71).then(s.bind(s,3802))]))}constructor(e,t=null,s,i,a){const o=!!a?.blockCompilation;super({...a,name:e,engine:t||r.N.LastCreatedEngine,useShaderStore:!0,useAsPostProcess:!0,fragmentShader:n.FragmentUrl,uniforms:n.Uniforms,samplers:n.Samplers,vertexUrl:n.VertexUrl,blockCompilation:!0}),this._packedFloat=!1,this._staticDefines="",this.textureWidth=0,this.textureHeight=0,this.options.blockCompilation=o,void 0!==s&&(this.direction=s),void 0!==i&&(this.kernel=i)}set kernel(e){this._idealKernel!==e&&(e=Math.max(e,1),this._idealKernel=e,this._kernel=this._nearestBestKernel(e),this.options.blockCompilation||this._updateParameters())}get kernel(){return this._idealKernel}set packedFloat(e){this._packedFloat!==e&&(this._packedFloat=e,this.options.blockCompilation||this._updateParameters())}get packedFloat(){return this._packedFloat}bind(){super.bind(),this._drawWrapper.effect.setFloat2("delta",1/this.textureWidth*this.direction.x,1/this.textureHeight*this.direction.y)}_updateParameters(e,t){const s=this._kernel,i=(s-1)/2;let r=[],n=[],a=0;for(let e=0;e0)return Math.max(e,3);return Math.max(t,3)}_gaussianWeight(e){const t=1/3,s=-e*e/(2*t*t);return 1/(Math.sqrt(2*Math.PI)*t)*Math.exp(s)}_glslFloat(e,t=8){return e.toFixed(t).replace(/0+$/,"")}}n.VertexUrl="kernelBlur",n.FragmentUrl="kernelBlur",n.Uniforms=["delta","direction"],n.Samplers=["circleOfConfusionSampler"]},3099:(e,t,s)=>{s.d(t,{m:()=>o});var i=s(7931),r=s(9923);class n{set opaqueSortCompareFn(e){this._opaqueSortCompareFn=e||n.PainterSortCompare,this._renderOpaque=this._renderOpaqueSorted}set alphaTestSortCompareFn(e){this._alphaTestSortCompareFn=e||n.PainterSortCompare,this._renderAlphaTest=this._renderAlphaTestSorted}set transparentSortCompareFn(e){this._transparentSortCompareFn=e||n.defaultTransparentSortCompare,this._renderTransparent=this._renderTransparentSorted}constructor(e,t,s=null,r=null,n=null){this.index=e,this._opaqueSubMeshes=new i.L(256),this._transparentSubMeshes=new i.L(256),this._alphaTestSubMeshes=new i.L(256),this._depthOnlySubMeshes=new i.L(256),this._particleSystems=new i.L(256),this._spriteManagers=new i.L(256),this._empty=!0,this._edgesRenderers=new i.b(16),this._scene=t,this.opaqueSortCompareFn=s,this.alphaTestSortCompareFn=r,this.transparentSortCompareFn=n}render(e,t,s,i){if(e)return void e(this._opaqueSubMeshes,this._alphaTestSubMeshes,this._transparentSubMeshes,this._depthOnlySubMeshes);const r=this._scene.getEngine();0!==this._depthOnlySubMeshes.length&&(r.setColorWrite(!1),this._renderAlphaTest(this._depthOnlySubMeshes),r.setColorWrite(!0)),0!==this._opaqueSubMeshes.length&&this._renderOpaque(this._opaqueSubMeshes),0!==this._alphaTestSubMeshes.length&&this._renderAlphaTest(this._alphaTestSubMeshes);const n=r.getStencilBuffer();if(r.setStencilBuffer(!1),t&&this._renderSprites(),s&&this._renderParticles(i),this.onBeforeTransparentRendering&&this.onBeforeTransparentRendering(),0!==this._transparentSubMeshes.length||this._scene.useOrderIndependentTransparency){if(r.setStencilBuffer(n),this._scene.useOrderIndependentTransparency){const e=this._scene.depthPeelingRenderer.render(this._transparentSubMeshes);e.length&&this._renderTransparent(e)}else this._renderTransparent(this._transparentSubMeshes);r.setAlphaMode(0)}if(r.setStencilBuffer(!1),this._edgesRenderers.length){for(let e=0;et._alphaIndex?1:e._alphaIndext._distanceToCamera?-1:0}static frontToBackSortCompare(e,t){return e._distanceToCamerat._distanceToCamera?1:0}static PainterSortCompare(e,t){const s=e.getMesh(),i=t.getMesh();return s.material&&i.material?s.material.uniqueId-i.material.uniqueId:s.uniqueId-i.uniqueId}prepare(){this._opaqueSubMeshes.reset(),this._transparentSubMeshes.reset(),this._alphaTestSubMeshes.reset(),this._depthOnlySubMeshes.reset(),this._particleSystems.reset(),this.prepareSprites(),this._edgesRenderers.reset(),this._empty=!0}prepareSprites(){this._spriteManagers.reset()}dispose(){this._opaqueSubMeshes.dispose(),this._transparentSubMeshes.dispose(),this._alphaTestSubMeshes.dispose(),this._depthOnlySubMeshes.dispose(),this._particleSystems.dispose(),this._spriteManagers.dispose(),this._edgesRenderers.dispose()}dispatch(e,t,s){void 0===t&&(t=e.getMesh()),void 0===s&&(s=e.getMaterial()),null!=s&&(s.needAlphaBlendingForMesh(t)?this._transparentSubMeshes.push(e):s.needAlphaTesting()?(s.needDepthPrePass&&this._depthOnlySubMeshes.push(e),this._alphaTestSubMeshes.push(e)):(s.needDepthPrePass&&this._depthOnlySubMeshes.push(e),this._opaqueSubMeshes.push(e)),t._renderingGroup=this,t._edgesRenderer&&t.isEnabled()&&t.isVisible&&t._edgesRenderer.isEnabled&&this._edgesRenderers.pushNoDuplicate(t._edgesRenderer),this._empty=!1)}dispatchSprites(e){this._spriteManagers.push(e),this._empty=!1}dispatchParticles(e){this._particleSystems.push(e),this._empty=!1}_renderParticles(e){if(0===this._particleSystems.length)return;const t=this._scene.activeCamera;this._scene.onBeforeParticlesRenderingObservable.notifyObservers(this._scene);for(let s=0;s{s(9610).l.IncludesShadersStore.bakedVertexAnimation="#ifdef BAKED_VERTEX_ANIMATION_TEXTURE\n{\n#ifdef INSTANCES\n#define BVASNAME bakedVertexAnimationSettingsInstanced\n#else\n#define BVASNAME bakedVertexAnimationSettings\n#endif\nfloat VATStartFrame=BVASNAME.x;float VATEndFrame=BVASNAME.y;float VATOffsetFrame=BVASNAME.z;float VATSpeed=BVASNAME.w;float totalFrames=VATEndFrame-VATStartFrame+1.0;float time=bakedVertexAnimationTime*VATSpeed/totalFrames;float frameCorrection=time<1.0 ? 0.0 : 1.0;float numOfFrames=totalFrames-frameCorrection;float VATFrameNum=fract(time)*numOfFrames;VATFrameNum=mod(VATFrameNum+VATOffsetFrame,numOfFrames);VATFrameNum=floor(VATFrameNum);VATFrameNum+=VATStartFrame+frameCorrection;mat4 VATInfluence;VATInfluence=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[0],VATFrameNum)*matricesWeights[0];\n#if NUM_BONE_INFLUENCERS>1\nVATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[1],VATFrameNum)*matricesWeights[1];\n#endif\n#if NUM_BONE_INFLUENCERS>2\nVATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[2],VATFrameNum)*matricesWeights[2];\n#endif\n#if NUM_BONE_INFLUENCERS>3\nVATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[3],VATFrameNum)*matricesWeights[3];\n#endif\n#if NUM_BONE_INFLUENCERS>4\nVATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[0],VATFrameNum)*matricesWeightsExtra[0];\n#endif\n#if NUM_BONE_INFLUENCERS>5\nVATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[1],VATFrameNum)*matricesWeightsExtra[1];\n#endif\n#if NUM_BONE_INFLUENCERS>6\nVATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[2],VATFrameNum)*matricesWeightsExtra[2];\n#endif\n#if NUM_BONE_INFLUENCERS>7\nVATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[3],VATFrameNum)*matricesWeightsExtra[3];\n#endif\nfinalWorld=finalWorld*VATInfluence;}\n#endif\n"},8959:(e,t,s)=>{s(9610).l.IncludesShadersStore.bakedVertexAnimationDeclaration="#ifdef BAKED_VERTEX_ANIMATION_TEXTURE\nuniform float bakedVertexAnimationTime;uniform vec2 bakedVertexAnimationTextureSizeInverted;uniform vec4 bakedVertexAnimationSettings;uniform sampler2D bakedVertexAnimationTexture;\n#ifdef INSTANCES\nattribute vec4 bakedVertexAnimationSettingsInstanced;\n#endif\n#define inline\nmat4 readMatrixFromRawSamplerVAT(sampler2D smp,float index,float frame)\n{float offset=index*4.0;float frameUV=(frame+0.5)*bakedVertexAnimationTextureSizeInverted.y;float dx=bakedVertexAnimationTextureSizeInverted.x;vec4 m0=texture2D(smp,vec2(dx*(offset+0.5),frameUV));vec4 m1=texture2D(smp,vec2(dx*(offset+1.5),frameUV));vec4 m2=texture2D(smp,vec2(dx*(offset+2.5),frameUV));vec4 m3=texture2D(smp,vec2(dx*(offset+3.5),frameUV));return mat4(m0,m1,m2,m3);}\n#endif\n"},9707:(e,t,s)=>{s(9610).l.IncludesShadersStore.bonesDeclaration="#if NUM_BONE_INFLUENCERS>0\nattribute vec4 matricesIndices;attribute vec4 matricesWeights;\n#if NUM_BONE_INFLUENCERS>4\nattribute vec4 matricesIndicesExtra;attribute vec4 matricesWeightsExtra;\n#endif\n#ifndef BAKED_VERTEX_ANIMATION_TEXTURE\n#ifdef BONETEXTURE\nuniform highp sampler2D boneSampler;uniform float boneTextureWidth;\n#else\nuniform mat4 mBones[BonesPerMesh];\n#endif\n#ifdef BONES_VELOCITY_ENABLED\nuniform mat4 mPreviousBones[BonesPerMesh];\n#endif\n#ifdef BONETEXTURE\n#define inline\nmat4 readMatrixFromRawSampler(sampler2D smp,float index)\n{float offset=index *4.0;float dx=1.0/boneTextureWidth;vec4 m0=texture2D(smp,vec2(dx*(offset+0.5),0.));vec4 m1=texture2D(smp,vec2(dx*(offset+1.5),0.));vec4 m2=texture2D(smp,vec2(dx*(offset+2.5),0.));vec4 m3=texture2D(smp,vec2(dx*(offset+3.5),0.));return mat4(m0,m1,m2,m3);}\n#endif\n#endif\n#endif\n"},3361:(e,t,s)=>{s(9610).l.IncludesShadersStore.bonesVertex="#ifndef BAKED_VERTEX_ANIMATION_TEXTURE\n#if NUM_BONE_INFLUENCERS>0\nmat4 influence;\n#ifdef BONETEXTURE\ninfluence=readMatrixFromRawSampler(boneSampler,matricesIndices[0])*matricesWeights[0];\n#if NUM_BONE_INFLUENCERS>1\ninfluence+=readMatrixFromRawSampler(boneSampler,matricesIndices[1])*matricesWeights[1];\n#endif\n#if NUM_BONE_INFLUENCERS>2\ninfluence+=readMatrixFromRawSampler(boneSampler,matricesIndices[2])*matricesWeights[2];\n#endif\n#if NUM_BONE_INFLUENCERS>3\ninfluence+=readMatrixFromRawSampler(boneSampler,matricesIndices[3])*matricesWeights[3];\n#endif\n#if NUM_BONE_INFLUENCERS>4\ninfluence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[0])*matricesWeightsExtra[0];\n#endif\n#if NUM_BONE_INFLUENCERS>5\ninfluence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[1])*matricesWeightsExtra[1];\n#endif\n#if NUM_BONE_INFLUENCERS>6\ninfluence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[2])*matricesWeightsExtra[2];\n#endif\n#if NUM_BONE_INFLUENCERS>7\ninfluence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[3])*matricesWeightsExtra[3];\n#endif\n#else\ninfluence=mBones[int(matricesIndices[0])]*matricesWeights[0];\n#if NUM_BONE_INFLUENCERS>1\ninfluence+=mBones[int(matricesIndices[1])]*matricesWeights[1];\n#endif\n#if NUM_BONE_INFLUENCERS>2\ninfluence+=mBones[int(matricesIndices[2])]*matricesWeights[2];\n#endif\n#if NUM_BONE_INFLUENCERS>3\ninfluence+=mBones[int(matricesIndices[3])]*matricesWeights[3];\n#endif\n#if NUM_BONE_INFLUENCERS>4\ninfluence+=mBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];\n#endif\n#if NUM_BONE_INFLUENCERS>5\ninfluence+=mBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];\n#endif\n#if NUM_BONE_INFLUENCERS>6\ninfluence+=mBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];\n#endif\n#if NUM_BONE_INFLUENCERS>7\ninfluence+=mBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];\n#endif\n#endif\nfinalWorld=finalWorld*influence;\n#endif\n#endif\n"},7412:(e,t,s)=>{s(9610).l.IncludesShadersStore.clipPlaneFragment="#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6)\nif (false) {}\n#endif\n#ifdef CLIPPLANE\nelse if (fClipDistance>0.0)\n{discard;}\n#endif\n#ifdef CLIPPLANE2\nelse if (fClipDistance2>0.0)\n{discard;}\n#endif\n#ifdef CLIPPLANE3\nelse if (fClipDistance3>0.0)\n{discard;}\n#endif\n#ifdef CLIPPLANE4\nelse if (fClipDistance4>0.0)\n{discard;}\n#endif\n#ifdef CLIPPLANE5\nelse if (fClipDistance5>0.0)\n{discard;}\n#endif\n#ifdef CLIPPLANE6\nelse if (fClipDistance6>0.0)\n{discard;}\n#endif\n"},6194:(e,t,s)=>{s(9610).l.IncludesShadersStore.clipPlaneFragmentDeclaration="#ifdef CLIPPLANE\nvarying float fClipDistance;\n#endif\n#ifdef CLIPPLANE2\nvarying float fClipDistance2;\n#endif\n#ifdef CLIPPLANE3\nvarying float fClipDistance3;\n#endif\n#ifdef CLIPPLANE4\nvarying float fClipDistance4;\n#endif\n#ifdef CLIPPLANE5\nvarying float fClipDistance5;\n#endif\n#ifdef CLIPPLANE6\nvarying float fClipDistance6;\n#endif\n"},7314:(e,t,s)=>{s(9610).l.IncludesShadersStore.clipPlaneVertex="#ifdef CLIPPLANE\nfClipDistance=dot(worldPos,vClipPlane);\n#endif\n#ifdef CLIPPLANE2\nfClipDistance2=dot(worldPos,vClipPlane2);\n#endif\n#ifdef CLIPPLANE3\nfClipDistance3=dot(worldPos,vClipPlane3);\n#endif\n#ifdef CLIPPLANE4\nfClipDistance4=dot(worldPos,vClipPlane4);\n#endif\n#ifdef CLIPPLANE5\nfClipDistance5=dot(worldPos,vClipPlane5);\n#endif\n#ifdef CLIPPLANE6\nfClipDistance6=dot(worldPos,vClipPlane6);\n#endif\n"},1636:(e,t,s)=>{s(9610).l.IncludesShadersStore.clipPlaneVertexDeclaration="#ifdef CLIPPLANE\nuniform vec4 vClipPlane;varying float fClipDistance;\n#endif\n#ifdef CLIPPLANE2\nuniform vec4 vClipPlane2;varying float fClipDistance2;\n#endif\n#ifdef CLIPPLANE3\nuniform vec4 vClipPlane3;varying float fClipDistance3;\n#endif\n#ifdef CLIPPLANE4\nuniform vec4 vClipPlane4;varying float fClipDistance4;\n#endif\n#ifdef CLIPPLANE5\nuniform vec4 vClipPlane5;varying float fClipDistance5;\n#endif\n#ifdef CLIPPLANE6\nuniform vec4 vClipPlane6;varying float fClipDistance6;\n#endif\n"},1218:(e,t,s)=>{s(9610).l.IncludesShadersStore.instancesDeclaration="#ifdef INSTANCES\nattribute vec4 world0;attribute vec4 world1;attribute vec4 world2;attribute vec4 world3;\n#ifdef INSTANCESCOLOR\nattribute vec4 instanceColor;\n#endif\n#if defined(THIN_INSTANCES) && !defined(WORLD_UBO)\nuniform mat4 world;\n#endif\n#if defined(VELOCITY) || defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) || defined(VELOCITY_LINEAR)\nattribute vec4 previousWorld0;attribute vec4 previousWorld1;attribute vec4 previousWorld2;attribute vec4 previousWorld3;\n#ifdef THIN_INSTANCES\nuniform mat4 previousWorld;\n#endif\n#endif\n#else\n#if !defined(WORLD_UBO)\nuniform mat4 world;\n#endif\n#if defined(VELOCITY) || defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) || defined(VELOCITY_LINEAR)\nuniform mat4 previousWorld;\n#endif\n#endif\n"},3298:(e,t,s)=>{s(9610).l.IncludesShadersStore.instancesVertex="#ifdef INSTANCES\nmat4 finalWorld=mat4(world0,world1,world2,world3);\n#if defined(PREPASS_VELOCITY) || defined(VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) || defined(VELOCITY_LINEAR)\nmat4 finalPreviousWorld=mat4(previousWorld0,previousWorld1,\npreviousWorld2,previousWorld3);\n#endif\n#ifdef THIN_INSTANCES\nfinalWorld=world*finalWorld;\n#if defined(PREPASS_VELOCITY) || defined(VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) || defined(VELOCITY_LINEAR)\nfinalPreviousWorld=previousWorld*finalPreviousWorld;\n#endif\n#endif\n#else\nmat4 finalWorld=world;\n#if defined(PREPASS_VELOCITY) || defined(VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) || defined(VELOCITY_LINEAR)\nmat4 finalPreviousWorld=previousWorld;\n#endif\n#endif\n"},5060:(e,t,s)=>{s(9610).l.IncludesShadersStore.morphTargetsVertex="#ifdef MORPHTARGETS\n#ifdef MORPHTARGETS_TEXTURE\n#if {X}==0\nfor (int i=0; i=morphTargetCount) break;vertexID=float(gl_VertexID)*morphTargetTextureInfo.x;positionUpdated+=(readVector3FromRawSampler(i,vertexID)-position)*morphTargetInfluences[i];vertexID+=1.0;\n#ifdef MORPHTARGETS_NORMAL\nnormalUpdated+=(readVector3FromRawSampler(i,vertexID) -normal)*morphTargetInfluences[i];vertexID+=1.0;\n#endif\n#ifdef MORPHTARGETS_UV\nuvUpdated+=(readVector3FromRawSampler(i,vertexID).xy-uv)*morphTargetInfluences[i];vertexID+=1.0;\n#endif\n#ifdef MORPHTARGETS_TANGENT\ntangentUpdated.xyz+=(readVector3FromRawSampler(i,vertexID) -tangent.xyz)*morphTargetInfluences[i];\n#endif\n}\n#endif\n#else\npositionUpdated+=(position{X}-position)*morphTargetInfluences[{X}];\n#ifdef MORPHTARGETS_NORMAL\nnormalUpdated+=(normal{X}-normal)*morphTargetInfluences[{X}];\n#endif\n#ifdef MORPHTARGETS_TANGENT\ntangentUpdated.xyz+=(tangent{X}-tangent.xyz)*morphTargetInfluences[{X}];\n#endif\n#ifdef MORPHTARGETS_UV\nuvUpdated+=(uv_{X}-uv)*morphTargetInfluences[{X}];\n#endif\n#endif\n#endif\n"},738:(e,t,s)=>{s(9610).l.IncludesShadersStore.morphTargetsVertexDeclaration="#ifdef MORPHTARGETS\n#ifndef MORPHTARGETS_TEXTURE\nattribute vec3 position{X};\n#ifdef MORPHTARGETS_NORMAL\nattribute vec3 normal{X};\n#endif\n#ifdef MORPHTARGETS_TANGENT\nattribute vec3 tangent{X};\n#endif\n#ifdef MORPHTARGETS_UV\nattribute vec2 uv_{X};\n#endif\n#elif {X}==0\nuniform int morphTargetCount;\n#endif\n#endif\n"},8451:(e,t,s)=>{s(9610).l.IncludesShadersStore.morphTargetsVertexGlobal="#ifdef MORPHTARGETS\n#ifdef MORPHTARGETS_TEXTURE\nfloat vertexID;\n#endif\n#endif\n"},7999:(e,t,s)=>{s(9610).l.IncludesShadersStore.morphTargetsVertexGlobalDeclaration="#ifdef MORPHTARGETS\nuniform float morphTargetInfluences[NUM_MORPH_INFLUENCERS];\n#ifdef MORPHTARGETS_TEXTURE \nuniform float morphTargetTextureIndices[NUM_MORPH_INFLUENCERS];uniform vec3 morphTargetTextureInfo;uniform highp sampler2DArray morphTargets;vec3 readVector3FromRawSampler(int targetIndex,float vertexIndex)\n{ \nfloat y=floor(vertexIndex/morphTargetTextureInfo.y);float x=vertexIndex-y*morphTargetTextureInfo.y;vec3 textureUV=vec3((x+0.5)/morphTargetTextureInfo.y,(y+0.5)/morphTargetTextureInfo.z,morphTargetTextureIndices[targetIndex]);return texture(morphTargets,textureUV).xyz;}\n#endif\n#endif\n"},8334:(e,t,s)=>{s(9610).l.IncludesShadersStore.packingFunctions="vec4 pack(float depth)\n{const vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);const vec4 bit_mask=vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}\nfloat unpack(vec4 color)\n{const vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(color,bit_shift);}"},1211:(e,t,s)=>{s(9610).l.IncludesShadersStore.pointCloudVertex="#if defined(POINTSIZE) && !defined(WEBGPU)\ngl_PointSize=pointSize;\n#endif\n"},8852:(e,t,s)=>{s.r(t),s.d(t,{depthPixelShader:()=>a});var i=s(9610);s(6194),s(8334),s(7412);const r="depthPixelShader",n="#ifdef ALPHATEST\nvarying vec2 vUV;uniform sampler2D diffuseSampler;\n#endif\n#include\nvarying float vDepthMetric;\n#ifdef PACKED\n#include\n#endif\n#ifdef STORE_CAMERASPACE_Z\nvarying vec4 vViewPos;\n#endif\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\n#include\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\n#ifdef STORE_CAMERASPACE_Z\n#ifdef PACKED\ngl_FragColor=pack(vViewPos.z);\n#else\ngl_FragColor=vec4(vViewPos.z,0.0,0.0,1.0);\n#endif\n#else\n#ifdef NONLINEARDEPTH\n#ifdef PACKED\ngl_FragColor=pack(gl_FragCoord.z);\n#else\ngl_FragColor=vec4(gl_FragCoord.z,0.0,0.0,0.0);\n#endif\n#else\n#ifdef PACKED\ngl_FragColor=pack(vDepthMetric);\n#else\ngl_FragColor=vec4(vDepthMetric,0.0,0.0,1.0);\n#endif\n#endif\n#endif\n}";i.l.ShadersStore[r]=n;const a={name:r,shader:n}},9977:(e,t,s)=>{s.r(t),s.d(t,{depthVertexShader:()=>a});var i=s(9610);s(9707),s(8959),s(7999),s(738),s(1636),s(1218);i.l.IncludesShadersStore.pointCloudVertexDeclaration="#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n",s(8451),s(5060),s(3298),s(3361),s(5523),s(7314),s(1211);const r="depthVertexShader",n="attribute vec3 position;\n#include\n#include\n#include\n#include[0..maxSimultaneousMorphTargets]\n#include\n#include\nuniform mat4 viewProjection;uniform vec2 depthValues;\n#if defined(ALPHATEST) || defined(NEED_UV)\nvarying vec2 vUV;uniform mat4 diffuseMatrix;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#endif\n#ifdef STORE_CAMERASPACE_Z\nuniform mat4 view;varying vec4 vViewPos;\n#endif\n#include\nvarying float vDepthMetric;\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void)\n{vec3 positionUpdated=position;\n#ifdef UV1\nvec2 uvUpdated=uv;\n#endif\n#include\n#include[0..maxSimultaneousMorphTargets]\n#include\n#include\n#include\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\n#include\ngl_Position=viewProjection*worldPos;\n#ifdef STORE_CAMERASPACE_Z\nvViewPos=view*worldPos;\n#else\n#ifdef USE_REVERSE_DEPTHBUFFER\nvDepthMetric=((-gl_Position.z+depthValues.x)/(depthValues.y));\n#else\nvDepthMetric=((gl_Position.z+depthValues.x)/(depthValues.y));\n#endif\n#endif\n#if defined(ALPHATEST) || defined(BASIC_RENDER)\n#ifdef UV1\nvUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#ifdef UV2\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n#include\n}\n";i.l.ShadersStore[r]=n;const a={name:r,shader:n}},6612:(e,t,s)=>{s.r(t),s.d(t,{postprocessVertexShader:()=>n});const i="postprocessVertexShader",r="attribute vec2 position;uniform vec2 scale;varying vec2 vUV;const vec2 madd=vec2(0.5,0.5);\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nvUV=(position*madd+madd)*scale;gl_Position=vec4(position,0.0,1.0);\n#define CUSTOM_VERTEX_MAIN_END\n}";s(9610).l.ShadersStore[i]=r;const n={name:i,shader:r}},8438:(e,t,s)=>{s.r(t),s.d(t,{sharpenPixelShader:()=>n});const i="sharpenPixelShader",r="varying vec2 vUV;uniform sampler2D textureSampler;uniform vec2 screenSize;uniform vec2 sharpnessAmounts;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{vec2 onePixel=vec2(1.0,1.0)/screenSize;vec4 color=texture2D(textureSampler,vUV);vec4 edgeDetection=texture2D(textureSampler,vUV+onePixel*vec2(0,-1)) +\ntexture2D(textureSampler,vUV+onePixel*vec2(-1,0)) +\ntexture2D(textureSampler,vUV+onePixel*vec2(1,0)) +\ntexture2D(textureSampler,vUV+onePixel*vec2(0,1)) -\ncolor*4.0;gl_FragColor=max(vec4(color.rgb*sharpnessAmounts.y,color.a)-(sharpnessAmounts.x*vec4(edgeDetection.rgb,0)),0.);}";s(9610).l.ShadersStore[i]=r;const n={name:i,shader:r}},7762:(e,t,s)=>{s.d(t,{WZ:()=>b});var i=s(5530),r=s(7328),n=s(861),a=s(1137),o=s(6315),h=s(9923),l=s(4609),c=s(5616),u=s(998),d=s(6552);i.e._instancedMeshFactory=(e,t)=>{const s=new _(e,t);if(t.instancedBuffers){s.instancedBuffers={};for(const e in t.instancedBuffers)s.instancedBuffers[e]=t.instancedBuffers[e]}return s};class _ extends n.u{constructor(e,t){super(e,t.getScene()),this._indexInSourceMeshInstanceArray=-1,this._distanceToCamera=0,t.addInstance(this),this._sourceMesh=t,this._unIndexed=t._unIndexed,this.position.copyFrom(t.position),this.rotation.copyFrom(t.rotation),this.scaling.copyFrom(t.scaling),t.rotationQuaternion&&(this.rotationQuaternion=t.rotationQuaternion.clone()),this.animations=t.animations.slice();for(const e of t.getAnimationRanges())null!=e&&this.createAnimationRange(e.name,e.from,e.to);this.infiniteDistance=t.infiniteDistance,this.setPivotMatrix(t.getPivotMatrix()),this.refreshBoundingInfo(!0,!0),this._syncSubMeshes()}getClassName(){return"InstancedMesh"}get lightSources(){return this._sourceMesh._lightSources}_resyncLightSources(){}_resyncLightSource(){}_removeLightSource(){}get receiveShadows(){return this._sourceMesh.receiveShadows}set receiveShadows(e){this._sourceMesh?.receiveShadows!==e&&u.S0.Warn("Setting receiveShadows on an instanced mesh has no effect")}get material(){return this._sourceMesh.material}set material(e){this._sourceMesh?.material!==e&&u.S0.Warn("Setting material on an instanced mesh has no effect")}get visibility(){return this._sourceMesh.visibility}set visibility(e){this._sourceMesh?.visibility!==e&&u.S0.Warn("Setting visibility on an instanced mesh has no effect")}get skeleton(){return this._sourceMesh.skeleton}set skeleton(e){this._sourceMesh?.skeleton!==e&&u.S0.Warn("Setting skeleton on an instanced mesh has no effect")}get renderingGroupId(){return this._sourceMesh.renderingGroupId}set renderingGroupId(e){this._sourceMesh&&e!==this._sourceMesh.renderingGroupId&&a.V.Warn("Note - setting renderingGroupId of an instanced mesh has no effect on the scene")}getTotalVertices(){return this._sourceMesh?this._sourceMesh.getTotalVertices():0}getTotalIndices(){return this._sourceMesh.getTotalIndices()}get sourceMesh(){return this._sourceMesh}createInstance(e){return this._sourceMesh.createInstance(e)}isReady(e=!1){return this._sourceMesh.isReady(e,!0)}getVerticesData(e,t,s){return this._sourceMesh.getVerticesData(e,t,s)}copyVerticesData(e,t){this._sourceMesh.copyVerticesData(e,t)}setVerticesData(e,t,s,i){return this.sourceMesh&&this.sourceMesh.setVerticesData(e,t,s,i),this.sourceMesh}updateVerticesData(e,t,s,i){return this.sourceMesh&&this.sourceMesh.updateVerticesData(e,t,s,i),this.sourceMesh}setIndices(e,t=null){return this.sourceMesh&&this.sourceMesh.setIndices(e,t),this.sourceMesh}isVerticesDataPresent(e){return this._sourceMesh.isVerticesDataPresent(e)}getIndices(){return this._sourceMesh.getIndices()}get _positions(){return this._sourceMesh._positions}refreshBoundingInfo(e=!1,t=!1){if(this.hasBoundingInfo&&this.getBoundingInfo().isLocked)return this;let s;s="object"==typeof e?e:{applySkeleton:e,applyMorph:t};const i=this._sourceMesh.geometry?this._sourceMesh.geometry.boundingBias:null;return this._refreshBoundingInfo(this._sourceMesh._getData(s,null,c.R.PositionKind),i),this}_preActivate(){return this._currentLOD&&this._currentLOD._preActivate(),this}_activate(e,t){if(super._activate(e,t),this._sourceMesh.subMeshes||a.V.Warn("Instances should only be created for meshes with geometry."),this._currentLOD){if(this._currentLOD._getWorldMatrixDeterminant()>=0!=this._getWorldMatrixDeterminant()>=0)return this._internalAbstractMeshDataInfo._actAsRegularMesh=!0,!0;if(this._internalAbstractMeshDataInfo._actAsRegularMesh=!1,this._currentLOD._registerInstanceForRenderId(this,e),t){if(!this._currentLOD._internalAbstractMeshDataInfo._isActiveIntermediate)return this._currentLOD._internalAbstractMeshDataInfo._onlyForInstancesIntermediate=!0,!0}else if(!this._currentLOD._internalAbstractMeshDataInfo._isActive)return this._currentLOD._internalAbstractMeshDataInfo._onlyForInstances=!0,!0}return!1}_postActivate(){this._sourceMesh.edgesShareWithInstances&&this._sourceMesh._edgesRenderer&&this._sourceMesh._edgesRenderer.isEnabled&&this._sourceMesh._renderingGroup?(this._sourceMesh._renderingGroup._edgesRenderers.pushNoDuplicate(this._sourceMesh._edgesRenderer),this._sourceMesh._edgesRenderer.customInstances.push(this.getWorldMatrix())):this._edgesRenderer&&this._edgesRenderer.isEnabled&&this._sourceMesh._renderingGroup&&this._sourceMesh._renderingGroup._edgesRenderers.push(this._edgesRenderer)}getWorldMatrix(){if(this._currentLOD&&this._currentLOD.billboardMode!==r.V.BILLBOARDMODE_NONE&&this._currentLOD._masterMesh!==this){this._billboardWorldMatrix||(this._billboardWorldMatrix=new h.uq);const e=this._currentLOD._masterMesh;return this._currentLOD._masterMesh=this,h.AA.Vector3[7].copyFrom(this._currentLOD.position),this._currentLOD.position.set(0,0,0),this._billboardWorldMatrix.copyFrom(this._currentLOD.computeWorldMatrix(!0)),this._currentLOD.position.copyFrom(h.AA.Vector3[7]),this._currentLOD._masterMesh=e,this._billboardWorldMatrix}return super.getWorldMatrix()}get isAnInstance(){return!0}getLOD(e){if(!e)return this;const t=this.sourceMesh.getLODLevels();if(t&&0!==t.length){const t=this.getBoundingInfo();this._currentLOD=this.sourceMesh.getLOD(e,t.boundingSphere)}else this._currentLOD=this.sourceMesh;return this._currentLOD}_preActivateForIntermediateRendering(e){return this.sourceMesh._preActivateForIntermediateRendering(e)}_syncSubMeshes(){if(this.releaseSubMeshes(),this._sourceMesh.subMeshes)for(let e=0;ee=e.concat(t.bones))),e}}class m extends g{}class T{constructor(){this.rootNodes=[],this.skeletons=[],this.animationGroups=[]}dispose(){this.rootNodes.slice(0).forEach((e=>{e.dispose()})),this.rootNodes.length=0,this.skeletons.slice(0).forEach((e=>{e.dispose()})),this.skeletons.length=0,this.animationGroups.slice(0).forEach((e=>{e.dispose()})),this.animationGroups.length=0}}class b extends g{constructor(e){super(),this._wasAddedToScene=!1,(e=e||o.q.LastCreatedScene)&&(this.scene=e,this.proceduralTextures=[],e.onDisposeObservable.add((()=>{this._wasAddedToScene||this.dispose()})),this._onContextRestoredObserver=e.getEngine().onContextRestoredObservable.add((()=>{for(const e of this.geometries)e._rebuild();for(const e of this.meshes)e._rebuild();for(const e of this.particleSystems)e.rebuild();for(const e of this.textures)e._rebuild()})))}_topologicalSort(e){const t=new Map;for(const s of e)t.set(s.uniqueId,s);const s={dependsOn:new Map,dependedBy:new Map};for(const t of e){const e=t.uniqueId;s.dependsOn.set(e,new Set),s.dependedBy.set(e,new Set)}for(const i of e){const e=i.uniqueId,r=s.dependsOn.get(e);if(i instanceof _){const n=i.sourceMesh;t.has(n.uniqueId)&&(r.add(n.uniqueId),s.dependedBy.get(n.uniqueId).add(e))}const n=s.dependedBy.get(e);for(const r of i.getDescendants()){const i=r.uniqueId;t.has(i)&&(n.add(i),s.dependsOn.get(i).add(e))}}const i=[],r=[];for(const i of e){const e=i.uniqueId;0===s.dependsOn.get(e).size&&(r.push(i),t.delete(e))}const n=r;for(;n.length>0;){const e=n.shift();i.push(e);const r=s.dependedBy.get(e.uniqueId);for(const i of Array.from(r.values())){const r=s.dependsOn.get(i);r.delete(e.uniqueId),0===r.size&&t.get(i)&&(n.push(t.get(i)),t.delete(i))}}return t.size>0&&(a.V.Error("SceneSerializer._topologicalSort: There were unvisited nodes:"),t.forEach((e=>a.V.Error(e.name)))),i}_addNodeAndDescendantsToList(e,t,s,i){if(s&&(!i||i(s))&&!t.has(s.uniqueId)){e.push(s),t.add(s.uniqueId);for(const r of s.getDescendants(!0))this._addNodeAndDescendantsToList(e,t,r,i)}}_isNodeInContainer(e){return e instanceof n.u&&-1!==this.meshes.indexOf(e)||e instanceof r.V&&-1!==this.transformNodes.indexOf(e)||e instanceof f.v&&-1!==this.lights.indexOf(e)||e instanceof p.i&&-1!==this.cameras.indexOf(e)}_isValidHierarchy(){for(const e of this.meshes)if(e.parent&&!this._isNodeInContainer(e.parent))return a.V.Warn(`Node ${e.name} has a parent that is not in the container.`),!1;for(const e of this.transformNodes)if(e.parent&&!this._isNodeInContainer(e.parent))return a.V.Warn(`Node ${e.name} has a parent that is not in the container.`),!1;for(const e of this.lights)if(e.parent&&!this._isNodeInContainer(e.parent))return a.V.Warn(`Node ${e.name} has a parent that is not in the container.`),!1;for(const e of this.cameras)if(e.parent&&!this._isNodeInContainer(e.parent))return a.V.Warn(`Node ${e.name} has a parent that is not in the container.`),!1;return!0}instantiateModelsToScene(e,t=!1,s){this._isValidHierarchy()||u.S0.Warn("SceneSerializer.InstantiateModelsToScene: The Asset Container hierarchy is not valid.");const r={},n={},a=new T,o=[],h=[],l={doNotInstantiate:!0,...s},c=[],d=new Set;for(const e of this.transformNodes)null===e.parent&&this._addNodeAndDescendantsToList(c,d,e,l.predicate);for(const e of this.meshes)null===e.parent&&this._addNodeAndDescendantsToList(c,d,e,l.predicate);const _=this._topologicalSort(c),f=(s,o)=>{if(((t,s)=>{if(r[t.uniqueId]=s.uniqueId,n[s.uniqueId]=s,e&&(s.name=e(t.name)),s instanceof i.e){const e=s;if(e.morphTargetManager){const s=t.morphTargetManager;e.morphTargetManager=s.clone();for(let t=0;te&&n[r[e.uniqueId]]))}}"InstancedMesh"!==i.getClassName()&&(i.material=n[r[t.uniqueId]])}else"MultiMaterial"===i.material.getClassName()?-1===this.scene.multiMaterials.indexOf(i.material)&&this.scene.addMultiMaterial(i.material):-1===this.scene.materials.indexOf(i.material)&&this.scene.addMaterial(i.material)}null===o.parent&&a.rootNodes.push(o)};return _.forEach((e=>{if("InstancedMesh"===e.getClassName()){const t=e,s=t.sourceMesh,i=r[s.uniqueId],a=("number"==typeof i?n[i]:s).createInstance(t.name);f(t,a)}else{let t=!0;"TransformNode"===e.getClassName()||"Node"===e.getClassName()||e.skeleton||!e.getTotalVertices||0===e.getTotalVertices()?t=!1:l.doNotInstantiate&&(t="function"==typeof l.doNotInstantiate?!l.doNotInstantiate(e):!l.doNotInstantiate);const s=t?e.createInstance(`instance of ${e.name}`):e.clone(`Clone of ${e.name}`,null,!0);if(!s)throw new Error(`Could not clone or instantiate node on Asset Container ${e.name}`);f(e,s)}})),this.skeletons.forEach((t=>{if(l.predicate&&!l.predicate(t))return;const s=t.clone(e?e(t.name):"Clone of "+t.name);for(const e of this.meshes)if(e.skeleton===t&&!e.isAnInstance){const t=n[r[e.uniqueId]];if(!t||t.isAnInstance)continue;if(t.skeleton=s,-1!==o.indexOf(s))continue;o.push(s);for(const e of s.bones)e._linkedTransformNode&&(e._linkedTransformNode=n[r[e._linkedTransformNode.uniqueId]])}a.skeletons.push(s)})),this.animationGroups.forEach((t=>{if(l.predicate&&!l.predicate(t))return;const s=t.clone(e?e(t.name):"Clone of "+t.name,(e=>n[r[e.uniqueId]]||e));a.animationGroups.push(s)})),a}addAllToScene(){if(!this._wasAddedToScene){this._isValidHierarchy()||u.S0.Warn("SceneSerializer.addAllToScene: The Asset Container hierarchy is not valid."),this._wasAddedToScene=!0,this.addToScene(null),this.environmentTexture&&(this.scene.environmentTexture=this.environmentTexture);for(const e of this.scene._serializableComponents)e.addFromContainer(this);this.scene.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver),this._onContextRestoredObserver=null}}addToScene(e=null){const t=[];this.cameras.forEach((s=>{e&&!e(s)||(this.scene.addCamera(s),t.push(s))})),this.lights.forEach((s=>{e&&!e(s)||(this.scene.addLight(s),t.push(s))})),this.meshes.forEach((s=>{e&&!e(s)||(this.scene.addMesh(s),t.push(s))})),this.skeletons.forEach((t=>{e&&!e(t)||this.scene.addSkeleton(t)})),this.animations.forEach((t=>{e&&!e(t)||this.scene.addAnimation(t)})),this.animationGroups.forEach((t=>{e&&!e(t)||this.scene.addAnimationGroup(t)})),this.multiMaterials.forEach((t=>{e&&!e(t)||this.scene.addMultiMaterial(t)})),this.materials.forEach((t=>{e&&!e(t)||this.scene.addMaterial(t)})),this.morphTargetManagers.forEach((t=>{e&&!e(t)||this.scene.addMorphTargetManager(t)})),this.geometries.forEach((t=>{e&&!e(t)||this.scene.addGeometry(t)})),this.transformNodes.forEach((s=>{e&&!e(s)||(this.scene.addTransformNode(s),t.push(s))})),this.actionManagers.forEach((t=>{e&&!e(t)||this.scene.addActionManager(t)})),this.textures.forEach((t=>{e&&!e(t)||this.scene.addTexture(t)})),this.reflectionProbes.forEach((t=>{e&&!e(t)||this.scene.addReflectionProbe(t)}));for(const e of t)e.parent&&-1===this.scene.getNodes().indexOf(e.parent)&&(e.setParent?e.setParent(null):e.parent=null)}removeAllFromScene(){this._isValidHierarchy()||u.S0.Warn("SceneSerializer.removeAllFromScene: The Asset Container hierarchy is not valid."),this._wasAddedToScene=!1,this.removeFromScene(null),this.environmentTexture===this.scene.environmentTexture&&(this.scene.environmentTexture=null);for(const e of this.scene._serializableComponents)e.removeFromContainer(this)}removeFromScene(e=null){this.cameras.forEach((t=>{e&&!e(t)||this.scene.removeCamera(t)})),this.lights.forEach((t=>{e&&!e(t)||this.scene.removeLight(t)})),this.meshes.forEach((t=>{e&&!e(t)||this.scene.removeMesh(t,!0)})),this.skeletons.forEach((t=>{e&&!e(t)||this.scene.removeSkeleton(t)})),this.animations.forEach((t=>{e&&!e(t)||this.scene.removeAnimation(t)})),this.animationGroups.forEach((t=>{e&&!e(t)||this.scene.removeAnimationGroup(t)})),this.multiMaterials.forEach((t=>{e&&!e(t)||this.scene.removeMultiMaterial(t)})),this.materials.forEach((t=>{e&&!e(t)||this.scene.removeMaterial(t)})),this.morphTargetManagers.forEach((t=>{e&&!e(t)||this.scene.removeMorphTargetManager(t)})),this.geometries.forEach((t=>{e&&!e(t)||this.scene.removeGeometry(t)})),this.transformNodes.forEach((t=>{e&&!e(t)||this.scene.removeTransformNode(t)})),this.actionManagers.forEach((t=>{e&&!e(t)||this.scene.removeActionManager(t)})),this.textures.forEach((t=>{e&&!e(t)||this.scene.removeTexture(t)})),this.reflectionProbes.forEach((t=>{e&&!e(t)||this.scene.removeReflectionProbe(t)}))}dispose(){this.cameras.slice(0).forEach((e=>{e.dispose()})),this.cameras.length=0,this.lights.slice(0).forEach((e=>{e.dispose()})),this.lights.length=0,this.meshes.slice(0).forEach((e=>{e.dispose()})),this.meshes.length=0,this.skeletons.slice(0).forEach((e=>{e.dispose()})),this.skeletons.length=0,this.animationGroups.slice(0).forEach((e=>{e.dispose()})),this.animationGroups.length=0,this.multiMaterials.slice(0).forEach((e=>{e.dispose()})),this.multiMaterials.length=0,this.materials.slice(0).forEach((e=>{e.dispose()})),this.materials.length=0,this.geometries.slice(0).forEach((e=>{e.dispose()})),this.geometries.length=0,this.transformNodes.slice(0).forEach((e=>{e.dispose()})),this.transformNodes.length=0,this.actionManagers.slice(0).forEach((e=>{e.dispose()})),this.actionManagers.length=0,this.textures.slice(0).forEach((e=>{e.dispose()})),this.textures.length=0,this.reflectionProbes.slice(0).forEach((e=>{e.dispose()})),this.reflectionProbes.length=0,this.morphTargetManagers.slice(0).forEach((e=>{e.dispose()})),this.morphTargetManagers.length=0,this.environmentTexture&&(this.environmentTexture.dispose(),this.environmentTexture=null);for(const e of this.scene._serializableComponents)e.removeFromContainer(this,!0);this._onContextRestoredObserver&&(this.scene.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver),this._onContextRestoredObserver=null)}_moveAssets(e,t,s){if(e&&t)for(const i of e){let e=!0;if(s)for(const t of s)if(i===t){e=!1;break}e&&(t.push(i),i._parentContainer=this)}}moveAllFromScene(e){this._wasAddedToScene=!1,void 0===e&&(e=new m);for(const t in this)Object.prototype.hasOwnProperty.call(this,t)&&(this[t]=this[t]||("_environmentTexture"===t?null:[]),this._moveAssets(this.scene[t],this[t],e[t]));this.environmentTexture=this.scene.environmentTexture,this.removeAllFromScene()}createRootMesh(){const e=new i.e("assetContainerRootMesh",this.scene);return this.meshes.forEach((t=>{t.parent||e.addChild(t)})),this.meshes.unshift(e),e}mergeAnimationsTo(e=o.q.LastCreatedScene,t,s=null){if(!e)return a.V.Error("No scene available to merge animations to"),[];const i=s||(t=>{let s=null;const i=t.animations.length?t.animations[0].targetProperty:"",r=t.name.split(".").join("").split("_primitive")[0];switch(i){case"position":case"rotationQuaternion":s=e.getTransformNodeByName(t.name)||e.getTransformNodeByName(r);break;case"influence":s=e.getMorphTargetByName(t.name)||e.getMorphTargetByName(r);break;default:s=e.getNodeByName(t.name)||e.getNodeByName(r)}return s});this.getNodes().forEach((e=>{const t=i(e);if(null!==t){for(const s of e.animations){const e=t.animations.filter((e=>e.targetProperty===s.targetProperty));for(const s of e){const e=t.animations.indexOf(s,0);e>-1&&t.animations.splice(e,1)}}t.animations=t.animations.concat(e.animations)}}));const r=[];return this.animationGroups.slice().forEach((e=>{r.push(e.clone(e.name,i)),e.animatables.forEach((e=>{e.stop()}))})),t.forEach((t=>{const s=i(t.target);s&&(e.beginAnimation(s,t.fromFrame,t.toFrame,t.loopAnimation,t.speedRatio,t.onAnimationEnd?t.onAnimationEnd:void 0,void 0,!0,void 0,t.onAnimationLoop?t.onAnimationLoop:void 0),e.stopAnimation(t.target))})),r}populateRootNodes(){this.rootNodes.length=0,this.meshes.forEach((e=>{e.parent||-1!==this.rootNodes.indexOf(e)||this.rootNodes.push(e)})),this.transformNodes.forEach((e=>{e.parent||-1!==this.rootNodes.indexOf(e)||this.rootNodes.push(e)})),this.lights.forEach((e=>{e.parent||-1!==this.rootNodes.indexOf(e)||this.rootNodes.push(e)})),this.cameras.forEach((e=>{e.parent||-1!==this.rootNodes.indexOf(e)||this.rootNodes.push(e)}))}addAllAssetsToContainer(e){if(!e)return;const t=[],s=new Set;for(t.push(e);t.length>0;){const e=t.pop();if(e instanceof i.e?(e.geometry&&-1===this.geometries.indexOf(e.geometry)&&this.geometries.push(e.geometry),this.meshes.push(e)):e instanceof r.V?this.transformNodes.push(e):e instanceof f.v?this.lights.push(e):e instanceof p.i&&this.cameras.push(e),e instanceof n.u){if(e.material&&-1===this.materials.indexOf(e.material)){this.materials.push(e.material);for(const t of e.material.getActiveTextures())-1===this.textures.indexOf(t)&&this.textures.push(t)}e.skeleton&&-1===this.skeletons.indexOf(e.skeleton)&&this.skeletons.push(e.skeleton),e.morphTargetManager&&-1===this.morphTargetManagers.indexOf(e.morphTargetManager)&&this.morphTargetManagers.push(e.morphTargetManager)}for(const i of e.getChildren())s.has(i)||t.push(i);s.add(e)}this.populateRootNodes()}}},4870:(e,t,s)=>{s.d(t,{b:()=>u});var i=s(5524),r=s(9923),n=s(9259),a=s(9848),o=s(6315),h=s(5503),l=s(6877);class c{constructor(){this._doNotSerialize=!1,this._isDisposed=!1,this._sceneRootNodesIndex=-1,this._isEnabled=!0,this._isParentEnabled=!0,this._isReady=!0,this._onEnabledStateChangedObservable=new a.cP,this._onClonedObservable=new a.cP}}class u{static AddNodeConstructor(e,t){this._NodeConstructors[e]=t}static Construct(e,t,s,i){const r=this._NodeConstructors[e];return r?r(t,s,i):null}set accessibilityTag(e){this._accessibilityTag=e,this.onAccessibilityTagChangedObservable.notifyObservers(e)}get accessibilityTag(){return this._accessibilityTag}get doNotSerialize(){return!!this._nodeDataStorage._doNotSerialize||!!this._parentNode&&this._parentNode.doNotSerialize}set doNotSerialize(e){this._nodeDataStorage._doNotSerialize=e}isDisposed(){return this._nodeDataStorage._isDisposed}set parent(e){if(this._parentNode===e)return;const t=this._parentNode;if(this._parentNode&&void 0!==this._parentNode._children&&null!==this._parentNode._children){const t=this._parentNode._children.indexOf(this);-1!==t&&this._parentNode._children.splice(t,1),e||this._nodeDataStorage._isDisposed||this._addToSceneRootNodes()}this._parentNode=e,this._isDirty=!0,this._parentNode&&(void 0!==this._parentNode._children&&null!==this._parentNode._children||(this._parentNode._children=new Array),this._parentNode._children.push(this),t||this._removeFromSceneRootNodes()),this._syncParentEnabledState()}get parent(){return this._parentNode}_serializeAsParent(e){e.parentId=this.uniqueId}_addToSceneRootNodes(){-1===this._nodeDataStorage._sceneRootNodesIndex&&(this._nodeDataStorage._sceneRootNodesIndex=this._scene.rootNodes.length,this._scene.rootNodes.push(this))}_removeFromSceneRootNodes(){if(-1!==this._nodeDataStorage._sceneRootNodesIndex){const e=this._scene.rootNodes,t=e.length-1;e[this._nodeDataStorage._sceneRootNodesIndex]=e[t],e[this._nodeDataStorage._sceneRootNodesIndex]._nodeDataStorage._sceneRootNodesIndex=this._nodeDataStorage._sceneRootNodesIndex,this._scene.rootNodes.pop(),this._nodeDataStorage._sceneRootNodesIndex=-1}}get animationPropertiesOverride(){return this._animationPropertiesOverride?this._animationPropertiesOverride:this._scene.animationPropertiesOverride}set animationPropertiesOverride(e){this._animationPropertiesOverride=e}getClassName(){return"Node"}set onDispose(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)}get onEnabledStateChangedObservable(){return this._nodeDataStorage._onEnabledStateChangedObservable}get onClonedObservable(){return this._nodeDataStorage._onClonedObservable}constructor(e,t=null,s=!0){this._isDirty=!1,this._nodeDataStorage=new c,this.state="",this.metadata=null,this.reservedDataStore=null,this._accessibilityTag=null,this.onAccessibilityTagChangedObservable=new a.cP,this._parentContainer=null,this.animations=[],this._ranges={},this.onReady=null,this._currentRenderId=-1,this._parentUpdateId=-1,this._childUpdateId=-1,this._waitingParentId=null,this._waitingParentInstanceIndex=null,this._waitingParsedUniqueId=null,this._cache={},this._parentNode=null,this._children=null,this._worldMatrix=r.uq.Identity(),this._worldMatrixDeterminant=0,this._worldMatrixDeterminantIsDirty=!0,this._animationPropertiesOverride=null,this._isNode=!0,this.onDisposeObservable=new a.cP,this._onDisposeObserver=null,this._behaviors=new Array,this.name=e,this.id=e,this._scene=t||o.q.LastCreatedScene,this.uniqueId=this._scene.getUniqueId(),this._initCache(),s&&this._addToSceneRootNodes()}getScene(){return this._scene}getEngine(){return this._scene.getEngine()}addBehavior(e,t=!1){return-1!==this._behaviors.indexOf(e)||(e.init(),this._scene.isLoading&&!t?this._scene.onDataLoadedObservable.addOnce((()=>{e.attach(this)})):e.attach(this),this._behaviors.push(e)),this}removeBehavior(e){const t=this._behaviors.indexOf(e);return-1===t||(this._behaviors[t].detach(),this._behaviors.splice(t,1)),this}get behaviors(){return this._behaviors}getBehaviorByName(e){for(const t of this._behaviors)if(t.name===e)return t;return null}getWorldMatrix(){return this._currentRenderId!==this._scene.getRenderId()&&this.computeWorldMatrix(),this._worldMatrix}_getWorldMatrixDeterminant(){return this._worldMatrixDeterminantIsDirty&&(this._worldMatrixDeterminantIsDirty=!1,this._worldMatrixDeterminant=this._worldMatrix.determinant()),this._worldMatrixDeterminant}get worldMatrixFromCache(){return this._worldMatrix}_initCache(){this._cache={}}updateCache(e){!e&&this.isSynchronized()||this._updateCache()}_getActionManagerForTrigger(e,t=!0){return this.parent?this.parent._getActionManagerForTrigger(e,!1):null}_updateCache(e){}_isSynchronized(){return!0}_markSyncedWithParent(){this._parentNode&&(this._parentUpdateId=this._parentNode._childUpdateId)}isSynchronizedWithParent(){return!this._parentNode||!this._parentNode._isDirty&&this._parentUpdateId===this._parentNode._childUpdateId&&this._parentNode.isSynchronized()}isSynchronized(){return!(this._parentNode&&!this.isSynchronizedWithParent())&&this._isSynchronized()}isReady(e=!1){return this._nodeDataStorage._isReady}markAsDirty(e){return this._currentRenderId=Number.MAX_VALUE,this._isDirty=!0,this}isEnabled(e=!0){return!1===e?this._nodeDataStorage._isEnabled:!!this._nodeDataStorage._isEnabled&&this._nodeDataStorage._isParentEnabled}_syncParentEnabledState(){this._nodeDataStorage._isParentEnabled=!this._parentNode||this._parentNode.isEnabled(),this._children&&this._children.forEach((e=>{e._syncParentEnabledState()}))}setEnabled(e){this._nodeDataStorage._isEnabled!==e&&(this._nodeDataStorage._isEnabled=e,this._syncParentEnabledState(),this._nodeDataStorage._onEnabledStateChangedObservable.notifyObservers(e))}isDescendantOf(e){return!!this.parent&&(this.parent===e||this.parent.isDescendantOf(e))}_getDescendants(e,t=!1,s){if(this._children)for(let i=0;i(!t||t(e))&&void 0!==e.cullingStrategy)),s}getChildren(e,t=!0){return this.getDescendants(t,e)}_setReady(e){e!==this._nodeDataStorage._isReady&&(e?(this.onReady&&this.onReady(this),this._nodeDataStorage._isReady=!0):this._nodeDataStorage._isReady=!1)}getAnimationByName(e){for(let t=0;tnew u(e,this.getScene())),this);if(t&&(i.parent=t),!s){const t=this.getDescendants(!0);for(let s=0;s{throw(0,h.n)("AnimationRange")},u._NodeConstructors={},(0,i.Cg)([(0,n.lK)()],u.prototype,"name",void 0),(0,i.Cg)([(0,n.lK)()],u.prototype,"id",void 0),(0,i.Cg)([(0,n.lK)()],u.prototype,"uniqueId",void 0),(0,i.Cg)([(0,n.lK)()],u.prototype,"state",void 0),(0,i.Cg)([(0,n.lK)()],u.prototype,"metadata",void 0)},554:(e,t,s)=>{s.d(t,{Z:()=>$});var i=s(998),r=s(6237),n=s(9848),a=s(7931);class o{constructor(){this._count=0,this._data={}}copyFrom(e){this.clear(),e.forEach(((e,t)=>this.add(e,t)))}get(e){const t=this._data[e];if(void 0!==t)return t}getOrAddWithFactory(e,t){let s=this.get(e);return void 0!==s||(s=t(e),s&&this.add(e,s)),s}getOrAdd(e,t){const s=this.get(e);return void 0!==s?s:(this.add(e,t),t)}contains(e){return void 0!==this._data[e]}add(e,t){return void 0===this._data[e]&&(this._data[e]=t,++this._count,!0)}set(e,t){return void 0!==this._data[e]&&(this._data[e]=t,!0)}getAndRemove(e){const t=this.get(e);return void 0!==t?(delete this._data[e],--this._count,t):null}remove(e){return!!this.contains(e)&&(delete this._data[e],--this._count,!0)}clear(){this._data={},this._count=0}get count(){return this._count}forEach(e){for(const t in this._data)e(t,this._data[t])}first(e){for(const t in this._data){const s=e(t,this._data[t]);if(s)return s}return null}}var h=s(7503),l=s(9923),c=s(1088),u=s(935),d=s(311);class _{constructor(e,t,s,i,r,n){this.source=e,this.pointerX=t,this.pointerY=s,this.meshUnderPointer=i,this.sourceEvent=r,this.additionalData=n}static CreateNew(e,t,s){const i=e.getScene();return new _(e,i.pointerX,i.pointerY,i.meshUnderPointer||e,t,s)}static CreateNewFromSprite(e,t,s,i){return new _(e,t.pointerX,t.pointerY,t.meshUnderPointer,s,i)}static CreateNewFromScene(e,t){return new _(null,e.pointerX,e.pointerY,e.meshUnderPointer,t)}static CreateNewFromPrimitive(e,t,s,i){return new _(e,t.x,t.y,null,s,i)}}var f=s(6096),p=s(3099),g=s(6945),m=s(8790),T=s(6315),b=s(5503),E=s(6240);class x{constructor(){this.hoverCursor="",this.actions=[],this.isRecursive=!1,this.disposeWhenUnowned=!0}static get HasTriggers(){for(const e in x.Triggers)if(Object.prototype.hasOwnProperty.call(x.Triggers,e))return!0;return!1}static get HasPickTriggers(){for(const e in x.Triggers)if(Object.prototype.hasOwnProperty.call(x.Triggers,e)){const t=parseInt(e);if(t>=1&&t<=7)return!0}return!1}static HasSpecificTrigger(e){for(const t in x.Triggers)if(Object.prototype.hasOwnProperty.call(x.Triggers,t)&&parseInt(t)===e)return!0;return!1}}x.Triggers={};var A,R,M,y,P,v,C,S=s(4146);!function(e){e[e.Generic=0]="Generic",e[e.Keyboard=1]="Keyboard",e[e.Mouse=2]="Mouse",e[e.Touch=3]="Touch",e[e.DualShock=4]="DualShock",e[e.Xbox=5]="Xbox",e[e.Switch=6]="Switch",e[e.DualSense=7]="DualSense"}(A||(A={})),function(e){e[e.Horizontal=0]="Horizontal",e[e.Vertical=1]="Vertical",e[e.LeftClick=2]="LeftClick",e[e.MiddleClick=3]="MiddleClick",e[e.RightClick=4]="RightClick",e[e.BrowserBack=5]="BrowserBack",e[e.BrowserForward=6]="BrowserForward",e[e.MouseWheelX=7]="MouseWheelX",e[e.MouseWheelY=8]="MouseWheelY",e[e.MouseWheelZ=9]="MouseWheelZ",e[e.Move=12]="Move"}(R||(R={})),function(e){e[e.Horizontal=0]="Horizontal",e[e.Vertical=1]="Vertical",e[e.LeftClick=2]="LeftClick",e[e.MiddleClick=3]="MiddleClick",e[e.RightClick=4]="RightClick",e[e.BrowserBack=5]="BrowserBack",e[e.BrowserForward=6]="BrowserForward",e[e.MouseWheelX=7]="MouseWheelX",e[e.MouseWheelY=8]="MouseWheelY",e[e.MouseWheelZ=9]="MouseWheelZ",e[e.DeltaHorizontal=10]="DeltaHorizontal",e[e.DeltaVertical=11]="DeltaVertical"}(M||(M={})),function(e){e[e.Cross=0]="Cross",e[e.Circle=1]="Circle",e[e.Square=2]="Square",e[e.Triangle=3]="Triangle",e[e.L1=4]="L1",e[e.R1=5]="R1",e[e.L2=6]="L2",e[e.R2=7]="R2",e[e.Share=8]="Share",e[e.Options=9]="Options",e[e.L3=10]="L3",e[e.R3=11]="R3",e[e.DPadUp=12]="DPadUp",e[e.DPadDown=13]="DPadDown",e[e.DPadLeft=14]="DPadLeft",e[e.DPadRight=15]="DPadRight",e[e.Home=16]="Home",e[e.TouchPad=17]="TouchPad",e[e.LStickXAxis=18]="LStickXAxis",e[e.LStickYAxis=19]="LStickYAxis",e[e.RStickXAxis=20]="RStickXAxis",e[e.RStickYAxis=21]="RStickYAxis"}(y||(y={})),function(e){e[e.Cross=0]="Cross",e[e.Circle=1]="Circle",e[e.Square=2]="Square",e[e.Triangle=3]="Triangle",e[e.L1=4]="L1",e[e.R1=5]="R1",e[e.L2=6]="L2",e[e.R2=7]="R2",e[e.Create=8]="Create",e[e.Options=9]="Options",e[e.L3=10]="L3",e[e.R3=11]="R3",e[e.DPadUp=12]="DPadUp",e[e.DPadDown=13]="DPadDown",e[e.DPadLeft=14]="DPadLeft",e[e.DPadRight=15]="DPadRight",e[e.Home=16]="Home",e[e.TouchPad=17]="TouchPad",e[e.LStickXAxis=18]="LStickXAxis",e[e.LStickYAxis=19]="LStickYAxis",e[e.RStickXAxis=20]="RStickXAxis",e[e.RStickYAxis=21]="RStickYAxis"}(P||(P={})),function(e){e[e.A=0]="A",e[e.B=1]="B",e[e.X=2]="X",e[e.Y=3]="Y",e[e.LB=4]="LB",e[e.RB=5]="RB",e[e.LT=6]="LT",e[e.RT=7]="RT",e[e.Back=8]="Back",e[e.Start=9]="Start",e[e.LS=10]="LS",e[e.RS=11]="RS",e[e.DPadUp=12]="DPadUp",e[e.DPadDown=13]="DPadDown",e[e.DPadLeft=14]="DPadLeft",e[e.DPadRight=15]="DPadRight",e[e.Home=16]="Home",e[e.LStickXAxis=17]="LStickXAxis",e[e.LStickYAxis=18]="LStickYAxis",e[e.RStickXAxis=19]="RStickXAxis",e[e.RStickYAxis=20]="RStickYAxis"}(v||(v={})),function(e){e[e.B=0]="B",e[e.A=1]="A",e[e.Y=2]="Y",e[e.X=3]="X",e[e.L=4]="L",e[e.R=5]="R",e[e.ZL=6]="ZL",e[e.ZR=7]="ZR",e[e.Minus=8]="Minus",e[e.Plus=9]="Plus",e[e.LS=10]="LS",e[e.RS=11]="RS",e[e.DPadUp=12]="DPadUp",e[e.DPadDown=13]="DPadDown",e[e.DPadLeft=14]="DPadLeft",e[e.DPadRight=15]="DPadRight",e[e.Home=16]="Home",e[e.Capture=17]="Capture",e[e.LStickXAxis=18]="LStickXAxis",e[e.LStickYAxis=19]="LStickYAxis",e[e.RStickXAxis=20]="RStickXAxis",e[e.RStickYAxis=21]="RStickYAxis"}(C||(C={}));var I=s(8123);class D{static CreateDeviceEvent(e,t,s,i,r,n,a){switch(e){case A.Keyboard:return this._CreateKeyboardEvent(s,i,r,n);case A.Mouse:if(s===R.MouseWheelX||s===R.MouseWheelY||s===R.MouseWheelZ)return this._CreateWheelEvent(e,t,s,i,r,n);case A.Touch:return this._CreatePointerEvent(e,t,s,i,r,n,a);default:throw`Unable to generate event for device ${A[e]}`}}static _CreatePointerEvent(e,t,s,i,r,n,a){const o=this._CreateMouseEvent(e,t,s,i,r,n);e===A.Mouse?(o.deviceType=A.Mouse,o.pointerId=1,o.pointerType="mouse"):(o.deviceType=A.Touch,o.pointerId=a??t,o.pointerType="touch");let h=0;return h+=r.pollInput(e,t,R.LeftClick),h+=2*r.pollInput(e,t,R.RightClick),h+=4*r.pollInput(e,t,R.MiddleClick),o.buttons=h,s===R.Move?o.type="pointermove":s>=R.LeftClick&&s<=R.RightClick&&(o.type=1===i?"pointerdown":"pointerup",o.button=s-2),o}static _CreateWheelEvent(e,t,s,i,r,n){const a=this._CreateMouseEvent(e,t,s,i,r,n);switch(a.pointerId=1,a.type="wheel",a.deltaMode=I.s.DOM_DELTA_PIXEL,a.deltaX=0,a.deltaY=0,a.deltaZ=0,s){case R.MouseWheelX:a.deltaX=i;break;case R.MouseWheelY:a.deltaY=i;break;case R.MouseWheelZ:a.deltaZ=i}return a}static _CreateMouseEvent(e,t,s,i,r,n){const a=this._CreateEvent(n),o=r.pollInput(e,t,R.Horizontal),h=r.pollInput(e,t,R.Vertical);return n?(a.movementX=0,a.movementY=0,a.offsetX=a.movementX-n.getBoundingClientRect().x,a.offsetY=a.movementY-n.getBoundingClientRect().y):(a.movementX=r.pollInput(e,t,10),a.movementY=r.pollInput(e,t,11),a.offsetX=0,a.offsetY=0),this._CheckNonCharacterKeys(a,r),a.clientX=o,a.clientY=h,a.x=o,a.y=h,a.deviceType=e,a.deviceSlot=t,a.inputIndex=s,a}static _CreateKeyboardEvent(e,t,s,i){const r=this._CreateEvent(i);return this._CheckNonCharacterKeys(r,s),r.deviceType=A.Keyboard,r.deviceSlot=0,r.inputIndex=e,r.type=1===t?"keydown":"keyup",r.key=String.fromCharCode(e),r.keyCode=e,r}static _CheckNonCharacterKeys(e,t){const s=t.isDeviceAvailable(A.Keyboard),i=s&&1===t.pollInput(A.Keyboard,0,18),r=s&&1===t.pollInput(A.Keyboard,0,17),n=s&&(1===t.pollInput(A.Keyboard,0,91)||1===t.pollInput(A.Keyboard,0,92)||1===t.pollInput(A.Keyboard,0,93)),a=s&&1===t.pollInput(A.Keyboard,0,16);e.altKey=i,e.ctrlKey=r,e.metaKey=n,e.shiftKey=a}static _CreateEvent(e){const t={preventDefault:()=>{}};return t.target=e,t}}class O{constructor(e,t,s){this._nativeInput=_native.DeviceInputSystem?new _native.DeviceInputSystem(e,t,((e,t,i,r)=>{const n=D.CreateDeviceEvent(e,t,i,r,this);s(e,t,n)})):this._createDummyNativeInput()}pollInput(e,t,s){return this._nativeInput.pollInput(e,t,s)}isDeviceAvailable(e){return e===A.Mouse||e===A.Touch}dispose(){this._nativeInput.dispose()}_createDummyNativeInput(){return{pollInput:()=>0,isDeviceAvailable:()=>!1,dispose:()=>{}}}}const F=Object.keys(R).length/2;class w{constructor(e,t,s,r){this._inputs=[],this._keyboardActive=!1,this._pointerActive=!1,this._usingSafari=i.S0.IsSafari(),this._usingMacOS=(0,m.XD)()&&/(Mac|iPhone|iPod|iPad)/i.test(navigator.platform),this._keyboardDownEvent=e=>{},this._keyboardUpEvent=e=>{},this._keyboardBlurEvent=e=>{},this._pointerMoveEvent=e=>{},this._pointerDownEvent=e=>{},this._pointerUpEvent=e=>{},this._pointerCancelEvent=e=>{},this._pointerWheelEvent=e=>{},this._pointerBlurEvent=e=>{},this._pointerMacOSChromeOutEvent=e=>{},this._eventsAttached=!1,this._mouseId=-1,this._isUsingFirefox=(0,m.XD)()&&navigator.userAgent&&-1!==navigator.userAgent.indexOf("Firefox"),this._isUsingChromium=(0,m.XD)()&&navigator.userAgent&&-1!==navigator.userAgent.indexOf("Chrome"),this._maxTouchPoints=0,this._pointerInputClearObserver=null,this._gamepadConnectedEvent=e=>{},this._gamepadDisconnectedEvent=e=>{},this._eventPrefix=i.S0.GetPointerPrefix(e),this._engine=e,this._onDeviceConnected=t,this._onDeviceDisconnected=s,this._onInputChanged=r,this._mouseId=this._isUsingFirefox?0:1,this._enableEvents(),this._usingMacOS&&(this._metaKeys=[]),this._engine._onEngineViewChanged||(this._engine._onEngineViewChanged=()=>{this._enableEvents()})}pollInput(e,t,s){const r=this._inputs[e][t];if(!r)throw`Unable to find device ${A[e]}`;e>=A.DualShock&&e<=A.DualSense&&this._updateDevice(e,t,s);const n=r[s];if(void 0===n)throw`Unable to find input ${s} for device ${A[e]} in slot ${t}`;return s===R.Move&&i.S0.Warn("Unable to provide information for PointerInput.Move. Try using PointerInput.Horizontal or PointerInput.Vertical for move data."),n}isDeviceAvailable(e){return void 0!==this._inputs[e]}dispose(){this._onDeviceConnected=()=>{},this._onDeviceDisconnected=()=>{},this._onInputChanged=()=>{},delete this._engine._onEngineViewChanged,this._elementToAttachTo&&this._disableEvents()}_enableEvents(){const e=this?._engine.getInputElement();if(e&&(!this._eventsAttached||this._elementToAttachTo!==e)){if(this._disableEvents(),this._inputs)for(const e of this._inputs)if(e)for(const t in e){const s=e[+t];if(s)for(let e=0;e{this._keyboardActive||(this._keyboardActive=!0,this._registerDevice(A.Keyboard,0,255));const t=this._inputs[A.Keyboard][0];if(t){t[e.keyCode]=1;const s=e;s.inputIndex=e.keyCode,this._usingMacOS&&e.metaKey&&"Meta"!==e.key&&(this._metaKeys.includes(e.keyCode)||this._metaKeys.push(e.keyCode)),this._onInputChanged(A.Keyboard,0,s)}},this._keyboardUpEvent=e=>{this._keyboardActive||(this._keyboardActive=!0,this._registerDevice(A.Keyboard,0,255));const t=this._inputs[A.Keyboard][0];if(t){t[e.keyCode]=0;const s=e;if(s.inputIndex=e.keyCode,this._usingMacOS&&"Meta"===e.key&&this._metaKeys.length>0){for(const e of this._metaKeys){const s=D.CreateDeviceEvent(A.Keyboard,0,e,0,this,this._elementToAttachTo);t[e]=0,this._onInputChanged(A.Keyboard,0,s)}this._metaKeys.splice(0,this._metaKeys.length)}this._onInputChanged(A.Keyboard,0,s)}},this._keyboardBlurEvent=()=>{if(this._keyboardActive){const e=this._inputs[A.Keyboard][0];for(let t=0;t{const t=this._getPointerType(e);let s=t===A.Mouse?0:this._activeTouchIds.indexOf(e.pointerId);if(t===A.Touch&&-1===s){const r=this._activeTouchIds.indexOf(-1);if(!(r>=0))return void i.S0.Warn(`Max number of touches exceeded. Ignoring touches in excess of ${this._maxTouchPoints}`);s=r,this._activeTouchIds[r]=e.pointerId,this._onDeviceConnected(t,s)}this._inputs[t]||(this._inputs[t]={}),this._inputs[t][s]||this._addPointerDevice(t,s,e.clientX,e.clientY);const r=this._inputs[t][s];if(r){const i=e;i.inputIndex=R.Move,r[R.Horizontal]=e.clientX,r[R.Vertical]=e.clientY,t===A.Touch&&0===r[R.LeftClick]&&(r[R.LeftClick]=1),void 0===e.pointerId&&(e.pointerId=this._mouseId),this._onInputChanged(t,s,i),this._usingSafari||-1===e.button||(i.inputIndex=e.button+2,r[e.button+2]=r[e.button+2]?0:1,this._onInputChanged(t,s,i))}},this._pointerDownEvent=e=>{const t=this._getPointerType(e);let s=t===A.Mouse?0:e.pointerId;if(t===A.Touch){let t=this._activeTouchIds.indexOf(e.pointerId);if(-1===t&&(t=this._activeTouchIds.indexOf(-1)),!(t>=0))return void i.S0.Warn(`Max number of touches exceeded. Ignoring touches in excess of ${this._maxTouchPoints}`);s=t,this._activeTouchIds[t]=e.pointerId}this._inputs[t]||(this._inputs[t]={}),this._inputs[t][s]?t===A.Touch&&this._onDeviceConnected(t,s):this._addPointerDevice(t,s,e.clientX,e.clientY);const r=this._inputs[t][s];if(r){const i=r[R.Horizontal],n=r[R.Vertical];if(t===A.Mouse){if(void 0===e.pointerId&&(e.pointerId=this._mouseId),!document.pointerLockElement)try{this._elementToAttachTo.setPointerCapture(this._mouseId)}catch(e){}}else if(e.pointerId&&!document.pointerLockElement)try{this._elementToAttachTo.setPointerCapture(e.pointerId)}catch(e){}r[R.Horizontal]=e.clientX,r[R.Vertical]=e.clientY,r[e.button+2]=1;const a=e;a.inputIndex=e.button+2,this._onInputChanged(t,s,a),i===e.clientX&&n===e.clientY||(a.inputIndex=R.Move,this._onInputChanged(t,s,a))}},this._pointerUpEvent=e=>{const t=this._getPointerType(e),s=t===A.Mouse?0:this._activeTouchIds.indexOf(e.pointerId);if(t===A.Touch){if(-1===s)return;this._activeTouchIds[s]=-1}const i=this._inputs[t]?.[s];if(i&&0!==i[e.button+2]){const r=i[R.Horizontal],n=i[R.Vertical];i[R.Horizontal]=e.clientX,i[R.Vertical]=e.clientY,i[e.button+2]=0;const a=e;void 0===e.pointerId&&(e.pointerId=this._mouseId),r===e.clientX&&n===e.clientY||(a.inputIndex=R.Move,this._onInputChanged(t,s,a)),a.inputIndex=e.button+2,t===A.Mouse&&this._mouseId>=0&&this._elementToAttachTo.hasPointerCapture?.(this._mouseId)?this._elementToAttachTo.releasePointerCapture(this._mouseId):e.pointerId&&this._elementToAttachTo.hasPointerCapture?.(e.pointerId)&&this._elementToAttachTo.releasePointerCapture(e.pointerId),this._onInputChanged(t,s,a),t===A.Touch&&this._onDeviceDisconnected(t,s)}},this._pointerCancelEvent=e=>{if("mouse"===e.pointerType){const e=this._inputs[A.Mouse][0];this._mouseId>=0&&this._elementToAttachTo.hasPointerCapture?.(this._mouseId)&&this._elementToAttachTo.releasePointerCapture(this._mouseId);for(let t=R.LeftClick;t<=R.BrowserForward;t++)if(1===e[t]){e[t]=0;const s=D.CreateDeviceEvent(A.Mouse,0,t,0,this,this._elementToAttachTo);this._onInputChanged(A.Mouse,0,s)}}else{const t=this._activeTouchIds.indexOf(e.pointerId);if(-1===t)return;this._elementToAttachTo.hasPointerCapture?.(e.pointerId)&&this._elementToAttachTo.releasePointerCapture(e.pointerId),this._inputs[A.Touch][t][R.LeftClick]=0;const s=D.CreateDeviceEvent(A.Touch,t,R.LeftClick,0,this,this._elementToAttachTo,e.pointerId);this._onInputChanged(A.Touch,t,s),this._activeTouchIds[t]=-1,this._onDeviceDisconnected(A.Touch,t)}},this._wheelEventName="onwheel"in document.createElement("div")?"wheel":void 0!==document.onmousewheel?"mousewheel":"DOMMouseScroll";let e=!1;const t=function(){};try{const s=Object.defineProperty({},"passive",{get:function(){e=!0}});this._elementToAttachTo.addEventListener("test",t,s),this._elementToAttachTo.removeEventListener("test",t,s)}catch(e){}this._pointerBlurEvent=()=>{if(this.isDeviceAvailable(A.Mouse)){const e=this._inputs[A.Mouse][0];this._mouseId>=0&&this._elementToAttachTo.hasPointerCapture?.(this._mouseId)&&this._elementToAttachTo.releasePointerCapture(this._mouseId);for(let t=R.LeftClick;t<=R.BrowserForward;t++)if(1===e[t]){e[t]=0;const s=D.CreateDeviceEvent(A.Mouse,0,t,0,this,this._elementToAttachTo);this._onInputChanged(A.Mouse,0,s)}}if(this.isDeviceAvailable(A.Touch)){const e=this._inputs[A.Touch];for(let t=0;t{const t=A.Mouse;this._inputs[t]||(this._inputs[t]=[]),this._inputs[t][0]||(this._pointerActive=!0,this._registerDevice(t,0,F));const s=this._inputs[t][0];if(s){s[R.MouseWheelX]=e.deltaX||0,s[R.MouseWheelY]=e.deltaY||e.wheelDelta||0,s[R.MouseWheelZ]=e.deltaZ||0;const i=e;void 0===e.pointerId&&(e.pointerId=this._mouseId),0!==s[R.MouseWheelX]&&(i.inputIndex=R.MouseWheelX,this._onInputChanged(t,0,i)),0!==s[R.MouseWheelY]&&(i.inputIndex=R.MouseWheelY,this._onInputChanged(t,0,i)),0!==s[R.MouseWheelZ]&&(i.inputIndex=R.MouseWheelZ,this._onInputChanged(t,0,i))}},this._usingMacOS&&this._isUsingChromium&&(this._pointerMacOSChromeOutEvent=e=>{e.buttons>1&&this._pointerCancelEvent(e)},this._elementToAttachTo.addEventListener("lostpointercapture",this._pointerMacOSChromeOutEvent)),this._elementToAttachTo.addEventListener(this._eventPrefix+"move",this._pointerMoveEvent),this._elementToAttachTo.addEventListener(this._eventPrefix+"down",this._pointerDownEvent),this._elementToAttachTo.addEventListener(this._eventPrefix+"up",this._pointerUpEvent),this._elementToAttachTo.addEventListener(this._eventPrefix+"cancel",this._pointerCancelEvent),this._elementToAttachTo.addEventListener("blur",this._pointerBlurEvent),this._elementToAttachTo.addEventListener(this._wheelEventName,this._pointerWheelEvent,!!e&&{passive:!1}),this._pointerInputClearObserver=this._engine.onEndFrameObservable.add((()=>{if(this.isDeviceAvailable(A.Mouse)){const e=this._inputs[A.Mouse][0];e[R.MouseWheelX]=0,e[R.MouseWheelY]=0,e[R.MouseWheelZ]=0}}))}_handleGamepadActions(){this._gamepadConnectedEvent=e=>{this._addGamePad(e.gamepad)},this._gamepadDisconnectedEvent=e=>{if(this._gamepads){const t=this._getGamepadDeviceType(e.gamepad.id),s=e.gamepad.index;this._unregisterDevice(t,s),delete this._gamepads[s]}},window.addEventListener("gamepadconnected",this._gamepadConnectedEvent),window.addEventListener("gamepaddisconnected",this._gamepadDisconnectedEvent)}_updateDevice(e,t,s){const i=navigator.getGamepads()[t];if(i&&e===this._gamepads[t]){const r=this._inputs[e][t];s>=i.buttons.length?r[s]=i.axes[s-i.buttons.length].valueOf():r[s]=i.buttons[s].value}}_getGamepadDeviceType(e){return-1!==e.indexOf("054c")?-1!==e.indexOf("0ce6")?A.DualSense:A.DualShock:-1!==e.indexOf("Xbox One")||-1!==e.search("Xbox 360")||-1!==e.search("xinput")?A.Xbox:-1!==e.indexOf("057e")?A.Switch:A.Generic}_getPointerType(e){let t=A.Mouse;return("touch"===e.pointerType||"pen"===e.pointerType||e.touches)&&(t=A.Touch),t}}class L{constructor(e,t,s=0){this.deviceType=t,this.deviceSlot=s,this.onInputChangedObservable=new n.cP,this._deviceInputSystem=e}getInput(e){return this._deviceInputSystem.pollInput(this.deviceType,this.deviceSlot,e)}}class B{constructor(e){this._registeredManagers=new Array,this._refCount=0,this.registerManager=e=>{for(let t=0;t{const t=this._registeredManagers.indexOf(e);t>-1&&this._registeredManagers.splice(t,1)};const t=Object.keys(A).length/2;this._devices=new Array(t);const s=(e,t)=>{this._devices[e]||(this._devices[e]=new Array),this._devices[e][t]||(this._devices[e][t]=t);for(const s of this._registeredManagers){const i=new L(this._deviceInputSystem,e,t);s._addDevice(i)}},i=(e,t)=>{this._devices[e]?.[t]&&delete this._devices[e][t];for(const s of this._registeredManagers)s._removeDevice(e,t)},r=(e,t,s)=>{if(s)for(const i of this._registeredManagers)i._onInputChanged(e,t,s)};"undefined"!=typeof _native?this._deviceInputSystem=new O(s,i,r):this._deviceInputSystem=new w(e,s,i,r)}dispose(){this._deviceInputSystem.dispose()}}class N{getDeviceSource(e,t){if(void 0===t){if(void 0===this._firstDevice[e])return null;t=this._firstDevice[e]}return this._devices[e]&&void 0!==this._devices[e][t]?this._devices[e][t]:null}getDeviceSources(e){return this._devices[e]?this._devices[e].filter((e=>!!e)):[]}constructor(e){const t=Object.keys(A).length/2;this._devices=new Array(t),this._firstDevice=new Array(t),this._engine=e,this._engine._deviceSourceManager||(this._engine._deviceSourceManager=new B(e)),this._engine._deviceSourceManager._refCount++,this.onDeviceConnectedObservable=new n.cP((e=>{for(const t of this._devices)if(t)for(const s of t)s&&this.onDeviceConnectedObservable.notifyObserver(e,s)})),this.onDeviceDisconnectedObservable=new n.cP,this._engine._deviceSourceManager.registerManager(this),this._onDisposeObserver=e.onDisposeObservable.add((()=>{this.dispose()}))}dispose(){this.onDeviceConnectedObservable.clear(),this.onDeviceDisconnectedObservable.clear(),this._engine._deviceSourceManager&&(this._engine._deviceSourceManager.unregisterManager(this),--this._engine._deviceSourceManager._refCount<1&&(this._engine._deviceSourceManager.dispose(),delete this._engine._deviceSourceManager)),this._engine.onDisposeObservable.remove(this._onDisposeObserver)}_addDevice(e){this._devices[e.deviceType]||(this._devices[e.deviceType]=new Array),this._devices[e.deviceType][e.deviceSlot]||(this._devices[e.deviceType][e.deviceSlot]=e,this._updateFirstDevices(e.deviceType)),this.onDeviceConnectedObservable.notifyObservers(e)}_removeDevice(e,t){const s=this._devices[e]?.[t];this.onDeviceDisconnectedObservable.notifyObservers(s),this._devices[e]?.[t]&&delete this._devices[e][t],this._updateFirstDevices(e)}_onInputChanged(e,t,s){this._devices[e]?.[t]?.onInputChangedObservable.notifyObservers(s)}_updateFirstDevices(e){switch(e){case A.Keyboard:case A.Mouse:this._firstDevice[e]=0;break;case A.Touch:case A.DualSense:case A.DualShock:case A.Xbox:case A.Switch:case A.Generic:{delete this._firstDevice[e];const t=this._devices[e];if(t)for(let s=0;s=R.MouseWheelX&&t.inputIndex<=R.MouseWheelZ?E.Zp.POINTERWHEEL:E.Zp.POINTERMOVE;let a;s.onPointerMove&&(e=e||this._pickMove(t),s.onPointerMove(t,e,n)),e?(a=new E.mx(n,t,e),this._setRayOnPointerInfo(e,t)):(a=new E.mx(n,t,null,this),this._movePointerInfo=a),s.onPointerObservable.hasObservers()&&s.onPointerObservable.notifyObservers(a,n)}_setRayOnPointerInfo(e,t){const s=this._scene;e&&U._IsPickingAvailable&&(e.ray||(e.ray=s.createPickingRay(t.offsetX,t.offsetY,l.uq.Identity(),s.activeCamera)))}_addCameraPointerObserver(e,t){return this._cameraObserverCount++,this._scene.onPointerObservable.add(e,t)}_removeCameraPointerObserver(e){return this._cameraObserverCount--,this._scene.onPointerObservable.remove(e)}_checkForPicking(){return!!(this._scene.onPointerObservable.observers.length>this._cameraObserverCount||this._scene.onPointerPick)}_checkPrePointerObservable(e,t,s){const i=this._scene,r=new E.tT(s,t,this._unTranslatedPointerX,this._unTranslatedPointerY);return e&&(r.originalPickingInfo=e,r.ray=e.ray,"xr-near"===t.pointerType&&e.originMesh&&(r.nearInteractionPickingInfo=e)),i.onPrePointerObservable.notifyObservers(r,s),!!r.skipOnPointerObservable}_pickMove(e){const t=this._scene,s=t.pick(this._unTranslatedPointerX,this._unTranslatedPointerY,t.pointerMovePredicate,t.pointerMoveFastCheck,t.cameraToUseForPointers,t.pointerMoveTrianglePredicate);return this._setCursorAndPointerOverMesh(s,e,t),s}_setCursorAndPointerOverMesh(e,t,s){const i=s.getEngine().getInputElement();if(e?.pickedMesh){if(this.setPointerOverMesh(e.pickedMesh,t.pointerId,e,t),!s.doNotHandleCursors&&i&&this._pointerOverMesh){const e=this._pointerOverMesh._getActionManagerForTrigger();e&&e.hasPointerTriggers&&(i.style.cursor=e.hoverCursor||s.hoverCursor)}}else this.setPointerOverMesh(null,t.pointerId,e,t)}simulatePointerMove(e,t){const s=new PointerEvent("pointermove",t);s.inputIndex=R.Move,this._checkPrePointerObservable(e,s,E.Zp.POINTERMOVE)||this._processPointerMove(e,s)}simulatePointerDown(e,t){const s=new PointerEvent("pointerdown",t);s.inputIndex=s.button+2,this._checkPrePointerObservable(e,s,E.Zp.POINTERDOWN)||this._processPointerDown(e,s)}_processPointerDown(e,t){const s=this._scene;if(e?.pickedMesh){this._pickedDownMesh=e.pickedMesh;const i=e.pickedMesh._getActionManagerForTrigger();if(i){if(i.hasPickTriggers)switch(i.processTrigger(5,_.CreateNew(e.pickedMesh,t,e)),t.button){case 0:i.processTrigger(2,_.CreateNew(e.pickedMesh,t,e));break;case 1:i.processTrigger(4,_.CreateNew(e.pickedMesh,t,e));break;case 2:i.processTrigger(3,_.CreateNew(e.pickedMesh,t,e))}i.hasSpecificTrigger(8)&&window.setTimeout((()=>{const e=s.pick(this._unTranslatedPointerX,this._unTranslatedPointerY,(e=>e.isPickable&&e.isVisible&&e.isReady()&&e.actionManager&&e.actionManager.hasSpecificTrigger(8)&&e===this._pickedDownMesh),!1,s.cameraToUseForPointers);e?.pickedMesh&&i&&0!==this._activePointerIdsCount&&Date.now()-this._startingPointerTime>V.LongPressDelay&&!this._isPointerSwiping()&&(this._startingPointerTime=0,i.processTrigger(8,_.CreateNew(e.pickedMesh,t)))}),V.LongPressDelay)}}else for(const i of s._pointerDownStage)e=i.action(this._unTranslatedPointerX,this._unTranslatedPointerY,e,t,!1);let i;const r=E.Zp.POINTERDOWN;e?(s.onPointerDown&&s.onPointerDown(t,e,r),i=new E.mx(r,t,e),this._setRayOnPointerInfo(e,t)):i=new E.mx(r,t,null,this),s.onPointerObservable.hasObservers()&&s.onPointerObservable.notifyObservers(i,r)}_isPointerSwiping(){return this._isSwiping}simulatePointerUp(e,t,s){const i=new PointerEvent("pointerup",t);i.inputIndex=R.Move;const r=new k;s?r.doubleClick=!0:r.singleClick=!0,this._checkPrePointerObservable(e,i,E.Zp.POINTERUP)||this._processPointerUp(e,i,r)}_processPointerUp(e,t,s){const i=this._scene;if(e?.pickedMesh){if(this._pickedUpMesh=e.pickedMesh,this._pickedDownMesh===this._pickedUpMesh&&(i.onPointerPick&&i.onPointerPick(t,e),s.singleClick&&!s.ignore&&i.onPointerObservable.observers.length>this._cameraObserverCount)){const s=E.Zp.POINTERPICK,r=new E.mx(s,t,e);this._setRayOnPointerInfo(e,t),i.onPointerObservable.notifyObservers(r,s)}const r=e.pickedMesh._getActionManagerForTrigger();if(r&&!s.ignore){r.processTrigger(7,_.CreateNew(e.pickedMesh,t,e)),!s.hasSwiped&&s.singleClick&&r.processTrigger(1,_.CreateNew(e.pickedMesh,t,e));const i=e.pickedMesh._getActionManagerForTrigger(6);s.doubleClick&&i&&i.processTrigger(6,_.CreateNew(e.pickedMesh,t,e))}}else if(!s.ignore)for(const r of i._pointerUpStage)e=r.action(this._unTranslatedPointerX,this._unTranslatedPointerY,e,t,s.doubleClick);if(this._pickedDownMesh&&this._pickedDownMesh!==this._pickedUpMesh){const e=this._pickedDownMesh._getActionManagerForTrigger(16);e&&e.processTrigger(16,_.CreateNew(this._pickedDownMesh,t))}if(!s.ignore){const r=new E.mx(E.Zp.POINTERUP,t,e);if(this._setRayOnPointerInfo(e,t),i.onPointerObservable.notifyObservers(r,E.Zp.POINTERUP),i.onPointerUp&&i.onPointerUp(t,e,E.Zp.POINTERUP),!s.hasSwiped&&!this._skipPointerTap&&!this._isMultiTouchGesture){let r=0;if(s.singleClick?r=E.Zp.POINTERTAP:s.doubleClick&&(r=E.Zp.POINTERDOUBLETAP),r){const s=new E.mx(r,t,e);i.onPointerObservable.hasObservers()&&i.onPointerObservable.hasSpecificMask(r)&&i.onPointerObservable.notifyObservers(s,r)}}}}isPointerCaptured(e=0){return this._pointerCaptures[e]}attachControl(e=!0,t=!0,s=!0,i=null){const r=this._scene,n=r.getEngine();i||(i=n.getInputElement()),this._alreadyAttached&&this.detachControl(),i&&(this._alreadyAttachedTo=i),this._deviceSourceManager=new N(n),this._initActionManager=e=>{if(!this._meshPickProceed){const t=r.skipPointerUpPicking||0===r._registeredActions&&!this._checkForPicking()&&!r.onPointerUp?null:r.pick(this._unTranslatedPointerX,this._unTranslatedPointerY,r.pointerUpPredicate,r.pointerUpFastCheck,r.cameraToUseForPointers,r.pointerUpTrianglePredicate);this._currentPickResult=t,t&&(e=t.hit&&t.pickedMesh?t.pickedMesh._getActionManagerForTrigger():null),this._meshPickProceed=!0}return e},this._delayedSimpleClick=(e,t,s)=>{if((Date.now()-this._previousStartingPointerTime>V.DoubleClickDelay&&!this._doubleClickOccured||e!==this._previousButtonPressed)&&(this._doubleClickOccured=!1,t.singleClick=!0,t.ignore=!1,this._delayedClicks[e])){const t=this._delayedClicks[e].evt,s=E.Zp.POINTERTAP,i=new E.mx(s,t,this._currentPickResult);r.onPointerObservable.hasObservers()&&r.onPointerObservable.hasSpecificMask(s)&&r.onPointerObservable.notifyObservers(i,s),this._delayedClicks[e]=null}},this._initClickEvent=(e,t,s,i)=>{const r=new k;this._currentPickResult=null;let n=null,a=e.hasSpecificMask(E.Zp.POINTERPICK)||t.hasSpecificMask(E.Zp.POINTERPICK)||e.hasSpecificMask(E.Zp.POINTERTAP)||t.hasSpecificMask(E.Zp.POINTERTAP)||e.hasSpecificMask(E.Zp.POINTERDOUBLETAP)||t.hasSpecificMask(E.Zp.POINTERDOUBLETAP);!a&&x&&(n=this._initActionManager(n,r),n&&(a=n.hasPickTriggers));let o=!1;if(a){const a=s.button;if(r.hasSwiped=this._isPointerSwiping(),!r.hasSwiped){let h=!V.ExclusiveDoubleClickMode;if(h||(h=!e.hasSpecificMask(E.Zp.POINTERDOUBLETAP)&&!t.hasSpecificMask(E.Zp.POINTERDOUBLETAP),h&&!x.HasSpecificTrigger(6)&&(n=this._initActionManager(n,r),n&&(h=!n.hasSpecificTrigger(6)))),h)(Date.now()-this._previousStartingPointerTime>V.DoubleClickDelay||a!==this._previousButtonPressed)&&(r.singleClick=!0,i(r,this._currentPickResult),o=!0);else{const e={evt:s,clickInfo:r,timeoutId:window.setTimeout(this._delayedSimpleClick.bind(this,a,r,i),V.DoubleClickDelay)};this._delayedClicks[a]=e}let l=e.hasSpecificMask(E.Zp.POINTERDOUBLETAP)||t.hasSpecificMask(E.Zp.POINTERDOUBLETAP);!l&&x.HasSpecificTrigger(6)&&(n=this._initActionManager(n,r),n&&(l=n.hasSpecificTrigger(6))),l&&(a===this._previousButtonPressed&&Date.now()-this._previousStartingPointerTime{if(this._updatePointerPosition(e),this._isSwiping||-1===this._swipeButtonPressed||(this._isSwiping=Math.abs(this._startingPointerPosition.x-this._pointerX)>V.DragMovementThreshold||Math.abs(this._startingPointerPosition.y-this._pointerY)>V.DragMovementThreshold),n.isPointerLock&&n._verifyPointerLock(),this._checkPrePointerObservable(null,e,e.inputIndex>=R.MouseWheelX&&e.inputIndex<=R.MouseWheelZ?E.Zp.POINTERWHEEL:E.Zp.POINTERMOVE))return;if(!r.cameraToUseForPointers&&!r.activeCamera)return;if(r.skipPointerMovePicking)return void this._processPointerMove(new d.G,e);r.pointerMovePredicate||(r.pointerMovePredicate=e=>e.isPickable&&e.isVisible&&e.isReady()&&e.isEnabled()&&(e.enablePointerMoveEvents||r.constantlyUpdateMeshUnderPointer||null!==e._getActionManagerForTrigger())&&(!r.cameraToUseForPointers||0!=(r.cameraToUseForPointers.layerMask&e.layerMask)));const t=r._registeredActions>0||r.constantlyUpdateMeshUnderPointer?this._pickMove(e):null;this._processPointerMove(t,e)},this._onPointerDown=e=>{const t=this._activePointerIds.indexOf(-1);if(-1===t?this._activePointerIds.push(e.pointerId):this._activePointerIds[t]=e.pointerId,this._activePointerIdsCount++,this._pickedDownMesh=null,this._meshPickProceed=!1,V.ExclusiveDoubleClickMode)for(let t=0;te.isPickable&&e.isVisible&&e.isReady()&&e.isEnabled()&&(!r.cameraToUseForPointers||0!=(r.cameraToUseForPointers.layerMask&e.layerMask))),this._pickedDownMesh=null,s=r.skipPointerDownPicking||0===r._registeredActions&&!this._checkForPicking()&&!r.onPointerDown?new d.G:r.pick(this._unTranslatedPointerX,this._unTranslatedPointerY,r.pointerDownPredicate,r.pointerDownFastCheck,r.cameraToUseForPointers,r.pointerDownTrianglePredicate),this._processPointerDown(s,e)},this._onPointerUp=e=>{const t=this._activePointerIds.indexOf(e.pointerId);-1!==t&&(this._activePointerIds[t]=-1,this._activePointerIdsCount--,this._pickedUpMesh=null,this._meshPickProceed=!1,this._updatePointerPosition(e),r.preventDefaultOnPointerUp&&i&&(e.preventDefault(),i.focus()),this._initClickEvent(r.onPrePointerObservable,r.onPointerObservable,e,((t,s)=>{if(r.onPrePointerObservable.hasObservers()&&(this._skipPointerTap=!1,!t.ignore)){if(this._checkPrePointerObservable(null,e,E.Zp.POINTERUP))return this._swipeButtonPressed===e.button&&(this._isSwiping=!1,this._swipeButtonPressed=-1),void(0===e.buttons&&(this._pointerCaptures[e.pointerId]=!1));t.hasSwiped||(t.singleClick&&r.onPrePointerObservable.hasSpecificMask(E.Zp.POINTERTAP)&&this._checkPrePointerObservable(null,e,E.Zp.POINTERTAP)&&(this._skipPointerTap=!0),t.doubleClick&&r.onPrePointerObservable.hasSpecificMask(E.Zp.POINTERDOUBLETAP)&&this._checkPrePointerObservable(null,e,E.Zp.POINTERDOUBLETAP)&&(this._skipPointerTap=!0))}this._pointerCaptures[e.pointerId]?(0===e.buttons&&(this._pointerCaptures[e.pointerId]=!1),(r.cameraToUseForPointers||r.activeCamera)&&(r.pointerUpPredicate||(r.pointerUpPredicate=e=>e.isPickable&&e.isVisible&&e.isReady()&&e.isEnabled()&&(!r.cameraToUseForPointers||0!=(r.cameraToUseForPointers.layerMask&e.layerMask))),!this._meshPickProceed&&(x&&x.HasTriggers||this._checkForPicking()||r.onPointerUp)&&this._initActionManager(null,t),s||(s=this._currentPickResult),this._processPointerUp(s,e,t),this._previousPickResult=this._currentPickResult,this._swipeButtonPressed===e.button&&(this._isSwiping=!1,this._swipeButtonPressed=-1))):this._swipeButtonPressed===e.button&&(this._isSwiping=!1,this._swipeButtonPressed=-1)})))},this._onKeyDown=e=>{const t=S.TB.KEYDOWN;if(r.onPreKeyboardObservable.hasObservers()){const s=new S.Bu(t,e);if(r.onPreKeyboardObservable.notifyObservers(s,t),s.skipOnKeyboardObservable)return}if(r.onKeyboardObservable.hasObservers()){const s=new S.W0(t,e);r.onKeyboardObservable.notifyObservers(s,t)}r.actionManager&&r.actionManager.processTrigger(14,_.CreateNewFromScene(r,e))},this._onKeyUp=e=>{const t=S.TB.KEYUP;if(r.onPreKeyboardObservable.hasObservers()){const s=new S.Bu(t,e);if(r.onPreKeyboardObservable.notifyObservers(s,t),s.skipOnKeyboardObservable)return}if(r.onKeyboardObservable.hasObservers()){const s=new S.W0(t,e);r.onKeyboardObservable.notifyObservers(s,t)}r.actionManager&&r.actionManager.processTrigger(15,_.CreateNewFromScene(r,e))},this._deviceSourceManager.onDeviceConnectedObservable.add((i=>{i.deviceType===A.Mouse?i.onInputChangedObservable.add((r=>{this._originMouseEvent=r,r.inputIndex===R.LeftClick||r.inputIndex===R.MiddleClick||r.inputIndex===R.RightClick||r.inputIndex===R.BrowserBack||r.inputIndex===R.BrowserForward?t&&1===i.getInput(r.inputIndex)?this._onPointerDown(r):e&&0===i.getInput(r.inputIndex)&&this._onPointerUp(r):s&&(r.inputIndex===R.Move?this._onPointerMove(r):r.inputIndex!==R.MouseWheelX&&r.inputIndex!==R.MouseWheelY&&r.inputIndex!==R.MouseWheelZ||this._onPointerMove(r))})):i.deviceType===A.Touch?i.onInputChangedObservable.add((r=>{r.inputIndex===R.LeftClick&&(t&&1===i.getInput(r.inputIndex)?(this._onPointerDown(r),this._activePointerIdsCount>1&&(this._isMultiTouchGesture=!0)):e&&0===i.getInput(r.inputIndex)&&(this._onPointerUp(r),0===this._activePointerIdsCount&&(this._isMultiTouchGesture=!1))),s&&r.inputIndex===R.Move&&this._onPointerMove(r)})):i.deviceType===A.Keyboard&&i.onInputChangedObservable.add((e=>{"keydown"===e.type?this._onKeyDown(e):"keyup"===e.type&&this._onKeyUp(e)}))})),this._alreadyAttached=!0}detachControl(){this._alreadyAttached&&(this._deviceSourceManager.dispose(),this._deviceSourceManager=null,this._alreadyAttachedTo&&!this._scene.doNotHandleCursors&&(this._alreadyAttachedTo.style.cursor=this._scene.defaultCursor),this._alreadyAttached=!1,this._alreadyAttachedTo=null)}setPointerOverMesh(e,t=0,s,i){if(!(this._meshUnderPointerId[t]!==e||e&&e._internalAbstractMeshDataInfo._pointerOverDisableMeshTesting))return;const r=this._meshUnderPointerId[t];let n;r&&(n=r._getActionManagerForTrigger(10),n&&n.processTrigger(10,_.CreateNew(r,i,{pointerId:t}))),e?(this._meshUnderPointerId[t]=e,this._pointerOverMesh=e,n=e._getActionManagerForTrigger(9),n&&n.processTrigger(9,_.CreateNew(e,i,{pointerId:t,pickResult:s}))):(delete this._meshUnderPointerId[t],this._pointerOverMesh=null)}getPointerOverMesh(){return this.meshUnderPointer}_invalidateMesh(e){this._pointerOverMesh===e&&(this._pointerOverMesh=null),this._pickedDownMesh===e&&(this._pickedDownMesh=null),this._pickedUpMesh===e&&(this._pickedUpMesh=null);for(const t in this._meshUnderPointerId)this._meshUnderPointerId[t]===e&&delete this._meshUnderPointerId[t]}}V.DragMovementThreshold=10,V.LongPressDelay=500,V.DoubleClickDelay=300,V.ExclusiveDoubleClickMode=!1;var G=s(4296),z=s(6041),W=s(2572);class H{static get UniqueId(){const e=this._UniqueIdCounter;return this._UniqueIdCounter++,e}}H._UniqueIdCounter=1;var K=s(655),q=s(5515),X=s(7309);class Y{constructor(){this.pointerDownFastCheck=!1,this.pointerUpFastCheck=!1,this.pointerMoveFastCheck=!1,this.skipPointerMovePicking=!1,this.skipPointerDownPicking=!1,this.skipPointerUpPicking=!1}}var j,Z=s(1137),Q=s(6552);!function(e){e[e.BackwardCompatible=0]="BackwardCompatible",e[e.Intermediate=1]="Intermediate",e[e.Aggressive=2]="Aggressive"}(j||(j={}));class ${static DefaultMaterialFactory(e){throw(0,b.n)("StandardMaterial")}static CollisionCoordinatorFactory(){throw(0,b.n)("DefaultCollisionCoordinator")}get clearColor(){return this._clearColor}set clearColor(e){e!==this._clearColor&&(this._clearColor=e,this.onClearColorChangedObservable.notifyObservers(this._clearColor))}get imageProcessingConfiguration(){return this._imageProcessingConfiguration}get performancePriority(){return this._performancePriority}set performancePriority(e){if(e!==this._performancePriority){switch(this._performancePriority=e,e){case 0:this.skipFrustumClipping=!1,this._renderingManager.maintainStateBetweenFrames=!1,this.skipPointerMovePicking=!1,this.autoClear=!0;break;case 1:this.skipFrustumClipping=!1,this._renderingManager.maintainStateBetweenFrames=!1,this.skipPointerMovePicking=!0,this.autoClear=!1;break;case 2:this.skipFrustumClipping=!0,this._renderingManager.maintainStateBetweenFrames=!0,this.skipPointerMovePicking=!0,this.autoClear=!1}this.onScenePerformancePriorityChangedObservable.notifyObservers(e)}}set forceWireframe(e){this._forceWireframe!==e&&(this._forceWireframe=e,this.markAllMaterialsAsDirty(16))}get forceWireframe(){return this._forceWireframe}set skipFrustumClipping(e){this._skipFrustumClipping!==e&&(this._skipFrustumClipping=e)}get skipFrustumClipping(){return this._skipFrustumClipping}set forcePointsCloud(e){this._forcePointsCloud!==e&&(this._forcePointsCloud=e,this.markAllMaterialsAsDirty(16))}get forcePointsCloud(){return this._forcePointsCloud}get environmentTexture(){return this._environmentTexture}set environmentTexture(e){this._environmentTexture!==e&&(this._environmentTexture=e,this.markAllMaterialsAsDirty(1))}getNodes(){let e=[];return e=e.concat(this.meshes),e=e.concat(this.lights),e=e.concat(this.cameras),e=e.concat(this.transformNodes),this.skeletons.forEach((t=>e=e.concat(t.bones))),e}get animationPropertiesOverride(){return this._animationPropertiesOverride}set animationPropertiesOverride(e){this._animationPropertiesOverride=e}set onDispose(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)}set beforeRender(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),e&&(this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e))}set afterRender(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),e&&(this._onAfterRenderObserver=this.onAfterRenderObservable.add(e))}set beforeCameraRender(e){this._onBeforeCameraRenderObserver&&this.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),this._onBeforeCameraRenderObserver=this.onBeforeCameraRenderObservable.add(e)}set afterCameraRender(e){this._onAfterCameraRenderObserver&&this.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver),this._onAfterCameraRenderObserver=this.onAfterCameraRenderObservable.add(e)}get pointerDownPredicate(){return this._pointerPickingConfiguration.pointerDownPredicate}set pointerDownPredicate(e){this._pointerPickingConfiguration.pointerDownPredicate=e}get pointerUpPredicate(){return this._pointerPickingConfiguration.pointerUpPredicate}set pointerUpPredicate(e){this._pointerPickingConfiguration.pointerUpPredicate=e}get pointerMovePredicate(){return this._pointerPickingConfiguration.pointerMovePredicate}set pointerMovePredicate(e){this._pointerPickingConfiguration.pointerMovePredicate=e}get pointerDownFastCheck(){return this._pointerPickingConfiguration.pointerDownFastCheck}set pointerDownFastCheck(e){this._pointerPickingConfiguration.pointerDownFastCheck=e}get pointerUpFastCheck(){return this._pointerPickingConfiguration.pointerUpFastCheck}set pointerUpFastCheck(e){this._pointerPickingConfiguration.pointerUpFastCheck=e}get pointerMoveFastCheck(){return this._pointerPickingConfiguration.pointerMoveFastCheck}set pointerMoveFastCheck(e){this._pointerPickingConfiguration.pointerMoveFastCheck=e}get skipPointerMovePicking(){return this._pointerPickingConfiguration.skipPointerMovePicking}set skipPointerMovePicking(e){this._pointerPickingConfiguration.skipPointerMovePicking=e}get skipPointerDownPicking(){return this._pointerPickingConfiguration.skipPointerDownPicking}set skipPointerDownPicking(e){this._pointerPickingConfiguration.skipPointerDownPicking=e}get skipPointerUpPicking(){return this._pointerPickingConfiguration.skipPointerUpPicking}set skipPointerUpPicking(e){this._pointerPickingConfiguration.skipPointerUpPicking=e}get unTranslatedPointer(){return this._inputManager.unTranslatedPointer}static get DragMovementThreshold(){return V.DragMovementThreshold}static set DragMovementThreshold(e){V.DragMovementThreshold=e}static get LongPressDelay(){return V.LongPressDelay}static set LongPressDelay(e){V.LongPressDelay=e}static get DoubleClickDelay(){return V.DoubleClickDelay}static set DoubleClickDelay(e){V.DoubleClickDelay=e}static get ExclusiveDoubleClickMode(){return V.ExclusiveDoubleClickMode}static set ExclusiveDoubleClickMode(e){V.ExclusiveDoubleClickMode=e}bindEyePosition(e,t="vEyePosition",s=!1){const i=this._forcedViewPosition?this._forcedViewPosition:this._mirroredCameraPosition?this._mirroredCameraPosition:this.activeCamera.globalPosition,r=this.useRightHandedSystem===(null!=this._mirroredCameraPosition);return l.AA.Vector4[0].set(i.x,i.y,i.z,r?-1:1),e&&(s?e.setFloat3(t,l.AA.Vector4[0].x,l.AA.Vector4[0].y,l.AA.Vector4[0].z):e.setVector4(t,l.AA.Vector4[0])),l.AA.Vector4[0]}finalizeSceneUbo(){const e=this.getSceneUniformBuffer(),t=this.bindEyePosition(null);return e.updateFloat4("vEyePosition",t.x,t.y,t.z,t.w),e.update(),e}set useRightHandedSystem(e){this._useRightHandedSystem!==e&&(this._useRightHandedSystem=e,this.markAllMaterialsAsDirty(16))}get useRightHandedSystem(){return this._useRightHandedSystem}setStepId(e){this._currentStepId=e}getStepId(){return this._currentStepId}getInternalStep(){return this._currentInternalStep}set fogEnabled(e){this._fogEnabled!==e&&(this._fogEnabled=e,this.markAllMaterialsAsDirty(16))}get fogEnabled(){return this._fogEnabled}set fogMode(e){this._fogMode!==e&&(this._fogMode=e,this.markAllMaterialsAsDirty(16))}get fogMode(){return this._fogMode}get prePass(){return!!this.prePassRenderer&&this.prePassRenderer.defaultRT.enabled}set shadowsEnabled(e){this._shadowsEnabled!==e&&(this._shadowsEnabled=e,this.markAllMaterialsAsDirty(2))}get shadowsEnabled(){return this._shadowsEnabled}set lightsEnabled(e){this._lightsEnabled!==e&&(this._lightsEnabled=e,this.markAllMaterialsAsDirty(2))}get lightsEnabled(){return this._lightsEnabled}get activeCameras(){return this._activeCameras}set activeCameras(e){this._unObserveActiveCameras&&(this._unObserveActiveCameras(),this._unObserveActiveCameras=null),e&&(this._unObserveActiveCameras=(0,X.lL)(e,(()=>{this.onActiveCamerasChanged.notifyObservers(this)}))),this._activeCameras=e}get activeCamera(){return this._activeCamera}set activeCamera(e){e!==this._activeCamera&&(this._activeCamera=e,this.onActiveCameraChanged.notifyObservers(this))}get defaultMaterial(){return this._defaultMaterial||(this._defaultMaterial=$.DefaultMaterialFactory(this)),this._defaultMaterial}set defaultMaterial(e){this._defaultMaterial=e}set texturesEnabled(e){this._texturesEnabled!==e&&(this._texturesEnabled=e,this.markAllMaterialsAsDirty(1))}get texturesEnabled(){return this._texturesEnabled}get frameGraph(){return this._frameGraph}set frameGraph(e){if(this._frameGraph)return this._frameGraph=e,void(e||(this.customRenderFunction=this._currentCustomRenderFunction));this._frameGraph=e,e&&(this._currentCustomRenderFunction=this.customRenderFunction,this.customRenderFunction=this._renderWithFrameGraph)}set skeletonsEnabled(e){this._skeletonsEnabled!==e&&(this._skeletonsEnabled=e,this.markAllMaterialsAsDirty(8))}get skeletonsEnabled(){return this._skeletonsEnabled}get collisionCoordinator(){return this._collisionCoordinator||(this._collisionCoordinator=$.CollisionCoordinatorFactory(),this._collisionCoordinator.init(this)),this._collisionCoordinator}get renderingManager(){return this._renderingManager}get frustumPlanes(){return this._frustumPlanes}_registerTransientComponents(){if(this._transientComponents.length>0){for(const e of this._transientComponents)e.register();this._transientComponents.length=0}}_addComponent(e){this._components.push(e),this._transientComponents.push(e);const t=e;t.addFromContainer&&t.serialize&&this._serializableComponents.push(t)}_getComponent(e){for(const t of this._components)if(t.name===e)return t;return null}constructor(e,t){this._inputManager=new V(this),this.cameraToUseForPointers=null,this._isScene=!0,this._blockEntityCollection=!1,this.autoClear=!0,this.autoClearDepthAndStencil=!0,this._clearColor=new z.ov(.2,.2,.3,1),this.onClearColorChangedObservable=new n.cP,this.ambientColor=new z.v9(0,0,0),this.environmentIntensity=1,this._performancePriority=0,this.onScenePerformancePriorityChangedObservable=new n.cP,this._forceWireframe=!1,this._skipFrustumClipping=!1,this._forcePointsCloud=!1,this.rootNodes=[],this.cameras=[],this.lights=[],this.meshes=[],this.skeletons=[],this.particleSystems=[],this.animations=[],this.animationGroups=[],this.multiMaterials=[],this.materials=[],this.morphTargetManagers=[],this.geometries=[],this.transformNodes=[],this.actionManagers=[],this.textures=[],this._environmentTexture=null,this.postProcesses=[],this.effectLayers=[],this.sounds=null,this.layers=[],this.lensFlareSystems=[],this.proceduralTextures=[],this.animationsEnabled=!0,this._animationPropertiesOverride=null,this.useConstantAnimationDeltaTime=!1,this.constantlyUpdateMeshUnderPointer=!1,this.hoverCursor="pointer",this.defaultCursor="",this.doNotHandleCursors=!1,this.preventDefaultOnPointerDown=!0,this.preventDefaultOnPointerUp=!0,this.metadata=null,this.reservedDataStore=null,this.disableOfflineSupportExceptionRules=[],this.onDisposeObservable=new n.cP,this._onDisposeObserver=null,this.onBeforeRenderObservable=new n.cP,this._onBeforeRenderObserver=null,this.onAfterRenderObservable=new n.cP,this.onAfterRenderCameraObservable=new n.cP,this._onAfterRenderObserver=null,this.onBeforeAnimationsObservable=new n.cP,this.onAfterAnimationsObservable=new n.cP,this.onBeforeDrawPhaseObservable=new n.cP,this.onAfterDrawPhaseObservable=new n.cP,this.onReadyObservable=new n.cP,this.onBeforeCameraRenderObservable=new n.cP,this._onBeforeCameraRenderObserver=null,this.onAfterCameraRenderObservable=new n.cP,this._onAfterCameraRenderObserver=null,this.onBeforeActiveMeshesEvaluationObservable=new n.cP,this.onAfterActiveMeshesEvaluationObservable=new n.cP,this.onBeforeParticlesRenderingObservable=new n.cP,this.onAfterParticlesRenderingObservable=new n.cP,this.onDataLoadedObservable=new n.cP,this.onNewCameraAddedObservable=new n.cP,this.onCameraRemovedObservable=new n.cP,this.onNewLightAddedObservable=new n.cP,this.onLightRemovedObservable=new n.cP,this.onNewGeometryAddedObservable=new n.cP,this.onGeometryRemovedObservable=new n.cP,this.onNewTransformNodeAddedObservable=new n.cP,this.onTransformNodeRemovedObservable=new n.cP,this.onNewMeshAddedObservable=new n.cP,this.onMeshRemovedObservable=new n.cP,this.onNewSkeletonAddedObservable=new n.cP,this.onSkeletonRemovedObservable=new n.cP,this.onNewMaterialAddedObservable=new n.cP,this.onNewMultiMaterialAddedObservable=new n.cP,this.onMaterialRemovedObservable=new n.cP,this.onMultiMaterialRemovedObservable=new n.cP,this.onNewTextureAddedObservable=new n.cP,this.onTextureRemovedObservable=new n.cP,this.onBeforeRenderTargetsRenderObservable=new n.cP,this.onAfterRenderTargetsRenderObservable=new n.cP,this.onBeforeStepObservable=new n.cP,this.onAfterStepObservable=new n.cP,this.onActiveCameraChanged=new n.cP,this.onActiveCamerasChanged=new n.cP,this.onBeforeRenderingGroupObservable=new n.cP,this.onAfterRenderingGroupObservable=new n.cP,this.onMeshImportedObservable=new n.cP,this.onAnimationFileImportedObservable=new n.cP,this._registeredForLateAnimationBindings=new a.b(256),this._pointerPickingConfiguration=new Y,this.onPrePointerObservable=new n.cP,this.onPointerObservable=new n.cP,this.onPreKeyboardObservable=new n.cP,this.onKeyboardObservable=new n.cP,this._useRightHandedSystem=!1,this._timeAccumulator=0,this._currentStepId=0,this._currentInternalStep=0,this._fogEnabled=!0,this._fogMode=$.FOGMODE_NONE,this.fogColor=new z.v9(.2,.2,.3),this.fogDensity=.1,this.fogStart=0,this.fogEnd=1e3,this.needsPreviousWorldMatrices=!1,this._shadowsEnabled=!0,this._lightsEnabled=!0,this._unObserveActiveCameras=null,this._texturesEnabled=!0,this._frameGraph=null,this.physicsEnabled=!0,this.particlesEnabled=!0,this.spritesEnabled=!0,this._skeletonsEnabled=!0,this.lensFlaresEnabled=!0,this.collisionsEnabled=!0,this.gravity=new l.Pq(0,-9.807,0),this.postProcessesEnabled=!0,this.renderTargetsEnabled=!0,this.dumpNextRenderTargets=!1,this.customRenderTargets=[],this.importedMeshesFiles=[],this.probesEnabled=!0,this._meshesForIntersections=new a.b(256),this.proceduralTexturesEnabled=!0,this._totalVertices=new G.A,this._activeIndices=new G.A,this._activeParticles=new G.A,this._activeBones=new G.A,this._animationTime=0,this.animationTimeScale=1,this._renderId=0,this._frameId=0,this._executeWhenReadyTimeoutId=null,this._intermediateRendering=!1,this._defaultFrameBufferCleared=!1,this._viewUpdateFlag=-1,this._projectionUpdateFlag=-1,this._toBeDisposed=new Array(256),this._activeRequests=new Array,this._pendingData=new Array,this._isDisposed=!1,this.dispatchAllSubMeshesOfActiveMeshes=!1,this._activeMeshes=new a.L(256),this._processedMaterials=new a.L(256),this._renderTargets=new a.b(256),this._materialsRenderTargets=new a.b(256),this._activeParticleSystems=new a.L(256),this._activeSkeletons=new a.b(32),this._softwareSkinnedMeshes=new a.b(32),this._activeAnimatables=new Array,this._transformMatrix=l.uq.Zero(),this.requireLightSorting=!1,this._components=[],this._serializableComponents=[],this._transientComponents=[],this._beforeCameraUpdateStage=g.B.Create(),this._beforeClearStage=g.B.Create(),this._beforeRenderTargetClearStage=g.B.Create(),this._gatherRenderTargetsStage=g.B.Create(),this._gatherActiveCameraRenderTargetsStage=g.B.Create(),this._isReadyForMeshStage=g.B.Create(),this._beforeEvaluateActiveMeshStage=g.B.Create(),this._evaluateSubMeshStage=g.B.Create(),this._preActiveMeshStage=g.B.Create(),this._cameraDrawRenderTargetStage=g.B.Create(),this._beforeCameraDrawStage=g.B.Create(),this._beforeRenderTargetDrawStage=g.B.Create(),this._beforeRenderingGroupDrawStage=g.B.Create(),this._beforeRenderingMeshStage=g.B.Create(),this._afterRenderingMeshStage=g.B.Create(),this._afterRenderingGroupDrawStage=g.B.Create(),this._afterCameraDrawStage=g.B.Create(),this._afterCameraPostProcessStage=g.B.Create(),this._afterRenderTargetDrawStage=g.B.Create(),this._afterRenderTargetPostProcessStage=g.B.Create(),this._afterRenderStage=g.B.Create(),this._pointerMoveStage=g.B.Create(),this._pointerDownStage=g.B.Create(),this._pointerUpStage=g.B.Create(),this._geometriesByUniqueId=null,this._defaultMeshCandidates={data:[],length:0},this._defaultSubMeshCandidates={data:[],length:0},this._preventFreeActiveMeshesAndRenderingGroups=!1,this._activeMeshesFrozen=!1,this._activeMeshesFrozenButKeepClipping=!1,this._skipEvaluateActiveMeshesCompletely=!1,this._allowPostProcessClearColor=!0,this.getDeterministicFrameTime=()=>this._engine.getTimeStep(),this._registeredActions=0,this._blockMaterialDirtyMechanism=!1,this._perfCollector=null,this.activeCameras=[];const s={useGeometryUniqueIdsMap:!0,useMaterialMeshMap:!0,useClonedMeshMap:!0,virtual:!1,...t};e=this._engine=e||T.q.LastCreatedEngine,s.virtual?e._virtualScenes.push(this):(T.q._LastCreatedScene=this,e.scenes.push(this)),this._uid=null,this._renderingManager=new p.m(this),f.X&&(this.postProcessManager=new f.X(this)),(0,m.BA)()&&this.attachControl(),this._createUbo(),c.p&&(this._imageProcessingConfiguration=new c.p),this.setDefaultCandidateProviders(),s.useGeometryUniqueIdsMap&&(this._geometriesByUniqueId={}),this.useMaterialMeshMap=s.useMaterialMeshMap,this.useClonedMeshMap=s.useClonedMeshMap,t&&t.virtual||e.onNewSceneAddedObservable.notifyObservers(this)}getClassName(){return"Scene"}_getDefaultMeshCandidates(){return this._defaultMeshCandidates.data=this.meshes,this._defaultMeshCandidates.length=this.meshes.length,this._defaultMeshCandidates}_getDefaultSubMeshCandidates(e){return this._defaultSubMeshCandidates.data=e.subMeshes,this._defaultSubMeshCandidates.length=e.subMeshes.length,this._defaultSubMeshCandidates}setDefaultCandidateProviders(){this.getActiveMeshCandidates=()=>this._getDefaultMeshCandidates(),this.getActiveSubMeshCandidates=e=>this._getDefaultSubMeshCandidates(e),this.getIntersectingSubMeshCandidates=(e,t)=>this._getDefaultSubMeshCandidates(e),this.getCollidingSubMeshCandidates=(e,t)=>this._getDefaultSubMeshCandidates(e)}get meshUnderPointer(){return this._inputManager.meshUnderPointer}get pointerX(){return this._inputManager.pointerX}set pointerX(e){this._inputManager.pointerX=e}get pointerY(){return this._inputManager.pointerY}set pointerY(e){this._inputManager.pointerY=e}getCachedMaterial(){return this._cachedMaterial}getCachedEffect(){return this._cachedEffect}getCachedVisibility(){return this._cachedVisibility}isCachedMaterialInvalid(e,t,s=1){return this._cachedEffect!==t||this._cachedMaterial!==e||this._cachedVisibility!==s}getEngine(){return this._engine}getTotalVertices(){return this._totalVertices.current}get totalVerticesPerfCounter(){return this._totalVertices}getActiveIndices(){return this._activeIndices.current}get totalActiveIndicesPerfCounter(){return this._activeIndices}getActiveParticles(){return this._activeParticles.current}get activeParticlesPerfCounter(){return this._activeParticles}getActiveBones(){return this._activeBones.current}get activeBonesPerfCounter(){return this._activeBones}getActiveMeshes(){return this._activeMeshes}getAnimationRatio(){return void 0!==this._animationRatio?this._animationRatio:1}getRenderId(){return this._renderId}getFrameId(){return this._frameId}incrementRenderId(){this._renderId++}_createUbo(){this.setSceneUniformBuffer(this.createSceneUniformBuffer())}simulatePointerMove(e,t){return this._inputManager.simulatePointerMove(e,t),this}simulatePointerDown(e,t){return this._inputManager.simulatePointerDown(e,t),this}simulatePointerUp(e,t,s){return this._inputManager.simulatePointerUp(e,t,s),this}isPointerCaptured(e=0){return this._inputManager.isPointerCaptured(e)}attachControl(e=!0,t=!0,s=!0){this._inputManager.attachControl(e,t,s)}detachControl(){this._inputManager.detachControl()}isReady(e=!0){if(this._isDisposed)return!1;let t;const s=this.getEngine(),i=s.currentRenderPassId;s.currentRenderPassId=this.activeCamera?.renderPassId??i;let r=!0;for(this._pendingData.length>0&&(r=!1),this.prePassRenderer?.update(),this.useOrderIndependentTransparency&&this.depthPeelingRenderer&&r&&(r=this.depthPeelingRenderer.isReady()),e&&(this._processedMaterials.reset(),this._materialsRenderTargets.reset()),t=0;t0;for(const e of this._isReadyForMeshStage)e.action(i,n)||(r=!1);if(!e)continue;const a=i.material||this.defaultMaterial;if(a)if(a._storeEffectOnSubMeshes)for(const e of i.subMeshes){const t=e.getMaterial();t&&t.hasRenderTargetTextures&&null!=t.getRenderTargetTextures&&-1===this._processedMaterials.indexOf(t)&&(this._processedMaterials.push(t),this._materialsRenderTargets.concatWithNoDuplicate(t.getRenderTargetTextures()))}else a.hasRenderTargetTextures&&null!=a.getRenderTargetTextures&&-1===this._processedMaterials.indexOf(a)&&(this._processedMaterials.push(a),this._materialsRenderTargets.concatWithNoDuplicate(a.getRenderTargetTextures()))}if(e)for(t=0;t0)for(const e of this.activeCameras)e.isReady(!0)||(r=!1);else this.activeCamera&&(this.activeCamera.isReady(!0)||(r=!1));for(const e of this.particleSystems)e.isReady()||(r=!1);if(this.layers)for(const e of this.layers)e.isReady()||(r=!1);return s.areAllEffectsReady()||(r=!1),s.currentRenderPassId=i,r}resetCachedMaterial(){this._cachedMaterial=null,this._cachedEffect=null,this._cachedVisibility=null}registerBeforeRender(e){this.onBeforeRenderObservable.add(e)}unregisterBeforeRender(e){this.onBeforeRenderObservable.removeCallback(e)}registerAfterRender(e){this.onAfterRenderObservable.add(e)}unregisterAfterRender(e){this.onAfterRenderObservable.removeCallback(e)}_executeOnceBeforeRender(e){const t=()=>{e(),setTimeout((()=>{this.unregisterBeforeRender(t)}))};this.registerBeforeRender(t)}executeOnceBeforeRender(e,t){void 0!==t?setTimeout((()=>{this._executeOnceBeforeRender(e)}),t):this._executeOnceBeforeRender(e)}addPendingData(e){this._pendingData.push(e)}removePendingData(e){const t=this.isLoading,s=this._pendingData.indexOf(e);-1!==s&&this._pendingData.splice(s,1),t&&!this.isLoading&&this.onDataLoadedObservable.notifyObservers(this)}getWaitingItemsCount(){return this._pendingData.length}get isLoading(){return this._pendingData.length>0}executeWhenReady(e,t=!1){this.onReadyObservable.addOnce(e),null===this._executeWhenReadyTimeoutId&&this._checkIsReady(t)}whenReadyAsync(e=!1){return new Promise((t=>{this.executeWhenReady((()=>{t()}),e)}))}_checkIsReady(e=!1){return this._registerTransientComponents(),this.isReady(e)?(this.onReadyObservable.notifyObservers(this),this.onReadyObservable.clear(),void(this._executeWhenReadyTimeoutId=null)):this._isDisposed?(this.onReadyObservable.clear(),void(this._executeWhenReadyTimeoutId=null)):void(this._executeWhenReadyTimeoutId=setTimeout((()=>{this.incrementRenderId(),this._checkIsReady(e)}),100))}get animatables(){return this._activeAnimatables}resetLastAnimationTimeFrame(){this._animationTimeLast=r.j.Now}getViewMatrix(){return this._viewMatrix}getProjectionMatrix(){return this._projectionMatrix}getTransformMatrix(){return this._transformMatrix}setTransformMatrix(e,t,s,i){s||i||!this._multiviewSceneUbo||(this._multiviewSceneUbo.dispose(),this._multiviewSceneUbo=null),this._viewUpdateFlag===e.updateFlag&&this._projectionUpdateFlag===t.updateFlag||(this._viewUpdateFlag=e.updateFlag,this._projectionUpdateFlag=t.updateFlag,this._viewMatrix=e,this._projectionMatrix=t,this._viewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix),this._frustumPlanes?W.P.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=W.P.GetPlanes(this._transformMatrix),this._multiviewSceneUbo&&this._multiviewSceneUbo.useUbo?this._updateMultiviewUbo(s,i):this._sceneUbo.useUbo&&(this._sceneUbo.updateMatrix("viewProjection",this._transformMatrix),this._sceneUbo.updateMatrix("view",this._viewMatrix),this._sceneUbo.updateMatrix("projection",this._projectionMatrix)))}getSceneUniformBuffer(){return this._multiviewSceneUbo?this._multiviewSceneUbo:this._sceneUbo}createSceneUniformBuffer(e){const t=new u.D(this._engine,void 0,!1,e??"scene");return t.addUniform("viewProjection",16),t.addUniform("view",16),t.addUniform("projection",16),t.addUniform("vEyePosition",4),t}setSceneUniformBuffer(e){this._sceneUbo=e,this._viewUpdateFlag=-1,this._projectionUpdateFlag=-1}getUniqueId(){return H.UniqueId}addMesh(e,t=!1){this._blockEntityCollection||(this.meshes.push(e),e._resyncLightSources(),e.parent||e._addToSceneRootNodes(),i.S0.SetImmediate((()=>{this.onNewMeshAddedObservable.notifyObservers(e)})),t&&e.getChildMeshes().forEach((e=>{this.addMesh(e)})))}removeMesh(e,t=!1){const s=this.meshes.indexOf(e);return-1!==s&&(this.meshes.splice(s,1),e.parent||e._removeFromSceneRootNodes()),this._inputManager._invalidateMesh(e),this.onMeshRemovedObservable.notifyObservers(e),t&&e.getChildMeshes().forEach((e=>{this.removeMesh(e)})),s}addTransformNode(e){this._blockEntityCollection||e.getScene()===this&&-1!==e._indexInSceneTransformNodesArray||(e._indexInSceneTransformNodesArray=this.transformNodes.length,this.transformNodes.push(e),e.parent||e._addToSceneRootNodes(),this.onNewTransformNodeAddedObservable.notifyObservers(e))}removeTransformNode(e){const t=e._indexInSceneTransformNodesArray;if(-1!==t){if(t!==this.transformNodes.length-1){const e=this.transformNodes[this.transformNodes.length-1];this.transformNodes[t]=e,e._indexInSceneTransformNodesArray=t}e._indexInSceneTransformNodesArray=-1,this.transformNodes.pop(),e.parent||e._removeFromSceneRootNodes()}return this.onTransformNodeRemovedObservable.notifyObservers(e),t}removeSkeleton(e){const t=this.skeletons.indexOf(e);return-1!==t&&(this.skeletons.splice(t,1),this.onSkeletonRemovedObservable.notifyObservers(e),this._executeActiveContainerCleanup(this._activeSkeletons)),t}removeMorphTargetManager(e){const t=this.morphTargetManagers.indexOf(e);return-1!==t&&this.morphTargetManagers.splice(t,1),t}removeLight(e){const t=this.lights.indexOf(e);if(-1!==t){for(const t of this.meshes)t._removeLightSource(e,!1);this.lights.splice(t,1),this.sortLightsByPriority(),e.parent||e._removeFromSceneRootNodes()}return this.onLightRemovedObservable.notifyObservers(e),t}removeCamera(e){const t=this.cameras.indexOf(e);if(-1!==t&&(this.cameras.splice(t,1),e.parent||e._removeFromSceneRootNodes()),this.activeCameras){const t=this.activeCameras.indexOf(e);-1!==t&&this.activeCameras.splice(t,1)}return this.activeCamera===e&&(this.cameras.length>0?this.activeCamera=this.cameras[0]:this.activeCamera=null),this.onCameraRemovedObservable.notifyObservers(e),t}removeParticleSystem(e){const t=this.particleSystems.indexOf(e);return-1!==t&&(this.particleSystems.splice(t,1),this._executeActiveContainerCleanup(this._activeParticleSystems)),t}removeAnimation(e){const t=this.animations.indexOf(e);return-1!==t&&this.animations.splice(t,1),t}stopAnimation(e,t,s){}removeAnimationGroup(e){const t=this.animationGroups.indexOf(e);return-1!==t&&this.animationGroups.splice(t,1),t}removeMultiMaterial(e){const t=this.multiMaterials.indexOf(e);return-1!==t&&this.multiMaterials.splice(t,1),this.onMultiMaterialRemovedObservable.notifyObservers(e),t}removeMaterial(e){const t=e._indexInSceneMaterialArray;if(-1!==t&&t{this.onNewLightAddedObservable.notifyObservers(e)}))}}sortLightsByPriority(){this.requireLightSorting&&this.lights.sort(q.c.CompareLightsPriority)}addCamera(e){this._blockEntityCollection||(this.cameras.push(e),i.S0.SetImmediate((()=>{this.onNewCameraAddedObservable.notifyObservers(e)})),e.parent||e._addToSceneRootNodes())}addSkeleton(e){this._blockEntityCollection||(this.skeletons.push(e),i.S0.SetImmediate((()=>{this.onNewSkeletonAddedObservable.notifyObservers(e)})))}addParticleSystem(e){this._blockEntityCollection||this.particleSystems.push(e)}addAnimation(e){this._blockEntityCollection||this.animations.push(e)}addAnimationGroup(e){this._blockEntityCollection||this.animationGroups.push(e)}addMultiMaterial(e){this._blockEntityCollection||(this.multiMaterials.push(e),i.S0.SetImmediate((()=>{this.onNewMultiMaterialAddedObservable.notifyObservers(e)})))}addMaterial(e){this._blockEntityCollection||e.getScene()===this&&-1!==e._indexInSceneMaterialArray||(e._indexInSceneMaterialArray=this.materials.length,this.materials.push(e),i.S0.SetImmediate((()=>{this.onNewMaterialAddedObservable.notifyObservers(e)})))}addMorphTargetManager(e){this._blockEntityCollection||this.morphTargetManagers.push(e)}addGeometry(e){this._blockEntityCollection||(this._geometriesByUniqueId&&(this._geometriesByUniqueId[e.uniqueId]=this.geometries.length),this.geometries.push(e))}addActionManager(e){this.actionManagers.push(e)}addTexture(e){this._blockEntityCollection||(this.textures.push(e),this.onNewTextureAddedObservable.notifyObservers(e))}switchActiveCamera(e,t=!0){this._engine.getInputElement()&&(this.activeCamera&&this.activeCamera.detachControl(),this.activeCamera=e,t&&e.attachControl())}setActiveCameraById(e){const t=this.getCameraById(e);return t?(this.activeCamera=t,t):null}setActiveCameraByName(e){const t=this.getCameraByName(e);return t?(this.activeCamera=t,t):null}getAnimationGroupByName(e){for(let t=0;tt.uniqueId===e))}getMaterialById(e,t=!1){return this._getMaterial(t,(t=>t.id===e))}getMaterialByName(e,t=!1){return this._getMaterial(t,(t=>t.name===e))}getLastMaterialById(e,t=!1){for(let t=this.materials.length-1;t>=0;t--)if(this.materials[t].id===e)return this.materials[t];if(t)for(let t=this.multiMaterials.length-1;t>=0;t--)if(this.multiMaterials[t].id===e)return this.multiMaterials[t];return null}getTextureByUniqueId(e){for(let t=0;t{this.onNewGeometryAddedObservable.notifyObservers(e)})),0))}removeGeometry(e){let t;if(this._geometriesByUniqueId){if(t=this._geometriesByUniqueId[e.uniqueId],void 0===t)return!1}else if(t=this.geometries.indexOf(e),t<0)return!1;if(t!==this.geometries.length-1){const e=this.geometries[this.geometries.length-1];e&&(this.geometries[t]=e,this._geometriesByUniqueId&&(this._geometriesByUniqueId[e.uniqueId]=t))}return this._geometriesByUniqueId&&(this._geometriesByUniqueId[e.uniqueId]=void 0),this.geometries.pop(),this.onGeometryRemovedObservable.notifyObservers(e),!0}getGeometries(){return this.geometries}getMeshById(e){for(let t=0;t=0;t--)if(this.meshes[t].id===e)return this.meshes[t];return null}getLastTransformNodeById(e){for(let t=this.transformNodes.length-1;t>=0;t--)if(this.transformNodes[t].id===e)return this.transformNodes[t];return null}getLastEntryById(e){let t;for(t=this.meshes.length-1;t>=0;t--)if(this.meshes[t].id===e)return this.meshes[t];for(t=this.transformNodes.length-1;t>=0;t--)if(this.transformNodes[t].id===e)return this.transformNodes[t];for(t=this.cameras.length-1;t>=0;t--)if(this.cameras[t].id===e)return this.cameras[t];for(t=this.lights.length-1;t>=0;t--)if(this.lights[t].id===e)return this.lights[t];return null}getNodeById(e){const t=this.getMeshById(e);if(t)return t;const s=this.getTransformNodeById(e);if(s)return s;const i=this.getLightById(e);if(i)return i;const r=this.getCameraById(e);if(r)return r;return this.getBoneById(e)||null}getNodeByName(e){const t=this.getMeshByName(e);if(t)return t;const s=this.getTransformNodeByName(e);if(s)return s;const i=this.getLightByName(e);if(i)return i;const r=this.getCameraByName(e);if(r)return r;return this.getBoneByName(e)||null}getMeshByName(e){for(let t=0;t=0;t--)if(this.skeletons[t].id===e)return this.skeletons[t];return null}getSkeletonByUniqueId(e){for(let t=0;t{if(this.activeCamera){if(this._frustumPlanes||this.updateTransformMatrix(),this._evaluateActiveMeshes(),this._activeMeshesFrozen=!0,this._activeMeshesFrozenButKeepClipping=r,this._skipEvaluateActiveMeshesCompletely=e,i)for(let e=0;ee.dispose()))}_evaluateActiveMeshes(){if(this._engine.snapshotRendering&&1===this._engine.snapshotRenderingMode)return void(this._activeMeshes.length>0&&(this.activeCamera?._activeMeshes.reset(),this._activeMeshes.reset(),this._renderingManager.reset(),this._processedMaterials.reset(),this._activeParticleSystems.reset(),this._activeSkeletons.reset(),this._softwareSkinnedMeshes.reset()));if(this._activeMeshesFrozen&&this._activeMeshes.length){if(!this._skipEvaluateActiveMeshesCompletely){const e=this._activeMeshes.length;for(let t=0;t0&&0!=(t.layerMask&this.activeCamera.layerMask)&&(this._skipFrustumClipping||t.alwaysSelectAsActiveMesh||t.isInFrustum(this._frustumPlanes)))){this._activeMeshes.push(t),this.activeCamera._activeMeshes.push(t),i!==t&&i._activate(this._renderId,!1);for(const e of this._preActiveMeshStage)e.action(t);t._activate(this._renderId,!1)&&(t.isAnInstance?t._internalAbstractMeshDataInfo._actAsRegularMesh&&(i=t):i._internalAbstractMeshDataInfo._onlyForInstances=!1,i._internalAbstractMeshDataInfo._isActive=!0,this._activeMesh(t,i)),t._postActivate()}}if(this.onAfterActiveMeshesEvaluationObservable.notifyObservers(this),this.particlesEnabled){this.onBeforeParticlesRenderingObservable.notifyObservers(this);for(let e=0;e0){const i=this.getActiveSubMeshCandidates(t),r=i.length;s=s||1===r;for(let n=0;n0&&this._renderTargets.concatWithNoDuplicate(e.customRenderTargets),t&&t.customRenderTargets&&t.customRenderTargets.length>0&&this._renderTargets.concatWithNoDuplicate(t.customRenderTargets),this.environmentTexture&&this.environmentTexture.isRenderTarget&&this._renderTargets.pushNoDuplicate(this.environmentTexture);for(const e of this._gatherActiveCameraRenderTargetsStage)e.action(this._renderTargets);let n=!1;if(this.renderTargetsEnabled){if(this._intermediateRendering=!0,this._renderTargets.length>0){i.S0.StartPerformanceCounter("Render targets",this._renderTargets.length>0);for(let e=0;e0),this._renderId++}for(const e of this._cameraDrawRenderTargetStage)n=e.action(this.activeCamera)||n;this._intermediateRendering=!1}this._engine.currentRenderPassId=e.outputRenderTarget?.renderPassId??e.renderPassId??0,n&&!this.prePass&&(this._bindFrameBuffer(this._activeCamera,!1),this.updateTransformMatrix()),this.onAfterRenderTargetsRenderObservable.notifyObservers(this),!this.postProcessManager||e._multiviewTexture||this.prePass||this.postProcessManager._prepareFrame();for(const e of this._beforeCameraDrawStage)e.action(this.activeCamera);this.onBeforeDrawPhaseObservable.notifyObservers(this),r.snapshotRendering&&1===r.snapshotRenderingMode&&this.finalizeSceneUbo(),this._renderingManager.render(null,null,!0,!0),this.onAfterDrawPhaseObservable.notifyObservers(this);for(const e of this._afterCameraDrawStage)e.action(this.activeCamera);if(this.postProcessManager&&!e._multiviewTexture){const t=e.outputRenderTarget?e.outputRenderTarget.renderTarget:void 0;this.postProcessManager._finalizeFrame(e.isIntermediate,t)}for(const e of this._afterCameraPostProcessStage)e.action(this.activeCamera);this._renderTargets.reset(),this.onAfterCameraRenderObservable.notifyObservers(this.activeCamera)}_processSubCameras(e,t=!0){if(0===e.cameraRigMode||e._renderingMultiview)return e._renderingMultiview&&!this._multiviewSceneUbo&&this._createMultiviewUbo(),this._renderForCamera(e,void 0,t),void this.onAfterRenderCameraObservable.notifyObservers(e);if(e._useMultiviewToSingleView)this._renderMultiviewToSingleView(e);else{this.onBeforeCameraRenderObservable.notifyObservers(e);for(let t=0;t-1&&(13===s.trigger&&s._executeCurrent(_.CreateNew(t,void 0,i)),t.actionManager.hasSpecificTrigger(13,(e=>{const t=e.mesh?e.mesh:e;return i===t}))&&13!==s.trigger||t._intersectionsInProgress.splice(n,1))}}}}_advancePhysicsEngineStep(e){}_animate(e){}animate(){if(this._engine.isDeterministicLockStep()){let e=Math.max($.MinDeltaTime,Math.min(this._engine.getDeltaTime(),$.MaxDeltaTime))+this._timeAccumulator;const t=this._engine.getTimeStep(),s=1e3/t/1e3;let i=0;const r=this._engine.getLockstepMaxSteps();let n=Math.floor(e/t);for(n=Math.min(n,r);e>0&&i0)for(let e=0;e0),this._intermediateRendering=!0;for(let s=0;s0),this._intermediateRendering=!1,this._renderId++}this._engine.currentRenderPassId=t?.renderPassId??0,this.activeCamera=t,this._activeCamera&&22!==this._activeCamera.cameraRigMode&&!this.prePass&&this._bindFrameBuffer(this._activeCamera,!1),this.onAfterRenderTargetsRenderObservable.notifyObservers(this);for(const e of this._beforeClearStage)e.action();this._clearFrameBuffer(this.activeCamera);for(const e of this._gatherRenderTargetsStage)e.action(this._renderTargets);if(this.activeCameras&&this.activeCameras.length>0)for(let e=0;e0);else{if(!this.activeCamera)throw new Error("No camera defined");this._processSubCameras(this.activeCamera,!!this.activeCamera.outputRenderTarget)}}this._checkIntersections();for(const e of this._afterRenderStage)e.action();if(this.afterRender&&this.afterRender(),this.onAfterRenderObservable.notifyObservers(this),this._toBeDisposed.length){for(let e=0;e{e.onAnimationEndObservable.clear(),e.onAnimationEnd=null})),this.stopAllAnimations()),this.resetCachedMaterial(),this.activeCamera&&(this.activeCamera._activeMeshes.dispose(),this.activeCamera=null),this.activeCameras=null,this._activeMeshes.dispose(),this._renderingManager.dispose(),this._processedMaterials.dispose(),this._activeParticleSystems.dispose(),this._activeSkeletons.dispose(),this._softwareSkinnedMeshes.dispose(),this._renderTargets.dispose(),this._materialsRenderTargets.dispose(),this._registeredForLateAnimationBindings.dispose(),this._meshesForIntersections.dispose(),this._toBeDisposed.length=0;const e=this._activeRequests.slice();for(const t of e)t.abort();this._activeRequests.length=0;try{this.onDisposeObservable.notifyObservers(this)}catch(e){Z.V.Error("An error occurred while calling onDisposeObservable!",e)}if(this.detachControl(),this._engine.getInputElement())for(let e=0;ee.dispose(!0))),this._disposeList(this.transformNodes,(e=>e.dispose(!0)));const t=this.cameras;this._disposeList(t),this._defaultMaterial&&this._defaultMaterial.dispose(),this._disposeList(this.multiMaterials),this._disposeList(this.materials),this._disposeList(this.particleSystems),this._disposeList(this.postProcesses),this._disposeList(this.textures),this._disposeList(this.morphTargetManagers),this._sceneUbo.dispose(),this._multiviewSceneUbo&&this._multiviewSceneUbo.dispose(),this.postProcessManager.dispose(),this._disposeList(this._components);let s=this._engine.scenes.indexOf(this);s>-1&&this._engine.scenes.splice(s,1),T.q._LastCreatedScene===this&&(this._engine.scenes.length>0?T.q._LastCreatedScene=this._engine.scenes[this._engine.scenes.length-1]:T.q._LastCreatedScene=null),s=this._engine._virtualScenes.indexOf(this),s>-1&&this._engine._virtualScenes.splice(s,1),this._engine.wipeCaches(!0),this.onDisposeObservable.clear(),this.onBeforeRenderObservable.clear(),this.onAfterRenderObservable.clear(),this.onBeforeRenderTargetsRenderObservable.clear(),this.onAfterRenderTargetsRenderObservable.clear(),this.onAfterStepObservable.clear(),this.onBeforeStepObservable.clear(),this.onBeforeActiveMeshesEvaluationObservable.clear(),this.onAfterActiveMeshesEvaluationObservable.clear(),this.onBeforeParticlesRenderingObservable.clear(),this.onAfterParticlesRenderingObservable.clear(),this.onBeforeDrawPhaseObservable.clear(),this.onAfterDrawPhaseObservable.clear(),this.onBeforeAnimationsObservable.clear(),this.onAfterAnimationsObservable.clear(),this.onDataLoadedObservable.clear(),this.onBeforeRenderingGroupObservable.clear(),this.onAfterRenderingGroupObservable.clear(),this.onMeshImportedObservable.clear(),this.onBeforeCameraRenderObservable.clear(),this.onAfterCameraRenderObservable.clear(),this.onAfterRenderCameraObservable.clear(),this.onReadyObservable.clear(),this.onNewCameraAddedObservable.clear(),this.onCameraRemovedObservable.clear(),this.onNewLightAddedObservable.clear(),this.onLightRemovedObservable.clear(),this.onNewGeometryAddedObservable.clear(),this.onGeometryRemovedObservable.clear(),this.onNewTransformNodeAddedObservable.clear(),this.onTransformNodeRemovedObservable.clear(),this.onNewMeshAddedObservable.clear(),this.onMeshRemovedObservable.clear(),this.onNewSkeletonAddedObservable.clear(),this.onSkeletonRemovedObservable.clear(),this.onNewMaterialAddedObservable.clear(),this.onNewMultiMaterialAddedObservable.clear(),this.onMaterialRemovedObservable.clear(),this.onMultiMaterialRemovedObservable.clear(),this.onNewTextureAddedObservable.clear(),this.onTextureRemovedObservable.clear(),this.onPrePointerObservable.clear(),this.onPointerObservable.clear(),this.onPreKeyboardObservable.clear(),this.onKeyboardObservable.clear(),this.onActiveCameraChanged.clear(),this.onScenePerformancePriorityChangedObservable.clear(),this.onClearColorChangedObservable.clear(),this._isDisposed=!0}_disposeList(e,t){const s=e.slice(0);t=t??(e=>e.dispose());for(const e of s)t(e);e.length=0}get isDisposed(){return this._isDisposed}clearCachedVertexData(){for(let e=0;e!0),this.meshes.filter(e).forEach((e=>{if(e.computeWorldMatrix(!0),!e.subMeshes||0===e.subMeshes.length||e.infiniteDistance)return;const i=e.getBoundingInfo(),r=i.boundingBox.minimumWorld,n=i.boundingBox.maximumWorld;l.Pq.CheckExtends(r,t,s),l.Pq.CheckExtends(n,t,s)})),{min:t,max:s}}createPickingRay(e,t,s,i,r=!1){throw(0,b.n)("Ray")}createPickingRayToRef(e,t,s,i,r,n=!1,a=!1){throw(0,b.n)("Ray")}createPickingRayInCameraSpace(e,t,s){throw(0,b.n)("Ray")}createPickingRayInCameraSpaceToRef(e,t,s,i){throw(0,b.n)("Ray")}pick(e,t,s,i,r,n){const a=(0,b.n)("Ray",!0);return a&&Z.V.Warn(a),new d.G}pickWithBoundingInfo(e,t,s,i,r){const n=(0,b.n)("Ray",!0);return n&&Z.V.Warn(n),new d.G}pickWithRay(e,t,s,i){throw(0,b.n)("Ray")}multiPick(e,t,s,i,r){throw(0,b.n)("Ray")}multiPickWithRay(e,t,s){throw(0,b.n)("Ray")}setPointerOverMesh(e,t,s){this._inputManager.setPointerOverMesh(e,t,s)}getPointerOverMesh(){return this._inputManager.getPointerOverMesh()}_rebuildGeometries(){for(const e of this.geometries)e._rebuild();for(const e of this.meshes)e._rebuild();this.postProcessManager&&this.postProcessManager._rebuild();for(const e of this._components)e.rebuild();for(const e of this.particleSystems)e.rebuild();if(this.spriteManagers)for(const e of this.spriteManagers)e.rebuild()}_rebuildTextures(){for(const e of this.textures)e._rebuild(!0);this.markAllMaterialsAsDirty(1)}_getByTags(e,t,s){if(void 0===t)return e;const i=[];for(const r in e){const n=e[r];h.Y&&h.Y.MatchesQuery(n,t)&&(!s||s(n))&&i.push(n)}return i}getMeshesByTags(e,t){return this._getByTags(this.meshes,e,t)}getCamerasByTags(e,t){return this._getByTags(this.cameras,e,t)}getLightsByTags(e,t){return this._getByTags(this.lights,e,t)}getMaterialByTags(e,t){return this._getByTags(this.materials,e,t).concat(this._getByTags(this.multiMaterials,e,t))}getTransformNodesByTags(e,t){return this._getByTags(this.transformNodes,e,t)}setRenderingOrder(e,t=null,s=null,i=null){this._renderingManager.setRenderingOrder(e,t,s,i)}setRenderingAutoClearDepthStencil(e,t,s=!0,i=!0){this._renderingManager.setRenderingAutoClearDepthStencil(e,t,s,i)}getAutoClearDepthStencilSetup(e){return this._renderingManager.getAutoClearDepthStencilSetup(e)}_forceBlockMaterialDirtyMechanism(e){this._blockMaterialDirtyMechanism=e}get blockMaterialDirtyMechanism(){return this._blockMaterialDirtyMechanism}set blockMaterialDirtyMechanism(e){this._blockMaterialDirtyMechanism!==e&&(this._blockMaterialDirtyMechanism=e,e||this.markAllMaterialsAsDirty(63))}markAllMaterialsAsDirty(e,t){if(!this._blockMaterialDirtyMechanism)for(const s of this.materials)t&&!t(s)||s.markAsDirty(e)}_loadFile(e,t,s,i,r,n,a){const o=(0,K.zU)(e,t,s,i?this.offlineProvider:void 0,r,n,a);return this._activeRequests.push(o),o.onCompleteObservable.add((e=>{this._activeRequests.splice(this._activeRequests.indexOf(e),1)})),o}_loadFileAsync(e,t,s,i,r){return new Promise(((n,a)=>{this._loadFile(e,(e=>{n(e)}),t,s,i,((e,t)=>{a(t)}),r)}))}_requestFile(e,t,s,i,r,n,a){const o=(0,K.sh)(e,t,s,i?this.offlineProvider:void 0,r,n,a);return this._activeRequests.push(o),o.onCompleteObservable.add((e=>{this._activeRequests.splice(this._activeRequests.indexOf(e),1)})),o}_requestFileAsync(e,t,s,i,r){return new Promise(((n,a)=>{this._requestFile(e,(e=>{n(e)}),t,s,i,(e=>{a(e)}),r)}))}_readFile(e,t,s,i,r){const n=(0,K.NJ)(e,t,s,i,r);return this._activeRequests.push(n),n.onCompleteObservable.add((e=>{this._activeRequests.splice(this._activeRequests.indexOf(e),1)})),n}_readFileAsync(e,t,s){return new Promise(((i,r)=>{this._readFile(e,(e=>{i(e)}),t,s,(e=>{r(e)}))}))}getPerfCollector(){throw(0,b.n)("performanceViewerSceneExtension")}setActiveCameraByID(e){return this.setActiveCameraById(e)}getMaterialByID(e){return this.getMaterialById(e)}getLastMaterialByID(e){return this.getLastMaterialById(e)}getTextureByUniqueID(e){return this.getTextureByUniqueId(e)}getCameraByID(e){return this.getCameraById(e)}getCameraByUniqueID(e){return this.getCameraByUniqueId(e)}getBoneByID(e){return this.getBoneById(e)}getLightByID(e){return this.getLightById(e)}getLightByUniqueID(e){return this.getLightByUniqueId(e)}getParticleSystemByID(e){return this.getParticleSystemById(e)}getGeometryByID(e){return this.getGeometryById(e)}getMeshByID(e){return this.getMeshById(e)}getMeshByUniqueID(e){return this.getMeshByUniqueId(e)}getLastMeshByID(e){return this.getLastMeshById(e)}getMeshesByID(e){return this.getMeshesById(e)}getTransformNodeByID(e){return this.getTransformNodeById(e)}getTransformNodeByUniqueID(e){return this.getTransformNodeByUniqueId(e)}getTransformNodesByID(e){return this.getTransformNodesById(e)}getNodeByID(e){return this.getNodeById(e)}getLastEntryByID(e){return this.getLastEntryById(e)}getLastSkeletonByID(e){return this.getLastSkeletonById(e)}}$.FOGMODE_NONE=0,$.FOGMODE_EXP=1,$.FOGMODE_EXP2=2,$.FOGMODE_LINEAR=3,$.MinDeltaTime=1,$.MaxDeltaTime=1e3,(0,Q.Y5)("BABYLON.Scene",$)},6945:(e,t,s)=>{s.d(t,{B:()=>r,v:()=>i});class i{}i.NAME_EFFECTLAYER="EffectLayer",i.NAME_LAYER="Layer",i.NAME_LENSFLARESYSTEM="LensFlareSystem",i.NAME_BOUNDINGBOXRENDERER="BoundingBoxRenderer",i.NAME_PARTICLESYSTEM="ParticleSystem",i.NAME_GAMEPAD="Gamepad",i.NAME_SIMPLIFICATIONQUEUE="SimplificationQueue",i.NAME_GEOMETRYBUFFERRENDERER="GeometryBufferRenderer",i.NAME_PREPASSRENDERER="PrePassRenderer",i.NAME_DEPTHRENDERER="DepthRenderer",i.NAME_DEPTHPEELINGRENDERER="DepthPeelingRenderer",i.NAME_IBLSHADOWSRENDERER="IblShadowsRenderer",i.NAME_POSTPROCESSRENDERPIPELINEMANAGER="PostProcessRenderPipelineManager",i.NAME_SPRITE="Sprite",i.NAME_SUBSURFACE="SubSurface",i.NAME_OUTLINERENDERER="Outline",i.NAME_PROCEDURALTEXTURE="ProceduralTexture",i.NAME_SHADOWGENERATOR="ShadowGenerator",i.NAME_OCTREE="Octree",i.NAME_PHYSICSENGINE="PhysicsEngine",i.NAME_AUDIO="Audio",i.NAME_FLUIDRENDERER="FluidRenderer",i.STEP_ISREADYFORMESH_EFFECTLAYER=0,i.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER=0,i.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER=0,i.STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER=0,i.STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER=1,i.STEP_BEFORECAMERADRAW_PREPASS=0,i.STEP_BEFORECAMERADRAW_EFFECTLAYER=1,i.STEP_BEFORECAMERADRAW_LAYER=2,i.STEP_BEFORERENDERTARGETDRAW_PREPASS=0,i.STEP_BEFORERENDERTARGETDRAW_LAYER=1,i.STEP_BEFORERENDERINGMESH_PREPASS=0,i.STEP_BEFORERENDERINGMESH_OUTLINE=1,i.STEP_AFTERRENDERINGMESH_PREPASS=0,i.STEP_AFTERRENDERINGMESH_OUTLINE=1,i.STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW=0,i.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER=1,i.STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE=0,i.STEP_BEFORECLEAR_PROCEDURALTEXTURE=0,i.STEP_BEFORECLEAR_PREPASS=1,i.STEP_BEFORERENDERTARGETCLEAR_PREPASS=0,i.STEP_AFTERRENDERTARGETDRAW_PREPASS=0,i.STEP_AFTERRENDERTARGETDRAW_LAYER=1,i.STEP_AFTERCAMERADRAW_PREPASS=0,i.STEP_AFTERCAMERADRAW_EFFECTLAYER=1,i.STEP_AFTERCAMERADRAW_LENSFLARESYSTEM=2,i.STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW=3,i.STEP_AFTERCAMERADRAW_LAYER=4,i.STEP_AFTERCAMERADRAW_FLUIDRENDERER=5,i.STEP_AFTERCAMERAPOSTPROCESS_LAYER=0,i.STEP_AFTERRENDERTARGETPOSTPROCESS_LAYER=0,i.STEP_AFTERRENDER_AUDIO=0,i.STEP_GATHERRENDERTARGETS_DEPTHRENDERER=0,i.STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER=1,i.STEP_GATHERRENDERTARGETS_SHADOWGENERATOR=2,i.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER=3,i.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER=0,i.STEP_GATHERACTIVECAMERARENDERTARGETS_FLUIDRENDERER=1,i.STEP_POINTERMOVE_SPRITE=0,i.STEP_POINTERDOWN_SPRITE=0,i.STEP_POINTERUP_SPRITE=0;class r extends Array{constructor(e){super(...e)}static Create(){return Object.create(r.prototype)}registerStep(e,t,s){let i=0,r=Number.MAX_VALUE;for(;i{function i(e,t,s,i){var r,n=arguments.length,a=n<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,s):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,s,i);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(a=(n<3?r(a):n>3?r(t,s,a):r(t,s))||a);return n>3&&a&&Object.defineProperty(t,s,a),a}s.d(t,{Cg:()=>i}),Object.create,Object.create}}]); +"use strict";(self.webpackChunkbabylon_mmd=self.webpackChunkbabylon_mmd||[]).push([[71],{3357:(e,n,i)=>{i.r(n),i.d(n,{mmdOutlinePixelShader:()=>t}),i(6194),i(4581),i(7412),i(9741);const o="mmdOutlinePixelShader",r="\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\nuniform vec4 color;\n#ifdef ALPHATEST\nvarying vec2 vUV;uniform sampler2D diffuseSampler;\n#endif\n#include\n#include\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\n#include\ngl_FragColor=color;\n#define CUSTOM_FRAGMENT_MAIN_END\n}\n";i(9610).l.ShadersStore[o]=r;const t={name:o,shader:r}},5043:(e,n,i)=>{i.r(n),i.d(n,{mmdOutlineVertexShader:()=>t}),i(9707),i(8959),i(7999),i(738),i(1636),i(1218),i(4581),i(8451),i(5060),i(3298),i(3361),i(5523),i(7314),i(2215);const o="mmdOutlineVertexShader",r="\nattribute vec3 position;attribute vec3 normal;\n#include\n#include\n#include\n#include[0..maxSimultaneousMorphTargets]\n#include\nuniform float offset;\n#include\nuniform vec2 viewport;uniform mat3 view;uniform mat4 viewProjection;\n#ifdef WORLDPOS_REQUIRED\nuniform mat4 inverseViewProjection;\n#endif\n#ifdef ALPHATEST\nvarying vec2 vUV;uniform mat4 diffuseMatrix;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#endif\n#include\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void)\n{vec3 positionUpdated=position;vec3 normalUpdated=normal;\n#ifdef UV1\nvec2 uvUpdated=uv;\n#endif\n#include\n#include[0..maxSimultaneousMorphTargets]\n#include\n#include\n#include\nvec3 viewNormal=view*(mat3(finalWorld)*normalUpdated);vec4 projectedPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);vec2 screenNormal=normalize(vec2(viewNormal));projectedPosition.xy+=screenNormal/(viewport*0.25/*0.5 */)*offset*projectedPosition.w;gl_Position=projectedPosition;\n#ifdef WORLDPOS_REQUIRED\nvec4 worldPos=inverseViewProjection*projectedPosition;\n#endif\n#ifdef ALPHATEST\n#ifdef UV1\nvUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#ifdef UV2\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n#include\n#include\n}\n";i(9610).l.ShadersStore[o]=r;const t={name:o,shader:r}},3313:(e,n,i)=>{i.r(n),i.d(n,{MmdPluginMaterial:()=>f});var o=i(5662),r=i(426);function t(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var a=i(9339),l=i(5041);class f extends r.ZL{isCompatible(e){return e===o.w.GLSL}getCustomCode(e){if("vertex"===e){const e={};return e.CUSTOM_VERTEX_DEFINITIONS=a.B,e[`!${t("finalWorld=finalWorld*influence;")}`]=`\n${l.Z}\nfinalWorld=(finalWorld*influence);\n`,e}if("fragment"===e){const e={CUSTOM_FRAGMENT_DEFINITIONS:"\n#if defined(SPHERE_TEXTURE) && defined(NORMAL)\nuniform sampler2D sphereSampler;\n#endif\n#ifdef TOON_TEXTURE\nuniform sampler2D toonSampler;\n#endif\n"};e[`!${t("#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION) || defined(PREPASS)\nuniform mat4 view;\n#endif")}`]="\n#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION) || defined(PREPASS)\nuniform mat4 view;\n#elif defined(NORMAL) && defined(SPHERE_TEXTURE)\nuniform mat4 view;\n#endif\n",e.CUSTOM_FRAGMENT_MAIN_BEGIN="\n#ifdef TOON_TEXTURE\nvec3 toonNdl;\n#endif\n",e[`!${t("vec3 diffuseColor=vDiffuseColor.rgb;")}`]="\n#ifdef APPLY_AMBIENT_COLOR_TO_DIFFUSE\nvec3 diffuseColor=clamp(vDiffuseColor.rgb+vAmbientColor,0.0,1.0);\n#else\nvec3 diffuseColor=(vDiffuseColor.rgb);\n#endif\n",e[`!${t("float alpha=vDiffuseColor.a;")}`]="\n#ifdef CLAMP_ALPHA\nfloat alpha=clamp(vDiffuseColor.a,0.0,1.0);\n#else\nfloat alpha=vDiffuseColor.a;\n#endif\n",e[`!${t("baseColor=texture2D(diffuseSampler,vDiffuseUV+uvOffset);")}`]="\n#if defined(DIFFUSE) && defined(TEXTURE_COLOR)\nbaseColor=texture2D(diffuseSampler,(vDiffuseUV+uvOffset));baseColor.rgb=mix(\nvec3(1.0),\nbaseColor.rgb*textureMultiplicativeColor.rgb,\ntextureMultiplicativeColor.a\n);baseColor.rgb=clamp(\nbaseColor.rgb+(baseColor.rgb-vec3(1.0))*textureAdditiveColor.a,\n0.0,\n1.0\n)+textureAdditiveColor.rgb;\n#else\nbaseColor=texture2D(diffuseSampler,(vDiffuseUV+uvOffset));\n#endif\n",e[`!${t("struct lightingInfo\n{")}`]="\nstruct lightingInfo {\n#ifdef TOON_TEXTURE\n#ifndef NDOTL\nfloat ndl;\n#endif\nfloat isToon;\n#endif\n",e[`!${t("result.diffuse=ndl*diffuseColor*attenuation;")}`]="\n#ifdef TOON_TEXTURE\nresult.diffuse=diffuseColor*attenuation;result.ndl=ndl;result.isToon=1.0;\n#elif defined(IGNORE_DIFFUSE_WHEN_TOON_TEXTURE_DISABLED) \nresult.diffuse=diffuseColor*attenuation;\n#else\nresult.diffuse=(ndl*diffuseColor*attenuation);\n#endif\n",e[`!${t("diffuseBase+=info.diffuse*shadow;")}`]="\n#ifdef TOON_TEXTURE\ntoonNdl=vec3(clamp(info.ndl*shadow,0.02,0.98));toonNdl.r=texture2D(toonSampler,vec2(0.5,toonNdl.r)).r;toonNdl.g=texture2D(toonSampler,vec2(0.5,toonNdl.g)).g;toonNdl.b=texture2D(toonSampler,vec2(0.5,toonNdl.b)).b;\n#ifdef TOON_TEXTURE_COLOR\ntoonNdl=mix(\nvec3(1.0),\ntoonNdl*toonTextureMultiplicativeColor.rgb,\ntoonTextureMultiplicativeColor.a\n);toonNdl=clamp(\ntoonNdl+(toonNdl-vec3(1.0))*toonTextureAdditiveColor.a,\n0.0,\n1.0\n)+toonTextureAdditiveColor.rgb;\n#endif\ndiffuseBase+=mix(info.diffuse*shadow,toonNdl*info.diffuse,info.isToon);\n#elif defined(IGNORE_DIFFUSE_WHEN_TOON_TEXTURE_DISABLED)\ndiffuseBase+=info.diffuse;\n#else\ndiffuseBase+=(info.diffuse*shadow);\n#endif\n";const n="\n#ifdef EMISSIVEASILLUMINATION\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#else\n#ifdef LINKEMISSIVEWITHDIFFUSE\nvec3 finalDiffuse=clamp((diffuseBase+emissiveColor)*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#else\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor+emissiveColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#endif\n#endif\n";return e[`!${t(n)}`]=`\n#ifdef APPLY_AMBIENT_COLOR_TO_DIFFUSE\n#ifdef EMISSIVEASILLUMINATION\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor,0.0,1.0)*baseColor.rgb;\n#else\n#ifdef LINKEMISSIVEWITHDIFFUSE\nvec3 finalDiffuse=clamp((diffuseBase+emissiveColor)*diffuseColor,0.0,1.0)*baseColor.rgb;\n#else\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor+emissiveColor,0.0,1.0)*baseColor.rgb;\n#endif\n#endif\n#else\n${n.replace("diffuseBase","(diffuseBase)")}#endif\n`,e.CUSTOM_FRAGMENT_BEFORE_FOG="\n#if defined(NORMAL) && defined(SPHERE_TEXTURE)\nvec3 viewSpaceNormal=normalize(mat3(view)*vNormalW);vec2 sphereUV=viewSpaceNormal.xy*0.5+0.5;vec4 sphereReflectionColor=texture2D(sphereSampler,sphereUV);\n#ifdef SPHERE_TEXTURE_COLOR\nsphereReflectionColor.rgb=mix(\nvec3(1.0),\nsphereReflectionColor.rgb*sphereTextureMultiplicativeColor.rgb,\nsphereTextureMultiplicativeColor.a\n);sphereReflectionColor.rgb=clamp(\nsphereReflectionColor.rgb+(sphereReflectionColor.rgb-vec3(1.0))*sphereTextureAdditiveColor.a,\n0.0,\n1.0\n)+sphereTextureAdditiveColor.rgb;\n#endif\nsphereReflectionColor.rgb*=diffuseBase;\n#ifdef SPHERE_TEXTURE_BLEND_MODE_MULTIPLY\ncolor*=sphereReflectionColor;\n#elif defined(SPHERE_TEXTURE_BLEND_MODE_ADD)\ncolor=vec4(color.rgb+sphereReflectionColor.rgb,color.a);\n#endif\n#endif\n",e}return null}getUniforms(e){return{...super.getUniforms(e),fragment:"\n#if defined(DIFFUSE) && defined(TEXTURE_COLOR)\nuniform vec4 textureMultiplicativeColor;uniform vec4 textureAdditiveColor;\n#endif\n#if defined(SPHERE_TEXTURE) && defined(SPHERE_TEXTURE_COLOR)\nuniform vec4 sphereTextureMultiplicativeColor;uniform vec4 sphereTextureAdditiveColor;\n#endif\n#if defined(TOON_TEXTURE) && defined(TOON_TEXTURE_COLOR)\nuniform vec4 toonTextureMultiplicativeColor;uniform vec4 toonTextureAdditiveColor;\n#endif\n"}}}},9457:(e,n,i)=>{i.r(n),i.d(n,{textureAlphaCheckerPixelShader:()=>t});const o="textureAlphaCheckerPixelShader",r="\nprecision highp float;uniform sampler2D textureSampler;varying vec2 vUv;void main() {gl_FragColor=vec4(vec3(1.0)-vec3(texture2D(textureSampler,vUv).a),1.0);}\n";i(9610).l.ShadersStore[o]=r;const t={name:o,shader:r}},71:(e,n,i)=>{i.r(n),i.d(n,{textureAlphaCheckerVertexShader:()=>t});const o="textureAlphaCheckerVertexShader",r="\nprecision highp float;attribute vec2 uv;varying vec2 vUv;void main() {vUv=uv;gl_Position=vec4(mod(uv,1.0)*2.0-1.0,0.0,1.0);}\n";i(9610).l.ShadersStore[o]=r;const t={name:o,shader:r}},1438:(e,n,i)=>{var o=i(9610);i(8764),i(6467);o.l.IncludesShadersStore.defaultUboDeclaration="layout(std140,column_major) uniform;uniform Material\n{vec4 diffuseLeftColor;vec4 diffuseRightColor;vec4 opacityParts;vec4 reflectionLeftColor;vec4 reflectionRightColor;vec4 refractionLeftColor;vec4 refractionRightColor;vec4 emissiveLeftColor;vec4 emissiveRightColor;vec2 vDiffuseInfos;vec2 vAmbientInfos;vec2 vOpacityInfos;vec2 vReflectionInfos;vec3 vReflectionPosition;vec3 vReflectionSize;vec2 vEmissiveInfos;vec2 vLightmapInfos;vec2 vSpecularInfos;vec3 vBumpInfos;mat4 diffuseMatrix;mat4 ambientMatrix;mat4 opacityMatrix;mat4 reflectionMatrix;mat4 emissiveMatrix;mat4 lightmapMatrix;mat4 specularMatrix;mat4 bumpMatrix;vec2 vTangentSpaceParams;float pointSize;float alphaCutOff;mat4 refractionMatrix;vec4 vRefractionInfos;vec3 vRefractionPosition;vec3 vRefractionSize;vec4 vSpecularColor;vec3 vEmissiveColor;vec4 vDiffuseColor;vec3 vAmbientColor;\n#define ADDITIONAL_UBO_DECLARATION\n};\n#include\n#include\n"},3325:(e,n,i)=>{i(9610).l.IncludesShadersStore.helperFunctions="const float PI=3.1415926535897932384626433832795;const float RECIPROCAL_PI=0.3183098861837907;const float RECIPROCAL_PI2=0.15915494309189535;const float HALF_MIN=5.96046448e-08; \nconst float LinearEncodePowerApprox=2.2;const float GammaEncodePowerApprox=1.0/LinearEncodePowerApprox;const vec3 LuminanceEncodeApprox=vec3(0.2126,0.7152,0.0722);const float Epsilon=0.0000001;\n#define saturate(x) clamp(x,0.0,1.0)\n#define absEps(x) abs(x)+Epsilon\n#define maxEps(x) max(x,Epsilon)\n#define saturateEps(x) clamp(x,Epsilon,1.0)\nmat3 transposeMat3(mat3 inMatrix) {vec3 i0=inMatrix[0];vec3 i1=inMatrix[1];vec3 i2=inMatrix[2];mat3 outMatrix=mat3(\nvec3(i0.x,i1.x,i2.x),\nvec3(i0.y,i1.y,i2.y),\nvec3(i0.z,i1.z,i2.z)\n);return outMatrix;}\nmat3 inverseMat3(mat3 inMatrix) {float a00=inMatrix[0][0],a01=inMatrix[0][1],a02=inMatrix[0][2];float a10=inMatrix[1][0],a11=inMatrix[1][1],a12=inMatrix[1][2];float a20=inMatrix[2][0],a21=inMatrix[2][1],a22=inMatrix[2][2];float b01=a22*a11-a12*a21;float b11=-a22*a10+a12*a20;float b21=a21*a10-a11*a20;float det=a00*b01+a01*b11+a02*b21;return mat3(b01,(-a22*a01+a02*a21),(a12*a01-a02*a11),\nb11,(a22*a00-a02*a20),(-a12*a00+a02*a10),\nb21,(-a21*a00+a01*a20),(a11*a00-a01*a10))/det;}\n#if USE_EXACT_SRGB_CONVERSIONS\nvec3 toLinearSpaceExact(vec3 color)\n{vec3 nearZeroSection=0.0773993808*color;vec3 remainingSection=pow(0.947867299*(color+vec3(0.055)),vec3(2.4));\n#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)\nreturn mix(remainingSection,nearZeroSection,lessThanEqual(color,vec3(0.04045)));\n#else\nreturn\nvec3(\ncolor.r<=0.04045 ? nearZeroSection.r : remainingSection.r,\ncolor.g<=0.04045 ? nearZeroSection.g : remainingSection.g,\ncolor.b<=0.04045 ? nearZeroSection.b : remainingSection.b);\n#endif\n}\nvec3 toGammaSpaceExact(vec3 color)\n{vec3 nearZeroSection=12.92*color;vec3 remainingSection=1.055*pow(color,vec3(0.41666))-vec3(0.055);\n#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)\nreturn mix(remainingSection,nearZeroSection,lessThanEqual(color,vec3(0.0031308)));\n#else\nreturn\nvec3(\ncolor.r<=0.0031308 ? nearZeroSection.r : remainingSection.r,\ncolor.g<=0.0031308 ? nearZeroSection.g : remainingSection.g,\ncolor.b<=0.0031308 ? nearZeroSection.b : remainingSection.b);\n#endif\n}\n#endif\nfloat toLinearSpace(float color)\n{\n#if USE_EXACT_SRGB_CONVERSIONS\nfloat nearZeroSection=0.0773993808*color;float remainingSection=pow(0.947867299*(color+0.055),2.4);return color<=0.04045 ? nearZeroSection : remainingSection;\n#else\nreturn pow(color,LinearEncodePowerApprox);\n#endif\n}\nvec3 toLinearSpace(vec3 color)\n{\n#if USE_EXACT_SRGB_CONVERSIONS\nreturn toLinearSpaceExact(color);\n#else\nreturn pow(color,vec3(LinearEncodePowerApprox));\n#endif\n}\nvec4 toLinearSpace(vec4 color)\n{\n#if USE_EXACT_SRGB_CONVERSIONS\nreturn vec4(toLinearSpaceExact(color.rgb),color.a);\n#else\nreturn vec4(pow(color.rgb,vec3(LinearEncodePowerApprox)),color.a);\n#endif\n}\nfloat toGammaSpace(float color)\n{\n#if USE_EXACT_SRGB_CONVERSIONS\nfloat nearZeroSection=12.92*color;float remainingSection=1.055*pow(color,0.41666)-0.055;return color<=0.0031308 ? nearZeroSection : remainingSection;\n#else\nreturn pow(color,GammaEncodePowerApprox);\n#endif\n}\nvec3 toGammaSpace(vec3 color)\n{\n#if USE_EXACT_SRGB_CONVERSIONS\nreturn toGammaSpaceExact(color);\n#else\nreturn pow(color,vec3(GammaEncodePowerApprox));\n#endif\n}\nvec4 toGammaSpace(vec4 color)\n{\n#if USE_EXACT_SRGB_CONVERSIONS\nreturn vec4(toGammaSpaceExact(color.rgb),color.a);\n#else\nreturn vec4(pow(color.rgb,vec3(GammaEncodePowerApprox)),color.a);\n#endif\n}\nfloat square(float value)\n{return value*value;}\nvec3 square(vec3 value)\n{return value*value;}\nfloat pow5(float value) {float sq=value*value;return sq*sq*value;}\nfloat getLuminance(vec3 color)\n{return clamp(dot(color,LuminanceEncodeApprox),0.,1.);}\nfloat getRand(vec2 seed) {return fract(sin(dot(seed.xy ,vec2(12.9898,78.233)))*43758.5453);}\nfloat dither(vec2 seed,float varianceAmount) {float rand=getRand(seed);float normVariance=varianceAmount/255.0;float dither=mix(-normVariance,normVariance,rand);return dither;}\nconst float rgbdMaxRange=255.0;vec4 toRGBD(vec3 color) {float maxRGB=maxEps(max(color.r,max(color.g,color.b)));float D =max(rgbdMaxRange/maxRGB,1.);D =clamp(floor(D)/255.0,0.,1.);vec3 rgb=color.rgb*D;rgb=toGammaSpace(rgb);return vec4(clamp(rgb,0.,1.),D); }\nvec3 fromRGBD(vec4 rgbd) {rgbd.rgb=toLinearSpace(rgbd.rgb);return rgbd.rgb/rgbd.a;}\nvec3 parallaxCorrectNormal( vec3 vertexPos,vec3 origVec,vec3 cubeSize,vec3 cubePos ) {vec3 invOrigVec=vec3(1.0,1.0,1.0)/origVec;vec3 halfSize=cubeSize*0.5;vec3 intersecAtMaxPlane=(cubePos+halfSize-vertexPos)*invOrigVec;vec3 intersecAtMinPlane=(cubePos-halfSize-vertexPos)*invOrigVec;vec3 largestIntersec=max(intersecAtMaxPlane,intersecAtMinPlane);float distance=min(min(largestIntersec.x,largestIntersec.y),largestIntersec.z);vec3 intersectPositionWS=vertexPos+origVec*distance;return intersectPositionWS-cubePos;}\n"},9392:(e,n,i)=>{i(9610).l.IncludesShadersStore.imageProcessingDeclaration="#ifdef EXPOSURE\nuniform float exposureLinear;\n#endif\n#ifdef CONTRAST\nuniform float contrast;\n#endif\n#if defined(VIGNETTE) || defined(DITHER)\nuniform vec2 vInverseScreenSize;\n#endif\n#ifdef VIGNETTE\nuniform vec4 vignetteSettings1;uniform vec4 vignetteSettings2;\n#endif\n#ifdef COLORCURVES\nuniform vec4 vCameraColorCurveNegative;uniform vec4 vCameraColorCurveNeutral;uniform vec4 vCameraColorCurvePositive;\n#endif\n#ifdef COLORGRADING\n#ifdef COLORGRADING3D\nuniform highp sampler3D txColorTransform;\n#else\nuniform sampler2D txColorTransform;\n#endif\nuniform vec4 colorTransformSettings;\n#endif\n#ifdef DITHER\nuniform float ditherIntensity;\n#endif\n"},4017:(e,n,i)=>{i(9610).l.IncludesShadersStore.imageProcessingFunctions="#if defined(COLORGRADING) && !defined(COLORGRADING3D)\n/** \n* Polyfill for SAMPLE_TEXTURE_3D,which is unsupported in WebGL.\n* sampler3dSetting.x=textureOffset (0.5/textureSize).\n* sampler3dSetting.y=textureSize.\n*/\n#define inline\nvec3 sampleTexture3D(sampler2D colorTransform,vec3 color,vec2 sampler3dSetting)\n{float sliceSize=2.0*sampler3dSetting.x; \n#ifdef SAMPLER3DGREENDEPTH\nfloat sliceContinuous=(color.g-sampler3dSetting.x)*sampler3dSetting.y;\n#else\nfloat sliceContinuous=(color.b-sampler3dSetting.x)*sampler3dSetting.y;\n#endif\nfloat sliceInteger=floor(sliceContinuous);float sliceFraction=sliceContinuous-sliceInteger;\n#ifdef SAMPLER3DGREENDEPTH\nvec2 sliceUV=color.rb;\n#else\nvec2 sliceUV=color.rg;\n#endif\nsliceUV.x*=sliceSize;sliceUV.x+=sliceInteger*sliceSize;sliceUV=saturate(sliceUV);vec4 slice0Color=texture2D(colorTransform,sliceUV);sliceUV.x+=sliceSize;sliceUV=saturate(sliceUV);vec4 slice1Color=texture2D(colorTransform,sliceUV);vec3 result=mix(slice0Color.rgb,slice1Color.rgb,sliceFraction);\n#ifdef SAMPLER3DBGRMAP\ncolor.rgb=result.rgb;\n#else\ncolor.rgb=result.bgr;\n#endif\nreturn color;}\n#endif\n#if TONEMAPPING==3\nconst float PBRNeutralStartCompression=0.8-0.04;const float PBRNeutralDesaturation=0.15;vec3 PBRNeutralToneMapping( vec3 color ) {float x=min(color.r,min(color.g,color.b));float offset=x<0.08 ? x-6.25*x*x : 0.04;color-=offset;float peak=max(color.r,max(color.g,color.b));if (peak{i(9610).l.IncludesShadersStore.kernelBlurVaryingDeclaration="varying vec2 sampleCoord{X};"},4581:(e,n,i)=>{i(9610).l.IncludesShadersStore.logDepthDeclaration="#ifdef LOGARITHMICDEPTH\nuniform float logarithmicDepthConstant;varying float vFragmentDepth;\n#endif\n"},9741:(e,n,i)=>{i(9610).l.IncludesShadersStore.logDepthFragment="#ifdef LOGARITHMICDEPTH\ngl_FragDepthEXT=log2(vFragmentDepth)*logarithmicDepthConstant*0.5;\n#endif\n"},2215:(e,n,i)=>{i(9610).l.IncludesShadersStore.logDepthVertex="#ifdef LOGARITHMICDEPTH\nvFragmentDepth=1.0+gl_Position.w;gl_Position.z=log2(max(0.000001,vFragmentDepth))*logarithmicDepthConstant;\n#endif\n"},4980:(e,n,i)=>{i(9610).l.IncludesShadersStore.mainUVVaryingDeclaration="#ifdef MAINUV{X}\nvarying vec2 vMainUV{X};\n#endif\n"},6467:(e,n,i)=>{i(9610).l.IncludesShadersStore.meshUboDeclaration="#ifdef WEBGL2\nuniform mat4 world;uniform float visibility;\n#else\nlayout(std140,column_major) uniform;uniform Mesh\n{mat4 world;float visibility;};\n#endif\n#define WORLD_UBO\n"},8764:(e,n,i)=>{i(9610).l.IncludesShadersStore.sceneUboDeclaration="layout(std140,column_major) uniform;uniform Scene {mat4 viewProjection;\n#ifdef MULTIVIEW\nmat4 viewProjectionR;\n#endif \nmat4 view;mat4 projection;vec4 vEyePosition;};\n"},5426:(e,n,i)=>{i.r(n),i.d(n,{shadowMapFragmentSoftTransparentShadow:()=>t});const o="shadowMapFragmentSoftTransparentShadow",r="#if SM_SOFTTRANSPARENTSHADOW==1\nif ((bayerDither8(floor(mod(gl_FragCoord.xy,8.0))))/64.0>=softTransparentShadowSM.x*alpha) discard;\n#endif\n";i(9610).l.IncludesShadersStore[o]=r;const t={name:o,shader:r}},9336:(e,n,i)=>{i.r(n),i.d(n,{bloomMergePixelShader:()=>t});const o="bloomMergePixelShader",r="uniform sampler2D textureSampler;uniform sampler2D bloomBlur;varying vec2 vUV;uniform float bloomWeight;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{gl_FragColor=texture2D(textureSampler,vUV);vec3 blurred=texture2D(bloomBlur,vUV).rgb;gl_FragColor.rgb=gl_FragColor.rgb+(blurred.rgb*bloomWeight); }\n";i(9610).l.ShadersStore[o]=r;const t={name:o,shader:r}},2048:(e,n,i)=>{i.r(n),i.d(n,{chromaticAberrationPixelShader:()=>t});const o="chromaticAberrationPixelShader",r="uniform sampler2D textureSampler; \nuniform float chromatic_aberration;uniform float radialIntensity;uniform vec2 direction;uniform vec2 centerPosition;uniform float screen_width;uniform float screen_height;varying vec2 vUV;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{vec2 centered_screen_pos=vec2(vUV.x-centerPosition.x,vUV.y-centerPosition.y);vec2 directionOfEffect=direction;if(directionOfEffect.x==0. && directionOfEffect.y==0.){directionOfEffect=normalize(centered_screen_pos);}\nfloat radius2=centered_screen_pos.x*centered_screen_pos.x\n+ centered_screen_pos.y*centered_screen_pos.y;float radius=sqrt(radius2);vec3 ref_indices=vec3(-0.3,0.0,0.3);float ref_shiftX=chromatic_aberration*pow(radius,radialIntensity)*directionOfEffect.x/screen_width;float ref_shiftY=chromatic_aberration*pow(radius,radialIntensity)*directionOfEffect.y/screen_height;vec2 ref_coords_r=vec2(vUV.x+ref_indices.r*ref_shiftX,vUV.y+ref_indices.r*ref_shiftY*0.5);vec2 ref_coords_g=vec2(vUV.x+ref_indices.g*ref_shiftX,vUV.y+ref_indices.g*ref_shiftY*0.5);vec2 ref_coords_b=vec2(vUV.x+ref_indices.b*ref_shiftX,vUV.y+ref_indices.b*ref_shiftY*0.5);vec4 r=texture2D(textureSampler,ref_coords_r);vec4 g=texture2D(textureSampler,ref_coords_g);vec4 b=texture2D(textureSampler,ref_coords_b);float a=clamp(r.a+g.a+b.a,0.,1.);gl_FragColor=vec4(r.r,g.g,b.b,a);}";i(9610).l.ShadersStore[o]=r;const t={name:o,shader:r}},7694:(e,n,i)=>{i.r(n),i.d(n,{circleOfConfusionPixelShader:()=>t});const o="circleOfConfusionPixelShader",r="uniform sampler2D depthSampler;varying vec2 vUV;\n#ifndef COC_DEPTH_NOT_NORMALIZED\nuniform vec2 cameraMinMaxZ;\n#endif\nuniform float focusDistance;uniform float cocPrecalculation;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{float depth=texture2D(depthSampler,vUV).r;\n#define CUSTOM_COC_DEPTH\n#ifdef COC_DEPTH_NOT_NORMALIZED\nfloat pixelDistance=depth*1000.0;\n#else\nfloat pixelDistance=(cameraMinMaxZ.x+cameraMinMaxZ.y*depth)*1000.0; \n#endif\n#define CUSTOM_COC_PIXELDISTANCE\nfloat coc=abs(cocPrecalculation*((focusDistance-pixelDistance)/pixelDistance));coc=clamp(coc,0.0,1.0);gl_FragColor=vec4(coc,coc,coc,1.0);}\n";i(9610).l.ShadersStore[o]=r;const t={name:o,shader:r}},9041:(e,n,i)=>{i.r(n),i.d(n,{defaultPixelShader:()=>a});var o=i(9610);o.l.IncludesShadersStore.decalFragmentDeclaration="#ifdef DECAL\nuniform vec4 vDecalInfos;\n#endif\n";o.l.IncludesShadersStore.defaultFragmentDeclaration="uniform vec4 vEyePosition;uniform vec4 vDiffuseColor;uniform vec4 vSpecularColor;uniform vec3 vEmissiveColor;uniform vec3 vAmbientColor;uniform float visibility;\n#ifdef DIFFUSE\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef AMBIENT\nuniform vec2 vAmbientInfos;\n#endif\n#ifdef OPACITY \nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;uniform vec2 vTangentSpaceParams;\n#endif\n#ifdef ALPHATEST\nuniform float alphaCutOff;\n#endif\n#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION) || defined(PREPASS)\nuniform mat4 view;\n#endif\n#ifdef REFRACTION\nuniform vec4 vRefractionInfos;\n#ifndef REFRACTIONMAP_3D\nuniform mat4 refractionMatrix;\n#endif\n#ifdef REFRACTIONFRESNEL\nuniform vec4 refractionLeftColor;uniform vec4 refractionRightColor;\n#endif\n#if defined(USE_LOCAL_REFRACTIONMAP_CUBIC) && defined(REFRACTIONMAP_3D)\nuniform vec3 vRefractionPosition;uniform vec3 vRefractionSize; \n#endif\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\nuniform vec2 vSpecularInfos;\n#endif\n#ifdef DIFFUSEFRESNEL\nuniform vec4 diffuseLeftColor;uniform vec4 diffuseRightColor;\n#endif\n#ifdef OPACITYFRESNEL\nuniform vec4 opacityParts;\n#endif\n#ifdef EMISSIVEFRESNEL\nuniform vec4 emissiveLeftColor;uniform vec4 emissiveRightColor;\n#endif\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\n#if defined(REFLECTIONMAP_PLANAR) || defined(REFLECTIONMAP_CUBIC) || defined(REFLECTIONMAP_PROJECTION) || defined(REFLECTIONMAP_EQUIRECTANGULAR) || defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_SKYBOX)\nuniform mat4 reflectionMatrix;\n#endif\n#ifndef REFLECTIONMAP_SKYBOX\n#if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC)\nuniform vec3 vReflectionPosition;uniform vec3 vReflectionSize; \n#endif\n#endif\n#ifdef REFLECTIONFRESNEL\nuniform vec4 reflectionLeftColor;uniform vec4 reflectionRightColor;\n#endif\n#endif\n#ifdef DETAIL\nuniform vec4 vDetailInfos;\n#endif\n#include\n#define ADDITIONAL_FRAGMENT_DECLARATION\n",i(1438);o.l.IncludesShadersStore.prePassDeclaration="#ifdef PREPASS\n#extension GL_EXT_draw_buffers : require\nlayout(location=0) out highp vec4 glFragData[{X}];highp vec4 gl_FragColor;\n#ifdef PREPASS_LOCAL_POSITION\nvarying highp vec3 vPosition;\n#endif\n#ifdef PREPASS_DEPTH\nvarying highp vec3 vViewPos;\n#endif\n#if defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR)\nvarying highp vec4 vCurrentPosition;varying highp vec4 vPreviousPosition;\n#endif\n#endif\n";o.l.IncludesShadersStore.oitDeclaration="#ifdef ORDER_INDEPENDENT_TRANSPARENCY\n#extension GL_EXT_draw_buffers : require\nlayout(location=0) out vec2 depth; \nlayout(location=1) out vec4 frontColor;layout(location=2) out vec4 backColor;\n#define MAX_DEPTH 99999.0\nhighp vec4 gl_FragColor;uniform sampler2D oitDepthSampler;uniform sampler2D oitFrontColorSampler;\n#endif\n",i(4980),i(3325);o.l.IncludesShadersStore.lightFragmentDeclaration="#ifdef LIGHT{X}\nuniform vec4 vLightData{X};uniform vec4 vLightDiffuse{X};\n#ifdef SPECULARTERM\nuniform vec4 vLightSpecular{X};\n#else\nvec4 vLightSpecular{X}=vec4(0.);\n#endif\n#ifdef SHADOW{X}\n#ifdef SHADOWCSM{X}\nuniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];uniform float viewFrustumZ{X}[SHADOWCSMNUM_CASCADES{X}];uniform float frustumLengths{X}[SHADOWCSMNUM_CASCADES{X}];uniform float cascadeBlendFactor{X};varying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];varying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];varying vec4 vPositionFromCamera{X};\n#if defined(SHADOWPCSS{X})\nuniform highp sampler2DArrayShadow shadowTexture{X};uniform highp sampler2DArray depthTexture{X};uniform vec2 lightSizeUVCorrection{X}[SHADOWCSMNUM_CASCADES{X}];uniform float depthCorrection{X}[SHADOWCSMNUM_CASCADES{X}];uniform float penumbraDarkness{X};\n#elif defined(SHADOWPCF{X})\nuniform highp sampler2DArrayShadow shadowTexture{X};\n#else\nuniform highp sampler2DArray shadowTexture{X};\n#endif\n#ifdef SHADOWCSMDEBUG{X}\nconst vec3 vCascadeColorsMultiplier{X}[8]=vec3[8]\n(\nvec3 ( 1.5,0.0,0.0 ),\nvec3 ( 0.0,1.5,0.0 ),\nvec3 ( 0.0,0.0,5.5 ),\nvec3 ( 1.5,0.0,5.5 ),\nvec3 ( 1.5,1.5,0.0 ),\nvec3 ( 1.0,1.0,1.0 ),\nvec3 ( 0.0,1.0,5.5 ),\nvec3 ( 0.5,3.5,0.75 )\n);vec3 shadowDebug{X};\n#endif\n#ifdef SHADOWCSMUSESHADOWMAXZ{X}\nint index{X}=-1;\n#else\nint index{X}=SHADOWCSMNUM_CASCADES{X}-1;\n#endif\nfloat diff{X}=0.;\n#elif defined(SHADOWCUBE{X})\nuniform samplerCube shadowTexture{X};\n#else\nvarying vec4 vPositionFromLight{X};varying float vDepthMetric{X};\n#if defined(SHADOWPCSS{X})\nuniform highp sampler2DShadow shadowTexture{X};uniform highp sampler2D depthTexture{X};\n#elif defined(SHADOWPCF{X})\nuniform highp sampler2DShadow shadowTexture{X};\n#else\nuniform sampler2D shadowTexture{X};\n#endif\nuniform mat4 lightMatrix{X};\n#endif\nuniform vec4 shadowsInfo{X};uniform vec2 depthValues{X};\n#endif\n#ifdef SPOTLIGHT{X}\nuniform vec4 vLightDirection{X};uniform vec4 vLightFalloff{X};\n#elif defined(POINTLIGHT{X})\nuniform vec4 vLightFalloff{X};\n#elif defined(HEMILIGHT{X})\nuniform vec3 vLightGround{X};\n#endif\n#ifdef PROJECTEDLIGHTTEXTURE{X}\nuniform mat4 textureProjectionMatrix{X};uniform sampler2D projectionLightTexture{X};\n#endif\n#endif\n";o.l.IncludesShadersStore.lightUboDeclaration="#ifdef LIGHT{X}\nuniform Light{X}\n{vec4 vLightData;vec4 vLightDiffuse;vec4 vLightSpecular;\n#ifdef SPOTLIGHT{X}\nvec4 vLightDirection;vec4 vLightFalloff;\n#elif defined(POINTLIGHT{X})\nvec4 vLightFalloff;\n#elif defined(HEMILIGHT{X})\nvec3 vLightGround;\n#endif\nvec4 shadowsInfo;vec2 depthValues;} light{X};\n#ifdef PROJECTEDLIGHTTEXTURE{X}\nuniform mat4 textureProjectionMatrix{X};uniform sampler2D projectionLightTexture{X};\n#endif\n#ifdef SHADOW{X}\n#ifdef SHADOWCSM{X}\nuniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];uniform float viewFrustumZ{X}[SHADOWCSMNUM_CASCADES{X}];uniform float frustumLengths{X}[SHADOWCSMNUM_CASCADES{X}];uniform float cascadeBlendFactor{X};varying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];varying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];varying vec4 vPositionFromCamera{X};\n#if defined(SHADOWPCSS{X})\nuniform highp sampler2DArrayShadow shadowTexture{X};uniform highp sampler2DArray depthTexture{X};uniform vec2 lightSizeUVCorrection{X}[SHADOWCSMNUM_CASCADES{X}];uniform float depthCorrection{X}[SHADOWCSMNUM_CASCADES{X}];uniform float penumbraDarkness{X};\n#elif defined(SHADOWPCF{X})\nuniform highp sampler2DArrayShadow shadowTexture{X};\n#else\nuniform highp sampler2DArray shadowTexture{X};\n#endif\n#ifdef SHADOWCSMDEBUG{X}\nconst vec3 vCascadeColorsMultiplier{X}[8]=vec3[8]\n(\nvec3 ( 1.5,0.0,0.0 ),\nvec3 ( 0.0,1.5,0.0 ),\nvec3 ( 0.0,0.0,5.5 ),\nvec3 ( 1.5,0.0,5.5 ),\nvec3 ( 1.5,1.5,0.0 ),\nvec3 ( 1.0,1.0,1.0 ),\nvec3 ( 0.0,1.0,5.5 ),\nvec3 ( 0.5,3.5,0.75 )\n);vec3 shadowDebug{X};\n#endif\n#ifdef SHADOWCSMUSESHADOWMAXZ{X}\nint index{X}=-1;\n#else\nint index{X}=SHADOWCSMNUM_CASCADES{X}-1;\n#endif\nfloat diff{X}=0.;\n#elif defined(SHADOWCUBE{X})\nuniform samplerCube shadowTexture{X}; \n#else\nvarying vec4 vPositionFromLight{X};varying float vDepthMetric{X};\n#if defined(SHADOWPCSS{X})\nuniform highp sampler2DShadow shadowTexture{X};uniform highp sampler2D depthTexture{X};\n#elif defined(SHADOWPCF{X})\nuniform highp sampler2DShadow shadowTexture{X};\n#else\nuniform sampler2D shadowTexture{X};\n#endif\nuniform mat4 lightMatrix{X};\n#endif\n#endif\n#endif\n";o.l.IncludesShadersStore.lightsFragmentFunctions="struct lightingInfo\n{vec3 diffuse;\n#ifdef SPECULARTERM\nvec3 specular;\n#endif\n#ifdef NDOTL\nfloat ndl;\n#endif\n};lightingInfo computeLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,float range,float glossiness) {lightingInfo result;vec3 lightVectorW;float attenuation=1.0;if (lightData.w==0.)\n{vec3 direction=lightData.xyz-vPositionW;attenuation=max(0.,1.0-length(direction)/range);lightVectorW=normalize(direction);}\nelse\n{lightVectorW=normalize(-lightData.xyz);}\nfloat ndl=max(0.,dot(vNormal,lightVectorW));\n#ifdef NDOTL\nresult.ndl=ndl;\n#endif\nresult.diffuse=ndl*diffuseColor*attenuation;\n#ifdef SPECULARTERM\nvec3 angleW=normalize(viewDirectionW+lightVectorW);float specComp=max(0.,dot(vNormal,angleW));specComp=pow(specComp,max(1.,glossiness));result.specular=specComp*specularColor*attenuation;\n#endif\nreturn result;}\nlightingInfo computeSpotLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec4 lightDirection,vec3 diffuseColor,vec3 specularColor,float range,float glossiness) {lightingInfo result;vec3 direction=lightData.xyz-vPositionW;vec3 lightVectorW=normalize(direction);float attenuation=max(0.,1.0-length(direction)/range);float cosAngle=max(0.,dot(lightDirection.xyz,-lightVectorW));if (cosAngle>=lightDirection.w)\n{cosAngle=max(0.,pow(cosAngle,lightData.w));attenuation*=cosAngle;float ndl=max(0.,dot(vNormal,lightVectorW));\n#ifdef NDOTL\nresult.ndl=ndl;\n#endif\nresult.diffuse=ndl*diffuseColor*attenuation;\n#ifdef SPECULARTERM\nvec3 angleW=normalize(viewDirectionW+lightVectorW);float specComp=max(0.,dot(vNormal,angleW));specComp=pow(specComp,max(1.,glossiness));result.specular=specComp*specularColor*attenuation;\n#endif\nreturn result;}\nresult.diffuse=vec3(0.);\n#ifdef SPECULARTERM\nresult.specular=vec3(0.);\n#endif\n#ifdef NDOTL\nresult.ndl=0.;\n#endif\nreturn result;}\nlightingInfo computeHemisphericLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,vec3 groundColor,float glossiness) {lightingInfo result;float ndl=dot(vNormal,lightData.xyz)*0.5+0.5;\n#ifdef NDOTL\nresult.ndl=ndl;\n#endif\nresult.diffuse=mix(groundColor,diffuseColor,ndl);\n#ifdef SPECULARTERM\nvec3 angleW=normalize(viewDirectionW+lightData.xyz);float specComp=max(0.,dot(vNormal,angleW));specComp=pow(specComp,max(1.,glossiness));result.specular=specComp*specularColor;\n#endif\nreturn result;}\n#define inline\nvec3 computeProjectionTextureDiffuseLighting(sampler2D projectionLightSampler,mat4 textureProjectionMatrix,vec3 posW){vec4 strq=textureProjectionMatrix*vec4(posW,1.0);strq/=strq.w;vec3 textureColor=texture2D(projectionLightSampler,strq.xy).rgb;return textureColor;}";o.l.IncludesShadersStore.shadowsFragmentFunctions="#ifdef SHADOWS\n#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)\n#define TEXTUREFUNC(s,c,l) texture2DLodEXT(s,c,l)\n#else\n#define TEXTUREFUNC(s,c,b) texture2D(s,c,b)\n#endif\n#ifndef SHADOWFLOAT\nfloat unpack(vec4 color)\n{const vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(color,bit_shift);}\n#endif\nfloat computeFallOff(float value,vec2 clipSpace,float frustumEdgeFalloff)\n{float mask=smoothstep(1.0-frustumEdgeFalloff,1.00000012,clamp(dot(clipSpace,clipSpace),0.,1.));return mix(value,1.0,mask);}\n#define inline\nfloat computeShadowCube(vec3 worldPos,vec3 lightPosition,samplerCube shadowSampler,float darkness,vec2 depthValues)\n{vec3 directionToLight=worldPos-lightPosition;float depth=length(directionToLight);depth=(depth+depthValues.x)/(depthValues.y);depth=clamp(depth,0.,1.0);directionToLight=normalize(directionToLight);directionToLight.y=-directionToLight.y;\n#ifndef SHADOWFLOAT\nfloat shadow=unpack(textureCube(shadowSampler,directionToLight));\n#else\nfloat shadow=textureCube(shadowSampler,directionToLight).x;\n#endif\nreturn depth>shadow ? darkness : 1.0;}\n#define inline\nfloat computeShadowWithPoissonSamplingCube(vec3 worldPos,vec3 lightPosition,samplerCube shadowSampler,float mapSize,float darkness,vec2 depthValues)\n{vec3 directionToLight=worldPos-lightPosition;float depth=length(directionToLight);depth=(depth+depthValues.x)/(depthValues.y);depth=clamp(depth,0.,1.0);directionToLight=normalize(directionToLight);directionToLight.y=-directionToLight.y;float visibility=1.;vec3 poissonDisk[4];poissonDisk[0]=vec3(-1.0,1.0,-1.0);poissonDisk[1]=vec3(1.0,-1.0,-1.0);poissonDisk[2]=vec3(-1.0,-1.0,-1.0);poissonDisk[3]=vec3(1.0,-1.0,1.0);\n#ifndef SHADOWFLOAT\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize))shadow ? computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff) : 1.;}\n#endif\n#define inline\nfloat computeShadow(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float frustumEdgeFalloff)\n{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec2 uv=0.5*clipSpace.xy+vec2(0.5);if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{return 1.0;}\nelse\n{float shadowPixelDepth=clamp(depthMetric,0.,1.0);\n#ifndef SHADOWFLOAT\nfloat shadow=unpack(TEXTUREFUNC(shadowSampler,uv,0.));\n#else\nfloat shadow=TEXTUREFUNC(shadowSampler,uv,0.).x;\n#endif\nreturn shadowPixelDepth>shadow ? computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff) : 1.;}}\n#define inline\nfloat computeShadowWithPoissonSampling(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float mapSize,float darkness,float frustumEdgeFalloff)\n{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec2 uv=0.5*clipSpace.xy+vec2(0.5);if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{return 1.0;}\nelse\n{float shadowPixelDepth=clamp(depthMetric,0.,1.0);float visibility=1.;vec2 poissonDisk[4];poissonDisk[0]=vec2(-0.94201624,-0.39906216);poissonDisk[1]=vec2(0.94558609,-0.76890725);poissonDisk[2]=vec2(-0.094184101,-0.92938870);poissonDisk[3]=vec2(0.34495938,0.29387760);\n#ifndef SHADOWFLOAT\nif (unpack(TEXTUREFUNC(shadowSampler,uv+poissonDisk[0]*mapSize,0.))1.0 || uv.y<0. || uv.y>1.0)\n{return 1.0;}\nelse\n{float shadowPixelDepth=clamp(depthMetric,0.,1.0);\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(TEXTUREFUNC(shadowSampler,uv,0.));\n#else\nfloat shadowMapSample=TEXTUREFUNC(shadowSampler,uv,0.).x;\n#endif\nfloat esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);return computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);}}\n#define inline\nfloat computeShadowWithCloseESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)\n{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec2 uv=0.5*clipSpace.xy+vec2(0.5);if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{return 1.0;}\nelse\n{float shadowPixelDepth=clamp(depthMetric,0.,1.0); \n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(TEXTUREFUNC(shadowSampler,uv,0.));\n#else\nfloat shadowMapSample=TEXTUREFUNC(shadowSampler,uv,0.).x;\n#endif\nfloat esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);return computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);}}\n#ifdef IS_NDC_HALF_ZRANGE\n#define ZINCLIP clipSpace.z\n#else\n#define ZINCLIP uvDepth.z\n#endif\n#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)\n#define GREATEST_LESS_THAN_ONE 0.99999994\n#define DISABLE_UNIFORMITY_ANALYSIS\n#define inline\nfloat computeShadowWithCSMPCF1(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,float darkness,float frustumEdgeFalloff)\n{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));uvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);vec4 uvDepthLayer=vec4(uvDepth.x,uvDepth.y,layer,uvDepth.z);float shadow=texture2D(shadowSampler,uvDepthLayer);shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}\n#define inline\nfloat computeShadowWithCSMPCF3(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\n{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));uvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);vec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x; \nuv+=0.5; \nvec2 st=fract(uv); \nvec2 base_uv=floor(uv)-0.5; \nbase_uv*=shadowMapSizeAndInverse.y; \nvec2 uvw0=3.-2.*st;vec2 uvw1=1.+2.*st;vec2 u=vec2((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y;vec2 v=vec2((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y;float shadow=0.;shadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[0]),layer,uvDepth.z));shadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[0]),layer,uvDepth.z));shadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[1]),layer,uvDepth.z));shadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[1]),layer,uvDepth.z));shadow=shadow/16.;shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}\n#define inline\nfloat computeShadowWithCSMPCF5(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\n{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));uvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);vec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x; \nuv+=0.5; \nvec2 st=fract(uv); \nvec2 base_uv=floor(uv)-0.5; \nbase_uv*=shadowMapSizeAndInverse.y; \nvec2 uvw0=4.-3.*st;vec2 uvw1=vec2(7.);vec2 uvw2=1.+3.*st;vec3 u=vec3((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y;vec3 v=vec3((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y;float shadow=0.;shadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[0]),layer,uvDepth.z));shadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[0]),layer,uvDepth.z));shadow+=uvw2.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[0]),layer,uvDepth.z));shadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[1]),layer,uvDepth.z));shadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[1]),layer,uvDepth.z));shadow+=uvw2.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[1]),layer,uvDepth.z));shadow+=uvw0.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[2]),layer,uvDepth.z));shadow+=uvw1.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[2]),layer,uvDepth.z));shadow+=uvw2.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[2]),layer,uvDepth.z));shadow=shadow/144.;shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}\n#define inline\nfloat computeShadowWithPCF1(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,float darkness,float frustumEdgeFalloff)\n{if (depthMetric>1.0 || depthMetric<0.0) {return 1.0;}\nelse\n{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));uvDepth.z=ZINCLIP;float shadow=TEXTUREFUNC(shadowSampler,uvDepth,0.);shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}}\n#define inline\nfloat computeShadowWithPCF3(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\n{if (depthMetric>1.0 || depthMetric<0.0) {return 1.0;}\nelse\n{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));uvDepth.z=ZINCLIP;vec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x; \nuv+=0.5; \nvec2 st=fract(uv); \nvec2 base_uv=floor(uv)-0.5; \nbase_uv*=shadowMapSizeAndInverse.y; \nvec2 uvw0=3.-2.*st;vec2 uvw1=1.+2.*st;vec2 u=vec2((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y;vec2 v=vec2((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y;float shadow=0.;shadow+=uvw0.x*uvw0.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z),0.);shadow+=uvw1.x*uvw0.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z),0.);shadow+=uvw0.x*uvw1.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z),0.);shadow+=uvw1.x*uvw1.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z),0.);shadow=shadow/16.;shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}}\n#define inline\nfloat computeShadowWithPCF5(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\n{if (depthMetric>1.0 || depthMetric<0.0) {return 1.0;}\nelse\n{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));uvDepth.z=ZINCLIP;vec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x; \nuv+=0.5; \nvec2 st=fract(uv); \nvec2 base_uv=floor(uv)-0.5; \nbase_uv*=shadowMapSizeAndInverse.y; \nvec2 uvw0=4.-3.*st;vec2 uvw1=vec2(7.);vec2 uvw2=1.+3.*st;vec3 u=vec3((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y;vec3 v=vec3((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y;float shadow=0.;shadow+=uvw0.x*uvw0.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z),0.);shadow+=uvw1.x*uvw0.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z),0.);shadow+=uvw2.x*uvw0.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[0]),uvDepth.z),0.);shadow+=uvw0.x*uvw1.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z),0.);shadow+=uvw1.x*uvw1.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z),0.);shadow+=uvw2.x*uvw1.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[1]),uvDepth.z),0.);shadow+=uvw0.x*uvw2.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[2]),uvDepth.z),0.);shadow+=uvw1.x*uvw2.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[2]),uvDepth.z),0.);shadow+=uvw2.x*uvw2.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[2]),uvDepth.z),0.);shadow=shadow/144.;shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}}\nconst vec3 PoissonSamplers32[64]=vec3[64](\nvec3(0.06407013,0.05409927,0.),\nvec3(0.7366577,0.5789394,0.),\nvec3(-0.6270542,-0.5320278,0.),\nvec3(-0.4096107,0.8411095,0.),\nvec3(0.6849564,-0.4990818,0.),\nvec3(-0.874181,-0.04579735,0.),\nvec3(0.9989998,0.0009880066,0.),\nvec3(-0.004920578,-0.9151649,0.),\nvec3(0.1805763,0.9747483,0.),\nvec3(-0.2138451,0.2635818,0.),\nvec3(0.109845,0.3884785,0.),\nvec3(0.06876755,-0.3581074,0.),\nvec3(0.374073,-0.7661266,0.),\nvec3(0.3079132,-0.1216763,0.),\nvec3(-0.3794335,-0.8271583,0.),\nvec3(-0.203878,-0.07715034,0.),\nvec3(0.5912697,0.1469799,0.),\nvec3(-0.88069,0.3031784,0.),\nvec3(0.5040108,0.8283722,0.),\nvec3(-0.5844124,0.5494877,0.),\nvec3(0.6017799,-0.1726654,0.),\nvec3(-0.5554981,0.1559997,0.),\nvec3(-0.3016369,-0.3900928,0.),\nvec3(-0.5550632,-0.1723762,0.),\nvec3(0.925029,0.2995041,0.),\nvec3(-0.2473137,0.5538505,0.),\nvec3(0.9183037,-0.2862392,0.),\nvec3(0.2469421,0.6718712,0.),\nvec3(0.3916397,-0.4328209,0.),\nvec3(-0.03576927,-0.6220032,0.),\nvec3(-0.04661255,0.7995201,0.),\nvec3(0.4402924,0.3640312,0.),\nvec3(0.),\nvec3(0.),\nvec3(0.),\nvec3(0.),\nvec3(0.),\nvec3(0.),\nvec3(0.),\nvec3(0.),\nvec3(0.),\nvec3(0.),\nvec3(0.),\nvec3(0.),\nvec3(0.),\nvec3(0.),\nvec3(0.),\nvec3(0.),\nvec3(0.),\nvec3(0.),\nvec3(0.),\nvec3(0.),\nvec3(0.),\nvec3(0.),\nvec3(0.),\nvec3(0.),\nvec3(0.),\nvec3(0.),\nvec3(0.),\nvec3(0.),\nvec3(0.),\nvec3(0.),\nvec3(0.),\nvec3(0.)\n);const vec3 PoissonSamplers64[64]=vec3[64](\nvec3(-0.613392,0.617481,0.),\nvec3(0.170019,-0.040254,0.),\nvec3(-0.299417,0.791925,0.),\nvec3(0.645680,0.493210,0.),\nvec3(-0.651784,0.717887,0.),\nvec3(0.421003,0.027070,0.),\nvec3(-0.817194,-0.271096,0.),\nvec3(-0.705374,-0.668203,0.),\nvec3(0.977050,-0.108615,0.),\nvec3(0.063326,0.142369,0.),\nvec3(0.203528,0.214331,0.),\nvec3(-0.667531,0.326090,0.),\nvec3(-0.098422,-0.295755,0.),\nvec3(-0.885922,0.215369,0.),\nvec3(0.566637,0.605213,0.),\nvec3(0.039766,-0.396100,0.),\nvec3(0.751946,0.453352,0.),\nvec3(0.078707,-0.715323,0.),\nvec3(-0.075838,-0.529344,0.),\nvec3(0.724479,-0.580798,0.),\nvec3(0.222999,-0.215125,0.),\nvec3(-0.467574,-0.405438,0.),\nvec3(-0.248268,-0.814753,0.),\nvec3(0.354411,-0.887570,0.),\nvec3(0.175817,0.382366,0.),\nvec3(0.487472,-0.063082,0.),\nvec3(-0.084078,0.898312,0.),\nvec3(0.488876,-0.783441,0.),\nvec3(0.470016,0.217933,0.),\nvec3(-0.696890,-0.549791,0.),\nvec3(-0.149693,0.605762,0.),\nvec3(0.034211,0.979980,0.),\nvec3(0.503098,-0.308878,0.),\nvec3(-0.016205,-0.872921,0.),\nvec3(0.385784,-0.393902,0.),\nvec3(-0.146886,-0.859249,0.),\nvec3(0.643361,0.164098,0.),\nvec3(0.634388,-0.049471,0.),\nvec3(-0.688894,0.007843,0.),\nvec3(0.464034,-0.188818,0.),\nvec3(-0.440840,0.137486,0.),\nvec3(0.364483,0.511704,0.),\nvec3(0.034028,0.325968,0.),\nvec3(0.099094,-0.308023,0.),\nvec3(0.693960,-0.366253,0.),\nvec3(0.678884,-0.204688,0.),\nvec3(0.001801,0.780328,0.),\nvec3(0.145177,-0.898984,0.),\nvec3(0.062655,-0.611866,0.),\nvec3(0.315226,-0.604297,0.),\nvec3(-0.780145,0.486251,0.),\nvec3(-0.371868,0.882138,0.),\nvec3(0.200476,0.494430,0.),\nvec3(-0.494552,-0.711051,0.),\nvec3(0.612476,0.705252,0.),\nvec3(-0.578845,-0.768792,0.),\nvec3(-0.772454,-0.090976,0.),\nvec3(0.504440,0.372295,0.),\nvec3(0.155736,0.065157,0.),\nvec3(0.391522,0.849605,0.),\nvec3(-0.620106,-0.328104,0.),\nvec3(0.789239,-0.419965,0.),\nvec3(-0.545396,0.538133,0.),\nvec3(-0.178564,-0.596057,0.)\n);\n#define inline\nfloat computeShadowWithCSMPCSS(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray depthSampler,highp sampler2DArrayShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,int searchTapCount,int pcfTapCount,vec3[64] poissonSamplers,vec2 lightSizeUVCorrection,float depthCorrection,float penumbraDarkness)\n{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));uvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);vec4 uvDepthLayer=vec4(uvDepth.x,uvDepth.y,layer,uvDepth.z);float blockerDepth=0.0;float sumBlockerDepth=0.0;float numBlocker=0.0;for (int i=0; i1.0 || depthMetric<0.0) {return 1.0;}\nelse\n{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));uvDepth.z=ZINCLIP;float blockerDepth=0.0;float sumBlockerDepth=0.0;float numBlocker=0.0;for (int i=0; i{i.r(n),i.d(n,{defaultVertexShader:()=>a});var o=i(9610);o.l.IncludesShadersStore.decalVertexDeclaration="#ifdef DECAL\nuniform vec4 vDecalInfos;uniform mat4 decalMatrix;\n#endif\n";o.l.IncludesShadersStore.defaultVertexDeclaration="uniform mat4 viewProjection;\n#ifdef MULTIVIEW\nmat4 viewProjectionR;\n#endif \nuniform mat4 view;\n#ifdef DIFFUSE\nuniform mat4 diffuseMatrix;uniform vec2 vDiffuseInfos;\n#endif\n#ifdef AMBIENT\nuniform mat4 ambientMatrix;uniform vec2 vAmbientInfos;\n#endif\n#ifdef OPACITY\nuniform mat4 opacityMatrix;uniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;uniform mat4 emissiveMatrix;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;uniform mat4 lightmapMatrix;\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\nuniform vec2 vSpecularInfos;uniform mat4 specularMatrix;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;uniform mat4 bumpMatrix;\n#endif\n#ifdef REFLECTION\nuniform mat4 reflectionMatrix;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n#ifdef DETAIL\nuniform vec4 vDetailInfos;uniform mat4 detailMatrix;\n#endif\n#include\n#define ADDITIONAL_VERTEX_DECLARATION\n",i(1438);o.l.IncludesShadersStore.uvAttributeDeclaration="#ifdef UV{X}\nattribute vec2 uv{X};\n#endif\n",i(3325),i(9707),i(8959),i(1218);o.l.IncludesShadersStore.prePassVertexDeclaration="#ifdef PREPASS\n#ifdef PREPASS_LOCAL_POSITION\nvarying vec3 vPosition;\n#endif\n#ifdef PREPASS_DEPTH\nvarying vec3 vViewPos;\n#endif\n#if defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR)\nuniform mat4 previousViewProjection;varying vec4 vCurrentPosition;varying vec4 vPreviousPosition;\n#endif\n#endif\n",i(4980);o.l.IncludesShadersStore.samplerVertexDeclaration="#if defined(_DEFINENAME_) && _DEFINENAME_DIRECTUV==0\nvarying vec2 v_VARYINGNAME_UV;\n#endif\n";o.l.IncludesShadersStore.bumpVertexDeclaration="#if defined(BUMP) || defined(PARALLAX) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC)\n#if defined(TANGENT) && defined(NORMAL) \nvarying mat3 vTBN;\n#endif\n#endif\n",i(1636);o.l.IncludesShadersStore.fogVertexDeclaration="#ifdef FOG\nvarying vec3 vFogDistance;\n#endif\n";o.l.IncludesShadersStore.lightVxFragmentDeclaration="#ifdef LIGHT{X}\nuniform vec4 vLightData{X};uniform vec4 vLightDiffuse{X};\n#ifdef SPECULARTERM\nuniform vec4 vLightSpecular{X};\n#else\nvec4 vLightSpecular{X}=vec4(0.);\n#endif\n#ifdef SHADOW{X}\n#ifdef SHADOWCSM{X}\nuniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];varying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];varying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];varying vec4 vPositionFromCamera{X};\n#elif defined(SHADOWCUBE{X})\n#else\nvarying vec4 vPositionFromLight{X};varying float vDepthMetric{X};uniform mat4 lightMatrix{X};\n#endif\nuniform vec4 shadowsInfo{X};uniform vec2 depthValues{X};\n#endif\n#ifdef SPOTLIGHT{X}\nuniform vec4 vLightDirection{X};uniform vec4 vLightFalloff{X};\n#elif defined(POINTLIGHT{X})\nuniform vec4 vLightFalloff{X};\n#elif defined(HEMILIGHT{X})\nuniform vec3 vLightGround{X};\n#endif\n#endif\n";o.l.IncludesShadersStore.lightVxUboDeclaration="#ifdef LIGHT{X}\nuniform Light{X}\n{vec4 vLightData;vec4 vLightDiffuse;vec4 vLightSpecular;\n#ifdef SPOTLIGHT{X}\nvec4 vLightDirection;vec4 vLightFalloff;\n#elif defined(POINTLIGHT{X})\nvec4 vLightFalloff;\n#elif defined(HEMILIGHT{X})\nvec3 vLightGround;\n#endif\nvec4 shadowsInfo;vec2 depthValues;} light{X};\n#ifdef SHADOW{X}\n#ifdef SHADOWCSM{X}\nuniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];varying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];varying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];varying vec4 vPositionFromCamera{X};\n#elif defined(SHADOWCUBE{X})\n#else\nvarying vec4 vPositionFromLight{X};varying float vDepthMetric{X};uniform mat4 lightMatrix{X};\n#endif\n#endif\n#endif\n",i(7999),i(738),i(4581),i(8451),i(5060),i(3298),i(3361),i(5523);o.l.IncludesShadersStore.prePassVertex="#ifdef PREPASS_DEPTH\nvViewPos=(view*worldPos).rgb;\n#endif\n#ifdef PREPASS_LOCAL_POSITION\nvPosition=positionUpdated.xyz;\n#endif\n#if (defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR)) && defined(BONES_VELOCITY_ENABLED)\nvCurrentPosition=viewProjection*worldPos;\n#if NUM_BONE_INFLUENCERS>0\nmat4 previousInfluence;previousInfluence=mPreviousBones[int(matricesIndices[0])]*matricesWeights[0];\n#if NUM_BONE_INFLUENCERS>1\npreviousInfluence+=mPreviousBones[int(matricesIndices[1])]*matricesWeights[1];\n#endif \n#if NUM_BONE_INFLUENCERS>2\npreviousInfluence+=mPreviousBones[int(matricesIndices[2])]*matricesWeights[2];\n#endif \n#if NUM_BONE_INFLUENCERS>3\npreviousInfluence+=mPreviousBones[int(matricesIndices[3])]*matricesWeights[3];\n#endif\n#if NUM_BONE_INFLUENCERS>4\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];\n#endif \n#if NUM_BONE_INFLUENCERS>5\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];\n#endif \n#if NUM_BONE_INFLUENCERS>6\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];\n#endif \n#if NUM_BONE_INFLUENCERS>7\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];\n#endif\nvPreviousPosition=previousViewProjection*finalPreviousWorld*previousInfluence*vec4(positionUpdated,1.0);\n#else\nvPreviousPosition=previousViewProjection*finalPreviousWorld*vec4(positionUpdated,1.0);\n#endif\n#endif\n";o.l.IncludesShadersStore.uvVariableDeclaration="#if !defined(UV{X}) && defined(MAINUV{X})\nvec2 uv{X}=vec2(0.,0.);\n#endif\n#ifdef MAINUV{X}\nvMainUV{X}=uv{X};\n#endif\n";o.l.IncludesShadersStore.samplerVertexImplementation="#if defined(_DEFINENAME_) && _DEFINENAME_DIRECTUV==0\nif (v_INFONAME_==0.)\n{v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uvUpdated,1.0,0.0));}\n#ifdef UV2\nelse if (v_INFONAME_==1.)\n{v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv2,1.0,0.0));}\n#endif\n#ifdef UV3\nelse if (v_INFONAME_==2.)\n{v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv3,1.0,0.0));}\n#endif\n#ifdef UV4\nelse if (v_INFONAME_==3.)\n{v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv4,1.0,0.0));}\n#endif\n#ifdef UV5\nelse if (v_INFONAME_==4.)\n{v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv5,1.0,0.0));}\n#endif\n#ifdef UV6\nelse if (v_INFONAME_==5.)\n{v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv6,1.0,0.0));}\n#endif\n#endif\n";o.l.IncludesShadersStore.bumpVertex="#if defined(BUMP) || defined(PARALLAX) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC)\n#if defined(TANGENT) && defined(NORMAL)\nvec3 tbnNormal=normalize(normalUpdated);vec3 tbnTangent=normalize(tangentUpdated.xyz);vec3 tbnBitangent=cross(tbnNormal,tbnTangent)*tangentUpdated.w;vTBN=mat3(finalWorld)*mat3(tbnTangent,tbnBitangent,tbnNormal);\n#endif\n#endif\n",i(7314);o.l.IncludesShadersStore.fogVertex="#ifdef FOG\nvFogDistance=(view*worldPos).xyz;\n#endif\n";o.l.IncludesShadersStore.shadowsVertex="#ifdef SHADOWS\n#if defined(SHADOWCSM{X})\nvPositionFromCamera{X}=view*worldPos;for (int i=0; i{i.r(n),i.d(n,{depthBoxBlurPixelShader:()=>t});const o="depthBoxBlurPixelShader",r="varying vec2 vUV;uniform sampler2D textureSampler;uniform vec2 screenSize;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{vec4 colorDepth=vec4(0.0);for (int x=-OFFSET; x<=OFFSET; x++)\nfor (int y=-OFFSET; y<=OFFSET; y++)\ncolorDepth+=texture2D(textureSampler,vUV+vec2(x,y)/screenSize);gl_FragColor=(colorDepth/float((OFFSET*2+1)*(OFFSET*2+1)));}";i(9610).l.ShadersStore[o]=r;const t={name:o,shader:r}},9411:(e,n,i)=>{i.r(n),i.d(n,{depthOfFieldMergePixelShader:()=>t});const o="depthOfFieldMergePixelShader",r="#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)\n#define TEXTUREFUNC(s,c,lod) texture2DLodEXT(s,c,lod)\n#else\n#define TEXTUREFUNC(s,c,bias) texture2D(s,c,bias)\n#endif\nuniform sampler2D textureSampler;varying vec2 vUV;uniform sampler2D circleOfConfusionSampler;uniform sampler2D blurStep0;\n#if BLUR_LEVEL>0\nuniform sampler2D blurStep1;\n#endif\n#if BLUR_LEVEL>1\nuniform sampler2D blurStep2;\n#endif\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{float coc=TEXTUREFUNC(circleOfConfusionSampler,vUV,0.0).r;\n#if BLUR_LEVEL==0\nvec4 original=TEXTUREFUNC(textureSampler,vUV,0.0);vec4 blurred0=TEXTUREFUNC(blurStep0,vUV,0.0);gl_FragColor=mix(original,blurred0,coc);\n#endif\n#if BLUR_LEVEL==1\nif(coc<0.5){vec4 original=TEXTUREFUNC(textureSampler,vUV,0.0);vec4 blurred1=TEXTUREFUNC(blurStep1,vUV,0.0);gl_FragColor=mix(original,blurred1,coc/0.5);}else{vec4 blurred0=TEXTUREFUNC(blurStep0,vUV,0.0);vec4 blurred1=TEXTUREFUNC(blurStep1,vUV,0.0);gl_FragColor=mix(blurred1,blurred0,(coc-0.5)/0.5);}\n#endif\n#if BLUR_LEVEL==2\nif(coc<0.33){vec4 original=TEXTUREFUNC(textureSampler,vUV,0.0);vec4 blurred2=TEXTUREFUNC(blurStep2,vUV,0.0);gl_FragColor=mix(original,blurred2,coc/0.33);}else if(coc<0.66){vec4 blurred1=TEXTUREFUNC(blurStep1,vUV,0.0);vec4 blurred2=TEXTUREFUNC(blurStep2,vUV,0.0);gl_FragColor=mix(blurred2,blurred1,(coc-0.33)/0.33);}else{vec4 blurred0=TEXTUREFUNC(blurStep0,vUV,0.0);vec4 blurred1=TEXTUREFUNC(blurStep1,vUV,0.0);gl_FragColor=mix(blurred1,blurred0,(coc-0.66)/0.34);}\n#endif\n}\n";i(9610).l.ShadersStore[o]=r;const t={name:o,shader:r}},5491:(e,n,i)=>{i.r(n),i.d(n,{extractHighlightsPixelShader:()=>a});var o=i(9610);i(3325);const r="extractHighlightsPixelShader",t="#include\nvarying vec2 vUV;uniform sampler2D textureSampler;uniform float threshold;uniform float exposure;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) \n{gl_FragColor=texture2D(textureSampler,vUV);float luma=dot(LuminanceEncodeApprox,gl_FragColor.rgb*exposure);gl_FragColor.rgb=step(threshold,luma)*gl_FragColor.rgb;}";o.l.ShadersStore[r]=t;const a={name:r,shader:t}},5499:(e,n,i)=>{i.r(n),i.d(n,{fxaaPixelShader:()=>t});const o="fxaaPixelShader",r="#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE)\n#define TEXTUREFUNC(s,c,l) texture2DLodEXT(s,c,l)\n#else\n#define TEXTUREFUNC(s,c,b) texture2D(s,c,b)\n#endif\nuniform sampler2D textureSampler;uniform vec2 texelSize;varying vec2 vUV;varying vec2 sampleCoordS;varying vec2 sampleCoordE;varying vec2 sampleCoordN;varying vec2 sampleCoordW;varying vec2 sampleCoordNW;varying vec2 sampleCoordSE;varying vec2 sampleCoordNE;varying vec2 sampleCoordSW;const float fxaaQualitySubpix=1.0;const float fxaaQualityEdgeThreshold=0.166;const float fxaaQualityEdgeThresholdMin=0.0833;const vec3 kLumaCoefficients=vec3(0.2126,0.7152,0.0722);\n#define FxaaLuma(rgba) dot(rgba.rgb,kLumaCoefficients)\nvoid main(){vec2 posM;posM.x=vUV.x;posM.y=vUV.y;vec4 rgbyM=TEXTUREFUNC(textureSampler,vUV,0.0);float lumaM=FxaaLuma(rgbyM);float lumaS=FxaaLuma(TEXTUREFUNC(textureSampler,sampleCoordS,0.0));float lumaE=FxaaLuma(TEXTUREFUNC(textureSampler,sampleCoordE,0.0));float lumaN=FxaaLuma(TEXTUREFUNC(textureSampler,sampleCoordN,0.0));float lumaW=FxaaLuma(TEXTUREFUNC(textureSampler,sampleCoordW,0.0));float maxSM=max(lumaS,lumaM);float minSM=min(lumaS,lumaM);float maxESM=max(lumaE,maxSM);float minESM=min(lumaE,minSM);float maxWN=max(lumaN,lumaW);float minWN=min(lumaN,lumaW);float rangeMax=max(maxWN,maxESM);float rangeMin=min(minWN,minESM);float rangeMaxScaled=rangeMax*fxaaQualityEdgeThreshold;float range=rangeMax-rangeMin;float rangeMaxClamped=max(fxaaQualityEdgeThresholdMin,rangeMaxScaled);\n#ifndef MALI\nif(range=edgeVert;float subpixA=subpixNSWE*2.0+subpixNWSWNESE;if (!horzSpan)\n{lumaN=lumaW;}\nif (!horzSpan) \n{lumaS=lumaE;}\nif (horzSpan) \n{lengthSign=texelSize.y;}\nfloat subpixB=(subpixA*(1.0/12.0))-lumaM;float gradientN=lumaN-lumaM;float gradientS=lumaS-lumaM;float lumaNN=lumaN+lumaM;float lumaSS=lumaS+lumaM;bool pairN=abs(gradientN)>=abs(gradientS);float gradient=max(abs(gradientN),abs(gradientS));if (pairN)\n{lengthSign=-lengthSign;}\nfloat subpixC=clamp(abs(subpixB)*subpixRcpRange,0.0,1.0);vec2 posB;posB.x=posM.x;posB.y=posM.y;vec2 offNP;offNP.x=(!horzSpan) ? 0.0 : texelSize.x;offNP.y=(horzSpan) ? 0.0 : texelSize.y;if (!horzSpan) \n{posB.x+=lengthSign*0.5;}\nif (horzSpan)\n{posB.y+=lengthSign*0.5;}\nvec2 posN;posN.x=posB.x-offNP.x*1.5;posN.y=posB.y-offNP.y*1.5;vec2 posP;posP.x=posB.x+offNP.x*1.5;posP.y=posB.y+offNP.y*1.5;float subpixD=((-2.0)*subpixC)+3.0;float lumaEndN=FxaaLuma(TEXTUREFUNC(textureSampler,posN,0.0));float subpixE=subpixC*subpixC;float lumaEndP=FxaaLuma(TEXTUREFUNC(textureSampler,posP,0.0));if (!pairN) \n{lumaNN=lumaSS;}\nfloat gradientScaled=gradient*1.0/4.0;float lumaMM=lumaM-lumaNN*0.5;float subpixF=subpixD*subpixE;bool lumaMLTZero=lumaMM<0.0;lumaEndN-=lumaNN*0.5;lumaEndP-=lumaNN*0.5;bool doneN=abs(lumaEndN)>=gradientScaled;bool doneP=abs(lumaEndP)>=gradientScaled;if (!doneN) \n{posN.x-=offNP.x*3.0;}\nif (!doneN) \n{posN.y-=offNP.y*3.0;}\nbool doneNP=(!doneN) || (!doneP);if (!doneP) \n{posP.x+=offNP.x*3.0;}\nif (!doneP)\n{posP.y+=offNP.y*3.0;}\nif (doneNP)\n{if (!doneN) lumaEndN=FxaaLuma(TEXTUREFUNC(textureSampler,posN.xy,0.0));if (!doneP) lumaEndP=FxaaLuma(TEXTUREFUNC(textureSampler,posP.xy,0.0));if (!doneN) lumaEndN=lumaEndN-lumaNN*0.5;if (!doneP) lumaEndP=lumaEndP-lumaNN*0.5;doneN=abs(lumaEndN)>=gradientScaled;doneP=abs(lumaEndP)>=gradientScaled;if (!doneN) posN.x-=offNP.x*12.0;if (!doneN) posN.y-=offNP.y*12.0;doneNP=(!doneN) || (!doneP);if (!doneP) posP.x+=offNP.x*12.0;if (!doneP) posP.y+=offNP.y*12.0;}\nfloat dstN=posM.x-posN.x;float dstP=posP.x-posM.x;if (!horzSpan)\n{dstN=posM.y-posN.y;}\nif (!horzSpan) \n{dstP=posP.y-posM.y;}\nbool goodSpanN=(lumaEndN<0.0) != lumaMLTZero;float spanLength=(dstP+dstN);bool goodSpanP=(lumaEndP<0.0) != lumaMLTZero;float spanLengthRcp=1.0/spanLength;bool directionN=dstN{i.r(n),i.d(n,{fxaaVertexShader:()=>t});const o="fxaaVertexShader",r="attribute vec2 position;uniform vec2 texelSize;varying vec2 vUV;varying vec2 sampleCoordS;varying vec2 sampleCoordE;varying vec2 sampleCoordN;varying vec2 sampleCoordW;varying vec2 sampleCoordNW;varying vec2 sampleCoordSE;varying vec2 sampleCoordNE;varying vec2 sampleCoordSW;const vec2 madd=vec2(0.5,0.5);\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nvUV=(position*madd+madd);sampleCoordS=vUV+vec2( 0.0,1.0)*texelSize;sampleCoordE=vUV+vec2( 1.0,0.0)*texelSize;sampleCoordN=vUV+vec2( 0.0,-1.0)*texelSize;sampleCoordW=vUV+vec2(-1.0,0.0)*texelSize;sampleCoordNW=vUV+vec2(-1.0,-1.0)*texelSize;sampleCoordSE=vUV+vec2( 1.0,1.0)*texelSize;sampleCoordNE=vUV+vec2( 1.0,-1.0)*texelSize;sampleCoordSW=vUV+vec2(-1.0,1.0)*texelSize;gl_Position=vec4(position,0.0,1.0);\n#define CUSTOM_VERTEX_MAIN_END\n}";i(9610).l.ShadersStore[o]=r;const t={name:o,shader:r}},7094:(e,n,i)=>{i.r(n),i.d(n,{glowBlurPostProcessPixelShader:()=>t});const o="glowBlurPostProcessPixelShader",r="varying vec2 vUV;uniform sampler2D textureSampler;uniform vec2 screenSize;uniform vec2 direction;uniform float blurWidth;float getLuminance(vec3 color)\n{return dot(color,vec3(0.2126,0.7152,0.0722));}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{float weights[7];weights[0]=0.05;weights[1]=0.1;weights[2]=0.2;weights[3]=0.3;weights[4]=0.2;weights[5]=0.1;weights[6]=0.05;vec2 texelSize=vec2(1.0/screenSize.x,1.0/screenSize.y);vec2 texelStep=texelSize*direction*blurWidth;vec2 start=vUV-3.0*texelStep;vec4 baseColor=vec4(0.,0.,0.,0.);vec2 texelOffset=vec2(0.,0.);for (int i=0; i<7; i++)\n{vec4 texel=texture2D(textureSampler,start+texelOffset);baseColor.a+=texel.a*weights[i];float luminance=getLuminance(baseColor.rgb);float luminanceTexel=getLuminance(texel.rgb);float choice=step(luminanceTexel,luminance);baseColor.rgb=choice*baseColor.rgb+(1.0-choice)*texel.rgb;texelOffset+=texelStep;}\ngl_FragColor=baseColor;}";i(9610).l.ShadersStore[o]=r;const t={name:o,shader:r}},3234:(e,n,i)=>{i.r(n),i.d(n,{glowMapGenerationPixelShader:()=>a});var o=i(9610);i(3325),i(6194),i(7412);const r="glowMapGenerationPixelShader",t="#if defined(DIFFUSE_ISLINEAR) || defined(EMISSIVE_ISLINEAR)\n#include\n#endif\n#ifdef DIFFUSE\nvarying vec2 vUVDiffuse;uniform sampler2D diffuseSampler;\n#endif\n#ifdef OPACITY\nvarying vec2 vUVOpacity;uniform sampler2D opacitySampler;uniform float opacityIntensity;\n#endif\n#ifdef EMISSIVE\nvarying vec2 vUVEmissive;uniform sampler2D emissiveSampler;\n#endif\n#ifdef VERTEXALPHA\nvarying vec4 vColor;\n#endif\nuniform vec4 glowColor;uniform float glowIntensity;\n#include\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\n#include\nvec4 finalColor=glowColor;\n#ifdef DIFFUSE\nvec4 albedoTexture=texture2D(diffuseSampler,vUVDiffuse);\n#ifdef DIFFUSE_ISLINEAR\nalbedoTexture=toGammaSpace(albedoTexture);\n#endif\n#ifdef GLOW\nfinalColor.a*=albedoTexture.a;\n#endif\n#ifdef HIGHLIGHT\nfinalColor.a=albedoTexture.a;\n#endif\n#endif\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vUVOpacity);\n#ifdef OPACITYRGB\nfinalColor.a*=getLuminance(opacityMap.rgb);\n#else\nfinalColor.a*=opacityMap.a;\n#endif\nfinalColor.a*=opacityIntensity;\n#endif\n#ifdef VERTEXALPHA\nfinalColor.a*=vColor.a;\n#endif\n#ifdef ALPHATEST\nif (finalColor.a{i.r(n),i.d(n,{glowMapGenerationVertexShader:()=>a});var o=i(9610);i(9707),i(8959),i(7999),i(738),i(1636),i(1218),i(8451),i(5060),i(3298),i(3361),i(5523),i(7314);const r="glowMapGenerationVertexShader",t="attribute vec3 position;\n#include\n#include\n#include\n#include[0..maxSimultaneousMorphTargets]\n#include\n#include\nuniform mat4 viewProjection;varying vec4 vPosition;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef DIFFUSE\nvarying vec2 vUVDiffuse;uniform mat4 diffuseMatrix;\n#endif\n#ifdef OPACITY\nvarying vec2 vUVOpacity;uniform mat4 opacityMatrix;\n#endif\n#ifdef EMISSIVE\nvarying vec2 vUVEmissive;uniform mat4 emissiveMatrix;\n#endif\n#ifdef VERTEXALPHA\nattribute vec4 color;varying vec4 vColor;\n#endif\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void)\n{vec3 positionUpdated=position;\n#ifdef UV1\nvec2 uvUpdated=uv;\n#endif\n#include\n#include[0..maxSimultaneousMorphTargets]\n#include\n#include\n#include\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\n#ifdef CUBEMAP\nvPosition=worldPos;gl_Position=viewProjection*finalWorld*vec4(position,1.0);\n#else\nvPosition=viewProjection*worldPos;gl_Position=vPosition;\n#endif\n#ifdef DIFFUSE\n#ifdef DIFFUSEUV1\nvUVDiffuse=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#ifdef DIFFUSEUV2\nvUVDiffuse=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n#ifdef OPACITY\n#ifdef OPACITYUV1\nvUVOpacity=vec2(opacityMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#ifdef OPACITYUV2\nvUVOpacity=vec2(opacityMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n#ifdef EMISSIVE\n#ifdef EMISSIVEUV1\nvUVEmissive=vec2(emissiveMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#ifdef EMISSIVEUV2\nvUVEmissive=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n#ifdef VERTEXALPHA\nvColor=color;\n#endif\n#include\n}";o.l.ShadersStore[r]=t;const a={name:r,shader:t}},9858:(e,n,i)=>{i.r(n),i.d(n,{glowMapMergePixelShader:()=>t});const o="glowMapMergePixelShader",r="varying vec2 vUV;uniform sampler2D textureSampler;\n#ifdef EMISSIVE\nuniform sampler2D textureSampler2;\n#endif\nuniform float offset;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\nvec4 baseColor=texture2D(textureSampler,vUV);\n#ifdef EMISSIVE\nbaseColor+=texture2D(textureSampler2,vUV);baseColor*=offset;\n#else\nbaseColor.a=abs(offset-baseColor.a);\n#ifdef STROKE\nfloat alpha=smoothstep(.0,.1,baseColor.a);baseColor.a=alpha;baseColor.rgb=baseColor.rgb*alpha;\n#endif\n#endif\n#if LDR\nbaseColor=clamp(baseColor,0.,1.0);\n#endif\ngl_FragColor=baseColor;\n#define CUSTOM_FRAGMENT_MAIN_END\n}";i(9610).l.ShadersStore[o]=r;const t={name:o,shader:r}},1288:(e,n,i)=>{i.r(n),i.d(n,{glowMapMergeVertexShader:()=>t});const o="glowMapMergeVertexShader",r="attribute vec2 position;varying vec2 vUV;const vec2 madd=vec2(0.5,0.5);\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nvUV=position*madd+madd;gl_Position=vec4(position,0.0,1.0);\n#define CUSTOM_VERTEX_MAIN_END\n}";i(9610).l.ShadersStore[o]=r;const t={name:o,shader:r}},890:(e,n,i)=>{i.r(n),i.d(n,{grainPixelShader:()=>a});var o=i(9610);i(3325);const r="grainPixelShader",t="#include\nuniform sampler2D textureSampler; \nuniform float intensity;uniform float animatedSeed;varying vec2 vUV;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{gl_FragColor=texture2D(textureSampler,vUV);vec2 seed=vUV*(animatedSeed);float grain=dither(seed,intensity);float lum=getLuminance(gl_FragColor.rgb);float grainAmount=(cos(-PI+(lum*PI*2.))+1.)/2.;gl_FragColor.rgb+=grain*grainAmount;gl_FragColor.rgb=max(gl_FragColor.rgb,0.0);}";o.l.ShadersStore[r]=t;const a={name:r,shader:t}},3153:(e,n,i)=>{i.r(n),i.d(n,{imageProcessingPixelShader:()=>a});var o=i(9610);i(9392),i(3325),i(4017);const r="imageProcessingPixelShader",t="varying vec2 vUV;uniform sampler2D textureSampler;\n#include\n#include\n#include\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{vec4 result=texture2D(textureSampler,vUV);\n#ifdef IMAGEPROCESSING\n#ifndef FROMLINEARSPACE\nresult.rgb=toLinearSpace(result.rgb);\n#endif\nresult=applyImageProcessing(result);\n#else\n#ifdef FROMLINEARSPACE\nresult=applyImageProcessing(result);\n#endif\n#endif\ngl_FragColor=result;}";o.l.ShadersStore[r]=t;const a={name:r,shader:t}},4509:(e,n,i)=>{i.r(n),i.d(n,{kernelBlurPixelShader:()=>a});var o=i(9610);i(7382),i(8334);o.l.IncludesShadersStore.kernelBlurFragment="#ifdef DOF\nfactor=sampleCoC(sampleCoord{X}); \ncomputedWeight=KERNEL_WEIGHT{X}*factor;sumOfWeights+=computedWeight;\n#else\ncomputedWeight=KERNEL_WEIGHT{X};\n#endif\n#ifdef PACKEDFLOAT\nblend+=unpack(texture2D(textureSampler,sampleCoord{X}))*computedWeight;\n#else\nblend+=texture2D(textureSampler,sampleCoord{X})*computedWeight;\n#endif\n";o.l.IncludesShadersStore.kernelBlurFragment2="#ifdef DOF\nfactor=sampleCoC(sampleCenter+delta*KERNEL_DEP_OFFSET{X});computedWeight=KERNEL_DEP_WEIGHT{X}*factor;sumOfWeights+=computedWeight;\n#else\ncomputedWeight=KERNEL_DEP_WEIGHT{X};\n#endif\n#ifdef PACKEDFLOAT\nblend+=unpack(texture2D(textureSampler,sampleCenter+delta*KERNEL_DEP_OFFSET{X}))*computedWeight;\n#else\nblend+=texture2D(textureSampler,sampleCenter+delta*KERNEL_DEP_OFFSET{X})*computedWeight;\n#endif\n";const r="kernelBlurPixelShader",t="uniform sampler2D textureSampler;uniform vec2 delta;varying vec2 sampleCenter;\n#ifdef DOF\nuniform sampler2D circleOfConfusionSampler;float sampleCoC(in vec2 offset) {float coc=texture2D(circleOfConfusionSampler,offset).r;return coc; }\n#endif\n#include[0..varyingCount]\n#ifdef PACKEDFLOAT\n#include\n#endif\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{float computedWeight=0.0;\n#ifdef PACKEDFLOAT\nfloat blend=0.;\n#else\nvec4 blend=vec4(0.);\n#endif\n#ifdef DOF\nfloat sumOfWeights=CENTER_WEIGHT; \nfloat factor=0.0;\n#ifdef PACKEDFLOAT\nblend+=unpack(texture2D(textureSampler,sampleCenter))*CENTER_WEIGHT;\n#else\nblend+=texture2D(textureSampler,sampleCenter)*CENTER_WEIGHT;\n#endif\n#endif\n#include[0..varyingCount]\n#include[0..depCount]\n#ifdef PACKEDFLOAT\ngl_FragColor=pack(blend);\n#else\ngl_FragColor=blend;\n#endif\n#ifdef DOF\ngl_FragColor/=sumOfWeights;\n#endif\n}";o.l.ShadersStore[r]=t;const a={name:r,shader:t}},3802:(e,n,i)=>{i.r(n),i.d(n,{kernelBlurVertexShader:()=>a});var o=i(9610);i(7382);o.l.IncludesShadersStore.kernelBlurVertex="sampleCoord{X}=sampleCenter+delta*KERNEL_OFFSET{X};";const r="kernelBlurVertexShader",t="attribute vec2 position;uniform vec2 delta;varying vec2 sampleCenter;\n#include[0..varyingCount]\nconst vec2 madd=vec2(0.5,0.5);\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nsampleCenter=(position*madd+madd);\n#include[0..varyingCount]\ngl_Position=vec4(position,0.0,1.0);\n#define CUSTOM_VERTEX_MAIN_END\n}";o.l.ShadersStore[r]=t;const a={name:r,shader:t}},9278:(e,n,i)=>{i.r(n),i.d(n,{lodPixelShader:()=>t});const o="lodPixelShader",r="#extension GL_EXT_shader_texture_lod : enable\nprecision highp float;const float GammaEncodePowerApprox=1.0/2.2;varying vec2 vUV;uniform sampler2D textureSampler;uniform float lod;uniform vec2 texSize;uniform int gamma;void main(void)\n{gl_FragColor=texture2DLodEXT(textureSampler,vUV,lod);if (gamma==0) {gl_FragColor.rgb=pow(gl_FragColor.rgb,vec3(GammaEncodePowerApprox));}}\n";i(9610).l.ShadersStore[o]=r;const t={name:o,shader:r}},2905:(e,n,i)=>{i.r(n),i.d(n,{lodCubePixelShader:()=>t});const o="lodCubePixelShader",r="precision highp float;const float GammaEncodePowerApprox=1.0/2.2;varying vec2 vUV;uniform samplerCube textureSampler;uniform float lod;uniform int gamma;void main(void)\n{vec2 uv=vUV*2.0-1.0;\n#ifdef POSITIVEX\ngl_FragColor=textureCube(textureSampler,vec3(1.001,uv.y,uv.x),lod);\n#endif\n#ifdef NEGATIVEX\ngl_FragColor=textureCube(textureSampler,vec3(-1.001,uv.y,uv.x),lod);\n#endif\n#ifdef POSITIVEY\ngl_FragColor=textureCube(textureSampler,vec3(uv.y,1.001,uv.x),lod);\n#endif\n#ifdef NEGATIVEY\ngl_FragColor=textureCube(textureSampler,vec3(uv.y,-1.001,uv.x),lod);\n#endif\n#ifdef POSITIVEZ\ngl_FragColor=textureCube(textureSampler,vec3(uv,1.001),lod);\n#endif\n#ifdef NEGATIVEZ\ngl_FragColor=textureCube(textureSampler,vec3(uv,-1.001),lod);\n#endif\nif (gamma==0) {gl_FragColor.rgb=pow(gl_FragColor.rgb,vec3(GammaEncodePowerApprox));}}\n";i(9610).l.ShadersStore[o]=r;const t={name:o,shader:r}},9820:(e,n,i)=>{i.r(n),i.d(n,{passPixelShader:()=>t});const o="passPixelShader",r="varying vec2 vUV;uniform sampler2D textureSampler;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) \n{gl_FragColor=texture2D(textureSampler,vUV);}";i(9610).l.ShadersStore[o]=r;const t={name:o,shader:r}},4511:(e,n,i)=>{i.r(n),i.d(n,{passCubePixelShader:()=>t});const o="passCubePixelShader",r="varying vec2 vUV;uniform samplerCube textureSampler;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) \n{vec2 uv=vUV*2.0-1.0;\n#ifdef POSITIVEX\ngl_FragColor=textureCube(textureSampler,vec3(1.001,uv.y,uv.x));\n#endif\n#ifdef NEGATIVEX\ngl_FragColor=textureCube(textureSampler,vec3(-1.001,uv.y,uv.x));\n#endif\n#ifdef POSITIVEY\ngl_FragColor=textureCube(textureSampler,vec3(uv.y,1.001,uv.x));\n#endif\n#ifdef NEGATIVEY\ngl_FragColor=textureCube(textureSampler,vec3(uv.y,-1.001,uv.x));\n#endif\n#ifdef POSITIVEZ\ngl_FragColor=textureCube(textureSampler,vec3(uv,1.001));\n#endif\n#ifdef NEGATIVEZ\ngl_FragColor=textureCube(textureSampler,vec3(uv,-1.001));\n#endif\n}";i(9610).l.ShadersStore[o]=r;const t={name:o,shader:r}},9682:(e,n,i)=>{i.r(n),i.d(n,{rgbdDecodePixelShader:()=>a});var o=i(9610);i(3325);const r="rgbdDecodePixelShader",t="varying vec2 vUV;uniform sampler2D textureSampler;\n#include\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) \n{gl_FragColor=vec4(fromRGBD(texture2D(textureSampler,vUV)),1.0);}";o.l.ShadersStore[r]=t;const a={name:r,shader:t}},2646:(e,n,i)=>{i.r(n),i.d(n,{rgbdEncodePixelShader:()=>a});var o=i(9610);i(3325);const r="rgbdEncodePixelShader",t="varying vec2 vUV;uniform sampler2D textureSampler;\n#include\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) \n{gl_FragColor=toRGBD(texture2D(textureSampler,vUV).rgb);}";o.l.ShadersStore[r]=t;const a={name:r,shader:t}},357:(e,n,i)=>{i.r(n),i.d(n,{shadowMapPixelShader:()=>a});var o=i(9610);i(8334);o.l.IncludesShadersStore.bayerDitherFunctions="float bayerDither2(vec2 _P) {return mod(2.0*_P.y+_P.x+1.0,4.0);}\nfloat bayerDither4(vec2 _P) {vec2 P1=mod(_P,2.0); \nvec2 P2=floor(0.5*mod(_P,4.0)); \nreturn 4.0*bayerDither2(P1)+bayerDither2(P2);}\nfloat bayerDither8(vec2 _P) {vec2 P1=mod(_P,2.0); \nvec2 P2=floor(0.5 *mod(_P,4.0)); \nvec2 P4=floor(0.25*mod(_P,8.0)); \nreturn 4.0*(4.0*bayerDither2(P1)+bayerDither2(P2))+bayerDither2(P4);}\n";o.l.IncludesShadersStore.shadowMapFragmentExtraDeclaration="#if SM_FLOAT==0\n#include\n#endif\n#if SM_SOFTTRANSPARENTSHADOW==1\n#include\nuniform vec2 softTransparentShadowSM;\n#endif\nvarying float vDepthMetricSM;\n#if SM_USEDISTANCE==1\nuniform vec3 lightDataSM;varying vec3 vPositionWSM;\n#endif\nuniform vec3 biasAndScaleSM;uniform vec2 depthValuesSM;\n#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP==1\nvarying float zSM;\n#endif\n",i(6194),i(7412);o.l.IncludesShadersStore.shadowMapFragment="float depthSM=vDepthMetricSM;\n#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP==1\n#if SM_USEDISTANCE==1\ndepthSM=(length(vPositionWSM-lightDataSM)+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;\n#else\n#ifdef USE_REVERSE_DEPTHBUFFER\ndepthSM=(-zSM+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;\n#else\ndepthSM=(zSM+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;\n#endif\n#endif\n#ifdef USE_REVERSE_DEPTHBUFFER\ngl_FragDepth=clamp(1.0-depthSM,0.0,1.0);\n#else\ngl_FragDepth=clamp(depthSM,0.0,1.0); \n#endif\n#elif SM_USEDISTANCE==1\ndepthSM=(length(vPositionWSM-lightDataSM)+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;\n#endif\n#if SM_ESM==1\ndepthSM=clamp(exp(-min(87.,biasAndScaleSM.z*depthSM)),0.,1.);\n#endif\n#if SM_FLOAT==1\ngl_FragColor=vec4(depthSM,1.0,1.0,1.0);\n#else\ngl_FragColor=pack(depthSM);\n#endif\nreturn;";const r="shadowMapPixelShader",t="#include\n#ifdef ALPHATEXTURE\nvarying vec2 vUV;uniform sampler2D diffuseSampler;\n#endif\n#include\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\n#include\n#ifdef ALPHATEXTURE\nvec4 opacityMap=texture2D(diffuseSampler,vUV);float alphaFromAlphaTexture=opacityMap.a;\n#if SM_SOFTTRANSPARENTSHADOW==1\nif (softTransparentShadowSM.y==1.0) {opacityMap.rgb=opacityMap.rgb*vec3(0.3,0.59,0.11);alphaFromAlphaTexture=opacityMap.x+opacityMap.y+opacityMap.z;}\n#endif\n#ifdef ALPHATESTVALUE\nif (alphaFromAlphaTexture=softTransparentShadowSM.x*alphaFromAlphaTexture) discard;\n#else\nif ((bayerDither8(floor(mod(gl_FragCoord.xy,8.0))))/64.0>=softTransparentShadowSM.x) discard;\n#endif\n#endif\n#include\n}";o.l.ShadersStore[r]=t;const a={name:r,shader:t}},3906:(e,n,i)=>{i.r(n),i.d(n,{shadowMapVertexShader:()=>a});var o=i(9610);i(9707),i(8959),i(7999),i(738),i(3325);o.l.IncludesShadersStore.sceneVertexDeclaration="uniform mat4 viewProjection;\n#ifdef MULTIVIEW\nuniform mat4 viewProjectionR;\n#endif\nuniform mat4 view;uniform mat4 projection;uniform vec4 vEyePosition;\n";o.l.IncludesShadersStore.meshVertexDeclaration="uniform mat4 world;uniform float visibility;\n";o.l.IncludesShadersStore.shadowMapVertexDeclaration="#include\n#include\n",i(8764),i(6467);o.l.IncludesShadersStore.shadowMapUboDeclaration="layout(std140,column_major) uniform;\n#include\n#include\n";o.l.IncludesShadersStore.shadowMapVertexExtraDeclaration="#if SM_NORMALBIAS==1\nuniform vec3 lightDataSM;\n#endif\nuniform vec3 biasAndScaleSM;uniform vec2 depthValuesSM;varying float vDepthMetricSM;\n#if SM_USEDISTANCE==1\nvarying vec3 vPositionWSM;\n#endif\n#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP==1\nvarying float zSM;\n#endif\n",i(1636),i(8451),i(5060),i(3298),i(3361),i(5523);o.l.IncludesShadersStore.shadowMapVertexNormalBias="#if SM_NORMALBIAS==1\n#if SM_DIRECTIONINLIGHTDATA==1\nvec3 worldLightDirSM=normalize(-lightDataSM.xyz);\n#else\nvec3 directionToLightSM=lightDataSM.xyz-worldPos.xyz;vec3 worldLightDirSM=normalize(directionToLightSM);\n#endif\nfloat ndlSM=dot(vNormalW,worldLightDirSM);float sinNLSM=sqrt(1.0-ndlSM*ndlSM);float normalBiasSM=biasAndScaleSM.y*sinNLSM;worldPos.xyz-=vNormalW*normalBiasSM;\n#endif\n";o.l.IncludesShadersStore.shadowMapVertexMetric="#if SM_USEDISTANCE==1\nvPositionWSM=worldPos.xyz;\n#endif\n#if SM_DEPTHTEXTURE==1\n#ifdef IS_NDC_HALF_ZRANGE\n#define BIASFACTOR 0.5\n#else\n#define BIASFACTOR 1.0\n#endif\n#ifdef USE_REVERSE_DEPTHBUFFER\ngl_Position.z-=biasAndScaleSM.x*gl_Position.w*BIASFACTOR;\n#else\ngl_Position.z+=biasAndScaleSM.x*gl_Position.w*BIASFACTOR;\n#endif\n#endif\n#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP==1\nzSM=gl_Position.z;gl_Position.z=0.0;\n#elif SM_USEDISTANCE==0\n#ifdef USE_REVERSE_DEPTHBUFFER\nvDepthMetricSM=(-gl_Position.z+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;\n#else\nvDepthMetricSM=(gl_Position.z+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;\n#endif\n#endif\n",i(7314);const r="shadowMapVertexShader",t="attribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#include\n#include\n#include\n#include[0..maxSimultaneousMorphTargets]\n#ifdef INSTANCES\nattribute vec4 world0;attribute vec4 world1;attribute vec4 world2;attribute vec4 world3;\n#endif\n#include\n#include<__decl__shadowMapVertex>\n#ifdef ALPHATEXTURE\nvarying vec2 vUV;uniform mat4 diffuseMatrix;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#endif\n#include\n#include\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void)\n{vec3 positionUpdated=position;\n#ifdef UV1\nvec2 uvUpdated=uv;\n#endif\n#ifdef NORMAL\nvec3 normalUpdated=normal;\n#endif\n#include\n#include[0..maxSimultaneousMorphTargets]\n#include\n#include\n#include\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\n#ifdef NORMAL\nmat3 normWorldSM=mat3(finalWorld);\n#if defined(INSTANCES) && defined(THIN_INSTANCES)\nvec3 vNormalW=normalUpdated/vec3(dot(normWorldSM[0],normWorldSM[0]),dot(normWorldSM[1],normWorldSM[1]),dot(normWorldSM[2],normWorldSM[2]));vNormalW=normalize(normWorldSM*vNormalW);\n#else\n#ifdef NONUNIFORMSCALING\nnormWorldSM=transposeMat3(inverseMat3(normWorldSM));\n#endif\nvec3 vNormalW=normalize(normWorldSM*normalUpdated);\n#endif\n#endif\n#include\ngl_Position=viewProjection*worldPos;\n#include\n#ifdef ALPHATEXTURE\n#ifdef UV1\nvUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#ifdef UV2\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n#include\n}";o.l.ShadersStore[r]=t;const a={name:r,shader:t}}}]); +"use strict";(self.webpackChunkbabylon_mmd=self.webpackChunkbabylon_mmd||[]).push([[928],{9928:(e,n,a)=>{a.r(n),a.d(n,{Dispose:()=>u,DumpData:()=>d,DumpDataAsync:()=>l,DumpFramebuffer:()=>c,DumpTools:()=>m});var r=a(4255),s=a(998),t=a(4867),i=a(6315);let p,o=null;async function c(e,n,a,r,s="image/png",t,i){const p=await a.readPixels(0,0,e,n);d(e,n,new Uint8Array(p.buffer),r,s,t,!0,void 0,i)}function l(e,n,a,r="image/png",s,t=!1,i=!1,p){return new Promise((o=>{d(e,n,a,(e=>o(e)),r,s,t,i,p)}))}function d(e,n,c,l,d="image/png",m,f=!1,h=!1,w){(async function(){return o||(o=new Promise(((e,n)=>{let s,t=null;const o={preserveDrawingBuffer:!0,depth:!1,stencil:!1,alpha:!0,premultipliedAlpha:!1,antialias:!1,failIfMajorPerformanceCaveat:!1};Promise.resolve().then(a.bind(a,6321)).then((({ThinEngine:c})=>{try{s=new OffscreenCanvas(100,100),t=new c(s,!1,o)}catch(e){s=document.createElement("canvas"),t=new c(s,!1,o)}i.q.Instances.pop(),i.q.OnEnginesDisposedObservable.add((e=>{t&&e!==t&&!t.isDisposed&&0===i.q.Instances.length&&u()})),t.getCaps().parallelShaderCompile=void 0;const l=new r.J(t);a.e(71).then(a.bind(a,9820)).then((({passPixelShader:a})=>{if(!t)return void n("Engine is not defined");const i=new r.$({engine:t,name:a.name,fragmentShader:a.shader,samplerNames:["textureSampler"]});p={canvas:s,engine:t,renderer:l,wrapper:i},e(p)}))})).catch(n)}))),await o})().then((a=>{if(a.engine.setSize(e,n,!0),c instanceof Float32Array){const e=new Uint8Array(c.length);let n=c.length;for(;n--;){const a=c[n];e[n]=Math.round(255*(0,t.OQ)(a))}c=e}const r=a.engine.createRawTexture(c,e,n,5,!1,!f,1);a.renderer.setViewport(),a.renderer.applyEffectWrapper(a.wrapper),a.wrapper.effect._bindTexture("textureSampler",r),a.renderer.draw(),h?s.S0.ToBlob(a.canvas,(e=>{const n=new FileReader;n.onload=e=>{const n=e.target.result;l&&l(n)},n.readAsArrayBuffer(e)}),d,w):s.S0.EncodeScreenshotCanvasData(a.canvas,l,d,m,w),r.dispose()}))}function u(){p?(p.wrapper.dispose(),p.renderer.dispose(),p.engine.dispose()):o?.then((e=>{e.wrapper.dispose(),e.renderer.dispose(),e.engine.dispose()})),o=null,p=null}const m={DumpData:d,DumpDataAsync:l,DumpFramebuffer:c,Dispose:u};s.S0.DumpData=d,s.S0.DumpDataAsync=l,s.S0.DumpFramebuffer=c}}]); +(()=>{"use strict";var e,t,n,r={7198:(e,t,n)=>{n.d(t,{B:()=>r});const r="\n#ifndef SDEFDECLARATION\n#define SDEFDECLARATION\n#if NUM_BONE_INFLUENCERS>0 && defined(SDEF)\nattribute matricesSdefC: vec3f;attribute matricesSdefRW0: vec3f;attribute matricesSdefRW1: vec3f;fn rotationMatrixToQuaternion(matrix: mat3x3f)->vec4f {let trace: f32=matrix[0][0]+matrix[1][1]+matrix[2][2];var s: f32;var sqrtParam: f32;if (trace>0.0) {sqrtParam=trace+1.0;} else if (matrix[0][0]>matrix[1][1] && matrix[0][0]>matrix[2][2]) {sqrtParam=1.0+matrix[0][0]-matrix[1][1]-matrix[2][2];} else if (matrix[1][1]>matrix[2][2]) {sqrtParam=1.0+matrix[1][1]-matrix[0][0]-matrix[2][2];} else {sqrtParam=1.0+matrix[2][2]-matrix[0][0]-matrix[1][1];}\nlet sqrtValue: f32=sqrt(sqrtParam);if (trace>0.0) {s=0.5/sqrtValue;return vec4f(\n(matrix[1][2]-matrix[2][1])*s,\n(matrix[2][0]-matrix[0][2])*s,\n(matrix[0][1]-matrix[1][0])*s,\n0.25/s\n);} else if (matrix[0][0]>matrix[1][1] && matrix[0][0]>matrix[2][2]) {s=2.0*sqrtValue;return vec4f(\n0.25*s,\n(matrix[0][1]+matrix[1][0])/s,\n(matrix[2][0]+matrix[0][2])/s,\n(matrix[1][2]-matrix[2][1])/s\n);} else if (matrix[1][1]>matrix[2][2]) {s=2.0*sqrtValue;return vec4f(\n(matrix[0][1]+matrix[1][0])/s,\n0.25*s,\n(matrix[1][2]+matrix[2][1])/s,\n(matrix[2][0]-matrix[0][2])/s\n);} else {s=2.0*sqrtValue;return vec4f(\n(matrix[2][0]+matrix[0][2])/s,\n(matrix[1][2]+matrix[2][1])/s,\n0.25*s,\n(matrix[0][1]-matrix[1][0])/s\n);}}\nfn quaternionToRotationMatrix(q: vec4f)->mat3x3f {let xx: f32=q.x*q.x;let yy: f32=q.y*q.y;let zz: f32=q.z*q.z;let xy: f32=q.x*q.y;let zw: f32=q.z*q.w;let zx: f32=q.z*q.x;let yw: f32=q.y*q.w;let yz: f32=q.y*q.z;let xw: f32=q.x*q.w;return mat3x3f(\n1.0-2.0*(yy+zz),2.0*(xy+zw),2.0*(zx-yw),\n2.0*(xy-zw),1.0-2.0*(zz+xx),2.0*(yz+xw),\n2.0*(zx+yw),2.0*(yz-xw),1.0-2.0*(yy+xx)\n);}\nfn slerp(q0: vec4f,_q1: vec4f,t: f32)->vec4f {var q1: vec4f=_q1;var cosTheta: f32=dot(q0,q1);q1=mix(-q1,q1,step(0.0,cosTheta));cosTheta=abs(cosTheta);if (cosTheta>0.999999) {return normalize(mix(q0,q1,t));}\nvar theta: f32=acos(cosTheta);var sinTheta: f32=sin(theta);var w0: f32=sin((1.0-t)*theta)/sinTheta;var w1: f32=sin(t*theta)/sinTheta;return q0*w0+q1*w1;}\n#endif\n#endif\n"},4122:(e,t,n)=>{n.d(t,{Z:()=>r});const r="\n#ifndef SDEFVERTEX\n#define SDEFVERTEX\n#if !defined(BAKED_VERTEX_ANIMATION_TEXTURE) && defined(SDEF)\n#if NUM_BONE_INFLUENCERS>0\n{let weight0: f32=vertexInputs.matricesWeights[0];let weight1: f32=vertexInputs.matricesWeights[1];\n#ifdef BONETEXTURE\nlet transformMatrix0: mat4x4f=readMatrixFromRawSampler(boneSampler,vertexInputs.matricesIndices[0]);let transformMatrix1: mat4x4f=readMatrixFromRawSampler(boneSampler,vertexInputs.matricesIndices[1]);\n#else\nlet transformMatrix0: mat4x4f=uniforms.mBones[int(vertexInputs.matricesIndices[0])];let transformMatrix1: mat4x4f=uniforms.mBones[int(vertexInputs.matricesIndices[1])];\n#endif\nlet slerpedRotationMatrix: mat3x3f=quaternionToRotationMatrix(slerp(\nrotationMatrixToQuaternion(mat3x3f(transformMatrix0[0].xyz,transformMatrix0[1].xyz,transformMatrix0[2].xyz)),\nrotationMatrixToQuaternion(mat3x3f(transformMatrix1[0].xyz,transformMatrix1[1].xyz,transformMatrix1[2].xyz)),\nweight1\n));var sdefInflunce: mat4x4f=mat4x4f(\nvec4f(1.0,0.0,0.0,0.0),\nvec4f(0.0,1.0,0.0,0.0),\nvec4f(0.0,0.0,1.0,0.0),\nvec4f(-vertexInputs.matricesSdefC,1.0)\n);let rotationMatrix: mat4x4f=mat4x4f(\nvec4f(slerpedRotationMatrix[0],0.0),\nvec4f(slerpedRotationMatrix[1],0.0),\nvec4f(slerpedRotationMatrix[2],0.0),\nvec4f(0.0,0.0,0.0,1.0)\n);sdefInflunce=rotationMatrix*sdefInflunce;let positionOffset: vec3f =\n(transformMatrix0*vec4f(vertexInputs.matricesSdefRW0,1)).xyz*weight0 +\n(transformMatrix1*vec4f(vertexInputs.matricesSdefRW1,1)).xyz*weight1;sdefInflunce[3]+=vec4f(positionOffset,0.0);let useLinearDeform: f32=step(0.0,-abs(vertexInputs.matricesSdefRW0.x));influence=mat4x4f(\nmix(sdefInflunce[0],influence[0],useLinearDeform),\nmix(sdefInflunce[1],influence[1],useLinearDeform),\nmix(sdefInflunce[2],influence[2],useLinearDeform),\nmix(sdefInflunce[3],influence[3],useLinearDeform)\n);}\n#endif\n#endif\n#endif\n"},9339:(e,t,n)=>{n.d(t,{B:()=>r});const r="\n#ifndef SDEFDECLARATION\n#define SDEFDECLARATION\n#if NUM_BONE_INFLUENCERS>0 && defined(SDEF)\nattribute vec3 matricesSdefC;attribute vec3 matricesSdefRW0;attribute vec3 matricesSdefRW1;vec4 rotationMatrixToQuaternion(mat3 matrix) {float trace=matrix[0][0]+matrix[1][1]+matrix[2][2];float s;float sqrtParam;if (trace>0.0) {sqrtParam=trace+1.0;} else if (matrix[0][0]>matrix[1][1] && matrix[0][0]>matrix[2][2]) {sqrtParam=1.0+matrix[0][0]-matrix[1][1]-matrix[2][2];} else if (matrix[1][1]>matrix[2][2]) {sqrtParam=1.0+matrix[1][1]-matrix[0][0]-matrix[2][2];} else {sqrtParam=1.0+matrix[2][2]-matrix[0][0]-matrix[1][1];}\nfloat sqrtValue=sqrt(sqrtParam);if (trace>0.0) {s=0.5/sqrtValue;return vec4(\n(matrix[1][2]-matrix[2][1])*s,\n(matrix[2][0]-matrix[0][2])*s,\n(matrix[0][1]-matrix[1][0])*s,\n0.25/s\n);} else if (matrix[0][0]>matrix[1][1] && matrix[0][0]>matrix[2][2]) {s=2.0*sqrtValue;return vec4(\n0.25*s,\n(matrix[0][1]+matrix[1][0])/s,\n(matrix[2][0]+matrix[0][2])/s,\n(matrix[1][2]-matrix[2][1])/s\n);} else if (matrix[1][1]>matrix[2][2]) {s=2.0*sqrtValue;return vec4(\n(matrix[0][1]+matrix[1][0])/s,\n0.25*s,\n(matrix[1][2]+matrix[2][1])/s,\n(matrix[2][0]-matrix[0][2])/s\n);} else {s=2.0*sqrtValue;return vec4(\n(matrix[2][0]+matrix[0][2])/s,\n(matrix[1][2]+matrix[2][1])/s,\n0.25*s,\n(matrix[0][1]-matrix[1][0])/s\n);}}\nmat3 quaternionToRotationMatrix(vec4 q) {float xx=q.x*q.x;float yy=q.y*q.y;float zz=q.z*q.z;float xy=q.x*q.y;float zw=q.z*q.w;float zx=q.z*q.x;float yw=q.y*q.w;float yz=q.y*q.z;float xw=q.x*q.w;return mat3(\n1.0-2.0*(yy+zz),2.0*(xy+zw),2.0*(zx-yw),\n2.0*(xy-zw),1.0-2.0*(zz+xx),2.0*(yz+xw),\n2.0*(zx+yw),2.0*(yz-xw),1.0-2.0*(yy+xx)\n);}\nvec4 slerp(vec4 q0,vec4 q1,float t) {float cosTheta=dot(q0,q1);q1=mix(-q1,q1,step(0.0,cosTheta));cosTheta=abs(cosTheta);if (cosTheta>0.999999) {return normalize(mix(q0,q1,t));}\nfloat theta=acos(cosTheta);float sinTheta=sin(theta);float w0=sin((1.0-t)*theta)/sinTheta;float w1=sin(t*theta)/sinTheta;return q0*w0+q1*w1;}\n#endif\n#endif\n"},5041:(e,t,n)=>{n.d(t,{Z:()=>r});const r="\n#ifndef SDEFVERTEX\n#define SDEFVERTEX\n#if !defined(BAKED_VERTEX_ANIMATION_TEXTURE) && defined(SDEF)\n#if NUM_BONE_INFLUENCERS>0\n{float weight0=matricesWeights[0];float weight1=matricesWeights[1];\n#ifdef BONETEXTURE\nmat4 transformMatrix0=readMatrixFromRawSampler(boneSampler,matricesIndices[0]);mat4 transformMatrix1=readMatrixFromRawSampler(boneSampler,matricesIndices[1]);\n#else\nmat4 transformMatrix0=mBones[int(matricesIndices[0])];mat4 transformMatrix1=mBones[int(matricesIndices[1])];\n#endif\nmat3 slerpedRotationMatrix=quaternionToRotationMatrix(slerp(\nrotationMatrixToQuaternion(mat3(transformMatrix0)),\nrotationMatrixToQuaternion(mat3(transformMatrix1)),\nweight1\n));mat4 sdefInflunce=mat4(\nvec4(1.0,0.0,0.0,0.0),\nvec4(0.0,1.0,0.0,0.0),\nvec4(0.0,0.0,1.0,0.0),\nvec4(-matricesSdefC,1.0)\n);mat4 rotationMatrix=mat4(\nvec4(slerpedRotationMatrix[0],0.0),\nvec4(slerpedRotationMatrix[1],0.0),\nvec4(slerpedRotationMatrix[2],0.0),\nvec4(0.0,0.0,0.0,1.0)\n);sdefInflunce=rotationMatrix*sdefInflunce;vec3 positionOffset =\nvec3(transformMatrix0*vec4(matricesSdefRW0,1))*weight0 +\nvec3(transformMatrix1*vec4(matricesSdefRW1,1))*weight1;sdefInflunce[3]+=vec4(positionOffset,0.0);float useLinearDeform=step(0.0,-abs(matricesSdefRW0.x));influence=mat4(\nmix(sdefInflunce[0],influence[0],useLinearDeform),\nmix(sdefInflunce[1],influence[1],useLinearDeform),\nmix(sdefInflunce[2],influence[2],useLinearDeform),\nmix(sdefInflunce[3],influence[3],useLinearDeform)\n);}\n#endif\n#endif\n#endif\n"},3036:(e,t,n)=>{n.d(t,{V:()=>r});class r{static AdditionalUV1Kind="additionalUv1";static AdditionalUV2Kind="additionalUv2";static AdditionalUV3Kind="additionalUv3";static AdditionalUV4Kind="additionalUv4";static MatricesSdefCKind="matricesSdefC";static MatricesSdefRW0Kind="matricesSdefRW0";static MatricesSdefRW1Kind="matricesSdefRW1";static MatricesSdefR0Kind="matricesSdefR0";static MatricesSdefR1Kind="matricesSdefR1";static EdgeScaleKind="edgeScale"}},426:(e,t,n)=>{n.d(t,{ZL:()=>p,rw:()=>r});var r,i=n(6125),s=n(9526),o=n(2277),a=n(6041),l=n(9259),d=n(6552),h=n(3036),c=function(e,t,n,r){var i,s=arguments.length,o=s<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(o=(s<3?i(o):s>3?i(t,n,o):i(t,n))||o);return s>3&&o&&Object.defineProperty(t,n,o),o};class u extends s.M{SPHERE_TEXTURE=!1;SPHERE_TEXTURE_BLEND_MODE_MULTIPLY=!1;SPHERE_TEXTURE_BLEND_MODE_ADD=!1;TOON_TEXTURE=!1;IGNORE_DIFFUSE_WHEN_TOON_TEXTURE_DISABLED=!1;APPLY_AMBIENT_COLOR_TO_DIFFUSE=!1;CLAMP_ALPHA=!1;TEXTURE_COLOR=!1;SPHERE_TEXTURE_COLOR=!1;TOON_TEXTURE_COLOR=!1;SDEF=!1}!function(e){e[e.Multiply=1]="Multiply",e[e.Add=2]="Add",e[e.SubTexture=3]="SubTexture"}(r||(r={}));class p extends o.y{_sphereTexture=null;_sphereTextureBlendMode=r.Add;_toonTexture=null;_ignoreDiffuseWhenToonTextureIsNull=!1;textureMultiplicativeColor=new a.ov(1,1,1,1);textureAdditiveColor=new a.ov(0,0,0,0);sphereTextureMultiplicativeColor=new a.ov(1,1,1,1);sphereTextureAdditiveColor=new a.ov(0,0,0,0);toonTextureMultiplicativeColor=new a.ov(1,1,1,1);toonTextureAdditiveColor=new a.ov(0,0,0,0);_applyAmbientColorToDiffuse=!0;_clampAlpha=!0;_useTextureColor=!1;_useSphereTextureColor=!1;_useToonTextureColor=!1;_isEnabled=!1;get isEnabled(){return this._isEnabled}set isEnabled(e){this._isEnabled!==e&&(this._isEnabled=e,this.markAllDefinesAsDirty(),this._enable(e))}get sphereTexture(){return this._sphereTexture}set sphereTexture(e){this._sphereTexture!==e&&(this._sphereTexture=e,this._markAllSubMeshesAsTexturesDirty())}get sphereTextureBlendMode(){return this._sphereTextureBlendMode}set sphereTextureBlendMode(e){this._sphereTextureBlendMode!==e&&(this._sphereTextureBlendMode=e,this.markAllDefinesAsDirty())}get toonTexture(){return this._toonTexture}set toonTexture(e){this._toonTexture!==e&&(this._toonTexture=e,this._markAllSubMeshesAsTexturesDirty())}get ignoreDiffuseWhenToonTextureIsNull(){return this._ignoreDiffuseWhenToonTextureIsNull}set ignoreDiffuseWhenToonTextureIsNull(e){this._ignoreDiffuseWhenToonTextureIsNull!==e&&(this._ignoreDiffuseWhenToonTextureIsNull=e,this.markAllDefinesAsDirty())}get applyAmbientColorToDiffuse(){return this._applyAmbientColorToDiffuse}set applyAmbientColorToDiffuse(e){this._applyAmbientColorToDiffuse!==e&&(this._applyAmbientColorToDiffuse=e,this.markAllDefinesAsDirty())}get clampAlpha(){return this._clampAlpha}set clampAlpha(e){this._clampAlpha!==e&&(this._clampAlpha=e,this.markAllDefinesAsDirty())}get useTextureColor(){return this._useTextureColor}set useTextureColor(e){this._useTextureColor!==e&&(this._useTextureColor=e,this.markAllDefinesAsDirty())}get useSphereTextureColor(){return this._useSphereTextureColor}set useSphereTextureColor(e){this._useSphereTextureColor!==e&&(this._useSphereTextureColor=e,this.markAllDefinesAsDirty())}get useToonTextureColor(){return this._useToonTextureColor}set useToonTextureColor(e){this._useToonTextureColor!==e&&(this._useToonTextureColor=e,this.markAllDefinesAsDirty())}_internalMarkAllSubMeshesAsTexturesDirty;_markAllSubMeshesAsTexturesDirty(){this._enable(this._isEnabled),this._internalMarkAllSubMeshesAsTexturesDirty()}isCompatible(e){return!0}constructor(e,t=!0,n=!1,r=!1){super(e,"MmdMaterial",100,new u,t,n,r),this._internalMarkAllSubMeshesAsTexturesDirty=e._dirtyCallbacks[i.Y.MATERIAL_TextureDirtyFlag]}isReadyForSubMesh(e,t){return!this._isEnabled||!(e._areTexturesDirty&&t.texturesEnabled&&this._sphereTexture&&!this._sphereTexture.isReadyOrNotBlocking())}bindForSubMesh(e,t,n,r){if(!this._isEnabled)return;const i=r.materialDefines,s=this._material.isFrozen;e.useUbo&&s&&e.isSync||(i.DIFFUSE&&i.TEXTURE_COLOR&&(e.updateDirectColor4("textureMultiplicativeColor",this.textureMultiplicativeColor),e.updateDirectColor4("textureAdditiveColor",this.textureAdditiveColor)),i.NORMAL&&i.SPHERE_TEXTURE&&i.SPHERE_TEXTURE_COLOR&&(e.updateDirectColor4("sphereTextureMultiplicativeColor",this.sphereTextureMultiplicativeColor),e.updateDirectColor4("sphereTextureAdditiveColor",this.sphereTextureAdditiveColor)),i.TOON_TEXTURE&&i.TOON_TEXTURE_COLOR&&(e.updateDirectColor4("toonTextureMultiplicativeColor",this.toonTextureMultiplicativeColor),e.updateDirectColor4("toonTextureAdditiveColor",this.toonTextureAdditiveColor)),i.SPHERE_TEXTURE&&null!==r.effect&&this._material.bindView(r.effect)),t.texturesEnabled&&(i.NORMAL&&this._sphereTexture&&e.setTexture("sphereSampler",this._sphereTexture),this._toonTexture&&e.setTexture("toonSampler",this._toonTexture))}dispose(e){e&&(this._sphereTexture?.dispose(),this._toonTexture?.dispose())}prepareDefines(e,t,n){if(this._isEnabled){const i=t.texturesEnabled;e.SPHERE_TEXTURE=null!==this._sphereTexture&&i,e.SPHERE_TEXTURE_BLEND_MODE_MULTIPLY=this._sphereTextureBlendMode===r.Multiply,e.SPHERE_TEXTURE_BLEND_MODE_ADD=this._sphereTextureBlendMode===r.Add,e.TOON_TEXTURE=null!==this._toonTexture&&i,e.IGNORE_DIFFUSE_WHEN_TOON_TEXTURE_DISABLED=this._ignoreDiffuseWhenToonTextureIsNull,e.APPLY_AMBIENT_COLOR_TO_DIFFUSE=this._applyAmbientColorToDiffuse,e.CLAMP_ALPHA=this._clampAlpha,e.TEXTURE_COLOR=this._useTextureColor,e.SPHERE_TEXTURE_COLOR=this._useSphereTextureColor,e.TOON_TEXTURE_COLOR=this._useToonTextureColor,e.SDEF=n.useBones&&n.computeBonesUsingShaders&&!!n.skeleton&&n.isVerticesDataPresent(h.V.MatricesSdefCKind)}else e.SPHERE_TEXTURE=!1,e.SPHERE_TEXTURE_BLEND_MODE_MULTIPLY=!1,e.SPHERE_TEXTURE_BLEND_MODE_ADD=!1,e.TOON_TEXTURE=!1,e.IGNORE_DIFFUSE_WHEN_TOON_TEXTURE_DISABLED=!1,e.APPLY_AMBIENT_COLOR_TO_DIFFUSE=!1,e.CLAMP_ALPHA=!1,e.TEXTURE_COLOR=!1,e.SPHERE_TEXTURE_COLOR=!1,e.TOON_TEXTURE_COLOR=!1,e.SDEF=!1}hasTexture(e){return this._sphereTexture===e||this._toonTexture===e}getActiveTextures(e){this._sphereTexture&&e.push(this._sphereTexture),this._toonTexture&&e.push(this._toonTexture)}getAnimatables(e){this._sphereTexture&&this._sphereTexture.animations&&0{var r=n(3720);class i{_canvas;_engine;_scene;_onTick;constructor(e){this._canvas=e.canvas,this._engine=e.engine,this._scene=null,this._onTick=null}static async Create(e){const t=new i(e);return t._scene=await t._initialize(e.sceneBuilder),t._onTick=t._makeOnTick(),t}run(){const e=this._engine;window.addEventListener("resize",this._onResize),e.runRenderLoop(this._onTick)}dispose(){window.removeEventListener("resize",this._onResize),this._engine.dispose()}_onResize=()=>{this._engine.resize()};async _initialize(e){return await e.build(this._canvas,this._engine)}_makeOnTick(){const e=this._scene;return()=>e.render()}}n(9679),n(9400),n(994),n(1318);var s=n(5616),o=n(6125),a=n(492),l=n(5476),d=n(2565),h=n(467),c=n(5662),u=n(9923),p=n(554),g=n(6945),f=n(3036),m=n(9339),x=n(5041),y=n(7198),A=n(4122);class T{static OverrideEngineCreateEffect(e){const t=e.createEffect.bind(e);e.createEffect=function(e,n,r,i,s,o,a,l,d,h=c.w.GLSL,u){let p;if(p=n.attributes?n:{attributes:n,uniformsNames:r,uniformBuffersNames:[],samplers:i??[],defines:s??"",fallbacks:o??null,onCompiled:a??null,onError:l??null,indexParameters:d??null,shaderLanguage:h,extraInitializationsAsync:u},(p.uniformsNames.includes("mBones")||p.samplers.includes("boneSampler"))&&-1===p.defines.indexOf("#define SDEF")){p.attributes.push(f.V.MatricesSdefCKind),p.attributes.push(f.V.MatricesSdefRW0Kind),p.attributes.push(f.V.MatricesSdefRW1Kind),p.defines+="\n#define SDEF";const e=p.processCodeAfterIncludes;p.processCodeAfterIncludes=e?function(t,n){return n=e(t,n),T.ProcessSdefCode(t,n)}:T.ProcessSdefCode}return t(e,p,this)}}static ProcessSdefCode(e,t){if("vertex"!==e)return t;if(t.includes("finalWorld=finalWorld*influence;")){const e=t.includes("fn main"),n="#define CUSTOM_VERTEX_DEFINITIONS";if(t.includes(n))t=t.replace(n,`${n}\n${e?y.B:m.B}`);else{const n="void main() {";t=t.replace(n,`${e?y.B:m.B}\nvoid main() {`)}const r=new RegExp("finalWorld=finalWorld\\*influence;","g");t=t.replace(r,`${e?A.Z:x.Z}\nfinalWorld=finalWorld*influence;`)}return t}}p.Z.prototype.getMmdOutlineRenderer=function(){return this._mmdOutlineRenderer||(this._mmdOutlineRenderer=new M(this)),this._mmdOutlineRenderer};class M{name="MmdOutline";scene;zOffset=4;zOffsetUnits=0;_engine;_passIdForDrawWrapper;constructor(e){this.scene=e,this._engine=e.getEngine(),this.scene._addComponent(this),this._passIdForDrawWrapper=this._engine.createRenderPassId("Mmd Outline Renderer")}register(){this.scene._afterRenderingMeshStage.registerStep(g.v.STEP_AFTERRENDERINGMESH_OUTLINE,this,this._afterRenderingMesh)}rebuild(){}dispose(){this._engine.releaseRenderPassId(this._passIdForDrawWrapper)}static _ViewMatrix=new Float32Array(9);static _InverseViewProjectionMatrix=new u.uq;render(e,t,n){n=n??this._passIdForDrawWrapper;const r=this.scene,i=r.getEngine(),s=i.getCaps().instancedArrays&&(null!==t.visibleInstances[e._id]&&void 0!==t.visibleInstances[e._id]||e.getRenderingMesh().hasThinInstances);if(!this.isReady(e,s,n))return;const o=e.getMesh(),d=o._internalAbstractMeshDataInfo._actAsRegularMesh?o:null,c=e.getRenderingMesh(),u=d||c,p=e.getMaterial();if(!p||!r.activeCamera)return;const g=e._getDrawWrapper(n),f=l.E.GetEffect(g);i.enableEffect(g),p.useLogarithmicDepth&&f.setFloat("logarithmicDepthConstant",2/(Math.log(r.activeCamera.maxZ+1)/Math.LN2)),f.setFloat("offset",p.outlineWidth),f.setColor4("color",p.outlineColor,p.outlineAlpha);const m=i.getRenderHeight(),x=i.getRenderWidth();f.setFloat2("viewport",x,m);const y=M._ViewMatrix;{const e=r.getViewMatrix().m;y[0]=e[0],y[1]=e[1],y[2]=e[2],y[3]=e[4],y[4]=e[5],y[5]=e[6],y[6]=e[8],y[7]=e[9],y[8]=e[10]}f.setMatrix3x3("view",y),f.setMatrix("viewProjection",r.getTransformMatrix()),f.setMatrix("world",u.getWorldMatrix()),(0,h.f$)(c,f),(0,h.nR)(c,f),c.morphTargetManager&&c.morphTargetManager.isUsingTextureForTargets&&c.morphTargetManager._bind(f),s||c._bind(e,f,p.fillMode);const A=e.getMesh().bakedVertexAnimationManager;if(A&&A.isEnabled&&A.bind(f,s),p&&p.needAlphaTesting()){const e=p.getAlphaTestTexture();e&&(f.setTexture("diffuseSampler",e),f.setMatrix("diffuseMatrix",e.getTextureMatrix()))}(0,a.gS)(f,p,r),f.defines.includes("WORLDPOS_REQUIRED")&&f.setMatrix("inverseViewProjection",r.getTransformMatrix().invertToRef(M._InverseViewProjectionMatrix)),i.setZOffset(this.zOffset),i.setZOffsetUnits(this.zOffsetUnits),c._processRendering(u,e,f,p.fillMode,t,s,((e,t)=>{f.setMatrix("world",t)})),i.setZOffset(0),i.setZOffsetUnits(0)}isReady(e,t,r){r=r??this._passIdForDrawWrapper;const i=[],o=[s.R.PositionKind,s.R.NormalKind],l=e.getMesh(),u=e.getMaterial();if(!u)return!1;const p=l.getScene();u.needAlphaTesting()&&(i.push("#define ALPHATEST"),l.isVerticesDataPresent(s.R.UVKind)&&(o.push(s.R.UVKind),i.push("#define UV1")),l.isVerticesDataPresent(s.R.UV2Kind)&&(o.push(s.R.UV2Kind),i.push("#define UV2"))),u.useLogarithmicDepth&&i.push("#define LOGARITHMICDEPTH"),(0,a.tv)(u,p,i);let g=!1;for(let e=0;e4&&(o.push(s.R.MatricesIndicesExtraKind),o.push(s.R.MatricesWeightsExtraKind)),l.isVerticesDataPresent(f.V.MatricesSdefCKind)&&(o.push(f.V.MatricesSdefCKind),o.push(f.V.MatricesSdefRW0Kind),o.push(f.V.MatricesSdefRW1Kind),i.push("#define SDEF"));const e=l.skeleton;i.push("#define NUM_BONE_INFLUENCERS "+l.numBoneInfluencers),l.numBoneInfluencers>0&&m.addCPUSkinningFallback(0,l),e.isUsingTextureForMatrices?i.push("#define BONETEXTURE"):i.push("#define BonesPerMesh "+(e.bones.length+1))}else i.push("#define NUM_BONE_INFLUENCERS 0");const x=l.morphTargetManager;let y=0;x&&(y=x.numMaxInfluencers||x.numInfluencers,y>0&&(i.push("#define MORPHTARGETS"),i.push("#define NUM_MORPH_INFLUENCERS "+y),x.isUsingTextureForTargets&&i.push("#define MORPHTARGETS_TEXTURE"),(0,h.MF)(o,l,y))),t&&(i.push("#define INSTANCES"),(0,h.te)(o),e.getRenderingMesh().hasThinInstances&&i.push("#define THIN_INSTANCES"));const A=l.bakedVertexAnimationManager;A&&A.isEnabled&&(i.push("#define BAKED_VERTEX_ANIMATION_TEXTURE"),t&&o.push("bakedVertexAnimationSettingsInstanced"));const M=e._getDrawWrapper(r,!0),_=M.defines,b=i.join("\n");if(_!==b){const e=["world","mBones","viewport","view","viewProjection","diffuseMatrix","offset","color","logarithmicDepthConstant","morphTargetInfluences","boneTextureWidth","morphTargetCount","morphTargetTextureInfo","morphTargetTextureIndices","bakedVertexAnimationSettings","bakedVertexAnimationTextureSizeInverted","bakedVertexAnimationTime","bakedVertexAnimationTexture"],t=["diffuseSampler","boneSampler","morphTargets","bakedVertexAnimationTexture"];(0,a.TV)(e),g&&e.push("inverseViewProjection");const r=p.getEngine().isWebGPU?c.w.WGSL:c.w.GLSL;M.setEffect(this.scene.getEngine().createEffect("mmdOutline",{attributes:o,uniformsNames:e,uniformBuffersNames:[],samplers:t,defines:b,fallbacks:m,onCompiled:null,onError:null,indexParameters:{maxSimultaneousMorphTargets:y},processCodeAfterIncludes:T.ProcessSdefCode,shaderLanguage:r,extraInitializationsAsync:async()=>{r===c.w.WGSL?await Promise.all([n.e(126).then(n.bind(n,8980)),n.e(126).then(n.bind(n,1870))]):await Promise.all([n.e(71).then(n.bind(n,3357)),n.e(71).then(n.bind(n,5043))])}},this.scene.getEngine()),b)}return M.effect.isReady()}_afterRenderingMesh(e,t,n){const r=t.getMaterial();if(null!==r&&r.renderOutline){const e=this._engine,r=e.getDepthWrite(),i=e.getAlphaMode(),s=e.alphaState.alphaBlend;e.setDepthWrite(!0),e.setAlphaMode(o.Y.ALPHA_COMBINE,!0),e.setState(!0,void 0,void 0,void 0,!!this.scene._mirroredCameraPosition),this.render(t,n,this._passIdForDrawWrapper),e.setAlphaMode(i,!0),e.setDepthWrite(r),e.alphaState.alphaBlend=s}}}var _,b,I=n(5909);class v{log(e){console.log(e)}warn(e){console.warn(e)}error(e){console.error(e)}}class w{isDeviceLittleEndian;_dataView;_decoder;_offset;constructor(e){this.isDeviceLittleEndian=this._getIsDeviceLittleEndian(),this._dataView=new DataView(e),this._decoder=null,this._offset=0}get offset(){return this._offset}set offset(e){this._offset=e}_getIsDeviceLittleEndian(){const e=new Int16Array([256]);return 1===new Int8Array(e.buffer)[1]}swap16Array(e){for(let t=0;t>8&255}}swap32Array(e){for(let t=0;t>8&65280|n>>24&255}}getUint8(){const e=this._dataView.getUint8(this._offset);return this._offset+=1,e}getInt8(){const e=this._dataView.getInt8(this._offset);return this._offset+=1,e}getUint8Array(e){const t=new Uint8Array(this._dataView.buffer,this._offset,e.byteLength);e.set(t),this._offset+=e.byteLength}getUint16(){const e=this._dataView.getUint16(this._offset,!0);return this._offset+=2,e}getUint16Array(e){const t=new Uint8Array(this._dataView.buffer,this._offset,e.byteLength);new Uint8Array(e.buffer,e.byteOffset,e.byteLength).set(t),this._offset+=e.byteLength,this.isDeviceLittleEndian||this.swap16Array(e)}getInt16(){const e=this._dataView.getInt16(this._offset,!0);return this._offset+=2,e}getUint32(){const e=this._dataView.getUint32(this._offset,!0);return this._offset+=4,e}getUint32Array(e){const t=new Uint8Array(this._dataView.buffer,this._offset,e.byteLength);new Uint8Array(e.buffer,e.byteOffset,e.byteLength).set(t),this._offset+=e.byteLength,this.isDeviceLittleEndian||this.swap32Array(e)}getInt32(){const e=this._dataView.getInt32(this._offset,!0);return this._offset+=4,e}getInt32Array(e){const t=new Uint8Array(this._dataView.buffer,this._offset,e.byteLength);new Uint8Array(e.buffer,e.byteOffset,e.byteLength).set(t),this._offset+=e.byteLength,this.isDeviceLittleEndian||this.swap32Array(e)}getFloat32(){const e=this._dataView.getFloat32(this._offset,!0);return this._offset+=4,e}getFloat32Array(e){const t=new Uint8Array(this._dataView.buffer,this._offset,e.byteLength);new Uint8Array(e.buffer,e.byteOffset,e.byteLength).set(t),this._offset+=e.byteLength,this.isDeviceLittleEndian||this.swap32Array(e)}getFloat32Tuple(e){const t=new Array(e);for(let n=0;n0&&t.warn(`There are ${n.bytesAvailable} bytes left after parsing`),{header:r,vertices:i,indices:s,textures:u,materials:p,bones:f,morphs:d,displayFrames:h,rigidBodies:g,joints:m,softBodies:[]}}static _ParseHeader(e){if(e.bytesAvailable<7)throw new Error("is not pmd file");const t=e.getSignatureString(3);if("Pmd"!==t)throw new Error("is not pmd file");const n=e.getFloat32(),r=e.getDecoderString(20,!0),i=e.getDecoderString(256,!0);return{signature:t,version:n,encoding:b.Header.Encoding.ShiftJis,additionalVec4Count:0,vertexIndexSize:2,textureIndexSize:4,materialIndexSize:4,boneIndexSize:2,morphIndexSize:2,rigidBodyIndexSize:4,modelName:r,englishModelName:"",comment:i,englishComment:""}}static async _ParseVerticesAsync(e){const t=e.getUint32(),n=[];let r=performance.now();for(let i=0;isetTimeout(e,0))),r=performance.now())}return n}static _ParseIndices(e){const t=e.getUint32(),n=new Uint16Array(t);return e.getUint16Array(n),n}static _ParseMaterials(e){const t=e.getUint32(),n=[];for(let r=0;rd[e+1][1]){h=!1;break}if(!h){d.sort(((e,t)=>e[1]-t[1]));const e=new Array(d.length);for(let t=1;td[t][0]||void 0!==e[t-1])&&(n=!1),n||(e[t]=o[d[t-1][0]])}const t=new Map;for(let n=0;n{this._createTexture(t,n,i,e,o,a,((e,t)=>{l?.(e,t)}),d)}),void 0,!0,!0,((e,t)=>{l?.(e?e.status+" "+e.statusText:"",t)}))}loadFromArrayBuffer(e){this._createTexture(this._scene,this._assetContainer,this._textureName,e,this._options,this._onLoad,((e,t)=>{this._onError?.(e,t)}),this._forcedExtension)}_onDisposeCallback=null;registerOnDisposeCallback(e){this._onDisposeCallback=e,this._texture.onDisposeObservable.addOnce(e)}unregisterOnDisposeCallback(){const e=this._onDisposeCallback;return null===e?null:(this._onDisposeCallback=null,this._texture.onDisposeObservable.removeCallback(e),e)}_createTexture(e,t,n,r,i,s,o,a){e._blockEntityCollection=!!t;const l={noMipmap:i.noMipmap,invertY:i.invertY,samplingMode:i.samplingMode,onLoad:()=>{null===this._texture?null!==s&&K._.SetImmediate(s):s?.()},onError:o,buffer:r,deleteBuffer:i.deleteBuffer,format:i.format,mimeType:i.mimeType,forcedExtension:a},d=this._texture=new W.g("data:"+n,e,l);d._parentContainer=t,e._blockEntityCollection=!1,t?.textures.push(d),d.name=n}get texture(){return this._texture}}class j{onModelTextureLoadedObservable=new Map;textureCache=new Map;_textureLoadInfoMap=new Map;_loadingModels=new Map;_errorTexturesReferenceCount=new Map;_incrementLeftLoadCount(e){let t=this._loadingModels.get(e);void 0===t&&(t=new Q(e),this._loadingModels.set(e,t)),t.leftLoadCount+=1;let n=this.onModelTextureLoadedObservable.get(e);return void 0===n&&(n=new q.cP,this.onModelTextureLoadedObservable.set(e,n)),t}_decrementLeftLoadCount(e){if(e.leftLoadCount-=1,!e.isRequesting&&0===e.leftLoadCount){this._removeErrorTexturesReferenceCount(e.uniqueId),this._loadingModels.delete(e.uniqueId);const t=this.onModelTextureLoadedObservable.get(e.uniqueId);t?.notifyObservers(),t?.clear(),this.onModelTextureLoadedObservable.delete(e.uniqueId)}}loadModelTexturesEnd(e){const t=this._loadingModels.get(e);if(void 0!==t&&(t.isRequesting=!1,0===t.leftLoadCount)){this._removeErrorTexturesReferenceCount(e),this._loadingModels.delete(e);const t=this.onModelTextureLoadedObservable.get(e);t?.notifyObservers(),t?.clear(),this.onModelTextureLoadedObservable.delete(e)}}_addErrorTextureReferenceCount(e,t){this._loadingModels.get(e).errorTextureDatas.push(t),this._errorTexturesReferenceCount.set(t,(this._errorTexturesReferenceCount.get(t)??0)+1)}_removeErrorTexturesReferenceCount(e){const t=this._loadingModels.get(e);for(let e=0;e{this._textureLoadInfoMap.delete(e.cacheKey),this.textureCache.delete(e.cacheKey),this._errorTexturesReferenceCount.delete(e)}))}_createTextureCacheKey(e,t){const n=e.lastIndexOf(".");let r="";return-1!==n&&(r=e.substring(n),e=e.substring(0,n)),e+ +(t.noMipmap??!1)+ +(t.invertY??!0)+(t.samplingMode??W.g.TRILINEAR_SAMPLINGMODE)+(t.format??o.Y.TEXTUREFORMAT_RGBA)+r}async _loadTextureAsyncInternal(e,t,n,r,i,s,o){const a=this._incrementLeftLoadCount(e),l=this._createTextureCacheKey(t,o);let d=this._textureLoadInfoMap.get(l);void 0===d&&(d=new X,this._textureLoadInfoMap.set(l,d));let h=this.textureCache.get(l);if(void 0===h&&!d.hasLoadError){const a=null!==r?H.Data[r]:t;h=new Y(l,i,s,a,t,null!==n,o,(()=>{this._handleTextureOnDispose(h),d.hasLoadError=!1,d.observable.notifyObservers(!1),d.observable.clear()}),((t,n)=>{null!==h.texture&&this._handleTextureOnDispose(h),this._addErrorTextureReferenceCount(e,h),d.hasLoadError=!0,d.observable.notifyObservers(!0),d.observable.clear()}),o.forcedExtension),this.textureCache.set(l,h);const c=n instanceof Blob?await n.arrayBuffer():n;null!==c&&h.loadFromArrayBuffer(c)}return null!==h.texture&&h.texture.isReady()?(this._decrementLeftLoadCount(a),d.hasLoadError?null:h.texture):new Promise((e=>{d.observable.addOnce((t=>{this._decrementLeftLoadCount(a),e(t?null:h.texture)}))}))}async loadTextureAsync(e,t,n,r,i,s){let o;"number"==typeof n?((n<-1||9=0;a--)(i=e[a])&&(o=(s<3?i(o):s>3?i(t,n,o):i(t,n))||o);return s>3&&o&&Object.defineProperty(t,n,o),o};class re{isMock=!0;sphereTexture=null;sphereTextureBlendMode=te.rw.Add;toonTexture=null;ignoreDiffuseWhenToonTextureIsNull=!1;applyAmbientColorToDiffuse=!0;clampAlpha=!0;textureMultiplicativeColor=new z.ov(1,1,1,1);textureAdditiveColor=new z.ov(0,0,0,0);sphereTextureMultiplicativeColor=new z.ov(1,1,1,1);sphereTextureAdditiveColor=new z.ov(0,0,0,0);toonTextureMultiplicativeColor=new z.ov(1,1,1,1);toonTextureAdditiveColor=new z.ov(0,0,0,0);useTextureColor=!1;useSphereTextureColor=!1;useToonTextureColor=!1}class ie extends $.F{_pluginMaterial;_renderOutline=!1;outlineWidth=.01;outlineColor=new z.v9(0,0,0);outlineAlpha=1;_disposed=!1;constructor(e,t,n=!1){super(e,t,n),this.specularColor=new z.v9(0,0,0),(this._pluginMaterial=new re).ignoreDiffuseWhenToonTextureIsNull=!0,this._initPluginShaderSourceAsync(this._shaderLanguage)}async _initPluginShaderSourceAsync(e){const t=e===c.w.GLSL?(await n.e(71).then(n.bind(n,3313))).MmdPluginMaterial:(await n.e(126).then(n.bind(n,5718))).MmdPluginMaterial;if(this._disposed)return;const r=this._pluginMaterial,i=this._pluginMaterial=new t(this);i.isEnabled=!0,i.sphereTexture=r.sphereTexture,i.sphereTextureBlendMode=r.sphereTextureBlendMode,i.toonTexture=r.toonTexture,i.ignoreDiffuseWhenToonTextureIsNull=r.ignoreDiffuseWhenToonTextureIsNull,i.applyAmbientColorToDiffuse=r.applyAmbientColorToDiffuse,i.clampAlpha=r.clampAlpha,i.textureMultiplicativeColor=r.textureMultiplicativeColor,i.textureAdditiveColor=r.textureAdditiveColor,i.sphereTextureMultiplicativeColor=r.sphereTextureMultiplicativeColor,i.sphereTextureAdditiveColor=r.sphereTextureAdditiveColor,i.toonTextureMultiplicativeColor=r.toonTextureMultiplicativeColor,i.toonTextureAdditiveColor=r.toonTextureAdditiveColor,i.useTextureColor=r.useTextureColor,i.useSphereTextureColor=r.useSphereTextureColor,i.useToonTextureColor=r.useToonTextureColor}dispose(e,t){super.dispose(e,t),this._disposed=!0}isReadyForSubMesh(e,t,n){return!this._pluginMaterial.isMock&&super.isReadyForSubMesh(e,t,n)}get sphereTexture(){return this._pluginMaterial.sphereTexture}set sphereTexture(e){this._pluginMaterial.sphereTexture=e}get sphereTextureBlendMode(){return this._pluginMaterial.sphereTextureBlendMode}set sphereTextureBlendMode(e){this._pluginMaterial.sphereTextureBlendMode=e}get toonTexture(){return this._pluginMaterial.toonTexture}set toonTexture(e){this._pluginMaterial.toonTexture=e}get ignoreDiffuseWhenToonTextureIsNull(){return this._pluginMaterial.ignoreDiffuseWhenToonTextureIsNull}set ignoreDiffuseWhenToonTextureIsNull(e){this._pluginMaterial.ignoreDiffuseWhenToonTextureIsNull=e}get applyAmbientColorToDiffuse(){return this._pluginMaterial.applyAmbientColorToDiffuse}set applyAmbientColorToDiffuse(e){this._pluginMaterial.applyAmbientColorToDiffuse=e}get clampAlpha(){return this._pluginMaterial.clampAlpha}set clampAlpha(e){this._pluginMaterial.clampAlpha=e}get textureMultiplicativeColor(){return this._pluginMaterial.useTextureColor=!0,this._pluginMaterial.textureMultiplicativeColor}set textureMultiplicativeColor(e){this._pluginMaterial.useTextureColor=!0,this._pluginMaterial.textureMultiplicativeColor=e}get textureAdditiveColor(){return this._pluginMaterial.useTextureColor=!0,this._pluginMaterial.textureAdditiveColor}set textureAdditiveColor(e){this._pluginMaterial.useTextureColor=!0,this._pluginMaterial.textureAdditiveColor=e}get sphereTextureMultiplicativeColor(){return this._pluginMaterial.useSphereTextureColor=!0,this._pluginMaterial.sphereTextureMultiplicativeColor}set sphereTextureMultiplicativeColor(e){this._pluginMaterial.useSphereTextureColor=!0,this._pluginMaterial.sphereTextureMultiplicativeColor=e}get sphereTextureAdditiveColor(){return this._pluginMaterial.useSphereTextureColor=!0,this._pluginMaterial.sphereTextureAdditiveColor}set sphereTextureAdditiveColor(e){this._pluginMaterial.useSphereTextureColor=!0,this._pluginMaterial.sphereTextureAdditiveColor=e}get toonTextureMultiplicativeColor(){return this._pluginMaterial.useToonTextureColor=!0,this._pluginMaterial.toonTextureMultiplicativeColor}set toonTextureMultiplicativeColor(e){this._pluginMaterial.useToonTextureColor=!0,this._pluginMaterial.toonTextureMultiplicativeColor=e}get toonTextureAdditiveColor(){return this._pluginMaterial.useToonTextureColor=!0,this._pluginMaterial.toonTextureAdditiveColor}set toonTextureAdditiveColor(e){this._pluginMaterial.useToonTextureColor=!0,this._pluginMaterial.toonTextureAdditiveColor=e}get renderOutline(){return this._renderOutline}set renderOutline(e){e&&this.getScene().getMmdOutlineRenderer?.(),this._renderOutline=e}needAlphaBlending(){return!this._disableAlphaBlending&&(super.needAlphaBlending()||null!==this._pluginMaterial.sphereTexture&&this._pluginMaterial.sphereTextureBlendMode===te.rw.Multiply)}clone(e,t=!0,n=""){const r=Z.p.Clone((()=>new ie(e,this.getScene())),this,{cloneTexturesOnlyOnce:t});return r.name=e,r.id=e,this.stencil.copyTo(r.stencil),this._clonePlugins(r,n),r}static Parse(e,t,n){const r=Z.p.Parse((()=>new ie(e.name,t)),e,t,n);return e.stencil&&r.stencil.parse(e.stencil,t,n),N.i._ParsePlugins(e,r,t,n),r}}ne([(0,J.lK)("renderOutline")],ie.prototype,"_renderOutline",void 0),ne([(0,J.lK)()],ie.prototype,"outlineWidth",void 0),ne([(0,J.jT)()],ie.prototype,"outlineColor",void 0),ne([(0,J.lK)()],ie.prototype,"outlineAlpha",void 0),(0,ee.Y5)("BABYLON.MmdStandardMaterial",ie);class se{files;_fileRootId;_fileMap=new Map;constructor(e,t,n){if(t=G(t),this.files=e,this._fileRootId=n,0!==e.length)if(e[0]instanceof File)for(const r of e){const e=G(r.webkitRelativePath);if(!e.startsWith(t))continue;const i=n+G(e.slice(t.length));this._fileMap.set(G(i).toUpperCase(),r)}else for(const t of e){const e=n+G(t.relativePath);this._fileMap.set(G(e).toUpperCase(),t)}}createFullPath(e){return this._fileRootId+G(e)}resolve(e){const t=G(e);return this._fileMap.get(t.toUpperCase())}}var oe,ae,le=n(917),de=n(6882);!function(e){e[e.Opaque=N.i.MATERIAL_OPAQUE]="Opaque",e[e.AlphaTest=N.i.MATERIAL_ALPHATEST]="AlphaTest",e[e.AlphaBlend=N.i.MATERIAL_ALPHABLEND]="AlphaBlend"}(oe||(oe={}));class he{_scene;_renderTargetTexture;_resultPixelsBuffer;constructor(e,t=512){this._scene=e;const n=e.getEngine(),r=this._renderTargetTexture=new de.$("texture_alpha_checker",t,e,{generateDepthBuffer:!1,generateStencilBuffer:!1,generateMipMaps:!1,type:o.Y.TEXTURETYPE_UNSIGNED_BYTE,format:n.isWebGPU||n.version>1?o.Y.TEXTUREFORMAT_RED:o.Y.TEXTUREFORMAT_RGBA,doNotChangeAspectRatio:!0});r.noPrePassRenderer=!0,r.anisotropicFilteringLevel=1,r.renderParticles=!1,r.optimizeUVAllocation=!0,r.ignoreCameraViewport=!0,r.clearColor=new z.ov(0,0,0,1),this._resultPixelsBuffer=new Uint8Array(t*t*4)}async _renderTexture(e,t,n){const r=he._GetShader(this._scene);r.setTexture("textureSampler",e);let i=null;null!==n&&(i=t.subMeshes,t.subMeshes=[t.subMeshes[n]]);const s=this._renderTargetTexture;for(s.renderList=[t],s.setMaterialForRendering(t,r);!s.isReadyForRendering()||!r.isReady();)if(await new Promise((e=>{setTimeout(e,0)})),null===s._texture)return new Uint8Array(0);const o=t._internalAbstractMeshDataInfo._currentLODIsUpToDate,a=t._internalAbstractMeshDataInfo._currentLOD;t._internalAbstractMeshDataInfo._currentLODIsUpToDate=!0,t._internalAbstractMeshDataInfo._currentLOD=t;const l=t._nodeDataStorage._isEnabled,d=t._nodeDataStorage._isParentEnabled;t._nodeDataStorage._isEnabled=!0,t._nodeDataStorage._isParentEnabled=!0,s.render(!1,!1),t._nodeDataStorage._isParentEnabled=d,t._nodeDataStorage._isEnabled=l,t._internalAbstractMeshDataInfo._currentLOD=a,t._internalAbstractMeshDataInfo._currentLODIsUpToDate=o;const h=r.getEffect();t.geometry._releaseVertexArrayObject(h);const c=t.subMeshes;for(let e=0,t=c.length;e{this._taskQueue.push(e)})),this._blockRendering=!0;const s=await this._renderTexture(e,t,n);let o=0,a=0,l=0;for(let e=0;e{this._taskQueue.push(e)})),this._blockRendering=!0;const r=await this._renderTexture(e,t,n);for(let e=0;e{t===c.w.WGSL?await Promise.all([n.e(126).then(n.bind(n,1306)),n.e(126).then(n.bind(n,6876))]):await Promise.all([n.e(71).then(n.bind(n,9457)),n.e(71).then(n.bind(n,71))])}});r.backFaceCulling=!1,r.alphaMode=o.Y.ALPHA_DISABLE,e.onDisposeObservable.add((()=>{e._textureAlphaCheckerShader?.dispose(),e._textureAlphaCheckerShader=null})),e._textureAlphaCheckerShader=r}return e._textureAlphaCheckerShader}static DisposeShader(e){e._textureAlphaCheckerShader?.dispose(),e._textureAlphaCheckerShader=null}}!function(e){e[e.DepthWriteAlphaBlendingWithEvaluation=0]="DepthWriteAlphaBlendingWithEvaluation",e[e.DepthWriteAlphaBlending=1]="DepthWriteAlphaBlending",e[e.AlphaEvaluation=2]="AlphaEvaluation"}(ae||(ae={}));class ce{renderMethod=ae.DepthWriteAlphaBlendingWithEvaluation;forceDisableAlphaEvaluation=!1;alphaThreshold=195;alphaBlendThreshold=100;alphaEvaluationResolution=512;deleteTextureBufferAfterLoad=!0;_textureLoader=new j;nextStartingAlphaIndex=65536;alphaIndexIncrementsPerModel=1024;_setMeshesAlphaIndex(e){let t=this.nextStartingAlphaIndex;for(let n=0;nnull!==m?m:this.forceDisableAlphaEvaluation?null:m=new he(d,this.alphaEvaluationResolution),y=new se(o,i,s),A=[],T={lengthComputable:!0,loaded:0,total:3*t.length},M=()=>{T.loaded+=1,p?.(T)},_=[];for(let s=0;sthis.setAlphaBlendMode(l,o,a[s],u,x);if(void 0!==p){const e=p.then(g);t.push(e)}else{const e=g();void 0!==e&&t.push(e)}const f=this.loadSphereTexture(e,l,o,r,n[o.sphereTextureIndex]??null,d,h,i,y,u,M);void 0!==f&&t.push(f);const m=this.loadToonTexture(e,l,o,r,n[o.toonTextureIndex]??null,d,h,i,y,u,M);void 0!==m&&t.push(m);const T=this.loadOutlineRenderingProperties(l,o,u);void 0!==T&&t.push(T),A.push(...t),Promise.all(t).then((()=>{this.afterBuildSingleMaterial(l,s,o,r,n,d,i)}))}_.push(l)}this._textureLoader.loadModelTexturesEnd(e);const b=this._textureLoader.onModelTextureLoadedObservable.get(e);return void 0!==b?b.addOnce((()=>{Promise.all(A).then((()=>{m?.dispose(),d._forceBlockMaterialDirtyMechanism(f),null!==c&&this._buildTextureNameMap(t,_,r,n,c),g?.()}))})):Promise.all(A).then((()=>{m?.dispose(),d._forceBlockMaterialDirtyMechanism(f),null!==c&&this._buildTextureNameMap(t,_,r,n,c),g?.()})),_}_buildTextureNameMap(e,t,n,r,i){for(let s=0;s{const r=t.diffuse;e.diffuseColor=new z.v9(r[0],r[1],r[2]);const i=t.specular;e.specularColor=new z.v9(i[0],i[1],i[2]);const s=t.ambient;e.ambientColor=new z.v9(s[0],s[1],s[2]);const o=t.diffuse[3];if(e.alpha=o,0===o)for(let e=0;e{t.backFaceCulling=!(n.flag&b.Material.Flag.IsDoubleSided);const u=r[i?.imagePathIndex??-1];if(void 0!==u){const n=d.createFullPath(u);let r;const p=d.resolve(n);r=void 0!==p?await this._textureLoader.loadTextureFromBufferAsync(e,n,p instanceof File?p:p.data,s,a,{...i,deleteBuffer:this.deleteTextureBufferAfterLoad,format:o.Y.TEXTUREFORMAT_RGBA,mimeType:p instanceof File?p.type:p.mimeType}):await this._textureLoader.loadTextureAsync(e,l,u,s,a,{...i,deleteBuffer:this.deleteTextureBufferAfterLoad,format:o.Y.TEXTUREFORMAT_RGBA});const g=r;null!==g?t.diffuseTexture=g:h.error(`Failed to load diffuse texture: ${n}`),c?.()}else c?.()};async _evaluateDiffuseTextureTransparencyMode(e,t,n,r,i){let s=Number.MIN_SAFE_INTEGER;if(this.renderMethod===ae.DepthWriteAlphaBlendingWithEvaluation){let r=t>>4&3;if(0==(3^r)&&(r=-1),-1===r){s=N.i.MATERIAL_OPAQUE;const t=i();if(null!==t)for(let r=0;r{if(this.renderMethod===ae.DepthWriteAlphaBlending)return e.diffuseTexture&&(e.diffuseTexture.hasAlpha=!0,e.useAlphaFromDiffuseTexture=!0),e.transparencyMode=N.i.MATERIAL_ALPHABLEND,void(e.forceDepthWrite=!0);if(this.renderMethod===ae.DepthWriteAlphaBlendingWithEvaluation&&e.alpha<1)return e.diffuseTexture&&(e.diffuseTexture.hasAlpha=!0,e.useAlphaFromDiffuseTexture=!0),e.transparencyMode=N.i.MATERIAL_ALPHABLEND,void(e.forceDepthWrite=!0);const s=e.diffuseTexture,o=t.evaluatedTransparency??-1;if(null!==s){const t=await this._evaluateDiffuseTextureTransparencyMode(s,o,n,r,i);if(null!==t){const n=t!==N.i.MATERIAL_OPAQUE;n&&(s.hasAlpha=!0),e.useAlphaFromDiffuseTexture=n,e.transparencyMode=t,this.renderMethod===ae.DepthWriteAlphaBlendingWithEvaluation&&(e.forceDepthWrite=n)}}else if(this.renderMethod===ae.DepthWriteAlphaBlendingWithEvaluation){let t=o>>4&3;0==(3^t)&&(t=0),e.transparencyMode=0===t?N.i.MATERIAL_OPAQUE:N.i.MATERIAL_ALPHABLEND}else{let t=15&o;0==(15^t)&&(t=0),e.transparencyMode=N.i.MATERIAL_OPAQUE}};loadSphereTexture=async(e,t,n,r,i,s,a,l,d,h,c)=>{if(n.sphereTextureMode!==b.Material.SphereTextureMode.Off){const u=r[i?.imagePathIndex??-1];if(void 0!==u){const r=s.getEngine().isWebGPU||n.sphereTextureMode===b.Material.SphereTextureMode.Multiply?o.Y.TEXTUREFORMAT_RGBA:o.Y.TEXTUREFORMAT_RGB,p=d.createFullPath(u);let g;const f=d.resolve(p);g=void 0!==f?await this._textureLoader.loadTextureFromBufferAsync(e,p,f instanceof File?f:f.data,s,a,{...i,deleteBuffer:this.deleteTextureBufferAfterLoad,format:r,mimeType:f instanceof File?f.type:f.mimeType}):await this._textureLoader.loadTextureAsync(e,l,u,s,a,{...i,deleteBuffer:this.deleteTextureBufferAfterLoad,format:r}),null!==g?(t.sphereTexture=g,t.sphereTextureBlendMode=n.sphereTextureMode):h.error(`Failed to load sphere texture: ${p}`),c?.()}else c?.()}else c?.()};loadToonTexture=async(e,t,n,r,i,s,a,l,d,h,c)=>{let u;if(u=n.isSharedToonTexture?n.toonTextureIndex:r[i?.imagePathIndex??-1],void 0!==u){const n=d.createFullPath(u.toString());let r;const p="string"==typeof u?d.resolve(n):void 0;r=void 0!==p?await this._textureLoader.loadTextureFromBufferAsync(e,n,p instanceof File?p:p.data,s,a,{...i,deleteBuffer:this.deleteTextureBufferAfterLoad,format:s.getEngine().isWebGPU?o.Y.TEXTUREFORMAT_RGBA:o.Y.TEXTUREFORMAT_RGB,mimeType:p instanceof File?p.type:p.mimeType}):await this._textureLoader.loadTextureAsync(e,l,u,s,a,{...i,deleteBuffer:this.deleteTextureBufferAfterLoad,format:s.getEngine().isWebGPU?o.Y.TEXTUREFORMAT_RGBA:o.Y.TEXTUREFORMAT_RGB}),null!==r?t.toonTexture=r:h.error(`Failed to load toon texture: ${n}`),c?.()}else c?.()};loadOutlineRenderingProperties=(e,t,n)=>{if(t.flag&b.Material.Flag.EnabledToonEdge){void 0===p.Z.prototype.getMmdOutlineRenderer&&n.warn('MMD Outline Renderer is not available. Please import "babylon-mmd/esm/Loader/mmdOutlineRenderer".'),e.renderOutline=!0,e.outlineWidth=t.edgeSize;const r=t.edgeColor;e.outlineColor=new z.v9(r[0],r[1],r[2]),e.outlineAlpha=r[3]}};afterBuildSingleMaterial=()=>{}}class ue{lengthComputable;total;_onProgress;_unprocessedTasks;_processingTasks;_endedTaskNames;_endedTasksTotal;constructor(e,t,n){this.lengthComputable=e;let r=0;for(let e=0;e=n.cost&&(this._processingTasks.delete(e),this._endedTaskNames.add(e),this._endedTasksTotal+=n.cost))}setTaskProgress(e,t){const n=this._getTaskState(e);return null!==n&&(n.progress=t,n.progress>=n.cost&&(this._processingTasks.delete(e),this._endedTaskNames.add(e),this._endedTasksTotal+=n.cost),!0)}setTaskProgressRatio(e,t,n){const r=this._getTaskState(e);return null!==r&&(r.progress=n?Math.floor(r.cost*t):r.cost*t,r.progress>=r.cost&&(this._processingTasks.delete(e),this._endedTaskNames.add(e),this._endedTasksTotal+=r.cost),!0)}endTask(e){const t=this._getTaskState(e);null!==t&&(this._processingTasks.delete(e),this._endedTaskNames.add(e),this._endedTasksTotal+=t.cost)}invokeProgressEvent(){null!==this._onProgress&&this._onProgress({lengthComputable:this.lengthComputable,loaded:this.loaded,total:this.total})}get loaded(){let e=this._endedTasksTotal;for(const[t,n]of this._processingTasks)e+=n.progress;return e}}class pe{name;extensions;materialBuilder;useSdef;buildSkeleton;buildMorph;boundingBoxMargin;preserveSerializationData;_loggingEnabled;log;warn;error;static _SharedStandardMaterialBuilder=new ce;constructor(e,t,n={},r){this.name=e,this.extensions=t,r=r??{materialBuilder:pe._SharedStandardMaterialBuilder,useSdef:!0,buildSkeleton:!0,buildMorph:!0,boundingBoxMargin:10,preserveSerializationData:!1,loggingEnabled:!1},this.materialBuilder=n.materialBuilder??r.materialBuilder,this.useSdef=n.useSdef??r.useSdef,this.buildSkeleton=n.buildSkeleton??r.buildSkeleton,this.buildMorph=n.buildMorph??r.buildMorph,this.boundingBoxMargin=n.boundingBoxMargin??r.boundingBoxMargin,this.preserveSerializationData=n.preserveSerializationData??r.preserveSerializationData,this._loggingEnabled=n.loggingEnabled??r.loggingEnabled,this._loggingEnabled?(this.log=this._logEnabled,this.warn=this._warnEnabled,this.error=this._errorEnabled):(this.log=this._logDisabled,this.warn=this._warnDisabled,this.error=this._errorDisabled)}importMeshAsync(e,t,n,r,i,s){return this._loadAsyncInternal(t,null,n,r,i)}loadAsync(e,t,n,r,i){return this._loadAsyncInternal(e,null,t,n,r).then((()=>{}))}loadAssetContainerAsync(e,t,n,r,i){const s=new P.WZ(e);return this._loadAsyncInternal(e,s,t,n,r).then((()=>s))}async _loadAsyncInternal(e,t,n,r,i){const s=await this._parseFileAsync(n.arrayBuffer),o=new ue(!0,this._getProgressTaskCosts(n,s),i??null);o.endTask("Parse"),o.invokeProgressEvent(),e._blockEntityCollection=!!t;const a=new F.e(s.header.modelName,e);a._parentContainer=t,e._blockEntityCollection=!1,a.setEnabled(!1);const l=await this._buildGeometryAsync(n,s,a,e,t,o),d=n.preserveSerializationData?new Map:null,{materials:h,multiMaterials:c,textureLoadPromise:u}=await this._buildMaterialAsync(n,s,a,l.meshes,d,e,t,r,o),p=[];let g=null;n.buildSkeleton?g=await this._buildSkeletonAsync(n,s,l.meshes,e,t,p,o):o.endTask("Build Skeleton");const f=[];let m=null;if(n.buildMorph&&(m=await this._buildMorphAsync(n,s,l,e,t,f,o)),0!==n.boundingBoxMargin&&this._applyBoundingBoxMargin(l.meshes,n.boundingBoxMargin),a.metadata={isMmdModel:!0,header:{modelName:s.header.modelName,englishModelName:s.header.englishModelName,comment:s.header.comment,englishComment:s.header.englishComment},bones:p,morphs:f,rigidBodies:s.rigidBodies,joints:s.joints,meshes:l.meshes,materials:h,skeleton:g},n.preserveSerializationData){const e=[],t=s.materials;for(let n=0;n4,g=p?this.getVerticesData(s.R.MatricesIndicesExtraKind):null,m=p?this.getVerticesData(s.R.MatricesWeightsExtraKind):null,x=e.getTransformMatrices(this),y=u.Pq.Zero(),A=new u.uq,T=new u.uq,M=new u.uq,_=new u.uq,b=new u.PT,I=new u.PT,v=new u.Pq,w=n._sourcePositions,E=n._sourceNormals;let S,C=0;for(let e=0;e0&&(u.uq.FromFloat32ArrayToRefScaled(x,Math.floor(16*h[C+S]),n,T),A.addToSelf(T));if(p)for(S=0;S<4;S++)n=m[C+S],n>0&&(u.uq.FromFloat32ArrayToRefScaled(x,Math.floor(16*g[C+S]),n,T),A.addToSelf(T));u.Pq.TransformCoordinatesFromFloatsToRef(w[e],w[e+1],w[e+2],A,y),y.toArray(r,e),t&&(u.Pq.TransformNormalFromFloatsToRef(E[e],E[e+1],E[e+2],A,y),y.toArray(i,e)),A.reset()}else{const n=c[C+0],s=c[C+1];u.uq.FromArrayToRef(x,Math.floor(16*h[C+0]),M),u.uq.FromArrayToRef(x,Math.floor(16*h[C+1]),_),u.PT.FromRotationMatrixToRef(M,b),u.PT.FromRotationMatrixToRef(_,I),u.uq.FromQuaternionToRef(u.PT.SlerpToRef(b,I,s,b),T),u.Pq.TransformCoordinatesFromFloatsToRef(w[e]-a[e],w[e+1]-a[e+1],w[e+2]-a[e+2],T,v),u.Pq.TransformCoordinatesFromFloatsToRef(l[e],l[e+1],l[e+2],M,y).scaleAndAddToRef(n,v),u.Pq.TransformCoordinatesFromFloatsToRef(d[e],d[e+1],d[e+2],_,y).scaleAndAddToRef(s,v),v.toArray(r,e),t&&(u.Pq.TransformNormalFromFloatsToRef(E[e],E[e+1],E[e+2],T,v),v.toArray(i,e))}}return this.updateVerticesData(s.R.PositionKind,r),t&&this.updateVerticesData(s.R.NormalKind,i),this}getClassName(){return"SdefMesh"}clone(e="",t=null,n,r=!0){return new fe(e,this.getScene(),t,this,n,r)}}(0,ee.Y5)("BABYLON.SdefMesh",fe);class me extends pe{referenceFiles;constructor(e,t,n={},r){super(e,t,n,r),this.referenceFiles=n.referenceFiles??r?.referenceFiles??[]}loadFile(e,t,n,r,i,s,o){const a=this.materialBuilder,l=this.useSdef,d=this.buildSkeleton,h=this.buildMorph,c=this.boundingBoxMargin,u=this.referenceFiles,p=this.preserveSerializationData;return e._loadFile(t,((e,n)=>{const i={arrayBuffer:e,pmFileId:t instanceof File?ge.GetId(t).toString():t,materialBuilder:a,useSdef:l,buildSkeleton:d,buildMorph:h,boundingBoxMargin:c,referenceFiles:u,preserveSerializationData:p};r(i,n)}),i,!0,s,o)}_getProgressTaskCosts(e,t){const n=super._getProgressTaskCosts(e,t);if(n.push({name:"Build Geometry",cost:t.indices.length}),e.buildMorph){let e=0;const r=t.morphs;for(let t=0;t{d=e.materialBuilder.buildMaterials(n.uniqueId,t.materials,h,t.textures,a,"file:"+e.pmFileId+"_",e.referenceFiles,c,r,s,o,i,this,(e=>{e.lengthComputable&&(l.setTaskProgressRatio("Texture Load",e.loaded/e.total,!0),l.invokeProgressEvent())}),(()=>u()))})),p=Array.isArray(d)?d:await d;for(let e=0;ePromise.reject(e)))}}(0,I.cH)(new xe);class ye{_vertexIndexSize;_textureIndexSize;_materialIndexSize;_boneIndexSize;_morphIndexSize;_rigidBodyIndexSize;constructor(e,t,n,r,i,s){this._vertexIndexSize=e,this._textureIndexSize=t,this._materialIndexSize=n,this._boneIndexSize=r,this._morphIndexSize=i,this._rigidBodyIndexSize=s}getVertexIndex(e){switch(this._vertexIndexSize){case 1:return e.getUint8();case 2:return e.getUint16();case 4:return e.getInt32();default:throw new Error(`Invalid vertexIndexSize: ${this._vertexIndexSize}`)}}_getNonVertexIndex(e,t){switch(t){case 1:return e.getInt8();case 2:return e.getInt16();case 4:return e.getInt32();default:throw new Error(`Invalid indexSize: ${t}`)}}getTextureIndex(e){return this._getNonVertexIndex(e,this._textureIndexSize)}getMaterialIndex(e){return this._getNonVertexIndex(e,this._materialIndexSize)}getBoneIndex(e){return this._getNonVertexIndex(e,this._boneIndexSize)}getMorphIndex(e){return this._getNonVertexIndex(e,this._morphIndexSize)}getRigidBodyIndex(e){return this._getNonVertexIndex(e,this._rigidBodyIndexSize)}}class Ae{constructor(){}static async ParseAsync(e,t=new v){const n=new w(e),r=this._ParseHeader(n,t),i=new ye(r.vertexIndexSize,r.textureIndexSize,r.materialIndexSize,r.boneIndexSize,r.morphIndexSize,r.rigidBodyIndexSize),s=await this._ParseVerticesAsync(n,i,r),o=this._ParseIndices(n,i,r),a=this._ParseTextures(n),l=this._ParseMaterials(n,i),d=this._ParseBones(n,i),h=this._ParseMorphs(n,i),c=this._ParseDisplayFrames(n,i),u=this._ParseRigidBodies(n,i),p=this._ParseJoints(n,i),g=r.version<=2?[]:this._ParseSoftBodies(n,i,r);return n.bytesAvailable>0&&t.warn(`There are ${n.bytesAvailable} bytes left after parsing`),{header:r,vertices:s,indices:o,textures:a,materials:l,bones:d,morphs:h,displayFrames:c,rigidBodies:u,joints:p,softBodies:g}}static _ParseHeader(e,t){if(e.bytesAvailable<17)throw new RangeError("is not pmx file");const n=e.getSignatureString(3);if("PMX"!==n)throw new RangeError("is not pmx file");e.getInt8();const r=e.getFloat32(),i=e.getUint8(),s=e.getUint8();e.initializeTextDecoder(s===b.Header.Encoding.Utf8?"utf-8":"utf-16le");const o=e.getUint8(),a=e.getUint8(),l=e.getUint8(),d=e.getUint8(),h=e.getUint8(),c=e.getUint8(),u=e.getUint8();if(i<8)throw new Error(`Invalid globalsCount: ${i}`);if(8setTimeout(e,0))),s=performance.now())}return i}static _ParseIndices(e,t,n){const r=e.getInt32(),i=new ArrayBuffer(r*n.vertexIndexSize);let s;switch(n.vertexIndexSize){case 1:s=new Uint8Array(i);break;case 2:s=new Uint16Array(i);break;case 4:s=new Int32Array(i);break;default:throw new Error(`Invalid vertexIndexSize: ${n.vertexIndexSize}`)}for(let n=0;nPromise.reject(e)))}}(0,I.cH)(new Me);var _e,be,Ie,ve=n(9057),we=n(5581),Ee=n(1513),Se=n(8595),Ce=n(8529),Fe=n(3770);!function(e){e.isMmdMesh=function(e){return!(null===e.metadata||!e.metadata.isMmdModel)},e.isMmdSkinnedMesh=function(e){return!(null===e.metadata||!e.metadata.isMmdModel)&&null!==e.metadata.skeleton}}(_e||(_e={})),function(e){e.isSerializationMetadata=function(e){return!0===e.containsSerializationData}}(be||(be={}));class Be{_dataView;_encoder;_offset;constructor(e){this._dataView=new DataView(e),this._encoder=new TextEncoder,this._offset=0}get offset(){return this._offset}set offset(e){this._offset=e}setUint8(e){this._dataView.setUint8(this._offset,e),this._offset+=1}setUint8Array(e){const t=this._dataView;for(let n=0;n0;){const e=t.pop(),n=i.get(e),r=e.children;for(let e=0;e{const t=e.children;for(let r=0;r{const n=r.get(e);if(void 0!==n)for(let e=0;ee.texture===M)):-1,I=d.sphereTexture,v=I?y.findIndex((e=>e.texture===I)):-1,w=d.sphereTextureBlendMode??b.Material.SphereTextureMode.Off,E=d.toonTexture,S=!!E&&E.name.startsWith("file:shared_toon_texture_")&&E.name.length<=27&&!isNaN(Number(E.name.substring(25)));let C;C=S?Number(E.name.substring(25))-1:E?y.findIndex((e=>e.texture===E)):-1;const F={name:n,englishName:s,diffuse:l,specular:h,shininess:u,ambient:p,evaluatedTransparency:g,flag:f,edgeColor:m,edgeSize:x,textureIndex:_,sphereTextureIndex:v,sphereTextureMode:w,isSharedToonTexture:S,toonTextureIndex:C,comment:e?.comment??"",linkedMaterial:d};A.push(F)}}}}const M=new Array(a.morphs.length).fill(null);for(let e=0;ee.linkedMaterial===i));w.setInt32(s),w.setUint32(r.verticesStart),w.setUint32(r.verticesCount),w.setUint32(r.indexStart),w.setUint32(r.indexCount)}}else{const e=t.material,n=A.findIndex((t=>t.linkedMaterial===e));w.setInt32(n)}const i=n.getVerticesData(s.R.PositionKind),o=i.length/3;w.setUint32(o),w.setFloat32Array(i);let a=n.getVerticesData(s.R.NormalKind);if(a.length!==3*o){this.warn(`mesh ${t.name} normals vertex count is different from positions vertex count`);const e=new Float32Array(3*o);e.set(a),a=e}w.setFloat32Array(a);let l=n.getVerticesData(s.R.UVKind);if(l.length!==2*o){this.warn(`mesh ${t.name} uv vertex count is different from positions vertex count`);const e=new Float32Array(2*o);e.set(l),l=e}w.setFloat32Array(l);const h=[];{const e=n.getVerticesData(f.V.AdditionalUV1Kind);null!==e&&h.push(e);const t=n.getVerticesData(f.V.AdditionalUV2Kind);null!==t&&h.push(t);const r=n.getVerticesData(f.V.AdditionalUV3Kind);null!==r&&h.push(r);const i=n.getVerticesData(f.V.AdditionalUV4Kind);null!==i&&h.push(i)}w.setUint8(h.length);for(let e=0;e0;){const r=i.pop(),s=r.getParent();if(s?r.getLocalMatrix().multiplyToRef(s.getFinalMatrix(),r.getFinalMatrix()):t?r.getLocalMatrix().multiplyToRef(t,r.getFinalMatrix()):r.getFinalMatrix().copyFrom(r.getLocalMatrix()),-1!==r._index){const t=null===r._index?n:r._index;r.getAbsoluteInverseBindMatrix().multiplyToArray(r.getFinalMatrix(),e,16*t)}const o=r.getChildren();for(const e of o)i.push(e)}}}this._identity.copyToArray(e,16*this.bones.length)}}}async function De(e,t=""){const n=[];for(let r=0;r{e.readEntries(t,n)}));n.push(...await De(r,t+i.name+"/"))}else n.push(i)}return n}const Pe=document.createElement("canvas");Pe.style.width="100%",Pe.style.height="100%",Pe.style.display="block",document.body.appendChild(Pe);const ke=new r.N(Pe,!1,{preserveDrawingBuffer:!1,stencil:!1,antialias:!0,alpha:!0,premultipliedAlpha:!1,powerPreference:"high-performance",doNotHandleTouchAction:!0,doNotHandleContextLost:!0,audioEngine:!1,disableWebGL2Support:!1},!0);i.Create({canvas:Pe,engine:ke,sceneBuilder:new class{async build(e,t){T.OverrideEngineCreateEffect(t);const n=new ce;n.deleteTextureBufferAfterLoad=!1,n.renderMethod=ae.AlphaEvaluation;const r=new p.Z(t);r.ambientColor=new z.v9(.5,.5,.5);const i=new ve.L("camera",0,0,45,new u.Pq(0,10,0),r);i.maxZ=5e3,i.fov=Math.PI/180*30,i.speed=.5,i.setPosition(new u.Pq(0,10,-45)),i.attachControl(e,!0);const s=new Ee.g("hemisphericLight",new u.Pq(0,1,0),r);s.intensity=.5,s.specular=new z.v9(0,0,0),s.groundColor=new z.v9(1,1,1);const o=new we.Z("directionalLight",new u.Pq(.5,-1,1),r);o.intensity=.5,o.autoCalcShadowZBounds=!1,o.autoUpdateExtends=!1,o.shadowMaxZ=60,o.shadowMinZ=-30,o.orthoTop=54,o.orthoBottom=-3,o.orthoLeft=-30,o.orthoRight=30,o.shadowOrthoScale=0;const a=new Se.o(1024,o,!0,i);a.transparencyShadow=!0,a.usePercentageCloserFiltering=!0,a.forceBackFacesOnly=!1,a.bias=.01,a.filteringQuality=Se.o.QUALITY_MEDIUM,a.frustumEdgeFalloff=.1,(0,Ce.km)("ground1",{width:100,height:100,subdivisions:2,updatable:!1},r).receiveShadows=!0;const l=new Fe.e("default",!0,r);l.samples=4,l.fxaaEnabled=!0,l.imageProcessingEnabled=!1;const d=new he(r),h=async e=>{if(y)return;if(null!==g){for(const e of g.metadata.meshes)a.removeShadowCaster(e);g.dispose(!1,!0),g=null}y=!0,t.displayLoadingUI();const i=e.webkitRelativePath;R.textContent=e.name,g=await(0,I.kS)(e,r,{onProgress:n=>t.loadingUIText=`


Loading (${e.name})... ${n.loaded}/${n.total} (${Math.floor(100*n.loaded/n.total)}%)`,rootUrl:i.substring(0,i.lastIndexOf("/")+1),pluginOptions:{mmdmodel:{materialBuilder:n,buildSkeleton:!0,buildMorph:!0,boundingBoxMargin:0,preserveSerializationData:$.checked,loggingEnabled:!0,referenceFiles:E}}}).then((e=>{e.addAllToScene();const t=e.meshes[0];return Ue.OverrideComputeTransformMatrices(t.metadata.skeleton),t.metadata.skeleton?._markAsDirty(),t}));{const e=g.metadata.meshes;for(let t=0;te.material===r));for(const e of t)if(await d.hasFragmentsOnlyOpaqueOnGeometry(i,e,null)){f[n]=!1;break}}else f[n]=!1;m[n]=r.transparencyMode??-1}}G(),t.hideLoadingUI(),setTimeout((()=>y=!1),1500)};let c=null,g=null;const f=[],m=[];let x="Alpha Mode",y=!1;const A=e=>{if(null===g)return;const t=g.metadata.materials;if("Alpha Mode"===e)for(let e=0;e{F.style.backgroundColor="#444444",B.style.backgroundColor="#111111",V.style.display="block",U.style.display="block",D.style.display="block",L.style.display="none",q.style.display="none",K.style.display="none"},C.appendChild(F);const B=document.createElement("div");B.textContent="Fix Material",B.style.width="100%",B.style.height="auto",B.style.border="none",B.style.backgroundColor="#111111",B.style.fontSize="20px",B.style.textAlign="center",B.style.color="white",B.style.cursor="pointer",B.onclick=()=>{F.style.backgroundColor="#111111",B.style.backgroundColor="#444444",V.style.display="none",U.style.display="none",D.style.display="none",L.style.display="flex",q.style.display="block",K.style.display="block"},C.appendChild(B);const R=document.createElement("div");R.textContent="No PMX file selected",R.style.width="350px",R.style.height="auto",R.style.fontSize="18px",R.style.marginBottom="10px",R.style.border="1px solid black",R.style.boxSizing="border-box",R.style.padding="10px",R.style.overflow="scroll",v.appendChild(R);const U=document.createElement("div");U.textContent="Files",U.style.width="100%",U.style.height="auto",U.style.fontSize="18px",U.style.backgroundColor="#444444",U.style.color="white",U.style.padding="2px 5px",U.style.boxSizing="border-box",v.appendChild(U);const D=document.createElement("div");D.style.width="350px",D.style.flexGrow="1",D.style.overflow="auto",D.style.marginBottom="10px",D.style.border="1px solid black",D.style.boxSizing="border-box",v.appendChild(D);const P=document.createElement("ul");P.style.height="auto",P.style.fontSize="16px",D.appendChild(P);const k=()=>{P.innerHTML="";for(const e of E){const t=document.createElement("li");t.style.whiteSpace="nowrap";const n=e.webkitRelativePath;t.textContent=n.substring(n.indexOf("/")+1),(e.name.endsWith(".pmx")||e.name.endsWith(".pmd"))&&(t.style.color="blue",t.style.cursor="pointer",t.style.textDecoration="underline",t.onclick=()=>{c=e,h(e)}),P.appendChild(t)}},V=document.createElement("input");V.style.width="100%",V.style.minHeight="80px",V.style.display="block",V.style.backgroundColor="black",V.style.color="white",V.style.marginBottom="10px",V.style.fontSize="20px",V.type="file",V.setAttribute("directory",""),V.setAttribute("webkitdirectory",""),V.setAttribute("allowdirs",""),V.ondragover=e=>{e.preventDefault()},V.ondrop=async e=>{e.preventDefault();const t=e.dataTransfer.items;if(!t)return;const n=[];for(let e=0;e{r.file(e,t)}));""===i.webkitRelativePath&&(Object.defineProperty(i,"webkitRelativePath",{writable:!0}),i.webkitRelativePath=r.fullPath),t.push(i)}return t}(r),k()},V.onchange=()=>{null!==V.files&&(E=Array.from(V.files),k())},v.appendChild(V);const L=document.createElement("div");L.style.width="100%",L.style.height="auto",L.style.display="flex",L.style.flexDirection="row",L.style.justifyContent="space-between",v.appendChild(L);const O=document.createElement("button");O.textContent="Alpha Mode",O.style.flexGrow="1",O.style.height="auto",O.style.border="none",O.style.fontSize="16px",O.style.backgroundColor="#444444",O.style.color="white",O.style.cursor="pointer",O.onclick=()=>{"Alpha Mode"!==x&&(O.style.backgroundColor="#444444",W.style.backgroundColor="#111111",x="Alpha Mode",A(x),G())},L.appendChild(O);const W=document.createElement("button");W.textContent="Force Depth Write Mode",W.style.flexGrow="1",W.style.height="auto",W.style.border="none",W.style.fontSize="16px",W.style.backgroundColor="#111111",W.style.color="white",W.style.cursor="pointer",W.onclick=()=>{"Force Depth Write Mode"!==x&&(O.style.backgroundColor="#111111",W.style.backgroundColor="#444444",x="Force Depth Write Mode",A(x),G())},L.appendChild(W);const q=document.createElement("div");q.textContent="Materials",q.style.width="100%",q.style.height="auto",q.style.fontSize="18px",q.style.backgroundColor="#444444",q.style.color="white",q.style.padding="2px 5px",q.style.boxSizing="border-box",v.appendChild(q);const K=document.createElement("div");K.style.width="350px",K.style.flexGrow="1",K.style.overflow="auto",K.style.marginBottom="10px",K.style.border="1px solid black",K.style.boxSizing="border-box",v.appendChild(K);const H=document.createElement("ol");H.start=0,H.style.height="auto",H.style.fontSize="16px",K.appendChild(H);const G=()=>{if(H.innerHTML="",null===g)return;const e=g.metadata.meshes;for(let n=0;n{null===r.transparencyMode&&(r.transparencyMode=0),r.transparencyMode=(r.transparencyMode+1)%3,m[s]=r.transparencyMode,e.textContent=t(r.transparencyMode??0)},i.appendChild(e)}else{const e=document.createElement("button");e.style.float="right",e.style.width="100px",e.style.height="auto",e.style.fontSize="14px",e.style.marginRight="10px",e.style.border="none",e.textContent=r.transparencyMode===N.i.MATERIAL_OPAQUE?"Opaque":"Alpha Blend";const t=n;e.onclick=()=>{r.transparencyMode=r.transparencyMode===N.i.MATERIAL_OPAQUE?N.i.MATERIAL_ALPHABLEND:N.i.MATERIAL_OPAQUE,f[t]=r.transparencyMode===N.i.MATERIAL_ALPHABLEND,e.textContent=r.transparencyMode===N.i.MATERIAL_OPAQUE?"Opaque":"Alpha Blend"},i.appendChild(e)}H.appendChild(i)}function t(e){switch(e){case N.i.MATERIAL_OPAQUE:return"Opaque";case N.i.MATERIAL_ALPHATEST:return"Alpha Test";case N.i.MATERIAL_ALPHABLEND:return"Alpha Blend";default:return"Unknown"}}},Q=document.createElement("div");Q.style.width="100%",Q.style.height="auto",Q.style.display="flex",Q.style.flexDirection="column",Q.style.justifyContent="center",Q.style.alignItems="center",Q.style.marginBottom="10px",Q.style.border="1px solid black",Q.style.padding="20px",Q.style.boxSizing="border-box",v.appendChild(Q);const X=document.createElement("div");X.style.width="100%",X.style.height="30px",X.style.display="flex",X.style.flexDirection="row",X.style.justifyContent="space-between",X.style.alignItems="center",X.style.marginBottom="10px",Q.appendChild(X);const Y=document.createElement("label");Y.textContent="Preserve Serialization Data",Y.title="If enabled, the converted file will be larger, but the converted file will be able to be converted back to PMX without any loss of data in technically(currently BPMX to PMX conversion is not supported).",Y.style.textAlign="left",Y.style.marginRight="10px",Y.style.fontSize="16px",X.appendChild(Y);const j=document.createElement("label");j.textContent="(reload required)",j.style.fontSize="11px",j.style.color="gray",j.style.flexGrow="1",X.appendChild(j);const $=document.createElement("input");$.style.width="16px",$.style.height="16px",$.type="checkbox",$.checked=!0,X.appendChild($),$.onclick=e=>{y?e.preventDefault():null!==c&&h(c)};const J=document.createElement("div");J.style.width="100%",J.style.height="30px",J.style.display="flex",J.style.flexDirection="row",J.style.justifyContent="space-between",J.style.alignItems="center",J.style.marginBottom="10px",Q.appendChild(J);const Z=document.createElement("label");Z.textContent="Build Skeleton",Z.title="If your model don't need to be animated by skeleton(e.g. stage model), you can disable this option to reduce the size of the converted file. also, it can improve the performance of the converted model.",Z.style.textAlign="left",Z.style.marginRight="10px",Z.style.fontSize="16px",Z.style.flexGrow="1",J.appendChild(Z);const ee=document.createElement("input");ee.style.width="16px",ee.style.height="16px",ee.type="checkbox",ee.checked=!0,J.appendChild(ee);const te=document.createElement("div");te.style.width="100%",te.style.height="30px",te.style.display="flex",te.style.flexDirection="row",te.style.justifyContent="space-between",te.style.alignItems="center",te.style.marginBottom="10px",Q.appendChild(te);const ne=document.createElement("label");ne.textContent="Build Morph",ne.title="If your model don't need to be animated by morph targets(e.g. stage model), you can disable this option to reduce the size of the converted file. also, it can improve the performance of the converted model.",ne.style.textAlign="left",ne.style.marginRight="10px",ne.style.fontSize="16px",ne.style.flexGrow="1",te.appendChild(ne);const re=document.createElement("input");re.style.width="16px",re.style.height="16px",re.type="checkbox",re.checked=!0,te.appendChild(re);const ie=document.createElement("div");ie.style.width="100%",ie.style.height="auto",ie.style.display="flex",ie.style.flexDirection="row",ie.style.justifyContent="space-between",ie.style.alignItems="center",v.appendChild(ie);const se=document.createElement("button");return se.textContent="Convert",se.style.width="100%",se.style.height="60px",se.style.border="none",se.style.fontSize="20px",ie.appendChild(se),se.onclick=async()=>{if(y)return;if(null===c)return;if(null===g)return;y=!0,t.displayLoadingUI(),t.loadingUIText=`


Converting (${c.name})...`;const e=w.convert(g,{includeSkinningData:ee.checked,includeMorphData:re.checked,translucentMaterials:f,alphaEvaluateResults:m}),n=new Blob([e],{type:"application/octet-stream"}),r=URL.createObjectURL(n),i=document.createElement("a");i.href=r,i.download=`${c.name.substring(0,c.name.lastIndexOf("."))}.bpmx`,i.click(),URL.revokeObjectURL(r),i.remove(),await new Promise((e=>{setTimeout((()=>{t.hideLoadingUI(),e()}),1500)})),y=!1},F.click(),t.resize(!0),r}}}).then((e=>e.run()))}},i={};function s(e){var t=i[e];if(void 0!==t)return t.exports;var n=i[e]={exports:{}};return r[e](n,n.exports,s),n.exports}s.m=r,e=[],s.O=(t,n,r,i)=>{if(!n){var o=1/0;for(h=0;h=i)&&Object.keys(s.O).every((e=>s.O[e](n[l])))?n.splice(l--,1):(a=!1,i0&&e[h-1][2]>i;h--)e[h]=e[h-1];e[h]=[n,r,i]},s.d=(e,t)=>{for(var n in t)s.o(t,n)&&!s.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},s.f={},s.e=e=>Promise.all(Object.keys(s.f).reduce(((t,n)=>(s.f[n](e,t),t)),[])),s.u=e=>(({71:"glslShaders",126:"wgslShaders"}[e]||e)+".bundle.js"),s.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),t={},n="babylon-mmd:",s.l=(e,r,i,o)=>{if(t[e])t[e].push(r);else{var a,l;if(void 0!==i)for(var d=document.getElementsByTagName("script"),h=0;h{a.onerror=a.onload=null,clearTimeout(p);var i=t[e];if(delete t[e],a.parentNode&&a.parentNode.removeChild(a),i&&i.forEach((e=>e(r))),n)return n(r)},p=setTimeout(u.bind(null,void 0,{type:"timeout",target:a}),12e4);a.onerror=u.bind(null,a.onerror),a.onload=u.bind(null,a.onload),l&&document.head.appendChild(a)}},s.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e;s.g.importScripts&&(e=s.g.location+"");var t=s.g.document;if(!e&&t&&(t.currentScript&&"SCRIPT"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var n=t.getElementsByTagName("script");if(n.length)for(var r=n.length-1;r>-1&&(!e||!/^http(s?):/.test(e));)e=n[r--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),s.p=e})(),(()=>{var e={792:0};s.f.j=(t,n)=>{var r=s.o(e,t)?e[t]:void 0;if(0!==r)if(r)n.push(r[2]);else{var i=new Promise(((n,i)=>r=e[t]=[n,i]));n.push(r[2]=i);var o=s.p+s.u(t),a=new Error;s.l(o,(n=>{if(s.o(e,t)&&(0!==(r=e[t])&&(e[t]=void 0),r)){var i=n&&("load"===n.type?"missing":n.type),o=n&&n.target&&n.target.src;a.message="Loading chunk "+t+" failed.\n("+i+": "+o+")",a.name="ChunkLoadError",a.type=i,a.request=o,r[1](a)}}),"chunk-"+t,t)}},s.O.j=t=>0===e[t];var t=(t,n)=>{var r,i,[o,a,l]=n,d=0;if(o.some((t=>0!==e[t]))){for(r in a)s.o(a,r)&&(s.m[r]=a[r]);if(l)var h=l(s)}for(t&&t(n);ds(8822)));o=s.O(o)})(); \ No newline at end of file